102 lines
2.6 KiB
TypeScript
102 lines
2.6 KiB
TypeScript
import { expect, test } from "vitest";
|
|
import { migrateWorkspaceV2ToV3 } from "../src/workspaces/migrate-v2-qdrant.js";
|
|
import { parseWorkspaceYaml } from "../src/workspaces/schema.js";
|
|
|
|
const workspaceV2Yaml = `workspace:
|
|
schema_version: 2
|
|
id: psd-clinical
|
|
name: Policlinico San Donato
|
|
description: Clinical data warehouse workspace
|
|
language: it
|
|
dwh:
|
|
engine: postgres
|
|
database: postgres
|
|
schema: datawarehouse
|
|
supported_transports:
|
|
- postgres_direct
|
|
- rest_api
|
|
semantic_index:
|
|
vector_store:
|
|
engine: pgvector
|
|
database: postgres
|
|
schema: vectors
|
|
collection: clinical_documents
|
|
dimensions: 768
|
|
distance: inner_product
|
|
supported_transports:
|
|
- pgvector_direct
|
|
- rest_api
|
|
embedding:
|
|
provider: openai_compatible
|
|
model: text-embedding-3-large
|
|
dimensions: 768
|
|
llm_policy:
|
|
default: zai/glm-5.2
|
|
allowed:
|
|
- zai/glm-5.2
|
|
diagnostics:
|
|
dwh_rest:
|
|
method: POST
|
|
path: /rpc/dwh
|
|
auth: bearer
|
|
response:
|
|
database: database
|
|
schema: schema
|
|
vector_rest:
|
|
metadata:
|
|
method: GET
|
|
path: /vector
|
|
auth: bearer
|
|
response:
|
|
collection: collection
|
|
dimensions: dimensions
|
|
distance: distance
|
|
embedding:
|
|
method: GET
|
|
path: /models
|
|
auth: none
|
|
response:
|
|
model: model
|
|
dimensions: dimensions
|
|
`;
|
|
|
|
test("migrates a schema v2 workspace to the internal qdrant schema v3 shape", () => {
|
|
const legacy = parseWorkspaceYaml(workspaceV2Yaml);
|
|
|
|
const migrated = migrateWorkspaceV2ToV3(legacy, "psd-clinical");
|
|
|
|
expect(migrated).toMatchObject({
|
|
workspace: { schema_version: 3, id: "psd-clinical", name: "Policlinico San Donato" },
|
|
dwh: legacy.dwh,
|
|
semantic_index: {
|
|
vector_store: {
|
|
engine: "qdrant",
|
|
collection: "psd-clinical",
|
|
dimensions: 1024,
|
|
distance: "cosine",
|
|
},
|
|
embedding: {
|
|
provider: "ollama_internal",
|
|
model: "qwen3-embedding:0.6b",
|
|
dimensions: 1024,
|
|
},
|
|
},
|
|
llm_policy: legacy.llm_policy,
|
|
diagnostics: {
|
|
dwh_rest: legacy.diagnostics?.dwh_rest,
|
|
},
|
|
});
|
|
});
|
|
|
|
test("drops vector and embedding diagnostics and transports during v2 to v3 migration", () => {
|
|
const legacy = parseWorkspaceYaml(workspaceV2Yaml);
|
|
|
|
const migrated = migrateWorkspaceV2ToV3(legacy, "psd-clinical");
|
|
|
|
expect(migrated.diagnostics).toEqual({
|
|
dwh_rest: legacy.diagnostics?.dwh_rest,
|
|
});
|
|
expect(migrated.semantic_index.vector_store).not.toHaveProperty("supported_transports");
|
|
expect(migrated.semantic_index.embedding).not.toHaveProperty("timeout_ms");
|
|
});
|