@nicia-ai/typegraph 0.29.0 → 0.31.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 +39 -0
- package/dist/backend/postgres/index.cjs +21 -20
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +11 -10
- package/dist/backend/postgres/pglite.cjs +16 -15
- 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 +11 -10
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +18 -18
- package/dist/backend/sqlite/index.d.cts +12 -7
- package/dist/backend/sqlite/index.d.ts +12 -7
- package/dist/backend/sqlite/index.js +9 -9
- package/dist/backend/sqlite/libsql.cjs +14 -14
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +10 -10
- package/dist/backend/sqlite/local.cjs +17 -16
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +9 -3
- package/dist/backend/sqlite/local.d.ts +9 -3
- package/dist/backend/sqlite/local.js +12 -11
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-7KLVFWXR.js → chunk-2HZGWCB4.js} +121 -497
- package/dist/chunk-2HZGWCB4.js.map +1 -0
- package/dist/chunk-2YMGNYXY.js +40 -0
- package/dist/chunk-2YMGNYXY.js.map +1 -0
- package/dist/chunk-2ZY4K43M.js +90 -0
- package/dist/chunk-2ZY4K43M.js.map +1 -0
- package/dist/chunk-3EUKJEQ3.js +77 -0
- package/dist/chunk-3EUKJEQ3.js.map +1 -0
- package/dist/chunk-3JBJEYWE.cjs +604 -0
- package/dist/chunk-3JBJEYWE.cjs.map +1 -0
- package/dist/{chunk-A4H6QMV4.js → chunk-4A4GUZTQ.js} +15 -11
- package/dist/chunk-4A4GUZTQ.js.map +1 -0
- package/dist/{chunk-F2Q76CQ4.cjs → chunk-54JVNOAQ.cjs} +5 -37
- package/dist/chunk-54JVNOAQ.cjs.map +1 -0
- package/dist/{chunk-KGAJ5HFO.cjs → chunk-5CN7B4CZ.cjs} +17 -98
- package/dist/chunk-5CN7B4CZ.cjs.map +1 -0
- package/dist/{chunk-XTQHSOIC.cjs → chunk-5DTPBFX5.cjs} +88 -87
- package/dist/chunk-5DTPBFX5.cjs.map +1 -0
- package/dist/chunk-6G35I3VW.cjs +40 -0
- package/dist/chunk-6G35I3VW.cjs.map +1 -0
- package/dist/{chunk-UPBXUOW7.cjs → chunk-6RMLO5O4.cjs} +19 -64
- package/dist/chunk-6RMLO5O4.cjs.map +1 -0
- package/dist/chunk-6SA7UIQJ.cjs +94 -0
- package/dist/chunk-6SA7UIQJ.cjs.map +1 -0
- package/dist/chunk-6ZR4QC3O.cjs +12 -0
- package/dist/{chunk-Q3ZZLU3O.cjs.map → chunk-6ZR4QC3O.cjs.map} +1 -1
- package/dist/chunk-73KASJGO.cjs +52 -0
- package/dist/chunk-73KASJGO.cjs.map +1 -0
- package/dist/{chunk-R2LA6MKR.cjs → chunk-7JGLPAFV.cjs} +8 -8
- package/dist/{chunk-R2LA6MKR.cjs.map → chunk-7JGLPAFV.cjs.map} +1 -1
- package/dist/chunk-A3W7QG7K.js +45 -0
- package/dist/chunk-A3W7QG7K.js.map +1 -0
- package/dist/{chunk-Q5ASTPM4.cjs → chunk-ASYQDPPU.cjs} +19 -19
- package/dist/{chunk-Q5ASTPM4.cjs.map → chunk-ASYQDPPU.cjs.map} +1 -1
- package/dist/{chunk-IE2TPFBT.js → chunk-ATTXBMAX.js} +4 -74
- package/dist/chunk-ATTXBMAX.js.map +1 -0
- package/dist/chunk-AW4A3P5A.cjs +51 -0
- package/dist/chunk-AW4A3P5A.cjs.map +1 -0
- package/dist/{chunk-ZYQEXGYC.cjs → chunk-CIINW6PS.cjs} +92 -87
- package/dist/chunk-CIINW6PS.cjs.map +1 -0
- package/dist/{chunk-UP4QAJND.cjs → chunk-FLOI7QOT.cjs} +66 -65
- package/dist/chunk-FLOI7QOT.cjs.map +1 -0
- package/dist/{chunk-7V335GHG.cjs → chunk-FLRCVI2G.cjs} +12 -2
- package/dist/chunk-FLRCVI2G.cjs.map +1 -0
- package/dist/{chunk-HKN622O4.js → chunk-GKFWM3DS.js} +4 -32
- package/dist/chunk-GKFWM3DS.js.map +1 -0
- package/dist/chunk-HTGDWIDE.cjs +89 -0
- package/dist/chunk-HTGDWIDE.cjs.map +1 -0
- package/dist/{chunk-OGUH56BB.js → chunk-IJORSAC3.js} +6 -42
- package/dist/chunk-IJORSAC3.js.map +1 -0
- package/dist/{chunk-G6P3OVDY.cjs → chunk-JIEJCTDS.cjs} +18 -2
- package/dist/chunk-JIEJCTDS.cjs.map +1 -0
- package/dist/{chunk-NZ5PMBTG.js → chunk-K5P5OZXS.js} +12 -3
- package/dist/chunk-K5P5OZXS.js.map +1 -0
- package/dist/{chunk-HM6XMR3E.cjs → chunk-KTIEB7VH.cjs} +42 -32
- package/dist/chunk-KTIEB7VH.cjs.map +1 -0
- package/dist/chunk-LJLMDDCW.js +282 -0
- package/dist/chunk-LJLMDDCW.js.map +1 -0
- package/dist/{chunk-Z36W5WUM.js → chunk-MAQJYNJR.js} +3 -3
- package/dist/{chunk-Z36W5WUM.js.map → chunk-MAQJYNJR.js.map} +1 -1
- package/dist/{chunk-N3VVQDMA.js → chunk-MXE2U3EX.js} +3 -3
- package/dist/{chunk-N3VVQDMA.js.map → chunk-MXE2U3EX.js.map} +1 -1
- package/dist/{chunk-4K6IHUW6.cjs → chunk-N2MBPTAF.cjs} +14 -14
- package/dist/{chunk-4K6IHUW6.cjs.map → chunk-N2MBPTAF.cjs.map} +1 -1
- package/dist/{chunk-CUZGBWFT.js → chunk-O4VUR6SI.js} +3 -3
- package/dist/{chunk-CUZGBWFT.js.map → chunk-O4VUR6SI.js.map} +1 -1
- package/dist/chunk-RZ4DH4E7.cjs +15832 -0
- package/dist/chunk-RZ4DH4E7.cjs.map +1 -0
- package/dist/chunk-SAJSMR2B.js +35 -0
- package/dist/chunk-SAJSMR2B.js.map +1 -0
- package/dist/{chunk-RU5BBUU2.cjs → chunk-SFFJ2IKN.cjs} +71 -67
- package/dist/chunk-SFFJ2IKN.cjs.map +1 -0
- package/dist/{chunk-Y52UNT66.js → chunk-STP7QVUB.js} +8 -7
- package/dist/chunk-STP7QVUB.js.map +1 -0
- package/dist/chunk-THX25XW6.js +590 -0
- package/dist/chunk-THX25XW6.js.map +1 -0
- package/dist/{chunk-MB363HT5.js → chunk-TQOYM4LN.js} +18 -3
- package/dist/chunk-TQOYM4LN.js.map +1 -0
- package/dist/chunk-UIFEEPME.js +15787 -0
- package/dist/chunk-UIFEEPME.js.map +1 -0
- package/dist/{chunk-GPUNAJFH.js → chunk-UJ4V3YUQ.js} +3 -3
- package/dist/{chunk-GPUNAJFH.js.map → chunk-UJ4V3YUQ.js.map} +1 -1
- package/dist/{chunk-C2RWFIYP.cjs → chunk-V4IQYOQ4.cjs} +127 -511
- package/dist/chunk-V4IQYOQ4.cjs.map +1 -0
- package/dist/chunk-VMEWZU2N.cjs +287 -0
- package/dist/chunk-VMEWZU2N.cjs.map +1 -0
- package/dist/{chunk-3DTLDGIM.js → chunk-VZX2KSY3.js} +14 -9
- package/dist/chunk-VZX2KSY3.js.map +1 -0
- package/dist/{chunk-BMDF2S7S.js → chunk-WYTUF3QO.js} +3 -3
- package/dist/{chunk-BMDF2S7S.js.map → chunk-WYTUF3QO.js.map} +1 -1
- package/dist/{chunk-MRMD7S7E.js → chunk-XKJQQQVR.js} +9 -8
- package/dist/chunk-XKJQQQVR.js.map +1 -0
- package/dist/{chunk-SFNUHFON.js → chunk-YCV72E6L.js} +25 -19
- package/dist/chunk-YCV72E6L.js.map +1 -0
- package/dist/{chunk-VGU26WIU.cjs → chunk-YQGLVWB2.cjs} +4 -4
- package/dist/{chunk-VGU26WIU.cjs.map → chunk-YQGLVWB2.cjs.map} +1 -1
- package/dist/{ddl-BwH00BB6.d.ts → ddl-BJcPrB4L.d.ts} +3 -3
- package/dist/{ddl-D3o-RmsV.d.cts → ddl-CPZ7mB7X.d.cts} +3 -3
- package/dist/{extension-types-CwHV-Uk4.d.ts → extension-types-D1k0inWU.d.cts} +1 -1
- package/dist/{extension-types-CwHV-Uk4.d.cts → extension-types-D1k0inWU.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +19 -19
- package/dist/graph-extension/index.d.cts +5 -16
- package/dist/graph-extension/index.d.ts +5 -16
- package/dist/graph-extension/index.js +4 -4
- package/dist/graph-merge/index.cjs +3822 -0
- package/dist/graph-merge/index.cjs.map +1 -0
- package/dist/graph-merge/index.d.cts +1191 -0
- package/dist/graph-merge/index.d.ts +1191 -0
- package/dist/graph-merge/index.js +3791 -0
- package/dist/graph-merge/index.js.map +1 -0
- package/dist/{index-CapHwi1a.d.ts → index-BEK0VtNB.d.ts} +11 -3
- package/dist/{index-jPPexxM5.d.cts → index-C8sSTErx.d.cts} +11 -3
- package/dist/index.cjs +365 -15732
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +27 -15533
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +32 -28
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +8 -4
- package/dist/interchange/index.cjs +50 -593
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -5
- package/dist/interchange/index.d.ts +5 -5
- package/dist/interchange/index.js +3 -589
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-BUugwCYz.d.ts → manager-By-WEd8M.d.ts} +3 -3
- package/dist/{manager-DpIpn1HQ.d.cts → manager-Np7VVSlE.d.cts} +3 -3
- package/dist/{materialize-indexes-lkawaDor.d.ts → materialize-indexes-CAGhqPHQ.d.ts} +1 -1
- package/dist/{materialize-indexes-oanE3RU0.d.cts → materialize-indexes-DEYkU-wr.d.cts} +1 -1
- package/dist/{postgres-CQL9UIn2.d.cts → postgres-4J2tmauh.d.cts} +1 -1
- package/dist/{postgres-CcRLaxz0.d.ts → postgres-BdIb7tS_.d.ts} +1 -1
- package/dist/profiler/index.cjs +9 -9
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -2
- package/dist/result-DWo6mUVz.d.cts +37 -0
- package/dist/result-DWo6mUVz.d.ts +37 -0
- package/dist/schema/index.cjs +33 -32
- 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 +10 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-Rj3xu4It.d.cts → sqlite-Gatk_iw_.d.cts} +1 -1
- package/dist/{sqlite-CZDFUfHS.d.ts → sqlite-aM_PAz-O.d.ts} +1 -1
- package/dist/{store-B43FpOVX.d.cts → store-DuCbdqsh.d.cts} +84 -44
- package/dist/{store-De0Y33wP.d.ts → store-MloRPwb9.d.ts} +84 -44
- package/dist/{types-DXCSyxac.d.cts → types-BKQljXom.d.ts} +18 -2
- package/dist/{types-CmAT-Z47.d.ts → types-C1CYxWrL.d.cts} +18 -2
- package/dist/{types-Bwlp_yvu.d.cts → types-DoByHGyU.d.cts} +2 -2
- package/dist/{types-B5GSeE3t.d.ts → types-K3vpaJAL.d.ts} +2 -2
- package/dist/{where-CP4qGIHd.d.ts → where-Dt49bvo6.d.ts} +2 -2
- package/dist/{where-2dsyYt3d.d.cts → where-DydZjGOb.d.cts} +2 -2
- package/package.json +6 -1
- package/dist/chunk-3DTLDGIM.js.map +0 -1
- package/dist/chunk-7KLVFWXR.js.map +0 -1
- package/dist/chunk-7V335GHG.cjs.map +0 -1
- package/dist/chunk-A4H6QMV4.js.map +0 -1
- package/dist/chunk-C2RWFIYP.cjs.map +0 -1
- package/dist/chunk-F2Q76CQ4.cjs.map +0 -1
- package/dist/chunk-G6P3OVDY.cjs.map +0 -1
- package/dist/chunk-HKN622O4.js.map +0 -1
- package/dist/chunk-HM6XMR3E.cjs.map +0 -1
- package/dist/chunk-IE2TPFBT.js.map +0 -1
- package/dist/chunk-KGAJ5HFO.cjs.map +0 -1
- package/dist/chunk-MB363HT5.js.map +0 -1
- package/dist/chunk-MRMD7S7E.js.map +0 -1
- package/dist/chunk-NZ5PMBTG.js.map +0 -1
- package/dist/chunk-OGUH56BB.js.map +0 -1
- package/dist/chunk-Q3ZZLU3O.cjs +0 -12
- package/dist/chunk-RU5BBUU2.cjs.map +0 -1
- package/dist/chunk-SFNUHFON.js.map +0 -1
- package/dist/chunk-UP4QAJND.cjs.map +0 -1
- package/dist/chunk-UPBXUOW7.cjs.map +0 -1
- package/dist/chunk-XTQHSOIC.cjs.map +0 -1
- package/dist/chunk-Y52UNT66.js.map +0 -1
- package/dist/chunk-ZYQEXGYC.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/drizzle/operations/shared.ts","../src/backend/table-contribution.ts","../src/query/dialect/fulltext-strategy.ts","../src/query/dialect/postgres.ts","../src/query/dialect/sqlite.ts","../src/query/dialect/vector-strategy.ts","../src/query/dialect/index.ts","../src/indexes/compiler.ts","../src/indexes/ddl.ts","../src/indexes/drizzle.ts","../src/indexes/profiler.ts","../src/indexes/where.ts"],"names":["sql","parseJsonPointer","quoteIdentifier","jsonPointer","CasingCache","escapeStringLiteral","pgUniqueIndex","pgIndex","sqliteUniqueIndex","sqliteIndex"],"mappings":";;;;;;;;AAWO,SAAS,QAAQ,KAAA,EAAyC;AAC/D,EAAA,OAAO,KAAA,IAASA,cAAA,CAAI,GAAA,CAAI,MAAM,CAAA;AAChC;AAEO,SAAS,aAAa,MAAA,EAA+B;AAC1D,EAAA,OAAOA,cAAA,CAAI,I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,eAAA,CAAgB,KAAK,CAAC,CAAA;AAC1C;;;AChCO,SAAS,YACX,UAAA,EACmB;AACtB,EAAA,IAAI,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,WAAW,CAAC,CAAA;AAAA,EACrB;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,iBAAA;AAAA,IACR;AAAA,GACF;AACF;AAEO,SAAS,WACX,UAAA,EACmB;AACtB,EAAA,IAAI,UAAA,CAAW,WAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,WAAW,CAAC,CAAA;AAAA,EACrB;AAEA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,gBAAA;AAAA,IACR;AAAA,GACF;AACF;AAEO,SAAS,SACd,SAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,iBAAA;AAAA,IACR;AAAA,GACF;AACF","file":"chunk-C2RWFIYP.cjs","sourcesContent":["import { type SQL, sql } from \"drizzle-orm\";\n\nimport type { PostgresTables } from \"../schema/postgres\";\nimport type { SqliteTables } from \"../schema/sqlite\";\n\nexport type Tables = SqliteTables | PostgresTables;\n\n/**\n * Converts undefined to SQL NULL for use in template literals.\n * Drizzle doesn't handle undefined in sql`` templates correctly.\n */\nexport function sqlNull(value: string | undefined): SQL | string {\n return value ?? sql.raw(\"NULL\");\n}\n\nexport function quotedColumn(column: { name: string }): SQL {\n return sql.raw(`\"${column.name.replaceAll('\"', '\"\"')}\"`);\n}\n\n/**\n * Returns a quoted SQL identifier for a bare table name string.\n * Use when the operation targets a table that isn't represented as a\n * Drizzle table object (e.g. the FTS5 virtual table).\n */\nexport function quotedTableName(tableName: string): SQL {\n return sql.raw(`\"${tableName.replaceAll('\"', '\"\"')}\"`);\n}\n\nexport function nodeColumnList(nodes: Tables[\"nodes\"]): SQL {\n return sql.raw(`\"${nodes.graphId.name}\", \"${nodes.kind.name}\", \"${nodes.id.name}\", \"${nodes.props.name}\", \"${nodes.version.name}\", \"${nodes.validFrom.name}\", \"${nodes.validTo.name}\", \"${nodes.createdAt.name}\", \"${nodes.updatedAt.name}\"`);\n}\n\nexport function edgeColumnList(edges: Tables[\"edges\"]): SQL {\n return sql.raw(`\"${edges.graphId.name}\", \"${edges.id.name}\", \"${edges.kind.name}\", \"${edges.fromKind.name}\", \"${edges.fromId.name}\", \"${edges.toKind.name}\", \"${edges.toId.name}\", \"${edges.props.name}\", \"${edges.validFrom.name}\", \"${edges.validTo.name}\", \"${edges.createdAt.name}\", \"${edges.updatedAt.name}\"`);\n}\n","/**\n * Unified table-contribution contract (#129).\n *\n * Every table TypeGraph owns — whether modeled as a Drizzle table or\n * emitted as strategy-owned raw DDL — is described by a single\n * {@link TableContribution} shape. This is the one place that answers\n * \"what tables does this backend/strategy own?\", replacing the\n * previously split surfaces (Drizzle named exports, tables-factory\n * recursion, strategy raw DDL, per-table `ensureXTable` methods).\n *\n * Lives in the neutral `backend/` layer (sibling of `backend/types.ts`,\n * which `query/dialect` already depends on) and is deliberately\n * Drizzle-free, so declaring contributions does not pull the concrete\n * Drizzle backend runtime into the query/dialect layer.\n *\n * ## Identity vs. signature (prerequisite for #135)\n *\n * #135 (durable fulltext/contribution materialization) needs to make\n * \"not materialized\" vs. \"materialized but stale\" a decidable, durable\n * fact instead of an in-memory per-backend latch. That requires two\n * conceptually separate things, and #129's job is only to make both\n * *derivable* from the contract:\n *\n * - **Materialization identity** — `owner` + `logicalName` +\n * resolved physical `tableName`. Keying on `logicalName` alone is\n * insufficient: custom per-deployment table names must be\n * distinguishable, otherwise two deployments with different physical\n * names would collide on one durable marker. (#135 additionally\n * scopes this by `graphId` at persistence time.)\n * - **Drift signature** — a hash of the strategy identity/version,\n * the resolved table name(s), and the normalized `createDdl`. #129\n * guarantees `createDdl` is deterministic for a given resolved\n * configuration so the hash #135 computes is meaningful.\n *\n * The signature is intentionally **not** eagerly carried on the\n * contribution: hashing is async (Web Crypto, see `utils/hash`) and\n * #135 already owns signature persistence the same way\n * `materializeIndexes` does for declared indexes.\n */\n\n/**\n * `logicalName` of the strategy-owned fulltext slot. Used as a logic\n * discriminant (latch routing, runtime-ensure) across the strategies\n * and both backends — a shared constant so a strategy declaring a\n * different name fails loudly at the call site instead of silently\n * skipping the latched fulltext path.\n */\nexport const FULLTEXT_CONTRIBUTION_NAME = \"fulltext\";\n\n/** `owner` of core/base schema tables (not strategy-owned). */\nexport const BASE_CONTRIBUTION_OWNER = \"base\";\n\n/**\n * A single table TypeGraph owns.\n */\nexport type TableContribution = Readonly<{\n /**\n * Stable, graph- and deployment-independent identity for the logical\n * slot this contribution fills (e.g. `\"fulltext\"`). NOT the physical\n * table name. Stable across table-name overrides and across strategy\n * swaps of the *same* logical slot, so #135's durable marker can\n * survive both.\n */\n logicalName: string;\n /**\n * Identifies the producer of this contribution (e.g. a strategy id\n * like `\"tsvector\"` / `\"fts5\"`, or `\"base\"` for core schema tables).\n * Part of the #135 materialization identity and an input to the\n * drift signature — a strategy swap on the same `logicalName` is a\n * legitimate, detectable drift, not a silent reuse.\n */\n owner: string;\n /**\n * Resolved physical table name after any per-deployment name\n * override. Part of the #135 materialization identity (custom names\n * must be distinguishable) and used by diagnostics / the focused\n * bootstrap ensure.\n */\n tableName: string;\n /**\n * Idempotent (`CREATE ... IF NOT EXISTS`) statements that\n * materialize this contribution's table **and its supporting\n * indexes**. Running the full list is how the runtime ensure\n * self-heals partial states (table present, index missing) — it is\n * not a probe-and-skip. Deterministic for a given resolved\n * configuration: the canonical normalized input to #135's drift\n * signature.\n */\n createDdl: readonly string[];\n /**\n * When `true`, the post-schema-load focused ensure\n * (`loadActiveSchemaWithBootstrap`) materializes this contribution\n * on every successful schema load.\n *\n * **Invariant: only strategy-declared contributions may set this.**\n * Core/base tables are always `false` — they are created by\n * drizzle-kit / `bootstrapTables`. This is what lets the boot path\n * derive runtime contributions straight from the strategy\n * (`fulltextStrategy.ownedTables`) without walking — and generating\n * DDL for — every base table.\n */\n runtimeEnsure: boolean;\n}>;\n\n/**\n * A table a {@link FulltextStrategy} declares it owns. An alias, not a\n * distinct shape: a strategy's declaration is already authoritative\n * (no resolution step). The name documents the producer role.\n */\nexport type StrategyTableContribution = TableContribution;\n","/**\n * Fulltext Strategy — pluggable DDL + SQL generation for a dialect's\n * fulltext stack. A strategy owns every SQL statement that touches its\n * backing table: DDL, upsert (single + batch), delete (single + batch),\n * MATCH condition, rank expression, and snippet expression.\n *\n * A dialect picks one as its default; `createPostgresBackend` /\n * `createSqliteBackend` accept an override for alternate Postgres stacks\n * (pg_trgm, ParadeDB/pg_search, pgroonga) to swap the entire fulltext\n * pipeline without forking TypeGraph.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport { quotedTableName } from \"../../backend/drizzle/operations/shared\";\nimport {\n FULLTEXT_CONTRIBUTION_NAME,\n type StrategyTableContribution,\n} from \"../../backend/table-contribution\";\nimport {\n type DeleteFulltextBatchParams,\n type DeleteFulltextParams,\n type FulltextBatchRow,\n type FulltextCapabilities,\n type FulltextQueryMode,\n type UpsertFulltextBatchParams,\n type UpsertFulltextParams,\n} from \"../../backend/types\";\n\n/**\n * Every `FulltextQueryMode` both shipped strategies accept.\n */\nexport const ALL_FULLTEXT_MODES: readonly FulltextQueryMode[] = [\n \"websearch\",\n \"phrase\",\n \"plain\",\n \"raw\",\n] as const;\n\n/**\n * Derives the `FulltextCapabilities` backends advertise from the active\n * strategy, so the two never drift.\n */\nexport function buildFulltextCapabilities(\n strategy: FulltextStrategy,\n): FulltextCapabilities {\n return {\n supported: true,\n languages: strategy.languages,\n phraseQueries: strategy.supportedModes.includes(\"phrase\"),\n prefixQueries: strategy.supportsPrefix,\n highlighting: strategy.supportsSnippets,\n };\n}\n\n/**\n * A pluggable fulltext implementation. Each strategy is expected to be\n * self-contained: given a table name, a query string, and a parse mode,\n * it emits every SQL statement the compiler and backend need — DDL,\n * reads, and writes. No out-of-band conventions across layers.\n */\nexport interface FulltextStrategy {\n /** Human-readable identifier used in error messages and telemetry. */\n readonly name: string;\n\n /**\n * Parse modes this strategy can translate. Callers validate against\n * this list before emitting SQL; a mode outside the set means the\n * strategy rejects the query at compile time.\n */\n readonly supportedModes: readonly FulltextQueryMode[];\n\n /**\n * Whether the strategy can emit a per-row highlighted snippet. When\n * false, `snippetExpression` returns a literal `NULL` so callers can\n * leave the `snippet` column in place without a branch.\n */\n readonly supportsSnippets: boolean;\n\n /**\n * Whether the strategy supports prefix queries (`foo*`). Used to\n * populate `BackendCapabilities.fulltext.prefixQueries`. A strategy\n * may support prefix queries via dedicated syntax without advertising\n * \"raw\" mode (and vice-versa).\n */\n readonly supportsPrefix: boolean;\n\n /**\n * Whether a per-query `language` override is honored. Postgres' tsvector\n * accepts any installed regconfig at query time; SQLite FTS5's tokenizer\n * is fixed at table-create time, so the override is silently ignored.\n * Callers may surface a warning when the user passes `language` to a\n * strategy that doesn't honor it.\n */\n readonly supportsLanguageOverride: boolean;\n\n /**\n * Languages / tokenizer names understood by the strategy. Advisory — a\n * runtime backend like Postgres may accept other installed regconfigs.\n * Used to populate `BackendCapabilities.fulltext.languages`.\n */\n readonly languages: readonly string[];\n\n /**\n * Emits the WHERE-side MATCH expression.\n *\n * @example\n * tsvector: `\"typegraph_node_fulltext\".\"tsv\" @@ websearch_to_tsquery('english', 'cats')`\n * fts5: `\"typegraph_node_fulltext\" MATCH '\"cats\"'`\n */\n matchCondition(\n tableName: string,\n query: string,\n mode: FulltextQueryMode,\n language?: string,\n ): SQL;\n\n /**\n * Emits the relevance expression. Higher values = more relevant. The\n * compiler orders by this expression DESC, and both builder and\n * backend-direct paths use the same form so their top-k results agree.\n */\n rankExpression(\n tableName: string,\n query: string,\n mode: FulltextQueryMode,\n language?: string,\n ): SQL;\n\n /**\n * Emits a per-row highlighted snippet expression, or `NULL` when\n * `supportsSnippets` is false. Snippet markup is `<mark>…</mark>` in\n * both shipped strategies so consumers can apply one stylesheet.\n */\n snippetExpression(\n tableName: string,\n query: string,\n mode: FulltextQueryMode,\n language?: string,\n ): SQL;\n\n /**\n * The tables this strategy owns, as Drizzle-free, already\n * authoritative `TableContribution`s (`logicalName`, `owner`,\n * resolved `tableName`, idempotent `createDdl` for the table **and\n * its supporting indexes**, `runtimeEnsure`). A strategy never\n * constructs a Drizzle table itself; drizzle-kit visibility, when\n * applicable, is the schema barrel's responsibility (the default\n * Postgres strategy's `schema/postgres.ts` exports a matching\n * `tables.fulltext` — a non-default strategy must export its own).\n *\n * Replaces the former `generateDdl(tableName)`: DDL is now one field\n * of a contribution rather than the strategy's whole storage\n * surface. (Public API change — see #129.)\n */\n ownedTables(primaryTableName: string): readonly StrategyTableContribution[];\n\n /**\n * Emits the statements that upsert a single fulltext row. Returns one\n * or more statements — some backends (SQLite FTS5) cannot emulate\n * upsert in a single statement and need DELETE + INSERT.\n */\n buildUpsert(\n tableName: string,\n params: UpsertFulltextParams,\n timestamp: string,\n ): readonly SQL[];\n\n /**\n * Emits the statements that upsert many fulltext rows at once. Input\n * rows are expected to be de-duplicated last-write-wins by the\n * strategy if the underlying SQL statement cannot tolerate duplicate\n * conflict keys. Returns `[]` when `params.rows` is empty.\n */\n buildBatchUpsert(\n tableName: string,\n params: UpsertFulltextBatchParams,\n timestamp: string,\n ): readonly SQL[];\n\n /**\n * Emits the statements that delete a single fulltext row. Normally a\n * single PK-scoped DELETE, but strategies that maintain auxiliary\n * indexes (delete-triggered external stores, ParadeDB-style secondary\n * structures) may need more.\n */\n buildDelete(tableName: string, params: DeleteFulltextParams): readonly SQL[];\n\n /**\n * Emits the statements that delete many fulltext rows at once. Returns\n * `[]` when `params.nodeIds` is empty.\n */\n buildBatchDelete(\n tableName: string,\n params: DeleteFulltextBatchParams,\n ): readonly SQL[];\n}\n\n// ============================================================\n// Internal helpers\n// ============================================================\n\nfunction quoteIdentifier(name: string): string {\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction tsvectorColumn(tableName: string): SQL {\n return sql`${quotedTableName(tableName)}.\"tsv\"`;\n}\n\n/**\n * Dedupes batch rows last-write-wins by nodeId. Returns a plain array\n * in insertion order of the last occurrence of each id. Shared by both\n * shipped strategies.\n */\nfunction dedupeFulltextBatchRows(\n rows: readonly FulltextBatchRow[],\n): FulltextBatchRow[] {\n const seen = new Map<string, FulltextBatchRow>();\n for (const row of rows) seen.set(row.nodeId, row);\n return [...seen.values()];\n}\n\nfunction buildPkScopedDelete(\n tableName: string,\n params: DeleteFulltextParams,\n): SQL {\n const table = quotedTableName(tableName);\n return sql`\n DELETE FROM ${table}\n WHERE \"graph_id\" = ${params.graphId}\n AND \"node_kind\" = ${params.nodeKind}\n AND \"node_id\" = ${params.nodeId}\n `;\n}\n\nfunction buildPkScopedBatchDelete(\n tableName: string,\n params: DeleteFulltextBatchParams,\n): SQL | undefined {\n if (params.nodeIds.length === 0) return undefined;\n const unique = [...new Set(params.nodeIds)];\n const table = quotedTableName(tableName);\n return sql`\n DELETE FROM ${table}\n WHERE \"graph_id\" = ${params.graphId}\n AND \"node_kind\" = ${params.nodeKind}\n AND \"node_id\" IN (${sql.join(\n unique.map((id) => sql`${id}`),\n sql`, `,\n )})\n `;\n}\n\n// ============================================================\n// tsvector strategy (PostgreSQL built-in)\n// ============================================================\n\nfunction postgresTsquery(\n mode: FulltextQueryMode,\n query: string,\n language: string | undefined,\n): SQL {\n // The `language` column is already `regconfig`, so the non-override\n // path references the column directly. The per-query override path\n // still arrives as a bound text parameter and needs the cast.\n const langExpr: SQL =\n language === undefined ? sql`\"language\"` : sql`${language}::regconfig`;\n switch (mode) {\n case \"websearch\": {\n return sql`websearch_to_tsquery(${langExpr}, ${query})`;\n }\n case \"phrase\": {\n return sql`phraseto_tsquery(${langExpr}, ${query})`;\n }\n case \"plain\": {\n return sql`plainto_tsquery(${langExpr}, ${query})`;\n }\n case \"raw\": {\n return sql`to_tsquery(${langExpr}, ${query})`;\n }\n default: {\n const _exhaustive: never = mode;\n throw new Error(`Unsupported fulltext mode: ${String(_exhaustive)}`);\n }\n }\n}\n\nexport const tsvectorStrategy: FulltextStrategy = {\n name: \"tsvector\",\n supportedModes: ALL_FULLTEXT_MODES,\n supportsSnippets: true,\n // `raw` mode exposes `foo:*` prefix-match syntax to callers.\n supportsPrefix: true,\n supportsLanguageOverride: true,\n // Canonical Postgres stemmers; every stock install ships these plus a\n // few others. Runtime `to_tsvector` accepts any installed regconfig\n // name — this list is advisory for capability discovery.\n languages: [\n \"simple\",\n \"english\",\n \"french\",\n \"german\",\n \"italian\",\n \"portuguese\",\n \"russian\",\n \"spanish\",\n \"swedish\",\n ] as const,\n\n matchCondition(tableName, query, mode, language) {\n const q = postgresTsquery(mode, query, language);\n return sql`${tsvectorColumn(tableName)} @@ ${q}`;\n },\n\n rankExpression(tableName, query, mode, language) {\n const q = postgresTsquery(mode, query, language);\n return sql`ts_rank_cd(${tsvectorColumn(tableName)}, ${q})`;\n },\n\n snippetExpression(_tableName, query, mode, language) {\n const langExpr: SQL =\n language === undefined ? sql`\"language\"` : sql`${language}::regconfig`;\n const q = postgresTsquery(mode, query, language);\n return sql`ts_headline(${langExpr}, \"content\", ${q}, 'StartSel=<mark>,StopSel=</mark>,MaxFragments=1,MinWords=5,MaxWords=30,ShortWord=3')`;\n },\n\n ownedTables(primaryTableName) {\n const name = quoteIdentifier(primaryTableName);\n const gin = quoteIdentifier(`${primaryTableName}_tsv_idx`);\n const kind = quoteIdentifier(`${primaryTableName}_kind_idx`);\n // `language` is `regconfig` so `to_tsvector(\"language\", \"content\")`\n // is an immutable expression — Postgres can then compute `tsv` as a\n // GENERATED STORED column and own the `content → tsv` invariant.\n // (The text→regconfig cast happens once at INSERT time against the\n // bound parameter, which is fine because it's not inside the\n // generated expression.)\n const createDdl = [\n `CREATE TABLE IF NOT EXISTS ${name} (\n \"graph_id\" TEXT NOT NULL,\n \"node_kind\" TEXT NOT NULL,\n \"node_id\" TEXT NOT NULL,\n \"content\" TEXT NOT NULL,\n \"language\" regconfig NOT NULL,\n \"tsv\" tsvector NOT NULL\n GENERATED ALWAYS AS (to_tsvector(\"language\", \"content\")) STORED,\n \"updated_at\" TIMESTAMPTZ NOT NULL,\n PRIMARY KEY (\"graph_id\", \"node_kind\", \"node_id\")\n);`,\n `CREATE INDEX IF NOT EXISTS ${gin} ON ${name} USING GIN (\"tsv\");`,\n `CREATE INDEX IF NOT EXISTS ${kind} ON ${name} (\"graph_id\", \"node_kind\");`,\n ];\n // drizzle-kit visibility for this default strategy comes from\n // `schema/postgres.ts` exporting the matching `tables.fulltext`\n // pgTable through the barrel — one object, not two. `runtimeEnsure`\n // because drizzle-kit-managed setups create every base table except\n // this strategy-owned one.\n return [\n {\n logicalName: FULLTEXT_CONTRIBUTION_NAME,\n owner: \"tsvector\",\n tableName: primaryTableName,\n createDdl,\n runtimeEnsure: true,\n },\n ];\n },\n\n buildUpsert(tableName, params, timestamp) {\n const table = quotedTableName(tableName);\n // `tsv` is a GENERATED STORED column — Postgres computes it from\n // `content` + `language`, so it must not appear in the column list\n // or the ON CONFLICT update set.\n return [\n sql`\n INSERT INTO ${table} (\"graph_id\", \"node_kind\", \"node_id\", \"content\", \"language\", \"updated_at\")\n VALUES (\n ${params.graphId}, ${params.nodeKind}, ${params.nodeId},\n ${params.content}, ${params.language}::regconfig,\n ${timestamp}\n )\n ON CONFLICT (\"graph_id\", \"node_kind\", \"node_id\")\n DO UPDATE SET\n \"content\" = EXCLUDED.\"content\",\n \"language\" = EXCLUDED.\"language\",\n \"updated_at\" = EXCLUDED.\"updated_at\"\n `,\n ];\n },\n\n buildBatchUpsert(tableName, params, timestamp) {\n const rows = dedupeFulltextBatchRows(params.rows);\n if (rows.length === 0) return [];\n\n const table = quotedTableName(tableName);\n const valueTuples = rows.map(\n (row) => sql`\n (\n ${params.graphId}, ${params.nodeKind}, ${row.nodeId},\n ${row.content}, ${row.language}::regconfig,\n ${timestamp}\n )\n `,\n );\n\n return [\n sql`\n INSERT INTO ${table} (\"graph_id\", \"node_kind\", \"node_id\", \"content\", \"language\", \"updated_at\")\n VALUES ${sql.join(valueTuples, sql`, `)}\n ON CONFLICT (\"graph_id\", \"node_kind\", \"node_id\")\n DO UPDATE SET\n \"content\" = EXCLUDED.\"content\",\n \"language\" = EXCLUDED.\"language\",\n \"updated_at\" = EXCLUDED.\"updated_at\"\n `,\n ];\n },\n\n buildDelete(tableName, params) {\n return [buildPkScopedDelete(tableName, params)];\n },\n\n buildBatchDelete(tableName, params) {\n const stmt = buildPkScopedBatchDelete(tableName, params);\n return stmt === undefined ? [] : [stmt];\n },\n};\n\n// ============================================================\n// FTS5 strategy (SQLite)\n// ============================================================\n\nfunction translateToFts5Query(query: string, mode: FulltextQueryMode): string {\n switch (mode) {\n case \"phrase\": {\n return `\"${query.replaceAll('\"', '\"\"')}\"`;\n }\n case \"plain\": {\n return query\n .trim()\n .split(/\\s+/u)\n .filter((token) => token.length > 0)\n .map((token) => `\"${token.replaceAll('\"', '\"\"')}\"`)\n .join(\" \");\n }\n case \"websearch\": {\n return translateWebsearchToFts5(query);\n }\n case \"raw\": {\n return query;\n }\n default: {\n const _exhaustive: never = mode;\n throw new Error(`Unsupported fulltext mode: ${String(_exhaustive)}`);\n }\n }\n}\n\nfunction translateWebsearchToFts5(query: string): string {\n const tokens: string[] = [];\n let index = 0;\n\n function skipWhitespace(): void {\n while (index < query.length && /\\s/u.test(query[index] ?? \"\")) {\n index += 1;\n }\n }\n\n function readPhrase(): string {\n index += 1;\n let content = \"\";\n while (index < query.length && query[index] !== '\"') {\n content += query[index] ?? \"\";\n index += 1;\n }\n if (query[index] === '\"') index += 1;\n return `\"${content.replaceAll('\"', '\"\"')}\"`;\n }\n\n function readBareTerm(): string {\n let term = \"\";\n while (index < query.length && !/\\s/u.test(query[index] ?? \"\")) {\n term += query[index] ?? \"\";\n index += 1;\n }\n return term;\n }\n\n while (index < query.length) {\n skipWhitespace();\n if (index >= query.length) break;\n const ch = query[index];\n if (ch === '\"') {\n tokens.push(readPhrase());\n continue;\n }\n if (ch === \"-\") {\n index += 1;\n const term =\n query[index] === '\"' ?\n readPhrase()\n : `\"${readBareTerm().replaceAll('\"', '\"\"')}\"`;\n tokens.push(`NOT ${term}`);\n continue;\n }\n if (ch === \"+\") {\n index += 1;\n continue;\n }\n const bare = readBareTerm();\n if (bare.length === 0) continue;\n if (bare.toUpperCase() === \"OR\") {\n tokens.push(\"OR\");\n continue;\n }\n tokens.push(`\"${bare.replaceAll('\"', '\"\"')}\"`);\n }\n\n if (tokens.length > 0 && tokens[0]?.startsWith(\"NOT \")) {\n tokens.shift();\n }\n\n return tokens.join(\" \");\n}\n\nexport const fts5Strategy: FulltextStrategy = {\n name: \"fts5\",\n supportedModes: ALL_FULLTEXT_MODES,\n supportsSnippets: true,\n // FTS5 supports `foo*` prefix matching natively.\n supportsPrefix: true,\n // FTS5 tokenizer is fixed at table-create time; per-row / per-query\n // language metadata is stored but not consulted.\n supportsLanguageOverride: false,\n // The built-in tokenizer is `porter unicode61 remove_diacritics 2`; the\n // `language` field on searchable() is recorded for future use but not\n // applied at query time.\n languages: [\"porter\", \"unicode61\", \"trigram\"] as const,\n\n matchCondition(tableName, query, mode, _language) {\n const matchExpression = translateToFts5Query(query, mode);\n return sql`${quotedTableName(tableName)} MATCH ${matchExpression}`;\n },\n\n rankExpression(tableName, _query, _mode, _language) {\n // FTS5 bm25() returns a negative score where lower = more relevant.\n // Negate so callers see higher = better (uniform with tsvector).\n return sql`-bm25(${quotedTableName(tableName)})`;\n },\n\n snippetExpression(tableName, _query, _mode, _language) {\n return sql`snippet(${quotedTableName(tableName)}, -1, '<mark>', '</mark>', '…', 20)`;\n },\n\n ownedTables(primaryTableName) {\n const name = quoteIdentifier(primaryTableName);\n // FTS5 virtual tables cannot be modeled as a Drizzle table, so this\n // contribution is raw-ddl: emitted verbatim and invisible to\n // drizzle-kit. `runtimeEnsure` because no drizzle-kit-managed setup\n // can create it.\n return [\n {\n logicalName: FULLTEXT_CONTRIBUTION_NAME,\n owner: \"fts5\",\n tableName: primaryTableName,\n createDdl: [\n `CREATE VIRTUAL TABLE IF NOT EXISTS ${name} USING fts5(\n graph_id UNINDEXED,\n node_kind UNINDEXED,\n node_id UNINDEXED,\n language UNINDEXED,\n updated_at UNINDEXED,\n content,\n tokenize='porter unicode61 remove_diacritics 2'\n);`,\n ],\n runtimeEnsure: true,\n },\n ];\n },\n\n buildUpsert(tableName, params, timestamp) {\n const table = quotedTableName(tableName);\n // FTS5 virtual tables don't support ON CONFLICT — emulate with\n // DELETE + INSERT, atomic under the caller's outer transaction.\n return [\n sql`\n DELETE FROM ${table}\n WHERE \"graph_id\" = ${params.graphId}\n AND \"node_kind\" = ${params.nodeKind}\n AND \"node_id\" = ${params.nodeId}\n `,\n sql`\n INSERT INTO ${table} (graph_id, node_kind, node_id, content, language, updated_at)\n VALUES (${params.graphId}, ${params.nodeKind}, ${params.nodeId}, ${params.content}, ${params.language}, ${timestamp})\n `,\n ];\n },\n\n buildBatchUpsert(tableName, params, timestamp) {\n const rows = dedupeFulltextBatchRows(params.rows);\n if (rows.length === 0) return [];\n\n const table = quotedTableName(tableName);\n const nodeIds = rows.map((row) => row.nodeId);\n\n const deleteStmt = sql`\n DELETE FROM ${table}\n WHERE \"graph_id\" = ${params.graphId}\n AND \"node_kind\" = ${params.nodeKind}\n AND \"node_id\" IN (${sql.join(\n nodeIds.map((id) => sql`${id}`),\n sql`, `,\n )})\n `;\n\n const valueTuples = rows.map(\n (row) => sql`\n (\n ${params.graphId}, ${params.nodeKind}, ${row.nodeId},\n ${row.content}, ${row.language}, ${timestamp}\n )\n `,\n );\n\n const insertStmt = sql`\n INSERT INTO ${table} (graph_id, node_kind, node_id, content, language, updated_at)\n VALUES ${sql.join(valueTuples, sql`, `)}\n `;\n\n return [deleteStmt, insertStmt];\n },\n\n buildDelete(tableName, params) {\n return [buildPkScopedDelete(tableName, params)];\n },\n\n buildBatchDelete(tableName, params) {\n const stmt = buildPkScopedBatchDelete(tableName, params);\n return stmt === undefined ? [] : [stmt];\n },\n};\n","/**\n * PostgreSQL Dialect Adapter\n *\n * Implements dialect-specific SQL generation for PostgreSQL databases.\n * Uses PostgreSQL's native JSONB operators for JSON operations.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport { type JsonPointer, parseJsonPointer } from \"../json-pointer\";\nimport { tsvectorStrategy } from \"./fulltext-strategy\";\nimport { type DialectAdapter } from \"./types\";\n\n/**\n * Escapes a string for use in a PostgreSQL string literal.\n * Uses single quotes and escapes embedded single quotes.\n */\nfunction escapePostgresLiteral(value: string): string {\n // PostgreSQL uses '' to escape single quotes inside string literals\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n\n/**\n * Converts a JSON pointer to PostgreSQL's text array path.\n *\n * Uses raw SQL (non-parameterized) to ensure the same expression text\n * is generated when the same field is used in multiple clauses (SELECT, GROUP BY).\n * This is safe because JSON pointers come from schema definitions, not user input.\n *\n * @example\n * \"/name\" → ARRAY['name']\n * \"/items/0\" → ARRAY['items', '0']\n * \"/a/b/c\" → ARRAY['a', 'b', 'c']\n */\nfunction toPostgresPath(pointer: JsonPointer): SQL {\n if (!pointer || pointer === \"\" || pointer === \"/\") {\n return sql.raw(\"ARRAY[]::text[]\");\n }\n\n const segments = parseJsonPointer(pointer);\n if (segments.length === 0) {\n return sql.raw(\"ARRAY[]::text[]\");\n }\n\n // Use raw SQL for path segments to ensure identical SQL text\n // when the same field is used in multiple clauses (e.g., SELECT and GROUP BY)\n const escapedSegments = segments\n .map((segment) => escapePostgresLiteral(segment))\n .join(\", \");\n return sql.raw(`ARRAY[${escapedSegments}]`);\n}\n\n/**\n * PostgreSQL dialect adapter implementation.\n */\nexport const postgresDialect: DialectAdapter = {\n name: \"postgres\",\n capabilities: {\n standardQueryStrategy: \"cte_project\",\n recursiveQueryStrategy: \"recursive_cte\",\n materializeIntermediateTraversalCtes: false,\n emitNotMaterializedHint: true,\n forceRecursiveWorktableOuterJoinOrder: false,\n vectorPredicateStrategy: \"native\",\n vectorMetrics: [\"cosine\", \"l2\", \"inner_product\"] as const,\n supportsFulltext: true,\n },\n\n // ============================================================\n // JSON Path Operations\n // ============================================================\n\n compilePath(pointer) {\n return toPostgresPath(pointer);\n },\n\n jsonExtract(column, pointer) {\n // #> returns JSONB value at path\n const path = toPostgresPath(pointer);\n return sql`${column} #> ${path}`;\n },\n\n jsonExtractText(column, pointer) {\n // #>> returns text value at path\n const path = toPostgresPath(pointer);\n return sql`${column} #>> ${path}`;\n },\n\n jsonExtractNumber(column, pointer) {\n // Extract as text then cast to numeric\n const path = toPostgresPath(pointer);\n return sql`(${column} #>> ${path})::numeric`;\n },\n\n jsonExtractBoolean(column, pointer) {\n // Extract as text then cast to boolean\n const path = toPostgresPath(pointer);\n return sql`(${column} #>> ${path})::boolean`;\n },\n\n jsonExtractDate(column, pointer) {\n // Extract as text then cast to timestamptz\n const path = toPostgresPath(pointer);\n return sql`(${column} #>> ${path})::timestamptz`;\n },\n\n // ============================================================\n // JSON Array Operations\n // ============================================================\n\n jsonArrayLength(column) {\n return sql`jsonb_array_length(${column})`;\n },\n\n jsonArrayContains(column, value) {\n // @> checks if left contains right\n const jsonValue = JSON.stringify([value]);\n return sql`${column} @> ${jsonValue}::jsonb`;\n },\n\n jsonArrayContainsAll(column, values) {\n if (values.length === 0) {\n return sql.raw(\"1=1\");\n }\n\n // @> with full array checks all values\n const jsonValue = JSON.stringify(values);\n return sql`${column} @> ${jsonValue}::jsonb`;\n },\n\n jsonArrayContainsAny(column, values) {\n if (values.length === 0) {\n return sql.raw(\"1=0\");\n }\n\n // Check each value with @> and OR them together\n // PostgreSQL doesn't have a native \"overlaps\" for jsonb arrays\n const conditions = values.map((value) => {\n const jsonValue = JSON.stringify([value]);\n return sql`${column} @> ${jsonValue}::jsonb`;\n });\n return sql`(${sql.join(conditions, sql` OR `)})`;\n },\n\n // ============================================================\n // JSON Object Operations\n // ============================================================\n\n jsonHasPath(column, pointer) {\n const path = toPostgresPath(pointer);\n return sql`${column} #> ${path} IS NOT NULL`;\n },\n\n jsonPathIsNull(column, pointer) {\n const path = toPostgresPath(pointer);\n // Check both SQL NULL and JSON null literal\n return sql`(${column} #> ${path} IS NULL OR ${column} #>> ${path} = 'null')`;\n },\n\n jsonPathIsNotNull(column, pointer) {\n const path = toPostgresPath(pointer);\n return sql`(${column} #> ${path} IS NOT NULL AND ${column} #>> ${path} != 'null')`;\n },\n\n // ============================================================\n // String Operations\n // ============================================================\n\n ilike(column, pattern) {\n // PostgreSQL has native ILIKE operator\n return sql`${column} ILIKE ${pattern}`;\n },\n\n // ============================================================\n // Set Operations\n // ============================================================\n\n wrapSetOperationOperand(inner) {\n // PostgreSQL allows a complete SELECT (incl. its own WITH) as a\n // parenthesized compound operand.\n return sql`(${inner})`;\n },\n\n // ============================================================\n // Recursive CTE Path Operations\n // ============================================================\n\n initializePath(nodeId) {\n // PostgreSQL uses text arrays: ARRAY[id]\n return sql`ARRAY[${nodeId}]`;\n },\n\n extendPath(currentPath, nodeId) {\n // Array concatenation: path || id\n return sql`${currentPath} || ${nodeId}`;\n },\n\n cycleCheck(nodeId, path) {\n // Check that id is NOT in array path\n // Returns TRUE if no cycle (id not in array)\n return sql`${nodeId} != ALL(${path})`;\n },\n\n // ============================================================\n // Type Utilities\n // ============================================================\n\n currentTimestamp() {\n return sql`NOW()`;\n },\n\n // ============================================================\n // Value Binding & Literals\n // ============================================================\n\n bindValue(value) {\n // PostgreSQL supports native booleans, no conversion needed\n return value;\n },\n\n booleanLiteral(value) {\n return sql.raw(this.booleanLiteralString(value));\n },\n\n booleanLiteralString(value) {\n return value ? \"TRUE\" : \"FALSE\";\n },\n\n quoteIdentifier(name) {\n // PostgreSQL uses double quotes, escape embedded quotes by doubling\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n },\n\n // ============================================================\n // Vector Operations\n // ============================================================\n\n // Compile-time gate for `field.similarTo(...)`; the active\n // `VectorStrategy` (pgvector) owns the distance SQL.\n supportsVectors: true,\n\n // ============================================================\n // Fulltext Operations\n // ============================================================\n\n fulltext: tsvectorStrategy,\n};\n","/**\n * SQLite Dialect Adapter\n *\n * Implements dialect-specific SQL generation for SQLite databases.\n * Uses SQLite's JSON1 extension for JSON operations.\n */\nimport { sql } from \"drizzle-orm\";\n\nimport { type JsonPointer, parseJsonPointer } from \"../json-pointer\";\nimport { fts5Strategy } from \"./fulltext-strategy\";\nimport { type DialectAdapter } from \"./types\";\n\n/**\n * Escapes a string for use in a SQLite string literal.\n * SQLite uses single quotes and escapes embedded single quotes by doubling them.\n */\nfunction escapeSqliteLiteral(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n\n/**\n * Converts a JSON pointer to SQLite's JSON path syntax.\n *\n * @example\n * \"/name\" → \"$.\\\"name\\\"\"\n * \"/items/0\" → \"$.\\\"items\\\"[0]\"\n * \"/a/b/c\" → \"$.\\\"a\\\".\\\"b\\\".\\\"c\\\"\"\n */\nfunction toSqlitePath(pointer: JsonPointer): string {\n if (!pointer || pointer === \"\" || pointer === \"/\") {\n return \"$\";\n }\n\n const segments = parseJsonPointer(pointer);\n const parts: string[] = [\"$\"];\n\n for (const segment of segments) {\n if (isArrayIndex(segment)) {\n parts.push(`[${segment}]`);\n } else {\n // Quote the key to handle special characters\n parts.push(`.${JSON.stringify(segment)}`);\n }\n }\n\n return parts.join(\"\");\n}\n\n/**\n * Checks if a JSON pointer segment is an array index.\n */\nfunction isArrayIndex(segment: string): boolean {\n return /^\\d+$/.test(segment);\n}\n\n/**\n * SQLite dialect adapter implementation.\n */\nexport const sqliteDialect: DialectAdapter = {\n name: \"sqlite\",\n capabilities: {\n standardQueryStrategy: \"cte_project\",\n recursiveQueryStrategy: \"recursive_cte\",\n materializeIntermediateTraversalCtes: true,\n emitNotMaterializedHint: false,\n forceRecursiveWorktableOuterJoinOrder: true,\n vectorPredicateStrategy: \"native\",\n vectorMetrics: [\"cosine\", \"l2\"] as const,\n supportsFulltext: true,\n },\n\n // ============================================================\n // JSON Path Operations\n // ============================================================\n\n compilePath(pointer) {\n // Use raw SQL to ensure the path is a literal, which allows expression\n // indexes on json_extract(...) to be used by the query planner.\n return sql.raw(escapeSqliteLiteral(toSqlitePath(pointer)));\n },\n\n jsonExtract(column, pointer) {\n const path = toSqlitePath(pointer);\n return sql`json_extract(${column}, ${sql.raw(escapeSqliteLiteral(path))})`;\n },\n\n jsonExtractText(column, pointer) {\n // SQLite's json_extract returns the native JSON type, which works\n // for text comparisons. For explicit text, we use the same function.\n const path = toSqlitePath(pointer);\n return sql`json_extract(${column}, ${sql.raw(escapeSqliteLiteral(path))})`;\n },\n\n jsonExtractNumber(column, pointer) {\n // SQLite json_extract returns numbers natively when the value is numeric\n const path = toSqlitePath(pointer);\n return sql`json_extract(${column}, ${sql.raw(escapeSqliteLiteral(path))})`;\n },\n\n jsonExtractBoolean(column, pointer) {\n // SQLite json_extract returns 0/1 for boolean values\n const path = toSqlitePath(pointer);\n return sql`json_extract(${column}, ${sql.raw(escapeSqliteLiteral(path))})`;\n },\n\n jsonExtractDate(column, pointer) {\n // SQLite stores dates as ISO strings, json_extract returns them as text\n const path = toSqlitePath(pointer);\n return sql`json_extract(${column}, ${sql.raw(escapeSqliteLiteral(path))})`;\n },\n\n // ============================================================\n // JSON Array Operations\n // ============================================================\n\n jsonArrayLength(column) {\n return sql`json_array_length(${column})`;\n },\n\n jsonArrayContains(column, value) {\n return sql`EXISTS (SELECT 1 FROM json_each(${column}) WHERE json_each.value = ${value})`;\n },\n\n jsonArrayContainsAll(column, values) {\n if (values.length === 0) {\n return sql.raw(\"1=1\");\n }\n\n const conditions = values.map(\n (value) =>\n sql`EXISTS (SELECT 1 FROM json_each(${column}) WHERE json_each.value = ${value})`,\n );\n return sql`(${sql.join(conditions, sql` AND `)})`;\n },\n\n jsonArrayContainsAny(column, values) {\n if (values.length === 0) {\n return sql.raw(\"1=0\");\n }\n\n const conditions = values.map(\n (value) =>\n sql`EXISTS (SELECT 1 FROM json_each(${column}) WHERE json_each.value = ${value})`,\n );\n return sql`(${sql.join(conditions, sql` OR `)})`;\n },\n\n // ============================================================\n // JSON Object Operations\n // ============================================================\n\n jsonHasPath(column, pointer) {\n const path = toSqlitePath(pointer);\n return sql`json_type(${column}, ${sql.raw(escapeSqliteLiteral(path))}) IS NOT NULL`;\n },\n\n jsonPathIsNull(column, pointer) {\n const path = toSqlitePath(pointer);\n const pathSql = sql.raw(escapeSqliteLiteral(path));\n return sql`(json_extract(${column}, ${pathSql}) IS NULL OR json_type(${column}, ${pathSql}) = 'null')`;\n },\n\n jsonPathIsNotNull(column, pointer) {\n const path = toSqlitePath(pointer);\n const pathSql = sql.raw(escapeSqliteLiteral(path));\n return sql`(json_extract(${column}, ${pathSql}) IS NOT NULL AND json_type(${column}, ${pathSql}) != 'null')`;\n },\n\n // ============================================================\n // String Operations\n // ============================================================\n\n ilike(column, pattern) {\n // SQLite LIKE is case-insensitive for ASCII by default, but we use\n // LOWER() for consistency with non-ASCII characters\n return sql`LOWER(${column}) LIKE LOWER(${pattern})`;\n },\n\n // ============================================================\n // Set Operations\n // ============================================================\n\n wrapSetOperationOperand(inner) {\n // SQLite forbids parenthesized compound operands, but a FROM-subquery may\n // carry its own WITH clause, so wrap each operand as a subquery.\n return sql`SELECT * FROM (${inner})`;\n },\n\n // ============================================================\n // Recursive CTE Path Operations\n // ============================================================\n\n initializePath(nodeId) {\n // SQLite uses string-based paths with delimiters: '|id|'\n return sql`'|' || ${nodeId} || '|'`;\n },\n\n extendPath(currentPath, nodeId) {\n // Append: path || id || '|'\n return sql`${currentPath} || ${nodeId} || '|'`;\n },\n\n cycleCheck(nodeId, path) {\n // Check that id is NOT in path using INSTR\n // Returns TRUE if no cycle (id not found in path)\n return sql`INSTR(${path}, '|' || ${nodeId} || '|') = 0`;\n },\n\n // ============================================================\n // Type Utilities\n // ============================================================\n\n currentTimestamp() {\n // Keep ISO-8601 format aligned with stored timestamps from Date.toISOString()\n // so string-based temporal comparisons remain correct in SQLite TEXT columns.\n return sql`strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`;\n },\n\n // ============================================================\n // Value Binding & Literals\n // ============================================================\n\n bindValue(value) {\n // SQLite doesn't support native booleans, convert to 0/1\n if (typeof value === \"boolean\") {\n return value ? 1 : 0;\n }\n return value;\n },\n\n booleanLiteral(value) {\n return sql.raw(this.booleanLiteralString(value));\n },\n\n booleanLiteralString(value) {\n return value ? \"1\" : \"0\";\n },\n\n quoteIdentifier(name) {\n // SQLite uses double quotes (or backticks), escape embedded quotes by doubling\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n },\n\n // ============================================================\n // Vector Operations\n // ============================================================\n\n // Compile-time gate for `field.similarTo(...)`; the active\n // `VectorStrategy` (sqlite-vec / libSQL-native) owns the distance SQL.\n supportsVectors: true,\n\n // ============================================================\n // Fulltext Operations\n // ============================================================\n\n fulltext: fts5Strategy,\n};\n","/**\n * Vector Strategy — pluggable storage + SQL generation for a backend's\n * vector stack. The sibling of {@link FulltextStrategy}: a strategy owns\n * every statement that touches its embedding storage — the per-field DDL,\n * upsert, delete, similarity search, and (optional) ANN index lifecycle —\n * plus the capability advertisement and the distance/score expressions the\n * query compiler splices into its relevance CTE.\n *\n * ## Why a strategy, and why per-(kind, field) storage\n *\n * The spike behind #157 established that \"real\" ANN on every engine we\n * support converges on a\n * **typed, fixed-dimension structure per `(nodeKind, fieldPath)`**:\n *\n * - pgvector: a `vector(N)` column + HNSW/IVFFlat;\n * - libSQL native: an `F32_BLOB(N)` column + `libsql_vector_idx` +\n * `vector_top_k` (a plain `BLOB` or dimensionless `F32_BLOB` is rejected\n * by the index — the dimension must live in the column type);\n * - sqlite-vec: a `vec0(embedding float[N])` virtual table.\n *\n * The legacy single shared `typegraph_node_embeddings` table (one generic\n * column holding mixed-dimension vectors) can only ever be brute-forced;\n * pgvector was the sole engine that hid this, because its index supplies the\n * dimension via a `::vector(N)` cast expression. So storage is the\n * strategy's to own, slot by slot, rather than a fixed global table.\n *\n * Brute force remains a legitimate, capability-advertised mode (libSQL's\n * `vector_distance_cos` over a column with no index, sqlite-vec's\n * `vec_distance_cosine`): a strategy whose `capabilities.indexTypes` is\n * `[\"none\"]` simply never emits an ANN index and `buildSearch` always scans.\n */\nimport { type SQL, sql } from \"drizzle-orm\";\n\nimport { type StrategyTableContribution } from \"../../backend/table-contribution\";\nimport {\n type DeleteEmbeddingParams,\n type UpsertEmbeddingParams,\n type VectorCapabilities,\n type VectorIndexType,\n type VectorMetric,\n type VectorSearchParams,\n} from \"../../backend/types\";\n\n/**\n * `logicalName` prefix of a strategy-owned vector slot. Each\n * `(nodeKind, fieldPath)` pair fills one logical vector slot; the full\n * logical name is `${VECTOR_CONTRIBUTION_PREFIX}:${nodeKind}.${fieldPath}`,\n * stable across table-name overrides and strategy swaps so #135's durable\n * materialization marker survives both.\n */\nexport const VECTOR_CONTRIBUTION_PREFIX = \"vector\";\n\n/**\n * The resolved identity of one embedding field's storage in a graph —\n * everything a strategy needs to DDL, address, and index it.\n *\n * Graph-scoped: each `(graphId, nodeKind, fieldPath)` gets its own physical\n * table. TypeGraph supports many graphs per physical database, and the same\n * `(kind, field)` can carry different embedding dimensions across graphs — a\n * shared per-`(kind, field)` table would collide on the fixed column type\n * (`vector(N)` / `F32_BLOB(N)`). Graph-scoping also makes libSQL's\n * table-global `vector_top_k` per-graph-exact (no cross-graph recall bleed).\n */\nexport type VectorSlot = Readonly<{\n /** Graph the embedding belongs to — scopes the physical table. */\n graphId: string;\n /** Node kind owning the embedding field (e.g. `\"Document\"`). */\n nodeKind: string;\n /** Dot-path of the embedding field within the node props (e.g. `\"embedding\"`). */\n fieldPath: string;\n /** Fixed vector dimension `N` for this field — carried into the column type. */\n dimensions: number;\n /** Distance metric the field's index is built for. */\n metric: VectorMetric;\n /**\n * Index type to materialize. `\"none\"` means brute-force only (no ANN\n * index emitted); the strategy still stores and searches the field.\n */\n indexType: VectorIndexType;\n /**\n * Optional ANN index tuning carried into the index DDL (pgvector\n * `m`/`ef_construction`/`lists`). Present on the create-index / re-embed\n * paths (resolved from the field's `embedding()` declaration); omitted on\n * the write/search ensure paths, where the strategy falls back to defaults.\n */\n indexParams?: Readonly<{\n m?: number;\n efConstruction?: number;\n lists?: number;\n }>;\n}>;\n\n/**\n * Derives the `VectorCapabilities` a backend advertises from its active\n * strategy, so the two never drift (mirrors `buildFulltextCapabilities`).\n * The strategy is the single source of truth; there are no per-call-site\n * `SQLITE_VECTOR_*` constants.\n */\nexport function buildVectorCapabilities(\n strategy: VectorStrategy,\n): VectorCapabilities {\n return strategy.capabilities;\n}\n\n/**\n * A pluggable vector implementation. Each strategy is self-contained:\n * given a {@link VectorSlot}, it emits every statement the backend and\n * compiler need — per-field storage DDL, writes, similarity search, ANN\n * index lifecycle — and advertises exactly the metrics and index types it\n * can honor. Adding the Nth backend is one of these objects; no core edits.\n */\nexport interface VectorStrategy {\n /** Human-readable identifier used in error messages and telemetry. */\n readonly name: string;\n\n /**\n * The metrics, index types, and dimension ceiling this strategy honors —\n * advertised verbatim as `backend.capabilities.vector`. Asymmetry across\n * engines is legitimate and explicit here (pgvector has `inner_product`;\n * libSQL/sqlite-vec do not), never a silent runtime failure.\n */\n readonly capabilities: VectorCapabilities;\n\n /**\n * Deterministic physical table (or virtual-table) name backing a field in\n * a graph. The compiler references this to scan the right per-field storage,\n * and the backend uses it to route upserts/deletes. Must be a stable,\n * collision-safe SQL identifier derived from `(graphId, nodeKind, fieldPath)`.\n */\n tableName(graphId: string, nodeKind: string, fieldPath: string): string;\n\n /**\n * The per-field storage this strategy owns for `slot`, as Drizzle-free\n * `StrategyTableContribution`s (resolved `tableName`, deterministic\n * idempotent `createDdl` for the table **and** its ANN index when the\n * slot's `indexType` warrants one, `runtimeEnsure`). Rides the #129/#135\n * table-contribution + durable-materialization machinery exactly as the\n * FTS5 / tsvector virtual tables do — these are materialized per graph by\n * `materializeIndexes()`, not by global `bootstrapTables`.\n */\n ownedTables(slot: VectorSlot): readonly StrategyTableContribution[];\n\n /**\n * Emits the statement(s) that upsert a single embedding into the slot's\n * storage. Multiple statements are allowed for engines that cannot upsert\n * a vector in one statement (e.g. a `vec0` virtual table → DELETE+INSERT).\n */\n buildUpsert(\n slot: VectorSlot,\n params: UpsertEmbeddingParams,\n timestamp: string,\n ): readonly SQL[];\n\n /** Emits the statement(s) that delete a single embedding from the slot. */\n buildDelete(slot: VectorSlot, params: DeleteEmbeddingParams): readonly SQL[];\n\n /**\n * Raw DDL statement(s) that drop the slot's entire physical storage\n * (table + ANN index, and any engine-managed shadow tables). Used by the\n * destructive `store.reembedVectorField()` path to recreate a field's\n * storage at a new dimension. Returned as raw strings (like\n * `ownedTables(...).createDdl`) for `backend.executeDdl`; must be idempotent\n * (`IF EXISTS`).\n */\n buildDropStorage(slot: VectorSlot): readonly string[];\n\n /**\n * Emits the similarity-search query for the `backend.vectorSearch` path,\n * returning rows shaped `{ node_id, score }` ordered best-first. The\n * strategy picks brute-force vs ANN based on whether `slot.indexType`\n * materialized an index — the caller never branches. `score` follows the\n * shared convention (cosine → similarity `1 - distance`; l2 /\n * inner_product → raw distance), so `coerceVectorScore` / fusion stay\n * dialect-neutral.\n */\n buildSearch(slot: VectorSlot, params: VectorSearchParams): SQL;\n\n /**\n * The distance expression over the slot's embedding column, used by the\n * **query compiler** to splice vector relevance into its CTE. This is the\n * one genuinely engine-specific fragment (`vec_distance_cosine` vs\n * `<=>` vs `vector_distance_cos`); the surrounding score / minScore /\n * ORDER BY math is shared (see {@link vectorScoreExpression} etc.).\n *\n * `embeddingColumn` is the already-qualified column SQL; `queryEmbedding`\n * is formatted by the strategy into its engine's literal form.\n */\n distanceExpression(\n embeddingColumn: SQL,\n queryEmbedding: readonly number[],\n metric: VectorMetric,\n ): SQL;\n\n /**\n * Emits the ANN index creation statement for a slot, or `undefined` when\n * indexing is inline (vec0) or unsupported (brute-force-only strategies).\n * Invoked through `backend.createVectorIndex` during `materializeIndexes`.\n */\n buildCreateIndex?(\n slot: VectorSlot,\n options?: Readonly<{ concurrent?: boolean }>,\n ): SQL | undefined;\n\n /** Emits the ANN index drop statement, or `undefined` when not applicable. */\n buildDropIndex?(slot: VectorSlot): SQL | undefined;\n}\n\n// ============================================================\n// Shared, dialect-neutral expression math\n// ============================================================\n//\n// These transforms are identical across pgvector / sqlite-vec / libSQL —\n// only `distanceExpression` differs — so they live once here and are reused\n// by both `buildSearch` implementations and the compiler CTE builder.\n\n/**\n * Converts a distance expression into a score expression (higher = better).\n * Cosine distance is mapped to similarity (`1 - d`); l2 and inner_product\n * are returned as-is (lower distance already ranks better, ordered ASC).\n */\nexport function vectorScoreExpression(\n distanceExpression: SQL,\n metric: VectorMetric,\n): SQL {\n switch (metric) {\n case \"cosine\": {\n return sql`(1 - (${distanceExpression}))`;\n }\n case \"l2\":\n case \"inner_product\": {\n return distanceExpression;\n }\n default: {\n const _exhaustive: never = metric;\n throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);\n }\n }\n}\n\n/**\n * Builds the `minScore` WHERE condition against a distance expression,\n * translating the score threshold back into the metric's distance space.\n */\nexport function vectorMinScoreCondition(\n distanceExpression: SQL,\n metric: VectorMetric,\n minScore: number,\n): SQL {\n // Validate against the RESOLVED metric — both the compiler's relevance CTE\n // and the backend search path funnel here, so an out-of-range floor (e.g. a\n // cosine minScore of 5 → `distance <= 1 - 5`, which matches nothing) is\n // rejected loudly instead of silently returning zero rows.\n assertVectorMinScore(minScore, metric);\n switch (metric) {\n case \"cosine\": {\n return sql`${distanceExpression} <= ${1 - minScore}`;\n }\n case \"l2\": {\n return sql`${distanceExpression} <= ${minScore}`;\n }\n case \"inner_product\": {\n return sql`${distanceExpression} <= ${-minScore}`;\n }\n default: {\n const _exhaustive: never = metric;\n throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);\n }\n }\n}\n\n/**\n * Validates that every value in an embedding is a finite number. Shared by\n * strategies so a NaN/Infinity is reported with the offending index before\n * it reaches engine-specific literal formatting (which would mask it).\n */\nexport function assertFiniteEmbedding(\n embedding: readonly number[],\n name: string,\n): void {\n for (const [index, value] of embedding.entries()) {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new TypeError(\n `${name}[${index}] must be a finite number, got: ${value}`,\n );\n }\n }\n}\n\n/**\n * Validates a vector-search `limit` is a positive integer. Enforced by the\n * backend's `vectorSearch` (defense in depth — the store boundary also\n * checks) so a direct backend call with `limit: 0` fails loudly instead of\n * silently scanning nothing.\n */\nexport function assertVectorSearchLimit(limit: number): void {\n if (!Number.isInteger(limit) || limit <= 0) {\n throw new RangeError(\n `vectorSearch limit must be a positive integer, got: ${limit}`,\n );\n }\n}\n\n/**\n * Validates a `minScore` floor against its (resolved) metric: it must be finite,\n * and for cosine it must lie in [-1, 1] (a cosine score is the `1 - distance`\n * similarity). Shared by the store facade, the compiler's relevance CTE\n * ({@link vectorMinScoreCondition}), and the backend search path so every entry\n * point rejects the same out-of-range floor instead of silently returning none.\n */\nexport function assertVectorMinScore(\n minScore: number,\n metric: VectorMetric,\n label = \"minScore\",\n): void {\n if (!Number.isFinite(minScore)) {\n throw new RangeError(`${label} must be a finite number, got: ${minScore}`);\n }\n if (metric === \"cosine\" && (minScore < -1 || minScore > 1)) {\n throw new RangeError(\n `${label} for the cosine metric must be between -1 and 1, got: ${minScore}`,\n );\n }\n}\n\n// ============================================================\n// Shared physical naming\n// ============================================================\n\n/**\n * pgvector inherits Postgres' 63-byte identifier ceiling; SQLite/libSQL are\n * far more generous, so the smallest common cap keeps one naming scheme\n * across every strategy.\n */\nconst MAX_VECTOR_IDENTIFIER_LENGTH = 63;\n\nfunction sanitizeIdentifierPart(value: string): string {\n return value.toLowerCase().replaceAll(/[^a-z0-9_]/g, \"_\");\n}\n\n/**\n * Deterministic 8-char hash for collision-safe truncation of over-long\n * identifiers. Self-contained so the strategy layer has no backend-runtime\n * dependency.\n */\nfunction shortHash(input: string): string {\n let h1 = 0xde_ad_be_ef;\n let h2 = 0x41_c6_ce_57;\n for (let index = 0; index < input.length; index++) {\n const ch = input.codePointAt(index)!;\n h1 = Math.imul(h1 ^ ch, 0x9e_37_79_b1);\n h2 = Math.imul(h2 ^ ch, 0x5f_35_64_95);\n }\n h1 =\n Math.imul(h1 ^ (h1 >>> 16), 0x85_eb_ca_6b) ^\n Math.imul(h2 ^ (h2 >>> 13), 0xc2_b2_ae_35);\n h2 =\n Math.imul(h2 ^ (h2 >>> 16), 0x85_eb_ca_6b) ^\n Math.imul(h1 ^ (h1 >>> 13), 0xc2_b2_ae_35);\n const hi = (h2 >>> 0).toString(16).padStart(8, \"0\");\n const lo = (h1 >>> 0).toString(16).padStart(8, \"0\");\n return `${hi}${lo}`.slice(0, 8);\n}\n\n/**\n * Deterministic per-`(graphId, nodeKind, fieldPath)` physical name. Shared by\n * every strategy's `tableName`, by index naming, and by the compiler's\n * per-field table resolution so all three agree on which physical object backs\n * a field in a graph. Truncated with a hash suffix past the 63-char ceiling;\n * the hash covers all three parts, so truncation stays collision-safe even\n * when long graph ids dominate the prefix.\n *\n * @example `vectorPhysicalName(\"tg_vec\", \"g1\", \"Document\", \"embedding\")`\n * → `\"tg_vec_g1_document_embedding_<hash8>\"`\n */\nexport function vectorPhysicalName(\n prefix: string,\n graphId: string,\n nodeKind: string,\n fieldPath: string,\n): string {\n const readable = `${prefix}_${sanitizeIdentifierPart(graphId)}_${sanitizeIdentifierPart(nodeKind)}_${sanitizeIdentifierPart(fieldPath)}`;\n // Always suffix a hash of the EXACT (graphId, nodeKind, fieldPath) tuple.\n // Sanitization is lossy (case-folding, every non-`[a-z0-9_]` char → `_`) and\n // the `_` join is ambiguous, so distinct fields can share a readable part —\n // e.g. (\"a_b\",\"c\") vs (\"a\",\"b_c\"), or \"Doc-A\" vs \"Doc_A\" vs \"doc\". The hash\n // keeps their physical tables distinct so writes/searches never cross fields.\n const hash = shortHash(JSON.stringify([graphId, nodeKind, fieldPath]));\n const full = `${readable}_${hash}`;\n if (full.length <= MAX_VECTOR_IDENTIFIER_LENGTH) return full;\n // Over the ceiling: truncate the readable part, always keep the hash.\n return `${readable.slice(0, MAX_VECTOR_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Double-quote a SQL identifier, escaping embedded quotes. Dialect-neutral\n * (both SQLite and Postgres use `\"...\"`), so the three vector strategies share\n * one implementation for quoting their per-field table / index names.\n */\nexport function quoteIdentifier(name: string): string {\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n","/**\n * SQL Dialect Module\n *\n * Provides dialect adapters for different SQL databases.\n * Use `getDialect()` to get the appropriate adapter for a dialect name.\n */\n\nexport type { FulltextStrategy } from \"./fulltext-strategy\";\nexport {\n ALL_FULLTEXT_MODES,\n buildFulltextCapabilities,\n fts5Strategy,\n tsvectorStrategy,\n} from \"./fulltext-strategy\";\nexport { postgresDialect } from \"./postgres\";\nexport { sqliteDialect } from \"./sqlite\";\nexport type {\n DialectAdapter,\n DialectCapabilities,\n DialectRecursiveQueryStrategy,\n DialectStandardQueryStrategy,\n DialectVectorPredicateStrategy,\n SqlDialect,\n} from \"./types\";\nexport {\n buildVectorCapabilities,\n type VectorSlot,\n type VectorStrategy,\n} from \"./vector-strategy\";\n\nimport { postgresDialect } from \"./postgres\";\nimport { sqliteDialect } from \"./sqlite\";\nimport { type DialectAdapter, type SqlDialect } from \"./types\";\n\n/**\n * Map of dialect names to their adapters.\n */\nconst DIALECT_ADAPTERS: Record<SqlDialect, DialectAdapter> = {\n sqlite: sqliteDialect,\n postgres: postgresDialect,\n};\n\n/**\n * Gets the dialect adapter for a given dialect name.\n *\n * @param dialect - The dialect name (\"sqlite\" or \"postgres\")\n * @returns The dialect adapter\n *\n * @example\n * ```typescript\n * const adapter = getDialect(\"postgres\");\n * const sql = adapter.jsonExtract(column, \"/name\");\n * ```\n */\nexport function getDialect(dialect: SqlDialect): DialectAdapter {\n return DIALECT_ADAPTERS[dialect];\n}\n\n/**\n * Default dialect used when none is specified.\n */\nexport const DEFAULT_DIALECT: SqlDialect = \"sqlite\";\n","import { type SQL, sql } from \"drizzle-orm\";\n\nimport { type ValueType } from \"../query/ast\";\nimport { getDialect, type SqlDialect } from \"../query/dialect\";\nimport { type JsonPointer, jsonPointer } from \"../query/json-pointer\";\nimport {\n type EdgeIndexDeclaration,\n type IndexWhereExpression,\n type IndexWhereLiteral,\n type IndexWhereOp,\n type IndexWhereOperand,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// Public Types\n// ============================================================\n\nexport type IndexCompilationContext = Readonly<{\n dialect: SqlDialect;\n propsColumn: SQL;\n systemColumn: (column: SystemColumnName) => SQL;\n}>;\n\ntype CompiledIndexKeys = Readonly<{\n /** SQL expressions in index key order */\n keys: readonly SQL[];\n}>;\n\n// ============================================================\n// Index Key Compilation\n// ============================================================\n\nexport function compileNodeIndexKeys(\n index: NodeIndexDeclaration,\n dialect: SqlDialect,\n propsColumn: SQL,\n systemColumn: (column: SystemColumnName) => SQL,\n): CompiledIndexKeys {\n const adapter = getDialect(dialect);\n const keys: SQL[] = [];\n\n for (const column of getNodeScopeColumns(index.scope)) {\n keys.push(systemColumn(column));\n }\n\n const allPointers = [...index.fields, ...index.coveringFields];\n const allValueTypes = [\n ...index.fieldValueTypes,\n ...index.coveringFieldValueTypes,\n ];\n\n for (const [pointerIndex, pointer] of allPointers.entries()) {\n const valueType = allValueTypes[pointerIndex];\n const extracted = compileIndexKeyValue(\n adapter,\n propsColumn,\n pointer,\n valueType,\n );\n keys.push(sql`(${extracted})`);\n }\n\n return { keys };\n}\n\nexport function compileEdgeIndexKeys(\n index: EdgeIndexDeclaration,\n dialect: SqlDialect,\n propsColumn: SQL,\n systemColumn: (column: SystemColumnName) => SQL,\n): CompiledIndexKeys {\n const adapter = getDialect(dialect);\n const keys: SQL[] = [];\n\n for (const column of getEdgeScopeColumns(index.scope, index.direction)) {\n keys.push(systemColumn(column));\n }\n\n const allPointers = [...index.fields, ...index.coveringFields];\n const allValueTypes = [\n ...index.fieldValueTypes,\n ...index.coveringFieldValueTypes,\n ];\n\n for (const [pointerIndex, pointer] of allPointers.entries()) {\n const valueType = allValueTypes[pointerIndex];\n const extracted = compileIndexKeyValue(\n adapter,\n propsColumn,\n pointer,\n valueType,\n );\n keys.push(sql`(${extracted})`);\n }\n\n return { keys };\n}\n\nfunction compileIndexKeyValue(\n dialect: ReturnType<typeof getDialect>,\n propsColumn: SQL,\n pointer: JsonPointer,\n valueType: ValueType | undefined,\n): SQL {\n switch (valueType) {\n case \"number\": {\n return dialect.jsonExtractNumber(propsColumn, pointer);\n }\n case \"boolean\": {\n return dialect.jsonExtractBoolean(propsColumn, pointer);\n }\n case \"date\": {\n return dialect.jsonExtractDate(propsColumn, pointer);\n }\n case \"string\":\n case \"unknown\":\n case undefined: {\n return dialect.jsonExtractText(propsColumn, pointer);\n }\n case \"array\":\n case \"object\":\n case \"embedding\": {\n // For advanced index types (GIN/json), callers should use dialect.jsonExtract\n // or index the props column directly. We keep this as a conservative fallback.\n return dialect.jsonExtract(propsColumn, pointer);\n }\n }\n}\n\nfunction getNodeScopeColumns(\n scope: NodeIndexDeclaration[\"scope\"],\n): readonly SystemColumnName[] {\n switch (scope) {\n case \"graphAndKind\": {\n return [\"graph_id\", \"kind\"];\n }\n case \"graph\": {\n return [\"graph_id\"];\n }\n case \"none\": {\n return [];\n }\n }\n}\n\nfunction getEdgeScopeColumns(\n scope: EdgeIndexDeclaration[\"scope\"],\n direction: EdgeIndexDeclaration[\"direction\"],\n): readonly SystemColumnName[] {\n const base =\n scope === \"graphAndKind\" ? ([\"graph_id\", \"kind\"] as const)\n : scope === \"graph\" ? ([\"graph_id\"] as const)\n : ([] as const);\n\n if (direction === \"out\") {\n return [...base, \"from_id\"];\n }\n if (direction === \"in\") {\n return [...base, \"to_id\"];\n }\n return [...base];\n}\n\n// ============================================================\n// WHERE Clause Compilation\n// ============================================================\n\nfunction isIndexWhereLiteralList(\n value: IndexWhereLiteral | readonly IndexWhereLiteral[],\n): value is readonly IndexWhereLiteral[] {\n return Array.isArray(value);\n}\n\nexport function compileIndexWhere(\n ctx: IndexCompilationContext,\n expression: IndexWhereExpression,\n): SQL {\n switch (expression.__type) {\n case \"index_where_and\": {\n return sql`(${sql.join(\n expression.predicates.map((p) => compileIndexWhere(ctx, p)),\n sql` AND `,\n )})`;\n }\n case \"index_where_or\": {\n return sql`(${sql.join(\n expression.predicates.map((p) => compileIndexWhere(ctx, p)),\n sql` OR `,\n )})`;\n }\n case \"index_where_not\": {\n return sql`(NOT ${compileIndexWhere(ctx, expression.predicate)})`;\n }\n case \"index_where_null_check\": {\n const operand = compileIndexWhereOperand(ctx, expression.operand);\n return expression.op === \"isNull\" ?\n sql`${operand} IS NULL`\n : sql`${operand} IS NOT NULL`;\n }\n case \"index_where_comparison\": {\n const left = compileIndexWhereOperand(ctx, expression.left);\n\n const right = expression.right;\n if (isIndexWhereLiteralList(right)) {\n if (expression.op !== \"in\" && expression.op !== \"notIn\") {\n throw new Error(\n `Operator \"${expression.op}\" does not support list comparison in index WHERE clause`,\n );\n }\n const values = right.map((literal) =>\n compileIndexWhereLiteral(ctx.dialect, literal),\n );\n const operator = expression.op === \"in\" ? sql`IN` : sql`NOT IN`;\n return sql`${left} ${operator} (${sql.join(values, sql`, `)})`;\n }\n\n if (expression.op === \"in\" || expression.op === \"notIn\") {\n throw new Error(\n `Operator \"${expression.op}\" requires a list of values in index WHERE clause`,\n );\n }\n\n const rightLiteral = compileIndexWhereLiteral(ctx.dialect, right);\n const opSql = compileComparisonOperator(expression.op);\n return sql`${left} ${opSql} ${rightLiteral}`;\n }\n }\n}\n\nfunction compileIndexWhereOperand(\n ctx: IndexCompilationContext,\n operand: IndexWhereOperand,\n): SQL {\n if (operand.__type === \"index_operand_system\") {\n return ctx.systemColumn(operand.column);\n }\n\n const adapter = getDialect(ctx.dialect);\n const pointer = jsonPointer([operand.field]);\n\n switch (operand.valueType) {\n case \"number\": {\n return adapter.jsonExtractNumber(ctx.propsColumn, pointer);\n }\n case \"boolean\": {\n return adapter.jsonExtractBoolean(ctx.propsColumn, pointer);\n }\n case \"date\": {\n return adapter.jsonExtractDate(ctx.propsColumn, pointer);\n }\n case \"array\":\n case \"object\":\n case \"embedding\": {\n return adapter.jsonExtract(ctx.propsColumn, pointer);\n }\n case \"string\":\n case \"unknown\":\n case undefined: {\n return adapter.jsonExtractText(ctx.propsColumn, pointer);\n }\n }\n}\n\nfunction compileIndexWhereLiteral(\n dialect: SqlDialect,\n literal: IndexWhereLiteral,\n): SQL {\n switch (literal.valueType) {\n case \"string\":\n case \"date\": {\n return sql.raw(escapeStringLiteral(literal.value.toString()));\n }\n case \"number\": {\n return sql.raw(literal.value.toString());\n }\n case \"boolean\": {\n return getDialect(dialect).booleanLiteral(literal.value as boolean);\n }\n case \"array\":\n case \"object\":\n case \"embedding\":\n case \"unknown\": {\n return sql.raw(escapeStringLiteral(literal.value.toString()));\n }\n }\n}\n\ntype ComparisonIndexWhereOp = Exclude<IndexWhereOp, \"in\" | \"notIn\">;\n\nfunction compileComparisonOperator(op: ComparisonIndexWhereOp): SQL {\n switch (op) {\n case \"eq\": {\n return sql`=`;\n }\n case \"neq\": {\n return sql`<>`;\n }\n case \"gt\": {\n return sql`>`;\n }\n case \"gte\": {\n return sql`>=`;\n }\n case \"lt\": {\n return sql`<`;\n }\n case \"lte\": {\n return sql`<=`;\n }\n }\n}\n\nfunction escapeStringLiteral(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n","import { type SQL, sql } from \"drizzle-orm\";\nimport { CasingCache } from \"drizzle-orm/casing\";\n\nimport { getDialect, type SqlDialect } from \"../query/dialect\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n type EdgeIndexDeclaration,\n type NodeIndexDeclaration,\n type RelationalIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\nexport type GenerateIndexDdlOptions = Readonly<{\n nodesTableName?: string | undefined;\n edgesTableName?: string | undefined;\n ifNotExists?: boolean | undefined;\n /**\n * Emit `CREATE INDEX CONCURRENTLY` (Postgres only). Required for\n * `store.materializeIndexes()` so live tables don't take an\n * `AccessExclusiveLock`. Ignored on SQLite (no equivalent; SQLite is\n * single-writer regardless). When true on Postgres, the resulting\n * statement cannot be executed inside a transaction.\n */\n concurrent?: boolean | undefined;\n}>;\n\n/**\n * Generate `CREATE INDEX` DDL for a single relational index declaration.\n *\n * Vector index declarations (`entity: \"vector\"`) are NOT handled here —\n * they go through `backend.createVectorIndex` instead because the DDL\n * is dialect-specific (`USING hnsw (...) WITH (m=..., ef_construction=...)`\n * on Postgres) and operates on the strategy's per-`(kind, field)` embedding\n * tables, not `typegraph_nodes` / `typegraph_edges`. Callers narrow to the\n * relational subset before calling this function.\n */\nexport function generateIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n if (index.entity === \"node\") {\n return generateNodeIndexDDL(index, dialect, options);\n }\n return generateEdgeIndexDDL(index, dialect, options);\n}\n\nexport function generateNodeIndexDDL(\n index: NodeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.nodesTableName ?? \"typegraph_nodes\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nexport function generateEdgeIndexDDL(\n index: EdgeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.edgesTableName ?? \"typegraph_edges\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nfunction generateTableIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n tableName: string,\n options: GenerateIndexDdlOptions,\n): string {\n const ifNotExists = options.ifNotExists ?? true;\n const propsColumn = sql.raw('\"props\"');\n const systemColumn = (column: SystemColumnName): SQL =>\n sql.raw(quoteIdentifier(column));\n\n const keys =\n index.entity === \"node\" ?\n compileNodeIndexKeys(index, dialect, propsColumn, systemColumn).keys\n : compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn).keys;\n\n const whereSql =\n index.where ?\n sqlToInlineString(\n compileIndexWhere(\n {\n dialect,\n propsColumn,\n systemColumn,\n } satisfies IndexCompilationContext,\n index.where,\n ),\n dialect,\n )\n : undefined;\n\n const keySql = keys.map((k) => sqlToInlineString(k, dialect)).join(\", \");\n const unique = index.unique ? \"UNIQUE \" : \"\";\n const concurrent =\n options.concurrent === true && dialect === \"postgres\" ?\n \"CONCURRENTLY \"\n : \"\";\n const ifNotExistsSql = ifNotExists ? \"IF NOT EXISTS \" : \"\";\n\n const whereClause = whereSql ? ` WHERE ${whereSql}` : \"\";\n\n return `CREATE ${unique}INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${keySql})${whereClause};`;\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction sqlToInlineString(object: SQL, dialect: SqlDialect): string {\n const query = object.toQuery({\n casing: new CasingCache(),\n escapeName: (name) => name,\n escapeParam: (_number, value) => inlineParam(value, dialect),\n escapeString: (value) => escapeStringLiteral(value),\n inlineParams: true,\n invokeSource: \"indexes\",\n });\n\n if (query.params.length > 0) {\n throw new Error(\n \"Index DDL generation produced parameters; expected fully inlined SQL\",\n );\n }\n\n return query.sql;\n}\n\nfunction inlineParam(value: unknown, dialect: SqlDialect): string {\n if (value === null || value === undefined) {\n return \"NULL\";\n }\n if (value instanceof Date) {\n return escapeStringLiteral(value.toISOString());\n }\n\n if (typeof value === \"string\") {\n return escapeStringLiteral(value);\n }\n if (typeof value === \"number\") {\n return value.toString();\n }\n if (typeof value === \"boolean\") {\n return getDialect(dialect).booleanLiteralString(value);\n }\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n\n throw new TypeError(\n \"Index DDL generation received an unsupported SQL parameter value\",\n );\n}\n\nfunction escapeStringLiteral(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n","import { type SQL, sql, type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration => index.entity === \"node\",\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = sql`${table.props}`;\n const systemColumn = (column: SystemColumnName): SQL =>\n sql`${getPostgresNodeSystemColumn(table, column)}`;\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const builder = base.on(...keys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(compileIndexWhere(ctx, index.where));\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration => index.entity === \"edge\",\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = sql`${table.props}`;\n const systemColumn = (column: SystemColumnName): SQL =>\n sql`${getPostgresEdgeSystemColumn(table, column)}`;\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const builder = base.on(...keys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(compileIndexWhere(ctx, index.where));\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): SQLWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): SQLWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration => index.entity === \"node\",\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = sql`${table.props}`;\n const systemColumn = (column: SystemColumnName): SQL =>\n sql`${getSqliteNodeSystemColumn(table, column)}`;\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const builder = base.on(...keys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(compileIndexWhere(ctx, index.where));\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration => index.entity === \"edge\",\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = sql`${table.props}`;\n const systemColumn = (column: SystemColumnName): SQL =>\n sql`${getSqliteEdgeSystemColumn(table, column)}`;\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const builder = base.on(...keys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(compileIndexWhere(ctx, index.where));\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): SQLWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): SQLWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NodeIndexTable = Readonly<{\n graphId: SQLWrapper;\n kind: SQLWrapper;\n id: SQLWrapper;\n props: SQLWrapper;\n version: SQLWrapper;\n validFrom: SQLWrapper;\n validTo: SQLWrapper;\n createdAt: SQLWrapper;\n updatedAt: SQLWrapper;\n deletedAt: SQLWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: SQLWrapper;\n id: SQLWrapper;\n kind: SQLWrapper;\n fromKind: SQLWrapper;\n fromId: SQLWrapper;\n toKind: SQLWrapper;\n toId: SQLWrapper;\n props: SQLWrapper;\n validFrom: SQLWrapper;\n validTo: SQLWrapper;\n createdAt: SQLWrapper;\n updatedAt: SQLWrapper;\n deletedAt: SQLWrapper;\n}>;\n\nfunction assertNonEmpty(\n values: readonly SQL[],\n label: string,\n): asserts values is readonly [SQL, ...SQL[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n","import { type DeclaredIndex } from \"../profiler/types\";\nimport {\n type IndexDeclaration,\n type RelationalIndexDeclaration,\n} from \"./types\";\n\nexport function toDeclaredIndex(\n index: RelationalIndexDeclaration,\n): DeclaredIndex {\n return {\n entityType: index.entity,\n kind: index.kind,\n fields: [...index.fields],\n unique: index.unique,\n name: index.name,\n };\n}\n\n/**\n * Vector indexes are excluded from the profiler-format conversion —\n * the profiler operates on relational tables (`typegraph_nodes` /\n * `typegraph_edges`) where index hits / misses can be measured against\n * SQL plans. Vector indexes live on the strategy's per-`(kind, field)`\n * embedding tables with a different access pattern.\n */\nexport function toDeclaredIndexes(\n indexes: readonly IndexDeclaration[],\n): readonly DeclaredIndex[] {\n return indexes\n .filter(\n (index): index is RelationalIndexDeclaration =>\n index.entity === \"node\" || index.entity === \"edge\",\n )\n .map((index) => toDeclaredIndex(index));\n}\n","import { type IndexWhereExpression } from \"./types\";\n\nexport function andWhere(\n ...predicates: [IndexWhereExpression, ...IndexWhereExpression[]]\n): IndexWhereExpression {\n if (predicates.length === 1) {\n return predicates[0];\n }\n\n return {\n __type: \"index_where_and\",\n predicates,\n };\n}\n\nexport function orWhere(\n ...predicates: [IndexWhereExpression, ...IndexWhereExpression[]]\n): IndexWhereExpression {\n if (predicates.length === 1) {\n return predicates[0];\n }\n\n return {\n __type: \"index_where_or\",\n predicates,\n };\n}\n\nexport function notWhere(\n predicate: IndexWhereExpression,\n): IndexWhereExpression {\n return {\n __type: \"index_where_not\",\n predicate,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/drizzle/schema/sqlite.ts","../src/backend/types.ts"],"names":["nodes","sqliteTable","text","integer","primaryKey","index","buildSqliteNodeIndexBuilders","edges","buildSqliteEdgeIndexBuilders","uniques","schemaVersions","uniqueIndex","sql"],"mappings":";;;;;;AAyDO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A,IAAI,QAAA,GAAW,KAAA;AACf,EAAA,OAAO;AAAA,IACL,GAAG,OAAA;AAAA,IACH,MAAM,KAAA,GAAuB;AAC3B,MAAA,IAAI,QAAA,EAAU;AACd,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,MAAM,QAAQ,KAAA,EAAM;AACpB,MAAA,MAAM,QAAA,EAAS;AAAA,IACjB;AAAA,GACF;AACF;AAeA,eAAsB,0BAAA,CACpB,OAAA,EACA,EAAA,EACA,QAAA,EACY;AACZ,EAAA,IAAI,CAAC,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc;AACtC,IAAA,OAAO,EAAA,CAAG,YAAY,OAAO,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,QAAQ,WAAA,CAAY,CAAC,EAAA,KAAO,EAAA,CAAG,EAAE,CAAC,CAAA;AAC3C;AA4OO,IAAM,mBAAA,GAA2C;AAAA,EACtD,YAAA,EAAc;AAAA;AAChB;AAKO,IAAM,qBAAA,GAA6C;AAAA,EACxD,YAAA,EAAc;AAAA;AAChB","file":"chunk-F2Q76CQ4.cjs","sourcesContent":["/**\n * Drizzle SQLite schema for TypeGraph.\n *\n * Provides table definitions that can be customized via the factory function.\n * Users import these tables into their Drizzle schema and use drizzle-kit\n * for migrations.\n *\n * @example\n * ```typescript\n * // Default table names\n * import { tables } from \"@nicia-ai/typegraph/sqlite\";\n *\n * // Custom table names\n * import { createSqliteTables } from \"@nicia-ai/typegraph/sqlite\";\n * const tables = createSqliteTables({\n * nodes: \"myapp_nodes\",\n * edges: \"myapp_edges\",\n * });\n * ```\n */\nimport { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n primaryKey,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport {\n buildSqliteEdgeIndexBuilders,\n buildSqliteNodeIndexBuilders,\n type IndexDeclaration,\n} from \"../../../indexes\";\n\n/**\n * Table name configuration.\n */\nexport type SqliteTableNames = Readonly<{\n nodes: string;\n edges: string;\n uniques: string;\n schemaVersions: string;\n fulltext: string;\n indexMaterializations: string;\n contributionMaterializations: string;\n kindRemovals: string;\n reconciliationMarkers: string;\n}>;\n\n/**\n * Physical name of the legacy single shared embeddings table, dropped in\n * the cross-backend vector cutover (the clean cut of #157). Strategies now\n * own per-`(nodeKind, fieldPath)` typed storage. Retained only so the\n * one-time migration utility can address and drain the old table.\n */\nexport const LEGACY_EMBEDDINGS_TABLE_NAME = \"typegraph_node_embeddings\";\n\nexport type CreateSqliteTablesOptions = Readonly<{\n /**\n * Additional TypeGraph indexes to include in the Drizzle schema.\n *\n * These become first-class Drizzle indexes, so drizzle-kit migrations will\n * pick them up automatically.\n */\n indexes?: readonly IndexDeclaration[] | undefined;\n}>;\n\nconst DEFAULT_TABLE_NAMES: SqliteTableNames = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n uniques: \"typegraph_node_uniques\",\n schemaVersions: \"typegraph_schema_versions\",\n fulltext: \"typegraph_node_fulltext\",\n indexMaterializations: \"typegraph_index_materializations\",\n contributionMaterializations: \"typegraph_contribution_materializations\",\n kindRemovals: \"typegraph_kind_removals\",\n reconciliationMarkers: \"typegraph_reconciliation_markers\",\n};\n\n/**\n * Creates SQLite table definitions with customizable table names.\n * Index names are derived from table names.\n */\nexport function createSqliteTables(\n names: Partial<SqliteTableNames> = {},\n options: CreateSqliteTablesOptions = {},\n) {\n const n: SqliteTableNames = { ...DEFAULT_TABLE_NAMES, ...names };\n const indexes = options.indexes ?? [];\n\n const nodes = sqliteTable(\n n.nodes,\n {\n graphId: text(\"graph_id\").notNull(),\n kind: text(\"kind\").notNull(),\n id: text(\"id\").notNull(),\n props: text(\"props\").notNull(),\n version: integer(\"version\").notNull().default(1),\n validFrom: text(\"valid_from\"),\n validTo: text(\"valid_to\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n deletedAt: text(\"deleted_at\"),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.kind, t.id] }),\n index(`${n.nodes}_kind_idx`).on(t.graphId, t.kind),\n index(`${n.nodes}_kind_created_idx`).on(\n t.graphId,\n t.kind,\n t.deletedAt,\n t.createdAt,\n ),\n index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),\n index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),\n ...buildSqliteNodeIndexBuilders(t, indexes),\n ],\n );\n\n const edges = sqliteTable(\n n.edges,\n {\n graphId: text(\"graph_id\").notNull(),\n id: text(\"id\").notNull(),\n kind: text(\"kind\").notNull(),\n fromKind: text(\"from_kind\").notNull(),\n fromId: text(\"from_id\").notNull(),\n toKind: text(\"to_kind\").notNull(),\n toId: text(\"to_id\").notNull(),\n props: text(\"props\").notNull(),\n validFrom: text(\"valid_from\"),\n validTo: text(\"valid_to\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n deletedAt: text(\"deleted_at\"),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.id] }),\n index(`${n.edges}_kind_idx`).on(t.graphId, t.kind),\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind.\n index(`${n.edges}_from_idx`).on(\n t.graphId,\n t.fromKind,\n t.fromId,\n t.kind,\n t.toKind,\n t.deletedAt,\n t.validTo,\n ),\n // Directional traversal index (incoming): mirrors from_idx for reverse traversals.\n index(`${n.edges}_to_idx`).on(\n t.graphId,\n t.toKind,\n t.toId,\n t.kind,\n t.fromKind,\n t.deletedAt,\n t.validTo,\n ),\n index(`${n.edges}_kind_created_idx`).on(\n t.graphId,\n t.kind,\n t.deletedAt,\n t.createdAt,\n ),\n index(`${n.edges}_deleted_idx`).on(t.graphId, t.deletedAt),\n index(`${n.edges}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),\n index(`${n.edges}_cardinality_idx`).on(\n t.graphId,\n t.kind,\n t.fromKind,\n t.fromId,\n t.validTo,\n ),\n ...buildSqliteEdgeIndexBuilders(t, indexes),\n ],\n );\n\n const uniques = sqliteTable(\n n.uniques,\n {\n graphId: text(\"graph_id\").notNull(),\n nodeKind: text(\"node_kind\").notNull(),\n constraintName: text(\"constraint_name\").notNull(),\n key: text(\"key\").notNull(),\n nodeId: text(\"node_id\").notNull(),\n concreteKind: text(\"concrete_kind\").notNull(),\n deletedAt: text(\"deleted_at\"),\n },\n (t) => [\n primaryKey({\n columns: [t.graphId, t.nodeKind, t.constraintName, t.key],\n }),\n index(`${n.uniques}_node_idx`).on(t.graphId, t.concreteKind, t.nodeId),\n ],\n );\n\n const schemaVersions = sqliteTable(\n n.schemaVersions,\n {\n graphId: text(\"graph_id\").notNull(),\n version: integer(\"version\").notNull(),\n schemaHash: text(\"schema_hash\").notNull(),\n schemaDoc: text(\"schema_doc\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n isActive: integer(\"is_active\", { mode: \"boolean\" })\n .notNull()\n .default(false),\n },\n (t) => [\n primaryKey({ columns: [t.graphId, t.version] }),\n index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),\n // Partial unique index enforcing the \"at most one active version\n // per graph\" invariant at the storage layer. Defense in depth\n // against buggy backend implementations or out-of-band writes.\n // Forces the deactivate-then-activate ordering used by\n // `commitSchemaVersion` and `setActiveVersion`.\n uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`)\n .on(t.graphId)\n .where(sql`${t.isActive} = 1`),\n ],\n );\n\n /**\n * Per-deployment record of which declared indexes have been\n * materialized against this database. Owned and written by\n * `store.materializeIndexes()`. Keyed on `index_name` because SQL\n * index names are physical, database-global identifiers — `graphId`\n * is provenance, not identity.\n */\n const indexMaterializations = sqliteTable(\n n.indexMaterializations,\n {\n indexName: text(\"index_name\").notNull(),\n graphId: text(\"graph_id\").notNull(),\n entity: text(\"entity\").notNull(),\n kind: text(\"kind\").notNull(),\n signature: text(\"signature\").notNull(),\n schemaVersion: integer(\"schema_version\").notNull(),\n materializedAt: text(\"materialized_at\"),\n lastAttemptedAt: text(\"last_attempted_at\").notNull(),\n lastError: text(\"last_error\"),\n },\n (t) => [primaryKey({ columns: [t.indexName] })],\n );\n\n /**\n * Per-deployment record of extension kinds removed via\n * `store.removeKinds()` whose data has not yet been cleaned up by\n * `store.materializeRemovals()`. Keyed on `(graph_id, kind_name,\n * entity, schema_version)` — each remove operation is its own row.\n * `entity` separates a node and an edge that share a kind name; the\n * `schema_version` discriminator keeps a re-add-then-re-remove cycle\n * (Foo removed at v=N, re-added, then removed again at v=N+2) from\n * collapsing onto the prior row, where the COALESCE-on-failure rule\n * would preserve the earlier `removed_at` and silently skip the new\n * pending cleanup. `removed_at` is null until the data-cleanup pass\n * succeeds; the pending set is \"rows where removed_at IS NULL\".\n */\n const kindRemovals = sqliteTable(\n n.kindRemovals,\n {\n graphId: text(\"graph_id\").notNull(),\n kindName: text(\"kind_name\").notNull(),\n entity: text(\"entity\").notNull(),\n schemaVersion: integer(\"schema_version\").notNull(),\n removedAt: text(\"removed_at\"),\n lastAttemptedAt: text(\"last_attempted_at\").notNull(),\n lastError: text(\"last_error\"),\n },\n (t) => [\n primaryKey({\n columns: [t.graphId, t.kindName, t.entity, t.schemaVersion],\n }),\n ],\n );\n\n /**\n * Per-deployment high-water mark for the `materializeRemovals`\n * reconciliation walk. One row per `graph_id` carrying the schema\n * version up to which the historical \"did every removal land in\n * `kindRemovals`?\" walk has been verified. Lets subsequent calls\n * skip already-checked transitions instead of re-walking from\n * version 1 every time.\n */\n const reconciliationMarkers = sqliteTable(\n n.reconciliationMarkers,\n {\n graphId: text(\"graph_id\").notNull(),\n reconciledToVersion: integer(\"reconciled_to_version\").notNull(),\n },\n (t) => [primaryKey({ columns: [t.graphId] })],\n );\n\n /**\n * Per-deployment durable marker that a strategy-owned table\n * contribution (#129 — the FTS5 virtual table today) has been\n * materialized against this database (#135). Replaces the in-memory\n * per-backend `fulltextEnsured` latch with a queryable database fact.\n * Keyed on `(graph_id, logical_name, owner, table_name)`; `signature`\n * stays out of the key so same-identity drift is a loud error, not a\n * silent re-materialize. Same COALESCE-on-failure preservation rule\n * as `indexMaterializations`.\n */\n const contributionMaterializations = sqliteTable(\n n.contributionMaterializations,\n {\n graphId: text(\"graph_id\").notNull(),\n logicalName: text(\"logical_name\").notNull(),\n owner: text(\"owner\").notNull(),\n tableName: text(\"table_name\").notNull(),\n signature: text(\"signature\").notNull(),\n materializedAt: text(\"materialized_at\"),\n lastAttemptedAt: text(\"last_attempted_at\").notNull(),\n lastError: text(\"last_error\"),\n },\n (t) => [\n primaryKey({\n columns: [t.graphId, t.logicalName, t.owner, t.tableName],\n }),\n ],\n );\n\n return {\n nodes,\n edges,\n uniques,\n schemaVersions,\n indexMaterializations,\n contributionMaterializations,\n kindRemovals,\n reconciliationMarkers,\n /**\n * The fulltext storage is a FTS5 virtual table which Drizzle cannot\n * represent. DDL is emitted as raw SQL and operations query it via\n * `sql.raw()`.\n */\n fulltextTableName: n.fulltext,\n } as const;\n}\n\n/**\n * Default tables with standard TypeGraph table names.\n */\nexport const tables = createSqliteTables();\n\n/**\n * Convenience exports for default tables.\n */\nexport const { nodes, edges, uniques, schemaVersions } = tables;\n\n/**\n * Type representing the tables object returned by createSqliteTables.\n */\nexport type SqliteTables = ReturnType<typeof createSqliteTables>;\n","/**\n * Backend interface types for TypeGraph storage.\n *\n * The backend abstracts database operations, allowing different\n * SQL implementations (SQLite, PostgreSQL) behind a common interface.\n */\nimport { type SQL } from \"drizzle-orm\";\n\nimport {\n type IndexEntity,\n type KindEntity,\n type TemporalMode,\n} from \"../core/types\";\nimport { type SqlTableNames } from \"../query/compiler/schema\";\nimport { type FulltextStrategy } from \"../query/dialect/fulltext-strategy\";\nimport { type VectorStrategy } from \"../query/dialect/vector-strategy\";\nimport { type SerializedSchema } from \"../schema/types\";\nimport {\n type AnyPgDatabase,\n type AnySqliteDatabase,\n} from \"./drizzle/execution\";\n\n// ============================================================\n// Vector Search Types\n// ============================================================\n\n/**\n * Supported vector similarity metrics.\n */\nexport type VectorMetric = \"cosine\" | \"l2\" | \"inner_product\";\n\n/**\n * Supported vector index types.\n */\nexport type VectorIndexType = \"hnsw\" | \"ivfflat\" | \"none\";\n\n/**\n * Vector search capabilities.\n */\nexport type VectorCapabilities = Readonly<{\n /** Whether the backend supports vector operations */\n supported: boolean;\n /** Supported similarity metrics */\n metrics: readonly VectorMetric[];\n /** Supported index types */\n indexTypes: readonly VectorIndexType[];\n /** Maximum dimensions supported */\n maxDimensions: number;\n}>;\n\n// ============================================================\n// Fulltext Search Types\n// ============================================================\n\n/**\n * Query modes for fulltext search.\n *\n * - \"websearch\": Google-style syntax (quoted phrases, +required, -excluded).\n * Postgres: `websearch_to_tsquery`. SQLite: translated to FTS5 MATCH.\n * - \"phrase\": treats the whole query as a phrase.\n * Postgres: `phraseto_tsquery`. SQLite: FTS5 `\"...\"` phrase.\n * - \"plain\": splits on whitespace and ANDs terms.\n * Postgres: `plainto_tsquery`. SQLite: default FTS5 AND.\n * - \"raw\": dialect-native syntax passed through unchanged.\n */\nexport type FulltextQueryMode = \"websearch\" | \"phrase\" | \"plain\" | \"raw\";\n\n/**\n * Fulltext search capabilities declared by a backend.\n */\nexport type FulltextCapabilities = Readonly<{\n /** Whether the backend supports fulltext operations */\n supported: boolean;\n /**\n * Language / tokenizer names understood by this backend.\n * Postgres: installed regconfigs (english, simple, ...).\n * SQLite FTS5: tokenizer names (unicode61, porter, trigram).\n */\n languages: readonly string[];\n /** Whether phrase queries are supported. */\n phraseQueries: boolean;\n /** Whether prefix (`foo*`) queries are supported. */\n prefixQueries: boolean;\n /** Whether highlighting / snippets are supported. */\n highlighting: boolean;\n}>;\n\n// ============================================================\n// SQL Dialect & Capabilities\n// ============================================================\n\nimport { type SqlDialect } from \"../query/dialect/types\";\n\nexport type { SqlDialect } from \"../query/dialect/types\";\n\n/**\n * Backend capabilities that vary by dialect.\n */\nexport type BackendCapabilities = Readonly<{\n /** Whether the backend supports atomic transactions (D1 does not) */\n transactions: boolean;\n /** Vector search capabilities (undefined if not configured) */\n vector?: VectorCapabilities | undefined;\n /** Fulltext search capabilities (undefined if not configured) */\n fulltext?: FulltextCapabilities | undefined;\n}>;\n\n// ============================================================\n// Row Types (Database Records)\n// ============================================================\n\n/**\n * A row from the typegraph_nodes table.\n */\nexport type NodeRow = Readonly<{\n graph_id: string;\n kind: string;\n id: string;\n props: string; // JSON string\n version: number;\n valid_from: string | undefined;\n valid_to: string | undefined;\n created_at: string;\n updated_at: string;\n deleted_at: string | undefined;\n}>;\n\n/**\n * A row from the typegraph_edges table.\n */\nexport type EdgeRow = Readonly<{\n graph_id: string;\n id: string;\n kind: string;\n from_kind: string;\n from_id: string;\n to_kind: string;\n to_id: string;\n props: string; // JSON string\n valid_from: string | undefined;\n valid_to: string | undefined;\n created_at: string;\n updated_at: string;\n deleted_at: string | undefined;\n}>;\n\n/**\n * A row from the typegraph_node_uniques table.\n */\nexport type UniqueRow = Readonly<{\n graph_id: string;\n node_kind: string;\n constraint_name: string;\n key: string;\n node_id: string;\n concrete_kind: string;\n deleted_at: string | undefined;\n}>;\n\n/**\n * A row from the typegraph_schema_versions table.\n */\nexport type SchemaVersionRow = Readonly<{\n graph_id: string;\n version: number;\n schema_hash: string;\n schema_doc: string; // JSON string\n created_at: string;\n is_active: boolean;\n}>;\n\n// ============================================================\n// Insert Parameters\n// ============================================================\n\n/**\n * Parameters for inserting a node.\n */\nexport type InsertNodeParams = Readonly<{\n graphId: string;\n kind: string;\n id: string;\n props: Readonly<Record<string, unknown>>;\n validFrom?: string;\n validTo?: string;\n}>;\n\n/**\n * Parameters for updating a node.\n */\nexport type UpdateNodeParams = Readonly<{\n graphId: string;\n kind: string;\n id: string;\n props: Readonly<Record<string, unknown>>;\n validTo?: string;\n incrementVersion?: boolean;\n /** If true, clears deleted_at (un-deletes the node). Used by upsert. */\n clearDeleted?: boolean;\n}>;\n\n/**\n * Parameters for deleting a node (soft delete).\n */\nexport type DeleteNodeParams = Readonly<{\n graphId: string;\n kind: string;\n id: string;\n}>;\n\n/**\n * Parameters for inserting an edge.\n */\nexport type InsertEdgeParams = Readonly<{\n graphId: string;\n id: string;\n kind: string;\n fromKind: string;\n fromId: string;\n toKind: string;\n toId: string;\n props: Readonly<Record<string, unknown>>;\n validFrom?: string;\n validTo?: string;\n}>;\n\n/**\n * Parameters for updating an edge.\n */\nexport type UpdateEdgeParams = Readonly<{\n graphId: string;\n id: string;\n props: Readonly<Record<string, unknown>>;\n validTo?: string;\n clearDeleted?: boolean;\n}>;\n\n/**\n * Parameters for deleting an edge (soft delete).\n */\nexport type DeleteEdgeParams = Readonly<{\n graphId: string;\n id: string;\n}>;\n\n/**\n * Parameters for hard deleting a node (permanent removal).\n */\nexport type HardDeleteNodeParams = Readonly<{\n graphId: string;\n kind: string;\n id: string;\n}>;\n\n/**\n * Parameters for hard deleting an edge (permanent removal).\n */\nexport type HardDeleteEdgeParams = Readonly<{\n graphId: string;\n id: string;\n}>;\n\n// ============================================================\n// Embedding Parameters\n// ============================================================\n\n/**\n * Parameters for inserting or updating an embedding.\n *\n * `dimensions`, `metric`, and `indexType` together resolve the slot's\n * typed per-`(nodeKind, fieldPath)` storage (the strategy needs the fixed\n * dimension for the column type, and the metric/index type to address the\n * right ANN structure). The store populates them from the schema's\n * `embedding()` declaration via `getEmbeddingDimensions()` /\n * `getEmbeddingIndex()`; the backend constructs a `VectorSlot` from them\n * and stays graph-agnostic.\n */\nexport type UpsertEmbeddingParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n embedding: readonly number[];\n dimensions: number;\n metric: VectorMetric;\n indexType: VectorIndexType;\n}>;\n\n/**\n * Parameters for deleting an embedding.\n *\n * `dimensions` / `metric` / `indexType` mirror {@link UpsertEmbeddingParams}\n * so the backend can resolve the slot's typed per-`(nodeKind, fieldPath)`\n * storage and idempotently ensure it exists before the DELETE. That\n * matters because a delete can run before any embedding was ever written\n * (e.g. a node hard-deleted having never carried one), and on Postgres a\n * DELETE against a missing relation inside a transaction aborts the whole\n * transaction. The store populates them from the schema's `embedding()`\n * declaration, exactly as for upserts.\n */\nexport type DeleteEmbeddingParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n fieldPath: string;\n dimensions: number;\n metric: VectorMetric;\n indexType: VectorIndexType;\n}>;\n\n/**\n * Parameters for vector similarity search.\n */\nexport type VectorSearchParams = Readonly<{\n graphId: string;\n nodeKind: string;\n fieldPath: string;\n queryEmbedding: readonly number[];\n metric: VectorMetric;\n /**\n * Fixed vector dimension `N` for the searched `(nodeKind, fieldPath)`\n * slot. The store populates it from the schema's `embedding()`\n * declaration via `getEmbeddingDimensions()`; the backend uses it to\n * construct the `VectorSlot` whose typed storage the strategy scans.\n */\n dimensions: number;\n /**\n * Index type materialized for this slot. `\"none\"` means brute-force\n * only; otherwise the strategy may route through its ANN structure.\n * The store populates it from `getEmbeddingIndex()`.\n */\n indexType: VectorIndexType;\n limit: number;\n minScore?: number;\n /**\n * HNSW search frontier for this query (pgvector `hnsw.ef_search`).\n * Sizes the dynamic candidate list the index scan maintains: higher\n * trades latency for recall. The floor for the over-fetch to fill its\n * candidate set is `efSearch >= limit`; ~2–4× is the high-recall\n * target. Applied transaction-locally (`SET LOCAL`) on the Postgres\n * HNSW path only. No-op on backends without an HNSW frontier knob\n * (sqlite-vec) and ignored — with a one-time warning — on Postgres\n * backends without transactions (e.g. `drizzle-orm/neon-http`).\n */\n efSearch?: number;\n}>;\n\n/**\n * Result from a vector similarity search.\n */\nexport type VectorSearchResult = Readonly<{\n nodeId: string;\n /**\n * Cosine metric returns similarity score (higher is better).\n * L2 and inner_product return raw distance (lower is better).\n */\n score: number;\n}>;\n\n/**\n * Parameters for creating a vector index.\n */\nexport type CreateVectorIndexParams = Readonly<{\n graphId: string;\n nodeKind: string;\n fieldPath: string;\n dimensions: number;\n metric: VectorMetric;\n indexType: VectorIndexType;\n /** Index-specific parameters */\n indexParams?: Readonly<{\n /** HNSW: max connections per layer */\n m?: number;\n /** HNSW: construction search depth */\n efConstruction?: number;\n /** IVFFlat: number of lists */\n lists?: number;\n }>;\n /**\n * Build the index without taking an `AccessExclusiveLock` on live\n * tables (Postgres `CREATE INDEX CONCURRENTLY`). Mirrors the\n * `concurrent` flag the relational DDL path uses inside\n * `materializeIndexes()`. Cannot be set inside a transaction —\n * callers (`materializeIndexes()`) run at top level. Backends that\n * don't have a CONCURRENTLY equivalent (SQLite) ignore this flag.\n */\n concurrent?: boolean;\n}>;\n\n/**\n * Parameters for dropping a vector index.\n */\nexport type DropVectorIndexParams = Readonly<{\n graphId: string;\n nodeKind: string;\n fieldPath: string;\n}>;\n\n// ============================================================\n// Fulltext Parameters\n// ============================================================\n\n/**\n * Parameters for inserting or updating a fulltext entry.\n *\n * One row per node. Callers concatenate the searchable fields into\n * `content` so a single MATCH query can find terms spread across fields.\n *\n * Note: `createFulltextIndex` / `dropFulltextIndex` were removed as\n * dead code in #PR_E. The fulltext table's canonical index (Postgres\n * GIN on `tsv`, SQLite FTS5 virtual table) is created with the table\n * itself by `bootstrapTables` per the active `FulltextStrategy`;\n * per-kind fulltext indexes are an \"advanced strategy\" surface that\n * doesn't fit the relational-style declaration model and is reserved\n * for future work.\n */\nexport type UpsertFulltextParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n content: string;\n language: string;\n}>;\n\n/**\n * Parameters for deleting a single fulltext entry.\n */\nexport type DeleteFulltextParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n}>;\n\n/**\n * A single row in a fulltext batch upsert.\n */\nexport type FulltextBatchRow = Readonly<{\n nodeId: string;\n content: string;\n language: string;\n}>;\n\n/**\n * Parameters for a batched fulltext upsert.\n *\n * Homogeneous: one graph, one node kind, many nodes. Duplicate `nodeId`\n * values within a single batch are deduplicated last-write-wins by the\n * builders before SQL generation — Postgres `ON CONFLICT` errors on\n * repeated conflict keys in one statement, and SQLite `DELETE + INSERT`\n * would create duplicate virtual-table rows otherwise.\n */\nexport type UpsertFulltextBatchParams = Readonly<{\n graphId: string;\n nodeKind: string;\n rows: readonly FulltextBatchRow[];\n}>;\n\n/**\n * Parameters for a batched fulltext delete.\n */\nexport type DeleteFulltextBatchParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeIds: readonly string[];\n}>;\n\n/**\n * Parameters for fulltext search.\n */\nexport type FulltextSearchParams = Readonly<{\n graphId: string;\n nodeKind: string;\n /** The user-supplied query string. */\n query: string;\n /** How to parse `query`. Default: \"websearch\". */\n mode?: FulltextQueryMode;\n /**\n * Language override. Default: per-row language (as stored at insert time).\n * Postgres: passed as the regconfig to `to_tsquery` / `websearch_to_tsquery`.\n * SQLite: informational only (FTS5 tokenizer is fixed at table-create time).\n */\n language?: string;\n /** Max rows to return. */\n limit: number;\n /** Minimum rank to include (backend-dependent units). */\n minScore?: number;\n /** Whether to return a highlighted snippet per match. */\n includeSnippets?: boolean;\n}>;\n\n/**\n * Result from a fulltext search.\n *\n * Score semantics differ by backend; prefer `rank` (1-based) when fusing\n * with another source via RRF.\n */\nexport type FulltextSearchResult = Readonly<{\n nodeId: string;\n /**\n * Backend-native relevance score.\n * Postgres: `ts_rank_cd` (higher is better).\n * SQLite FTS5: negated `bm25()` (higher is better; FTS5 returns lower-is-better).\n */\n score: number;\n /** 1-based rank within the result set, suitable for RRF. */\n rank: number;\n /** Highlighted snippet of the content (if `includeSnippets` was set). */\n snippet?: string;\n}>;\n\n/**\n * Parameters for creating a fulltext index.\n *\n * The canonical index (Postgres GIN on `tsv`, SQLite FTS5 virtual table)\n * is created when the fulltext table itself is created. This is reserved\n * for advanced per-kind specializations.\n */\n\n// ============================================================\n// Index Materialization Status\n// ============================================================\n\n/**\n * Per-deployment record for a single declared index.\n *\n * Identified by `indexName` because SQL index names are physical,\n * database-global identifiers — `graphId` is provenance, not identity.\n * `materializedAt` is null until the first successful CREATE INDEX\n * completes; `lastAttemptedAt` is always set, even on failure.\n */\nexport type IndexMaterializationRow = Readonly<{\n indexName: string;\n graphId: string;\n entity: IndexEntity;\n kind: string;\n signature: string;\n schemaVersion: number;\n materializedAt: string | undefined;\n lastAttemptedAt: string;\n lastError: string | undefined;\n}>;\n\n/**\n * Parameters for upserting a materialization attempt.\n *\n * On success: pass `materializedAt` (ISO timestamp) and undefined `error`.\n * On failure: pass undefined `materializedAt` (preserve any existing\n * timestamp from a prior success) and the error message.\n */\nexport type RecordIndexMaterializationParams = Readonly<{\n indexName: string;\n graphId: string;\n entity: IndexEntity;\n kind: string;\n signature: string;\n schemaVersion: number;\n attemptedAt: string;\n /** ISO timestamp on success; undefined on failure (preserves existing). */\n materializedAt: string | undefined;\n /** Error message on failure; undefined on success (clears existing). */\n error: string | undefined;\n}>;\n\n// ============================================================\n// Contribution Materializations (#135 — durable strategy-owned\n// storage marker, sibling of index materializations)\n// ============================================================\n\n/**\n * Durable identity of a strategy-owned table contribution (#129),\n * scoped to a graph. This is the primary key of\n * `typegraph_contribution_materializations`.\n *\n * `logicalName` is the stable slot (\"fulltext\"); `owner` is the\n * producing strategy (\"tsvector\" / \"fts5\"); `tableName` is the resolved\n * physical name (custom per-deployment names must be distinguishable).\n * `graphId` is part of identity here — unlike the index status table\n * where the physical index name is database-global, two graphs can each\n * own a logically-identical fulltext contribution.\n */\nexport type ContributionMaterializationIdentity = Readonly<{\n graphId: string;\n logicalName: string;\n owner: string;\n tableName: string;\n}>;\n\n/**\n * Per-deployment record that a strategy-owned contribution has been\n * durably materialized against this database.\n *\n * `signature` is intentionally NOT part of the identity: a row with the\n * same identity but a different signature means \"materialized artifact\n * is stale/drifted\" — a loud error on the hot path, never a silent\n * re-materialize. `materializedAt` is undefined until the first\n * successful materialization; `lastAttemptedAt` is always set.\n */\nexport type ContributionMaterializationRow = Readonly<{\n graphId: string;\n logicalName: string;\n owner: string;\n tableName: string;\n signature: string;\n materializedAt: string | undefined;\n lastAttemptedAt: string;\n lastError: string | undefined;\n}>;\n\n/**\n * Parameters for upserting a contribution-materialization attempt.\n * Same success/failure contract as\n * {@link RecordIndexMaterializationParams}: on failure pass undefined\n * `materializedAt` so a prior successful timestamp is preserved via\n * COALESCE, and the error message.\n */\nexport type RecordContributionMaterializationParams = Readonly<{\n graphId: string;\n logicalName: string;\n owner: string;\n tableName: string;\n signature: string;\n attemptedAt: string;\n /** ISO timestamp on success; undefined on failure (preserves existing). */\n materializedAt: string | undefined;\n /** Error message on failure; undefined on success (clears existing). */\n error: string | undefined;\n}>;\n\n// ============================================================\n// Kind Removals (data-cleanup status)\n// ============================================================\n\n/**\n * One row of the per-deployment `typegraph_kind_removals` table:\n * a graph-extension kind that has been removed from the schema and whose\n * data may or may not have been cleaned up yet.\n */\nexport type KindRemovalRow = Readonly<{\n graphId: string;\n kindName: string;\n entity: KindEntity;\n schemaVersion: number;\n /** ISO timestamp when the data-cleanup pass succeeded; undefined while pending. */\n removedAt: string | undefined;\n lastAttemptedAt: string;\n lastError: string | undefined;\n}>;\n\n/**\n * Upsert payload for a kind-removal status row. On removal-commit:\n * pass `removedAt: undefined` (the pending state). On successful\n * data-cleanup: pass `removedAt` set and `error: undefined`. On\n * cleanup failure: pass `removedAt: undefined` (preserves any prior\n * timestamp from a partial success on a different replica) and the\n * error message.\n */\nexport type RecordKindRemovalParams = Readonly<{\n graphId: string;\n kindName: string;\n entity: KindEntity;\n schemaVersion: number;\n attemptedAt: string;\n /** ISO timestamp on success; undefined while pending or on failure. */\n removedAt: string | undefined;\n /** Error message on failure; undefined on success or while pending. */\n error: string | undefined;\n}>;\n\n// ============================================================\n// Query Types\n// ============================================================\n\n/**\n * Transaction options.\n */\nexport type TransactionOptions = Readonly<{\n /** Transaction isolation level (if supported) */\n isolationLevel?:\n | \"read_uncommitted\"\n | \"read_committed\"\n | \"repeatable_read\"\n | \"serializable\";\n}>;\n\n/**\n * A caller-owned, already-open Drizzle transaction handle that a\n * TypeGraph store can adopt so both layers commit/rollback together.\n *\n * The literal client the caller's transaction runs on — a `PgDatabase`\n * transaction (node-postgres / `neon-serverless` Pool) or a\n * `BaseSQLiteDatabase` connection. Async drivers obtain it from\n * `db.transaction(async (tx) => …)`; synchronous `better-sqlite3` (whose\n * driver rejects an `async` transaction callback) passes the connection\n * itself under an explicit `BEGIN`/`COMMIT`/`ROLLBACK`. Passing it to\n * {@link GraphBackend.adoptTransaction} threads that *literal* client\n * through TypeGraph's SQL, so graph writes and the caller's own\n * relational writes share one Postgres/SQLite transaction (#134).\n */\nexport type AdoptedTransaction = AnyPgDatabase | AnySqliteDatabase;\n\n// ============================================================\n// Backend Interface\n// ============================================================\n\n/**\n * Transaction backend — a backend scoped to a transaction.\n *\n * `commitSchemaVersion` and `setActiveVersion` are intentionally omitted:\n * the atomicity / CAS guarantees of those primitives depend on\n * dialect-specific write-locking (BEGIN IMMEDIATE on SQLite,\n * `pg_advisory_xact_lock` on Postgres) acquired by the top-level\n * backend wrappers, not the transaction itself. Calling them from a\n * user-supplied `backend.transaction(...)` callback would bypass that\n * locking and silently weaken the orphan-row crash window the primitive\n * exists to eliminate. Schema commits go through the top-level backend\n * methods only.\n */\nexport type TransactionBackend = Omit<\n GraphBackend,\n | \"transaction\"\n | \"adoptTransaction\"\n | \"close\"\n | \"refreshStatistics\"\n | \"commitSchemaVersion\"\n | \"setActiveVersion\"\n>;\n\n/**\n * The GraphBackend interface abstracts database operations.\n *\n * Implementations should provide:\n * - SQLite backend via better-sqlite3 or libsql\n * - PostgreSQL backend via pg or postgres\n */\nexport type GraphBackend = Readonly<{\n /** The SQL dialect */\n dialect: SqlDialect;\n /** Backend capabilities */\n capabilities: BackendCapabilities;\n /** Table names used by this backend (for query schema auto-derivation) */\n tableNames?: SqlTableNames | undefined;\n /**\n * Optional fulltext strategy override. When present, both the compiler\n * (for `$fulltext.matches()` in query builder) and backend-direct\n * search paths use this instead of the dialect's default strategy —\n * allowing a Postgres backend to ship pg_trgm, ParadeDB, pgroonga etc.\n * When absent, the dialect's default strategy is used.\n */\n fulltextStrategy?: FulltextStrategy | undefined;\n /**\n * Optional vector strategy this backend is wired with. The query\n * compiler reads it (via `compileQuery` options) to emit per-`(kind,\n * field)` relevance scans for `field.similarTo(...)` predicates, and\n * the index-materialization / removal paths read its deterministic\n * `tableName(...)` to address the right physical per-field storage.\n * `undefined` when the backend has no vector support (e.g. a generic\n * SQLite backend without sqlite-vec).\n */\n vectorStrategy?: VectorStrategy | undefined;\n\n // === Node Operations ===\n insertNode: (params: InsertNodeParams) => Promise<NodeRow>;\n insertNodeNoReturn?: (params: InsertNodeParams) => Promise<void>;\n insertNodesBatch?: (params: readonly InsertNodeParams[]) => Promise<void>;\n insertNodesBatchReturning?: (\n params: readonly InsertNodeParams[],\n ) => Promise<readonly NodeRow[]>;\n updateNode: (params: UpdateNodeParams) => Promise<NodeRow>;\n deleteNode: (params: DeleteNodeParams) => Promise<void>;\n hardDeleteNode: (params: HardDeleteNodeParams) => Promise<void>;\n getNode: (\n graphId: string,\n kind: string,\n id: string,\n ) => Promise<NodeRow | undefined>;\n getNodes?: (\n graphId: string,\n kind: string,\n ids: readonly string[],\n ) => Promise<readonly NodeRow[]>;\n\n // === Edge Operations ===\n insertEdge: (params: InsertEdgeParams) => Promise<EdgeRow>;\n insertEdgeNoReturn?: (params: InsertEdgeParams) => Promise<void>;\n insertEdgesBatch?: (params: readonly InsertEdgeParams[]) => Promise<void>;\n insertEdgesBatchReturning?: (\n params: readonly InsertEdgeParams[],\n ) => Promise<readonly EdgeRow[]>;\n updateEdge: (params: UpdateEdgeParams) => Promise<EdgeRow>;\n deleteEdge: (params: DeleteEdgeParams) => Promise<void>;\n hardDeleteEdge: (params: HardDeleteEdgeParams) => Promise<void>;\n getEdge: (graphId: string, id: string) => Promise<EdgeRow | undefined>;\n getEdges?: (\n graphId: string,\n ids: readonly string[],\n ) => Promise<readonly EdgeRow[]>;\n\n // === Edge Cardinality Operations ===\n countEdgesFrom: (params: CountEdgesFromParams) => Promise<number>;\n edgeExistsBetween: (params: EdgeExistsBetweenParams) => Promise<boolean>;\n\n // === Edge Query Operations ===\n findEdgesConnectedTo: (\n params: FindEdgesConnectedToParams,\n ) => Promise<readonly EdgeRow[]>;\n\n // === Collection Query Operations ===\n findNodesByKind: (\n params: FindNodesByKindParams,\n ) => Promise<readonly NodeRow[]>;\n countNodesByKind: (params: CountNodesByKindParams) => Promise<number>;\n findEdgesByKind: (\n params: FindEdgesByKindParams,\n ) => Promise<readonly EdgeRow[]>;\n countEdgesByKind: (params: CountEdgesByKindParams) => Promise<number>;\n\n // === Unique Constraint Operations ===\n insertUnique: (params: InsertUniqueParams) => Promise<void>;\n deleteUnique: (params: DeleteUniqueParams) => Promise<void>;\n checkUnique: (params: CheckUniqueParams) => Promise<UniqueRow | undefined>;\n checkUniqueBatch?: (\n params: CheckUniqueBatchParams,\n ) => Promise<readonly UniqueRow[]>;\n\n // === Schema Operations ===\n getActiveSchema: (graphId: string) => Promise<SchemaVersionRow | undefined>;\n getSchemaVersion: (\n graphId: string,\n version: number,\n ) => Promise<SchemaVersionRow | undefined>;\n /**\n * Atomically inserts a new schema version and activates it as a single\n * transactional unit, with optimistic compare-and-swap on the currently\n * active version.\n *\n * - If `expected.kind === \"active\"` and the actual active version\n * differs, throws `StaleVersionError` (caller should refetch and\n * retry).\n * - If a row already exists at `params.version` with the same\n * `schemaHash`, returns it idempotently — reactivating it if it was\n * left inactive by an earlier crashed commit.\n * - If a row already exists at `params.version` with a different\n * `schemaHash`, throws `SchemaContentConflictError`.\n *\n * Requires `capabilities.transactions === true`. On non-transactional\n * backends (e.g. Cloudflare D1, drizzle-orm/neon-http) this method\n * throws `ConfigurationError` rather than running with degraded\n * atomicity that would silently re-introduce the orphan-row crash\n * window the primitive exists to eliminate.\n */\n commitSchemaVersion: (\n params: CommitSchemaVersionParams,\n ) => Promise<SchemaVersionRow>;\n /**\n * Atomically flips the active schema pointer to an existing version,\n * with optimistic compare-and-swap on the currently active version.\n * Used by `rollbackSchema` and any other \"promote/demote existing\n * version\" workflow. Throws `StaleVersionError` on CAS mismatch and\n * `MigrationError` if the target version row does not exist.\n *\n * Same transactional requirements as `commitSchemaVersion`.\n */\n setActiveVersion: (params: SetActiveVersionParams) => Promise<void>;\n\n // === Embedding Operations (optional - depends on vector capabilities) ===\n upsertEmbedding?: (params: UpsertEmbeddingParams) => Promise<void>;\n deleteEmbedding?: (params: DeleteEmbeddingParams) => Promise<void>;\n vectorSearch?: (\n params: VectorSearchParams,\n ) => Promise<readonly VectorSearchResult[]>;\n createVectorIndex?: (params: CreateVectorIndexParams) => Promise<void>;\n dropVectorIndex?: (params: DropVectorIndexParams) => Promise<void>;\n\n // === Fulltext Operations (optional - depends on fulltext capabilities) ===\n upsertFulltext?: (params: UpsertFulltextParams) => Promise<void>;\n deleteFulltext?: (params: DeleteFulltextParams) => Promise<void>;\n /**\n * Batched variant of `upsertFulltext`. Optional — callers fall back to\n * per-row `upsertFulltext` when unset.\n */\n upsertFulltextBatch?: (params: UpsertFulltextBatchParams) => Promise<void>;\n /**\n * Batched variant of `deleteFulltext`. Optional — callers fall back to\n * per-row `deleteFulltext` when unset.\n */\n deleteFulltextBatch?: (params: DeleteFulltextBatchParams) => Promise<void>;\n fulltextSearch?: (\n params: FulltextSearchParams,\n ) => Promise<readonly FulltextSearchResult[]>;\n\n // === Index Materialization (used by store.materializeIndexes) ===\n /**\n * Idempotently ensure ONLY the `typegraph_index_materializations`\n * table exists — separate from `bootstrapTables` so that\n * `materializeIndexes` doesn't pull in the full base-table DDL set\n * just to access the status table.\n *\n * Why focused: `bootstrapTables` issues 20+ `CREATE TABLE / CREATE\n * INDEX IF NOT EXISTS` statements covering every base table. Two\n * concurrent calls (e.g. two replicas of the same `schema_doc` both\n * starting up and calling `materializeIndexes`) race on\n * Postgres SHARE locks and DEADLOCK. Restricting the ensure-step to\n * the single status table eliminates the cross-table race entirely\n * — concurrent `CREATE TABLE IF NOT EXISTS` for one specific table\n * is well-behaved on Postgres.\n */\n ensureIndexMaterializationsTable?: () => Promise<void>;\n\n /**\n * Look up a recorded materialization for a declared index by its\n * physical SQL index name. Returns `undefined` if no row exists.\n */\n getIndexMaterialization?: (\n indexName: string,\n ) => Promise<IndexMaterializationRow | undefined>;\n /**\n * Bulk variant of `getIndexMaterialization`: load every recorded\n * materialization whose `indexName` (status key) is in `statusKeys`,\n * in a single round-trip. Returned rows are unordered — callers index\n * by `indexName`. Optional; consumers fall back to per-key\n * `getIndexMaterialization` when unset.\n */\n getIndexMaterializations?: (\n statusKeys: readonly string[],\n ) => Promise<readonly IndexMaterializationRow[]>;\n /**\n * Upsert a materialization attempt — success or failure. Failure rows\n * preserve any prior `materializedAt` so the historical successful\n * timestamp survives across error windows.\n */\n recordIndexMaterialization?: (\n params: RecordIndexMaterializationParams,\n ) => Promise<void>;\n\n // === Contribution Materialization (#135 — durable strategy-owned\n // storage marker, sibling of the index status table) ===\n\n /**\n * Idempotently ensure ONLY the\n * `typegraph_contribution_materializations` table exists. Same\n * focused-bootstrap rationale as `ensureIndexMaterializationsTable`:\n * a single `CREATE TABLE IF NOT EXISTS` is concurrency-safe under\n * replica startup, where the full `bootstrapTables` set risks a\n * Postgres SHARE-lock deadlock.\n */\n ensureContributionMaterializationsTable?: () => Promise<void>;\n\n /**\n * Look up the durable materialization marker for one strategy-owned\n * contribution identity. Returns `undefined` when no row exists\n * (\"never initialized\").\n */\n getContributionMaterialization?: (\n identity: ContributionMaterializationIdentity,\n ) => Promise<ContributionMaterializationRow | undefined>;\n\n /**\n * Upsert a contribution-materialization attempt — success or failure.\n * Failure rows preserve any prior `materializedAt` via COALESCE so a\n * later failed re-attempt doesn't erase the historical success.\n */\n recordContributionMaterialization?: (\n params: RecordContributionMaterializationParams,\n ) => Promise<void>;\n\n /**\n * Resolve (once per backend instance, cached) and assert the durable\n * materialization markers for every `runtimeEnsure` contribution this\n * backend's strategy declares, for `graphId`. Throws\n * `StoreNotInitializedError` when a marker is missing, stale\n * (signature drift), or recorded a failed last attempt.\n *\n * This is the single read-side gate the fulltext hot-path wrappers\n * and `store.transaction()` consult. It performs ZERO DDL and ZERO\n * marker writes — initialization is the exclusive job of the async\n * boot path (`createStoreWithSchema` → `ensureRuntimeContributions`).\n */\n assertRuntimeContributionsInitialized?: (graphId: string) => Promise<void>;\n\n // === Kind Removal Status ===\n\n /**\n * Bootstraps the per-deployment `typegraph_kind_removals` table so\n * `store.removeKinds()` and `store.materializeRemovals()` can persist\n * removal status. Mirrors the focused-bootstrap rationale documented\n * on `ensureIndexMaterializationsTable` — the full `bootstrapTables`\n * touches every base table and risks Postgres SHARE-lock deadlock\n * under concurrent replica startup.\n */\n ensureKindRemovalsTable?: () => Promise<void>;\n\n /**\n * List graph-extension kind removals whose data-cleanup pass has not yet\n * succeeded for this `graphId`. Returns rows with\n * `removedAt: undefined`. Order is unspecified; callers materialize\n * one-at-a-time and don't depend on it.\n */\n getPendingKindRemovals?: (\n graphId: string,\n ) => Promise<readonly KindRemovalRow[]>;\n\n /**\n * List ALL kind-removal rows for a `graphId` — pending and completed.\n * Used by `materializeRemovals()` reconciliation to detect rows that\n * are missing entirely (the `removeKinds()` crash window) versus\n * already completed. Without this distinction the reconciler would\n * have to upsert every expected historical removal on every call,\n * churning `last_attempted_at` on rows that long since succeeded.\n * Order is unspecified.\n */\n getAllKindRemovals?: (graphId: string) => Promise<readonly KindRemovalRow[]>;\n\n /**\n * Upsert a kind-removal status row. `removedAt: undefined` records\n * the pending state at schema-commit time; `removedAt: <iso>`\n * marks the data cleanup successful. The COALESCE rule on `removedAt`\n * mirrors `recordIndexMaterialization` so a later failure doesn't\n * clobber the historical successful timestamp from another replica.\n */\n recordKindRemoval?: (params: RecordKindRemovalParams) => Promise<void>;\n\n // === Reconciliation Watermark ===\n\n /**\n * Bootstraps the per-deployment `typegraph_reconciliation_markers`\n * table so `materializeRemovals()` can persist reconciliation\n * progress. Same focused-bootstrap rationale as the other status\n * tables — full `bootstrapTables` risks Postgres SHARE-lock\n * deadlock under concurrent replica startup.\n */\n ensureReconciliationMarkersTable?: () => Promise<void>;\n\n // === Table Contributions (#129) ===\n\n /**\n * Materializes every contribution flagged `runtimeEnsure` — the\n * strategy-owned runtime tables (fulltext today) that drizzle-kit-\n * managed setups don't create. Called once after a successful schema\n * load. Deliberately scoped: base/drizzle-visible tables are\n * `runtimeEnsure: false`, so this does not regress startup into\n * broad DDL/probing across every table.\n *\n * The canonical durable-marker writer (#135): for each runtime\n * contribution it short-circuits when the marker already records a\n * matching signature, otherwise runs the idempotent `createDdl` and\n * records the marker (success or failure) keyed by `graphId`.\n */\n ensureRuntimeContributions?: (graphId: string) => Promise<void>;\n\n /**\n * Bootstraps the fulltext storage table the active `FulltextStrategy`\n * owns. Same focused-bootstrap rationale as the other `ensure*Table`\n * methods: idempotent and concurrency-safe under replica startup.\n *\n * Superseded by `ensureRuntimeContributions()` (#129); retained as\n * a thin back-compat wrapper for backends/callers predating #129. Not\n * machine-`@deprecated` because the manager still calls it as the\n * pre-#129 fallback. #135 removed the remaining hot-path callers and\n * routed this through the durable-marker writer.\n */\n ensureFulltextTable?: (graphId: string) => Promise<void>;\n\n /**\n * Read the high-water mark schema version for which\n * `materializeRemovals` reconciliation has already verified history\n * for `graphId`. Returns `undefined` when no marker has been\n * recorded yet. Used to skip already-checked transitions in the\n * recovery walk.\n */\n getReconciliationMarker?: (graphId: string) => Promise<number | undefined>;\n\n /**\n * Persist the reconciliation high-water mark for `graphId`. Called\n * after `materializeRemovals` completes a clean walk; subsequent\n * calls walk only versions newer than this marker. Idempotent\n * upsert by `graphId`.\n */\n setReconciliationMarker?: (graphId: string, version: number) => Promise<void>;\n\n // === Graph Lifecycle ===\n /**\n * Hard-deletes all data for a graph (nodes, edges, uniques, embeddings, schema versions).\n * Intended for import-replacement workflows. No hooks, no per-row logic.\n */\n clearGraph: (graphId: string) => Promise<void>;\n\n /**\n * Creates the base TypeGraph tables if they don't already exist.\n *\n * Called automatically by `createStoreWithSchema()` when a fresh database\n * is detected. Users who manage DDL themselves via `createStore()` never\n * hit this path.\n */\n bootstrapTables?: () => Promise<void>;\n\n /**\n * Refreshes the backend's query-planner statistics.\n *\n * Call this once after a large initial import or bulk backfill. Without\n * up-to-date statistics, the planner can pick suboptimal execution plans\n * — on PostgreSQL this is the difference between a 0.5ms and a 5ms\n * forward traversal; on SQLite it's the difference between 0.9ms and\n * 23ms fulltext search. Autovacuum / background statistics collection\n * will catch up eventually, but calling this explicitly after a bulk\n * load gives you correct latencies immediately.\n *\n * Implementations:\n * - SQLite runs `ANALYZE`, which populates `sqlite_stat1`\n * - PostgreSQL runs `ANALYZE` on the TypeGraph-managed tables\n *\n * Safe to call at any time; costs a few tens of milliseconds on the\n * sizes this library is designed for.\n */\n refreshStatistics: () => Promise<void>;\n\n // === Query Execution ===\n execute: <T>(query: SQL) => Promise<readonly T[]>;\n\n /** Execute pre-compiled SQL text with bound parameters. Available on sync SQLite and pg backends. */\n executeRaw?: <T>(\n sqlText: string,\n params: readonly unknown[],\n ) => Promise<readonly T[]>;\n\n /** Compile a Drizzle SQL object to { sql, params } without executing. */\n compileSql?: (\n query: SQL,\n ) => Readonly<{ sql: string; params: readonly unknown[] }>;\n\n /**\n * Execute a DDL statement that returns no rows (CREATE INDEX,\n * CREATE TABLE, ALTER TABLE, etc.). Separate from `executeRaw`\n * because some drivers (better-sqlite3) require `.run()` for DDL\n * and `.all()` for queries — the ambiguity can't be resolved by\n * inspecting the SQL string portably.\n *\n * Postgres path can use this for `CREATE INDEX CONCURRENTLY`, which\n * cannot run inside a transaction. Implementations must execute the\n * statement outside `transaction(...)`.\n */\n executeDdl?: (ddl: string) => Promise<void>;\n\n // === Transaction ===\n /**\n * `fn` receives the tx-scoped backend and the raw Drizzle handle\n * **bound to that same transaction** (`AdoptedTransaction`). The\n * store surfaces the second argument as `TransactionContext.sql` so\n * callers can write their own relational tables inside the\n * graph-owned transaction. Implementations MUST pass the *exact*\n * handle the tx-scoped backend writes through (the Postgres/libsql\n * tx handle; for better-sqlite3 / do-sqlite the bound connection),\n * never a fresh one.\n */\n transaction: <T>(\n fn: (tx: TransactionBackend, sql: AdoptedTransaction) => Promise<T>,\n options?: TransactionOptions,\n ) => Promise<T>;\n\n /**\n * Adopt a caller-owned, already-open transaction (#134).\n *\n * Returns a transaction-scoped backend bound to the *exact*\n * `externalTx` client, reusing this backend's already-resolved\n * schema/strategy config — no `createStoreWithSchema` / `evolve` /\n * `migrateSchema`, and **no DDL inside the caller's business\n * transaction**. The caller owns `BEGIN`/`COMMIT`/`ROLLBACK`; this\n * method neither opens nor closes a transaction. Async drivers\n * (node-postgres, `neon-serverless` Pool, libsql) wrap with\n * `db.transaction(async …)`; synchronous `better-sqlite3` must instead\n * issue explicit `BEGIN`/`COMMIT`/`ROLLBACK` (its driver rejects an\n * `async` transaction callback).\n *\n * Optional and presence-detected like the other capability-scoped\n * members: only the Drizzle Postgres/SQLite backends provide it.\n * Implementations MUST throw (not silently degrade) when\n * `capabilities.transactions` is `false` — a non-atomic fallback is\n * safe for graph-only writes but dangerous for cross-store flows,\n * where the caller's relational write *would* still commit.\n *\n * Fulltext stays safe by construction: the returned backend's\n * fulltext methods assert the durable materialization marker (a\n * cached SELECT, never DDL) at point of use and throw\n * `StoreNotInitializedError` on a missing/stale/failed marker rather\n * than migrating mid-transaction. Prefer booting the parent store via\n * `createStoreWithSchema` so that assertion is a warm-cache no-op.\n */\n adoptTransaction?: (externalTx: AdoptedTransaction) => TransactionBackend;\n\n // === Lifecycle ===\n close: () => Promise<void>;\n}>;\n\n// ============================================================\n// Managed Backend Helper\n// ============================================================\n\n/**\n * Wraps a GraphBackend with idempotent close that also runs a teardown\n * callback (e.g. closing the underlying database connection).\n */\nexport function wrapWithManagedClose(\n backend: GraphBackend,\n teardown: () => void | Promise<void>,\n): GraphBackend {\n let isClosed = false;\n return {\n ...backend,\n async close(): Promise<void> {\n if (isClosed) return;\n isClosed = true;\n await backend.close();\n await teardown();\n },\n };\n}\n\n/**\n * Runs `fn` inside a transaction when the backend supports one, falling\n * through to a direct invocation otherwise. Lets call sites benefit from\n * atomicity on backends that have transactions while staying functional\n * on backends that don't (Cloudflare D1, `drizzle-orm/neon-http` over\n * HTTP). The single-statement race window is already implicit on any\n * backend that reports `transactions: false`; callers that cannot\n * tolerate it must branch on the capability themselves.\n *\n * Pass `fallback` only when the toplevel backend method would recurse\n * — pass the operation-level backend so the no-tx path doesn't loop\n * back through the same toplevel method.\n */\nexport async function runOptionallyInTransaction<T>(\n backend: GraphBackend,\n fn: (target: GraphBackend | TransactionBackend) => Promise<T>,\n fallback?: GraphBackend | TransactionBackend,\n): Promise<T> {\n if (!backend.capabilities.transactions) {\n return fn(fallback ?? backend);\n }\n return backend.transaction((tx) => fn(tx));\n}\n\n// ============================================================\n// Additional Parameter Types\n// ============================================================\n\n/**\n * Parameters for inserting a unique constraint entry.\n */\nexport type InsertUniqueParams = Readonly<{\n graphId: string;\n nodeKind: string;\n constraintName: string;\n key: string;\n nodeId: string;\n concreteKind: string;\n}>;\n\n/**\n * Parameters for deleting a unique constraint entry.\n */\nexport type DeleteUniqueParams = Readonly<{\n graphId: string;\n nodeKind: string;\n constraintName: string;\n key: string;\n}>;\n\n/**\n * Parameters for checking a unique constraint.\n */\nexport type CheckUniqueParams = Readonly<{\n graphId: string;\n nodeKind: string;\n constraintName: string;\n key: string;\n /** If true, also returns soft-deleted entries. Used by get-or-create operations. */\n includeDeleted?: boolean;\n}>;\n\n/**\n * Parameters for batch-checking unique constraints.\n */\nexport type CheckUniqueBatchParams = Readonly<{\n graphId: string;\n nodeKind: string;\n constraintName: string;\n keys: readonly string[];\n /** If true, also returns soft-deleted entries. Used by get-or-create operations. */\n includeDeleted?: boolean;\n}>;\n\n/**\n * Parameters for inserting a schema version.\n *\n * Used internally by backend implementations. Public callers go through\n * `commitSchemaVersion`, which handles the insert + activate atomically\n * with CAS guarantees.\n */\nexport type InsertSchemaParams = Readonly<{\n graphId: string;\n version: number;\n schemaHash: string;\n schemaDoc: SerializedSchema;\n isActive: boolean;\n}>;\n\n/**\n * The caller's claim about the currently-active schema version, used as\n * the optimistic compare-and-swap guard for `commitSchemaVersion`.\n *\n * - `{ kind: \"initial\" }` — caller is committing the first-ever version\n * for this graph and asserts no active version exists yet.\n * - `{ kind: \"active\", version: N }` — caller observed version N as\n * active and is committing version N+1 against that baseline. The\n * commit fails with `StaleVersionError` if some other writer has\n * advanced or rolled back the pointer in the meantime.\n *\n * Tagged-union form (rather than a magic `version: 0` sentinel) because\n * the two cases have materially different semantics: the initial path\n * skips the \"deactivate prior\" UPDATE, and the no-active-row state is\n * a *valid* expected state, not an out-of-band signal.\n */\nexport type CommitSchemaVersionExpected =\n | Readonly<{ kind: \"initial\" }>\n | Readonly<{ kind: \"active\"; version: number }>;\n\n/**\n * Parameters for `commitSchemaVersion`.\n */\nexport type CommitSchemaVersionParams = Readonly<{\n graphId: string;\n /** CAS guard — see `CommitSchemaVersionExpected`. */\n expected: CommitSchemaVersionExpected;\n /** The new version to insert and activate. */\n version: number;\n schemaHash: string;\n schemaDoc: SerializedSchema;\n}>;\n\n/**\n * Parameters for `setActiveVersion`.\n *\n * Flips the active pointer from `expected` to `version` for an existing\n * row. CAS prevents overwriting a concurrent rollback or commit.\n */\nexport type SetActiveVersionParams = Readonly<{\n graphId: string;\n /** CAS guard. Same semantics as `commitSchemaVersion.expected`. */\n expected: CommitSchemaVersionExpected;\n /** The version to mark active. Must already exist. */\n version: number;\n}>;\n\n/**\n * Parameters for counting edges from a source node.\n */\nexport type CountEdgesFromParams = Readonly<{\n graphId: string;\n edgeKind: string;\n fromKind: string;\n fromId: string;\n /** If true, only count edges where valid_to IS NULL */\n activeOnly?: boolean;\n}>;\n\n/**\n * Parameters for checking if an edge exists between two nodes.\n */\nexport type EdgeExistsBetweenParams = Readonly<{\n graphId: string;\n edgeKind: string;\n fromKind: string;\n fromId: string;\n toKind: string;\n toId: string;\n}>;\n\n/**\n * Parameters for finding edges connected to a node.\n */\nexport type FindEdgesConnectedToParams = Readonly<{\n graphId: string;\n nodeKind: string;\n nodeId: string;\n}>;\n\n/**\n * Parameters for finding nodes by kind.\n */\nexport type FindNodesByKindParams = Readonly<{\n graphId: string;\n kind: string;\n /** Max rows to return. */\n limit?: number;\n /** Offset. Present for backward compat; rebuild uses `after` instead. */\n offset?: number;\n /** If true, exclude deleted nodes. Default true. */\n excludeDeleted?: boolean;\n /** Temporal mode for filtering by validity period. */\n temporalMode?: TemporalMode;\n /** Timestamp for \"current\" and \"asOf\" temporal modes. */\n asOf?: string;\n /**\n * Stable ordering for keyset pagination. Default: \"created_at\" (existing\n * behavior). Rebuild should use \"id\" for iteration that is stable under\n * concurrent writes and shared timestamps.\n */\n orderBy?: \"id\" | \"created_at\";\n /**\n * Keyset cursor. Returns rows strictly greater (by `orderBy`) than this\n * value. When `orderBy: \"id\"`, compared lexicographically. Mutually\n * exclusive with `offset` — callers pick one.\n */\n after?: string;\n}>;\n\n/**\n * Parameters for counting nodes by kind.\n */\nexport type CountNodesByKindParams = Readonly<{\n graphId: string;\n kind: string;\n /** If true, exclude deleted nodes. Default true. */\n excludeDeleted?: boolean;\n /** Temporal mode for filtering by validity period. */\n temporalMode?: TemporalMode;\n /** Timestamp for \"current\" and \"asOf\" temporal modes. */\n asOf?: string;\n}>;\n\n/**\n * Parameters for finding edges by kind.\n */\nexport type FindEdgesByKindParams = Readonly<{\n graphId: string;\n kind: string;\n fromKind?: string;\n fromId?: string;\n toKind?: string;\n toId?: string;\n limit?: number;\n offset?: number;\n /** If true, exclude deleted edges. Default true. */\n excludeDeleted?: boolean;\n /** Temporal mode for filtering by validity period. */\n temporalMode?: TemporalMode;\n /** Timestamp for \"current\" and \"asOf\" temporal modes. */\n asOf?: string;\n}>;\n\n/**\n * Parameters for counting edges by kind.\n */\nexport type CountEdgesByKindParams = Readonly<{\n graphId: string;\n kind: string;\n fromKind?: string;\n fromId?: string;\n toKind?: string;\n toId?: string;\n /** If true, exclude deleted edges. Default true. */\n excludeDeleted?: boolean;\n /** Temporal mode for filtering by validity period. */\n temporalMode?: TemporalMode;\n /** Timestamp for \"current\" and \"asOf\" temporal modes. */\n asOf?: string;\n}>;\n\n// ============================================================\n// Default Capabilities\n// ============================================================\n\n/**\n * Default capabilities for SQLite.\n */\nexport const SQLITE_CAPABILITIES: BackendCapabilities = {\n transactions: true, // SQLite supports transactions\n};\n\n/**\n * Default capabilities for PostgreSQL.\n */\nexport const POSTGRES_CAPABILITIES: BackendCapabilities = {\n transactions: true, // PostgreSQL supports transactions\n};\n"]}
|