@nicia-ai/typegraph 0.39.0 → 0.41.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 (255) hide show
  1. package/dist/backend/drizzle/indexes.cjs +8 -10
  2. package/dist/backend/drizzle/indexes.d.cts +2 -2
  3. package/dist/backend/drizzle/indexes.d.ts +2 -2
  4. package/dist/backend/drizzle/indexes.js +4 -6
  5. package/dist/backend/index.cjs +60 -39
  6. package/dist/backend/index.d.cts +60 -1
  7. package/dist/backend/index.d.ts +60 -1
  8. package/dist/backend/index.js +12 -3
  9. package/dist/backend/postgres/index.cjs +24 -26
  10. package/dist/backend/postgres/index.d.cts +6 -6
  11. package/dist/backend/postgres/index.d.ts +6 -6
  12. package/dist/backend/postgres/index.js +11 -13
  13. package/dist/backend/postgres/pglite-store.cjs +25 -26
  14. package/dist/backend/postgres/pglite-store.cjs.map +1 -1
  15. package/dist/backend/postgres/pglite-store.d.cts +6 -5
  16. package/dist/backend/postgres/pglite-store.d.ts +6 -5
  17. package/dist/backend/postgres/pglite-store.js +21 -22
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +13 -15
  20. package/dist/backend/postgres/pglite.d.cts +3 -3
  21. package/dist/backend/postgres/pglite.d.ts +3 -3
  22. package/dist/backend/postgres/pglite.js +12 -14
  23. package/dist/backend/sqlite/index.cjs +25 -27
  24. package/dist/backend/sqlite/index.d.cts +6 -6
  25. package/dist/backend/sqlite/index.d.ts +6 -6
  26. package/dist/backend/sqlite/index.js +9 -11
  27. package/dist/backend/sqlite/libsql.cjs +15 -17
  28. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  29. package/dist/backend/sqlite/libsql.d.cts +3 -3
  30. package/dist/backend/sqlite/libsql.d.ts +3 -3
  31. package/dist/backend/sqlite/libsql.js +14 -16
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +26 -27
  34. package/dist/backend/sqlite/local-store.cjs.map +1 -1
  35. package/dist/backend/sqlite/local-store.d.cts +6 -5
  36. package/dist/backend/sqlite/local-store.d.ts +6 -5
  37. package/dist/backend/sqlite/local-store.js +22 -23
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +14 -16
  40. package/dist/backend/sqlite/local.d.cts +3 -3
  41. package/dist/backend/sqlite/local.d.ts +3 -3
  42. package/dist/backend/sqlite/local.js +12 -14
  43. package/dist/{chunk-U4JDJKPD.js → chunk-2I3DNNBU.js} +4 -4
  44. package/dist/{chunk-U4JDJKPD.js.map → chunk-2I3DNNBU.js.map} +1 -1
  45. package/dist/{chunk-NPWACFQJ.cjs → chunk-2J5NMMVR.cjs} +43 -43
  46. package/dist/{chunk-NPWACFQJ.cjs.map → chunk-2J5NMMVR.cjs.map} +1 -1
  47. package/dist/{chunk-3YFDFOYB.cjs → chunk-2X73QTIC.cjs} +12 -13
  48. package/dist/chunk-2X73QTIC.cjs.map +1 -0
  49. package/dist/chunk-3SHAUJRB.js +79 -0
  50. package/dist/chunk-3SHAUJRB.js.map +1 -0
  51. package/dist/{chunk-3SK4SVTW.js → chunk-53BSOG3O.js} +8 -7
  52. package/dist/chunk-53BSOG3O.js.map +1 -0
  53. package/dist/chunk-5J4VNCUD.js +856 -0
  54. package/dist/chunk-5J4VNCUD.js.map +1 -0
  55. package/dist/chunk-5YBDB7UG.cjs +12 -0
  56. package/dist/{chunk-FMNUSGZ4.cjs.map → chunk-5YBDB7UG.cjs.map} +1 -1
  57. package/dist/{chunk-6XDBRDZE.js → chunk-6N7QBIWN.js} +7 -3
  58. package/dist/chunk-6N7QBIWN.js.map +1 -0
  59. package/dist/{chunk-EZH7FNUS.js → chunk-6QP4QXBR.js} +3 -3
  60. package/dist/{chunk-EZH7FNUS.js.map → chunk-6QP4QXBR.js.map} +1 -1
  61. package/dist/{chunk-E6TXEISH.cjs → chunk-7UTUKH4E.cjs} +4 -4
  62. package/dist/{chunk-E6TXEISH.cjs.map → chunk-7UTUKH4E.cjs.map} +1 -1
  63. package/dist/chunk-7WLEQIHA.cjs +605 -0
  64. package/dist/chunk-7WLEQIHA.cjs.map +1 -0
  65. package/dist/{chunk-BQITNFQJ.js → chunk-AQVDAKXH.js} +3 -3
  66. package/dist/{chunk-BQITNFQJ.js.map → chunk-AQVDAKXH.js.map} +1 -1
  67. package/dist/{chunk-X6CNEA32.js → chunk-BUZWMDNL.js} +5 -5
  68. package/dist/{chunk-X6CNEA32.js.map → chunk-BUZWMDNL.js.map} +1 -1
  69. package/dist/{chunk-7M3NACL3.cjs → chunk-CKFBZ4LV.cjs} +4 -4
  70. package/dist/{chunk-7M3NACL3.cjs.map → chunk-CKFBZ4LV.cjs.map} +1 -1
  71. package/dist/{chunk-IFRPHG7O.js → chunk-EFZ4S22A.js} +10 -9
  72. package/dist/chunk-EFZ4S22A.js.map +1 -0
  73. package/dist/chunk-ELA3V6UN.js +601 -0
  74. package/dist/chunk-ELA3V6UN.js.map +1 -0
  75. package/dist/chunk-HAQVISUF.cjs +1098 -0
  76. package/dist/chunk-HAQVISUF.cjs.map +1 -0
  77. package/dist/{chunk-BKAKAVRW.cjs → chunk-HQRZEYYB.cjs} +44 -44
  78. package/dist/{chunk-BKAKAVRW.cjs.map → chunk-HQRZEYYB.cjs.map} +1 -1
  79. package/dist/{chunk-KAFXPB2L.js → chunk-I5CRUPKO.js} +9 -10
  80. package/dist/{chunk-KAFXPB2L.js.map → chunk-I5CRUPKO.js.map} +1 -1
  81. package/dist/{chunk-IFDXG2YJ.js → chunk-JHK6NPFV.js} +217 -305
  82. package/dist/chunk-JHK6NPFV.js.map +1 -0
  83. package/dist/{chunk-VXAFOF6Z.cjs → chunk-JP5EICR6.cjs} +12 -7
  84. package/dist/chunk-JP5EICR6.cjs.map +1 -0
  85. package/dist/chunk-JZYMOHHM.cjs +226 -0
  86. package/dist/chunk-JZYMOHHM.cjs.map +1 -0
  87. package/dist/{chunk-ERZ4QPQX.js → chunk-K6CD6W5J.js} +5 -5
  88. package/dist/{chunk-ERZ4QPQX.js.map → chunk-K6CD6W5J.js.map} +1 -1
  89. package/dist/{chunk-JD2YC62H.cjs → chunk-KHNKYSGP.cjs} +34 -34
  90. package/dist/{chunk-JD2YC62H.cjs.map → chunk-KHNKYSGP.cjs.map} +1 -1
  91. package/dist/{chunk-CWX77JB4.cjs → chunk-KLR77R5A.cjs} +13 -13
  92. package/dist/{chunk-CWX77JB4.cjs.map → chunk-KLR77R5A.cjs.map} +1 -1
  93. package/dist/chunk-KOI7UEI5.js +81 -0
  94. package/dist/chunk-KOI7UEI5.js.map +1 -0
  95. package/dist/{chunk-AOL64O4Z.js → chunk-L3DDZUZP.js} +3 -3
  96. package/dist/{chunk-AOL64O4Z.js.map → chunk-L3DDZUZP.js.map} +1 -1
  97. package/dist/{chunk-PZHC5GCD.js → chunk-L5ET7FYQ.js} +3 -3
  98. package/dist/{chunk-PZHC5GCD.js.map → chunk-L5ET7FYQ.js.map} +1 -1
  99. package/dist/{chunk-B63IFHXR.cjs → chunk-LFFVD5ZR.cjs} +41 -41
  100. package/dist/{chunk-B63IFHXR.cjs.map → chunk-LFFVD5ZR.cjs.map} +1 -1
  101. package/dist/chunk-LL5D5T5W.cjs +157 -0
  102. package/dist/chunk-LL5D5T5W.cjs.map +1 -0
  103. package/dist/{chunk-GUUWKPTK.cjs → chunk-LLE25NRD.cjs} +7 -7
  104. package/dist/{chunk-GUUWKPTK.cjs.map → chunk-LLE25NRD.cjs.map} +1 -1
  105. package/dist/chunk-LLHMAHG4.cjs +886 -0
  106. package/dist/chunk-LLHMAHG4.cjs.map +1 -0
  107. package/dist/{chunk-6SRLCSAV.cjs → chunk-LOKG3KQV.cjs} +962 -875
  108. package/dist/chunk-LOKG3KQV.cjs.map +1 -0
  109. package/dist/{chunk-KIZSHRUI.cjs → chunk-M2RPZS7J.cjs} +10 -10
  110. package/dist/{chunk-KIZSHRUI.cjs.map → chunk-M2RPZS7J.cjs.map} +1 -1
  111. package/dist/chunk-MNURF4RF.cjs +85 -0
  112. package/dist/chunk-MNURF4RF.cjs.map +1 -0
  113. package/dist/{chunk-CBK2IVI2.js → chunk-MQBF3XGY.js} +119 -32
  114. package/dist/chunk-MQBF3XGY.js.map +1 -0
  115. package/dist/chunk-QCKD3RCI.cjs +83 -0
  116. package/dist/chunk-QCKD3RCI.cjs.map +1 -0
  117. package/dist/chunk-QOHTVDHU.js +144 -0
  118. package/dist/chunk-QOHTVDHU.js.map +1 -0
  119. package/dist/{chunk-HTQOBY75.cjs → chunk-QXKVUJLI.cjs} +110 -109
  120. package/dist/chunk-QXKVUJLI.cjs.map +1 -0
  121. package/dist/{chunk-GNPGGLAE.cjs → chunk-QYDUCWD2.cjs} +4 -4
  122. package/dist/{chunk-GNPGGLAE.cjs.map → chunk-QYDUCWD2.cjs.map} +1 -1
  123. package/dist/{chunk-DOKUXLFH.js → chunk-QZYGZVUI.js} +34 -34
  124. package/dist/chunk-QZYGZVUI.js.map +1 -0
  125. package/dist/{chunk-GKQU44SQ.cjs → chunk-SAMJLDGG.cjs} +103 -103
  126. package/dist/{chunk-GKQU44SQ.cjs.map → chunk-SAMJLDGG.cjs.map} +1 -1
  127. package/dist/{chunk-DOVMTPKE.cjs → chunk-SE422RES.cjs} +27 -27
  128. package/dist/{chunk-DOVMTPKE.cjs.map → chunk-SE422RES.cjs.map} +1 -1
  129. package/dist/{chunk-5ELKD2FQ.cjs → chunk-UCHW2MGP.cjs} +330 -431
  130. package/dist/chunk-UCHW2MGP.cjs.map +1 -0
  131. package/dist/{chunk-Y6UA55YS.cjs → chunk-UDS5DZNY.cjs} +495 -1095
  132. package/dist/chunk-UDS5DZNY.cjs.map +1 -0
  133. package/dist/{chunk-SU7VQOJ3.js → chunk-V3S74J44.js} +9 -5
  134. package/dist/chunk-V3S74J44.js.map +1 -0
  135. package/dist/{chunk-VDYA2HMS.js → chunk-VWEFXG73.js} +3 -3
  136. package/dist/{chunk-VDYA2HMS.js.map → chunk-VWEFXG73.js.map} +1 -1
  137. package/dist/{chunk-KXFUQNF2.js → chunk-W66YCXWT.js} +463 -1047
  138. package/dist/chunk-W66YCXWT.js.map +1 -0
  139. package/dist/{chunk-NQBYTLPW.js → chunk-XMEYZYGE.js} +6 -6
  140. package/dist/{chunk-NQBYTLPW.js.map → chunk-XMEYZYGE.js.map} +1 -1
  141. package/dist/{chunk-G3CSQLLT.js → chunk-Y5UC3IXF.js} +461 -6
  142. package/dist/chunk-Y5UC3IXF.js.map +1 -0
  143. package/dist/{chunk-SDHV2MWU.js → chunk-YGX4PMG6.js} +5 -5
  144. package/dist/{chunk-SDHV2MWU.js.map → chunk-YGX4PMG6.js.map} +1 -1
  145. package/dist/{chunk-E2Q7SP2K.cjs → chunk-YIX3BEBR.cjs} +86 -85
  146. package/dist/chunk-YIX3BEBR.cjs.map +1 -0
  147. package/dist/{chunk-X6RDQ5NB.cjs → chunk-YX3H63VV.cjs} +8 -2
  148. package/dist/chunk-YX3H63VV.cjs.map +1 -0
  149. package/dist/chunk-YYLMXERH.js +211 -0
  150. package/dist/chunk-YYLMXERH.js.map +1 -0
  151. package/dist/{chunk-YPUNPG2T.js → chunk-ZE7E46IZ.js} +5 -5
  152. package/dist/{chunk-YPUNPG2T.js.map → chunk-ZE7E46IZ.js.map} +1 -1
  153. package/dist/{chunk-Z2PPIVOO.js → chunk-ZVME6OSV.js} +5 -5
  154. package/dist/{chunk-Z2PPIVOO.js.map → chunk-ZVME6OSV.js.map} +1 -1
  155. package/dist/core/index.cjs +15 -3
  156. package/dist/core/index.d.cts +4 -3
  157. package/dist/core/index.d.ts +4 -3
  158. package/dist/core/index.js +2 -2
  159. package/dist/{ddl-J6sDyABg.d.cts → ddl-BCXFRLWg.d.cts} +3 -3
  160. package/dist/{ddl-Dx3Z0_WC.d.ts → ddl-ByLmGgn9.d.ts} +3 -3
  161. package/dist/{define-graph-DRo9xpYN.d.ts → define-graph-BSviZubs.d.ts} +1 -1
  162. package/dist/{define-graph-CzEvA_8F.d.cts → define-graph-XyJheaFm.d.cts} +1 -1
  163. package/dist/graph-merge/index.cjs +37 -38
  164. package/dist/graph-merge/index.cjs.map +1 -1
  165. package/dist/graph-merge/index.d.cts +6 -5
  166. package/dist/graph-merge/index.d.ts +6 -5
  167. package/dist/graph-merge/index.js +15 -16
  168. package/dist/graph-merge/index.js.map +1 -1
  169. package/dist/index.cjs +146 -117
  170. package/dist/index.cjs.map +1 -1
  171. package/dist/index.d.cts +12 -10
  172. package/dist/index.d.ts +12 -10
  173. package/dist/index.js +23 -22
  174. package/dist/index.js.map +1 -1
  175. package/dist/indexes/index.cjs +12 -14
  176. package/dist/indexes/index.d.cts +5 -5
  177. package/dist/indexes/index.d.ts +5 -5
  178. package/dist/indexes/index.js +5 -7
  179. package/dist/interchange/index.cjs +28 -29
  180. package/dist/interchange/index.cjs.map +1 -1
  181. package/dist/interchange/index.d.cts +6 -5
  182. package/dist/interchange/index.d.ts +6 -5
  183. package/dist/interchange/index.js +9 -10
  184. package/dist/interchange/index.js.map +1 -1
  185. package/dist/{manager-CASfhmzV.d.ts → manager-C7iC5bk_.d.ts} +27 -3
  186. package/dist/{manager-nCEJiYBb.d.cts → manager-Dm6MCYO7.d.cts} +27 -3
  187. package/dist/{postgres-Cl1ZAN1G.d.ts → postgres-Cb6ceh4-.d.ts} +100 -49
  188. package/dist/{postgres-DMgIKQU-.d.cts → postgres-DZxwzCQ8.d.cts} +100 -49
  189. package/dist/profiler/index.d.cts +8 -7
  190. package/dist/profiler/index.d.ts +8 -7
  191. package/dist/provenance/index.cjs +19 -19
  192. package/dist/provenance/index.d.cts +6 -5
  193. package/dist/provenance/index.d.ts +6 -5
  194. package/dist/provenance/index.js +6 -6
  195. package/dist/schema/index.cjs +33 -101
  196. package/dist/schema/index.cjs.map +1 -1
  197. package/dist/schema/index.d.cts +55 -55
  198. package/dist/schema/index.d.ts +55 -55
  199. package/dist/schema/index.js +6 -86
  200. package/dist/schema/index.js.map +1 -1
  201. package/dist/{temporal-DqtOEo_B.d.ts → searchable-Cet4Oztt.d.ts} +3 -58
  202. package/dist/{temporal-BC_NQV5Y.d.cts → searchable-aUaKh3_r.d.cts} +3 -58
  203. package/dist/{sqlite-BDkW39aa.d.cts → sqlite-Cb3Ilj9_.d.ts} +124 -97
  204. package/dist/{sqlite-CYfhvESj.d.ts → sqlite-Dxklpizv.d.cts} +124 -97
  205. package/dist/{store-view-CLIhwMMX.d.ts → store-view-BDjGFjpN.d.ts} +67 -23
  206. package/dist/{store-view-BJd6Vwpt.d.cts → store-view-PCT7vTKH.d.cts} +67 -23
  207. package/dist/temporal-CyFsSPe8.d.ts +73 -0
  208. package/dist/temporal-Dn_JADWY.d.cts +73 -0
  209. package/dist/{types-CUevi_D1.d.ts → types-CFZiEEPh.d.ts} +1 -1
  210. package/dist/{types-COq3-vMC.d.cts → types-CsaG00wS.d.cts} +1 -1
  211. package/dist/{index-Bq7vSPHy.d.ts → types-D-vOo_pM.d.ts} +2 -2
  212. package/dist/{index-CrFL_ENI.d.cts → types-ho4DJJb_.d.cts} +2 -2
  213. package/dist/{where-BdE_cYtx.d.ts → where-DLYaXa4L.d.ts} +1 -1
  214. package/dist/{where-C92TXCzT.d.cts → where-udes1WRA.d.cts} +1 -1
  215. package/package.json +1 -1
  216. package/dist/chunk-3SK4SVTW.js.map +0 -1
  217. package/dist/chunk-3YFDFOYB.cjs.map +0 -1
  218. package/dist/chunk-5ELKD2FQ.cjs.map +0 -1
  219. package/dist/chunk-6SRLCSAV.cjs.map +0 -1
  220. package/dist/chunk-6XDBRDZE.js.map +0 -1
  221. package/dist/chunk-CBK2IVI2.js.map +0 -1
  222. package/dist/chunk-DDCIXXOO.js +0 -9
  223. package/dist/chunk-DDCIXXOO.js.map +0 -1
  224. package/dist/chunk-DDCYVIVV.cjs +0 -44
  225. package/dist/chunk-DDCYVIVV.cjs.map +0 -1
  226. package/dist/chunk-DOKUXLFH.js.map +0 -1
  227. package/dist/chunk-E2Q7SP2K.cjs.map +0 -1
  228. package/dist/chunk-EOJFGECD.cjs +0 -284
  229. package/dist/chunk-EOJFGECD.cjs.map +0 -1
  230. package/dist/chunk-FMNUSGZ4.cjs +0 -12
  231. package/dist/chunk-G3CSQLLT.js.map +0 -1
  232. package/dist/chunk-HTQOBY75.cjs.map +0 -1
  233. package/dist/chunk-I6FX7AAG.js +0 -39
  234. package/dist/chunk-I6FX7AAG.js.map +0 -1
  235. package/dist/chunk-IFDXG2YJ.js.map +0 -1
  236. package/dist/chunk-IFRPHG7O.js.map +0 -1
  237. package/dist/chunk-J6IJARLG.js +0 -94
  238. package/dist/chunk-J6IJARLG.js.map +0 -1
  239. package/dist/chunk-KXFUQNF2.js.map +0 -1
  240. package/dist/chunk-MTNEGGM2.js +0 -273
  241. package/dist/chunk-MTNEGGM2.js.map +0 -1
  242. package/dist/chunk-SU7VQOJ3.js.map +0 -1
  243. package/dist/chunk-SVUKGWSN.cjs +0 -102
  244. package/dist/chunk-SVUKGWSN.cjs.map +0 -1
  245. package/dist/chunk-UH2USOMG.cjs +0 -627
  246. package/dist/chunk-UH2USOMG.cjs.map +0 -1
  247. package/dist/chunk-VXAFOF6Z.cjs.map +0 -1
  248. package/dist/chunk-X6RDQ5NB.cjs.map +0 -1
  249. package/dist/chunk-Y6UA55YS.cjs.map +0 -1
  250. package/dist/chunk-Y7M44XEK.js +0 -462
  251. package/dist/chunk-Y7M44XEK.js.map +0 -1
  252. package/dist/chunk-Z5QHVL5U.cjs +0 -12
  253. package/dist/chunk-Z5QHVL5U.cjs.map +0 -1
  254. package/dist/chunk-ZKZAIX42.cjs +0 -479
  255. package/dist/chunk-ZKZAIX42.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkHTQOBY75_cjs = require('./chunk-HTQOBY75.cjs');
4
- var chunkY6UA55YS_cjs = require('./chunk-Y6UA55YS.cjs');
5
- var chunkGNPGGLAE_cjs = require('./chunk-GNPGGLAE.cjs');
3
+ var chunkQXKVUJLI_cjs = require('./chunk-QXKVUJLI.cjs');
4
+ var chunkLLHMAHG4_cjs = require('./chunk-LLHMAHG4.cjs');
5
+ var chunkQYDUCWD2_cjs = require('./chunk-QYDUCWD2.cjs');
6
6
  var chunkSAFZ6JTI_cjs = require('./chunk-SAFZ6JTI.cjs');
7
7
  var pglite = require('@electric-sql/pglite');
8
8
  var pglite$1 = require('drizzle-orm/pglite');
@@ -20,7 +20,7 @@ async function loadDefaultPgvectorExtension() {
20
20
  }
21
21
  }
22
22
  async function createLocalPgliteBackend(options = {}) {
23
- const tables2 = options.tables ?? chunkY6UA55YS_cjs.tables;
23
+ const tables2 = options.tables ?? chunkLLHMAHG4_cjs.tables;
24
24
  const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
25
25
  const vectorEnabled = vectorExtension !== void 0;
26
26
  const client = await pglite.PGlite.create({
@@ -28,22 +28,22 @@ async function createLocalPgliteBackend(options = {}) {
28
28
  ...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
29
29
  });
30
30
  try {
31
- const migrationSql = vectorEnabled ? chunkY6UA55YS_cjs.generatePostgresMigrationSQL(tables2) : chunkY6UA55YS_cjs.generatePostgresDDL(tables2).join("\n\n");
31
+ const migrationSql = vectorEnabled ? chunkLLHMAHG4_cjs.generatePostgresMigrationSQL(tables2) : chunkLLHMAHG4_cjs.generatePostgresDDL(tables2).join("\n\n");
32
32
  await client.exec(migrationSql);
33
33
  const db = pglite$1.drizzle(client);
34
- const backend = chunkHTQOBY75_cjs.createPostgresBackend(db, {
34
+ const backend = chunkQXKVUJLI_cjs.createPostgresBackend(db, {
35
35
  tables: tables2,
36
36
  ...vectorEnabled ? {} : { vector: false }
37
37
  });
38
- const managedBackend = chunkGNPGGLAE_cjs.wrapWithManagedClose(backend, async () => {
38
+ const managedBackend = chunkQYDUCWD2_cjs.wrapWithManagedClose(backend, async () => {
39
39
  await client.close();
40
40
  });
41
41
  return { backend: managedBackend, db, client };
42
42
  } catch (error) {
43
- return chunkGNPGGLAE_cjs.closeAfterFailure(client, error);
43
+ return chunkQYDUCWD2_cjs.closeAfterFailure(client, error);
44
44
  }
45
45
  }
46
46
 
47
47
  exports.createLocalPgliteBackend = createLocalPgliteBackend;
48
- //# sourceMappingURL=chunk-KIZSHRUI.cjs.map
49
- //# sourceMappingURL=chunk-KIZSHRUI.cjs.map
48
+ //# sourceMappingURL=chunk-M2RPZS7J.cjs.map
49
+ //# sourceMappingURL=chunk-M2RPZS7J.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose","closeAfterFailure"],"mappings":";;;;;;;;;AAiIA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAED,EAAA,IAAI;AAGF,IAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,IAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,IAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,MACxC,MAAA,EAAAL,OAAAA;AAAA,MACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,KAC1C,CAAA;AACD,IAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,mCAAA,CAAkB,QAAQ,KAAK,CAAA;AAAA,EACxC;AACF","file":"chunk-KIZSHRUI.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport { type AnyPgTransaction } from \"../drizzle/execution\";\nexport type { AnyPgDatabase, AnyPgTransaction } from \"../drizzle/execution\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport {\n type AdapterBackend,\n closeAfterFailure,\n wrapWithManagedClose,\n} from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: AdapterBackend<AnyPgTransaction>;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n try {\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n } catch (error) {\n return closeAfterFailure(client, error);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose","closeAfterFailure"],"mappings":";;;;;;;;;AAiIA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAED,EAAA,IAAI;AAGF,IAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,IAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,IAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,MACxC,MAAA,EAAAL,OAAAA;AAAA,MACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,KAC1C,CAAA;AACD,IAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,mCAAA,CAAkB,QAAQ,KAAK,CAAA;AAAA,EACxC;AACF","file":"chunk-M2RPZS7J.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport { type AnyPgTransaction } from \"../drizzle/execution\";\nexport type { AnyPgDatabase, AnyPgTransaction } from \"../drizzle/execution\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport {\n type AdapterBackend,\n closeAfterFailure,\n wrapWithManagedClose,\n} from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: AdapterBackend<AnyPgTransaction>;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n try {\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n } catch (error) {\n return closeAfterFailure(client, error);\n }\n}\n"]}
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ var chunkSAFZ6JTI_cjs = require('./chunk-SAFZ6JTI.cjs');
4
+
5
+ // src/utils/date.ts
6
+ var CANONICAL_ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
7
+ var ZONELESS_DATETIME_PATTERN = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;
8
+ var OFFSET_DATETIME_PATTERN = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)(Z|[+-]\d{2}(?::?\d{2})?)$/i;
9
+ var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
10
+ function normalizedOffset(offset) {
11
+ if (offset.toUpperCase() === "Z") return "Z";
12
+ if (/^[+-]\d{2}$/.test(offset)) return `${offset}:00`;
13
+ if (/^[+-]\d{4}$/.test(offset)) {
14
+ return `${offset.slice(0, 3)}:${offset.slice(3)}`;
15
+ }
16
+ return offset;
17
+ }
18
+ function databaseTimestampMilliseconds(value) {
19
+ if (ZONELESS_DATETIME_PATTERN.test(value)) {
20
+ return Date.parse(`${value.replace(" ", "T")}Z`);
21
+ }
22
+ const offsetMatch = OFFSET_DATETIME_PATTERN.exec(value);
23
+ if (offsetMatch !== null) {
24
+ const date = offsetMatch[1];
25
+ const time = offsetMatch[2];
26
+ const offset = offsetMatch[3];
27
+ if (date === void 0 || time === void 0 || offset === void 0) {
28
+ return Number.NaN;
29
+ }
30
+ return Date.parse(`${date}T${time}${normalizedOffset(offset)}`);
31
+ }
32
+ if (DATE_ONLY_PATTERN.test(value)) {
33
+ return Date.parse(`${value}T00:00:00.000Z`);
34
+ }
35
+ return Number.NaN;
36
+ }
37
+ function canonicalizeDatabaseTimestamp(value) {
38
+ if (value instanceof Date) {
39
+ if (Number.isNaN(value.getTime())) return void 0;
40
+ return value.toISOString();
41
+ }
42
+ if (typeof value !== "string") return void 0;
43
+ const milliseconds = databaseTimestampMilliseconds(value);
44
+ if (Number.isNaN(milliseconds)) return void 0;
45
+ return new Date(milliseconds).toISOString();
46
+ }
47
+ function isCanonicalIsoDate(value) {
48
+ if (!CANONICAL_ISO_DATE_PATTERN.test(value)) return false;
49
+ const date = new Date(value);
50
+ return !Number.isNaN(date.getTime()) && date.toISOString() === value;
51
+ }
52
+ function validateCanonicalIsoDate(value, fieldName) {
53
+ if (!isCanonicalIsoDate(value)) {
54
+ throw new chunkSAFZ6JTI_cjs.ValidationError(
55
+ `Invalid canonical ISO 8601 datetime for "${fieldName}": "${value}". Expected fixed-width UTC: YYYY-MM-DDTHH:mm:ss.sssZ`,
56
+ {
57
+ issues: [
58
+ {
59
+ path: fieldName,
60
+ message: `Expected canonical UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), got: "${value}"`
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ suggestion: `Use a fixed-width UTC datetime like "2024-01-15T10:30:00.000Z" (e.g. new Date(value).toISOString()).`
66
+ }
67
+ );
68
+ }
69
+ return value;
70
+ }
71
+ function validateOptionalCanonicalIsoDate(value, fieldName) {
72
+ if (value === void 0) return void 0;
73
+ return validateCanonicalIsoDate(value, fieldName);
74
+ }
75
+ function nowIso() {
76
+ return (/* @__PURE__ */ new Date()).toISOString();
77
+ }
78
+
79
+ exports.canonicalizeDatabaseTimestamp = canonicalizeDatabaseTimestamp;
80
+ exports.isCanonicalIsoDate = isCanonicalIsoDate;
81
+ exports.nowIso = nowIso;
82
+ exports.validateCanonicalIsoDate = validateCanonicalIsoDate;
83
+ exports.validateOptionalCanonicalIsoDate = validateOptionalCanonicalIsoDate;
84
+ //# sourceMappingURL=chunk-MNURF4RF.cjs.map
85
+ //# sourceMappingURL=chunk-MNURF4RF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/date.ts"],"names":["ValidationError"],"mappings":";;;;;AAyEA,IAAM,0BAAA,GACJ,+CAAA;AAEF,IAAM,yBAAA,GACJ,yDAAA;AACF,IAAM,uBAAA,GACJ,uFAAA;AACF,IAAM,iBAAA,GAAoB,qBAAA;AAE1B,SAAS,iBAAiB,MAAA,EAAwB;AAChD,EAAA,IAAI,MAAA,CAAO,WAAA,EAAY,KAAM,GAAA,EAAK,OAAO,GAAA;AACzC,EAAA,IAAI,cAAc,IAAA,CAAK,MAAM,CAAA,EAAG,OAAO,GAAG,MAAM,CAAA,GAAA,CAAA;AAChD,EAAA,IAAI,aAAA,CAAc,IAAA,CAAK,MAAM,CAAA,EAAG;AAC9B,IAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,8BAA8B,KAAA,EAAuB;AAC5D,EAAA,IAAI,yBAAA,CAA0B,IAAA,CAAK,KAAK,CAAA,EAAG;AACzC,IAAA,OAAO,IAAA,CAAK,MAAM,CAAA,EAAG,KAAA,CAAM,QAAQ,GAAA,EAAK,GAAG,CAAC,CAAA,CAAA,CAAG,CAAA;AAAA,EACjD;AACA,EAAA,MAAM,WAAA,GAAc,uBAAA,CAAwB,IAAA,CAAK,KAAK,CAAA;AACtD,EAAA,IAAI,gBAAgB,IAAA,EAAM;AACxB,IAAA,MAAM,IAAA,GAAO,YAAY,CAAC,CAAA;AAC1B,IAAA,MAAM,IAAA,GAAO,YAAY,CAAC,CAAA;AAC1B,IAAA,MAAM,MAAA,GAAS,YAAY,CAAC,CAAA;AAC5B,IAAA,IAAI,IAAA,KAAS,MAAA,IAAa,IAAA,KAAS,MAAA,IAAa,WAAW,MAAA,EAAW;AACpE,MAAA,OAAO,MAAA,CAAO,GAAA;AAAA,IAChB;AACA,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,IAAI,CAAA,EAAG,gBAAA,CAAiB,MAAM,CAAC,CAAA,CAAE,CAAA;AAAA,EAChE;AACA,EAAA,IAAI,iBAAA,CAAkB,IAAA,CAAK,KAAK,CAAA,EAAG;AACjC,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA,cAAA,CAAgB,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,MAAA,CAAO,GAAA;AAChB;AAWO,SAAS,8BACd,KAAA,EACoB;AACpB,EAAA,IAAI,iBAAiB,IAAA,EAAM;AACzB,IAAA,IAAI,OAAO,KAAA,CAAM,KAAA,CAAM,OAAA,EAAS,GAAG,OAAO,MAAA;AAC1C,IAAA,OAAO,MAAM,WAAA,EAAY;AAAA,EAC3B;AACA,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,MAAA;AACtC,EAAA,MAAM,YAAA,GAAe,8BAA8B,KAAK,CAAA;AACxD,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,YAAY,CAAA,EAAG,OAAO,MAAA;AACvC,EAAA,OAAO,IAAI,IAAA,CAAK,YAAY,CAAA,CAAE,WAAA,EAAY;AAC5C;AAMO,SAAS,mBAAmB,KAAA,EAAwB;AACzD,EAAA,IAAI,CAAC,0BAAA,CAA2B,IAAA,CAAK,KAAK,GAAG,OAAO,KAAA;AACpD,EAAA,MAAM,IAAA,GAAO,IAAI,IAAA,CAAK,KAAK,CAAA;AAC3B,EAAA,OAAO,CAAC,OAAO,KAAA,CAAM,IAAA,CAAK,SAAS,CAAA,IAAK,IAAA,CAAK,WAAA,EAAY,KAAM,KAAA;AACjE;AAgBO,SAAS,wBAAA,CACd,OACA,SAAA,EACQ;AACR,EAAA,IAAI,CAAC,kBAAA,CAAmB,KAAK,CAAA,EAAG;AAC9B,IAAA,MAAM,IAAIA,iCAAA;AAAA,MACR,CAAA,yCAAA,EAA4C,SAAS,CAAA,IAAA,EAAO,KAAK,CAAA,qDAAA,CAAA;AAAA,MAEjE;AAAA,QACE,MAAA,EAAQ;AAAA,UACN;AAAA,YACE,IAAA,EAAM,SAAA;AAAA,YACN,OAAA,EAAS,qEAAqE,KAAK,CAAA,CAAA;AAAA;AACrF;AACF,OACF;AAAA,MACA;AAAA,QACE,UAAA,EAAY,CAAA,oGAAA;AAAA;AACd,KACF;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAUO,SAAS,gCAAA,CACd,OACA,SAAA,EACoB;AACpB,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,MAAA;AAChC,EAAA,OAAO,wBAAA,CAAyB,OAAO,SAAS,CAAA;AAClD;AAuBO,SAAS,MAAA,GAAiB;AAC/B,EAAA,OAAA,iBAAO,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AAChC","file":"chunk-MNURF4RF.cjs","sourcesContent":["/**\n * Date encoding utilities for consistent storage.\n *\n * Contract: All dates are stored as ISO 8601 strings in UTC.\n * - Always includes milliseconds\n * - Always UTC (Z suffix)\n * - Sorts correctly as strings\n */\n\nimport { ValidationError } from \"../errors\";\n\n/**\n * ISO 8601 datetime pattern.\n * Matches formats like:\n * - 2024-01-15T10:30:00.000Z\n * - 2024-01-15T10:30:00Z\n * - 2024-01-15T10:30:00.123Z\n */\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?Z$/;\n\n/**\n * Checks if a string is a valid ISO 8601 datetime.\n *\n * @param value - String to validate\n * @returns True if valid ISO 8601 datetime\n */\nexport function isValidIsoDate(value: string): boolean {\n if (!ISO_DATE_PATTERN.test(value)) {\n return false;\n }\n // Also check that Date parsing produces a valid date\n const date = new Date(value);\n return !Number.isNaN(date.getTime());\n}\n\n/**\n * Validates that a string is a valid ISO 8601 datetime.\n * Throws ValidationError if invalid.\n *\n * @param value - String to validate\n * @param fieldName - Name of field for error message\n * @returns The validated string\n * @throws ValidationError if not a valid ISO datetime\n */\nexport function validateIsoDate(value: string, fieldName: string): string {\n if (!isValidIsoDate(value)) {\n throw new ValidationError(\n `Invalid ISO 8601 datetime for \"${fieldName}\": \"${value}\". ` +\n `Expected format: YYYY-MM-DDTHH:mm:ss.sssZ`,\n {\n issues: [\n {\n path: fieldName,\n message: `Invalid ISO 8601 datetime format. Expected: YYYY-MM-DDTHH:mm:ss.sssZ, got: \"${value}\"`,\n },\n ],\n },\n {\n suggestion: `Use a valid ISO 8601 UTC datetime like \"2024-01-15T10:30:00.000Z\"`,\n },\n );\n }\n return value;\n}\n\n/**\n * Strict canonical ISO 8601 pattern: fixed-width UTC with exactly\n * millisecond precision (`YYYY-MM-DDTHH:mm:ss.sssZ`). Unlike\n * {@link ISO_DATE_PATTERN}, which tolerates a missing or variable-width\n * fractional part, this is the only shape whose lexicographic text order\n * matches chronological order — avoiding cases like `\"...:00.1Z\"` (= `.100`)\n * sorting *after* `\"...:00.101Z\"`.\n */\nconst CANONICAL_ISO_DATE_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/;\n\nconst ZONELESS_DATETIME_PATTERN =\n /^\\d{4}-\\d{2}-\\d{2}[ T]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?$/;\nconst OFFSET_DATETIME_PATTERN =\n /^(\\d{4}-\\d{2}-\\d{2})[ T](\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?)(Z|[+-]\\d{2}(?::?\\d{2})?)$/i;\nconst DATE_ONLY_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nfunction normalizedOffset(offset: string): string {\n if (offset.toUpperCase() === \"Z\") return \"Z\";\n if (/^[+-]\\d{2}$/.test(offset)) return `${offset}:00`;\n if (/^[+-]\\d{4}$/.test(offset)) {\n return `${offset.slice(0, 3)}:${offset.slice(3)}`;\n }\n return offset;\n}\n\nfunction databaseTimestampMilliseconds(value: string): number {\n if (ZONELESS_DATETIME_PATTERN.test(value)) {\n return Date.parse(`${value.replace(\" \", \"T\")}Z`);\n }\n const offsetMatch = OFFSET_DATETIME_PATTERN.exec(value);\n if (offsetMatch !== null) {\n const date = offsetMatch[1];\n const time = offsetMatch[2];\n const offset = offsetMatch[3];\n if (date === undefined || time === undefined || offset === undefined) {\n return Number.NaN;\n }\n return Date.parse(`${date}T${time}${normalizedOffset(offset)}`);\n }\n if (DATE_ONLY_PATTERN.test(value)) {\n return Date.parse(`${value}T00:00:00.000Z`);\n }\n return Number.NaN;\n}\n\n/**\n * Canonicalizes a database-driver timestamp without interpreting a zoneless\n * string in the host timezone. PostgreSQL drivers can return values such as\n * `2026-06-25 12:00:00`; TypeGraph treats that shape as UTC so the same stored\n * clock value cannot move across hosts or daylight-saving boundaries.\n *\n * Returns `undefined` for an unsupported or unrepresentable value so callers\n * can raise an error specific to their storage boundary.\n */\nexport function canonicalizeDatabaseTimestamp(\n value: unknown,\n): string | undefined {\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) return undefined;\n return value.toISOString();\n }\n if (typeof value !== \"string\") return undefined;\n const milliseconds = databaseTimestampMilliseconds(value);\n if (Number.isNaN(milliseconds)) return undefined;\n return new Date(milliseconds).toISOString();\n}\n\n/**\n * Checks if a string is a canonical UTC ISO 8601 datetime with fixed\n * millisecond width (`YYYY-MM-DDTHH:mm:ss.sssZ`).\n */\nexport function isCanonicalIsoDate(value: string): boolean {\n if (!CANONICAL_ISO_DATE_PATTERN.test(value)) return false;\n const date = new Date(value);\n return !Number.isNaN(date.getTime()) && date.toISOString() === value;\n}\n\n/**\n * Validates that a string is a canonical UTC ISO 8601 datetime with fixed\n * millisecond width. Stricter than {@link validateIsoDate} (which also\n * accepts missing or 1–2 digit milliseconds): required wherever the value\n * is compared **as text** against stored timestamps and must sort\n * chronologically — e.g. a temporal `asOf` coordinate, where a\n * variable-width value would mis-order and silently include or exclude the\n * wrong rows. Produce one with `new Date(value).toISOString()`.\n *\n * @param value - String to validate\n * @param fieldName - Name of field for error message\n * @returns The validated string\n * @throws ValidationError if not a canonical UTC ISO datetime\n */\nexport function validateCanonicalIsoDate(\n value: string,\n fieldName: string,\n): string {\n if (!isCanonicalIsoDate(value)) {\n throw new ValidationError(\n `Invalid canonical ISO 8601 datetime for \"${fieldName}\": \"${value}\". ` +\n `Expected fixed-width UTC: YYYY-MM-DDTHH:mm:ss.sssZ`,\n {\n issues: [\n {\n path: fieldName,\n message: `Expected canonical UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), got: \"${value}\"`,\n },\n ],\n },\n {\n suggestion: `Use a fixed-width UTC datetime like \"2024-01-15T10:30:00.000Z\" (e.g. new Date(value).toISOString()).`,\n },\n );\n }\n return value;\n}\n\n/**\n * Validates an optional canonical ISO date string. Returns `undefined` for an\n * absent value; otherwise enforces canonical fixed-width UTC ISO 8601 via\n * {@link validateCanonicalIsoDate}. Used for stored validity-window inputs\n * (`validFrom` / `validTo`) so every timestamp the temporal filters compare as\n * text is canonical and sorts chronologically — the same contract the `asOf`\n * read coordinate already enforces.\n */\nexport function validateOptionalCanonicalIsoDate(\n value: string | undefined,\n fieldName: string,\n): string | undefined {\n if (value === undefined) return undefined;\n return validateCanonicalIsoDate(value, fieldName);\n}\n\n/**\n * Encodes a Date to an ISO 8601 string for storage.\n */\nexport function encodeDate(date: Date): string {\n return date.toISOString();\n}\n\n/**\n * Decodes an ISO 8601 string to a Date.\n * Validates the string format first.\n *\n * @throws ValidationError if not a valid ISO datetime\n */\nexport function decodeDate(isoString: string): Date {\n validateIsoDate(isoString, \"date\");\n return new Date(isoString);\n}\n\n/**\n * Returns the current timestamp as an ISO string.\n */\nexport function nowIso(): string {\n return new Date().toISOString();\n}\n"]}
@@ -1,25 +1,25 @@
1
1
  import { compareStrings, compareCodePoints } from './chunk-DRACN6XG.js';
2
- import { createEdgeRowMapper, createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, POSTGRES_ROW_MAPPER_CONFIG } from './chunk-AOL64O4Z.js';
3
- import { rowToNode, executeNodeBulkFindByIndex, executeNodeBulkFindByConstraint, executeNodeFindByConstraint, executeNodeBulkGetOrCreateByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeDelete, nodeUpsertDirtyCheck, executeNodeUpsertUpdate, executeNodeUpdate, executeNodeCreateNoReturnBatch, executeNodeCreateBatch, executeNodeCreate, rowToEdge, runInWriteTransaction, checkCardinalityConstraint, runHookedWriteOperation, rowToNodeMeta, rowToEdgeMeta } from './chunk-3SK4SVTW.js';
4
- import { isParameterRef, fieldRef, buildFieldBuilderForTypeInfo, stringField, createFulltextAccessor, storeRuntime, CURRENT_READ_INSTANT_PLACEHOLDER, DEFAULT_SQL_SCHEMA, requireSqlSchema, recordedReadSchemaFor, withPinnedReadInstant, STORE_RUNTIME, assertRevisionTrackableBackend, createSqlSchema, requireExternalRecordedReadSource, createRecordedReadBinding, createRecordedBackend, readRecordedClock, ensureRevisionOrigin, TRANSACTION_RUNTIME, withRecordedFlushObserver, recordedCaptureRequiresCallbackTransactionError, assertRecordedCaptureTransactionIsolation, createRecordedTransactionScope, lockRecordedGraphWrite, generateId, createGraphBackendProjection, vectorSlotKey, baseField, objectField, arrayField, dateField, numberField, computeFulltextContent, AUTO_REFRESH_STATISTICS_ROW_THRESHOLD, advanceRevisionClock, recordedReadSqlSchema, requireRecordedReadBinding, runInsertBatch, edgeInsertDispatch, runInsertBatchReturning, projectBackendMembers, sqlValueList, getEmbeddingFields, getNodeRowsByIds, getEdgeRowsByIds, compileKindFilter, currentReadInstant, compileTemporalFilter, validateEdgeEndpoints, buildPredicateIndex, compileFieldValue, recordedBindParamBudget, extractVectorSimilarityPredicates, extractFulltextMatchPredicates, currentReadInstantFor, extractTemporalOptions, compilePredicateExpression, getPredicatesForAlias, getFieldPointer, getNodeKindsForAlias, getHybridTargetAlias, closeRecordedHardDeletedKind, throwHistoryUnsafeSqlAccess, throwRevisionTrackingUnsafeSqlAccess, compilePredicateClauses, ALIAS_CTE_PREFIX, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS } from './chunk-IFDXG2YJ.js';
2
+ import { createEdgeRowMapper, createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, POSTGRES_ROW_MAPPER_CONFIG } from './chunk-L3DDZUZP.js';
3
+ import { rowToNode, executeNodeBulkFindByIndex, executeNodeBulkFindByConstraint, executeNodeFindByConstraint, executeNodeBulkGetOrCreateByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeDelete, nodeUpsertDirtyCheck, executeNodeUpsertUpdate, executeNodeUpdate, executeNodeCreateNoReturnBatch, executeNodeCreateBatch, executeNodeCreate, rowToEdge, runInWriteTransaction, checkCardinalityConstraint, runHookedWriteOperation, rowToNodeMeta, rowToEdgeMeta } from './chunk-53BSOG3O.js';
4
+ import { isParameterRef, fieldRef, buildFieldBuilderForTypeInfo, stringField, createFulltextAccessor, storeRuntime, CURRENT_READ_INSTANT_PLACEHOLDER, withPinnedReadInstant, STORE_RUNTIME, assertRevisionTrackableBackend, createRecordedBackend, readRecordedClock, ensureRevisionOrigin, TRANSACTION_RUNTIME, withRecordedFlushObserver, recordedCaptureRequiresCallbackTransactionError, assertRecordedCaptureTransactionIsolation, createRecordedTransactionScope, lockRecordedGraphWrite, generateId, createGraphBackendProjection, assertCurrentRecordedSchema, baseField, objectField, arrayField, dateField, numberField, computeFulltextContent, AUTO_REFRESH_STATISTICS_ROW_THRESHOLD, advanceRevisionClock, runInsertBatch, edgeInsertDispatch, runInsertBatchReturning, projectBackendMembers, sqlValueList, getEmbeddingFields, getNodeRowsByIds, getEdgeRowsByIds, compileKindFilter, currentReadInstant, compileTemporalFilter, validateEdgeEndpoints, buildPredicateIndex, compileFieldValue, recordedBindParamBudget, extractVectorSimilarityPredicates, extractFulltextMatchPredicates, currentReadInstantFor, extractTemporalOptions, compilePredicateExpression, getPredicatesForAlias, getFieldPointer, getNodeKindsForAlias, getHybridTargetAlias, closeRecordedHardDeletedKind, throwHistoryUnsafeSqlAccess, throwRevisionTrackingUnsafeSqlAccess, compilePredicateClauses } from './chunk-JHK6NPFV.js';
5
5
  import { chunk } from './chunk-35S6P5ZU.js';
6
- import { runOptionallyInTransaction, createTransactionReadBackend, rowPropsToObject, createBackendOverlay, INTERNAL_TEMPORARY_WRITES } from './chunk-PZHC5GCD.js';
7
- import { resolveReadCoordinate, withRecordedCoordinate, describeCoordinate, coordinateContext, asRecordedInstant, assertValidRecordedInstant } from './chunk-J6IJARLG.js';
8
- import { loadAndMergeGraphExtensionDocument, ensureSchema, loadAndVerifyGraph, buildKindRegistry, mergeGraphExtension, commitNewSchemaVersion, applyDeprecatedKinds, loadActiveSchemaWithBootstrap, parseSerializedSchema, extensionKindNames, serializeSchemaProperties, buildGraphExtensionOntologyKeySet, compileTimeOntologyKey, serializeIndexDeclaration } from './chunk-SU7VQOJ3.js';
6
+ import { DEFAULT_SQL_SCHEMA, requireSqlSchema, recordedReadSchemaFor, createSqlSchema, requireExternalRecordedReadSource, createRecordedReadBinding, vectorSlotKey, recordedReadSqlSchema, requireRecordedReadBinding, ALIAS_CTE_PREFIX, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS } from './chunk-YYLMXERH.js';
7
+ import { runOptionallyInTransaction, createTransactionReadBackend, rowPropsToObject, createBackendOverlay, INTERNAL_TEMPORARY_WRITES } from './chunk-L5ET7FYQ.js';
8
+ import { resolveReadCoordinate, withRecordedCoordinate, describeCoordinate, coordinateContext, recordedInstantWallTime, asRecordedInstant, assertValidRecordedInstant } from './chunk-QOHTVDHU.js';
9
+ import { loadAndMergeGraphExtensionDocument, ensureSchema, loadAndVerifyGraph, buildKindRegistry, mergeGraphExtension, commitNewSchemaVersion, applyDeprecatedKinds, loadActiveSchemaWithBootstrap, parseSerializedSchema, extensionKindNames, serializeSchemaProperties, buildGraphExtensionOntologyKeySet, compileTimeOntologyKey, serializeIndexDeclaration } from './chunk-V3S74J44.js';
9
10
  import { getTypeName } from './chunk-76HE7DJP.js';
10
11
  import { validateEdgeProps } from './chunk-ZE6NVENI.js';
11
12
  import { canonicalEqual, sortedReplacer } from './chunk-UR7W5YQK.js';
12
13
  import { withRecordedRelationsPrecondition, isMissingTableError } from './chunk-UUIBACKJ.js';
13
14
  import { isKnownKind } from './chunk-PH4IJ3V5.js';
14
- import { nowIso, validateOptionalCanonicalIsoDate } from './chunk-I6FX7AAG.js';
15
- import { generateIndexDDL } from './chunk-U4JDJKPD.js';
16
- import { SYSTEM_INDEX_DECLARATIONS, resolveSystemIndexTableName, systemIndexName, resolveSystemIndexNames, generateSystemIndexDDL } from './chunk-BQITNFQJ.js';
17
- import { NODE_META_KEYS, EDGE_META_KEYS } from './chunk-VDYA2HMS.js';
15
+ import { nowIso, validateOptionalCanonicalIsoDate } from './chunk-3SHAUJRB.js';
16
+ import { generateIndexDDL } from './chunk-2I3DNNBU.js';
17
+ import { SYSTEM_INDEX_DECLARATIONS, resolveSystemIndexTableName, systemIndexName, resolveSystemIndexNames, generateSystemIndexDDL } from './chunk-AQVDAKXH.js';
18
+ import { NODE_META_KEYS, EDGE_META_KEYS } from './chunk-VWEFXG73.js';
18
19
  import { sha256Hex, fnv1aBase36 } from './chunk-K34OPSJK.js';
19
20
  import { DEFAULT_PAGINATION_LIMIT, DEFAULT_STREAM_BATCH_SIZE, SQLITE_PATH_DELIMITER, PG_ARRAY_START, PG_ARRAY_END, PG_PATH_ELEMENT_SEPARATOR, MAX_PG_IDENTIFIER_LENGTH } from './chunk-2EBMPJBO.js';
20
- import { getDialect } from './chunk-G3CSQLLT.js';
21
- import { assertVectorMinScore, vectorScoreExpression, vectorMinScoreCondition } from './chunk-Y7M44XEK.js';
22
- import { isSqlPlaceholder, bindSqlValue, markAnnIndexScan, asCompiledSelectSql, isRawExecutable, annIndexScanTypes, sql, asCompiledRowsSql, markForceCustomPlan, asCompiledTemporaryStatementSql, asCompiledStatementSql } from './chunk-6XDBRDZE.js';
21
+ import { getDialect, assertVectorMinScore, vectorScoreExpression, vectorMinScoreCondition } from './chunk-Y5UC3IXF.js';
22
+ import { isSqlPlaceholder, bindSqlValue, markAnnIndexScan, asCompiledSelectSql, isRawExecutable, annIndexScanTypes, sql, asCompiledRowsSql, markForceCustomPlan, asCompiledTemporaryStatementSql, asCompiledStatementSql } from './chunk-6N7QBIWN.js';
23
23
  import { createSchemaIntrospector } from './chunk-D7PG5D5K.js';
24
24
  import { requireDefined, isPresent } from './chunk-QMQLUA66.js';
25
25
  import { getSearchableFields, resolveEmbeddingFields, resolveGraphVectorSlots, resolveDeclaredFulltextLanguage } from './chunk-PC2UBAUB.js';
@@ -610,7 +610,7 @@ var RecordedStoreView = class extends CoordinatePinnedView {
610
610
  }
611
611
  });
612
612
  }
613
- /** The recorded/system-time timestamp this view reconstructs. */
613
+ /** The recorded/system-time anchor this view reconstructs. */
614
614
  get asOfRecorded() {
615
615
  const recorded = this.coordinate.recorded;
616
616
  if (recorded === void 0) {
@@ -16971,6 +16971,37 @@ var StoreImplementation = class _StoreImplementation {
16971
16971
  get registry() {
16972
16972
  return this.#registry;
16973
16973
  }
16974
+ /**
16975
+ * An opaque, in-memory snapshot of this store's reconciled schema — the
16976
+ * merged compile-time + runtime-committed graph plus the committed version
16977
+ * it reflects. Cache it after a verified open and hand it to
16978
+ * {@link createAdapterStore} via `{ reconciled }` (or call
16979
+ * {@link AdapterStoreImplementation.withBackend}) to build request-scoped
16980
+ * stores against fresh connections with zero database round-trips. Refresh
16981
+ * it when {@link getCommittedSchemaVersion} reports a moved version.
16982
+ */
16983
+ get reconciledSchema() {
16984
+ return Object.freeze({
16985
+ graph: this.#graph,
16986
+ version: this.#schemaMetadata.schemaVersion,
16987
+ hash: this.#schemaMetadata.schemaHash
16988
+ });
16989
+ }
16990
+ /**
16991
+ * Reconstruction inputs for a connection rebind: the merged graph, the
16992
+ * verbatim construction options, and the reconciled schema metadata. Lets an
16993
+ * adapter subclass rebuild an equivalent store against a fresh backend
16994
+ * without a verify round-trip.
16995
+ *
16996
+ * @internal
16997
+ */
16998
+ reconstructionState() {
16999
+ return {
17000
+ graph: this.#graph,
17001
+ options: this.#options,
17002
+ schemaMetadata: this.#schemaMetadata
17003
+ };
17004
+ }
16974
17005
  /**
16975
17006
  * Whether recorded-time capture is enabled for this store.
16976
17007
  *
@@ -17476,22 +17507,24 @@ var StoreImplementation = class _StoreImplementation {
17476
17507
  * Returns a narrow read-only view pinned to a recorded/system-time instant.
17477
17508
  *
17478
17509
  * Direct `store.asOfRecorded(T)` is diagonal bitemporal sugar: it reads the
17479
- * recorded-time relation as of `T` and uses the same `T` for the valid-time
17480
- * axis. Use `store.asOf(validT).asOfRecorded(recordedT)` when the valid and
17481
- * recorded axes should differ.
17510
+ * recorded-time relation at the anchor's logical revision and uses the
17511
+ * anchor's wall-time component for the valid-time axis. Use
17512
+ * `store.asOf(validT).asOfRecorded(recordedT)` when the valid and recorded
17513
+ * axes should differ.
17482
17514
  *
17483
17515
  * The returned view exposes only reconstructing-safe reads: query,
17484
17516
  * subgraph, graph algorithms, and collection point reads.
17485
17517
  *
17486
- * Prefer `await store.recordedNow()` as the anchor over a wall-clock
17487
- * timestamp: recorded instants are monotonic and can run briefly ahead of the
17488
- * wall clock under bursty writes, so a `new Date().toISOString()` passed here
17489
- * may sort before the most recent commits and silently omit them.
17518
+ * Prefer `await store.recordedNow()` over a wall-clock timestamp. The anchor
17519
+ * carries both the graph's strict logical revision and a non-decreasing
17520
+ * physical wall-time high-water mark, so several commits in one millisecond
17521
+ * remain independently addressable without manufacturing timestamp
17522
+ * increments.
17490
17523
  */
17491
17524
  asOfRecorded(recordedAsOf) {
17492
17525
  const validCoordinate = resolveReadCoordinate(
17493
17526
  "asOf",
17494
- recordedAsOf,
17527
+ recordedInstantWallTime(recordedAsOf),
17495
17528
  "Use await store.recordedNow() as the anchor, or asRecordedInstant(value) only for an instant previously read from recordedNow()."
17496
17529
  );
17497
17530
  return new RecordedStoreView(
@@ -17503,9 +17536,10 @@ var StoreImplementation = class _StoreImplementation {
17503
17536
  * Returns the latest recorded-time instant captured for this graph — the
17504
17537
  * recorded high-water mark. After guarding the `undefined` case,
17505
17538
  * `store.asOfRecorded(checkpoint)` reconstructs everything committed so far, a
17506
- * deterministic anchor that avoids guessing with the wall clock (recorded
17507
- * instants are monotonic and can run briefly ahead of wall-clock time under
17508
- * bursty writes). Capture each anchor right after the writes it should cover.
17539
+ * deterministic anchor that avoids guessing with the wall clock. Its logical
17540
+ * revision is strictly monotonic per graph while its timestamp is a
17541
+ * non-decreasing physical wall-time high-water mark. Capture each anchor right
17542
+ * after the writes it should cover.
17509
17543
  *
17510
17544
  * Returns `undefined` until the first write has been captured, so on a
17511
17545
  * brand-new graph guard the composition — `asOfRecorded(undefined)` rejects
@@ -18947,7 +18981,7 @@ var StoreImplementation = class _StoreImplementation {
18947
18981
  );
18948
18982
  }
18949
18983
  };
18950
- var AdapterStoreImplementation = class extends StoreImplementation {
18984
+ var AdapterStoreImplementation = class _AdapterStoreImplementation extends StoreImplementation {
18951
18985
  backend;
18952
18986
  constructor(graph, backend, options, schemaMetadata) {
18953
18987
  super(graph, backend, options, schemaMetadata, backend);
@@ -18955,6 +18989,23 @@ var AdapterStoreImplementation = class extends StoreImplementation {
18955
18989
  createGraphBackendProjection(this[STORE_RUNTIME].backend)
18956
18990
  );
18957
18991
  }
18992
+ /**
18993
+ * Rebind this store's already-reconciled schema onto a fresh backend/
18994
+ * connection, returning a new equivalent store with **no** verify round-trip.
18995
+ * The connection is captured at construction and never mutated, so this
18996
+ * returns a new instance rather than rebinding in place — the serverless
18997
+ * per-request primitive: verify once per isolate, then `withBackend` the
18998
+ * per-request connection.
18999
+ */
19000
+ withBackend(backend) {
19001
+ const state = this.reconstructionState();
19002
+ return new _AdapterStoreImplementation(
19003
+ state.graph,
19004
+ backend,
19005
+ state.options,
19006
+ state.schemaMetadata
19007
+ );
19008
+ }
18958
19009
  async evolve(extension, options) {
18959
19010
  return this.#withAdapterReplacement(
18960
19011
  options?.ref,
@@ -19038,8 +19089,26 @@ function createStore(graph, backend, options) {
19038
19089
  return new StoreImplementation(graph, backend, options);
19039
19090
  }
19040
19091
  function createAdapterStore(graph, backend, options) {
19092
+ const reconciled = options?.reconciled;
19093
+ if (reconciled !== void 0 && reconciled.graph.id !== graph.id) {
19094
+ throw new ConfigurationError(
19095
+ `Reconciled snapshot is for graph "${reconciled.graph.id}", not "${graph.id}".`,
19096
+ { code: "RECONCILED_GRAPH_MISMATCH" },
19097
+ {
19098
+ suggestion: "Pass the ReconciledSchema produced from the same graph you are building the store with; snapshots are not interchangeable across graphs."
19099
+ }
19100
+ );
19101
+ }
19102
+ const storeOptions = stripReconciledOption(options);
19103
+ const resolvedGraph = reconciled?.graph ?? graph;
19104
+ const schemaMetadata = reconciled === void 0 ? void 0 : reconciledSchemaMetadata(reconciled);
19041
19105
  return asAdapterStoreSurface(
19042
- new AdapterStoreImplementation(graph, backend, options)
19106
+ new AdapterStoreImplementation(
19107
+ resolvedGraph,
19108
+ backend,
19109
+ storeOptions,
19110
+ schemaMetadata
19111
+ )
19043
19112
  );
19044
19113
  }
19045
19114
  function isKnownEdgeKind(graph, name) {
@@ -19057,6 +19126,17 @@ function schemaMetadataFromRow(row) {
19057
19126
  schemaHash: row.schema_hash
19058
19127
  });
19059
19128
  }
19129
+ function reconciledSchemaMetadata(reconciled) {
19130
+ return Object.freeze({
19131
+ schemaVersion: reconciled.version,
19132
+ schemaHash: reconciled.hash
19133
+ });
19134
+ }
19135
+ function stripReconciledOption(options) {
19136
+ if (options === void 0 || !("reconciled" in options)) return options;
19137
+ const { reconciled: _reconciled, ...rest } = options;
19138
+ return rest;
19139
+ }
19060
19140
  function schemaMetadataForResult(activeRow, result) {
19061
19141
  if (result.status === "initialized" || result.status === "migrated") {
19062
19142
  return schemaMetadataFromRow(result.committedRow);
@@ -19096,6 +19176,11 @@ async function createStoreWithSchema(graph, backend, options) {
19096
19176
  prepared.result
19097
19177
  ];
19098
19178
  }
19179
+ async function assertHistorySchemaOnOpen(backend, options) {
19180
+ if (options?.history !== true) return;
19181
+ const schema = options.schema === void 0 ? createSqlSchema(backend.tableNames) : requireSqlSchema(options.schema, "store schema");
19182
+ await assertCurrentRecordedSchema(backend, schema);
19183
+ }
19099
19184
  async function prepareStoreWithSchema(graph, backend, options) {
19100
19185
  const {
19101
19186
  graph: merged,
@@ -19106,6 +19191,7 @@ async function prepareStoreWithSchema(graph, backend, options) {
19106
19191
  ...options,
19107
19192
  preloaded: { activeRow, storedSchema }
19108
19193
  });
19194
+ await assertHistorySchemaOnOpen(backend, options);
19109
19195
  await materializeRuntimeContributions(backend, merged.id);
19110
19196
  await materializeVectorContributions(backend, merged);
19111
19197
  if (options?.systemIndexes !== "skip") {
@@ -19156,7 +19242,7 @@ async function materializeSystemIndexesOnBoot(backend, graphId, result) {
19156
19242
  }
19157
19243
  }
19158
19244
  async function createVerifiedStore(graph, backend, options) {
19159
- const prepared = await prepareVerifiedStore(graph, backend);
19245
+ const prepared = await prepareVerifiedStore(graph, backend, options);
19160
19246
  return [
19161
19247
  new StoreImplementation(
19162
19248
  prepared.graph,
@@ -19167,12 +19253,13 @@ async function createVerifiedStore(graph, backend, options) {
19167
19253
  prepared.result
19168
19254
  ];
19169
19255
  }
19170
- async function prepareVerifiedStore(graph, backend) {
19256
+ async function prepareVerifiedStore(graph, backend, options) {
19171
19257
  const {
19172
19258
  graph: merged,
19173
19259
  activeRow,
19174
19260
  result
19175
19261
  } = await loadAndVerifyGraph(backend, graph);
19262
+ await assertHistorySchemaOnOpen(backend, options);
19176
19263
  return {
19177
19264
  graph: merged,
19178
19265
  result,
@@ -19180,7 +19267,7 @@ async function prepareVerifiedStore(graph, backend) {
19180
19267
  };
19181
19268
  }
19182
19269
  async function createVerifiedAdapterStore(graph, backend, options) {
19183
- const prepared = await prepareVerifiedStore(graph, backend);
19270
+ const prepared = await prepareVerifiedStore(graph, backend, options);
19184
19271
  return [
19185
19272
  asAdapterStoreSurface(
19186
19273
  new AdapterStoreImplementation(
@@ -19195,5 +19282,5 @@ async function createVerifiedAdapterStore(graph, backend, options) {
19195
19282
  }
19196
19283
 
19197
19284
  export { ExecutableAggregateQuery, ExecutableQuery, MAX_EXPLICIT_RECURSIVE_DEPTH, MAX_RECURSIVE_DEPTH, PreparedQuery, QueryBuilder, RecordedStoreView, StoreSearch, StoreView, UnionableQuery, avg, composeFragments, count, countDistinct, countDistinctEdges, countEdges, createAdapterStore, createAdapterStoreWithSchema, createFragment, createQueryBuilder, createStore, createStoreWithSchema, createVerifiedAdapterStore, createVerifiedStore, defineSubgraphProject, field, having, havingEq, havingGt, havingGte, havingLt, havingLte, limitFragment, max, min, offsetFragment, orderByFragment, sum };
19198
- //# sourceMappingURL=chunk-CBK2IVI2.js.map
19199
- //# sourceMappingURL=chunk-CBK2IVI2.js.map
19285
+ //# sourceMappingURL=chunk-MQBF3XGY.js.map
19286
+ //# sourceMappingURL=chunk-MQBF3XGY.js.map