From b563631f6969094e82f06b88c539cb9e970d975c Mon Sep 17 00:00:00 2001 From: Rassl Date: Sat, 12 Sep 2026 04:47:46 +0400 Subject: [PATCH] fix: move schema store back to v1 /schema endpoints The /v2/schema migration from #407 does not work, so reads and writes go back to /schema/all and /schema/*. The height/centrality mapping and the sidebar type ordering stay: /schema/all returns the same payload. Claude-Session: https://claude.ai/code/session_0167GfTeyTixCjzz5SWDDDMG --- src/lib/__tests__/schema-store.test.ts | 12 ++++++------ src/stores/schema-store.ts | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/__tests__/schema-store.test.ts b/src/lib/__tests__/schema-store.test.ts index 3d5062f..6d6cd58 100644 --- a/src/lib/__tests__/schema-store.test.ts +++ b/src/lib/__tests__/schema-store.test.ts @@ -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() @@ -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"]) }) }) diff --git a/src/stores/schema-store.ts b/src/stores/schema-store.ts index 5fa730e..ffad8b9 100644 --- a/src/stores/schema-store.ts +++ b/src/stores/schema-store.ts @@ -62,7 +62,7 @@ export const useSchemaStore = create((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, @@ -93,7 +93,7 @@ export const useSchemaStore = create((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, @@ -129,7 +129,7 @@ export const useSchemaStore = create((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 @@ -145,7 +145,7 @@ export const useSchemaStore = create((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, @@ -182,7 +182,7 @@ export const useSchemaStore = create((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 ?? {}, }) @@ -204,7 +204,7 @@ export const useSchemaStore = create((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 @@ -235,7 +235,7 @@ export const useSchemaStore = create((set) => ({ centrality?: number }> edges: SchemaEdge[] - }>("/v2/schema") + }>("/schema/all") const schemas: SchemaNode[] = (res.schemas ?? []).map((s) => ({ ref_id: s.ref_id,