@nicia-ai/typegraph 0.31.0 → 0.33.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 +31 -0
- package/dist/backend/postgres/index.cjs +31 -18
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +9 -8
- package/dist/backend/postgres/pglite.cjs +13 -12
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +9 -8
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +29 -16
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +8 -7
- package/dist/backend/sqlite/libsql.cjs +13 -12
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +9 -8
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +14 -13
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +9 -8
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-SFFJ2IKN.cjs → chunk-3642VBVC.cjs} +70 -68
- package/dist/chunk-3642VBVC.cjs.map +1 -0
- package/dist/chunk-3E7SNSIA.cjs +55 -0
- package/dist/chunk-3E7SNSIA.cjs.map +1 -0
- package/dist/{chunk-6RMLO5O4.cjs → chunk-3IR2GEMJ.cjs} +8 -7
- package/dist/chunk-3IR2GEMJ.cjs.map +1 -0
- package/dist/{chunk-6SA7UIQJ.cjs → chunk-3QRBXYT5.cjs} +6 -6
- package/dist/{chunk-6SA7UIQJ.cjs.map → chunk-3QRBXYT5.cjs.map} +1 -1
- package/dist/{chunk-54JVNOAQ.cjs → chunk-4RBAJVEC.cjs} +128 -6
- package/dist/chunk-4RBAJVEC.cjs.map +1 -0
- package/dist/{chunk-IJORSAC3.js → chunk-6NRFUHMS.js} +4 -3
- package/dist/chunk-6NRFUHMS.js.map +1 -0
- package/dist/{chunk-FLOI7QOT.cjs → chunk-BF3ZDEUE.cjs} +104 -72
- package/dist/chunk-BF3ZDEUE.cjs.map +1 -0
- package/dist/{chunk-2HZGWCB4.js → chunk-C4C4Q7A6.js} +3 -3
- package/dist/chunk-C4C4Q7A6.js.map +1 -0
- package/dist/{chunk-O4VUR6SI.js → chunk-CEF2QOTO.js} +3 -3
- package/dist/{chunk-O4VUR6SI.js.map → chunk-CEF2QOTO.js.map} +1 -1
- package/dist/{chunk-V4IQYOQ4.cjs → chunk-CFNT3ITG.cjs} +3 -3
- package/dist/chunk-CFNT3ITG.cjs.map +1 -0
- package/dist/{chunk-LJLMDDCW.js → chunk-CWFPJ3RC.js} +3 -3
- package/dist/{chunk-LJLMDDCW.js.map → chunk-CWFPJ3RC.js.map} +1 -1
- package/dist/{chunk-RZ4DH4E7.cjs → chunk-D3EWZ67S.cjs} +3348 -2030
- package/dist/chunk-D3EWZ67S.cjs.map +1 -0
- package/dist/{chunk-GKFWM3DS.js → chunk-DJYRRDHA.js} +124 -5
- package/dist/chunk-DJYRRDHA.js.map +1 -0
- package/dist/{chunk-YQGLVWB2.cjs → chunk-EF3Z645U.cjs} +2 -52
- package/dist/chunk-EF3Z645U.cjs.map +1 -0
- package/dist/{chunk-ASYQDPPU.cjs → chunk-FDN43KXV.cjs} +19 -19
- package/dist/{chunk-ASYQDPPU.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
- package/dist/chunk-GYVBEZAO.js +120 -0
- package/dist/chunk-GYVBEZAO.js.map +1 -0
- package/dist/chunk-I4W7MKVG.cjs +1526 -0
- package/dist/chunk-I4W7MKVG.cjs.map +1 -0
- package/dist/{chunk-MXE2U3EX.js → chunk-IZ4PCL47.js} +3 -52
- package/dist/chunk-IZ4PCL47.js.map +1 -0
- package/dist/{chunk-4A4GUZTQ.js → chunk-JHOBXD7O.js} +10 -8
- package/dist/chunk-JHOBXD7O.js.map +1 -0
- package/dist/{chunk-CIINW6PS.cjs → chunk-KY5SDVA7.cjs} +676 -635
- package/dist/chunk-KY5SDVA7.cjs.map +1 -0
- package/dist/{chunk-N2MBPTAF.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
- package/dist/{chunk-N2MBPTAF.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
- package/dist/{chunk-7JGLPAFV.cjs → chunk-MBLXCV2Y.cjs} +16 -16
- package/dist/chunk-MBLXCV2Y.cjs.map +1 -0
- package/dist/{chunk-5DTPBFX5.cjs → chunk-NG5N7R45.cjs} +28 -28
- package/dist/{chunk-5DTPBFX5.cjs.map → chunk-NG5N7R45.cjs.map} +1 -1
- package/dist/chunk-OIE2UPVG.cjs +126 -0
- package/dist/chunk-OIE2UPVG.cjs.map +1 -0
- package/dist/{chunk-STP7QVUB.js → chunk-OS6KS3HV.js} +43 -11
- package/dist/chunk-OS6KS3HV.js.map +1 -0
- package/dist/{chunk-2ZY4K43M.js → chunk-PIHXFF73.js} +3 -3
- package/dist/{chunk-2ZY4K43M.js.map → chunk-PIHXFF73.js.map} +1 -1
- package/dist/{chunk-ATTXBMAX.js → chunk-PRMKPFN5.js} +3 -3
- package/dist/{chunk-ATTXBMAX.js.map → chunk-PRMKPFN5.js.map} +1 -1
- package/dist/chunk-PYD3UCDU.js +1480 -0
- package/dist/chunk-PYD3UCDU.js.map +1 -0
- package/dist/{chunk-MAQJYNJR.js → chunk-QBYTJSAY.js} +14 -16
- package/dist/chunk-QBYTJSAY.js.map +1 -0
- package/dist/{chunk-THX25XW6.js → chunk-SPT5JMME.js} +27 -7
- package/dist/chunk-SPT5JMME.js.map +1 -0
- package/dist/{chunk-3JBJEYWE.cjs → chunk-SST7XDY6.cjs} +32 -12
- package/dist/chunk-SST7XDY6.cjs.map +1 -0
- package/dist/{chunk-VZX2KSY3.js → chunk-UPDMJEW6.js} +608 -563
- package/dist/chunk-UPDMJEW6.js.map +1 -0
- package/dist/{chunk-UIFEEPME.js → chunk-WLP6TKFB.js} +3141 -1823
- package/dist/chunk-WLP6TKFB.js.map +1 -0
- package/dist/{chunk-VMEWZU2N.cjs → chunk-WWVV44DY.cjs} +11 -11
- package/dist/{chunk-VMEWZU2N.cjs.map → chunk-WWVV44DY.cjs.map} +1 -1
- package/dist/{chunk-UJ4V3YUQ.js → chunk-XKNAK27R.js} +3 -3
- package/dist/{chunk-UJ4V3YUQ.js.map → chunk-XKNAK27R.js.map} +1 -1
- package/dist/chunk-XLUNB2TZ.js +53 -0
- package/dist/chunk-XLUNB2TZ.js.map +1 -0
- package/dist/{chunk-XKJQQQVR.js → chunk-XVUJY72M.js} +6 -6
- package/dist/{chunk-XKJQQQVR.js.map → chunk-XVUJY72M.js.map} +1 -1
- package/dist/{chunk-5CN7B4CZ.cjs → chunk-YW7GHMF4.cjs} +17 -17
- package/dist/{chunk-5CN7B4CZ.cjs.map → chunk-YW7GHMF4.cjs.map} +1 -1
- package/dist/{ddl-BJcPrB4L.d.ts → ddl-CVnHJcar.d.ts} +3 -3
- package/dist/{ddl-CPZ7mB7X.d.cts → ddl-Dxt_fBHr.d.cts} +3 -3
- package/dist/{extension-types-D1k0inWU.d.cts → extension-types-YGFJPrzK.d.cts} +1 -1
- package/dist/{extension-types-D1k0inWU.d.ts → extension-types-YGFJPrzK.d.ts} +1 -1
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-merge/index.cjs +200 -55
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +6 -6
- package/dist/graph-merge/index.d.ts +6 -6
- package/dist/graph-merge/index.js +185 -40
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-BEK0VtNB.d.ts → index-DGX6D9j1.d.ts} +2 -2
- package/dist/{index-C8sSTErx.d.cts → index-SEvUHDA6.d.cts} +2 -2
- package/dist/index.cjs +145 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -55
- package/dist/index.d.ts +25 -55
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +15 -14
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +6 -5
- package/dist/interchange/index.cjs +15 -15
- package/dist/interchange/index.d.cts +9 -9
- package/dist/interchange/index.d.ts +9 -9
- package/dist/interchange/index.js +2 -2
- package/dist/{manager-Np7VVSlE.d.cts → manager-BYl_zyZR.d.cts} +2 -2
- package/dist/{manager-By-WEd8M.d.ts → manager-C0_r0ALf.d.ts} +2 -2
- package/dist/{materialize-indexes-CAGhqPHQ.d.ts → materialize-indexes-CAkIYFV-.d.ts} +1 -1
- package/dist/{materialize-indexes-DEYkU-wr.d.cts → materialize-indexes-D20xNluI.d.cts} +1 -1
- package/dist/{postgres-4J2tmauh.d.cts → postgres-MzBPkYzq.d.ts} +2651 -596
- package/dist/{postgres-BdIb7tS_.d.ts → postgres-_9psmVGm.d.cts} +2651 -596
- package/dist/profiler/index.cjs +4 -3
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -1
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +30 -29
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +7 -6
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-aM_PAz-O.d.ts → sqlite-BfksSb45.d.cts} +2726 -455
- package/dist/{sqlite-Gatk_iw_.d.cts → sqlite-gm44dShb.d.ts} +2726 -455
- package/dist/{store-DuCbdqsh.d.cts → store-view-9jQ2rPum.d.cts} +1101 -465
- package/dist/{store-MloRPwb9.d.ts → store-view-FfE5_7eo.d.ts} +1101 -465
- package/dist/{types-DoByHGyU.d.cts → types-B6mhrcLv.d.cts} +2 -2
- package/dist/{types-C1CYxWrL.d.cts → types-C_UnQOQp.d.cts} +154 -23
- package/dist/{types-K3vpaJAL.d.ts → types-CdWxK-nD.d.ts} +2 -2
- package/dist/{types-BKQljXom.d.ts → types-DGylBhWo.d.ts} +154 -23
- package/dist/{where-DydZjGOb.d.cts → where-Bpp2ul_z.d.cts} +2 -2
- package/dist/{where-Dt49bvo6.d.ts → where-BsEXraKW.d.ts} +2 -2
- package/package.json +2 -2
- package/dist/chunk-2HZGWCB4.js.map +0 -1
- package/dist/chunk-3JBJEYWE.cjs.map +0 -1
- package/dist/chunk-4A4GUZTQ.js.map +0 -1
- package/dist/chunk-54JVNOAQ.cjs.map +0 -1
- package/dist/chunk-6G35I3VW.cjs +0 -40
- package/dist/chunk-6G35I3VW.cjs.map +0 -1
- package/dist/chunk-6RMLO5O4.cjs.map +0 -1
- package/dist/chunk-7JGLPAFV.cjs.map +0 -1
- package/dist/chunk-CIINW6PS.cjs.map +0 -1
- package/dist/chunk-FLOI7QOT.cjs.map +0 -1
- package/dist/chunk-GKFWM3DS.js.map +0 -1
- package/dist/chunk-IJORSAC3.js.map +0 -1
- package/dist/chunk-M6OC455F.js +0 -65
- package/dist/chunk-M6OC455F.js.map +0 -1
- package/dist/chunk-MAQJYNJR.js.map +0 -1
- package/dist/chunk-MXE2U3EX.js.map +0 -1
- package/dist/chunk-RP7YITHX.cjs +0 -70
- package/dist/chunk-RP7YITHX.cjs.map +0 -1
- package/dist/chunk-RZ4DH4E7.cjs.map +0 -1
- package/dist/chunk-SAJSMR2B.js +0 -35
- package/dist/chunk-SAJSMR2B.js.map +0 -1
- package/dist/chunk-SFFJ2IKN.cjs.map +0 -1
- package/dist/chunk-STP7QVUB.js.map +0 -1
- package/dist/chunk-THX25XW6.js.map +0 -1
- package/dist/chunk-UIFEEPME.js.map +0 -1
- package/dist/chunk-V4IQYOQ4.cjs.map +0 -1
- package/dist/chunk-VZX2KSY3.js.map +0 -1
- package/dist/chunk-YQGLVWB2.cjs.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/meta-edge.ts","../src/core/external-ref.ts","../src/backend/migrate-vectors.ts"],"names":["META_EDGE_BRAND","z","DEFAULT_EMBEDDING_METRIC","DEFAULT_EMBEDDING_INDEX_TYPE","LEGACY_EMBEDDINGS_TABLE_NAME","isMissingTableError","embedding","EmbeddingDimensionChangedError","quotedTableName","sql"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CO,SAAS,QAAA,CACd,IAAA,EACA,OAAA,GAA2B,EAAC,EACf;AACb,EAAA,MAAM,UAAA,GAAiC;AAAA,IACrC,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,SAAA,EAAW,QAAQ,SAAA,IAAa,MAAA;AAAA,IAChC,aAAa,OAAA,CAAQ;AAAA,GACvB;AAEA,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACnB,CAACA,iCAAe,GAAG,IAAA;AAAA,IACnB,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;AC/CO,IAAM,sBAAA,GAAyB,mBAAA;AA6E/B,SAAS,YAA8B,KAAA,EAAgC;AAC5E,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,WAAW,CAAA,EAAG;AACnD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,0DAAA,EAA6D,OAAO,KAAA,KAAU,QAAA,GAAW,IAAI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AW,CAAA,EAAG;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,qBAAA,EAAwB,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,GAAA,CAAI,OAAO,CAAA,wCAAA;AAAA,KAE/C;AAAA,EACF;AACA,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,KAAK,CAAA,IAAK,MAAA,CAAO,SAAQ,EAAG;AAC7C,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AACxD,MAAA,MAAM,IAAI,SAAA;AAAA,QACR,wBAAwB,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,IAAI,OAAO,CAAA,kCAAA,EACzB,KAAK,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAAA,OAC7C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["import {\n type InferenceType,\n META_EDGE_BRAND,\n type MetaEdge,\n type MetaEdgeProperties,\n} from \"../ontology/types\";\n\n// ============================================================\n// Meta-Edge Factory Options\n// ============================================================\n\n/**\n * Options for creating a meta-edge.\n */\nexport type MetaEdgeOptions = Readonly<{\n /** Whether the relationship is transitive (A→B, B→C implies A→C) */\n transitive?: boolean;\n /** Whether the relationship is symmetric (A→B implies B→A) */\n symmetric?: boolean;\n /** Whether the relationship is reflexive (A→A is always true) */\n reflexive?: boolean;\n /** Name of the inverse meta-edge */\n inverse?: string;\n /** How this meta-edge affects queries and validation */\n inference?: InferenceType;\n /** Optional description */\n description?: string;\n}>;\n\n// ============================================================\n// Meta-Edge Factory\n// ============================================================\n\n/**\n * Creates a custom meta-edge definition.\n *\n * @example\n * ```typescript\n * // Custom meta-edge for regulatory relationships\n * const regulatedBy = metaEdge(\"regulatedBy\", {\n * description: \"Type X is regulated by authority type Y\",\n * transitive: false,\n * symmetric: false,\n * });\n * ```\n */\nexport function metaEdge<K extends string>(\n name: K,\n options: MetaEdgeOptions = {},\n): MetaEdge<K> {\n const properties: MetaEdgeProperties = {\n transitive: options.transitive ?? false,\n symmetric: options.symmetric ?? false,\n reflexive: options.reflexive ?? false,\n inverse: options.inverse,\n inference: options.inference ?? \"none\",\n description: options.description,\n };\n\n return Object.freeze({\n [META_EDGE_BRAND]: true as const,\n name,\n properties,\n });\n}\n","/**\n * External reference type for hybrid overlay patterns.\n *\n * Creates a Zod-compatible schema for referencing entities in external\n * data sources (e.g., existing application tables) from TypeGraph nodes.\n */\nimport { z } from \"zod\";\n\n// ============================================================\n// External Reference Metadata Symbol\n// ============================================================\n\n/**\n * Symbol key for storing external table name on the schema.\n * This allows the schema introspector to detect external reference types\n * and extract source information.\n */\nexport const EXTERNAL_REF_TABLE_KEY = \"_externalRefTable\" as const;\n\n// ============================================================\n// External Reference Value Type\n// ============================================================\n\n/**\n * The shape of an external reference value.\n * Contains the source table identifier and the ID of the referenced record.\n */\nexport type ExternalRefValue<T extends string = string> = Readonly<{\n table: T;\n id: string;\n}>;\n\n// ============================================================\n// External Reference Schema Type\n// ============================================================\n\n/**\n * A Zod schema for external references with attached table metadata.\n */\nexport type ExternalRefSchema<T extends string = string> = z.ZodType<\n ExternalRefValue<T>\n> &\n Readonly<{\n [EXTERNAL_REF_TABLE_KEY]: T;\n }>;\n\n// ============================================================\n// External Reference Factory\n// ============================================================\n\n/**\n * Creates a Zod schema for referencing external data sources.\n *\n * Use this when building a hybrid overlay where TypeGraph stores\n * graph relationships and metadata while your existing tables\n * remain the source of truth for entity data.\n *\n * @param table - The identifier for the external table/source (e.g., \"users\", \"documents\")\n * @returns A Zod schema that validates external reference objects\n *\n * @example\n * ```typescript\n * import { defineNode, externalRef, embedding } from \"@nicia-ai/typegraph\";\n *\n * // Reference documents from your existing application database\n * const Document = defineNode(\"Document\", {\n * schema: z.object({\n * source: externalRef(\"documents\"),\n * embedding: embedding(1536).optional(),\n * extractedTopics: z.array(z.string()).optional(),\n * }),\n * });\n *\n * // Create a node referencing an external document\n * await store.nodes.Document.create({\n * source: { table: \"documents\", id: \"doc_abc123\" },\n * embedding: await generateEmbedding(docContent),\n * });\n *\n * // Query and hydrate with external data\n * const results = await store\n * .query()\n * .from(\"Document\", \"d\")\n * .whereNode(\"d\", (d) => d.embedding.similarTo(query, 10))\n * .select((ctx) => ctx.d.source)\n * .execute();\n *\n * // Fetch full data from your app database\n * const externalIds = results.map((r) => r.id);\n * const fullDocs = await appDb.query.documents.findMany({\n * where: inArray(documents.id, externalIds),\n * });\n * ```\n */\nexport function externalRef<T extends string>(table: T): ExternalRefSchema<T> {\n if (typeof table !== \"string\" || table.length === 0) {\n throw new Error(\n `External reference table must be a non-empty string, got: ${typeof table === \"string\" ? `\"${table}\"` : typeof table}`,\n );\n }\n\n const schema = z.object({\n table: z.literal(table),\n id: z.string().min(1, \"External reference ID must be non-empty\"),\n });\n\n // Attach table metadata for introspection\n return Object.assign(schema, {\n [EXTERNAL_REF_TABLE_KEY]: table,\n });\n}\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is an external reference schema.\n */\nexport function isExternalRefSchema(\n value: unknown,\n): value is ExternalRefSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EXTERNAL_REF_TABLE_KEY in value &&\n typeof (value as Record<string, unknown>)[EXTERNAL_REF_TABLE_KEY] ===\n \"string\"\n );\n}\n\n/**\n * Gets the table name from an external reference schema.\n * Returns undefined if the schema is not an external reference schema.\n */\nexport function getExternalRefTable(schema: z.ZodType): string | undefined {\n if (isExternalRefSchema(schema)) {\n return schema[EXTERNAL_REF_TABLE_KEY];\n }\n return undefined;\n}\n\n// ============================================================\n// Helper for creating reference values\n// ============================================================\n\n/**\n * Helper function to create a typed external reference value.\n * Useful when you want to avoid repeating the table name.\n *\n * @example\n * ```typescript\n * const docRef = createExternalRef(\"documents\");\n *\n * await store.nodes.Document.create({\n * source: docRef(\"doc_123\"),\n * embedding: [...],\n * });\n * ```\n */\nexport function createExternalRef<T extends string>(\n table: T,\n): (id: string) => ExternalRefValue<T> {\n return (id: string) => ({ table, id });\n}\n","/**\n * One-time offline migration: legacy shared embeddings table → per-field\n * strategy storage.\n *\n * ## What this is for\n *\n * The cross-backend vector cutover (#157) dropped the single shared\n * `typegraph_node_embeddings` table. Each\n * `VectorStrategy` now OWNS one typed, fixed-dimension structure per\n * `(nodeKind, fieldPath)` — the only layout that can be ANN-indexed on\n * libSQL and sqlite-vec, not just pgvector.\n *\n * Deployments that wrote embeddings under the old shared table before\n * upgrading still hold those rows. This utility drains them into the new\n * per-field storage **once**, during the upgrade, so existing embedded\n * data survives the cutover without re-embedding from source.\n *\n * It is an explicitly-run, offline step — not wired into `materializeIndexes`\n * or any boot path. Run it once after deploying the new version and before\n * (or alongside) the first `materializeIndexes()`, then drop the legacy\n * table at your leisure.\n *\n * ## How it works\n *\n * - Skips cleanly (returns a zero summary) when the legacy table is absent —\n * a fresh install, or a re-run after the table was dropped.\n * - Reads rows in keyset-paginated batches (never the whole table at once),\n * decoding the engine-native embedding column to a numeric array at the SQL\n * level: sqlite-vec stored a `vec_f32` blob (`vec_to_json` decodes it);\n * pgvector stored a native `vector` (`::text` yields a `[…]` literal).\n * - Re-inserts each row through `backend.upsertEmbedding`, which routes the\n * active strategy's `buildUpsert` and idempotently provisions the per-field\n * storage (the same `(nodeKind, fieldPath)` slot a fresh store write uses).\n * The migration stays graph-agnostic and execution-correct on both the\n * sync (better-sqlite3) and async (libsql / Postgres) backends — it does\n * not re-implement the backend's statement-execution glue.\n *\n * Idempotent and resumable: a partial run followed by a full run converges\n * to the same per-field tables, because every write is an upsert keyed by\n * `(graph_id, node_id)` in the strategy's owned storage.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport {\n DEFAULT_EMBEDDING_INDEX_TYPE,\n DEFAULT_EMBEDDING_METRIC,\n type EmbeddingIndexType,\n type EmbeddingMetric,\n} from \"../core/embedding\";\nimport { EmbeddingDimensionChangedError } from \"../errors\";\nimport { isMissingTableError } from \"../utils/sql-errors\";\nimport { quotedTableName } from \"./drizzle/operations/shared\";\nimport { LEGACY_EMBEDDINGS_TABLE_NAME } from \"./drizzle/schema/sqlite\";\nimport { type GraphBackend } from \"./types\";\n\n/**\n * Default rows read per round-trip. Large enough to amortize round-trip\n * latency, small enough to bound peak memory regardless of table size.\n */\nconst DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Metric / index type applied to a migrated field when no\n * {@link MigrateLegacyEmbeddingsOptions.resolveSlotConfig} is supplied (or\n * it returns `undefined`). Matches the defaults `embedding()` and\n * `resolveEmbeddingFields` apply, so a migrated field lands in storage shaped\n * identically to one written fresh through the store. Migrated data is only\n * ever brute-forceable until `materializeIndexes()` builds the ANN index, so\n * the index-type default governs only which ANN structure the per-field\n * storage DDL provisions, not the migration's correctness.\n */\nconst DEFAULT_SLOT_METRIC: EmbeddingMetric = DEFAULT_EMBEDDING_METRIC;\nconst DEFAULT_SLOT_INDEX_TYPE: EmbeddingIndexType =\n DEFAULT_EMBEDDING_INDEX_TYPE;\n\n/**\n * The resolved storage config for one `(nodeKind, fieldPath)` slot that the\n * legacy table did not record. The legacy shared table stored only the\n * vector and its dimension count — not the metric or index type — so a\n * caller that wants migrated fields to match a specific graph's `embedding()`\n * declarations supplies this resolver.\n */\nexport type LegacyEmbeddingSlotConfig = Readonly<{\n metric: EmbeddingMetric;\n indexType: EmbeddingIndexType;\n}>;\n\n/**\n * Options for {@link migrateLegacyEmbeddings}.\n */\nexport type MigrateLegacyEmbeddingsOptions = Readonly<{\n /**\n * The backend to migrate, wired with the destination `VectorStrategy`\n * (i.e. the post-cutover backend). Its `vectorStrategy` owns the per-field\n * storage rows are written into and its `upsertEmbedding` performs the\n * writes.\n */\n backend: GraphBackend;\n\n /**\n * Restrict the migration to a single graph. When omitted, every graph's\n * rows in the legacy table are migrated (the table is graph-scoped by its\n * `graph_id` column).\n */\n graphId?: string;\n\n /**\n * Resolves the metric / index type for a `(nodeKind, fieldPath)` slot the\n * legacy table didn't persist. Return `undefined` to fall back to the\n * cosine / hnsw defaults. Supply this (typically reading the graph's\n * `embedding()` declarations) when migrated fields must match a specific\n * metric — e.g. an `l2` field, which scores incorrectly under the cosine\n * default.\n */\n resolveSlotConfig?: (\n nodeKind: string,\n fieldPath: string,\n ) => LegacyEmbeddingSlotConfig | undefined;\n\n /** Rows read per round-trip. Defaults to {@link DEFAULT_BATCH_SIZE}. */\n batchSize?: number;\n\n /**\n * Physical name of the legacy table to drain. Defaults to\n * {@link LEGACY_EMBEDDINGS_TABLE_NAME}. Override only for a non-default\n * deployment that renamed the embeddings table.\n */\n legacyTableName?: string;\n}>;\n\n/**\n * Summary of a {@link migrateLegacyEmbeddings} run.\n */\nexport type MigrateLegacyEmbeddingsResult = Readonly<{\n /** Total embedding rows re-inserted into per-field storage. */\n migrated: number;\n /**\n * Per-`(nodeKind, fieldPath)` counts, keyed `\"<nodeKind>.<fieldPath>\"`\n * (the strategy's logical-slot key form). Empty when the legacy table was\n * absent or held no rows for the requested scope.\n */\n perField: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their vector length didn't match the per-field\n * table's fixed dimension. The legacy shared column allowed mixed\n * dimensions for one `(nodeKind, fieldPath)` (e.g. an unmigrated model\n * change); the first migrated row fixes the typed table's dimension and\n * any differently-sized rows for that slot are skipped rather than aborting\n * the whole migration. Keyed `\"<nodeKind>.<fieldPath>\"`. Non-empty here\n * means those fields need a deliberate re-embed at a single dimension.\n */\n skippedDimensionMismatch: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their legacy embedding could not be decoded into a\n * finite-number array — a corrupt value (e.g. a pgvector `vector` column\n * permits `NaN`/`Infinity`, which is not valid JSON). Keyed\n * `\"<nodeKind>.<fieldPath>\"`. Skipping + reporting keeps one bad row from\n * aborting the whole migration; non-empty here means those rows need manual\n * repair.\n */\n skippedDecodeError: Readonly<Record<string, number>>;\n /**\n * Whether the legacy table existed. `false` means the run was a clean\n * no-op (fresh install, or already-dropped table on a re-run).\n */\n legacyTablePresent: boolean;\n}>;\n\n/**\n * A single legacy embedding row, with the engine-native vector already\n * decoded to a JSON array string by the dialect-specific SELECT. The\n * legacy `dimensions` column is intentionally not read: the decoded array's\n * length is the authoritative fixed dimension for the destination slot, and\n * relying on it sidesteps the per-driver string/number coercion the legacy\n * integer column would otherwise need.\n */\ntype LegacyEmbeddingRow = Readonly<{\n graph_id: string;\n node_kind: string;\n node_id: string;\n field_path: string;\n /** JSON array text, e.g. `\"[0.1,0.2,0.3]\"` — decoded per dialect. */\n embedding_json: string;\n}>;\n\n/**\n * Re-inserts every embedding from the legacy shared\n * `typegraph_node_embeddings` table into the active\n * `backend.vectorStrategy`'s per-`(nodeKind, fieldPath)` storage.\n *\n * One-time, explicitly-run upgrade step for the shared-table → per-field\n * cutover (#157). Idempotent, batched, and a clean no-op when the legacy\n * table is absent. See the module doc comment for the full contract.\n *\n * @throws Error when the backend exposes no `vectorStrategy` /\n * `upsertEmbedding` (nothing to migrate *into*) — a configuration\n * error the caller must fix by wiring the destination strategy\n * before migrating.\n */\nexport async function migrateLegacyEmbeddings(\n options: MigrateLegacyEmbeddingsOptions,\n): Promise<MigrateLegacyEmbeddingsResult> {\n const {\n backend,\n graphId,\n resolveSlotConfig,\n batchSize = DEFAULT_BATCH_SIZE,\n legacyTableName = LEGACY_EMBEDDINGS_TABLE_NAME,\n } = options;\n\n if (\n backend.vectorStrategy === undefined ||\n backend.upsertEmbedding === undefined\n ) {\n throw new Error(\n \"migrateLegacyEmbeddings requires a backend wired with a vectorStrategy \" +\n \"(the destination per-field storage). Pass the post-cutover backend.\",\n );\n }\n if (!Number.isInteger(batchSize) || batchSize <= 0) {\n throw new RangeError(\n `batchSize must be a positive integer, got: ${batchSize}`,\n );\n }\n const upsertEmbedding = backend.upsertEmbedding;\n\n const perField: Record<string, number> = {};\n const skippedDimensionMismatch: Record<string, number> = {};\n const skippedDecodeError: Record<string, number> = {};\n let migrated = 0;\n\n let cursor: LegacyRowCursor | undefined;\n for (;;) {\n let batch: readonly LegacyEmbeddingRow[];\n try {\n batch = await readLegacyBatch(backend, {\n legacyTableName,\n graphId,\n batchSize,\n after: cursor,\n });\n } catch (error) {\n // A missing legacy table is the expected \"nothing to migrate\" path on\n // the first read — surface it as a clean no-op, not a failure.\n if (cursor === undefined && isMissingTableError(error)) {\n return {\n migrated: 0,\n perField: {},\n skippedDimensionMismatch: {},\n skippedDecodeError: {},\n legacyTablePresent: false,\n };\n }\n throw error;\n }\n\n if (batch.length === 0) break;\n\n for (const row of batch) {\n const slotKey = `${row.node_kind}.${row.field_path}`;\n\n let embedding: readonly number[];\n try {\n embedding = decodeEmbeddingJson(row);\n } catch {\n // A corrupt legacy value (e.g. a pgvector `vector` column permits\n // NaN/Infinity, which is not valid JSON) is skipped + reported rather\n // than aborting the whole migration on one bad row.\n skippedDecodeError[slotKey] = (skippedDecodeError[slotKey] ?? 0) + 1;\n continue;\n }\n const config = resolveSlotConfig?.(row.node_kind, row.field_path);\n\n try {\n await upsertEmbedding({\n graphId: row.graph_id,\n nodeKind: row.node_kind,\n nodeId: row.node_id,\n fieldPath: row.field_path,\n embedding,\n // The decoded length is the authoritative fixed dimension — the\n // strategy provisions its column type (e.g. `F32_BLOB(N)`) from it.\n dimensions: embedding.length,\n metric: config?.metric ?? DEFAULT_SLOT_METRIC,\n indexType: config?.indexType ?? DEFAULT_SLOT_INDEX_TYPE,\n });\n } catch (error) {\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension, so a differently-sized row is skipped and\n // reported rather than aborting the whole migration.\n if (error instanceof EmbeddingDimensionChangedError) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n throw error;\n }\n\n migrated += 1;\n perField[slotKey] = (perField[slotKey] ?? 0) + 1;\n }\n\n if (batch.length < batchSize) break;\n const last = batch.at(-1)!;\n cursor = {\n graphId: last.graph_id,\n nodeKind: last.node_kind,\n nodeId: last.node_id,\n fieldPath: last.field_path,\n };\n }\n\n return {\n migrated,\n perField,\n skippedDimensionMismatch,\n skippedDecodeError,\n legacyTablePresent: true,\n };\n}\n\n/**\n * Composite keyset cursor over the legacy table's primary key\n * `(graph_id, node_kind, node_id, field_path)`. Stable under concurrent\n * writes and immune to OFFSET drift, so a batched walk reads every row once.\n */\ntype LegacyRowCursor = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n}>;\n\ntype ReadLegacyBatchParams = Readonly<{\n legacyTableName: string;\n graphId: string | undefined;\n batchSize: number;\n after: LegacyRowCursor | undefined;\n}>;\n\n/**\n * Reads one keyset-paginated batch of legacy rows, ordered by the primary\n * key, with the engine-native embedding column decoded to a JSON array\n * string by the dialect.\n */\nasync function readLegacyBatch(\n backend: GraphBackend,\n params: ReadLegacyBatchParams,\n): Promise<readonly LegacyEmbeddingRow[]> {\n const table = quotedTableName(params.legacyTableName);\n const embeddingJson = legacyEmbeddingDecodeExpression(backend);\n\n const conditions: SQL[] = [];\n if (params.graphId !== undefined) {\n conditions.push(sql`\"graph_id\" = ${params.graphId}`);\n }\n if (params.after !== undefined) {\n conditions.push(keysetAfterCondition(params.after));\n }\n\n const whereClause =\n conditions.length === 0 ?\n sql``\n : sql` WHERE ${sql.join(conditions, sql` AND `)}`;\n\n const query = sql`\n SELECT\n \"graph_id\" AS graph_id,\n \"node_kind\" AS node_kind,\n \"node_id\" AS node_id,\n \"field_path\" AS field_path,\n ${embeddingJson} AS embedding_json\n FROM ${table}${whereClause}\n ORDER BY \"graph_id\" ASC, \"node_kind\" ASC, \"node_id\" ASC, \"field_path\" ASC\n LIMIT ${params.batchSize}\n `;\n\n return backend.execute<LegacyEmbeddingRow>(query);\n}\n\n/**\n * The strict `>` comparison over the composite primary key, expressed as\n * the standard lexicographic OR-chain so it works on every dialect (SQLite\n * supports row-value comparison, but Postgres + SQLite both accept this\n * portable form).\n */\nfunction keysetAfterCondition(after: LegacyRowCursor): SQL {\n return sql`\n (\n \"graph_id\" > ${after.graphId}\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" > ${after.nodeKind})\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" = ${after.nodeKind} AND \"node_id\" > ${after.nodeId})\n OR (\n \"graph_id\" = ${after.graphId}\n AND \"node_kind\" = ${after.nodeKind}\n AND \"node_id\" = ${after.nodeId}\n AND \"field_path\" > ${after.fieldPath}\n )\n )\n `;\n}\n\n/**\n * The SQL expression that decodes the legacy engine-native embedding column\n * into a JSON array string `embedding_json`. The single dialect branch in\n * this whole module: the legacy storage formats are genuinely engine-\n * specific, and there is no longer a strategy abstraction over the *legacy*\n * table to delegate to.\n */\nfunction legacyEmbeddingDecodeExpression(backend: GraphBackend): SQL {\n switch (backend.dialect) {\n case \"sqlite\": {\n // Legacy SQLite embeddings were written via `vec_f32('[…]')`\n // (sqlite-vec binary). `vec_to_json` is its inverse, yielding the\n // JSON array text. Requires sqlite-vec on the connection — which the\n // legacy write path also required, so any deployment with legacy rows\n // has it loaded.\n return sql`vec_to_json(\"embedding\")`;\n }\n case \"postgres\": {\n // pgvector's native `vector` casts to its `[…]` text literal, which is\n // valid JSON for `JSON.parse`.\n return sql`\"embedding\"::text`;\n }\n default: {\n const _exhaustive: never = backend.dialect;\n throw new Error(\n `migrateLegacyEmbeddings does not support dialect: ${String(_exhaustive)}`,\n );\n }\n }\n}\n\n/**\n * Parses a decoded `embedding_json` array, asserting it is a non-empty array\n * of finite numbers. A bad decode (wrong type, NaN) names the offending row\n * loudly instead of writing a corrupt vector into per-field storage.\n */\nfunction decodeEmbeddingJson(row: LegacyEmbeddingRow): readonly number[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(row.embedding_json) as unknown;\n } catch (error) {\n throw new Error(\n `Failed to decode legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}): not valid JSON.`,\n { cause: error },\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) decoded to a non-array ` +\n `or empty value.`,\n );\n }\n for (const [index, value] of parsed.entries()) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) has a non-finite ` +\n `value at index ${index}: ${String(value)}.`,\n );\n }\n }\n return parsed as readonly number[];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/meta-edge.ts","../src/core/external-ref.ts","../src/backend/migrate-vectors.ts"],"names":["META_EDGE_BRAND","z","DEFAULT_EMBEDDING_METRIC","DEFAULT_EMBEDDING_INDEX_TYPE","LEGACY_EMBEDDINGS_TABLE_NAME","isMissingTableError","embedding","EmbeddingDimensionChangedError","quotedTableName","sql","asCompiledRowsSql"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CO,SAAS,QAAA,CACd,IAAA,EACA,OAAA,GAA2B,EAAC,EACf;AACb,EAAA,MAAM,UAAA,GAAiC;AAAA,IACrC,UAAA,EAAY,QAAQ,UAAA,IAAc,KAAA;AAAA,IAClC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAA,EAAW,QAAQ,SAAA,IAAa,KAAA;AAAA,IAChC,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,SAAA,EAAW,QAAQ,SAAA,IAAa,MAAA;AAAA,IAChC,aAAa,OAAA,CAAQ;AAAA,GACvB;AAEA,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACnB,CAACA,iCAAe,GAAG,IAAA;AAAA,IACnB,IAAA;AAAA,IACA;AAAA,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AAyC,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC5D,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,GAAA,CAAI,OAAO,CAAA,kBAAA,CAAA;AAAA,MAC7C,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACA,EAAA,IAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,IAAK,MAAA,CAAO,WAAW,CAAA,EAAG;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,qBAAA,EAAwB,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,GAAA,CAAI,OAAO,CAAA,wCAAA;AAAA,KAE/C;AAAA,EACF;AACA,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,KAAK,CAAA,IAAK,MAAA,CAAO,SAAQ,EAAG;AAC7C,IAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AACxD,MAAA,MAAM,IAAI,SAAA;AAAA,QACR,wBAAwB,GAAA,CAAI,SAAS,CAAA,CAAA,EAAI,GAAA,CAAI,UAAU,CAAA,QAAA,EAC3C,GAAA,CAAI,QAAQ,CAAA,OAAA,EAAU,IAAI,OAAO,CAAA,kCAAA,EACzB,KAAK,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA,CAAA;AAAA,OAC7C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["import {\n type InferenceType,\n META_EDGE_BRAND,\n type MetaEdge,\n type MetaEdgeProperties,\n} from \"../ontology/types\";\n\n// ============================================================\n// Meta-Edge Factory Options\n// ============================================================\n\n/**\n * Options for creating a meta-edge.\n */\nexport type MetaEdgeOptions = Readonly<{\n /** Whether the relationship is transitive (A→B, B→C implies A→C) */\n transitive?: boolean;\n /** Whether the relationship is symmetric (A→B implies B→A) */\n symmetric?: boolean;\n /** Whether the relationship is reflexive (A→A is always true) */\n reflexive?: boolean;\n /** Name of the inverse meta-edge */\n inverse?: string;\n /** How this meta-edge affects queries and validation */\n inference?: InferenceType;\n /** Optional description */\n description?: string;\n}>;\n\n// ============================================================\n// Meta-Edge Factory\n// ============================================================\n\n/**\n * Creates a custom meta-edge definition.\n *\n * @example\n * ```typescript\n * // Custom meta-edge for regulatory relationships\n * const regulatedBy = metaEdge(\"regulatedBy\", {\n * description: \"Type X is regulated by authority type Y\",\n * transitive: false,\n * symmetric: false,\n * });\n * ```\n */\nexport function metaEdge<K extends string>(\n name: K,\n options: MetaEdgeOptions = {},\n): MetaEdge<K> {\n const properties: MetaEdgeProperties = {\n transitive: options.transitive ?? false,\n symmetric: options.symmetric ?? false,\n reflexive: options.reflexive ?? false,\n inverse: options.inverse,\n inference: options.inference ?? \"none\",\n description: options.description,\n };\n\n return Object.freeze({\n [META_EDGE_BRAND]: true as const,\n name,\n properties,\n });\n}\n","/**\n * External reference type for hybrid overlay patterns.\n *\n * Creates a Zod-compatible schema for referencing entities in external\n * data sources (e.g., existing application tables) from TypeGraph nodes.\n */\nimport { z } from \"zod\";\n\n// ============================================================\n// External Reference Metadata Symbol\n// ============================================================\n\n/**\n * Symbol key for storing external table name on the schema.\n * This allows the schema introspector to detect external reference types\n * and extract source information.\n */\nexport const EXTERNAL_REF_TABLE_KEY = \"_externalRefTable\" as const;\n\n// ============================================================\n// External Reference Value Type\n// ============================================================\n\n/**\n * The shape of an external reference value.\n * Contains the source table identifier and the ID of the referenced record.\n */\nexport type ExternalRefValue<T extends string = string> = Readonly<{\n table: T;\n id: string;\n}>;\n\n// ============================================================\n// External Reference Schema Type\n// ============================================================\n\n/**\n * A Zod schema for external references with attached table metadata.\n */\nexport type ExternalRefSchema<T extends string = string> = z.ZodType<\n ExternalRefValue<T>\n> &\n Readonly<{\n [EXTERNAL_REF_TABLE_KEY]: T;\n }>;\n\n// ============================================================\n// External Reference Factory\n// ============================================================\n\n/**\n * Creates a Zod schema for referencing external data sources.\n *\n * Use this when building a hybrid overlay where TypeGraph stores\n * graph relationships and metadata while your existing tables\n * remain the source of truth for entity data.\n *\n * @param table - The identifier for the external table/source (e.g., \"users\", \"documents\")\n * @returns A Zod schema that validates external reference objects\n *\n * @example\n * ```typescript\n * import { defineNode, externalRef, embedding } from \"@nicia-ai/typegraph\";\n *\n * // Reference documents from your existing application database\n * const Document = defineNode(\"Document\", {\n * schema: z.object({\n * source: externalRef(\"documents\"),\n * embedding: embedding(1536).optional(),\n * extractedTopics: z.array(z.string()).optional(),\n * }),\n * });\n *\n * // Create a node referencing an external document\n * await store.nodes.Document.create({\n * source: { table: \"documents\", id: \"doc_abc123\" },\n * embedding: await generateEmbedding(docContent),\n * });\n *\n * // Query and hydrate with external data\n * const results = await store\n * .query()\n * .from(\"Document\", \"d\")\n * .whereNode(\"d\", (d) => d.embedding.similarTo(query, 10))\n * .select((ctx) => ctx.d.source)\n * .execute();\n *\n * // Fetch full data from your app database\n * const externalIds = results.map((r) => r.id);\n * const fullDocs = await appDb.query.documents.findMany({\n * where: inArray(documents.id, externalIds),\n * });\n * ```\n */\nexport function externalRef<T extends string>(table: T): ExternalRefSchema<T> {\n if (typeof table !== \"string\" || table.length === 0) {\n throw new Error(\n `External reference table must be a non-empty string, got: ${typeof table === \"string\" ? `\"${table}\"` : typeof table}`,\n );\n }\n\n const schema = z.object({\n table: z.literal(table),\n id: z.string().min(1, \"External reference ID must be non-empty\"),\n });\n\n // Attach table metadata for introspection\n return Object.assign(schema, {\n [EXTERNAL_REF_TABLE_KEY]: table,\n });\n}\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is an external reference schema.\n */\nexport function isExternalRefSchema(\n value: unknown,\n): value is ExternalRefSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EXTERNAL_REF_TABLE_KEY in value &&\n typeof (value as Record<string, unknown>)[EXTERNAL_REF_TABLE_KEY] ===\n \"string\"\n );\n}\n\n/**\n * Gets the table name from an external reference schema.\n * Returns undefined if the schema is not an external reference schema.\n */\nexport function getExternalRefTable(schema: z.ZodType): string | undefined {\n if (isExternalRefSchema(schema)) {\n return schema[EXTERNAL_REF_TABLE_KEY];\n }\n return undefined;\n}\n\n// ============================================================\n// Helper for creating reference values\n// ============================================================\n\n/**\n * Helper function to create a typed external reference value.\n * Useful when you want to avoid repeating the table name.\n *\n * @example\n * ```typescript\n * const docRef = createExternalRef(\"documents\");\n *\n * await store.nodes.Document.create({\n * source: docRef(\"doc_123\"),\n * embedding: [...],\n * });\n * ```\n */\nexport function createExternalRef<T extends string>(\n table: T,\n): (id: string) => ExternalRefValue<T> {\n return (id: string) => ({ table, id });\n}\n","/**\n * One-time offline migration: legacy shared embeddings table → per-field\n * strategy storage.\n *\n * ## What this is for\n *\n * The cross-backend vector cutover (#157) dropped the single shared\n * `typegraph_node_embeddings` table. Each\n * `VectorStrategy` now OWNS one typed, fixed-dimension structure per\n * `(nodeKind, fieldPath)` — the only layout that can be ANN-indexed on\n * libSQL and sqlite-vec, not just pgvector.\n *\n * Deployments that wrote embeddings under the old shared table before\n * upgrading still hold those rows. This utility drains them into the new\n * per-field storage **once**, during the upgrade, so existing embedded\n * data survives the cutover without re-embedding from source.\n *\n * It is an explicitly-run, offline step — not wired into `materializeIndexes`\n * or any boot path. Run it once after deploying the new version and before\n * (or alongside) the first `materializeIndexes()`, then drop the legacy\n * table at your leisure.\n *\n * ## How it works\n *\n * - Skips cleanly (returns a zero summary) when the legacy table is absent —\n * a fresh install, or a re-run after the table was dropped.\n * - Reads rows in keyset-paginated batches (never the whole table at once),\n * decoding the engine-native embedding column to a numeric array at the SQL\n * level: sqlite-vec stored a `vec_f32` blob (`vec_to_json` decodes it);\n * pgvector stored a native `vector` (`::text` yields a `[…]` literal).\n * - Re-inserts each row through `backend.upsertEmbedding`, which routes the\n * active strategy's `buildUpsert` and idempotently provisions the per-field\n * storage (the same `(nodeKind, fieldPath)` slot a fresh store write uses).\n * The migration stays graph-agnostic and execution-correct on both the\n * sync (better-sqlite3) and async (libsql / Postgres) backends — it does\n * not re-implement the backend's statement-execution glue.\n *\n * Idempotent and resumable: a partial run followed by a full run converges\n * to the same per-field tables, because every write is an upsert keyed by\n * `(graph_id, node_id)` in the strategy's owned storage.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport {\n DEFAULT_EMBEDDING_INDEX_TYPE,\n DEFAULT_EMBEDDING_METRIC,\n type EmbeddingIndexType,\n type EmbeddingMetric,\n} from \"../core/embedding\";\nimport { EmbeddingDimensionChangedError } from \"../errors\";\nimport { asCompiledRowsSql } from \"../query/sql-intent\";\nimport { isMissingTableError } from \"../utils/sql-errors\";\nimport { quotedTableName } from \"./drizzle/operations/shared\";\nimport { LEGACY_EMBEDDINGS_TABLE_NAME } from \"./drizzle/schema/sqlite\";\nimport { type GraphBackend } from \"./types\";\n\n/**\n * Default rows read per round-trip. Large enough to amortize round-trip\n * latency, small enough to bound peak memory regardless of table size.\n */\nconst DEFAULT_BATCH_SIZE = 500;\n\n/**\n * Metric / index type applied to a migrated field when no\n * {@link MigrateLegacyEmbeddingsOptions.resolveSlotConfig} is supplied (or\n * it returns `undefined`). Matches the defaults `embedding()` and\n * `resolveEmbeddingFields` apply, so a migrated field lands in storage shaped\n * identically to one written fresh through the store. Migrated data is only\n * ever brute-forceable until `materializeIndexes()` builds the ANN index, so\n * the index-type default governs only which ANN structure the per-field\n * storage DDL provisions, not the migration's correctness.\n */\nconst DEFAULT_SLOT_METRIC: EmbeddingMetric = DEFAULT_EMBEDDING_METRIC;\nconst DEFAULT_SLOT_INDEX_TYPE: EmbeddingIndexType =\n DEFAULT_EMBEDDING_INDEX_TYPE;\n\n/**\n * The resolved storage config for one `(nodeKind, fieldPath)` slot that the\n * legacy table did not record. The legacy shared table stored only the\n * vector and its dimension count — not the metric or index type — so a\n * caller that wants migrated fields to match a specific graph's `embedding()`\n * declarations supplies this resolver.\n */\nexport type LegacyEmbeddingSlotConfig = Readonly<{\n metric: EmbeddingMetric;\n indexType: EmbeddingIndexType;\n}>;\n\n/**\n * Options for {@link migrateLegacyEmbeddings}.\n */\nexport type MigrateLegacyEmbeddingsOptions = Readonly<{\n /**\n * The backend to migrate, wired with the destination `VectorStrategy`\n * (i.e. the post-cutover backend). Its `vectorStrategy` owns the per-field\n * storage rows are written into and its `upsertEmbedding` performs the\n * writes.\n */\n backend: GraphBackend;\n\n /**\n * Restrict the migration to a single graph. When omitted, every graph's\n * rows in the legacy table are migrated (the table is graph-scoped by its\n * `graph_id` column).\n */\n graphId?: string;\n\n /**\n * Resolves the metric / index type for a `(nodeKind, fieldPath)` slot the\n * legacy table didn't persist. Return `undefined` to fall back to the\n * cosine / hnsw defaults. Supply this (typically reading the graph's\n * `embedding()` declarations) when migrated fields must match a specific\n * metric — e.g. an `l2` field, which scores incorrectly under the cosine\n * default.\n */\n resolveSlotConfig?: (\n nodeKind: string,\n fieldPath: string,\n ) => LegacyEmbeddingSlotConfig | undefined;\n\n /** Rows read per round-trip. Defaults to {@link DEFAULT_BATCH_SIZE}. */\n batchSize?: number;\n\n /**\n * Physical name of the legacy table to drain. Defaults to\n * {@link LEGACY_EMBEDDINGS_TABLE_NAME}. Override only for a non-default\n * deployment that renamed the embeddings table.\n */\n legacyTableName?: string;\n}>;\n\n/**\n * Summary of a {@link migrateLegacyEmbeddings} run.\n */\nexport type MigrateLegacyEmbeddingsResult = Readonly<{\n /** Total embedding rows re-inserted into per-field storage. */\n migrated: number;\n /**\n * Per-`(nodeKind, fieldPath)` counts, keyed `\"<nodeKind>.<fieldPath>\"`\n * (the strategy's logical-slot key form). Empty when the legacy table was\n * absent or held no rows for the requested scope.\n */\n perField: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their vector length didn't match the per-field\n * table's fixed dimension. The legacy shared column allowed mixed\n * dimensions for one `(nodeKind, fieldPath)` (e.g. an unmigrated model\n * change); the first migrated row fixes the typed table's dimension and\n * any differently-sized rows for that slot are skipped rather than aborting\n * the whole migration. Keyed `\"<nodeKind>.<fieldPath>\"`. Non-empty here\n * means those fields need a deliberate re-embed at a single dimension.\n */\n skippedDimensionMismatch: Readonly<Record<string, number>>;\n /**\n * Rows skipped because their legacy embedding could not be decoded into a\n * finite-number array — a corrupt value (e.g. a pgvector `vector` column\n * permits `NaN`/`Infinity`, which is not valid JSON). Keyed\n * `\"<nodeKind>.<fieldPath>\"`. Skipping + reporting keeps one bad row from\n * aborting the whole migration; non-empty here means those rows need manual\n * repair.\n */\n skippedDecodeError: Readonly<Record<string, number>>;\n /**\n * Whether the legacy table existed. `false` means the run was a clean\n * no-op (fresh install, or already-dropped table on a re-run).\n */\n legacyTablePresent: boolean;\n}>;\n\n/**\n * A single legacy embedding row, with the engine-native vector already\n * decoded to a JSON array string by the dialect-specific SELECT. The\n * legacy `dimensions` column is intentionally not read: the decoded array's\n * length is the authoritative fixed dimension for the destination slot, and\n * relying on it sidesteps the per-driver string/number coercion the legacy\n * integer column would otherwise need.\n */\ntype LegacyEmbeddingRow = Readonly<{\n graph_id: string;\n node_kind: string;\n node_id: string;\n field_path: string;\n /** JSON array text, e.g. `\"[0.1,0.2,0.3]\"` — decoded per dialect. */\n embedding_json: string;\n}>;\n\n/**\n * Re-inserts every embedding from the legacy shared\n * `typegraph_node_embeddings` table into the active\n * `backend.vectorStrategy`'s per-`(nodeKind, fieldPath)` storage.\n *\n * One-time, explicitly-run upgrade step for the shared-table → per-field\n * cutover (#157). Idempotent, batched, and a clean no-op when the legacy\n * table is absent. See the module doc comment for the full contract.\n *\n * @throws Error when the backend exposes no `vectorStrategy` /\n * `upsertEmbedding` (nothing to migrate *into*) — a configuration\n * error the caller must fix by wiring the destination strategy\n * before migrating.\n */\nexport async function migrateLegacyEmbeddings(\n options: MigrateLegacyEmbeddingsOptions,\n): Promise<MigrateLegacyEmbeddingsResult> {\n const {\n backend,\n graphId,\n resolveSlotConfig,\n batchSize = DEFAULT_BATCH_SIZE,\n legacyTableName = LEGACY_EMBEDDINGS_TABLE_NAME,\n } = options;\n\n if (\n backend.vectorStrategy === undefined ||\n backend.upsertEmbedding === undefined\n ) {\n throw new Error(\n \"migrateLegacyEmbeddings requires a backend wired with a vectorStrategy \" +\n \"(the destination per-field storage). Pass the post-cutover backend.\",\n );\n }\n if (!Number.isInteger(batchSize) || batchSize <= 0) {\n throw new RangeError(\n `batchSize must be a positive integer, got: ${batchSize}`,\n );\n }\n const upsertEmbedding = backend.upsertEmbedding;\n\n const perField: Record<string, number> = {};\n const skippedDimensionMismatch: Record<string, number> = {};\n const skippedDecodeError: Record<string, number> = {};\n let migrated = 0;\n\n let cursor: LegacyRowCursor | undefined;\n for (;;) {\n let batch: readonly LegacyEmbeddingRow[];\n try {\n batch = await readLegacyBatch(backend, {\n legacyTableName,\n graphId,\n batchSize,\n after: cursor,\n });\n } catch (error) {\n // A missing legacy table is the expected \"nothing to migrate\" path on\n // the first read — surface it as a clean no-op, not a failure.\n if (cursor === undefined && isMissingTableError(error)) {\n return {\n migrated: 0,\n perField: {},\n skippedDimensionMismatch: {},\n skippedDecodeError: {},\n legacyTablePresent: false,\n };\n }\n throw error;\n }\n\n if (batch.length === 0) break;\n\n for (const row of batch) {\n const slotKey = `${row.node_kind}.${row.field_path}`;\n\n let embedding: readonly number[];\n try {\n embedding = decodeEmbeddingJson(row);\n } catch {\n // A corrupt legacy value (e.g. a pgvector `vector` column permits\n // NaN/Infinity, which is not valid JSON) is skipped + reported rather\n // than aborting the whole migration on one bad row.\n skippedDecodeError[slotKey] = (skippedDecodeError[slotKey] ?? 0) + 1;\n continue;\n }\n const config = resolveSlotConfig?.(row.node_kind, row.field_path);\n\n try {\n await upsertEmbedding({\n graphId: row.graph_id,\n nodeKind: row.node_kind,\n nodeId: row.node_id,\n fieldPath: row.field_path,\n embedding,\n // The decoded length is the authoritative fixed dimension — the\n // strategy provisions its column type (e.g. `F32_BLOB(N)`) from it.\n dimensions: embedding.length,\n metric: config?.metric ?? DEFAULT_SLOT_METRIC,\n indexType: config?.indexType ?? DEFAULT_SLOT_INDEX_TYPE,\n });\n } catch (error) {\n // The legacy shared column allowed mixed dimensions for one\n // (nodeKind, fieldPath); the per-field table is fixed at the first\n // migrated row's dimension, so a differently-sized row is skipped and\n // reported rather than aborting the whole migration.\n if (error instanceof EmbeddingDimensionChangedError) {\n skippedDimensionMismatch[slotKey] =\n (skippedDimensionMismatch[slotKey] ?? 0) + 1;\n continue;\n }\n throw error;\n }\n\n migrated += 1;\n perField[slotKey] = (perField[slotKey] ?? 0) + 1;\n }\n\n if (batch.length < batchSize) break;\n const last = batch.at(-1)!;\n cursor = {\n graphId: last.graph_id,\n nodeKind: last.node_kind,\n nodeId: last.node_id,\n fieldPath: last.field_path,\n };\n }\n\n return {\n migrated,\n perField,\n skippedDimensionMismatch,\n skippedDecodeError,\n legacyTablePresent: true,\n };\n}\n\n/**\n * Composite keyset cursor over the legacy table's primary key\n * `(graph_id, node_kind, node_id, field_path)`. Stable under concurrent\n * writes and immune to OFFSET drift, so a batched walk reads every row once.\n */\ntype LegacyRowCursor = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n}>;\n\ntype ReadLegacyBatchParams = Readonly<{\n legacyTableName: string;\n graphId: string | undefined;\n batchSize: number;\n after: LegacyRowCursor | undefined;\n}>;\n\n/**\n * Reads one keyset-paginated batch of legacy rows, ordered by the primary\n * key, with the engine-native embedding column decoded to a JSON array\n * string by the dialect.\n */\nasync function readLegacyBatch(\n backend: GraphBackend,\n params: ReadLegacyBatchParams,\n): Promise<readonly LegacyEmbeddingRow[]> {\n const table = quotedTableName(params.legacyTableName);\n const embeddingJson = legacyEmbeddingDecodeExpression(backend);\n\n const conditions: SQL[] = [];\n if (params.graphId !== undefined) {\n conditions.push(sql`\"graph_id\" = ${params.graphId}`);\n }\n if (params.after !== undefined) {\n conditions.push(keysetAfterCondition(params.after));\n }\n\n const whereClause =\n conditions.length === 0 ?\n sql``\n : sql` WHERE ${sql.join(conditions, sql` AND `)}`;\n\n const query = sql`\n SELECT\n \"graph_id\" AS graph_id,\n \"node_kind\" AS node_kind,\n \"node_id\" AS node_id,\n \"field_path\" AS field_path,\n ${embeddingJson} AS embedding_json\n FROM ${table}${whereClause}\n ORDER BY \"graph_id\" ASC, \"node_kind\" ASC, \"node_id\" ASC, \"field_path\" ASC\n LIMIT ${params.batchSize}\n `;\n\n return backend.execute<LegacyEmbeddingRow>(asCompiledRowsSql(query));\n}\n\n/**\n * The strict `>` comparison over the composite primary key, expressed as\n * the standard lexicographic OR-chain so it works on every dialect (SQLite\n * supports row-value comparison, but Postgres + SQLite both accept this\n * portable form).\n */\nfunction keysetAfterCondition(after: LegacyRowCursor): SQL {\n return sql`\n (\n \"graph_id\" > ${after.graphId}\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" > ${after.nodeKind})\n OR (\"graph_id\" = ${after.graphId} AND \"node_kind\" = ${after.nodeKind} AND \"node_id\" > ${after.nodeId})\n OR (\n \"graph_id\" = ${after.graphId}\n AND \"node_kind\" = ${after.nodeKind}\n AND \"node_id\" = ${after.nodeId}\n AND \"field_path\" > ${after.fieldPath}\n )\n )\n `;\n}\n\n/**\n * The SQL expression that decodes the legacy engine-native embedding column\n * into a JSON array string `embedding_json`. The single dialect branch in\n * this whole module: the legacy storage formats are genuinely engine-\n * specific, and there is no longer a strategy abstraction over the *legacy*\n * table to delegate to.\n */\nfunction legacyEmbeddingDecodeExpression(backend: GraphBackend): SQL {\n switch (backend.dialect) {\n case \"sqlite\": {\n // Legacy SQLite embeddings were written via `vec_f32('[…]')`\n // (sqlite-vec binary). `vec_to_json` is its inverse, yielding the\n // JSON array text. Requires sqlite-vec on the connection — which the\n // legacy write path also required, so any deployment with legacy rows\n // has it loaded.\n return sql`vec_to_json(\"embedding\")`;\n }\n case \"postgres\": {\n // pgvector's native `vector` casts to its `[…]` text literal, which is\n // valid JSON for `JSON.parse`.\n return sql`\"embedding\"::text`;\n }\n default: {\n const _exhaustive: never = backend.dialect;\n throw new Error(\n `migrateLegacyEmbeddings does not support dialect: ${String(_exhaustive)}`,\n );\n }\n }\n}\n\n/**\n * Parses a decoded `embedding_json` array, asserting it is a non-empty array\n * of finite numbers. A bad decode (wrong type, NaN) names the offending row\n * loudly instead of writing a corrupt vector into per-field storage.\n */\nfunction decodeEmbeddingJson(row: LegacyEmbeddingRow): readonly number[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(row.embedding_json) as unknown;\n } catch (error) {\n throw new Error(\n `Failed to decode legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}): not valid JSON.`,\n { cause: error },\n );\n }\n if (!Array.isArray(parsed) || parsed.length === 0) {\n throw new Error(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) decoded to a non-array ` +\n `or empty value.`,\n );\n }\n for (const [index, value] of parsed.entries()) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(\n `Legacy embedding for ${row.node_kind}.${row.field_path} ` +\n `(graph ${row.graph_id}, node ${row.node_id}) has a non-finite ` +\n `value at index ${index}: ${String(value)}.`,\n );\n }\n }\n return parsed as readonly number[];\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { f as KindAnnotations, N as NodeType, g as EdgeType } from './extension-types-
|
|
3
|
-
export { A as AnyEdgeType,
|
|
4
|
-
import { K as InferenceType, M as MetaEdge, V as VectorStrategy, G as GraphBackend, O as OntologyRelation, L as AggregateExpr, P as FieldRef, T as ComparisonOp, U as AggregateComparisonPredicate } from './types-
|
|
5
|
-
export {
|
|
6
|
-
import { E as EmbeddingMetric, a as EmbeddingIndexType, A as AliasMap, b as EdgeAliasMap, Q as QueryBuilder,
|
|
7
|
-
export {
|
|
8
|
-
import { G as GraphDef
|
|
9
|
-
export { A as AllEdgeTypes, v as AllNodeTypes, w as EdgeKinds, x as GetEdgeType, u as GetNodeType, t as NodeKinds, c as SchemaManagerOptions, d as SchemaValidationResult, y as defineGraph, z as getEdgeKinds, B as getNodeKinds, F as isGraphDef } from './manager-
|
|
10
|
-
export { B as BackendDisposedError, C as CardinalityError, b as CompilerInvariantError, c as ConfigurationError, D as DatabaseOperationError, d as DisjointError, E as EagerMaterializationError, e as EdgeNotFoundError, f as EmbeddingDimensionChangedError, g as EndpointError, h as EndpointNotFoundError, i as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, j as NodeIndexNotFoundError, k as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaContentConflictError, l as SchemaMismatchError, m as StaleVersionError, n as StoreNotInitializedError, o as StoreNotInitializedReason, T as TypeGraphError, p as TypeGraphErrorOptions, U as UniquenessError, q as UnsupportedPredicateError, a as ValidationError, r as ValidationErrorDetails, V as ValidationIssue, s as VersionConflictError, t as getErrorSuggestion, u as isConstraintError, v as isSystemError, w as isTypeGraphError, x as isUserRecoverable } from './index-
|
|
11
|
-
export { a as MaterializeIndexesEntry, b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-
|
|
12
|
-
export { a as andWhere, d as defineEdgeIndex, b as defineNodeIndex, n as notWhere, o as orWhere } from './where-
|
|
2
|
+
import { f as KindAnnotations, N as NodeType, g as EdgeType } from './extension-types-YGFJPrzK.cjs';
|
|
3
|
+
export { A as AnyEdgeType, C as CURRENT_GRAPH_EXTENSION_VERSION, m as Cardinality, n as Collation, D as DeleteBehavior, e as EdgeId, o as EdgeProps, E as EdgeRegistration, p as EdgeTypeWithEndpoints, q as EndpointExistence, c as GraphDefaults, G as GraphExtension, h as GraphExtensionVersion, J as JsonValue, L as LEGACY_GRAPH_EXTENSION_VERSION, d as NodeId, r as NodeProps, b as NodeRegistration, T as TemporalMode, U as UniqueConstraint, s as UniquenessScope, t as isEdgeType, u as isEdgeTypeWithEndpoints, v as isNodeType } from './extension-types-YGFJPrzK.cjs';
|
|
4
|
+
import { K as InferenceType, M as MetaEdge, V as VectorStrategy, G as GraphBackend, O as OntologyRelation, L as AggregateExpr, P as FieldRef, T as ComparisonOp, U as AggregateComparisonPredicate, W as TraversalDirection } from './types-C_UnQOQp.cjs';
|
|
5
|
+
export { X as AdoptedTransaction, B as BackendCapabilities, Y as BackendIdentity, Z as BackendLifecycle, _ as BackendMaintenance, $ as BackendTransactions, a0 as CommitSchemaVersionExpected, a1 as CommitSchemaVersionParams, a2 as CompiledRowsSql, a3 as CompiledSelectSql, a4 as CompiledStatementSql, a5 as ContributionMaterializationBackend, a6 as DEFAULT_SQL_SCHEMA, a7 as DeleteFulltextBatchParams, a8 as EdgeEntityReadBackend, a9 as EdgeEntityWriteBackend, E as EdgeIndexConfig, c as EdgeIndexDeclaration, q as EdgeIndexDirection, r as EdgeIndexWhereBuilder, aa as ExternalRecordedReadSource, ab as FulltextBatchRow, ac as FulltextCapabilities, ad as FulltextOperationBackend, ae as FulltextQueryMode, af as FulltextSearchParams, ag as FulltextSearchResult, F as FulltextStrategy, ah as GraphEntityReadBackend, ai as GraphEntityWriteBackend, aj as GraphLifecycleBackend, ak as HybridFusionOptions, I as IndexDeclaration, al as IndexMaterializationBackend, s as IndexOrigin, t as IndexScope, e as IndexWhereExpression, u as IndexWhereFieldBuilder, v as IndexWhereInput, am as IntentSql, J as JsonPointer, an as JsonPointerFor, ao as JsonPointerInput, ap as JsonPointerSegment, aq as JsonPointerSegments, ar as JsonPointerSegmentsFor, as as MAX_JSON_POINTER_DEPTH, at as MetaEdgeProperties, au as NodeEntityReadBackend, av as NodeEntityWriteBackend, N as NodeIndexConfig, d as NodeIndexDeclaration, w as NodeIndexWhereBuilder, aw as OrderSpec, ax as ParameterRef, ay as QueryExecutionBackend, az as RawQueryExecutionBackend, aA as RawStatementExecutionBackend, aB as RecordedRelationOptions, aC as RemovalMaterializationBackend, aD as ResolveJsonPointer, aE as ResolveJsonPointerSegments, aF as ResolvedSqlTableNames, aG as SchemaCommitBackend, aH as SchemaReadBackend, H as SchemaVersionRow, aI as SetActiveVersionParams, aJ as SortDirection, p as SqlDialect, aK as SqlIntent, aL as SqlSchema, aM as SqlTableNames, aN as StrategyTableContribution, aO as TableContribution, aP as TransactionBackend, aQ as TraversalExpansion, aR as UniqueConstraintBackend, aS as UpsertFulltextBatchParams, aT as VectorCapabilities, aU as VectorOperationBackend, aV as VectorSlot, aW as asCompiledRowsSql, aX as asCompiledSelectSql, aY as asCompiledStatementSql, aZ as buildVectorCapabilities, a_ as createSqlSchema, a$ as fts5Strategy, b0 as isMetaEdge, b1 as joinJsonPointers, b2 as jsonPointer, b3 as normalizeJsonPointer, b4 as parseJsonPointer, b5 as recordedRelation, b6 as tsvectorStrategy } from './types-C_UnQOQp.cjs';
|
|
6
|
+
import { E as EmbeddingMetric, a as EmbeddingIndexType, A as AliasMap, b as EdgeAliasMap, R as RecursiveAliasMap, Q as QueryCoordinateState, c as QueryBuilder, d as EmptyRecursiveAliasMap, T as TraversalBuilder } from './store-view-9jQ2rPum.cjs';
|
|
7
|
+
export { e as AggregateResult, f as AlgorithmCyclePolicy, g as AnyEdge, h as AnyNode, B as BaseTraversalOptions, i as BatchResults, j as BatchableQuery, C as ConstraintNames, k as CreateEdgeInput, l as CreateNodeInput, D as DEFAULT_SEARCHABLE_LANGUAGE, m as DegreeOptions, n as DynamicEdgeAccessor, o as DynamicEdgeCollection, p as DynamicEdgeType, q as DynamicFieldBuilder, r as DynamicNodeAccessor, s as DynamicNodeCollection, t as DynamicNodeType, u as DynamicSelectableEdge, v as DynamicSelectableNode, w as Edge, x as EdgeAccessor, y as EdgeBatchReads, z as EdgeCollection, F as EdgeFindByEndpointsOptions, G as EdgeGetOrCreateByEndpointsOptions, H as EdgeGetOrCreateByEndpointsResult, I as EdgeIntrospection, J as EdgeTemporalReads, K as EdgeWrites, L as EmbeddingSchema, M as EmbeddingValue, O as EmptyAliasMap, P as EmptyEdgeAliasMap, V as ExecutableAggregateQuery, W as ExecutableQuery, X as FieldAccessor, Y as FulltextSearchHit, Z as FulltextSearchOptions, _ as GetOrCreateAction, $ as GraphAlgorithms, a0 as GraphEdgeCollections, a1 as GraphNodeCollections, a2 as HistorySafeBackend, a3 as HistorySafeTransactionBackend, a4 as HistoryStore, a5 as HistoryStoreOptions, a6 as HistoryTransactionContext, a7 as HookContext, a8 as HybridFulltextOptions, a9 as HybridSearchHit, aa as HybridSearchOptions, ab as HybridVectorOptions, ac as IfExistsMode, ad as InitialQueryBuilder, ae as KindIntrospection, af as LiveStoreOptions, ag as MaterializeRemovalsEntry, ah as MaterializeRemovalsOptions, ai as MaterializeRemovalsResult, aj as NeighborsOptions, ak as NoRecordedCoordinate, N as Node, al as NodeAccessor, am as NodeAlias, an as NodeBulkFindByIndexOptions, ao as NodeCollection, ap as NodeCurrentReads, aq as NodeGetOrCreateByConstraintOptions, ar as NodeGetOrCreateByConstraintResult, as as NodeIdentifier, at as NodeRef, au as NodeTemporalReads, av as NodeWrites, aw as OntologyIntrospection, ax as OperationHookContext, ay as PaginateOptions, az as PaginatedResult, aA as PathNode, aB as Predicate, aC as PreparedQuery, aD as PropsAccessor, aE as QueryHookContext, aF as QueryOptions, aG as ReachableNode, aH as ReachableOptions, aI as RebuildFulltextOptions, aJ as RebuildFulltextResult, aK as ReclaimedVectorFieldEntry, aL as RecordedInstant, aM as RecordedReadStore, aN as RecordedStoreView, aO as RecordedStoreViewEdgeCollection, aP as RecordedStoreViewEdgeCollections, aQ as RecordedStoreViewNodeCollection, aR as RecordedStoreViewNodeCollections, aS as RecursiveTraversalOptions, aT as ReembedFunction, aU as ReembedVectorFieldOptions, aV as ReembedVectorFieldResult, aW as SchemaIntrospection, aX as SearchableMetadata, aY as SearchableOptions, aZ as SearchableSchema, a_ as SelectContext, a$ as SelectableEdge, b0 as SelectableNode, b1 as ShortestPathOptions, b2 as ShortestPathResult, S as Store, b3 as StoreHooks, b4 as StoreOptions, b5 as StoreProjection, b6 as StoreRef, b7 as StoreSearch, b8 as StoreView, b9 as StoreViewCanReachOptions, ba as StoreViewCoordinate, bb as StoreViewDegreeOptions, bc as StoreViewEdgeCollection, bd as StoreViewEdgeCollections, be as StoreViewNeighborsOptions, bf as StoreViewNodeCollection, bg as StoreViewNodeCollections, bh as StoreViewReachableOptions, bi as StoreViewShortestPathOptions, bj as StoreViewSubgraphOptions, bk as StreamOptions, bl as SubgraphEdgeResult, bm as SubgraphNodeResult, bn as SubgraphOptions, bo as SubgraphResult, bp as SubsetEdge, bq as SubsetNode, br as TemporalAlgorithmOptions, bs as TransactionContext, bt as TraversalDirection, bu as TypedEdgeCollection, bv as TypedRecordedStoreViewEdgeCollection, bw as TypedStoreViewEdgeCollection, bx as UnionableQuery, U as UniqueIntrospection, by as UpdateEdgeInput, bz as UpdateNodeInput, bA as VectorSearchHit, bB as VectorSearchOptions, bC as asRecordedInstant, bD as createQueryBuilder, bE as createStore, bF as createStoreWithSchema, bG as createVerifiedStore, bH as defineSubgraphProject, bI as embedding, bJ as exists, bK as fieldRef, bL as getEmbeddingDimensions, bM as getSearchableMetadata, bN as inSubquery, bO as isEmbeddingSchema, bP as isParameterRef, bQ as isSearchableSchema, bR as notExists, bS as notInSubquery, bT as param, bU as searchable } from './store-view-9jQ2rPum.cjs';
|
|
8
|
+
import { G as GraphDef } from './manager-BYl_zyZR.cjs';
|
|
9
|
+
export { A as AllEdgeTypes, v as AllNodeTypes, w as EdgeKinds, x as GetEdgeType, u as GetNodeType, t as NodeKinds, c as SchemaManagerOptions, d as SchemaValidationResult, y as defineGraph, z as getEdgeKinds, B as getNodeKinds, F as isGraphDef } from './manager-BYl_zyZR.cjs';
|
|
10
|
+
export { B as BackendDisposedError, C as CardinalityError, b as CompilerInvariantError, c as ConfigurationError, D as DatabaseOperationError, d as DisjointError, E as EagerMaterializationError, e as EdgeNotFoundError, f as EmbeddingDimensionChangedError, g as EndpointError, h as EndpointNotFoundError, i as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, j as NodeIndexNotFoundError, k as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaContentConflictError, l as SchemaMismatchError, m as StaleVersionError, n as StoreNotInitializedError, o as StoreNotInitializedReason, T as TypeGraphError, p as TypeGraphErrorOptions, U as UniquenessError, q as UnsupportedPredicateError, a as ValidationError, r as ValidationErrorDetails, V as ValidationIssue, s as VersionConflictError, t as getErrorSuggestion, u as isConstraintError, v as isSystemError, w as isTypeGraphError, x as isUserRecoverable } from './index-SEvUHDA6.cjs';
|
|
11
|
+
export { a as MaterializeIndexesEntry, b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-D20xNluI.cjs';
|
|
12
|
+
export { a as andWhere, d as defineEdgeIndex, b as defineNodeIndex, n as notWhere, o as orWhere } from './where-Bpp2ul_z.cjs';
|
|
13
13
|
export { GraphExtensionError, GraphExtensionIssue, GraphExtensionIssueCode, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, IncompatibleChange, IncompatibleChangeError, KindCollisionError, KindHasReferentsError, KindReferent, RemoveCompileTimeKindError, defineGraphExtension, validateGraphExtension } from './graph-extension/index.cjs';
|
|
14
14
|
import 'drizzle-orm';
|
|
15
15
|
import 'drizzle-orm/pg-core';
|
|
@@ -791,23 +791,25 @@ declare function havingEq(aggregate: AggregateExpr, value: number): AggregateCom
|
|
|
791
791
|
* @typeParam OutAliases - Output alias map (what the fragment produces)
|
|
792
792
|
* @typeParam InEdgeAliases - Input edge alias map
|
|
793
793
|
* @typeParam OutEdgeAliases - Output edge alias map
|
|
794
|
+
* @typeParam InRecursiveAliases - Input recursive alias map
|
|
795
|
+
* @typeParam OutRecursiveAliases - Output recursive alias map
|
|
794
796
|
*/
|
|
795
|
-
type QueryFragment<G extends GraphDef, InAliases extends AliasMap = AliasMap, OutAliases extends AliasMap = InAliases, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap = InEdgeAliases> = (builder: QueryBuilder<G, InAliases, InEdgeAliases>) => QueryBuilder<G, OutAliases, OutEdgeAliases>;
|
|
797
|
+
type QueryFragment<G extends GraphDef, InAliases extends AliasMap = AliasMap, OutAliases extends AliasMap = InAliases, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap = InEdgeAliases, InRecursiveAliases extends RecursiveAliasMap = EmptyRecursiveAliasMap, OutRecursiveAliases extends RecursiveAliasMap = InRecursiveAliases> = <CoordinateState extends QueryCoordinateState>(builder: QueryBuilder<G, InAliases, InEdgeAliases, InRecursiveAliases, CoordinateState>) => QueryBuilder<G, OutAliases, OutEdgeAliases, OutRecursiveAliases, CoordinateState>;
|
|
796
798
|
/**
|
|
797
799
|
* A flexible query fragment that works with any compatible builder.
|
|
798
800
|
*
|
|
799
801
|
* Use this when you want a fragment that only requires certain aliases
|
|
800
802
|
* to exist, but doesn't care about other aliases that may be present.
|
|
801
803
|
*/
|
|
802
|
-
type FlexibleQueryFragment<G extends GraphDef, RequiredAliases extends AliasMap = AliasMap, AddedAliases extends AliasMap = AliasMap, RequiredEdgeAliases extends EdgeAliasMap = EdgeAliasMap, AddedEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Aliases extends RequiredAliases, EdgeAliases extends RequiredEdgeAliases>(builder: QueryBuilder<G, Aliases, EdgeAliases>) => QueryBuilder<G, Aliases & AddedAliases, EdgeAliases & AddedEdgeAliases>;
|
|
804
|
+
type FlexibleQueryFragment<G extends GraphDef, RequiredAliases extends AliasMap = AliasMap, AddedAliases extends AliasMap = AliasMap, RequiredEdgeAliases extends EdgeAliasMap = EdgeAliasMap, AddedEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Aliases extends RequiredAliases, EdgeAliases extends RequiredEdgeAliases, RecursiveAliases extends RecursiveAliasMap, CoordinateState extends QueryCoordinateState>(builder: QueryBuilder<G, Aliases, EdgeAliases, RecursiveAliases, CoordinateState>) => QueryBuilder<G, Aliases & AddedAliases, EdgeAliases & AddedEdgeAliases, RecursiveAliases, CoordinateState>;
|
|
803
805
|
/**
|
|
804
806
|
* A traversal fragment that transforms a TraversalBuilder.
|
|
805
807
|
*
|
|
806
808
|
* Use this for reusable traversal patterns including edge filtering,
|
|
807
809
|
* recursive traversals, and path collection.
|
|
808
810
|
*/
|
|
809
|
-
type TraversalFragment<G extends GraphDef, EK extends keyof G["edges"] & string, EA extends string, InAliases extends AliasMap = AliasMap, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = (builder: TraversalBuilder<G, InAliases, InEdgeAliases, EK, EA,
|
|
810
|
-
declare function createFragment<G extends GraphDef>(): <InAliases extends AliasMap, OutAliases extends AliasMap, InEdgeAliases extends EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap>(fn:
|
|
811
|
+
type TraversalFragment<G extends GraphDef, EK extends keyof G["edges"] & string, EA extends string, InAliases extends AliasMap = AliasMap, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Dir extends TraversalDirection, Optional extends boolean, DC extends boolean | string, PC extends boolean | string, RecursiveAliases extends RecursiveAliasMap, CoordinateState extends QueryCoordinateState>(builder: TraversalBuilder<G, InAliases, InEdgeAliases, EK, EA, Dir, Optional, DC, PC, RecursiveAliases, CoordinateState>) => unknown;
|
|
812
|
+
declare function createFragment<G extends GraphDef>(): <InAliases extends AliasMap, OutAliases extends AliasMap, InEdgeAliases extends EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap, InRecursiveAliases extends RecursiveAliasMap = EmptyRecursiveAliasMap, OutRecursiveAliases extends RecursiveAliasMap = InRecursiveAliases>(fn: QueryFragment<G, InAliases, OutAliases, InEdgeAliases, OutEdgeAliases, InRecursiveAliases, OutRecursiveAliases>) => QueryFragment<G, InAliases, OutAliases, InEdgeAliases, OutEdgeAliases, InRecursiveAliases, OutRecursiveAliases>;
|
|
811
813
|
/**
|
|
812
814
|
* Combines multiple fragments into a single fragment.
|
|
813
815
|
*
|
|
@@ -827,10 +829,10 @@ declare function createFragment<G extends GraphDef>(): <InAliases extends AliasM
|
|
|
827
829
|
* .select(...)
|
|
828
830
|
* ```
|
|
829
831
|
*/
|
|
830
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>): QueryFragment<G, A1, A2, E1, E2>;
|
|
831
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>): QueryFragment<G, A1, A3, E1, E3>;
|
|
832
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>, f3: QueryFragment<G, A3, A4, E3, E4>): QueryFragment<G, A1, A4, E1, E4>;
|
|
833
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, A5 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, E5 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>, f3: QueryFragment<G, A3, A4, E3, E4>, f4: QueryFragment<G, A4, A5, E4, E5>): QueryFragment<G, A1, A5, E1, E5>;
|
|
832
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>): QueryFragment<G, A1, A2, E1, E2, R1, R2>;
|
|
833
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>): QueryFragment<G, A1, A3, E1, E3, R1, R3>;
|
|
834
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap, R4 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>, f3: QueryFragment<G, A3, A4, E3, E4, R3, R4>): QueryFragment<G, A1, A4, E1, E4, R1, R4>;
|
|
835
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, A5 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, E5 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap, R4 extends RecursiveAliasMap, R5 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>, f3: QueryFragment<G, A3, A4, E3, E4, R3, R4>, f4: QueryFragment<G, A4, A5, E4, E5, R4, R5>): QueryFragment<G, A1, A5, E1, E5, R1, R5>;
|
|
834
836
|
/**
|
|
835
837
|
* Creates a fragment that adds ordering.
|
|
836
838
|
*
|
|
@@ -839,7 +841,7 @@ declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 ex
|
|
|
839
841
|
* const byCreatedAt = orderByFragment<MyGraph, "u">("u", "createdAt", "desc");
|
|
840
842
|
* ```
|
|
841
843
|
*/
|
|
842
|
-
declare function orderByFragment<G extends GraphDef, A extends string>(alias: A, field: string, direction?: "asc" | "desc"):
|
|
844
|
+
declare function orderByFragment<G extends GraphDef, A extends string>(alias: A, field: string, direction?: "asc" | "desc"): FlexibleQueryFragment<G>;
|
|
843
845
|
/**
|
|
844
846
|
* Creates a fragment that adds a limit.
|
|
845
847
|
*
|
|
@@ -848,7 +850,7 @@ declare function orderByFragment<G extends GraphDef, A extends string>(alias: A,
|
|
|
848
850
|
* const first10 = limitFragment<MyGraph>(10);
|
|
849
851
|
* ```
|
|
850
852
|
*/
|
|
851
|
-
declare function limitFragment<G extends GraphDef>(n: number):
|
|
853
|
+
declare function limitFragment<G extends GraphDef>(n: number): FlexibleQueryFragment<G>;
|
|
852
854
|
/**
|
|
853
855
|
* Creates a fragment that adds an offset.
|
|
854
856
|
*
|
|
@@ -857,39 +859,7 @@ declare function limitFragment<G extends GraphDef>(n: number): QueryFragment<G,
|
|
|
857
859
|
* const skip10 = offsetFragment<MyGraph>(10);
|
|
858
860
|
* ```
|
|
859
861
|
*/
|
|
860
|
-
declare function offsetFragment<G extends GraphDef>(n: number):
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Fluent query builder for TypeGraph.
|
|
864
|
-
*
|
|
865
|
-
* Provides a type-safe, chainable API for building queries.
|
|
866
|
-
* Each method returns a new builder instance with expanded type information.
|
|
867
|
-
*
|
|
868
|
-
* This module re-exports from the builder submodules and provides the
|
|
869
|
-
* createQueryBuilder factory function.
|
|
870
|
-
*/
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Creates a new query builder for a graph.
|
|
874
|
-
*
|
|
875
|
-
* @param graphId - The graph identifier
|
|
876
|
-
* @param registry - The kind registry for ontology lookups
|
|
877
|
-
* @param options - Optional backend and dialect configuration
|
|
878
|
-
* @returns A new QueryBuilder instance
|
|
879
|
-
*
|
|
880
|
-
* @example
|
|
881
|
-
* ```typescript
|
|
882
|
-
* // Without execution capability (compile only)
|
|
883
|
-
* const builder = createQueryBuilder<MyGraph>("my_graph", registry);
|
|
884
|
-
*
|
|
885
|
-
* // With execution capability
|
|
886
|
-
* const builder = createQueryBuilder<MyGraph>("my_graph", registry, {
|
|
887
|
-
* backend: myBackend,
|
|
888
|
-
* dialect: "sqlite",
|
|
889
|
-
* });
|
|
890
|
-
* ```
|
|
891
|
-
*/
|
|
892
|
-
declare function createQueryBuilder<G extends GraphDef>(graphId: string, registry: KindRegistry, options?: CreateQueryBuilderOptions): QueryBuilder<G>;
|
|
862
|
+
declare function offsetFragment<G extends GraphDef>(n: number): FlexibleQueryFragment<G>;
|
|
893
863
|
|
|
894
864
|
/**
|
|
895
865
|
* ID generation utilities.
|
|
@@ -918,4 +888,4 @@ type IdConfig = Readonly<{
|
|
|
918
888
|
edgeIdGenerator: IdGenerator;
|
|
919
889
|
}>;
|
|
920
890
|
|
|
921
|
-
export { AliasMap, type DefineEdgeOptions, type DefineNodeOptions, EdgeType, type ExternalRefSchema, type ExternalRefValue, FieldRef, type FlexibleQueryFragment, GraphBackend, GraphDef, type IdConfig, type IdGenerator, InferenceType, KindAnnotations, type LegacyEmbeddingSlotConfig, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, MetaEdge, type MetaEdgeOptions, type MigrateLegacyEmbeddingsOptions, type MigrateLegacyEmbeddingsResult, NodeType, OntologyRelation, QueryBuilder, type QueryFragment, type TraversalFragment, VectorStrategy, avg, broader, composeFragments, computeTransitiveClosure, core, count, countDistinct, countDistinctEdges, countEdges, createExternalRef, createFragment,
|
|
891
|
+
export { AliasMap, type DefineEdgeOptions, type DefineNodeOptions, EdgeType, EmptyRecursiveAliasMap, type ExternalRefSchema, type ExternalRefValue, FieldRef, type FlexibleQueryFragment, GraphBackend, GraphDef, type IdConfig, type IdGenerator, InferenceType, KindAnnotations, type LegacyEmbeddingSlotConfig, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, MetaEdge, type MetaEdgeOptions, type MigrateLegacyEmbeddingsOptions, type MigrateLegacyEmbeddingsResult, NodeType, OntologyRelation, QueryBuilder, QueryCoordinateState, type QueryFragment, type TraversalFragment, VectorStrategy, avg, broader, composeFragments, computeTransitiveClosure, core, count, countDistinct, countDistinctEdges, countEdges, createExternalRef, createFragment, defineEdge, defineNode, differentFrom, disjointWith, equivalentTo, externalRef, field, generateId, getExternalRefTable, hasPart, having, havingEq, havingGt, havingGte, havingLt, havingLte, implies, inverseOf, invertClosure, isExternalRefSchema, isReachable, libsqlVectorStrategy, limitFragment, max, metaEdge, migrateLegacyEmbeddings, min, narrower, offsetFragment, orderByFragment, partOf, pgvectorStrategy, relatedTo, sameAs, sqliteVecStrategy, subClassOf, sum };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { f as KindAnnotations, N as NodeType, g as EdgeType } from './extension-types-
|
|
3
|
-
export { A as AnyEdgeType,
|
|
4
|
-
import { K as InferenceType, M as MetaEdge, V as VectorStrategy, G as GraphBackend, O as OntologyRelation, L as AggregateExpr, P as FieldRef, T as ComparisonOp, U as AggregateComparisonPredicate } from './types-
|
|
5
|
-
export {
|
|
6
|
-
import { E as EmbeddingMetric, a as EmbeddingIndexType, A as AliasMap, b as EdgeAliasMap, Q as QueryBuilder,
|
|
7
|
-
export {
|
|
8
|
-
import { G as GraphDef
|
|
9
|
-
export { A as AllEdgeTypes, v as AllNodeTypes, w as EdgeKinds, x as GetEdgeType, u as GetNodeType, t as NodeKinds, c as SchemaManagerOptions, d as SchemaValidationResult, y as defineGraph, z as getEdgeKinds, B as getNodeKinds, F as isGraphDef } from './manager-
|
|
10
|
-
export { B as BackendDisposedError, C as CardinalityError, b as CompilerInvariantError, c as ConfigurationError, D as DatabaseOperationError, d as DisjointError, E as EagerMaterializationError, e as EdgeNotFoundError, f as EmbeddingDimensionChangedError, g as EndpointError, h as EndpointNotFoundError, i as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, j as NodeIndexNotFoundError, k as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaContentConflictError, l as SchemaMismatchError, m as StaleVersionError, n as StoreNotInitializedError, o as StoreNotInitializedReason, T as TypeGraphError, p as TypeGraphErrorOptions, U as UniquenessError, q as UnsupportedPredicateError, a as ValidationError, r as ValidationErrorDetails, V as ValidationIssue, s as VersionConflictError, t as getErrorSuggestion, u as isConstraintError, v as isSystemError, w as isTypeGraphError, x as isUserRecoverable } from './index-
|
|
11
|
-
export { a as MaterializeIndexesEntry, b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-
|
|
12
|
-
export { a as andWhere, d as defineEdgeIndex, b as defineNodeIndex, n as notWhere, o as orWhere } from './where-
|
|
2
|
+
import { f as KindAnnotations, N as NodeType, g as EdgeType } from './extension-types-YGFJPrzK.js';
|
|
3
|
+
export { A as AnyEdgeType, C as CURRENT_GRAPH_EXTENSION_VERSION, m as Cardinality, n as Collation, D as DeleteBehavior, e as EdgeId, o as EdgeProps, E as EdgeRegistration, p as EdgeTypeWithEndpoints, q as EndpointExistence, c as GraphDefaults, G as GraphExtension, h as GraphExtensionVersion, J as JsonValue, L as LEGACY_GRAPH_EXTENSION_VERSION, d as NodeId, r as NodeProps, b as NodeRegistration, T as TemporalMode, U as UniqueConstraint, s as UniquenessScope, t as isEdgeType, u as isEdgeTypeWithEndpoints, v as isNodeType } from './extension-types-YGFJPrzK.js';
|
|
4
|
+
import { K as InferenceType, M as MetaEdge, V as VectorStrategy, G as GraphBackend, O as OntologyRelation, L as AggregateExpr, P as FieldRef, T as ComparisonOp, U as AggregateComparisonPredicate, W as TraversalDirection } from './types-DGylBhWo.js';
|
|
5
|
+
export { X as AdoptedTransaction, B as BackendCapabilities, Y as BackendIdentity, Z as BackendLifecycle, _ as BackendMaintenance, $ as BackendTransactions, a0 as CommitSchemaVersionExpected, a1 as CommitSchemaVersionParams, a2 as CompiledRowsSql, a3 as CompiledSelectSql, a4 as CompiledStatementSql, a5 as ContributionMaterializationBackend, a6 as DEFAULT_SQL_SCHEMA, a7 as DeleteFulltextBatchParams, a8 as EdgeEntityReadBackend, a9 as EdgeEntityWriteBackend, E as EdgeIndexConfig, c as EdgeIndexDeclaration, q as EdgeIndexDirection, r as EdgeIndexWhereBuilder, aa as ExternalRecordedReadSource, ab as FulltextBatchRow, ac as FulltextCapabilities, ad as FulltextOperationBackend, ae as FulltextQueryMode, af as FulltextSearchParams, ag as FulltextSearchResult, F as FulltextStrategy, ah as GraphEntityReadBackend, ai as GraphEntityWriteBackend, aj as GraphLifecycleBackend, ak as HybridFusionOptions, I as IndexDeclaration, al as IndexMaterializationBackend, s as IndexOrigin, t as IndexScope, e as IndexWhereExpression, u as IndexWhereFieldBuilder, v as IndexWhereInput, am as IntentSql, J as JsonPointer, an as JsonPointerFor, ao as JsonPointerInput, ap as JsonPointerSegment, aq as JsonPointerSegments, ar as JsonPointerSegmentsFor, as as MAX_JSON_POINTER_DEPTH, at as MetaEdgeProperties, au as NodeEntityReadBackend, av as NodeEntityWriteBackend, N as NodeIndexConfig, d as NodeIndexDeclaration, w as NodeIndexWhereBuilder, aw as OrderSpec, ax as ParameterRef, ay as QueryExecutionBackend, az as RawQueryExecutionBackend, aA as RawStatementExecutionBackend, aB as RecordedRelationOptions, aC as RemovalMaterializationBackend, aD as ResolveJsonPointer, aE as ResolveJsonPointerSegments, aF as ResolvedSqlTableNames, aG as SchemaCommitBackend, aH as SchemaReadBackend, H as SchemaVersionRow, aI as SetActiveVersionParams, aJ as SortDirection, p as SqlDialect, aK as SqlIntent, aL as SqlSchema, aM as SqlTableNames, aN as StrategyTableContribution, aO as TableContribution, aP as TransactionBackend, aQ as TraversalExpansion, aR as UniqueConstraintBackend, aS as UpsertFulltextBatchParams, aT as VectorCapabilities, aU as VectorOperationBackend, aV as VectorSlot, aW as asCompiledRowsSql, aX as asCompiledSelectSql, aY as asCompiledStatementSql, aZ as buildVectorCapabilities, a_ as createSqlSchema, a$ as fts5Strategy, b0 as isMetaEdge, b1 as joinJsonPointers, b2 as jsonPointer, b3 as normalizeJsonPointer, b4 as parseJsonPointer, b5 as recordedRelation, b6 as tsvectorStrategy } from './types-DGylBhWo.js';
|
|
6
|
+
import { E as EmbeddingMetric, a as EmbeddingIndexType, A as AliasMap, b as EdgeAliasMap, R as RecursiveAliasMap, Q as QueryCoordinateState, c as QueryBuilder, d as EmptyRecursiveAliasMap, T as TraversalBuilder } from './store-view-FfE5_7eo.js';
|
|
7
|
+
export { e as AggregateResult, f as AlgorithmCyclePolicy, g as AnyEdge, h as AnyNode, B as BaseTraversalOptions, i as BatchResults, j as BatchableQuery, C as ConstraintNames, k as CreateEdgeInput, l as CreateNodeInput, D as DEFAULT_SEARCHABLE_LANGUAGE, m as DegreeOptions, n as DynamicEdgeAccessor, o as DynamicEdgeCollection, p as DynamicEdgeType, q as DynamicFieldBuilder, r as DynamicNodeAccessor, s as DynamicNodeCollection, t as DynamicNodeType, u as DynamicSelectableEdge, v as DynamicSelectableNode, w as Edge, x as EdgeAccessor, y as EdgeBatchReads, z as EdgeCollection, F as EdgeFindByEndpointsOptions, G as EdgeGetOrCreateByEndpointsOptions, H as EdgeGetOrCreateByEndpointsResult, I as EdgeIntrospection, J as EdgeTemporalReads, K as EdgeWrites, L as EmbeddingSchema, M as EmbeddingValue, O as EmptyAliasMap, P as EmptyEdgeAliasMap, V as ExecutableAggregateQuery, W as ExecutableQuery, X as FieldAccessor, Y as FulltextSearchHit, Z as FulltextSearchOptions, _ as GetOrCreateAction, $ as GraphAlgorithms, a0 as GraphEdgeCollections, a1 as GraphNodeCollections, a2 as HistorySafeBackend, a3 as HistorySafeTransactionBackend, a4 as HistoryStore, a5 as HistoryStoreOptions, a6 as HistoryTransactionContext, a7 as HookContext, a8 as HybridFulltextOptions, a9 as HybridSearchHit, aa as HybridSearchOptions, ab as HybridVectorOptions, ac as IfExistsMode, ad as InitialQueryBuilder, ae as KindIntrospection, af as LiveStoreOptions, ag as MaterializeRemovalsEntry, ah as MaterializeRemovalsOptions, ai as MaterializeRemovalsResult, aj as NeighborsOptions, ak as NoRecordedCoordinate, N as Node, al as NodeAccessor, am as NodeAlias, an as NodeBulkFindByIndexOptions, ao as NodeCollection, ap as NodeCurrentReads, aq as NodeGetOrCreateByConstraintOptions, ar as NodeGetOrCreateByConstraintResult, as as NodeIdentifier, at as NodeRef, au as NodeTemporalReads, av as NodeWrites, aw as OntologyIntrospection, ax as OperationHookContext, ay as PaginateOptions, az as PaginatedResult, aA as PathNode, aB as Predicate, aC as PreparedQuery, aD as PropsAccessor, aE as QueryHookContext, aF as QueryOptions, aG as ReachableNode, aH as ReachableOptions, aI as RebuildFulltextOptions, aJ as RebuildFulltextResult, aK as ReclaimedVectorFieldEntry, aL as RecordedInstant, aM as RecordedReadStore, aN as RecordedStoreView, aO as RecordedStoreViewEdgeCollection, aP as RecordedStoreViewEdgeCollections, aQ as RecordedStoreViewNodeCollection, aR as RecordedStoreViewNodeCollections, aS as RecursiveTraversalOptions, aT as ReembedFunction, aU as ReembedVectorFieldOptions, aV as ReembedVectorFieldResult, aW as SchemaIntrospection, aX as SearchableMetadata, aY as SearchableOptions, aZ as SearchableSchema, a_ as SelectContext, a$ as SelectableEdge, b0 as SelectableNode, b1 as ShortestPathOptions, b2 as ShortestPathResult, S as Store, b3 as StoreHooks, b4 as StoreOptions, b5 as StoreProjection, b6 as StoreRef, b7 as StoreSearch, b8 as StoreView, b9 as StoreViewCanReachOptions, ba as StoreViewCoordinate, bb as StoreViewDegreeOptions, bc as StoreViewEdgeCollection, bd as StoreViewEdgeCollections, be as StoreViewNeighborsOptions, bf as StoreViewNodeCollection, bg as StoreViewNodeCollections, bh as StoreViewReachableOptions, bi as StoreViewShortestPathOptions, bj as StoreViewSubgraphOptions, bk as StreamOptions, bl as SubgraphEdgeResult, bm as SubgraphNodeResult, bn as SubgraphOptions, bo as SubgraphResult, bp as SubsetEdge, bq as SubsetNode, br as TemporalAlgorithmOptions, bs as TransactionContext, bt as TraversalDirection, bu as TypedEdgeCollection, bv as TypedRecordedStoreViewEdgeCollection, bw as TypedStoreViewEdgeCollection, bx as UnionableQuery, U as UniqueIntrospection, by as UpdateEdgeInput, bz as UpdateNodeInput, bA as VectorSearchHit, bB as VectorSearchOptions, bC as asRecordedInstant, bD as createQueryBuilder, bE as createStore, bF as createStoreWithSchema, bG as createVerifiedStore, bH as defineSubgraphProject, bI as embedding, bJ as exists, bK as fieldRef, bL as getEmbeddingDimensions, bM as getSearchableMetadata, bN as inSubquery, bO as isEmbeddingSchema, bP as isParameterRef, bQ as isSearchableSchema, bR as notExists, bS as notInSubquery, bT as param, bU as searchable } from './store-view-FfE5_7eo.js';
|
|
8
|
+
import { G as GraphDef } from './manager-C0_r0ALf.js';
|
|
9
|
+
export { A as AllEdgeTypes, v as AllNodeTypes, w as EdgeKinds, x as GetEdgeType, u as GetNodeType, t as NodeKinds, c as SchemaManagerOptions, d as SchemaValidationResult, y as defineGraph, z as getEdgeKinds, B as getNodeKinds, F as isGraphDef } from './manager-C0_r0ALf.js';
|
|
10
|
+
export { B as BackendDisposedError, C as CardinalityError, b as CompilerInvariantError, c as ConfigurationError, D as DatabaseOperationError, d as DisjointError, E as EagerMaterializationError, e as EdgeNotFoundError, f as EmbeddingDimensionChangedError, g as EndpointError, h as EndpointNotFoundError, i as ErrorCategory, K as KindNotFoundError, M as MigrationError, N as NodeConstraintNotFoundError, j as NodeIndexNotFoundError, k as NodeNotFoundError, R as RestrictedDeleteError, S as SchemaContentConflictError, l as SchemaMismatchError, m as StaleVersionError, n as StoreNotInitializedError, o as StoreNotInitializedReason, T as TypeGraphError, p as TypeGraphErrorOptions, U as UniquenessError, q as UnsupportedPredicateError, a as ValidationError, r as ValidationErrorDetails, V as ValidationIssue, s as VersionConflictError, t as getErrorSuggestion, u as isConstraintError, v as isSystemError, w as isTypeGraphError, x as isUserRecoverable } from './index-DGX6D9j1.js';
|
|
11
|
+
export { a as MaterializeIndexesEntry, b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-CAkIYFV-.js';
|
|
12
|
+
export { a as andWhere, d as defineEdgeIndex, b as defineNodeIndex, n as notWhere, o as orWhere } from './where-BsEXraKW.js';
|
|
13
13
|
export { GraphExtensionError, GraphExtensionIssue, GraphExtensionIssueCode, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, IncompatibleChange, IncompatibleChangeError, KindCollisionError, KindHasReferentsError, KindReferent, RemoveCompileTimeKindError, defineGraphExtension, validateGraphExtension } from './graph-extension/index.js';
|
|
14
14
|
import 'drizzle-orm';
|
|
15
15
|
import 'drizzle-orm/pg-core';
|
|
@@ -791,23 +791,25 @@ declare function havingEq(aggregate: AggregateExpr, value: number): AggregateCom
|
|
|
791
791
|
* @typeParam OutAliases - Output alias map (what the fragment produces)
|
|
792
792
|
* @typeParam InEdgeAliases - Input edge alias map
|
|
793
793
|
* @typeParam OutEdgeAliases - Output edge alias map
|
|
794
|
+
* @typeParam InRecursiveAliases - Input recursive alias map
|
|
795
|
+
* @typeParam OutRecursiveAliases - Output recursive alias map
|
|
794
796
|
*/
|
|
795
|
-
type QueryFragment<G extends GraphDef, InAliases extends AliasMap = AliasMap, OutAliases extends AliasMap = InAliases, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap = InEdgeAliases> = (builder: QueryBuilder<G, InAliases, InEdgeAliases>) => QueryBuilder<G, OutAliases, OutEdgeAliases>;
|
|
797
|
+
type QueryFragment<G extends GraphDef, InAliases extends AliasMap = AliasMap, OutAliases extends AliasMap = InAliases, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap = InEdgeAliases, InRecursiveAliases extends RecursiveAliasMap = EmptyRecursiveAliasMap, OutRecursiveAliases extends RecursiveAliasMap = InRecursiveAliases> = <CoordinateState extends QueryCoordinateState>(builder: QueryBuilder<G, InAliases, InEdgeAliases, InRecursiveAliases, CoordinateState>) => QueryBuilder<G, OutAliases, OutEdgeAliases, OutRecursiveAliases, CoordinateState>;
|
|
796
798
|
/**
|
|
797
799
|
* A flexible query fragment that works with any compatible builder.
|
|
798
800
|
*
|
|
799
801
|
* Use this when you want a fragment that only requires certain aliases
|
|
800
802
|
* to exist, but doesn't care about other aliases that may be present.
|
|
801
803
|
*/
|
|
802
|
-
type FlexibleQueryFragment<G extends GraphDef, RequiredAliases extends AliasMap = AliasMap, AddedAliases extends AliasMap = AliasMap, RequiredEdgeAliases extends EdgeAliasMap = EdgeAliasMap, AddedEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Aliases extends RequiredAliases, EdgeAliases extends RequiredEdgeAliases>(builder: QueryBuilder<G, Aliases, EdgeAliases>) => QueryBuilder<G, Aliases & AddedAliases, EdgeAliases & AddedEdgeAliases>;
|
|
804
|
+
type FlexibleQueryFragment<G extends GraphDef, RequiredAliases extends AliasMap = AliasMap, AddedAliases extends AliasMap = AliasMap, RequiredEdgeAliases extends EdgeAliasMap = EdgeAliasMap, AddedEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Aliases extends RequiredAliases, EdgeAliases extends RequiredEdgeAliases, RecursiveAliases extends RecursiveAliasMap, CoordinateState extends QueryCoordinateState>(builder: QueryBuilder<G, Aliases, EdgeAliases, RecursiveAliases, CoordinateState>) => QueryBuilder<G, Aliases & AddedAliases, EdgeAliases & AddedEdgeAliases, RecursiveAliases, CoordinateState>;
|
|
803
805
|
/**
|
|
804
806
|
* A traversal fragment that transforms a TraversalBuilder.
|
|
805
807
|
*
|
|
806
808
|
* Use this for reusable traversal patterns including edge filtering,
|
|
807
809
|
* recursive traversals, and path collection.
|
|
808
810
|
*/
|
|
809
|
-
type TraversalFragment<G extends GraphDef, EK extends keyof G["edges"] & string, EA extends string, InAliases extends AliasMap = AliasMap, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = (builder: TraversalBuilder<G, InAliases, InEdgeAliases, EK, EA,
|
|
810
|
-
declare function createFragment<G extends GraphDef>(): <InAliases extends AliasMap, OutAliases extends AliasMap, InEdgeAliases extends EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap>(fn:
|
|
811
|
+
type TraversalFragment<G extends GraphDef, EK extends keyof G["edges"] & string, EA extends string, InAliases extends AliasMap = AliasMap, InEdgeAliases extends EdgeAliasMap = EdgeAliasMap> = <Dir extends TraversalDirection, Optional extends boolean, DC extends boolean | string, PC extends boolean | string, RecursiveAliases extends RecursiveAliasMap, CoordinateState extends QueryCoordinateState>(builder: TraversalBuilder<G, InAliases, InEdgeAliases, EK, EA, Dir, Optional, DC, PC, RecursiveAliases, CoordinateState>) => unknown;
|
|
812
|
+
declare function createFragment<G extends GraphDef>(): <InAliases extends AliasMap, OutAliases extends AliasMap, InEdgeAliases extends EdgeAliasMap, OutEdgeAliases extends EdgeAliasMap, InRecursiveAliases extends RecursiveAliasMap = EmptyRecursiveAliasMap, OutRecursiveAliases extends RecursiveAliasMap = InRecursiveAliases>(fn: QueryFragment<G, InAliases, OutAliases, InEdgeAliases, OutEdgeAliases, InRecursiveAliases, OutRecursiveAliases>) => QueryFragment<G, InAliases, OutAliases, InEdgeAliases, OutEdgeAliases, InRecursiveAliases, OutRecursiveAliases>;
|
|
811
813
|
/**
|
|
812
814
|
* Combines multiple fragments into a single fragment.
|
|
813
815
|
*
|
|
@@ -827,10 +829,10 @@ declare function createFragment<G extends GraphDef>(): <InAliases extends AliasM
|
|
|
827
829
|
* .select(...)
|
|
828
830
|
* ```
|
|
829
831
|
*/
|
|
830
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>): QueryFragment<G, A1, A2, E1, E2>;
|
|
831
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>): QueryFragment<G, A1, A3, E1, E3>;
|
|
832
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>, f3: QueryFragment<G, A3, A4, E3, E4>): QueryFragment<G, A1, A4, E1, E4>;
|
|
833
|
-
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, A5 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, E5 extends EdgeAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2>, f2: QueryFragment<G, A2, A3, E2, E3>, f3: QueryFragment<G, A3, A4, E3, E4>, f4: QueryFragment<G, A4, A5, E4, E5>): QueryFragment<G, A1, A5, E1, E5>;
|
|
832
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>): QueryFragment<G, A1, A2, E1, E2, R1, R2>;
|
|
833
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>): QueryFragment<G, A1, A3, E1, E3, R1, R3>;
|
|
834
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap, R4 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>, f3: QueryFragment<G, A3, A4, E3, E4, R3, R4>): QueryFragment<G, A1, A4, E1, E4, R1, R4>;
|
|
835
|
+
declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 extends AliasMap, A3 extends AliasMap, A4 extends AliasMap, A5 extends AliasMap, E1 extends EdgeAliasMap, E2 extends EdgeAliasMap, E3 extends EdgeAliasMap, E4 extends EdgeAliasMap, E5 extends EdgeAliasMap, R1 extends RecursiveAliasMap, R2 extends RecursiveAliasMap, R3 extends RecursiveAliasMap, R4 extends RecursiveAliasMap, R5 extends RecursiveAliasMap>(f1: QueryFragment<G, A1, A2, E1, E2, R1, R2>, f2: QueryFragment<G, A2, A3, E2, E3, R2, R3>, f3: QueryFragment<G, A3, A4, E3, E4, R3, R4>, f4: QueryFragment<G, A4, A5, E4, E5, R4, R5>): QueryFragment<G, A1, A5, E1, E5, R1, R5>;
|
|
834
836
|
/**
|
|
835
837
|
* Creates a fragment that adds ordering.
|
|
836
838
|
*
|
|
@@ -839,7 +841,7 @@ declare function composeFragments<G extends GraphDef, A1 extends AliasMap, A2 ex
|
|
|
839
841
|
* const byCreatedAt = orderByFragment<MyGraph, "u">("u", "createdAt", "desc");
|
|
840
842
|
* ```
|
|
841
843
|
*/
|
|
842
|
-
declare function orderByFragment<G extends GraphDef, A extends string>(alias: A, field: string, direction?: "asc" | "desc"):
|
|
844
|
+
declare function orderByFragment<G extends GraphDef, A extends string>(alias: A, field: string, direction?: "asc" | "desc"): FlexibleQueryFragment<G>;
|
|
843
845
|
/**
|
|
844
846
|
* Creates a fragment that adds a limit.
|
|
845
847
|
*
|
|
@@ -848,7 +850,7 @@ declare function orderByFragment<G extends GraphDef, A extends string>(alias: A,
|
|
|
848
850
|
* const first10 = limitFragment<MyGraph>(10);
|
|
849
851
|
* ```
|
|
850
852
|
*/
|
|
851
|
-
declare function limitFragment<G extends GraphDef>(n: number):
|
|
853
|
+
declare function limitFragment<G extends GraphDef>(n: number): FlexibleQueryFragment<G>;
|
|
852
854
|
/**
|
|
853
855
|
* Creates a fragment that adds an offset.
|
|
854
856
|
*
|
|
@@ -857,39 +859,7 @@ declare function limitFragment<G extends GraphDef>(n: number): QueryFragment<G,
|
|
|
857
859
|
* const skip10 = offsetFragment<MyGraph>(10);
|
|
858
860
|
* ```
|
|
859
861
|
*/
|
|
860
|
-
declare function offsetFragment<G extends GraphDef>(n: number):
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Fluent query builder for TypeGraph.
|
|
864
|
-
*
|
|
865
|
-
* Provides a type-safe, chainable API for building queries.
|
|
866
|
-
* Each method returns a new builder instance with expanded type information.
|
|
867
|
-
*
|
|
868
|
-
* This module re-exports from the builder submodules and provides the
|
|
869
|
-
* createQueryBuilder factory function.
|
|
870
|
-
*/
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Creates a new query builder for a graph.
|
|
874
|
-
*
|
|
875
|
-
* @param graphId - The graph identifier
|
|
876
|
-
* @param registry - The kind registry for ontology lookups
|
|
877
|
-
* @param options - Optional backend and dialect configuration
|
|
878
|
-
* @returns A new QueryBuilder instance
|
|
879
|
-
*
|
|
880
|
-
* @example
|
|
881
|
-
* ```typescript
|
|
882
|
-
* // Without execution capability (compile only)
|
|
883
|
-
* const builder = createQueryBuilder<MyGraph>("my_graph", registry);
|
|
884
|
-
*
|
|
885
|
-
* // With execution capability
|
|
886
|
-
* const builder = createQueryBuilder<MyGraph>("my_graph", registry, {
|
|
887
|
-
* backend: myBackend,
|
|
888
|
-
* dialect: "sqlite",
|
|
889
|
-
* });
|
|
890
|
-
* ```
|
|
891
|
-
*/
|
|
892
|
-
declare function createQueryBuilder<G extends GraphDef>(graphId: string, registry: KindRegistry, options?: CreateQueryBuilderOptions): QueryBuilder<G>;
|
|
862
|
+
declare function offsetFragment<G extends GraphDef>(n: number): FlexibleQueryFragment<G>;
|
|
893
863
|
|
|
894
864
|
/**
|
|
895
865
|
* ID generation utilities.
|
|
@@ -918,4 +888,4 @@ type IdConfig = Readonly<{
|
|
|
918
888
|
edgeIdGenerator: IdGenerator;
|
|
919
889
|
}>;
|
|
920
890
|
|
|
921
|
-
export { AliasMap, type DefineEdgeOptions, type DefineNodeOptions, EdgeType, type ExternalRefSchema, type ExternalRefValue, FieldRef, type FlexibleQueryFragment, GraphBackend, GraphDef, type IdConfig, type IdGenerator, InferenceType, KindAnnotations, type LegacyEmbeddingSlotConfig, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, MetaEdge, type MetaEdgeOptions, type MigrateLegacyEmbeddingsOptions, type MigrateLegacyEmbeddingsResult, NodeType, OntologyRelation, QueryBuilder, type QueryFragment, type TraversalFragment, VectorStrategy, avg, broader, composeFragments, computeTransitiveClosure, core, count, countDistinct, countDistinctEdges, countEdges, createExternalRef, createFragment,
|
|
891
|
+
export { AliasMap, type DefineEdgeOptions, type DefineNodeOptions, EdgeType, EmptyRecursiveAliasMap, type ExternalRefSchema, type ExternalRefValue, FieldRef, type FlexibleQueryFragment, GraphBackend, GraphDef, type IdConfig, type IdGenerator, InferenceType, KindAnnotations, type LegacyEmbeddingSlotConfig, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, MetaEdge, type MetaEdgeOptions, type MigrateLegacyEmbeddingsOptions, type MigrateLegacyEmbeddingsResult, NodeType, OntologyRelation, QueryBuilder, QueryCoordinateState, type QueryFragment, type TraversalFragment, VectorStrategy, avg, broader, composeFragments, computeTransitiveClosure, core, count, countDistinct, countDistinctEdges, countEdges, createExternalRef, createFragment, defineEdge, defineNode, differentFrom, disjointWith, equivalentTo, externalRef, field, generateId, getExternalRefTable, hasPart, having, havingEq, havingGt, havingGte, havingLt, havingLte, implies, inverseOf, invertClosure, isExternalRefSchema, isReachable, libsqlVectorStrategy, limitFragment, max, metaEdge, migrateLegacyEmbeddings, min, narrower, offsetFragment, orderByFragment, partOf, pgvectorStrategy, relatedTo, sameAs, sqliteVecStrategy, subClassOf, sum };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
export { sqliteVecStrategy } from './chunk-
|
|
2
|
-
export { libsqlVectorStrategy } from './chunk-
|
|
3
|
-
export { pgvectorStrategy } from './chunk-
|
|
1
|
+
export { sqliteVecStrategy } from './chunk-XKNAK27R.js';
|
|
2
|
+
export { libsqlVectorStrategy } from './chunk-CEF2QOTO.js';
|
|
3
|
+
export { pgvectorStrategy } from './chunk-PRMKPFN5.js';
|
|
4
4
|
export { andWhere, notWhere, orWhere } from './chunk-A3W7QG7K.js';
|
|
5
5
|
export { defineGraphExtension } from './chunk-WYTUF3QO.js';
|
|
6
|
-
|
|
6
|
+
import { asCompiledRowsSql } from './chunk-WLP6TKFB.js';
|
|
7
|
+
export { DEFAULT_SQL_SCHEMA, ExecutableAggregateQuery, ExecutableQuery, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, PreparedQuery, QueryBuilder, RecordedStoreView, StoreSearch, StoreView, UnionableQuery, asCompiledRowsSql, asCompiledSelectSql, asCompiledStatementSql, asRecordedInstant, avg, composeFragments, count, countDistinct, countDistinctEdges, countEdges, createFragment, createQueryBuilder, createSqlSchema, createStore, createStoreWithSchema, createVerifiedStore, defineSubgraphProject, field, generateId, having, havingEq, havingGt, havingGte, havingLt, havingLte, limitFragment, max, min, offsetFragment, orderByFragment, recordedRelation, sum } from './chunk-WLP6TKFB.js';
|
|
7
8
|
import './chunk-3EUKJEQ3.js';
|
|
8
|
-
import { META_EDGE_BRAND } from './chunk-
|
|
9
|
-
export { broader, core, defineEdge, defineNode, differentFrom, disjointWith, equivalentTo, hasPart, implies, inverseOf, isMetaEdge, narrower, partOf, relatedTo, sameAs, subClassOf } from './chunk-
|
|
10
|
-
export { defineGraph, getEdgeKinds, getNodeKinds, isEdgeType, isEdgeTypeWithEndpoints, isGraphDef, isNodeType } from './chunk-
|
|
11
|
-
import './chunk-
|
|
12
|
-
export { defineEdgeIndex, defineNodeIndex } from './chunk-
|
|
13
|
-
export { DEFAULT_SEARCHABLE_LANGUAGE, getSearchableMetadata, isSearchableSchema, searchable } from './chunk-
|
|
9
|
+
import { META_EDGE_BRAND } from './chunk-XVUJY72M.js';
|
|
10
|
+
export { broader, core, defineEdge, defineNode, differentFrom, disjointWith, equivalentTo, hasPart, implies, inverseOf, isMetaEdge, narrower, partOf, relatedTo, sameAs, subClassOf } from './chunk-XVUJY72M.js';
|
|
11
|
+
export { defineGraph, getEdgeKinds, getNodeKinds, isEdgeType, isEdgeTypeWithEndpoints, isGraphDef, isNodeType } from './chunk-QBYTJSAY.js';
|
|
12
|
+
import './chunk-PIHXFF73.js';
|
|
13
|
+
export { defineEdgeIndex, defineNodeIndex } from './chunk-6NRFUHMS.js';
|
|
14
|
+
export { DEFAULT_SEARCHABLE_LANGUAGE, getSearchableMetadata, isSearchableSchema, searchable } from './chunk-IZ4PCL47.js';
|
|
14
15
|
import { DEFAULT_EMBEDDING_INDEX_TYPE, DEFAULT_EMBEDDING_METRIC } from './chunk-454I6GDF.js';
|
|
15
16
|
export { embedding, getEmbeddingDimensions, isEmbeddingSchema } from './chunk-454I6GDF.js';
|
|
16
17
|
export { CURRENT_GRAPH_EXTENSION_VERSION, GraphExtensionError, GraphExtensionUnresolvedEndpointError, GraphExtensionValidationError, GraphExtensionVersionUnsupportedError, IncompatibleChangeError, KindCollisionError, KindHasReferentsError, LEGACY_GRAPH_EXTENSION_VERSION, RemoveCompileTimeKindError, computeTransitiveClosure, invertClosure, isReachable, validateGraphExtension } from './chunk-YCV72E6L.js';
|
|
17
|
-
import { LEGACY_EMBEDDINGS_TABLE_NAME } from './chunk-
|
|
18
|
-
import './chunk-
|
|
19
|
-
|
|
20
|
-
import { isMissingTableError } from './chunk-
|
|
21
|
-
import { quotedTableName } from './chunk-
|
|
22
|
-
export { buildVectorCapabilities, fts5Strategy, tsvectorStrategy } from './chunk-
|
|
18
|
+
import { LEGACY_EMBEDDINGS_TABLE_NAME } from './chunk-DJYRRDHA.js';
|
|
19
|
+
import './chunk-CWFPJ3RC.js';
|
|
20
|
+
export { exists, fieldRef, inSubquery, isParameterRef, notExists, notInSubquery, param } from './chunk-PYD3UCDU.js';
|
|
21
|
+
import { isMissingTableError } from './chunk-GYVBEZAO.js';
|
|
22
|
+
import { quotedTableName } from './chunk-C4C4Q7A6.js';
|
|
23
|
+
export { buildVectorCapabilities, fts5Strategy, tsvectorStrategy } from './chunk-C4C4Q7A6.js';
|
|
23
24
|
import './chunk-2YMGNYXY.js';
|
|
25
|
+
import './chunk-XLUNB2TZ.js';
|
|
24
26
|
import { EmbeddingDimensionChangedError } from './chunk-TQOYM4LN.js';
|
|
25
27
|
export { BackendDisposedError, CardinalityError, CompilerInvariantError, ConfigurationError, DatabaseOperationError, DisjointError, EagerMaterializationError, EdgeNotFoundError, EmbeddingDimensionChangedError, EndpointError, EndpointNotFoundError, KindNotFoundError, MigrationError, NodeConstraintNotFoundError, NodeIndexNotFoundError, NodeNotFoundError, RestrictedDeleteError, SchemaContentConflictError, SchemaMismatchError, StaleVersionError, StoreNotInitializedError, TypeGraphError, UniquenessError, UnsupportedPredicateError, ValidationError, VersionConflictError, getErrorSuggestion, isConstraintError, isSystemError, isTypeGraphError, isUserRecoverable } from './chunk-TQOYM4LN.js';
|
|
26
28
|
export { MAX_JSON_POINTER_DEPTH, joinJsonPointers, jsonPointer, normalizeJsonPointer, parseJsonPointer } from './chunk-K5P5OZXS.js';
|
|
@@ -191,7 +193,7 @@ async function readLegacyBatch(backend, params) {
|
|
|
191
193
|
ORDER BY "graph_id" ASC, "node_kind" ASC, "node_id" ASC, "field_path" ASC
|
|
192
194
|
LIMIT ${params.batchSize}
|
|
193
195
|
`;
|
|
194
|
-
return backend.execute(query);
|
|
196
|
+
return backend.execute(asCompiledRowsSql(query));
|
|
195
197
|
}
|
|
196
198
|
function keysetAfterCondition(after) {
|
|
197
199
|
return sql`
|