@nicia-ai/typegraph 0.30.0 → 0.32.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 (187) hide show
  1. package/README.md +39 -0
  2. package/dist/backend/postgres/index.cjs +19 -18
  3. package/dist/backend/postgres/index.d.cts +6 -6
  4. package/dist/backend/postgres/index.d.ts +6 -6
  5. package/dist/backend/postgres/index.js +9 -8
  6. package/dist/backend/postgres/pglite.cjs +13 -12
  7. package/dist/backend/postgres/pglite.cjs.map +1 -1
  8. package/dist/backend/postgres/pglite.d.cts +3 -3
  9. package/dist/backend/postgres/pglite.d.ts +3 -3
  10. package/dist/backend/postgres/pglite.js +9 -8
  11. package/dist/backend/postgres/pglite.js.map +1 -1
  12. package/dist/backend/sqlite/index.cjs +16 -16
  13. package/dist/backend/sqlite/index.d.cts +7 -7
  14. package/dist/backend/sqlite/index.d.ts +7 -7
  15. package/dist/backend/sqlite/index.js +7 -7
  16. package/dist/backend/sqlite/libsql.cjs +12 -12
  17. package/dist/backend/sqlite/libsql.d.cts +3 -3
  18. package/dist/backend/sqlite/libsql.d.ts +3 -3
  19. package/dist/backend/sqlite/libsql.js +8 -8
  20. package/dist/backend/sqlite/local.cjs +13 -13
  21. package/dist/backend/sqlite/local.d.cts +3 -3
  22. package/dist/backend/sqlite/local.d.ts +3 -3
  23. package/dist/backend/sqlite/local.js +8 -8
  24. package/dist/{chunk-3JLRHQ67.js → chunk-2BVHPOIG.js} +7 -6
  25. package/dist/chunk-2BVHPOIG.js.map +1 -0
  26. package/dist/chunk-2LAT5BIK.cjs +16277 -0
  27. package/dist/chunk-2LAT5BIK.cjs.map +1 -0
  28. package/dist/chunk-2YMGNYXY.js +40 -0
  29. package/dist/chunk-2YMGNYXY.js.map +1 -0
  30. package/dist/chunk-3EUKJEQ3.js +77 -0
  31. package/dist/chunk-3EUKJEQ3.js.map +1 -0
  32. package/dist/{chunk-WFCECD6Q.cjs → chunk-3HQDMOBK.cjs} +73 -68
  33. package/dist/chunk-3HQDMOBK.cjs.map +1 -0
  34. package/dist/chunk-3QRBXYT5.cjs +94 -0
  35. package/dist/chunk-3QRBXYT5.cjs.map +1 -0
  36. package/dist/chunk-6G35I3VW.cjs +40 -0
  37. package/dist/chunk-6G35I3VW.cjs.map +1 -0
  38. package/dist/{chunk-4BXHVEFB.cjs → chunk-6RMLO5O4.cjs} +6 -51
  39. package/dist/chunk-6RMLO5O4.cjs.map +1 -0
  40. package/dist/chunk-6ZR4QC3O.cjs +12 -0
  41. package/dist/{chunk-LUHU4T2F.cjs.map → chunk-6ZR4QC3O.cjs.map} +1 -1
  42. package/dist/chunk-73KASJGO.cjs +52 -0
  43. package/dist/chunk-73KASJGO.cjs.map +1 -0
  44. package/dist/{chunk-IUIJJYPI.js → chunk-7WW3WL6E.js} +6 -5
  45. package/dist/chunk-7WW3WL6E.js.map +1 -0
  46. package/dist/chunk-A3W7QG7K.js +45 -0
  47. package/dist/chunk-A3W7QG7K.js.map +1 -0
  48. package/dist/chunk-AW4A3P5A.cjs +51 -0
  49. package/dist/chunk-AW4A3P5A.cjs.map +1 -0
  50. package/dist/{chunk-AI3RNREM.js → chunk-C4C4Q7A6.js} +94 -496
  51. package/dist/chunk-C4C4Q7A6.js.map +1 -0
  52. package/dist/{chunk-4LBO6KIF.cjs → chunk-CAMMC3E4.cjs} +60 -59
  53. package/dist/chunk-CAMMC3E4.cjs.map +1 -0
  54. package/dist/{chunk-3IRMLJEK.js → chunk-CEF2QOTO.js} +3 -3
  55. package/dist/{chunk-3IRMLJEK.js.map → chunk-CEF2QOTO.js.map} +1 -1
  56. package/dist/{chunk-UESTHN47.cjs → chunk-CFNT3ITG.cjs} +95 -507
  57. package/dist/chunk-CFNT3ITG.cjs.map +1 -0
  58. package/dist/chunk-CWFPJ3RC.js +282 -0
  59. package/dist/chunk-CWFPJ3RC.js.map +1 -0
  60. package/dist/{chunk-7JGLPAFV.cjs → chunk-EEYV6UOE.cjs} +16 -16
  61. package/dist/chunk-EEYV6UOE.cjs.map +1 -0
  62. package/dist/{chunk-FWBVPATK.cjs → chunk-FDN43KXV.cjs} +19 -19
  63. package/dist/{chunk-FWBVPATK.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
  64. package/dist/chunk-HFBRAOF7.js +610 -0
  65. package/dist/chunk-HFBRAOF7.js.map +1 -0
  66. package/dist/chunk-HTGDWIDE.cjs +89 -0
  67. package/dist/chunk-HTGDWIDE.cjs.map +1 -0
  68. package/dist/{chunk-R4JOBEJU.js → chunk-IJORSAC3.js} +4 -40
  69. package/dist/chunk-IJORSAC3.js.map +1 -0
  70. package/dist/{chunk-WEMZM7J7.cjs → chunk-JKRKIEVA.cjs} +5 -41
  71. package/dist/chunk-JKRKIEVA.cjs.map +1 -0
  72. package/dist/{chunk-SGPXKJ4A.cjs → chunk-KTIEB7VH.cjs} +26 -16
  73. package/dist/chunk-KTIEB7VH.cjs.map +1 -0
  74. package/dist/{chunk-K4N35E7B.cjs → chunk-LAZGHOZW.cjs} +72 -71
  75. package/dist/chunk-LAZGHOZW.cjs.map +1 -0
  76. package/dist/{chunk-VFX3LC76.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
  77. package/dist/{chunk-VFX3LC76.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
  78. package/dist/{chunk-K5VREXMZ.js → chunk-NDM5PXEH.js} +7 -6
  79. package/dist/chunk-NDM5PXEH.js.map +1 -0
  80. package/dist/chunk-PIHXFF73.js +90 -0
  81. package/dist/chunk-PIHXFF73.js.map +1 -0
  82. package/dist/{chunk-FVIGJTS7.js → chunk-PRMKPFN5.js} +4 -74
  83. package/dist/chunk-PRMKPFN5.js.map +1 -0
  84. package/dist/chunk-SAJSMR2B.js +35 -0
  85. package/dist/chunk-SAJSMR2B.js.map +1 -0
  86. package/dist/chunk-SB65GJNY.cjs +624 -0
  87. package/dist/chunk-SB65GJNY.cjs.map +1 -0
  88. package/dist/{chunk-N2OEOGBB.js → chunk-TUA3MEJJ.js} +13 -8
  89. package/dist/chunk-TUA3MEJJ.js.map +1 -0
  90. package/dist/{chunk-MAQJYNJR.js → chunk-W4ZX2GCP.js} +14 -16
  91. package/dist/chunk-W4ZX2GCP.js.map +1 -0
  92. package/dist/chunk-WNORITK6.js +16231 -0
  93. package/dist/chunk-WNORITK6.js.map +1 -0
  94. package/dist/chunk-WWVV44DY.cjs +287 -0
  95. package/dist/chunk-WWVV44DY.cjs.map +1 -0
  96. package/dist/{chunk-IX7RE7CG.js → chunk-WYTUF3QO.js} +3 -3
  97. package/dist/{chunk-IX7RE7CG.js.map → chunk-WYTUF3QO.js.map} +1 -1
  98. package/dist/{chunk-2QA5EHEN.js → chunk-XKNAK27R.js} +3 -3
  99. package/dist/{chunk-2QA5EHEN.js.map → chunk-XKNAK27R.js.map} +1 -1
  100. package/dist/{chunk-633N7DSE.js → chunk-XQFAJVYW.js} +4 -36
  101. package/dist/chunk-XQFAJVYW.js.map +1 -0
  102. package/dist/{chunk-ENDUY2CD.js → chunk-YCV72E6L.js} +23 -17
  103. package/dist/chunk-YCV72E6L.js.map +1 -0
  104. package/dist/{chunk-26HWIIVS.cjs → chunk-YL4F3CMD.cjs} +63 -62
  105. package/dist/chunk-YL4F3CMD.cjs.map +1 -0
  106. package/dist/{chunk-IE6GN7L3.cjs → chunk-YW7GHMF4.cjs} +17 -98
  107. package/dist/chunk-YW7GHMF4.cjs.map +1 -0
  108. package/dist/{ddl-EdkIiFVU.d.ts → ddl-C8e8zDAE.d.ts} +3 -3
  109. package/dist/{ddl-BSFlbGQF.d.cts → ddl-CwyG4HoQ.d.cts} +3 -3
  110. package/dist/{extension-types-CwHV-Uk4.d.cts → extension-types-D1k0inWU.d.cts} +1 -1
  111. package/dist/{extension-types-CwHV-Uk4.d.ts → extension-types-D1k0inWU.d.ts} +1 -1
  112. package/dist/graph-extension/index.cjs +17 -17
  113. package/dist/graph-extension/index.d.cts +5 -16
  114. package/dist/graph-extension/index.d.ts +5 -16
  115. package/dist/graph-extension/index.js +2 -2
  116. package/dist/graph-merge/index.cjs +3966 -0
  117. package/dist/graph-merge/index.cjs.map +1 -0
  118. package/dist/graph-merge/index.d.cts +1191 -0
  119. package/dist/graph-merge/index.d.ts +1191 -0
  120. package/dist/graph-merge/index.js +3935 -0
  121. package/dist/graph-merge/index.js.map +1 -0
  122. package/dist/{index-DzeIiMO3.d.ts → index-BEK0VtNB.d.ts} +2 -2
  123. package/dist/{index-Ln_KHTGA.d.cts → index-C8sSTErx.d.cts} +2 -2
  124. package/dist/index.cjs +291 -15919
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.d.cts +12 -11
  127. package/dist/index.d.ts +12 -11
  128. package/dist/index.js +24 -15791
  129. package/dist/index.js.map +1 -1
  130. package/dist/indexes/index.cjs +30 -26
  131. package/dist/indexes/index.d.cts +5 -5
  132. package/dist/indexes/index.d.ts +5 -5
  133. package/dist/indexes/index.js +6 -2
  134. package/dist/interchange/index.cjs +49 -592
  135. package/dist/interchange/index.cjs.map +1 -1
  136. package/dist/interchange/index.d.cts +9 -9
  137. package/dist/interchange/index.d.ts +9 -9
  138. package/dist/interchange/index.js +2 -588
  139. package/dist/interchange/index.js.map +1 -1
  140. package/dist/{manager-BbdyNhkv.d.ts → manager-8htmuGr-.d.ts} +3 -3
  141. package/dist/{manager-wTDgjoXG.d.cts → manager-aVgxbGt-.d.cts} +3 -3
  142. package/dist/{materialize-indexes-lkawaDor.d.ts → materialize-indexes-CAGhqPHQ.d.ts} +1 -1
  143. package/dist/{materialize-indexes-oanE3RU0.d.cts → materialize-indexes-DEYkU-wr.d.cts} +1 -1
  144. package/dist/{postgres-CK2ByP1q.d.cts → postgres-Dhom7iiX.d.ts} +1 -1
  145. package/dist/{postgres-ymXYC6Rr.d.ts → postgres-jgXmD45C.d.cts} +1 -1
  146. package/dist/profiler/index.d.cts +7 -7
  147. package/dist/profiler/index.d.ts +7 -7
  148. package/dist/result-DWo6mUVz.d.cts +37 -0
  149. package/dist/result-DWo6mUVz.d.ts +37 -0
  150. package/dist/schema/index.cjs +30 -29
  151. package/dist/schema/index.cjs.map +1 -1
  152. package/dist/schema/index.d.cts +7 -7
  153. package/dist/schema/index.d.ts +7 -7
  154. package/dist/schema/index.js +7 -6
  155. package/dist/schema/index.js.map +1 -1
  156. package/dist/{sqlite-R8YGOqVQ.d.ts → sqlite-BfLsCEqO.d.ts} +1 -1
  157. package/dist/{sqlite-DxH1lrwD.d.cts → sqlite-DcQ_BCUW.d.cts} +1 -1
  158. package/dist/{store-CNKM334w.d.ts → store-view-lTcb_cnp.d.cts} +694 -366
  159. package/dist/{store--z1Tmk7U.d.cts → store-view-pBOUrQte.d.ts} +694 -366
  160. package/dist/{types-D5B6Be5c.d.cts → types-5RQwzWXx.d.cts} +2 -2
  161. package/dist/{types-CMvxx2kd.d.ts → types-DGDiXAYc.d.ts} +2 -2
  162. package/dist/{types-BBiDqJCU.d.ts → types-Dk8r09KY.d.ts} +16 -2
  163. package/dist/{types-dL-clxO3.d.cts → types-Dvmn-eal.d.cts} +16 -2
  164. package/dist/{where-CAo6wsBZ.d.ts → where-CHZFELX0.d.ts} +2 -2
  165. package/dist/{where-bJjuOCeV.d.cts → where-Cx_glEEB.d.cts} +2 -2
  166. package/package.json +7 -2
  167. package/dist/chunk-26HWIIVS.cjs.map +0 -1
  168. package/dist/chunk-3JLRHQ67.js.map +0 -1
  169. package/dist/chunk-4BXHVEFB.cjs.map +0 -1
  170. package/dist/chunk-4LBO6KIF.cjs.map +0 -1
  171. package/dist/chunk-633N7DSE.js.map +0 -1
  172. package/dist/chunk-7JGLPAFV.cjs.map +0 -1
  173. package/dist/chunk-AI3RNREM.js.map +0 -1
  174. package/dist/chunk-ENDUY2CD.js.map +0 -1
  175. package/dist/chunk-FVIGJTS7.js.map +0 -1
  176. package/dist/chunk-IE6GN7L3.cjs.map +0 -1
  177. package/dist/chunk-IUIJJYPI.js.map +0 -1
  178. package/dist/chunk-K4N35E7B.cjs.map +0 -1
  179. package/dist/chunk-K5VREXMZ.js.map +0 -1
  180. package/dist/chunk-LUHU4T2F.cjs +0 -12
  181. package/dist/chunk-MAQJYNJR.js.map +0 -1
  182. package/dist/chunk-N2OEOGBB.js.map +0 -1
  183. package/dist/chunk-R4JOBEJU.js.map +0 -1
  184. package/dist/chunk-SGPXKJ4A.cjs.map +0 -1
  185. package/dist/chunk-UESTHN47.cjs.map +0 -1
  186. package/dist/chunk-WEMZM7J7.cjs.map +0 -1
  187. package/dist/chunk-WFCECD6Q.cjs.map +0 -1
@@ -2,9 +2,6 @@
2
2
 
3
3
  var chunkFLRCVI2G_cjs = require('./chunk-FLRCVI2G.cjs');
4
4
  var drizzleOrm = require('drizzle-orm');
5
- var casing = require('drizzle-orm/casing');
6
- var pgCore = require('drizzle-orm/pg-core');
7
- var sqliteCore = require('drizzle-orm/sqlite-core');
8
5
 
9
6
  function sqlNull(value) {
10
7
  return value ?? drizzleOrm.sql.raw("NULL");
@@ -384,6 +381,97 @@ var fts5Strategy = {
384
381
  return stmt === void 0 ? [] : [stmt];
385
382
  }
386
383
  };
384
+ var VECTOR_CONTRIBUTION_PREFIX = "vector";
385
+ function buildVectorCapabilities(strategy) {
386
+ return strategy.capabilities;
387
+ }
388
+ function vectorScoreExpression(distanceExpression, metric) {
389
+ switch (metric) {
390
+ case "cosine": {
391
+ return drizzleOrm.sql`(1 - (${distanceExpression}))`;
392
+ }
393
+ case "l2":
394
+ case "inner_product": {
395
+ return distanceExpression;
396
+ }
397
+ default: {
398
+ const _exhaustive = metric;
399
+ throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);
400
+ }
401
+ }
402
+ }
403
+ function vectorMinScoreCondition(distanceExpression, metric, minScore) {
404
+ assertVectorMinScore(minScore, metric);
405
+ switch (metric) {
406
+ case "cosine": {
407
+ return drizzleOrm.sql`${distanceExpression} <= ${1 - minScore}`;
408
+ }
409
+ case "l2": {
410
+ return drizzleOrm.sql`${distanceExpression} <= ${minScore}`;
411
+ }
412
+ case "inner_product": {
413
+ return drizzleOrm.sql`${distanceExpression} <= ${-minScore}`;
414
+ }
415
+ default: {
416
+ const _exhaustive = metric;
417
+ throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);
418
+ }
419
+ }
420
+ }
421
+ function assertFiniteEmbedding(embedding, name) {
422
+ for (const [index, value] of embedding.entries()) {
423
+ if (typeof value !== "number" || !Number.isFinite(value)) {
424
+ throw new TypeError(
425
+ `${name}[${index}] must be a finite number, got: ${value}`
426
+ );
427
+ }
428
+ }
429
+ }
430
+ function assertVectorSearchLimit(limit) {
431
+ if (!Number.isInteger(limit) || limit <= 0) {
432
+ throw new RangeError(
433
+ `vectorSearch limit must be a positive integer, got: ${limit}`
434
+ );
435
+ }
436
+ }
437
+ function assertVectorMinScore(minScore, metric, label = "minScore") {
438
+ if (!Number.isFinite(minScore)) {
439
+ throw new RangeError(`${label} must be a finite number, got: ${minScore}`);
440
+ }
441
+ if (metric === "cosine" && Math.abs(minScore) > 1) {
442
+ throw new RangeError(
443
+ `${label} for the cosine metric must be between -1 and 1, got: ${minScore}`
444
+ );
445
+ }
446
+ }
447
+ var MAX_VECTOR_IDENTIFIER_LENGTH = 63;
448
+ function sanitizeIdentifierPart(value) {
449
+ return value.toLowerCase().replaceAll(/[^a-z0-9_]/g, "_");
450
+ }
451
+ function shortHash(input) {
452
+ let h1 = 3735928559;
453
+ let h2 = 1103547991;
454
+ for (let index = 0; index < input.length; index++) {
455
+ const ch = input.codePointAt(index);
456
+ h1 = Math.imul(h1 ^ ch, 2654435761);
457
+ h2 = Math.imul(h2 ^ ch, 1597334677);
458
+ }
459
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
460
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
461
+ const hi = (h2 >>> 0).toString(16).padStart(8, "0");
462
+ const lo = (h1 >>> 0).toString(16).padStart(8, "0");
463
+ return `${hi}${lo}`.slice(0, 8);
464
+ }
465
+ function vectorPhysicalName(prefix, graphId, nodeKind, fieldPath) {
466
+ const readable = `${prefix}_${sanitizeIdentifierPart(graphId)}_${sanitizeIdentifierPart(nodeKind)}_${sanitizeIdentifierPart(fieldPath)}`;
467
+ const hash = shortHash(JSON.stringify([graphId, nodeKind, fieldPath]));
468
+ const full = `${readable}_${hash}`;
469
+ if (full.length <= MAX_VECTOR_IDENTIFIER_LENGTH) return full;
470
+ return `${readable.slice(0, MAX_VECTOR_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;
471
+ }
472
+ function quoteIdentifier2(name) {
473
+ return `"${name.replaceAll('"', '""')}"`;
474
+ }
387
475
  function escapePostgresLiteral(value) {
388
476
  return `'${value.replaceAll("'", "''")}'`;
389
477
  }
@@ -708,97 +796,6 @@ var sqliteDialect = {
708
796
  // ============================================================
709
797
  fulltext: fts5Strategy
710
798
  };
711
- var VECTOR_CONTRIBUTION_PREFIX = "vector";
712
- function buildVectorCapabilities(strategy) {
713
- return strategy.capabilities;
714
- }
715
- function vectorScoreExpression(distanceExpression, metric) {
716
- switch (metric) {
717
- case "cosine": {
718
- return drizzleOrm.sql`(1 - (${distanceExpression}))`;
719
- }
720
- case "l2":
721
- case "inner_product": {
722
- return distanceExpression;
723
- }
724
- default: {
725
- const _exhaustive = metric;
726
- throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);
727
- }
728
- }
729
- }
730
- function vectorMinScoreCondition(distanceExpression, metric, minScore) {
731
- assertVectorMinScore(minScore, metric);
732
- switch (metric) {
733
- case "cosine": {
734
- return drizzleOrm.sql`${distanceExpression} <= ${1 - minScore}`;
735
- }
736
- case "l2": {
737
- return drizzleOrm.sql`${distanceExpression} <= ${minScore}`;
738
- }
739
- case "inner_product": {
740
- return drizzleOrm.sql`${distanceExpression} <= ${-minScore}`;
741
- }
742
- default: {
743
- const _exhaustive = metric;
744
- throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);
745
- }
746
- }
747
- }
748
- function assertFiniteEmbedding(embedding, name) {
749
- for (const [index, value] of embedding.entries()) {
750
- if (typeof value !== "number" || !Number.isFinite(value)) {
751
- throw new TypeError(
752
- `${name}[${index}] must be a finite number, got: ${value}`
753
- );
754
- }
755
- }
756
- }
757
- function assertVectorSearchLimit(limit) {
758
- if (!Number.isInteger(limit) || limit <= 0) {
759
- throw new RangeError(
760
- `vectorSearch limit must be a positive integer, got: ${limit}`
761
- );
762
- }
763
- }
764
- function assertVectorMinScore(minScore, metric, label = "minScore") {
765
- if (!Number.isFinite(minScore)) {
766
- throw new RangeError(`${label} must be a finite number, got: ${minScore}`);
767
- }
768
- if (metric === "cosine" && (minScore < -1 || minScore > 1)) {
769
- throw new RangeError(
770
- `${label} for the cosine metric must be between -1 and 1, got: ${minScore}`
771
- );
772
- }
773
- }
774
- var MAX_VECTOR_IDENTIFIER_LENGTH = 63;
775
- function sanitizeIdentifierPart(value) {
776
- return value.toLowerCase().replaceAll(/[^a-z0-9_]/g, "_");
777
- }
778
- function shortHash(input) {
779
- let h1 = 3735928559;
780
- let h2 = 1103547991;
781
- for (let index = 0; index < input.length; index++) {
782
- const ch = input.codePointAt(index);
783
- h1 = Math.imul(h1 ^ ch, 2654435761);
784
- h2 = Math.imul(h2 ^ ch, 1597334677);
785
- }
786
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
787
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
788
- const hi = (h2 >>> 0).toString(16).padStart(8, "0");
789
- const lo = (h1 >>> 0).toString(16).padStart(8, "0");
790
- return `${hi}${lo}`.slice(0, 8);
791
- }
792
- function vectorPhysicalName(prefix, graphId, nodeKind, fieldPath) {
793
- const readable = `${prefix}_${sanitizeIdentifierPart(graphId)}_${sanitizeIdentifierPart(nodeKind)}_${sanitizeIdentifierPart(fieldPath)}`;
794
- const hash = shortHash(JSON.stringify([graphId, nodeKind, fieldPath]));
795
- const full = `${readable}_${hash}`;
796
- if (full.length <= MAX_VECTOR_IDENTIFIER_LENGTH) return full;
797
- return `${readable.slice(0, MAX_VECTOR_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;
798
- }
799
- function quoteIdentifier2(name) {
800
- return `"${name.replaceAll('"', '""')}"`;
801
- }
802
799
 
803
800
  // src/query/dialect/index.ts
804
801
  var DIALECT_ADAPTERS = {
@@ -1038,437 +1035,28 @@ function escapeStringLiteral(value) {
1038
1035
  return `'${value.replaceAll("'", "''")}'`;
1039
1036
  }
1040
1037
 
1041
- // src/indexes/ddl.ts
1042
- function generateIndexDDL(index, dialect, options = {}) {
1043
- if (index.entity === "node") {
1044
- return generateNodeIndexDDL(index, dialect, options);
1045
- }
1046
- return generateEdgeIndexDDL(index, dialect, options);
1047
- }
1048
- function generateNodeIndexDDL(index, dialect, options = {}) {
1049
- const tableName = options.nodesTableName ?? "typegraph_nodes";
1050
- return generateTableIndexDDL(index, dialect, tableName, options);
1051
- }
1052
- function generateEdgeIndexDDL(index, dialect, options = {}) {
1053
- const tableName = options.edgesTableName ?? "typegraph_edges";
1054
- return generateTableIndexDDL(index, dialect, tableName, options);
1055
- }
1056
- function generateTableIndexDDL(index, dialect, tableName, options) {
1057
- const ifNotExists = options.ifNotExists ?? true;
1058
- const propsColumn = drizzleOrm.sql.raw('"props"');
1059
- const systemColumn = (column) => drizzleOrm.sql.raw(quoteIdentifier3(column));
1060
- const keys = index.entity === "node" ? compileNodeIndexKeys(index, dialect, propsColumn, systemColumn).keys : compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn).keys;
1061
- const whereSql = index.where ? sqlToInlineString(
1062
- compileIndexWhere(
1063
- {
1064
- dialect,
1065
- propsColumn,
1066
- systemColumn
1067
- },
1068
- index.where
1069
- ),
1070
- dialect
1071
- ) : void 0;
1072
- const keySql = keys.map((k) => sqlToInlineString(k, dialect)).join(", ");
1073
- const unique = index.unique ? "UNIQUE " : "";
1074
- const concurrent = options.concurrent === true && dialect === "postgres" ? "CONCURRENTLY " : "";
1075
- const ifNotExistsSql = ifNotExists ? "IF NOT EXISTS " : "";
1076
- const whereClause = whereSql ? ` WHERE ${whereSql}` : "";
1077
- return `CREATE ${unique}INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier3(index.name)} ON ${quoteIdentifier3(tableName)} (${keySql})${whereClause};`;
1078
- }
1079
- function quoteIdentifier3(identifier) {
1080
- return `"${identifier.replaceAll('"', '""')}"`;
1081
- }
1082
- function sqlToInlineString(object, dialect) {
1083
- const query = object.toQuery({
1084
- casing: new casing.CasingCache(),
1085
- escapeName: (name) => name,
1086
- escapeParam: (_number, value) => inlineParam(value, dialect),
1087
- escapeString: (value) => escapeStringLiteral2(value),
1088
- inlineParams: true,
1089
- invokeSource: "indexes"
1090
- });
1091
- if (query.params.length > 0) {
1092
- throw new Error(
1093
- "Index DDL generation produced parameters; expected fully inlined SQL"
1094
- );
1095
- }
1096
- return query.sql;
1097
- }
1098
- function inlineParam(value, dialect) {
1099
- if (value === null || value === void 0) {
1100
- return "NULL";
1101
- }
1102
- if (value instanceof Date) {
1103
- return escapeStringLiteral2(value.toISOString());
1104
- }
1105
- if (typeof value === "string") {
1106
- return escapeStringLiteral2(value);
1107
- }
1108
- if (typeof value === "number") {
1109
- return value.toString();
1110
- }
1111
- if (typeof value === "boolean") {
1112
- return getDialect(dialect).booleanLiteralString(value);
1113
- }
1114
- if (typeof value === "bigint") {
1115
- return value.toString();
1116
- }
1117
- throw new TypeError(
1118
- "Index DDL generation received an unsupported SQL parameter value"
1119
- );
1120
- }
1121
- function escapeStringLiteral2(value) {
1122
- return `'${value.replaceAll("'", "''")}'`;
1123
- }
1124
- function buildPostgresNodeIndexBuilders(table, indexes) {
1125
- const nodeIndexes = indexes.filter(
1126
- (index) => index.entity === "node"
1127
- );
1128
- return nodeIndexes.map((index) => {
1129
- const propsColumn = drizzleOrm.sql`${table.props}`;
1130
- const systemColumn = (column) => drizzleOrm.sql`${getPostgresNodeSystemColumn(table, column)}`;
1131
- const { keys } = compileNodeIndexKeys(
1132
- index,
1133
- "postgres",
1134
- propsColumn,
1135
- systemColumn
1136
- );
1137
- assertNonEmpty(keys, `node index "${index.name}"`);
1138
- const base = index.unique ? pgCore.uniqueIndex(index.name) : pgCore.index(index.name);
1139
- const builder = base.on(...keys);
1140
- if (index.where) {
1141
- const ctx = {
1142
- dialect: "postgres",
1143
- propsColumn,
1144
- systemColumn
1145
- };
1146
- builder.where(compileIndexWhere(ctx, index.where));
1147
- }
1148
- return builder;
1149
- });
1150
- }
1151
- function buildPostgresEdgeIndexBuilders(table, indexes) {
1152
- const edgeIndexes = indexes.filter(
1153
- (index) => index.entity === "edge"
1154
- );
1155
- return edgeIndexes.map((index) => {
1156
- const propsColumn = drizzleOrm.sql`${table.props}`;
1157
- const systemColumn = (column) => drizzleOrm.sql`${getPostgresEdgeSystemColumn(table, column)}`;
1158
- const { keys } = compileEdgeIndexKeys(
1159
- index,
1160
- "postgres",
1161
- propsColumn,
1162
- systemColumn
1163
- );
1164
- assertNonEmpty(keys, `edge index "${index.name}"`);
1165
- const base = index.unique ? pgCore.uniqueIndex(index.name) : pgCore.index(index.name);
1166
- const builder = base.on(...keys);
1167
- if (index.where) {
1168
- const ctx = {
1169
- dialect: "postgres",
1170
- propsColumn,
1171
- systemColumn
1172
- };
1173
- builder.where(compileIndexWhere(ctx, index.where));
1174
- }
1175
- return builder;
1176
- });
1177
- }
1178
- function getPostgresNodeSystemColumn(table, column) {
1179
- switch (column) {
1180
- case "graph_id": {
1181
- return table.graphId;
1182
- }
1183
- case "kind": {
1184
- return table.kind;
1185
- }
1186
- case "id": {
1187
- return table.id;
1188
- }
1189
- case "from_kind":
1190
- case "from_id":
1191
- case "to_kind":
1192
- case "to_id": {
1193
- throw new Error(`Unsupported node system column for indexes: ${column}`);
1194
- }
1195
- case "deleted_at": {
1196
- return table.deletedAt;
1197
- }
1198
- case "valid_from": {
1199
- return table.validFrom;
1200
- }
1201
- case "valid_to": {
1202
- return table.validTo;
1203
- }
1204
- case "created_at": {
1205
- return table.createdAt;
1206
- }
1207
- case "updated_at": {
1208
- return table.updatedAt;
1209
- }
1210
- case "version": {
1211
- return table.version;
1212
- }
1213
- }
1214
- }
1215
- function getPostgresEdgeSystemColumn(table, column) {
1216
- switch (column) {
1217
- case "graph_id": {
1218
- return table.graphId;
1219
- }
1220
- case "kind": {
1221
- return table.kind;
1222
- }
1223
- case "id": {
1224
- return table.id;
1225
- }
1226
- case "from_kind": {
1227
- return table.fromKind;
1228
- }
1229
- case "from_id": {
1230
- return table.fromId;
1231
- }
1232
- case "to_kind": {
1233
- return table.toKind;
1234
- }
1235
- case "to_id": {
1236
- return table.toId;
1237
- }
1238
- case "deleted_at": {
1239
- return table.deletedAt;
1240
- }
1241
- case "valid_from": {
1242
- return table.validFrom;
1243
- }
1244
- case "valid_to": {
1245
- return table.validTo;
1246
- }
1247
- case "created_at": {
1248
- return table.createdAt;
1249
- }
1250
- case "updated_at": {
1251
- return table.updatedAt;
1252
- }
1253
- case "version": {
1254
- throw new Error(`Unsupported edge system column for indexes: ${column}`);
1255
- }
1256
- }
1257
- }
1258
- function buildSqliteNodeIndexBuilders(table, indexes) {
1259
- const nodeIndexes = indexes.filter(
1260
- (index) => index.entity === "node"
1261
- );
1262
- return nodeIndexes.map((index) => {
1263
- const propsColumn = drizzleOrm.sql`${table.props}`;
1264
- const systemColumn = (column) => drizzleOrm.sql`${getSqliteNodeSystemColumn(table, column)}`;
1265
- const { keys } = compileNodeIndexKeys(
1266
- index,
1267
- "sqlite",
1268
- propsColumn,
1269
- systemColumn
1270
- );
1271
- assertNonEmpty(keys, `node index "${index.name}"`);
1272
- const base = index.unique ? sqliteCore.uniqueIndex(index.name) : sqliteCore.index(index.name);
1273
- const builder = base.on(...keys);
1274
- if (index.where) {
1275
- const ctx = {
1276
- dialect: "sqlite",
1277
- propsColumn,
1278
- systemColumn
1279
- };
1280
- builder.where(compileIndexWhere(ctx, index.where));
1281
- }
1282
- return builder;
1283
- });
1284
- }
1285
- function buildSqliteEdgeIndexBuilders(table, indexes) {
1286
- const edgeIndexes = indexes.filter(
1287
- (index) => index.entity === "edge"
1288
- );
1289
- return edgeIndexes.map((index) => {
1290
- const propsColumn = drizzleOrm.sql`${table.props}`;
1291
- const systemColumn = (column) => drizzleOrm.sql`${getSqliteEdgeSystemColumn(table, column)}`;
1292
- const { keys } = compileEdgeIndexKeys(
1293
- index,
1294
- "sqlite",
1295
- propsColumn,
1296
- systemColumn
1297
- );
1298
- assertNonEmpty(keys, `edge index "${index.name}"`);
1299
- const base = index.unique ? sqliteCore.uniqueIndex(index.name) : sqliteCore.index(index.name);
1300
- const builder = base.on(...keys);
1301
- if (index.where) {
1302
- const ctx = {
1303
- dialect: "sqlite",
1304
- propsColumn,
1305
- systemColumn
1306
- };
1307
- builder.where(compileIndexWhere(ctx, index.where));
1308
- }
1309
- return builder;
1310
- });
1311
- }
1312
- function getSqliteNodeSystemColumn(table, column) {
1313
- switch (column) {
1314
- case "graph_id": {
1315
- return table.graphId;
1316
- }
1317
- case "kind": {
1318
- return table.kind;
1319
- }
1320
- case "id": {
1321
- return table.id;
1322
- }
1323
- case "from_kind":
1324
- case "from_id":
1325
- case "to_kind":
1326
- case "to_id": {
1327
- throw new Error(`Unsupported node system column for indexes: ${column}`);
1328
- }
1329
- case "deleted_at": {
1330
- return table.deletedAt;
1331
- }
1332
- case "valid_from": {
1333
- return table.validFrom;
1334
- }
1335
- case "valid_to": {
1336
- return table.validTo;
1337
- }
1338
- case "created_at": {
1339
- return table.createdAt;
1340
- }
1341
- case "updated_at": {
1342
- return table.updatedAt;
1343
- }
1344
- case "version": {
1345
- return table.version;
1346
- }
1347
- }
1348
- }
1349
- function getSqliteEdgeSystemColumn(table, column) {
1350
- switch (column) {
1351
- case "graph_id": {
1352
- return table.graphId;
1353
- }
1354
- case "kind": {
1355
- return table.kind;
1356
- }
1357
- case "id": {
1358
- return table.id;
1359
- }
1360
- case "from_kind": {
1361
- return table.fromKind;
1362
- }
1363
- case "from_id": {
1364
- return table.fromId;
1365
- }
1366
- case "to_kind": {
1367
- return table.toKind;
1368
- }
1369
- case "to_id": {
1370
- return table.toId;
1371
- }
1372
- case "deleted_at": {
1373
- return table.deletedAt;
1374
- }
1375
- case "valid_from": {
1376
- return table.validFrom;
1377
- }
1378
- case "valid_to": {
1379
- return table.validTo;
1380
- }
1381
- case "created_at": {
1382
- return table.createdAt;
1383
- }
1384
- case "updated_at": {
1385
- return table.updatedAt;
1386
- }
1387
- case "version": {
1388
- throw new Error(`Unsupported edge system column for indexes: ${column}`);
1389
- }
1390
- }
1391
- }
1392
- function assertNonEmpty(values, label) {
1393
- if (values.length === 0) {
1394
- throw new Error(`Index must have at least one key (${label})`);
1395
- }
1396
- }
1397
-
1398
- // src/indexes/profiler.ts
1399
- function toDeclaredIndex(index) {
1400
- return {
1401
- entityType: index.entity,
1402
- kind: index.kind,
1403
- fields: [...index.fields],
1404
- unique: index.unique,
1405
- name: index.name
1406
- };
1407
- }
1408
- function toDeclaredIndexes(indexes) {
1409
- return indexes.filter(
1410
- (index) => index.entity === "node" || index.entity === "edge"
1411
- ).map((index) => toDeclaredIndex(index));
1412
- }
1413
-
1414
- // src/indexes/where.ts
1415
- function andWhere(...predicates) {
1416
- if (predicates.length === 1) {
1417
- return predicates[0];
1418
- }
1419
- return {
1420
- __type: "index_where_and",
1421
- predicates
1422
- };
1423
- }
1424
- function orWhere(...predicates) {
1425
- if (predicates.length === 1) {
1426
- return predicates[0];
1427
- }
1428
- return {
1429
- __type: "index_where_or",
1430
- predicates
1431
- };
1432
- }
1433
- function notWhere(predicate) {
1434
- return {
1435
- __type: "index_where_not",
1436
- predicate
1437
- };
1438
- }
1439
-
1440
1038
  exports.BASE_CONTRIBUTION_OWNER = BASE_CONTRIBUTION_OWNER;
1441
1039
  exports.VECTOR_CONTRIBUTION_PREFIX = VECTOR_CONTRIBUTION_PREFIX;
1442
- exports.andWhere = andWhere;
1443
1040
  exports.assertFiniteEmbedding = assertFiniteEmbedding;
1444
1041
  exports.assertVectorMinScore = assertVectorMinScore;
1445
1042
  exports.assertVectorSearchLimit = assertVectorSearchLimit;
1446
1043
  exports.buildFulltextCapabilities = buildFulltextCapabilities;
1447
- exports.buildPostgresEdgeIndexBuilders = buildPostgresEdgeIndexBuilders;
1448
- exports.buildPostgresNodeIndexBuilders = buildPostgresNodeIndexBuilders;
1449
- exports.buildSqliteEdgeIndexBuilders = buildSqliteEdgeIndexBuilders;
1450
- exports.buildSqliteNodeIndexBuilders = buildSqliteNodeIndexBuilders;
1451
1044
  exports.buildVectorCapabilities = buildVectorCapabilities;
1045
+ exports.compileEdgeIndexKeys = compileEdgeIndexKeys;
1452
1046
  exports.compileIndexWhere = compileIndexWhere;
1453
1047
  exports.compileNodeIndexFieldKeys = compileNodeIndexFieldKeys;
1048
+ exports.compileNodeIndexKeys = compileNodeIndexKeys;
1454
1049
  exports.edgeColumnList = edgeColumnList;
1455
1050
  exports.fts5Strategy = fts5Strategy;
1456
- exports.generateEdgeIndexDDL = generateEdgeIndexDDL;
1457
- exports.generateIndexDDL = generateIndexDDL;
1458
- exports.generateNodeIndexDDL = generateNodeIndexDDL;
1459
1051
  exports.getDialect = getDialect;
1460
1052
  exports.nodeColumnList = nodeColumnList;
1461
- exports.notWhere = notWhere;
1462
- exports.orWhere = orWhere;
1463
1053
  exports.quoteIdentifier = quoteIdentifier2;
1464
1054
  exports.quotedColumn = quotedColumn;
1465
1055
  exports.quotedTableName = quotedTableName;
1466
1056
  exports.sqlNull = sqlNull;
1467
- exports.toDeclaredIndex = toDeclaredIndex;
1468
- exports.toDeclaredIndexes = toDeclaredIndexes;
1469
1057
  exports.tsvectorStrategy = tsvectorStrategy;
1470
1058
  exports.vectorMinScoreCondition = vectorMinScoreCondition;
1471
1059
  exports.vectorPhysicalName = vectorPhysicalName;
1472
1060
  exports.vectorScoreExpression = vectorScoreExpression;
1473
- //# sourceMappingURL=chunk-UESTHN47.cjs.map
1474
- //# sourceMappingURL=chunk-UESTHN47.cjs.map
1061
+ //# sourceMappingURL=chunk-CFNT3ITG.cjs.map
1062
+ //# sourceMappingURL=chunk-CFNT3ITG.cjs.map