@nicia-ai/typegraph 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/backend/postgres/index.cjs +19 -19
  2. package/dist/backend/postgres/index.d.cts +5 -5
  3. package/dist/backend/postgres/index.d.ts +5 -5
  4. package/dist/backend/postgres/index.js +9 -9
  5. package/dist/backend/postgres/pglite.cjs +14 -14
  6. package/dist/backend/postgres/pglite.d.cts +2 -2
  7. package/dist/backend/postgres/pglite.d.ts +2 -2
  8. package/dist/backend/postgres/pglite.js +9 -9
  9. package/dist/backend/sqlite/index.cjs +17 -17
  10. package/dist/backend/sqlite/index.d.cts +11 -6
  11. package/dist/backend/sqlite/index.d.ts +11 -6
  12. package/dist/backend/sqlite/index.js +8 -8
  13. package/dist/backend/sqlite/libsql.cjs +13 -13
  14. package/dist/backend/sqlite/libsql.d.cts +2 -2
  15. package/dist/backend/sqlite/libsql.d.ts +2 -2
  16. package/dist/backend/sqlite/libsql.js +9 -9
  17. package/dist/backend/sqlite/local.cjs +16 -15
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +8 -2
  20. package/dist/backend/sqlite/local.d.ts +8 -2
  21. package/dist/backend/sqlite/local.js +11 -10
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-UP4QAJND.cjs → chunk-26HWIIVS.cjs} +65 -65
  24. package/dist/{chunk-UP4QAJND.cjs.map → chunk-26HWIIVS.cjs.map} +1 -1
  25. package/dist/{chunk-GPUNAJFH.js → chunk-2QA5EHEN.js} +3 -3
  26. package/dist/{chunk-GPUNAJFH.js.map → chunk-2QA5EHEN.js.map} +1 -1
  27. package/dist/{chunk-CUZGBWFT.js → chunk-3IRMLJEK.js} +3 -3
  28. package/dist/{chunk-CUZGBWFT.js.map → chunk-3IRMLJEK.js.map} +1 -1
  29. package/dist/{chunk-MRMD7S7E.js → chunk-3JLRHQ67.js} +7 -7
  30. package/dist/{chunk-MRMD7S7E.js.map → chunk-3JLRHQ67.js.map} +1 -1
  31. package/dist/{chunk-UPBXUOW7.cjs → chunk-4BXHVEFB.cjs} +15 -15
  32. package/dist/{chunk-UPBXUOW7.cjs.map → chunk-4BXHVEFB.cjs.map} +1 -1
  33. package/dist/{chunk-RU5BBUU2.cjs → chunk-4LBO6KIF.cjs} +70 -67
  34. package/dist/chunk-4LBO6KIF.cjs.map +1 -0
  35. package/dist/{chunk-HKN622O4.js → chunk-633N7DSE.js} +9 -5
  36. package/dist/chunk-633N7DSE.js.map +1 -0
  37. package/dist/{chunk-R2LA6MKR.cjs → chunk-7JGLPAFV.cjs} +8 -8
  38. package/dist/{chunk-R2LA6MKR.cjs.map → chunk-7JGLPAFV.cjs.map} +1 -1
  39. package/dist/{chunk-7KLVFWXR.js → chunk-AI3RNREM.js} +30 -4
  40. package/dist/chunk-AI3RNREM.js.map +1 -0
  41. package/dist/{chunk-SFNUHFON.js → chunk-ENDUY2CD.js} +4 -4
  42. package/dist/{chunk-SFNUHFON.js.map → chunk-ENDUY2CD.js.map} +1 -1
  43. package/dist/{chunk-7V335GHG.cjs → chunk-FLRCVI2G.cjs} +12 -2
  44. package/dist/chunk-FLRCVI2G.cjs.map +1 -0
  45. package/dist/{chunk-IE2TPFBT.js → chunk-FVIGJTS7.js} +3 -3
  46. package/dist/{chunk-IE2TPFBT.js.map → chunk-FVIGJTS7.js.map} +1 -1
  47. package/dist/{chunk-Q5ASTPM4.cjs → chunk-FWBVPATK.cjs} +19 -19
  48. package/dist/{chunk-Q5ASTPM4.cjs.map → chunk-FWBVPATK.cjs.map} +1 -1
  49. package/dist/{chunk-KGAJ5HFO.cjs → chunk-IE6GN7L3.cjs} +17 -17
  50. package/dist/{chunk-KGAJ5HFO.cjs.map → chunk-IE6GN7L3.cjs.map} +1 -1
  51. package/dist/{chunk-A4H6QMV4.js → chunk-IUIJJYPI.js} +14 -11
  52. package/dist/chunk-IUIJJYPI.js.map +1 -0
  53. package/dist/{chunk-BMDF2S7S.js → chunk-IX7RE7CG.js} +3 -3
  54. package/dist/{chunk-BMDF2S7S.js.map → chunk-IX7RE7CG.js.map} +1 -1
  55. package/dist/{chunk-G6P3OVDY.cjs → chunk-JIEJCTDS.cjs} +18 -2
  56. package/dist/chunk-JIEJCTDS.cjs.map +1 -0
  57. package/dist/{chunk-XTQHSOIC.cjs → chunk-K4N35E7B.cjs} +86 -86
  58. package/dist/{chunk-XTQHSOIC.cjs.map → chunk-K4N35E7B.cjs.map} +1 -1
  59. package/dist/{chunk-NZ5PMBTG.js → chunk-K5P5OZXS.js} +12 -3
  60. package/dist/chunk-K5P5OZXS.js.map +1 -0
  61. package/dist/{chunk-Y52UNT66.js → chunk-K5VREXMZ.js} +7 -7
  62. package/dist/{chunk-Y52UNT66.js.map → chunk-K5VREXMZ.js.map} +1 -1
  63. package/dist/chunk-LUHU4T2F.cjs +12 -0
  64. package/dist/{chunk-Q3ZZLU3O.cjs.map → chunk-LUHU4T2F.cjs.map} +1 -1
  65. package/dist/{chunk-Z36W5WUM.js → chunk-MAQJYNJR.js} +3 -3
  66. package/dist/{chunk-Z36W5WUM.js.map → chunk-MAQJYNJR.js.map} +1 -1
  67. package/dist/{chunk-N3VVQDMA.js → chunk-MXE2U3EX.js} +3 -3
  68. package/dist/{chunk-N3VVQDMA.js.map → chunk-MXE2U3EX.js.map} +1 -1
  69. package/dist/{chunk-3DTLDGIM.js → chunk-N2OEOGBB.js} +6 -6
  70. package/dist/{chunk-3DTLDGIM.js.map → chunk-N2OEOGBB.js.map} +1 -1
  71. package/dist/{chunk-OGUH56BB.js → chunk-R4JOBEJU.js} +4 -4
  72. package/dist/{chunk-OGUH56BB.js.map → chunk-R4JOBEJU.js.map} +1 -1
  73. package/dist/{chunk-HM6XMR3E.cjs → chunk-SGPXKJ4A.cjs} +18 -18
  74. package/dist/{chunk-HM6XMR3E.cjs.map → chunk-SGPXKJ4A.cjs.map} +1 -1
  75. package/dist/{chunk-MB363HT5.js → chunk-TQOYM4LN.js} +18 -3
  76. package/dist/chunk-TQOYM4LN.js.map +1 -0
  77. package/dist/{chunk-C2RWFIYP.cjs → chunk-UESTHN47.cjs} +34 -6
  78. package/dist/chunk-UESTHN47.cjs.map +1 -0
  79. package/dist/{chunk-4K6IHUW6.cjs → chunk-VFX3LC76.cjs} +14 -14
  80. package/dist/{chunk-4K6IHUW6.cjs.map → chunk-VFX3LC76.cjs.map} +1 -1
  81. package/dist/{chunk-F2Q76CQ4.cjs → chunk-WEMZM7J7.cjs} +11 -7
  82. package/dist/chunk-WEMZM7J7.cjs.map +1 -0
  83. package/dist/{chunk-ZYQEXGYC.cjs → chunk-WFCECD6Q.cjs} +84 -84
  84. package/dist/{chunk-ZYQEXGYC.cjs.map → chunk-WFCECD6Q.cjs.map} +1 -1
  85. package/dist/{chunk-VGU26WIU.cjs → chunk-YQGLVWB2.cjs} +4 -4
  86. package/dist/{chunk-VGU26WIU.cjs.map → chunk-YQGLVWB2.cjs.map} +1 -1
  87. package/dist/{ddl-D3o-RmsV.d.cts → ddl-BSFlbGQF.d.cts} +3 -3
  88. package/dist/{ddl-BwH00BB6.d.ts → ddl-EdkIiFVU.d.ts} +3 -3
  89. package/dist/graph-extension/index.cjs +19 -19
  90. package/dist/graph-extension/index.d.cts +1 -1
  91. package/dist/graph-extension/index.d.ts +1 -1
  92. package/dist/graph-extension/index.js +4 -4
  93. package/dist/{index-CapHwi1a.d.ts → index-DzeIiMO3.d.ts} +9 -1
  94. package/dist/{index-jPPexxM5.d.cts → index-Ln_KHTGA.d.cts} +9 -1
  95. package/dist/index.cjs +780 -515
  96. package/dist/index.cjs.map +1 -1
  97. package/dist/index.d.cts +8 -8
  98. package/dist/index.d.ts +8 -8
  99. package/dist/index.js +314 -53
  100. package/dist/index.js.map +1 -1
  101. package/dist/indexes/index.cjs +18 -18
  102. package/dist/indexes/index.d.cts +4 -4
  103. package/dist/indexes/index.d.ts +4 -4
  104. package/dist/indexes/index.js +4 -4
  105. package/dist/interchange/index.cjs +7 -7
  106. package/dist/interchange/index.d.cts +3 -3
  107. package/dist/interchange/index.d.ts +3 -3
  108. package/dist/interchange/index.js +2 -2
  109. package/dist/{manager-BUugwCYz.d.ts → manager-BbdyNhkv.d.ts} +1 -1
  110. package/dist/{manager-DpIpn1HQ.d.cts → manager-wTDgjoXG.d.cts} +1 -1
  111. package/dist/{postgres-CQL9UIn2.d.cts → postgres-CK2ByP1q.d.cts} +1 -1
  112. package/dist/{postgres-CcRLaxz0.d.ts → postgres-ymXYC6Rr.d.ts} +1 -1
  113. package/dist/profiler/index.cjs +9 -9
  114. package/dist/profiler/index.d.cts +5 -5
  115. package/dist/profiler/index.d.ts +5 -5
  116. package/dist/profiler/index.js +2 -2
  117. package/dist/schema/index.cjs +31 -31
  118. package/dist/schema/index.d.cts +5 -5
  119. package/dist/schema/index.d.ts +5 -5
  120. package/dist/schema/index.js +8 -8
  121. package/dist/{sqlite-Rj3xu4It.d.cts → sqlite-DxH1lrwD.d.cts} +1 -1
  122. package/dist/{sqlite-CZDFUfHS.d.ts → sqlite-R8YGOqVQ.d.ts} +1 -1
  123. package/dist/{store-B43FpOVX.d.cts → store--z1Tmk7U.d.cts} +43 -3
  124. package/dist/{store-De0Y33wP.d.ts → store-CNKM334w.d.ts} +43 -3
  125. package/dist/{types-CmAT-Z47.d.ts → types-BBiDqJCU.d.ts} +2 -0
  126. package/dist/{types-B5GSeE3t.d.ts → types-CMvxx2kd.d.ts} +1 -1
  127. package/dist/{types-Bwlp_yvu.d.cts → types-D5B6Be5c.d.cts} +1 -1
  128. package/dist/{types-DXCSyxac.d.cts → types-dL-clxO3.d.cts} +2 -0
  129. package/dist/{where-CP4qGIHd.d.ts → where-CAo6wsBZ.d.ts} +1 -1
  130. package/dist/{where-2dsyYt3d.d.cts → where-bJjuOCeV.d.cts} +1 -1
  131. package/package.json +1 -1
  132. package/dist/chunk-7KLVFWXR.js.map +0 -1
  133. package/dist/chunk-7V335GHG.cjs.map +0 -1
  134. package/dist/chunk-A4H6QMV4.js.map +0 -1
  135. package/dist/chunk-C2RWFIYP.cjs.map +0 -1
  136. package/dist/chunk-F2Q76CQ4.cjs.map +0 -1
  137. package/dist/chunk-G6P3OVDY.cjs.map +0 -1
  138. package/dist/chunk-HKN622O4.js.map +0 -1
  139. package/dist/chunk-MB363HT5.js.map +0 -1
  140. package/dist/chunk-NZ5PMBTG.js.map +0 -1
  141. package/dist/chunk-Q3ZZLU3O.cjs +0 -12
  142. package/dist/chunk-RU5BBUU2.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
- import { G as GraphBackend } from '../../types-DXCSyxac.cjs';
3
- import { S as SqliteTables } from '../../sqlite-Rj3xu4It.cjs';
2
+ import { B as BackendCapabilities, G as GraphBackend } from '../../types-dL-clxO3.cjs';
3
+ import { S as SqliteTables } from '../../sqlite-DxH1lrwD.cjs';
4
4
  import 'zod';
5
5
  import '../../extension-types-CwHV-Uk4.cjs';
6
6
  import 'drizzle-orm';
@@ -21,6 +21,12 @@ type LocalSqliteBackendOptions = Readonly<{
21
21
  * Defaults to standard TypeGraph table names.
22
22
  */
23
23
  tables?: SqliteTables;
24
+ /**
25
+ * Override specific backend capabilities — e.g. to simulate an engine-level
26
+ * gap like missing SQL window functions in tests. Forwarded to
27
+ * createSqliteBackend.
28
+ */
29
+ capabilities?: Partial<BackendCapabilities>;
24
30
  }>;
25
31
  /**
26
32
  * Result of creating a local SQLite backend.
@@ -1,6 +1,6 @@
1
1
  import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
- import { G as GraphBackend } from '../../types-CmAT-Z47.js';
3
- import { S as SqliteTables } from '../../sqlite-CZDFUfHS.js';
2
+ import { B as BackendCapabilities, G as GraphBackend } from '../../types-BBiDqJCU.js';
3
+ import { S as SqliteTables } from '../../sqlite-R8YGOqVQ.js';
4
4
  import 'zod';
5
5
  import '../../extension-types-CwHV-Uk4.js';
6
6
  import 'drizzle-orm';
@@ -21,6 +21,12 @@ type LocalSqliteBackendOptions = Readonly<{
21
21
  * Defaults to standard TypeGraph table names.
22
22
  */
23
23
  tables?: SqliteTables;
24
+ /**
25
+ * Override specific backend capabilities — e.g. to simulate an engine-level
26
+ * gap like missing SQL window functions in tests. Forwarded to
27
+ * createSqliteBackend.
28
+ */
29
+ capabilities?: Partial<BackendCapabilities>;
24
30
  }>;
25
31
  /**
26
32
  * Result of creating a local SQLite backend.
@@ -1,14 +1,14 @@
1
- import { sqliteVecStrategy } from '../../chunk-GPUNAJFH.js';
2
- import { createSqliteBackend } from '../../chunk-A4H6QMV4.js';
3
- import { generateSqliteDDL } from '../../chunk-3DTLDGIM.js';
4
- import { tables, wrapWithManagedClose } from '../../chunk-HKN622O4.js';
1
+ import { sqliteVecStrategy } from '../../chunk-2QA5EHEN.js';
2
+ import { createSqliteBackend } from '../../chunk-IUIJJYPI.js';
3
+ import { generateSqliteDDL } from '../../chunk-N2OEOGBB.js';
4
+ import { tables, wrapWithManagedClose } from '../../chunk-633N7DSE.js';
5
5
  import '../../chunk-M6OC455F.js';
6
- import '../../chunk-7KLVFWXR.js';
7
- import '../../chunk-OGUH56BB.js';
8
- import '../../chunk-N3VVQDMA.js';
6
+ import '../../chunk-AI3RNREM.js';
7
+ import '../../chunk-R4JOBEJU.js';
8
+ import '../../chunk-MXE2U3EX.js';
9
9
  import '../../chunk-454I6GDF.js';
10
- import { ConfigurationError } from '../../chunk-MB363HT5.js';
11
- import '../../chunk-NZ5PMBTG.js';
10
+ import { ConfigurationError } from '../../chunk-TQOYM4LN.js';
11
+ import '../../chunk-K5P5OZXS.js';
12
12
  import { createRequire } from 'module';
13
13
  import Database from 'better-sqlite3';
14
14
  import { drizzle } from 'drizzle-orm/better-sqlite3';
@@ -67,7 +67,8 @@ function createLocalSqliteBackend(options = {}) {
67
67
  isSync: true
68
68
  },
69
69
  tables: tables2,
70
- ...hasSqliteVec ? { vector: sqliteVecStrategy } : {}
70
+ ...hasSqliteVec ? { vector: sqliteVecStrategy } : {},
71
+ ...options.capabilities ? { capabilities: options.capabilities } : {}
71
72
  });
72
73
  const managedBackend = wrapWithManagedClose(backend, () => {
73
74
  sqlite.close();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["tables"],"mappings":"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","file":"local.js","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport { sqliteVecStrategy } from \"../../query/dialect/vector/sqlite-vec-strategy\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport { type GraphBackend, wrapWithManagedClose } from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups.compiled);\n const required = Number(match.groups.required);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to\n // per-`(kind, field)` `vec0` storage. Without it, nodes with\n // `embedding()` fields validate and insert but their vectors are silently\n // dropped. When the user has installed sqlite-vec as a peer dep we load\n // it and wire the strategy; otherwise we proceed without vector support.\n const hasSqliteVec = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // Generate and execute DDL from schema\n const ddlStatements = generateSqliteDDL(tables);\n for (const statement of ddlStatements) {\n sqlite.exec(statement);\n }\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n ...(hasSqliteVec ? { vector: sqliteVecStrategy } : {}),\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: managedBackend, db };\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/backend/sqlite/local.ts"],"names":["tables"],"mappings":"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","file":"local.js","sourcesContent":["/**\n * Local SQLite backend using better-sqlite3.\n *\n * This module depends on the `better-sqlite3` native addon and should only\n * be imported in Node.js environments. For bundler-friendly SQLite DDL\n * generation and Drizzle backend creation, import from `@nicia-ai/typegraph/sqlite`.\n *\n * @example In-memory database (default)\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database for persistent local development\n * ```typescript\n * import { createLocalSqliteBackend } from \"@nicia-ai/typegraph/sqlite/local\";\n *\n * const { backend, db } = createLocalSqliteBackend({ path: \"./dev.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nimport { createRequire } from \"node:module\";\n\nimport Database from \"better-sqlite3\";\nimport {\n type BetterSQLite3Database,\n drizzle,\n} from \"drizzle-orm/better-sqlite3\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport { sqliteVecStrategy } from \"../../query/dialect/vector/sqlite-vec-strategy\";\nimport { generateSqliteDDL } from \"../drizzle/ddl\";\nimport {\n createSqliteBackend,\n type SqliteTables,\n tables as defaultTables,\n} from \"../drizzle/sqlite\";\nimport {\n type BackendCapabilities,\n type GraphBackend,\n wrapWithManagedClose,\n} from \"../types\";\n\nconst nodeRequire = createRequire(import.meta.url);\n\n// ============================================================\n// Native Addon Helpers\n// ============================================================\n\ntype NodeModuleVersionMismatch = Readonly<{\n compiled: number;\n required: number;\n}>;\n\nfunction getUnknownErrorMessage(error: unknown): string {\n if (error instanceof Error) return error.message;\n return String(error);\n}\n\nfunction parseNodeModuleVersionMismatchMessage(\n message: string,\n): NodeModuleVersionMismatch | undefined {\n const regexp =\n /NODE_MODULE_VERSION (?<compiled>\\d+)[\\s\\S]*?NODE_MODULE_VERSION (?<required>\\d+)/;\n const match = regexp.exec(message);\n if (!match?.groups) return undefined;\n\n const compiled = Number(match.groups.compiled);\n const required = Number(match.groups.required);\n\n if (!Number.isFinite(compiled) || !Number.isFinite(required))\n return undefined;\n\n return { compiled, required };\n}\n\nfunction createDatabase(path: string): Database.Database {\n try {\n return new Database(path);\n } catch (error) {\n const message = getUnknownErrorMessage(error);\n const mismatch = parseNodeModuleVersionMismatchMessage(message);\n if (!mismatch) throw error;\n\n throw new ConfigurationError(\n [\n \"Failed to load better-sqlite3 native addon.\",\n `It was compiled for NODE_MODULE_VERSION ${mismatch.compiled}, but this Node.js runtime requires ${mismatch.required}.`,\n \"This usually happens after switching Node versions without rebuilding native dependencies.\",\n \"Rebuild with: pnpm rebuild better-sqlite3 (or npm rebuild better-sqlite3).\",\n ].join(\" \"),\n {\n nodeVersion: process.version,\n nodeModuleVersion: process.versions.modules,\n compiledNodeModuleVersion: mismatch.compiled,\n requiredNodeModuleVersion: mismatch.required,\n },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local SQLite backend.\n */\nexport type LocalSqliteBackendOptions = Readonly<{\n /**\n * Path to the SQLite database file.\n * Defaults to \":memory:\" for an in-memory database.\n */\n path?: string;\n\n /**\n * Custom table definitions.\n * Defaults to standard TypeGraph table names.\n */\n tables?: SqliteTables;\n\n /**\n * Override specific backend capabilities — e.g. to simulate an engine-level\n * gap like missing SQL window functions in tests. Forwarded to\n * createSqliteBackend.\n */\n capabilities?: Partial<BackendCapabilities>;\n}>;\n\n/**\n * Result of creating a local SQLite backend.\n */\nexport type LocalSqliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore.\n */\n backend: GraphBackend;\n\n /**\n * The underlying Drizzle database instance.\n * Useful for direct SQL access or cleanup.\n */\n db: BetterSQLite3Database;\n}>;\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a SQLite backend with minimal configuration.\n *\n * This is a convenience function for local development and testing.\n * It handles database creation, schema migration, and backend setup.\n *\n * For production deployments or custom configurations, use createSqliteBackend\n * directly with your own Drizzle database instance.\n *\n * @param options - Configuration options\n * @returns Backend and database instances\n *\n * @example In-memory database (default)\n * ```typescript\n * const { backend } = createLocalSqliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example File-based database\n * ```typescript\n * const { backend, db } = createLocalSqliteBackend({ path: \"./data.db\" });\n * const store = createStore(graph, backend);\n * ```\n */\nexport function createLocalSqliteBackend(\n options: LocalSqliteBackendOptions = {},\n): LocalSqliteBackendResult {\n const path = options.path ?? \":memory:\";\n const tables = options.tables ?? defaultTables;\n\n const sqlite = createDatabase(path);\n\n // Best-effort: load sqlite-vec so embedding fields are persisted to\n // per-`(kind, field)` `vec0` storage. Without it, nodes with\n // `embedding()` fields validate and insert but their vectors are silently\n // dropped. When the user has installed sqlite-vec as a peer dep we load\n // it and wire the strategy; otherwise we proceed without vector support.\n const hasSqliteVec = tryLoadSqliteVec(sqlite);\n\n const db = drizzle(sqlite);\n\n // Generate and execute DDL from schema\n const ddlStatements = generateSqliteDDL(tables);\n for (const statement of ddlStatements) {\n sqlite.exec(statement);\n }\n\n const backend = createSqliteBackend(db, {\n executionProfile: {\n isSync: true,\n },\n tables,\n ...(hasSqliteVec ? { vector: sqliteVecStrategy } : {}),\n ...(options.capabilities ? { capabilities: options.capabilities } : {}),\n });\n const managedBackend = wrapWithManagedClose(backend, () => {\n sqlite.close();\n });\n\n return { backend: managedBackend, db };\n}\n\nfunction tryLoadSqliteVec(sqlite: Database.Database): boolean {\n try {\n // `sqlite-vec` is an optional peer dep; resolved via createRequire so\n // bundlers don't mark it as a hard import. Node resolves the package\n // only when it's actually installed.\n const module_: unknown = nodeRequire(\"sqlite-vec\");\n if (\n typeof module_ === \"object\" &&\n module_ !== null &&\n \"load\" in module_ &&\n typeof module_.load === \"function\"\n ) {\n (module_ as { load: (db: Database.Database) => void }).load(sqlite);\n return true;\n }\n return false;\n } catch {\n return false;\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkKGAJ5HFO_cjs = require('./chunk-KGAJ5HFO.cjs');
4
- var chunkZYQEXGYC_cjs = require('./chunk-ZYQEXGYC.cjs');
5
- var chunkF2Q76CQ4_cjs = require('./chunk-F2Q76CQ4.cjs');
3
+ var chunkIE6GN7L3_cjs = require('./chunk-IE6GN7L3.cjs');
4
+ var chunkWFCECD6Q_cjs = require('./chunk-WFCECD6Q.cjs');
5
+ var chunkWEMZM7J7_cjs = require('./chunk-WEMZM7J7.cjs');
6
6
  var chunkRP7YITHX_cjs = require('./chunk-RP7YITHX.cjs');
7
- var chunkC2RWFIYP_cjs = require('./chunk-C2RWFIYP.cjs');
8
- var chunkG6P3OVDY_cjs = require('./chunk-G6P3OVDY.cjs');
7
+ var chunkUESTHN47_cjs = require('./chunk-UESTHN47.cjs');
8
+ var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.cjs');
9
9
  var drizzleOrm = require('drizzle-orm');
10
10
  var pgCore = require('drizzle-orm/pg-core');
11
11
 
@@ -34,7 +34,7 @@ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
34
34
  var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
35
35
  var nextStatementId = 0;
36
36
  function statementNameFor(sqlText, cacheMax) {
37
- return chunkZYQEXGYC_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
37
+ return chunkWFCECD6Q_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
38
38
  const name = `tg_${nextStatementId}`;
39
39
  nextStatementId += 1;
40
40
  return name;
@@ -128,7 +128,7 @@ function createPostgresExecutionAdapter(db, options = {}) {
128
128
  const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
129
129
  const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
130
130
  function compile(query) {
131
- return chunkZYQEXGYC_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
131
+ return chunkWFCECD6Q_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
132
132
  }
133
133
  if (pgClient === void 0) {
134
134
  return {
@@ -184,24 +184,24 @@ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
184
184
  1,
185
185
  POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
186
186
  );
187
- var toNodeRow = chunkZYQEXGYC_cjs.createNodeRowMapper(chunkZYQEXGYC_cjs.POSTGRES_ROW_MAPPER_CONFIG);
188
- var toEdgeRow = chunkZYQEXGYC_cjs.createEdgeRowMapper(chunkZYQEXGYC_cjs.POSTGRES_ROW_MAPPER_CONFIG);
189
- var toUniqueRow = chunkZYQEXGYC_cjs.createUniqueRowMapper(chunkZYQEXGYC_cjs.POSTGRES_ROW_MAPPER_CONFIG);
190
- var toSchemaVersionRow = chunkZYQEXGYC_cjs.createSchemaVersionRowMapper(
191
- chunkZYQEXGYC_cjs.POSTGRES_ROW_MAPPER_CONFIG
187
+ var toNodeRow = chunkWFCECD6Q_cjs.createNodeRowMapper(chunkWFCECD6Q_cjs.POSTGRES_ROW_MAPPER_CONFIG);
188
+ var toEdgeRow = chunkWFCECD6Q_cjs.createEdgeRowMapper(chunkWFCECD6Q_cjs.POSTGRES_ROW_MAPPER_CONFIG);
189
+ var toUniqueRow = chunkWFCECD6Q_cjs.createUniqueRowMapper(chunkWFCECD6Q_cjs.POSTGRES_ROW_MAPPER_CONFIG);
190
+ var toSchemaVersionRow = chunkWFCECD6Q_cjs.createSchemaVersionRowMapper(
191
+ chunkWFCECD6Q_cjs.POSTGRES_ROW_MAPPER_CONFIG
192
192
  );
193
193
  function buildPostgresCapabilities(fulltextStrategy, vectorStrategy) {
194
194
  return {
195
- ...chunkF2Q76CQ4_cjs.POSTGRES_CAPABILITIES,
196
- ...vectorStrategy === void 0 ? {} : { vector: chunkC2RWFIYP_cjs.buildVectorCapabilities(vectorStrategy) },
197
- fulltext: chunkC2RWFIYP_cjs.buildFulltextCapabilities(fulltextStrategy)
195
+ ...chunkWEMZM7J7_cjs.POSTGRES_CAPABILITIES,
196
+ ...vectorStrategy === void 0 ? {} : { vector: chunkUESTHN47_cjs.buildVectorCapabilities(vectorStrategy) },
197
+ fulltext: chunkUESTHN47_cjs.buildFulltextCapabilities(fulltextStrategy)
198
198
  };
199
199
  }
200
200
  function createPostgresBackend(db, options = {}) {
201
- const tables2 = options.tables ?? chunkZYQEXGYC_cjs.tables;
202
- const fulltextStrategy = options.fulltext ?? chunkC2RWFIYP_cjs.tsvectorStrategy;
203
- const vectorStrategy = options.vector === false ? void 0 : options.vector ?? chunkKGAJ5HFO_cjs.pgvectorStrategy;
204
- const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunkZYQEXGYC_cjs.createVectorSlotLatch();
201
+ const tables2 = options.tables ?? chunkWFCECD6Q_cjs.tables;
202
+ const fulltextStrategy = options.fulltext ?? chunkUESTHN47_cjs.tsvectorStrategy;
203
+ const vectorStrategy = options.vector === false ? void 0 : options.vector ?? chunkIE6GN7L3_cjs.pgvectorStrategy;
204
+ const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunkWFCECD6Q_cjs.createVectorSlotLatch();
205
205
  const baseCapabilities = buildPostgresCapabilities(
206
206
  fulltextStrategy,
207
207
  vectorStrategy
@@ -229,10 +229,10 @@ function createPostgresBackend(db, options = {}) {
229
229
  tableNames.edges,
230
230
  drizzleOrm.getTableName(tables2.uniques),
231
231
  tableNames.fulltext
232
- ].map((name) => chunkKGAJ5HFO_cjs.quoteIdentifier(name)),
232
+ ].map((name) => chunkIE6GN7L3_cjs.quoteIdentifier(name)),
233
233
  drizzleOrm.sql`, `
234
234
  )}`;
235
- const operationStrategy = chunkZYQEXGYC_cjs.createPostgresOperationStrategy(
235
+ const operationStrategy = chunkWFCECD6Q_cjs.createPostgresOperationStrategy(
236
236
  tables2,
237
237
  fulltextStrategy
238
238
  );
@@ -249,7 +249,7 @@ function createPostgresBackend(db, options = {}) {
249
249
  });
250
250
  function runSchemaWriteTransaction(graphId, fn) {
251
251
  if (!capabilities.transactions) {
252
- throw new chunkG6P3OVDY_cjs.ConfigurationError(
252
+ throw new chunkJIEJCTDS_cjs.ConfigurationError(
253
253
  "commitSchemaVersion and setActiveVersion require atomic transactions, but this Postgres backend does not provide them. The drizzle-orm/neon-http driver communicates over HTTP and cannot hold a session across statements; use drizzle-orm/neon-serverless (websocket) for transactional writes.",
254
254
  {
255
255
  backend: "postgres",
@@ -273,7 +273,7 @@ function createPostgresBackend(db, options = {}) {
273
273
  }
274
274
  const matTable = tables2.contributionMaterializations;
275
275
  async function ensureContributionMaterializationsTableImpl() {
276
- await db.execute(drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generatePgCreateTableSQL(matTable)));
276
+ await db.execute(drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generatePgCreateTableSQL(matTable)));
277
277
  }
278
278
  async function getContributionMaterializationRow(identity) {
279
279
  const rows = await db.select().from(matTable).where(
@@ -286,16 +286,16 @@ function createPostgresBackend(db, options = {}) {
286
286
  );
287
287
  const row = rows[0];
288
288
  if (row === void 0) return void 0;
289
- return chunkZYQEXGYC_cjs.mapContributionMaterializationRow(
289
+ return chunkWFCECD6Q_cjs.mapContributionMaterializationRow(
290
290
  row,
291
- chunkZYQEXGYC_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.decode
291
+ chunkWFCECD6Q_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.decode
292
292
  );
293
293
  }
294
294
  async function recordContributionMaterializationRow(params) {
295
295
  await db.insert(matTable).values(
296
- chunkZYQEXGYC_cjs.buildContributionInsertValues(
296
+ chunkWFCECD6Q_cjs.buildContributionInsertValues(
297
297
  params,
298
- chunkZYQEXGYC_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.encode
298
+ chunkWFCECD6Q_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.encode
299
299
  )
300
300
  ).onConflictDoUpdate({
301
301
  target: [
@@ -304,13 +304,13 @@ function createPostgresBackend(db, options = {}) {
304
304
  matTable.owner,
305
305
  matTable.tableName
306
306
  ],
307
- set: chunkZYQEXGYC_cjs.buildContributionOnConflictSet(
307
+ set: chunkWFCECD6Q_cjs.buildContributionOnConflictSet(
308
308
  matTable.materializedAt,
309
309
  params.materializedAt
310
310
  )
311
311
  });
312
312
  }
313
- const contributionMaterializer = chunkZYQEXGYC_cjs.createContributionMaterializer({
313
+ const contributionMaterializer = chunkWFCECD6Q_cjs.createContributionMaterializer({
314
314
  dialect: "postgres",
315
315
  fulltextStrategy,
316
316
  fulltextTableName: tables2.fulltextTableName,
@@ -330,12 +330,12 @@ function createPostgresBackend(db, options = {}) {
330
330
  capabilities,
331
331
  fulltextStrategy,
332
332
  vectorStrategy});
333
- return chunkZYQEXGYC_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
333
+ return chunkWFCECD6Q_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
334
334
  }
335
335
  const backend = {
336
336
  ...operations,
337
337
  async bootstrapTables() {
338
- const statements = chunkZYQEXGYC_cjs.generatePostgresDDL(tables2, fulltextStrategy);
338
+ const statements = chunkWFCECD6Q_cjs.generatePostgresDDL(tables2, fulltextStrategy);
339
339
  for (const statement of statements) {
340
340
  await db.execute(drizzleOrm.sql.raw(statement));
341
341
  }
@@ -345,7 +345,7 @@ function createPostgresBackend(db, options = {}) {
345
345
  // uninitialized database throws `StoreNotInitializedError` loudly
346
346
  // rather than self-healing on a read/write path (#135). Shared
347
347
  // verbatim with the tx-scoped gate via `gateFulltextMethods`.
348
- ...chunkZYQEXGYC_cjs.gateFulltextMethods(
348
+ ...chunkWFCECD6Q_cjs.gateFulltextMethods(
349
349
  operations,
350
350
  contributionMaterializer.assertInitialized
351
351
  ),
@@ -354,7 +354,7 @@ function createPostgresBackend(db, options = {}) {
354
354
  },
355
355
  async ensureIndexMaterializationsTable() {
356
356
  await db.execute(
357
- drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
357
+ drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
358
358
  );
359
359
  },
360
360
  async getIndexMaterialization(indexName) {
@@ -362,26 +362,26 @@ function createPostgresBackend(db, options = {}) {
362
362
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
363
363
  const row = rows[0];
364
364
  if (row === void 0) return void 0;
365
- return chunkZYQEXGYC_cjs.mapMaterializationRow(row, chunkZYQEXGYC_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
365
+ return chunkWFCECD6Q_cjs.mapMaterializationRow(row, chunkWFCECD6Q_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
366
366
  },
367
367
  async getIndexMaterializations(statusKeys) {
368
368
  if (statusKeys.length === 0) return [];
369
369
  const t = tables2.indexMaterializations;
370
370
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
371
371
  return rows.map(
372
- (row) => chunkZYQEXGYC_cjs.mapMaterializationRow(row, chunkZYQEXGYC_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
372
+ (row) => chunkWFCECD6Q_cjs.mapMaterializationRow(row, chunkWFCECD6Q_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
373
373
  );
374
374
  },
375
375
  async recordIndexMaterialization(params) {
376
376
  const t = tables2.indexMaterializations;
377
377
  await db.insert(t).values(
378
- chunkZYQEXGYC_cjs.buildMaterializationInsertValues(
378
+ chunkWFCECD6Q_cjs.buildMaterializationInsertValues(
379
379
  params,
380
- chunkZYQEXGYC_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
380
+ chunkWFCECD6Q_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
381
381
  )
382
382
  ).onConflictDoUpdate({
383
383
  target: t.indexName,
384
- set: chunkZYQEXGYC_cjs.buildMaterializationOnConflictSet(
384
+ set: chunkWFCECD6Q_cjs.buildMaterializationOnConflictSet(
385
385
  t.materializedAt,
386
386
  params.materializedAt
387
387
  )
@@ -400,37 +400,37 @@ function createPostgresBackend(db, options = {}) {
400
400
  await contributionMaterializer.assertInitialized(graphId);
401
401
  },
402
402
  async ensureKindRemovalsTable() {
403
- await db.execute(drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generatePgCreateTableSQL(tables2.kindRemovals)));
403
+ await db.execute(drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generatePgCreateTableSQL(tables2.kindRemovals)));
404
404
  },
405
405
  async getPendingKindRemovals(graphId) {
406
406
  const t = tables2.kindRemovals;
407
407
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
408
408
  return rows.map(
409
- (row) => chunkZYQEXGYC_cjs.mapKindRemovalRow(row, chunkZYQEXGYC_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
409
+ (row) => chunkWFCECD6Q_cjs.mapKindRemovalRow(row, chunkWFCECD6Q_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
410
410
  );
411
411
  },
412
412
  async getAllKindRemovals(graphId) {
413
413
  const t = tables2.kindRemovals;
414
414
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
415
415
  return rows.map(
416
- (row) => chunkZYQEXGYC_cjs.mapKindRemovalRow(row, chunkZYQEXGYC_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
416
+ (row) => chunkWFCECD6Q_cjs.mapKindRemovalRow(row, chunkWFCECD6Q_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
417
417
  );
418
418
  },
419
419
  async recordKindRemoval(params) {
420
420
  const t = tables2.kindRemovals;
421
421
  await db.insert(t).values(
422
- chunkZYQEXGYC_cjs.buildKindRemovalInsertValues(
422
+ chunkWFCECD6Q_cjs.buildKindRemovalInsertValues(
423
423
  params,
424
- chunkZYQEXGYC_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
424
+ chunkWFCECD6Q_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
425
425
  )
426
426
  ).onConflictDoUpdate({
427
427
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
428
- set: chunkZYQEXGYC_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
428
+ set: chunkWFCECD6Q_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
429
429
  });
430
430
  },
431
431
  async ensureReconciliationMarkersTable() {
432
432
  await db.execute(
433
- drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
433
+ drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
434
434
  );
435
435
  },
436
436
  async ensureRuntimeContributions(graphId) {
@@ -482,7 +482,7 @@ function createPostgresBackend(db, options = {}) {
482
482
  },
483
483
  adoptTransaction(externalTx) {
484
484
  if (!capabilities.transactions) {
485
- throw new chunkG6P3OVDY_cjs.ConfigurationError(
485
+ throw new chunkJIEJCTDS_cjs.ConfigurationError(
486
486
  "Cross-store atomicity is unavailable on this Postgres backend: its driver does not support transactions (drizzle-orm/neon-http, Cloudflare D1). Adopting an external transaction here would let the caller's relational write commit with no way to roll back the graph write. Use a node-postgres or neon-serverless (Pool/WebSocket) connection for cross-store transactions.",
487
487
  {
488
488
  backend: "postgres",
@@ -491,7 +491,7 @@ function createPostgresBackend(db, options = {}) {
491
491
  }
492
492
  );
493
493
  }
494
- chunkZYQEXGYC_cjs.assertAdoptedDialect(externalTx, pgCore.PgDatabase, "postgres");
494
+ chunkWFCECD6Q_cjs.assertAdoptedDialect(externalTx, pgCore.PgDatabase, "postgres");
495
495
  return bindTransactionBackend(externalTx);
496
496
  },
497
497
  async close() {
@@ -566,7 +566,7 @@ function createPostgresOperationBackend(options) {
566
566
  await execRun(drizzleOrm.sql.raw(statement));
567
567
  });
568
568
  }
569
- const commonBackend = chunkZYQEXGYC_cjs.createCommonOperationBackend({
569
+ const commonBackend = chunkWFCECD6Q_cjs.createCommonOperationBackend({
570
570
  batchConfig: {
571
571
  checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
572
572
  edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
@@ -579,7 +579,7 @@ function createPostgresOperationBackend(options) {
579
579
  execGet,
580
580
  execRun
581
581
  },
582
- nowIso: chunkZYQEXGYC_cjs.nowIso,
582
+ nowIso: chunkWFCECD6Q_cjs.nowIso,
583
583
  operationStrategy,
584
584
  rowMappers: {
585
585
  toEdgeRow,
@@ -596,19 +596,19 @@ function createPostgresOperationBackend(options) {
596
596
  };
597
597
  const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
598
598
  async upsertEmbedding(params) {
599
- const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
599
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromParams(params);
600
600
  await ensureVectorSlotStorage(slot);
601
- const statements = vectorStrategy.buildUpsert(slot, params, chunkZYQEXGYC_cjs.nowIso());
601
+ const statements = vectorStrategy.buildUpsert(slot, params, chunkWFCECD6Q_cjs.nowIso());
602
602
  try {
603
603
  for (const statement of statements) {
604
604
  await execRun(statement);
605
605
  }
606
606
  } catch (error) {
607
- throw chunkZYQEXGYC_cjs.mapVectorWriteError(error, params);
607
+ throw chunkWFCECD6Q_cjs.mapVectorWriteError(error, params);
608
608
  }
609
609
  },
610
610
  async deleteEmbedding(params) {
611
- const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
611
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromParams(params);
612
612
  await ensureVectorSlotStorage(slot);
613
613
  const statements = vectorStrategy.buildDelete(slot, params);
614
614
  for (const statement of statements) {
@@ -616,16 +616,16 @@ function createPostgresOperationBackend(options) {
616
616
  }
617
617
  },
618
618
  async vectorSearch(params) {
619
- chunkC2RWFIYP_cjs.assertVectorSearchLimit(params.limit);
620
- chunkKGAJ5HFO_cjs.assertPgvectorEfSearch(params.efSearch);
621
- const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
619
+ chunkUESTHN47_cjs.assertVectorSearchLimit(params.limit);
620
+ chunkIE6GN7L3_cjs.assertPgvectorEfSearch(params.efSearch);
621
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromParams(params);
622
622
  await ensureVectorSlotStorage(slot);
623
623
  const query = vectorStrategy.buildSearch(slot, params);
624
624
  let rows;
625
625
  try {
626
626
  rows = await runVectorSearch(params.efSearch, query);
627
627
  } catch (error) {
628
- throw chunkZYQEXGYC_cjs.mapVectorWriteError(error, params);
628
+ throw chunkWFCECD6Q_cjs.mapVectorWriteError(error, params);
629
629
  }
630
630
  return rows.map((row) => ({
631
631
  nodeId: row.node_id,
@@ -645,7 +645,7 @@ function createPostgresOperationBackend(options) {
645
645
  // === Vector Index Operations ===
646
646
  async createVectorIndex(params) {
647
647
  if (vectorStrategy === void 0) return;
648
- const slot = chunkZYQEXGYC_cjs.vectorSlotFromCreateIndexParams(params);
648
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromCreateIndexParams(params);
649
649
  await ensureVectorSlotStorage(slot);
650
650
  const indexStatement = vectorStrategy.buildCreateIndex?.(slot, {
651
651
  concurrent: params.concurrent === true
@@ -656,7 +656,7 @@ function createPostgresOperationBackend(options) {
656
656
  },
657
657
  // === Fulltext Operations ===
658
658
  async upsertFulltext(params) {
659
- const timestamp = chunkZYQEXGYC_cjs.nowIso();
659
+ const timestamp = chunkWFCECD6Q_cjs.nowIso();
660
660
  const statements = operationStrategy.buildUpsertFulltext(
661
661
  params,
662
662
  timestamp
@@ -673,7 +673,7 @@ function createPostgresOperationBackend(options) {
673
673
  },
674
674
  async upsertFulltextBatch(params) {
675
675
  if (params.rows.length === 0) return;
676
- const timestamp = chunkZYQEXGYC_cjs.nowIso();
676
+ const timestamp = chunkWFCECD6Q_cjs.nowIso();
677
677
  const statements = operationStrategy.buildUpsertFulltextBatch(
678
678
  params,
679
679
  timestamp
@@ -694,14 +694,14 @@ function createPostgresOperationBackend(options) {
694
694
  const rows = await execAll(query);
695
695
  return rows.map((row, index) => ({
696
696
  nodeId: row.node_id,
697
- score: chunkZYQEXGYC_cjs.coerceNumericScore(row.score),
697
+ score: chunkWFCECD6Q_cjs.coerceNumericScore(row.score),
698
698
  rank: index + 1,
699
699
  ...row.snippet === null ? {} : { snippet: row.snippet }
700
700
  }));
701
701
  },
702
702
  async dropVectorIndex(params) {
703
703
  if (vectorStrategy === void 0) return;
704
- const slot = chunkZYQEXGYC_cjs.vectorSlotFromDropIndexParams(params);
704
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromDropIndexParams(params);
705
705
  const dropStatement = vectorStrategy.buildDropIndex?.(slot);
706
706
  if (dropStatement === void 0) return;
707
707
  try {
@@ -731,10 +731,10 @@ function createTransactionBackend(options) {
731
731
  capabilities: options.capabilities,
732
732
  fulltextStrategy: options.fulltextStrategy,
733
733
  vectorStrategy: options.vectorStrategy,
734
- vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : chunkZYQEXGYC_cjs.createVectorSlotLatch()
734
+ vectorSlotLatch: options.vectorStrategy === void 0 ? void 0 : chunkWFCECD6Q_cjs.createVectorSlotLatch()
735
735
  });
736
736
  }
737
737
 
738
738
  exports.createPostgresBackend = createPostgresBackend;
739
- //# sourceMappingURL=chunk-UP4QAJND.cjs.map
740
- //# sourceMappingURL=chunk-UP4QAJND.cjs.map
739
+ //# sourceMappingURL=chunk-26HWIIVS.cjs.map
740
+ //# sourceMappingURL=chunk-26HWIIVS.cjs.map