@nicia-ai/typegraph 0.25.0 → 0.26.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 (122) hide show
  1. package/dist/backend/postgres/index.cjs +167 -71
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +6 -8
  4. package/dist/backend/postgres/index.d.ts +6 -8
  5. package/dist/backend/postgres/index.js +119 -27
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/sqlite/index.cjs +16 -15
  8. package/dist/backend/sqlite/index.d.cts +11 -26
  9. package/dist/backend/sqlite/index.d.ts +11 -26
  10. package/dist/backend/sqlite/index.js +6 -5
  11. package/dist/backend/sqlite/libsql.cjs +9 -8
  12. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  13. package/dist/backend/sqlite/libsql.d.cts +4 -3
  14. package/dist/backend/sqlite/libsql.d.ts +4 -3
  15. package/dist/backend/sqlite/libsql.js +6 -5
  16. package/dist/backend/sqlite/libsql.js.map +1 -1
  17. package/dist/backend/sqlite/local.cjs +11 -10
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +4 -3
  20. package/dist/backend/sqlite/local.d.ts +4 -3
  21. package/dist/backend/sqlite/local.js +6 -5
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-LVCSL6A3.js → chunk-3W6AIFT2.js} +11 -34
  24. package/dist/chunk-3W6AIFT2.js.map +1 -0
  25. package/dist/chunk-4FJVSF3K.cjs +12 -0
  26. package/dist/{chunk-D2GO3RBL.cjs.map → chunk-4FJVSF3K.cjs.map} +1 -1
  27. package/dist/{chunk-7W3KAMVQ.cjs → chunk-4TJI44WP.cjs} +94 -119
  28. package/dist/chunk-4TJI44WP.cjs.map +1 -0
  29. package/dist/chunk-5H3BAMTB.js +32 -0
  30. package/dist/chunk-5H3BAMTB.js.map +1 -0
  31. package/dist/{chunk-OJ6IQVZG.js → chunk-DDVA4QBA.js} +177 -37
  32. package/dist/chunk-DDVA4QBA.js.map +1 -0
  33. package/dist/{chunk-7CDXX3QZ.cjs → chunk-DN4RUDF3.cjs} +2 -2
  34. package/dist/chunk-DN4RUDF3.cjs.map +1 -0
  35. package/dist/{chunk-NHQWXSTS.js → chunk-E5ROA3MN.js} +3 -3
  36. package/dist/{chunk-NHQWXSTS.js.map → chunk-E5ROA3MN.js.map} +1 -1
  37. package/dist/{chunk-FPCOUJSL.js → chunk-ENXJLDRK.js} +2 -2
  38. package/dist/chunk-ENXJLDRK.js.map +1 -0
  39. package/dist/chunk-IUIWCFG3.cjs +36 -0
  40. package/dist/chunk-IUIWCFG3.cjs.map +1 -0
  41. package/dist/{chunk-EG6TJ3I5.js → chunk-OYLF3IC7.js} +3 -3
  42. package/dist/{chunk-EG6TJ3I5.js.map → chunk-OYLF3IC7.js.map} +1 -1
  43. package/dist/{chunk-JTI5WT4P.cjs → chunk-PN37HVAV.cjs} +32 -10
  44. package/dist/chunk-PN37HVAV.cjs.map +1 -0
  45. package/dist/{chunk-RCAJZG67.cjs → chunk-PYJOBZR3.cjs} +10 -10
  46. package/dist/{chunk-RCAJZG67.cjs.map → chunk-PYJOBZR3.cjs.map} +1 -1
  47. package/dist/{chunk-WI5VRP3X.js → chunk-RF5EUQWS.js} +371 -47
  48. package/dist/chunk-RF5EUQWS.js.map +1 -0
  49. package/dist/{chunk-ZEMNF3QK.cjs → chunk-RVT2N4RF.cjs} +209 -69
  50. package/dist/chunk-RVT2N4RF.cjs.map +1 -0
  51. package/dist/{chunk-4BOWVUGQ.js → chunk-TSGBRPNE.js} +3 -3
  52. package/dist/{chunk-4BOWVUGQ.js.map → chunk-TSGBRPNE.js.map} +1 -1
  53. package/dist/{chunk-O2P3KAUT.cjs → chunk-TVUARC7S.cjs} +445 -110
  54. package/dist/chunk-TVUARC7S.cjs.map +1 -0
  55. package/dist/{chunk-DOTEN2FG.js → chunk-U5ROKVRF.js} +26 -3
  56. package/dist/chunk-U5ROKVRF.js.map +1 -0
  57. package/dist/{chunk-E5JZSEGJ.cjs → chunk-WFUN6DCM.cjs} +8 -8
  58. package/dist/{chunk-E5JZSEGJ.cjs.map → chunk-WFUN6DCM.cjs.map} +1 -1
  59. package/dist/{chunk-W5MTHMTE.cjs → chunk-YEDQLNVE.cjs} +26 -2
  60. package/dist/chunk-YEDQLNVE.cjs.map +1 -0
  61. package/dist/{chunk-YZZBDCLV.js → chunk-ZTREJOGB.js} +32 -11
  62. package/dist/chunk-ZTREJOGB.js.map +1 -0
  63. package/dist/{ddl-B2jjLjpR.d.cts → ddl-9kw8UADK.d.ts} +697 -29
  64. package/dist/{ddl-DpaeAKPp.d.ts → ddl-Cw82BPM4.d.cts} +697 -29
  65. package/dist/{extension-types-D07e_NTw.d.cts → extension-types-B78CZfA5.d.cts} +1 -1
  66. package/dist/{extension-types-D07e_NTw.d.ts → extension-types-B78CZfA5.d.ts} +1 -1
  67. package/dist/graph-extension/index.cjs +18 -18
  68. package/dist/graph-extension/index.d.cts +4 -4
  69. package/dist/graph-extension/index.d.ts +4 -4
  70. package/dist/graph-extension/index.js +3 -3
  71. package/dist/{index-CT6nvtxL.d.cts → index-Bilw0pYm.d.cts} +34 -3
  72. package/dist/{index-DQheiVQV.d.ts → index-CWdBFWbI.d.ts} +34 -3
  73. package/dist/index.cjs +460 -361
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +13 -11
  76. package/dist/index.d.ts +13 -11
  77. package/dist/index.js +131 -36
  78. package/dist/index.js.map +1 -1
  79. package/dist/indexes/index.cjs +13 -13
  80. package/dist/indexes/index.d.cts +5 -5
  81. package/dist/indexes/index.d.ts +5 -5
  82. package/dist/indexes/index.js +1 -1
  83. package/dist/interchange/index.cjs +7 -7
  84. package/dist/interchange/index.d.cts +7 -5
  85. package/dist/interchange/index.d.ts +7 -5
  86. package/dist/interchange/index.js +2 -2
  87. package/dist/{manager-BpjBW1JK.d.cts → manager-Aqzmztkb.d.cts} +11 -3
  88. package/dist/{manager-BKaPQbns.d.ts → manager-C3LxzPcX.d.ts} +11 -3
  89. package/dist/{materialize-indexes-BB9N5uQl.d.cts → materialize-indexes-BQfaAZKA.d.cts} +1 -1
  90. package/dist/{materialize-indexes-BYpU2RKh.d.ts → materialize-indexes-DFavFQah.d.ts} +1 -1
  91. package/dist/profiler/index.d.cts +9 -7
  92. package/dist/profiler/index.d.ts +9 -7
  93. package/dist/schema/index.cjs +28 -27
  94. package/dist/schema/index.cjs.map +1 -1
  95. package/dist/schema/index.d.cts +9 -7
  96. package/dist/schema/index.d.ts +9 -7
  97. package/dist/schema/index.js +6 -5
  98. package/dist/schema/index.js.map +1 -1
  99. package/dist/{sqlite-Myo8e3Lr.d.cts → sqlite-BvSEbybu.d.cts} +320 -1
  100. package/dist/{sqlite-CU3j6rc7.d.ts → sqlite-GKvcDPVn.d.ts} +320 -1
  101. package/dist/{store-BAGuOHDh.d.cts → store-CiS_AGNH.d.ts} +112 -4
  102. package/dist/{store-De98Lod4.d.ts → store-DbQLsSor.d.cts} +112 -4
  103. package/dist/{types-CYga3lZp.d.cts → types-CF7nDH3q.d.cts} +2 -2
  104. package/dist/{types-BLmJq4wI.d.ts → types-Cars4JZ1.d.ts} +2 -2
  105. package/dist/{types--0EslBx5.d.cts → types-DZPBXZOK.d.cts} +275 -8
  106. package/dist/{types-BNWYZ-0-.d.ts → types-Dzkr0Eqi.d.ts} +275 -8
  107. package/dist/{where-m1uWsdua.d.cts → where-BmtjfWuS.d.cts} +2 -2
  108. package/dist/{where-CluR73rs.d.ts → where-kk1Zz2En.d.ts} +2 -2
  109. package/package.json +3 -1
  110. package/dist/chunk-7CDXX3QZ.cjs.map +0 -1
  111. package/dist/chunk-7W3KAMVQ.cjs.map +0 -1
  112. package/dist/chunk-D2GO3RBL.cjs +0 -12
  113. package/dist/chunk-DOTEN2FG.js.map +0 -1
  114. package/dist/chunk-FPCOUJSL.js.map +0 -1
  115. package/dist/chunk-JTI5WT4P.cjs.map +0 -1
  116. package/dist/chunk-LVCSL6A3.js.map +0 -1
  117. package/dist/chunk-O2P3KAUT.cjs.map +0 -1
  118. package/dist/chunk-OJ6IQVZG.js.map +0 -1
  119. package/dist/chunk-W5MTHMTE.cjs.map +0 -1
  120. package/dist/chunk-WI5VRP3X.js.map +0 -1
  121. package/dist/chunk-YZZBDCLV.js.map +0 -1
  122. package/dist/chunk-ZEMNF3QK.cjs.map +0 -1
@@ -1,15 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkHTGDWIDE_cjs = require('../../chunk-HTGDWIDE.cjs');
4
- var chunkO2P3KAUT_cjs = require('../../chunk-O2P3KAUT.cjs');
5
- var chunk7CDXX3QZ_cjs = require('../../chunk-7CDXX3QZ.cjs');
6
- var chunkJTI5WT4P_cjs = require('../../chunk-JTI5WT4P.cjs');
4
+ var chunkTVUARC7S_cjs = require('../../chunk-TVUARC7S.cjs');
5
+ var chunkDN4RUDF3_cjs = require('../../chunk-DN4RUDF3.cjs');
6
+ require('../../chunk-IUIWCFG3.cjs');
7
+ var chunkPN37HVAV_cjs = require('../../chunk-PN37HVAV.cjs');
7
8
  require('../../chunk-CTHNVU6K.cjs');
8
9
  require('../../chunk-EK6RJ373.cjs');
9
10
  require('../../chunk-X3244EKP.cjs');
10
- var chunkW5MTHMTE_cjs = require('../../chunk-W5MTHMTE.cjs');
11
+ var chunkYEDQLNVE_cjs = require('../../chunk-YEDQLNVE.cjs');
11
12
  require('../../chunk-7V335GHG.cjs');
12
13
  var drizzleOrm = require('drizzle-orm');
14
+ var pgCore = require('drizzle-orm/pg-core');
13
15
 
14
16
  // src/backend/drizzle/execution/postgres-execution.ts
15
17
  function hasFunctionProperty(value, property) {
@@ -33,7 +35,7 @@ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
33
35
  var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
34
36
  var nextStatementId = 0;
35
37
  function statementNameFor(sqlText, cacheMax) {
36
- return chunkO2P3KAUT_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
38
+ return chunkTVUARC7S_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
37
39
  const name = `tg_${nextStatementId}`;
38
40
  nextStatementId += 1;
39
41
  return name;
@@ -124,7 +126,7 @@ function createPostgresExecutionAdapter(db, options = {}) {
124
126
  const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
125
127
  const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
126
128
  function compile(query) {
127
- return chunkO2P3KAUT_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
129
+ return chunkTVUARC7S_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
128
130
  }
129
131
  if (pgClient === void 0) {
130
132
  return {
@@ -180,10 +182,10 @@ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
180
182
  1,
181
183
  POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
182
184
  );
183
- var toNodeRow = chunkO2P3KAUT_cjs.createNodeRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
184
- var toEdgeRow = chunkO2P3KAUT_cjs.createEdgeRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
185
- var toUniqueRow = chunkO2P3KAUT_cjs.createUniqueRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
186
- var toSchemaVersionRow = chunkO2P3KAUT_cjs.createSchemaVersionRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
185
+ var toNodeRow = chunkTVUARC7S_cjs.createNodeRowMapper(chunkTVUARC7S_cjs.POSTGRES_ROW_MAPPER_CONFIG);
186
+ var toEdgeRow = chunkTVUARC7S_cjs.createEdgeRowMapper(chunkTVUARC7S_cjs.POSTGRES_ROW_MAPPER_CONFIG);
187
+ var toUniqueRow = chunkTVUARC7S_cjs.createUniqueRowMapper(chunkTVUARC7S_cjs.POSTGRES_ROW_MAPPER_CONFIG);
188
+ var toSchemaVersionRow = chunkTVUARC7S_cjs.createSchemaVersionRowMapper(chunkTVUARC7S_cjs.POSTGRES_ROW_MAPPER_CONFIG);
187
189
  function toEmbeddingRow(row) {
188
190
  let embedding;
189
191
  if (typeof row.embedding === "string") {
@@ -201,23 +203,13 @@ function toEmbeddingRow(row) {
201
203
  field_path: row.field_path,
202
204
  embedding,
203
205
  dimensions: row.dimensions,
204
- created_at: chunkO2P3KAUT_cjs.formatPostgresTimestamp(row.created_at) ?? "",
205
- updated_at: chunkO2P3KAUT_cjs.formatPostgresTimestamp(row.updated_at) ?? ""
206
+ created_at: chunkTVUARC7S_cjs.formatPostgresTimestamp(row.created_at) ?? "",
207
+ updated_at: chunkTVUARC7S_cjs.formatPostgresTimestamp(row.updated_at) ?? ""
206
208
  };
207
209
  }
208
- function coerceNumericScore(value) {
209
- if (typeof value === "number") return value;
210
- const parsed = Number.parseFloat(value);
211
- if (Number.isNaN(parsed)) {
212
- throw new TypeError(
213
- `Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`
214
- );
215
- }
216
- return parsed;
217
- }
218
210
  function buildPostgresCapabilities(strategy) {
219
211
  return {
220
- ...chunk7CDXX3QZ_cjs.POSTGRES_CAPABILITIES,
212
+ ...chunkDN4RUDF3_cjs.POSTGRES_CAPABILITIES,
221
213
  vector: {
222
214
  supported: true,
223
215
  metrics: ["cosine", "l2", "inner_product"],
@@ -225,12 +217,12 @@ function buildPostgresCapabilities(strategy) {
225
217
  maxDimensions: 16e3
226
218
  // pgvector limit
227
219
  },
228
- fulltext: chunkJTI5WT4P_cjs.buildFulltextCapabilities(strategy)
220
+ fulltext: chunkPN37HVAV_cjs.buildFulltextCapabilities(strategy)
229
221
  };
230
222
  }
231
223
  function createPostgresBackend(db, options = {}) {
232
- const tables2 = options.tables ?? chunkO2P3KAUT_cjs.tables;
233
- const fulltextStrategy = options.fulltext ?? chunkJTI5WT4P_cjs.tsvectorStrategy;
224
+ const tables2 = options.tables ?? chunkTVUARC7S_cjs.tables;
225
+ const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.tsvectorStrategy;
234
226
  const baseCapabilities = buildPostgresCapabilities(fulltextStrategy);
235
227
  const httpOnlyOverrides = isNeonHttpClient(db) ? { transactions: false } : {};
236
228
  const capabilities = {
@@ -260,7 +252,7 @@ function createPostgresBackend(db, options = {}) {
260
252
  ].map((name) => chunkHTGDWIDE_cjs.quoteIdentifier(name)),
261
253
  drizzleOrm.sql`, `
262
254
  )}`;
263
- const operationStrategy = chunkO2P3KAUT_cjs.createPostgresOperationStrategy(
255
+ const operationStrategy = chunkTVUARC7S_cjs.createPostgresOperationStrategy(
264
256
  tables2,
265
257
  fulltextStrategy
266
258
  );
@@ -274,7 +266,7 @@ function createPostgresBackend(db, options = {}) {
274
266
  });
275
267
  function runSchemaWriteTransaction(graphId, fn) {
276
268
  if (!capabilities.transactions) {
277
- throw new chunkW5MTHMTE_cjs.ConfigurationError(
269
+ throw new chunkYEDQLNVE_cjs.ConfigurationError(
278
270
  "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.",
279
271
  {
280
272
  backend: "postgres",
@@ -298,20 +290,90 @@ function createPostgresBackend(db, options = {}) {
298
290
  return fn(txBackend);
299
291
  });
300
292
  }
293
+ const matTable = tables2.contributionMaterializations;
294
+ async function ensureContributionMaterializationsTableImpl() {
295
+ await db.execute(drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generatePgCreateTableSQL(matTable)));
296
+ }
297
+ async function getContributionMaterializationRow(identity) {
298
+ const rows = await db.select().from(matTable).where(
299
+ drizzleOrm.and(
300
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
301
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
302
+ drizzleOrm.eq(matTable.owner, identity.owner),
303
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
304
+ )
305
+ );
306
+ const row = rows[0];
307
+ if (row === void 0) return void 0;
308
+ return chunkTVUARC7S_cjs.mapContributionMaterializationRow(
309
+ row,
310
+ chunkTVUARC7S_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.decode
311
+ );
312
+ }
313
+ async function recordContributionMaterializationRow(params) {
314
+ await db.insert(matTable).values(
315
+ chunkTVUARC7S_cjs.buildContributionInsertValues(
316
+ params,
317
+ chunkTVUARC7S_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.encode
318
+ )
319
+ ).onConflictDoUpdate({
320
+ target: [
321
+ matTable.graphId,
322
+ matTable.logicalName,
323
+ matTable.owner,
324
+ matTable.tableName
325
+ ],
326
+ set: chunkTVUARC7S_cjs.buildContributionOnConflictSet(
327
+ matTable.materializedAt,
328
+ params.materializedAt
329
+ )
330
+ });
331
+ }
332
+ const contributionMaterializer = chunkTVUARC7S_cjs.createContributionMaterializer({
333
+ dialect: "postgres",
334
+ fulltextStrategy,
335
+ fulltextTableName: tables2.fulltextTableName,
336
+ execDdl: async (statement) => {
337
+ await db.execute(drizzleOrm.sql.raw(statement));
338
+ },
339
+ ensureMarkerTable: ensureContributionMaterializationsTableImpl,
340
+ getMarker: getContributionMaterializationRow,
341
+ recordMarker: recordContributionMaterializationRow
342
+ });
343
+ function bindTransactionBackend(tx) {
344
+ const txBackend = createTransactionBackend({
345
+ db: tx,
346
+ adapterOptions,
347
+ operationStrategy,
348
+ tableNames,
349
+ capabilities,
350
+ fulltextStrategy
351
+ });
352
+ return chunkTVUARC7S_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
353
+ }
301
354
  const backend = {
302
355
  ...operations,
303
356
  async bootstrapTables() {
304
- const statements = chunkO2P3KAUT_cjs.generatePostgresDDL(tables2, fulltextStrategy);
357
+ const statements = chunkTVUARC7S_cjs.generatePostgresDDL(tables2, fulltextStrategy);
305
358
  for (const statement of statements) {
306
359
  await db.execute(drizzleOrm.sql.raw(statement));
307
360
  }
308
361
  },
362
+ // Every fulltext-touching method asserts the durable marker instead
363
+ // of lazily emitting DDL. Steady state performs zero ensure; an
364
+ // uninitialized database throws `StoreNotInitializedError` loudly
365
+ // rather than self-healing on a read/write path (#135). Shared
366
+ // verbatim with the tx-scoped gate via `gateFulltextMethods`.
367
+ ...chunkTVUARC7S_cjs.gateFulltextMethods(
368
+ operations,
369
+ contributionMaterializer.assertInitialized
370
+ ),
309
371
  async executeDdl(ddl) {
310
372
  await db.execute(drizzleOrm.sql.raw(ddl));
311
373
  },
312
374
  async ensureIndexMaterializationsTable() {
313
375
  await db.execute(
314
- drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
376
+ drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
315
377
  );
316
378
  },
317
379
  async getIndexMaterialization(indexName) {
@@ -319,67 +381,90 @@ function createPostgresBackend(db, options = {}) {
319
381
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
320
382
  const row = rows[0];
321
383
  if (row === void 0) return void 0;
322
- return chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
384
+ return chunkTVUARC7S_cjs.mapMaterializationRow(row, chunkTVUARC7S_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
323
385
  },
324
386
  async getIndexMaterializations(statusKeys) {
325
387
  if (statusKeys.length === 0) return [];
326
388
  const t = tables2.indexMaterializations;
327
389
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
328
390
  return rows.map(
329
- (row) => chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
391
+ (row) => chunkTVUARC7S_cjs.mapMaterializationRow(row, chunkTVUARC7S_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
330
392
  );
331
393
  },
332
394
  async recordIndexMaterialization(params) {
333
395
  const t = tables2.indexMaterializations;
334
396
  await db.insert(t).values(
335
- chunkO2P3KAUT_cjs.buildMaterializationInsertValues(
397
+ chunkTVUARC7S_cjs.buildMaterializationInsertValues(
336
398
  params,
337
- chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
399
+ chunkTVUARC7S_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
338
400
  )
339
401
  ).onConflictDoUpdate({
340
402
  target: t.indexName,
341
- set: chunkO2P3KAUT_cjs.buildMaterializationOnConflictSet(
403
+ set: chunkTVUARC7S_cjs.buildMaterializationOnConflictSet(
342
404
  t.materializedAt,
343
405
  params.materializedAt
344
406
  )
345
407
  });
346
408
  },
409
+ async ensureContributionMaterializationsTable() {
410
+ await ensureContributionMaterializationsTableImpl();
411
+ },
412
+ async getContributionMaterialization(identity) {
413
+ return getContributionMaterializationRow(identity);
414
+ },
415
+ async recordContributionMaterialization(params) {
416
+ await recordContributionMaterializationRow(params);
417
+ },
418
+ async assertRuntimeContributionsInitialized(graphId) {
419
+ await contributionMaterializer.assertInitialized(graphId);
420
+ },
347
421
  async ensureKindRemovalsTable() {
348
422
  await db.execute(
349
- drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.kindRemovals))
423
+ drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generatePgCreateTableSQL(tables2.kindRemovals))
350
424
  );
351
425
  },
352
426
  async getPendingKindRemovals(graphId) {
353
427
  const t = tables2.kindRemovals;
354
428
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
355
429
  return rows.map(
356
- (row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
430
+ (row) => chunkTVUARC7S_cjs.mapKindRemovalRow(row, chunkTVUARC7S_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
357
431
  );
358
432
  },
359
433
  async getAllKindRemovals(graphId) {
360
434
  const t = tables2.kindRemovals;
361
435
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
362
436
  return rows.map(
363
- (row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
437
+ (row) => chunkTVUARC7S_cjs.mapKindRemovalRow(row, chunkTVUARC7S_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
364
438
  );
365
439
  },
366
440
  async recordKindRemoval(params) {
367
441
  const t = tables2.kindRemovals;
368
442
  await db.insert(t).values(
369
- chunkO2P3KAUT_cjs.buildKindRemovalInsertValues(
443
+ chunkTVUARC7S_cjs.buildKindRemovalInsertValues(
370
444
  params,
371
- chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
445
+ chunkTVUARC7S_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
372
446
  )
373
447
  ).onConflictDoUpdate({
374
448
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
375
- set: chunkO2P3KAUT_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
449
+ set: chunkTVUARC7S_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
376
450
  });
377
451
  },
378
452
  async ensureReconciliationMarkersTable() {
379
453
  await db.execute(
380
- drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
454
+ drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
381
455
  );
382
456
  },
457
+ async ensureRuntimeContributions(graphId) {
458
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
459
+ },
460
+ /**
461
+ * Superseded by `ensureRuntimeContributions(graphId)` (#129).
462
+ * Retained as a thin back-compat wrapper for callers predating
463
+ * #129; #135 routed it through the durable-marker writer.
464
+ */
465
+ async ensureFulltextTable(graphId) {
466
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
467
+ },
383
468
  async getReconciliationMarker(graphId) {
384
469
  const t = tables2.reconciliationMarkers;
385
470
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
@@ -411,17 +496,24 @@ function createPostgresBackend(db, options = {}) {
411
496
  const txConfig = options2?.isolationLevel ? {
412
497
  isolationLevel: options2.isolationLevel.replace("_", " ")
413
498
  } : void 0;
414
- return db.transaction(async (tx) => {
415
- const txBackend = createTransactionBackend({
416
- db: tx,
417
- adapterOptions,
418
- operationStrategy,
419
- tableNames,
420
- capabilities,
421
- fulltextStrategy
422
- });
423
- return fn(txBackend);
424
- }, txConfig);
499
+ return db.transaction(
500
+ async (tx) => fn(bindTransactionBackend(tx), tx),
501
+ txConfig
502
+ );
503
+ },
504
+ adoptTransaction(externalTx) {
505
+ if (!capabilities.transactions) {
506
+ throw new chunkYEDQLNVE_cjs.ConfigurationError(
507
+ "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.",
508
+ {
509
+ backend: "postgres",
510
+ capability: "transactions",
511
+ supportsTransactions: false
512
+ }
513
+ );
514
+ }
515
+ chunkTVUARC7S_cjs.assertAdoptedDialect(externalTx, pgCore.PgDatabase, "postgres");
516
+ return bindTransactionBackend(externalTx);
425
517
  },
426
518
  async close() {
427
519
  }
@@ -447,7 +539,7 @@ function createPostgresOperationBackend(options) {
447
539
  async function execRun(query) {
448
540
  await executionAdapter.execute(query);
449
541
  }
450
- const commonBackend = chunkO2P3KAUT_cjs.createCommonOperationBackend({
542
+ const commonBackend = chunkTVUARC7S_cjs.createCommonOperationBackend({
451
543
  batchConfig: {
452
544
  checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
453
545
  edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
@@ -460,7 +552,7 @@ function createPostgresOperationBackend(options) {
460
552
  execGet,
461
553
  execRun
462
554
  },
463
- nowIso: chunkO2P3KAUT_cjs.nowIso,
555
+ nowIso: chunkTVUARC7S_cjs.nowIso,
464
556
  operationStrategy,
465
557
  rowMappers: {
466
558
  toEdgeRow,
@@ -484,7 +576,7 @@ function createPostgresOperationBackend(options) {
484
576
  tableNames,
485
577
  // === Embedding Operations ===
486
578
  async upsertEmbedding(params) {
487
- const timestamp = chunkO2P3KAUT_cjs.nowIso();
579
+ const timestamp = chunkTVUARC7S_cjs.nowIso();
488
580
  const query = operationStrategy.buildUpsertEmbedding(params, timestamp);
489
581
  await execRun(query);
490
582
  },
@@ -524,7 +616,7 @@ function createPostgresOperationBackend(options) {
524
616
  ...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists },
525
617
  ...params.concurrent === true ? { concurrent: true } : {}
526
618
  };
527
- const result = await chunkO2P3KAUT_cjs.createPostgresVectorIndex(db, indexOptions);
619
+ const result = await chunkTVUARC7S_cjs.createPostgresVectorIndex(db, indexOptions);
528
620
  if (!result.success) {
529
621
  throw new Error(
530
622
  result.message ?? "Failed to create PostgreSQL vector index"
@@ -533,7 +625,7 @@ function createPostgresOperationBackend(options) {
533
625
  },
534
626
  // === Fulltext Operations ===
535
627
  async upsertFulltext(params) {
536
- const timestamp = chunkO2P3KAUT_cjs.nowIso();
628
+ const timestamp = chunkTVUARC7S_cjs.nowIso();
537
629
  const statements = operationStrategy.buildUpsertFulltext(
538
630
  params,
539
631
  timestamp
@@ -550,7 +642,7 @@ function createPostgresOperationBackend(options) {
550
642
  },
551
643
  async upsertFulltextBatch(params) {
552
644
  if (params.rows.length === 0) return;
553
- const timestamp = chunkO2P3KAUT_cjs.nowIso();
645
+ const timestamp = chunkTVUARC7S_cjs.nowIso();
554
646
  const statements = operationStrategy.buildUpsertFulltextBatch(
555
647
  params,
556
648
  timestamp
@@ -571,7 +663,7 @@ function createPostgresOperationBackend(options) {
571
663
  const rows = await execAll(query);
572
664
  return rows.map((row, index) => ({
573
665
  nodeId: row.node_id,
574
- score: coerceNumericScore(row.score),
666
+ score: chunkTVUARC7S_cjs.coerceNumericScore(row.score),
575
667
  rank: index + 1,
576
668
  ...row.snippet === null ? {} : { snippet: row.snippet }
577
669
  }));
@@ -580,13 +672,13 @@ function createPostgresOperationBackend(options) {
580
672
  const metrics = capabilities.vector?.metrics ?? ["cosine"];
581
673
  await Promise.all(
582
674
  metrics.map(async (metric) => {
583
- const indexName = chunkO2P3KAUT_cjs.generateVectorIndexName(
675
+ const indexName = chunkTVUARC7S_cjs.generateVectorIndexName(
584
676
  params.graphId,
585
677
  params.nodeKind,
586
678
  params.fieldPath,
587
679
  metric
588
680
  );
589
- const result = await chunkO2P3KAUT_cjs.dropPostgresVectorIndex(db, indexName);
681
+ const result = await chunkTVUARC7S_cjs.dropPostgresVectorIndex(db, indexName);
590
682
  if (!result.success) {
591
683
  throw new Error(
592
684
  result.message ?? "Failed to drop PostgreSQL vector index"
@@ -619,39 +711,43 @@ function createTransactionBackend(options) {
619
711
 
620
712
  Object.defineProperty(exports, "createPostgresTables", {
621
713
  enumerable: true,
622
- get: function () { return chunkO2P3KAUT_cjs.createPostgresTables; }
714
+ get: function () { return chunkTVUARC7S_cjs.createPostgresTables; }
623
715
  });
624
716
  Object.defineProperty(exports, "edges", {
625
717
  enumerable: true,
626
- get: function () { return chunkO2P3KAUT_cjs.edges; }
718
+ get: function () { return chunkTVUARC7S_cjs.edges; }
627
719
  });
628
720
  Object.defineProperty(exports, "embeddings", {
629
721
  enumerable: true,
630
- get: function () { return chunkO2P3KAUT_cjs.embeddings; }
722
+ get: function () { return chunkTVUARC7S_cjs.embeddings; }
723
+ });
724
+ Object.defineProperty(exports, "fulltext", {
725
+ enumerable: true,
726
+ get: function () { return chunkTVUARC7S_cjs.fulltext; }
631
727
  });
632
728
  Object.defineProperty(exports, "generatePostgresDDL", {
633
729
  enumerable: true,
634
- get: function () { return chunkO2P3KAUT_cjs.generatePostgresDDL; }
730
+ get: function () { return chunkTVUARC7S_cjs.generatePostgresDDL; }
635
731
  });
636
732
  Object.defineProperty(exports, "generatePostgresMigrationSQL", {
637
733
  enumerable: true,
638
- get: function () { return chunkO2P3KAUT_cjs.generatePostgresMigrationSQL; }
734
+ get: function () { return chunkTVUARC7S_cjs.generatePostgresMigrationSQL; }
639
735
  });
640
736
  Object.defineProperty(exports, "nodes", {
641
737
  enumerable: true,
642
- get: function () { return chunkO2P3KAUT_cjs.nodes; }
738
+ get: function () { return chunkTVUARC7S_cjs.nodes; }
643
739
  });
644
740
  Object.defineProperty(exports, "schemaVersions", {
645
741
  enumerable: true,
646
- get: function () { return chunkO2P3KAUT_cjs.schemaVersions; }
742
+ get: function () { return chunkTVUARC7S_cjs.schemaVersions; }
647
743
  });
648
744
  Object.defineProperty(exports, "tables", {
649
745
  enumerable: true,
650
- get: function () { return chunkO2P3KAUT_cjs.tables; }
746
+ get: function () { return chunkTVUARC7S_cjs.tables; }
651
747
  });
652
748
  Object.defineProperty(exports, "uniques", {
653
749
  enumerable: true,
654
- get: function () { return chunkO2P3KAUT_cjs.uniques; }
750
+ get: function () { return chunkTVUARC7S_cjs.uniques; }
655
751
  });
656
752
  exports.createPostgresBackend = createPostgresBackend;
657
753
  //# sourceMappingURL=index.cjs.map