@xtandard/kit 0.0.0-stage → 0.1.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 (402) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -2
  3. package/bin/xtandard-kit.mjs +3 -0
  4. package/dist/base-path-BJugWLNO.cjs +42 -0
  5. package/dist/base-path-BJugWLNO.cjs.map +1 -0
  6. package/dist/base-path-CDb4In5E.mjs +31 -0
  7. package/dist/base-path-CDb4In5E.mjs.map +1 -0
  8. package/dist/basic-Qtriv0xS.mjs +176 -0
  9. package/dist/basic-Qtriv0xS.mjs.map +1 -0
  10. package/dist/basic-ZaO92-lB.cjs +199 -0
  11. package/dist/basic-ZaO92-lB.cjs.map +1 -0
  12. package/dist/bin.cjs +126 -0
  13. package/dist/bin.cjs.map +1 -0
  14. package/dist/bin.d.cts +20 -0
  15. package/dist/bin.d.mts +20 -0
  16. package/dist/bin.mjs +125 -0
  17. package/dist/bin.mjs.map +1 -0
  18. package/dist/cas-CuPSaXBV.cjs +23 -0
  19. package/dist/cas-CuPSaXBV.cjs.map +1 -0
  20. package/dist/cas-CzA-yECx.mjs +18 -0
  21. package/dist/cas-CzA-yECx.mjs.map +1 -0
  22. package/dist/chunk-DakpK96I.cjs +43 -0
  23. package/dist/contract-B3UPXXLx.d.cts +30 -0
  24. package/dist/contract-B3UPXXLx.d.mts +30 -0
  25. package/dist/contract-BDPNvjtp.d.mts +64 -0
  26. package/dist/contract-BEdfGTPs.mjs +85 -0
  27. package/dist/contract-BEdfGTPs.mjs.map +1 -0
  28. package/dist/contract-BIVzAn4f.d.cts +64 -0
  29. package/dist/contract-BvgtswLX.d.cts +75 -0
  30. package/dist/contract-BvgtswLX.d.mts +75 -0
  31. package/dist/contract-DUj9P3Vt.d.cts +72 -0
  32. package/dist/contract-DUj9P3Vt.d.mts +72 -0
  33. package/dist/contract-wAEMDmYG.cjs +132 -0
  34. package/dist/contract-wAEMDmYG.cjs.map +1 -0
  35. package/dist/drizzle-BElCHWri.d.mts +115 -0
  36. package/dist/drizzle-BXaQXCr0.cjs +232 -0
  37. package/dist/drizzle-BXaQXCr0.cjs.map +1 -0
  38. package/dist/drizzle-CEpahWQB.d.cts +115 -0
  39. package/dist/drizzle-DxnelsPT.mjs +197 -0
  40. package/dist/drizzle-DxnelsPT.mjs.map +1 -0
  41. package/dist/duration-7WpAK-xe.mjs +52 -0
  42. package/dist/duration-7WpAK-xe.mjs.map +1 -0
  43. package/dist/duration-DVA0Fzkx.cjs +63 -0
  44. package/dist/duration-DVA0Fzkx.cjs.map +1 -0
  45. package/dist/duration-FPwbmWIU.d.cts +35 -0
  46. package/dist/duration-FPwbmWIU.d.mts +35 -0
  47. package/dist/entry-adapters-bun.cjs +10 -0
  48. package/dist/entry-adapters-bun.cjs.map +1 -0
  49. package/dist/entry-adapters-bun.d.cts +10 -0
  50. package/dist/entry-adapters-bun.d.mts +10 -0
  51. package/dist/entry-adapters-bun.mjs +9 -0
  52. package/dist/entry-adapters-bun.mjs.map +1 -0
  53. package/dist/entry-adapters-elysia.cjs +54 -0
  54. package/dist/entry-adapters-elysia.cjs.map +1 -0
  55. package/dist/entry-adapters-elysia.d.cts +38 -0
  56. package/dist/entry-adapters-elysia.d.mts +38 -0
  57. package/dist/entry-adapters-elysia.mjs +53 -0
  58. package/dist/entry-adapters-elysia.mjs.map +1 -0
  59. package/dist/entry-adapters-express.cjs +27 -0
  60. package/dist/entry-adapters-express.cjs.map +1 -0
  61. package/dist/entry-adapters-express.d.cts +24 -0
  62. package/dist/entry-adapters-express.d.mts +24 -0
  63. package/dist/entry-adapters-express.mjs +26 -0
  64. package/dist/entry-adapters-express.mjs.map +1 -0
  65. package/dist/entry-adapters-hono.cjs +33 -0
  66. package/dist/entry-adapters-hono.cjs.map +1 -0
  67. package/dist/entry-adapters-hono.d.cts +36 -0
  68. package/dist/entry-adapters-hono.d.mts +36 -0
  69. package/dist/entry-adapters-hono.mjs +30 -0
  70. package/dist/entry-adapters-hono.mjs.map +1 -0
  71. package/dist/entry-adapters-next.cjs +19 -0
  72. package/dist/entry-adapters-next.cjs.map +1 -0
  73. package/dist/entry-adapters-next.d.cts +35 -0
  74. package/dist/entry-adapters-next.d.mts +35 -0
  75. package/dist/entry-adapters-next.mjs +18 -0
  76. package/dist/entry-adapters-next.mjs.map +1 -0
  77. package/dist/entry-adapters-node.cjs +7 -0
  78. package/dist/entry-adapters-node.d.cts +2 -0
  79. package/dist/entry-adapters-node.d.mts +2 -0
  80. package/dist/entry-adapters-node.mjs +2 -0
  81. package/dist/entry-auth-basic.cjs +5 -0
  82. package/dist/entry-auth-basic.d.cts +83 -0
  83. package/dist/entry-auth-basic.d.mts +83 -0
  84. package/dist/entry-auth-basic.mjs +2 -0
  85. package/dist/entry-auth-delegated.cjs +28 -0
  86. package/dist/entry-auth-delegated.cjs.map +1 -0
  87. package/dist/entry-auth-delegated.d.cts +36 -0
  88. package/dist/entry-auth-delegated.d.mts +36 -0
  89. package/dist/entry-auth-delegated.mjs +27 -0
  90. package/dist/entry-auth-delegated.mjs.map +1 -0
  91. package/dist/entry-auth-none.cjs +4 -0
  92. package/dist/entry-auth-none.d.cts +25 -0
  93. package/dist/entry-auth-none.d.mts +25 -0
  94. package/dist/entry-auth-none.mjs +2 -0
  95. package/dist/entry-auth.cjs +0 -0
  96. package/dist/entry-auth.d.cts +2 -0
  97. package/dist/entry-auth.d.mts +2 -0
  98. package/dist/entry-auth.mjs +1 -0
  99. package/dist/entry-authorization-delegated.cjs +27 -0
  100. package/dist/entry-authorization-delegated.cjs.map +1 -0
  101. package/dist/entry-authorization-delegated.d.cts +31 -0
  102. package/dist/entry-authorization-delegated.d.mts +31 -0
  103. package/dist/entry-authorization-delegated.mjs +26 -0
  104. package/dist/entry-authorization-delegated.mjs.map +1 -0
  105. package/dist/entry-authorization-none.cjs +3 -0
  106. package/dist/entry-authorization-none.d.cts +18 -0
  107. package/dist/entry-authorization-none.d.mts +18 -0
  108. package/dist/entry-authorization-none.mjs +2 -0
  109. package/dist/entry-authorization-roles.cjs +3 -0
  110. package/dist/entry-authorization-roles.d.cts +2 -0
  111. package/dist/entry-authorization-roles.d.mts +2 -0
  112. package/dist/entry-authorization-roles.mjs +2 -0
  113. package/dist/entry-authorization.cjs +35 -0
  114. package/dist/entry-authorization.cjs.map +1 -0
  115. package/dist/entry-authorization.d.cts +2 -0
  116. package/dist/entry-authorization.d.mts +2 -0
  117. package/dist/entry-authorization.mjs +34 -0
  118. package/dist/entry-authorization.mjs.map +1 -0
  119. package/dist/entry-build.cjs +481 -0
  120. package/dist/entry-build.cjs.map +1 -0
  121. package/dist/entry-build.d.cts +355 -0
  122. package/dist/entry-build.d.mts +355 -0
  123. package/dist/entry-build.mjs +460 -0
  124. package/dist/entry-build.mjs.map +1 -0
  125. package/dist/entry-cli.cjs +368 -0
  126. package/dist/entry-cli.cjs.map +1 -0
  127. package/dist/entry-cli.d.cts +275 -0
  128. package/dist/entry-cli.d.mts +275 -0
  129. package/dist/entry-cli.mjs +355 -0
  130. package/dist/entry-cli.mjs.map +1 -0
  131. package/dist/entry-drizzle-mysql.cjs +36 -0
  132. package/dist/entry-drizzle-mysql.cjs.map +1 -0
  133. package/dist/entry-drizzle-mysql.d.cts +55 -0
  134. package/dist/entry-drizzle-mysql.d.mts +55 -0
  135. package/dist/entry-drizzle-mysql.mjs +34 -0
  136. package/dist/entry-drizzle-mysql.mjs.map +1 -0
  137. package/dist/entry-drizzle-pg.cjs +38 -0
  138. package/dist/entry-drizzle-pg.cjs.map +1 -0
  139. package/dist/entry-drizzle-pg.d.cts +78 -0
  140. package/dist/entry-drizzle-pg.d.mts +78 -0
  141. package/dist/entry-drizzle-pg.mjs +36 -0
  142. package/dist/entry-drizzle-pg.mjs.map +1 -0
  143. package/dist/entry-drizzle-sqlite.cjs +20 -0
  144. package/dist/entry-drizzle-sqlite.cjs.map +1 -0
  145. package/dist/entry-drizzle-sqlite.d.cts +22 -0
  146. package/dist/entry-drizzle-sqlite.d.mts +22 -0
  147. package/dist/entry-drizzle-sqlite.mjs +19 -0
  148. package/dist/entry-drizzle-sqlite.mjs.map +1 -0
  149. package/dist/entry-hooks-log.cjs +32 -0
  150. package/dist/entry-hooks-log.cjs.map +1 -0
  151. package/dist/entry-hooks-log.d.cts +36 -0
  152. package/dist/entry-hooks-log.d.mts +36 -0
  153. package/dist/entry-hooks-log.mjs +31 -0
  154. package/dist/entry-hooks-log.mjs.map +1 -0
  155. package/dist/entry-hooks.cjs +10 -0
  156. package/dist/entry-hooks.d.cts +2 -0
  157. package/dist/entry-hooks.d.mts +2 -0
  158. package/dist/entry-hooks.mjs +2 -0
  159. package/dist/entry-server-router.cjs +235 -0
  160. package/dist/entry-server-router.cjs.map +1 -0
  161. package/dist/entry-server-router.d.cts +193 -0
  162. package/dist/entry-server-router.d.mts +193 -0
  163. package/dist/entry-server-router.mjs +228 -0
  164. package/dist/entry-server-router.mjs.map +1 -0
  165. package/dist/entry-server.cjs +344 -0
  166. package/dist/entry-server.cjs.map +1 -0
  167. package/dist/entry-server.d.cts +230 -0
  168. package/dist/entry-server.d.mts +230 -0
  169. package/dist/entry-server.mjs +322 -0
  170. package/dist/entry-server.mjs.map +1 -0
  171. package/dist/entry-site.cjs +1083 -0
  172. package/dist/entry-site.cjs.map +1 -0
  173. package/dist/entry-site.d.cts +336 -0
  174. package/dist/entry-site.d.mts +336 -0
  175. package/dist/entry-site.mjs +1060 -0
  176. package/dist/entry-site.mjs.map +1 -0
  177. package/dist/entry-storage-cloudflare-kv.cjs +51 -0
  178. package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
  179. package/dist/entry-storage-cloudflare-kv.d.cts +52 -0
  180. package/dist/entry-storage-cloudflare-kv.d.mts +52 -0
  181. package/dist/entry-storage-cloudflare-kv.mjs +50 -0
  182. package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
  183. package/dist/entry-storage-drizzle-internals.cjs +6 -0
  184. package/dist/entry-storage-drizzle-internals.d.cts +2 -0
  185. package/dist/entry-storage-drizzle-internals.d.mts +2 -0
  186. package/dist/entry-storage-drizzle-internals.mjs +2 -0
  187. package/dist/entry-storage-drizzle.cjs +4 -0
  188. package/dist/entry-storage-drizzle.d.cts +3 -0
  189. package/dist/entry-storage-drizzle.d.mts +3 -0
  190. package/dist/entry-storage-drizzle.mjs +2 -0
  191. package/dist/entry-storage-file.cjs +306 -0
  192. package/dist/entry-storage-file.cjs.map +1 -0
  193. package/dist/entry-storage-file.d.cts +76 -0
  194. package/dist/entry-storage-file.d.mts +76 -0
  195. package/dist/entry-storage-file.mjs +301 -0
  196. package/dist/entry-storage-file.mjs.map +1 -0
  197. package/dist/entry-storage-libsql-internals.cjs +7 -0
  198. package/dist/entry-storage-libsql-internals.d.cts +3 -0
  199. package/dist/entry-storage-libsql-internals.d.mts +3 -0
  200. package/dist/entry-storage-libsql-internals.mjs +3 -0
  201. package/dist/entry-storage-libsql.cjs +3 -0
  202. package/dist/entry-storage-libsql.d.cts +2 -0
  203. package/dist/entry-storage-libsql.d.mts +2 -0
  204. package/dist/entry-storage-libsql.mjs +2 -0
  205. package/dist/entry-storage-memory.cjs +78 -0
  206. package/dist/entry-storage-memory.cjs.map +1 -0
  207. package/dist/entry-storage-memory.d.cts +35 -0
  208. package/dist/entry-storage-memory.d.mts +35 -0
  209. package/dist/entry-storage-memory.mjs +77 -0
  210. package/dist/entry-storage-memory.mjs.map +1 -0
  211. package/dist/entry-storage-mongodb-internals.cjs +5 -0
  212. package/dist/entry-storage-mongodb-internals.d.cts +2 -0
  213. package/dist/entry-storage-mongodb-internals.d.mts +2 -0
  214. package/dist/entry-storage-mongodb-internals.mjs +2 -0
  215. package/dist/entry-storage-mongodb.cjs +3 -0
  216. package/dist/entry-storage-mongodb.d.cts +2 -0
  217. package/dist/entry-storage-mongodb.d.mts +2 -0
  218. package/dist/entry-storage-mongodb.mjs +2 -0
  219. package/dist/entry-storage-postgres-internals.cjs +6 -0
  220. package/dist/entry-storage-postgres-internals.d.cts +2 -0
  221. package/dist/entry-storage-postgres-internals.d.mts +2 -0
  222. package/dist/entry-storage-postgres-internals.mjs +2 -0
  223. package/dist/entry-storage-postgres.cjs +4 -0
  224. package/dist/entry-storage-postgres.d.cts +2 -0
  225. package/dist/entry-storage-postgres.d.mts +2 -0
  226. package/dist/entry-storage-postgres.mjs +2 -0
  227. package/dist/entry-storage-redis-internals.cjs +7 -0
  228. package/dist/entry-storage-redis-internals.d.cts +2 -0
  229. package/dist/entry-storage-redis-internals.d.mts +2 -0
  230. package/dist/entry-storage-redis-internals.mjs +2 -0
  231. package/dist/entry-storage-redis.cjs +4 -0
  232. package/dist/entry-storage-redis.d.cts +2 -0
  233. package/dist/entry-storage-redis.d.mts +2 -0
  234. package/dist/entry-storage-redis.mjs +2 -0
  235. package/dist/entry-storage-sqlite-internals.cjs +7 -0
  236. package/dist/entry-storage-sqlite-internals.d.cts +3 -0
  237. package/dist/entry-storage-sqlite-internals.d.mts +3 -0
  238. package/dist/entry-storage-sqlite-internals.mjs +3 -0
  239. package/dist/entry-storage-sqlite.cjs +3 -0
  240. package/dist/entry-storage-sqlite.d.cts +2 -0
  241. package/dist/entry-storage-sqlite.d.mts +2 -0
  242. package/dist/entry-storage-sqlite.mjs +2 -0
  243. package/dist/entry-storage-testing.cjs +801 -0
  244. package/dist/entry-storage-testing.cjs.map +1 -0
  245. package/dist/entry-storage-testing.d.cts +150 -0
  246. package/dist/entry-storage-testing.d.mts +150 -0
  247. package/dist/entry-storage-testing.mjs +790 -0
  248. package/dist/entry-storage-testing.mjs.map +1 -0
  249. package/dist/entry-storage-unstorage.cjs +78 -0
  250. package/dist/entry-storage-unstorage.cjs.map +1 -0
  251. package/dist/entry-storage-unstorage.d.cts +30 -0
  252. package/dist/entry-storage-unstorage.d.mts +30 -0
  253. package/dist/entry-storage-unstorage.mjs +77 -0
  254. package/dist/entry-storage-unstorage.mjs.map +1 -0
  255. package/dist/entry-storage.cjs +114 -0
  256. package/dist/entry-storage.cjs.map +1 -0
  257. package/dist/entry-storage.d.cts +152 -0
  258. package/dist/entry-storage.d.mts +152 -0
  259. package/dist/entry-storage.mjs +91 -0
  260. package/dist/entry-storage.mjs.map +1 -0
  261. package/dist/entry-testing.cjs +79 -0
  262. package/dist/entry-testing.cjs.map +1 -0
  263. package/dist/entry-testing.d.cts +55 -0
  264. package/dist/entry-testing.d.mts +55 -0
  265. package/dist/entry-testing.mjs +77 -0
  266. package/dist/entry-testing.mjs.map +1 -0
  267. package/dist/entry-tokens.cjs +4 -0
  268. package/dist/entry-tokens.d.cts +85 -0
  269. package/dist/entry-tokens.d.mts +85 -0
  270. package/dist/entry-tokens.mjs +2 -0
  271. package/dist/entry-ui-embed.cjs +131 -0
  272. package/dist/entry-ui-embed.cjs.map +1 -0
  273. package/dist/entry-ui-embed.d.cts +87 -0
  274. package/dist/entry-ui-embed.d.mts +87 -0
  275. package/dist/entry-ui-embed.mjs +127 -0
  276. package/dist/entry-ui-embed.mjs.map +1 -0
  277. package/dist/entry-ui.cjs +795 -0
  278. package/dist/entry-ui.cjs.map +1 -0
  279. package/dist/entry-ui.d.cts +574 -0
  280. package/dist/entry-ui.d.mts +574 -0
  281. package/dist/entry-ui.mjs +731 -0
  282. package/dist/entry-ui.mjs.map +1 -0
  283. package/dist/entry-util.cjs +145 -0
  284. package/dist/entry-util.cjs.map +1 -0
  285. package/dist/entry-util.d.cts +85 -0
  286. package/dist/entry-util.d.mts +85 -0
  287. package/dist/entry-util.mjs +130 -0
  288. package/dist/entry-util.mjs.map +1 -0
  289. package/dist/http-B_rTnLW9.cjs +235 -0
  290. package/dist/http-B_rTnLW9.cjs.map +1 -0
  291. package/dist/http-CxYM7kPT.d.mts +133 -0
  292. package/dist/http-DVdVI6kJ.mjs +164 -0
  293. package/dist/http-DVdVI6kJ.mjs.map +1 -0
  294. package/dist/http-XBVRk8uo.d.cts +133 -0
  295. package/dist/index.cjs +8 -0
  296. package/dist/index.cjs.map +1 -0
  297. package/dist/index.d.cts +6 -0
  298. package/dist/index.d.mts +6 -0
  299. package/dist/index.mjs +7 -0
  300. package/dist/index.mjs.map +1 -0
  301. package/dist/json-CCyzstIm.d.cts +44 -0
  302. package/dist/json-CCyzstIm.d.mts +44 -0
  303. package/dist/json-CM7TwYQ7.cjs +92 -0
  304. package/dist/json-CM7TwYQ7.cjs.map +1 -0
  305. package/dist/json-CmM1M5Kz.mjs +63 -0
  306. package/dist/json-CmM1M5Kz.mjs.map +1 -0
  307. package/dist/keys-Bwubabk0.mjs +73 -0
  308. package/dist/keys-Bwubabk0.mjs.map +1 -0
  309. package/dist/keys-DQrwxDKI.cjs +126 -0
  310. package/dist/keys-DQrwxDKI.cjs.map +1 -0
  311. package/dist/kv-sqlite-B6iTLOx2.d.cts +20 -0
  312. package/dist/kv-sqlite-CHOdIMJ-.cjs +77 -0
  313. package/dist/kv-sqlite-CHOdIMJ-.cjs.map +1 -0
  314. package/dist/kv-sqlite-DIIPfflJ.mjs +66 -0
  315. package/dist/kv-sqlite-DIIPfflJ.mjs.map +1 -0
  316. package/dist/kv-sqlite-Tx4UedJs.d.mts +20 -0
  317. package/dist/libsql-0160BubR.d.mts +65 -0
  318. package/dist/libsql-BZmRZIqt.d.cts +65 -0
  319. package/dist/libsql-CiBfVtbS.cjs +103 -0
  320. package/dist/libsql-CiBfVtbS.cjs.map +1 -0
  321. package/dist/libsql-CkOjQINi.mjs +86 -0
  322. package/dist/libsql-CkOjQINi.mjs.map +1 -0
  323. package/dist/mongodb--Cuj7V_9.cjs +150 -0
  324. package/dist/mongodb--Cuj7V_9.cjs.map +1 -0
  325. package/dist/mongodb-DGtsolQ2.d.cts +61 -0
  326. package/dist/mongodb-JMizy4Wg.mjs +127 -0
  327. package/dist/mongodb-JMizy4Wg.mjs.map +1 -0
  328. package/dist/mongodb-xGEU5Gwz.d.mts +61 -0
  329. package/dist/node-B1Djcwfi.d.cts +57 -0
  330. package/dist/node-B1Djcwfi.d.mts +57 -0
  331. package/dist/node-BYjocCbU.mjs +167 -0
  332. package/dist/node-BYjocCbU.mjs.map +1 -0
  333. package/dist/node-DFFqYRk-.cjs +201 -0
  334. package/dist/node-DFFqYRk-.cjs.map +1 -0
  335. package/dist/none-BEY7Kc_-.mjs +33 -0
  336. package/dist/none-BEY7Kc_-.mjs.map +1 -0
  337. package/dist/none-BoQ6-30P.cjs +33 -0
  338. package/dist/none-BoQ6-30P.cjs.map +1 -0
  339. package/dist/none-CHwVkQL-.cjs +49 -0
  340. package/dist/none-CHwVkQL-.cjs.map +1 -0
  341. package/dist/none-yu3qC47E.mjs +23 -0
  342. package/dist/none-yu3qC47E.mjs.map +1 -0
  343. package/dist/peer-BIjBFzwQ.cjs +56 -0
  344. package/dist/peer-BIjBFzwQ.cjs.map +1 -0
  345. package/dist/peer-CTHMzOdn.mjs +40 -0
  346. package/dist/peer-CTHMzOdn.mjs.map +1 -0
  347. package/dist/portal-container-CJIcau3B.mjs +610 -0
  348. package/dist/portal-container-CJIcau3B.mjs.map +1 -0
  349. package/dist/portal-container-Ca1NxrLE.cjs +774 -0
  350. package/dist/portal-container-Ca1NxrLE.cjs.map +1 -0
  351. package/dist/postgres-BJzxKBk0.d.cts +72 -0
  352. package/dist/postgres-CA8_XcAE.cjs +164 -0
  353. package/dist/postgres-CA8_XcAE.cjs.map +1 -0
  354. package/dist/postgres-RfQMgAsj.d.mts +72 -0
  355. package/dist/postgres-aDiBmNzr.mjs +135 -0
  356. package/dist/postgres-aDiBmNzr.mjs.map +1 -0
  357. package/dist/redis-B2AS4xAQ.cjs +259 -0
  358. package/dist/redis-B2AS4xAQ.cjs.map +1 -0
  359. package/dist/redis-B362ofBw.d.cts +159 -0
  360. package/dist/redis-CahNAVTW.d.mts +159 -0
  361. package/dist/redis-hdoKymfG.mjs +218 -0
  362. package/dist/redis-hdoKymfG.mjs.map +1 -0
  363. package/dist/roles-7JPrQXZa.mjs +46 -0
  364. package/dist/roles-7JPrQXZa.mjs.map +1 -0
  365. package/dist/roles-B_8QqJ3j.cjs +56 -0
  366. package/dist/roles-B_8QqJ3j.cjs.map +1 -0
  367. package/dist/roles-DLISB4T3.d.mts +41 -0
  368. package/dist/roles-DQbbtUPW.d.cts +41 -0
  369. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  370. package/dist/scope-css-BN3jf0ly.cjs +315 -0
  371. package/dist/scope-css-BN3jf0ly.cjs.map +1 -0
  372. package/dist/scope-css-BuJfRCsE.mjs +256 -0
  373. package/dist/scope-css-BuJfRCsE.mjs.map +1 -0
  374. package/dist/scoped-BRoE1W1x.cjs +175 -0
  375. package/dist/scoped-BRoE1W1x.cjs.map +1 -0
  376. package/dist/scoped-cFBbotCh.mjs +164 -0
  377. package/dist/scoped-cFBbotCh.mjs.map +1 -0
  378. package/dist/sqlite-B2g1JJz1.d.cts +47 -0
  379. package/dist/sqlite-BIPIlxfj.d.mts +47 -0
  380. package/dist/sqlite-BntoYaXZ.cjs +79 -0
  381. package/dist/sqlite-BntoYaXZ.cjs.map +1 -0
  382. package/dist/sqlite-DYJDcu7p.mjs +62 -0
  383. package/dist/sqlite-DYJDcu7p.mjs.map +1 -0
  384. package/dist/table-BrioFSra.d.cts +11 -0
  385. package/dist/table-BrioFSra.d.mts +11 -0
  386. package/dist/theme-context-DzZ1otaD.d.cts +270 -0
  387. package/dist/theme-context-J65pythD.d.mts +270 -0
  388. package/dist/ui/styles.css +239 -0
  389. package/dist/util-Dnj5T-yw.mjs +39 -0
  390. package/dist/util-Dnj5T-yw.mjs.map +1 -0
  391. package/dist/util-dAnTK9x-.cjs +74 -0
  392. package/dist/util-dAnTK9x-.cjs.map +1 -0
  393. package/dist/validation-B-atP968.mjs +191 -0
  394. package/dist/validation-B-atP968.mjs.map +1 -0
  395. package/dist/validation-BJifGoB2.d.mts +122 -0
  396. package/dist/validation-DLnzBVJr.cjs +258 -0
  397. package/dist/validation-DLnzBVJr.cjs.map +1 -0
  398. package/dist/validation-tfV2qhbD.d.cts +122 -0
  399. package/package.json +715 -4
  400. package/tsconfig/assets.d.ts +21 -0
  401. package/tsconfig/base.json +21 -0
  402. package/tsconfig/react.json +9 -0
@@ -0,0 +1,126 @@
1
+ //#region src/storage/contract.ts
2
+ /** Runtime feature-detection: does this storage implement `watch`? */
3
+ function isWatchable(storage) {
4
+ return typeof storage.watch === "function";
5
+ }
6
+ /**
7
+ * Runtime feature-detection: does this storage implement `transaction`?
8
+ *
9
+ * @deprecated No driver implements {@link TransactionalKvStorage}; kept for API compatibility.
10
+ */
11
+ function isTransactional(storage) {
12
+ return typeof storage.transaction === "function";
13
+ }
14
+ /** Runtime feature-detection: does this storage implement `compareAndSwap`? */
15
+ function isCompareAndSwap(storage) {
16
+ return typeof storage.compareAndSwap === "function";
17
+ }
18
+ //#endregion
19
+ //#region src/storage/keys.ts
20
+ /**
21
+ * Generic key-layout helpers. Products keep their own layouts (`whk/…`, `aud/…`); these are the
22
+ * pieces every layout reuses:
23
+ *
24
+ * - {@link encodeSegment} / {@link decodeSegment} escape a free-form segment so `/` and `~` cannot
25
+ * break the layout;
26
+ * - {@link lastSegment} reads a key's trailing segment back (decoded);
27
+ * - {@link padMillis} and {@link sortableLeaf} / {@link parseSortableLeaf} build zero-padded
28
+ * `<millis>~<id>` leaves whose lexicographic order is chronological on every backend.
29
+ *
30
+ * @module
31
+ */
32
+ /**
33
+ * Escape a free-form key segment: `encodeURIComponent`, plus `~` → `%7E` (`~` is the separator of
34
+ * {@link sortableLeaf}).
35
+ */
36
+ const encodeSegment = (segment) => encodeURIComponent(segment).replace(/~/g, "%7E");
37
+ /** Reverse {@link encodeSegment} (also decodes plain `encodeURIComponent` output). */
38
+ const decodeSegment = (segment) => decodeURIComponent(segment);
39
+ /** The trailing `/`-separated segment of `key`, decoded with {@link decodeSegment}. */
40
+ const lastSegment = (key) => decodeSegment(key.slice(key.lastIndexOf("/") + 1));
41
+ /**
42
+ * Zero-pad epoch milliseconds (default 13 digits, enough until the year 2286) so the
43
+ * lexicographic order of the strings is the numeric order. Negative values clamp to 0 and
44
+ * fractions are truncated.
45
+ */
46
+ const padMillis = (ms, width = 13) => String(Math.max(0, Math.trunc(ms))).padStart(width, "0");
47
+ /**
48
+ * A sortable leaf `<padded millis>~<id>`: listing a prefix and sorting the keys yields them in time
49
+ * order (ties broken by `id`). The `id` is used verbatim, so it must not contain `/`; encode
50
+ * free-form ids with {@link encodeSegment} first.
51
+ */
52
+ const sortableLeaf = (ms, id, width = 13) => `${padMillis(ms, width)}~${id}`;
53
+ /**
54
+ * Parse a {@link sortableLeaf} (or a key ending in one) back into `{ ms, id }`. Returns `null` when
55
+ * the trailing segment has no `~`, the millis are not a number, or the id is empty. The id is
56
+ * returned verbatim (not decoded).
57
+ */
58
+ function parseSortableLeaf(keyOrLeaf) {
59
+ const leaf = keyOrLeaf.slice(keyOrLeaf.lastIndexOf("/") + 1);
60
+ const sep = leaf.indexOf("~");
61
+ if (sep <= 0) return null;
62
+ const ms = Number(leaf.slice(0, sep));
63
+ const id = leaf.slice(sep + 1);
64
+ if (!Number.isFinite(ms) || id.length === 0) return null;
65
+ return {
66
+ ms,
67
+ id
68
+ };
69
+ }
70
+ //#endregion
71
+ Object.defineProperty(exports, "decodeSegment", {
72
+ enumerable: true,
73
+ get: function() {
74
+ return decodeSegment;
75
+ }
76
+ });
77
+ Object.defineProperty(exports, "encodeSegment", {
78
+ enumerable: true,
79
+ get: function() {
80
+ return encodeSegment;
81
+ }
82
+ });
83
+ Object.defineProperty(exports, "isCompareAndSwap", {
84
+ enumerable: true,
85
+ get: function() {
86
+ return isCompareAndSwap;
87
+ }
88
+ });
89
+ Object.defineProperty(exports, "isTransactional", {
90
+ enumerable: true,
91
+ get: function() {
92
+ return isTransactional;
93
+ }
94
+ });
95
+ Object.defineProperty(exports, "isWatchable", {
96
+ enumerable: true,
97
+ get: function() {
98
+ return isWatchable;
99
+ }
100
+ });
101
+ Object.defineProperty(exports, "lastSegment", {
102
+ enumerable: true,
103
+ get: function() {
104
+ return lastSegment;
105
+ }
106
+ });
107
+ Object.defineProperty(exports, "padMillis", {
108
+ enumerable: true,
109
+ get: function() {
110
+ return padMillis;
111
+ }
112
+ });
113
+ Object.defineProperty(exports, "parseSortableLeaf", {
114
+ enumerable: true,
115
+ get: function() {
116
+ return parseSortableLeaf;
117
+ }
118
+ });
119
+ Object.defineProperty(exports, "sortableLeaf", {
120
+ enumerable: true,
121
+ get: function() {
122
+ return sortableLeaf;
123
+ }
124
+ });
125
+
126
+ //# sourceMappingURL=keys-DQrwxDKI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys-DQrwxDKI.cjs","names":[],"sources":["../src/storage/contract.ts","../src/storage/keys.ts"],"sourcesContent":["/**\n * The key/value storage contract shared by every xtandard product. The base {@link KvStorage} is\n * intentionally tiny (four async methods) so users can bring their own backend. Optional\n * capabilities (`watch`, `compareAndSwap`) are separate interfaces that drivers may implement and\n * callers feature-detect with {@link isWatchable} / {@link isCompareAndSwap}.\n *\n * Products alias these under their own names (`type WebhooksStorage = KvStorage`, …).\n *\n * @module\n */\n\n/** The minimal key/value contract every storage backend must satisfy. */\nexport interface KvStorage {\n /** Read a value, or `null` if absent. */\n getItem<T>(key: string): Promise<T | null>;\n /** Write a value (overwriting any existing). */\n setItem<T>(key: string, value: T): Promise<void>;\n /** Delete a key (no-op if absent). */\n removeItem(key: string): Promise<void>;\n /** List all keys beginning with `prefix` (a plain, case-sensitive string prefix). */\n getKeys(prefix: string): Promise<string[]>;\n}\n\n/** A storage change event delivered to {@link WatchableKvStorage.watch} callbacks. */\nexport interface StorageChangeEvent {\n /** `update` for a write, `remove` for a delete. */\n type: \"update\" | \"remove\";\n /** The changed key. */\n key: string;\n}\n\n/** Storage that can push change notifications (e.g. Redis keyspace events, `fs.watch`). */\nexport interface WatchableKvStorage extends KvStorage {\n /** Subscribe to changes under `prefix`. Resolves to an unsubscribe function. */\n watch(prefix: string, callback: (event: StorageChangeEvent) => void): Promise<() => void>;\n}\n\n/**\n * Storage that supports atomic multi-key transactions.\n *\n * @deprecated Declared for API compatibility only: no driver implements it and nothing calls it.\n * Use {@link CompareAndSwapKvStorage} for optimistic concurrency.\n */\nexport interface TransactionalKvStorage extends KvStorage {\n /** Run `callback` atomically against a transactional view of the storage. */\n transaction<T>(callback: (tx: KvStorage) => Promise<T>): Promise<T>;\n}\n\n/** Input of {@link CompareAndSwapKvStorage.compareAndSwap}. */\nexport interface CompareAndSwapInput<T> {\n /** The key to swap. */\n key: string;\n /** The value the key must hold (structurally), or `null` to require that it is absent. */\n expected: T | null;\n /** The value to write when the expectation holds. */\n next: T;\n}\n\n/** Storage that supports optimistic concurrency via compare-and-swap. */\nexport interface CompareAndSwapKvStorage extends KvStorage {\n /**\n * Atomically write `next` when the key currently holds a value structurally equal to `expected`\n * (object key order ignored), or is absent when `expected` is `null`. Resolves `true` when the\n * write happened. Of several concurrent swaps from the same `expected`, exactly one wins.\n */\n compareAndSwap<T>(input: CompareAndSwapInput<T>): Promise<boolean>;\n}\n\n/** Runtime feature-detection: does this storage implement `watch`? */\nexport function isWatchable(storage: KvStorage): storage is WatchableKvStorage {\n return typeof (storage as Partial<WatchableKvStorage>).watch === \"function\";\n}\n\n/**\n * Runtime feature-detection: does this storage implement `transaction`?\n *\n * @deprecated No driver implements {@link TransactionalKvStorage}; kept for API compatibility.\n */\nexport function isTransactional(storage: KvStorage): storage is TransactionalKvStorage {\n return typeof (storage as Partial<TransactionalKvStorage>).transaction === \"function\";\n}\n\n/** Runtime feature-detection: does this storage implement `compareAndSwap`? */\nexport function isCompareAndSwap(storage: KvStorage): storage is CompareAndSwapKvStorage {\n return typeof (storage as Partial<CompareAndSwapKvStorage>).compareAndSwap === \"function\";\n}\n","/**\n * Generic key-layout helpers. Products keep their own layouts (`whk/…`, `aud/…`); these are the\n * pieces every layout reuses:\n *\n * - {@link encodeSegment} / {@link decodeSegment} escape a free-form segment so `/` and `~` cannot\n * break the layout;\n * - {@link lastSegment} reads a key's trailing segment back (decoded);\n * - {@link padMillis} and {@link sortableLeaf} / {@link parseSortableLeaf} build zero-padded\n * `<millis>~<id>` leaves whose lexicographic order is chronological on every backend.\n *\n * @module\n */\n\n/**\n * Escape a free-form key segment: `encodeURIComponent`, plus `~` → `%7E` (`~` is the separator of\n * {@link sortableLeaf}).\n */\nexport const encodeSegment = (segment: string): string =>\n encodeURIComponent(segment).replace(/~/g, \"%7E\");\n\n/** Reverse {@link encodeSegment} (also decodes plain `encodeURIComponent` output). */\nexport const decodeSegment = (segment: string): string => decodeURIComponent(segment);\n\n/** The trailing `/`-separated segment of `key`, decoded with {@link decodeSegment}. */\nexport const lastSegment = (key: string): string =>\n decodeSegment(key.slice(key.lastIndexOf(\"/\") + 1));\n\n/**\n * Zero-pad epoch milliseconds (default 13 digits, enough until the year 2286) so the\n * lexicographic order of the strings is the numeric order. Negative values clamp to 0 and\n * fractions are truncated.\n */\nexport const padMillis = (ms: number, width = 13): string =>\n String(Math.max(0, Math.trunc(ms))).padStart(width, \"0\");\n\n/**\n * A sortable leaf `<padded millis>~<id>`: listing a prefix and sorting the keys yields them in time\n * order (ties broken by `id`). The `id` is used verbatim, so it must not contain `/`; encode\n * free-form ids with {@link encodeSegment} first.\n */\nexport const sortableLeaf = (ms: number, id: string, width = 13): string =>\n `${padMillis(ms, width)}~${id}`;\n\n/**\n * Parse a {@link sortableLeaf} (or a key ending in one) back into `{ ms, id }`. Returns `null` when\n * the trailing segment has no `~`, the millis are not a number, or the id is empty. The id is\n * returned verbatim (not decoded).\n */\nexport function parseSortableLeaf(keyOrLeaf: string): { ms: number; id: string } | null {\n const leaf = keyOrLeaf.slice(keyOrLeaf.lastIndexOf(\"/\") + 1);\n const sep = leaf.indexOf(\"~\");\n if (sep <= 0) return null;\n const ms = Number(leaf.slice(0, sep));\n const id = leaf.slice(sep + 1);\n if (!Number.isFinite(ms) || id.length === 0) return null;\n return { ms, id };\n}\n"],"mappings":";;AAqEA,SAAgB,YAAY,SAAmD;CAC7E,OAAO,OAAQ,QAAwC,UAAU;AACnE;;;;;;AAOA,SAAgB,gBAAgB,SAAuD;CACrF,OAAO,OAAQ,QAA4C,gBAAgB;AAC7E;;AAGA,SAAgB,iBAAiB,SAAwD;CACvF,OAAO,OAAQ,QAA6C,mBAAmB;AACjF;;;;;;;;;;;;;;;;;;;ACpEA,MAAa,iBAAiB,YAC5B,mBAAmB,OAAO,EAAE,QAAQ,MAAM,KAAK;;AAGjD,MAAa,iBAAiB,YAA4B,mBAAmB,OAAO;;AAGpF,MAAa,eAAe,QAC1B,cAAc,IAAI,MAAM,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC;;;;;;AAOnD,MAAa,aAAa,IAAY,QAAQ,OAC5C,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC,EAAE,SAAS,OAAO,GAAG;;;;;;AAOzD,MAAa,gBAAgB,IAAY,IAAY,QAAQ,OAC3D,GAAG,UAAU,IAAI,KAAK,EAAE,GAAG;;;;;;AAO7B,SAAgB,kBAAkB,WAAsD;CACtF,MAAM,OAAO,UAAU,MAAM,UAAU,YAAY,GAAG,IAAI,CAAC;CAC3D,MAAM,MAAM,KAAK,QAAQ,GAAG;CAC5B,IAAI,OAAO,GAAG,OAAO;CACrB,MAAM,KAAK,OAAO,KAAK,MAAM,GAAG,GAAG,CAAC;CACpC,MAAM,KAAK,KAAK,MAAM,MAAM,CAAC;CAC7B,IAAI,CAAC,OAAO,SAAS,EAAE,KAAK,GAAG,WAAW,GAAG,OAAO;CACpD,OAAO;EAAE;EAAI;CAAG;AAClB"}
@@ -0,0 +1,20 @@
1
+ import { n as CompareAndSwapKvStorage } from "./contract-BvgtswLX.cjs";
2
+
3
+ //#region src/storage/kv-sqlite.d.ts
4
+ /** One row returned by an executor. */
5
+ type SqliteRow = Record<string, unknown>;
6
+ /** The tiny async SQL surface the core needs (positional `?` parameters). */
7
+ interface SqliteExecutor {
8
+ /** Run a statement and return its rows (empty for statements without `RETURNING`). */
9
+ all(sql: string, args: unknown[]): Promise<SqliteRow[]>;
10
+ }
11
+ /** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */
12
+ declare const sqliteKvSchema: (table: string) => string;
13
+ /**
14
+ * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the
15
+ * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.
16
+ */
17
+ declare function sqliteKvStorage(table: string, exec: () => Promise<SqliteExecutor>): CompareAndSwapKvStorage;
18
+ //#endregion
19
+ export { sqliteKvStorage as i, SqliteRow as n, sqliteKvSchema as r, SqliteExecutor as t };
20
+ //# sourceMappingURL=kv-sqlite-B6iTLOx2.d.cts.map
@@ -0,0 +1,77 @@
1
+ const require_util = require("./util-dAnTK9x-.cjs");
2
+ const require_json = require("./json-CM7TwYQ7.cjs");
3
+ const require_cas = require("./cas-CuPSaXBV.cjs");
4
+ //#region src/storage/kv-sqlite.ts
5
+ /**
6
+ * The SQLite-dialect key/value core shared by the `bun:sqlite` and libSQL drivers, exported from
7
+ * their `…/internals` subpaths (semi-public, ADR 0004).
8
+ *
9
+ * - Values are written as **canonical JSON** text (object keys sorted), so `compareAndSwap` is one
10
+ * `UPDATE … WHERE key = ? AND value = ?`. A row written before canonicalisation (unsorted keys)
11
+ * misses that fast path; the swap then reads the row, compares it structurally and swaps on the
12
+ * exact stored text, with bounded retries (ADR 0005).
13
+ * - `getKeys` uses `GLOB` (case-sensitive and index-usable; SQLite's `LIKE` folds ASCII case) with
14
+ * the prefix's glob metacharacters escaped, plus an exact `startsWith` filter.
15
+ *
16
+ * @module
17
+ */
18
+ /** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */
19
+ const sqliteKvSchema = (table) => `CREATE TABLE IF NOT EXISTS ${require_util.assertIdentifier(table)} (key TEXT PRIMARY KEY, value TEXT NOT NULL)`;
20
+ /**
21
+ * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the
22
+ * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.
23
+ */
24
+ function sqliteKvStorage(table, exec) {
25
+ require_util.assertIdentifier(table);
26
+ return {
27
+ async getItem(key) {
28
+ const value = (await (await exec()).all(`SELECT value FROM ${table} WHERE key = ?`, [key]))[0]?.value;
29
+ return typeof value === "string" ? JSON.parse(value) : null;
30
+ },
31
+ async setItem(key, value) {
32
+ await (await exec()).all(`INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, [key, require_json.canonicalJson(value)]);
33
+ },
34
+ async removeItem(key) {
35
+ await (await exec()).all(`DELETE FROM ${table} WHERE key = ?`, [key]);
36
+ },
37
+ async getKeys(prefix) {
38
+ return (await (await exec()).all(`SELECT key FROM ${table} WHERE key GLOB ?`, [`${require_util.escapeGlob(prefix)}*`])).map((r) => String(r.key)).filter((key) => key.startsWith(prefix));
39
+ },
40
+ async compareAndSwap(input) {
41
+ const db = await exec();
42
+ const next = require_json.canonicalJson(input.next);
43
+ const swap = async (current) => (await db.all(`UPDATE ${table} SET value = ? WHERE key = ? AND value = ? RETURNING key`, [
44
+ next,
45
+ input.key,
46
+ current
47
+ ])).length === 1;
48
+ if (input.expected === null) return (await db.all(`INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING RETURNING key`, [input.key, next])).length === 1;
49
+ return require_cas.swapWithFallback(input.expected, {
50
+ fast: () => swap(require_json.canonicalJson(input.expected)),
51
+ async read() {
52
+ const raw = (await db.all(`SELECT value FROM ${table} WHERE key = ?`, [input.key]))[0]?.value;
53
+ return typeof raw === "string" ? {
54
+ raw,
55
+ value: JSON.parse(raw)
56
+ } : null;
57
+ },
58
+ swapRaw: swap
59
+ });
60
+ }
61
+ };
62
+ }
63
+ //#endregion
64
+ Object.defineProperty(exports, "sqliteKvSchema", {
65
+ enumerable: true,
66
+ get: function() {
67
+ return sqliteKvSchema;
68
+ }
69
+ });
70
+ Object.defineProperty(exports, "sqliteKvStorage", {
71
+ enumerable: true,
72
+ get: function() {
73
+ return sqliteKvStorage;
74
+ }
75
+ });
76
+
77
+ //# sourceMappingURL=kv-sqlite-CHOdIMJ-.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv-sqlite-CHOdIMJ-.cjs","names":["assertIdentifier","canonicalJson","escapeGlob","swapWithFallback"],"sources":["../src/storage/kv-sqlite.ts"],"sourcesContent":["/**\n * The SQLite-dialect key/value core shared by the `bun:sqlite` and libSQL drivers, exported from\n * their `…/internals` subpaths (semi-public, ADR 0004).\n *\n * - Values are written as **canonical JSON** text (object keys sorted), so `compareAndSwap` is one\n * `UPDATE … WHERE key = ? AND value = ?`. A row written before canonicalisation (unsorted keys)\n * misses that fast path; the swap then reads the row, compares it structurally and swaps on the\n * exact stored text, with bounded retries (ADR 0005).\n * - `getKeys` uses `GLOB` (case-sensitive and index-usable; SQLite's `LIKE` folds ASCII case) with\n * the prefix's glob metacharacters escaped, plus an exact `startsWith` filter.\n *\n * @module\n */\n\nimport { canonicalJson } from \"../internal/json.ts\";\nimport { swapWithFallback } from \"./cas.ts\";\nimport type { CompareAndSwapInput, CompareAndSwapKvStorage } from \"./contract.ts\";\nimport { assertIdentifier, escapeGlob } from \"./util.ts\";\n\n/** One row returned by an executor. */\nexport type SqliteRow = Record<string, unknown>;\n\n/** The tiny async SQL surface the core needs (positional `?` parameters). */\nexport interface SqliteExecutor {\n /** Run a statement and return its rows (empty for statements without `RETURNING`). */\n all(sql: string, args: unknown[]): Promise<SqliteRow[]>;\n}\n\n/** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */\nexport const sqliteKvSchema = (table: string): string =>\n `CREATE TABLE IF NOT EXISTS ${assertIdentifier(table)} (key TEXT PRIMARY KEY, value TEXT NOT NULL)`;\n\n/**\n * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the\n * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.\n */\nexport function sqliteKvStorage(\n table: string,\n exec: () => Promise<SqliteExecutor>,\n): CompareAndSwapKvStorage {\n assertIdentifier(table);\n return {\n async getItem<T>(key: string): Promise<T | null> {\n const rows = await (await exec()).all(`SELECT value FROM ${table} WHERE key = ?`, [key]);\n const value = rows[0]?.value;\n return typeof value === \"string\" ? (JSON.parse(value) as T) : null;\n },\n\n async setItem<T>(key: string, value: T): Promise<void> {\n await (\n await exec()\n ).all(\n `INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`,\n [key, canonicalJson(value)],\n );\n },\n\n async removeItem(key: string): Promise<void> {\n await (await exec()).all(`DELETE FROM ${table} WHERE key = ?`, [key]);\n },\n\n async getKeys(prefix: string): Promise<string[]> {\n const rows = await (\n await exec()\n ).all(`SELECT key FROM ${table} WHERE key GLOB ?`, [`${escapeGlob(prefix)}*`]);\n return rows.map((r) => String(r.key)).filter((key) => key.startsWith(prefix));\n },\n\n async compareAndSwap<T>(input: CompareAndSwapInput<T>): Promise<boolean> {\n const db = await exec();\n const next = canonicalJson(input.next);\n const swap = async (current: string): Promise<boolean> =>\n (\n await db.all(`UPDATE ${table} SET value = ? WHERE key = ? AND value = ? RETURNING key`, [\n next,\n input.key,\n current,\n ])\n ).length === 1;\n if (input.expected === null) {\n const rows = await db.all(\n `INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING RETURNING key`,\n [input.key, next],\n );\n return rows.length === 1;\n }\n return swapWithFallback<string>(input.expected, {\n fast: () => swap(canonicalJson(input.expected)),\n async read() {\n const raw = (await db.all(`SELECT value FROM ${table} WHERE key = ?`, [input.key]))[0]\n ?.value;\n return typeof raw === \"string\" ? { raw, value: JSON.parse(raw) as unknown } : null;\n },\n swapRaw: swap,\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAa,kBAAkB,UAC7B,8BAA8BA,aAAAA,iBAAiB,KAAK,EAAE;;;;;AAMxD,SAAgB,gBACd,OACA,MACyB;CACzB,aAAA,iBAAiB,KAAK;CACtB,OAAO;EACL,MAAM,QAAW,KAAgC;GAE/C,MAAM,SAAQ,OADM,MAAM,KAAK,GAAG,IAAI,qBAAqB,MAAM,iBAAiB,CAAC,GAAG,CAAC,GACpE,IAAI;GACvB,OAAO,OAAO,UAAU,WAAY,KAAK,MAAM,KAAK,IAAU;EAChE;EAEA,MAAM,QAAW,KAAa,OAAyB;GACrD,OACE,MAAM,KAAK,GACX,IACA,eAAe,MAAM,oFACrB,CAAC,KAAKC,aAAAA,cAAc,KAAK,CAAC,CAC5B;EACF;EAEA,MAAM,WAAW,KAA4B;GAC3C,OAAO,MAAM,KAAK,GAAG,IAAI,eAAe,MAAM,iBAAiB,CAAC,GAAG,CAAC;EACtE;EAEA,MAAM,QAAQ,QAAmC;GAI/C,QAAO,OAFL,MAAM,KAAK,GACX,IAAI,mBAAmB,MAAM,oBAAoB,CAAC,GAAGC,aAAAA,WAAW,MAAM,EAAE,EAAE,CAAC,GACjE,KAAK,MAAM,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;EAC9E;EAEA,MAAM,eAAkB,OAAiD;GACvE,MAAM,KAAK,MAAM,KAAK;GACtB,MAAM,OAAOD,aAAAA,cAAc,MAAM,IAAI;GACrC,MAAM,OAAO,OAAO,aAEhB,MAAM,GAAG,IAAI,UAAU,MAAM,2DAA2D;IACtF;IACA,MAAM;IACN;GACF,CAAC,GACD,WAAW;GACf,IAAI,MAAM,aAAa,MAKrB,QAAO,MAJY,GAAG,IACpB,eAAe,MAAM,wEACrB,CAAC,MAAM,KAAK,IAAI,CAClB,GACY,WAAW;GAEzB,OAAOE,YAAAA,iBAAyB,MAAM,UAAU;IAC9C,YAAY,KAAKF,aAAAA,cAAc,MAAM,QAAQ,CAAC;IAC9C,MAAM,OAAO;KACX,MAAM,OAAO,MAAM,GAAG,IAAI,qBAAqB,MAAM,iBAAiB,CAAC,MAAM,GAAG,CAAC,GAAG,IAChF;KACJ,OAAO,OAAO,QAAQ,WAAW;MAAE;MAAK,OAAO,KAAK,MAAM,GAAG;KAAa,IAAI;IAChF;IACA,SAAS;GACX,CAAC;EACH;CACF;AACF"}
@@ -0,0 +1,66 @@
1
+ import { n as assertIdentifier, r as escapeGlob } from "./util-Dnj5T-yw.mjs";
2
+ import { n as canonicalJson } from "./json-CmM1M5Kz.mjs";
3
+ import { t as swapWithFallback } from "./cas-CzA-yECx.mjs";
4
+ //#region src/storage/kv-sqlite.ts
5
+ /**
6
+ * The SQLite-dialect key/value core shared by the `bun:sqlite` and libSQL drivers, exported from
7
+ * their `…/internals` subpaths (semi-public, ADR 0004).
8
+ *
9
+ * - Values are written as **canonical JSON** text (object keys sorted), so `compareAndSwap` is one
10
+ * `UPDATE … WHERE key = ? AND value = ?`. A row written before canonicalisation (unsorted keys)
11
+ * misses that fast path; the swap then reads the row, compares it structurally and swaps on the
12
+ * exact stored text, with bounded retries (ADR 0005).
13
+ * - `getKeys` uses `GLOB` (case-sensitive and index-usable; SQLite's `LIKE` folds ASCII case) with
14
+ * the prefix's glob metacharacters escaped, plus an exact `startsWith` filter.
15
+ *
16
+ * @module
17
+ */
18
+ /** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */
19
+ const sqliteKvSchema = (table) => `CREATE TABLE IF NOT EXISTS ${assertIdentifier(table)} (key TEXT PRIMARY KEY, value TEXT NOT NULL)`;
20
+ /**
21
+ * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the
22
+ * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.
23
+ */
24
+ function sqliteKvStorage(table, exec) {
25
+ assertIdentifier(table);
26
+ return {
27
+ async getItem(key) {
28
+ const value = (await (await exec()).all(`SELECT value FROM ${table} WHERE key = ?`, [key]))[0]?.value;
29
+ return typeof value === "string" ? JSON.parse(value) : null;
30
+ },
31
+ async setItem(key, value) {
32
+ await (await exec()).all(`INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, [key, canonicalJson(value)]);
33
+ },
34
+ async removeItem(key) {
35
+ await (await exec()).all(`DELETE FROM ${table} WHERE key = ?`, [key]);
36
+ },
37
+ async getKeys(prefix) {
38
+ return (await (await exec()).all(`SELECT key FROM ${table} WHERE key GLOB ?`, [`${escapeGlob(prefix)}*`])).map((r) => String(r.key)).filter((key) => key.startsWith(prefix));
39
+ },
40
+ async compareAndSwap(input) {
41
+ const db = await exec();
42
+ const next = canonicalJson(input.next);
43
+ const swap = async (current) => (await db.all(`UPDATE ${table} SET value = ? WHERE key = ? AND value = ? RETURNING key`, [
44
+ next,
45
+ input.key,
46
+ current
47
+ ])).length === 1;
48
+ if (input.expected === null) return (await db.all(`INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING RETURNING key`, [input.key, next])).length === 1;
49
+ return swapWithFallback(input.expected, {
50
+ fast: () => swap(canonicalJson(input.expected)),
51
+ async read() {
52
+ const raw = (await db.all(`SELECT value FROM ${table} WHERE key = ?`, [input.key]))[0]?.value;
53
+ return typeof raw === "string" ? {
54
+ raw,
55
+ value: JSON.parse(raw)
56
+ } : null;
57
+ },
58
+ swapRaw: swap
59
+ });
60
+ }
61
+ };
62
+ }
63
+ //#endregion
64
+ export { sqliteKvStorage as n, sqliteKvSchema as t };
65
+
66
+ //# sourceMappingURL=kv-sqlite-DIIPfflJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv-sqlite-DIIPfflJ.mjs","names":[],"sources":["../src/storage/kv-sqlite.ts"],"sourcesContent":["/**\n * The SQLite-dialect key/value core shared by the `bun:sqlite` and libSQL drivers, exported from\n * their `…/internals` subpaths (semi-public, ADR 0004).\n *\n * - Values are written as **canonical JSON** text (object keys sorted), so `compareAndSwap` is one\n * `UPDATE … WHERE key = ? AND value = ?`. A row written before canonicalisation (unsorted keys)\n * misses that fast path; the swap then reads the row, compares it structurally and swaps on the\n * exact stored text, with bounded retries (ADR 0005).\n * - `getKeys` uses `GLOB` (case-sensitive and index-usable; SQLite's `LIKE` folds ASCII case) with\n * the prefix's glob metacharacters escaped, plus an exact `startsWith` filter.\n *\n * @module\n */\n\nimport { canonicalJson } from \"../internal/json.ts\";\nimport { swapWithFallback } from \"./cas.ts\";\nimport type { CompareAndSwapInput, CompareAndSwapKvStorage } from \"./contract.ts\";\nimport { assertIdentifier, escapeGlob } from \"./util.ts\";\n\n/** One row returned by an executor. */\nexport type SqliteRow = Record<string, unknown>;\n\n/** The tiny async SQL surface the core needs (positional `?` parameters). */\nexport interface SqliteExecutor {\n /** Run a statement and return its rows (empty for statements without `RETURNING`). */\n all(sql: string, args: unknown[]): Promise<SqliteRow[]>;\n}\n\n/** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */\nexport const sqliteKvSchema = (table: string): string =>\n `CREATE TABLE IF NOT EXISTS ${assertIdentifier(table)} (key TEXT PRIMARY KEY, value TEXT NOT NULL)`;\n\n/**\n * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the\n * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.\n */\nexport function sqliteKvStorage(\n table: string,\n exec: () => Promise<SqliteExecutor>,\n): CompareAndSwapKvStorage {\n assertIdentifier(table);\n return {\n async getItem<T>(key: string): Promise<T | null> {\n const rows = await (await exec()).all(`SELECT value FROM ${table} WHERE key = ?`, [key]);\n const value = rows[0]?.value;\n return typeof value === \"string\" ? (JSON.parse(value) as T) : null;\n },\n\n async setItem<T>(key: string, value: T): Promise<void> {\n await (\n await exec()\n ).all(\n `INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`,\n [key, canonicalJson(value)],\n );\n },\n\n async removeItem(key: string): Promise<void> {\n await (await exec()).all(`DELETE FROM ${table} WHERE key = ?`, [key]);\n },\n\n async getKeys(prefix: string): Promise<string[]> {\n const rows = await (\n await exec()\n ).all(`SELECT key FROM ${table} WHERE key GLOB ?`, [`${escapeGlob(prefix)}*`]);\n return rows.map((r) => String(r.key)).filter((key) => key.startsWith(prefix));\n },\n\n async compareAndSwap<T>(input: CompareAndSwapInput<T>): Promise<boolean> {\n const db = await exec();\n const next = canonicalJson(input.next);\n const swap = async (current: string): Promise<boolean> =>\n (\n await db.all(`UPDATE ${table} SET value = ? WHERE key = ? AND value = ? RETURNING key`, [\n next,\n input.key,\n current,\n ])\n ).length === 1;\n if (input.expected === null) {\n const rows = await db.all(\n `INSERT INTO ${table} (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING RETURNING key`,\n [input.key, next],\n );\n return rows.length === 1;\n }\n return swapWithFallback<string>(input.expected, {\n fast: () => swap(canonicalJson(input.expected)),\n async read() {\n const raw = (await db.all(`SELECT value FROM ${table} WHERE key = ?`, [input.key]))[0]\n ?.value;\n return typeof raw === \"string\" ? { raw, value: JSON.parse(raw) as unknown } : null;\n },\n swapRaw: swap,\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAa,kBAAkB,UAC7B,8BAA8B,iBAAiB,KAAK,EAAE;;;;;AAMxD,SAAgB,gBACd,OACA,MACyB;CACzB,iBAAiB,KAAK;CACtB,OAAO;EACL,MAAM,QAAW,KAAgC;GAE/C,MAAM,SAAQ,OADM,MAAM,KAAK,GAAG,IAAI,qBAAqB,MAAM,iBAAiB,CAAC,GAAG,CAAC,GACpE,IAAI;GACvB,OAAO,OAAO,UAAU,WAAY,KAAK,MAAM,KAAK,IAAU;EAChE;EAEA,MAAM,QAAW,KAAa,OAAyB;GACrD,OACE,MAAM,KAAK,GACX,IACA,eAAe,MAAM,oFACrB,CAAC,KAAK,cAAc,KAAK,CAAC,CAC5B;EACF;EAEA,MAAM,WAAW,KAA4B;GAC3C,OAAO,MAAM,KAAK,GAAG,IAAI,eAAe,MAAM,iBAAiB,CAAC,GAAG,CAAC;EACtE;EAEA,MAAM,QAAQ,QAAmC;GAI/C,QAAO,OAFL,MAAM,KAAK,GACX,IAAI,mBAAmB,MAAM,oBAAoB,CAAC,GAAG,WAAW,MAAM,EAAE,EAAE,CAAC,GACjE,KAAK,MAAM,OAAO,EAAE,GAAG,CAAC,EAAE,QAAQ,QAAQ,IAAI,WAAW,MAAM,CAAC;EAC9E;EAEA,MAAM,eAAkB,OAAiD;GACvE,MAAM,KAAK,MAAM,KAAK;GACtB,MAAM,OAAO,cAAc,MAAM,IAAI;GACrC,MAAM,OAAO,OAAO,aAEhB,MAAM,GAAG,IAAI,UAAU,MAAM,2DAA2D;IACtF;IACA,MAAM;IACN;GACF,CAAC,GACD,WAAW;GACf,IAAI,MAAM,aAAa,MAKrB,QAAO,MAJY,GAAG,IACpB,eAAe,MAAM,wEACrB,CAAC,MAAM,KAAK,IAAI,CAClB,GACY,WAAW;GAEzB,OAAO,iBAAyB,MAAM,UAAU;IAC9C,YAAY,KAAK,cAAc,MAAM,QAAQ,CAAC;IAC9C,MAAM,OAAO;KACX,MAAM,OAAO,MAAM,GAAG,IAAI,qBAAqB,MAAM,iBAAiB,CAAC,MAAM,GAAG,CAAC,GAAG,IAChF;KACJ,OAAO,OAAO,QAAQ,WAAW;MAAE;MAAK,OAAO,KAAK,MAAM,GAAG;KAAa,IAAI;IAChF;IACA,SAAS;GACX,CAAC;EACH;CACF;AACF"}
@@ -0,0 +1,20 @@
1
+ import { n as CompareAndSwapKvStorage } from "./contract-BvgtswLX.mjs";
2
+
3
+ //#region src/storage/kv-sqlite.d.ts
4
+ /** One row returned by an executor. */
5
+ type SqliteRow = Record<string, unknown>;
6
+ /** The tiny async SQL surface the core needs (positional `?` parameters). */
7
+ interface SqliteExecutor {
8
+ /** Run a statement and return its rows (empty for statements without `RETURNING`). */
9
+ all(sql: string, args: unknown[]): Promise<SqliteRow[]>;
10
+ }
11
+ /** The DDL for a KV table: `key TEXT PRIMARY KEY, value TEXT NOT NULL` (validates `table`). */
12
+ declare const sqliteKvSchema: (table: string) => string;
13
+ /**
14
+ * Build a compare-and-swap capable storage over a SQLite-dialect executor. `exec` resolves the
15
+ * executor before every operation (lazy connect + DDL); the core issues no DDL of its own.
16
+ */
17
+ declare function sqliteKvStorage(table: string, exec: () => Promise<SqliteExecutor>): CompareAndSwapKvStorage;
18
+ //#endregion
19
+ export { sqliteKvStorage as i, SqliteRow as n, sqliteKvSchema as r, SqliteExecutor as t };
20
+ //# sourceMappingURL=kv-sqlite-Tx4UedJs.d.mts.map
@@ -0,0 +1,65 @@
1
+ import { n as CompareAndSwapKvStorage } from "./contract-BvgtswLX.mjs";
2
+ import { t as SqliteExecutor } from "./kv-sqlite-Tx4UedJs.mjs";
3
+
4
+ //#region src/storage/libsql.d.ts
5
+ /** Options for {@link createLibsqlStorage}. */
6
+ interface LibsqlStorageOptions {
7
+ /** libSQL URL (`libsql://…`, `https://…`, `file:…`, `:memory:`). Used when no `client`. */
8
+ url?: string;
9
+ /** Turso auth token for remote databases. */
10
+ authToken?: string;
11
+ /** A pre-constructed `@libsql/client` client to use instead of connecting. Never closed. */
12
+ client?: LibsqlClientLike;
13
+ /** Table name (default `"xtandard_kv"`; products pass theirs). Validated as a safe identifier. */
14
+ table?: string;
15
+ }
16
+ /** A compare-and-swap capable storage backed by libSQL/Turso, plus `close()`. */
17
+ interface LibsqlKvStorage extends CompareAndSwapKvStorage {
18
+ /** Close the client if this driver created it; no-op for a borrowed one. */
19
+ close(): void;
20
+ }
21
+ /** Minimal structural view of the `@libsql/client` surface the drivers use. */
22
+ interface LibsqlClientLike {
23
+ /** Run one statement. */
24
+ execute(stmt: string | {
25
+ sql: string;
26
+ args: unknown[];
27
+ }): Promise<{
28
+ rows: ArrayLike<Record<string, unknown>>;
29
+ }>;
30
+ /** Close the client. */
31
+ close(): void;
32
+ }
33
+ /** A lazily created libSQL client whose DDL runs once (semi-public, ADR 0004). */
34
+ interface LibsqlConnection {
35
+ /** Resolve the client, creating it and running the DDL on first use (retried after a failure). */
36
+ get(): Promise<LibsqlClientLike>;
37
+ /** Close the client if this connection created it. */
38
+ close(): void;
39
+ }
40
+ /**
41
+ * Build a {@link LibsqlConnection} that runs `ddl` (in order) once before the first use. A failed
42
+ * connect or DDL is not cached: the next `get()` retries. Products add their own tables by passing
43
+ * extra statements (au's event log).
44
+ */
45
+ declare function libsqlConnection(options: Pick<LibsqlStorageOptions, "url" | "authToken" | "client">, ddl: string[], subpath?: string): LibsqlConnection;
46
+ /** Adapt a libSQL client to the positional-args {@link SqliteExecutor} of the SQLite core. */
47
+ declare function libsqlExecutor(client: LibsqlClientLike): SqliteExecutor;
48
+ /**
49
+ * Create a libSQL/Turso-backed {@link LibsqlKvStorage}.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { createLibsqlStorage } from "@xtandard/kit/storage/libsql";
54
+ *
55
+ * const storage = createLibsqlStorage({
56
+ * url: process.env.TURSO_DATABASE_URL!,
57
+ * authToken: process.env.TURSO_AUTH_TOKEN,
58
+ * table: "xtandard_kv",
59
+ * });
60
+ * ```
61
+ */
62
+ declare function createLibsqlStorage(options: LibsqlStorageOptions): LibsqlKvStorage;
63
+ //#endregion
64
+ export { createLibsqlStorage as a, LibsqlStorageOptions as i, LibsqlConnection as n, libsqlConnection as o, LibsqlKvStorage as r, libsqlExecutor as s, LibsqlClientLike as t };
65
+ //# sourceMappingURL=libsql-0160BubR.d.mts.map
@@ -0,0 +1,65 @@
1
+ import { n as CompareAndSwapKvStorage } from "./contract-BvgtswLX.cjs";
2
+ import { t as SqliteExecutor } from "./kv-sqlite-B6iTLOx2.cjs";
3
+
4
+ //#region src/storage/libsql.d.ts
5
+ /** Options for {@link createLibsqlStorage}. */
6
+ interface LibsqlStorageOptions {
7
+ /** libSQL URL (`libsql://…`, `https://…`, `file:…`, `:memory:`). Used when no `client`. */
8
+ url?: string;
9
+ /** Turso auth token for remote databases. */
10
+ authToken?: string;
11
+ /** A pre-constructed `@libsql/client` client to use instead of connecting. Never closed. */
12
+ client?: LibsqlClientLike;
13
+ /** Table name (default `"xtandard_kv"`; products pass theirs). Validated as a safe identifier. */
14
+ table?: string;
15
+ }
16
+ /** A compare-and-swap capable storage backed by libSQL/Turso, plus `close()`. */
17
+ interface LibsqlKvStorage extends CompareAndSwapKvStorage {
18
+ /** Close the client if this driver created it; no-op for a borrowed one. */
19
+ close(): void;
20
+ }
21
+ /** Minimal structural view of the `@libsql/client` surface the drivers use. */
22
+ interface LibsqlClientLike {
23
+ /** Run one statement. */
24
+ execute(stmt: string | {
25
+ sql: string;
26
+ args: unknown[];
27
+ }): Promise<{
28
+ rows: ArrayLike<Record<string, unknown>>;
29
+ }>;
30
+ /** Close the client. */
31
+ close(): void;
32
+ }
33
+ /** A lazily created libSQL client whose DDL runs once (semi-public, ADR 0004). */
34
+ interface LibsqlConnection {
35
+ /** Resolve the client, creating it and running the DDL on first use (retried after a failure). */
36
+ get(): Promise<LibsqlClientLike>;
37
+ /** Close the client if this connection created it. */
38
+ close(): void;
39
+ }
40
+ /**
41
+ * Build a {@link LibsqlConnection} that runs `ddl` (in order) once before the first use. A failed
42
+ * connect or DDL is not cached: the next `get()` retries. Products add their own tables by passing
43
+ * extra statements (au's event log).
44
+ */
45
+ declare function libsqlConnection(options: Pick<LibsqlStorageOptions, "url" | "authToken" | "client">, ddl: string[], subpath?: string): LibsqlConnection;
46
+ /** Adapt a libSQL client to the positional-args {@link SqliteExecutor} of the SQLite core. */
47
+ declare function libsqlExecutor(client: LibsqlClientLike): SqliteExecutor;
48
+ /**
49
+ * Create a libSQL/Turso-backed {@link LibsqlKvStorage}.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { createLibsqlStorage } from "@xtandard/kit/storage/libsql";
54
+ *
55
+ * const storage = createLibsqlStorage({
56
+ * url: process.env.TURSO_DATABASE_URL!,
57
+ * authToken: process.env.TURSO_AUTH_TOKEN,
58
+ * table: "xtandard_kv",
59
+ * });
60
+ * ```
61
+ */
62
+ declare function createLibsqlStorage(options: LibsqlStorageOptions): LibsqlKvStorage;
63
+ //#endregion
64
+ export { createLibsqlStorage as a, LibsqlStorageOptions as i, LibsqlConnection as n, libsqlConnection as o, LibsqlKvStorage as r, libsqlExecutor as s, LibsqlClientLike as t };
65
+ //# sourceMappingURL=libsql-BZmRZIqt.d.cts.map
@@ -0,0 +1,103 @@
1
+ const require_peer = require("./peer-BIjBFzwQ.cjs");
2
+ const require_util = require("./util-dAnTK9x-.cjs");
3
+ const require_kv_sqlite = require("./kv-sqlite-CHOdIMJ-.cjs");
4
+ //#region src/storage/libsql.ts
5
+ /**
6
+ * libSQL / [Turso](https://turso.tech) storage driver over the `@libsql/client` package (an
7
+ * optional peer). Same SQL dialect as SQLite, against a remote, replicated database, an embedded
8
+ * replica or a local file, so it suits multi-node and edge runtimes where `bun:sqlite` does not.
9
+ *
10
+ * Pass a pre-constructed `client`, or `url` (+ `authToken`) to create one lazily on first use. The
11
+ * table is created on first use; a failed connect or DDL is retried on the next call (not cached).
12
+ * Values are canonical JSON, so `compareAndSwap` is one conditional `UPDATE` evaluated by the
13
+ * server (see `kv-sqlite.ts`).
14
+ *
15
+ * @module
16
+ */
17
+ const SUBPATH = "@xtandard/kit/storage/libsql";
18
+ /**
19
+ * Build a {@link LibsqlConnection} that runs `ddl` (in order) once before the first use. A failed
20
+ * connect or DDL is not cached: the next `get()` retries. Products add their own tables by passing
21
+ * extra statements (au's event log).
22
+ */
23
+ function libsqlConnection(options, ddl, subpath = SUBPATH) {
24
+ const ownsClient = !options.client;
25
+ let client = options.client;
26
+ let ready;
27
+ return {
28
+ get() {
29
+ ready ??= (async () => {
30
+ if (!client) {
31
+ if (!options.url) throw new Error(`${subpath} requires either a \`client\` or a \`url\``);
32
+ const { createClient } = await require_peer.importPeer("@libsql/client", subpath, () => import("@libsql/client"));
33
+ client = createClient({
34
+ url: options.url,
35
+ authToken: options.authToken
36
+ });
37
+ }
38
+ for (const statement of ddl) await client.execute(statement);
39
+ return client;
40
+ })().catch((error) => {
41
+ ready = void 0;
42
+ throw error;
43
+ });
44
+ return ready;
45
+ },
46
+ close() {
47
+ if (ownsClient) client?.close();
48
+ }
49
+ };
50
+ }
51
+ /** Adapt a libSQL client to the positional-args {@link SqliteExecutor} of the SQLite core. */
52
+ function libsqlExecutor(client) {
53
+ return { async all(sql, args) {
54
+ const { rows } = await client.execute({
55
+ sql,
56
+ args
57
+ });
58
+ return Array.from(rows);
59
+ } };
60
+ }
61
+ /**
62
+ * Create a libSQL/Turso-backed {@link LibsqlKvStorage}.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { createLibsqlStorage } from "@xtandard/kit/storage/libsql";
67
+ *
68
+ * const storage = createLibsqlStorage({
69
+ * url: process.env.TURSO_DATABASE_URL!,
70
+ * authToken: process.env.TURSO_AUTH_TOKEN,
71
+ * table: "xtandard_kv",
72
+ * });
73
+ * ```
74
+ */
75
+ function createLibsqlStorage(options) {
76
+ const table = require_util.assertIdentifier(options.table ?? "xtandard_kv");
77
+ const connection = libsqlConnection(options, [require_kv_sqlite.sqliteKvSchema(table)]);
78
+ return {
79
+ ...require_kv_sqlite.sqliteKvStorage(table, async () => libsqlExecutor(await connection.get())),
80
+ close: connection.close
81
+ };
82
+ }
83
+ //#endregion
84
+ Object.defineProperty(exports, "createLibsqlStorage", {
85
+ enumerable: true,
86
+ get: function() {
87
+ return createLibsqlStorage;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "libsqlConnection", {
91
+ enumerable: true,
92
+ get: function() {
93
+ return libsqlConnection;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "libsqlExecutor", {
97
+ enumerable: true,
98
+ get: function() {
99
+ return libsqlExecutor;
100
+ }
101
+ });
102
+
103
+ //# sourceMappingURL=libsql-CiBfVtbS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libsql-CiBfVtbS.cjs","names":["importPeer","assertIdentifier","sqliteKvSchema","sqliteKvStorage"],"sources":["../src/storage/libsql.ts"],"sourcesContent":["/**\n * libSQL / [Turso](https://turso.tech) storage driver over the `@libsql/client` package (an\n * optional peer). Same SQL dialect as SQLite, against a remote, replicated database, an embedded\n * replica or a local file, so it suits multi-node and edge runtimes where `bun:sqlite` does not.\n *\n * Pass a pre-constructed `client`, or `url` (+ `authToken`) to create one lazily on first use. The\n * table is created on first use; a failed connect or DDL is retried on the next call (not cached).\n * Values are canonical JSON, so `compareAndSwap` is one conditional `UPDATE` evaluated by the\n * server (see `kv-sqlite.ts`).\n *\n * @module\n */\n\nimport { importPeer } from \"../internal/peer.ts\";\nimport type { CompareAndSwapKvStorage } from \"./contract.ts\";\nimport { sqliteKvSchema, sqliteKvStorage, type SqliteExecutor } from \"./kv-sqlite.ts\";\nimport { assertIdentifier } from \"./util.ts\";\n\nconst SUBPATH = \"@xtandard/kit/storage/libsql\";\n\n/** Options for {@link createLibsqlStorage}. */\nexport interface LibsqlStorageOptions {\n /** libSQL URL (`libsql://…`, `https://…`, `file:…`, `:memory:`). Used when no `client`. */\n url?: string;\n /** Turso auth token for remote databases. */\n authToken?: string;\n /** A pre-constructed `@libsql/client` client to use instead of connecting. Never closed. */\n client?: LibsqlClientLike;\n /** Table name (default `\"xtandard_kv\"`; products pass theirs). Validated as a safe identifier. */\n table?: string;\n}\n\n/** A compare-and-swap capable storage backed by libSQL/Turso, plus `close()`. */\nexport interface LibsqlKvStorage extends CompareAndSwapKvStorage {\n /** Close the client if this driver created it; no-op for a borrowed one. */\n close(): void;\n}\n\n/** Minimal structural view of the `@libsql/client` surface the drivers use. */\nexport interface LibsqlClientLike {\n /** Run one statement. */\n execute(\n stmt: string | { sql: string; args: unknown[] },\n ): Promise<{ rows: ArrayLike<Record<string, unknown>> }>;\n /** Close the client. */\n close(): void;\n}\n\n/** A lazily created libSQL client whose DDL runs once (semi-public, ADR 0004). */\nexport interface LibsqlConnection {\n /** Resolve the client, creating it and running the DDL on first use (retried after a failure). */\n get(): Promise<LibsqlClientLike>;\n /** Close the client if this connection created it. */\n close(): void;\n}\n\n/**\n * Build a {@link LibsqlConnection} that runs `ddl` (in order) once before the first use. A failed\n * connect or DDL is not cached: the next `get()` retries. Products add their own tables by passing\n * extra statements (au's event log).\n */\nexport function libsqlConnection(\n options: Pick<LibsqlStorageOptions, \"url\" | \"authToken\" | \"client\">,\n ddl: string[],\n subpath = SUBPATH,\n): LibsqlConnection {\n const ownsClient = !options.client;\n let client: LibsqlClientLike | undefined = options.client;\n let ready: Promise<LibsqlClientLike> | undefined;\n return {\n get(): Promise<LibsqlClientLike> {\n ready ??= (async () => {\n if (!client) {\n if (!options.url) throw new Error(`${subpath} requires either a \\`client\\` or a \\`url\\``);\n const { createClient } = await importPeer(\n \"@libsql/client\",\n subpath,\n () =>\n import(\"@libsql/client\") as unknown as Promise<{\n createClient: (opts: { url: string; authToken?: string }) => LibsqlClientLike;\n }>,\n );\n client = createClient({ url: options.url, authToken: options.authToken });\n }\n for (const statement of ddl) await client.execute(statement);\n return client;\n })().catch((error: unknown) => {\n ready = undefined; // let a later call retry\n throw error;\n });\n return ready;\n },\n close(): void {\n if (ownsClient) client?.close();\n },\n };\n}\n\n/** Adapt a libSQL client to the positional-args {@link SqliteExecutor} of the SQLite core. */\nexport function libsqlExecutor(client: LibsqlClientLike): SqliteExecutor {\n return {\n async all(sql, args) {\n const { rows } = await client.execute({ sql, args });\n return Array.from(rows);\n },\n };\n}\n\n/**\n * Create a libSQL/Turso-backed {@link LibsqlKvStorage}.\n *\n * @example\n * ```ts\n * import { createLibsqlStorage } from \"@xtandard/kit/storage/libsql\";\n *\n * const storage = createLibsqlStorage({\n * url: process.env.TURSO_DATABASE_URL!,\n * authToken: process.env.TURSO_AUTH_TOKEN,\n * table: \"xtandard_kv\",\n * });\n * ```\n */\nexport function createLibsqlStorage(options: LibsqlStorageOptions): LibsqlKvStorage {\n const table = assertIdentifier(options.table ?? \"xtandard_kv\");\n const connection = libsqlConnection(options, [sqliteKvSchema(table)]);\n return {\n ...sqliteKvStorage(table, async () => libsqlExecutor(await connection.get())),\n close: connection.close,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,UAAU;;;;;;AA2ChB,SAAgB,iBACd,SACA,KACA,UAAU,SACQ;CAClB,MAAM,aAAa,CAAC,QAAQ;CAC5B,IAAI,SAAuC,QAAQ;CACnD,IAAI;CACJ,OAAO;EACL,MAAiC;GAC/B,WAAW,YAAY;IACrB,IAAI,CAAC,QAAQ;KACX,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,MAAM,GAAG,QAAQ,2CAA2C;KACxF,MAAM,EAAE,iBAAiB,MAAMA,aAAAA,WAC7B,kBACA,eAEE,OAAO,iBAGX;KACA,SAAS,aAAa;MAAE,KAAK,QAAQ;MAAK,WAAW,QAAQ;KAAU,CAAC;IAC1E;IACA,KAAK,MAAM,aAAa,KAAK,MAAM,OAAO,QAAQ,SAAS;IAC3D,OAAO;GACT,GAAG,EAAE,OAAO,UAAmB;IAC7B,QAAQ,KAAA;IACR,MAAM;GACR,CAAC;GACD,OAAO;EACT;EACA,QAAc;GACZ,IAAI,YAAY,QAAQ,MAAM;EAChC;CACF;AACF;;AAGA,SAAgB,eAAe,QAA0C;CACvE,OAAO,EACL,MAAM,IAAI,KAAK,MAAM;EACnB,MAAM,EAAE,SAAS,MAAM,OAAO,QAAQ;GAAE;GAAK;EAAK,CAAC;EACnD,OAAO,MAAM,KAAK,IAAI;CACxB,EACF;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,oBAAoB,SAAgD;CAClF,MAAM,QAAQC,aAAAA,iBAAiB,QAAQ,SAAS,aAAa;CAC7D,MAAM,aAAa,iBAAiB,SAAS,CAACC,kBAAAA,eAAe,KAAK,CAAC,CAAC;CACpE,OAAO;EACL,GAAGC,kBAAAA,gBAAgB,OAAO,YAAY,eAAe,MAAM,WAAW,IAAI,CAAC,CAAC;EAC5E,OAAO,WAAW;CACpB;AACF"}