@nicia-ai/typegraph 0.25.1 → 0.27.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 +161 -113
  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 +116 -68
  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-4FJVSF3K.cjs +12 -0
  24. package/dist/{chunk-D2GO3RBL.cjs.map → chunk-4FJVSF3K.cjs.map} +1 -1
  25. package/dist/chunk-5H3BAMTB.js +32 -0
  26. package/dist/chunk-5H3BAMTB.js.map +1 -0
  27. package/dist/{chunk-CLEUFN2K.js → chunk-DDVA4QBA.js} +174 -78
  28. package/dist/chunk-DDVA4QBA.js.map +1 -0
  29. package/dist/{chunk-OECDVACY.cjs → chunk-DN4RUDF3.cjs} +2 -2
  30. package/dist/chunk-DN4RUDF3.cjs.map +1 -0
  31. package/dist/{chunk-NHQWXSTS.js → chunk-E5ROA3MN.js} +3 -3
  32. package/dist/{chunk-NHQWXSTS.js.map → chunk-E5ROA3MN.js.map} +1 -1
  33. package/dist/{chunk-CPFR3O7L.js → chunk-ENXJLDRK.js} +2 -2
  34. package/dist/chunk-ENXJLDRK.js.map +1 -0
  35. package/dist/chunk-IUIWCFG3.cjs +36 -0
  36. package/dist/chunk-IUIWCFG3.cjs.map +1 -0
  37. package/dist/{chunk-EG6TJ3I5.js → chunk-OYLF3IC7.js} +3 -3
  38. package/dist/{chunk-EG6TJ3I5.js.map → chunk-OYLF3IC7.js.map} +1 -1
  39. package/dist/{chunk-JTI5WT4P.cjs → chunk-PN37HVAV.cjs} +32 -10
  40. package/dist/chunk-PN37HVAV.cjs.map +1 -0
  41. package/dist/{chunk-RCAJZG67.cjs → chunk-PYJOBZR3.cjs} +10 -10
  42. package/dist/{chunk-RCAJZG67.cjs.map → chunk-PYJOBZR3.cjs.map} +1 -1
  43. package/dist/{chunk-PSKUWVCB.js → chunk-RF5EUQWS.js} +336 -36
  44. package/dist/chunk-RF5EUQWS.js.map +1 -0
  45. package/dist/{chunk-CLGC7AQ2.cjs → chunk-RVT2N4RF.cjs} +206 -110
  46. package/dist/chunk-RVT2N4RF.cjs.map +1 -0
  47. package/dist/{chunk-4BOWVUGQ.js → chunk-TSGBRPNE.js} +3 -3
  48. package/dist/{chunk-4BOWVUGQ.js.map → chunk-TSGBRPNE.js.map} +1 -1
  49. package/dist/{chunk-CQVNGKU7.cjs → chunk-TVUARC7S.cjs} +410 -100
  50. package/dist/chunk-TVUARC7S.cjs.map +1 -0
  51. package/dist/{chunk-DOTEN2FG.js → chunk-U5ROKVRF.js} +26 -3
  52. package/dist/chunk-U5ROKVRF.js.map +1 -0
  53. package/dist/{chunk-E5JZSEGJ.cjs → chunk-WFUN6DCM.cjs} +8 -8
  54. package/dist/{chunk-E5JZSEGJ.cjs.map → chunk-WFUN6DCM.cjs.map} +1 -1
  55. package/dist/{chunk-AAA2CR3P.js → chunk-X53YKGHR.js} +78 -37
  56. package/dist/chunk-X53YKGHR.js.map +1 -0
  57. package/dist/{chunk-W5MTHMTE.cjs → chunk-YEDQLNVE.cjs} +26 -2
  58. package/dist/chunk-YEDQLNVE.cjs.map +1 -0
  59. package/dist/{chunk-QMQYK3IF.cjs → chunk-ZGEMI7MJ.cjs} +163 -122
  60. package/dist/chunk-ZGEMI7MJ.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-BqMmpNor.d.ts → ddl-9kw8UADK.d.ts} +298 -12
  64. package/dist/{ddl-Bwjh8Hff.d.cts → ddl-Cw82BPM4.d.cts} +298 -12
  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 +482 -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 +153 -37
  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-Cy3dhwYO.d.cts → manager-CWa9cgwb.d.cts} +36 -9
  88. package/dist/{manager-sZkU2VPC.d.ts → manager-Cfcb2sJL.d.ts} +36 -9
  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 +32 -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-h6dta1IJ.d.ts → sqlite-BvSEbybu.d.cts} +320 -1
  100. package/dist/{sqlite-BhFswiAR.d.cts → sqlite-GKvcDPVn.d.ts} +320 -1
  101. package/dist/{store-BS_hehiz.d.ts → store-C57kdvAa.d.ts} +155 -5
  102. package/dist/{store-CkCvqRUf.d.cts → store-Ojf0NOKk.d.cts} +155 -5
  103. package/dist/{types-BpgACExN.d.cts → types-CF7nDH3q.d.cts} +2 -2
  104. package/dist/{types-Bz-Pi681.d.ts → types-Cars4JZ1.d.ts} +2 -2
  105. package/dist/{types-DptZHe-l.d.ts → types-DZPBXZOK.d.cts} +272 -14
  106. package/dist/{types-WF5ItKQu.d.cts → types-Dzkr0Eqi.d.ts} +272 -14
  107. package/dist/{where-DZYMiXVq.d.cts → where-BmtjfWuS.d.cts} +2 -2
  108. package/dist/{where-C40InMIp.d.ts → where-kk1Zz2En.d.ts} +2 -2
  109. package/package.json +3 -1
  110. package/dist/chunk-AAA2CR3P.js.map +0 -1
  111. package/dist/chunk-CLEUFN2K.js.map +0 -1
  112. package/dist/chunk-CLGC7AQ2.cjs.map +0 -1
  113. package/dist/chunk-CPFR3O7L.js.map +0 -1
  114. package/dist/chunk-CQVNGKU7.cjs.map +0 -1
  115. package/dist/chunk-D2GO3RBL.cjs +0 -12
  116. package/dist/chunk-DOTEN2FG.js.map +0 -1
  117. package/dist/chunk-JTI5WT4P.cjs.map +0 -1
  118. package/dist/chunk-OECDVACY.cjs.map +0 -1
  119. package/dist/chunk-PSKUWVCB.js.map +0 -1
  120. package/dist/chunk-QMQYK3IF.cjs.map +0 -1
  121. package/dist/chunk-W5MTHMTE.cjs.map +0 -1
  122. package/dist/chunk-YZZBDCLV.js.map +0 -1
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkJTI5WT4P_cjs = require('./chunk-JTI5WT4P.cjs');
3
+ var chunkIUIWCFG3_cjs = require('./chunk-IUIWCFG3.cjs');
4
+ var chunkPN37HVAV_cjs = require('./chunk-PN37HVAV.cjs');
4
5
  var chunkCTHNVU6K_cjs = require('./chunk-CTHNVU6K.cjs');
5
- var chunkW5MTHMTE_cjs = require('./chunk-W5MTHMTE.cjs');
6
+ var chunkYEDQLNVE_cjs = require('./chunk-YEDQLNVE.cjs');
6
7
  var drizzleOrm = require('drizzle-orm');
7
8
  var pgCore = require('drizzle-orm/pg-core');
8
9
  var sqliteCore = require('drizzle-orm/sqlite-core');
@@ -41,6 +42,7 @@ var DEFAULT_TABLE_NAMES = {
41
42
  embeddings: "typegraph_node_embeddings",
42
43
  fulltext: "typegraph_node_fulltext",
43
44
  indexMaterializations: "typegraph_index_materializations",
45
+ contributionMaterializations: "typegraph_contribution_materializations",
44
46
  kindRemovals: "typegraph_kind_removals",
45
47
  reconciliationMarkers: "typegraph_reconciliation_markers"
46
48
  };
@@ -72,7 +74,7 @@ function createPostgresTables(names = {}, options = {}) {
72
74
  ),
73
75
  pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
74
76
  pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
75
- ...chunkJTI5WT4P_cjs.buildPostgresNodeIndexBuilders(t, indexes)
77
+ ...chunkPN37HVAV_cjs.buildPostgresNodeIndexBuilders(t, indexes)
76
78
  ]
77
79
  );
78
80
  const edges3 = pgCore.pgTable(
@@ -131,7 +133,7 @@ function createPostgresTables(names = {}, options = {}) {
131
133
  t.fromId,
132
134
  t.validTo
133
135
  ),
134
- ...chunkJTI5WT4P_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
136
+ ...chunkPN37HVAV_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
135
137
  ]
136
138
  );
137
139
  const uniques3 = pgCore.pgTable(
@@ -249,6 +251,26 @@ function createPostgresTables(names = {}, options = {}) {
249
251
  },
250
252
  (t) => [pgCore.primaryKey({ columns: [t.graphId] })]
251
253
  );
254
+ const contributionMaterializations = pgCore.pgTable(
255
+ n.contributionMaterializations,
256
+ {
257
+ graphId: pgCore.text("graph_id").notNull(),
258
+ logicalName: pgCore.text("logical_name").notNull(),
259
+ owner: pgCore.text("owner").notNull(),
260
+ tableName: pgCore.text("table_name").notNull(),
261
+ signature: pgCore.text("signature").notNull(),
262
+ materializedAt: pgCore.timestamp("materialized_at", { withTimezone: true }),
263
+ lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
264
+ withTimezone: true
265
+ }).notNull(),
266
+ lastError: pgCore.text("last_error")
267
+ },
268
+ (t) => [
269
+ pgCore.primaryKey({
270
+ columns: [t.graphId, t.logicalName, t.owner, t.tableName]
271
+ })
272
+ ]
273
+ );
252
274
  const fulltext2 = pgCore.pgTable(
253
275
  n.fulltext,
254
276
  {
@@ -273,6 +295,7 @@ function createPostgresTables(names = {}, options = {}) {
273
295
  schemaVersions: schemaVersions3,
274
296
  embeddings: embeddings3,
275
297
  indexMaterializations,
298
+ contributionMaterializations,
276
299
  kindRemovals,
277
300
  reconciliationMarkers,
278
301
  fulltext: fulltext2,
@@ -296,6 +319,7 @@ var DEFAULT_TABLE_NAMES2 = {
296
319
  embeddings: "typegraph_node_embeddings",
297
320
  fulltext: "typegraph_node_fulltext",
298
321
  indexMaterializations: "typegraph_index_materializations",
322
+ contributionMaterializations: "typegraph_contribution_materializations",
299
323
  kindRemovals: "typegraph_kind_removals",
300
324
  reconciliationMarkers: "typegraph_reconciliation_markers"
301
325
  };
@@ -327,7 +351,7 @@ function createSqliteTables(names = {}, options = {}) {
327
351
  ),
328
352
  sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
329
353
  sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
330
- ...chunkJTI5WT4P_cjs.buildSqliteNodeIndexBuilders(t, indexes)
354
+ ...chunkPN37HVAV_cjs.buildSqliteNodeIndexBuilders(t, indexes)
331
355
  ]
332
356
  );
333
357
  const edges3 = sqliteCore.sqliteTable(
@@ -386,7 +410,7 @@ function createSqliteTables(names = {}, options = {}) {
386
410
  t.fromId,
387
411
  t.validTo
388
412
  ),
389
- ...chunkJTI5WT4P_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
413
+ ...chunkPN37HVAV_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
390
414
  ]
391
415
  );
392
416
  const uniques3 = sqliteCore.sqliteTable(
@@ -504,6 +528,24 @@ function createSqliteTables(names = {}, options = {}) {
504
528
  },
505
529
  (t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
506
530
  );
531
+ const contributionMaterializations = sqliteCore.sqliteTable(
532
+ n.contributionMaterializations,
533
+ {
534
+ graphId: sqliteCore.text("graph_id").notNull(),
535
+ logicalName: sqliteCore.text("logical_name").notNull(),
536
+ owner: sqliteCore.text("owner").notNull(),
537
+ tableName: sqliteCore.text("table_name").notNull(),
538
+ signature: sqliteCore.text("signature").notNull(),
539
+ materializedAt: sqliteCore.text("materialized_at"),
540
+ lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
541
+ lastError: sqliteCore.text("last_error")
542
+ },
543
+ (t) => [
544
+ sqliteCore.primaryKey({
545
+ columns: [t.graphId, t.logicalName, t.owner, t.tableName]
546
+ })
547
+ ]
548
+ );
507
549
  return {
508
550
  nodes: nodes3,
509
551
  edges: edges3,
@@ -511,6 +553,7 @@ function createSqliteTables(names = {}, options = {}) {
511
553
  schemaVersions: schemaVersions3,
512
554
  embeddings: embeddings3,
513
555
  indexMaterializations,
556
+ contributionMaterializations,
514
557
  kindRemovals,
515
558
  reconciliationMarkers,
516
559
  /**
@@ -578,9 +621,9 @@ function renderIndexColumn(col) {
578
621
  if (col && typeof col === "object" && "name" in col) {
579
622
  return `"${col.name}"`;
580
623
  }
581
- const sql14 = tryInlineSql(col);
582
- if (sql14 !== void 0) {
583
- return sql14;
624
+ const sql15 = tryInlineSql(col);
625
+ if (sql15 !== void 0) {
626
+ return sql15;
584
627
  }
585
628
  return "unknown";
586
629
  }
@@ -651,23 +694,37 @@ function generateSqliteCreateIndexSQL(table) {
651
694
  return statements;
652
695
  }
653
696
  function isSqliteTable(value) {
654
- return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
655
- typeof value !== "string";
697
+ return drizzleOrm.is(value, sqliteCore.SQLiteTable);
656
698
  }
657
- function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
658
- const statements = [];
659
- for (const table of Object.values(tables3)) {
699
+ function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
700
+ return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
701
+ }
702
+ function sqliteContributions(tables3 = tables2, fulltextStrategy = chunkPN37HVAV_cjs.fts5Strategy) {
703
+ const contributions = [];
704
+ for (const [key, table] of Object.entries(tables3)) {
660
705
  if (!isSqliteTable(table)) continue;
661
- statements.push(generateSqliteCreateTableSQL(table));
706
+ contributions.push({
707
+ logicalName: key,
708
+ owner: chunkPN37HVAV_cjs.BASE_CONTRIBUTION_OWNER,
709
+ tableName: sqliteCore.getTableConfig(table).name,
710
+ createDdl: [
711
+ generateSqliteCreateTableSQL(table),
712
+ ...generateSqliteCreateIndexSQL(table)
713
+ ],
714
+ runtimeEnsure: false
715
+ });
662
716
  }
663
- for (const table of Object.values(tables3)) {
664
- if (!isSqliteTable(table)) continue;
665
- statements.push(...generateSqliteCreateIndexSQL(table));
717
+ for (const declared of fulltextStrategy.ownedTables(
718
+ tables3.fulltextTableName
719
+ )) {
720
+ contributions.push(declared);
666
721
  }
667
- statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
668
- return statements;
722
+ return contributions;
669
723
  }
670
- function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
724
+ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkPN37HVAV_cjs.fts5Strategy) {
725
+ return sqliteContributions(tables3, fulltextStrategy).flatMap((contribution) => [...contribution.createDdl]);
726
+ }
727
+ function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkPN37HVAV_cjs.fts5Strategy) {
671
728
  return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
672
729
  }
673
730
  function getPgColumnType(column) {
@@ -750,24 +807,35 @@ function generatePgCreateIndexSQL(table) {
750
807
  return statements;
751
808
  }
752
809
  function isPgTable(value) {
753
- return typeof value === "object" && value !== null && typeof value !== "string";
810
+ return drizzleOrm.is(value, pgCore.PgTable);
754
811
  }
755
- function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
756
- const statements = [];
757
- for (const table of Object.values(tables3)) {
812
+ function postgresContributions(tables3 = tables, fulltextStrategy = chunkPN37HVAV_cjs.tsvectorStrategy) {
813
+ const contributions = [];
814
+ for (const [key, table] of Object.entries(tables3)) {
758
815
  if (!isPgTable(table)) continue;
759
816
  if (table === tables3.fulltext) continue;
760
- statements.push(generatePgCreateTableSQL(table));
817
+ contributions.push({
818
+ logicalName: key,
819
+ owner: chunkPN37HVAV_cjs.BASE_CONTRIBUTION_OWNER,
820
+ tableName: pgCore.getTableConfig(table).name,
821
+ createDdl: [
822
+ generatePgCreateTableSQL(table),
823
+ ...generatePgCreateIndexSQL(table)
824
+ ],
825
+ runtimeEnsure: false
826
+ });
761
827
  }
762
- for (const table of Object.values(tables3)) {
763
- if (!isPgTable(table)) continue;
764
- if (table === tables3.fulltext) continue;
765
- statements.push(...generatePgCreateIndexSQL(table));
828
+ for (const declared of fulltextStrategy.ownedTables(
829
+ tables3.fulltextTableName
830
+ )) {
831
+ contributions.push(declared);
766
832
  }
767
- statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
768
- return statements;
833
+ return contributions;
769
834
  }
770
- function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
835
+ function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkPN37HVAV_cjs.tsvectorStrategy) {
836
+ return postgresContributions(tables3, fulltextStrategy).flatMap((contribution) => [...contribution.createDdl]);
837
+ }
838
+ function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkPN37HVAV_cjs.tsvectorStrategy) {
771
839
  const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
772
840
  const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
773
841
  return `${extensionSql}
@@ -778,7 +846,7 @@ ${ddlSql}`;
778
846
  // src/backend/drizzle/row-mappers.ts
779
847
  function requireTimestamp(value, field) {
780
848
  if (value === void 0) {
781
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
849
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
782
850
  `Expected non-null ${field} timestamp`,
783
851
  { operation: "select", entity: "row" }
784
852
  );
@@ -787,7 +855,7 @@ function requireTimestamp(value, field) {
787
855
  }
788
856
  function asString(value, field) {
789
857
  if (typeof value !== "string") {
790
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
858
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
791
859
  `Expected ${field} to be string, got ${typeof value}`,
792
860
  { operation: "select", entity: "row" }
793
861
  );
@@ -796,7 +864,7 @@ function asString(value, field) {
796
864
  }
797
865
  function asNumber(value, field) {
798
866
  if (typeof value !== "number") {
799
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
867
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
800
868
  `Expected ${field} to be number, got ${typeof value}`,
801
869
  { operation: "select", entity: "row" }
802
870
  );
@@ -820,6 +888,16 @@ function formatPostgresTimestamp(value) {
820
888
  }
821
889
  return void 0;
822
890
  }
891
+ function coerceNumericScore(value) {
892
+ if (typeof value === "number") return value;
893
+ const parsed = Number.parseFloat(value);
894
+ if (Number.isNaN(parsed)) {
895
+ throw new TypeError(
896
+ `Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`
897
+ );
898
+ }
899
+ return parsed;
900
+ }
823
901
  function normalizeJsonColumn(value) {
824
902
  return typeof value === "string" ? value : JSON.stringify(value ?? {});
825
903
  }
@@ -827,7 +905,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
827
905
  formatTimestamp: (value) => {
828
906
  if (value === null || value === void 0) return;
829
907
  if (typeof value !== "string") {
830
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
908
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
831
909
  `Expected timestamp to be string, got ${typeof value}`,
832
910
  { operation: "select", entity: "row" }
833
911
  );
@@ -836,7 +914,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
836
914
  },
837
915
  normalizeJson: (value) => {
838
916
  if (typeof value !== "string") {
839
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
917
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
840
918
  `Expected JSON column to be string, got ${typeof value}`,
841
919
  { operation: "select", entity: "row" }
842
920
  );
@@ -904,6 +982,222 @@ function createSchemaVersionRowMapper(config) {
904
982
  };
905
983
  };
906
984
  }
985
+ var SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = {
986
+ decode: (value) => typeof value === "string" ? value : void 0,
987
+ encode: (value) => value
988
+ };
989
+ var POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS = {
990
+ decode: formatPostgresTimestamp,
991
+ encode: (value) => new Date(value)
992
+ };
993
+ function mapContributionMaterializationRow(row, decode) {
994
+ const lastAttemptedAt = decode(row.lastAttemptedAt);
995
+ if (lastAttemptedAt === void 0) {
996
+ throw new Error(
997
+ `contribution materialization row missing required last_attempted_at: ${row.graphId}/${row.logicalName}`
998
+ );
999
+ }
1000
+ return {
1001
+ graphId: row.graphId,
1002
+ logicalName: row.logicalName,
1003
+ owner: row.owner,
1004
+ tableName: row.tableName,
1005
+ signature: row.signature,
1006
+ materializedAt: decode(row.materializedAt),
1007
+ lastAttemptedAt,
1008
+ lastError: row.lastError ?? void 0
1009
+ };
1010
+ }
1011
+ function buildContributionInsertValues(params, encode) {
1012
+ return {
1013
+ graphId: params.graphId,
1014
+ logicalName: params.logicalName,
1015
+ owner: params.owner,
1016
+ tableName: params.tableName,
1017
+ signature: params.signature,
1018
+ materializedAt: params.materializedAt === void 0 ? void 0 : encode(params.materializedAt),
1019
+ lastAttemptedAt: encode(params.attemptedAt),
1020
+ lastError: params.error
1021
+ };
1022
+ }
1023
+ function buildContributionOnConflictSet(materializedAtColumn, paramsMaterializedAt) {
1024
+ const materializedAtSet = paramsMaterializedAt === void 0 ? drizzleOrm.sql`COALESCE(excluded.${drizzleOrm.sql.identifier("materialized_at")}, ${materializedAtColumn})` : drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("materialized_at")}`;
1025
+ return {
1026
+ signature: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("signature")}`,
1027
+ materializedAt: materializedAtSet,
1028
+ lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
1029
+ lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
1030
+ };
1031
+ }
1032
+ async function computeContributionSignature(dialect, identity, createDdl) {
1033
+ const hashable = {
1034
+ dialect,
1035
+ owner: identity.owner,
1036
+ logicalName: identity.logicalName,
1037
+ tableName: identity.tableName,
1038
+ createDdl
1039
+ };
1040
+ return chunkCTHNVU6K_cjs.sha256Hex(JSON.stringify(hashable, chunkIUIWCFG3_cjs.sortedReplacer), 16);
1041
+ }
1042
+ function evaluateContributionState(row, signature) {
1043
+ if (row === void 0) return "missing";
1044
+ if (row.lastError !== void 0) return "failed";
1045
+ if (row.signature !== signature) return "stale";
1046
+ if (row.materializedAt === void 0) return "missing";
1047
+ return "initialized";
1048
+ }
1049
+ function identityOf(graphId, contribution) {
1050
+ return {
1051
+ graphId,
1052
+ logicalName: contribution.logicalName,
1053
+ owner: contribution.owner,
1054
+ tableName: contribution.tableName
1055
+ };
1056
+ }
1057
+ function gateFulltextMethods(source, assert) {
1058
+ const gated = {};
1059
+ if (source.upsertFulltext) {
1060
+ const raw = source.upsertFulltext;
1061
+ gated.upsertFulltext = async (params) => {
1062
+ await assert(params.graphId);
1063
+ await raw(params);
1064
+ };
1065
+ }
1066
+ if (source.deleteFulltext) {
1067
+ const raw = source.deleteFulltext;
1068
+ gated.deleteFulltext = async (params) => {
1069
+ await assert(params.graphId);
1070
+ await raw(params);
1071
+ };
1072
+ }
1073
+ if (source.upsertFulltextBatch) {
1074
+ const raw = source.upsertFulltextBatch;
1075
+ gated.upsertFulltextBatch = async (params) => {
1076
+ if (params.rows.length === 0) return;
1077
+ await assert(params.graphId);
1078
+ await raw(params);
1079
+ };
1080
+ }
1081
+ if (source.deleteFulltextBatch) {
1082
+ const raw = source.deleteFulltextBatch;
1083
+ gated.deleteFulltextBatch = async (params) => {
1084
+ if (params.nodeIds.length === 0) return;
1085
+ await assert(params.graphId);
1086
+ await raw(params);
1087
+ };
1088
+ }
1089
+ if (source.fulltextSearch) {
1090
+ const raw = source.fulltextSearch;
1091
+ gated.fulltextSearch = async (params) => {
1092
+ await assert(params.graphId);
1093
+ return raw(params);
1094
+ };
1095
+ }
1096
+ const rawHardDelete = source.hardDeleteNode;
1097
+ gated.hardDeleteNode = async (params) => {
1098
+ await assert(params.graphId);
1099
+ await rawHardDelete(params);
1100
+ };
1101
+ return gated;
1102
+ }
1103
+ function gateFulltext(tx, assert) {
1104
+ return { ...tx, ...gateFulltextMethods(tx, assert) };
1105
+ }
1106
+ function createContributionMaterializer(deps) {
1107
+ const { dialect, fulltextStrategy, fulltextTableName } = deps;
1108
+ const initializedGraphIds = /* @__PURE__ */ new Set();
1109
+ function runtimeContributions() {
1110
+ return runtimeStrategyContributions(fulltextStrategy, fulltextTableName);
1111
+ }
1112
+ async function materializeOne(graphId, contribution) {
1113
+ const signature = await computeContributionSignature(
1114
+ dialect,
1115
+ contribution,
1116
+ contribution.createDdl
1117
+ );
1118
+ const identity = identityOf(graphId, contribution);
1119
+ const existing = await deps.getMarker(identity);
1120
+ if (evaluateContributionState(existing, signature) === "initialized") {
1121
+ return;
1122
+ }
1123
+ const priorSuccess = existing?.materializedAt !== void 0;
1124
+ if (priorSuccess && existing.signature !== signature) {
1125
+ const error = new Error(
1126
+ `Contribution "${contribution.logicalName}" (owner "${contribution.owner}", table "${contribution.tableName}") was already materialized with a different signature. The recorded physical shape is stale relative to the current strategy/DDL \u2014 migrate or drop the table and retry, or restore the original strategy.`
1127
+ );
1128
+ await deps.recordMarker({
1129
+ ...identity,
1130
+ signature,
1131
+ attemptedAt: nowIso(),
1132
+ materializedAt: void 0,
1133
+ error: error.message
1134
+ });
1135
+ throw error;
1136
+ }
1137
+ const attemptedAt = nowIso();
1138
+ try {
1139
+ for (const statement of contribution.createDdl) {
1140
+ await deps.execDdl(statement);
1141
+ }
1142
+ } catch (error) {
1143
+ await deps.recordMarker({
1144
+ ...identity,
1145
+ signature,
1146
+ attemptedAt,
1147
+ materializedAt: void 0,
1148
+ error: error instanceof Error ? error.message : String(error)
1149
+ });
1150
+ throw error;
1151
+ }
1152
+ await deps.recordMarker({
1153
+ ...identity,
1154
+ signature,
1155
+ attemptedAt,
1156
+ materializedAt: attemptedAt,
1157
+ error: void 0
1158
+ });
1159
+ }
1160
+ async function ensureRuntimeContributions(graphId) {
1161
+ if (initializedGraphIds.has(graphId)) return;
1162
+ const contributions = runtimeContributions();
1163
+ if (contributions.length > 0) {
1164
+ await deps.ensureMarkerTable();
1165
+ for (const contribution of contributions) {
1166
+ await materializeOne(graphId, contribution);
1167
+ }
1168
+ }
1169
+ initializedGraphIds.add(graphId);
1170
+ }
1171
+ async function assertInitialized(graphId) {
1172
+ if (initializedGraphIds.has(graphId)) return;
1173
+ for (const contribution of runtimeContributions()) {
1174
+ const signature = await computeContributionSignature(
1175
+ dialect,
1176
+ contribution,
1177
+ contribution.createDdl
1178
+ );
1179
+ const identity = identityOf(graphId, contribution);
1180
+ let existing;
1181
+ try {
1182
+ existing = await deps.getMarker(identity);
1183
+ } catch (error) {
1184
+ if (!chunkIUIWCFG3_cjs.isMissingTableError(error)) throw error;
1185
+ throw new chunkYEDQLNVE_cjs.StoreNotInitializedError(graphId, "missing", {
1186
+ cause: error,
1187
+ details: { logicalName: contribution.logicalName }
1188
+ });
1189
+ }
1190
+ const state = evaluateContributionState(existing, signature);
1191
+ if (state !== "initialized") {
1192
+ throw new chunkYEDQLNVE_cjs.StoreNotInitializedError(graphId, state, {
1193
+ details: { logicalName: contribution.logicalName }
1194
+ });
1195
+ }
1196
+ }
1197
+ initializedGraphIds.add(graphId);
1198
+ }
1199
+ return { ensureRuntimeContributions, assertInitialized };
1200
+ }
907
1201
  var SQLITE_INDEX_MAT_TIMESTAMPS = {
908
1202
  decode: (value) => typeof value === "string" ? value : void 0,
909
1203
  encode: (value) => value
@@ -1003,8 +1297,14 @@ function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
1003
1297
  lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
1004
1298
  };
1005
1299
  }
1006
-
1007
- // src/backend/drizzle/operation-backend-core.ts
1300
+ function assertAdoptedDialect(externalTx, brand, backend) {
1301
+ if (drizzleOrm.is(externalTx, brand)) return;
1302
+ const label = backend === "postgres" ? "Postgres" : "SQLite";
1303
+ throw new chunkYEDQLNVE_cjs.ConfigurationError(
1304
+ `adoptTransaction received a handle that is not a ${label} Drizzle transaction. Pass the \`tx\` from a ${label} \`db.transaction(...)\` opened on this backend's connection.`,
1305
+ { backend, capability: "adoptTransaction" }
1306
+ );
1307
+ }
1008
1308
  function chunkArray(values, size) {
1009
1309
  if (values.length <= size) {
1010
1310
  return [values];
@@ -1018,7 +1318,7 @@ function chunkArray(values, size) {
1018
1318
  function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
1019
1319
  const expectedVersion = expected.kind === "active" ? expected.version : 0;
1020
1320
  if (actualActiveVersion !== expectedVersion) {
1021
- throw new chunkW5MTHMTE_cjs.StaleVersionError({
1321
+ throw new chunkYEDQLNVE_cjs.StaleVersionError({
1022
1322
  graphId,
1023
1323
  expected: expectedVersion,
1024
1324
  actual: actualActiveVersion
@@ -1039,7 +1339,7 @@ function createCommonOperationBackend(options) {
1039
1339
  const timestamp2 = nowIso2();
1040
1340
  const query = operationStrategy.buildInsertNode(params, timestamp2);
1041
1341
  const row = await execution.execGet(query);
1042
- if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
1342
+ if (!row) throw new chunkYEDQLNVE_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
1043
1343
  return rowMappers.toNodeRow(row);
1044
1344
  },
1045
1345
  async insertNodeNoReturn(params) {
@@ -1089,7 +1389,7 @@ function createCommonOperationBackend(options) {
1089
1389
  const timestamp2 = nowIso2();
1090
1390
  const query = operationStrategy.buildUpdateNode(params, timestamp2);
1091
1391
  const row = await execution.execGet(query);
1092
- if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
1392
+ if (!row) throw new chunkYEDQLNVE_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
1093
1393
  return rowMappers.toNodeRow(row);
1094
1394
  },
1095
1395
  async deleteNode(params) {
@@ -1132,7 +1432,7 @@ function createCommonOperationBackend(options) {
1132
1432
  const timestamp2 = nowIso2();
1133
1433
  const query = operationStrategy.buildInsertEdge(params, timestamp2);
1134
1434
  const row = await execution.execGet(query);
1135
- if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
1435
+ if (!row) throw new chunkYEDQLNVE_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
1136
1436
  return rowMappers.toEdgeRow(row);
1137
1437
  },
1138
1438
  async insertEdgeNoReturn(params) {
@@ -1182,7 +1482,7 @@ function createCommonOperationBackend(options) {
1182
1482
  const timestamp2 = nowIso2();
1183
1483
  const query = operationStrategy.buildUpdateEdge(params, timestamp2);
1184
1484
  const row = await execution.execGet(query);
1185
- if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
1485
+ if (!row) throw new chunkYEDQLNVE_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
1186
1486
  return rowMappers.toEdgeRow(row);
1187
1487
  },
1188
1488
  async deleteEdge(params) {
@@ -1233,7 +1533,7 @@ function createCommonOperationBackend(options) {
1233
1533
  const query = operationStrategy.buildInsertUnique(params);
1234
1534
  const result = await execution.execGet(query);
1235
1535
  if (result && result.node_id !== params.nodeId) {
1236
- throw new chunkW5MTHMTE_cjs.UniquenessError({
1536
+ throw new chunkYEDQLNVE_cjs.UniquenessError({
1237
1537
  constraintName: params.constraintName,
1238
1538
  kind: params.nodeKind,
1239
1539
  existingId: result.node_id,
@@ -1283,7 +1583,7 @@ function createCommonOperationBackend(options) {
1283
1583
  if (existingRaw !== void 0) {
1284
1584
  const existing = rowMappers.toSchemaVersionRow(existingRaw);
1285
1585
  if (existing.schema_hash !== params.schemaHash) {
1286
- throw new chunkW5MTHMTE_cjs.SchemaContentConflictError({
1586
+ throw new chunkYEDQLNVE_cjs.SchemaContentConflictError({
1287
1587
  graphId: params.graphId,
1288
1588
  version: params.version,
1289
1589
  existingHash: existing.schema_hash,
@@ -1331,7 +1631,7 @@ function createCommonOperationBackend(options) {
1331
1631
  );
1332
1632
  const insertedRaw = await execution.execGet(insertQuery);
1333
1633
  if (!insertedRaw) {
1334
- throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
1634
+ throw new chunkYEDQLNVE_cjs.DatabaseOperationError(
1335
1635
  "Insert schema failed: no row returned",
1336
1636
  { operation: "insert", entity: "schema" }
1337
1637
  );
@@ -1352,7 +1652,7 @@ function createCommonOperationBackend(options) {
1352
1652
  )
1353
1653
  );
1354
1654
  if (!targetRaw) {
1355
- throw new chunkW5MTHMTE_cjs.MigrationError(
1655
+ throw new chunkYEDQLNVE_cjs.MigrationError(
1356
1656
  `Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
1357
1657
  {
1358
1658
  graphId: params.graphId,
@@ -1377,7 +1677,7 @@ function createCommonOperationBackend(options) {
1377
1677
  };
1378
1678
  }
1379
1679
  function buildClearGraph(tables3, graphId) {
1380
- const fulltext2 = chunkJTI5WT4P_cjs.quotedTableName(tables3.fulltextTableName);
1680
+ const fulltext2 = chunkPN37HVAV_cjs.quotedTableName(tables3.fulltextTableName);
1381
1681
  return [
1382
1682
  drizzleOrm.sql`DELETE FROM ${fulltext2} WHERE "graph_id" = ${graphId}`,
1383
1683
  drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
@@ -1527,13 +1827,13 @@ function buildCountEdgesByKind(tables3, params) {
1527
1827
  function buildInsertEdge(tables3, params, timestamp2) {
1528
1828
  const { edges: edges3 } = tables3;
1529
1829
  const propsJson = JSON.stringify(params.props);
1530
- const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
1830
+ const columns = chunkPN37HVAV_cjs.edgeColumnList(edges3);
1531
1831
  return drizzleOrm.sql`
1532
1832
  INSERT INTO ${edges3} (${columns})
1533
1833
  VALUES (
1534
1834
  ${params.graphId}, ${params.id}, ${params.kind},
1535
1835
  ${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
1536
- ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
1836
+ ${propsJson}, ${chunkPN37HVAV_cjs.sqlNull(params.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(params.validTo)},
1537
1837
  ${timestamp2}, ${timestamp2}
1538
1838
  )
1539
1839
  RETURNING *
@@ -1542,23 +1842,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
1542
1842
  function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
1543
1843
  const { edges: edges3 } = tables3;
1544
1844
  const propsJson = JSON.stringify(params.props);
1545
- const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
1845
+ const columns = chunkPN37HVAV_cjs.edgeColumnList(edges3);
1546
1846
  return drizzleOrm.sql`
1547
1847
  INSERT INTO ${edges3} (${columns})
1548
1848
  VALUES (
1549
1849
  ${params.graphId}, ${params.id}, ${params.kind},
1550
1850
  ${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
1551
- ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
1851
+ ${propsJson}, ${chunkPN37HVAV_cjs.sqlNull(params.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(params.validTo)},
1552
1852
  ${timestamp2}, ${timestamp2}
1553
1853
  )
1554
1854
  `;
1555
1855
  }
1556
1856
  function buildInsertEdgesBatch(tables3, params, timestamp2) {
1557
1857
  const { edges: edges3 } = tables3;
1558
- const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
1858
+ const columns = chunkPN37HVAV_cjs.edgeColumnList(edges3);
1559
1859
  const values = params.map((edgeParams) => {
1560
1860
  const propsJson = JSON.stringify(edgeParams.props);
1561
- return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1861
+ return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkPN37HVAV_cjs.sqlNull(edgeParams.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1562
1862
  });
1563
1863
  return drizzleOrm.sql`
1564
1864
  INSERT INTO ${edges3} (${columns})
@@ -1567,10 +1867,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
1567
1867
  }
1568
1868
  function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
1569
1869
  const { edges: edges3 } = tables3;
1570
- const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
1870
+ const columns = chunkPN37HVAV_cjs.edgeColumnList(edges3);
1571
1871
  const values = params.map((edgeParams) => {
1572
1872
  const propsJson = JSON.stringify(edgeParams.props);
1573
- return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1873
+ return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkPN37HVAV_cjs.sqlNull(edgeParams.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1574
1874
  });
1575
1875
  return drizzleOrm.sql`
1576
1876
  INSERT INTO ${edges3} (${columns})
@@ -1602,14 +1902,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
1602
1902
  const { edges: edges3 } = tables3;
1603
1903
  const propsJson = JSON.stringify(params.props);
1604
1904
  const setParts = [
1605
- drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
1606
- drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
1905
+ drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
1906
+ drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
1607
1907
  ];
1608
1908
  if (params.validTo !== void 0) {
1609
- setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
1909
+ setParts.push(drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
1610
1910
  }
1611
1911
  if (params.clearDeleted) {
1612
- setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
1912
+ setParts.push(drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
1613
1913
  }
1614
1914
  const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
1615
1915
  if (params.clearDeleted) {
@@ -1634,7 +1934,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
1634
1934
  const { edges: edges3 } = tables3;
1635
1935
  return drizzleOrm.sql`
1636
1936
  UPDATE ${edges3}
1637
- SET ${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
1937
+ SET ${chunkPN37HVAV_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
1638
1938
  WHERE ${edges3.graphId} = ${params.graphId}
1639
1939
  AND ${edges3.id} = ${params.id}
1640
1940
  AND ${edges3.deletedAt} IS NULL
@@ -1721,7 +2021,7 @@ function resolveMode(mode) {
1721
2021
  function buildFulltextSearch(tableName, params, strategy) {
1722
2022
  assertValidSearchParams(params);
1723
2023
  const mode = resolveMode(params.mode);
1724
- const table = chunkJTI5WT4P_cjs.quotedTableName(tableName);
2024
+ const table = chunkPN37HVAV_cjs.quotedTableName(tableName);
1725
2025
  const matchCondition = strategy.matchCondition(
1726
2026
  tableName,
1727
2027
  params.query,
@@ -1772,12 +2072,12 @@ function assertValidSearchParams(params) {
1772
2072
  function buildInsertNode(tables3, params, timestamp2) {
1773
2073
  const { nodes: nodes3 } = tables3;
1774
2074
  const propsJson = JSON.stringify(params.props);
1775
- const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
2075
+ const columns = chunkPN37HVAV_cjs.nodeColumnList(nodes3);
1776
2076
  return drizzleOrm.sql`
1777
2077
  INSERT INTO ${nodes3} (${columns})
1778
2078
  VALUES (
1779
2079
  ${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
1780
- 1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
2080
+ 1, ${chunkPN37HVAV_cjs.sqlNull(params.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(params.validTo)},
1781
2081
  ${timestamp2}, ${timestamp2}
1782
2082
  )
1783
2083
  RETURNING *
@@ -1786,22 +2086,22 @@ function buildInsertNode(tables3, params, timestamp2) {
1786
2086
  function buildInsertNodeNoReturn(tables3, params, timestamp2) {
1787
2087
  const { nodes: nodes3 } = tables3;
1788
2088
  const propsJson = JSON.stringify(params.props);
1789
- const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
2089
+ const columns = chunkPN37HVAV_cjs.nodeColumnList(nodes3);
1790
2090
  return drizzleOrm.sql`
1791
2091
  INSERT INTO ${nodes3} (${columns})
1792
2092
  VALUES (
1793
2093
  ${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
1794
- 1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
2094
+ 1, ${chunkPN37HVAV_cjs.sqlNull(params.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(params.validTo)},
1795
2095
  ${timestamp2}, ${timestamp2}
1796
2096
  )
1797
2097
  `;
1798
2098
  }
1799
2099
  function buildInsertNodesBatch(tables3, params, timestamp2) {
1800
2100
  const { nodes: nodes3 } = tables3;
1801
- const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
2101
+ const columns = chunkPN37HVAV_cjs.nodeColumnList(nodes3);
1802
2102
  const values = params.map((nodeParams) => {
1803
2103
  const propsJson = JSON.stringify(nodeParams.props);
1804
- return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
2104
+ return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkPN37HVAV_cjs.sqlNull(nodeParams.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1805
2105
  });
1806
2106
  return drizzleOrm.sql`
1807
2107
  INSERT INTO ${nodes3} (${columns})
@@ -1810,10 +2110,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
1810
2110
  }
1811
2111
  function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
1812
2112
  const { nodes: nodes3 } = tables3;
1813
- const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
2113
+ const columns = chunkPN37HVAV_cjs.nodeColumnList(nodes3);
1814
2114
  const values = params.map((nodeParams) => {
1815
2115
  const propsJson = JSON.stringify(nodeParams.props);
1816
- return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
2116
+ return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkPN37HVAV_cjs.sqlNull(nodeParams.validFrom)}, ${chunkPN37HVAV_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
1817
2117
  });
1818
2118
  return drizzleOrm.sql`
1819
2119
  INSERT INTO ${nodes3} (${columns})
@@ -1847,19 +2147,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
1847
2147
  const { nodes: nodes3 } = tables3;
1848
2148
  const propsJson = JSON.stringify(params.props);
1849
2149
  const setParts = [
1850
- drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
1851
- drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
2150
+ drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
2151
+ drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
1852
2152
  ];
1853
2153
  if (params.incrementVersion) {
1854
2154
  setParts.push(
1855
- drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} = ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} + 1`
2155
+ drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(nodes3.version)} = ${chunkPN37HVAV_cjs.quotedColumn(nodes3.version)} + 1`
1856
2156
  );
1857
2157
  }
1858
2158
  if (params.validTo !== void 0) {
1859
- setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
2159
+ setParts.push(drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
1860
2160
  }
1861
2161
  if (params.clearDeleted) {
1862
- setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
2162
+ setParts.push(drizzleOrm.sql`${chunkPN37HVAV_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
1863
2163
  }
1864
2164
  const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
1865
2165
  if (params.clearDeleted) {
@@ -1886,7 +2186,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
1886
2186
  const { nodes: nodes3 } = tables3;
1887
2187
  return drizzleOrm.sql`
1888
2188
  UPDATE ${nodes3}
1889
- SET ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
2189
+ SET ${chunkPN37HVAV_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
1890
2190
  WHERE ${nodes3.graphId} = ${params.graphId}
1891
2191
  AND ${nodes3.kind} = ${params.kind}
1892
2192
  AND ${nodes3.id} = ${params.id}
@@ -1953,12 +2253,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
1953
2253
  const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
1954
2254
  const deactivateAll = drizzleOrm.sql`
1955
2255
  UPDATE ${schemaVersions3}
1956
- SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
2256
+ SET ${chunkPN37HVAV_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
1957
2257
  WHERE ${schemaVersions3.graphId} = ${graphId}
1958
2258
  `;
1959
2259
  const activateVersion = drizzleOrm.sql`
1960
2260
  UPDATE ${schemaVersions3}
1961
- SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
2261
+ SET ${chunkPN37HVAV_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
1962
2262
  WHERE ${schemaVersions3.graphId} = ${graphId}
1963
2263
  AND ${schemaVersions3.version} = ${version}
1964
2264
  `;
@@ -1976,22 +2276,22 @@ function buildInsertUniqueSqlite(tables3, params) {
1976
2276
  )
1977
2277
  ON CONFLICT (${conflictColumns})
1978
2278
  DO UPDATE SET
1979
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
1980
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
1981
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
1982
- ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)}
2279
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} = CASE
2280
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
2281
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
2282
+ ELSE ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)}
1983
2283
  END,
1984
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
1985
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
1986
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
1987
- ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)}
2284
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.concreteKind)} = CASE
2285
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
2286
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
2287
+ ELSE ${chunkPN37HVAV_cjs.quotedColumn(uniques3.concreteKind)}
1988
2288
  END,
1989
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
1990
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
1991
- WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
1992
- ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)}
2289
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} = CASE
2290
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
2291
+ WHEN ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
2292
+ ELSE ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)}
1993
2293
  END
1994
- RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
2294
+ RETURNING ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} as node_id
1995
2295
  `;
1996
2296
  }
1997
2297
  function buildInsertUniquePostgres(tables3, params) {
@@ -2008,22 +2308,22 @@ function buildInsertUniquePostgres(tables3, params) {
2008
2308
  )
2009
2309
  ON CONFLICT (${conflictColumns})
2010
2310
  DO UPDATE SET
2011
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
2311
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} = CASE
2012
2312
  WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
2013
2313
  WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
2014
2314
  ELSE ${existingColumn(uniques3.nodeId)}
2015
2315
  END,
2016
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
2316
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.concreteKind)} = CASE
2017
2317
  WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
2018
2318
  WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
2019
2319
  ELSE ${existingColumn(uniques3.concreteKind)}
2020
2320
  END,
2021
- ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
2321
+ ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} = CASE
2022
2322
  WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
2023
2323
  WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
2024
2324
  ELSE ${existingColumn(uniques3.deletedAt)}
2025
2325
  END
2026
- RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
2326
+ RETURNING ${chunkPN37HVAV_cjs.quotedColumn(uniques3.nodeId)} as node_id
2027
2327
  `;
2028
2328
  }
2029
2329
  var UNIQUE_INSERT_BUILDERS = {
@@ -2038,7 +2338,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
2038
2338
  const { uniques: uniques3 } = tables3;
2039
2339
  return drizzleOrm.sql`
2040
2340
  UPDATE ${uniques3}
2041
- SET ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
2341
+ SET ${chunkPN37HVAV_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
2042
2342
  WHERE ${uniques3.graphId} = ${params.graphId}
2043
2343
  AND ${uniques3.nodeKind} = ${params.nodeKind}
2044
2344
  AND ${uniques3.constraintName} = ${params.constraintName}
@@ -2675,18 +2975,25 @@ function compileQueryWithDialect(db, query, backendName) {
2675
2975
  return compiler.sqlToQuery(query);
2676
2976
  }
2677
2977
 
2978
+ exports.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS = POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS;
2678
2979
  exports.POSTGRES_INDEX_MAT_TIMESTAMPS = POSTGRES_INDEX_MAT_TIMESTAMPS;
2679
2980
  exports.POSTGRES_KIND_REMOVAL_TIMESTAMPS = POSTGRES_KIND_REMOVAL_TIMESTAMPS;
2680
2981
  exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
2982
+ exports.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = SQLITE_CONTRIBUTION_MAT_TIMESTAMPS;
2681
2983
  exports.SQLITE_INDEX_MAT_TIMESTAMPS = SQLITE_INDEX_MAT_TIMESTAMPS;
2682
2984
  exports.SQLITE_KIND_REMOVAL_TIMESTAMPS = SQLITE_KIND_REMOVAL_TIMESTAMPS;
2683
2985
  exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
2986
+ exports.assertAdoptedDialect = assertAdoptedDialect;
2987
+ exports.buildContributionInsertValues = buildContributionInsertValues;
2988
+ exports.buildContributionOnConflictSet = buildContributionOnConflictSet;
2684
2989
  exports.buildKindRemovalInsertValues = buildKindRemovalInsertValues;
2685
2990
  exports.buildKindRemovalOnConflictSet = buildKindRemovalOnConflictSet;
2686
2991
  exports.buildMaterializationInsertValues = buildMaterializationInsertValues;
2687
2992
  exports.buildMaterializationOnConflictSet = buildMaterializationOnConflictSet;
2993
+ exports.coerceNumericScore = coerceNumericScore;
2688
2994
  exports.compileQueryWithDialect = compileQueryWithDialect;
2689
2995
  exports.createCommonOperationBackend = createCommonOperationBackend;
2996
+ exports.createContributionMaterializer = createContributionMaterializer;
2690
2997
  exports.createEdgeRowMapper = createEdgeRowMapper;
2691
2998
  exports.createNodeRowMapper = createNodeRowMapper;
2692
2999
  exports.createPostgresOperationStrategy = createPostgresOperationStrategy;
@@ -2705,6 +3012,8 @@ exports.embeddings = embeddings;
2705
3012
  exports.embeddings2 = embeddings2;
2706
3013
  exports.formatPostgresTimestamp = formatPostgresTimestamp;
2707
3014
  exports.fulltext = fulltext;
3015
+ exports.gateFulltext = gateFulltext;
3016
+ exports.gateFulltextMethods = gateFulltextMethods;
2708
3017
  exports.generatePgCreateTableSQL = generatePgCreateTableSQL;
2709
3018
  exports.generatePostgresDDL = generatePostgresDDL;
2710
3019
  exports.generatePostgresMigrationSQL = generatePostgresMigrationSQL;
@@ -2713,6 +3022,7 @@ exports.generateSqliteDDL = generateSqliteDDL;
2713
3022
  exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
2714
3023
  exports.generateVectorIndexName = generateVectorIndexName;
2715
3024
  exports.getOrCreateLru = getOrCreateLru;
3025
+ exports.mapContributionMaterializationRow = mapContributionMaterializationRow;
2716
3026
  exports.mapKindRemovalRow = mapKindRemovalRow;
2717
3027
  exports.mapMaterializationRow = mapMaterializationRow;
2718
3028
  exports.nodes = nodes;
@@ -2724,5 +3034,5 @@ exports.tables = tables;
2724
3034
  exports.tables2 = tables2;
2725
3035
  exports.uniques = uniques;
2726
3036
  exports.uniques2 = uniques2;
2727
- //# sourceMappingURL=chunk-CQVNGKU7.cjs.map
2728
- //# sourceMappingURL=chunk-CQVNGKU7.cjs.map
3037
+ //# sourceMappingURL=chunk-TVUARC7S.cjs.map
3038
+ //# sourceMappingURL=chunk-TVUARC7S.cjs.map