@nicia-ai/typegraph 0.38.0 → 0.40.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 (254) 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 +25 -27
  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 +12 -14
  13. package/dist/backend/postgres/pglite-store.cjs +26 -27
  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 +22 -23
  18. package/dist/backend/postgres/pglite-store.js.map +1 -1
  19. package/dist/backend/postgres/pglite.cjs +14 -16
  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 +13 -15
  23. package/dist/backend/sqlite/index.cjs +26 -28
  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 +10 -12
  27. package/dist/backend/sqlite/libsql.cjs +16 -18
  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 +15 -17
  32. package/dist/backend/sqlite/libsql.js.map +1 -1
  33. package/dist/backend/sqlite/local-store.cjs +27 -28
  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 +23 -24
  38. package/dist/backend/sqlite/local-store.js.map +1 -1
  39. package/dist/backend/sqlite/local.cjs +15 -17
  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 +13 -15
  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-NU23DUSJ.cjs → chunk-2X73QTIC.cjs} +12 -13
  48. package/dist/chunk-2X73QTIC.cjs.map +1 -0
  49. package/dist/{chunk-A2FGSWMQ.js → chunk-3BL3JFHL.js} +202 -52
  50. package/dist/chunk-3BL3JFHL.js.map +1 -0
  51. package/dist/chunk-3SHAUJRB.js +79 -0
  52. package/dist/chunk-3SHAUJRB.js.map +1 -0
  53. package/dist/{chunk-UPXDVI3T.js → chunk-53BSOG3O.js} +8 -7
  54. package/dist/chunk-53BSOG3O.js.map +1 -0
  55. package/dist/chunk-5J4VNCUD.js +856 -0
  56. package/dist/chunk-5J4VNCUD.js.map +1 -0
  57. package/dist/chunk-5YBDB7UG.cjs +12 -0
  58. package/dist/{chunk-FMNUSGZ4.cjs.map → chunk-5YBDB7UG.cjs.map} +1 -1
  59. package/dist/{chunk-6XDBRDZE.js → chunk-6N7QBIWN.js} +7 -3
  60. package/dist/chunk-6N7QBIWN.js.map +1 -0
  61. package/dist/{chunk-EZH7FNUS.js → chunk-6QP4QXBR.js} +3 -3
  62. package/dist/{chunk-EZH7FNUS.js.map → chunk-6QP4QXBR.js.map} +1 -1
  63. package/dist/{chunk-E6TXEISH.cjs → chunk-7UTUKH4E.cjs} +4 -4
  64. package/dist/{chunk-E6TXEISH.cjs.map → chunk-7UTUKH4E.cjs.map} +1 -1
  65. package/dist/chunk-7WLEQIHA.cjs +605 -0
  66. package/dist/chunk-7WLEQIHA.cjs.map +1 -0
  67. package/dist/{chunk-BQITNFQJ.js → chunk-AQVDAKXH.js} +3 -3
  68. package/dist/{chunk-BQITNFQJ.js.map → chunk-AQVDAKXH.js.map} +1 -1
  69. package/dist/{chunk-X6CNEA32.js → chunk-BUZWMDNL.js} +5 -5
  70. package/dist/{chunk-X6CNEA32.js.map → chunk-BUZWMDNL.js.map} +1 -1
  71. package/dist/{chunk-7M3NACL3.cjs → chunk-CKFBZ4LV.cjs} +4 -4
  72. package/dist/{chunk-7M3NACL3.cjs.map → chunk-CKFBZ4LV.cjs.map} +1 -1
  73. package/dist/{chunk-VBH7ZXSZ.js → chunk-CU3LPYNB.js} +5 -5
  74. package/dist/{chunk-VBH7ZXSZ.js.map → chunk-CU3LPYNB.js.map} +1 -1
  75. package/dist/{chunk-YJDSPA5E.js → chunk-EFZ4S22A.js} +11 -10
  76. package/dist/chunk-EFZ4S22A.js.map +1 -0
  77. package/dist/chunk-ELA3V6UN.js +601 -0
  78. package/dist/chunk-ELA3V6UN.js.map +1 -0
  79. package/dist/{chunk-2SL7OGPR.cjs → chunk-H6I36MGT.cjs} +1037 -887
  80. package/dist/chunk-H6I36MGT.cjs.map +1 -0
  81. package/dist/chunk-HAQVISUF.cjs +1098 -0
  82. package/dist/chunk-HAQVISUF.cjs.map +1 -0
  83. package/dist/{chunk-O5H62ZWJ.cjs → chunk-HP6LWBLB.cjs} +14 -2
  84. package/dist/chunk-HP6LWBLB.cjs.map +1 -0
  85. package/dist/{chunk-BKAKAVRW.cjs → chunk-HQRZEYYB.cjs} +44 -44
  86. package/dist/{chunk-BKAKAVRW.cjs.map → chunk-HQRZEYYB.cjs.map} +1 -1
  87. package/dist/{chunk-XD6X7O5R.js → chunk-I5CRUPKO.js} +9 -10
  88. package/dist/{chunk-XD6X7O5R.js.map → chunk-I5CRUPKO.js.map} +1 -1
  89. package/dist/{chunk-RQPRCEIO.js → chunk-JHK6NPFV.js} +218 -306
  90. package/dist/chunk-JHK6NPFV.js.map +1 -0
  91. package/dist/chunk-JZYMOHHM.cjs +226 -0
  92. package/dist/chunk-JZYMOHHM.cjs.map +1 -0
  93. package/dist/{chunk-CQC6VBAF.cjs → chunk-K4FB2RMO.cjs} +10 -10
  94. package/dist/{chunk-CQC6VBAF.cjs.map → chunk-K4FB2RMO.cjs.map} +1 -1
  95. package/dist/{chunk-ERZ4QPQX.js → chunk-K6CD6W5J.js} +5 -5
  96. package/dist/{chunk-ERZ4QPQX.js.map → chunk-K6CD6W5J.js.map} +1 -1
  97. package/dist/{chunk-LZ3TVJY4.cjs → chunk-KHNKYSGP.cjs} +34 -34
  98. package/dist/{chunk-LZ3TVJY4.cjs.map → chunk-KHNKYSGP.cjs.map} +1 -1
  99. package/dist/{chunk-CWX77JB4.cjs → chunk-KLR77R5A.cjs} +13 -13
  100. package/dist/{chunk-CWX77JB4.cjs.map → chunk-KLR77R5A.cjs.map} +1 -1
  101. package/dist/{chunk-AOL64O4Z.js → chunk-L3DDZUZP.js} +3 -3
  102. package/dist/{chunk-AOL64O4Z.js.map → chunk-L3DDZUZP.js.map} +1 -1
  103. package/dist/{chunk-PZHC5GCD.js → chunk-L5ET7FYQ.js} +3 -3
  104. package/dist/{chunk-PZHC5GCD.js.map → chunk-L5ET7FYQ.js.map} +1 -1
  105. package/dist/{chunk-B63IFHXR.cjs → chunk-LFFVD5ZR.cjs} +41 -41
  106. package/dist/{chunk-B63IFHXR.cjs.map → chunk-LFFVD5ZR.cjs.map} +1 -1
  107. package/dist/chunk-LL5D5T5W.cjs +157 -0
  108. package/dist/chunk-LL5D5T5W.cjs.map +1 -0
  109. package/dist/{chunk-GUUWKPTK.cjs → chunk-LLE25NRD.cjs} +7 -7
  110. package/dist/{chunk-GUUWKPTK.cjs.map → chunk-LLE25NRD.cjs.map} +1 -1
  111. package/dist/chunk-LLHMAHG4.cjs +886 -0
  112. package/dist/chunk-LLHMAHG4.cjs.map +1 -0
  113. package/dist/{chunk-ZHX4KEM7.cjs → chunk-M2RPZS7J.cjs} +10 -10
  114. package/dist/{chunk-ZHX4KEM7.cjs.map → chunk-M2RPZS7J.cjs.map} +1 -1
  115. package/dist/chunk-MNURF4RF.cjs +85 -0
  116. package/dist/chunk-MNURF4RF.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-7VLCN3JB.cjs → chunk-QXKVUJLI.cjs} +113 -112
  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-TE5ZA4VX.js → chunk-QZYGZVUI.js} +45 -41
  124. package/dist/chunk-QZYGZVUI.js.map +1 -0
  125. package/dist/{chunk-YLINFV7Z.cjs → chunk-SAMJLDGG.cjs} +114 -110
  126. package/dist/chunk-SAMJLDGG.cjs.map +1 -0
  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-NWYCOFEZ.cjs → chunk-UCHW2MGP.cjs} +332 -433
  130. package/dist/chunk-UCHW2MGP.cjs.map +1 -0
  131. package/dist/{chunk-XFY73JWD.cjs → chunk-UDS5DZNY.cjs} +498 -1098
  132. package/dist/chunk-UDS5DZNY.cjs.map +1 -0
  133. package/dist/{chunk-KFLXWVUJ.js → chunk-UUIBACKJ.js} +14 -3
  134. package/dist/chunk-UUIBACKJ.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-G32AO634.js → chunk-W66YCXWT.js} +464 -1048
  138. package/dist/chunk-W66YCXWT.js.map +1 -0
  139. package/dist/{chunk-E6YZRKMM.js → chunk-XMEYZYGE.js} +6 -6
  140. package/dist/{chunk-E6YZRKMM.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-KCLZHYPU.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-6G5CQ6JX.js → chunk-ZE7E46IZ.js} +5 -5
  152. package/dist/{chunk-6G5CQ6JX.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-Dx3Z0_WC.d.ts → ddl-BLEzHw6j.d.ts} +3 -3
  160. package/dist/{ddl-J6sDyABg.d.cts → ddl-KnCdF_le.d.cts} +3 -3
  161. package/dist/{define-graph-CzEvA_8F.d.cts → define-graph-Cv3CFwKm.d.cts} +1 -1
  162. package/dist/{define-graph-DRo9xpYN.d.ts → define-graph-DQnj3fNH.d.ts} +1 -1
  163. package/dist/graph-merge/index.cjs +40 -43
  164. package/dist/graph-merge/index.cjs.map +1 -1
  165. package/dist/graph-merge/index.d.cts +15 -9
  166. package/dist/graph-merge/index.d.ts +15 -9
  167. package/dist/graph-merge/index.js +19 -22
  168. package/dist/graph-merge/index.js.map +1 -1
  169. package/dist/index.cjs +143 -119
  170. package/dist/index.d.cts +12 -10
  171. package/dist/index.d.ts +12 -10
  172. package/dist/index.js +23 -23
  173. package/dist/indexes/index.cjs +12 -14
  174. package/dist/indexes/index.d.cts +5 -5
  175. package/dist/indexes/index.d.ts +5 -5
  176. package/dist/indexes/index.js +5 -7
  177. package/dist/interchange/index.cjs +29 -30
  178. package/dist/interchange/index.cjs.map +1 -1
  179. package/dist/interchange/index.d.cts +6 -5
  180. package/dist/interchange/index.d.ts +6 -5
  181. package/dist/interchange/index.js +10 -11
  182. package/dist/interchange/index.js.map +1 -1
  183. package/dist/{manager-CASfhmzV.d.ts → manager-DjE6Mhag.d.ts} +2 -2
  184. package/dist/{manager-nCEJiYBb.d.cts → manager-mqee5MVB.d.cts} +2 -2
  185. package/dist/{postgres-DMgIKQU-.d.cts → postgres-Bm4DyFQU.d.cts} +100 -49
  186. package/dist/{postgres-Cl1ZAN1G.d.ts → postgres-DtaVALOZ.d.ts} +100 -49
  187. package/dist/profiler/index.d.cts +8 -7
  188. package/dist/profiler/index.d.ts +8 -7
  189. package/dist/provenance/index.cjs +20 -20
  190. package/dist/provenance/index.d.cts +6 -5
  191. package/dist/provenance/index.d.ts +6 -5
  192. package/dist/provenance/index.js +7 -7
  193. package/dist/schema/index.cjs +26 -28
  194. package/dist/schema/index.cjs.map +1 -1
  195. package/dist/schema/index.d.cts +5 -5
  196. package/dist/schema/index.d.ts +5 -5
  197. package/dist/schema/index.js +7 -9
  198. package/dist/schema/index.js.map +1 -1
  199. package/dist/{temporal-DqtOEo_B.d.ts → searchable-BxlJQVFw.d.cts} +3 -58
  200. package/dist/{temporal-BC_NQV5Y.d.cts → searchable-ChJ29MCd.d.ts} +3 -58
  201. package/dist/{sqlite-BDkW39aa.d.cts → sqlite-DT6tTHOG.d.cts} +124 -97
  202. package/dist/{sqlite-CYfhvESj.d.ts → sqlite-m9Izphk_.d.ts} +124 -97
  203. package/dist/{store-view-BoHqdHjB.d.cts → store-view-C-buB8Q8.d.cts} +46 -31
  204. package/dist/{store-view-Ctq-3OHy.d.ts → store-view-CagdeyNn.d.ts} +46 -31
  205. package/dist/temporal-CyFsSPe8.d.ts +73 -0
  206. package/dist/temporal-Dn_JADWY.d.cts +73 -0
  207. package/dist/{types-CUevi_D1.d.ts → types-CYdXzZef.d.ts} +1 -1
  208. package/dist/{types-COq3-vMC.d.cts → types-CqSfMRW3.d.cts} +1 -1
  209. package/dist/{where-C92TXCzT.d.cts → where-C3-HRgUq.d.cts} +1 -1
  210. package/dist/{where-BdE_cYtx.d.ts → where-sQL4u5h-.d.ts} +1 -1
  211. package/package.json +1 -1
  212. package/dist/chunk-2SL7OGPR.cjs.map +0 -1
  213. package/dist/chunk-6XDBRDZE.js.map +0 -1
  214. package/dist/chunk-7VLCN3JB.cjs.map +0 -1
  215. package/dist/chunk-A2FGSWMQ.js.map +0 -1
  216. package/dist/chunk-DDCIXXOO.js +0 -9
  217. package/dist/chunk-DDCIXXOO.js.map +0 -1
  218. package/dist/chunk-DDCYVIVV.cjs +0 -44
  219. package/dist/chunk-DDCYVIVV.cjs.map +0 -1
  220. package/dist/chunk-EOJFGECD.cjs +0 -284
  221. package/dist/chunk-EOJFGECD.cjs.map +0 -1
  222. package/dist/chunk-FMNUSGZ4.cjs +0 -12
  223. package/dist/chunk-G32AO634.js.map +0 -1
  224. package/dist/chunk-G3CSQLLT.js.map +0 -1
  225. package/dist/chunk-I6FX7AAG.js +0 -39
  226. package/dist/chunk-I6FX7AAG.js.map +0 -1
  227. package/dist/chunk-J6IJARLG.js +0 -94
  228. package/dist/chunk-J6IJARLG.js.map +0 -1
  229. package/dist/chunk-KCLZHYPU.cjs.map +0 -1
  230. package/dist/chunk-KFLXWVUJ.js.map +0 -1
  231. package/dist/chunk-MTNEGGM2.js +0 -273
  232. package/dist/chunk-MTNEGGM2.js.map +0 -1
  233. package/dist/chunk-NU23DUSJ.cjs.map +0 -1
  234. package/dist/chunk-NWYCOFEZ.cjs.map +0 -1
  235. package/dist/chunk-O5H62ZWJ.cjs.map +0 -1
  236. package/dist/chunk-RQPRCEIO.js.map +0 -1
  237. package/dist/chunk-SVUKGWSN.cjs +0 -102
  238. package/dist/chunk-SVUKGWSN.cjs.map +0 -1
  239. package/dist/chunk-TE5ZA4VX.js.map +0 -1
  240. package/dist/chunk-UH2USOMG.cjs +0 -627
  241. package/dist/chunk-UH2USOMG.cjs.map +0 -1
  242. package/dist/chunk-UPXDVI3T.js.map +0 -1
  243. package/dist/chunk-X6RDQ5NB.cjs.map +0 -1
  244. package/dist/chunk-XFY73JWD.cjs.map +0 -1
  245. package/dist/chunk-Y7M44XEK.js +0 -462
  246. package/dist/chunk-Y7M44XEK.js.map +0 -1
  247. package/dist/chunk-YJDSPA5E.js.map +0 -1
  248. package/dist/chunk-YLINFV7Z.cjs.map +0 -1
  249. package/dist/chunk-Z5QHVL5U.cjs +0 -12
  250. package/dist/chunk-Z5QHVL5U.cjs.map +0 -1
  251. package/dist/chunk-ZKZAIX42.cjs +0 -479
  252. package/dist/chunk-ZKZAIX42.cjs.map +0 -1
  253. package/dist/{index-CrFL_ENI.d.cts → types-C5pZeKTl.d.cts} +1 -1
  254. package/dist/{index-Bq7vSPHy.d.ts → types-D8szWDUo.d.ts} +1 -1
@@ -1,11 +1,10 @@
1
1
  import { groupBy, chunk } from './chunk-35S6P5ZU.js';
2
- import { createBackendOverlay, rowPropsToObject, rowPropsToJsonText } from './chunk-PZHC5GCD.js';
3
- import { RECORDED_MAX } from './chunk-J6IJARLG.js';
4
- import { withRecordedRelationsPrecondition } from './chunk-KFLXWVUJ.js';
5
- import { nowIso } from './chunk-I6FX7AAG.js';
6
- import { MAX_PG_IDENTIFIER_LENGTH } from './chunk-2EBMPJBO.js';
7
- import { likeEscapeClause, LIKE_ESCAPE_CHARACTER } from './chunk-DDCIXXOO.js';
8
- import { typeGraphGlobalSymbol, sql, asCompiledRowsSql, isSqlFragment, asCompiledStatementSql } from './chunk-6XDBRDZE.js';
2
+ import { createSqlSchema } from './chunk-YYLMXERH.js';
3
+ import { createBackendOverlay, rowPropsToObject, rowPropsToJsonText } from './chunk-L5ET7FYQ.js';
4
+ import { parseRecordedInstant, createRecordedInstant, RECORDED_MAX_REVISION } from './chunk-QOHTVDHU.js';
5
+ import { withRecordedRelationsPrecondition } from './chunk-UUIBACKJ.js';
6
+ import { nowIso, canonicalizeDatabaseTimestamp } from './chunk-3SHAUJRB.js';
7
+ import { typeGraphGlobalSymbol, sql, asCompiledRowsSql, likeEscapeClause, asCompiledStatementSql, LIKE_ESCAPE_CHARACTER } from './chunk-6N7QBIWN.js';
9
8
  import { resolveFieldTypeInfoAtJsonPointer } from './chunk-SNXVDZAJ.js';
10
9
  import { requireDefined, isPresent } from './chunk-QMQLUA66.js';
11
10
  import { resolveEmbeddingFields, getSearchableFields, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-PC2UBAUB.js';
@@ -13,210 +12,6 @@ import { ConfigurationError, UnsupportedPredicateError, CompilerInvariantError,
13
12
  import { normalizeJsonPointer, joinJsonPointers, jsonPointer } from './chunk-G6Q5UM7U.js';
14
13
  import { nanoid } from 'nanoid';
15
14
 
16
- // src/query/compiler/schema.ts
17
- var SQL_SCHEMA_BRAND = typeGraphGlobalSymbol("sql-schema-v1");
18
- var SqlSchema = class {
19
- };
20
- var SqlSchemaDescriptor = class extends SqlSchema {
21
- tables;
22
- nodesTable;
23
- edgesTable;
24
- recordedNodesTable;
25
- recordedEdgesTable;
26
- recordedClockTable;
27
- revisionOriginsTable;
28
- fulltextTable;
29
- constructor(fields) {
30
- super();
31
- Object.defineProperty(this, SQL_SCHEMA_BRAND, {
32
- configurable: false,
33
- enumerable: false,
34
- value: true,
35
- writable: false
36
- });
37
- this.tables = fields.tables;
38
- this.nodesTable = fields.nodesTable;
39
- this.edgesTable = fields.edgesTable;
40
- this.recordedNodesTable = fields.recordedNodesTable;
41
- this.recordedEdgesTable = fields.recordedEdgesTable;
42
- this.recordedClockTable = fields.recordedClockTable;
43
- this.revisionOriginsTable = fields.revisionOriginsTable;
44
- this.fulltextTable = fields.fulltextTable;
45
- Object.freeze(this);
46
- }
47
- };
48
- var DEFAULT_TABLE_NAMES = {
49
- nodes: "typegraph_nodes",
50
- edges: "typegraph_edges",
51
- recordedNodes: "typegraph_recorded_nodes",
52
- recordedEdges: "typegraph_recorded_edges",
53
- recordedClock: "typegraph_recorded_clock",
54
- revisionOrigins: "typegraph_revision_origins",
55
- fulltext: "typegraph_node_fulltext",
56
- uniques: "typegraph_node_uniques"
57
- };
58
- function resolveTableNames(names) {
59
- return {
60
- nodes: names.nodes ?? DEFAULT_TABLE_NAMES.nodes,
61
- edges: names.edges ?? DEFAULT_TABLE_NAMES.edges,
62
- recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
63
- recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
64
- recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
65
- revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
66
- fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
67
- uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
68
- };
69
- }
70
- var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
71
- function validateTableName(name, label) {
72
- if (!name || name.length === 0) {
73
- throw new ConfigurationError(`${label} table name cannot be empty`);
74
- }
75
- if (name.length > MAX_PG_IDENTIFIER_LENGTH) {
76
- throw new ConfigurationError(
77
- `${label} table name exceeds maximum length of ${MAX_PG_IDENTIFIER_LENGTH} characters`
78
- );
79
- }
80
- if (!VALID_IDENTIFIER_PATTERN.test(name)) {
81
- throw new ConfigurationError(
82
- `${label} table name "${name}" is not a valid SQL identifier. Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`
83
- );
84
- }
85
- }
86
- function freezeSqlSchema(fields) {
87
- return new SqlSchemaDescriptor(fields);
88
- }
89
- function isSqlSchema(schema) {
90
- if (typeof schema !== "object" || schema === null) return false;
91
- const candidate = schema;
92
- return candidate[SQL_SCHEMA_BRAND] === true && typeof candidate["tables"] === "object" && candidate["tables"] !== null && Object.isFrozen(candidate["tables"]) && isSqlFragment(candidate["nodesTable"]) && isSqlFragment(candidate["edgesTable"]) && isSqlFragment(candidate["recordedNodesTable"]) && isSqlFragment(candidate["recordedEdgesTable"]) && isSqlFragment(candidate["recordedClockTable"]) && isSqlFragment(candidate["revisionOriginsTable"]) && isSqlFragment(candidate["fulltextTable"]) && Object.isFrozen(candidate);
93
- }
94
- function requireSqlSchema(schema, surface = "SqlSchema") {
95
- if (isSqlSchema(schema)) return schema;
96
- throw new ConfigurationError(
97
- `${surface} must be created with createSqlSchema(...).`,
98
- { code: "INVALID_SQL_SCHEMA", surface },
99
- {
100
- suggestion: "Pass the result of createSqlSchema(...) instead of a plain schema-shaped object."
101
- }
102
- );
103
- }
104
- function createSqlSchema(names = {}) {
105
- const tables = resolveTableNames(names);
106
- validateTableName(tables.nodes, "nodes");
107
- validateTableName(tables.edges, "edges");
108
- validateTableName(tables.recordedNodes, "recordedNodes");
109
- validateTableName(tables.recordedEdges, "recordedEdges");
110
- validateTableName(tables.recordedClock, "recordedClock");
111
- validateTableName(tables.revisionOrigins, "revisionOrigins");
112
- validateTableName(tables.fulltext, "fulltext");
113
- validateTableName(tables.uniques, "uniques");
114
- return freezeSqlSchema({
115
- tables: Object.freeze(tables),
116
- nodesTable: sql.identifier(tables.nodes),
117
- edgesTable: sql.identifier(tables.edges),
118
- recordedNodesTable: sql.identifier(tables.recordedNodes),
119
- recordedEdgesTable: sql.identifier(tables.recordedEdges),
120
- recordedClockTable: sql.identifier(tables.recordedClock),
121
- revisionOriginsTable: sql.identifier(tables.revisionOrigins),
122
- fulltextTable: sql.identifier(tables.fulltext)
123
- });
124
- }
125
- var EXTERNAL_RECORDED_READ_SOURCE = typeGraphGlobalSymbol(
126
- "external-recorded-read-source-v1"
127
- );
128
- var TYPEGRAPH_RECORDED_READ_SOURCE = typeGraphGlobalSymbol(
129
- "typegraph-recorded-read-source-v1"
130
- );
131
- function recordedRelation(options) {
132
- const schema = requireSqlSchema(options.schema, "recordedRelation schema");
133
- return Object.freeze({
134
- source: "external",
135
- schema,
136
- [EXTERNAL_RECORDED_READ_SOURCE]: true
137
- });
138
- }
139
- function requireExternalRecordedReadSource(source) {
140
- if (source === void 0) return void 0;
141
- if (isExternalRecordedReadSource(source)) return source;
142
- throw new ConfigurationError(
143
- "recordedRead must be created with recordedRelation({ schema }).",
144
- { code: "INVALID_RECORDED_READ_SOURCE" },
145
- {
146
- suggestion: "Pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation. Use { history: true } when TypeGraph should capture writes."
147
- }
148
- );
149
- }
150
- function isExternalRecordedReadSource(source) {
151
- if (typeof source !== "object" || source === null) return false;
152
- const candidate = source;
153
- return candidate.source === "external" && candidate[EXTERNAL_RECORDED_READ_SOURCE] === true && isSqlSchema(candidate.schema) && Object.isFrozen(candidate);
154
- }
155
- function createRecordedReadBinding(schema) {
156
- const readSchema = requireSqlSchema(schema, "recorded read binding schema");
157
- return Object.freeze({
158
- source: "typegraph-capture",
159
- schema: readSchema,
160
- [TYPEGRAPH_RECORDED_READ_SOURCE]: true
161
- });
162
- }
163
- function requireRecordedReadBinding(binding, surface) {
164
- if (isRecordedReadBinding(binding)) return binding;
165
- if (binding !== void 0) {
166
- throw new ConfigurationError(
167
- "Recorded-time reads require a recorded read relation created by TypeGraph.",
168
- { code: "INVALID_RECORDED_READ_BINDING", surface },
169
- {
170
- suggestion: "Use createStore(graph, backend, { history: true }) or { recordedRead: recordedRelation({ schema }) } instead of passing a plain object."
171
- }
172
- );
173
- }
174
- throw new ConfigurationError(
175
- "Recorded-time reads require a recorded read relation.",
176
- { code: "RECORDED_READ_REQUIRES_BINDING", surface },
177
- {
178
- suggestion: "Create the store with createStore(graph, backend, { history: true }) to bind TypeGraph's built-in captured relation, or pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation."
179
- }
180
- );
181
- }
182
- function isTypeGraphRecordedReadSource(source) {
183
- if (typeof source !== "object" || source === null) return false;
184
- const candidate = source;
185
- return candidate.source === "typegraph-capture" && candidate[TYPEGRAPH_RECORDED_READ_SOURCE] === true && isSqlSchema(candidate.schema) && Object.isFrozen(candidate);
186
- }
187
- function isRecordedReadBinding(binding) {
188
- return isExternalRecordedReadSource(binding) || isTypeGraphRecordedReadSource(binding);
189
- }
190
- function recordedReadSqlSchema(binding) {
191
- const { schema } = requireRecordedReadBinding(
192
- binding,
193
- "recorded-read-schema"
194
- );
195
- return freezeSqlSchema({
196
- tables: schema.tables,
197
- nodesTable: schema.recordedNodesTable,
198
- edgesTable: schema.recordedEdgesTable,
199
- recordedNodesTable: schema.recordedNodesTable,
200
- recordedEdgesTable: schema.recordedEdgesTable,
201
- recordedClockTable: schema.recordedClockTable,
202
- revisionOriginsTable: schema.revisionOriginsTable,
203
- fulltextTable: schema.fulltextTable
204
- });
205
- }
206
- function recordedReadSchemaFor(schema, recordedAsOf, binding, surface) {
207
- const baseSchema = requireSqlSchema(schema, `${surface} schema`);
208
- if (recordedAsOf === void 0) return baseSchema;
209
- return recordedReadSqlSchema(requireRecordedReadBinding(binding, surface));
210
- }
211
- var DEFAULT_SQL_SCHEMA = createSqlSchema();
212
- function vectorSlotKey(nodeKind, fieldPath) {
213
- return `${nodeKind}\0${fieldPath}`;
214
- }
215
- var ALIAS_CTE_PREFIX = "cte_";
216
- var EMBEDDINGS_CTE_ALIAS = "cte_embeddings";
217
- var FULLTEXT_CTE_ALIAS = "cte_fulltext";
218
- var HYBRID_CANDIDATES_CTE_ALIAS = "cte_relevance_candidates";
219
-
220
15
  // src/store/types.ts
221
16
  var AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = 1e3;
222
17
  var TRANSACTION_RUNTIME = typeGraphGlobalSymbol(
@@ -286,7 +81,7 @@ function compileTemporalFilter(options) {
286
81
  const validFilter = (() => {
287
82
  switch (mode) {
288
83
  case "current": {
289
- const now = recordedAsOf === void 0 ? currentTimestamp ?? currentReadInstant() : sql`${recordedAsOf}`;
84
+ const now = recordedAsOf === void 0 ? currentTimestamp ?? currentReadInstant() : sql`${parseRecordedInstant(recordedAsOf, "recordedAsOf").recordedAt}`;
290
85
  return sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${now}) AND (${validTo} IS NULL OR ${validTo} > ${now})`;
291
86
  }
292
87
  case "asOf": {
@@ -309,7 +104,11 @@ function compileTemporalFilter(options) {
309
104
  if (recordedAsOf === void 0) return validFilter;
310
105
  const recordedFrom = sql`${prefix}recorded_from`;
311
106
  const recordedTo = sql`${prefix}recorded_to`;
312
- return sql`(${validFilter}) AND ${recordedFrom} <= ${recordedAsOf} AND ${recordedAsOf} < ${recordedTo}`;
107
+ const recordedRevision = parseRecordedInstant(
108
+ recordedAsOf,
109
+ "recordedAsOf"
110
+ ).revision;
111
+ return sql`(${validFilter}) AND ${recordedFrom} <= ${recordedRevision} AND ${recordedRevision} < ${recordedTo}`;
313
112
  }
314
113
  function extractTemporalOptions(ast, tableAlias) {
315
114
  return {
@@ -1073,8 +872,8 @@ function assertRevisionTrackableBackend(backend) {
1073
872
  }
1074
873
 
1075
874
  // src/store/recorded-capture/clock.ts
1076
- var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
1077
- var RECORDED_MAX_TIME = new Date(RECORDED_MAX).getTime();
875
+ var RECORDED_MIN_REVISION = 0;
876
+ var RECORDED_MIN_TIME = "1970-01-01T00:00:00.000Z";
1078
877
  var RECORDED_CLOCK_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-clock";
1079
878
  var RECORDED_GRAPH_WRITE_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-graph-write";
1080
879
  var USES_RECORDED_GRAPH_ADVISORY_LOCK = {
@@ -1139,61 +938,62 @@ async function lockRecordedGraphWrite(target, graphId, memo) {
1139
938
  await pending;
1140
939
  return graphWriteLockEvidence();
1141
940
  }
1142
- function failInvalidClockTimestamp(value) {
941
+ function failInvalidClock(value, cause) {
1143
942
  throw new ConfigurationError(
1144
- "Recorded clock row contained an invalid timestamp",
1145
- { value }
943
+ "Recorded clock row contained an invalid revision or wall time",
944
+ { value },
945
+ {
946
+ cause,
947
+ suggestion: "Run migrateLegacyRecordedTime() before using recorded-time tables created by the timestamp-only preview schema."
948
+ }
1146
949
  );
1147
950
  }
1148
- var ZONELESS_DATETIME_PATTERN = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?$/;
1149
- var OFFSET_DATETIME_PATTERN = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)(Z|[+-]\d{2}(?::?\d{2})?)$/i;
1150
- function normalizeOffsetDesignator(offset) {
1151
- if (offset.toUpperCase() === "Z") return "Z";
1152
- if (/^[+-]\d{2}$/.test(offset)) return `${offset}:00`;
1153
- if (/^[+-]\d{4}$/.test(offset)) {
1154
- return `${offset.slice(0, 3)}:${offset.slice(3)}`;
1155
- }
1156
- return offset;
1157
- }
1158
- function clockTimestampMs(value) {
1159
- if (ZONELESS_DATETIME_PATTERN.test(value)) {
1160
- return Date.parse(`${value.replace(" ", "T")}Z`);
1161
- }
1162
- const offsetMatch = OFFSET_DATETIME_PATTERN.exec(value);
1163
- if (offsetMatch) {
1164
- const [, date, time, offset] = offsetMatch;
1165
- return Date.parse(
1166
- `${date}T${time}${normalizeOffsetDesignator(requireDefined(offset))}`
1167
- );
951
+ function recordedClockRevision(value) {
952
+ const revision = typeof value === "bigint" ? Number(value) : typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
953
+ if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < RECORDED_MIN_REVISION || revision >= RECORDED_MAX_REVISION) {
954
+ return failInvalidClock(value);
1168
955
  }
1169
- return Date.parse(value);
956
+ return revision;
1170
957
  }
1171
- function toCanonicalIso(value) {
1172
- if (value instanceof Date) {
1173
- if (Number.isNaN(value.getTime())) return failInvalidClockTimestamp(value);
1174
- return value.toISOString();
1175
- }
1176
- if (typeof value === "string") {
1177
- const timestamp = clockTimestampMs(value);
1178
- if (Number.isNaN(timestamp)) return failInvalidClockTimestamp(value);
1179
- return new Date(timestamp).toISOString();
958
+ function recordedClockWallTime(value) {
959
+ return canonicalizeDatabaseTimestamp(value) ?? failInvalidClock(value);
960
+ }
961
+ function recordedClockParts(row) {
962
+ const revision = recordedClockRevision(row.revision);
963
+ if (revision === RECORDED_MIN_REVISION) return void 0;
964
+ return { revision, recordedAt: recordedClockWallTime(row.recorded_at) };
965
+ }
966
+ function nextRecordedCommitParts(previous) {
967
+ const wallTime = nowIso();
968
+ if (previous === void 0) {
969
+ return { revision: 1, recordedAt: wallTime };
1180
970
  }
1181
- return failInvalidClockTimestamp(value);
971
+ return {
972
+ revision: previous.revision + 1,
973
+ // Keep diagonal replay cumulative across backward clock corrections without
974
+ // manufacturing a new millisecond for same-ms commits. Throughput can make
975
+ // this component repeat, never run ahead of the greatest observed wall time.
976
+ recordedAt: nonDecreasingWallTime(wallTime, previous.recordedAt)
977
+ };
1182
978
  }
1183
- function nextRecordedCommitTime(previous) {
1184
- const wallTime = Date.parse(nowIso());
1185
- return previous === void 0 ? wallTime : Math.max(wallTime, Date.parse(previous) + 1);
979
+ function nonDecreasingWallTime(current, previous) {
980
+ if (current < previous) return previous;
981
+ return current;
1186
982
  }
1187
983
  async function readRecordedClock(target, schema, graphId) {
984
+ const parts = await readRecordedClockParts(target, schema, graphId);
985
+ return parts === void 0 ? void 0 : createRecordedInstant(parts.revision, parts.recordedAt);
986
+ }
987
+ async function readRecordedClockParts(target, schema, graphId) {
1188
988
  const rows = await target.execute(
1189
989
  asCompiledRowsSql(sql`
1190
- SELECT recorded_at
990
+ SELECT revision, recorded_at
1191
991
  FROM ${schema.recordedClockTable}
1192
992
  WHERE graph_id = ${graphId}
1193
993
  `)
1194
994
  );
1195
- const first = rows[0];
1196
- return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
995
+ const row = rows[0];
996
+ return row === void 0 ? void 0 : recordedClockParts(row);
1197
997
  }
1198
998
  async function readRevisionOrigin(target, schema, graphId) {
1199
999
  const rows = await target.execute(
@@ -1242,13 +1042,14 @@ async function ensureRevisionOrigin(target, schema, graphId) {
1242
1042
  { graphId, dialect: target.dialect }
1243
1043
  );
1244
1044
  }
1245
- async function writeRecordedClock(target, schema, graphId, recordedAt) {
1045
+ async function writeRecordedClock(target, schema, graphId, parts) {
1246
1046
  await executeStatement(
1247
1047
  target,
1248
1048
  sql`
1249
- INSERT INTO ${schema.recordedClockTable} (graph_id, recorded_at)
1250
- VALUES (${graphId}, ${recordedAt})
1251
- ON CONFLICT (graph_id) DO UPDATE SET recorded_at = ${recordedAt}
1049
+ INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
1050
+ VALUES (${graphId}, ${parts.revision}, ${parts.recordedAt})
1051
+ ON CONFLICT (graph_id) DO UPDATE
1052
+ SET revision = ${parts.revision}, recorded_at = ${parts.recordedAt}
1252
1053
  `
1253
1054
  );
1254
1055
  }
@@ -1265,9 +1066,9 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
1265
1066
  await executeStatement(
1266
1067
  target,
1267
1068
  sql`
1268
- INSERT INTO ${schema.recordedClockTable} (graph_id, recorded_at)
1269
- VALUES (${graphId}, ${RECORDED_MIN})
1270
- ON CONFLICT (graph_id) DO UPDATE SET recorded_at = recorded_at
1069
+ INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
1070
+ VALUES (${graphId}, ${RECORDED_MIN_REVISION}, ${RECORDED_MIN_TIME})
1071
+ ON CONFLICT (graph_id) DO UPDATE SET revision = revision
1271
1072
  `
1272
1073
  );
1273
1074
  return;
@@ -1279,29 +1080,30 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
1279
1080
  }
1280
1081
  async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
1281
1082
  await lockRecordedClock(target, schema, graphId, ownsWriteLock);
1282
- const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
1283
- const recordedCommitTime = nextRecordedCommitTime(previous);
1284
- if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
1083
+ const previous = previousRevision === void 0 ? await readRecordedClockParts(target, schema, graphId) : parseRecordedInstant(previousRevision, "previous recorded revision");
1084
+ const { revision, recordedAt } = nextRecordedCommitParts(previous);
1085
+ if (revision >= RECORDED_MAX_REVISION) {
1285
1086
  throw new ConfigurationError(
1286
- `Recorded commit clock reached the open sentinel ${RECORDED_MAX}`,
1287
- { graphId, recordedCommitTime },
1087
+ `Recorded commit clock reached the open revision sentinel ${RECORDED_MAX_REVISION}`,
1088
+ { graphId, revision },
1288
1089
  {
1289
- suggestion: "Use a graph with a normal recorded-time clock; the open sentinel is reserved for relation intervals."
1090
+ suggestion: "Start a new graph before exhausting the per-graph recorded revision space."
1290
1091
  }
1291
1092
  );
1292
1093
  }
1293
- const recordedCommit = new Date(recordedCommitTime).toISOString();
1294
- await writeRecordedClock(target, schema, graphId, recordedCommit);
1295
- return recordedCommit;
1094
+ const instant = createRecordedInstant(revision, recordedAt);
1095
+ await writeRecordedClock(target, schema, graphId, { revision, recordedAt });
1096
+ return { instant, revision, recordedAt };
1296
1097
  }
1297
1098
  async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
1298
- return allocateRecordedCommit(
1099
+ const commit = await allocateRecordedCommit(
1299
1100
  target,
1300
1101
  schema,
1301
1102
  graphId,
1302
1103
  ownsWriteLock,
1303
1104
  previousRevision
1304
1105
  );
1106
+ return commit.instant;
1305
1107
  }
1306
1108
 
1307
1109
  // src/backend/graph-backend-projection.ts
@@ -2241,8 +2043,8 @@ function recordedCommonCells() {
2241
2043
  created_at: (row) => sql`${row.created_at}`,
2242
2044
  updated_at: (row) => sql`${row.updated_at}`,
2243
2045
  deleted_at: (row) => sql`${sqlNull(row.deleted_at)}`,
2244
- recorded_from: (_row, recordedCommit) => sql`${recordedCommit}`,
2245
- recorded_to: () => sql`${RECORDED_MAX}`,
2046
+ recorded_from: (_row, recordedRevision) => sql`${recordedRevision}`,
2047
+ recorded_to: () => sql`${RECORDED_MAX_REVISION}`,
2246
2048
  op: (_row, _recordedCommit, operation) => sql`${operation}`,
2247
2049
  schema_version: () => sql`NULL`,
2248
2050
  tx_id: () => sql`NULL`,
@@ -2260,20 +2062,20 @@ var recordedEdgeCells = {
2260
2062
  to_kind: (row) => sql`${row.to_kind}`,
2261
2063
  to_id: (row) => sql`${row.to_id}`
2262
2064
  };
2263
- function recordedValuesTuple(columns, cells, row, recordedCommit, operation) {
2065
+ function recordedValuesTuple(columns, cells, row, recordedRevision, operation) {
2264
2066
  const tuple = columns.map(
2265
- (column) => cells[column](row, recordedCommit, operation)
2067
+ (column) => cells[column](row, recordedRevision, operation)
2266
2068
  );
2267
2069
  return sql`(${sql.join(tuple, sql`, `)})`;
2268
2070
  }
2269
- async function insertRecordedRows(target, table, columnList, columns, cells, inserts, recordedCommit) {
2071
+ async function insertRecordedRows(target, table, columnList, columns, cells, inserts, recordedRevision) {
2270
2072
  if (inserts.length === 0) return;
2271
2073
  const values = inserts.map(
2272
2074
  (insert) => recordedValuesTuple(
2273
2075
  columns,
2274
2076
  cells,
2275
2077
  insert.row,
2276
- recordedCommit,
2078
+ recordedRevision,
2277
2079
  insert.operation
2278
2080
  )
2279
2081
  );
@@ -2291,7 +2093,7 @@ function recordedNodeChunkSize(target) {
2291
2093
  function recordedEdgeChunkSize(target) {
2292
2094
  return recordedChunkSize(target, RECORDED_EDGE_COLUMNS.length);
2293
2095
  }
2294
- function insertRecordedNodeRows(target, table, inserts, recordedCommit) {
2096
+ function insertRecordedNodeRows(target, table, inserts, recordedRevision) {
2295
2097
  return insertRecordedRows(
2296
2098
  target,
2297
2099
  table,
@@ -2299,10 +2101,10 @@ function insertRecordedNodeRows(target, table, inserts, recordedCommit) {
2299
2101
  RECORDED_NODE_COLUMNS,
2300
2102
  recordedNodeCells,
2301
2103
  inserts,
2302
- recordedCommit
2104
+ recordedRevision
2303
2105
  );
2304
2106
  }
2305
- function insertRecordedEdgeRows(target, table, inserts, recordedCommit) {
2107
+ function insertRecordedEdgeRows(target, table, inserts, recordedRevision) {
2306
2108
  return insertRecordedRows(
2307
2109
  target,
2308
2110
  table,
@@ -2310,7 +2112,7 @@ function insertRecordedEdgeRows(target, table, inserts, recordedCommit) {
2310
2112
  RECORDED_EDGE_COLUMNS,
2311
2113
  recordedEdgeCells,
2312
2114
  inserts,
2313
- recordedCommit
2115
+ recordedRevision
2314
2116
  );
2315
2117
  }
2316
2118
 
@@ -2325,15 +2127,15 @@ function entityKey(entity) {
2325
2127
  }
2326
2128
  }
2327
2129
  }
2328
- async function closeOpenReturning(target, table, graphId, ids, recordedCommit, kind) {
2130
+ async function closeOpenReturning(target, table, graphId, ids, recordedRevision, kind) {
2329
2131
  const kindFilter = kind === void 0 ? sql`` : sql`AND kind = ${kind}`;
2330
2132
  const rows = await target.execute(
2331
2133
  asCompiledRowsSql(sql`
2332
2134
  UPDATE ${table}
2333
- SET recorded_to = ${recordedCommit}
2135
+ SET recorded_to = ${recordedRevision}
2334
2136
  WHERE graph_id = ${graphId}
2335
2137
  ${kindFilter}
2336
- AND recorded_to = ${RECORDED_MAX}
2138
+ AND recorded_to = ${RECORDED_MAX_REVISION}
2337
2139
  AND id IN (${sqlValueList(ids)})
2338
2140
  RETURNING id, deleted_at
2339
2141
  `)
@@ -2375,7 +2177,7 @@ function recordedInsertsFor(afterById, closed) {
2375
2177
  operation: recordedOp(closed.has(row.id), closed.get(row.id) ?? false, row)
2376
2178
  }));
2377
2179
  }
2378
- async function flushNodes(target, schema, graphId, entities, recordedCommit) {
2180
+ async function flushNodes(target, schema, graphId, entities, recordedRevision) {
2379
2181
  const chunkSize = recordedNodeChunkSize(target);
2380
2182
  for (const [kind, group] of groupNodesByKind(entities)) {
2381
2183
  for (const entityChunk of chunk(group, chunkSize)) {
@@ -2385,7 +2187,7 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
2385
2187
  schema.recordedNodesTable,
2386
2188
  graphId,
2387
2189
  ids,
2388
- recordedCommit,
2190
+ recordedRevision,
2389
2191
  kind
2390
2192
  );
2391
2193
  const afterById = await resolveAfterImages(
@@ -2396,12 +2198,12 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
2396
2198
  target,
2397
2199
  schema.recordedNodesTable,
2398
2200
  recordedInsertsFor(afterById, closed),
2399
- recordedCommit
2201
+ recordedRevision
2400
2202
  );
2401
2203
  }
2402
2204
  }
2403
2205
  }
2404
- async function flushEdges(target, schema, graphId, entities, recordedCommit) {
2206
+ async function flushEdges(target, schema, graphId, entities, recordedRevision) {
2405
2207
  const chunkSize = recordedEdgeChunkSize(target);
2406
2208
  for (const entityChunk of chunk(entities, chunkSize)) {
2407
2209
  const ids = entityChunk.map((entity) => entity.id);
@@ -2410,7 +2212,7 @@ async function flushEdges(target, schema, graphId, entities, recordedCommit) {
2410
2212
  schema.recordedEdgesTable,
2411
2213
  graphId,
2412
2214
  ids,
2413
- recordedCommit
2215
+ recordedRevision
2414
2216
  );
2415
2217
  const afterById = await resolveAfterImages(
2416
2218
  entityChunk,
@@ -2420,31 +2222,31 @@ async function flushEdges(target, schema, graphId, entities, recordedCommit) {
2420
2222
  target,
2421
2223
  schema.recordedEdgesTable,
2422
2224
  recordedInsertsFor(afterById, closed),
2423
- recordedCommit
2225
+ recordedRevision
2424
2226
  );
2425
2227
  }
2426
2228
  }
2427
- async function closeOpenByKind(target, table, graphId, kind, recordedCommit) {
2229
+ async function closeOpenByKind(target, table, graphId, kind, recordedRevision) {
2428
2230
  await executeStatement(
2429
2231
  target,
2430
2232
  sql`
2431
2233
  UPDATE ${table}
2432
- SET recorded_to = ${recordedCommit}
2234
+ SET recorded_to = ${recordedRevision}
2433
2235
  WHERE graph_id = ${graphId}
2434
2236
  AND kind = ${kind}
2435
- AND recorded_to = ${RECORDED_MAX}
2237
+ AND recorded_to = ${RECORDED_MAX_REVISION}
2436
2238
  `
2437
2239
  );
2438
2240
  }
2439
- async function closeOpenEdgesByNodeKind(target, schema, graphId, nodeKind, recordedCommit) {
2241
+ async function closeOpenEdgesByNodeKind(target, schema, graphId, nodeKind, recordedRevision) {
2440
2242
  await executeStatement(
2441
2243
  target,
2442
2244
  sql`
2443
2245
  UPDATE ${schema.recordedEdgesTable}
2444
- SET recorded_to = ${recordedCommit}
2246
+ SET recorded_to = ${recordedRevision}
2445
2247
  WHERE graph_id = ${graphId}
2446
2248
  AND (from_kind = ${nodeKind} OR to_kind = ${nodeKind})
2447
- AND recorded_to = ${RECORDED_MAX}
2249
+ AND recorded_to = ${RECORDED_MAX_REVISION}
2448
2250
  `
2449
2251
  );
2450
2252
  }
@@ -2461,14 +2263,14 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
2461
2263
  schema.recordedNodesTable,
2462
2264
  graphId,
2463
2265
  removal.kind,
2464
- recordedCommit
2266
+ recordedCommit.revision
2465
2267
  );
2466
2268
  await closeOpenEdgesByNodeKind(
2467
2269
  target,
2468
2270
  schema,
2469
2271
  graphId,
2470
2272
  removal.kind,
2471
- recordedCommit
2273
+ recordedCommit.revision
2472
2274
  );
2473
2275
  return;
2474
2276
  }
@@ -2477,7 +2279,7 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
2477
2279
  schema.recordedEdgesTable,
2478
2280
  graphId,
2479
2281
  removal.kind,
2480
- recordedCommit
2282
+ recordedCommit.revision
2481
2283
  );
2482
2284
  }
2483
2285
  async function queryConnectedEdgeIds(target, schema, params) {
@@ -2495,6 +2297,104 @@ async function queryConnectedEdgeIds(target, schema, params) {
2495
2297
  return rows.map((row) => row.id);
2496
2298
  }
2497
2299
 
2300
+ // src/store/recorded-capture/schema-version.ts
2301
+ function normalizedColumnType(value) {
2302
+ if (typeof value !== "string") return void 0;
2303
+ const normalized = value.trim().toLowerCase();
2304
+ return normalized.length === 0 ? void 0 : normalized;
2305
+ }
2306
+ async function readColumnTypes(backend, table) {
2307
+ const rows = backend.dialect === "sqlite" ? await backend.execute(
2308
+ asCompiledRowsSql(sql`PRAGMA table_info(${sql.identifier(table)})`)
2309
+ ) : await backend.execute(
2310
+ asCompiledRowsSql(sql`
2311
+ SELECT column_name AS name, data_type AS type
2312
+ FROM information_schema.columns
2313
+ WHERE table_schema = current_schema()
2314
+ AND table_name = ${table}
2315
+ `)
2316
+ );
2317
+ return new Map(
2318
+ rows.flatMap((row) => {
2319
+ if (typeof row.name !== "string") return [];
2320
+ const type = normalizedColumnType(row.type);
2321
+ return type === void 0 ? [] : [[row.name, type]];
2322
+ })
2323
+ );
2324
+ }
2325
+ function hasSqliteAffinity(declaredType, kind) {
2326
+ if (kind === "revision") return declaredType.includes("int");
2327
+ return declaredType.includes("char") || declaredType.includes("clob") || declaredType.includes("text");
2328
+ }
2329
+ function isCompatibleColumnType(dialect, declaredType, kind) {
2330
+ if (dialect === "sqlite") return hasSqliteAffinity(declaredType, kind);
2331
+ return kind === "revision" ? declaredType === "bigint" : declaredType === "timestamp with time zone";
2332
+ }
2333
+ function requiredRecordedColumns(schema) {
2334
+ return [
2335
+ {
2336
+ table: schema.tables.recordedNodes,
2337
+ column: "recorded_from",
2338
+ kind: "revision"
2339
+ },
2340
+ {
2341
+ table: schema.tables.recordedNodes,
2342
+ column: "recorded_to",
2343
+ kind: "revision"
2344
+ },
2345
+ {
2346
+ table: schema.tables.recordedEdges,
2347
+ column: "recorded_from",
2348
+ kind: "revision"
2349
+ },
2350
+ {
2351
+ table: schema.tables.recordedEdges,
2352
+ column: "recorded_to",
2353
+ kind: "revision"
2354
+ },
2355
+ {
2356
+ table: schema.tables.recordedClock,
2357
+ column: "revision",
2358
+ kind: "revision"
2359
+ },
2360
+ {
2361
+ table: schema.tables.recordedClock,
2362
+ column: "recorded_at",
2363
+ kind: "wall-time"
2364
+ }
2365
+ ];
2366
+ }
2367
+ async function assertCurrentRecordedSchema(backend, schema) {
2368
+ const requirements = requiredRecordedColumns(schema);
2369
+ const tables = [...new Set(requirements.map((entry) => entry.table))];
2370
+ const columnTypes = new Map(
2371
+ await Promise.all(
2372
+ tables.map(
2373
+ async (table) => [table, await readColumnTypes(backend, table)]
2374
+ )
2375
+ )
2376
+ );
2377
+ const incompatible = requirements.flatMap((requirement) => {
2378
+ const actual = columnTypes.get(requirement.table)?.get(requirement.column);
2379
+ if (actual !== void 0 && isCompatibleColumnType(backend.dialect, actual, requirement.kind)) {
2380
+ return [];
2381
+ }
2382
+ return [{ ...requirement, actual: actual ?? "missing" }];
2383
+ });
2384
+ if (incompatible.length === 0) return;
2385
+ throw new ConfigurationError(
2386
+ "Recorded-time schema is incompatible with history capture.",
2387
+ {
2388
+ code: "RECORDED_SCHEMA_INCOMPATIBLE",
2389
+ dialect: backend.dialect,
2390
+ incompatible
2391
+ },
2392
+ {
2393
+ suggestion: "Run migrateLegacyRecordedTime({ backend }) before opening a store with history: true. If these are not preview-schema tables, provision the current recorded relations first."
2394
+ }
2395
+ );
2396
+ }
2397
+
2498
2398
  // src/store/recorded-capture.ts
2499
2399
  var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
2500
2400
  function readRecordedFlushObserver(options) {
@@ -2582,15 +2482,27 @@ function createRecordedCaptureSession() {
2582
2482
  graphId,
2583
2483
  ownsWriteLock
2584
2484
  );
2585
- recordedByGraph.set(graphId, recordedCommit);
2485
+ recordedByGraph.set(graphId, recordedCommit.instant);
2586
2486
  const nodes = entities.filter(
2587
2487
  (entity) => entity.entity === "node"
2588
2488
  );
2589
2489
  const edges = entities.filter(
2590
2490
  (entity) => entity.entity === "edge"
2591
2491
  );
2592
- await flushNodes(target, schema, graphId, nodes, recordedCommit);
2593
- await flushEdges(target, schema, graphId, edges, recordedCommit);
2492
+ await flushNodes(
2493
+ target,
2494
+ schema,
2495
+ graphId,
2496
+ nodes,
2497
+ recordedCommit.revision
2498
+ );
2499
+ await flushEdges(
2500
+ target,
2501
+ schema,
2502
+ graphId,
2503
+ edges,
2504
+ recordedCommit.revision
2505
+ );
2594
2506
  }
2595
2507
  touched.clear();
2596
2508
  return recordedByGraph;
@@ -3683,6 +3595,6 @@ async function applyNodeResurrect(ctx, args, backend) {
3683
3595
  return row;
3684
3596
  }
3685
3597
 
3686
- export { ALIAS_CTE_PREFIX, AUTO_REFRESH_STATISTICS_ROW_THRESHOLD, CURRENT_READ_INSTANT_PLACEHOLDER, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, STORE_RUNTIME, TRANSACTION_RUNTIME, advanceRevisionClock, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeInsertSideEffectsBatch, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, arrayField, assertRecordedCaptureTransactionIsolation, assertRevisionTrackableBackend, baseField, buildFieldBuilderForTypeInfo, buildPredicateIndex, checkCardinality, checkDisjointness, checkUniqueEdge, checkUniquenessConstraints, checkWherePredicate, closeRecordedHardDeletedKind, compileFieldValue, compileKindFilter, compilePredicateClauses, compilePredicateExpression, compileTemporalFilter, computeFulltextContent, computeUniqueKey, createFulltextAccessor, createGraphBackendProjection, createNodeWriteContext, createRecordedBackend, createRecordedReadBinding, createRecordedTransactionScope, createSqlSchema, createUniquenessContext, currentReadInstant, currentReadInstantFor, dateField, edgeInsertDispatch, ensureRevisionOrigin, exists, extractFulltextMatchPredicates, extractTemporalOptions, extractVectorSimilarityPredicates, fieldRef, generateId, getEdgeRowsByIds, getEmbeddingFields, getFieldPointer, getHybridTargetAlias, getKindsForUniquenessCheck, getNodeKindsForAlias, getNodeRowsByIds, getPredicatesForAlias, inSubquery, isParameterRef, lockRecordedGraphWrite, nodeInsertDispatch, notExists, notInSubquery, numberField, objectField, param, projectBackendMembers, readRecordedClock, readRevisionOrigin, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, recordedReadSchemaFor, recordedReadSqlSchema, recordedRelation, requireExternalRecordedReadSource, requireRecordedReadBinding, requireSqlSchema, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, sqlValueList, storeBackend, storeRuntime, stringField, throwHistoryUnsafeSqlAccess, throwRevisionTrackingUnsafeSqlAccess, transactionBackend, transactionNodeOperationHookRunner, uncapturedGraphWriteLock, validateEdgeEndpoints, vectorSlotKey, withPinnedReadInstant, withRecordedFlushObserver };
3687
- //# sourceMappingURL=chunk-RQPRCEIO.js.map
3688
- //# sourceMappingURL=chunk-RQPRCEIO.js.map
3598
+ export { AUTO_REFRESH_STATISTICS_ROW_THRESHOLD, CURRENT_READ_INSTANT_PLACEHOLDER, STORE_RUNTIME, TRANSACTION_RUNTIME, advanceRevisionClock, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeInsertSideEffectsBatch, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, arrayField, assertCurrentRecordedSchema, assertRecordedCaptureTransactionIsolation, assertRevisionTrackableBackend, baseField, buildFieldBuilderForTypeInfo, buildPredicateIndex, checkCardinality, checkDisjointness, checkUniqueEdge, checkUniquenessConstraints, checkWherePredicate, closeRecordedHardDeletedKind, compileFieldValue, compileKindFilter, compilePredicateClauses, compilePredicateExpression, compileTemporalFilter, computeFulltextContent, computeUniqueKey, createFulltextAccessor, createGraphBackendProjection, createNodeWriteContext, createRecordedBackend, createRecordedTransactionScope, createUniquenessContext, currentReadInstant, currentReadInstantFor, dateField, edgeInsertDispatch, ensureRevisionOrigin, exists, extractFulltextMatchPredicates, extractTemporalOptions, extractVectorSimilarityPredicates, fieldRef, generateId, getEdgeRowsByIds, getEmbeddingFields, getFieldPointer, getHybridTargetAlias, getKindsForUniquenessCheck, getNodeKindsForAlias, getNodeRowsByIds, getPredicatesForAlias, inSubquery, isParameterRef, lockRecordedGraphWrite, nodeInsertDispatch, notExists, notInSubquery, numberField, objectField, param, projectBackendMembers, readRecordedClock, readRevisionOrigin, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, sqlValueList, storeBackend, storeRuntime, stringField, throwHistoryUnsafeSqlAccess, throwRevisionTrackingUnsafeSqlAccess, transactionBackend, transactionNodeOperationHookRunner, uncapturedGraphWriteLock, validateEdgeEndpoints, withPinnedReadInstant, withRecordedFlushObserver };
3599
+ //# sourceMappingURL=chunk-JHK6NPFV.js.map
3600
+ //# sourceMappingURL=chunk-JHK6NPFV.js.map