@nicia-ai/typegraph 0.40.0 → 0.42.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 (266) hide show
  1. package/dist/backend/drizzle/indexes.cjs +9 -9
  2. package/dist/backend/drizzle/indexes.d.cts +1 -2
  3. package/dist/backend/drizzle/indexes.d.ts +1 -2
  4. package/dist/backend/drizzle/indexes.js +5 -5
  5. package/dist/backend/index.cjs +50 -50
  6. package/dist/backend/index.d.cts +3 -4
  7. package/dist/backend/index.d.ts +3 -4
  8. package/dist/backend/index.js +11 -11
  9. package/dist/backend/postgres/index.cjs +26 -26
  10. package/dist/backend/postgres/index.d.cts +5 -6
  11. package/dist/backend/postgres/index.d.ts +5 -6
  12. package/dist/backend/postgres/index.js +13 -13
  13. package/dist/backend/postgres/pglite-store.cjs +34 -34
  14. package/dist/backend/postgres/pglite-store.d.cts +7 -8
  15. package/dist/backend/postgres/pglite-store.d.ts +7 -8
  16. package/dist/backend/postgres/pglite-store.js +30 -30
  17. package/dist/backend/postgres/pglite.cjs +15 -15
  18. package/dist/backend/postgres/pglite.d.cts +2 -3
  19. package/dist/backend/postgres/pglite.d.ts +2 -3
  20. package/dist/backend/postgres/pglite.js +14 -14
  21. package/dist/backend/sqlite/index.cjs +23 -23
  22. package/dist/backend/sqlite/index.d.cts +5 -6
  23. package/dist/backend/sqlite/index.d.ts +5 -6
  24. package/dist/backend/sqlite/index.js +11 -11
  25. package/dist/backend/sqlite/libsql.cjs +17 -17
  26. package/dist/backend/sqlite/libsql.d.cts +2 -3
  27. package/dist/backend/sqlite/libsql.d.ts +2 -3
  28. package/dist/backend/sqlite/libsql.js +13 -13
  29. package/dist/backend/sqlite/local-store.cjs +35 -35
  30. package/dist/backend/sqlite/local-store.d.cts +7 -8
  31. package/dist/backend/sqlite/local-store.d.ts +7 -8
  32. package/dist/backend/sqlite/local-store.js +31 -31
  33. package/dist/backend/sqlite/local.cjs +16 -16
  34. package/dist/backend/sqlite/local.d.cts +2 -3
  35. package/dist/backend/sqlite/local.d.ts +2 -3
  36. package/dist/backend/sqlite/local.js +14 -14
  37. package/dist/{chunk-H6I36MGT.cjs → chunk-277UZV7X.cjs} +1191 -1090
  38. package/dist/chunk-277UZV7X.cjs.map +1 -0
  39. package/dist/{chunk-2I3DNNBU.js → chunk-2G6ZEGYO.js} +4 -4
  40. package/dist/{chunk-2I3DNNBU.js.map → chunk-2G6ZEGYO.js.map} +1 -1
  41. package/dist/{chunk-76HE7DJP.js → chunk-2HKIID5K.js} +5 -5
  42. package/dist/{chunk-76HE7DJP.js.map → chunk-2HKIID5K.js.map} +1 -1
  43. package/dist/{chunk-QOHTVDHU.js → chunk-2OOY4OYT.js} +4 -4
  44. package/dist/{chunk-QOHTVDHU.js.map → chunk-2OOY4OYT.js.map} +1 -1
  45. package/dist/{chunk-UCHW2MGP.cjs → chunk-2SO5I5AI.cjs} +196 -196
  46. package/dist/{chunk-UCHW2MGP.cjs.map → chunk-2SO5I5AI.cjs.map} +1 -1
  47. package/dist/{chunk-LFFVD5ZR.cjs → chunk-33PAKPED.cjs} +41 -41
  48. package/dist/{chunk-LFFVD5ZR.cjs.map → chunk-33PAKPED.cjs.map} +1 -1
  49. package/dist/chunk-3RPQDGUE.cjs +83 -0
  50. package/dist/chunk-3RPQDGUE.cjs.map +1 -0
  51. package/dist/{chunk-PH4IJ3V5.js → chunk-3V6D5DEC.js} +3 -3
  52. package/dist/{chunk-PH4IJ3V5.js.map → chunk-3V6D5DEC.js.map} +1 -1
  53. package/dist/{chunk-Y5UC3IXF.js → chunk-42XYPKZU.js} +3 -3
  54. package/dist/{chunk-Y5UC3IXF.js.map → chunk-42XYPKZU.js.map} +1 -1
  55. package/dist/{chunk-XZA3Y4YH.js → chunk-4WYFRACU.js} +3 -3
  56. package/dist/{chunk-XZA3Y4YH.js.map → chunk-4WYFRACU.js.map} +1 -1
  57. package/dist/{chunk-AQVDAKXH.js → chunk-4XRP2N6B.js} +3 -3
  58. package/dist/{chunk-AQVDAKXH.js.map → chunk-4XRP2N6B.js.map} +1 -1
  59. package/dist/{chunk-PWXGB77L.cjs → chunk-5AERZSHC.cjs} +4 -4
  60. package/dist/{chunk-PWXGB77L.cjs.map → chunk-5AERZSHC.cjs.map} +1 -1
  61. package/dist/{chunk-K6CD6W5J.js → chunk-5C75HQYQ.js} +5 -5
  62. package/dist/{chunk-K6CD6W5J.js.map → chunk-5C75HQYQ.js.map} +1 -1
  63. package/dist/{chunk-2J5NMMVR.cjs → chunk-5GV4JQNA.cjs} +43 -43
  64. package/dist/{chunk-2J5NMMVR.cjs.map → chunk-5GV4JQNA.cjs.map} +1 -1
  65. package/dist/{chunk-KHNKYSGP.cjs → chunk-5P6IPIT6.cjs} +41 -41
  66. package/dist/{chunk-KHNKYSGP.cjs.map → chunk-5P6IPIT6.cjs.map} +1 -1
  67. package/dist/{chunk-53BSOG3O.js → chunk-6NB73BXV.js} +11 -11
  68. package/dist/{chunk-53BSOG3O.js.map → chunk-6NB73BXV.js.map} +1 -1
  69. package/dist/{chunk-SE422RES.cjs → chunk-6TJ6PKPS.cjs} +27 -27
  70. package/dist/{chunk-SE422RES.cjs.map → chunk-6TJ6PKPS.cjs.map} +1 -1
  71. package/dist/{chunk-QXKVUJLI.cjs → chunk-7TOT7RKY.cjs} +120 -120
  72. package/dist/{chunk-QXKVUJLI.cjs.map → chunk-7TOT7RKY.cjs.map} +1 -1
  73. package/dist/{chunk-7WLEQIHA.cjs → chunk-7Y6BV3TK.cjs} +100 -100
  74. package/dist/{chunk-7WLEQIHA.cjs.map → chunk-7Y6BV3TK.cjs.map} +1 -1
  75. package/dist/{chunk-HP6LWBLB.cjs → chunk-AO2WPYFZ.cjs} +4 -4
  76. package/dist/{chunk-HP6LWBLB.cjs.map → chunk-AO2WPYFZ.cjs.map} +1 -1
  77. package/dist/{chunk-7UTUKH4E.cjs → chunk-AQR6BHB3.cjs} +10 -10
  78. package/dist/{chunk-7UTUKH4E.cjs.map → chunk-AQR6BHB3.cjs.map} +1 -1
  79. package/dist/{chunk-X4PVHAZ6.cjs → chunk-ARN3ZODS.cjs} +6 -6
  80. package/dist/{chunk-X4PVHAZ6.cjs.map → chunk-ARN3ZODS.cjs.map} +1 -1
  81. package/dist/{chunk-EFZ4S22A.js → chunk-BGXKXGDI.js} +12 -12
  82. package/dist/{chunk-EFZ4S22A.js.map → chunk-BGXKXGDI.js.map} +1 -1
  83. package/dist/{chunk-YYLMXERH.js → chunk-CDYRPI5U.js} +4 -4
  84. package/dist/{chunk-YYLMXERH.js.map → chunk-CDYRPI5U.js.map} +1 -1
  85. package/dist/{chunk-3LKL3S6X.js → chunk-CI5NPLXX.js} +3 -3
  86. package/dist/{chunk-3LKL3S6X.js.map → chunk-CI5NPLXX.js.map} +1 -1
  87. package/dist/{chunk-UUIBACKJ.js → chunk-CUPJL6TS.js} +3 -3
  88. package/dist/{chunk-UUIBACKJ.js.map → chunk-CUPJL6TS.js.map} +1 -1
  89. package/dist/{chunk-JZYMOHHM.cjs → chunk-CVK4T34X.cjs} +22 -22
  90. package/dist/{chunk-JZYMOHHM.cjs.map → chunk-CVK4T34X.cjs.map} +1 -1
  91. package/dist/{chunk-L3DDZUZP.js → chunk-CVNGKTHO.js} +4 -4
  92. package/dist/{chunk-L3DDZUZP.js.map → chunk-CVNGKTHO.js.map} +1 -1
  93. package/dist/{chunk-RW24SAHI.cjs → chunk-DMZEVJGL.cjs} +13 -13
  94. package/dist/{chunk-RW24SAHI.cjs.map → chunk-DMZEVJGL.cjs.map} +1 -1
  95. package/dist/{chunk-3BL3JFHL.js → chunk-DP7KC6CL.js} +126 -25
  96. package/dist/{chunk-3BL3JFHL.js.map → chunk-DP7KC6CL.js.map} +1 -1
  97. package/dist/{chunk-QYDUCWD2.cjs → chunk-ECU53PMN.cjs} +4 -4
  98. package/dist/{chunk-QYDUCWD2.cjs.map → chunk-ECU53PMN.cjs.map} +1 -1
  99. package/dist/{chunk-SCTZRFW5.js → chunk-EQOQOT55.js} +5 -5
  100. package/dist/{chunk-SCTZRFW5.js.map → chunk-EQOQOT55.js.map} +1 -1
  101. package/dist/{chunk-JHK6NPFV.js → chunk-EVFL2ZY5.js} +9 -9
  102. package/dist/{chunk-JHK6NPFV.js.map → chunk-EVFL2ZY5.js.map} +1 -1
  103. package/dist/{chunk-SAMJLDGG.cjs → chunk-F2KVJ6FF.cjs} +112 -112
  104. package/dist/{chunk-SAMJLDGG.cjs.map → chunk-F2KVJ6FF.cjs.map} +1 -1
  105. package/dist/{chunk-NMQ6C6TS.cjs → chunk-F7TDKSVB.cjs} +4 -4
  106. package/dist/{chunk-NMQ6C6TS.cjs.map → chunk-F7TDKSVB.cjs.map} +1 -1
  107. package/dist/{chunk-HQRZEYYB.cjs → chunk-FFQGI67R.cjs} +44 -44
  108. package/dist/{chunk-HQRZEYYB.cjs.map → chunk-FFQGI67R.cjs.map} +1 -1
  109. package/dist/{chunk-YIRLBUNN.js → chunk-FMPZPOUD.js} +3 -3
  110. package/dist/{chunk-YIRLBUNN.js.map → chunk-FMPZPOUD.js.map} +1 -1
  111. package/dist/{chunk-LL5D5T5W.cjs → chunk-FSCJOTHF.cjs} +10 -10
  112. package/dist/{chunk-LL5D5T5W.cjs.map → chunk-FSCJOTHF.cjs.map} +1 -1
  113. package/dist/{chunk-2X73QTIC.cjs → chunk-FY4VY5EV.cjs} +20 -20
  114. package/dist/{chunk-2X73QTIC.cjs.map → chunk-FY4VY5EV.cjs.map} +1 -1
  115. package/dist/{chunk-3SHAUJRB.js → chunk-GT7NEXSU.js} +3 -3
  116. package/dist/{chunk-3SHAUJRB.js.map → chunk-GT7NEXSU.js.map} +1 -1
  117. package/dist/{chunk-W66YCXWT.js → chunk-HHBKGPEI.js} +11 -10
  118. package/dist/chunk-HHBKGPEI.js.map +1 -0
  119. package/dist/{chunk-CKFBZ4LV.cjs → chunk-I73ATSAH.cjs} +4 -4
  120. package/dist/{chunk-CKFBZ4LV.cjs.map → chunk-I73ATSAH.cjs.map} +1 -1
  121. package/dist/{chunk-ELA3V6UN.js → chunk-JOYPNY33.js} +9 -9
  122. package/dist/{chunk-ELA3V6UN.js.map → chunk-JOYPNY33.js.map} +1 -1
  123. package/dist/{chunk-YIX3BEBR.cjs → chunk-K2HHCWZO.cjs} +108 -108
  124. package/dist/{chunk-YIX3BEBR.cjs.map → chunk-K2HHCWZO.cjs.map} +1 -1
  125. package/dist/{chunk-SAFZ6JTI.cjs → chunk-KTBTSHU6.cjs} +19 -2
  126. package/dist/chunk-KTBTSHU6.cjs.map +1 -0
  127. package/dist/chunk-LDCWO5B6.js +81 -0
  128. package/dist/chunk-LDCWO5B6.js.map +1 -0
  129. package/dist/{chunk-I5CRUPKO.js → chunk-LQLVJWUH.js} +7 -7
  130. package/dist/{chunk-I5CRUPKO.js.map → chunk-LQLVJWUH.js.map} +1 -1
  131. package/dist/{chunk-ZE7E46IZ.js → chunk-LTVBD56M.js} +6 -6
  132. package/dist/{chunk-ZE7E46IZ.js.map → chunk-LTVBD56M.js.map} +1 -1
  133. package/dist/{chunk-6N7QBIWN.js → chunk-M4GYQF2H.js} +3 -3
  134. package/dist/{chunk-6N7QBIWN.js.map → chunk-M4GYQF2H.js.map} +1 -1
  135. package/dist/{chunk-XRU7V7FF.cjs → chunk-O2GZM7UK.cjs} +7 -7
  136. package/dist/{chunk-XRU7V7FF.cjs.map → chunk-O2GZM7UK.cjs.map} +1 -1
  137. package/dist/{chunk-ZE6NVENI.js → chunk-O3USVVWS.js} +3 -3
  138. package/dist/{chunk-ZE6NVENI.js.map → chunk-O3USVVWS.js.map} +1 -1
  139. package/dist/{chunk-UDS5DZNY.cjs → chunk-O7XVCLXW.cjs} +68 -67
  140. package/dist/chunk-O7XVCLXW.cjs.map +1 -0
  141. package/dist/{chunk-KLR77R5A.cjs → chunk-OM6RIOA5.cjs} +13 -13
  142. package/dist/{chunk-KLR77R5A.cjs.map → chunk-OM6RIOA5.cjs.map} +1 -1
  143. package/dist/{chunk-LLHMAHG4.cjs → chunk-OMQ2NBOR.cjs} +27 -27
  144. package/dist/{chunk-LLHMAHG4.cjs.map → chunk-OMQ2NBOR.cjs.map} +1 -1
  145. package/dist/{chunk-DPNA466P.js → chunk-OYJSYDIH.js} +19 -3
  146. package/dist/chunk-OYJSYDIH.js.map +1 -0
  147. package/dist/{chunk-CU3LPYNB.js → chunk-RAWG2FEU.js} +138 -22
  148. package/dist/chunk-RAWG2FEU.js.map +1 -0
  149. package/dist/{chunk-M2RPZS7J.cjs → chunk-RTUCOEIO.cjs} +12 -12
  150. package/dist/{chunk-M2RPZS7J.cjs.map → chunk-RTUCOEIO.cjs.map} +1 -1
  151. package/dist/{chunk-TAUGGLNQ.js → chunk-RXOAXO3R.js} +3 -3
  152. package/dist/{chunk-TAUGGLNQ.js.map → chunk-RXOAXO3R.js.map} +1 -1
  153. package/dist/{chunk-LLE25NRD.cjs → chunk-TRC646QQ.cjs} +7 -7
  154. package/dist/{chunk-LLE25NRD.cjs.map → chunk-TRC646QQ.cjs.map} +1 -1
  155. package/dist/chunk-U3YRCZ5L.cjs +12 -0
  156. package/dist/{chunk-IMQKXL4E.cjs.map → chunk-U3YRCZ5L.cjs.map} +1 -1
  157. package/dist/{chunk-ZVME6OSV.js → chunk-UJRWOV5B.js} +5 -5
  158. package/dist/{chunk-ZVME6OSV.js.map → chunk-UJRWOV5B.js.map} +1 -1
  159. package/dist/{chunk-HAQVISUF.cjs → chunk-UTTW2Q3M.cjs} +133 -133
  160. package/dist/{chunk-HAQVISUF.cjs.map → chunk-UTTW2Q3M.cjs.map} +1 -1
  161. package/dist/{chunk-L5ET7FYQ.js → chunk-UZLEQFTV.js} +3 -3
  162. package/dist/{chunk-L5ET7FYQ.js.map → chunk-UZLEQFTV.js.map} +1 -1
  163. package/dist/{chunk-K4FB2RMO.cjs → chunk-V2GZBPY2.cjs} +184 -65
  164. package/dist/chunk-V2GZBPY2.cjs.map +1 -0
  165. package/dist/{chunk-BUZWMDNL.js → chunk-VC26BUNP.js} +5 -5
  166. package/dist/{chunk-BUZWMDNL.js.map → chunk-VC26BUNP.js.map} +1 -1
  167. package/dist/chunk-VGMNGWBR.cjs +12 -0
  168. package/dist/{chunk-5YBDB7UG.cjs.map → chunk-VGMNGWBR.cjs.map} +1 -1
  169. package/dist/{chunk-XMEYZYGE.js → chunk-WYQILW5V.js} +8 -8
  170. package/dist/{chunk-XMEYZYGE.js.map → chunk-WYQILW5V.js.map} +1 -1
  171. package/dist/{chunk-YX3H63VV.cjs → chunk-X2XOQZT3.cjs} +9 -9
  172. package/dist/{chunk-YX3H63VV.cjs.map → chunk-X2XOQZT3.cjs.map} +1 -1
  173. package/dist/{chunk-N2V3HJFV.cjs → chunk-XDMPDUKL.cjs} +9 -9
  174. package/dist/{chunk-N2V3HJFV.cjs.map → chunk-XDMPDUKL.cjs.map} +1 -1
  175. package/dist/{chunk-5J4VNCUD.js → chunk-Z3WIL6S3.js} +5 -5
  176. package/dist/{chunk-5J4VNCUD.js.map → chunk-Z3WIL6S3.js.map} +1 -1
  177. package/dist/{chunk-MNURF4RF.cjs → chunk-ZBV4LQD2.cjs} +4 -4
  178. package/dist/{chunk-MNURF4RF.cjs.map → chunk-ZBV4LQD2.cjs.map} +1 -1
  179. package/dist/{chunk-YGX4PMG6.js → chunk-ZGOUVMVS.js} +5 -5
  180. package/dist/{chunk-YGX4PMG6.js.map → chunk-ZGOUVMVS.js.map} +1 -1
  181. package/dist/{chunk-QZYGZVUI.js → chunk-ZIRC2U6G.js} +11 -11
  182. package/dist/{chunk-QZYGZVUI.js.map → chunk-ZIRC2U6G.js.map} +1 -1
  183. package/dist/{chunk-6QP4QXBR.js → chunk-ZOHCFYXE.js} +3 -3
  184. package/dist/{chunk-6QP4QXBR.js.map → chunk-ZOHCFYXE.js.map} +1 -1
  185. package/dist/{chunk-VWEFXG73.js → chunk-ZP2KPDNN.js} +3 -3
  186. package/dist/{chunk-VWEFXG73.js.map → chunk-ZP2KPDNN.js.map} +1 -1
  187. package/dist/{chunk-NT6ILURI.cjs → chunk-ZPCKPLMX.cjs} +8 -8
  188. package/dist/{chunk-NT6ILURI.cjs.map → chunk-ZPCKPLMX.cjs.map} +1 -1
  189. package/dist/core/index.cjs +28 -28
  190. package/dist/core/index.d.cts +5 -6
  191. package/dist/core/index.d.ts +5 -6
  192. package/dist/core/index.js +8 -8
  193. package/dist/{ddl-KnCdF_le.d.cts → ddl-3unqC-kg.d.cts} +3 -3
  194. package/dist/{ddl-BLEzHw6j.d.ts → ddl-Bc4Dl8fu.d.ts} +3 -3
  195. package/dist/{define-graph-DQnj3fNH.d.ts → define-graph-Byslw2OO.d.cts} +1 -2
  196. package/dist/{define-graph-Cv3CFwKm.d.cts → define-graph-DBFnc7u_.d.ts} +1 -2
  197. package/dist/graph-extension/index.cjs +20 -20
  198. package/dist/graph-extension/index.d.cts +4 -4
  199. package/dist/graph-extension/index.d.ts +4 -4
  200. package/dist/graph-extension/index.js +5 -5
  201. package/dist/graph-merge/index.cjs +105 -105
  202. package/dist/graph-merge/index.d.cts +8 -9
  203. package/dist/graph-merge/index.d.ts +8 -9
  204. package/dist/graph-merge/index.js +25 -25
  205. package/dist/{index-BD_3TCgh.d.ts → index-DHXw7QAl.d.cts} +19 -4
  206. package/dist/{index-BihFPsPu.d.cts → index-DQzVJBHa.d.ts} +19 -4
  207. package/dist/index.cjs +209 -200
  208. package/dist/index.cjs.map +1 -1
  209. package/dist/index.d.cts +13 -15
  210. package/dist/index.d.ts +13 -15
  211. package/dist/index.js +35 -34
  212. package/dist/index.js.map +1 -1
  213. package/dist/indexes/index.cjs +13 -13
  214. package/dist/indexes/index.d.cts +4 -5
  215. package/dist/indexes/index.d.ts +4 -5
  216. package/dist/indexes/index.js +6 -6
  217. package/dist/interchange/index.cjs +40 -40
  218. package/dist/interchange/index.d.cts +9 -10
  219. package/dist/interchange/index.d.ts +9 -10
  220. package/dist/interchange/index.js +14 -14
  221. package/dist/{manager-DjE6Mhag.d.ts → manager-Dl0-er1G.d.ts} +45 -156
  222. package/dist/{manager-mqee5MVB.d.cts → manager-U9_zopqr.d.cts} +45 -156
  223. package/dist/materialize-indexes-BM3u0aXE.d.ts +258 -0
  224. package/dist/materialize-indexes-DzMCetZe.d.cts +258 -0
  225. package/dist/{postgres-Bm4DyFQU.d.cts → postgres-C5-WMKFA.d.ts} +1 -1
  226. package/dist/{postgres-DtaVALOZ.d.ts → postgres-DpJqtbSX.d.cts} +1 -1
  227. package/dist/profiler/index.d.cts +9 -10
  228. package/dist/profiler/index.d.ts +9 -10
  229. package/dist/provenance/index.cjs +39 -39
  230. package/dist/provenance/index.d.cts +7 -8
  231. package/dist/provenance/index.d.ts +7 -8
  232. package/dist/provenance/index.js +9 -9
  233. package/dist/schema/index.cjs +55 -112
  234. package/dist/schema/index.cjs.map +1 -1
  235. package/dist/schema/index.d.cts +57 -58
  236. package/dist/schema/index.d.ts +57 -58
  237. package/dist/schema/index.js +15 -92
  238. package/dist/schema/index.js.map +1 -1
  239. package/dist/{searchable-BxlJQVFw.d.cts → searchable-B4mUXZT6.d.cts} +2 -2
  240. package/dist/{searchable-ChJ29MCd.d.ts → searchable-C7jmPNLT.d.ts} +2 -2
  241. package/dist/{sqlite-m9Izphk_.d.ts → sqlite-Ch5tSYQY.d.ts} +1 -1
  242. package/dist/{sqlite-DT6tTHOG.d.cts → sqlite-Da7jiYu9.d.cts} +1 -1
  243. package/dist/{store-view-CagdeyNn.d.ts → store-view-6C2vTWqf.d.ts} +68 -16
  244. package/dist/{store-view-C-buB8Q8.d.cts → store-view-CNcOG8bQ.d.cts} +68 -16
  245. package/dist/{temporal-CyFsSPe8.d.ts → temporal-BtrTYTiB.d.ts} +1 -1
  246. package/dist/{temporal-Dn_JADWY.d.cts → temporal-CMpigMCW.d.cts} +1 -1
  247. package/dist/{types-CYdXzZef.d.ts → types-D2rU5Taq.d.ts} +1 -2
  248. package/dist/{types-D8szWDUo.d.ts → types-Dh-EgT-w.d.cts} +569 -2
  249. package/dist/{types-C5pZeKTl.d.cts → types-Dh-EgT-w.d.ts} +569 -2
  250. package/dist/{types-CqSfMRW3.d.cts → types-G4sVM-76.d.cts} +1 -2
  251. package/dist/{where-sQL4u5h-.d.ts → where-B8Y21kig.d.ts} +1 -2
  252. package/dist/{where-C3-HRgUq.d.cts → where-DbZ9XDOI.d.cts} +1 -2
  253. package/package.json +1 -1
  254. package/dist/chunk-5YBDB7UG.cjs +0 -12
  255. package/dist/chunk-CU3LPYNB.js.map +0 -1
  256. package/dist/chunk-DPNA466P.js.map +0 -1
  257. package/dist/chunk-H6I36MGT.cjs.map +0 -1
  258. package/dist/chunk-IMQKXL4E.cjs +0 -12
  259. package/dist/chunk-K4FB2RMO.cjs.map +0 -1
  260. package/dist/chunk-SAFZ6JTI.cjs.map +0 -1
  261. package/dist/chunk-UDS5DZNY.cjs.map +0 -1
  262. package/dist/chunk-W66YCXWT.js.map +0 -1
  263. package/dist/extension-types-BLEVH4SG.d.cts +0 -571
  264. package/dist/extension-types-BLEVH4SG.d.ts +0 -571
  265. package/dist/materialize-indexes-D4iei4Kp.d.ts +0 -90
  266. package/dist/materialize-indexes-ExQ6OrAh.d.cts +0 -90
@@ -1,5 +1,5 @@
1
- import { compileNodeIndexKeys, compileEdgeIndexKeys, compileIndexWhere, getDialect } from './chunk-Y5UC3IXF.js';
2
- import { sql, renderSqlInline } from './chunk-6N7QBIWN.js';
1
+ import { compileNodeIndexKeys, compileEdgeIndexKeys, compileIndexWhere, getDialect } from './chunk-42XYPKZU.js';
2
+ import { sql, renderSqlInline } from './chunk-M4GYQF2H.js';
3
3
  import { requireDefined } from './chunk-QMQLUA66.js';
4
4
 
5
5
  // src/indexes/ddl.ts
@@ -67,5 +67,5 @@ function quoteIdentifier(identifier) {
67
67
  }
68
68
 
69
69
  export { generateEdgeIndexDDL, generateIndexDDL, generateNodeIndexDDL };
70
- //# sourceMappingURL=chunk-2I3DNNBU.js.map
71
- //# sourceMappingURL=chunk-2I3DNNBU.js.map
70
+ //# sourceMappingURL=chunk-2G6ZEGYO.js.map
71
+ //# s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,CAAA,CAAA,EAAI,UAAA,CAAW,UAAA,CAAW,GAAA,EAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAC7C","file":"chunk-2I3DNNBU.js","sourcesContent":["import { getDialect } from \"../query/dialect\";\nimport { type SqlDialect } from \"../query/dialect/types\";\nimport { renderSqlInline, sql, type SqlFragment } from \"../query/sql-fragment\";\nimport { requireDefined } from \"../utils/presence\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n type EdgeIndexDeclaration,\n type NodeIndexDeclaration,\n type RelationalIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\nexport type GenerateIndexDdlOptions = Readonly<{\n nodesTableName?: string | undefined;\n edgesTableName?: string | undefined;\n ifNotExists?: boolean | undefined;\n /**\n * Emit `CREATE INDEX CONCURRENTLY` (Postgres only). Required for\n * `store.materializeIndexes()` so live tables don't take an\n * `AccessExclusiveLock`. Ignored on SQLite (no equivalent; SQLite is\n * single-writer regardless). When true on Postgres, the resulting\n * statement cannot be executed inside a transaction.\n */\n concurrent?: boolean | undefined;\n}>;\n\nconst INDEX_DDL_BEHAVIOR = {\n postgres: { concurrentBuilds: true, supportsGinFamily: true },\n sqlite: { concurrentBuilds: false, supportsGinFamily: false },\n} as const satisfies Record<\n SqlDialect,\n Readonly<{ concurrentBuilds: boolean; supportsGinFamily: boolean }>\n>;\n\n/**\n * Generate `CREATE INDEX` DDL for a single relational index declaration.\n *\n * Vector index declarations (`entity: \"vector\"`) are NOT handled here —\n * they go through `backend.createVectorIndex` instead because the DDL\n * is dialect-specific (`USING hnsw (...) WITH (m=..., ef_construction=...)`\n * on Postgres) and operates on the strategy's per-`(kind, field)` embedding\n * tables, not `typegraph_nodes` / `typegraph_edges`. Callers narrow to the\n * relational subset before calling this function.\n */\nexport function generateIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n if (index.entity === \"node\") {\n return generateNodeIndexDDL(index, dialect, options);\n }\n return generateEdgeIndexDDL(index, dialect, options);\n}\n\nexport function generateNodeIndexDDL(\n index: NodeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.nodesTableName ?? \"typegraph_nodes\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nexport function generateEdgeIndexDDL(\n index: EdgeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.edgesTableName ?? \"typegraph_edges\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nfunction generateTableIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n tableName: string,\n options: GenerateIndexDdlOptions,\n): string {\n if (index.method !== undefined) {\n return generateGinFamilyIndexDDL(index, dialect, tableName, options);\n }\n const ifNotExists = options.ifNotExists ?? true;\n const propsColumn = sql.identifier(\"props\");\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n sql.identifier(column);\n\n const keys =\n index.entity === \"node\" ?\n compileNodeIndexKeys(index, dialect, propsColumn, systemColumn).keys\n : compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn).keys;\n\n const whereSql =\n index.where ?\n renderSqlInline(\n compileIndexWhere(\n {\n dialect,\n propsColumn,\n systemColumn,\n } satisfies IndexCompilationContext,\n index.where,\n ),\n dialect,\n )\n : undefined;\n\n const keySql = keys.map((key) => renderSqlInline(key, dialect)).join(\", \");\n const unique = index.unique ? \"UNIQUE \" : \"\";\n const concurrent =\n (\n options.concurrent === true &&\n INDEX_DDL_BEHAVIOR[dialect].concurrentBuilds\n ) ?\n \"CONCURRENTLY \"\n : \"\";\n const ifNotExistsSql = ifNotExists ? \"IF NOT EXISTS \" : \"\";\n\n const whereClause = whereSql ? ` WHERE ${whereSql}` : \"\";\n\n return `CREATE ${unique}INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${keySql})${whereClause};`;\n}\n\n/**\n * DDL for the GIN-family methods (`\"gin\"` / `\"trigram\"`) — a PostgreSQL\n * expression GIN over the declaration's single field.\n *\n * The indexed expression is built from the SAME dialect extraction the\n * query compiler emits for the field (`jsonExtract` → `\"props\" #> ARRAY[…]`\n * for containment, `jsonExtractText` → `#>>` for text), because Postgres\n * matches expression indexes structurally: `(props #> ARRAY['tags']) @> $1`\n * and `(props #>> ARRAY['name']) ILIKE $1 ESCAPE '\\'` both hit their GIN\n * (verified against parameterized prepared statements). No scope prefix\n * columns, uniqueness, or partial clause: a GIN indexes one expression, and\n * the query's `graph_id` / `kind` equality filters apply as residual\n * conditions over the candidate rows.\n */\nfunction generateGinFamilyIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n tableName: string,\n options: GenerateIndexDdlOptions,\n): string {\n if (!INDEX_DDL_BEHAVIOR[dialect].supportsGinFamily) {\n throw new Error(\n `Index \"${index.name}\" declares method \"${index.method}\", which ` +\n \"requires PostgreSQL. materializeIndexes() reports such \" +\n \"declarations as skipped on SQLite instead of calling this.\",\n );\n }\n const adapter = getDialect(dialect);\n const propsColumn = sql.identifier(\"props\");\n const pointer = requireDefined(index.fields[0]);\n const expression =\n index.method === \"gin\" ?\n adapter.jsonExtract(propsColumn, pointer)\n : adapter.jsonExtractText(propsColumn, pointer);\n const operatorClass =\n index.method === \"gin\" ? \"jsonb_path_ops\" : \"gin_trgm_ops\";\n const concurrent = options.concurrent === true ? \"CONCURRENTLY \" : \"\";\n const ifNotExistsSql = (options.ifNotExists ?? true) ? \"IF NOT EXISTS \" : \"\";\n return `CREATE INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} USING GIN ((${renderSqlInline(expression, dialect)}) ${operatorClass});`;\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replaceAll('\"', '\"\"')}\"`;\n}\n"]}
1
+ {"version":3,"sources":["../src/indexes/dd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CAAA,CAAA;AAC7C","file":"chunk-2G6ZEGYO.js","sourcesContent":["import { getDialect } from \"../query/dialect\";\nimport { type SqlDialect } from \"../query/dialect/types\";\nimport { renderSqlInline, sql, type SqlFragment } from \"../query/sql-fragment\";\nimport { requireDefined } from \"../utils/presence\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n type EdgeIndexDeclaration,\n type NodeIndexDeclaration,\n type RelationalIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\nexport type GenerateIndexDdlOptions = Readonly<{\n nodesTableName?: string | undefined;\n edgesTableName?: string | undefined;\n ifNotExists?: boolean | undefined;\n /**\n * Emit `CREATE INDEX CONCURRENTLY` (Postgres only). Required for\n * `store.materializeIndexes()` so live tables don't take an\n * `AccessExclusiveLock`. Ignored on SQLite (no equivalent; SQLite is\n * single-writer regardless). When true on Postgres, the resulting\n * statement cannot be executed inside a transaction.\n */\n concurrent?: boolean | undefined;\n}>;\n\nconst INDEX_DDL_BEHAVIOR = {\n postgres: { concurrentBuilds: true, supportsGinFamily: true },\n sqlite: { concurrentBuilds: false, supportsGinFamily: false },\n} as const satisfies Record<\n SqlDialect,\n Readonly<{ concurrentBuilds: boolean; supportsGinFamily: boolean }>\n>;\n\n/**\n * Generate `CREATE INDEX` DDL for a single relational index declaration.\n *\n * Vector index declarations (`entity: \"vector\"`) are NOT handled here —\n * they go through `backend.createVectorIndex` instead because the DDL\n * is dialect-specific (`USING hnsw (...) WITH (m=..., ef_construction=...)`\n * on Postgres) and operates on the strategy's per-`(kind, field)` embedding\n * tables, not `typegraph_nodes` / `typegraph_edges`. Callers narrow to the\n * relational subset before calling this function.\n */\nexport function generateIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n if (index.entity === \"node\") {\n return generateNodeIndexDDL(index, dialect, options);\n }\n return generateEdgeIndexDDL(index, dialect, options);\n}\n\nexport function generateNodeIndexDDL(\n index: NodeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.nodesTableName ?? \"typegraph_nodes\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nexport function generateEdgeIndexDDL(\n index: EdgeIndexDeclaration,\n dialect: SqlDialect,\n options: GenerateIndexDdlOptions = {},\n): string {\n const tableName = options.edgesTableName ?? \"typegraph_edges\";\n return generateTableIndexDDL(index, dialect, tableName, options);\n}\n\nfunction generateTableIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n tableName: string,\n options: GenerateIndexDdlOptions,\n): string {\n if (index.method !== undefined) {\n return generateGinFamilyIndexDDL(index, dialect, tableName, options);\n }\n const ifNotExists = options.ifNotExists ?? true;\n const propsColumn = sql.identifier(\"props\");\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n sql.identifier(column);\n\n const keys =\n index.entity === \"node\" ?\n compileNodeIndexKeys(index, dialect, propsColumn, systemColumn).keys\n : compileEdgeIndexKeys(index, dialect, propsColumn, systemColumn).keys;\n\n const whereSql =\n index.where ?\n renderSqlInline(\n compileIndexWhere(\n {\n dialect,\n propsColumn,\n systemColumn,\n } satisfies IndexCompilationContext,\n index.where,\n ),\n dialect,\n )\n : undefined;\n\n const keySql = keys.map((key) => renderSqlInline(key, dialect)).join(\", \");\n const unique = index.unique ? \"UNIQUE \" : \"\";\n const concurrent =\n (\n options.concurrent === true &&\n INDEX_DDL_BEHAVIOR[dialect].concurrentBuilds\n ) ?\n \"CONCURRENTLY \"\n : \"\";\n const ifNotExistsSql = ifNotExists ? \"IF NOT EXISTS \" : \"\";\n\n const whereClause = whereSql ? ` WHERE ${whereSql}` : \"\";\n\n return `CREATE ${unique}INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${keySql})${whereClause};`;\n}\n\n/**\n * DDL for the GIN-family methods (`\"gin\"` / `\"trigram\"`) — a PostgreSQL\n * expression GIN over the declaration's single field.\n *\n * The indexed expression is built from the SAME dialect extraction the\n * query compiler emits for the field (`jsonExtract` → `\"props\" #> ARRAY[…]`\n * for containment, `jsonExtractText` → `#>>` for text), because Postgres\n * matches expression indexes structurally: `(props #> ARRAY['tags']) @> $1`\n * and `(props #>> ARRAY['name']) ILIKE $1 ESCAPE '\\'` both hit their GIN\n * (verified against parameterized prepared statements). No scope prefix\n * columns, uniqueness, or partial clause: a GIN indexes one expression, and\n * the query's `graph_id` / `kind` equality filters apply as residual\n * conditions over the candidate rows.\n */\nfunction generateGinFamilyIndexDDL(\n index: RelationalIndexDeclaration,\n dialect: SqlDialect,\n tableName: string,\n options: GenerateIndexDdlOptions,\n): string {\n if (!INDEX_DDL_BEHAVIOR[dialect].supportsGinFamily) {\n throw new Error(\n `Index \"${index.name}\" declares method \"${index.method}\", which ` +\n \"requires PostgreSQL. materializeIndexes() reports such \" +\n \"declarations as skipped on SQLite instead of calling this.\",\n );\n }\n const adapter = getDialect(dialect);\n const propsColumn = sql.identifier(\"props\");\n const pointer = requireDefined(index.fields[0]);\n const expression =\n index.method === \"gin\" ?\n adapter.jsonExtract(propsColumn, pointer)\n : adapter.jsonExtractText(propsColumn, pointer);\n const operatorClass =\n index.method === \"gin\" ? \"jsonb_path_ops\" : \"gin_trgm_ops\";\n const concurrent = options.concurrent === true ? \"CONCURRENTLY \" : \"\";\n const ifNotExistsSql = (options.ifNotExists ?? true) ? \"IF NOT EXISTS \" : \"\";\n return `CREATE INDEX ${concurrent}${ifNotExistsSql}${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} USING GIN ((${renderSqlInline(expression, dialect)}) ${operatorClass});`;\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replaceAll('\"', '\"\"')}\"`;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { NODE_TYPE_BRAND, EDGE_TYPE_BRAND } from './chunk-PH4IJ3V5.js';
2
- import { assertJsonValue } from './chunk-TAUGGLNQ.js';
3
- import { assertSchemaKeysAreFree, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS } from './chunk-XZA3Y4YH.js';
1
+ import { NODE_TYPE_BRAND, EDGE_TYPE_BRAND } from './chunk-3V6D5DEC.js';
2
+ import { assertJsonValue } from './chunk-RXOAXO3R.js';
3
+ import { assertSchemaKeysAreFree, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS } from './chunk-4WYFRACU.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  // src/core/node.ts
@@ -64,5 +64,5 @@ function getTypeName(typeOrIri) {
64
64
  }
65
65
 
66
66
  export { META_EDGE_BRAND, defineEdge, defineNode, getTypeName, isMetaEdge };
67
- //# sourceMappingURL=chunk-76HE7DJP.js.map
68
- //# sourceMappingURL=chunk-76HE7DJP.js.map
67
+ //# sourceMappingURL=chunk-2HKIID5K.js.map
68
+ //# sourceMappingURL=chunk-2HKIID5K.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/node.ts","../src/core/edge.ts","../src/ontology/types.ts"],"names":["validateSchemaKeys"],"mappings":";;;;;;AAmCA,SAAS,kBAAA,CACP,QACA,IAAA,EACM;AACN,EAAA,uBAAA;AAAA,IACE,MAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA;AAAA,IACxB;AAAA,GACF;AACF;AAgBO,SAAS,UAAA,CAGd,MAAS,OAAA,EAA+C;AACxD,EAAA,kBAAA,CAAmB,OAAA,CAAQ,QAAQ,IAAI,CAAA;AACvC,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,eAAA,CAAgB,OAAA,CAAQ,WAAA,EAAa,aAAA,EAAe,CAAA,MAAA,EAAS,IAAI,CAAA,CAAA,CAAG,CAAA;AAAA,EACtE;AAEA,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACnB,CAAC,eAAe,GAAG,IAAA;AAAA,IACnB,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AAc,QAAA,EAAU;AACjC,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA,CAAU,IAAA;AACnB","file":"chunk-76HE7DJP.js","sourcesContent":["import { type z } from \"zod\";\n\nimport {\n assertSchemaKeysAreFree,\n RESERVED_NODE_KEYS,\n} from \"../store/reserved-keys\";\nimport { assertJsonValue } from \"./json-value\";\nimport { type KindAnnotations, NODE_TYPE_BRAND, type NodeType } from \"./types\";\n\n// ============================================================\n// Node Factory Options\n// ============================================================\n\n/**\n * Options for defining a node type.\n */\nexport type DefineNodeOptions<S extends z.ZodObject<z.ZodRawShape>> = Readonly<{\n /** Zod schema for node properties */\n schema: S;\n /** Optional description for documentation */\n description?: string;\n /**\n * Consumer-owned structured annotations for the kind.\n *\n * Stored in the canonical schema and **participates in schema hashing** —\n * any change bumps the schema version and shows up as a `safe`-severity\n * diff in `getSchemaChanges`. See `KindAnnotations` for the contract.\n */\n annotations?: KindAnnotations;\n}>;\n\n// ============================================================\n// Node Factory\n// ============================================================\n\nfunction validateSchemaKeys(\n schema: z.ZodObject<z.ZodRawShape>,\n name: string,\n): void {\n assertSchemaKeysAreFree(\n \"Node\",\n name,\n Object.keys(schema.shape),\n RESERVED_NODE_KEYS,\n );\n}\n\n/**\n * Creates a node type definition.\n *\n * @example\n * ```typescript\n * const Person = defineNode(\"Person\", {\n * schema: z.object({\n * fullName: z.string().min(1),\n * email: z.string().email().optional(),\n * }),\n * description: \"A person in the system\",\n * });\n * ```\n */\nexport function defineNode<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n>(name: K, options: DefineNodeOptions<S>): NodeType<K, S> {\n validateSchemaKeys(options.schema, name);\n if (options.annotations !== undefined) {\n assertJsonValue(options.annotations, \"annotations\", `Node \"${name}\"`);\n }\n\n return Object.freeze({\n [NODE_TYPE_BRAND]: true as const,\n kind: name,\n schema: options.schema,\n description: options.description,\n annotations: options.annotations,\n });\n}\n","import { z } from \"zod\";\n\nimport {\n assertSchemaKeysAreFree,\n RESERVED_EDGE_KEYS,\n} from \"../store/reserved-keys\";\nimport { assertJsonValue } from \"./json-value\";\nimport {\n EDGE_TYPE_BRAND,\n type EdgeType,\n type KindAnnotations,\n type NodeType,\n} from \"./types\";\n\n// ============================================================\n// Edge Factory Options\n// ============================================================\n\n/**\n * Options for defining an edge type.\n */\nexport type DefineEdgeOptions<\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined = undefined,\n To extends readonly NodeType[] | undefined = undefined,\n> = Readonly<{\n /** Zod schema for edge properties (defaults to empty object) */\n schema?: S;\n /** Optional description for documentation */\n description?: string;\n /**\n * Consumer-owned structured annotations for the kind.\n *\n * Stored in the canonical schema and **participates in schema hashing** —\n * any change bumps the schema version and shows up as a `safe`-severity\n * diff in `getSchemaChanges`. See `KindAnnotations` for the contract.\n */\n annotations?: KindAnnotations;\n /** Node types that can be the source of this edge (domain constraint) */\n from?: From;\n /** Node types that can be the target of this edge (range constraint) */\n to?: To;\n}>;\n\n// ============================================================\n// Empty Schema\n// ============================================================\n\nconst EMPTY_SCHEMA = z.object({});\ntype EmptySchema = typeof EMPTY_SCHEMA;\n\n// ============================================================\n// Edge Factory\n// ============================================================\n\nfunction validateSchemaKeys(\n schema: z.ZodObject<z.ZodRawShape>,\n name: string,\n): void {\n assertSchemaKeysAreFree(\n \"Edge\",\n name,\n Object.keys(schema.shape),\n RESERVED_EDGE_KEYS,\n );\n}\n\n/**\n * Creates an edge type definition.\n *\n * @example\n * ```typescript\n * // Edge with no properties\n * const hasEpisode = defineEdge(\"hasEpisode\");\n *\n * // Edge with properties\n * const employedAt = defineEdge(\"employedAt\", {\n * schema: z.object({\n * isPrimary: z.boolean().default(true),\n * startedAt: z.date(),\n * }),\n * description: \"Employment relationship\",\n * });\n *\n * // Edge with domain/range constraints (can be used directly in defineGraph)\n * const worksAt = defineEdge(\"worksAt\", {\n * schema: z.object({ role: z.string() }),\n * from: [Person],\n * to: [Company],\n * });\n * ```\n */\n// Overload: no options - returns edge without domain/range\nexport function defineEdge<K extends string>(name: K): EdgeType<K, EmptySchema>;\n\n// Overload: options with both from and to - returns edge with domain/range\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[],\n To extends readonly NodeType[],\n>(\n name: K,\n options: DefineEdgeOptions<S, From, To> & { from: From; to: To },\n): EdgeType<K, S, From, To>;\n\n// Overload: options without from/to - returns edge without domain/range\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n>(name: K, options: DefineEdgeOptions<S>): EdgeType<K, S>;\n\n// Implementation\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined,\n To extends readonly NodeType[] | undefined,\n>(\n name: K,\n options?: DefineEdgeOptions<S, From, To>,\n): EdgeType<K, S, From, To> | EdgeType<K, EmptySchema> {\n const schema = options?.schema ?? EMPTY_SCHEMA;\n validateSchemaKeys(schema, name);\n if (options?.annotations !== undefined) {\n assertJsonValue(options.annotations, \"annotations\", `Edge \"${name}\"`);\n }\n\n return Object.freeze({\n [EDGE_TYPE_BRAND]: true as const,\n kind: name,\n schema,\n description: options?.description,\n annotations: options?.annotations,\n from: options?.from,\n to: options?.to,\n }) as EdgeType<K, S, From, To> | EdgeType<K, EmptySchema>;\n}\n","import { type EdgeType, type NodeType } from \"../core/types\";\n\n// ============================================================\n// Brand Key\n// ============================================================\n\n/** Brand key for MetaEdge */\nexport const META_EDGE_BRAND = \"__metaEdge\" as const;\n\n// ============================================================\n// Inference Types\n// ============================================================\n\n/**\n * How a meta-edge affects queries and validation.\n */\nexport type InferenceType =\n | \"subsumption\" // Query for X includes instances of subclasses\n | \"hierarchy\" // Enables broader/narrower traversal\n | \"substitution\" // Can substitute equivalent types\n | \"constraint\" // Validation rules\n | \"composition\" // Part-whole navigation\n | \"association\" // Discovery/recommendation\n | \"none\"; // No automatic inference\n\n// ============================================================\n// Meta-Edge Properties\n// ============================================================\n\n/**\n * Properties of a meta-edge.\n */\nexport type MetaEdgeProperties = Readonly<{\n transitive: boolean; // A→B, B→C implies A→C\n symmetric: boolean; // A→B implies B→A\n reflexive: boolean; // A→A is always true\n inverse: string | undefined; // Name of inverse meta-edge\n inference: InferenceType; // How this affects queries\n description: string | undefined;\n}>;\n\n// ============================================================\n// Meta-Edge Type\n// ============================================================\n\n/**\n * A meta-edge definition.\n *\n * Meta-edges represent type-level relationships (between kinds),\n * not instance-level relationships (between nodes).\n */\nexport type MetaEdge<K extends string = string> = Readonly<{\n [META_EDGE_BRAND]: true;\n name: K;\n properties: MetaEdgeProperties;\n}>;\n\n// ============================================================\n// Ontology Relation\n// ============================================================\n\n/**\n * A relation in the ontology (instance of meta-edge between types).\n *\n * @example\n * ```typescript\n * // Podcast subClassOf Media\n * subClassOf(Podcast, Media)\n *\n * // Person equivalentTo schema:Person\n * equivalentTo(Person, \"https://schema.org/Person\")\n * ```\n */\nexport type OntologyRelation = Readonly<{\n metaEdge: MetaEdge;\n from: NodeType | EdgeType | string; // string for external IRIs\n to: NodeType | EdgeType | string;\n}>;\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is a MetaEdge.\n */\nexport function isMetaEdge(value: unknown): value is MetaEdge {\n return (\n typeof value === \"object\" &&\n value !== null &&\n META_EDGE_BRAND in value &&\n (value as Record<string, unknown>)[META_EDGE_BRAND] === true\n );\n}\n\n/**\n * Gets the type name from a NodeType, EdgeType, or IRI string.\n */\nexport function getTypeName(typeOrIri: NodeType | EdgeType | string): string {\n if (typeof typeOrIri === \"string\") {\n return typeOrIri;\n }\n return typeOrIri.kind;\n}\n"]}
1
+ {"version":3,"sources":["../src/core/node.ts","../src/core/edge.ts","../src/ontology/types.ts"],"names":["validateSchemaKeys"],"mappings":";;;;;;AAmCA,SAAS,kBAAA,CACP,QACA,IAAA,EACM;AACN,EAAA,uBAAA;AAAA,IACE,MAAA;AAAA,IACA,IAAA;AAAA,IACA,MAAA,CAAO,IAA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AAAA,IACN,MAAA;AAAA,IACA,aAAa,OAAA,EAAS,WAAA;AAAA,IACtB,aAAa,OAAA,EAAS,WAAA;AAAA,IACtB,MAAM,OAAA,EAAS,IAAA;AAAA,IACf,IAAI,OAAA,EAAS;AAAA,GACd,CAAA;AACH;;;AClIO,IAAM,eAAA,GAAkB;AA+ExB,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,YAAY,SAAA,EAAiD;AAC3E,EAAA,IAAI,OAAO,cAAc,QAAA,EAAU;AACjC,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA,CAAU,IAAA;AACnB","file":"chunk-2HKIID5K.js","sourcesContent":["import { type z } from \"zod\";\n\nimport {\n assertSchemaKeysAreFree,\n RESERVED_NODE_KEYS,\n} from \"../store/reserved-keys\";\nimport { assertJsonValue } from \"./json-value\";\nimport { type KindAnnotations, NODE_TYPE_BRAND, type NodeType } from \"./types\";\n\n// ============================================================\n// Node Factory Options\n// ============================================================\n\n/**\n * Options for defining a node type.\n */\nexport type DefineNodeOptions<S extends z.ZodObject<z.ZodRawShape>> = Readonly<{\n /** Zod schema for node properties */\n schema: S;\n /** Optional description for documentation */\n description?: string;\n /**\n * Consumer-owned structured annotations for the kind.\n *\n * Stored in the canonical schema and **participates in schema hashing** —\n * any change bumps the schema version and shows up as a `safe`-severity\n * diff in `getSchemaChanges`. See `KindAnnotations` for the contract.\n */\n annotations?: KindAnnotations;\n}>;\n\n// ============================================================\n// Node Factory\n// ============================================================\n\nfunction validateSchemaKeys(\n schema: z.ZodObject<z.ZodRawShape>,\n name: string,\n): void {\n assertSchemaKeysAreFree(\n \"Node\",\n name,\n Object.keys(schema.shape),\n RESERVED_NODE_KEYS,\n );\n}\n\n/**\n * Creates a node type definition.\n *\n * @example\n * ```typescript\n * const Person = defineNode(\"Person\", {\n * schema: z.object({\n * fullName: z.string().min(1),\n * email: z.string().email().optional(),\n * }),\n * description: \"A person in the system\",\n * });\n * ```\n */\nexport function defineNode<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n>(name: K, options: DefineNodeOptions<S>): NodeType<K, S> {\n validateSchemaKeys(options.schema, name);\n if (options.annotations !== undefined) {\n assertJsonValue(options.annotations, \"annotations\", `Node \"${name}\"`);\n }\n\n return Object.freeze({\n [NODE_TYPE_BRAND]: true as const,\n kind: name,\n schema: options.schema,\n description: options.description,\n annotations: options.annotations,\n });\n}\n","import { z } from \"zod\";\n\nimport {\n assertSchemaKeysAreFree,\n RESERVED_EDGE_KEYS,\n} from \"../store/reserved-keys\";\nimport { assertJsonValue } from \"./json-value\";\nimport {\n EDGE_TYPE_BRAND,\n type EdgeType,\n type KindAnnotations,\n type NodeType,\n} from \"./types\";\n\n// ============================================================\n// Edge Factory Options\n// ============================================================\n\n/**\n * Options for defining an edge type.\n */\nexport type DefineEdgeOptions<\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined = undefined,\n To extends readonly NodeType[] | undefined = undefined,\n> = Readonly<{\n /** Zod schema for edge properties (defaults to empty object) */\n schema?: S;\n /** Optional description for documentation */\n description?: string;\n /**\n * Consumer-owned structured annotations for the kind.\n *\n * Stored in the canonical schema and **participates in schema hashing** —\n * any change bumps the schema version and shows up as a `safe`-severity\n * diff in `getSchemaChanges`. See `KindAnnotations` for the contract.\n */\n annotations?: KindAnnotations;\n /** Node types that can be the source of this edge (domain constraint) */\n from?: From;\n /** Node types that can be the target of this edge (range constraint) */\n to?: To;\n}>;\n\n// ============================================================\n// Empty Schema\n// ============================================================\n\nconst EMPTY_SCHEMA = z.object({});\ntype EmptySchema = typeof EMPTY_SCHEMA;\n\n// ============================================================\n// Edge Factory\n// ============================================================\n\nfunction validateSchemaKeys(\n schema: z.ZodObject<z.ZodRawShape>,\n name: string,\n): void {\n assertSchemaKeysAreFree(\n \"Edge\",\n name,\n Object.keys(schema.shape),\n RESERVED_EDGE_KEYS,\n );\n}\n\n/**\n * Creates an edge type definition.\n *\n * @example\n * ```typescript\n * // Edge with no properties\n * const hasEpisode = defineEdge(\"hasEpisode\");\n *\n * // Edge with properties\n * const employedAt = defineEdge(\"employedAt\", {\n * schema: z.object({\n * isPrimary: z.boolean().default(true),\n * startedAt: z.date(),\n * }),\n * description: \"Employment relationship\",\n * });\n *\n * // Edge with domain/range constraints (can be used directly in defineGraph)\n * const worksAt = defineEdge(\"worksAt\", {\n * schema: z.object({ role: z.string() }),\n * from: [Person],\n * to: [Company],\n * });\n * ```\n */\n// Overload: no options - returns edge without domain/range\nexport function defineEdge<K extends string>(name: K): EdgeType<K, EmptySchema>;\n\n// Overload: options with both from and to - returns edge with domain/range\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[],\n To extends readonly NodeType[],\n>(\n name: K,\n options: DefineEdgeOptions<S, From, To> & { from: From; to: To },\n): EdgeType<K, S, From, To>;\n\n// Overload: options without from/to - returns edge without domain/range\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n>(name: K, options: DefineEdgeOptions<S>): EdgeType<K, S>;\n\n// Implementation\nexport function defineEdge<\n K extends string,\n S extends z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined,\n To extends readonly NodeType[] | undefined,\n>(\n name: K,\n options?: DefineEdgeOptions<S, From, To>,\n): EdgeType<K, S, From, To> | EdgeType<K, EmptySchema> {\n const schema = options?.schema ?? EMPTY_SCHEMA;\n validateSchemaKeys(schema, name);\n if (options?.annotations !== undefined) {\n assertJsonValue(options.annotations, \"annotations\", `Edge \"${name}\"`);\n }\n\n return Object.freeze({\n [EDGE_TYPE_BRAND]: true as const,\n kind: name,\n schema,\n description: options?.description,\n annotations: options?.annotations,\n from: options?.from,\n to: options?.to,\n }) as EdgeType<K, S, From, To> | EdgeType<K, EmptySchema>;\n}\n","import { type EdgeType, type NodeType } from \"../core/types\";\n\n// ============================================================\n// Brand Key\n// ============================================================\n\n/** Brand key for MetaEdge */\nexport const META_EDGE_BRAND = \"__metaEdge\" as const;\n\n// ============================================================\n// Inference Types\n// ============================================================\n\n/**\n * How a meta-edge affects queries and validation.\n */\nexport type InferenceType =\n | \"subsumption\" // Query for X includes instances of subclasses\n | \"hierarchy\" // Enables broader/narrower traversal\n | \"substitution\" // Can substitute equivalent types\n | \"constraint\" // Validation rules\n | \"composition\" // Part-whole navigation\n | \"association\" // Discovery/recommendation\n | \"none\"; // No automatic inference\n\n// ============================================================\n// Meta-Edge Properties\n// ============================================================\n\n/**\n * Properties of a meta-edge.\n */\nexport type MetaEdgeProperties = Readonly<{\n transitive: boolean; // A→B, B→C implies A→C\n symmetric: boolean; // A→B implies B→A\n reflexive: boolean; // A→A is always true\n inverse: string | undefined; // Name of inverse meta-edge\n inference: InferenceType; // How this affects queries\n description: string | undefined;\n}>;\n\n// ============================================================\n// Meta-Edge Type\n// ============================================================\n\n/**\n * A meta-edge definition.\n *\n * Meta-edges represent type-level relationships (between kinds),\n * not instance-level relationships (between nodes).\n */\nexport type MetaEdge<K extends string = string> = Readonly<{\n [META_EDGE_BRAND]: true;\n name: K;\n properties: MetaEdgeProperties;\n}>;\n\n// ============================================================\n// Ontology Relation\n// ============================================================\n\n/**\n * A relation in the ontology (instance of meta-edge between types).\n *\n * @example\n * ```typescript\n * // Podcast subClassOf Media\n * subClassOf(Podcast, Media)\n *\n * // Person equivalentTo schema:Person\n * equivalentTo(Person, \"https://schema.org/Person\")\n * ```\n */\nexport type OntologyRelation = Readonly<{\n metaEdge: MetaEdge;\n from: NodeType | EdgeType | string; // string for external IRIs\n to: NodeType | EdgeType | string;\n}>;\n\n// ============================================================\n// Type Guards\n// ============================================================\n\n/**\n * Checks if a value is a MetaEdge.\n */\nexport function isMetaEdge(value: unknown): value is MetaEdge {\n return (\n typeof value === \"object\" &&\n value !== null &&\n META_EDGE_BRAND in value &&\n (value as Record<string, unknown>)[META_EDGE_BRAND] === true\n );\n}\n\n/**\n * Gets the type name from a NodeType, EdgeType, or IRI string.\n */\nexport function getTypeName(typeOrIri: NodeType | EdgeType | string): string {\n if (typeof typeOrIri === \"string\") {\n return typeOrIri;\n }\n return typeOrIri.kind;\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { validateCanonicalIsoDate } from './chunk-3SHAUJRB.js';
2
- import { ValidationError } from './chunk-DPNA466P.js';
1
+ import { validateCanonicalIsoDate } from './chunk-GT7NEXSU.js';
2
+ import { ValidationError } from './chunk-OYJSYDIH.js';
3
3
 
4
4
  // src/core/temporal.ts
5
5
  var RECORDED_INSTANT_VERSION = "r1";
@@ -140,5 +140,5 @@ function coordinateContext(coordinate) {
140
140
  }
141
141
 
142
142
  export { RECORDED_MAX_REVISION, asRecordedInstant, assertValidRecordedInstant, compareRecordedInstants, coordinateContext, createRecordedInstant, describeCoordinate, parseRecordedInstant, recordedInstantRevision, recordedInstantWallTime, resolveReadCoordinate, withRecordedCoordinate };
143
- //# sourceMappingURL=chunk-QOHTVDHU.js.map
144
- //# sourceMappingURL=chunk-QOHTVDHU.js.map
143
+ //# sourceMappingURL=chunk-2OOY4OYT.js.map
144
+ //# sourceMappingURL=chunk-2OOY4OYT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/temporal.ts"],"names":[],"mappings":";;;;AAOA,IAAM,wBAAA,GAA2B,IAAA;AACjC,IAAM,uBAAA,GAA0B,EAAA;AAEzB,IAAM,wBAAwB,MAAA,CAAO;AAC5C,IAAM,wBAAA,GACJ,6DAAA;AA2BF,SAAS,sBAAA,CAAuB,OAAe,IAAA,EAA+B;AAC5E,EAAA,OAAO,IAAI,eAAA;AAAA,IACT,GAAG,IAAI,CAAA,gDAAA,CAAA;AAAA,IACP;AAAA,MACE,MAAA,EAAQ;AAAA,QACN;AAAA,UACE,IAAA;AAAA,UACA,SAAS,CAAA,SAAA,EAAY,wBAAw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IAAI,CAAA,CAAA;AACrE,EAAA,OAAO,UAAA,CAAW,aAAa,MAAA,GAC3B,KAAA,GACA,GAAG,KAAK,CAAA,gBAAA,EAAmB,UAAA,CAAW,QAAA,CAAS,IAAI,CAAA,CAAA;AACzD;AAMO,SAAS,kBACd,UAAA,EACyB;AACzB,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,UAAA,CAAW,KAAA;AAClC,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,IAAA;AAAA,IACd,GAAI,IAAA,KAAS,MAAA,IAAa,EAAE,IAAA,EAAK;AAAA,IACjC,GAAI,UAAA,CAAW,QAAA,KAAa,MAAA,GAC1B,KACA,EAAE,YAAA,EAAc,UAAA,CAAW,QAAA,CAAS,IAAA;AAAK,GAC7C;AACF","file":"chunk-QOHTVDHU.js","sourcesContent":["/**\n * Shared temporal coordinate + validation.\n */\nimport { ValidationError } from \"../errors\";\nimport { validateCanonicalIsoDate } from \"../utils/date\";\nimport { type TemporalMode } from \"./types\";\n\nconst RECORDED_INSTANT_VERSION = \"r1\";\nconst RECORDED_REVISION_WIDTH = 16;\n/** Open interval ceiling for numeric recorded-revision columns. */\nexport const RECORDED_MAX_REVISION = Number.MAX_SAFE_INTEGER;\nconst RECORDED_INSTANT_PATTERN =\n /^r1:(\\d{16}):(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z)$/;\n\ndeclare const RECORDED_INSTANT_BRAND: unique symbol;\n\n/**\n * A versioned recorded-time anchor containing a fixed-width logical revision\n * and a canonical UTC physical timestamp:\n * `r1:0000000000000001:YYYY-MM-DDTHH:mm:ss.sssZ`.\n *\n * Logical revisions are strictly monotonic per graph and make every commit\n * addressable even when many commits share one wall-clock millisecond. The\n * timestamp is a non-decreasing physical wall-time high-water mark used by\n * diagonal valid-time reads. Same-millisecond commits repeat it; backward clock\n * corrections hold it at the previous value until wall time catches up. The\n * string is canonical and lexicographically ordered by revision, so it can\n * round-trip through plain string checkpoint columns without a custom\n * serializer.\n */\nexport type RecordedInstant = string & {\n readonly [RECORDED_INSTANT_BRAND]: \"RecordedInstant\";\n};\n\nexport type RecordedInstantParts = Readonly<{\n revision: number;\n recordedAt: string;\n}>;\n\nfunction invalidRecordedInstant(value: string, path: string): ValidationError {\n return new ValidationError(\n `${path} must be a canonical versioned recorded instant.`,\n {\n issues: [\n {\n path,\n message: `Expected ${RECORDED_INSTANT_VERSION}:<${RECORDED_REVISION_WIDTH}-digit revision>:YYYY-MM-DDTHH:mm:ss.sssZ, got \"${value}\"`,\n },\n ],\n },\n {\n suggestion:\n \"Persist the exact string returned by store.recordedNow(); migrate preview-schema checkpoints with migrateLegacyRecordedTime() and migrateRecordedAnchor().\",\n },\n );\n}\n\nexport function parseRecordedInstant(\n value: string,\n path = \"RecordedInstant\",\n): RecordedInstantParts {\n const match = RECORDED_INSTANT_PATTERN.exec(value);\n if (match === null) throw invalidRecordedInstant(value, path);\n const revisionText = match[1];\n const recordedAt = match[2];\n if (revisionText === undefined || recordedAt === undefined) {\n throw invalidRecordedInstant(value, path);\n }\n const revision = Number(revisionText);\n if (\n !Number.isSafeInteger(revision) ||\n revision < 1 ||\n revision >= RECORDED_MAX_REVISION\n ) {\n throw invalidRecordedInstant(value, path);\n }\n validateCanonicalIsoDate(recordedAt, path);\n return { revision, recordedAt };\n}\n\nexport function assertValidRecordedInstant(value: string, path: string): void {\n parseRecordedInstant(value, path);\n}\n\nexport function createRecordedInstant(\n revision: number,\n recordedAt: string,\n): RecordedInstant {\n if (\n !Number.isSafeInteger(revision) ||\n revision < 1 ||\n revision >= RECORDED_MAX_REVISION\n ) {\n throw new ValidationError(\n \"createRecordedInstant revision must be a valid recorded revision.\",\n {\n issues: [\n {\n path: \"createRecordedInstant.revision\",\n message: `Expected a safe integer from 1 through ${String(RECORDED_MAX_REVISION - 1)}, got ${String(revision)}`,\n },\n ],\n },\n );\n }\n const revisionText = revision\n .toString()\n .padStart(RECORDED_REVISION_WIDTH, \"0\");\n return asRecordedInstant(\n `${RECORDED_INSTANT_VERSION}:${revisionText}:${recordedAt}`,\n );\n}\n\n/**\n * Returns the canonical UTC wall-time component of a recorded anchor.\n *\n * The value is non-decreasing per graph, but it is not the commit-order key;\n * use the complete {@link RecordedInstant} when ordering or replaying commits.\n */\nexport function recordedInstantWallTime(instant: RecordedInstant): string {\n return parseRecordedInstant(instant).recordedAt;\n}\n\n/** Returns the strict per-graph logical revision carried by an anchor. */\nexport function recordedInstantRevision(instant: RecordedInstant): number {\n return parseRecordedInstant(instant).revision;\n}\n\n/**\n * Compares two recorded anchors by logical revision.\n *\n * Revisions are local to a graph, so only compare anchors produced by the same\n * graph. The physical wall-time component deliberately does not participate.\n */\nexport function compareRecordedInstants(\n left: RecordedInstant,\n right: RecordedInstant,\n): -1 | 0 | 1 {\n const leftRevision = recordedInstantRevision(left);\n const rightRevision = recordedInstantRevision(right);\n if (leftRevision < rightRevision) return -1;\n if (leftRevision > rightRevision) return 1;\n return 0;\n}\n\n/**\n * Brands a canonical versioned anchor string as a {@link RecordedInstant}.\n *\n * The escape hatch for an instant that round-trips through untyped storage:\n * captured from {@link Store.recordedNow}, persisted as a plain string, read\n * back, and replayed into `asOfRecorded`. Validates the canonical form eagerly —\n * the same check `asOfRecorded` applies — so a malformed value fails here, at the\n * brand site, rather than deeper in a read. Does *not* assert the instant is a\n * real captured commit; it only guarantees the value is well-formed enough to\n * compare correctly against the recorded relations.\n *\n * @throws {ValidationError} when `value` is not a canonical versioned anchor.\n */\nexport function asRecordedInstant(value: string): RecordedInstant {\n assertValidRecordedInstant(value, \"asRecordedInstant\");\n return value as RecordedInstant;\n}\n\n/**\n * The single opaque temporal coordinate every pinned read is resolved\n * against. It carries the valid-time axis plus an optional recorded/system-time\n * axis, so every surface can inject one coordinate object instead of threading\n * each temporal dimension separately.\n */\nexport type ReadCoordinate = Readonly<{\n /**\n * The valid-time axis: a resolved temporal mode and (only for `\"asOf\"`) the\n * instant it is pinned to.\n */\n valid: Readonly<{\n mode: TemporalMode;\n /** Defined only when `mode` is `\"asOf\"`. */\n asOf?: string;\n }>;\n /** The recorded/system-time axis. Defined only for recorded-pinned views. */\n recorded?: Readonly<{ asOf: RecordedInstant }>;\n}>;\n\n/**\n * Resolves and validates a `(mode, asOf)` pair into a {@link ReadCoordinate}.\n * Rejects an `asOf` paired with any non-`\"asOf\"` mode rather than silently\n * dropping it — pinning an instant is only meaningful in `\"asOf\"` mode, so a\n * `view({ mode: \"current\", asOf })` is a caller mistake, not a coordinate to\n * quietly discard. Then validates via {@link assertValidAsOf}.\n *\n * @param mode - The temporal mode to pin.\n * @param asOf - The supplied timestamp. Required for `\"asOf\"`; rejected for\n * every other mode.\n * @param suggestion - Caller-specific remediation hint for the\n * missing/invalid-timestamp case.\n */\nexport function resolveReadCoordinate(\n mode: TemporalMode,\n asOf: string | undefined,\n suggestion?: string,\n): ReadCoordinate {\n if (mode !== \"asOf\" && asOf !== undefined) {\n throw new ValidationError(\n `Temporal mode \"${mode}\" does not take an asOf timestamp.`,\n {\n issues: [\n {\n path: \"asOf\",\n message: `asOf is only valid with mode \"asOf\", not \"${mode}\"`,\n },\n ],\n },\n {\n suggestion:\n 'Pin an instant with store.asOf(timestamp) or store.view({ mode: \"asOf\", asOf }); drop asOf for other modes.',\n },\n );\n }\n assertValidAsOf(\n mode,\n asOf,\n suggestion === undefined ? undefined : { suggestion },\n );\n return { valid: asOf === undefined ? { mode } : { mode, asOf } };\n}\n\n/**\n * Adds a recorded/system-time pin to an existing valid-time coordinate.\n * Direct `store.asOfRecorded(T)` passes the diagonal valid-time coordinate\n * (`mode: \"asOf\", asOf: T`); `store.asOf(vt).asOfRecorded(rt)` passes the\n * already-resolved valid coordinate and adds the recorded sibling.\n */\nexport function withRecordedCoordinate(\n coordinate: ReadCoordinate,\n recordedAsOf: RecordedInstant,\n): ReadCoordinate {\n assertValidRecordedInstant(recordedAsOf, \"asOfRecorded\");\n return {\n ...coordinate,\n recorded: { asOf: recordedAsOf },\n };\n}\n\n/**\n * Validates the `asOf` coordinate of a temporal read: `\"asOf\"` mode\n * requires a timestamp, and any supplied timestamp must be a canonical\n * fixed-width UTC ISO-8601 string (`YYYY-MM-DDTHH:mm:ss.sssZ`). The latter\n * is load-bearing — temporal filters compare `asOf` against `valid_from` /\n * `valid_to` as text on SQLite, so a non-canonical value (date-only, an\n * offset, natural language, or variable-width / missing milliseconds like\n * `.1Z`) would sort and compare wrong rather than error. Reached only through\n * {@link resolveReadCoordinate}, which every temporal read entry point routes\n * through (direct reads, queries, subgraphs, algorithms, and StoreView), so\n * they all fail identically.\n *\n * @param mode - The resolved temporal mode.\n * @param asOf - The supplied timestamp (may be `undefined`).\n * @param options.suggestion - A caller-specific remediation hint for the\n * missing-timestamp case.\n *\n * @throws {ValidationError} when `mode` is `\"asOf\"` and `asOf` is missing, or\n * when any supplied `asOf` is not a canonical UTC ISO-8601 timestamp. The\n * canonical check runs for *every* mode that consumes `asOf`, so a\n * non-canonical value can never reach a text comparison.\n */\nfunction assertValidAsOf(\n mode: TemporalMode,\n asOf: string | undefined,\n options?: Readonly<{ suggestion?: string }>,\n): void {\n if (mode === \"asOf\" && asOf === undefined) {\n throw new ValidationError(\n 'Temporal mode \"asOf\" requires a timestamp',\n {\n issues: [\n { path: \"asOf\", message: \"Timestamp is required for asOf mode\" },\n ],\n },\n {\n suggestion:\n options?.suggestion ??\n 'Provide an ISO-8601 timestamp for asOf mode, e.g. \"2026-01-01T00:00:00.000Z\".',\n },\n );\n }\n if (asOf !== undefined) {\n validateCanonicalIsoDate(asOf, \"asOf\");\n }\n}\n\n/**\n * A human-readable description of a coordinate for error messages, e.g.\n * `mode \"current\"` or `mode \"asOf\" asOf 2026-01-01T00:00:00.000Z`. Shared by\n * every refusal path (the `StoreView` read-only / current-only / search facades\n * and the sealed-query builder) so they describe a coordinate identically — and\n * a future axis (recorded time) is reflected everywhere from one place.\n */\nexport function describeCoordinate(coordinate: ReadCoordinate): string {\n const { mode, asOf } = coordinate.valid;\n const valid =\n asOf === undefined ? `mode \"${mode}\"` : `mode \"${mode}\" asOf ${asOf}`;\n return coordinate.recorded === undefined ?\n valid\n : `${valid}, recorded asOf ${coordinate.recorded.asOf}`;\n}\n\n/**\n * The structured error-context fields describing a coordinate, shared by the\n * same refusal paths as {@link describeCoordinate}.\n */\nexport function coordinateContext(\n coordinate: ReadCoordinate,\n): Record<string, unknown> {\n const { mode, asOf } = coordinate.valid;\n return {\n temporalMode: mode,\n ...(asOf !== undefined && { asOf }),\n ...(coordinate.recorded === undefined ?\n {}\n : { recordedAsOf: coordinate.recorded.asOf }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/core/temporal.ts"],"names":[],"mappings":";;;;AAOA,IAAM,wBAAA,GAA2B,IAAA;AACjC,IAAM,uBAAA,GAA0B,EAAA;AAEzB,IAAM,wBAAwB,MAAA,CAAO;AAC5C,IAAM,wBAAA,GACJ,6DAAA;AA2BF,SAAS,sBAAA,CAAuB,OAAe,IAAA,EAA+B;AAC5E,EAAA,OAAO,IAAI,eAAA;AAAA,IACT,GAAG,IAAI,CAAA,gDAAA,CAAA;AAAA,IACP;AAAA,MACE,MAAA,EAAQ;AAAA,QACN;AAAA,UACE,IAAA;AAAA,UACA,SAAS,CAAA,SAAA,EAAY,wBAAwB,CAAA,EAAA,EAAK,uBAAuB,mDAAmD,KAAK,CAAA,CAAA;AAAA;AACnI;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF;AAEO,SAAS,oBAAA,CACd,KAAA,EACA,IAAA,GAAO,iBAAA,EACe;AACtB,EAAA,MAAM,KAAA,GAAQ,wBAAA,CAAyB,IAAA,CAAK,KAAK,CAAA;AACjD,EAAA,IAAI,KAAA,KAAU,IAAA,EAAM,MAAM,sBAAA,CAAuB,OAAO,IAAI,CAAA;AAC5D,EAAA,MAAM,YAAA,GAAe,MAAM,CAAC,CAAA;AAC5B,EAAA,MAAM,UAAA,GAAa,MAAM,CAAC,CAAA;A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AAc,UAAA,CAAW,QAAA,CAAS,IAAA;AAAK,GAC7C;AACF","file":"chunk-2OOY4OYT.js","sourcesContent":["/**\n * Shared temporal coordinate + validation.\n */\nimport { ValidationError } from \"../errors\";\nimport { validateCanonicalIsoDate } from \"../utils/date\";\nimport { type TemporalMode } from \"./types\";\n\nconst RECORDED_INSTANT_VERSION = \"r1\";\nconst RECORDED_REVISION_WIDTH = 16;\n/** Open interval ceiling for numeric recorded-revision columns. */\nexport const RECORDED_MAX_REVISION = Number.MAX_SAFE_INTEGER;\nconst RECORDED_INSTANT_PATTERN =\n /^r1:(\\d{16}):(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z)$/;\n\ndeclare const RECORDED_INSTANT_BRAND: unique symbol;\n\n/**\n * A versioned recorded-time anchor containing a fixed-width logical revision\n * and a canonical UTC physical timestamp:\n * `r1:0000000000000001:YYYY-MM-DDTHH:mm:ss.sssZ`.\n *\n * Logical revisions are strictly monotonic per graph and make every commit\n * addressable even when many commits share one wall-clock millisecond. The\n * timestamp is a non-decreasing physical wall-time high-water mark used by\n * diagonal valid-time reads. Same-millisecond commits repeat it; backward clock\n * corrections hold it at the previous value until wall time catches up. The\n * string is canonical and lexicographically ordered by revision, so it can\n * round-trip through plain string checkpoint columns without a custom\n * serializer.\n */\nexport type RecordedInstant = string & {\n readonly [RECORDED_INSTANT_BRAND]: \"RecordedInstant\";\n};\n\nexport type RecordedInstantParts = Readonly<{\n revision: number;\n recordedAt: string;\n}>;\n\nfunction invalidRecordedInstant(value: string, path: string): ValidationError {\n return new ValidationError(\n `${path} must be a canonical versioned recorded instant.`,\n {\n issues: [\n {\n path,\n message: `Expected ${RECORDED_INSTANT_VERSION}:<${RECORDED_REVISION_WIDTH}-digit revision>:YYYY-MM-DDTHH:mm:ss.sssZ, got \"${value}\"`,\n },\n ],\n },\n {\n suggestion:\n \"Persist the exact string returned by store.recordedNow(); migrate preview-schema checkpoints with migrateLegacyRecordedTime() and migrateRecordedAnchor().\",\n },\n );\n}\n\nexport function parseRecordedInstant(\n value: string,\n path = \"RecordedInstant\",\n): RecordedInstantParts {\n const match = RECORDED_INSTANT_PATTERN.exec(value);\n if (match === null) throw invalidRecordedInstant(value, path);\n const revisionText = match[1];\n const recordedAt = match[2];\n if (revisionText === undefined || recordedAt === undefined) {\n throw invalidRecordedInstant(value, path);\n }\n const revision = Number(revisionText);\n if (\n !Number.isSafeInteger(revision) ||\n revision < 1 ||\n revision >= RECORDED_MAX_REVISION\n ) {\n throw invalidRecordedInstant(value, path);\n }\n validateCanonicalIsoDate(recordedAt, path);\n return { revision, recordedAt };\n}\n\nexport function assertValidRecordedInstant(value: string, path: string): void {\n parseRecordedInstant(value, path);\n}\n\nexport function createRecordedInstant(\n revision: number,\n recordedAt: string,\n): RecordedInstant {\n if (\n !Number.isSafeInteger(revision) ||\n revision < 1 ||\n revision >= RECORDED_MAX_REVISION\n ) {\n throw new ValidationError(\n \"createRecordedInstant revision must be a valid recorded revision.\",\n {\n issues: [\n {\n path: \"createRecordedInstant.revision\",\n message: `Expected a safe integer from 1 through ${String(RECORDED_MAX_REVISION - 1)}, got ${String(revision)}`,\n },\n ],\n },\n );\n }\n const revisionText = revision\n .toString()\n .padStart(RECORDED_REVISION_WIDTH, \"0\");\n return asRecordedInstant(\n `${RECORDED_INSTANT_VERSION}:${revisionText}:${recordedAt}`,\n );\n}\n\n/**\n * Returns the canonical UTC wall-time component of a recorded anchor.\n *\n * The value is non-decreasing per graph, but it is not the commit-order key;\n * use the complete {@link RecordedInstant} when ordering or replaying commits.\n */\nexport function recordedInstantWallTime(instant: RecordedInstant): string {\n return parseRecordedInstant(instant).recordedAt;\n}\n\n/** Returns the strict per-graph logical revision carried by an anchor. */\nexport function recordedInstantRevision(instant: RecordedInstant): number {\n return parseRecordedInstant(instant).revision;\n}\n\n/**\n * Compares two recorded anchors by logical revision.\n *\n * Revisions are local to a graph, so only compare anchors produced by the same\n * graph. The physical wall-time component deliberately does not participate.\n */\nexport function compareRecordedInstants(\n left: RecordedInstant,\n right: RecordedInstant,\n): -1 | 0 | 1 {\n const leftRevision = recordedInstantRevision(left);\n const rightRevision = recordedInstantRevision(right);\n if (leftRevision < rightRevision) return -1;\n if (leftRevision > rightRevision) return 1;\n return 0;\n}\n\n/**\n * Brands a canonical versioned anchor string as a {@link RecordedInstant}.\n *\n * The escape hatch for an instant that round-trips through untyped storage:\n * captured from {@link Store.recordedNow}, persisted as a plain string, read\n * back, and replayed into `asOfRecorded`. Validates the canonical form eagerly —\n * the same check `asOfRecorded` applies — so a malformed value fails here, at the\n * brand site, rather than deeper in a read. Does *not* assert the instant is a\n * real captured commit; it only guarantees the value is well-formed enough to\n * compare correctly against the recorded relations.\n *\n * @throws {ValidationError} when `value` is not a canonical versioned anchor.\n */\nexport function asRecordedInstant(value: string): RecordedInstant {\n assertValidRecordedInstant(value, \"asRecordedInstant\");\n return value as RecordedInstant;\n}\n\n/**\n * The single opaque temporal coordinate every pinned read is resolved\n * against. It carries the valid-time axis plus an optional recorded/system-time\n * axis, so every surface can inject one coordinate object instead of threading\n * each temporal dimension separately.\n */\nexport type ReadCoordinate = Readonly<{\n /**\n * The valid-time axis: a resolved temporal mode and (only for `\"asOf\"`) the\n * instant it is pinned to.\n */\n valid: Readonly<{\n mode: TemporalMode;\n /** Defined only when `mode` is `\"asOf\"`. */\n asOf?: string;\n }>;\n /** The recorded/system-time axis. Defined only for recorded-pinned views. */\n recorded?: Readonly<{ asOf: RecordedInstant }>;\n}>;\n\n/**\n * Resolves and validates a `(mode, asOf)` pair into a {@link ReadCoordinate}.\n * Rejects an `asOf` paired with any non-`\"asOf\"` mode rather than silently\n * dropping it — pinning an instant is only meaningful in `\"asOf\"` mode, so a\n * `view({ mode: \"current\", asOf })` is a caller mistake, not a coordinate to\n * quietly discard. Then validates via {@link assertValidAsOf}.\n *\n * @param mode - The temporal mode to pin.\n * @param asOf - The supplied timestamp. Required for `\"asOf\"`; rejected for\n * every other mode.\n * @param suggestion - Caller-specific remediation hint for the\n * missing/invalid-timestamp case.\n */\nexport function resolveReadCoordinate(\n mode: TemporalMode,\n asOf: string | undefined,\n suggestion?: string,\n): ReadCoordinate {\n if (mode !== \"asOf\" && asOf !== undefined) {\n throw new ValidationError(\n `Temporal mode \"${mode}\" does not take an asOf timestamp.`,\n {\n issues: [\n {\n path: \"asOf\",\n message: `asOf is only valid with mode \"asOf\", not \"${mode}\"`,\n },\n ],\n },\n {\n suggestion:\n 'Pin an instant with store.asOf(timestamp) or store.view({ mode: \"asOf\", asOf }); drop asOf for other modes.',\n },\n );\n }\n assertValidAsOf(\n mode,\n asOf,\n suggestion === undefined ? undefined : { suggestion },\n );\n return { valid: asOf === undefined ? { mode } : { mode, asOf } };\n}\n\n/**\n * Adds a recorded/system-time pin to an existing valid-time coordinate.\n * Direct `store.asOfRecorded(T)` passes the diagonal valid-time coordinate\n * (`mode: \"asOf\", asOf: T`); `store.asOf(vt).asOfRecorded(rt)` passes the\n * already-resolved valid coordinate and adds the recorded sibling.\n */\nexport function withRecordedCoordinate(\n coordinate: ReadCoordinate,\n recordedAsOf: RecordedInstant,\n): ReadCoordinate {\n assertValidRecordedInstant(recordedAsOf, \"asOfRecorded\");\n return {\n ...coordinate,\n recorded: { asOf: recordedAsOf },\n };\n}\n\n/**\n * Validates the `asOf` coordinate of a temporal read: `\"asOf\"` mode\n * requires a timestamp, and any supplied timestamp must be a canonical\n * fixed-width UTC ISO-8601 string (`YYYY-MM-DDTHH:mm:ss.sssZ`). The latter\n * is load-bearing — temporal filters compare `asOf` against `valid_from` /\n * `valid_to` as text on SQLite, so a non-canonical value (date-only, an\n * offset, natural language, or variable-width / missing milliseconds like\n * `.1Z`) would sort and compare wrong rather than error. Reached only through\n * {@link resolveReadCoordinate}, which every temporal read entry point routes\n * through (direct reads, queries, subgraphs, algorithms, and StoreView), so\n * they all fail identically.\n *\n * @param mode - The resolved temporal mode.\n * @param asOf - The supplied timestamp (may be `undefined`).\n * @param options.suggestion - A caller-specific remediation hint for the\n * missing-timestamp case.\n *\n * @throws {ValidationError} when `mode` is `\"asOf\"` and `asOf` is missing, or\n * when any supplied `asOf` is not a canonical UTC ISO-8601 timestamp. The\n * canonical check runs for *every* mode that consumes `asOf`, so a\n * non-canonical value can never reach a text comparison.\n */\nfunction assertValidAsOf(\n mode: TemporalMode,\n asOf: string | undefined,\n options?: Readonly<{ suggestion?: string }>,\n): void {\n if (mode === \"asOf\" && asOf === undefined) {\n throw new ValidationError(\n 'Temporal mode \"asOf\" requires a timestamp',\n {\n issues: [\n { path: \"asOf\", message: \"Timestamp is required for asOf mode\" },\n ],\n },\n {\n suggestion:\n options?.suggestion ??\n 'Provide an ISO-8601 timestamp for asOf mode, e.g. \"2026-01-01T00:00:00.000Z\".',\n },\n );\n }\n if (asOf !== undefined) {\n validateCanonicalIsoDate(asOf, \"asOf\");\n }\n}\n\n/**\n * A human-readable description of a coordinate for error messages, e.g.\n * `mode \"current\"` or `mode \"asOf\" asOf 2026-01-01T00:00:00.000Z`. Shared by\n * every refusal path (the `StoreView` read-only / current-only / search facades\n * and the sealed-query builder) so they describe a coordinate identically — and\n * a future axis (recorded time) is reflected everywhere from one place.\n */\nexport function describeCoordinate(coordinate: ReadCoordinate): string {\n const { mode, asOf } = coordinate.valid;\n const valid =\n asOf === undefined ? `mode \"${mode}\"` : `mode \"${mode}\" asOf ${asOf}`;\n return coordinate.recorded === undefined ?\n valid\n : `${valid}, recorded asOf ${coordinate.recorded.asOf}`;\n}\n\n/**\n * The structured error-context fields describing a coordinate, shared by the\n * same refusal paths as {@link describeCoordinate}.\n */\nexport function coordinateContext(\n coordinate: ReadCoordinate,\n): Record<string, unknown> {\n const { mode, asOf } = coordinate.valid;\n return {\n temporalMode: mode,\n ...(asOf !== undefined && { asOf }),\n ...(coordinate.recorded === undefined ?\n {}\n : { recordedAsOf: coordinate.recorded.asOf }),\n };\n}\n"]}