Skip to content

Commit

Permalink
Move entity types to @/core (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcginnes authored Jan 24, 2025
1 parent 38700d3 commit b676ac1
Show file tree
Hide file tree
Showing 55 changed files with 54 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef } from "react";
import { Vertex } from "@/@types/entities";
import { Vertex } from "@/core";
import { DrawBoxWithAdornmentOptions } from "@/components/utils";
import drawBoxWithAdornment from "@/components/utils/canvas/drawBoxWithAdornment";
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import globalMockFetch from "@/connector/testUtils/globalMockFetch";
import mockGremlinFetch from "@/connector/testUtils/mockGremlinFetch";
import fetchNeighbors from ".";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

describe("Gremlin > fetchNeighbors", () => {
beforeEach(globalMockFetch);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { normalizeWithNoSpace as normalize } from "@/utils/testing";
import oneHopTemplate from "./oneHopTemplate";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

describe("Gremlin > oneHopTemplate", () => {
it("Should return a template for a simple vertex id", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import globalMockFetch from "@/connector/testUtils/globalMockFetch";
import mockGremlinFetch from "@/connector/testUtils/mockGremlinFetch";
import fetchNeighborsCount from ".";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

describe("Gremlin > fetchNeighborsCount", () => {
beforeEach(globalMockFetch);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";
import neighborsCountTemplate from "./neighborsCountTemplate";
import { normalizeWithNoSpace as normalize } from "@/utils/testing";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntityIdType } from "@/@types/entities";
import { EntityIdType } from "@/core";
import { GInt64, JanusID } from "../types";
import { isJanusID } from "./toStringId";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Edge, EdgeId, VertexId } from "@/@types/entities";
import type { Edge, EdgeId, VertexId } from "@/core";
import type { GEdge } from "../types";
import parseEdgePropertiesValues from "./parseEdgePropertiesValues";
import toStringId from "./toStringId";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Vertex, VertexId } from "@/@types/entities";
import type { Vertex, VertexId } from "@/core";
import type { GVertex } from "../types";
import { detectIdType } from "./detectIdType";
import parsePropertiesValues from "./parsePropertiesValues";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex, Edge } from "@/@types/entities";
import { Vertex, Edge } from "@/core";
import { GAnyValue } from "../types";
import mapApiEdge from "./mapApiEdge";
import mapApiVertex from "./mapApiVertex";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { normalize } from "@/utils/testing";
import oneHopTemplate from "./oneHopTemplate";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

describe("OpenCypher > oneHopTemplate", () => {
it("Should return a template for a simple vertex id", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { normalize } from "@/utils/testing";
import neighborsCountTemplate from "./neighborsCountTemplate";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

describe("OpenCypher > neighborsCountTemplate", () => {
it("Should return a template for the given vertex id", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex } from "@/@types/entities";
import { Vertex } from "@/core";
import type {
ErrorResponse,
KeywordSearchRequest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Edge, EdgeId, VertexId } from "@/@types/entities";
import type { Edge, EdgeId, VertexId } from "@/core";
import type { OCEdge } from "../types";

const mapApiEdge = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mapApiVertex from "./mapApiVertex";
import { Vertex, VertexId } from "@/@types/entities";
import { Vertex, VertexId } from "@/core";

test("maps empty vertex", () => {
const input = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Vertex, VertexId } from "@/@types/entities";
import type { Vertex, VertexId } from "@/core";
import type { OCVertex } from "../types";

export default function mapApiVertex(apiVertex: OCVertex): Vertex {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/connector/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
VertexDetailsResponse,
VertexRef,
} from "./useGEFetchTypes";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";

/**
* Performs a search with the provided parameters.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge } from "@/@types/entities";
import { Edge } from "@/core";
import { EdgeDetailsRequest, EdgeDetailsResponse } from "../useGEFetchTypes";
import {
parseEdgeId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import groupBy from "lodash/groupBy";
import { Edge } from "@/@types/entities";
import { Edge } from "@/core";
import type { NeighborsResponse } from "@/connector/useGEFetchTypes";
import mapIncomingToEdge, {
IncomingPredicate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, EdgeId, VertexId } from "@/@types/entities";
import { Edge, EdgeId, VertexId } from "@/core";
import { RawValue } from "../types";

export type IncomingPredicate = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, EdgeId, VertexId } from "@/@types/entities";
import { Edge, EdgeId, VertexId } from "@/core";
import { RawValue } from "../types";

export type OutgoingPredicate = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex, VertexId } from "@/@types/entities";
import { Vertex, VertexId } from "@/core";
import { RawResult } from "../types";

const mapRawResultToVertex = (rawResult: RawResult): Vertex => {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/connector/sparql/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EdgeId } from "@/@types/entities";
import { EdgeId } from "@/core";
import { parseEdgeId } from "./types";

test("parseEdgeId", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/connector/sparql/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, EdgeId, Vertex, VertexId } from "@/types/entities";
import { Edge, EdgeId, Vertex, VertexId } from "@/core";
import type { NeighborsCountResponse } from "../useGEFetchTypes";
import { z } from "zod";
import { logger } from "@/utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SparqlValue,
} from "./types";
import { z } from "zod";
import { Vertex, VertexId } from "@/@types/entities";
import { Vertex, VertexId } from "@/core";
import isErrorResponse from "../utils/isErrorResponse";

const bindingSchema = z.object({
Expand Down
8 changes: 1 addition & 7 deletions packages/graph-explorer/src/connector/useGEFetchTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import {
} from "@/core";
import { ConnectionConfig } from "@shared/types";
import { MappedQueryResults } from "./gremlin/mappers/mapResults";
import {
Edge,
EdgeId,
Vertex,
VertexId,
EntityIdType,
} from "@/@types/entities";
import { Edge, EdgeId, Vertex, VertexId, EntityIdType } from "@/core";

export type QueryOptions = RequestInit & {
queryId?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex, Edge } from "@/@types/entities";
import { Vertex, Edge } from "@/core";
import { MISSING_DISPLAY_VALUE, formatDate } from "@/utils";
import { TextTransformer } from "@/hooks";
import { AttributeConfig } from "@/core";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge } from "@/@types/entities";
import { Edge } from "@/core";
import {
createRandomEdge,
createRandomEdgeTypeConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, EdgeId, EntityIdType, VertexId } from "@/@types/entities";
import { Edge, EdgeId, EntityIdType, VertexId } from "@/core";
import { selector, selectorFamily, useRecoilValue } from "recoil";
import { textTransformSelector } from "@/hooks";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
renderHookWithRecoilRoot,
} from "@/utils/testing";
import { useDisplayVertexFromVertex } from "./displayVertex";
import { Vertex, VertexId } from "@/@types/entities";
import { Vertex, VertexId } from "@/core";
import { formatDate, sanitizeText } from "@/utils";
import { Schema } from "../ConfigurationProvider";
import { MutableSnapshot } from "recoil";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { selector, selectorFamily, useRecoilValue } from "recoil";
import { Vertex, VertexId, EntityIdType } from "@/@types/entities";
import { Vertex, VertexId, EntityIdType } from "@/core";
import {
DisplayAttribute,
getSortedDisplayAttributes,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/core/StateProvider/edges.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { atom, selector, selectorFamily } from "recoil";
import type { Edge, EdgeId } from "@/types/entities";
import type { Edge, EdgeId } from "@/core";
import isDefaultValue from "./isDefaultValue";
import { nodesFilteredIdsAtom, nodesTypesFilteredAtom } from "./nodes";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import isEqual from "lodash/isEqual";
import isEqualWith from "lodash/isEqualWith";
import type { GetRecoilValue, RecoilState, SetRecoilState } from "recoil";
import { selector } from "recoil";
import type { Edge, EdgeId, Vertex, VertexId } from "@/types/entities";
import type { Edge, EdgeId, Vertex, VertexId } from "@/core";
import {
edgesAtom,
edgesSelectedIdsAtom,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";
import { calculateNeighbors, useNeighbors } from "./neighbors";
import {
createRandomVertex,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";
import { selectorFamily, useRecoilCallback, useRecoilValue } from "recoil";
import { edgesAtom } from "./edges";
import { nodesAtom } from "./nodes";
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/core/StateProvider/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { atom, selector, selectorFamily, useRecoilValue } from "recoil";
import type { Vertex, VertexId } from "@/types/entities";
import type { Vertex, VertexId } from "@/core";
import isDefaultValue from "./isDefaultValue";

export function toNodeMap(nodes: Vertex[]): Map<VertexId, Vertex> {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/core/StateProvider/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import localForageEffect from "./localForageEffect";
import { activeConfigurationAtom } from "./configuration";
import isDefaultValue from "./isDefaultValue";
import { Edge, Vertex } from "@/@types/entities";
import { Edge, Vertex } from "@/core";
import { sanitizeText } from "@/utils";
import { Entities } from "./entitiesSelector";

Expand Down
1 change: 1 addition & 0 deletions packages/graph-explorer/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./ThemeProvider";
export * from "./featureFlags";
export * from "./StateProvider";
export * from "./connector";
export * from "./entities";
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useAddToGraph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Edge, Vertex } from "@/types/entities";
import { Edge, Vertex } from "@/core";
import { toNodeMap } from "@/core/StateProvider/nodes";
import { toEdgeMap } from "@/core/StateProvider/edges";
import entitiesSelector from "@/core/StateProvider/entitiesSelector";
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useEntities.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRecoilValue } from "recoil";
import useEntities from "./useEntities";
import { Edge, Vertex, VertexId } from "@/types/entities";
import { Edge, Vertex, VertexId } from "@/core";
import {
createRandomEdge,
createRandomEntities,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useExpandNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import useEntities from "./useEntities";
import { useRecoilValue } from "recoil";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { Vertex } from "@/types/entities";
import { Vertex } from "@/core";
import { createDisplayError } from "@/utils/createDisplayError";
import { toNodeMap } from "@/core/StateProvider/nodes";
import { toEdgeMap } from "@/core/StateProvider/edges";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";
import { nodesAtom } from "@/core";
import { useRecoilValue } from "recoil";

Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useNeighborsOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from "react";
import { Vertex } from "@/types/entities";
import { Vertex } from "@/core";
import { SelectOption } from "@/components";
import {
DisplayVertexTypeConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/hooks/useRemoveFromGraph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EdgeId, VertexId } from "@/types/entities";
import { EdgeId, VertexId } from "@/core";
import useEntities from "./useEntities";

export function useRemoveNodeFromGraph(nodeId: VertexId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MouseEvent, useCallback, useMemo, useRef, useState } from "react";
import { useRecoilState, useRecoilValue } from "recoil";
import { EdgeId, Vertex, VertexId } from "@/types/entities";
import { EdgeId, Vertex, VertexId } from "@/core";
import {
Panel,
PanelContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from "@/core/StateProvider/userPreferences";
import { useEntities, useTranslations } from "@/hooks";
import useGraphGlobalActions from "../useGraphGlobalActions";
import { EdgeId, VertexId } from "@/@types/entities";
import { EdgeId, VertexId } from "@/core";
import { MinusCircleIcon } from "lucide-react";

export type ContextMenuProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useRef, useState } from "react";
import { useLayer, useMousePositionAsTrigger } from "react-laag";
import type { Edge, EdgeId, Vertex, VertexId } from "@/types/entities";
import type { Edge, EdgeId, Vertex, VertexId } from "@/core";
import type {
ElementEventCallback,
GraphEventCallback,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Color from "color";
import { useEffect, useState } from "react";
import { EdgeId } from "@/types/entities";
import { EdgeId } from "@/core";
import type { GraphProps } from "@/components";
import useTextTransform from "@/hooks/useTextTransform";
import { renderNode } from "./renderNode";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from "react";
import { BadgeRenderer } from "@/components/Graph/hooks/useRenderBadges";
import { VertexId } from "@/@types/entities";
import { VertexId } from "@/core";
import { useDisplayVerticesInCanvas } from "@/core";
import { useAllNeighbors } from "@/core";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import type { Vertex, VertexId } from "@/types/entities";
import type { Vertex, VertexId } from "@/core";
import { PanelError, PanelFooter, VertexRow } from "@/components";
import Button from "@/components/Button";
import ExpandGraphIcon from "@/components/icons/ExpandGraphIcon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex } from "@/@types/entities";
import { Vertex } from "@/core";
import {
Button,
Tooltip,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cn } from "@/utils";
import { Vertex, VertexId } from "@/@types/entities";
import { Vertex, VertexId } from "@/core";
import {
Button,
Chip,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/utils/testing/DbState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vertex } from "@/@types/entities";
import { Vertex } from "@/core";
import {
activeConfigurationAtom,
configurationAtom,
Expand Down
2 changes: 1 addition & 1 deletion packages/graph-explorer/src/utils/testing/randomData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Schema,
VertexTypeConfig,
} from "@/core";
import { Edge, EdgeId, Vertex, VertexId } from "@/types/entities";
import { Edge, EdgeId, Vertex, VertexId } from "@/core";
import { Entities } from "@/core/StateProvider/entitiesSelector";
import {
createArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@tanstack/react-query";
import { Link, useNavigate, useParams, useSearchParams } from "react-router";
import { useRecoilValue, useSetRecoilState } from "recoil";
import { Vertex } from "@/types/entities";
import { Vertex } from "@/core";
import {
CheckIcon,
ChevronLeftIcon,
Expand Down

0 comments on commit b676ac1

Please sign in to comment.