@nicia-ai/typegraph 0.66.1 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +15 -0
  3. package/dist/backend/postgres/pglite-store.cjs +1 -1
  4. package/dist/backend/postgres/pglite-store.js +1 -1
  5. package/dist/backend/sqlite/local-store.cjs +1 -1
  6. package/dist/backend/sqlite/local-store.js +1 -1
  7. package/dist/{chunk-TR7QTODF.js → chunk-55DGFZYC.js} +3 -3
  8. package/dist/{chunk-TR7QTODF.js.map → chunk-55DGFZYC.js.map} +1 -1
  9. package/dist/{chunk-WB55URNM.js → chunk-6CKSTY2D.js} +7 -3
  10. package/dist/chunk-6CKSTY2D.js.map +1 -0
  11. package/dist/{chunk-SSDHR2C2.js → chunk-EFSXK3DW.js} +3 -3
  12. package/dist/{chunk-SSDHR2C2.js.map → chunk-EFSXK3DW.js.map} +1 -1
  13. package/dist/{chunk-Y4X6ODVY.cjs → chunk-FS2GVO2T.cjs} +56 -56
  14. package/dist/{chunk-Y4X6ODVY.cjs.map → chunk-FS2GVO2T.cjs.map} +1 -1
  15. package/dist/{chunk-K7YACILO.cjs → chunk-GXHEGNI6.cjs} +9 -9
  16. package/dist/{chunk-K7YACILO.cjs.map → chunk-GXHEGNI6.cjs.map} +1 -1
  17. package/dist/{chunk-BX42F7IJ.cjs → chunk-SSDLQPMY.cjs} +7 -2
  18. package/dist/chunk-SSDLQPMY.cjs.map +1 -0
  19. package/dist/graph-merge/index.cjs +500 -26
  20. package/dist/graph-merge/index.cjs.map +1 -1
  21. package/dist/graph-merge/index.d.cts +384 -2
  22. package/dist/graph-merge/index.d.ts +384 -2
  23. package/dist/graph-merge/index.js +485 -15
  24. package/dist/graph-merge/index.js.map +1 -1
  25. package/dist/index.cjs +63 -63
  26. package/dist/index.js +3 -3
  27. package/dist/{local-store-impl-OUINMCYI.cjs → local-store-impl-7SPBIS4M.cjs} +5 -5
  28. package/dist/{local-store-impl-OUINMCYI.cjs.map → local-store-impl-7SPBIS4M.cjs.map} +1 -1
  29. package/dist/{local-store-impl-ERPNYOCL.js → local-store-impl-E23EDYPV.js} +4 -4
  30. package/dist/{local-store-impl-ERPNYOCL.js.map → local-store-impl-E23EDYPV.js.map} +1 -1
  31. package/dist/{pglite-store-impl-Z3SOOP75.cjs → pglite-store-impl-U55HQ5ZY.cjs} +5 -5
  32. package/dist/{pglite-store-impl-Z3SOOP75.cjs.map → pglite-store-impl-U55HQ5ZY.cjs.map} +1 -1
  33. package/dist/{pglite-store-impl-DUJBQZS5.js → pglite-store-impl-VAIEJZOU.js} +4 -4
  34. package/dist/{pglite-store-impl-DUJBQZS5.js.map → pglite-store-impl-VAIEJZOU.js.map} +1 -1
  35. package/dist/schema/index.cjs +27 -27
  36. package/dist/schema/index.js +2 -2
  37. package/package.json +1 -1
  38. package/dist/chunk-BX42F7IJ.cjs.map +0 -1
  39. package/dist/chunk-WB55URNM.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { buildValidatedKindRegistry, serializeSchema, computeSchemaHash } from './chunk-WB55URNM.js';
1
+ import { buildValidatedKindRegistry, serializeSchema, computeSchemaHash } from './chunk-6CKSTY2D.js';
2
2
  import { resolveGraphVectorSlots } from './chunk-PC2UBAUB.js';
3
3
  import { hasOwnKey } from './chunk-QD2JFTSL.js';
4
4
  import { ConfigurationError } from './chunk-GMKPIYHY.js';
@@ -187,5 +187,5 @@ function graphTemplatesUnsupportedError(backend) {
187
187
  }
188
188
 
189
189
  export { deserializeSchema, instantiateGraph, instantiateGraphTemplate, registerGraphTemplate };
190
- //# sourceMappingURL=chunk-SSDHR2C2.js.map
191
- //# sourceMappingURL=chunk-SSDHR2C2.js.map
190
+ //# sourceMappingURL=chunk-EFSXK3DW.js.map
191
+ //# sourceMappingURL=chunk-EFSXK3DW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema/deserializer.ts","../src/schema/graph-templ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,EAAY,OAAO,MAAA,CAAO;AAAA,MACxB,KAAA,EAAO,WAAA;AAAA,MACP,OAAA,EAAS,OAAO,GAAA,CAAI,OAAA;AAAA,MACpB,IAAA,EAAM,OAAO,GAAA,CAAI;AAAA,KAClB,CAAA;AAAA,IACD,QAAQ,MAAA,CAAO;AAAA,GAChB,CAAA;AACH;AAEA,SAAS,iCACP,UAAA,EACoB;AACpB,EAAA,OAAO,IAAI,kBAAA;AAAA,IACT,0BAA0B,UAAU,CAAA,gDAAA,CAAA;AAAA,IACpC,EAAE,IAAA,EAAM,gCAAA,EAAkC,UAAA;AAAW,GACvD;AACF;AAGO,SAAS,gBAAA,CACd,SACA,MAAA,EAC4C;AAC5C,EAAA,OAAO,wBAAA,CAAyB,SAAS,MAAM,CAAA;AACjD;AAEA,SAAS,+BACP,OAAA,EACoB;AACpB,EAAA,OAAO,IAAI,kBAAA;AAAA,IACT,CAAA,IAAA,EAAO,QAAQ,OAAO,CAAA,kDAAA,CAAA;AAAA,IACtB,EAAE,IAAA,EAAM,6BAAA,EAA+B,OAAA,EAAS,QAAQ,OAAA;AAAQ,GAClE;AACF","file":"chunk-SSDHR2C2.js","sourcesContent":["/**\n * Schema deserializer for loading stored schemas.\n *\n * Reconstructs runtime objects from SerializedSchema.\n * Note: Zod schemas cannot be fully reconstructed from JSON Schema,\n * so this provides access to the serialized data for introspection.\n */\nimport { type AnyEdgeType, type NodeType } from \"../core/types\";\nimport { type NamedOntologyRelation } from \"../ontology/validation\";\nimport { buildValidatedKindRegistry } from \"../registry/build-validated\";\nimport type { KindRegistry } from \"../registry/kind-registry\";\nimport { type EdgeEndpointKinds } from \"../registry/validate-implies\";\nimport { hasOwnKey } from \"../utils/object\";\nimport {\n type SerializedClosures,\n type SerializedEdgeDef,\n type SerializedMetaEdge,\n type SerializedNodeDef,\n type SerializedOntologyRelation,\n type SerializedSchema,\n} from \"./types\";\n\n// ============================================================\n// Deserialized Schema\n// ============================================================\n\n/**\n * A deserialized schema provides read-only access to schema metadata.\n *\n * Note: Unlike the original GraphDef, this does not include Zod schemas\n * since those cannot be reconstructed from JSON Schema. Use this for\n * introspection and metadata access only.\n */\nexport type DeserializedSchema = Readonly<{\n graphId: string;\n version: number;\n generatedAt: string;\n\n /** Get node definition by name */\n getNode: (name: string) => SerializedNodeDef | undefined;\n\n /** Get all node names */\n getNodeNames: () => readonly string[];\n\n /** Get edge definition by name */\n getEdge: (name: string) => SerializedEdgeDef | undefined;\n\n /** Get all edge names */\n getEdgeNames: () => readonly string[];\n\n /** Get meta-edge definition by name */\n getMetaEdge: (name: string) => SerializedMetaEdge | undefined;\n\n /** Get all meta-edge names */\n getMetaEdgeNames: () => readonly string[];\n\n /** Get all ontology relations */\n getRelations: () => readonly SerializedOntologyRelation[];\n\n /** Get precomputed closures */\n getClosures: () => SerializedClosures;\n\n /** Get graph defaults */\n getDefaults: () => SerializedSchema[\"defaults\"];\n\n /** Get the durable TypeGraph Identity Profile configuration. */\n getIdentity: () => SerializedSchema[\"identity\"];\n\n /** Get the raw serialized schema */\n getRaw: () => SerializedSchema;\n\n /** Build a validated KindRegistry by recomputing closures from relations */\n buildRegistry: () => KindRegistry;\n}>;\n\n// ============================================================\n// Deserialization\n// ============================================================\n\n/**\n * Deserializes a SerializedSchema into a DeserializedSchema.\n *\n * @param schema - The serialized schema to deserialize\n * @returns A deserialized schema with accessor methods\n */\nexport function deserializeSchema(\n schema: SerializedSchema,\n): DeserializedSchema {\n const nodeNames = Object.keys(schema.nodes);\n const edgeNames = Object.keys(schema.edges);\n const metaEdgeNames = Object.keys(schema.ontology.metaEdges);\n\n return {\n graphId: schema.graphId,\n version: schema.version,\n generatedAt: schema.generatedAt,\n\n // Own-key reads, for the same reason {@link buildEdgeEndpointKinds} below\n // uses a `Map`: `schema` is parsed out of a stored JSON document and the\n // caller supplies the name, so a raw read hands back an `Object.prototype`\n // member typed as a definition for any name no kind is registered under.\n getNode: (name) =>\n hasOwnKey(schema.nodes, name) ? schema.nodes[name] : undefined,\n getNodeNames: () => nodeNames,\n\n getEdge: (name) =>\n hasOwnKey(schema.edges, name) ? schema.edges[name] : undefined,\n getEdgeNames: () => edgeNames,\n\n getMetaEdge: (name) =>\n hasOwnKey(schema.ontology.metaEdges, name) ?\n schema.ontology.metaEdges[name]\n : undefined,\n getMetaEdgeNames: () => metaEdgeNames,\n\n getRelations: () => schema.ontology.relations,\n getClosures: () => schema.ontology.closures,\n\n getDefaults: () => schema.defaults,\n getIdentity: () => schema.identity,\n getRaw: () => schema,\n\n buildRegistry: () => buildRegistryFromRelations(schema),\n };\n}\n\n// ============================================================\n// Registry Building\n// ============================================================\n\n/**\n * Builds a KindRegistry from serialized relations.\n *\n * Persisted closures are a legacy inspection artifact. Relations are validated\n * and closures are recomputed so old schemas gain current hardening rules.\n */\nfunction buildRegistryFromRelations(schema: SerializedSchema): KindRegistry {\n // Build empty node/edge kind maps (we don't have the actual Zod schemas)\n const nodeKinds = new Map<string, NodeType>();\n const edgeKinds = new Map<string, AnyEdgeType>();\n return buildValidatedKindRegistry({\n nodeKinds,\n edgeKinds,\n ontology: schema.ontology.relations.map(\n (relation): NamedOntologyRelation => ({\n metaEdge: relation.metaEdge,\n from: relation.from,\n to: relation.to,\n }),\n ),\n edgeEndpoints: buildEdgeEndpointKinds(schema.edges),\n ...(schema.identity === undefined ? {} : { identity: schema.identity }),\n });\n}\n\n/**\n * Maps each edge kind's serialized definition to its domain/range kind\n * names, for `validateImpliesEndpointCompatibility`. A `Map` (rather than\n * the plain `schema.edges` object) so a lookup for an edge kind literally\n * named \"toString\" or another `Object.prototype` member can't resolve to\n * an inherited member instead of `undefined`.\n */\nfunction buildEdgeEndpointKinds(\n edges: Record<string, SerializedEdgeDef>,\n): ReadonlyMap<string, EdgeEndpointKinds> {\n const result = new Map<string, EdgeEndpointKinds>();\n for (const [kind, def] of Object.entries(edges)) {\n const pairs: { from: string; to: string }[] = [];\n if (def.targetKindsBySource === undefined) {\n for (const fromKind of def.fromKinds) {\n for (const toKind of def.toKinds) {\n pairs.push({ from: fromKind, to: toKind });\n }\n }\n } else {\n for (const [sourceKind, targetKinds] of Object.entries(\n def.targetKindsBySource,\n )) {\n for (const targetKind of targetKinds) {\n pairs.push({ from: sourceKind, to: targetKind });\n }\n }\n }\n result.set(kind, {\n from: def.fromKinds,\n to: def.toKinds,\n pairs,\n });\n }\n return result;\n}\n","import type { GraphBackend, SchemaVersionRow } from \"../backend/types\";\nimport { type GraphDef } from \"../core/define-graph\";\nimport { resolveGraphVectorSlots } from \"../core/embedding\";\nimport { ConfigurationError } from \"../errors\";\nimport { type ReconciledSchema } from \"../store/store\";\nimport { computeSchemaHash, serializeSchema } from \"./serializer\";\n\n/** A locally held handle for a durable server-side graph template. */\nexport type GraphTemplate<G extends GraphDef> = Readonly<{\n id: string;\n reconciled: ReconciledSchema<G>;\n schemaHash: string;\n}>;\n\nexport type InstantiateGraphTemplateResult<G extends GraphDef> = Readonly<{\n status: \"ready\";\n reconciled: ReconciledSchema<G>;\n schema: SchemaVersionRow;\n}>;\n\n/**\n * Registers the fully materialized shape of a verified store as a durable\n * template. The original schema version is retained only as snapshot\n * provenance: every instantiated graph starts at v1 with that final shape.\n */\nexport async function registerGraphTemplate<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ templateId: string; reconciled: ReconciledSchema<G> }>,\n): Promise<GraphTemplate<G>> {\n const register = backend.registerGraphTemplate;\n if (register === undefined) throw graphTemplatesUnsupportedError(backend);\n await backend.assertBaseSchemaCurrent?.();\n const { reconciled } = params;\n if (reconciled.version === undefined || reconciled.hash === undefined) {\n throw new ConfigurationError(\n \"A graph template requires a reconciled schema from a managed or verified Store.\",\n { code: \"GRAPH_TEMPLATE_REQUIRES_RECONCILED_SCHEMA\" },\n );\n }\n if (\n resolveGraphVectorSlots(reconciled.graph).length > 0 &&\n backend.capabilities.vector?.supported === true\n ) {\n throw new ConfigurationError(\n \"Graph templates do not support embedding fields because vector storage is graph-scoped and cannot be instantiated schema-only.\",\n {\n code: \"GRAPH_TEMPLATE_VECTOR_UNSUPPORTED\",\n graphId: reconciled.graph.id,\n },\n {\n suggestion:\n \"Provision the graph through createStoreWithSchema until template instantiation can atomically materialize vector contributions.\",\n },\n );\n }\n const schemaDocument = serializeSchema(reconciled.graph, reconciled.version);\n const schemaHash = await computeSchemaHash(schemaDocument);\n if (schemaHash !== reconciled.hash) {\n throw new ConfigurationError(\n \"Reconciled schema hash does not match its graph snapshot.\",\n { code: \"GRAPH_TEMPLATE_RECONCILED_HASH_MISMATCH\" },\n );\n }\n await register({\n templateId: params.templateId,\n schemaHash,\n schemaDoc: schemaDocument,\n });\n return Object.freeze({\n id: params.templateId,\n reconciled,\n schemaHash,\n });\n}\n\n/**\n * Instantiates the template's final graph shape as target schema v1. Only the\n * target hash crosses the wire; the durable source document stays in the\n * backend template registry and is rebound to `graphId` by one SQL statement.\n */\nexport async function instantiateGraphTemplate<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ template: GraphTemplate<G>; graphId: string }>,\n): Promise<InstantiateGraphTemplateResult<G>> {\n const instantiate = backend.instantiateGraphTemplate;\n if (instantiate === undefined) throw graphTemplatesUnsupportedError(backend);\n await backend.assertBaseSchemaCurrent?.();\n const sourceVersion = params.template.reconciled.version;\n const reconciledHash = params.template.reconciled.hash;\n if (sourceVersion === undefined || reconciledHash === undefined) {\n throw graphTemplateHandleMismatchError(params.template.id);\n }\n const sourceHash = await computeSchemaHash(\n serializeSchema(params.template.reconciled.graph, sourceVersion),\n );\n if (\n sourceHash !== params.template.schemaHash ||\n reconciledHash !== params.template.schemaHash\n ) {\n throw graphTemplateHandleMismatchError(params.template.id);\n }\n const targetGraph: G = Object.freeze({\n ...params.template.reconciled.graph,\n id: params.graphId,\n });\n const targetHash = await computeSchemaHash(serializeSchema(targetGraph, 1));\n const result = await instantiate({\n templateId: params.template.id,\n templateSchemaHash: params.template.schemaHash,\n graphId: params.graphId,\n schemaHash: targetHash,\n });\n if (result.status === \"refused\") {\n throw new ConfigurationError(\n `Graph template instantiation was refused for graph \"${params.graphId}\". The template may be absent, or the graph already has a different schema.`,\n {\n code: \"GRAPH_TEMPLATE_INSTANTIATION_REFUSED\",\n graphId: params.graphId,\n templateId: params.template.id,\n },\n );\n }\n if (\n result.row.graph_id !== params.graphId ||\n result.row.version !== 1 ||\n result.row.schema_hash !== targetHash\n ) {\n throw new ConfigurationError(\n \"Graph template backend returned a schema row that does not match the requested target.\",\n { code: \"GRAPH_TEMPLATE_INVALID_RESULT\", graphId: params.graphId },\n );\n }\n return Object.freeze({\n status: \"ready\",\n reconciled: Object.freeze({\n graph: targetGraph,\n version: result.row.version,\n hash: result.row.schema_hash,\n }),\n schema: result.row,\n });\n}\n\nfunction graphTemplateHandleMismatchError(\n templateId: string,\n): ConfigurationError {\n return new ConfigurationError(\n `Graph template handle \"${templateId}\" does not match its reconciled schema snapshot.`,\n { code: \"GRAPH_TEMPLATE_HANDLE_MISMATCH\", templateId },\n );\n}\n\n/** Short public name for {@link instantiateGraphTemplate}. */\nexport function instantiateGraph<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ template: GraphTemplate<G>; graphId: string }>,\n): Promise<InstantiateGraphTemplateResult<G>> {\n return instantiateGraphTemplate(backend, params);\n}\n\nfunction graphTemplatesUnsupportedError(\n backend: GraphBackend,\n): ConfigurationError {\n return new ConfigurationError(\n `The ${backend.dialect} backend does not support durable graph templates.`,\n { code: \"GRAPH_TEMPLATES_UNSUPPORTED\", dialect: backend.dialect },\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/schema/deserializer.ts","../src/schema/graph-templates.ts"],"names":[],"mappings":";;;;;;AAqFO,SAAS,kBACd,MAAA,EACoB;AACpB,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA;AAC1C,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA;AAC1C,EAAA,MAAM,aAAA,GAAgB,MAAA,CAAO,I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O,IAAI,kBAAA;AAAA,IACT,0BAA0B,UAAU,CAAA,gDAAA,CAAA;AAAA,IACpC,EAAE,IAAA,EAAM,gCAAA,EAAkC,UAAA;AAAW,GACvD;AACF;AAGO,SAAS,gBAAA,CACd,SACA,MAAA,EAC4C;AAC5C,EAAA,OAAO,wBAAA,CAAyB,SAAS,MAAM,CAAA;AACjD;AAEA,SAAS,+BACP,OAAA,EACoB;AACpB,EAAA,OAAO,IAAI,kBAAA;AAAA,IACT,CAAA,IAAA,EAAO,QAAQ,OAAO,CAAA,kDAAA,CAAA;AAAA,IACtB,EAAE,IAAA,EAAM,6BAAA,EAA+B,OAAA,EAAS,QAAQ,OAAA;AAAQ,GAClE;AACF","file":"chunk-EFSXK3DW.js","sourcesContent":["/**\n * Schema deserializer for loading stored schemas.\n *\n * Reconstructs runtime objects from SerializedSchema.\n * Note: Zod schemas cannot be fully reconstructed from JSON Schema,\n * so this provides access to the serialized data for introspection.\n */\nimport { type AnyEdgeType, type NodeType } from \"../core/types\";\nimport { type NamedOntologyRelation } from \"../ontology/validation\";\nimport { buildValidatedKindRegistry } from \"../registry/build-validated\";\nimport type { KindRegistry } from \"../registry/kind-registry\";\nimport { type EdgeEndpointKinds } from \"../registry/validate-implies\";\nimport { hasOwnKey } from \"../utils/object\";\nimport {\n type SerializedClosures,\n type SerializedEdgeDef,\n type SerializedMetaEdge,\n type SerializedNodeDef,\n type SerializedOntologyRelation,\n type SerializedSchema,\n} from \"./types\";\n\n// ============================================================\n// Deserialized Schema\n// ============================================================\n\n/**\n * A deserialized schema provides read-only access to schema metadata.\n *\n * Note: Unlike the original GraphDef, this does not include Zod schemas\n * since those cannot be reconstructed from JSON Schema. Use this for\n * introspection and metadata access only.\n */\nexport type DeserializedSchema = Readonly<{\n graphId: string;\n version: number;\n generatedAt: string;\n\n /** Get node definition by name */\n getNode: (name: string) => SerializedNodeDef | undefined;\n\n /** Get all node names */\n getNodeNames: () => readonly string[];\n\n /** Get edge definition by name */\n getEdge: (name: string) => SerializedEdgeDef | undefined;\n\n /** Get all edge names */\n getEdgeNames: () => readonly string[];\n\n /** Get meta-edge definition by name */\n getMetaEdge: (name: string) => SerializedMetaEdge | undefined;\n\n /** Get all meta-edge names */\n getMetaEdgeNames: () => readonly string[];\n\n /** Get all ontology relations */\n getRelations: () => readonly SerializedOntologyRelation[];\n\n /** Get precomputed closures */\n getClosures: () => SerializedClosures;\n\n /** Get graph defaults */\n getDefaults: () => SerializedSchema[\"defaults\"];\n\n /** Get the durable TypeGraph Identity Profile configuration. */\n getIdentity: () => SerializedSchema[\"identity\"];\n\n /** Get the raw serialized schema */\n getRaw: () => SerializedSchema;\n\n /** Build a validated KindRegistry by recomputing closures from relations */\n buildRegistry: () => KindRegistry;\n}>;\n\n// ============================================================\n// Deserialization\n// ============================================================\n\n/**\n * Deserializes a SerializedSchema into a DeserializedSchema.\n *\n * @param schema - The serialized schema to deserialize\n * @returns A deserialized schema with accessor methods\n */\nexport function deserializeSchema(\n schema: SerializedSchema,\n): DeserializedSchema {\n const nodeNames = Object.keys(schema.nodes);\n const edgeNames = Object.keys(schema.edges);\n const metaEdgeNames = Object.keys(schema.ontology.metaEdges);\n\n return {\n graphId: schema.graphId,\n version: schema.version,\n generatedAt: schema.generatedAt,\n\n // Own-key reads, for the same reason {@link buildEdgeEndpointKinds} below\n // uses a `Map`: `schema` is parsed out of a stored JSON document and the\n // caller supplies the name, so a raw read hands back an `Object.prototype`\n // member typed as a definition for any name no kind is registered under.\n getNode: (name) =>\n hasOwnKey(schema.nodes, name) ? schema.nodes[name] : undefined,\n getNodeNames: () => nodeNames,\n\n getEdge: (name) =>\n hasOwnKey(schema.edges, name) ? schema.edges[name] : undefined,\n getEdgeNames: () => edgeNames,\n\n getMetaEdge: (name) =>\n hasOwnKey(schema.ontology.metaEdges, name) ?\n schema.ontology.metaEdges[name]\n : undefined,\n getMetaEdgeNames: () => metaEdgeNames,\n\n getRelations: () => schema.ontology.relations,\n getClosures: () => schema.ontology.closures,\n\n getDefaults: () => schema.defaults,\n getIdentity: () => schema.identity,\n getRaw: () => schema,\n\n buildRegistry: () => buildRegistryFromRelations(schema),\n };\n}\n\n// ============================================================\n// Registry Building\n// ============================================================\n\n/**\n * Builds a KindRegistry from serialized relations.\n *\n * Persisted closures are a legacy inspection artifact. Relations are validated\n * and closures are recomputed so old schemas gain current hardening rules.\n */\nfunction buildRegistryFromRelations(schema: SerializedSchema): KindRegistry {\n // Build empty node/edge kind maps (we don't have the actual Zod schemas)\n const nodeKinds = new Map<string, NodeType>();\n const edgeKinds = new Map<string, AnyEdgeType>();\n return buildValidatedKindRegistry({\n nodeKinds,\n edgeKinds,\n ontology: schema.ontology.relations.map(\n (relation): NamedOntologyRelation => ({\n metaEdge: relation.metaEdge,\n from: relation.from,\n to: relation.to,\n }),\n ),\n edgeEndpoints: buildEdgeEndpointKinds(schema.edges),\n ...(schema.identity === undefined ? {} : { identity: schema.identity }),\n });\n}\n\n/**\n * Maps each edge kind's serialized definition to its domain/range kind\n * names, for `validateImpliesEndpointCompatibility`. A `Map` (rather than\n * the plain `schema.edges` object) so a lookup for an edge kind literally\n * named \"toString\" or another `Object.prototype` member can't resolve to\n * an inherited member instead of `undefined`.\n */\nfunction buildEdgeEndpointKinds(\n edges: Record<string, SerializedEdgeDef>,\n): ReadonlyMap<string, EdgeEndpointKinds> {\n const result = new Map<string, EdgeEndpointKinds>();\n for (const [kind, def] of Object.entries(edges)) {\n const pairs: { from: string; to: string }[] = [];\n if (def.targetKindsBySource === undefined) {\n for (const fromKind of def.fromKinds) {\n for (const toKind of def.toKinds) {\n pairs.push({ from: fromKind, to: toKind });\n }\n }\n } else {\n for (const [sourceKind, targetKinds] of Object.entries(\n def.targetKindsBySource,\n )) {\n for (const targetKind of targetKinds) {\n pairs.push({ from: sourceKind, to: targetKind });\n }\n }\n }\n result.set(kind, {\n from: def.fromKinds,\n to: def.toKinds,\n pairs,\n });\n }\n return result;\n}\n","import type { GraphBackend, SchemaVersionRow } from \"../backend/types\";\nimport { type GraphDef } from \"../core/define-graph\";\nimport { resolveGraphVectorSlots } from \"../core/embedding\";\nimport { ConfigurationError } from \"../errors\";\nimport { type ReconciledSchema } from \"../store/store\";\nimport { computeSchemaHash, serializeSchema } from \"./serializer\";\n\n/** A locally held handle for a durable server-side graph template. */\nexport type GraphTemplate<G extends GraphDef> = Readonly<{\n id: string;\n reconciled: ReconciledSchema<G>;\n schemaHash: string;\n}>;\n\nexport type InstantiateGraphTemplateResult<G extends GraphDef> = Readonly<{\n status: \"ready\";\n reconciled: ReconciledSchema<G>;\n schema: SchemaVersionRow;\n}>;\n\n/**\n * Registers the fully materialized shape of a verified store as a durable\n * template. The original schema version is retained only as snapshot\n * provenance: every instantiated graph starts at v1 with that final shape.\n */\nexport async function registerGraphTemplate<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ templateId: string; reconciled: ReconciledSchema<G> }>,\n): Promise<GraphTemplate<G>> {\n const register = backend.registerGraphTemplate;\n if (register === undefined) throw graphTemplatesUnsupportedError(backend);\n await backend.assertBaseSchemaCurrent?.();\n const { reconciled } = params;\n if (reconciled.version === undefined || reconciled.hash === undefined) {\n throw new ConfigurationError(\n \"A graph template requires a reconciled schema from a managed or verified Store.\",\n { code: \"GRAPH_TEMPLATE_REQUIRES_RECONCILED_SCHEMA\" },\n );\n }\n if (\n resolveGraphVectorSlots(reconciled.graph).length > 0 &&\n backend.capabilities.vector?.supported === true\n ) {\n throw new ConfigurationError(\n \"Graph templates do not support embedding fields because vector storage is graph-scoped and cannot be instantiated schema-only.\",\n {\n code: \"GRAPH_TEMPLATE_VECTOR_UNSUPPORTED\",\n graphId: reconciled.graph.id,\n },\n {\n suggestion:\n \"Provision the graph through createStoreWithSchema until template instantiation can atomically materialize vector contributions.\",\n },\n );\n }\n const schemaDocument = serializeSchema(reconciled.graph, reconciled.version);\n const schemaHash = await computeSchemaHash(schemaDocument);\n if (schemaHash !== reconciled.hash) {\n throw new ConfigurationError(\n \"Reconciled schema hash does not match its graph snapshot.\",\n { code: \"GRAPH_TEMPLATE_RECONCILED_HASH_MISMATCH\" },\n );\n }\n await register({\n templateId: params.templateId,\n schemaHash,\n schemaDoc: schemaDocument,\n });\n return Object.freeze({\n id: params.templateId,\n reconciled,\n schemaHash,\n });\n}\n\n/**\n * Instantiates the template's final graph shape as target schema v1. Only the\n * target hash crosses the wire; the durable source document stays in the\n * backend template registry and is rebound to `graphId` by one SQL statement.\n */\nexport async function instantiateGraphTemplate<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ template: GraphTemplate<G>; graphId: string }>,\n): Promise<InstantiateGraphTemplateResult<G>> {\n const instantiate = backend.instantiateGraphTemplate;\n if (instantiate === undefined) throw graphTemplatesUnsupportedError(backend);\n await backend.assertBaseSchemaCurrent?.();\n const sourceVersion = params.template.reconciled.version;\n const reconciledHash = params.template.reconciled.hash;\n if (sourceVersion === undefined || reconciledHash === undefined) {\n throw graphTemplateHandleMismatchError(params.template.id);\n }\n const sourceHash = await computeSchemaHash(\n serializeSchema(params.template.reconciled.graph, sourceVersion),\n );\n if (\n sourceHash !== params.template.schemaHash ||\n reconciledHash !== params.template.schemaHash\n ) {\n throw graphTemplateHandleMismatchError(params.template.id);\n }\n const targetGraph: G = Object.freeze({\n ...params.template.reconciled.graph,\n id: params.graphId,\n });\n const targetHash = await computeSchemaHash(serializeSchema(targetGraph, 1));\n const result = await instantiate({\n templateId: params.template.id,\n templateSchemaHash: params.template.schemaHash,\n graphId: params.graphId,\n schemaHash: targetHash,\n });\n if (result.status === \"refused\") {\n throw new ConfigurationError(\n `Graph template instantiation was refused for graph \"${params.graphId}\". The template may be absent, or the graph already has a different schema.`,\n {\n code: \"GRAPH_TEMPLATE_INSTANTIATION_REFUSED\",\n graphId: params.graphId,\n templateId: params.template.id,\n },\n );\n }\n if (\n result.row.graph_id !== params.graphId ||\n result.row.version !== 1 ||\n result.row.schema_hash !== targetHash\n ) {\n throw new ConfigurationError(\n \"Graph template backend returned a schema row that does not match the requested target.\",\n { code: \"GRAPH_TEMPLATE_INVALID_RESULT\", graphId: params.graphId },\n );\n }\n return Object.freeze({\n status: \"ready\",\n reconciled: Object.freeze({\n graph: targetGraph,\n version: result.row.version,\n hash: result.row.schema_hash,\n }),\n schema: result.row,\n });\n}\n\nfunction graphTemplateHandleMismatchError(\n templateId: string,\n): ConfigurationError {\n return new ConfigurationError(\n `Graph template handle \"${templateId}\" does not match its reconciled schema snapshot.`,\n { code: \"GRAPH_TEMPLATE_HANDLE_MISMATCH\", templateId },\n );\n}\n\n/** Short public name for {@link instantiateGraphTemplate}. */\nexport function instantiateGraph<G extends GraphDef>(\n backend: GraphBackend,\n params: Readonly<{ template: GraphTemplate<G>; graphId: string }>,\n): Promise<InstantiateGraphTemplateResult<G>> {\n return instantiateGraphTemplate(backend, params);\n}\n\nfunction graphTemplatesUnsupportedError(\n backend: GraphBackend,\n): ConfigurationError {\n return new ConfigurationError(\n `The ${backend.dialect} backend does not support durable graph templates.`,\n { code: \"GRAPH_TEMPLATES_UNSUPPORTED\", dialect: backend.dialect },\n );\n}\n"]}
@@ -8,7 +8,7 @@ var chunkI7SBZJI2_cjs = require('./chunk-I7SBZJI2.cjs');
8
8
  var chunkG7OKJDMG_cjs = require('./chunk-G7OKJDMG.cjs');
9
9
  var chunkR255UE5U_cjs = require('./chunk-R255UE5U.cjs');
10
10
  var chunkMRUOOAIQ_cjs = require('./chunk-MRUOOAIQ.cjs');
11
- var chunkBX42F7IJ_cjs = require('./chunk-BX42F7IJ.cjs');
11
+ var chunkSSDLQPMY_cjs = require('./chunk-SSDLQPMY.cjs');
12
12
  var chunk6YKISECL_cjs = require('./chunk-6YKISECL.cjs');
13
13
  var chunkICOTLZBV_cjs = require('./chunk-ICOTLZBV.cjs');
14
14
  var chunkEBQX7MYL_cjs = require('./chunk-EBQX7MYL.cjs');
@@ -16717,7 +16717,7 @@ function declaredPathsForEntity(graph, entity) {
16717
16717
  );
16718
16718
  for (const schema of schemas) {
16719
16719
  for (const path of declaredPropertyPaths(
16720
- chunkBX42F7IJ_cjs.serializeSchemaProperties(schema)
16720
+ chunkSSDLQPMY_cjs.serializeSchemaProperties(schema)
16721
16721
  )) {
16722
16722
  paths.add(pathToPointer(path));
16723
16723
  }
@@ -16782,7 +16782,7 @@ async function readEntityPopulation(ctx, entity, paths, currentTimestamp) {
16782
16782
  function populationForKind(entity, kind, schema, populations) {
16783
16783
  const population = populations.get(kind);
16784
16784
  const count2 = population?.count ?? 0;
16785
- const declaredPaths = declaredPropertyPaths(chunkBX42F7IJ_cjs.serializeSchemaProperties(schema)).map((path) => pathToPointer(path)).toSorted();
16785
+ const declaredPaths = declaredPropertyPaths(chunkSSDLQPMY_cjs.serializeSchemaProperties(schema)).map((path) => pathToPointer(path)).toSorted();
16786
16786
  return {
16787
16787
  entity,
16788
16788
  kind,
@@ -17368,7 +17368,7 @@ async function prepareEvolutionPlan(params) {
17368
17368
  extension: callerExtension
17369
17369
  } = params;
17370
17370
  const extension = chunkBXHAPCQG_cjs.freezeDeep(structuredClone(callerExtension));
17371
- const mergedGraph = chunkBX42F7IJ_cjs.mergeGraphExtension(baselineGraph, extension);
17371
+ const mergedGraph = chunkSSDLQPMY_cjs.mergeGraphExtension(baselineGraph, extension);
17372
17372
  if (mergedGraph === baselineGraph) {
17373
17373
  const baseline = Object.freeze({
17374
17374
  version: baselineVersion,
@@ -17394,7 +17394,7 @@ async function prepareEvolutionPlan(params) {
17394
17394
  baselineGraph.id
17395
17395
  );
17396
17396
  }
17397
- const prepared = await chunkBX42F7IJ_cjs.prepareNewSchemaVersion(
17397
+ const prepared = await chunkSSDLQPMY_cjs.prepareNewSchemaVersion(
17398
17398
  mergedGraph,
17399
17399
  baselineVersion,
17400
17400
  storedSchema
@@ -22052,7 +22052,7 @@ function createHistoryStoreBackendProjection(backend) {
22052
22052
  // src/store/introspect.ts
22053
22053
  function introspectSchema(graph, context) {
22054
22054
  const extension = graph.extension;
22055
- const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkBX42F7IJ_cjs.extensionKindNames(extension);
22055
+ const { nodes: runtimeNodeNames, edges: runtimeEdgeNames } = chunkSSDLQPMY_cjs.extensionKindNames(extension);
22056
22056
  const deprecated = graph.deprecatedKinds;
22057
22057
  const kinds = [];
22058
22058
  for (const [name, registration] of Object.entries(graph.nodes)) {
@@ -22063,7 +22063,7 @@ function introspectSchema(graph, context) {
22063
22063
  description: reg.type.description,
22064
22064
  annotations: reg.type.annotations,
22065
22065
  deprecated: deprecated.has(name),
22066
- properties: chunkBX42F7IJ_cjs.serializeSchemaProperties(reg.type.schema),
22066
+ properties: chunkSSDLQPMY_cjs.serializeSchemaProperties(reg.type.schema),
22067
22067
  unique: (reg.unique ?? []).map((constraint) => ({
22068
22068
  name: constraint.name,
22069
22069
  fields: [...constraint.fields],
@@ -22084,17 +22084,17 @@ function introspectSchema(graph, context) {
22084
22084
  to: chunk5ICDVLI3_cjs.projectTargetKinds(reg.to),
22085
22085
  cardinality: reg.cardinality ?? "many",
22086
22086
  endpointExistence: reg.endpointExistence ?? "notDeleted",
22087
- properties: chunkBX42F7IJ_cjs.serializeSchemaProperties(edgeType.schema),
22087
+ properties: chunkSSDLQPMY_cjs.serializeSchemaProperties(edgeType.schema),
22088
22088
  annotations: edgeType.annotations,
22089
22089
  deprecated: deprecated.has(name)
22090
22090
  });
22091
22091
  }
22092
- const runtimeOntologyKeys = chunkBX42F7IJ_cjs.buildGraphExtensionOntologyKeySet(extension);
22092
+ const runtimeOntologyKeys = chunkSSDLQPMY_cjs.buildGraphExtensionOntologyKeySet(extension);
22093
22093
  const ontology = graph.ontology.map((relation) => ({
22094
22094
  metaEdge: relation.metaEdge.name,
22095
22095
  from: chunkICOTLZBV_cjs.getTypeName(relation.from),
22096
22096
  to: chunkICOTLZBV_cjs.getTypeName(relation.to),
22097
- origin: runtimeOntologyKeys.has(chunkBX42F7IJ_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
22097
+ origin: runtimeOntologyKeys.has(chunkSSDLQPMY_cjs.compileTimeOntologyKey(relation)) ? "runtime" : "compile-time"
22098
22098
  }));
22099
22099
  return {
22100
22100
  graphId: context.graphId,
@@ -22807,7 +22807,7 @@ async function computeIndexSignature(dialect, targetTableName, declaration) {
22807
22807
  const hashable = {
22808
22808
  dialect,
22809
22809
  targetTableName,
22810
- declaration: chunkBX42F7IJ_cjs.serializeIndexDeclaration(declaration)
22810
+ declaration: chunkSSDLQPMY_cjs.serializeIndexDeclaration(declaration)
22811
22811
  };
22812
22812
  const json = JSON.stringify(hashable, chunk5JOCIMQ3_cjs.sortedReplacer);
22813
22813
  return chunkZY4GXIVN_cjs.sha256Hex(json, 16);
@@ -22829,7 +22829,7 @@ async function materializeRemovals(context, options = {}) {
22829
22829
  await ensureFocusedStatusTable(backend, backend.ensureKindRemovalsTable);
22830
22830
  await reconcilePendingRemovals(context);
22831
22831
  const activeRow = await backend.getActiveSchema(graphId);
22832
- const activeSchema = activeRow === void 0 ? void 0 : chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
22832
+ const activeSchema = activeRow === void 0 ? void 0 : chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
22833
22833
  const reclaimedVectorFields = await reclaimRemovedVectorFieldTables(
22834
22834
  context,
22835
22835
  activeRow
@@ -22898,14 +22898,14 @@ async function reconcilePendingRemovals(context) {
22898
22898
  const reconciliations = [];
22899
22899
  const stopAtVersion = marker ?? 1;
22900
22900
  let currentRow = activeRow;
22901
- let currentSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
22901
+ let currentSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
22902
22902
  while (currentRow.version > stopAtVersion) {
22903
22903
  const priorRow = await backend.getSchemaVersion(
22904
22904
  graphId,
22905
22905
  currentRow.version - 1
22906
22906
  );
22907
22907
  if (priorRow === void 0) break;
22908
- const priorSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(priorRow.schema_doc);
22908
+ const priorSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(priorRow.schema_doc);
22909
22909
  for (const entity of ENTITY_KINDS) {
22910
22910
  const priorEntries = priorSchema[entity === "node" ? "nodes" : "edges"];
22911
22911
  const currentEntries = currentSchema[entity === "node" ? "nodes" : "edges"];
@@ -22970,7 +22970,7 @@ async function materializeOne2(row, ctx) {
22970
22970
  ctx.graphId,
22971
22971
  async (target) => {
22972
22972
  const activeRow = await target.getActiveSchema(ctx.graphId);
22973
- const activeSchema = activeRow === void 0 ? void 0 : chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
22973
+ const activeSchema = activeRow === void 0 ? void 0 : chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
22974
22974
  if (liveKindNamesFrom(activeSchema)[row.entity].has(row.kindName)) {
22975
22975
  return "skipped";
22976
22976
  }
@@ -23133,7 +23133,7 @@ async function resolveRemovedKindEmbeddingSlots(backend, row) {
23133
23133
  if (priorVersion < 1) return [];
23134
23134
  const priorRow = await backend.getSchemaVersion(row.graphId, priorVersion);
23135
23135
  if (priorRow === void 0) return [];
23136
- const priorSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(priorRow.schema_doc);
23136
+ const priorSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(priorRow.schema_doc);
23137
23137
  const slots = /* @__PURE__ */ new Map();
23138
23138
  for (const declaration of priorSchema.indexes ?? []) {
23139
23139
  if (declaration.entity === "vector" && declaration.kind === row.kindName) {
@@ -23170,14 +23170,14 @@ async function reclaimRemovedVectorFieldTables(context, activeRow) {
23170
23170
  let perBackend = reclaimCache.get(backend);
23171
23171
  const cached = perBackend?.get(cacheKey);
23172
23172
  if (cached !== void 0) return cached;
23173
- const activeSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
23173
+ const activeSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
23174
23174
  const activeVectorFields = vectorFieldKeysFrom(activeSchema);
23175
23175
  const survivingKinds = new Set(Object.keys(activeSchema.nodes));
23176
23176
  const historical = /* @__PURE__ */ new Map();
23177
23177
  for (let version = activeRow.version - 1; version >= 1; version -= 1) {
23178
23178
  const priorRow = await backend.getSchemaVersion(graphId, version);
23179
23179
  if (priorRow === void 0) continue;
23180
- const priorSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(priorRow.schema_doc);
23180
+ const priorSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(priorRow.schema_doc);
23181
23181
  for (const declaration of priorSchema.indexes ?? []) {
23182
23182
  if (declaration.entity !== "vector") continue;
23183
23183
  const key = vectorFieldKey(declaration.kind, declaration.fieldPath);
@@ -23215,7 +23215,7 @@ async function reclaimRemovedVectorFieldTables(context, activeRow) {
23215
23215
  async (target) => {
23216
23216
  const lockedActiveRow = await target.getActiveSchema(graphId);
23217
23217
  if (lockedActiveRow === void 0) return false;
23218
- const lockedActiveSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(
23218
+ const lockedActiveSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(
23219
23219
  lockedActiveRow.schema_doc
23220
23220
  );
23221
23221
  const lockedVectorFields = vectorFieldKeysFrom(lockedActiveSchema);
@@ -26456,7 +26456,7 @@ function syncStoreReplacementRef(ref, replacement) {
26456
26456
  ref.current = replacement;
26457
26457
  }
26458
26458
  async function commitEvolvedSchemaWhenRequiredKindsAreEmpty(backend, graph, currentVersion, classification, storedSchema) {
26459
- const result = await chunkBX42F7IJ_cjs.commitNewSchemaVersionIfKindsEmpty(
26459
+ const result = await chunkSSDLQPMY_cjs.commitNewSchemaVersionIfKindsEmpty(
26460
26460
  backend,
26461
26461
  graph,
26462
26462
  currentVersion,
@@ -26677,7 +26677,7 @@ var StoreImplementation = class _StoreImplementation {
26677
26677
  mapRecordedNodeRow: chunk76OB5RSH_cjs.createNodeRowMapper(rowMapperConfig),
26678
26678
  mapRecordedEdgeRow: chunk76OB5RSH_cjs.createEdgeRowMapper(rowMapperConfig)
26679
26679
  });
26680
- this.#registry = chunkBX42F7IJ_cjs.buildKindRegistry(graph);
26680
+ this.#registry = chunkSSDLQPMY_cjs.buildKindRegistry(graph);
26681
26681
  this.#hooks = options?.hooks ?? {};
26682
26682
  this.#defaultTraversalExpansion = options?.queryDefaults?.traversalExpansion ?? "inverse";
26683
26683
  this.#options = options;
@@ -26898,7 +26898,7 @@ var StoreImplementation = class _StoreImplementation {
26898
26898
  * fails leaves no half-published derived relation behind.
26899
26899
  */
26900
26900
  async identitySchemaPreflight(target, provisionDerivedRelations) {
26901
- await chunkBX42F7IJ_cjs.identitySchemaCommitPreflight(this.#identityContext(this.#backend), {
26901
+ await chunkSSDLQPMY_cjs.identitySchemaCommitPreflight(this.#identityContext(this.#backend), {
26902
26902
  enablement: false,
26903
26903
  provisionDerivedRelations
26904
26904
  })(target);
@@ -27461,7 +27461,7 @@ var StoreImplementation = class _StoreImplementation {
27461
27461
  * between "proceed" and "ask the user" *before* attempting a commit.
27462
27462
  */
27463
27463
  async schemaChanges() {
27464
- return chunkBX42F7IJ_cjs.getSchemaChanges(this.#backend, this.#graph);
27464
+ return chunkSSDLQPMY_cjs.getSchemaChanges(this.#backend, this.#graph);
27465
27465
  }
27466
27466
  /**
27467
27467
  * Whether committing this store's graph would require a schema migration —
@@ -27473,7 +27473,7 @@ var StoreImplementation = class _StoreImplementation {
27473
27473
  * through a user's request.
27474
27474
  */
27475
27475
  async requiresMigration() {
27476
- return chunkBX42F7IJ_cjs.requiresMigration(this.#backend, this.#graph);
27476
+ return chunkSSDLQPMY_cjs.requiresMigration(this.#backend, this.#graph);
27477
27477
  }
27478
27478
  /**
27479
27479
  * Node operations bound to this store instance.
@@ -29324,7 +29324,7 @@ var StoreImplementation = class _StoreImplementation {
29324
29324
  });
29325
29325
  }
29326
29326
  if (requirements.identityAffectedKinds.length > 0) {
29327
- const storage = await chunkBX42F7IJ_cjs.inspectAdoptedIdentityStorage(
29327
+ const storage = await chunkSSDLQPMY_cjs.inspectAdoptedIdentityStorage(
29328
29328
  adopted.backend,
29329
29329
  this.#sqlSchema(),
29330
29330
  {
@@ -29381,7 +29381,7 @@ var StoreImplementation = class _StoreImplementation {
29381
29381
  }
29382
29382
  );
29383
29383
  }
29384
- const storedSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
29384
+ const storedSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
29385
29385
  this.#evolutionPlanningSnapshot = {
29386
29386
  activeRow,
29387
29387
  storedSchema,
@@ -29441,7 +29441,7 @@ var StoreImplementation = class _StoreImplementation {
29441
29441
  return this;
29442
29442
  }
29443
29443
  return this.#cloneWithGraph(
29444
- this.#catchUpToStored(chunkBX42F7IJ_cjs.parseSerializedSchema(active.schema_doc)),
29444
+ this.#catchUpToStored(chunkSSDLQPMY_cjs.parseSerializedSchema(active.schema_doc)),
29445
29445
  options?.ref,
29446
29446
  schemaMetadataFromRow(active)
29447
29447
  );
@@ -29497,7 +29497,7 @@ var StoreImplementation = class _StoreImplementation {
29497
29497
  */
29498
29498
  async evolve(extension, options) {
29499
29499
  const { activeRow, storedSchema, baseline } = await this.#loadCaughtUp("evolve");
29500
- const merged = chunkBX42F7IJ_cjs.mergeGraphExtension(baseline, extension);
29500
+ const merged = chunkSSDLQPMY_cjs.mergeGraphExtension(baseline, extension);
29501
29501
  if (merged === baseline) {
29502
29502
  if (baseline === this.#graph) {
29503
29503
  syncStoreReplacementRef(options?.ref, this);
@@ -29526,7 +29526,7 @@ var StoreImplementation = class _StoreImplementation {
29526
29526
  );
29527
29527
  }
29528
29528
  const identityCandidate = merged.identity === void 0 ? void 0 : this.#cloneWithGraph(merged, void 0);
29529
- const identityProvisioning = identityCandidate === void 0 ? void 0 : await chunkBX42F7IJ_cjs.ensureIdentitySchemaStorage(
29529
+ const identityProvisioning = identityCandidate === void 0 ? void 0 : await chunkSSDLQPMY_cjs.ensureIdentitySchemaStorage(
29530
29530
  this.#baseBackend,
29531
29531
  this.#sqlSchema(),
29532
29532
  {
@@ -29535,7 +29535,7 @@ var StoreImplementation = class _StoreImplementation {
29535
29535
  // The evolved graph's registry — the one the candidate's own
29536
29536
  // preflight rebuilds through, so the predicate and the fill agree
29537
29537
  // on which assertions count.
29538
- registry: chunkBX42F7IJ_cjs.buildKindRegistry(merged)
29538
+ registry: chunkSSDLQPMY_cjs.buildKindRegistry(merged)
29539
29539
  }
29540
29540
  );
29541
29541
  const committed = identityCandidate === void 0 ? classification.requireEmpty.length > 0 ? await commitEvolvedSchemaWhenRequiredKindsAreEmpty(
@@ -29544,12 +29544,12 @@ var StoreImplementation = class _StoreImplementation {
29544
29544
  activeRow.version,
29545
29545
  classification,
29546
29546
  storedSchema
29547
- ) : await chunkBX42F7IJ_cjs.commitNewSchemaVersion(
29547
+ ) : await chunkSSDLQPMY_cjs.commitNewSchemaVersion(
29548
29548
  this.#backend,
29549
29549
  merged,
29550
29550
  activeRow.version,
29551
29551
  storedSchema
29552
- ) : await chunkBX42F7IJ_cjs.commitNewSchemaVersionWithPreflight(
29552
+ ) : await chunkSSDLQPMY_cjs.commitNewSchemaVersionWithPreflight(
29553
29553
  this.#backend,
29554
29554
  merged,
29555
29555
  activeRow.version,
@@ -29935,8 +29935,8 @@ var StoreImplementation = class _StoreImplementation {
29935
29935
  */
29936
29936
  async verifyConstraintFences() {
29937
29937
  const activeRow = await this.#baseBackend.getActiveSchema(this.graphId);
29938
- const graph = activeRow === void 0 ? this.#graph : this.#catchUpToStored(chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc));
29939
- const registry = graph === this.#graph ? this.#registry : chunkBX42F7IJ_cjs.buildKindRegistry(graph);
29938
+ const graph = activeRow === void 0 ? this.#graph : this.#catchUpToStored(chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc));
29939
+ const registry = graph === this.#graph ? this.#registry : chunkSSDLQPMY_cjs.buildKindRegistry(graph);
29940
29940
  return verifyConstraintFences({
29941
29941
  graph,
29942
29942
  registry,
@@ -30195,7 +30195,7 @@ var StoreImplementation = class _StoreImplementation {
30195
30195
  */
30196
30196
  async removeKinds(names, options) {
30197
30197
  const { activeRow, storedSchema, baseline } = await this.#loadCaughtUp("remove");
30198
- const plan = chunkBX42F7IJ_cjs.planRemovals(baseline, names);
30198
+ const plan = chunkSSDLQPMY_cjs.planRemovals(baseline, names);
30199
30199
  if (plan.removedNodeKinds.length === 0 && plan.removedEdgeKinds.length === 0) {
30200
30200
  if (baseline === this.#graph) {
30201
30201
  syncStoreReplacementRef(options?.ref, this);
@@ -30207,19 +30207,19 @@ var StoreImplementation = class _StoreImplementation {
30207
30207
  schemaMetadataFromRow(activeRow)
30208
30208
  );
30209
30209
  }
30210
- const compileTimeGraph = chunkBX42F7IJ_cjs.stripGraphExtension(this.#graph);
30211
- const merged = plan.document === void 0 ? compileTimeGraph : chunkBX42F7IJ_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
30212
- const finalGraph = chunkBX42F7IJ_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
30210
+ const compileTimeGraph = chunkSSDLQPMY_cjs.stripGraphExtension(this.#graph);
30211
+ const merged = plan.document === void 0 ? compileTimeGraph : chunkSSDLQPMY_cjs.mergeGraphExtension(compileTimeGraph, plan.document);
30212
+ const finalGraph = chunkSSDLQPMY_cjs.applyDeprecatedKinds(merged, baseline.deprecatedKinds);
30213
30213
  const identityCascade = await this.#identityRemovalPreflight(
30214
30214
  finalGraph,
30215
30215
  plan.removedNodeKinds
30216
30216
  );
30217
- const committedRow = identityCascade === void 0 ? await chunkBX42F7IJ_cjs.commitNewSchemaVersion(
30217
+ const committedRow = identityCascade === void 0 ? await chunkSSDLQPMY_cjs.commitNewSchemaVersion(
30218
30218
  this.#backend,
30219
30219
  finalGraph,
30220
30220
  activeRow.version,
30221
30221
  storedSchema
30222
- ) : await chunkBX42F7IJ_cjs.commitNewSchemaVersionWithPreflight(
30222
+ ) : await chunkSSDLQPMY_cjs.commitNewSchemaVersionWithPreflight(
30223
30223
  this.#backend,
30224
30224
  finalGraph,
30225
30225
  activeRow.version,
@@ -30278,7 +30278,7 @@ var StoreImplementation = class _StoreImplementation {
30278
30278
  async #identityRemovalPreflight(finalGraph, removedNodeKinds) {
30279
30279
  if (removedNodeKinds.length === 0) return void 0;
30280
30280
  const repairClosure = finalGraph.identity !== void 0;
30281
- if (!repairClosure && !await chunkBX42F7IJ_cjs.identityKindCascadeNeeded(
30281
+ if (!repairClosure && !await chunkSSDLQPMY_cjs.identityKindCascadeNeeded(
30282
30282
  this.#backend,
30283
30283
  this.#sqlSchema(),
30284
30284
  this.graphId,
@@ -30339,8 +30339,8 @@ var StoreImplementation = class _StoreImplementation {
30339
30339
  schemaMetadataFromRow(activeRow)
30340
30340
  );
30341
30341
  }
30342
- const merged = chunkBX42F7IJ_cjs.applyDeprecatedKinds(baseline, nextSet);
30343
- const result = await chunkBX42F7IJ_cjs.ensureSchema(this.#backend, merged, {
30342
+ const merged = chunkSSDLQPMY_cjs.applyDeprecatedKinds(baseline, nextSet);
30343
+ const result = await chunkSSDLQPMY_cjs.ensureSchema(this.#backend, merged, {
30344
30344
  preloaded: { activeRow, storedSchema },
30345
30345
  autoMigrate: true
30346
30346
  });
@@ -30348,9 +30348,9 @@ var StoreImplementation = class _StoreImplementation {
30348
30348
  return this.#cloneWithGraph(merged, options?.ref, metadata);
30349
30349
  }
30350
30350
  #catchUpToStored(storedSchema) {
30351
- const compileTimeGraph = chunkBX42F7IJ_cjs.stripGraphExtension(this.#graph);
30352
- const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunkBX42F7IJ_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
30353
- return chunkBX42F7IJ_cjs.applyDeprecatedKinds(
30351
+ const compileTimeGraph = chunkSSDLQPMY_cjs.stripGraphExtension(this.#graph);
30352
+ const withGraphExtension = storedSchema.extension === void 0 ? compileTimeGraph : chunkSSDLQPMY_cjs.mergeGraphExtension(compileTimeGraph, storedSchema.extension);
30353
+ return chunkSSDLQPMY_cjs.applyDeprecatedKinds(
30354
30354
  withGraphExtension,
30355
30355
  storedSchema.deprecatedKinds
30356
30356
  );
@@ -30368,7 +30368,7 @@ var StoreImplementation = class _StoreImplementation {
30368
30368
  * serializes the actual commit.
30369
30369
  */
30370
30370
  async #loadCaughtUp(verb) {
30371
- const activeRow = await chunkBX42F7IJ_cjs.loadActiveSchemaWithBootstrap(
30371
+ const activeRow = await chunkSSDLQPMY_cjs.loadActiveSchemaWithBootstrap(
30372
30372
  this.#backend,
30373
30373
  this.graphId
30374
30374
  );
@@ -30379,7 +30379,7 @@ var StoreImplementation = class _StoreImplementation {
30379
30379
  { code }
30380
30380
  );
30381
30381
  }
30382
- const storedSchema = chunkBX42F7IJ_cjs.parseSerializedSchema(activeRow.schema_doc);
30382
+ const storedSchema = chunkSSDLQPMY_cjs.parseSerializedSchema(activeRow.schema_doc);
30383
30383
  const baseline = this.#catchUpToStored(storedSchema);
30384
30384
  return { activeRow, storedSchema, baseline };
30385
30385
  }
@@ -30981,7 +30981,7 @@ var IDENTITY_GATE_CODES = {
30981
30981
  };
30982
30982
  async function ensureSchemaWithIdentityPrecedence(backend, graph, options, gate) {
30983
30983
  try {
30984
- return await chunkBX42F7IJ_cjs.ensureSchema(backend, graph, options);
30984
+ return await chunkSSDLQPMY_cjs.ensureSchema(backend, graph, options);
30985
30985
  } catch (error) {
30986
30986
  if (gate === void 0 || !isIdentityOnlyBreakingChange(error)) throw error;
30987
30987
  throw identityMigrationRequiredError(graph.id, gate, {
@@ -31029,20 +31029,20 @@ async function prepareStoreWithSchema(graph, backend, options) {
31029
31029
  graph: merged,
31030
31030
  activeRow,
31031
31031
  storedSchema
31032
- } = await chunkBX42F7IJ_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
31032
+ } = await chunkSSDLQPMY_cjs.loadAndMergeGraphExtensionDocument(backend, graph);
31033
31033
  const identityProfileChanged = activeRow !== void 0 && storedSchema?.identity?.sameIdAcrossKinds !== merged.identity?.sameIdAcrossKinds;
31034
31034
  const identityInitialization = activeRow === void 0 && merged.identity !== void 0;
31035
31035
  const identityEnablement = identityInitialization || identityProfileChanged && storedSchema?.identity === void 0 && merged.identity !== void 0;
31036
31036
  const identitySemanticsChanged = identityProfileChanged || activeRow !== void 0 && storedSchema !== void 0 && merged.identity !== void 0 && identityOntologyChanged(
31037
31037
  storedSchema,
31038
- chunkBX42F7IJ_cjs.serializeSchema(merged, activeRow.version + 1)
31038
+ chunkSSDLQPMY_cjs.serializeSchema(merged, activeRow.version + 1)
31039
31039
  );
31040
31040
  const identityGate = identitySemanticsChanged ? identityEnablement ? "enablement" : identityProfileChanged ? "profile" : "ontology" : void 0;
31041
31041
  const identityProfile = merged.identity;
31042
31042
  if (identityProfile !== void 0) {
31043
31043
  const resolvedIdentitySchema = options?.schema === void 0 ? chunk6JRVV2SS_cjs.createSqlSchema(backend.tableNames) : chunk6JRVV2SS_cjs.requireSqlSchema(options.schema, "store schema");
31044
- const identityRegistry = chunkBX42F7IJ_cjs.buildKindRegistry(merged);
31045
- await chunkBX42F7IJ_cjs.ensureIdentitySchemaStorage(backend, resolvedIdentitySchema, {
31044
+ const identityRegistry = chunkSSDLQPMY_cjs.buildKindRegistry(merged);
31045
+ await chunkSSDLQPMY_cjs.ensureIdentitySchemaStorage(backend, resolvedIdentitySchema, {
31046
31046
  graphId: merged.id,
31047
31047
  enablement: identityEnablement,
31048
31048
  registry: identityRegistry,
@@ -31172,7 +31172,7 @@ async function prepareVerifiedStore(graph, backend, options) {
31172
31172
  graph: merged,
31173
31173
  activeRow,
31174
31174
  result
31175
- } = await chunkBX42F7IJ_cjs.loadAndVerifyGraph(backend, graph);
31175
+ } = await chunkSSDLQPMY_cjs.loadAndVerifyGraph(backend, graph);
31176
31176
  await assertHistorySchemaOnOpen(backend, merged, options);
31177
31177
  return {
31178
31178
  graph: merged,
@@ -31237,5 +31237,5 @@ exports.min = min;
31237
31237
  exports.offsetFragment = offsetFragment;
31238
31238
  exports.orderByFragment = orderByFragment;
31239
31239
  exports.sum = sum;
31240
- //# sourceMappingURL=chunk-Y4X6ODVY.cjs.map
31241
- //# sourceMappingURL=chunk-Y4X6ODVY.cjs.map
31240
+ //# sourceMappingURL=chunk-FS2GVO2T.cjs.map
31241
+ //# sourceMappingURL=chunk-FS2GVO2T.cjs.map