@nicia-ai/typegraph 0.2.0 → 0.3.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.
- package/README.md +23 -0
- package/dist/{ast-BVyihVbP.d.cts → ast-CXFx6bF6.d.ts} +45 -165
- package/dist/{ast-BVyihVbP.d.ts → ast-D-3bOanX.d.cts} +45 -165
- package/dist/backend/drizzle/index.cjs +20 -20
- package/dist/backend/drizzle/index.d.cts +6 -5
- package/dist/backend/drizzle/index.d.ts +6 -5
- package/dist/backend/drizzle/index.js +8 -8
- package/dist/backend/drizzle/postgres.cjs +9 -9
- package/dist/backend/drizzle/postgres.d.cts +9 -11
- package/dist/backend/drizzle/postgres.d.ts +9 -11
- package/dist/backend/drizzle/postgres.js +6 -6
- package/dist/backend/drizzle/schema/postgres.cjs +10 -10
- package/dist/backend/drizzle/schema/postgres.d.cts +6 -5
- package/dist/backend/drizzle/schema/postgres.d.ts +6 -5
- package/dist/backend/drizzle/schema/postgres.js +3 -3
- package/dist/backend/drizzle/schema/sqlite.cjs +10 -10
- package/dist/backend/drizzle/schema/sqlite.d.cts +6 -5
- package/dist/backend/drizzle/schema/sqlite.d.ts +6 -5
- package/dist/backend/drizzle/schema/sqlite.js +3 -3
- package/dist/backend/drizzle/sqlite.cjs +9 -9
- package/dist/backend/drizzle/sqlite.d.cts +17 -18
- package/dist/backend/drizzle/sqlite.d.ts +17 -18
- package/dist/backend/drizzle/sqlite.js +6 -6
- package/dist/backend/postgres/index.cjs +21 -17
- package/dist/backend/postgres/index.d.cts +8 -7
- package/dist/backend/postgres/index.d.ts +8 -7
- package/dist/backend/postgres/index.js +8 -8
- package/dist/backend/sqlite/index.cjs +27 -21
- package/dist/backend/sqlite/index.cjs.map +1 -1
- package/dist/backend/sqlite/index.d.cts +7 -6
- package/dist/backend/sqlite/index.d.ts +7 -6
- package/dist/backend/sqlite/index.js +18 -12
- package/dist/backend/sqlite/index.js.map +1 -1
- package/dist/{chunk-YM5AL65Y.cjs → chunk-2WVFEIHR.cjs} +29 -3
- package/dist/chunk-2WVFEIHR.cjs.map +1 -0
- package/dist/{chunk-4PIEL2VO.js → chunk-3PURVEA4.js} +36 -5
- package/dist/chunk-3PURVEA4.js.map +1 -0
- package/dist/chunk-4HARSV2G.js +1448 -0
- package/dist/chunk-4HARSV2G.js.map +1 -0
- package/dist/{chunk-IIAT36MI.js → chunk-54WJF3DW.js} +29 -3
- package/dist/chunk-54WJF3DW.js.map +1 -0
- package/dist/chunk-CMHFS34N.cjs +390 -0
- package/dist/chunk-CMHFS34N.cjs.map +1 -0
- package/dist/chunk-DD6ONEBN.cjs +1264 -0
- package/dist/chunk-DD6ONEBN.cjs.map +1 -0
- package/dist/chunk-F2BZSEFE.js +388 -0
- package/dist/chunk-F2BZSEFE.js.map +1 -0
- package/dist/{chunk-DDM2FZRJ.cjs → chunk-JQDWEX6V.cjs} +24 -24
- package/dist/{chunk-DDM2FZRJ.cjs.map → chunk-JQDWEX6V.cjs.map} +1 -1
- package/dist/chunk-NP4G4ZKM.js +1228 -0
- package/dist/chunk-NP4G4ZKM.js.map +1 -0
- package/dist/{chunk-UJAGXJDG.cjs → chunk-NU2XNMVI.cjs} +38 -7
- package/dist/chunk-NU2XNMVI.cjs.map +1 -0
- package/dist/{chunk-JKTO7TW3.js → chunk-O5XPCJLF.js} +25 -3
- package/dist/chunk-O5XPCJLF.js.map +1 -0
- package/dist/{chunk-2QHQ2C4P.js → chunk-OGGLFYFA.js} +36 -5
- package/dist/chunk-OGGLFYFA.js.map +1 -0
- package/dist/{chunk-SV5H3XM5.cjs → chunk-OYL2SGBD.cjs} +26 -2
- package/dist/chunk-OYL2SGBD.cjs.map +1 -0
- package/dist/chunk-SFY2PPOY.cjs +1469 -0
- package/dist/chunk-SFY2PPOY.cjs.map +1 -0
- package/dist/{chunk-JDAET5LO.js → chunk-SMLIWLS7.js} +9 -9
- package/dist/chunk-SMLIWLS7.js.map +1 -0
- package/dist/{chunk-VXRVGFCI.js → chunk-U3452TEU.js} +17 -17
- package/dist/{chunk-VXRVGFCI.js.map → chunk-U3452TEU.js.map} +1 -1
- package/dist/{chunk-MNO33ASC.cjs → chunk-UYMT4LO2.cjs} +9 -8
- package/dist/chunk-UYMT4LO2.cjs.map +1 -0
- package/dist/chunk-V7CS2MDB.cjs +289 -0
- package/dist/chunk-V7CS2MDB.cjs.map +1 -0
- package/dist/chunk-WE5BKYNB.js +287 -0
- package/dist/chunk-WE5BKYNB.js.map +1 -0
- package/dist/{chunk-L642L24T.js → chunk-XDTYTNYL.js} +14 -21
- package/dist/chunk-XDTYTNYL.js.map +1 -0
- package/dist/{chunk-N4AOJ3VF.cjs → chunk-XZL6MCZJ.cjs} +38 -7
- package/dist/chunk-XZL6MCZJ.cjs.map +1 -0
- package/dist/{chunk-DBFCKELK.cjs → chunk-ZJHQZZT2.cjs} +18 -27
- package/dist/chunk-ZJHQZZT2.cjs.map +1 -0
- package/dist/index-Dkicw49A.d.cts +373 -0
- package/dist/index-Dkicw49A.d.ts +373 -0
- package/dist/index.cjs +5915 -3377
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -664
- package/dist/index.d.ts +24 -664
- package/dist/index.js +5781 -3223
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.d.cts +5 -4
- package/dist/indexes/index.d.ts +5 -4
- package/dist/indexes/index.js +2 -2
- package/dist/interchange/index.cjs +9 -9
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -3
- package/dist/interchange/index.d.ts +5 -3
- package/dist/interchange/index.js +8 -8
- package/dist/interchange/index.js.map +1 -1
- package/dist/manager-Jc5Btay9.d.cts +493 -0
- package/dist/manager-e9LXthrx.d.ts +493 -0
- package/dist/profiler/index.cjs +2 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +9 -161
- package/dist/profiler/index.d.ts +9 -161
- package/dist/profiler/index.js +4 -4
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +145 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.cts +237 -0
- package/dist/schema/index.d.ts +237 -0
- package/dist/schema/index.js +72 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/{store-BPhjw5S8.d.ts → store-DM3Tk3Pw.d.ts} +874 -1283
- package/dist/{store-DNOOQEm8.d.cts → store-nbBybLWP.d.cts} +874 -1283
- package/dist/{test-helpers-BjyRYJZX.d.ts → test-helpers-CIq1Hhj1.d.ts} +5 -1
- package/dist/{test-helpers-NoQXhleQ.d.cts → test-helpers-DPRFVky4.d.cts} +5 -1
- package/dist/{types-D_3mEv2y.d.ts → types-BL1GyVku.d.cts} +2 -2
- package/dist/{types-DsRfx0yk.d.ts → types-Cdbi4hcx.d.ts} +228 -4
- package/dist/{types-BrSfFSpW.d.cts → types-DCGa53O2.d.ts} +2 -2
- package/dist/{types-aapj0GLz.d.cts → types-DDP0MGBF.d.cts} +228 -4
- package/dist/{types-CX4cLd7M.d.ts → types-DHRsi6j9.d.cts} +4 -3
- package/dist/types-DTJEu_-h.d.cts +158 -0
- package/dist/types-DTJEu_-h.d.ts +158 -0
- package/dist/{types-a5rAxC92.d.cts → types-ZT5mlism.d.ts} +4 -3
- package/package.json +17 -2
- package/dist/chunk-2FURVVAX.cjs +0 -350
- package/dist/chunk-2FURVVAX.cjs.map +0 -1
- package/dist/chunk-2QHQ2C4P.js.map +0 -1
- package/dist/chunk-4PIEL2VO.js.map +0 -1
- package/dist/chunk-DBFCKELK.cjs.map +0 -1
- package/dist/chunk-H7THXVH6.cjs +0 -314
- package/dist/chunk-H7THXVH6.cjs.map +0 -1
- package/dist/chunk-HXAPXPZH.cjs +0 -680
- package/dist/chunk-HXAPXPZH.cjs.map +0 -1
- package/dist/chunk-IIAT36MI.js.map +0 -1
- package/dist/chunk-JDAET5LO.js.map +0 -1
- package/dist/chunk-JKTO7TW3.js.map +0 -1
- package/dist/chunk-L642L24T.js.map +0 -1
- package/dist/chunk-MNO33ASC.cjs.map +0 -1
- package/dist/chunk-N4AOJ3VF.cjs.map +0 -1
- package/dist/chunk-QB3WBMDT.js +0 -646
- package/dist/chunk-QB3WBMDT.js.map +0 -1
- package/dist/chunk-SV5H3XM5.cjs.map +0 -1
- package/dist/chunk-UJAGXJDG.cjs.map +0 -1
- package/dist/chunk-X4EVMBON.js +0 -312
- package/dist/chunk-X4EVMBON.js.map +0 -1
- package/dist/chunk-XZL4NLV6.js +0 -348
- package/dist/chunk-XZL4NLV6.js.map +0 -1
- package/dist/chunk-YM5AL65Y.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ontology/types.ts","../src/errors/validation.ts","../src/schema/migration.ts","../src/ontology/closures.ts","../src/ontology/constants.ts","../src/registry/kind-registry.ts","../src/schema/serializer.ts","../src/schema/manager.ts"],"names":["index"],"mappings":";;;;;AAOO,IAAM,eAAA,GAAkB;AA+ExB,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,YAAY,SAAA,EAAiD;AAC3E,EAAA,IAAI,OAAO,cAAc,QAAA,EAAU;AACjC,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA,CAAU,IAAA;AACnB;;;AC3DA,SAAS,4BAA4B,KAAA,EAAoC;AACvE,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAAW;AAAA,IAClC,IAAA,EAAM,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA;AAAA,IACzB,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,MAAM,KAAA,CAAM;AAAA,GACd,CAAE,CAAA;AACJ;AAKA,SAAS,oBAAoB,OAAA,EAAoC;AAC/D,EAAA,I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,EAAA,IAAI,CAAC,KAAK,OAAO,MAAA;AACjB,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,UAAU,CAAA;AAClC;AASA,eAAsB,mBAAA,CACpB,SACA,OAAA,EACkB;AAClB,EAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,eAAA,CAAgB,OAAO,CAAA;AACjD,EAAA,OAAO,GAAA,KAAQ,MAAA;AACjB;AASA,eAAsB,gBAAA,CACpB,SACA,KAAA,EACiC;AACjC,EAAA,MAAM,YAAA,GAAe,MAAM,OAAA,CAAQ,eAAA,CAAgB,MAAM,EAAE,CAAA;AAC3D,EAAA,IAAI,CAAC,cAAc,OAAO,MAAA;AAE1B,EAAA,MAAM,YAAA,GAAe,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,UAAU,CAAA;AACvD,EAAA,MAAM,aAAA,GAAgB,eAAA,CAAgB,KAAA,EAAO,YAAA,CAAa,UAAU,CAAC,CAAA;AAErE,EAAA,OAAO,iBAAA,CAAkB,cAAc,aAAa,CAAA;AACtD","file":"chunk-NP4G4ZKM.js","sourcesContent":["import { type EdgeType, type NodeType } from \"../core/types\";\n\n// ============================================================\n// Brand Key\n// ============================================================\n\n/** Brand key for MetaEdge */\nexport const META_EDGE_BRAND = \"__metaEdge\" as const;\n\n// ============================================================\n// Inference Types\n// ============================================================\n\n/**\n * How a meta-edge affects queries and validation.\n */\nexport type InferenceType =\n | \"subsumption\" // Query for X includes instances of subclasses\n | \"hierarchy\" // Enables broader/narrower traversal\n | \"substitution\" // Can substitute equivalent types\n | \"constraint\" // Validation rules\n | \"composition\" // Part-whole navigation\n | \"association\" // Discovery/recommendation\n | \"none\"; // No automatic inference\n\n// ============================================================\n// Meta-Edge Properties\n// ============================================================\n\n/**\n * Properties of a meta-edge.\n */\nexport type MetaEdgeProperties = Readonly<{\n transitive: boolean; // A→B, B→C implies A→C\n symmetric: boolean; // A→B implies B→A\n reflexive: boolean; // A→A is always true\n inverse: string | undefined; // Name of inverse meta-edge\n inference: InferenceType; // How this affects queries\n description: string | undefined;\n}>;\n\n// ============================================================\n// Meta-Edge Type\n// ============================================================\n\n/**\n * A meta-edge definition.\n *\n * Meta-edges represent type-level relationships (between kinds),\n * not instance-level relationships (between nodes).\n */\nexport type MetaEdge<K extends string = string> = Readonly<{\n [META_EDGE_BRAND]: true;\n name: K;\n properties: MetaEdgeProperties;\n}>;\n\n// ============================================================\n// Ontology Relation\n// ============================================================\n\n/**\n * A relation in the ontology (instance of meta-edge between types).\n *\n * @example\n * ```typescript\n * // Podcast subClassOf Media\n * subClassOf(Podcast, Media)\n *\n * // Person equivalentTo schema:Person\n * equivalentTo(Person, \"https://schema.org/Person\")\n * ```\n */\nexport type OntologyRelation = Readonly<{\n metaEdge: MetaEdge;\n from: NodeType | EdgeType | string; // string for external IRIs\n to: NodeType | EdgeType | string;\n}>;\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is a MetaEdge.\n */\nexport function isMetaEdge(value: unknown): value is MetaEdge {\n return (\n typeof value === \"object\" &&\n value !== null &&\n META_EDGE_BRAND in value &&\n (value as Record<string, unknown>)[META_EDGE_BRAND] === true\n );\n}\n\n/**\n * Gets the type name from a NodeType, EdgeType, or IRI string.\n */\nexport function getTypeName(typeOrIri: NodeType | EdgeType | string): string {\n if (typeof typeOrIri === \"string\") {\n return typeOrIri;\n }\n return typeOrIri.kind;\n}\n","/**\n * Contextual Validation Utilities\n *\n * Provides Zod validation wrappers that include full context about\n * which entity (node/edge) and operation (create/update) failed.\n *\n * @example\n * ```typescript\n * const props = validateNodeProps(schema, input, {\n * kind: \"Person\",\n * operation: \"create\",\n * });\n * ```\n */\n\nimport { type ZodError, type ZodType } from \"zod\";\n\nimport { ValidationError, type ValidationIssue } from \"./index\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Context for validation operations.\n */\nexport type ValidationContext = Readonly<{\n /** Type of entity being validated */\n entityType: \"node\" | \"edge\";\n /** Kind/type name of the entity */\n kind: string;\n /** Operation being performed */\n operation: \"create\" | \"update\";\n /** Entity ID (for updates) */\n id?: string;\n}>;\n\n// ============================================================\n// Validation Functions\n// ============================================================\n\n/**\n * Converts Zod issues to ValidationIssue format.\n */\nfunction zodIssuesToValidationIssues(error: ZodError): ValidationIssue[] {\n return error.issues.map((issue) => ({\n path: issue.path.join(\".\"),\n message: issue.message,\n code: issue.code,\n }));\n}\n\n/**\n * Builds a descriptive location string for error messages.\n */\nfunction buildLocationString(context: ValidationContext): string {\n if (context.id) {\n return `${context.kind}/${context.id}`;\n }\n return `new ${context.kind}`;\n}\n\n/**\n * Validates props with full context for error messages.\n *\n * @param schema - Zod schema to validate against\n * @param props - Properties to validate\n * @param context - Context about the entity and operation\n * @returns Validated and transformed props\n * @throws ValidationError with full context if validation fails\n *\n * @example\n * ```typescript\n * const validatedProps = validateProps(personSchema, input, {\n * entityType: \"node\",\n * kind: \"Person\",\n * operation: \"create\",\n * });\n * ```\n */\nexport function validateProps<T>(\n schema: ZodType<T>,\n props: unknown,\n context: ValidationContext,\n): T {\n const result = schema.safeParse(props);\n\n if (result.success) {\n return result.data;\n }\n\n const issues = zodIssuesToValidationIssues(result.error);\n const location = buildLocationString(context);\n\n throw new ValidationError(\n `Invalid ${context.entityType} props for ${location}: ${result.error.message}`,\n {\n entityType: context.entityType,\n kind: context.kind,\n operation: context.operation,\n ...(context.id !== undefined && { id: context.id }),\n issues,\n },\n { cause: result.error },\n );\n}\n\n/**\n * Validates node props with full context.\n *\n * Convenience wrapper around validateProps for node operations.\n *\n * @example\n * ```typescript\n * const props = validateNodeProps(schema, input, {\n * kind: \"Person\",\n * operation: \"create\",\n * });\n * ```\n */\nexport function validateNodeProps<T>(\n schema: ZodType<T>,\n props: unknown,\n context: Readonly<{\n kind: string;\n operation: \"create\" | \"update\";\n id?: string;\n }>,\n): T {\n return validateProps(schema, props, {\n entityType: \"node\",\n ...context,\n });\n}\n\n/**\n * Validates edge props with full context.\n *\n * Convenience wrapper around validateProps for edge operations.\n *\n * @example\n * ```typescript\n * const props = validateEdgeProps(schema, input, {\n * kind: \"worksAt\",\n * operation: \"create\",\n * });\n * ```\n */\nexport function validateEdgeProps<T>(\n schema: ZodType<T>,\n props: unknown,\n context: Readonly<{\n kind: string;\n operation: \"create\" | \"update\";\n id?: string;\n }>,\n): T {\n return validateProps(schema, props, {\n entityType: \"edge\",\n ...context,\n });\n}\n\n/**\n * Wraps a Zod error with TypeGraph context.\n *\n * Use this when you've already caught a ZodError and want to\n * convert it to a ValidationError with context.\n *\n * @example\n * ```typescript\n * try {\n * schema.parse(input);\n * } catch (error) {\n * if (error instanceof ZodError) {\n * throw wrapZodError(error, {\n * entityType: \"node\",\n * kind: \"Person\",\n * operation: \"create\",\n * });\n * }\n * throw error;\n * }\n * ```\n */\nexport function wrapZodError(\n error: ZodError,\n context: ValidationContext,\n): ValidationError {\n const issues = zodIssuesToValidationIssues(error);\n const location = buildLocationString(context);\n\n return new ValidationError(\n `Validation failed for ${context.entityType} ${location}: ${error.message}`,\n {\n entityType: context.entityType,\n kind: context.kind,\n operation: context.operation,\n ...(context.id !== undefined && { id: context.id }),\n issues,\n },\n { cause: error },\n );\n}\n\n/**\n * Creates a simple ValidationError without Zod context.\n *\n * Use this for custom validation rules that aren't part of a Zod schema.\n *\n * @example\n * ```typescript\n * if (startDate > endDate) {\n * throw createValidationError(\n * \"Start date must be before end date\",\n * [{ path: \"startDate\", message: \"Must be before endDate\" }],\n * { entityType: \"edge\", kind: \"employment\", operation: \"create\" }\n * );\n * }\n * ```\n */\nexport function createValidationError(\n message: string,\n issues: ValidationIssue[],\n context?: Partial<ValidationContext>,\n): ValidationError {\n return new ValidationError(message, {\n ...(context?.entityType !== undefined && {\n entityType: context.entityType,\n }),\n ...(context?.kind !== undefined && { kind: context.kind }),\n ...(context?.operation !== undefined && { operation: context.operation }),\n ...(context?.id !== undefined && { id: context.id }),\n issues,\n });\n}\n","/**\n * Schema migration utilities.\n *\n * Provides diff detection between schema versions to identify\n * what has changed and what migrations might be needed.\n */\nimport {\n type SerializedEdgeDef,\n type SerializedNodeDef,\n type SerializedOntology,\n type SerializedSchema,\n} from \"./types\";\n\n// ============================================================\n// Change Types\n// ============================================================\n\n/**\n * Types of changes that can occur in a schema.\n */\nexport type ChangeType = \"added\" | \"removed\" | \"modified\" | \"renamed\";\n\n/**\n * Severity of a change for migration purposes.\n */\nexport type ChangeSeverity =\n | \"safe\" // No data migration needed\n | \"warning\" // Might need attention\n | \"breaking\"; // Requires data migration\n\n// ============================================================\n// Node Changes\n// ============================================================\n\n/**\n * A change to a node definition.\n */\nexport type NodeChange = Readonly<{\n type: ChangeType;\n kind: string;\n severity: ChangeSeverity;\n details: string;\n before?: SerializedNodeDef | undefined;\n after?: SerializedNodeDef | undefined;\n}>;\n\n// ============================================================\n// Edge Changes\n// ============================================================\n\n/**\n * A change to an edge definition.\n */\nexport type EdgeChange = Readonly<{\n type: ChangeType;\n kind: string;\n severity: ChangeSeverity;\n details: string;\n before?: SerializedEdgeDef | undefined;\n after?: SerializedEdgeDef | undefined;\n}>;\n\n// ============================================================\n// Ontology Changes\n// ============================================================\n\n/**\n * A change to the ontology.\n */\nexport type OntologyChange = Readonly<{\n type: ChangeType;\n entity: \"metaEdge\" | \"relation\";\n name: string;\n severity: ChangeSeverity;\n details: string;\n}>;\n\n// ============================================================\n// Schema Diff\n// ============================================================\n\n/**\n * A complete diff between two schema versions.\n */\nexport type SchemaDiff = Readonly<{\n fromVersion: number;\n toVersion: number;\n\n /** Changes to node definitions */\n nodes: readonly NodeChange[];\n\n /** Changes to edge definitions */\n edges: readonly EdgeChange[];\n\n /** Changes to ontology */\n ontology: readonly OntologyChange[];\n\n /** Whether any breaking changes exist */\n hasBreakingChanges: boolean;\n\n /** Whether the change is backwards compatible (no breaking changes) */\n isBackwardsCompatible: boolean;\n\n /** Whether any changes exist at all */\n hasChanges: boolean;\n\n /** Summary of changes */\n summary: string;\n}>;\n\n// ============================================================\n// Diff Computation\n// ============================================================\n\n/**\n * Computes the diff between two schema versions.\n *\n * @param before - The previous schema version\n * @param after - The new schema version\n * @returns A diff describing all changes\n */\nexport function computeSchemaDiff(\n before: SerializedSchema,\n after: SerializedSchema,\n): SchemaDiff {\n const nodeChanges = diffNodes(before.nodes, after.nodes);\n const edgeChanges = diffEdges(before.edges, after.edges);\n const ontologyChanges = diffOntology(before.ontology, after.ontology);\n\n const allChanges = [...nodeChanges, ...edgeChanges, ...ontologyChanges];\n const hasBreakingChanges = allChanges.some(\n (change) => change.severity === \"breaking\",\n );\n const hasChanges = allChanges.length > 0;\n\n const summary = generateSummary(nodeChanges, edgeChanges, ontologyChanges);\n\n return {\n fromVersion: before.version,\n toVersion: after.version,\n nodes: nodeChanges,\n edges: edgeChanges,\n ontology: ontologyChanges,\n hasBreakingChanges,\n isBackwardsCompatible: !hasBreakingChanges,\n hasChanges,\n summary,\n };\n}\n\n// ============================================================\n// Node Diff\n// ============================================================\n\n/**\n * Computes changes between node definitions.\n */\nfunction diffNodes(\n before: Record<string, SerializedNodeDef>,\n after: Record<string, SerializedNodeDef>,\n): readonly NodeChange[] {\n const changes: NodeChange[] = [];\n const beforeNames = new Set(Object.keys(before));\n const afterNames = new Set(Object.keys(after));\n\n // Find removed nodes\n for (const name of beforeNames) {\n if (!afterNames.has(name)) {\n changes.push({\n type: \"removed\",\n kind: name,\n severity: \"breaking\",\n details: `Node kind \"${name}\" was removed`,\n before: before[name],\n });\n }\n }\n\n // Find added nodes\n for (const name of afterNames) {\n if (!beforeNames.has(name)) {\n changes.push({\n type: \"added\",\n kind: name,\n severity: \"safe\",\n details: `Node kind \"${name}\" was added`,\n after: after[name],\n });\n }\n }\n\n // Find modified nodes\n for (const name of beforeNames) {\n if (afterNames.has(name)) {\n const nodeBefore = before[name]!;\n const nodeAfter = after[name]!;\n const nodeChanges = diffNodeDef(name, nodeBefore, nodeAfter);\n changes.push(...nodeChanges);\n }\n }\n\n return changes;\n}\n\n/**\n * Computes changes to a single node definition.\n */\nfunction diffNodeDef(\n name: string,\n before: SerializedNodeDef,\n after: SerializedNodeDef,\n): readonly NodeChange[] {\n const changes: NodeChange[] = [];\n\n // Check property schema changes\n const propsBefore = JSON.stringify(before.properties);\n const propsAfter = JSON.stringify(after.properties);\n if (propsBefore !== propsAfter) {\n // Determine if properties were added or removed\n const beforeProps = before.properties.properties ?? {};\n const afterProps = after.properties.properties ?? {};\n const beforeRequired = new Set(before.properties.required);\n const afterRequired = new Set(after.properties.required);\n\n const addedProps = Object.keys(afterProps).filter(\n (p) => !(p in beforeProps),\n );\n const removedProps = Object.keys(beforeProps).filter(\n (p) => !(p in afterProps),\n );\n const newRequired = [...afterRequired].filter(\n (p) => !beforeRequired.has(p),\n );\n\n const { severity, details } = computePropertyChangeSeverity(\n name,\n removedProps,\n addedProps,\n newRequired,\n );\n\n changes.push({\n type: \"modified\",\n kind: name,\n severity,\n details,\n before,\n after,\n });\n }\n\n // Check onDelete behavior\n if (before.onDelete !== after.onDelete) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"warning\",\n details: `onDelete changed from \"${before.onDelete}\" to \"${after.onDelete}\" for \"${name}\"`,\n before,\n after,\n });\n }\n\n // Check unique constraints\n const constraintsBefore = JSON.stringify(before.uniqueConstraints);\n const constraintsAfter = JSON.stringify(after.uniqueConstraints);\n if (constraintsBefore !== constraintsAfter) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"warning\",\n details: `Unique constraints changed for \"${name}\"`,\n before,\n after,\n });\n }\n\n return changes;\n}\n\n/**\n * Computes the severity and details message for property changes.\n */\nfunction computePropertyChangeSeverity(\n name: string,\n removedProps: readonly string[],\n addedProps: readonly string[],\n newRequired: readonly string[],\n): { severity: ChangeSeverity; details: string } {\n if (removedProps.length > 0) {\n return {\n severity: \"breaking\",\n details: `Properties removed from \"${name}\": ${removedProps.join(\", \")}`,\n };\n }\n if (newRequired.length > 0) {\n return {\n severity: \"breaking\",\n details: `New required properties in \"${name}\": ${newRequired.join(\", \")}`,\n };\n }\n if (addedProps.length > 0) {\n return {\n severity: \"safe\",\n details: `Properties added to \"${name}\": ${addedProps.join(\", \")}`,\n };\n }\n return {\n severity: \"safe\",\n details: `Properties changed in \"${name}\"`,\n };\n}\n\n// ============================================================\n// Edge Diff\n// ============================================================\n\n/**\n * Computes changes between edge definitions.\n */\nfunction diffEdges(\n before: Record<string, SerializedEdgeDef>,\n after: Record<string, SerializedEdgeDef>,\n): readonly EdgeChange[] {\n const changes: EdgeChange[] = [];\n const beforeNames = new Set(Object.keys(before));\n const afterNames = new Set(Object.keys(after));\n\n // Find removed edges\n for (const name of beforeNames) {\n if (!afterNames.has(name)) {\n changes.push({\n type: \"removed\",\n kind: name,\n severity: \"breaking\",\n details: `Edge kind \"${name}\" was removed`,\n before: before[name],\n });\n }\n }\n\n // Find added edges\n for (const name of afterNames) {\n if (!beforeNames.has(name)) {\n changes.push({\n type: \"added\",\n kind: name,\n severity: \"safe\",\n details: `Edge kind \"${name}\" was added`,\n after: after[name],\n });\n }\n }\n\n // Find modified edges\n for (const name of beforeNames) {\n if (afterNames.has(name)) {\n const edgeBefore = before[name]!;\n const edgeAfter = after[name]!;\n const edgeChanges = diffEdgeDef(name, edgeBefore, edgeAfter);\n changes.push(...edgeChanges);\n }\n }\n\n return changes;\n}\n\n/**\n * Computes changes to a single edge definition.\n */\nfunction diffEdgeDef(\n name: string,\n before: SerializedEdgeDef,\n after: SerializedEdgeDef,\n): readonly EdgeChange[] {\n const changes: EdgeChange[] = [];\n\n // Check endpoint kinds\n const fromBefore = JSON.stringify(before.fromKinds);\n const fromAfter = JSON.stringify(after.fromKinds);\n if (fromBefore !== fromAfter) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"warning\",\n details: `fromKinds changed for \"${name}\"`,\n before,\n after,\n });\n }\n\n const toBefore = JSON.stringify(before.toKinds);\n const toAfter = JSON.stringify(after.toKinds);\n if (toBefore !== toAfter) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"warning\",\n details: `toKinds changed for \"${name}\"`,\n before,\n after,\n });\n }\n\n // Check cardinality\n if (before.cardinality !== after.cardinality) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"warning\",\n details: `Cardinality changed from \"${before.cardinality}\" to \"${after.cardinality}\" for \"${name}\"`,\n before,\n after,\n });\n }\n\n // Check properties\n const propsBefore = JSON.stringify(before.properties);\n const propsAfter = JSON.stringify(after.properties);\n if (propsBefore !== propsAfter) {\n changes.push({\n type: \"modified\",\n kind: name,\n severity: \"safe\",\n details: `Properties changed for \"${name}\"`,\n before,\n after,\n });\n }\n\n return changes;\n}\n\n// ============================================================\n// Ontology Diff\n// ============================================================\n\n/**\n * Computes changes to the ontology.\n */\nfunction diffOntology(\n before: SerializedOntology,\n after: SerializedOntology,\n): readonly OntologyChange[] {\n const changes: OntologyChange[] = [];\n\n // Diff meta-edges\n const metaEdgesBefore = new Set(Object.keys(before.metaEdges));\n const metaEdgesAfter = new Set(Object.keys(after.metaEdges));\n\n for (const name of metaEdgesBefore) {\n if (!metaEdgesAfter.has(name)) {\n changes.push({\n type: \"removed\",\n entity: \"metaEdge\",\n name,\n severity: \"breaking\",\n details: `Meta-edge \"${name}\" was removed`,\n });\n }\n }\n\n for (const name of metaEdgesAfter) {\n if (!metaEdgesBefore.has(name)) {\n changes.push({\n type: \"added\",\n entity: \"metaEdge\",\n name,\n severity: \"safe\",\n details: `Meta-edge \"${name}\" was added`,\n });\n }\n }\n\n // Diff relations (simplified - just detect additions/removals)\n const relationsBefore = new Set(\n before.relations.map((r) => `${r.metaEdge}:${r.from}:${r.to}`),\n );\n const relationsAfter = new Set(\n after.relations.map((r) => `${r.metaEdge}:${r.from}:${r.to}`),\n );\n\n for (const relationKey of relationsBefore) {\n if (!relationsAfter.has(relationKey)) {\n const [metaEdge, from, to] = relationKey.split(\":\");\n changes.push({\n type: \"removed\",\n entity: \"relation\",\n name: relationKey,\n severity: \"warning\",\n details: `Relation ${metaEdge}(${from}, ${to}) was removed`,\n });\n }\n }\n\n for (const relationKey of relationsAfter) {\n if (!relationsBefore.has(relationKey)) {\n const [metaEdge, from, to] = relationKey.split(\":\");\n changes.push({\n type: \"added\",\n entity: \"relation\",\n name: relationKey,\n severity: \"safe\",\n details: `Relation ${metaEdge}(${from}, ${to}) was added`,\n });\n }\n }\n\n return changes;\n}\n\n// ============================================================\n// Summary Generation\n// ============================================================\n\n/**\n * Generates a human-readable summary of changes.\n */\nfunction generateSummary(\n nodeChanges: readonly NodeChange[],\n edgeChanges: readonly EdgeChange[],\n ontologyChanges: readonly OntologyChange[],\n): string {\n const parts: string[] = [];\n\n const nodeAdded = nodeChanges.filter((c) => c.type === \"added\").length;\n const nodeRemoved = nodeChanges.filter((c) => c.type === \"removed\").length;\n const nodeModified = nodeChanges.filter((c) => c.type === \"modified\").length;\n\n if (nodeAdded > 0 || nodeRemoved > 0 || nodeModified > 0) {\n parts.push(\n `Nodes: ${nodeAdded} added, ${nodeRemoved} removed, ${nodeModified} modified`,\n );\n }\n\n const edgeAdded = edgeChanges.filter((c) => c.type === \"added\").length;\n const edgeRemoved = edgeChanges.filter((c) => c.type === \"removed\").length;\n const edgeModified = edgeChanges.filter((c) => c.type === \"modified\").length;\n\n if (edgeAdded > 0 || edgeRemoved > 0 || edgeModified > 0) {\n parts.push(\n `Edges: ${edgeAdded} added, ${edgeRemoved} removed, ${edgeModified} modified`,\n );\n }\n\n const ontologyAdded = ontologyChanges.filter(\n (c) => c.type === \"added\",\n ).length;\n const ontologyRemoved = ontologyChanges.filter(\n (c) => c.type === \"removed\",\n ).length;\n\n if (ontologyAdded > 0 || ontologyRemoved > 0) {\n parts.push(`Ontology: ${ontologyAdded} added, ${ontologyRemoved} removed`);\n }\n\n if (parts.length === 0) {\n return \"No changes\";\n }\n\n return parts.join(\"; \");\n}\n\n// ============================================================\n// Migration Helpers\n// ============================================================\n\n/**\n * Checks if a schema change is backwards compatible.\n *\n * A change is backwards compatible if:\n * - No nodes or edges were removed\n * - No required properties were added\n * - No existing properties were removed\n */\nexport function isBackwardsCompatible(diff: SchemaDiff): boolean {\n return !diff.hasBreakingChanges;\n}\n\n/**\n * Gets a list of actions needed for migration.\n */\nexport function getMigrationActions(diff: SchemaDiff): readonly string[] {\n const actions: string[] = [];\n\n for (const change of diff.nodes) {\n if (change.type === \"removed\") {\n actions.push(`DELETE data for removed node kind \"${change.kind}\"`);\n }\n if (change.severity === \"breaking\" && change.type === \"modified\") {\n actions.push(\n `MIGRATE data for node kind \"${change.kind}\": ${change.details}`,\n );\n }\n }\n\n for (const change of diff.edges) {\n if (change.type === \"removed\") {\n actions.push(`DELETE data for removed edge kind \"${change.kind}\"`);\n }\n }\n\n return actions;\n}\n","/**\n * Transitive closure computation for ontology relationships.\n *\n * Uses Warshall's algorithm for efficient closure computation.\n */\n\n/**\n * Computes the transitive closure of a set of directed relations.\n *\n * Given relations like [A→B, B→C], computes all transitive paths [A→B, A→C, B→C].\n *\n * @param relations - Array of [from, to] pairs representing direct relationships\n * @returns Map from each 'from' to the set of all reachable 'to' values\n */\nexport function computeTransitiveClosure(\n relations: readonly (readonly [string, string])[],\n): ReadonlyMap<string, ReadonlySet<string>> {\n // Build mutable map for computation\n const closure = new Map<string, Set<string>>();\n\n // Collect all nodes\n const allNodes = new Set<string>();\n for (const [from, to] of relations) {\n allNodes.add(from);\n allNodes.add(to);\n }\n\n // Initialize empty sets for all nodes\n for (const node of allNodes) {\n closure.set(node, new Set());\n }\n\n // Add direct relationships\n for (const [from, to] of relations) {\n closure.get(from)?.add(to);\n }\n\n // Warshall's algorithm for transitive closure\n // For each intermediate node k, check if i→k and k→j implies i→j\n for (const k of allNodes) {\n for (const index of allNodes) {\n const indexReaches = closure.get(index);\n if (!indexReaches?.has(k)) continue;\n\n const kReaches = closure.get(k);\n if (!kReaches) continue;\n\n for (const index of kReaches) {\n indexReaches.add(index);\n }\n }\n }\n\n return closure;\n}\n\n/**\n * Computes the inverse of a transitive closure map.\n *\n * Given A→{B, C}, returns B→{A}, C→{A}.\n */\nexport function invertClosure(\n closure: ReadonlyMap<string, ReadonlySet<string>>,\n): ReadonlyMap<string, ReadonlySet<string>> {\n const result = new Map<string, Set<string>>();\n\n for (const [from, tos] of closure) {\n for (const to of tos) {\n const existing = result.get(to) ?? new Set();\n existing.add(from);\n result.set(to, existing);\n }\n }\n\n return result;\n}\n\n/**\n * Checks if there's a path from source to target in the closure.\n */\nexport function isReachable(\n closure: ReadonlyMap<string, ReadonlySet<string>>,\n source: string,\n target: string,\n): boolean {\n return closure.get(source)?.has(target) ?? false;\n}\n","/**\n * Named constants for ontology meta-edge names.\n *\n * Use these constants instead of string literals for type safety\n * and IDE support.\n */\n\n// ============================================================\n// Meta-Edge Names\n// ============================================================\n\n/** Type inheritance (Podcast subClassOf Media) */\nexport const META_EDGE_SUB_CLASS_OF = \"subClassOf\" as const;\n\n/** Broader concept (ML broader AI) */\nexport const META_EDGE_BROADER = \"broader\" as const;\n\n/** Narrower concept (AI narrower ML) */\nexport const META_EDGE_NARROWER = \"narrower\" as const;\n\n/** Non-hierarchical association */\nexport const META_EDGE_RELATED_TO = \"relatedTo\" as const;\n\n/** Same class, different representation */\nexport const META_EDGE_EQUIVALENT_TO = \"equivalentTo\" as const;\n\n/** Same individual (for deduplication) */\nexport const META_EDGE_SAME_AS = \"sameAs\" as const;\n\n/** Explicitly different individuals */\nexport const META_EDGE_DIFFERENT_FROM = \"differentFrom\" as const;\n\n/** Mutually exclusive types */\nexport const META_EDGE_DISJOINT_WITH = \"disjointWith\" as const;\n\n/** X is part of Y */\nexport const META_EDGE_PART_OF = \"partOf\" as const;\n\n/** Y has part X */\nexport const META_EDGE_HAS_PART = \"hasPart\" as const;\n\n/** Edge A is inverse of edge B */\nexport const META_EDGE_INVERSE_OF = \"inverseOf\" as const;\n\n/** Edge A implies edge B exists */\nexport const META_EDGE_IMPLIES = \"implies\" as const;\n\n// ============================================================\n// All Meta-Edge Names (for validation)\n// ============================================================\n\nexport const ALL_META_EDGE_NAMES = [\n META_EDGE_SUB_CLASS_OF,\n META_EDGE_BROADER,\n META_EDGE_NARROWER,\n META_EDGE_RELATED_TO,\n META_EDGE_EQUIVALENT_TO,\n META_EDGE_SAME_AS,\n META_EDGE_DIFFERENT_FROM,\n META_EDGE_DISJOINT_WITH,\n META_EDGE_PART_OF,\n META_EDGE_HAS_PART,\n META_EDGE_INVERSE_OF,\n META_EDGE_IMPLIES,\n] as const;\n\nexport type MetaEdgeName = (typeof ALL_META_EDGE_NAMES)[number];\n","import { type AnyEdgeType, type NodeType } from \"../core/types\";\nimport {\n computeTransitiveClosure,\n invertClosure,\n isReachable,\n} from \"../ontology/closures\";\nimport {\n META_EDGE_BROADER,\n META_EDGE_DISJOINT_WITH,\n META_EDGE_EQUIVALENT_TO,\n META_EDGE_HAS_PART,\n META_EDGE_IMPLIES,\n META_EDGE_INVERSE_OF,\n META_EDGE_NARROWER,\n META_EDGE_PART_OF,\n META_EDGE_SAME_AS,\n META_EDGE_SUB_CLASS_OF,\n} from \"../ontology/constants\";\nimport { type OntologyRelation } from \"../ontology/types\";\n\n/**\n * KindRegistry holds precomputed closures for ontological reasoning.\n *\n * Computed at store initialization and cached for fast query-time lookups.\n */\nexport class KindRegistry {\n // === Node & Edge Kinds ===\n readonly nodeKinds: ReadonlyMap<string, NodeType>;\n readonly edgeKinds: ReadonlyMap<string, AnyEdgeType>;\n\n // === Subsumption (subClassOf) ===\n // Transitive closure for inheritance\n readonly subClassAncestors: ReadonlyMap<string, ReadonlySet<string>>;\n readonly subClassDescendants: ReadonlyMap<string, ReadonlySet<string>>;\n\n // === Hierarchy (broader/narrower) ===\n // Transitive closure for concept hierarchy (separate from subClassOf!)\n readonly broaderClosure: ReadonlyMap<string, ReadonlySet<string>>;\n readonly narrowerClosure: ReadonlyMap<string, ReadonlySet<string>>;\n\n // === Equivalence ===\n readonly equivalenceSets: ReadonlyMap<string, ReadonlySet<string>>;\n readonly iriToKind: ReadonlyMap<string, string>;\n\n // === Constraints ===\n readonly disjointPairs: ReadonlySet<string>; // Normalized pairs: \"Organization|Person\"\n\n // === Composition ===\n readonly partOfClosure: ReadonlyMap<string, ReadonlySet<string>>;\n readonly hasPartClosure: ReadonlyMap<string, ReadonlySet<string>>;\n\n // === Edge Relationships ===\n readonly edgeInverses: ReadonlyMap<string, string>;\n readonly edgeImplicationsClosure: ReadonlyMap<string, ReadonlySet<string>>;\n readonly edgeImplyingClosure: ReadonlyMap<string, ReadonlySet<string>>;\n\n constructor(\n nodeKinds: ReadonlyMap<string, NodeType>,\n edgeKinds: ReadonlyMap<string, AnyEdgeType>,\n closures: {\n subClassAncestors: ReadonlyMap<string, ReadonlySet<string>>;\n subClassDescendants: ReadonlyMap<string, ReadonlySet<string>>;\n broaderClosure: ReadonlyMap<string, ReadonlySet<string>>;\n narrowerClosure: ReadonlyMap<string, ReadonlySet<string>>;\n equivalenceSets: ReadonlyMap<string, ReadonlySet<string>>;\n iriToKind: ReadonlyMap<string, string>;\n disjointPairs: ReadonlySet<string>;\n partOfClosure: ReadonlyMap<string, ReadonlySet<string>>;\n hasPartClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeInverses: ReadonlyMap<string, string>;\n edgeImplicationsClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeImplyingClosure: ReadonlyMap<string, ReadonlySet<string>>;\n },\n ) {\n this.nodeKinds = nodeKinds;\n this.edgeKinds = edgeKinds;\n this.subClassAncestors = closures.subClassAncestors;\n this.subClassDescendants = closures.subClassDescendants;\n this.broaderClosure = closures.broaderClosure;\n this.narrowerClosure = closures.narrowerClosure;\n this.equivalenceSets = closures.equivalenceSets;\n this.iriToKind = closures.iriToKind;\n this.disjointPairs = closures.disjointPairs;\n this.partOfClosure = closures.partOfClosure;\n this.hasPartClosure = closures.hasPartClosure;\n this.edgeInverses = closures.edgeInverses;\n this.edgeImplicationsClosure = closures.edgeImplicationsClosure;\n this.edgeImplyingClosure = closures.edgeImplyingClosure;\n }\n\n // === Subsumption Methods ===\n\n /**\n * Checks if child is a subclass of parent (directly or transitively).\n */\n isSubClassOf(child: string, parent: string): boolean {\n return isReachable(this.subClassAncestors, child, parent);\n }\n\n /**\n * Expands a kind to include all its subclasses.\n * Returns [kind, ...subclasses].\n */\n expandSubClasses(kind: string): readonly string[] {\n const descendants = this.subClassDescendants.get(kind) ?? new Set();\n return [kind, ...descendants];\n }\n\n /**\n * Gets all ancestors of a kind (via subClassOf).\n */\n getAncestors(kind: string): ReadonlySet<string> {\n return this.subClassAncestors.get(kind) ?? new Set();\n }\n\n /**\n * Gets all descendants of a kind (via subClassOf).\n */\n getDescendants(kind: string): ReadonlySet<string> {\n return this.subClassDescendants.get(kind) ?? new Set();\n }\n\n // === Hierarchy Methods ===\n\n /**\n * Checks if narrowerConcept is narrower than broaderConcept.\n */\n isNarrowerThan(narrowerConcept: string, broaderConcept: string): boolean {\n return isReachable(this.broaderClosure, narrowerConcept, broaderConcept);\n }\n\n /**\n * Checks if broaderConcept is broader than narrowerConcept.\n */\n isBroaderThan(broaderConcept: string, narrowerConcept: string): boolean {\n return isReachable(this.narrowerClosure, broaderConcept, narrowerConcept);\n }\n\n /**\n * Expands to include all narrower concepts.\n */\n expandNarrower(kind: string): readonly string[] {\n const narrower = this.narrowerClosure.get(kind) ?? new Set();\n return [kind, ...narrower];\n }\n\n /**\n * Expands to include all broader concepts.\n */\n expandBroader(kind: string): readonly string[] {\n const broader = this.broaderClosure.get(kind) ?? new Set();\n return [kind, ...broader];\n }\n\n // === Equivalence Methods ===\n\n /**\n * Checks if two kinds are equivalent.\n */\n areEquivalent(a: string, b: string): boolean {\n const equivalents = this.equivalenceSets.get(a);\n return equivalents?.has(b) ?? false;\n }\n\n /**\n * Gets all equivalents of a kind (including external IRIs).\n */\n getEquivalents(kind: string): readonly string[] {\n const equivalents = this.equivalenceSets.get(kind);\n return equivalents ? [...equivalents] : [];\n }\n\n /**\n * Resolves an external IRI to an internal kind name.\n */\n resolveIri(iri: string): string | undefined {\n return this.iriToKind.get(iri);\n }\n\n // === Constraint Methods ===\n\n /**\n * Checks if two kinds are disjoint.\n */\n areDisjoint(a: string, b: string): boolean {\n const normalizedPair = a < b ? `${a}|${b}` : `${b}|${a}`;\n return this.disjointPairs.has(normalizedPair);\n }\n\n /**\n * Gets all kinds that are disjoint with the given kind.\n */\n getDisjointKinds(kind: string): readonly string[] {\n const result: string[] = [];\n for (const pair of this.disjointPairs) {\n const parts = pair.split(\"|\");\n const a = parts[0]!;\n const b = parts[1]!;\n if (a === kind) result.push(b);\n else if (b === kind) result.push(a);\n }\n return result;\n }\n\n // === Composition Methods ===\n\n /**\n * Checks if part is part of whole (directly or transitively).\n */\n isPartOf(part: string, whole: string): boolean {\n return isReachable(this.partOfClosure, part, whole);\n }\n\n /**\n * Gets all wholes that contain this part.\n */\n getWholes(part: string): readonly string[] {\n const wholes = this.partOfClosure.get(part);\n return wholes ? [...wholes] : [];\n }\n\n /**\n * Gets all parts of this whole.\n */\n getParts(whole: string): readonly string[] {\n const parts = this.hasPartClosure.get(whole);\n return parts ? [...parts] : [];\n }\n\n // === Edge Relationship Methods ===\n\n /**\n * Gets the inverse edge kind for a given edge kind.\n * If edgeA inverseOf edgeB, then getInverseEdge(\"edgeA\") returns \"edgeB\".\n */\n getInverseEdge(edgeKind: string): string | undefined {\n return this.edgeInverses.get(edgeKind);\n }\n\n /**\n * Gets all edges implied by a given edge (transitively).\n * If A implies B and B implies C, then getImpliedEdges(\"A\") returns [\"B\", \"C\"].\n */\n getImpliedEdges(edgeKind: string): readonly string[] {\n const implied = this.edgeImplicationsClosure.get(edgeKind);\n return implied ? [...implied] : [];\n }\n\n /**\n * Gets all edges that imply a given edge (transitively).\n * If A implies B and B implies C, then getImplyingEdges(\"C\") returns [\"A\", \"B\"].\n * Used for query-time expansion: when querying for C, also include A and B edges.\n */\n getImplyingEdges(edgeKind: string): readonly string[] {\n const implying = this.edgeImplyingClosure.get(edgeKind);\n return implying ? [...implying] : [];\n }\n\n /**\n * Expands an edge kind to include all edges that imply it.\n * Returns [edgeKind, ...implyingEdges].\n */\n expandImplyingEdges(edgeKind: string): readonly string[] {\n const implying = this.edgeImplyingClosure.get(edgeKind) ?? new Set();\n return [edgeKind, ...implying];\n }\n\n // === Edge Endpoint Validation ===\n\n /**\n * Checks if a concrete kind is assignable to a target kind.\n * Uses subsumption: Company is assignable to Organization if Company subClassOf Organization.\n */\n isAssignableTo(concreteKind: string, targetKind: string): boolean {\n if (concreteKind === targetKind) return true;\n return this.isSubClassOf(concreteKind, targetKind);\n }\n\n /**\n * Validates that a kind exists in the registry.\n */\n hasNodeType(name: string): boolean {\n return this.nodeKinds.has(name);\n }\n\n /**\n * Validates that an edge kind exists in the registry.\n */\n hasEdgeType(name: string): boolean {\n return this.edgeKinds.has(name);\n }\n\n /**\n * Gets a node kind by name.\n */\n getNodeType(name: string): NodeType | undefined {\n return this.nodeKinds.get(name);\n }\n\n /**\n * Gets an edge kind by name.\n */\n getEdgeType(name: string): AnyEdgeType | undefined {\n return this.edgeKinds.get(name);\n }\n}\n\n/**\n * Builder function to create empty closures.\n */\nexport function createEmptyClosures(): {\n subClassAncestors: ReadonlyMap<string, ReadonlySet<string>>;\n subClassDescendants: ReadonlyMap<string, ReadonlySet<string>>;\n broaderClosure: ReadonlyMap<string, ReadonlySet<string>>;\n narrowerClosure: ReadonlyMap<string, ReadonlySet<string>>;\n equivalenceSets: ReadonlyMap<string, ReadonlySet<string>>;\n iriToKind: ReadonlyMap<string, string>;\n disjointPairs: ReadonlySet<string>;\n partOfClosure: ReadonlyMap<string, ReadonlySet<string>>;\n hasPartClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeInverses: ReadonlyMap<string, string>;\n edgeImplicationsClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeImplyingClosure: ReadonlyMap<string, ReadonlySet<string>>;\n} {\n return {\n subClassAncestors: new Map(),\n subClassDescendants: new Map(),\n broaderClosure: new Map(),\n narrowerClosure: new Map(),\n equivalenceSets: new Map(),\n iriToKind: new Map(),\n disjointPairs: new Set(),\n partOfClosure: new Map(),\n hasPartClosure: new Map(),\n edgeInverses: new Map(),\n edgeImplicationsClosure: new Map(),\n edgeImplyingClosure: new Map(),\n };\n}\n\n/**\n * Computes all closures from an ontology.\n */\nexport function computeClosuresFromOntology(\n ontology: readonly OntologyRelation[],\n): {\n subClassAncestors: ReadonlyMap<string, ReadonlySet<string>>;\n subClassDescendants: ReadonlyMap<string, ReadonlySet<string>>;\n broaderClosure: ReadonlyMap<string, ReadonlySet<string>>;\n narrowerClosure: ReadonlyMap<string, ReadonlySet<string>>;\n equivalenceSets: ReadonlyMap<string, ReadonlySet<string>>;\n iriToKind: ReadonlyMap<string, string>;\n disjointPairs: ReadonlySet<string>;\n partOfClosure: ReadonlyMap<string, ReadonlySet<string>>;\n hasPartClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeInverses: ReadonlyMap<string, string>;\n edgeImplicationsClosure: ReadonlyMap<string, ReadonlySet<string>>;\n edgeImplyingClosure: ReadonlyMap<string, ReadonlySet<string>>;\n} {\n // Collect relations by type\n const subClassRelations: [string, string][] = [];\n const broaderRelations: [string, string][] = [];\n const equivalentRelations: [string, string][] = [];\n const disjointRelations: [string, string][] = [];\n const partOfRelations: [string, string][] = [];\n const inverseOfRelations: [string, string][] = [];\n const impliesRelations: [string, string][] = [];\n\n for (const relation of ontology) {\n const fromName = getKindName(relation.from);\n const toName = getKindName(relation.to);\n\n switch (relation.metaEdge.name) {\n case META_EDGE_SUB_CLASS_OF: {\n subClassRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_BROADER: {\n broaderRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_NARROWER: {\n // narrower is inverse of broader\n broaderRelations.push([toName, fromName]);\n break;\n }\n case META_EDGE_EQUIVALENT_TO:\n case META_EDGE_SAME_AS: {\n equivalentRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_DISJOINT_WITH: {\n disjointRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_PART_OF: {\n partOfRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_HAS_PART: {\n // hasPart is inverse of partOf\n partOfRelations.push([toName, fromName]);\n break;\n }\n case META_EDGE_INVERSE_OF: {\n // inverseOf is symmetric: if A inverseOf B, then B inverseOf A\n inverseOfRelations.push([fromName, toName]);\n break;\n }\n case META_EDGE_IMPLIES: {\n impliesRelations.push([fromName, toName]);\n break;\n }\n }\n }\n\n // Compute subClassOf closures\n const subClassAncestors = computeTransitiveClosure(subClassRelations);\n const subClassDescendants = invertClosure(subClassAncestors);\n\n // Compute broader/narrower closures\n const broaderClosure = computeTransitiveClosure(broaderRelations);\n const narrowerClosure = invertClosure(broaderClosure);\n\n // Compute equivalence sets and IRI mappings\n const equivalenceSets = computeEquivalenceSets(equivalentRelations);\n const iriToKind = computeIriMapping(equivalentRelations);\n\n // Compute disjoint pairs (normalize for symmetric lookup)\n const disjointPairs = computeDisjointPairs(disjointRelations);\n\n // Compute partOf closures\n const partOfClosure = computeTransitiveClosure(partOfRelations);\n const hasPartClosure = invertClosure(partOfClosure);\n\n // Compute edge inverses (symmetric: store both directions)\n const edgeInverses = computeEdgeInverses(inverseOfRelations);\n\n // Compute edge implications closure (transitive)\n // edgeImplicationsClosure: A -> [B, C] means A implies B and C\n // edgeImplyingClosure: C -> [A, B] means A and B imply C (inverse direction)\n const edgeImplicationsClosure = computeTransitiveClosure(impliesRelations);\n const edgeImplyingClosure = invertClosure(edgeImplicationsClosure);\n\n return {\n subClassAncestors,\n subClassDescendants,\n broaderClosure,\n narrowerClosure,\n equivalenceSets,\n iriToKind,\n disjointPairs,\n partOfClosure,\n hasPartClosure,\n edgeInverses,\n edgeImplicationsClosure,\n edgeImplyingClosure,\n };\n}\n\n/**\n * Gets the name from a NodeType, EdgeType, or string.\n */\nfunction getKindName(kindOrIri: NodeType | AnyEdgeType | string): string {\n if (typeof kindOrIri === \"string\") {\n return kindOrIri;\n }\n return kindOrIri.kind;\n}\n\n/**\n * Checks if a string is an external IRI (not a local kind name).\n */\nfunction isExternalIri(value: string): boolean {\n return value.startsWith(\"http://\") || value.startsWith(\"https://\");\n}\n\n/**\n * Computes equivalence sets (symmetric + transitive closure).\n */\nfunction computeEquivalenceSets(\n relations: readonly (readonly [string, string])[],\n): ReadonlyMap<string, ReadonlySet<string>> {\n // Use union-find to compute equivalence classes\n const parent = new Map<string, string>();\n\n function find(x: string): string {\n if (!parent.has(x)) {\n parent.set(x, x);\n return x;\n }\n // Safe: has() check above guarantees key exists\n const p = parent.get(x)!;\n if (p === x) return x;\n const root = find(p);\n parent.set(x, root); // Path compression\n return root;\n }\n\n function union(a: string, b: string): void {\n const rootA = find(a);\n const rootB = find(b);\n if (rootA !== rootB) {\n parent.set(rootA, rootB);\n }\n }\n\n // Build equivalence classes\n for (const [a, b] of relations) {\n union(a, b);\n }\n\n // Collect all members of each equivalence class\n const classes = new Map<string, Set<string>>();\n for (const key of parent.keys()) {\n const root = find(key);\n const existing = classes.get(root) ?? new Set();\n existing.add(key);\n classes.set(root, existing);\n }\n\n // Build result: each node maps to its equivalence set\n const result = new Map<string, ReadonlySet<string>>();\n for (const members of classes.values()) {\n for (const member of members) {\n // Exclude self from equivalence set\n const others = new Set(members);\n others.delete(member);\n result.set(member, others);\n }\n }\n\n return result;\n}\n\n/**\n * Computes mapping from external IRIs to internal kind names.\n */\nfunction computeIriMapping(\n relations: readonly (readonly [string, string])[],\n): ReadonlyMap<string, string> {\n const result = new Map<string, string>();\n\n for (const [a, b] of relations) {\n // If one is an IRI and other is a kind name, map IRI → kind\n if (isExternalIri(a) && !isExternalIri(b)) {\n result.set(a, b);\n } else if (isExternalIri(b) && !isExternalIri(a)) {\n result.set(b, a);\n }\n }\n\n return result;\n}\n\n/**\n * Computes normalized disjoint pairs.\n */\nfunction computeDisjointPairs(\n relations: readonly (readonly [string, string])[],\n): ReadonlySet<string> {\n const result = new Set<string>();\n\n for (const [a, b] of relations) {\n // Normalize pair for consistent lookup\n const normalized = a < b ? `${a}|${b}` : `${b}|${a}`;\n result.add(normalized);\n }\n\n return result;\n}\n\n/**\n * Computes edge inverse mapping (symmetric: stores both directions).\n */\nfunction computeEdgeInverses(\n relations: readonly (readonly [string, string])[],\n): ReadonlyMap<string, string> {\n const result = new Map<string, string>();\n\n for (const [a, b] of relations) {\n // inverseOf is symmetric: A inverseOf B means B inverseOf A too\n result.set(a, b);\n result.set(b, a);\n }\n\n return result;\n}\n","/**\n * Schema serializer for homoiconic storage.\n *\n * Converts a GraphDef to a SerializedSchema for database storage.\n * Uses Zod's toJSONSchema() for property schema serialization.\n */\nimport { z } from \"zod\";\n\nimport {\n getEdgeKinds,\n getNodeKinds,\n type GraphDef,\n} from \"../core/define-graph\";\nimport {\n type EdgeRegistration,\n type NodeRegistration,\n type UniqueConstraint,\n} from \"../core/types\";\nimport {\n getTypeName,\n type MetaEdge,\n type OntologyRelation,\n} from \"../ontology/types\";\nimport { computeClosuresFromOntology } from \"../registry/kind-registry\";\nimport { nowIso } from \"../utils/date\";\nimport {\n type JsonSchema,\n type SchemaHash,\n type SerializedClosures,\n type SerializedEdgeDef,\n type SerializedMetaEdge,\n type SerializedNodeDef,\n type SerializedOntology,\n type SerializedOntologyRelation,\n type SerializedSchema,\n type SerializedUniqueConstraint,\n} from \"./types\";\n\n// ============================================================\n// Main Serialization\n// ============================================================\n\n/**\n * Serializes a GraphDef to a SerializedSchema.\n *\n * @param graph - The graph definition to serialize\n * @param version - The schema version number\n * @returns The serialized schema\n */\nexport function serializeSchema<G extends GraphDef>(\n graph: G,\n version: number,\n): SerializedSchema {\n const nodes = serializeNodes(graph);\n const edges = serializeEdges(graph);\n const ontology = serializeOntology(graph.ontology);\n\n return {\n graphId: graph.id,\n version,\n generatedAt: nowIso(),\n nodes,\n edges,\n ontology,\n defaults: {\n onNodeDelete: graph.defaults.onNodeDelete,\n temporalMode: graph.defaults.temporalMode,\n },\n };\n}\n\n// ============================================================\n// Node Serialization\n// ============================================================\n\n/**\n * Serializes all node definitions.\n */\nfunction serializeNodes<G extends GraphDef>(\n graph: G,\n): Record<string, SerializedNodeDef> {\n const result: Record<string, SerializedNodeDef> = {};\n\n for (const kindName of getNodeKinds(graph)) {\n const registration = graph.nodes[kindName];\n if (registration === undefined) continue;\n result[kindName] = serializeNodeDef(registration);\n }\n\n return result;\n}\n\n/**\n * Serializes a single node registration.\n */\nfunction serializeNodeDef(registration: NodeRegistration): SerializedNodeDef {\n const node = registration.type;\n\n return {\n kind: node.kind,\n properties: serializeZodSchema(node.schema),\n uniqueConstraints: serializeUniqueConstraints(registration.unique ?? []),\n onDelete: registration.onDelete ?? \"restrict\",\n description: node.description,\n };\n}\n\n/**\n * Serializes unique constraints.\n */\nfunction serializeUniqueConstraints(\n constraints: readonly UniqueConstraint[],\n): readonly SerializedUniqueConstraint[] {\n return constraints.map((constraint) => ({\n name: constraint.name,\n fields: [...constraint.fields],\n where:\n constraint.where ? serializeWherePredicate(constraint.where) : undefined,\n scope: constraint.scope,\n collation: constraint.collation,\n }));\n}\n\n/**\n * A serialized predicate structure (matches UniqueConstraintPredicate from core/types).\n */\ntype SerializedPredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: \"isNull\" | \"isNotNull\";\n}>;\n\n/**\n * Field builder returned by the predicate proxy.\n */\ntype FieldPredicateBuilder = Readonly<{\n isNull: () => SerializedPredicate;\n isNotNull: () => SerializedPredicate;\n}>;\n\n/**\n * Predicate builder type for where clause serialization.\n */\ntype PredicateBuilder = Readonly<Record<string, FieldPredicateBuilder>>;\n\n/**\n * Serializes a where predicate function to a JSON-serializable structure.\n *\n * The where function is called with a proxy builder that captures the\n * field and operation, which can then be serialized and later deserialized.\n */\nfunction serializeWherePredicate(\n whereFunction: (builder: PredicateBuilder) => SerializedPredicate,\n): string {\n // Create a proxy builder that captures the predicate structure\n const builder = new Proxy({} as PredicateBuilder, {\n get(_target, field: string): FieldPredicateBuilder {\n return {\n isNull: (): SerializedPredicate => ({\n __type: \"unique_predicate\",\n field,\n op: \"isNull\" as const,\n }),\n isNotNull: (): SerializedPredicate => ({\n __type: \"unique_predicate\",\n field,\n op: \"isNotNull\" as const,\n }),\n };\n },\n });\n\n // Call the where function to get the predicate\n const predicate = whereFunction(builder);\n\n // Serialize the predicate structure as JSON\n return JSON.stringify({ field: predicate.field, op: predicate.op });\n}\n\n/**\n * Deserializes a where predicate JSON back to a predicate function.\n *\n * This can be used to reconstruct a UniqueConstraint's where clause\n * from a serialized schema.\n *\n * @param serialized - The JSON string from serialization\n * @returns A where function that returns the predicate structure\n */\n/**\n * Unique predicate result type.\n */\ntype UniquePredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: \"isNull\" | \"isNotNull\";\n}>;\n\nexport function deserializeWherePredicate(\n serialized: string,\n): (builder: PredicateBuilder) => UniquePredicate {\n const parsed = JSON.parse(serialized) as {\n field: string;\n op: \"isNull\" | \"isNotNull\";\n };\n\n return (builder: PredicateBuilder): UniquePredicate => {\n const fieldBuilder = builder[parsed.field];\n if (!fieldBuilder) {\n throw new Error(`Unknown field in where predicate: ${parsed.field}`);\n }\n\n const result =\n parsed.op === \"isNull\" ? fieldBuilder.isNull() : fieldBuilder.isNotNull();\n return {\n __type: \"unique_predicate\",\n field: result.field,\n op: result.op,\n };\n };\n}\n\n// ============================================================\n// Edge Serialization\n// ============================================================\n\n/**\n * Serializes all edge definitions.\n */\nfunction serializeEdges<G extends GraphDef>(\n graph: G,\n): Record<string, SerializedEdgeDef> {\n const result: Record<string, SerializedEdgeDef> = {};\n\n for (const kindName of getEdgeKinds(graph)) {\n const registration = graph.edges[kindName];\n if (registration === undefined) continue;\n result[kindName] = serializeEdgeDef(registration);\n }\n\n return result;\n}\n\n/**\n * Serializes a single edge registration.\n */\nfunction serializeEdgeDef(registration: EdgeRegistration): SerializedEdgeDef {\n const edge = registration.type;\n\n return {\n kind: edge.kind,\n fromKinds: registration.from.map((node) => node.kind),\n toKinds: registration.to.map((node) => node.kind),\n properties: serializeZodSchema(edge.schema),\n cardinality: registration.cardinality ?? \"many\",\n endpointExistence: registration.endpointExistence ?? \"notDeleted\",\n description: edge.description,\n };\n}\n\n// ============================================================\n// Ontology Serialization\n// ============================================================\n\n/**\n * Serializes the complete ontology.\n */\nfunction serializeOntology(\n relations: readonly OntologyRelation[],\n): SerializedOntology {\n // Collect unique meta-edges\n const metaEdgeMap = new Map<string, MetaEdge>();\n for (const relation of relations) {\n const metaEdge = relation.metaEdge;\n if (!metaEdgeMap.has(metaEdge.name)) {\n metaEdgeMap.set(metaEdge.name, metaEdge);\n }\n }\n\n // Serialize meta-edges\n const metaEdges: Record<string, SerializedMetaEdge> = {};\n for (const [name, metaEdge] of metaEdgeMap) {\n metaEdges[name] = serializeMetaEdge(metaEdge);\n }\n\n // Serialize relations\n const serializedRelations = relations.map((relation) =>\n serializeOntologyRelation(relation),\n );\n\n // Compute and serialize closures\n const closures = serializeClosures(relations);\n\n return {\n metaEdges,\n relations: serializedRelations,\n closures,\n };\n}\n\n/**\n * Serializes a meta-edge.\n */\nfunction serializeMetaEdge(metaEdge: MetaEdge): SerializedMetaEdge {\n return {\n name: metaEdge.name,\n transitive: metaEdge.properties.transitive,\n symmetric: metaEdge.properties.symmetric,\n reflexive: metaEdge.properties.reflexive,\n inverse: metaEdge.properties.inverse,\n inference: metaEdge.properties.inference,\n description: metaEdge.properties.description,\n };\n}\n\n/**\n * Serializes an ontology relation.\n */\nfunction serializeOntologyRelation(\n relation: OntologyRelation,\n): SerializedOntologyRelation {\n return {\n metaEdge: relation.metaEdge.name,\n from: getTypeName(relation.from),\n to: getTypeName(relation.to),\n };\n}\n\n/**\n * Serializes precomputed closures.\n */\nfunction serializeClosures(\n relations: readonly OntologyRelation[],\n): SerializedClosures {\n if (relations.length === 0) {\n return {\n subClassAncestors: {},\n subClassDescendants: {},\n broaderClosure: {},\n narrowerClosure: {},\n equivalenceSets: {},\n disjointPairs: [],\n partOfClosure: {},\n hasPartClosure: {},\n iriToKind: {},\n edgeInverses: {},\n edgeImplicationsClosure: {},\n edgeImplyingClosure: {},\n };\n }\n\n const computed = computeClosuresFromOntology(relations);\n\n return {\n subClassAncestors: mapToRecord(computed.subClassAncestors),\n subClassDescendants: mapToRecord(computed.subClassDescendants),\n broaderClosure: mapToRecord(computed.broaderClosure),\n narrowerClosure: mapToRecord(computed.narrowerClosure),\n equivalenceSets: mapToRecord(computed.equivalenceSets),\n disjointPairs: [...computed.disjointPairs],\n partOfClosure: mapToRecord(computed.partOfClosure),\n hasPartClosure: mapToRecord(computed.hasPartClosure),\n iriToKind: mapToSimpleRecord(computed.iriToKind),\n edgeInverses: mapToSimpleRecord(computed.edgeInverses),\n edgeImplicationsClosure: mapToRecord(computed.edgeImplicationsClosure),\n edgeImplyingClosure: mapToRecord(computed.edgeImplyingClosure),\n };\n}\n\n/**\n * Converts a Map<string, Set<string>> to Record<string, string[]>.\n */\nfunction mapToRecord(\n map: ReadonlyMap<string, ReadonlySet<string>>,\n): Record<string, readonly string[]> {\n const result: Record<string, readonly string[]> = {};\n for (const [key, values] of map) {\n result[key] = [...values];\n }\n return result;\n}\n\n/**\n * Converts a Map<string, string> to Record<string, string>.\n */\nfunction mapToSimpleRecord(\n map: ReadonlyMap<string, string>,\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [key, value] of map) {\n result[key] = value;\n }\n return result;\n}\n\n// ============================================================\n// Zod Schema Serialization\n// ============================================================\n\n/**\n * Serializes a Zod schema to JSON Schema.\n *\n * Uses Zod 4's toJSONSchema() method for conversion.\n */\nfunction serializeZodSchema(schema: z.ZodType): JsonSchema {\n try {\n // Zod 4 has toJSONSchema as a standard export\n const jsonSchema = z.toJSONSchema(schema);\n return jsonSchema as JsonSchema;\n } catch {\n // Fallback for schemas that can't be converted\n return { type: \"object\" };\n }\n}\n\n// ============================================================\n// Schema Hashing\n// ============================================================\n\n/**\n * Computes a hash of the schema content for change detection.\n *\n * Excludes version and generatedAt since those change on every save.\n */\nexport async function computeSchemaHash(\n schema: SerializedSchema,\n): Promise<SchemaHash> {\n // Create a hashable representation excluding dynamic fields\n const hashable = {\n graphId: schema.graphId,\n nodes: schema.nodes,\n edges: schema.edges,\n ontology: schema.ontology,\n defaults: schema.defaults,\n };\n\n // Serialize with sorted keys for deterministic output\n const json = JSON.stringify(hashable, sortedReplacer);\n return sha256Hash(json);\n}\n\n/**\n * JSON replacer that sorts object keys for deterministic serialization.\n */\nfunction sortedReplacer(_key: string, value: unknown): unknown {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).toSorted()) {\n sorted[key] = (value as Record<string, unknown>)[key];\n }\n return sorted;\n }\n return value;\n}\n\n/**\n * Computes SHA-256 hash of a string using the Web Crypto API.\n *\n * Works in Node.js 16+, Cloudflare Workers, Deno, and browsers.\n * Returns first 16 hex characters (64 bits) for a compact but collision-resistant hash.\n */\nasync function sha256Hash(input: string): Promise<string> {\n const encoded = new TextEncoder().encode(input);\n const digest = await globalThis.crypto.subtle.digest(\"SHA-256\", encoded);\n const bytes = new Uint8Array(digest);\n // Only need 8 bytes (16 hex chars) — avoid converting the full 32-byte digest\n let hex = \"\";\n for (let index = 0; index < 8; index++) {\n const byte = bytes[index];\n if (byte === undefined) break;\n hex += byte.toString(16).padStart(2, \"0\");\n }\n return hex;\n}\n","/**\n * Schema manager for TypeGraph.\n *\n * Provides schema lifecycle management:\n * - Initialization on first store creation\n * - Validation on store open\n * - Auto-migration for safe changes\n * - Error reporting for breaking changes\n */\nimport { type GraphBackend, type SchemaVersionRow } from \"../backend/types\";\nimport { type GraphDef } from \"../core/define-graph\";\nimport { MigrationError } from \"../errors\";\nimport {\n computeSchemaDiff,\n getMigrationActions,\n isBackwardsCompatible,\n type SchemaDiff,\n} from \"./migration\";\nimport { computeSchemaHash, serializeSchema } from \"./serializer\";\nimport { type SerializedSchema } from \"./types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Result of schema validation.\n */\nexport type SchemaValidationResult =\n | { status: \"initialized\"; version: number }\n | { status: \"unchanged\"; version: number }\n | {\n status: \"migrated\";\n fromVersion: number;\n toVersion: number;\n diff: SchemaDiff;\n }\n | { status: \"pending\"; version: number; diff: SchemaDiff }\n | { status: \"breaking\"; diff: SchemaDiff; actions: readonly string[] };\n\n/**\n * Context passed to migration lifecycle hooks.\n *\n * Hooks are intended for observability (logging, metrics, alerts),\n * not for data transformations. Use an explicit migration runner\n * for backfill scripts — see the schema evolution guide.\n */\nexport type MigrationHookContext = Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n diff: SchemaDiff;\n}>;\n\n/**\n * Options for schema management.\n */\nexport type SchemaManagerOptions = Readonly<{\n /** If true, auto-migrate safe changes. Default: true */\n autoMigrate?: boolean;\n /** If true, throw on breaking changes. Default: true */\n throwOnBreaking?: boolean;\n /** Called before a safe auto-migration is applied. For observability only. */\n onBeforeMigrate?: (context: MigrationHookContext) => void | Promise<void>;\n /** Called after a safe auto-migration is applied. For observability only. */\n onAfterMigrate?: (context: MigrationHookContext) => void | Promise<void>;\n}>;\n\n// ============================================================\n// Schema Manager\n// ============================================================\n\n/**\n * Ensures the schema is initialized and up-to-date.\n *\n * This is the main entry point for schema management. It:\n * 1. Initializes the schema if this is the first run (version 1)\n * 2. Returns \"unchanged\" if the schema matches the current graph\n * 3. Auto-migrates safe changes if autoMigrate is true\n * 4. Throws MigrationError for breaking changes if throwOnBreaking is true\n *\n * @param backend - The database backend\n * @param graph - The current graph definition\n * @param options - Schema management options\n * @returns The result of schema validation\n * @throws MigrationError if breaking changes detected and throwOnBreaking is true\n */\nexport async function ensureSchema<G extends GraphDef>(\n backend: GraphBackend,\n graph: G,\n options?: SchemaManagerOptions,\n): Promise<SchemaValidationResult> {\n const autoMigrate = options?.autoMigrate ?? true;\n const throwOnBreaking = options?.throwOnBreaking ?? true;\n\n // Get the active schema from the database\n const activeSchema = await backend.getActiveSchema(graph.id);\n\n if (!activeSchema) {\n // No schema exists - initialize with version 1\n const result = await initializeSchema(backend, graph);\n return { status: \"initialized\", version: result.version };\n }\n\n // Parse the stored schema\n const storedSchema = JSON.parse(activeSchema.schema_doc) as SerializedSchema;\n\n // Serialize the current graph for comparison\n const currentSchema = serializeSchema(graph, activeSchema.version + 1);\n\n // Quick hash check - if hashes match, schemas are identical\n const storedHash = activeSchema.schema_hash;\n const currentHash = await computeSchemaHash(currentSchema);\n\n if (storedHash === currentHash) {\n return { status: \"unchanged\", version: activeSchema.version };\n }\n\n // Hashes differ - compute the diff\n const diff = computeSchemaDiff(storedSchema, currentSchema);\n\n if (!diff.hasChanges) {\n // Hash changed but no semantic changes (shouldn't happen, but handle it)\n return { status: \"unchanged\", version: activeSchema.version };\n }\n\n // Check if changes are backwards compatible\n if (isBackwardsCompatible(diff)) {\n if (autoMigrate) {\n // Safe changes - auto-migrate\n const hookContext: MigrationHookContext = {\n graphId: graph.id,\n fromVersion: activeSchema.version,\n toVersion: activeSchema.version + 1,\n diff,\n };\n await options?.onBeforeMigrate?.(hookContext);\n const newVersion = await migrateSchema(\n backend,\n graph,\n activeSchema.version,\n );\n await options?.onAfterMigrate?.(hookContext);\n return {\n status: \"migrated\",\n fromVersion: activeSchema.version,\n toVersion: newVersion,\n diff,\n };\n }\n // Auto-migrate disabled but changes are safe\n return {\n status: \"pending\",\n version: activeSchema.version,\n diff,\n };\n }\n\n // Breaking changes detected\n const actions = getMigrationActions(diff);\n\n if (throwOnBreaking) {\n throw new MigrationError(\n `Schema migration required: ${diff.summary}. ` +\n `${actions.length} migration action(s) needed. ` +\n `Use getSchemaChanges() to review, then migrateSchema() to apply.`,\n {\n graphId: graph.id,\n fromVersion: activeSchema.version,\n toVersion: activeSchema.version + 1,\n },\n );\n }\n\n return { status: \"breaking\", diff, actions };\n}\n\n/**\n * Initializes the schema for a new graph.\n *\n * Creates version 1 of the schema and marks it as active.\n *\n * @param backend - The database backend\n * @param graph - The graph definition\n * @returns The created schema version row\n */\nexport async function initializeSchema<G extends GraphDef>(\n backend: GraphBackend,\n graph: G,\n): Promise<SchemaVersionRow> {\n const schema = serializeSchema(graph, 1);\n const hash = await computeSchemaHash(schema);\n\n return backend.insertSchema({\n graphId: graph.id,\n version: 1,\n schemaHash: hash,\n schemaDoc: schema,\n isActive: true,\n });\n}\n\n/**\n * Migrates the schema to match the current graph definition.\n *\n * This creates a new schema version and marks it as active.\n * The old version is preserved for history/rollback.\n *\n * @param backend - The database backend\n * @param graph - The current graph definition\n * @param currentVersion - The current active schema version\n * @returns The new version number\n */\nexport async function migrateSchema<G extends GraphDef>(\n backend: GraphBackend,\n graph: G,\n currentVersion: number,\n): Promise<number> {\n const newVersion = currentVersion + 1;\n const schema = serializeSchema(graph, newVersion);\n const hash = await computeSchemaHash(schema);\n\n // Insert new version (not active yet)\n await backend.insertSchema({\n graphId: graph.id,\n version: newVersion,\n schemaHash: hash,\n schemaDoc: schema,\n isActive: false,\n });\n\n // Atomically switch to the new version\n await backend.setActiveSchema(graph.id, newVersion);\n\n return newVersion;\n}\n\n/**\n * Rolls back the active schema to a previous version.\n *\n * The target version must already exist in the version history.\n * This does not delete newer versions — it simply switches the active pointer.\n *\n * @param backend - The database backend\n * @param graphId - The graph ID\n * @param targetVersion - The version to roll back to\n * @throws MigrationError if the target version does not exist\n */\nexport async function rollbackSchema(\n backend: GraphBackend,\n graphId: string,\n targetVersion: number,\n): Promise<void> {\n const row = await backend.getSchemaVersion(graphId, targetVersion);\n if (!row) {\n throw new MigrationError(\n `Cannot rollback to version ${targetVersion}: version does not exist.`,\n { graphId, fromVersion: targetVersion, toVersion: targetVersion },\n );\n }\n await backend.setActiveSchema(graphId, targetVersion);\n}\n\n/**\n * Gets the current active schema for a graph.\n *\n * @param backend - The database backend\n * @param graphId - The graph ID\n * @returns The active schema or undefined if not initialized\n */\nexport async function getActiveSchema(\n backend: GraphBackend,\n graphId: string,\n): Promise<SerializedSchema | undefined> {\n const row = await backend.getActiveSchema(graphId);\n if (!row) return undefined;\n return JSON.parse(row.schema_doc) as SerializedSchema;\n}\n\n/**\n * Checks if a graph's schema has been initialized.\n *\n * @param backend - The database backend\n * @param graphId - The graph ID\n * @returns True if the schema has been initialized\n */\nexport async function isSchemaInitialized(\n backend: GraphBackend,\n graphId: string,\n): Promise<boolean> {\n const row = await backend.getActiveSchema(graphId);\n return row !== undefined;\n}\n\n/**\n * Gets the schema diff between the stored schema and current graph.\n *\n * @param backend - The database backend\n * @param graph - The current graph definition\n * @returns The diff, or undefined if schema not initialized\n */\nexport async function getSchemaChanges<G extends GraphDef>(\n backend: GraphBackend,\n graph: G,\n): Promise<SchemaDiff | undefined> {\n const activeSchema = await backend.getActiveSchema(graph.id);\n if (!activeSchema) return undefined;\n\n const storedSchema = JSON.parse(activeSchema.schema_doc) as SerializedSchema;\n const currentSchema = serializeSchema(graph, activeSchema.version + 1);\n\n return computeSchemaDiff(storedSchema, currentSchema);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJQDWEX6V_cjs = require('./chunk-JQDWEX6V.cjs');
|
|
4
4
|
var pgCore = require('drizzle-orm/pg-core');
|
|
5
5
|
|
|
6
6
|
var vector = pgCore.customType({
|
|
@@ -50,9 +50,15 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
50
50
|
(t) => [
|
|
51
51
|
pgCore.primaryKey({ columns: [t.graphId, t.kind, t.id] }),
|
|
52
52
|
pgCore.index(`${n.nodes}_kind_idx`).on(t.graphId, t.kind),
|
|
53
|
+
pgCore.index(`${n.nodes}_kind_created_idx`).on(
|
|
54
|
+
t.graphId,
|
|
55
|
+
t.kind,
|
|
56
|
+
t.deletedAt,
|
|
57
|
+
t.createdAt
|
|
58
|
+
),
|
|
53
59
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
54
60
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
55
|
-
...
|
|
61
|
+
...chunkJQDWEX6V_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
56
62
|
]
|
|
57
63
|
);
|
|
58
64
|
const edges2 = pgCore.pgTable(
|
|
@@ -75,8 +81,33 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
75
81
|
(t) => [
|
|
76
82
|
pgCore.primaryKey({ columns: [t.graphId, t.id] }),
|
|
77
83
|
pgCore.index(`${n.edges}_kind_idx`).on(t.graphId, t.kind),
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
// Directional traversal index (outgoing): supports endpoint lookups
|
|
85
|
+
// and extra filtering by edge kind / target kind.
|
|
86
|
+
pgCore.index(`${n.edges}_from_idx`).on(
|
|
87
|
+
t.graphId,
|
|
88
|
+
t.fromKind,
|
|
89
|
+
t.fromId,
|
|
90
|
+
t.kind,
|
|
91
|
+
t.toKind,
|
|
92
|
+
t.deletedAt,
|
|
93
|
+
t.validTo
|
|
94
|
+
),
|
|
95
|
+
// Directional traversal index (incoming): mirrors from_idx for reverse traversals.
|
|
96
|
+
pgCore.index(`${n.edges}_to_idx`).on(
|
|
97
|
+
t.graphId,
|
|
98
|
+
t.toKind,
|
|
99
|
+
t.toId,
|
|
100
|
+
t.kind,
|
|
101
|
+
t.fromKind,
|
|
102
|
+
t.deletedAt,
|
|
103
|
+
t.validTo
|
|
104
|
+
),
|
|
105
|
+
pgCore.index(`${n.edges}_kind_created_idx`).on(
|
|
106
|
+
t.graphId,
|
|
107
|
+
t.kind,
|
|
108
|
+
t.deletedAt,
|
|
109
|
+
t.createdAt
|
|
110
|
+
),
|
|
80
111
|
pgCore.index(`${n.edges}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
81
112
|
pgCore.index(`${n.edges}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
82
113
|
pgCore.index(`${n.edges}_cardinality_idx`).on(
|
|
@@ -86,7 +117,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
86
117
|
t.fromId,
|
|
87
118
|
t.validTo
|
|
88
119
|
),
|
|
89
|
-
...
|
|
120
|
+
...chunkJQDWEX6V_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
90
121
|
]
|
|
91
122
|
);
|
|
92
123
|
const uniques2 = pgCore.pgTable(
|
|
@@ -166,5 +197,5 @@ exports.nodes = nodes;
|
|
|
166
197
|
exports.schemaVersions = schemaVersions;
|
|
167
198
|
exports.tables = tables;
|
|
168
199
|
exports.uniques = uniques;
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
200
|
+
//# sourceMappingURL=chunk-NU2XNMVI.cjs.map
|
|
201
|
+
//# sourceMappingURL=chunk-NU2XNMVI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/backend/drizzle/columns/vector.ts","../src/backend/drizzle/schema/postgres.ts"],"names":["customType","nodes","pgTable","text","jsonb","integer","timestamp","primaryKey","index","buildPostgresNodeIndexBuilders","edges","buildPostgresEdgeIndexBuilders","uniques","schemaVersions","boolean","embeddings"],"mappings":";;;;;AA0CO,IAAM,SAASA,iBAAA,CAInB;AAAA,EACD,SAAS,MAAA,EAAQ;AAEf,IAAA,OAAO,MAAA,EAAQ,UAAA,GAAa,CAAA,OAAA,EAAU,MAAA,CAAO,UAAU,CAAA,CAAA,CAAA,GAAM,QAAA;AAAA,EAC/D,CAAA;AAAA,EAEA,SAAS,KAAA,EAAyB;AAEhC,IAAA,OAAO,CAAA,CAAA,EAAI,KAAA,CAAM,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,EAC5B,CAAA;AAAA,EAEA,WAAW,KAAA,EAAyB;AAGlC,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACjC,IAAA,IAAI,YAAY,EAAA,EAAI;AAClB,MAAA,OAAO,EAAC;AAAA,IACV;AACA,IAAA,OAAO,OAA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c,EAAE,cAAc,IAAA,EAAM,EAAE,OAAA;AAAQ,KACrE;AAAA,IACA,CAAC,CAAA,KAAM;AAAA,MACLC,iBAAA,CAAW;AAAA,QACT,OAAA,EAAS,CAAC,CAAA,CAAE,OAAA,EAAS,EAAE,QAAA,EAAU,CAAA,CAAE,MAAA,EAAQ,CAAA,CAAE,SAAS;AAAA,OACvD,CAAA;AAAA;AAAA,MAEDC,YAAA,CAAM,CAAA,EAAG,CAAA,CAAE,UAAU,WAAW,CAAA,CAAE,EAAA;AAAA,QAChC,CAAA,CAAE,OAAA;AAAA,QACF,CAAA,CAAE,QAAA;AAAA,QACF,CAAA,CAAE;AAAA,OACJ;AAAA;AAAA,MAEAA,YAAA,CAAM,CAAA,EAAG,CAAA,CAAE,UAAU,iBAAiB,CAAA,CAAE,EAAA;AAAA,QACtC,CAAA,CAAE,OAAA;AAAA,QACF,CAAA,CAAE,QAAA;AAAA,QACF,CAAA,CAAE;AAAA;AACJ;AACF,GACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAAP,MAAAA,EAAO,KAAA,EAAAS,MAAAA,EAAO,SAAAE,QAAAA,EAAS,cAAA,EAAAC,eAAAA,EAAgB,UAAA,EAAAE,WAAAA,EAAW;AAC7D;AAKO,IAAM,SAAS,oBAAA;AAKf,IAAM,EAAE,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,cAAA,EAAgB,YAAW,GAAI","file":"chunk-NU2XNMVI.cjs","sourcesContent":["/**\n * Custom Drizzle column type for pgvector's VECTOR type.\n *\n * Provides native support for PostgreSQL vector embeddings without\n * requiring runtime casts in queries.\n *\n * @example\n * ```typescript\n * import { pgTable, text, integer } from \"drizzle-orm/pg-core\";\n * import { vector } from \"./columns/vector\";\n *\n * const embeddings = pgTable(\"embeddings\", {\n * id: text(\"id\").primaryKey(),\n * embedding: vector(\"embedding\"),\n * dimensions: integer(\"dimensions\"),\n * });\n * ```\n */\nimport { customType } from \"drizzle-orm/pg-core\";\n\n/**\n * PostgreSQL vector column type for pgvector extension.\n *\n * Stores embeddings as native VECTOR type, enabling efficient\n * similarity search without runtime casts.\n *\n * The column type is unparameterized (`VECTOR` not `VECTOR(N)`)\n * to support multiple embedding dimensions in a single table.\n * Dimension validation is handled at the application level.\n *\n * @example\n * ```typescript\n * // In table definition\n * embedding: vector(\"embedding\").notNull(),\n *\n * // In queries - no cast needed\n * db.execute(sql`\n * SELECT * FROM embeddings\n * WHERE embedding <=> ${formatVector([0.1, 0.2, 0.3])} < 0.5\n * `);\n * ```\n */\nexport const vector = customType<{\n data: number[];\n driverData: string;\n config: { dimensions?: number };\n}>({\n dataType(config) {\n // Use parameterized type if dimensions specified, otherwise unparameterized\n return config?.dimensions ? `vector(${config.dimensions})` : \"vector\";\n },\n\n toDriver(value: number[]): string {\n // Format as pgvector literal: [1.0,2.0,3.0]\n return `[${value.join(\",\")}]`;\n },\n\n fromDriver(value: string): number[] {\n // pgvector returns '[1,2,3]' format\n // Handle both string and already-parsed array (some drivers differ)\n if (Array.isArray(value)) {\n return value as number[];\n }\n // Parse the string representation\n const content = value.slice(1, -1); // Remove [ and ]\n if (content === \"\") {\n return [];\n }\n return content.split(\",\").map((s) => Number.parseFloat(s.trim()));\n },\n});\n\n/**\n * Formats a number array as a pgvector literal string.\n *\n * Use this when building raw SQL queries with embeddings.\n *\n * @example\n * ```typescript\n * const embedding = [0.1, 0.2, 0.3];\n * db.execute(sql`\n * SELECT * FROM embeddings\n * WHERE embedding <=> ${formatVector(embedding)}::vector < 0.5\n * `);\n * ```\n */\nexport function formatVector(embedding: readonly number[]): string {\n return `[${embedding.join(\",\")}]`;\n}\n","/**\n * Drizzle PostgreSQL schema for TypeGraph.\n *\n * Provides table definitions that can be customized via the factory function.\n * Uses PostgreSQL-native types: JSONB, TIMESTAMPTZ, BOOLEAN, VECTOR.\n *\n * The embeddings table uses pgvector's native VECTOR type. Ensure the\n * extension is enabled before creating tables:\n *\n * ```sql\n * CREATE EXTENSION IF NOT EXISTS vector;\n * ```\n *\n * @example\n * ```typescript\n * // Default table names\n * import { tables } from \"@nicia-ai/typegraph/drizzle/schema/postgres\";\n *\n * // Custom table names\n * import { createPostgresTables } from \"@nicia-ai/typegraph/drizzle/schema/postgres\";\n * const tables = createPostgresTables({\n * nodes: \"myapp_nodes\",\n * edges: \"myapp_edges\",\n * });\n * ```\n */\nimport {\n boolean,\n index,\n integer,\n jsonb,\n pgTable,\n primaryKey,\n text,\n timestamp,\n} from \"drizzle-orm/pg-core\";\n\nimport {\n buildPostgresEdgeIndexBuilders,\n buildPostgresNodeIndexBuilders,\n type TypeGraphIndex,\n} from \"../../../indexes\";\nimport { vector } from \"../columns/vector\";\n\n/**\n * Table name configuration.\n */\nexport type PostgresTableNames = Readonly<{\n nodes: string;\n edges: string;\n uniques: string;\n schemaVersions: string;\n embeddings: string;\n}>;\n\nexport type CreatePostgresTablesOptions = Readonly<{\n /**\n * Additional TypeGraph indexes to include in the Drizzle schema.\n *\n * These become first-class Drizzle indexes, so drizzle-kit migrations will\n * pick them up automatically.\n */\n indexes?: readonly TypeGraphIndex[] | undefined;\n}>;\n\nconst DEFAULT_TABLE_NAMES: PostgresTableNames = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n uniques: \"typegraph_node_uniques\",\n schemaVersions: \"typegraph_schema_versions\",\n embeddings: \"typegraph_node_embeddings\",\n};\n\n/**\n * Creates PostgreSQL table definitions with customizable table names.\n * Index names are derived from table names.\n */\nexport function createPostgresTables(\n names: Partial<PostgresTableNames> = {},\n options: CreatePostgresTablesOptions = {},\n) {\n const n: PostgresTableNames = { ...DEFAULT_TABLE_NAMES, ...names };\n const indexes = options.indexes ?? [];\n\n const nodes = pgTable(\n n.nodes,\n {\n graphId: text(\"graph_id\").notNull(),\n kind: text(\"kind\").notNull(),\n id: text(\"id\").notNull(),\n props: jsonb(\"props\").notNull(),\n version: integer(\"version\").notNull().default(1),\n validFrom: timestamp(\"valid_from\", { withTimezone: true }),\n validTo: timestamp(\"valid_to\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull(),\n deletedAt: timestamp(\"deleted_at\", { withTimezone: true }),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.kind, t.id] }),\n index(`${n.nodes}_kind_idx`).on(t.graphId, t.kind),\n index(`${n.nodes}_kind_created_idx`).on(\n t.graphId,\n t.kind,\n t.deletedAt,\n t.createdAt,\n ),\n index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),\n index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),\n ...buildPostgresNodeIndexBuilders(t, indexes),\n ],\n );\n\n const edges = pgTable(\n n.edges,\n {\n graphId: text(\"graph_id\").notNull(),\n id: text(\"id\").notNull(),\n kind: text(\"kind\").notNull(),\n fromKind: text(\"from_kind\").notNull(),\n fromId: text(\"from_id\").notNull(),\n toKind: text(\"to_kind\").notNull(),\n toId: text(\"to_id\").notNull(),\n props: jsonb(\"props\").notNull(),\n validFrom: timestamp(\"valid_from\", { withTimezone: true }),\n validTo: timestamp(\"valid_to\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull(),\n deletedAt: timestamp(\"deleted_at\", { withTimezone: true }),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.id] }),\n index(`${n.edges}_kind_idx`).on(t.graphId, t.kind),\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind.\n index(`${n.edges}_from_idx`).on(\n t.graphId,\n t.fromKind,\n t.fromId,\n t.kind,\n t.toKind,\n t.deletedAt,\n t.validTo,\n ),\n // Directional traversal index (incoming): mirrors from_idx for reverse traversals.\n index(`${n.edges}_to_idx`).on(\n t.graphId,\n t.toKind,\n t.toId,\n t.kind,\n t.fromKind,\n t.deletedAt,\n t.validTo,\n ),\n index(`${n.edges}_kind_created_idx`).on(\n t.graphId,\n t.kind,\n t.deletedAt,\n t.createdAt,\n ),\n index(`${n.edges}_deleted_idx`).on(t.graphId, t.deletedAt),\n index(`${n.edges}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),\n index(`${n.edges}_cardinality_idx`).on(\n t.graphId,\n t.kind,\n t.fromKind,\n t.fromId,\n t.validTo,\n ),\n ...buildPostgresEdgeIndexBuilders(t, indexes),\n ],\n );\n\n const uniques = pgTable(\n n.uniques,\n {\n graphId: text(\"graph_id\").notNull(),\n nodeKind: text(\"node_kind\").notNull(),\n constraintName: text(\"constraint_name\").notNull(),\n key: text(\"key\").notNull(),\n nodeId: text(\"node_id\").notNull(),\n concreteKind: text(\"concrete_kind\").notNull(),\n deletedAt: timestamp(\"deleted_at\", { withTimezone: true }),\n },\n (t) => [\n primaryKey({\n columns: [t.graphId, t.nodeKind, t.constraintName, t.key],\n }),\n index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId),\n ],\n );\n\n const schemaVersions = pgTable(\n n.schemaVersions,\n {\n graphId: text(\"graph_id\").notNull(),\n version: integer(\"version\").notNull(),\n schemaHash: text(\"schema_hash\").notNull(),\n schemaDoc: jsonb(\"schema_doc\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull(),\n isActive: boolean(\"is_active\").notNull().default(false),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.version] }),\n index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),\n ],\n );\n\n /**\n * Embeddings table for vector search.\n *\n * Stores embeddings using pgvector's native VECTOR type for efficient\n * similarity operations without runtime casts.\n *\n * The column uses unparameterized VECTOR type to support multiple\n * embedding dimensions in a single table. Dimension validation is\n * handled at the application level via the `dimensions` column.\n *\n * Requires pgvector extension:\n * CREATE EXTENSION IF NOT EXISTS vector;\n *\n * Vector indices (HNSW, IVFFlat) are created dynamically based on the\n * configured metric and dimensions.\n */\n const embeddings = pgTable(\n n.embeddings,\n {\n graphId: text(\"graph_id\").notNull(),\n nodeKind: text(\"node_kind\").notNull(),\n nodeId: text(\"node_id\").notNull(),\n fieldPath: text(\"field_path\").notNull(),\n /** Embedding vector stored as native pgvector type */\n embedding: vector(\"embedding\").notNull(),\n /** Number of dimensions (for validation) */\n dimensions: integer(\"dimensions\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true }).notNull(),\n },\n (t) => [\n primaryKey({\n columns: [t.graphId, t.nodeKind, t.nodeId, t.fieldPath],\n }),\n // Index for looking up embeddings by node\n index(`${n.embeddings}_node_idx`).on(\n t.graphId,\n t.nodeKind,\n t.nodeId,\n ),\n // Index for filtering by kind and field (used in vector search)\n index(`${n.embeddings}_kind_field_idx`).on(\n t.graphId,\n t.nodeKind,\n t.fieldPath,\n ),\n ],\n );\n\n return { nodes, edges, uniques, schemaVersions, embeddings } as const;\n}\n\n/**\n * Default tables with standard TypeGraph table names.\n */\nexport const tables = createPostgresTables();\n\n/**\n * Convenience exports for default tables.\n */\nexport const { nodes, edges, uniques, schemaVersions, embeddings } = tables;\n\n/**\n * Type representing the tables object returned by createPostgresTables.\n */\nexport type PostgresTables = ReturnType<typeof createPostgresTables>;\n\n/**\n * Type for nodes table.\n */\nexport type NodesTable = PostgresTables[\"nodes\"];\n\n/**\n * Type for edges table.\n */\nexport type EdgesTable = PostgresTables[\"edges\"];\n\n/**\n * Type for uniques table.\n */\nexport type UniquesTable = PostgresTables[\"uniques\"];\n\n/**\n * Type for schema versions table.\n */\nexport type SchemaVersionsTable = PostgresTables[\"schemaVersions\"];\n\n/**\n * Type for embeddings table.\n */\nexport type EmbeddingsTable = PostgresTables[\"embeddings\"];\n"]}
|
|
@@ -266,6 +266,17 @@ var ConfigurationError = class extends TypeGraphError {
|
|
|
266
266
|
this.name = "ConfigurationError";
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
|
+
var DatabaseOperationError = class extends TypeGraphError {
|
|
270
|
+
constructor(message, details, options) {
|
|
271
|
+
super(message, "DATABASE_OPERATION_ERROR", {
|
|
272
|
+
details,
|
|
273
|
+
category: "system",
|
|
274
|
+
suggestion: `This is a system-level database error. Check the database connection and retry the operation. If the problem persists, investigate the underlying cause.`,
|
|
275
|
+
cause: options?.cause
|
|
276
|
+
});
|
|
277
|
+
this.name = "DatabaseOperationError";
|
|
278
|
+
}
|
|
279
|
+
};
|
|
269
280
|
var UnsupportedPredicateError = class extends TypeGraphError {
|
|
270
281
|
constructor(message, details = {}, options) {
|
|
271
282
|
super(message, "UNSUPPORTED_PREDICATE", {
|
|
@@ -277,6 +288,17 @@ var UnsupportedPredicateError = class extends TypeGraphError {
|
|
|
277
288
|
this.name = "UnsupportedPredicateError";
|
|
278
289
|
}
|
|
279
290
|
};
|
|
291
|
+
var CompilerInvariantError = class extends TypeGraphError {
|
|
292
|
+
constructor(message, details, options) {
|
|
293
|
+
super(message, "COMPILER_INVARIANT_ERROR", {
|
|
294
|
+
details: details ?? {},
|
|
295
|
+
category: "system",
|
|
296
|
+
suggestion: `This is an internal compiler error. Please report it as a bug with the query that triggered it.`,
|
|
297
|
+
cause: options?.cause
|
|
298
|
+
});
|
|
299
|
+
this.name = "CompilerInvariantError";
|
|
300
|
+
}
|
|
301
|
+
};
|
|
280
302
|
function isTypeGraphError(error) {
|
|
281
303
|
return error instanceof TypeGraphError;
|
|
282
304
|
}
|
|
@@ -294,6 +316,6 @@ function getErrorSuggestion(error) {
|
|
|
294
316
|
return isTypeGraphError(error) ? error.suggestion : void 0;
|
|
295
317
|
}
|
|
296
318
|
|
|
297
|
-
export { CardinalityError, ConfigurationError, DisjointError, EdgeNotFoundError, EndpointError, EndpointNotFoundError, KindNotFoundError, MigrationError, NodeNotFoundError, RestrictedDeleteError, SchemaMismatchError, TypeGraphError, UniquenessError, UnsupportedPredicateError, ValidationError, VersionConflictError, getErrorSuggestion, isConstraintError, isSystemError, isTypeGraphError, isUserRecoverable };
|
|
298
|
-
//# sourceMappingURL=chunk-
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
319
|
+
export { CardinalityError, CompilerInvariantError, ConfigurationError, DatabaseOperationError, DisjointError, EdgeNotFoundError, EndpointError, EndpointNotFoundError, KindNotFoundError, MigrationError, NodeNotFoundError, RestrictedDeleteError, SchemaMismatchError, TypeGraphError, UniquenessError, UnsupportedPredicateError, ValidationError, VersionConflictError, getErrorSuggestion, isConstraintError, isSystemError, isTypeGraphError, isUserRecoverable };
|
|
320
|
+
//# sourceMappingURL=chunk-O5XPCJLF.js.map
|
|
321
|
+
//# sourceMappingURL=chunk-O5XPCJLF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors/index.ts"],"names":[],"mappings":";AAmDA,SAAS,YAAY,KAAA,EAAwB;AAC3C,EAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,IAAA,OAAO,KAAA,CAAM,SAAS,KAAA,CAAM,OAAA;AAAA,EAC9B;AACA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IACE,OAAO,UAAU,QAAA,IACjB,OAAO,UAAU,SAAA,IACjB,OAAO,UAAU,QAAA,EACjB;AACA,IAAA,OAAO,OAAO,KAAK,CAAA;AAAA,EACrB;AACA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,MAAM,WAAA,IAAe,QAAA;AAAA,EAC9B;AACA,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,UAAU,KAAK,CAAA;AAAA,EAC7B,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,CAAA,sBAAA,EACL,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,eAC3C,CAAA,CAAA;AAAA,EACF;AACF;AAYO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA;AAA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O,SAAS,iBAAiB,KAAA,EAAyC;AACxE,EAAA,OAAO,KAAA,YAAiB,cAAA;AAC1B;AAmBO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,IAAI,CAAC,gBAAA,CAAiB,KAAK,CAAA,EAAG,OAAO,KAAA;AACrC,EAAA,OAAO,KAAA,CAAM,QAAA,KAAa,MAAA,IAAU,KAAA,CAAM,QAAA,KAAa,YAAA;AACzD;AAUO,SAAS,cAAc,KAAA,EAAyB;AACrD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,QAAA;AACvD;AAKO,SAAS,kBAAkB,KAAA,EAAyB;AACzD,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,IAAK,KAAA,CAAM,QAAA,KAAa,YAAA;AACvD;AAKO,SAAS,mBAAmB,KAAA,EAAoC;AACrE,EAAA,OAAO,gBAAA,CAAiB,KAAK,CAAA,GAAI,KAAA,CAAM,UAAA,GAAa,MAAA;AACtD","file":"chunk-O5XPCJLF.js","sourcesContent":["/**\n * TypeGraph Error Hierarchy\n *\n * All errors extend TypeGraphError with:\n * - `code`: Machine-readable error code for programmatic handling\n * - `category`: Classification for error handling strategies\n * - `suggestion`: Optional recovery guidance for users\n * - `details`: Structured context about the error\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ name: \"\" });\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.error(error.toUserMessage());\n * if (isUserRecoverable(error)) {\n * // Show to user for correction\n * }\n * }\n * }\n * ```\n */\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Error category for programmatic handling.\n *\n * - `user`: Caused by invalid input or incorrect usage. Recoverable by fixing input.\n * - `constraint`: Business rule or schema constraint violation. Recoverable by changing data.\n * - `system`: Internal error or infrastructure issue. May require investigation or retry.\n */\nexport type ErrorCategory = \"user\" | \"constraint\" | \"system\";\n\n/**\n * Options for TypeGraphError constructor.\n */\nexport type TypeGraphErrorOptions = Readonly<{\n /** Structured context about the error */\n details?: Record<string, unknown>;\n /** Error category for handling strategies */\n category: ErrorCategory;\n /** Recovery guidance for users */\n suggestion?: string;\n /** Underlying cause of the error */\n cause?: unknown;\n}>;\n\nfunction formatCause(cause: unknown): string {\n if (cause instanceof Error) {\n return cause.stack ?? cause.message;\n }\n if (typeof cause === \"string\") {\n return cause;\n }\n if (\n typeof cause === \"number\" ||\n typeof cause === \"boolean\" ||\n typeof cause === \"bigint\"\n ) {\n return String(cause);\n }\n if (typeof cause === \"symbol\") {\n return cause.description ?? \"Symbol\";\n }\n if (cause === undefined) {\n return \"Unknown cause\";\n }\n\n try {\n return JSON.stringify(cause);\n } catch (error) {\n return `Unserializable cause: ${\n error instanceof Error ? error.message : \"Unknown error\"\n }`;\n }\n}\n\n// ============================================================\n// Base Error\n// ============================================================\n\n/**\n * Base error class for all TypeGraph errors.\n *\n * Provides structured error information for both programmatic handling\n * and user-friendly messages.\n */\nexport class TypeGraphError extends Error {\n /** Machine-readable error code (e.g., \"VALIDATION_ERROR\") */\n readonly code: string;\n\n /** Error category for handling strategies */\n readonly category: ErrorCategory;\n\n /** Structured context about the error */\n readonly details: Readonly<Record<string, unknown>>;\n\n /** Recovery guidance for users */\n readonly suggestion?: string;\n\n constructor(message: string, code: string, options: TypeGraphErrorOptions) {\n super(message, options.cause ? { cause: options.cause } : undefined);\n this.name = \"TypeGraphError\";\n this.code = code;\n this.category = options.category;\n this.details = Object.freeze(options.details ?? {});\n if (options.suggestion !== undefined) {\n this.suggestion = options.suggestion;\n }\n }\n\n /**\n * Returns a user-friendly error message with suggestion if available.\n */\n toUserMessage(): string {\n if (this.suggestion) {\n return `${this.message}\\n\\nSuggestion: ${this.suggestion}`;\n }\n return this.message;\n }\n\n /**\n * Returns a detailed string representation for logging.\n */\n toLogString(): string {\n const lines = [\n `[${this.code}] ${this.message}`,\n ` Category: ${this.category}`,\n ];\n\n if (this.suggestion) {\n lines.push(` Suggestion: ${this.suggestion}`);\n }\n\n const detailKeys = Object.keys(this.details);\n if (detailKeys.length > 0) {\n lines.push(` Details: ${JSON.stringify(this.details)}`);\n }\n\n if (this.cause) {\n lines.push(` Cause: ${formatCause(this.cause)}`);\n }\n\n return lines.join(\"\\n\");\n }\n}\n\n// ============================================================\n// Validation Errors (category: \"user\")\n// ============================================================\n\n/**\n * Validation issue from Zod or custom validation.\n */\nexport type ValidationIssue = Readonly<{\n /** Path to the invalid field (e.g., \"address.city\") */\n path: string;\n /** Human-readable error message */\n message: string;\n /** Zod error code if from Zod validation */\n code?: string;\n}>;\n\n/**\n * Details for ValidationError.\n */\nexport type ValidationErrorDetails = Readonly<{\n /** Type of entity being validated */\n entityType?: \"node\" | \"edge\";\n /** Kind/type name of the entity */\n kind?: string;\n /** Operation being performed */\n operation?: \"create\" | \"update\";\n /** Entity ID if updating */\n id?: string;\n /** Individual validation issues */\n issues: readonly ValidationIssue[];\n}>;\n\n/**\n * Thrown when schema validation fails during node or edge operations.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({ email: \"invalid\" });\n * } catch (error) {\n * if (error instanceof ValidationError) {\n * console.log(error.details.issues);\n * // [{ path: \"email\", message: \"Invalid email\" }]\n * }\n * }\n * ```\n */\nexport class ValidationError extends TypeGraphError {\n declare readonly details: ValidationErrorDetails;\n\n constructor(\n message: string,\n details: ValidationErrorDetails,\n options?: { cause?: unknown; suggestion?: string },\n ) {\n const fieldList =\n details.issues.length > 0 ?\n details.issues.map((index) => index.path || \"(root)\").join(\", \")\n : \"unknown\";\n\n super(message, \"VALIDATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ??\n `Check the following fields: ${fieldList}. See error.details.issues for specific validation failures.`,\n cause: options?.cause,\n });\n this.name = \"ValidationError\";\n }\n}\n\n// ============================================================\n// Not Found Errors (category: \"user\")\n// ============================================================\n\n/**\n * Thrown when a node is not found.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.get(\"nonexistent-id\");\n * } catch (error) {\n * if (error instanceof NodeNotFoundError) {\n * console.log(error.details.kind, error.details.id);\n * }\n * }\n * ```\n */\nexport class NodeNotFoundError extends TypeGraphError {\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Node not found: ${kind}/${id}`, \"NODE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the node ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"NodeNotFoundError\";\n }\n}\n\n/**\n * Thrown when an edge is not found.\n */\nexport class EdgeNotFoundError extends TypeGraphError {\n constructor(kind: string, id: string, options?: { cause?: unknown }) {\n super(`Edge not found: ${kind}/${id}`, \"EDGE_NOT_FOUND\", {\n details: { kind, id },\n category: \"user\",\n suggestion: `Verify the edge ID \"${id}\" exists and has not been deleted.`,\n cause: options?.cause,\n });\n this.name = \"EdgeNotFoundError\";\n }\n}\n\n/**\n * Thrown when a kind is not found in the graph registry.\n */\nexport class KindNotFoundError extends TypeGraphError {\n constructor(\n kind: string,\n type: \"node\" | \"edge\",\n options?: { cause?: unknown },\n ) {\n super(\n `${type === \"node\" ? \"Node\" : \"Edge\"} kind not found: ${kind}`,\n \"KIND_NOT_FOUND\",\n {\n details: { kind, type },\n category: \"user\",\n suggestion: `Verify \"${kind}\" is defined in your graph schema and spelled correctly.`,\n cause: options?.cause,\n },\n );\n this.name = \"KindNotFoundError\";\n }\n}\n\n// ============================================================\n// Constraint Errors (category: \"constraint\")\n// ============================================================\n\n/**\n * Thrown when edge endpoint node does not exist or is deleted.\n */\nexport class EndpointNotFoundError extends TypeGraphError {\n constructor(\n details: Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n nodeKind: string;\n nodeId: string;\n }>,\n options?: { cause?: unknown },\n ) {\n super(\n `Endpoint node not found for edge \"${details.edgeKind}\": ${details.nodeKind}/${details.nodeId} (${details.endpoint})`,\n \"ENDPOINT_NOT_FOUND\",\n {\n details,\n category: \"constraint\",\n suggestion: `Ensure the ${details.endpoint} node exists before creating the edge.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointNotFoundError\";\n }\n}\n\n/**\n * Thrown when edge endpoint has wrong node type.\n */\nexport class EndpointError extends TypeGraphError {\n constructor(\n details: Readonly<{\n edgeKind: string;\n endpoint: \"from\" | \"to\";\n actualKind: string;\n expectedKinds: readonly string[];\n }>,\n options?: { cause?: unknown },\n ) {\n const expected = details.expectedKinds.join(\" | \");\n super(\n `Invalid ${details.endpoint} endpoint for edge \"${details.edgeKind}\": got \"${details.actualKind}\", expected ${expected}`,\n \"ENDPOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a node of type ${expected} as the ${details.endpoint} endpoint.`,\n cause: options?.cause,\n },\n );\n this.name = \"EndpointError\";\n }\n}\n\n/**\n * Thrown when uniqueness constraint is violated.\n */\nexport class UniquenessError extends TypeGraphError {\n constructor(\n details: Readonly<{\n constraintName: string;\n kind: string;\n existingId: string;\n newId: string;\n fields: readonly string[];\n }>,\n options?: { cause?: unknown },\n ) {\n const fieldList = details.fields.join(\", \");\n super(\n `Uniqueness violation on \"${details.kind}\": constraint \"${details.constraintName}\" (fields: ${fieldList}) conflicts with existing node ${details.existingId}`,\n \"UNIQUENESS_VIOLATION\",\n {\n details,\n category: \"constraint\",\n suggestion: `Change the values for fields [${fieldList}] to be unique, or update the existing node ${details.existingId} instead.`,\n cause: options?.cause,\n },\n );\n this.name = \"UniquenessError\";\n }\n}\n\n/**\n * Thrown when cardinality constraint is violated.\n */\nexport class CardinalityError extends TypeGraphError {\n constructor(\n details: Readonly<{\n edgeKind: string;\n fromKind: string;\n fromId: string;\n cardinality: string;\n existingCount: number;\n }>,\n options?: { cause?: unknown },\n ) {\n super(\n `Cardinality violation: \"${details.edgeKind}\" from ${details.fromKind}/${details.fromId} allows \"${details.cardinality}\" but ${details.existingCount} edge(s) already exist`,\n \"CARDINALITY_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion:\n details.cardinality === \"one\" || details.cardinality === \"unique\" ?\n `Delete the existing edge before creating a new one, or use cardinality \"many\".`\n : `Check if the cardinality constraint \"${details.cardinality}\" is correct for your use case.`,\n cause: options?.cause,\n },\n );\n this.name = \"CardinalityError\";\n }\n}\n\n/**\n * Thrown when disjointness constraint is violated.\n *\n * Disjoint types cannot share the same ID - a node cannot be both\n * a Person and an Organization if they are declared disjoint.\n */\nexport class DisjointError extends TypeGraphError {\n constructor(\n details: Readonly<{\n nodeId: string;\n attemptedKind: string;\n conflictingKind: string;\n }>,\n options?: { cause?: unknown },\n ) {\n super(\n `Disjoint constraint violation: cannot create ${details.attemptedKind} with ID \"${details.nodeId}\" - conflicts with existing ${details.conflictingKind}`,\n \"DISJOINT_ERROR\",\n {\n details,\n category: \"constraint\",\n suggestion: `Use a different ID for the new ${details.attemptedKind} node, or delete the existing ${details.conflictingKind}/${details.nodeId} first.`,\n cause: options?.cause,\n },\n );\n this.name = \"DisjointError\";\n }\n}\n\n/**\n * Thrown when deletion is blocked due to existing edges (restrict behavior).\n */\nexport class RestrictedDeleteError extends TypeGraphError {\n constructor(\n details: Readonly<{\n nodeKind: string;\n nodeId: string;\n edgeCount: number;\n edgeKinds: readonly string[];\n }>,\n options?: { cause?: unknown },\n ) {\n const edgeList = details.edgeKinds.join(\", \");\n super(\n `Cannot delete ${details.nodeKind}/${details.nodeId}: ${details.edgeCount} connected edge(s) exist (${edgeList})`,\n \"RESTRICTED_DELETE\",\n {\n details,\n category: \"constraint\",\n suggestion: `Delete the connected edges first, or change onDelete behavior to \"cascade\" (auto-delete edges) or \"disconnect\" (soft-delete edges).`,\n cause: options?.cause,\n },\n );\n this.name = \"RestrictedDeleteError\";\n }\n}\n\n// ============================================================\n// Concurrency Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when optimistic locking detects a concurrent modification.\n *\n * This occurs when two operations try to update the same entity simultaneously.\n * The operation with the stale version fails.\n */\nexport class VersionConflictError extends TypeGraphError {\n constructor(\n details: Readonly<{\n kind: string;\n id: string;\n expectedVersion: number;\n actualVersion: number;\n }>,\n options?: { cause?: unknown },\n ) {\n super(\n `Version conflict on ${details.kind}/${details.id}: expected version ${details.expectedVersion}, found ${details.actualVersion}`,\n \"VERSION_CONFLICT\",\n {\n details,\n category: \"system\",\n suggestion: `Fetch the latest version of the entity and retry the operation. This error indicates concurrent modification.`,\n cause: options?.cause,\n },\n );\n this.name = \"VersionConflictError\";\n }\n}\n\n// ============================================================\n// Schema Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when the schema in code doesn't match the schema in the database.\n */\nexport class SchemaMismatchError extends TypeGraphError {\n constructor(\n details: Readonly<{\n graphId: string;\n expectedHash: string;\n actualHash: string;\n }>,\n options?: { cause?: unknown },\n ) {\n super(\n `Schema mismatch for graph \"${details.graphId}\": code schema differs from database schema`,\n \"SCHEMA_MISMATCH\",\n {\n details,\n category: \"system\",\n suggestion: `Run schema migration to update the database, or use createStoreWithSchema() for automatic migration.`,\n cause: options?.cause,\n },\n );\n this.name = \"SchemaMismatchError\";\n }\n}\n\n/**\n * Thrown when schema migration fails.\n */\nexport class MigrationError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<{\n graphId: string;\n fromVersion: number;\n toVersion: number;\n reason?: string;\n }>,\n options?: { cause?: unknown },\n ) {\n super(message, \"MIGRATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `Review the schema changes and ensure they are backwards compatible, or implement a data migration.`,\n cause: options?.cause,\n });\n this.name = \"MigrationError\";\n }\n}\n\n// ============================================================\n// Configuration Errors (category: \"user\")\n// ============================================================\n\n/**\n * Thrown when graph configuration is invalid.\n *\n * This includes invalid schema definitions, ontology conflicts,\n * and other configuration issues detected at graph creation time.\n */\nexport class ConfigurationError extends TypeGraphError {\n constructor(\n message: string,\n details: Record<string, unknown> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"CONFIGURATION_ERROR\", {\n details,\n category: \"user\",\n suggestion:\n options?.suggestion ?? `Review your graph definition for errors.`,\n cause: options?.cause,\n });\n this.name = \"ConfigurationError\";\n }\n}\n\n// ============================================================\n// Database Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a database operation fails unexpectedly.\n *\n * This indicates a system-level failure in the database backend,\n * not a user-recoverable error.\n */\nexport class DatabaseOperationError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<{ operation: string; entity: string }>,\n options?: { cause?: unknown },\n ) {\n super(message, \"DATABASE_OPERATION_ERROR\", {\n details,\n category: \"system\",\n suggestion: `This is a system-level database error. Check the database connection and retry the operation. If the problem persists, investigate the underlying cause.`,\n cause: options?.cause,\n });\n this.name = \"DatabaseOperationError\";\n }\n}\n\n// ============================================================\n// Query Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a query predicate cannot be compiled for the target database.\n */\nexport class UnsupportedPredicateError extends TypeGraphError {\n constructor(\n message: string,\n details: Readonly<Record<string, unknown>> = {},\n options?: { cause?: unknown; suggestion?: string },\n ) {\n super(message, \"UNSUPPORTED_PREDICATE\", {\n details,\n category: \"system\",\n suggestion:\n options?.suggestion ??\n `This predicate may not be supported by your database backend. Check the documentation for supported predicates.`,\n cause: options?.cause,\n });\n this.name = \"UnsupportedPredicateError\";\n }\n}\n\n// ============================================================\n// Compiler Errors (category: \"system\")\n// ============================================================\n\n/**\n * Thrown when a compiler invariant is violated.\n *\n * This indicates a bug in the query compiler — the compiler reached\n * a state that should be unreachable. These errors are not user-recoverable.\n */\nexport class CompilerInvariantError extends TypeGraphError {\n constructor(\n message: string,\n details?: Readonly<Record<string, unknown>>,\n options?: { cause?: unknown },\n ) {\n super(message, \"COMPILER_INVARIANT_ERROR\", {\n details: details ?? {},\n category: \"system\",\n suggestion: `This is an internal compiler error. Please report it as a bug with the query that triggered it.`,\n cause: options?.cause,\n });\n this.name = \"CompilerInvariantError\";\n }\n}\n\n// ============================================================\n// Utility Functions\n// ============================================================\n\n/**\n * Type guard for TypeGraphError.\n *\n * @example\n * ```typescript\n * try {\n * await store.nodes.Person.create({});\n * } catch (error) {\n * if (isTypeGraphError(error)) {\n * console.log(error.code, error.category);\n * }\n * }\n * ```\n */\nexport function isTypeGraphError(error: unknown): error is TypeGraphError {\n return error instanceof TypeGraphError;\n}\n\n/**\n * Check if error is recoverable by user action (user or constraint error).\n *\n * User-recoverable errors can typically be resolved by:\n * - Fixing invalid input data\n * - Using different IDs or values\n * - Deleting conflicting data first\n *\n * @example\n * ```typescript\n * if (isUserRecoverable(error)) {\n * showErrorToUser(error.toUserMessage());\n * } else {\n * logAndAlertOps(error);\n * }\n * ```\n */\nexport function isUserRecoverable(error: unknown): boolean {\n if (!isTypeGraphError(error)) return false;\n return error.category === \"user\" || error.category === \"constraint\";\n}\n\n/**\n * Check if error indicates a system/infrastructure issue.\n *\n * System errors typically require:\n * - Retry logic (for transient failures)\n * - Investigation (for persistent failures)\n * - Ops team notification\n */\nexport function isSystemError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"system\";\n}\n\n/**\n * Check if error is a constraint violation.\n */\nexport function isConstraintError(error: unknown): boolean {\n return isTypeGraphError(error) && error.category === \"constraint\";\n}\n\n/**\n * Extract suggestion from error if available.\n */\nexport function getErrorSuggestion(error: unknown): string | undefined {\n return isTypeGraphError(error) ? error.suggestion : undefined;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-
|
|
1
|
+
import { buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-U3452TEU.js';
|
|
2
2
|
import { sqliteTable, text, integer, primaryKey, index, blob } from 'drizzle-orm/sqlite-core';
|
|
3
3
|
|
|
4
4
|
var DEFAULT_TABLE_NAMES = {
|
|
@@ -28,6 +28,12 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
28
28
|
(t) => [
|
|
29
29
|
primaryKey({ columns: [t.graphId, t.kind, t.id] }),
|
|
30
30
|
index(`${n.nodes}_kind_idx`).on(t.graphId, t.kind),
|
|
31
|
+
index(`${n.nodes}_kind_created_idx`).on(
|
|
32
|
+
t.graphId,
|
|
33
|
+
t.kind,
|
|
34
|
+
t.deletedAt,
|
|
35
|
+
t.createdAt
|
|
36
|
+
),
|
|
31
37
|
index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
32
38
|
index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
33
39
|
...buildSqliteNodeIndexBuilders(t, indexes)
|
|
@@ -53,8 +59,33 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
53
59
|
(t) => [
|
|
54
60
|
primaryKey({ columns: [t.graphId, t.id] }),
|
|
55
61
|
index(`${n.edges}_kind_idx`).on(t.graphId, t.kind),
|
|
56
|
-
index(
|
|
57
|
-
|
|
62
|
+
// Directional traversal index (outgoing): supports endpoint lookups
|
|
63
|
+
// and extra filtering by edge kind / target kind.
|
|
64
|
+
index(`${n.edges}_from_idx`).on(
|
|
65
|
+
t.graphId,
|
|
66
|
+
t.fromKind,
|
|
67
|
+
t.fromId,
|
|
68
|
+
t.kind,
|
|
69
|
+
t.toKind,
|
|
70
|
+
t.deletedAt,
|
|
71
|
+
t.validTo
|
|
72
|
+
),
|
|
73
|
+
// Directional traversal index (incoming): mirrors from_idx for reverse traversals.
|
|
74
|
+
index(`${n.edges}_to_idx`).on(
|
|
75
|
+
t.graphId,
|
|
76
|
+
t.toKind,
|
|
77
|
+
t.toId,
|
|
78
|
+
t.kind,
|
|
79
|
+
t.fromKind,
|
|
80
|
+
t.deletedAt,
|
|
81
|
+
t.validTo
|
|
82
|
+
),
|
|
83
|
+
index(`${n.edges}_kind_created_idx`).on(
|
|
84
|
+
t.graphId,
|
|
85
|
+
t.kind,
|
|
86
|
+
t.deletedAt,
|
|
87
|
+
t.createdAt
|
|
88
|
+
),
|
|
58
89
|
index(`${n.edges}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
59
90
|
index(`${n.edges}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
60
91
|
index(`${n.edges}_cardinality_idx`).on(
|
|
@@ -142,5 +173,5 @@ var tables = createSqliteTables();
|
|
|
142
173
|
var { nodes, edges, uniques, schemaVersions, embeddings } = tables;
|
|
143
174
|
|
|
144
175
|
export { createSqliteTables, edges, embeddings, nodes, schemaVersions, tables, uniques };
|
|
145
|
-
//# sourceMappingURL=chunk-
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
176
|
+
//# sourceMappingURL=chunk-OGGLFYFA.js.map
|
|
177
|
+
//# sourceMappingURL=chunk-OGGLFYFA.js.map
|