Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib/__tests__/schema-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@ describe("schema-store – addSchema", () => {
})
})

describe("schema-store – v2 endpoints", () => {
describe("schema-store – endpoints", () => {
beforeEach(() => {
vi.clearAllMocks()
useSchemaStore.setState({ schemas: [makeSchema()], edges: [], loading: false })
})

it("fetches the ontology from /v2/schema", async () => {
it("fetches the ontology from /schema/all", async () => {
mockGet.mockResolvedValueOnce({ schemas: [], edges: [] })
await useSchemaStore.getState().fetchAll()
expect(mockGet).toHaveBeenCalledWith("/v2/schema")
expect(mockGet).toHaveBeenCalledWith("/schema/all")
})

it("sends type and relationship writes to /v2/schema", async () => {
it("sends type and relationship writes to /schema", async () => {
mockPut.mockResolvedValueOnce({}).mockResolvedValueOnce({})
mockPost.mockResolvedValueOnce({}).mockResolvedValueOnce({})
const store = useSchemaStore.getState()
Expand All @@ -254,7 +254,7 @@ describe("schema-store – v2 endpoints", () => {
await store.addEdge({ ref_id: "e-1", source: "a", target: "b", source_type: "A", target_type: "B", edge_type: "LINKS" })
await store.updateEdge({ ref_id: "e-1", source: "a", target: "b", edge_type: "LINKS" })

expect(mockPut.mock.calls.map(([path]) => path)).toEqual(["/v2/schema/test-1", "/v2/schema/edge/e-1"])
expect(mockPost.mock.calls.map(([path]) => path)).toEqual(["/v2/schema", "/v2/schema/edge"])
expect(mockPut.mock.calls.map(([path]) => path)).toEqual(["/schema/test-1", "/schema/edge/e-1"])
expect(mockPost.mock.calls.map(([path]) => path)).toEqual(["/schema", "/schema/edge"])
})
})
14 changes: 7 additions & 7 deletions src/stores/schema-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
if (isMocksEnabled()) return

try {
await api.put(`/v2/schema/${updated.ref_id}`, {
await api.put(`/schema/${updated.ref_id}`, {
type: updated.type,
parent: updated.parent,
primary_color: updated.color,
Expand Down Expand Up @@ -93,7 +93,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
if (isMocksEnabled()) return schema.ref_id

try {
const res = await api.post<{ ref_id?: string }>("/v2/schema", {
const res = await api.post<{ ref_id?: string }>("/schema", {
type: schema.type,
parent: schema.parent,
primary_color: schema.color,
Expand Down Expand Up @@ -129,7 +129,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
if (isMocksEnabled()) return

try {
await api.delete(`/v2/schema/${refId}`)
await api.delete(`/schema/${refId}`)
} catch (err) {
console.error("Failed to delete schema:", err)
// Rollback
Expand All @@ -145,7 +145,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({

try {
// The backend keys edge schemas off type NAMES, not ref_ids.
const res = await api.post<{ ref_id?: string }>("/v2/schema/edge", {
const res = await api.post<{ ref_id?: string }>("/schema/edge", {
source: edge.source_type ?? edge.source,
target: edge.target_type ?? edge.target,
edge_type: edge.edge_type,
Expand Down Expand Up @@ -182,7 +182,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
if (isMocksEnabled()) return

try {
await api.put(`/v2/schema/edge/${edge.ref_id}`, {
await api.put(`/schema/edge/${edge.ref_id}`, {
edge_type: edge.edge_type,
attributes: edge.attributes ?? {},
})
Expand All @@ -204,7 +204,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
if (isMocksEnabled()) return

try {
await api.delete(`/v2/schema/edge/${refId}`)
await api.delete(`/schema/edge/${refId}`)
} catch (err) {
console.error("Failed to delete relationship:", err)
// Rollback
Expand Down Expand Up @@ -235,7 +235,7 @@ export const useSchemaStore = create<SchemaState>((set) => ({
centrality?: number
}>
edges: SchemaEdge[]
}>("/v2/schema")
}>("/schema/all")

const schemas: SchemaNode[] = (res.schemas ?? []).map((s) => ({
ref_id: s.ref_id,
Expand Down
Loading