viborm 1.2.3 → 1.3.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 (276) hide show
  1. package/README.md +6 -1
  2. package/dist/{adapter-internals-n3Mf3css.mjs → adapter-internals-AGgQRu5t.mjs} +1 -1
  3. package/dist/{adapter-internals-n3Mf3css.mjs.map → adapter-internals-AGgQRu5t.mjs.map} +1 -1
  4. package/dist/adapter-namespace-BpMbLKpL.mjs +2 -0
  5. package/dist/{adapter-namespace-DqkJQdrD.mjs.map → adapter-namespace-BpMbLKpL.mjs.map} +1 -1
  6. package/dist/adapters.d.mts +1 -1
  7. package/dist/adapters.mjs +1 -1
  8. package/dist/{array-literal-BsbbSLw3.mjs → array-literal-BKdLfNzM.mjs} +1 -1
  9. package/dist/{array-literal-BsbbSLw3.mjs.map → array-literal-BKdLfNzM.mjs.map} +1 -1
  10. package/dist/{base-AdXAoy6l.mjs → base-D3m1S7Uc.mjs} +2 -2
  11. package/dist/{base-AdXAoy6l.mjs.map → base-D3m1S7Uc.mjs.map} +1 -1
  12. package/dist/{batch-refs-4L8ECdPU.mjs → batch-refs-B4zn-FAu.mjs} +2 -2
  13. package/dist/{batch-refs-4L8ECdPU.mjs.map → batch-refs-B4zn-FAu.mjs.map} +1 -1
  14. package/dist/{bind-parameter-capacity-CjPgqnmx.mjs → bind-parameter-capacity-qfEejeOX.mjs} +2 -2
  15. package/dist/{bind-parameter-capacity-CjPgqnmx.mjs.map → bind-parameter-capacity-qfEejeOX.mjs.map} +1 -1
  16. package/dist/builder-Df24l2Bd.mjs +2 -0
  17. package/dist/builder-Df24l2Bd.mjs.map +1 -0
  18. package/dist/bun-sql.d.mts +3 -1
  19. package/dist/bun-sql.mjs +1 -1
  20. package/dist/bun-sql.mjs.map +1 -1
  21. package/dist/bun-sqlite.d.mts +1 -1
  22. package/dist/bun-sqlite.mjs +1 -1
  23. package/dist/cache/cloudflare-kv.d.mts +1 -1
  24. package/dist/cache/cloudflare-kv.mjs +1 -1
  25. package/dist/cache/memory.d.mts +1 -1
  26. package/dist/cache/memory.mjs +1 -1
  27. package/dist/{cache-BO57X0TT.mjs → cache-CIPRF-pz.mjs} +2 -2
  28. package/dist/{cache-BO57X0TT.mjs.map → cache-CIPRF-pz.mjs.map} +1 -1
  29. package/dist/cache.d.mts +1 -1
  30. package/dist/cache.mjs +1 -1
  31. package/dist/cache.mjs.map +1 -1
  32. package/dist/{canonical-json-rfC2Dg0X.mjs → canonical-json-BReb5nFO.mjs} +2 -2
  33. package/dist/{canonical-json-rfC2Dg0X.mjs.map → canonical-json-BReb5nFO.mjs.map} +1 -1
  34. package/dist/chain-C7c1YTXD.mjs +2 -0
  35. package/dist/chain-C7c1YTXD.mjs.map +1 -0
  36. package/dist/cli.mjs +2 -2
  37. package/dist/cli.mjs.map +1 -1
  38. package/dist/{client-GoDZgqdq.d.mts → client-70MrTq1E.d.mts} +3 -3
  39. package/dist/client-DM1UHfYG.mjs +49 -0
  40. package/dist/client-DM1UHfYG.mjs.map +1 -0
  41. package/dist/client-_WKrPNmm.mjs +2 -0
  42. package/dist/client-_WKrPNmm.mjs.map +1 -0
  43. package/dist/client.d.mts +2 -2
  44. package/dist/client.mjs +1 -1
  45. package/dist/{clock-CK41KO7t.mjs → clock-C24RcpwO.mjs} +1 -1
  46. package/dist/{clock-CK41KO7t.mjs.map → clock-C24RcpwO.mjs.map} +1 -1
  47. package/dist/config.d.mts +2 -2
  48. package/dist/config.mjs +1 -1
  49. package/dist/controls-Da-efekX.mjs +2 -0
  50. package/dist/controls-Da-efekX.mjs.map +1 -0
  51. package/dist/{current-DyzK6OCh.mjs → current-oXcxSCBQ.mjs} +1 -1
  52. package/dist/{current-DyzK6OCh.mjs.map → current-oXcxSCBQ.mjs.map} +1 -1
  53. package/dist/d1.d.mts +1 -1
  54. package/dist/d1.mjs +1 -1
  55. package/dist/d1.mjs.map +1 -1
  56. package/dist/{datetime-physical-codec-oIhiYZEP.mjs → datetime-physical-codec-BEqQbIP_.mjs} +2 -2
  57. package/dist/{datetime-physical-codec-oIhiYZEP.mjs.map → datetime-physical-codec-BEqQbIP_.mjs.map} +1 -1
  58. package/dist/driver-B9fIori_.mjs +2 -0
  59. package/dist/driver-B9fIori_.mjs.map +1 -0
  60. package/dist/{driver-B19QlFqn.mjs → driver-CPD0Xxw2.mjs} +2 -2
  61. package/dist/{driver-B19QlFqn.mjs.map → driver-CPD0Xxw2.mjs.map} +1 -1
  62. package/dist/driver.d.mts +1 -1
  63. package/dist/driver.mjs +1 -1
  64. package/dist/error-mapping-C9WgitPi.mjs +2 -0
  65. package/dist/error-mapping-C9WgitPi.mjs.map +1 -0
  66. package/dist/every-1pKZteeB.mjs +2 -0
  67. package/dist/{every-DCY4HV0X.mjs.map → every-1pKZteeB.mjs.map} +1 -1
  68. package/dist/{execution-context-BKR3bgES.mjs → execution-context-rJXTRVrJ.mjs} +1 -1
  69. package/dist/{execution-context-BKR3bgES.mjs.map → execution-context-rJXTRVrJ.mjs.map} +1 -1
  70. package/dist/{fs-estate-CAhDg7nY.mjs → fs-estate-i8Zlr1OQ.mjs} +2 -2
  71. package/dist/{fs-estate-CAhDg7nY.mjs.map → fs-estate-i8Zlr1OQ.mjs.map} +1 -1
  72. package/dist/{geo-area-codec-1SY9im7O.mjs → geo-area-codec-CbkmFArQ.mjs} +2 -2
  73. package/dist/{geo-area-codec-1SY9im7O.mjs.map → geo-area-codec-CbkmFArQ.mjs.map} +1 -1
  74. package/dist/geo-point-codec-DyEHMdJg.mjs +2 -0
  75. package/dist/geo-point-codec-DyEHMdJg.mjs.map +1 -0
  76. package/dist/hydration-DsyHNSDS.mjs +2 -0
  77. package/dist/{hydration-CAxOL4aI.mjs.map → hydration-DsyHNSDS.mjs.map} +1 -1
  78. package/dist/identifier-conversion-DaZ9yNpv.mjs +2 -0
  79. package/dist/{identifier-conversion-GgbwHc2G.mjs.map → identifier-conversion-DaZ9yNpv.mjs.map} +1 -1
  80. package/dist/{identity-CLFhCTZx.mjs → identity-oQvIe7u8.mjs} +2 -2
  81. package/dist/{identity-CLFhCTZx.mjs.map → identity-oQvIe7u8.mjs.map} +1 -1
  82. package/dist/{index-BaK35ze2.d.mts → index-VsM29vYN.d.mts} +5269 -4918
  83. package/dist/index.d.mts +3 -3
  84. package/dist/index.mjs +1 -1
  85. package/dist/index.mjs.map +1 -1
  86. package/dist/instrumentation.d.mts +1 -1
  87. package/dist/instrumentation.mjs +1 -1
  88. package/dist/{invariant-BnLYqsHO.mjs → invariant-D57gi_yW.mjs} +1 -1
  89. package/dist/{invariant-BnLYqsHO.mjs.map → invariant-D57gi_yW.mjs.map} +1 -1
  90. package/dist/{json-number-CGXpPu4D.mjs → json-number-DvmiNx0n.mjs} +1 -1
  91. package/dist/{json-number-CGXpPu4D.mjs.map → json-number-DvmiNx0n.mjs.map} +1 -1
  92. package/dist/key-D_kagnFv.mjs +2 -0
  93. package/dist/{key-BeoOwGr3.mjs.map → key-D_kagnFv.mjs.map} +1 -1
  94. package/dist/{libsql-x0RPVRDS.mjs → libsql-DFAoHXrI.mjs} +3 -3
  95. package/dist/{libsql-x0RPVRDS.mjs.map → libsql-DFAoHXrI.mjs.map} +1 -1
  96. package/dist/libsql.d.mts +1 -1
  97. package/dist/libsql.mjs +1 -1
  98. package/dist/{memory-gv5jLGYm.mjs → memory-GTWgeDNY.mjs} +2 -2
  99. package/dist/{memory-gv5jLGYm.mjs.map → memory-GTWgeDNY.mjs.map} +1 -1
  100. package/dist/migrations/mysql.d.mts +5 -5
  101. package/dist/migrations/mysql.mjs +1 -1
  102. package/dist/migrations/postgres.d.mts +5 -5
  103. package/dist/migrations/postgres.mjs +1 -1
  104. package/dist/migrations/sqlite.d.mts +5 -5
  105. package/dist/migrations/sqlite.mjs +1 -1
  106. package/dist/migrations/storage/durable-object.d.mts +1 -1
  107. package/dist/migrations/storage/durable-object.mjs +1 -1
  108. package/dist/migrations/storage/fs.d.mts +1 -1
  109. package/dist/migrations/storage/fs.mjs +1 -1
  110. package/dist/migrations/storage/r2.d.mts +1 -1
  111. package/dist/migrations/storage/r2.mjs +1 -1
  112. package/dist/migrations/tenant.d.mts +3 -3
  113. package/dist/migrations/tenant.mjs +1 -1
  114. package/dist/{migrations-DTObIjAm.mjs → migrations-Bn1SatyB.mjs} +2 -2
  115. package/dist/{migrations-DTObIjAm.mjs.map → migrations-Bn1SatyB.mjs.map} +1 -1
  116. package/dist/migrations.d.mts +5 -5
  117. package/dist/migrations.mjs +1 -1
  118. package/dist/mysql-adapter-C6c5govr.mjs +2 -0
  119. package/dist/{mysql-adapter-DkJPfoGf.mjs.map → mysql-adapter-C6c5govr.mjs.map} +1 -1
  120. package/dist/{mysql-B5cqxG99.mjs → mysql-xChEivOe.mjs} +6 -6
  121. package/dist/{mysql-B5cqxG99.mjs.map → mysql-xChEivOe.mjs.map} +1 -1
  122. package/dist/mysql2.d.mts +1 -1
  123. package/dist/mysql2.mjs +1 -1
  124. package/dist/{native-types-veeTk36s.mjs → native-types-asNCr26n.mjs} +1 -1
  125. package/dist/{native-types-veeTk36s.mjs.map → native-types-asNCr26n.mjs.map} +1 -1
  126. package/dist/neon-http.d.mts +3 -1
  127. package/dist/neon-http.mjs +1 -1
  128. package/dist/neon-http.mjs.map +1 -1
  129. package/dist/{object-store-DQR6bTBY.mjs → object-store-ChYHlOMD.mjs} +2 -2
  130. package/dist/{object-store-DQR6bTBY.mjs.map → object-store-ChYHlOMD.mjs.map} +1 -1
  131. package/dist/{object-store-Cj8Cnnba.d.mts → object-store-D9mvOHP4.d.mts} +4 -4
  132. package/dist/{observation-DUSm7oXK.mjs → observation-Co72iCd1.mjs} +2 -2
  133. package/dist/{observation-DUSm7oXK.mjs.map → observation-Co72iCd1.mjs.map} +1 -1
  134. package/dist/permissions.d.mts +424 -0
  135. package/dist/permissions.mjs +2 -0
  136. package/dist/permissions.mjs.map +1 -0
  137. package/dist/pg.d.mts +9 -1
  138. package/dist/pg.mjs +1 -1
  139. package/dist/pg.mjs.map +1 -1
  140. package/dist/pglite.d.mts +3 -1
  141. package/dist/pglite.mjs +1 -1
  142. package/dist/pglite.mjs.map +1 -1
  143. package/dist/{physical-6V_LNU3L.mjs → physical-CAOaNM4R.mjs} +2 -2
  144. package/dist/{physical-6V_LNU3L.mjs.map → physical-CAOaNM4R.mjs.map} +1 -1
  145. package/dist/{pinned-session-CLxj5M5e.mjs → pinned-session-BTplL3iZ.mjs} +2 -2
  146. package/dist/{pinned-session-CLxj5M5e.mjs.map → pinned-session-BTplL3iZ.mjs.map} +1 -1
  147. package/dist/planetscale.d.mts +1 -1
  148. package/dist/planetscale.mjs +1 -1
  149. package/dist/{planner-DH-K2gSq.d.mts → planner-C1NzLBge.d.mts} +1 -1
  150. package/dist/{postgres-DrXDok0O.mjs → postgres-BqAxDWTQ.mjs} +4 -4
  151. package/dist/{postgres-DrXDok0O.mjs.map → postgres-BqAxDWTQ.mjs.map} +1 -1
  152. package/dist/postgres-adapter-CGthb5yh.mjs +2 -0
  153. package/dist/postgres-adapter-CGthb5yh.mjs.map +1 -0
  154. package/dist/postgres-adapter-CxEit2-v.mjs +2 -0
  155. package/dist/postgres-adapter-CxEit2-v.mjs.map +1 -0
  156. package/dist/{postgres-result-7F0DllQe.mjs → postgres-result-KyBKBNJr.mjs} +2 -2
  157. package/dist/{postgres-result-7F0DllQe.mjs.map → postgres-result-KyBKBNJr.mjs.map} +1 -1
  158. package/dist/postgres.d.mts +3 -1
  159. package/dist/postgres.mjs +1 -1
  160. package/dist/postgres.mjs.map +1 -1
  161. package/dist/{provider-limits-BHATED_m.mjs → provider-limits-Da00ilvv.mjs} +2 -2
  162. package/dist/{provider-limits-BHATED_m.mjs.map → provider-limits-Da00ilvv.mjs.map} +1 -1
  163. package/dist/{result-parsing-DRXC89ek.mjs → result-parsing-8wEK3GY1.mjs} +1 -1
  164. package/dist/{result-parsing-DRXC89ek.mjs.map → result-parsing-8wEK3GY1.mjs.map} +1 -1
  165. package/dist/result-shape-CDgX_vzn.mjs +2 -0
  166. package/dist/result-shape-CDgX_vzn.mjs.map +1 -0
  167. package/dist/scalar-S8yMvdmx.mjs +4 -0
  168. package/dist/scalar-S8yMvdmx.mjs.map +1 -0
  169. package/dist/schema/json.d.mts +1 -1
  170. package/dist/schema/json.mjs +1 -1
  171. package/dist/schema/json.mjs.map +1 -1
  172. package/dist/schema-9N9jQlVL.mjs +2 -0
  173. package/dist/{schema-Cjem1-0f.mjs.map → schema-9N9jQlVL.mjs.map} +1 -1
  174. package/dist/{schema-introspection-DEYGC2qg.mjs → schema-introspection-CyXKReK1.mjs} +4 -4
  175. package/dist/{schema-introspection-DEYGC2qg.mjs.map → schema-introspection-CyXKReK1.mjs.map} +1 -1
  176. package/dist/schema.d.mts +1 -1
  177. package/dist/schema.mjs +1 -1
  178. package/dist/{select-assembly-f1UGoblh.mjs → select-assembly-CkGe2ABs.mjs} +2 -2
  179. package/dist/{select-assembly-f1UGoblh.mjs.map → select-assembly-CkGe2ABs.mjs.map} +1 -1
  180. package/dist/{settle-B9Vg1FnP.mjs → settle-CS_k6Ztm.mjs} +2 -2
  181. package/dist/{settle-B9Vg1FnP.mjs.map → settle-CS_k6Ztm.mjs.map} +1 -1
  182. package/dist/soft-delete.d.mts +27 -96
  183. package/dist/soft-delete.mjs +1 -1
  184. package/dist/soft-delete.mjs.map +1 -1
  185. package/dist/sql-Bhxq9arK.mjs +2 -0
  186. package/dist/sql-Bhxq9arK.mjs.map +1 -0
  187. package/dist/{sql-BvfwUKIh.d.mts → sql-EsoN_7Et.d.mts} +24 -0
  188. package/dist/{sql-statement-tokens-BBcoGmJb.mjs → sql-statement-tokens-CFi1y3bK.mjs} +1 -1
  189. package/dist/{sql-statement-tokens-BBcoGmJb.mjs.map → sql-statement-tokens-CFi1y3bK.mjs.map} +1 -1
  190. package/dist/sql.d.mts +1 -1
  191. package/dist/sql.mjs +1 -1
  192. package/dist/sqlite-adapter-BXAJy3mI.mjs +2 -0
  193. package/dist/sqlite-adapter-BXAJy3mI.mjs.map +1 -0
  194. package/dist/{sqlite-utils-DlgokMJN.mjs → sqlite-utils-D_cypcyW.mjs} +2 -2
  195. package/dist/{sqlite-utils-DlgokMJN.mjs.map → sqlite-utils-D_cypcyW.mjs.map} +1 -1
  196. package/dist/sqlite3.d.mts +3 -1
  197. package/dist/sqlite3.mjs +1 -1
  198. package/dist/sqlite3.mjs.map +1 -1
  199. package/dist/{standard-sql-Bk4RZPqJ.mjs → standard-sql-CoGqv-iX.mjs} +3 -3
  200. package/dist/standard-sql-CoGqv-iX.mjs.map +1 -0
  201. package/dist/{suppressed-failure-BwULh-8h.mjs → suppressed-failure-Bdo2aK81.mjs} +1 -1
  202. package/dist/{suppressed-failure-BwULh-8h.mjs.map → suppressed-failure-Bdo2aK81.mjs.map} +1 -1
  203. package/dist/to-many-C1PuFIpf.mjs +2 -0
  204. package/dist/to-many-C1PuFIpf.mjs.map +1 -0
  205. package/dist/{transaction-Bnl6ULTw.mjs → transaction-4dfqals6.mjs} +2 -2
  206. package/dist/{transaction-Bnl6ULTw.mjs.map → transaction-4dfqals6.mjs.map} +1 -1
  207. package/dist/{transaction-operation-CKK3l_9x.mjs → transaction-operation-CU1zlxiG.mjs} +2 -2
  208. package/dist/{transaction-operation-CKK3l_9x.mjs.map → transaction-operation-CU1zlxiG.mjs.map} +1 -1
  209. package/dist/{types-C4v6iAmY.mjs → types-C5Oxz9yp.mjs} +1 -1
  210. package/dist/{types-C4v6iAmY.mjs.map → types-C5Oxz9yp.mjs.map} +1 -1
  211. package/dist/{utils-CZNaOZR7.mjs → utils-CtFUE8UN.mjs} +4 -4
  212. package/dist/{utils-CZNaOZR7.mjs.map → utils-CtFUE8UN.mjs.map} +1 -1
  213. package/dist/v-CYTUI0H5.mjs +2 -0
  214. package/dist/v-CYTUI0H5.mjs.map +1 -0
  215. package/dist/validation-BQtO6srU.mjs +2 -0
  216. package/dist/{validation-PF9-_nKd.mjs.map → validation-BQtO6srU.mjs.map} +1 -1
  217. package/dist/validation-BamBwne9.mjs +2 -0
  218. package/dist/validation-BamBwne9.mjs.map +1 -0
  219. package/dist/validation.d.mts +1 -1
  220. package/dist/validation.mjs +1 -1
  221. package/dist/validator-DgffZq9C.mjs +2 -0
  222. package/dist/validator-DgffZq9C.mjs.map +1 -0
  223. package/dist/version-CXuJzC-q.mjs +2 -0
  224. package/dist/{version-Bemp-64P.mjs.map → version-CXuJzC-q.mjs.map} +1 -1
  225. package/package.json +35 -9
  226. package/dist/adapter-namespace-DqkJQdrD.mjs +0 -2
  227. package/dist/builder-Ycvq3ETg.mjs +0 -2
  228. package/dist/builder-Ycvq3ETg.mjs.map +0 -1
  229. package/dist/chain-Dh0FV72b.mjs +0 -2
  230. package/dist/chain-Dh0FV72b.mjs.map +0 -1
  231. package/dist/client-B1p6Le_h.mjs +0 -49
  232. package/dist/client-B1p6Le_h.mjs.map +0 -1
  233. package/dist/client-BLiBmykn.mjs +0 -2
  234. package/dist/client-BLiBmykn.mjs.map +0 -1
  235. package/dist/controls-DXgIn4zh.mjs +0 -2
  236. package/dist/controls-DXgIn4zh.mjs.map +0 -1
  237. package/dist/driver-BlnKXPFF.mjs +0 -2
  238. package/dist/driver-BlnKXPFF.mjs.map +0 -1
  239. package/dist/error-mapping-CnPCv1dm.mjs +0 -2
  240. package/dist/error-mapping-CnPCv1dm.mjs.map +0 -1
  241. package/dist/every-DCY4HV0X.mjs +0 -2
  242. package/dist/geo-point-codec-lhxH42SK.mjs +0 -2
  243. package/dist/geo-point-codec-lhxH42SK.mjs.map +0 -1
  244. package/dist/hydration-CAxOL4aI.mjs +0 -2
  245. package/dist/identifier-conversion-GgbwHc2G.mjs +0 -2
  246. package/dist/identifier-hQCs8M1n.mjs +0 -2
  247. package/dist/identifier-hQCs8M1n.mjs.map +0 -1
  248. package/dist/key-BeoOwGr3.mjs +0 -2
  249. package/dist/mysql-adapter-DkJPfoGf.mjs +0 -2
  250. package/dist/postgres-adapter-B3SQvcV1.mjs +0 -2
  251. package/dist/postgres-adapter-B3SQvcV1.mjs.map +0 -1
  252. package/dist/postgres-adapter-CQD2oGuD.mjs +0 -2
  253. package/dist/postgres-adapter-CQD2oGuD.mjs.map +0 -1
  254. package/dist/registration-preflight-DEjv050M.mjs +0 -4
  255. package/dist/registration-preflight-DEjv050M.mjs.map +0 -1
  256. package/dist/result-shape-CTNdNSW3.mjs +0 -2
  257. package/dist/result-shape-CTNdNSW3.mjs.map +0 -1
  258. package/dist/scalar-U0wD5bKy.mjs +0 -2
  259. package/dist/scalar-U0wD5bKy.mjs.map +0 -1
  260. package/dist/schema-Cjem1-0f.mjs +0 -2
  261. package/dist/sql-Bp7jicEX.mjs +0 -2
  262. package/dist/sql-Bp7jicEX.mjs.map +0 -1
  263. package/dist/sqlite-adapter-CW_3l6ea.mjs +0 -2
  264. package/dist/sqlite-adapter-CW_3l6ea.mjs.map +0 -1
  265. package/dist/standard-sql-Bk4RZPqJ.mjs.map +0 -1
  266. package/dist/terminal-C8cq1WWX.mjs +0 -2
  267. package/dist/terminal-C8cq1WWX.mjs.map +0 -1
  268. package/dist/v-D5Z06FKN.mjs +0 -2
  269. package/dist/v-D5Z06FKN.mjs.map +0 -1
  270. package/dist/validation-Dk9Q_-C7.mjs +0 -2
  271. package/dist/validation-Dk9Q_-C7.mjs.map +0 -1
  272. package/dist/validation-PF9-_nKd.mjs +0 -2
  273. package/dist/validator-X9-bwtRo.mjs +0 -2
  274. package/dist/validator-X9-bwtRo.mjs.map +0 -1
  275. package/dist/version-Bemp-64P.mjs +0 -2
  276. /package/dist/{contract-CIIqgFyb.d.mts → contract-Dw0FR78e.d.mts} +0 -0
@@ -1,6 +1,6 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t,t as n}from"./sql-Bp7jicEX.mjs";const createIdentifierQuoter=e=>t=>e+(t.indexOf(e)===-1?t:t.replaceAll(e,e+e))+e,qualifiedPrefix=(e,t)=>`${e(t)}.`,renderQualifiedIdentifier=(e,t,n)=>t===void 0?e(n):qualifiedPrefix(e,t)+e(n),createQualifiedIdentifierRenderer=(e,t)=>{if(t===void 0)return e;let n=qualifiedPrefix(e,t);return t=>n+e(t)},createRawSql=()=>e=>t.raw(e),stringifyJson=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t),r=/^\d+$/,buildJsonPath=e=>{let t=`$`;for(let n of e)t+=r.test(n)?`[${n}]`:`.${JSON.stringify(n)}`;return t},createStandardLiterals=()=>({value:e=>t`${e}`,null:()=>t.raw(`NULL`),list:e=>e.length===0?t.raw(`()`):t`(${t.join(e,`, `)})`}),createComparisonOperators=()=>({eq:(e,n)=>t`${e} = ${n}`,neq:(e,n)=>t`${e} <> ${n}`,lt:(e,n)=>t`${e} < ${n}`,lte:(e,n)=>t`${e} <= ${n}`,gt:(e,n)=>t`${e} > ${n}`,gte:(e,n)=>t`${e} >= ${n}`}),createNullOperators=()=>({isNull:e=>t`${e} IS NULL`,isNotNull:e=>t`${e} IS NOT NULL`}),createRangeOperators=()=>({between:(e,n,r)=>t`${e} BETWEEN ${n} AND ${r}`,notBetween:(e,n,r)=>t`${e} NOT BETWEEN ${n} AND ${r}`}),createExistenceOperators=()=>({exists:e=>t`EXISTS (${e})`,notExists:e=>t`NOT EXISTS (${e})`}),createAggregateFunctions=e=>({count:e=>e?t`COUNT(${e})`:t.raw(`COUNT(*)`),countDistinct:e=>t`COUNT(DISTINCT ${e})`,sum:e=>t`SUM(${e})`,numberSum:n=>{let r=t`SUM(CASE WHEN ABS(${n}) >= 1e-288 THEN ${n} / 4294967296.0 / 4294967296.0 END)`,i=t`SUM(CASE WHEN ABS(${n}) < 1e-288 THEN ${n} END)`,a=t.raw(e??`1.7976931348623157e308`),o=t`CASE WHEN ${r} IS NULL THEN ${i} WHEN ABS(${r}) < 9.7453140114e288 THEN ${r} * 4294967296.0 * 4294967296.0 + COALESCE(${i}, 0) WHEN ${r} > 0 THEN ${a} ELSE -${a} END`;return{parts:[r,i],value:o,order:e?[o]:[o,r]}},avg:e=>t`AVG(${e})`,min:e=>t`MIN(${e})`,max:e=>t`MAX(${e})`});function decimalCoefficientPrecision(e){return e.startsWith(`-`)?e.length-1:e.length}function createDecimalSumOperandPrecision(e){return t=>{let n=decimalCoefficientPrecision(t);return n<=e?n:void 0}}const createDirectionOrderBy=()=>({asc:e=>t`${e} ASC`,desc:e=>t`${e} DESC`}),directionKeyword=e=>e===`desc`?t.raw(`DESC`):t.raw(`ASC`),createEmulatedNullsOrderBy=()=>({nullsFirst:(e,n)=>t`(${e} IS NULL) DESC, ${e} ${directionKeyword(n)}`,nullsLast:(e,n)=>t`(${e} IS NULL) ASC, ${e} ${directionKeyword(n)}`}),createStandardClauses=()=>({select:e=>t`SELECT ${e}`,selectDistinct:e=>t`SELECT DISTINCT ${e}`,from:e=>t`FROM ${e}`,where:e=>t`WHERE ${e}`,orderBy:e=>t`ORDER BY ${e}`,limit:e=>t`LIMIT ${e}`,offset:e=>t`OFFSET ${e}`,groupBy:e=>t`GROUP BY ${e}`,having:e=>t`HAVING ${e}`}),createNumericSetOperations=()=>({assign:(e,n)=>t`${e} = ${n}`,increment:(e,n)=>t`${e} = ${e} + ${n}`,decrement:(e,n)=>t`${e} = ${e} - ${n}`}),createRelationFilters=()=>({some:e=>t`EXISTS (${e})`,every:e=>t`NOT EXISTS (${e})`,none:e=>t`NOT EXISTS (${e})`,is:e=>t`EXISTS (${e})`,isNot:e=>t`NOT EXISTS (${e})`}),createMutationCommands=()=>({update:(e,n,r)=>r?t`UPDATE ${e} SET ${n} WHERE ${r}`:t`UPDATE ${e} SET ${n}`,delete:(e,n)=>n?t`DELETE FROM ${e} WHERE ${n}`:t`DELETE FROM ${e}`}),createSetOperations=()=>({union:(...e)=>t.join(e,` UNION `),unionAll:(...e)=>t.join(e,` UNION ALL `),intersect:(...e)=>t.join(e,` INTERSECT `),except:(e,n)=>t`${e} EXCEPT ${n}`}),createIdentifiers=(e,r)=>{let i=createQualifiedIdentifierRenderer(e,r);return{escape:n=>t.raw(e(n)),column:(n,r)=>{let i=n?`${e(n)}.${e(r)}`:e(r);return t.raw(i)},table:(n,r)=>{let a=i(n);return t.raw(r===void 0?a:`${a} AS ${e(r)}`)},aliased:(t,r)=>new n([``,` AS ${e(r)}`],[t])}},createSubqueries=e=>({scalar:e=>t`(${e})`,correlate:(n,r)=>t`(${n}) AS ${t.raw(e(r))}`,existsCheck:(e,n)=>t`SELECT 1 FROM ${e} WHERE ${n}`}),createCteBuilders=e=>({with:n=>{let r=n.map(({name:n,query:r})=>t`${t.raw(e(n))} AS (${r})`);return t`WITH ${t.join(r,`, `)}`},recursive:(n,r,i,a=`all`)=>{let o=a===`all`?t.raw(`UNION ALL`):t.raw(`UNION`);return t`WITH RECURSIVE ${t.raw(e(n))} AS (
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t,t as n}from"./sql-Bhxq9arK.mjs";const createIdentifierQuoter=e=>t=>e+(t.indexOf(e)===-1?t:t.replaceAll(e,e+e))+e,qualifiedPrefix=(e,t)=>`${e(t)}.`,renderQualifiedIdentifier=(e,t,n)=>t===void 0?e(n):qualifiedPrefix(e,t)+e(n),createQualifiedIdentifierRenderer=(e,t)=>{if(t===void 0)return e;let n=qualifiedPrefix(e,t);return t=>n+e(t)},createRawSql=()=>e=>t.raw(e),stringifyJson=e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t),r=/^\d+$/,buildJsonPath=e=>{let t=`$`;for(let n of e)t+=r.test(n)?`[${n}]`:`.${JSON.stringify(n)}`;return t},createStandardLiterals=()=>({value:e=>t`${e}`,null:()=>t.raw(`NULL`),list:e=>e.length===0?t.raw(`()`):t`(${t.join(e,`, `)})`}),createComparisonOperators=()=>({eq:(e,n)=>t`${e} = ${n}`,neq:(e,n)=>t`${e} <> ${n}`,lt:(e,n)=>t`${e} < ${n}`,lte:(e,n)=>t`${e} <= ${n}`,gt:(e,n)=>t`${e} > ${n}`,gte:(e,n)=>t`${e} >= ${n}`}),createNullOperators=()=>({isNull:e=>t`${e} IS NULL`,isNotNull:e=>t`${e} IS NOT NULL`}),createRangeOperators=()=>({between:(e,n,r)=>t`${e} BETWEEN ${n} AND ${r}`,notBetween:(e,n,r)=>t`${e} NOT BETWEEN ${n} AND ${r}`}),createExistenceOperators=()=>({exists:e=>t`EXISTS (${e})`,notExists:e=>t`NOT EXISTS (${e})`}),createAggregateFunctions=e=>({count:e=>e?t`COUNT(${e})`:t.raw(`COUNT(*)`),countDistinct:e=>t`COUNT(DISTINCT ${e})`,sum:e=>t`SUM(${e})`,numberSum:n=>{let r=t`SUM(CASE WHEN ABS(${n}) >= 1e-288 THEN ${n} / 4294967296.0 / 4294967296.0 END)`,i=t`SUM(CASE WHEN ABS(${n}) < 1e-288 THEN ${n} END)`,a=t.raw(e??`1.7976931348623157e308`),o=t`CASE WHEN ${r} IS NULL THEN ${i} WHEN ABS(${r}) < 9.7453140114e288 THEN ${r} * 4294967296.0 * 4294967296.0 + COALESCE(${i}, 0) WHEN ${r} > 0 THEN ${a} ELSE -${a} END`;return{parts:[r,i],value:o,order:e?[o]:[o,r]}},avg:e=>t`AVG(${e})`,min:e=>t`MIN(${e})`,max:e=>t`MAX(${e})`});function decimalCoefficientPrecision(e){return e.startsWith(`-`)?e.length-1:e.length}function createDecimalSumOperandPrecision(e){return t=>{let n=decimalCoefficientPrecision(t);return n<=e?n:void 0}}const createDirectionOrderBy=()=>({asc:e=>t`${e} ASC`,desc:e=>t`${e} DESC`}),directionKeyword=e=>e===`desc`?t.raw(`DESC`):t.raw(`ASC`),createEmulatedNullsOrderBy=()=>({nullsFirst:(e,n)=>t`(${e} IS NULL) DESC, ${e} ${directionKeyword(n)}`,nullsLast:(e,n)=>t`(${e} IS NULL) ASC, ${e} ${directionKeyword(n)}`}),createStandardClauses=()=>({select:e=>t`SELECT ${e}`,selectDistinct:e=>t`SELECT DISTINCT ${e}`,from:e=>t`FROM ${e}`,where:e=>t`WHERE ${e}`,orderBy:e=>t`ORDER BY ${e}`,limit:e=>t`LIMIT ${e}`,offset:e=>t`OFFSET ${e}`,groupBy:e=>t`GROUP BY ${e}`,having:e=>t`HAVING ${e}`}),createNumericSetOperations=()=>({assign:(e,n)=>t`${e} = ${n}`,increment:(e,n)=>t`${e} = ${e} + ${n}`,decrement:(e,n)=>t`${e} = ${e} - ${n}`}),createRelationFilters=()=>({some:e=>t`EXISTS (${e})`,every:e=>t`NOT EXISTS (${e})`,none:e=>t`NOT EXISTS (${e})`,is:e=>t`EXISTS (${e})`,isNot:e=>t`NOT EXISTS (${e})`}),createMutationCommands=()=>({update:(e,n,r)=>r?t`UPDATE ${e} SET ${n} WHERE ${r}`:t`UPDATE ${e} SET ${n}`,delete:(e,n)=>n?t`DELETE FROM ${e} WHERE ${n}`:t`DELETE FROM ${e}`}),rowValues=e=>t`(${t.join(e,`, `)})`,unionTypedRows=e=>(n,r,i)=>t`(${t.join([n.head,...r.map(e=>t`SELECT ${t.join(e,`, `)}`)],` UNION ALL `)}) AS ${t.raw(e(i))}`,createSetOperations=(e,n=unionTypedRows(e))=>({union:(...e)=>t.join(e,` UNION `),unionAll:(...e)=>t.join(e,` UNION ALL `),intersect:(...e)=>t.join(e,` INTERSECT `),except:(e,n)=>t`${e} EXCEPT ${n}`,typedRows:n}),createIdentifiers=(e,r)=>{let i=createQualifiedIdentifierRenderer(e,r);return{escape:n=>t.raw(e(n)),column:(n,r)=>{let i=n?`${e(n)}.${e(r)}`:e(r);return t.raw(i)},table:(n,r)=>{let a=i(n);return t.raw(r===void 0?a:`${a} AS ${e(r)}`)},aliased:(t,r)=>new n([``,` AS ${e(r)}`],[t])}},createSubqueries=e=>({scalar:e=>t`(${e})`,correlate:(n,r)=>t`(${n}) AS ${t.raw(e(r))}`,existsCheck:(e,n)=>t`SELECT 1 FROM ${e} WHERE ${n}`,isolated:e=>e}),createCteBuilders=e=>({with:n=>{let r=n.map(({name:n,query:r})=>t`${t.raw(e(n))} AS (${r})`);return t`WITH ${t.join(r,`, `)}`},recursive:(n,r,i,a=`all`)=>{let o=a===`all`?t.raw(`UNION ALL`):t.raw(`UNION`);return t`WITH RECURSIVE ${t.raw(e(n))} AS (
2
2
  ${r}
3
3
  ${o}
4
4
  ${i}
5
- )`}}),createInsertStatement=e=>(n,r,i,a)=>{let o=r.map(n=>t.raw(e(n))),s=Array.isArray(i)?t`VALUES ${t.join(i.map(e=>t`(${t.join(e,`, `)})`),`, `)}`:i.select;return t`INSERT ${a?t`${a} `:t``}INTO ${n} (${t.join(o,`, `)}) ${s}`},createOnConflictBuilders=()=>({onConflict:(e,n,r)=>e?r?t`ON CONFLICT (${e}) WHERE ${r} DO ${n}`:t`ON CONFLICT (${e}) DO ${n}`:t`ON CONFLICT DO ${n}`,onConflictUpdate:(e,n)=>n?t`UPDATE SET ${e} WHERE ${n}`:t`UPDATE SET ${e}`,skipDuplicates:()=>({prefix:t``,suffix:t`ON CONFLICT DO NOTHING`})}),createMembershipOperators=()=>({in:(e,n)=>t`${e} IN ${n}`,notIn:(e,n)=>t`${e} NOT IN ${n}`}),createLogicalOperators=(e,n)=>({and:(...n)=>n.length===0?e():n.length===1?n[0]:t`(${t.join(n,` AND `)})`,or:(...e)=>e.length===0?n():e.length===1?e[0]:t`(${t.join(e,` OR `)})`,not:e=>t`NOT (${e})`}),createCommonExpressions=()=>({caseWhen:(e,n)=>e.length===0?n:t`CASE ${t.join(e.map(e=>t`WHEN ${e.when} THEN ${e.then}`),` `)} ELSE ${n} END`,add:(e,n)=>t`(${e} + ${n})`,subtract:(e,n)=>t`(${e} - ${n})`,multiply:(e,n)=>t`(${e} * ${n})`,divide:(e,n)=>t`(${e} / ${n})`,upper:e=>t`UPPER(${e})`,lower:e=>t`LOWER(${e})`,coalesce:(...e)=>t`COALESCE(${t.join(e,`, `)})`}),createCastExpression=e=>(n,r)=>t`CAST(${n} AS ${t.raw(e[r])})`,createCoreJoins=()=>({inner:(e,n)=>t`INNER JOIN ${e} ON ${n}`,left:(e,n)=>t`LEFT JOIN ${e} ON ${n}`,right:(e,n)=>t`RIGHT JOIN ${e} ON ${n}`,cross:e=>t`CROSS JOIN ${e}`}),createLateralJoins=e=>({lateral:(n,r)=>t`JOIN LATERAL (${n}) AS ${t.raw(e(r))} ON TRUE`,lateralLeft:(n,r)=>t`LEFT JOIN LATERAL (${n}) AS ${t.raw(e(r))} ON TRUE`}),escapeLikeLiteral=e=>e.replace(/[\\%_]/g,e=>`\\${e}`),escapeGlobLiteral=e=>e.replace(/[*?[]/g,e=>`[${e}]`);export{escapeLikeLiteral as A,createRelationFilters as C,createSubqueries as D,createStandardLiterals as E,createIdentifierQuoter as M,renderQualifiedIdentifier as N,decimalCoefficientPrecision as O,createRawSql as S,createStandardClauses as T,createMutationCommands as _,createComparisonOperators as a,createOnConflictBuilders as b,createDecimalSumOperandPrecision as c,createExistenceOperators as d,createIdentifiers as f,createMembershipOperators as g,createLogicalOperators as h,createCommonExpressions as i,stringifyJson as j,escapeGlobLiteral as k,createDirectionOrderBy as l,createLateralJoins as m,createAggregateFunctions as n,createCoreJoins as o,createInsertStatement as p,createCastExpression as r,createCteBuilders as s,buildJsonPath as t,createEmulatedNullsOrderBy as u,createNullOperators as v,createSetOperations as w,createRangeOperators as x,createNumericSetOperations as y};
6
- //# sourceMappingURL=standard-sql-Bk4RZPqJ.mjs.map
5
+ )`}}),createInsertStatement=e=>(n,r,i,a)=>{let o=r.map(n=>t.raw(e(n))),s=Array.isArray(i)?t`VALUES ${t.join(i.map(e=>t`(${t.join(e,`, `)})`),`, `)}`:i.select;return t`INSERT ${a?t`${a} `:t``}INTO ${n} (${t.join(o,`, `)}) ${s}`},createOnConflictBuilders=()=>({onConflict:(e,n,r)=>e?r?t`ON CONFLICT (${e}) WHERE ${r} DO ${n}`:t`ON CONFLICT (${e}) DO ${n}`:t`ON CONFLICT DO ${n}`,onConflictUpdate:(e,n)=>n?t`UPDATE SET ${e} WHERE ${n}`:t`UPDATE SET ${e}`,skipDuplicates:()=>({prefix:t``,suffix:t`ON CONFLICT DO NOTHING`})}),createMembershipOperators=()=>({in:(e,n)=>t`${e} IN ${n}`,notIn:(e,n)=>t`${e} NOT IN ${n}`}),createLogicalOperators=(e,n)=>({and:(...n)=>n.length===0?e():n.length===1?n[0]:t`(${t.join(n,` AND `)})`,or:(...e)=>e.length===0?n():e.length===1?e[0]:t`(${t.join(e,` OR `)})`,not:e=>t`NOT (${e})`}),createCommonExpressions=()=>({caseWhen:(e,n)=>e.length===0?n:t`CASE ${t.join(e.map(e=>t`WHEN ${e.when} THEN ${e.then}`),` `)} ELSE ${n} END`,add:(e,n)=>t`(${e} + ${n})`,subtract:(e,n)=>t`(${e} - ${n})`,multiply:(e,n)=>t`(${e} * ${n})`,divide:(e,n)=>t`(${e} / ${n})`,upper:e=>t`UPPER(${e})`,lower:e=>t`LOWER(${e})`,coalesce:(...e)=>t`COALESCE(${t.join(e,`, `)})`}),createCastExpression=e=>(n,r)=>t`CAST(${n} AS ${t.raw(e[r])})`,createCoreJoins=()=>({inner:(e,n)=>t`INNER JOIN ${e} ON ${n}`,left:(e,n)=>t`LEFT JOIN ${e} ON ${n}`,right:(e,n)=>t`RIGHT JOIN ${e} ON ${n}`,cross:e=>t`CROSS JOIN ${e}`}),createLateralJoins=e=>({lateral:(n,r)=>t`JOIN LATERAL (${n}) AS ${t.raw(e(r))} ON TRUE`,lateralLeft:(n,r)=>t`LEFT JOIN LATERAL (${n}) AS ${t.raw(e(r))} ON TRUE`}),escapeLikeLiteral=e=>e.replace(/[\\%_]/g,e=>`\\${e}`),escapeGlobLiteral=e=>e.replace(/[*?[]/g,e=>`[${e}]`);export{escapeLikeLiteral as A,createRelationFilters as C,createSubqueries as D,createStandardLiterals as E,stringifyJson as M,createIdentifierQuoter as N,decimalCoefficientPrecision as O,renderQualifiedIdentifier as P,createRawSql as S,createStandardClauses as T,createMutationCommands as _,createComparisonOperators as a,createOnConflictBuilders as b,createDecimalSumOperandPrecision as c,createExistenceOperators as d,createIdentifiers as f,createMembershipOperators as g,createLogicalOperators as h,createCommonExpressions as i,rowValues as j,escapeGlobLiteral as k,createDirectionOrderBy as l,createLateralJoins as m,createAggregateFunctions as n,createCoreJoins as o,createInsertStatement as p,createCastExpression as r,createCteBuilders as s,buildJsonPath as t,createEmulatedNullsOrderBy as u,createNullOperators as v,createSetOperations as w,createRangeOperators as x,createNumericSetOperations as y};
6
+ //# sourceMappingURL=standard-sql-CoGqv-iX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-sql-CoGqv-iX.mjs","names":["sql"],"sources":["../src/sql/identifiers.ts","../src/adapters/shared/standard-sql.ts"],"sourcesContent":["/**\n * Identifier text primitives.\n *\n * Quoting one name for a dialect, and composing a namespace-qualified object\n * name, are string concerns with no `Sql` involvement: runtime adapters wrap the\n * result in `Sql`, migration drivers splice it into DDL text. Both pass their\n * own quoter — the two differ in escape semantics and null handling — so what is\n * shared here is the composition rule alone, and it has one owner.\n */\n\n/** Quote a single identifier for the dialect: `\"name\"` or `` `name` ``. */\nexport type IdentifierQuoter = (name: string) => string;\n\n/** Build an identifier quoter that doubles embedded quote characters to prevent SQL injection. */\nexport const createIdentifierQuoter =\n (quoteChar: '\"' | \"`\"): IdentifierQuoter =>\n (name: string): string => {\n const escaped =\n name.indexOf(quoteChar) === -1\n ? name\n : name.replaceAll(quoteChar, quoteChar + quoteChar);\n return quoteChar + escaped + quoteChar;\n };\n\n/**\n * The one qualification rule. A present namespace contributes a quoted prefix;\n * an absent one contributes nothing, which is what unbound MySQL and every\n * SQLite adapter mean.\n */\nconst qualifiedPrefix = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string\n): string => `${quoteIdentifier(namespace)}.`;\n\n/**\n * Compose one namespace-qualified object name. The namespace must already be\n * normalized: this primitive validates nothing, holds nothing, and returns text\n * for exactly one object.\n */\nexport const renderQualifiedIdentifier = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined,\n object: string\n): string =>\n namespace === undefined\n ? quoteIdentifier(object)\n : qualifiedPrefix(quoteIdentifier, namespace) + quoteIdentifier(object);\n\n/**\n * Bind one namespace so its prefix is quoted once per adapter rather than once\n * per rendered statement. The returned function renders exactly what\n * `renderQualifiedIdentifier` would for the same namespace.\n */\nexport const createQualifiedIdentifierRenderer = (\n quoteIdentifier: IdentifierQuoter,\n namespace: string | undefined\n): IdentifierQuoter => {\n if (namespace === undefined) {\n return quoteIdentifier;\n }\n const prefix = qualifiedPrefix(quoteIdentifier, namespace);\n return (object: string): string => prefix + quoteIdentifier(object);\n};\n","import { Sql, sql } from \"@sql\";\nimport {\n createQualifiedIdentifierRenderer,\n type IdentifierQuoter,\n} from \"../../sql/identifiers\";\nimport type { CastType, DatabaseAdapter } from \"../database-adapter\";\n\ntype StandardLiterals = Pick<\n DatabaseAdapter[\"literals\"],\n \"value\" | \"null\" | \"list\"\n>;\n\ntype ComparisonOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"eq\" | \"neq\" | \"lt\" | \"lte\" | \"gt\" | \"gte\"\n>;\n\ntype NullOperators = Pick<DatabaseAdapter[\"operators\"], \"isNull\" | \"isNotNull\">;\n\ntype RangeOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"between\" | \"notBetween\"\n>;\n\ntype ExistenceOperators = Pick<\n DatabaseAdapter[\"operators\"],\n \"exists\" | \"notExists\"\n>;\n\ntype DirectionOrderBy = Pick<DatabaseAdapter[\"orderBy\"], \"asc\" | \"desc\">;\n\ntype NumericSetOperations = Pick<\n DatabaseAdapter[\"set\"],\n \"assign\" | \"increment\" | \"decrement\"\n>;\n\ntype MutationCommands = Pick<DatabaseAdapter[\"mutations\"], \"update\" | \"delete\">;\n\nexport const createRawSql = (): DatabaseAdapter[\"raw\"] => {\n return (sqlString: string): Sql => sql.raw(sqlString);\n};\n\n/**\n * JSON-serialize a value for dialects that store lists/JSON as JSON text\n * (MySQL, SQLite). BigInt has no JSON representation, so it serializes as a\n * string; the result parser converts it back via the scalar's bigint type.\n */\nexport const stringifyJson = (value: unknown): string =>\n JSON.stringify(value, (_key, v) =>\n typeof v === \"bigint\" ? v.toString() : v\n );\n\nconst JSON_PATH_ARRAY_INDEX = /^\\d+$/;\n\n/**\n * Build a MySQL/SQLite JSONPath string from path segments: '$' plus `[N]`\n * for integer segments (array indices) and `.\"seg\"` for object keys.\n * Keys are JSON-string-escaped so quotes/dots/backslashes in a segment\n * cannot alter the path structure; the result is bound as a parameter.\n */\nexport const buildJsonPath = (path: string[]): string => {\n let jsonPath = \"$\";\n for (const segment of path) {\n jsonPath += JSON_PATH_ARRAY_INDEX.test(segment)\n ? `[${segment}]`\n : `.${JSON.stringify(segment)}`;\n }\n return jsonPath;\n};\n\nexport const createStandardLiterals = (): StandardLiterals => ({\n value: (v: unknown): Sql => sql`${v}`,\n null: (): Sql => sql.raw(\"NULL\"),\n list: (values: Sql[]): Sql => {\n if (values.length === 0) return sql.raw(\"()\");\n return sql`(${sql.join(values, \", \")})`;\n },\n});\n\nexport const createComparisonOperators = (): ComparisonOperators => ({\n eq: (left: Sql, right: Sql): Sql => sql`${left} = ${right}`,\n neq: (left: Sql, right: Sql): Sql => sql`${left} <> ${right}`,\n lt: (left: Sql, right: Sql): Sql => sql`${left} < ${right}`,\n lte: (left: Sql, right: Sql): Sql => sql`${left} <= ${right}`,\n gt: (left: Sql, right: Sql): Sql => sql`${left} > ${right}`,\n gte: (left: Sql, right: Sql): Sql => sql`${left} >= ${right}`,\n});\n\nexport const createNullOperators = (): NullOperators => ({\n isNull: (expr: Sql): Sql => sql`${expr} IS NULL`,\n isNotNull: (expr: Sql): Sql => sql`${expr} IS NOT NULL`,\n});\n\nexport const createRangeOperators = (): RangeOperators => ({\n between: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} BETWEEN ${min} AND ${max}`,\n notBetween: (column: Sql, min: Sql, max: Sql): Sql =>\n sql`${column} NOT BETWEEN ${min} AND ${max}`,\n});\n\nexport const createExistenceOperators = (): ExistenceOperators => ({\n exists: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n notExists: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\ntype StandardAggregates = Omit<\n DatabaseAdapter[\"aggregates\"],\n \"decimalAvg\" | \"decimalSumOperandPrecision\"\n>;\n\n/**\n * The aggregate functions every dialect spells identically. `decimalAvg` is\n * deliberately absent: an exact decimal average is derived from `SUM` and\n * `COUNT` in the column's own physical domain, which is the one thing the three\n * dialects do not agree on, so each adapter states it.\n * `decimalSumOperandPrecision` is absent because each dialect also owns exact\n * admission of an operand compared with a widened sum.\n *\n * `infinity` is the dialect's infinite double literal; MySQL has none.\n */\nexport const createAggregateFunctions = (\n infinity?: string\n): StandardAggregates => ({\n count: (expr?: Sql): Sql =>\n expr ? sql`COUNT(${expr})` : sql.raw(\"COUNT(*)\"),\n countDistinct: (expr: Sql): Sql => sql`COUNT(DISTINCT ${expr})`,\n sum: (expr: Sql): Sql => sql`SUM(${expr})`,\n numberSum: (expr: Sql) => {\n const high = sql`SUM(CASE WHEN ABS(${expr}) >= 1e-288 THEN ${expr} / 4294967296.0 / 4294967296.0 END)`;\n const low = sql`SUM(CASE WHEN ABS(${expr}) < 1e-288 THEN ${expr} END)`;\n // The reader's join in SQL: scaling `high` back by 2^64 is exact below\n // 2^960 and leaves the double range from there, where this multiplies\n // nothing — PostgreSQL and MySQL raise on an overflowing product. Without\n // an infinite double (MySQL) the overflow clamps to the largest finite\n // one, which a `having` operand of exactly that value cannot tell apart,\n // and `high` then sorts an infinite sum past a clamped one.\n const bound = sql.raw(infinity ?? \"1.7976931348623157e308\");\n const value = sql`CASE WHEN ${high} IS NULL THEN ${low} WHEN ABS(${high}) < 9.7453140114e288 THEN ${high} * 4294967296.0 * 4294967296.0 + COALESCE(${low}, 0) WHEN ${high} > 0 THEN ${bound} ELSE -${bound} END`;\n return {\n parts: [high, low] as const,\n value,\n order: infinity ? [value] : [value, high],\n };\n },\n avg: (expr: Sql): Sql => sql`AVG(${expr})`,\n min: (expr: Sql): Sql => sql`MIN(${expr})`,\n max: (expr: Sql): Sql => sql`MAX(${expr})`,\n});\n\n/** The widened precision carried by one trusted coefficient spelling. */\nexport function decimalCoefficientPrecision(coefficient: string): number {\n return coefficient.startsWith(\"-\")\n ? coefficient.length - 1\n : coefficient.length;\n}\n\n/** Exact-decimal aggregate operand admission for precision-bounded dialects. */\nexport function createDecimalSumOperandPrecision(\n maxPrecision: number\n): (coefficient: string) => number | undefined {\n return (coefficient) => {\n const precision = decimalCoefficientPrecision(coefficient);\n return precision <= maxPrecision ? precision : undefined;\n };\n}\n\nexport const createDirectionOrderBy = (): DirectionOrderBy => ({\n asc: (column: Sql): Sql => sql`${column} ASC`,\n desc: (column: Sql): Sql => sql`${column} DESC`,\n});\n\nconst directionKeyword = (direction: \"asc\" | \"desc\"): Sql =>\n direction === \"desc\" ? sql.raw(\"DESC\") : sql.raw(\"ASC\");\n\n/**\n * NULLS FIRST/LAST emulation for dialects without native support\n * (MySQL, SQLite): prepend an IS NULL sort key. IS NULL yields 1 for\n * NULL rows, so DESC puts them first and ASC puts them last.\n */\nexport const createEmulatedNullsOrderBy = (): Pick<\n DatabaseAdapter[\"orderBy\"],\n \"nullsFirst\" | \"nullsLast\"\n> => ({\n nullsFirst: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) DESC, ${column} ${directionKeyword(direction)}`,\n nullsLast: (column: Sql, direction: \"asc\" | \"desc\"): Sql =>\n sql`(${column} IS NULL) ASC, ${column} ${directionKeyword(direction)}`,\n});\n\nexport const createStandardClauses = (): DatabaseAdapter[\"clauses\"] => ({\n select: (columns: Sql): Sql => sql`SELECT ${columns}`,\n selectDistinct: (columns: Sql): Sql => sql`SELECT DISTINCT ${columns}`,\n from: (table: Sql): Sql => sql`FROM ${table}`,\n where: (condition: Sql): Sql => sql`WHERE ${condition}`,\n orderBy: (orders: Sql): Sql => sql`ORDER BY ${orders}`,\n limit: (count: Sql): Sql => sql`LIMIT ${count}`,\n offset: (count: Sql): Sql => sql`OFFSET ${count}`,\n groupBy: (columns: Sql): Sql => sql`GROUP BY ${columns}`,\n having: (condition: Sql): Sql => sql`HAVING ${condition}`,\n});\n\n/**\n * The native arithmetic every dialect shares.\n *\n * `increment`/`decrement` are complete here for EVERY scalar including decimal:\n * addition of two values already in the column's domain — logical decimals on\n * PostgreSQL/MySQL, unscaled coefficients at the same scale on SQLite — creates\n * no digit beyond that domain and therefore never rounds.\n *\n * `multiply` and `divide` do create such digits, so each adapter overrides them\n * to route a decimal target through the shared half-even rule.\n */\nexport const createNumericSetOperations = (): NumericSetOperations => ({\n assign: (column: Sql, value: Sql): Sql => sql`${column} = ${value}`,\n increment: (column: Sql, by: Sql): Sql => sql`${column} = ${column} + ${by}`,\n decrement: (column: Sql, by: Sql): Sql => sql`${column} = ${column} - ${by}`,\n});\n\nexport const createRelationFilters = (): DatabaseAdapter[\"filters\"] => ({\n some: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n every: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n none: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n is: (subquery: Sql): Sql => sql`EXISTS (${subquery})`,\n isNot: (subquery: Sql): Sql => sql`NOT EXISTS (${subquery})`,\n});\n\nexport const createMutationCommands = (): MutationCommands => ({\n update: (table: Sql, sets: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`UPDATE ${table} SET ${sets} WHERE ${where}`;\n }\n return sql`UPDATE ${table} SET ${sets}`;\n },\n delete: (table: Sql, where?: Sql): Sql => {\n if (where) {\n return sql`DELETE FROM ${table} WHERE ${where}`;\n }\n return sql`DELETE FROM ${table}`;\n },\n});\n\ntype TypedRows = DatabaseAdapter[\"setOperations\"][\"typedRows\"];\n\n/** One row's values, in order: `(a, b)`. */\nexport const rowValues = (row: readonly Sql[]): Sql =>\n sql`(${sql.join(row, \", \")})`;\n\n/**\n * `typedRows`' default form: the empty typed read, then one `UNION ALL\n * SELECT` per row, each typed against the arms before it.\n */\nconst unionTypedRows =\n (quoteIdent: IdentifierQuoter): TypedRows =>\n (typed, rows, alias) =>\n sql`(${sql.join(\n [typed.head, ...rows.map((row) => sql`SELECT ${sql.join(row, \", \")}`)],\n \" UNION ALL \"\n )}) AS ${sql.raw(quoteIdent(alias))}`;\n\nexport const createSetOperations = (\n quoteIdent: IdentifierQuoter,\n typedRows: TypedRows = unionTypedRows(quoteIdent)\n): DatabaseAdapter[\"setOperations\"] => ({\n union: (...queries: Sql[]): Sql => sql.join(queries, \" UNION \"),\n unionAll: (...queries: Sql[]): Sql => sql.join(queries, \" UNION ALL \"),\n intersect: (...queries: Sql[]): Sql => sql.join(queries, \" INTERSECT \"),\n except: (left: Sql, right: Sql): Sql => sql`${left} EXCEPT ${right}`,\n typedRows,\n});\n\n// ============================================================\n// Dialect-parameterized factories: identical grammar across\n// adapters, differing only in the identifier quote character.\n// ============================================================\n\n/**\n * `namespace` is the adapter's prevalidated database namespace, or `undefined`\n * for the unqualified dialects. It is quoted once here, at adapter\n * construction — `table()` runs once per persistent table per compiled\n * statement and must not re-quote it.\n */\nexport const createIdentifiers = (\n quoteIdent: IdentifierQuoter,\n namespace?: string\n): DatabaseAdapter[\"identifiers\"] => {\n const qualify = createQualifiedIdentifierRenderer(quoteIdent, namespace);\n return {\n escape: (name: string): Sql => sql.raw(quoteIdent(name)),\n\n column: (alias: string, field: string): Sql => {\n const identifier = alias\n ? `${quoteIdent(alias)}.${quoteIdent(field)}`\n : quoteIdent(field);\n return sql.raw(identifier);\n },\n\n table: (tableName: string, alias?: string): Sql => {\n const qualified = qualify(tableName);\n return sql.raw(\n alias === undefined ? qualified : `${qualified} AS ${quoteIdent(alias)}`\n );\n },\n\n aliased: (expression: Sql, alias: string): Sql =>\n new Sql([\"\", ` AS ${quoteIdent(alias)}`], [expression]),\n };\n};\n\nexport const createSubqueries = (\n quoteIdent: IdentifierQuoter\n): DatabaseAdapter[\"subqueries\"] => ({\n scalar: (query: Sql): Sql => sql`(${query})`,\n\n correlate: (query: Sql, alias: string): Sql =>\n sql`(${query}) AS ${sql.raw(quoteIdent(alias))}`,\n\n existsCheck: (from: Sql, where: Sql): Sql =>\n sql`SELECT 1 FROM ${from} WHERE ${where}`,\n\n isolated: (condition: Sql): Sql => condition,\n});\n\nexport const createCteBuilders = (\n quoteIdent: IdentifierQuoter\n): DatabaseAdapter[\"cte\"] => ({\n with: (definitions: { name: string; query: Sql }[]): Sql => {\n const defs = definitions.map(\n ({ name, query }) => sql`${sql.raw(quoteIdent(name))} AS (${query})`\n );\n return sql`WITH ${sql.join(defs, \", \")}`;\n },\n\n recursive: (\n name: string,\n anchor: Sql,\n recursive: Sql,\n union: \"all\" | \"distinct\" = \"all\"\n ): Sql => {\n const unionKeyword =\n union === \"all\" ? sql.raw(\"UNION ALL\") : sql.raw(\"UNION\");\n return sql`WITH RECURSIVE ${sql.raw(quoteIdent(name))} AS (\n ${anchor}\n ${unionKeyword}\n ${recursive}\n )`;\n },\n});\n\nexport const createInsertStatement =\n (quoteIdent: IdentifierQuoter): DatabaseAdapter[\"mutations\"][\"insert\"] =>\n (\n table: Sql,\n columns: string[],\n source: Sql[][] | { readonly select: Sql },\n prefix?: Sql\n ): Sql => {\n const cols = columns.map((c) => sql.raw(quoteIdent(c)));\n const body = Array.isArray(source)\n ? sql`VALUES ${sql.join(\n source.map((row) => sql`(${sql.join(row, \", \")})`),\n \", \"\n )}`\n : source.select;\n const prefixPart = prefix ? sql`${prefix} ` : sql``;\n return sql`INSERT ${prefixPart}INTO ${table} (${sql.join(\n cols,\n \", \"\n )}) ${body}`;\n };\n\n/**\n * Standard ON CONFLICT grammar shared by PostgreSQL and SQLite.\n * MySQL's ON DUPLICATE KEY UPDATE is a different grammar with different\n * semantics — it stays in the MySQL adapter.\n */\nexport const createOnConflictBuilders = (): Pick<\n DatabaseAdapter[\"mutations\"],\n \"onConflict\" | \"onConflictUpdate\" | \"skipDuplicates\"\n> => ({\n onConflict: (target: Sql | null, action: Sql, targetWhere?: Sql): Sql => {\n if (target) {\n if (targetWhere) {\n // ON CONFLICT (id) WHERE <targetWhere> DO UPDATE ...\n return sql`ON CONFLICT (${target}) WHERE ${targetWhere} DO ${action}`;\n }\n return sql`ON CONFLICT (${target}) DO ${action}`;\n }\n return sql`ON CONFLICT DO ${action}`;\n },\n\n onConflictUpdate: (sets: Sql, setWhere?: Sql): Sql => {\n if (setWhere) {\n // UPDATE SET x = y WHERE <setWhere>\n return sql`UPDATE SET ${sets} WHERE ${setWhere}`;\n }\n return sql`UPDATE SET ${sets}`;\n },\n\n // The UNTARGETED skip, and the only caller left is top-level `createMany`,\n // whose `skipDuplicates: true` means \"any unique constraint\". Junction\n // membership inserts want the opposite — only an exact repeat of the complete\n // membership key — and reach `onConflict` above with that key as the target.\n skipDuplicates: () => ({\n prefix: sql``,\n suffix: sql`ON CONFLICT DO NOTHING`,\n }),\n});\n\nexport const createMembershipOperators = (): Pick<\n DatabaseAdapter[\"operators\"],\n \"in\" | \"notIn\"\n> => ({\n in: (column: Sql, values: Sql): Sql => sql`${column} IN ${values}`,\n notIn: (column: Sql, values: Sql): Sql => sql`${column} NOT IN ${values}`,\n});\n\n/**\n * AND/OR/NOT with vacuous-case literals: the dialect's TRUE for an empty\n * AND and FALSE for an empty OR (pass the adapter's literals.true/false).\n */\nexport const createLogicalOperators = (\n vacuousTrue: () => Sql,\n vacuousFalse: () => Sql\n): Pick<DatabaseAdapter[\"operators\"], \"and\" | \"or\" | \"not\"> => ({\n and: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousTrue();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" AND \")})`;\n },\n\n or: (...conditions: Sql[]): Sql => {\n if (conditions.length === 0) return vacuousFalse();\n if (conditions.length === 1) return conditions[0]!;\n return sql`(${sql.join(conditions, \" OR \")})`;\n },\n\n not: (condition: Sql): Sql => sql`NOT (${condition})`,\n});\n\nexport const createCommonExpressions = (): Pick<\n DatabaseAdapter[\"expressions\"],\n | \"caseWhen\"\n | \"add\"\n | \"subtract\"\n | \"multiply\"\n | \"divide\"\n | \"upper\"\n | \"lower\"\n | \"coalesce\"\n> => ({\n caseWhen: (branches, otherwise): Sql =>\n branches.length === 0\n ? otherwise\n : sql`CASE ${sql.join(\n branches.map(\n (branch) => sql`WHEN ${branch.when} THEN ${branch.then}`\n ),\n \" \"\n )} ELSE ${otherwise} END`,\n add: (left: Sql, right: Sql): Sql => sql`(${left} + ${right})`,\n subtract: (left: Sql, right: Sql): Sql => sql`(${left} - ${right})`,\n multiply: (left: Sql, right: Sql): Sql => sql`(${left} * ${right})`,\n divide: (left: Sql, right: Sql): Sql => sql`(${left} / ${right})`,\n upper: (expr: Sql): Sql => sql`UPPER(${expr})`,\n lower: (expr: Sql): Sql => sql`LOWER(${expr})`,\n coalesce: (...exprs: Sql[]): Sql => sql`COALESCE(${sql.join(exprs, \", \")})`,\n});\n\nexport const createCastExpression =\n (typeMap: Record<CastType, string>): DatabaseAdapter[\"expressions\"][\"cast\"] =>\n (expr: Sql, type: CastType): Sql =>\n sql`CAST(${expr} AS ${sql.raw(typeMap[type])})`;\n\nexport const createCoreJoins = (): Pick<\n DatabaseAdapter[\"joins\"],\n \"inner\" | \"left\" | \"right\" | \"cross\"\n> => ({\n inner: (table: Sql, condition: Sql): Sql =>\n sql`INNER JOIN ${table} ON ${condition}`,\n\n left: (table: Sql, condition: Sql): Sql =>\n sql`LEFT JOIN ${table} ON ${condition}`,\n\n right: (table: Sql, condition: Sql): Sql =>\n sql`RIGHT JOIN ${table} ON ${condition}`,\n\n cross: (table: Sql): Sql => sql`CROSS JOIN ${table}`,\n});\n\nexport const createLateralJoins = (\n quoteIdent: IdentifierQuoter\n): Pick<DatabaseAdapter[\"joins\"], \"lateral\" | \"lateralLeft\"> => ({\n lateral: (subquery: Sql, alias: string): Sql =>\n sql`JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n\n lateralLeft: (subquery: Sql, alias: string): Sql =>\n sql`LEFT JOIN LATERAL (${subquery}) AS ${sql.raw(quoteIdent(alias))} ON TRUE`,\n});\n\n/**\n * Escape a user value so a SQL `LIKE` pattern matches it literally.\n *\n * `%`, `_` and the escape character itself become escaped; every other\n * character is left alone. The caller appends its own wildcard and must emit\n * a matching `ESCAPE` clause — backslash is only the escape character because\n * every `ESCAPE` clause in this codebase spells backslash.\n */\nexport const escapeLikeLiteral = (value: string): string =>\n value.replace(/[\\\\%_]/g, (char) => `\\\\${char}`);\n\n/**\n * Escape a user value so a SQLite `GLOB` pattern matches it literally.\n *\n * GLOB has no `ESCAPE` clause, so a metacharacter is quoted by wrapping it in\n * a one-character class: `*` becomes `[*]`. Only `*`, `?` and `[` need it —\n * a `]` outside a class is already literal in SQLite's GLOB, and backslash is\n * not a GLOB metacharacter at all.\n */\nexport const escapeGlobLiteral = (value: string): string =>\n value.replace(/[*?[]/g, (char) => `[${char}]`);\n"],"mappings":"uFAcA,MAAa,uBACV,GACA,GAKQ,GAHL,EAAK,QAAQ,EAAU,GAAK,GACxB,EACA,EAAK,WAAW,EAAW,EAAY,EAAU,EAC1B,EAQ3B,iBACJ,EACA,IACW,GAAG,EAAgB,EAAU,CAAC,GAO9B,2BACX,EACA,EACA,IAEA,IAAc,IAAA,GACV,EAAgB,EAAO,CACvB,gBAAgB,EAAiB,EAAU,CAAG,EAAgB,EAAO,CAO9D,mCACX,EACA,IACqB,CACrB,GAAI,IAAc,IAAA,GAChB,OAAO,EAET,IAAM,EAAS,gBAAgB,EAAiB,EAAU,CAC1D,MAAQ,IAA2B,EAAS,EAAgB,EAAO,ECvBxD,iBACH,GAA2BA,EAAI,IAAI,EAAU,CAQ1C,cAAiB,GAC5B,KAAK,UAAU,GAAQ,EAAM,IAC3B,OAAO,GAAM,SAAW,EAAE,UAAU,CAAG,EACxC,CAEG,EAAwB,QAQjB,cAAiB,GAA2B,CACvD,IAAI,EAAW,IACf,IAAK,IAAM,KAAW,EACpB,GAAY,EAAsB,KAAK,EAAQ,CAC3C,IAAI,EAAQ,GACZ,IAAI,KAAK,UAAU,EAAQ,GAEjC,OAAO,GAGI,4BAAkD,CAC7D,MAAQ,G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AI,EAAK,KAAK,EAAM,GAC/D,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,MAAQ,GAAmB,CAAG,SAAS,EAAK,GAC5C,UAAW,GAAG,IAAsB,CAAG,YAAYA,EAAI,KAAK,EAAO,KAAK,CAAC,GAC1E,EAEY,qBACV,IACA,EAAW,IACV,CAAG,QAAQ,EAAK,MAAMA,EAAI,IAAI,EAAQ,GAAM,CAAC,GAEpC,qBAGP,CACJ,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAO,EAAY,IACjB,CAAG,aAAa,EAAM,MAAM,IAE9B,OAAQ,EAAY,IAClB,CAAG,cAAc,EAAM,MAAM,IAE/B,MAAQ,GAAoB,CAAG,cAAc,IAC9C,EAEY,mBACX,IAC+D,CAC/D,SAAU,EAAe,IACvB,CAAG,iBAAiB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UAEjE,aAAc,EAAe,IAC3B,CAAG,sBAAsB,EAAS,OAAOA,EAAI,IAAI,EAAW,EAAM,CAAC,CAAC,UACvE,EAUY,kBAAqB,GAChC,EAAM,QAAQ,UAAY,GAAS,KAAK,IAAO,CAUpC,kBAAqB,GAChC,EAAM,QAAQ,SAAW,GAAS,IAAI,EAAK,GAAG"}
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";const t=`suppressedFailures`,n=new WeakMap;function isReference(e){return typeof e==`object`&&!!e||typeof e==`function`}function readSuppressedFailures(e){return isReference(e)?n.get(e)??[]:[]}function withSuppressedFailure(e,t){if(!isReference(e))return withSuppressedFailure(AggregateError([e,t],describe(e),{cause:e}),t);let r=Object.freeze([...n.get(e)??[],t]);return n.set(e,r),mirrorOnto(e,r),e}function mirrorOnto(e,n){try{if(Object.getOwnPropertyDescriptor(e,t)!==void 0)return;Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n,writable:!0})}catch{}}function describe(e){try{return typeof e==`string`?e:String(e)}catch{return`The operation failed, with an additional suppressed failure.`}}export{withSuppressedFailure as n,readSuppressedFailures as t};
2
- //# sourceMappingURL=suppressed-failure-BwULh-8h.mjs.map
2
+ //# sourceMappingURL=suppressed-failure-Bdo2aK81.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"suppressed-failure-BwULh-8h.mjs","names":[],"sources":["../src/drivers/shared/suppressed-failure.ts"],"sourcesContent":["/**\n * The ONE rule for retaining secondary failures beside a primary failure.\n *\n * A secondary failure can arrive while a primary is already propagating: a\n * pinned session cleanup can fail after its body, or a pool can retain an idle\n * socket failure before a requested acquisition fails. The rule is total,\n * because every way of bending it loses evidence the caller can act on:\n *\n * - the primary failure stays primary, and stays UNCHANGED. Appending the\n * secondary's text to `message` writes to an object VibORM does not own —\n * which throws outright for a frozen Error or an accessor-backed `message`,\n * and then the caller is told about a `TypeError` from evidence recording\n * instead of the failure that produced it.\n * - the secondary failure stays inspectable beside it, because a caller sees ONE\n * thrown value and anything that value does not carry is gone.\n * - the record of what failed lives HERE, in this module's own map, and never\n * on the error. The error is not VibORM's object: a frozen one refuses the\n * write outright, a Proxy can accept it and store nothing, and a visible\n * property is a copy anything can rewrite afterwards.\n * - recording it cannot itself throw. Neither value is coerced, rendered, or\n * assigned. The optional debugger mirror is attempted only when its name is\n * unused, and every reflection or write refusal is contained.\n *\n * Not the transaction layer's `AggregateError` shape (`transactions.ts`): that\n * one REPLACES the primary, which is right where the caller is handed a\n * lifecycle report and wrong where the caller is handed the estate's own\n * failure. Here the primary is what the command already promised to report.\n */\n\n/**\n * Where a failure MIRRORS its suppressed evidence.\n *\n * A named own property rather than a symbol: it is meant to be found by a human\n * reading a caught error in a debugger. It is non-enumerable so that it stays\n * out of every structured log line and JSON snapshot of the error. It is added\n * only when the name is unused; an existing property belongs to the caller and\n * must stay unchanged. The canonical reader never answers from this mirror.\n */\nconst SUPPRESSED_FAILURES_MIRROR = \"suppressedFailures\";\n\n/**\n * The canonical ordered record, for every reference primary.\n *\n * Not a fallback for the errors that refused the property: THE record, written\n * first and read alone. A Proxy whose `defineProperty` trap answers `true`\n * without defining anything is the case that makes the distinction matter —\n * nothing throws, so a fallback keyed on the write's failure never fires and\n * the evidence is simply gone. Keyed weakly on the failure itself, so the\n * record lives precisely as long as the error a caller still holds.\n */\nconst RECORDED_SUPPRESSED_FAILURES = new WeakMap<object, readonly unknown[]>();\n\n/** Whether a value can carry an own property or key a WeakMap. */\nfunction isReference(value: unknown): value is object {\n return (\n (typeof value === \"object\" && value !== null) || typeof value === \"function\"\n );\n}\n\n/**\n * The secondary failures this module recorded against a thrown value, oldest\n * first.\n *\n * One source, and it is not the error: the question a caller asks is \"what\n * secondary failures did VibORM retain\", and only this module can answer it.\n * Reading the error's own `suppressedFailures` would answer \"does this object\n * have a property with that name\", which is a different question.\n */\nexport function readSuppressedFailures(thrown: unknown): readonly unknown[] {\n if (!isReference(thrown)) {\n return [];\n }\n return RECORDED_SUPPRESSED_FAILURES.get(thrown) ?? [];\n}\n\n/**\n * The value to throw for `primary`, now also carrying `secondary`.\n *\n * Returns `primary` ITSELF, at its exact identity, for every object — a frozen\n * Error, a Proxy that lies about the write, a proxy revoked afterwards, all of\n * them, because the record does not live on the value. A primary that is not an\n * object cannot key the record, and only then does the thrown value change\n * shape: an `AggregateError` whose `errors[0]` and `cause` are that primary, so\n * it is still the first thing anyone reads.\n */\nexport function withSuppressedFailure(\n primary: unknown,\n secondary: unknown\n): unknown {\n if (!isReference(primary)) {\n // The carrier then carries the evidence the same way everything else does,\n // so one reader answers for every shape this rule can produce.\n return withSuppressedFailure(\n new AggregateError([primary, secondary], describe(primary), {\n cause: primary,\n }),\n secondary\n );\n }\n\n // Extends this module's OWN previous record, never an array found on the\n // error. Iterating a caller's array is running the caller's code at the exact\n // moment a failure is propagating, and a throw there does not lose\n // the secondary evidence — it replaces the primary with a report about the\n // recording. Frozen because the reader hands this array out, and the record\n // the next secondary extends must be the one this one wrote.\n const recorded = Object.freeze([\n ...(RECORDED_SUPPRESSED_FAILURES.get(primary) ?? []),\n secondary,\n ]);\n RECORDED_SUPPRESSED_FAILURES.set(primary, recorded);\n mirrorOnto(primary, recorded);\n return primary;\n}\n\n/**\n * Publishes the record onto the failure, for whoever opens it in a debugger.\n *\n * Best effort by definition, and by design: a frozen Error refuses the write, a\n * Proxy may accept it and store nothing, and a revoked one refuses everything.\n * None of that costs a caller evidence, because the record is already complete\n * before this runs and the canonical reader never uses the property.\n */\nfunction mirrorOnto(primary: object, recorded: readonly unknown[]): void {\n try {\n if (\n Object.getOwnPropertyDescriptor(primary, SUPPRESSED_FAILURES_MIRROR) !==\n undefined\n ) {\n return;\n }\n Object.defineProperty(primary, SUPPRESSED_FAILURES_MIRROR, {\n configurable: true,\n enumerable: false,\n value: recorded,\n writable: true,\n });\n } catch {\n // An error VibORM does not own is entitled to refuse the write, and the\n // refusal is not this module's to report.\n }\n}\n\n/**\n * A message for the carrier, from a primary that is not an object.\n *\n * `String()` throws on a Symbol and runs a caller's `toString` on anything\n * else, so the coercion is attempted and its refusal answered — the carrier's\n * whole job is to keep both values, not to describe them.\n */\nfunction describe(primary: unknown): string {\n try {\n return typeof primary === \"string\" ? primary : String(primary);\n } catch {\n return \"The operation failed, with an additional suppressed failure.\";\n }\n}\n"],"mappings":"yCAsCA,MAAM,EAA6B,qBAY7B,EAA+B,IAAI,QAGzC,SAAS,YAAY,EAAiC,CACpD,OACG,OAAO,GAAU,YAAY,GAAmB,OAAO,GAAU,WAatE,SAAgB,uBAAuB,EAAqC,CAI1E,OAHK,YAAY,EAAO,CAGjB,EAA6B,IAAI,EAAO,EAAI,EAAE,CAF5C,EAAE,CAeb,SAAgB,sBACd,EACA,EACS,CACT,GAAI,CAAC,YAAY,EAAQ,CAGvB,OAAO,sBACD,eAAe,CAAC,EAAS,EAAU,CAAE,SAAS,EAAQ,CAAE,CAC1D,MAAO,EACR,CAAC,CACF,EACD,CASH,IAAM,EAAW,OAAO,OAAO,CAC7B,GAAI,EAA6B,IAAI,EAAQ,EAAI,EAAE,CACnD,EACD,CAAC,CAGF,OAFA,EAA6B,IAAI,EAAS,EAAS,CACnD,WAAW,EAAS,EAAS,CACtB,EAWT,SAAS,WAAW,EAAiB,EAAoC,CACvE,GAAI,CACF,GACE,OAAO,yBAAyB,EAAS,EAA2B,GACpE,IAAA,GAEA,OAEF,OAAO,eAAe,EAAS,EAA4B,CACzD,aAAc,GACd,WAAY,GACZ,MAAO,EACP,SAAU,GACX,CAAC,MACI,GAaV,SAAS,SAAS,EAA0B,CAC1C,GAAI,CACF,OAAO,OAAO,GAAY,SAAW,EAAU,OAAO,EAAQ,MACxD,CACN,MAAO"}
1
+ {"version":3,"file":"suppressed-failure-Bdo2aK81.mjs","names":[],"sources":["../src/drivers/shared/suppressed-failure.ts"],"sourcesContent":["/**\n * The ONE rule for retaining secondary failures beside a primary failure.\n *\n * A secondary failure can arrive while a primary is already propagating: a\n * pinned session cleanup can fail after its body, or a pool can retain an idle\n * socket failure before a requested acquisition fails. The rule is total,\n * because every way of bending it loses evidence the caller can act on:\n *\n * - the primary failure stays primary, and stays UNCHANGED. Appending the\n * secondary's text to `message` writes to an object VibORM does not own —\n * which throws outright for a frozen Error or an accessor-backed `message`,\n * and then the caller is told about a `TypeError` from evidence recording\n * instead of the failure that produced it.\n * - the secondary failure stays inspectable beside it, because a caller sees ONE\n * thrown value and anything that value does not carry is gone.\n * - the record of what failed lives HERE, in this module's own map, and never\n * on the error. The error is not VibORM's object: a frozen one refuses the\n * write outright, a Proxy can accept it and store nothing, and a visible\n * property is a copy anything can rewrite afterwards.\n * - recording it cannot itself throw. Neither value is coerced, rendered, or\n * assigned. The optional debugger mirror is attempted only when its name is\n * unused, and every reflection or write refusal is contained.\n *\n * Not the transaction layer's `AggregateError` shape (`transactions.ts`): that\n * one REPLACES the primary, which is right where the caller is handed a\n * lifecycle report and wrong where the caller is handed the estate's own\n * failure. Here the primary is what the command already promised to report.\n */\n\n/**\n * Where a failure MIRRORS its suppressed evidence.\n *\n * A named own property rather than a symbol: it is meant to be found by a human\n * reading a caught error in a debugger. It is non-enumerable so that it stays\n * out of every structured log line and JSON snapshot of the error. It is added\n * only when the name is unused; an existing property belongs to the caller and\n * must stay unchanged. The canonical reader never answers from this mirror.\n */\nconst SUPPRESSED_FAILURES_MIRROR = \"suppressedFailures\";\n\n/**\n * The canonical ordered record, for every reference primary.\n *\n * Not a fallback for the errors that refused the property: THE record, written\n * first and read alone. A Proxy whose `defineProperty` trap answers `true`\n * without defining anything is the case that makes the distinction matter —\n * nothing throws, so a fallback keyed on the write's failure never fires and\n * the evidence is simply gone. Keyed weakly on the failure itself, so the\n * record lives precisely as long as the error a caller still holds.\n */\nconst RECORDED_SUPPRESSED_FAILURES = new WeakMap<object, readonly unknown[]>();\n\n/** Whether a value can carry an own property or key a WeakMap. */\nfunction isReference(value: unknown): value is object {\n return (\n (typeof value === \"object\" && value !== null) || typeof value === \"function\"\n );\n}\n\n/**\n * The secondary failures this module recorded against a thrown value, oldest\n * first.\n *\n * One source, and it is not the error: the question a caller asks is \"what\n * secondary failures did VibORM retain\", and only this module can answer it.\n * Reading the error's own `suppressedFailures` would answer \"does this object\n * have a property with that name\", which is a different question.\n */\nexport function readSuppressedFailures(thrown: unknown): readonly unknown[] {\n if (!isReference(thrown)) {\n return [];\n }\n return RECORDED_SUPPRESSED_FAILURES.get(thrown) ?? [];\n}\n\n/**\n * The value to throw for `primary`, now also carrying `secondary`.\n *\n * Returns `primary` ITSELF, at its exact identity, for every object — a frozen\n * Error, a Proxy that lies about the write, a proxy revoked afterwards, all of\n * them, because the record does not live on the value. A primary that is not an\n * object cannot key the record, and only then does the thrown value change\n * shape: an `AggregateError` whose `errors[0]` and `cause` are that primary, so\n * it is still the first thing anyone reads.\n */\nexport function withSuppressedFailure(\n primary: unknown,\n secondary: unknown\n): unknown {\n if (!isReference(primary)) {\n // The carrier then carries the evidence the same way everything else does,\n // so one reader answers for every shape this rule can produce.\n return withSuppressedFailure(\n new AggregateError([primary, secondary], describe(primary), {\n cause: primary,\n }),\n secondary\n );\n }\n\n // Extends this module's OWN previous record, never an array found on the\n // error. Iterating a caller's array is running the caller's code at the exact\n // moment a failure is propagating, and a throw there does not lose\n // the secondary evidence — it replaces the primary with a report about the\n // recording. Frozen because the reader hands this array out, and the record\n // the next secondary extends must be the one this one wrote.\n const recorded = Object.freeze([\n ...(RECORDED_SUPPRESSED_FAILURES.get(primary) ?? []),\n secondary,\n ]);\n RECORDED_SUPPRESSED_FAILURES.set(primary, recorded);\n mirrorOnto(primary, recorded);\n return primary;\n}\n\n/**\n * Publishes the record onto the failure, for whoever opens it in a debugger.\n *\n * Best effort by definition, and by design: a frozen Error refuses the write, a\n * Proxy may accept it and store nothing, and a revoked one refuses everything.\n * None of that costs a caller evidence, because the record is already complete\n * before this runs and the canonical reader never uses the property.\n */\nfunction mirrorOnto(primary: object, recorded: readonly unknown[]): void {\n try {\n if (\n Object.getOwnPropertyDescriptor(primary, SUPPRESSED_FAILURES_MIRROR) !==\n undefined\n ) {\n return;\n }\n Object.defineProperty(primary, SUPPRESSED_FAILURES_MIRROR, {\n configurable: true,\n enumerable: false,\n value: recorded,\n writable: true,\n });\n } catch {\n // An error VibORM does not own is entitled to refuse the write, and the\n // refusal is not this module's to report.\n }\n}\n\n/**\n * A message for the carrier, from a primary that is not an object.\n *\n * `String()` throws on a Symbol and runs a caller's `toString` on anything\n * else, so the coercion is attempted and its refusal answered — the carrier's\n * whole job is to keep both values, not to describe them.\n */\nfunction describe(primary: unknown): string {\n try {\n return typeof primary === \"string\" ? primary : String(primary);\n } catch {\n return \"The operation failed, with an additional suppressed failure.\";\n }\n}\n"],"mappings":"yCAsCA,MAAM,EAA6B,qBAY7B,EAA+B,IAAI,QAGzC,SAAS,YAAY,EAAiC,CACpD,OACG,OAAO,GAAU,YAAY,GAAmB,OAAO,GAAU,WAatE,SAAgB,uBAAuB,EAAqC,CAI1E,OAHK,YAAY,EAAO,CAGjB,EAA6B,IAAI,EAAO,EAAI,EAAE,CAF5C,EAAE,CAeb,SAAgB,sBACd,EACA,EACS,CACT,GAAI,CAAC,YAAY,EAAQ,CAGvB,OAAO,sBACD,eAAe,CAAC,EAAS,EAAU,CAAE,SAAS,EAAQ,CAAE,CAC1D,MAAO,EACR,CAAC,CACF,EACD,CASH,IAAM,EAAW,OAAO,OAAO,CAC7B,GAAI,EAA6B,IAAI,EAAQ,EAAI,EAAE,CACnD,EACD,CAAC,CAGF,OAFA,EAA6B,IAAI,EAAS,EAAS,CACnD,WAAW,EAAS,EAAS,CACtB,EAWT,SAAS,WAAW,EAAiB,EAAoC,CACvE,GAAI,CACF,GACE,OAAO,yBAAyB,EAAS,EAA2B,GACpE,IAAA,GAEA,OAEF,OAAO,eAAe,EAAS,EAA4B,CACzD,aAAc,GACd,WAAY,GACZ,MAAO,EACP,SAAU,GACX,CAAC,MACI,GAaV,SAAS,SAAS,EAA0B,CAC1C,GAAI,CACF,OAAO,OAAO,GAAY,SAAW,EAAU,OAAO,EAAQ,MACxD,CACN,MAAO"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./value-guards-CK9guf2Z.mjs";import{t as n}from"./validation-BamBwne9.mjs";import{A as r,D as i,S as a,b as o,m as s,n as c,w as l,y as u}from"./v-CYTUI0H5.mjs";import{rt as d}from"./geo-point-codec-DyEHMdJg.mjs";import{_ as f,a as p,c as m,l as h,n as g,o as _,u as v,v as y}from"./scalar-S8yMvdmx.mjs";import{t as b}from"./current-oXcxSCBQ.mjs";const x=c.bigint();var S=class BigIntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BigIntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.bigint({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new BigIntScalar(v(this,{array:!0,base:c.bigint({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new BigIntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new BigIntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new BigIntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new BigIntScalar(v(this,{schema:e,base:c.bigint({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new BigIntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new BigIntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const bigInt=e=>new S(p(`bigint`,x),g(`s.bigInt`,e)),C=c.blob();var w=class BlobScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BlobScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.blob({nullable:!0})}),this._nativeType)}default(e){return new BlobScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BlobScalar(v(this,{columnName:e}),this._nativeType)}array(){throw Error(`Blob scalars don't support array modifier`)}id(){throw Error(`Blob scalars cannot be used as IDs`)}unique(){throw Error(`Blob scalars cannot be unique`)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const blob=e=>new w(p(`blob`,C),g(`s.blob`,e)),T=c.boolean();var E=class BooleanScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new BooleanScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.boolean({nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new BooleanScalar(v(this,{array:!0,base:c.boolean({nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new BooleanScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new BooleanScalar(v(this,{columnName:e}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const boolean=e=>new E(p(`boolean`,T),g(`s.boolean`,e)),D=_(()=>b(`date`)),O=_(()=>b(`date`)),k=c.isoDate();var A=class DateScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoDate({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.date`),new DateScalar(v(this,{array:!0,base:c.isoDate({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateScalar(v(this,{schema:e,base:c.isoDate({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:D,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.date`),new DateScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:O,optional:!0}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const date=e=>new A(p(`date`,k),g(`s.date`,e)),j=_(()=>b(`datetime`)),M=_(()=>b(`datetime`)),N=c.isoTimestamp();var P=class DateTimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new DateTimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTimestamp({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.dateTime`),new DateTimeScalar(v(this,{array:!0,base:c.isoTimestamp({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new DateTimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new DateTimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new DateTimeScalar(v(this,{schema:e,base:c.isoTimestamp({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new DateTimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new DateTimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:j,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.dateTime`),new DateTimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:M,optional:!0}),this._nativeType)}withoutTimezone(){return new DateTimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const dateTime=e=>new P({...p(`datetime`,N),withTimezone:!0},g(`s.dateTime`,e)),F=_(()=>b(`time`)),I=_(()=>b(`time`)),L=c.isoTime();var R=class TimeScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new TimeScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.isoTime({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return(this.state.autoGenerate?.kind===`now`||this.state.autoGenerate?.kind===`updatedAt`)&&h(`s.time`),new TimeScalar(v(this,{array:!0,base:c.isoTime({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new TimeScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new TimeScalar(v(this,{isUnique:!0}),this._nativeType)}schema(e){return new TimeScalar(v(this,{schema:e,base:c.isoTime({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}default(e){return new TimeScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new TimeScalar(v(this,{columnName:e}),this._nativeType)}now(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`now`},default:F,optional:!0}),this._nativeType)}updatedAt(){return this.state.array&&h(`s.time`),new TimeScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`updatedAt`},default:I,optional:!0}),this._nativeType)}withoutTimezone(){return new TimeScalar(v(this,{withTimezone:!1}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const time=e=>new R({...p(`time`,L),withTimezone:!1},g(`s.time`,e));function refuse(e,t){throw new n({kind:`schema-builder`,builder:`s.decimal`,path:e},[{path:e,message:t}])}function readDecimalDescriptor(e){let n=t(e)?e.precision:void 0,r=t(e)?e.scale:void 0;return typeof n==`number`&&Number.isSafeInteger(n)&&n>=1||refuse(`descriptor.precision`,`'precision' must be an integer between 1 and the maximum safe integer`),typeof r==`number`&&Number.isSafeInteger(r)&&r>=0&&r<=n&&!Object.is(r,-0)||refuse(`descriptor.scale`,`'scale' must be an integer between 0 and precision`),Object.freeze({precision:n,scale:r})}function refuseDecimalListKey(e){let t=`a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member`;refuse(e,e===`array`?`A decimal key cannot become a list: ${t}`:`A decimal list cannot be declared '.${e}()': ${t}`)}function normalizeDecimalDefault(e,t){if(typeof e==`function`)return e;let n=d(t,e);return n.issues!==void 0&&refuse(`default`,`The decimal default did not satisfy its field schema`),n.value}var z=class DecimalScalar{state;constructor(e){this.state=e}get descriptor(){return this.state.decimal}nullable(){return new DecimalScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.decimal({nullable:!0,array:this.state.array,decimal:this.descriptor,schema:this.state.schema})}))}array(){(this.state.isId||this.state.isUnique)&&refuseDecimalListKey(`array`);let e=c.decimal({nullable:this.state.nullable,array:!0,decimal:this.descriptor,schema:this.state.schema}),t=v(this,{array:!0,base:e});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(t,`default`,{value:normalizeDecimalDefault(this.state.default,e),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(t)}id(){return this.state.array&&refuseDecimalListKey(`id`),new DecimalScalar(v(this,{isId:!0,isUnique:!0}))}unique(){return this.state.array&&refuseDecimalListKey(`unique`),new DecimalScalar(v(this,{isUnique:!0}))}default(e){return withValidatedDecimalDefault(this,normalizeDecimalDefault(e,this.state.base))}schema(e){let t=c.decimal({nullable:this.state.nullable,array:this.state.array,decimal:this.descriptor,schema:e}),n=v(this,{schema:e,base:t});return this.state.hasDefault&&typeof this.state.default!=`function`&&Object.defineProperty(n,`default`,{value:normalizeDecimalDefault(this.state.default,t),configurable:!0,enumerable:!0,writable:!0}),new DecimalScalar(n)}map(e){return new DecimalScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function withValidatedDecimalDefault(e,t){return new z(v(e,{hasDefault:!0,default:t,optional:!0}))}const buildDecimalScalar=e=>{let t=readDecimalDescriptor(e);return new z({...p(`decimal`,c.decimal({decimal:t})),decimal:t})},decimal=e=>buildDecimalScalar(e);var B=class EnumScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}get enumValues(){return`values`in this.state.base?this.state.base.values:[]}nullable(){return new EnumScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.enum(this.enumValues,{nullable:!0,array:this.state.array})}),this._nativeType)}array(){return new EnumScalar(v(this,{array:!0,base:c.enum(this.enumValues,{nullable:this.state.nullable,array:!0})}),this._nativeType)}default(e){return new EnumScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new EnumScalar(v(this,{columnName:e}),this._nativeType)}name(e){return new EnumScalar(v(this,{enumName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const enumScalar=(e,t)=>new B(p(`enum`,c.enum(e)),g(`s.enum`,t)),V=c.integer();var H=class IntScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new IntScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.integer({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new IntScalar(v(this,{array:!0,base:c.integer({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new IntScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new IntScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new IntScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new IntScalar(v(this,{schema:e,base:c.integer({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new IntScalar(v(this,{columnName:e}),this._nativeType)}increment(){return new IntScalar(v(this,{hasDefault:!0,autoGenerate:{kind:`increment`},default:void 0,disallowZero:!0,optional:!0}),this._nativeType)}_internal;get"~"(){return this._internal??={state:this.state,nativeType:this._nativeType}}};const int=e=>new H(p(`int`,V),g(`s.int`,e)),U=c.json();var W=class JsonScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new JsonScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.json({nullable:!0,schema:this.state.schema})}),this._nativeType)}default(e){let t=r(e);if(t===`AnyNull`||t===`DbNull`&&!this.state.nullable)throw new n({kind:`schema-builder`,builder:`s.json`,path:`default`},[{path:`default`,message:`JSON default must name a null this column can store`}]);let a=e===null&&!this.state.nullable?i:e;return new JsonScalar(v(this,{hasDefault:!0,default:a,optional:!0}),this._nativeType)}schema(e){return new JsonScalar(v(this,{schema:e,base:c.json({nullable:this.state.nullable,schema:e})}),this._nativeType)}map(e){return new JsonScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const json=e=>new W(p(`json`,U),g(`s.json`,e)),G=c.number();var K=class NumberScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new NumberScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.number({nullable:!0,array:this.state.array,schema:this.state.schema})}),this._nativeType)}array(){return new NumberScalar(v(this,{array:!0,base:c.number({nullable:this.state.nullable,array:!0,schema:this.state.schema})}),this._nativeType)}id(){return new NumberScalar(v(this,{isId:!0,isUnique:!0}),this._nativeType)}unique(){return new NumberScalar(v(this,{isUnique:!0}),this._nativeType)}default(e){return new NumberScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}schema(e){return new NumberScalar(v(this,{schema:e,base:c.number({nullable:this.state.nullable,array:this.state.array,schema:e})}),this._nativeType)}map(e){return new NumberScalar(v(this,{columnName:e}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const number=e=>new K(p(`number`,G),g(`s.number`,e)),q=c.point();var J=class PointScalar{state;constructor(e){this.state=e}nullable(){return new PointScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.point({nullable:!0})}))}default(e){return new PointScalar(v(this,{hasDefault:!0,default:normalizePointDefault(e,this.state.base),optional:!0}))}map(e){return new PointScalar(v(this,{columnName:e}))}get"~"(){return{state:this.state}}};function normalizePointDefault(e,t){if(typeof e==`function`)return e;let r=d(t,e);if(!r.issues)return r.value;throw new n({kind:`schema-builder`,builder:`s.point`,path:`default`},r.issues.map(e=>({path:e.path?.join(`.`)??`default`,message:e.message})))}function point(...e){if(e.length!==0)throw new n({kind:`schema-builder`,builder:`s.point`,path:`arguments`},[{path:`arguments`,message:`s.point() takes no native type or options`}]);return new J(p(`point`,q))}const Y=c.vector();var X=class VectorScalar{state;_nativeType;constructor(e,t){this.state=e,this._nativeType=t}nullable(){return new VectorScalar(v(this,{nullable:!0,hasDefault:!0,default:m(this.state),optional:!0,base:c.vector(this.state.dimension,{nullable:!0})}),this._nativeType)}default(e){return new VectorScalar(v(this,{hasDefault:!0,default:e,optional:!0}),this._nativeType)}map(e){return new VectorScalar(v(this,{columnName:e}),this._nativeType)}dimension(e){if(!Number.isSafeInteger(e)||e<=0)throw new n({kind:`schema-builder`,builder:`s.vector`,path:`dimension`},[{path:`dimension`,message:`Vector dimension must be a positive safe integer`}]);return new VectorScalar(v(this,{dimension:e,base:c.vector(e,{nullable:this.state.nullable})}),this._nativeType)}get"~"(){return{state:this.state,nativeType:this._nativeType}}};const vector=e=>new X(p(`vector`,Y),g(`s.vector`,e));var Z=class ModelToMany{#e;#t;constructor(e){this.#e=Object.freeze(e),this.#t=Object.freeze({state:this.#e,settleTarget:s(()=>this.#e.target.getter)})}name(e){return new ModelToMany({...this.#e,name:a(`s.toMany`,e)})}through(e){return this.#n({...this.#e.junction,table:o(`through`,e)})}source(e){return this.#n({...this.#e.junction,source:o(`source`,e)})}target(e){return this.#n({...this.#e.junction,target:o(`target`,e)})}onDelete(e){return this.#n({...this.#e.junction,onDelete:u(`onDelete`,e)})}onUpdate(e){return this.#n({...this.#e.junction,onUpdate:u(`onUpdate`,e)})}#n(e){return new ModelToMany({...this.#e,junction:Object.freeze(e)})}get"~"(){return this.#t}};function toMany(e,t){return typeof e==`function`?(arguments.length>1&&l(`s.toMany`,`options`,`A model-target relation takes exactly one argument`),new Z({kind:`relation`,cardinality:`many`,target:{kind:`model`,getter:e}})):y({kind:`relation`,cardinality:`many`,target:{kind:`variants`,entries:f(`s.toMany`,e,t)}})}export{bigInt as _,json as a,z as c,withValidatedDecimalDefault as d,time as f,blob as g,boolean as h,number as i,buildDecimalScalar as l,date as m,vector as n,int as o,dateTime as p,point as r,enumScalar as s,toMany as t,decimal as u};
2
+ //# sourceMappingURL=to-many-C1PuFIpf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-many-C1PuFIpf.mjs","names":["v","v","v","defaultNow","defaultUpdatedAt","v","defaultNow","defaultUpdatedAt","v","v","v","v","v","v","v","v","v","#state","#internal","#withJunction"],"sources":["../src/schema/scalars/bigint/scalar.ts","../src/schema/scalars/blob/scalar.ts","../src/schema/scalars/boolean/scalar.ts","../src/schema/scalars/datetime/date-scalar.ts","../src/schema/scalars/datetime/scalar.ts","../src/schema/scalars/datetime/time-scalar.ts","../src/schema/scalars/decimal/descriptor.ts","../src/schema/scalars/decimal/scalar.ts","../src/schema/scalars/enum/scalar.ts","../src/schema/scalars/int/scalar.ts","../src/schema/scalars/json/scalar.ts","../src/schema/scalars/number/scalar.ts","../src/schema/scalars/point/scalar.ts","../src/schema/scalars/vector/scalar.ts","../src/schema/relation/to-many.ts"],"sourcesContent":["// BigInt Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst bigIntBase = v.bigint();\n\nexport class BigIntScalar<State extends ScalarState<\"bigint\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BigIntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.bigint<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BigIntScalar(\n updateState(this, {\n array: true,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new BigIntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new BigIntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BigIntScalar(\n updateState(this, { hasDefault: true, default: value, optional: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<bigint>>(schema: S) {\n return new BigIntScalar(\n updateState(this, {\n schema,\n base: v.bigint<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new BigIntScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n increment() {\n return new BigIntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const bigInt = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BigIntScalar(\n createDefaultState(\"bigint\", bigIntBase),\n admitNativeType(\"s.bigInt\", nativeType)\n );\n","// Blob Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst blobBase = v.blob();\n\nexport class BlobScalar<State extends ScalarState<\"blob\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BlobScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.blob<{\n nullable: true;\n }>({\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BlobScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BlobScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n // Blob scalars don't support array(), id(), or unique()\n array(): never {\n throw new Error(\"Blob scalars don't support array modifier\");\n }\n\n id(): never {\n throw new Error(\"Blob scalars cannot be used as IDs\");\n }\n\n unique(): never {\n throw new Error(\"Blob scalars cannot be unique\");\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const blob = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BlobScalar(\n createDefaultState(\"blob\", blobBase),\n admitNativeType(\"s.blob\", nativeType)\n );\n","// Boolean Scalar\n// Standalone scalar class with State generic pattern\n\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst booleanBase = v.boolean();\n\nexport class BooleanScalar<State extends ScalarState<\"boolean\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new BooleanScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.boolean<{\n nullable: true;\n array: State[\"array\"];\n }>({\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new BooleanScalar(\n updateState(this, {\n array: true,\n base: v.boolean<{\n nullable: State[\"nullable\"];\n array: true;\n }>({\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new BooleanScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new BooleanScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const boolean = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new BooleanScalar(\n createDefaultState(\"boolean\", booleanBase),\n admitNativeType(\"s.boolean\", nativeType)\n );\n","// Date Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"date\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"date\"));\nconst dateBase = v.isoDate();\n\nexport class DateScalar<State extends ScalarState<\"date\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoDate<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n array: true,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateScalar(\n updateState(this, {\n schema,\n base: v.isoDate<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new DateScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.date\");\n return new DateScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const date = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateScalar(\n createDefaultState(\"date\", dateBase),\n admitNativeType(\"s.date\", nativeType)\n );\n","// DateTime Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"datetime\"));\nconst defaultUpdatedAt = generatorDefault(() =>\n currentTemporalValue(\"datetime\")\n);\nconst datetimeBase = v.isoTimestamp();\n\nexport class DateTimeScalar<State extends ScalarState<\"datetime\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new DateTimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTimestamp<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new DateTimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new DateTimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new DateTimeScalar(\n updateState(this, {\n schema,\n base: v.isoTimestamp<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new DateTimeScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.dateTime\");\n return new DateTimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n withoutTimezone() {\n return new DateTimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const dateTime = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new DateTimeScalar(\n { ...createDefaultState(\"datetime\", datetimeBase), withTimezone: true },\n admitNativeType(\"s.dateTime\", nativeType)\n );\n","// Time Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n generatorDefault,\n nullableDefault,\n refuseListGenerator,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\nimport { currentTemporalValue } from \"./current\";\n\nconst defaultNow = generatorDefault(() => currentTemporalValue(\"time\"));\nconst defaultUpdatedAt = generatorDefault(() => currentTemporalValue(\"time\"));\nconst timeBase = v.isoTime();\n\nexport class TimeScalar<State extends ScalarState<\"time\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new TimeScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.isoTime<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n if (\n this.state.autoGenerate?.kind === \"now\" ||\n this.state.autoGenerate?.kind === \"updatedAt\"\n )\n refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n array: true,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new TimeScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new TimeScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<string>>(schema: S) {\n return new TimeScalar(\n updateState(this, {\n schema,\n base: v.isoTime<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new TimeScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n now() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"now\" },\n default: defaultNow,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n updatedAt() {\n if (this.state.array) refuseListGenerator(\"s.time\");\n return new TimeScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"updatedAt\" },\n default: defaultUpdatedAt,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Stores time without timezone information (the default).\n * Use an explicit native type for an existing TIMETZ column.\n *\n * Use this when:\n * - You want to store local times (e.g., \"store opens at 9:00 AM\")\n * - The time should not be converted based on timezone\n */\n withoutTimezone() {\n return new TimeScalar(\n updateState(this, { withTimezone: false }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const time = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new TimeScalar(\n { ...createDefaultState(\"time\", timeBase), withTimezone: false },\n admitNativeType(\"s.time\", nativeType)\n );\n","/**\n * The definition boundary for `s.decimal({ precision, scale })`.\n *\n * A scale cannot be inferred from storage, a value, a driver, or an operation:\n * SQLite ignores the numbers in `DECIMAL(10,5)` and may put a fractional value\n * in a binary64 double. So the domain is DECLARED once, here, and every later\n * consumer — validation, DDL, binding, decoding, comparison, arithmetic,\n * migration — reads that one frozen fact off the resolved scalar.\n *\n * The descriptor is the developer's own argument, or two numbers a schema\n * document carried verbatim; neither is a hostile object, so it is read like\n * any other argument — no read-once snapshot, no key enumeration. What this\n * module owns is whether the two numbers name a domain at all.\n */\n\nimport { ValidationError } from \"@errors\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport { isRecord } from \"@validation/value-guards\";\n\n/** The one construction-time refusal of a decimal declaration. */\nfunction refuse(path: string, message: string): never {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.decimal\", path },\n [{ path, message }]\n );\n}\n\n/**\n * The frozen fixed-decimal domain the two numbers name: `precision` an integer\n * from 1 to the maximum safe integer, `scale` an integer from 0 to `precision`,\n * so \"at most `precision` total digits and at most `scale` fractional digits\"\n * is a domain with values in it.\n *\n * Its unique coverage is the schema document and an untyped JavaScript caller:\n * `read.ts` hands the numbers over as they were written, so `10.5`, `1e300` and\n * `-0` (which `JSON.parse` keeps and `JSON.stringify` loses) reach this check\n * and nothing earlier. The argument is `unknown` because the document seam\n * passes it untyped; it is read as an ordinary object, not a hostile one.\n * Whether a given PROVIDER can store the domain is a different question with a\n * different owner: the adapter answers it once when the schema is bound.\n */\nexport function readDecimalDescriptor(source: unknown): DecimalDescriptor {\n const precision = isRecord(source) ? source.precision : undefined;\n const scale = isRecord(source) ? source.scale : undefined;\n if (\n !(\n typeof precision === \"number\" &&\n Number.isSafeInteger(precision) &&\n precision >= 1\n )\n ) {\n refuse(\n \"descriptor.precision\",\n \"'precision' must be an integer between 1 and the maximum safe integer\"\n );\n }\n if (\n !(\n typeof scale === \"number\" &&\n Number.isSafeInteger(scale) &&\n scale >= 0 &&\n scale <= precision &&\n !Object.is(scale, -0)\n )\n ) {\n refuse(\n \"descriptor.scale\",\n \"'scale' must be an integer between 0 and precision\"\n );\n }\n return Object.freeze({ precision, scale });\n}\n\n/**\n * A fixed-decimal LIST is not a key, and this is where a chain that tries to\n * make one into a key stops (plan 2.1).\n *\n * Both directions are refused because the chain has two of them:\n * `.array().id()` names a list and then a key, `.id().array()` names a key and\n * then a list, and only refusing the one that comes second would leave the\n * other spelling admitted. The exclusion is the DECLARATION's, not the\n * database's: a decimal list is stored as one container value on two of three\n * providers, so a key over it would be a key over a JSON document whose\n * identity is its spelling rather than its members — and there is no member\n * arrangement that could make it addressable.\n *\n * The whole-schema rule F007 (\"an ID cannot be an array\") is untouched and\n * still owns every OTHER scalar type. This refuses earlier, at the call that\n * writes the illegal chain, and it also owns `.unique()`, which no rule in the\n * repository refuses on a list of any type.\n */\nexport function refuseDecimalListKey(\n position: \"id\" | \"unique\" | \"array\"\n): never {\n const explanation =\n \"a fixed-decimal list cannot be an ID, a unique field, an index member, a foreign-key member, or a relation identity member\";\n refuse(\n position,\n position === \"array\"\n ? `A decimal key cannot become a list: ${explanation}`\n : `A decimal list cannot be declared '.${position}()': ${explanation}`\n );\n}\n\n/**\n * A literal default, normalized through the field's complete current schema at\n * DEFINITION time, so model metadata holds the canonical logical value the DDL\n * renderer, the schema-document serializer and the create schema's trusted\n * default all read. A value outside the declared domain fails at the call that\n * wrote it, not at the first write.\n *\n * A function default keeps its closure, exactly as every other scalar's does:\n * a closure has no canonical spelling to retain, and the create schema runs the\n * field codec on each value it returns.\n */\nexport function normalizeDecimalDefault(\n value: unknown,\n schema: StandardSchemaV1<unknown, unknown>\n): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (result.issues !== undefined) {\n refuse(\"default\", \"The decimal default did not satisfy its field schema\");\n }\n return result.value;\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { DecimalDescriptor } from \"@validation/primitives/decimal-codec\";\nimport type { Decimal } from \"@validation/primitives/decimal-value\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport {\n normalizeDecimalDefault,\n readDecimalDescriptor,\n refuseDecimalListKey,\n} from \"./descriptor\";\n\n/**\n * The shared L1 descriptor supplies the two required keys. This intersection\n * makes that surface exact for held objects too, without declaring a second L2\n * precision/scale bag.\n */\ntype KeysOfUnion<Given> = Given extends unknown ? keyof Given : never;\n\ntype ExactDomain<Given> = Given &\n Record<Exclude<KeysOfUnion<Given>, keyof DecimalDescriptor>, never>;\n\n/**\n * The type-level half of plan 2.1's list exclusion.\n *\n * A key position is refused by making the RECEIVER unassignable, which is what\n * lets the diagnostic carry the reason: TypeScript reports the missing property\n * by name, so `s.decimal({...}).array().id()` reads as \"a fixed-decimal list\n * cannot be a key\" rather than as an arity or an argument error. The scalar's\n * own type is intersected in, so inside the method body `this` is the scalar it\n * has always been and no assertion is needed to reach its state.\n *\n * `unknown` on the legal side is inert: intersecting it changes nothing, so a\n * non-list decimal keeps exactly the chain it had, and a scalar whose arity is\n * still the unresolved `boolean` is admitted — only a declared list is refused.\n */\ninterface DecimalListKeyRefusal {\n readonly \"a fixed-decimal list cannot be a key\": never;\n}\n\ntype NotAList<State extends ScalarState<\"decimal\">> =\n State[\"array\"] extends true ? DecimalListKeyRefusal : unknown;\n\ntype NotAKey<State extends ScalarState<\"decimal\">> = State[\"isId\"] extends true\n ? DecimalListKeyRefusal\n : State[\"isUnique\"] extends true\n ? DecimalListKeyRefusal\n : unknown;\n\ntype DecimalScalarState<State extends ScalarState<\"decimal\">> = State & {\n readonly decimal: DecimalDescriptor;\n};\n\nexport class DecimalScalar<State extends ScalarState<\"decimal\">> {\n private readonly state: DecimalScalarState<State>;\n\n constructor(state: DecimalScalarState<State>) {\n this.state = state;\n }\n\n /** The frozen domain, carried by reference so identity survives a chain. */\n private get descriptor(): DecimalDescriptor {\n return this.state.decimal;\n }\n\n nullable() {\n return new DecimalScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n // The custom schema travels with the rebuilt base. `create` reads\n // `state.schema` directly, but `set`, `equals` and the field's own\n // value schema all read `state.base` — dropping it here would make one\n // field refine on create and not on update.\n base: v.decimal<{\n nullable: true;\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n decimal: this.descriptor,\n schema: this.state.schema,\n }),\n })\n );\n }\n\n array(this: DecimalScalar<State> & NotAKey<State>) {\n if (this.state.isId || this.state.isUnique) refuseDecimalListKey(\"array\");\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: true;\n decimal: DecimalDescriptor;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n decimal: this.descriptor,\n schema: this.state.schema,\n });\n const state = updateState(this, { array: true, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n id(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"id\");\n return new DecimalScalar(updateState(this, { isId: true, isUnique: true }));\n }\n\n unique(this: DecimalScalar<State> & NotAList<State>) {\n if (this.state.array) refuseDecimalListKey(\"unique\");\n return new DecimalScalar(updateState(this, { isUnique: true }));\n }\n\n /**\n * A literal default is normalized through the field codec HERE, at\n * definition time, so model metadata retains the canonical logical value and\n * a schema document round-trips to the same declaration. A value outside the\n * declared domain fails at the call that wrote it, not at the first write.\n */\n default<V extends DefaultValueInput<State>>(value: V) {\n return withValidatedDecimalDefault(\n this,\n normalizeDecimalDefault(value, this.state.base)\n );\n }\n\n /**\n * Refine or brand the exact value. The schema observes a `Decimal` — the\n * public value type — and the declared domain validates whatever it returns\n * LAST, so a custom schema can narrow the domain but never escape it, and it\n * cannot change the value family the field reads back as.\n */\n schema<S extends StandardSchemaV1<Decimal>>(schema: S) {\n const base = v.decimal<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n decimal: DecimalDescriptor;\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n decimal: this.descriptor,\n schema,\n });\n const state = updateState(this, { schema, base });\n if (this.state.hasDefault && typeof this.state.default !== \"function\") {\n Object.defineProperty(state, \"default\", {\n value: normalizeDecimalDefault(this.state.default, base),\n configurable: true,\n enumerable: true,\n writable: true,\n });\n }\n return new DecimalScalar(state);\n }\n\n map(columnName: string) {\n return new DecimalScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): {\n state: DecimalScalarState<State>;\n nativeType?: undefined;\n } {\n // A fixed decimal has no native-type override: PostgreSQL's `NUMERIC(p,s)`,\n // MySQL's `DECIMAL(p,s)` and SQLite's checked scaled `INTEGER` are all\n // DERIVED from the declared domain, and a second spelling beside it would\n // be a second answer to what the column is. The absence is DECLARED so the\n // scalar union keeps one internal shape for every reader.\n return { state: this.state };\n }\n}\n\n/**\n * Store the canonical verdict of the field's current base schema.\n *\n * This is an internal schema-document seam, deliberately absent from the\n * public decimal barrel. The document interpreter already has to validate a\n * decoded default to own its J008 diagnostic; feeding that verdict back\n * through `.default()` would run the same field codec a second time.\n */\nexport function withValidatedDecimalDefault<\n State extends ScalarState<\"decimal\">,\n>(scalar: DecimalScalar<State>, value: unknown) {\n return new DecimalScalar(\n updateState(scalar, {\n hasDefault: true,\n default: value,\n optional: true,\n })\n );\n}\n\n/**\n * The one public decimal factory.\n *\n * `precision` is the maximum total digit count and `scale` the maximum\n * fractional digit count; values are multiples of `10^-scale`, and an input\n * that does not fit is refused rather than silently rounded. There is no\n * zero-argument form, no native-type override, and no second \"fixed decimal\"\n * factory: portable exact decimal arithmetic needs these two numbers, and\n * SQLite cannot supply them from storage, so they are declared once here.\n */\nexport const buildDecimalScalar = (descriptor: unknown) => {\n const domain = readDecimalDescriptor(descriptor);\n return new DecimalScalar({\n ...createDefaultState(\n \"decimal\",\n v.decimal<{ decimal: DecimalDescriptor }>({ decimal: domain })\n ),\n decimal: domain,\n });\n};\n\n/** The exact public argument surface over the untyped construction seam. */\nexport const decimal = <const D>(\n descriptor: D & NoInfer<DecimalDescriptor & ExactDomain<D>>\n) => buildDecimalScalar(descriptor);\n","// Enum Scalar\n// Standalone scalar class with State generic pattern\n\nimport type { EnumValues } from \"@validation/primitives/enum\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nexport class EnumScalar<State extends ScalarState<\"enum\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n get enumValues() {\n return (\n \"values\" in this.state.base ? this.state.base.values : []\n ) as EnumValues<State[\"base\"]>;\n }\n\n nullable() {\n return new EnumScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: true;\n array: State[\"array\"];\n }\n >(this.enumValues, {\n nullable: true,\n array: this.state.array,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new EnumScalar(\n updateState(this, {\n array: true,\n base: v.enum<\n typeof this.enumValues,\n {\n nullable: State[\"nullable\"];\n array: true;\n }\n >(this.enumValues, {\n nullable: this.state.nullable,\n array: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new EnumScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new EnumScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n /**\n * Set a custom name for the enum type in the database.\n * This allows reusing the same enum across multiple tables.\n *\n * @example\n * ```ts\n * const Status = s.enum([\"PENDING\", \"ACTIVE\"]).name(\"status\");\n *\n * const user = s.model({ status: Status });\n * const order = s.model({ status: Status }); // Same \"status\" enum type\n * ```\n */\n name(enumName: string) {\n return new EnumScalar(updateState(this, { enumName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const enumScalar = <\n // A readonly tuple is admitted; see `enum_` for the mutable arm.\n const T extends string[] | readonly string[],\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n values: T,\n nativeType?: NativeTypeArgument<Db, Given>\n) => {\n return new EnumScalar(\n createDefaultState(\"enum\", v.enum(values)),\n admitNativeType(\"s.enum\", nativeType)\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst intBase = v.integer();\n\nexport class IntScalar<State extends ScalarState<\"int\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new IntScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.integer<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new IntScalar(\n updateState(this, {\n array: true,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new IntScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new IntScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new IntScalar(\n updateState(this, {\n schema,\n base: v.integer<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new IntScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n increment() {\n return new IntScalar(\n updateState(this, {\n hasDefault: true,\n autoGenerate: { kind: \"increment\" },\n default: undefined,\n disallowZero: true,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n private _internal?: {\n state: State;\n nativeType: NativeTypeDeclaration | undefined;\n };\n\n get [\"~\"]() {\n return (this._internal ??= {\n state: this.state,\n nativeType: this._nativeType,\n });\n }\n}\n\nexport const int = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new IntScalar(\n createDefaultState(\"int\", intBase),\n admitNativeType(\"s.int\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport {\n JsonNull,\n type JsonNullSentinel,\n jsonNullKindOf,\n} from \"@schema/json-null\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonValue } from \"@validation\";\nimport type { JsonInput } from \"@validation/primitives/json\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValue,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst jsonBase = v.json();\n\nexport class JsonScalar<\n State extends ScalarState<\"json\"> = ScalarState<\"json\">,\n> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new JsonScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.json<{\n nullable: true;\n schema: State[\"schema\"];\n }>({\n nullable: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n default<\n V extends\n | DefaultValueInput<State>\n | DefaultValue<\n JsonNullSentinel<\n State[\"nullable\"] extends true ? \"JsonNull\" | \"DbNull\" : \"JsonNull\"\n >\n >,\n >(value: V) {\n const kind = jsonNullKindOf(value);\n if (kind === \"AnyNull\" || (kind === \"DbNull\" && !this.state.nullable)) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.json\", path: \"default\" },\n [\n {\n path: \"default\",\n message: \"JSON default must name a null this column can store\",\n },\n ]\n );\n }\n const defaultValue =\n value === null && !this.state.nullable ? JsonNull : value;\n return new JsonScalar(\n updateState(this, {\n hasDefault: true,\n default: defaultValue,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<JsonInput, JsonValue>>(schema: S) {\n return new JsonScalar(\n updateState(this, {\n schema,\n base: v.json<{\n nullable: State[\"nullable\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new JsonScalar(updateState(this, { columnName }), this._nativeType);\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const json = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new JsonScalar(\n createDefaultState(\"json\", jsonBase),\n admitNativeType(\"s.json\", nativeType)\n );\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst numberBase = v.number();\n\nexport class NumberScalar<State extends ScalarState<\"number\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new NumberScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.number<{\n nullable: true;\n array: State[\"array\"];\n schema: State[\"schema\"];\n }>({\n nullable: true,\n array: this.state.array,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n array() {\n return new NumberScalar(\n updateState(this, {\n array: true,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: true;\n schema: State[\"schema\"];\n }>({\n nullable: this.state.nullable,\n array: true,\n schema: this.state.schema,\n }),\n }),\n this._nativeType\n );\n }\n\n id() {\n return new NumberScalar(\n updateState(this, { isId: true, isUnique: true }),\n this._nativeType\n );\n }\n\n unique() {\n return new NumberScalar(\n updateState(this, { isUnique: true }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new NumberScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n schema<S extends StandardSchemaV1<number>>(schema: S) {\n return new NumberScalar(\n updateState(this, {\n schema,\n base: v.number<{\n nullable: State[\"nullable\"];\n array: State[\"array\"];\n schema: S;\n }>({\n nullable: this.state.nullable,\n array: this.state.array,\n schema,\n }),\n }),\n this._nativeType\n );\n }\n\n map(columnName: string) {\n return new NumberScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const number = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new NumberScalar(\n createDefaultState(\"number\", numberBase),\n admitNativeType(\"s.number\", nativeType)\n );\n","import { ValidationError } from \"@errors\";\nimport { validateSchema } from \"@validation/primitives/helpers\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\n\nconst pointBase = v.point();\n\nexport class PointScalar<State extends ScalarState<\"point\">> {\n private readonly state: State;\n constructor(state: State) {\n this.state = state;\n }\n\n nullable() {\n return new PointScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.point<{\n nullable: true;\n }>({\n nullable: true,\n }),\n })\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new PointScalar(\n updateState(this, {\n hasDefault: true,\n default: normalizePointDefault(value, this.state.base),\n optional: true,\n })\n );\n }\n\n map(columnName: string) {\n return new PointScalar(updateState(this, { columnName }));\n }\n\n get [\"~\"](): { state: State; nativeType?: undefined } {\n return { state: this.state };\n }\n}\n\nfunction normalizePointDefault(value: unknown, schema: StateSchema): unknown {\n if (typeof value === \"function\") return value;\n const result = validateSchema(schema, value);\n if (!result.issues) return result.value;\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"default\" },\n result.issues.map((issue) => ({\n path: issue.path?.join(\".\") ?? \"default\",\n message: issue.message,\n }))\n );\n}\n\ntype StateSchema = ScalarState<\"point\">[\"base\"];\n\n/** The one public GeoPoint scalar factory; EPSG:4326 is not configurable. */\nexport function point(...args: []) {\n if (args.length !== 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.point\", path: \"arguments\" },\n [\n {\n path: \"arguments\",\n message: \"s.point() takes no native type or options\",\n },\n ]\n );\n }\n return new PointScalar(createDefaultState(\"point\", pointBase));\n}\n","// Vector Scalar\n// Standalone scalar class with State generic pattern\n\nimport { ValidationError } from \"@errors\";\nimport v from \"@validation/primitives/v\";\nimport {\n createDefaultState,\n type DefaultValueInput,\n nullableDefault,\n type ScalarState,\n updateState,\n} from \"../common\";\nimport { admitNativeType } from \"../native-catalog\";\nimport type {\n ExactNativeTypeMap,\n NativeDialect,\n NativeTypeArgument,\n NativeTypeDeclaration,\n} from \"../native-types\";\n\nconst vectorBase = v.vector();\n\nexport class VectorScalar<State extends ScalarState<\"vector\">> {\n private readonly state: State;\n private readonly _nativeType?: NativeTypeDeclaration | undefined;\n\n constructor(state: State, _nativeType?: NativeTypeDeclaration) {\n this.state = state;\n this._nativeType = _nativeType;\n }\n\n nullable() {\n return new VectorScalar(\n updateState(this, {\n nullable: true,\n hasDefault: true,\n default: nullableDefault(this.state),\n optional: true,\n base: v.vector<{\n nullable: true;\n }>(this.state.dimension, {\n nullable: true,\n }),\n }),\n this._nativeType\n );\n }\n\n default<V extends DefaultValueInput<State>>(value: V) {\n return new VectorScalar(\n updateState(this, {\n hasDefault: true,\n default: value,\n optional: true,\n }),\n this._nativeType\n );\n }\n\n /**\n * Maps this scalar to a custom column name in the database\n */\n map(columnName: string) {\n return new VectorScalar(\n updateState(this, { columnName }),\n this._nativeType\n );\n }\n\n dimension(dim: number) {\n if (!Number.isSafeInteger(dim) || dim <= 0) {\n throw new ValidationError(\n { kind: \"schema-builder\", builder: \"s.vector\", path: \"dimension\" },\n [\n {\n path: \"dimension\",\n message: \"Vector dimension must be a positive safe integer\",\n },\n ]\n );\n }\n return new VectorScalar(\n updateState(this, {\n dimension: dim,\n base: v.vector(dim, { nullable: this.state.nullable }),\n }),\n this._nativeType\n );\n }\n\n get [\"~\"]() {\n return {\n state: this.state,\n nativeType: this._nativeType,\n };\n }\n}\n\nexport const vector = <\n Db extends NativeDialect = never,\n const Given extends ExactNativeTypeMap<Given> = never,\n>(\n nativeType?: NativeTypeArgument<Db, Given>\n) =>\n new VectorScalar(\n createDefaultState(\"vector\", vectorBase),\n admitNativeType(\"s.vector\", nativeType)\n );\n","// `s.toMany` — the other of the two relation factories.\n//\n// The factory states the SLOT CARDINALITY (many) and its argument states the\n// TARGET DOMAIN. A model-target collection is junction-capable and an empty\n// collection is `[]`, so there is no `.optional()` here and no `.unique()`\n// anywhere: the paired slot cardinality owns remote uniqueness.\n\nimport {\n type ExactVariantOptions,\n type NormalizedManyEntries,\n normalizeVariantEntries,\n type VariantGetterMap,\n type VariantMapGuard,\n type VariantOptions,\n type VariantToManyRelation,\n variantToManyTerminal,\n} from \"./polymorphic\";\nimport {\n createTargetSettlement,\n normalizeJunctionActions,\n normalizeJunctionToken,\n normalizeRelationName,\n refuseRelationInput,\n} from \"./terminal\";\nimport type {\n AnyRelation,\n Getter,\n GetterOnly,\n JunctionReferentialAction,\n JunctionSideActions,\n ModelToManyState,\n OrdinaryJunctionOverrides,\n RelationInternal,\n Replace,\n} from \"./types\";\n\n// =============================================================================\n// TERMINAL CAPABILITY SURFACE\n// =============================================================================\n\n/** A junction action: the symmetric shorthand, or one action per side. */\nexport type JunctionActionDeclaration =\n | JunctionReferentialAction\n | JunctionSideActions;\n\n/** Every key any map member of `Action` declares; a bare action declares none. */\ntype DeclaredMapKeys<Action> = Action extends JunctionReferentialAction\n ? never\n : keyof Action;\n\n/**\n * `{ source, target }` is exact: a key beside the two sides is refused\n * structurally, so a map held in a variable cannot carry one past\n * excess-property checking either. The keys are gathered across a union\n * before the check, so one clean member cannot vouch for another that carries\n * an extra key.\n */\nexport type ExactJunctionActions<Action> = Record<\n Exclude<DeclaredMapKeys<Action>, keyof JunctionSideActions>,\n never\n>;\n\n/**\n * A model-target collection slot.\n *\n * The junction overrides are independent, meaningful facts rather than stages of\n * one all-or-nothing value, so any subset may override its canonical default.\n * Exactly one endpoint owns all supplied overrides; the other endpoint supplies\n * none and consumes the mirrored resolved view. Whether these overrides belong\n * on the resolved physical owner is one full-schema topology rule, not a second\n * type-level guess — which is why they are offered before the inverse graph\n * exists and why the state does not carry them as a public type parameter.\n */\nexport type ModelToManyRelation<State> = {\n readonly \"~\": RelationInternal<State>;\n name<const Name extends string>(\n name: Name\n ): ModelToManyRelation<Replace<State, { readonly name: Name }>>;\n through(table: string): ModelToManyRelation<State>;\n source(token: string): ModelToManyRelation<State>;\n target(token: string): ModelToManyRelation<State>;\n onDelete<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n onUpdate<const Action extends JunctionActionDeclaration>(\n action: Action & ExactJunctionActions<Action>\n ): ModelToManyRelation<State>;\n};\n\n// =============================================================================\n// PRIVATE TERMINAL\n// =============================================================================\n\nclass ModelToMany {\n readonly #state: ModelToManyState;\n readonly #internal: RelationInternal<ModelToManyState>;\n\n constructor(state: ModelToManyState) {\n this.#state = Object.freeze(state);\n this.#internal = Object.freeze({\n state: this.#state,\n settleTarget: createTargetSettlement(() => this.#state.target.getter),\n });\n }\n\n name(name: string): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n name: normalizeRelationName(\"s.toMany\", name),\n });\n }\n\n through(table: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n table: normalizeJunctionToken(\"through\", table),\n });\n }\n\n source(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n source: normalizeJunctionToken(\"source\", token),\n });\n }\n\n target(token: string): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n target: normalizeJunctionToken(\"target\", token),\n });\n }\n\n onDelete(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onDelete: normalizeJunctionActions(\"onDelete\", action),\n });\n }\n\n onUpdate(action: JunctionActionDeclaration): ModelToMany {\n return this.#withJunction({\n ...this.#state.junction,\n onUpdate: normalizeJunctionActions(\"onUpdate\", action),\n });\n }\n\n #withJunction(junction: OrdinaryJunctionOverrides): ModelToMany {\n return new ModelToMany({\n ...this.#state,\n junction: Object.freeze(junction),\n });\n }\n\n get \"~\"(): RelationInternal<ModelToManyState> {\n return this.#internal;\n }\n}\n\n// =============================================================================\n// FACTORY\n// =============================================================================\n\n/**\n * Declare a slot that holds a COLLECTION.\n *\n * The map overload is declared first so a variant map is never swallowed by the\n * broad getter overload. Dispatch examines only the argument representation and\n * never invokes a getter.\n */\nexport function toMany<\n const Entries extends VariantGetterMap,\n const Options extends VariantOptions<Entries> | undefined = undefined,\n>(\n variants: Entries & VariantMapGuard<Entries>,\n options?: Options & ExactVariantOptions<Options, Entries>\n): VariantToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: {\n readonly kind: \"variants\";\n readonly entries: NormalizedManyEntries<Entries>;\n };\n}>;\nexport function toMany<const G>(getter: G & GetterOnly<G>): G extends Getter\n ? ModelToManyRelation<{\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: { readonly kind: \"model\"; readonly getter: G };\n }>\n : never;\nexport function toMany(target: unknown, options?: unknown): AnyRelation {\n if (typeof target === \"function\") {\n // biome-ignore lint/complexity/noArguments: distinguishes omission from explicit undefined without changing the factory's public arity\n if (arguments.length > 1) {\n refuseRelationInput(\n \"s.toMany\",\n \"options\",\n \"A model-target relation takes exactly one argument\"\n );\n }\n return new ModelToMany({\n kind: \"relation\",\n cardinality: \"many\",\n target: { kind: \"model\", getter: target },\n });\n }\n return variantToManyTerminal({\n kind: \"relation\",\n cardinality: \"many\",\n target: {\n kind: \"variants\",\n entries: normalizeVariantEntries(\"s.toMany\", target, options),\n },\n });\n}\n"],"mappings":"uZAoBA,MAAM,EAAaA,EAAE,QAAQ,CAE7B,IAAa,EAAb,MAAa,YAAkD,CAC7D,MACA,YAEA,YAAY,EAAc,EAAqC,CAC7D,KAAK,MAAQ,EACb,KAAK,YAAc,EAGrB,UAAW,CACT,OAAO,IAAI,aACT,EAAY,KAAM,CAChB,SAAU,GACV,WAAY,GACZ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as n}from"./base-AdXAoy6l.mjs";var TransactionError=class extends n{static diagnosticName=`TransactionError`;constructor(e,n){super(e,n?.code??t.TRANSACTION_FAILED,n)}},InvalidTransactionInputError=class extends n{static diagnosticName=`InvalidTransactionInputError`;constructor(e){super(`$transaction array must contain only pending operations from client methods`,t.INVALID_TRANSACTION_INPUT,e)}};export{TransactionError as n,InvalidTransactionInputError as t};
2
- //# sourceMappingURL=transaction-Bnl6ULTw.mjs.map
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{n as t,t as n}from"./base-D3m1S7Uc.mjs";var TransactionError=class extends n{static diagnosticName=`TransactionError`;constructor(e,n){super(e,n?.code??t.TRANSACTION_FAILED,n)}},InvalidTransactionInputError=class extends n{static diagnosticName=`InvalidTransactionInputError`;constructor(e){super(`$transaction array must contain only pending operations from client methods`,t.INVALID_TRANSACTION_INPUT,e)}};export{TransactionError as n,InvalidTransactionInputError as t};
2
+ //# sourceMappingURL=transaction-4dfqals6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-Bnl6ULTw.mjs","names":[],"sources":["../src/errors/transaction.ts"],"sourcesContent":["import {\n VibORMError,\n VibORMErrorCode,\n type VibORMErrorMeta,\n type VibORMErrorOptions,\n} from \"./base\";\n\n/**\n * Every code {@link TransactionError} can carry.\n *\n * A family, not a single literal: the driver error mapping raises the same class for a plain\n * failure, a timeout, lock contention, a deadlock and a serialization failure, and the retry policy reads the\n * code to tell them apart. `INVALID_TRANSACTION_INPUT` is in the union too — the transaction\n * OPTION refusals (`drivers/shared/transaction-options.ts`) raise it through this class, while\n * {@link InvalidTransactionInputError} owns the `$transaction([...])` array-form refusal.\n * Measured at the construction sites; the two are told apart by class, not by code.\n */\nexport type TransactionErrorCode =\n | typeof VibORMErrorCode.TRANSACTION_FAILED\n | typeof VibORMErrorCode.TRANSACTION_TIMEOUT\n | typeof VibORMErrorCode.DEADLOCK\n | typeof VibORMErrorCode.SERIALIZATION_FAILURE\n | typeof VibORMErrorCode.INVALID_TRANSACTION_INPUT\n | typeof VibORMErrorCode.TRANSACTION_CONTENTION;\n\n/**\n * Transaction errors\n */\nexport class TransactionError extends VibORMError {\n static override readonly diagnosticName = \"TransactionError\";\n\n /** Discriminant: one of {@link TransactionErrorCode}, never a code outside the family. */\n declare readonly code: TransactionErrorCode;\n\n constructor(\n message: string,\n options?: VibORMErrorOptions & { code?: TransactionErrorCode | undefined }\n ) {\n super(\n message,\n options?.code ?? VibORMErrorCode.TRANSACTION_FAILED,\n options\n );\n }\n}\n\n/**\n * Invalid input passed to $transaction array mode\n */\nexport class InvalidTransactionInputError extends VibORMError {\n static override readonly diagnosticName = \"InvalidTransactionInputError\";\n\n /** Literal discriminant: this class always carries `INVALID_TRANSACTION_INPUT`. */\n declare readonly code: typeof VibORMErrorCode.INVALID_TRANSACTION_INPUT;\n\n constructor(options?: { meta?: VibORMErrorMeta }) {\n super(\n \"$transaction array must contain only pending operations from client methods\",\n VibORMErrorCode.INVALID_TRANSACTION_INPUT,\n options\n );\n }\n}\n"],"mappings":"wFA4BA,IAAa,iBAAb,cAAsC,CAAY,CAChD,OAAyB,eAAiB,mBAK1C,YACE,EACA,EACA,CACA,MACE,EACA,GAAS,MAAQ,EAAgB,mBACjC,EACD,GAOQ,6BAAb,cAAkD,CAAY,CAC5D,OAAyB,eAAiB,+BAK1C,YAAY,EAAsC,CAChD,MACE,8EACA,EAAgB,0BAChB,EACD"}
1
+ {"version":3,"file":"transaction-4dfqals6.mjs","names":[],"sources":["../src/errors/transaction.ts"],"sourcesContent":["import {\n VibORMError,\n VibORMErrorCode,\n type VibORMErrorMeta,\n type VibORMErrorOptions,\n} from \"./base\";\n\n/**\n * Every code {@link TransactionError} can carry.\n *\n * A family, not a single literal: the driver error mapping raises the same class for a plain\n * failure, a timeout, lock contention, a deadlock and a serialization failure, and the retry policy reads the\n * code to tell them apart. `INVALID_TRANSACTION_INPUT` is in the union too — the transaction\n * OPTION refusals (`drivers/shared/transaction-options.ts`) raise it through this class, while\n * {@link InvalidTransactionInputError} owns the `$transaction([...])` array-form refusal.\n * Measured at the construction sites; the two are told apart by class, not by code.\n */\nexport type TransactionErrorCode =\n | typeof VibORMErrorCode.TRANSACTION_FAILED\n | typeof VibORMErrorCode.TRANSACTION_TIMEOUT\n | typeof VibORMErrorCode.DEADLOCK\n | typeof VibORMErrorCode.SERIALIZATION_FAILURE\n | typeof VibORMErrorCode.INVALID_TRANSACTION_INPUT\n | typeof VibORMErrorCode.TRANSACTION_CONTENTION;\n\n/**\n * Transaction errors\n */\nexport class TransactionError extends VibORMError {\n static override readonly diagnosticName = \"TransactionError\";\n\n /** Discriminant: one of {@link TransactionErrorCode}, never a code outside the family. */\n declare readonly code: TransactionErrorCode;\n\n constructor(\n message: string,\n options?: VibORMErrorOptions & { code?: TransactionErrorCode | undefined }\n ) {\n super(\n message,\n options?.code ?? VibORMErrorCode.TRANSACTION_FAILED,\n options\n );\n }\n}\n\n/**\n * Invalid input passed to $transaction array mode\n */\nexport class InvalidTransactionInputError extends VibORMError {\n static override readonly diagnosticName = \"InvalidTransactionInputError\";\n\n /** Literal discriminant: this class always carries `INVALID_TRANSACTION_INPUT`. */\n declare readonly code: typeof VibORMErrorCode.INVALID_TRANSACTION_INPUT;\n\n constructor(options?: { meta?: VibORMErrorMeta }) {\n super(\n \"$transaction array must contain only pending operations from client methods\",\n VibORMErrorCode.INVALID_TRANSACTION_INPUT,\n options\n );\n }\n}\n"],"mappings":"wFA4BA,IAAa,iBAAb,cAAsC,CAAY,CAChD,OAAyB,eAAiB,mBAK1C,YACE,EACA,EACA,CACA,MACE,EACA,GAAS,MAAQ,EAAgB,mBACjC,EACD,GAOQ,6BAAb,cAAkD,CAAY,CAC5D,OAAyB,eAAiB,+BAK1C,YAAY,EAAsC,CAChD,MACE,8EACA,EAAgB,0BAChB,EACD"}
@@ -1,2 +1,2 @@
1
- import{n as e,t}from"./chunk-BuuaeEvq.mjs";import{t as n}from"./transaction-Bnl6ULTw.mjs";var r=t({readTransactionOperation:()=>readTransactionOperation,registerTransactionOperationOwner:()=>registerTransactionOperationOwner,transactionOperationOwner:()=>transactionOperationOwner});const i=[],a=new WeakMap;function transactionOperationOwner(e){let t=Object.getPrototypeOf(e),r=a.get(t);if(r===void 0)throw new n;return r}function registerTransactionOperationOwner(e,t,n){let r=n,resolve=n=>t(n)&&Object.getPrototypeOf(n)===e?r:void 0,o=Object.freeze({resolve});i.push(o),a.set(e,r)}function readTransactionOperation(e){for(let t of i)try{let n=t.resolve(e);if(n!==void 0)return n}catch{}}export{r as i,registerTransactionOperationOwner as n,transactionOperationOwner as r,readTransactionOperation as t};
2
- //# sourceMappingURL=transaction-operation-CKK3l_9x.mjs.map
1
+ import{n as e,t}from"./chunk-BuuaeEvq.mjs";import{t as n}from"./transaction-4dfqals6.mjs";var r=t({readTransactionOperation:()=>readTransactionOperation,registerTransactionOperationOwner:()=>registerTransactionOperationOwner,transactionOperationOwner:()=>transactionOperationOwner});const i=[],a=new WeakMap;function transactionOperationOwner(e){let t=Object.getPrototypeOf(e),r=a.get(t);if(r===void 0)throw new n;return r}function registerTransactionOperationOwner(e,t,n){let r=n,resolve=n=>t(n)&&Object.getPrototypeOf(n)===e?r:void 0,o=Object.freeze({resolve});i.push(o),a.set(e,r)}function readTransactionOperation(e){for(let t of i)try{let n=t.resolve(e);if(n!==void 0)return n}catch{}}export{r as i,registerTransactionOperationOwner as n,transactionOperationOwner as r,readTransactionOperation as t};
2
+ //# sourceMappingURL=transaction-operation-CU1zlxiG.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-operation-CKK3l_9x.mjs","names":[],"sources":["../src/query-engine/transaction-operation.ts"],"sourcesContent":["import type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { InvalidTransactionInputError } from \"@errors\";\nimport type { ObservationCompletionFactsReader } from \"@extensions/observation\";\nimport type {\n QueryInterceptorExecutionControl,\n TransactionWriteOutcomes,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { PreparedBatchOperation, PreparedQuery } from \"./types\";\n\n/** One shared owner table registered once by each genuine operation class. */\nexport interface TransactionOperationOwner<Owner extends object = object> {\n clientId(owner: Owner): symbol;\n scopeId(owner: Owner): symbol;\n model(owner: Owner): string;\n operation(owner: Owner): string;\n context(owner: Owner): QueryExecutionContext;\n requiresInterception(owner: Owner): boolean;\n prepareAdmission(owner: Owner, phase?: \"input\" | \"plan\"): void;\n stagePackageWriteOutcomes(\n owner: Owner,\n outcomes: TransactionWriteOutcomes\n ): void;\n startInterception(\n owner: Owner,\n child: (notifications?: WriteOutcomeNotifications) => Promise<unknown>,\n outcomes: TransactionWriteOutcomes,\n control: QueryInterceptorExecutionControl\n ): Promise<unknown>;\n executeCore(\n owner: Owner,\n driver: AnyDriver,\n notifications?: WriteOutcomeNotifications\n ): Promise<unknown>;\n isWrite(owner: Owner): boolean;\n hasObservation(owner: Owner): boolean;\n observe(\n owner: Owner,\n child: () => Promise<unknown>,\n readCompletionFacts?: ObservationCompletionFactsReader\n ): Promise<unknown>;\n reserveWith(owner: Owner, driver: AnyDriver): void;\n executeWith(owner: Owner, driver: AnyDriver): Promise<unknown>;\n prepare(owner: Owner, driver?: AnyDriver): PreparedQuery | undefined;\n prepareBatch(\n owner: Owner\n ): Promise<PreparedBatchOperation<unknown> | undefined>;\n parseResult(owner: Owner, raw: QueryResult<unknown>): unknown;\n observeBatchPhase<Result>(\n owner: Owner,\n driver: AnyDriver,\n execute: () => Result | Promise<Result>\n ): Promise<Result>;\n}\n\n/** The private authority resolved only while coordinating an array. */\nexport type TransactionOperationCapability = object;\n\ninterface RegisteredTransactionOperationOwner {\n readonly resolve: TransactionOperationResolver;\n}\n\ntype TransactionOperationResolver = (\n value: object\n) => TransactionOperationOwner<TransactionOperationCapability> | undefined;\n\nconst transactionOperationOwners: RegisteredTransactionOperationOwner[] = [];\nconst transactionOperationOwnersByPrototype = new WeakMap<\n object,\n TransactionOperationOwner<TransactionOperationCapability>\n>();\n\n/** Resolve the one class owner after the capability passed admission. */\nexport function transactionOperationOwner(\n operation: TransactionOperationCapability\n): TransactionOperationOwner<TransactionOperationCapability> {\n const prototype = Object.getPrototypeOf(operation);\n const owner = transactionOperationOwnersByPrototype.get(prototype);\n if (owner === undefined) throw new InvalidTransactionInputError();\n return owner;\n}\n\n/** Register one class-owned array authority for its exact private brand. */\nexport function registerTransactionOperationOwner<Owner extends object>(\n prototype: object,\n authenticate: (value: object) => value is Owner,\n owner: TransactionOperationOwner<Owner>\n): void {\n const resolvedOwner: TransactionOperationOwner<TransactionOperationCapability> =\n owner;\n const resolve = (\n value: object\n ): TransactionOperationOwner<TransactionOperationCapability> | undefined =>\n authenticate(value) && Object.getPrototypeOf(value) === prototype\n ? resolvedOwner\n : undefined;\n const registration: RegisteredTransactionOperationOwner = Object.freeze({\n resolve,\n });\n transactionOperationOwners.push(registration);\n transactionOperationOwnersByPrototype.set(prototype, resolvedOwner);\n}\n\n/** Resolve one owner only for an object constructed by its registered class. */\nexport function readTransactionOperation(\n value: object\n): TransactionOperationOwner<TransactionOperationCapability> | undefined {\n for (const registration of transactionOperationOwners) {\n try {\n const owner = registration.resolve(value);\n if (owner !== undefined) return owner;\n } catch {\n // A hostile candidate cannot interrupt the remaining genuine owners.\n }\n }\n return undefined;\n}\n\n/** The static thenable accepted by internal transaction composition. */\nexport interface TransactionOperation<T> extends PromiseLike<T> {}\n"],"mappings":"2RAsEA,MAAM,EAAoE,EAAE,CACtE,EAAwC,IAAI,QAMlD,SAAgB,0BACd,EAC2D,CAC3D,IAAM,EAAY,OAAO,eAAe,EAAU,CAC5C,EAAQ,EAAsC,IAAI,EAAU,CAClE,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EACnC,OAAO,EAIT,SAAgB,kCACd,EACA,EACA,EACM,CACN,IAAM,EACJ,EACI,QACJ,GAEA,EAAa,EAAM,EAAI,OAAO,eAAe,EAAM,GAAK,EACpD,EACA,IAAA,GACA,EAAoD,OAAO,OAAO,CACtE,QACD,CAAC,CACF,EAA2B,KAAK,EAAa,CAC7C,EAAsC,IAAI,EAAW,EAAc,CAIrE,SAAgB,yBACd,EACuE,CACvE,IAAK,IAAM,KAAgB,EACzB,GAAI,CACF,IAAM,EAAQ,EAAa,QAAQ,EAAM,CACzC,GAAI,IAAU,IAAA,GAAW,OAAO,OAC1B"}
1
+ {"version":3,"file":"transaction-operation-CU1zlxiG.mjs","names":[],"sources":["../src/query-engine/transaction-operation.ts"],"sourcesContent":["import type {\n AnyDriver,\n QueryExecutionContext,\n QueryResult,\n} from \"@drivers/exports\";\nimport { InvalidTransactionInputError } from \"@errors\";\nimport type { ObservationCompletionFactsReader } from \"@extensions/observation\";\nimport type {\n QueryInterceptorExecutionControl,\n TransactionWriteOutcomes,\n WriteOutcomeNotifications,\n} from \"@extensions/query\";\nimport type { PreparedBatchOperation, PreparedQuery } from \"./types\";\n\n/** One shared owner table registered once by each genuine operation class. */\nexport interface TransactionOperationOwner<Owner extends object = object> {\n clientId(owner: Owner): symbol;\n scopeId(owner: Owner): symbol;\n model(owner: Owner): string;\n operation(owner: Owner): string;\n context(owner: Owner): QueryExecutionContext;\n requiresInterception(owner: Owner): boolean;\n prepareAdmission(owner: Owner, phase?: \"input\" | \"plan\"): void;\n stagePackageWriteOutcomes(\n owner: Owner,\n outcomes: TransactionWriteOutcomes\n ): void;\n startInterception(\n owner: Owner,\n child: (notifications?: WriteOutcomeNotifications) => Promise<unknown>,\n outcomes: TransactionWriteOutcomes,\n control: QueryInterceptorExecutionControl\n ): Promise<unknown>;\n executeCore(\n owner: Owner,\n driver: AnyDriver,\n notifications?: WriteOutcomeNotifications\n ): Promise<unknown>;\n isWrite(owner: Owner): boolean;\n hasObservation(owner: Owner): boolean;\n observe(\n owner: Owner,\n child: () => Promise<unknown>,\n readCompletionFacts?: ObservationCompletionFactsReader\n ): Promise<unknown>;\n reserveWith(owner: Owner, driver: AnyDriver): void;\n executeWith(owner: Owner, driver: AnyDriver): Promise<unknown>;\n prepare(owner: Owner, driver?: AnyDriver): PreparedQuery | undefined;\n prepareBatch(\n owner: Owner\n ): Promise<PreparedBatchOperation<unknown> | undefined>;\n parseResult(owner: Owner, raw: QueryResult<unknown>): unknown;\n observeBatchPhase<Result>(\n owner: Owner,\n driver: AnyDriver,\n execute: () => Result | Promise<Result>\n ): Promise<Result>;\n}\n\n/** The private authority resolved only while coordinating an array. */\nexport type TransactionOperationCapability = object;\n\ninterface RegisteredTransactionOperationOwner {\n readonly resolve: TransactionOperationResolver;\n}\n\ntype TransactionOperationResolver = (\n value: object\n) => TransactionOperationOwner<TransactionOperationCapability> | undefined;\n\nconst transactionOperationOwners: RegisteredTransactionOperationOwner[] = [];\nconst transactionOperationOwnersByPrototype = new WeakMap<\n object,\n TransactionOperationOwner<TransactionOperationCapability>\n>();\n\n/** Resolve the one class owner after the capability passed admission. */\nexport function transactionOperationOwner(\n operation: TransactionOperationCapability\n): TransactionOperationOwner<TransactionOperationCapability> {\n const prototype = Object.getPrototypeOf(operation);\n const owner = transactionOperationOwnersByPrototype.get(prototype);\n if (owner === undefined) throw new InvalidTransactionInputError();\n return owner;\n}\n\n/** Register one class-owned array authority for its exact private brand. */\nexport function registerTransactionOperationOwner<Owner extends object>(\n prototype: object,\n authenticate: (value: object) => value is Owner,\n owner: TransactionOperationOwner<Owner>\n): void {\n const resolvedOwner: TransactionOperationOwner<TransactionOperationCapability> =\n owner;\n const resolve = (\n value: object\n ): TransactionOperationOwner<TransactionOperationCapability> | undefined =>\n authenticate(value) && Object.getPrototypeOf(value) === prototype\n ? resolvedOwner\n : undefined;\n const registration: RegisteredTransactionOperationOwner = Object.freeze({\n resolve,\n });\n transactionOperationOwners.push(registration);\n transactionOperationOwnersByPrototype.set(prototype, resolvedOwner);\n}\n\n/** Resolve one owner only for an object constructed by its registered class. */\nexport function readTransactionOperation(\n value: object\n): TransactionOperationOwner<TransactionOperationCapability> | undefined {\n for (const registration of transactionOperationOwners) {\n try {\n const owner = registration.resolve(value);\n if (owner !== undefined) return owner;\n } catch {\n // A hostile candidate cannot interrupt the remaining genuine owners.\n }\n }\n return undefined;\n}\n\n/** The static thenable accepted by internal transaction composition. */\nexport interface TransactionOperation<T> extends PromiseLike<T> {}\n"],"mappings":"2RAsEA,MAAM,EAAoE,EAAE,CACtE,EAAwC,IAAI,QAMlD,SAAgB,0BACd,EAC2D,CAC3D,IAAM,EAAY,OAAO,eAAe,EAAU,CAC5C,EAAQ,EAAsC,IAAI,EAAU,CAClE,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EACnC,OAAO,EAIT,SAAgB,kCACd,EACA,EACA,EACM,CACN,IAAM,EACJ,EACI,QACJ,GAEA,EAAa,EAAM,EAAI,OAAO,eAAe,EAAM,GAAK,EACpD,EACA,IAAA,GACA,EAAoD,OAAO,OAAO,CACtE,QACD,CAAC,CACF,EAA2B,KAAK,EAAa,CAC7C,EAAsC,IAAI,EAAW,EAAc,CAIrE,SAAgB,yBACd,EACuE,CACvE,IAAK,IAAM,KAAgB,EACzB,GAAI,CACF,IAAM,EAAQ,EAAa,QAAQ,EAAM,CACzC,GAAI,IAAU,IAAA,GAAW,OAAO,OAC1B"}
@@ -1,2 +1,2 @@
1
1
  import{n as e}from"./chunk-BuuaeEvq.mjs";const isVariantRelationState=e=>e.target.kind===`variants`;export{isVariantRelationState as t};
2
- //# sourceMappingURL=types-C4v6iAmY.mjs.map
2
+ //# sourceMappingURL=types-C5Oxz9yp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-C4v6iAmY.mjs","names":[],"sources":["../src/schema/relation/types.ts"],"sourcesContent":["// The canonical relation declaration representation.\n//\n// A declaration states exactly two independent facts: the SLOT CARDINALITY the\n// factory was spelled with (`toOne` / `toMany`) and the TARGET DOMAIN its\n// argument names (one model, or named variants). Everything else about an edge —\n// which endpoint owns the foreign key, whether storage is a row FK or a\n// junction, whether the pair is one-to-one or many-to-many, whether a\n// model-target singular slot may be empty — is DERIVED by the full-schema\n// topology owner and is deliberately absent from this union.\n\nimport type { AnyModel } from \"@schema/model\";\n\n/** Workaround to allow circular dependencies */\nexport type Getter = () => any;\n\n/** Referential action for foreign key constraints */\nexport type ReferentialAction = \"cascade\" | \"setNull\" | \"restrict\" | \"noAction\";\n\n/**\n * `setNull` is absent because every junction side is a non-null membership-key\n * member: the action would null a column that carries the membership itself.\n */\nexport type JunctionReferentialAction = Exclude<ReferentialAction, \"setNull\">;\n\n/**\n * One junction action per foreign key, named by the DECLARING endpoint:\n * `source` is the junction's foreign key to the model whose slot carries the\n * declaration, `target` the one to that slot's target model. Never the\n * alphabetical column order, and never whichever endpoint a query traverses.\n * A bare action is the symmetric shorthand for both.\n */\nexport type JunctionSideActions = {\n readonly source: JunctionReferentialAction;\n readonly target: JunctionReferentialAction;\n};\n\n/**\n * Last-call-wins at the type level: every modifier returns a new value whose\n * state REPLACES its own fact rather than intersecting with the prior one, so\n * repeating `.name(...)` keeps the last literal instead of collapsing to\n * `never`.\n */\nexport type Replace<State, Patch> = Omit<State, keyof Patch> & Patch;\n\n/**\n * The getter overload's phantom refusal — the counterpart of\n * `VariantMapGuard`. It uniquely owns \"not a map at all and not a getter\": the\n * map overload is tried first, so without this guard a direct model object or a\n * malformed map reaching the getter overload would answer `never`, and `never`\n * is assignable to a model shape, which makes the refusal vanish.\n */\nexport type GetterOnly<G> = G extends Getter\n ? unknown\n : {\n readonly \"a relation target is either `() => model` or a map of named `() => model` getters\": never;\n };\n\n/** How many rows one slot addresses. */\nexport type RelationCardinality = \"one\" | \"many\";\n\n// =============================================================================\n// TARGET DOMAIN\n// =============================================================================\n\nexport type ModelTarget<G = any> = {\n readonly kind: \"model\";\n readonly getter: G;\n};\n\n/** One member junction's table and its two DIRECTED side naming tokens. */\nexport type VariantJunctionOverride = {\n readonly table: string;\n readonly source: string;\n readonly target: string;\n};\n\n/**\n * One normalized variant. The public map key stays the query/result/mutation\n * discriminator; `storedValue` is the string written to storage. They are two\n * facts, and a renamed public key with a preserved stored value is\n * metadata-only.\n */\nexport type VariantEntry<G = any> = {\n readonly getter: G;\n readonly storedValue: string;\n};\n\nexport type VariantOneEntry<G = any> = VariantEntry<G> & {\n readonly junction?: never;\n};\n\nexport type VariantManyEntry<G = any> = VariantEntry<G> & {\n readonly junction?: VariantJunctionOverride;\n};\n\nexport type VariantTarget<\n Entries extends Readonly<Record<string, VariantEntry<any>>>,\n> = {\n readonly kind: \"variants\";\n readonly entries: Entries;\n};\n\n// =============================================================================\n// FOREIGN KEY AND JUNCTION CONFIGURATION\n// =============================================================================\n\nexport type NonEmptyFieldTuple = readonly [string, ...string[]];\n\n/**\n * The complete result of `.fields(...).references(...)`, plus the referential\n * actions that are only meaningful once that complete reference exists. A\n * partial foreign key is never a value of this type: the transient references\n * stage holds the local tuple until `.references(...)` completes the pair.\n */\nexport type ForeignKeyDeclaration<\n Fields extends NonEmptyFieldTuple = NonEmptyFieldTuple,\n References extends NonEmptyFieldTuple = NonEmptyFieldTuple,\n> = {\n readonly fields: Fields;\n readonly references: References;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\ntype AtLeastOne<Value> = {\n [Key in keyof Value]-?: Required<Pick<Value, Key>> &\n Partial<Omit<Value, Key>>;\n}[keyof Value];\n\n/**\n * Any subset of the canonical junction defaults, but never the empty object:\n * trusted state stores an override only when an override was declared. An\n * action is stored in its one normalized form, the side pair, whichever\n * spelling declared it.\n */\nexport type OrdinaryJunctionOverrides = AtLeastOne<{\n readonly table?: string;\n readonly source?: string;\n readonly target?: string;\n readonly onDelete?: JunctionSideActions;\n readonly onUpdate?: JunctionSideActions;\n}>;\n\n// =============================================================================\n// THE CLOSED STATE UNION\n// =============================================================================\n\n/**\n * The broad state arms deliberately use `any` for the getter, not `G extends\n * Getter`: constraining a function-typed member forces TypeScript to resolve\n * recursive getter returns, and that resolution is circular in mutually\n * recursive schemas and silently collapses both model consts to `any`.\n * Comparing against `any` short-circuits without touching the return type.\n * Concrete factory states retain the exact getter or getter-map generic.\n */\nexport type ModelToOneState<\n G = any,\n ForeignKey extends ForeignKeyDeclaration | undefined =\n | ForeignKeyDeclaration\n | undefined,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"one\";\n readonly target: ModelTarget<G>;\n readonly name?: string;\n readonly junction?: never;\n readonly optional?: never;\n} & (ForeignKey extends ForeignKeyDeclaration\n ? { readonly foreignKey: ForeignKey }\n : { readonly foreignKey?: never });\n\nexport type ModelToManyState<G = any> = {\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: ModelTarget<G>;\n readonly name?: string;\n readonly junction?: OrdinaryJunctionOverrides;\n readonly foreignKey?: never;\n readonly optional?: never;\n};\n\nexport type VariantToOneState<\n Entries extends Readonly<Record<string, VariantOneEntry<any>>> = Readonly<\n Record<string, VariantOneEntry<any>>\n >,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"one\";\n readonly target: VariantTarget<Entries>;\n readonly name?: string;\n readonly optional?: true;\n readonly foreignKey?: never;\n readonly junction?: never;\n};\n\nexport type VariantToManyState<\n Entries extends Readonly<Record<string, VariantManyEntry<any>>> = Readonly<\n Record<string, VariantManyEntry<any>>\n >,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: VariantTarget<Entries>;\n readonly name?: string;\n readonly foreignKey?: never;\n readonly junction?: never;\n readonly optional?: never;\n};\n\n/**\n * Optional properties use one canonical representation: the property is absent,\n * or it holds the one normalized value. Trusted state never stores explicit\n * `undefined`, `false`, an empty override object, or a partial foreign key. The\n * `?: never` exclusions make illegal cross-arm configuration fail under\n * structural assignment too, so the algebra does not rely on excess-property\n * checking or factory etiquette.\n */\nexport type RelationState =\n | ModelToOneState\n | ModelToManyState\n | VariantToOneState\n | VariantToManyState;\n\n/**\n * The two arms of one TARGET DOMAIN, named because the derived views split on\n * that axis before they split on anything else (§8.2): a variant target has a\n * discriminated element union, a discriminated projection envelope, and its own\n * family key set, whatever its cardinality.\n */\nexport type VariantRelationState = VariantToOneState | VariantToManyState;\n\n/**\n * The predicate for {@link VariantRelationState} — one declared property read,\n * spelled once so both halves of a target-domain partition ask it the same way.\n * It classifies a declaration; it resolves nothing.\n */\nexport const isVariantRelationState = (\n state: RelationState\n): state is VariantRelationState => state.target.kind === \"variants\";\n\n// =============================================================================\n// INTERNAL ACCESSOR\n// =============================================================================\n\n/**\n * The internal accessor every terminal exposes under `\"~\"`.\n *\n * `settleTarget` is the source-independent lazy once-cell required by the\n * declaration algebra: the first caller settles a target's raw getter return OR\n * one normalized `Error`, and every later consumer — in this schema graph or\n * another one reusing the same immutable terminal — observes that same outcome.\n * It is derived cache state, not a declaration fact; the resolver decides\n * whether a settled return is a registered model and owns the contextual\n * diagnostic, so nothing model-specific is cached here.\n */\nexport type RelationInternal<State> = {\n readonly state: State;\n /** Variant key for a variant target; omitted for a model target. */\n readonly settleTarget: (variantKey?: string) => unknown;\n};\n\n/** Any relation terminal, matched by its internal brand. */\nexport type AnyRelation = { readonly \"~\": RelationInternal<RelationState> };\n\n/**\n * The identity of a contextual relation reference.\n *\n * A relation object does not store its source model: `.extends()` may reuse one\n * terminal under more than one model or key, so the source model plus the field\n * key is the whole identity and the declaration is read from that model's\n * canonical relation map rather than copied into the identity.\n */\nexport type RelationSlot = {\n readonly source: AnyModel;\n readonly field: string;\n};\n"],"mappings":"yCA4OA,MAAa,uBACX,GACkC,EAAM,OAAO,OAAS"}
1
+ {"version":3,"file":"types-C5Oxz9yp.mjs","names":[],"sources":["../src/schema/relation/types.ts"],"sourcesContent":["// The canonical relation declaration representation.\n//\n// A declaration states exactly two independent facts: the SLOT CARDINALITY the\n// factory was spelled with (`toOne` / `toMany`) and the TARGET DOMAIN its\n// argument names (one model, or named variants). Everything else about an edge —\n// which endpoint owns the foreign key, whether storage is a row FK or a\n// junction, whether the pair is one-to-one or many-to-many, whether a\n// model-target singular slot may be empty — is DERIVED by the full-schema\n// topology owner and is deliberately absent from this union.\n\nimport type { AnyModel } from \"@schema/model\";\n\n/** Workaround to allow circular dependencies */\nexport type Getter = () => any;\n\n/** Referential action for foreign key constraints */\nexport type ReferentialAction = \"cascade\" | \"setNull\" | \"restrict\" | \"noAction\";\n\n/**\n * `setNull` is absent because every junction side is a non-null membership-key\n * member: the action would null a column that carries the membership itself.\n */\nexport type JunctionReferentialAction = Exclude<ReferentialAction, \"setNull\">;\n\n/**\n * One junction action per foreign key, named by the DECLARING endpoint:\n * `source` is the junction's foreign key to the model whose slot carries the\n * declaration, `target` the one to that slot's target model. Never the\n * alphabetical column order, and never whichever endpoint a query traverses.\n * A bare action is the symmetric shorthand for both.\n */\nexport type JunctionSideActions = {\n readonly source: JunctionReferentialAction;\n readonly target: JunctionReferentialAction;\n};\n\n/**\n * Last-call-wins at the type level: every modifier returns a new value whose\n * state REPLACES its own fact rather than intersecting with the prior one, so\n * repeating `.name(...)` keeps the last literal instead of collapsing to\n * `never`.\n */\nexport type Replace<State, Patch> = Omit<State, keyof Patch> & Patch;\n\n/**\n * The getter overload's phantom refusal — the counterpart of\n * `VariantMapGuard`. It uniquely owns \"not a map at all and not a getter\": the\n * map overload is tried first, so without this guard a direct model object or a\n * malformed map reaching the getter overload would answer `never`, and `never`\n * is assignable to a model shape, which makes the refusal vanish.\n */\nexport type GetterOnly<G> = G extends Getter\n ? unknown\n : {\n readonly \"a relation target is either `() => model` or a map of named `() => model` getters\": never;\n };\n\n/** How many rows one slot addresses. */\nexport type RelationCardinality = \"one\" | \"many\";\n\n// =============================================================================\n// TARGET DOMAIN\n// =============================================================================\n\nexport type ModelTarget<G = any> = {\n readonly kind: \"model\";\n readonly getter: G;\n};\n\n/** One member junction's table and its two DIRECTED side naming tokens. */\nexport type VariantJunctionOverride = {\n readonly table: string;\n readonly source: string;\n readonly target: string;\n};\n\n/**\n * One normalized variant. The public map key stays the query/result/mutation\n * discriminator; `storedValue` is the string written to storage. They are two\n * facts, and a renamed public key with a preserved stored value is\n * metadata-only.\n */\nexport type VariantEntry<G = any> = {\n readonly getter: G;\n readonly storedValue: string;\n};\n\nexport type VariantOneEntry<G = any> = VariantEntry<G> & {\n readonly junction?: never;\n};\n\nexport type VariantManyEntry<G = any> = VariantEntry<G> & {\n readonly junction?: VariantJunctionOverride;\n};\n\nexport type VariantTarget<\n Entries extends Readonly<Record<string, VariantEntry<any>>>,\n> = {\n readonly kind: \"variants\";\n readonly entries: Entries;\n};\n\n// =============================================================================\n// FOREIGN KEY AND JUNCTION CONFIGURATION\n// =============================================================================\n\nexport type NonEmptyFieldTuple = readonly [string, ...string[]];\n\n/**\n * The complete result of `.fields(...).references(...)`, plus the referential\n * actions that are only meaningful once that complete reference exists. A\n * partial foreign key is never a value of this type: the transient references\n * stage holds the local tuple until `.references(...)` completes the pair.\n */\nexport type ForeignKeyDeclaration<\n Fields extends NonEmptyFieldTuple = NonEmptyFieldTuple,\n References extends NonEmptyFieldTuple = NonEmptyFieldTuple,\n> = {\n readonly fields: Fields;\n readonly references: References;\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n};\n\ntype AtLeastOne<Value> = {\n [Key in keyof Value]-?: Required<Pick<Value, Key>> &\n Partial<Omit<Value, Key>>;\n}[keyof Value];\n\n/**\n * Any subset of the canonical junction defaults, but never the empty object:\n * trusted state stores an override only when an override was declared. An\n * action is stored in its one normalized form, the side pair, whichever\n * spelling declared it.\n */\nexport type OrdinaryJunctionOverrides = AtLeastOne<{\n readonly table?: string;\n readonly source?: string;\n readonly target?: string;\n readonly onDelete?: JunctionSideActions;\n readonly onUpdate?: JunctionSideActions;\n}>;\n\n// =============================================================================\n// THE CLOSED STATE UNION\n// =============================================================================\n\n/**\n * The broad state arms deliberately use `any` for the getter, not `G extends\n * Getter`: constraining a function-typed member forces TypeScript to resolve\n * recursive getter returns, and that resolution is circular in mutually\n * recursive schemas and silently collapses both model consts to `any`.\n * Comparing against `any` short-circuits without touching the return type.\n * Concrete factory states retain the exact getter or getter-map generic.\n */\nexport type ModelToOneState<\n G = any,\n ForeignKey extends ForeignKeyDeclaration | undefined =\n | ForeignKeyDeclaration\n | undefined,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"one\";\n readonly target: ModelTarget<G>;\n readonly name?: string;\n readonly junction?: never;\n readonly optional?: never;\n} & (ForeignKey extends ForeignKeyDeclaration\n ? { readonly foreignKey: ForeignKey }\n : { readonly foreignKey?: never });\n\nexport type ModelToManyState<G = any> = {\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: ModelTarget<G>;\n readonly name?: string;\n readonly junction?: OrdinaryJunctionOverrides;\n readonly foreignKey?: never;\n readonly optional?: never;\n};\n\nexport type VariantToOneState<\n Entries extends Readonly<Record<string, VariantOneEntry<any>>> = Readonly<\n Record<string, VariantOneEntry<any>>\n >,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"one\";\n readonly target: VariantTarget<Entries>;\n readonly name?: string;\n readonly optional?: true;\n readonly foreignKey?: never;\n readonly junction?: never;\n};\n\nexport type VariantToManyState<\n Entries extends Readonly<Record<string, VariantManyEntry<any>>> = Readonly<\n Record<string, VariantManyEntry<any>>\n >,\n> = {\n readonly kind: \"relation\";\n readonly cardinality: \"many\";\n readonly target: VariantTarget<Entries>;\n readonly name?: string;\n readonly foreignKey?: never;\n readonly junction?: never;\n readonly optional?: never;\n};\n\n/**\n * Optional properties use one canonical representation: the property is absent,\n * or it holds the one normalized value. Trusted state never stores explicit\n * `undefined`, `false`, an empty override object, or a partial foreign key. The\n * `?: never` exclusions make illegal cross-arm configuration fail under\n * structural assignment too, so the algebra does not rely on excess-property\n * checking or factory etiquette.\n */\nexport type RelationState =\n | ModelToOneState\n | ModelToManyState\n | VariantToOneState\n | VariantToManyState;\n\n/**\n * The two arms of one TARGET DOMAIN, named because the derived views split on\n * that axis before they split on anything else (§8.2): a variant target has a\n * discriminated element union, a discriminated projection envelope, and its own\n * family key set, whatever its cardinality.\n */\nexport type VariantRelationState = VariantToOneState | VariantToManyState;\n\n/**\n * The predicate for {@link VariantRelationState} — one declared property read,\n * spelled once so both halves of a target-domain partition ask it the same way.\n * It classifies a declaration; it resolves nothing.\n */\nexport const isVariantRelationState = (\n state: RelationState\n): state is VariantRelationState => state.target.kind === \"variants\";\n\n// =============================================================================\n// INTERNAL ACCESSOR\n// =============================================================================\n\n/**\n * The internal accessor every terminal exposes under `\"~\"`.\n *\n * `settleTarget` is the source-independent lazy once-cell required by the\n * declaration algebra: the first caller settles a target's raw getter return OR\n * one normalized `Error`, and every later consumer — in this schema graph or\n * another one reusing the same immutable terminal — observes that same outcome.\n * It is derived cache state, not a declaration fact; the resolver decides\n * whether a settled return is a registered model and owns the contextual\n * diagnostic, so nothing model-specific is cached here.\n */\nexport type RelationInternal<State> = {\n readonly state: State;\n /** Variant key for a variant target; omitted for a model target. */\n readonly settleTarget: (variantKey?: string) => unknown;\n};\n\n/** Any relation terminal, matched by its internal brand. */\nexport type AnyRelation = { readonly \"~\": RelationInternal<RelationState> };\n\n/**\n * The identity of a contextual relation reference.\n *\n * A relation object does not store its source model: `.extends()` may reuse one\n * terminal under more than one model or key, so the source model plus the field\n * key is the whole identity and the declaration is read from that model's\n * canonical relation map rather than copied into the identity.\n */\nexport type RelationSlot = {\n readonly source: AnyModel;\n readonly field: string;\n};\n"],"mappings":"yCA4OA,MAAa,uBACX,GACkC,EAAM,OAAO,OAAS"}
@@ -1,5 +1,5 @@
1
- import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t}from"./base-AdXAoy6l.mjs";import{n}from"./suppressed-failure-BwULh-8h.mjs";import{a as r}from"./validator-X9-bwtRo.mjs";import{existsSync as i}from"node:fs";import{resolve as a}from"node:path";import{loadEnvFile as o}from"node:process";import{createJiti as s}from"jiti";const c=[`viborm.config.ts`,`viborm.config.mts`,`viborm.config.js`,`viborm.config.mjs`];function findFile(e,t){for(let n of t){let t=a(e,n);if(i(t))return t}return null}function failCli(e,n=!1){let r=t(e),i=e instanceof Error?e.message:typeof e==`string`?e:`CLI operation failed`,a=r?e.code:void 0,o=a?.startsWith(`V11`)?Number(a.slice(1))-11e3+10:r?2:1;process.stderr.write(n?`${JSON.stringify({error:r?e.toJSON():{name:e instanceof Error?e.name:`Error`,message:i},exitCode:o})}\n`:`${a?`[${a}] `:``}${i}\n`),process.exit(o)}async function finishCli(e,t,r=!1){let i=t;try{await e?.$disconnect()}catch(e){i={value:t?n(t.value,e):e}}i&&(r?failCli(i.value,!0):failCli(i.value))}async function runCli(e,t,n){let r,i;try{let t=await loadConfig(e);r=t.client,await n(t)}catch(e){i={value:e}}finally{await finishCli(r,i,t)}}function printJson(e,t){if(t){process.stdout.write(`${JSON.stringify(e,null,2)}\n`);return}let n=[],render=(e,t=``)=>{if(Array.isArray(e)){for(let r of e)n.push(`${t}-`),render(r,`${t} `);e.length===0&&n.push(`${t}(none)`)}else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))typeof i==`object`&&i?(n.push(`${t}${r}:`),render(i,`${t} `)):n.push(`${t}${r}: ${String(i)}`);else n.push(`${t}${String(e)}`)};render(e),process.stdout.write(`${n.join(`
2
- `)}\n`)}async function loadConfig(e={}){let t=process.cwd(),n=a(t,`.env`);i(n)&&o(n);let s=e.config?a(t,e.config):findFile(t,c);if(!(s&&i(s))){let t=e.config?[e.config]:c;throw Error(`Could not find VibORM configuration file.
1
+ import{n as e}from"./chunk-BuuaeEvq.mjs";import{i as t}from"./base-D3m1S7Uc.mjs";import{a as n}from"./validator-DgffZq9C.mjs";import{n as r}from"./suppressed-failure-Bdo2aK81.mjs";import{existsSync as i}from"node:fs";import{resolve as a}from"node:path";import{loadEnvFile as o}from"node:process";import{createJiti as s}from"jiti";const c=[`viborm.config.ts`,`viborm.config.mts`,`viborm.config.js`,`viborm.config.mjs`];function findFile(e,t){for(let n of t){let t=a(e,n);if(i(t))return t}return null}function failCli(e,n=!1){let r=t(e),i=e instanceof Error?e.message:typeof e==`string`?e:`CLI operation failed`,a=r?e.code:void 0,o=a?.startsWith(`V11`)?Number(a.slice(1))-11e3+10:r?2:1;process.stderr.write(n?`${JSON.stringify({error:r?e.toJSON():{name:e instanceof Error?e.name:`Error`,message:i},exitCode:o})}\n`:`${a?`[${a}] `:``}${i}\n`),process.exit(o)}async function finishCli(e,t,n=!1){let i=t;try{await e?.$disconnect()}catch(e){i={value:t?r(t.value,e):e}}i&&(n?failCli(i.value,!0):failCli(i.value))}async function runCli(e,t,n){let r,i;try{let t=await loadConfig(e);r=t.client,await n(t)}catch(e){i={value:e}}finally{await finishCli(r,i,t)}}function printJson(e,t){if(t){process.stdout.write(`${JSON.stringify(e,null,2)}\n`);return}let n=[],render=(e,t=``)=>{if(Array.isArray(e)){for(let r of e)n.push(`${t}-`),render(r,`${t} `);e.length===0&&n.push(`${t}(none)`)}else if(typeof e==`object`&&e)for(let[r,i]of Object.entries(e))typeof i==`object`&&i?(n.push(`${t}${r}:`),render(i,`${t} `)):n.push(`${t}${r}: ${String(i)}`);else n.push(`${t}${String(e)}`)};render(e),process.stdout.write(`${n.join(`
2
+ `)}\n`)}async function loadConfig(e={}){let t=process.cwd(),r=a(t,`.env`);i(r)&&o(r);let s=e.config?a(t,e.config):findFile(t,c);if(!(s&&i(s))){let t=e.config?[e.config]:c;throw Error(`Could not find VibORM configuration file.
3
3
 
4
4
  Searched for:\n${t.map(e=>` - ${e}`).join(`
5
5
  `)}\n\nCreate a viborm.config.ts file:
@@ -22,5 +22,5 @@ Searched for:\n${t.map(e=>` - ${e}`).join(`
22
22
  id: s.string().id(),
23
23
  name: s.string(),
24
24
  });
25
- `);return e.skipValidation||r(p),{client:u.client,driver:d,models:p,migrations:u.migrations}}function loadCliModule(e){return s(e,{tsconfigPaths:!0,interopDefault:!0}).import(e)}function extractModels(e){let t={};for(let[n,r]of Object.entries(e))isModel(r)&&(t[n]=r);return t}function isModel(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`~`);if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`state`);return typeof n==`object`&&!!n&&`scalars`in n}function isValidClient(e){return e===null||typeof e!=`object`&&typeof e!=`function`?!1:Reflect.get(e,`$driver`)!==void 0&&Reflect.get(e,`$schema`)!==void 0}function defineConfig(e){return e}export{runCli as i,loadCliModule as n,printJson as r,defineConfig as t};
26
- //# sourceMappingURL=utils-CZNaOZR7.mjs.map
25
+ `);return e.skipValidation||n(p),{client:u.client,driver:d,models:p,migrations:u.migrations}}function loadCliModule(e){return s(e,{tsconfigPaths:!0,interopDefault:!0}).import(e)}function extractModels(e){let t={};for(let[n,r]of Object.entries(e))isModel(r)&&(t[n]=r);return t}function isModel(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`~`);if(typeof t!=`object`||!t)return!1;let n=Reflect.get(t,`state`);return typeof n==`object`&&!!n&&`scalars`in n}function isValidClient(e){return e===null||typeof e!=`object`&&typeof e!=`function`?!1:Reflect.get(e,`$driver`)!==void 0&&Reflect.get(e,`$schema`)!==void 0}function defineConfig(e){return e}export{runCli as i,loadCliModule as n,printJson as r,defineConfig as t};
26
+ //# sourceMappingURL=utils-CtFUE8UN.mjs.map