@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.
- package/LICENSE +21 -0
- package/README.md +71 -2
- package/bin/xtandard-kit.mjs +3 -0
- package/dist/base-path-BJugWLNO.cjs +42 -0
- package/dist/base-path-BJugWLNO.cjs.map +1 -0
- package/dist/base-path-CDb4In5E.mjs +31 -0
- package/dist/base-path-CDb4In5E.mjs.map +1 -0
- package/dist/basic-Qtriv0xS.mjs +176 -0
- package/dist/basic-Qtriv0xS.mjs.map +1 -0
- package/dist/basic-ZaO92-lB.cjs +199 -0
- package/dist/basic-ZaO92-lB.cjs.map +1 -0
- package/dist/bin.cjs +126 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +20 -0
- package/dist/bin.d.mts +20 -0
- package/dist/bin.mjs +125 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/cas-CuPSaXBV.cjs +23 -0
- package/dist/cas-CuPSaXBV.cjs.map +1 -0
- package/dist/cas-CzA-yECx.mjs +18 -0
- package/dist/cas-CzA-yECx.mjs.map +1 -0
- package/dist/chunk-DakpK96I.cjs +43 -0
- package/dist/contract-B3UPXXLx.d.cts +30 -0
- package/dist/contract-B3UPXXLx.d.mts +30 -0
- package/dist/contract-BDPNvjtp.d.mts +64 -0
- package/dist/contract-BEdfGTPs.mjs +85 -0
- package/dist/contract-BEdfGTPs.mjs.map +1 -0
- package/dist/contract-BIVzAn4f.d.cts +64 -0
- package/dist/contract-BvgtswLX.d.cts +75 -0
- package/dist/contract-BvgtswLX.d.mts +75 -0
- package/dist/contract-DUj9P3Vt.d.cts +72 -0
- package/dist/contract-DUj9P3Vt.d.mts +72 -0
- package/dist/contract-wAEMDmYG.cjs +132 -0
- package/dist/contract-wAEMDmYG.cjs.map +1 -0
- package/dist/drizzle-BElCHWri.d.mts +115 -0
- package/dist/drizzle-BXaQXCr0.cjs +232 -0
- package/dist/drizzle-BXaQXCr0.cjs.map +1 -0
- package/dist/drizzle-CEpahWQB.d.cts +115 -0
- package/dist/drizzle-DxnelsPT.mjs +197 -0
- package/dist/drizzle-DxnelsPT.mjs.map +1 -0
- package/dist/duration-7WpAK-xe.mjs +52 -0
- package/dist/duration-7WpAK-xe.mjs.map +1 -0
- package/dist/duration-DVA0Fzkx.cjs +63 -0
- package/dist/duration-DVA0Fzkx.cjs.map +1 -0
- package/dist/duration-FPwbmWIU.d.cts +35 -0
- package/dist/duration-FPwbmWIU.d.mts +35 -0
- package/dist/entry-adapters-bun.cjs +10 -0
- package/dist/entry-adapters-bun.cjs.map +1 -0
- package/dist/entry-adapters-bun.d.cts +10 -0
- package/dist/entry-adapters-bun.d.mts +10 -0
- package/dist/entry-adapters-bun.mjs +9 -0
- package/dist/entry-adapters-bun.mjs.map +1 -0
- package/dist/entry-adapters-elysia.cjs +54 -0
- package/dist/entry-adapters-elysia.cjs.map +1 -0
- package/dist/entry-adapters-elysia.d.cts +38 -0
- package/dist/entry-adapters-elysia.d.mts +38 -0
- package/dist/entry-adapters-elysia.mjs +53 -0
- package/dist/entry-adapters-elysia.mjs.map +1 -0
- package/dist/entry-adapters-express.cjs +27 -0
- package/dist/entry-adapters-express.cjs.map +1 -0
- package/dist/entry-adapters-express.d.cts +24 -0
- package/dist/entry-adapters-express.d.mts +24 -0
- package/dist/entry-adapters-express.mjs +26 -0
- package/dist/entry-adapters-express.mjs.map +1 -0
- package/dist/entry-adapters-hono.cjs +33 -0
- package/dist/entry-adapters-hono.cjs.map +1 -0
- package/dist/entry-adapters-hono.d.cts +36 -0
- package/dist/entry-adapters-hono.d.mts +36 -0
- package/dist/entry-adapters-hono.mjs +30 -0
- package/dist/entry-adapters-hono.mjs.map +1 -0
- package/dist/entry-adapters-next.cjs +19 -0
- package/dist/entry-adapters-next.cjs.map +1 -0
- package/dist/entry-adapters-next.d.cts +35 -0
- package/dist/entry-adapters-next.d.mts +35 -0
- package/dist/entry-adapters-next.mjs +18 -0
- package/dist/entry-adapters-next.mjs.map +1 -0
- package/dist/entry-adapters-node.cjs +7 -0
- package/dist/entry-adapters-node.d.cts +2 -0
- package/dist/entry-adapters-node.d.mts +2 -0
- package/dist/entry-adapters-node.mjs +2 -0
- package/dist/entry-auth-basic.cjs +5 -0
- package/dist/entry-auth-basic.d.cts +83 -0
- package/dist/entry-auth-basic.d.mts +83 -0
- package/dist/entry-auth-basic.mjs +2 -0
- package/dist/entry-auth-delegated.cjs +28 -0
- package/dist/entry-auth-delegated.cjs.map +1 -0
- package/dist/entry-auth-delegated.d.cts +36 -0
- package/dist/entry-auth-delegated.d.mts +36 -0
- package/dist/entry-auth-delegated.mjs +27 -0
- package/dist/entry-auth-delegated.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +4 -0
- package/dist/entry-auth-none.d.cts +25 -0
- package/dist/entry-auth-none.d.mts +25 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-auth.cjs +0 -0
- package/dist/entry-auth.d.cts +2 -0
- package/dist/entry-auth.d.mts +2 -0
- package/dist/entry-auth.mjs +1 -0
- package/dist/entry-authorization-delegated.cjs +27 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +31 -0
- package/dist/entry-authorization-delegated.d.mts +31 -0
- package/dist/entry-authorization-delegated.mjs +26 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +3 -0
- package/dist/entry-authorization-none.d.cts +18 -0
- package/dist/entry-authorization-none.d.mts +18 -0
- package/dist/entry-authorization-none.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +3 -0
- package/dist/entry-authorization-roles.d.cts +2 -0
- package/dist/entry-authorization-roles.d.mts +2 -0
- package/dist/entry-authorization-roles.mjs +2 -0
- package/dist/entry-authorization.cjs +35 -0
- package/dist/entry-authorization.cjs.map +1 -0
- package/dist/entry-authorization.d.cts +2 -0
- package/dist/entry-authorization.d.mts +2 -0
- package/dist/entry-authorization.mjs +34 -0
- package/dist/entry-authorization.mjs.map +1 -0
- package/dist/entry-build.cjs +481 -0
- package/dist/entry-build.cjs.map +1 -0
- package/dist/entry-build.d.cts +355 -0
- package/dist/entry-build.d.mts +355 -0
- package/dist/entry-build.mjs +460 -0
- package/dist/entry-build.mjs.map +1 -0
- package/dist/entry-cli.cjs +368 -0
- package/dist/entry-cli.cjs.map +1 -0
- package/dist/entry-cli.d.cts +275 -0
- package/dist/entry-cli.d.mts +275 -0
- package/dist/entry-cli.mjs +355 -0
- package/dist/entry-cli.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +36 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +55 -0
- package/dist/entry-drizzle-mysql.d.mts +55 -0
- package/dist/entry-drizzle-mysql.mjs +34 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +38 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +78 -0
- package/dist/entry-drizzle-pg.d.mts +78 -0
- package/dist/entry-drizzle-pg.mjs +36 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +20 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +22 -0
- package/dist/entry-drizzle-sqlite.d.mts +22 -0
- package/dist/entry-drizzle-sqlite.mjs +19 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +32 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +36 -0
- package/dist/entry-hooks-log.d.mts +36 -0
- package/dist/entry-hooks-log.mjs +31 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-hooks.cjs +10 -0
- package/dist/entry-hooks.d.cts +2 -0
- package/dist/entry-hooks.d.mts +2 -0
- package/dist/entry-hooks.mjs +2 -0
- package/dist/entry-server-router.cjs +235 -0
- package/dist/entry-server-router.cjs.map +1 -0
- package/dist/entry-server-router.d.cts +193 -0
- package/dist/entry-server-router.d.mts +193 -0
- package/dist/entry-server-router.mjs +228 -0
- package/dist/entry-server-router.mjs.map +1 -0
- package/dist/entry-server.cjs +344 -0
- package/dist/entry-server.cjs.map +1 -0
- package/dist/entry-server.d.cts +230 -0
- package/dist/entry-server.d.mts +230 -0
- package/dist/entry-server.mjs +322 -0
- package/dist/entry-server.mjs.map +1 -0
- package/dist/entry-site.cjs +1083 -0
- package/dist/entry-site.cjs.map +1 -0
- package/dist/entry-site.d.cts +336 -0
- package/dist/entry-site.d.mts +336 -0
- package/dist/entry-site.mjs +1060 -0
- package/dist/entry-site.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +51 -0
- package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +52 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +52 -0
- package/dist/entry-storage-cloudflare-kv.mjs +50 -0
- package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
- package/dist/entry-storage-drizzle-internals.cjs +6 -0
- package/dist/entry-storage-drizzle-internals.d.cts +2 -0
- package/dist/entry-storage-drizzle-internals.d.mts +2 -0
- package/dist/entry-storage-drizzle-internals.mjs +2 -0
- package/dist/entry-storage-drizzle.cjs +4 -0
- package/dist/entry-storage-drizzle.d.cts +3 -0
- package/dist/entry-storage-drizzle.d.mts +3 -0
- package/dist/entry-storage-drizzle.mjs +2 -0
- package/dist/entry-storage-file.cjs +306 -0
- package/dist/entry-storage-file.cjs.map +1 -0
- package/dist/entry-storage-file.d.cts +76 -0
- package/dist/entry-storage-file.d.mts +76 -0
- package/dist/entry-storage-file.mjs +301 -0
- package/dist/entry-storage-file.mjs.map +1 -0
- package/dist/entry-storage-libsql-internals.cjs +7 -0
- package/dist/entry-storage-libsql-internals.d.cts +3 -0
- package/dist/entry-storage-libsql-internals.d.mts +3 -0
- package/dist/entry-storage-libsql-internals.mjs +3 -0
- package/dist/entry-storage-libsql.cjs +3 -0
- package/dist/entry-storage-libsql.d.cts +2 -0
- package/dist/entry-storage-libsql.d.mts +2 -0
- package/dist/entry-storage-libsql.mjs +2 -0
- package/dist/entry-storage-memory.cjs +78 -0
- package/dist/entry-storage-memory.cjs.map +1 -0
- package/dist/entry-storage-memory.d.cts +35 -0
- package/dist/entry-storage-memory.d.mts +35 -0
- package/dist/entry-storage-memory.mjs +77 -0
- package/dist/entry-storage-memory.mjs.map +1 -0
- package/dist/entry-storage-mongodb-internals.cjs +5 -0
- package/dist/entry-storage-mongodb-internals.d.cts +2 -0
- package/dist/entry-storage-mongodb-internals.d.mts +2 -0
- package/dist/entry-storage-mongodb-internals.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +3 -0
- package/dist/entry-storage-mongodb.d.cts +2 -0
- package/dist/entry-storage-mongodb.d.mts +2 -0
- package/dist/entry-storage-mongodb.mjs +2 -0
- package/dist/entry-storage-postgres-internals.cjs +6 -0
- package/dist/entry-storage-postgres-internals.d.cts +2 -0
- package/dist/entry-storage-postgres-internals.d.mts +2 -0
- package/dist/entry-storage-postgres-internals.mjs +2 -0
- package/dist/entry-storage-postgres.cjs +4 -0
- package/dist/entry-storage-postgres.d.cts +2 -0
- package/dist/entry-storage-postgres.d.mts +2 -0
- package/dist/entry-storage-postgres.mjs +2 -0
- package/dist/entry-storage-redis-internals.cjs +7 -0
- package/dist/entry-storage-redis-internals.d.cts +2 -0
- package/dist/entry-storage-redis-internals.d.mts +2 -0
- package/dist/entry-storage-redis-internals.mjs +2 -0
- package/dist/entry-storage-redis.cjs +4 -0
- package/dist/entry-storage-redis.d.cts +2 -0
- package/dist/entry-storage-redis.d.mts +2 -0
- package/dist/entry-storage-redis.mjs +2 -0
- package/dist/entry-storage-sqlite-internals.cjs +7 -0
- package/dist/entry-storage-sqlite-internals.d.cts +3 -0
- package/dist/entry-storage-sqlite-internals.d.mts +3 -0
- package/dist/entry-storage-sqlite-internals.mjs +3 -0
- package/dist/entry-storage-sqlite.cjs +3 -0
- package/dist/entry-storage-sqlite.d.cts +2 -0
- package/dist/entry-storage-sqlite.d.mts +2 -0
- package/dist/entry-storage-sqlite.mjs +2 -0
- package/dist/entry-storage-testing.cjs +801 -0
- package/dist/entry-storage-testing.cjs.map +1 -0
- package/dist/entry-storage-testing.d.cts +150 -0
- package/dist/entry-storage-testing.d.mts +150 -0
- package/dist/entry-storage-testing.mjs +790 -0
- package/dist/entry-storage-testing.mjs.map +1 -0
- package/dist/entry-storage-unstorage.cjs +78 -0
- package/dist/entry-storage-unstorage.cjs.map +1 -0
- package/dist/entry-storage-unstorage.d.cts +30 -0
- package/dist/entry-storage-unstorage.d.mts +30 -0
- package/dist/entry-storage-unstorage.mjs +77 -0
- package/dist/entry-storage-unstorage.mjs.map +1 -0
- package/dist/entry-storage.cjs +114 -0
- package/dist/entry-storage.cjs.map +1 -0
- package/dist/entry-storage.d.cts +152 -0
- package/dist/entry-storage.d.mts +152 -0
- package/dist/entry-storage.mjs +91 -0
- package/dist/entry-storage.mjs.map +1 -0
- package/dist/entry-testing.cjs +79 -0
- package/dist/entry-testing.cjs.map +1 -0
- package/dist/entry-testing.d.cts +55 -0
- package/dist/entry-testing.d.mts +55 -0
- package/dist/entry-testing.mjs +77 -0
- package/dist/entry-testing.mjs.map +1 -0
- package/dist/entry-tokens.cjs +4 -0
- package/dist/entry-tokens.d.cts +85 -0
- package/dist/entry-tokens.d.mts +85 -0
- package/dist/entry-tokens.mjs +2 -0
- package/dist/entry-ui-embed.cjs +131 -0
- package/dist/entry-ui-embed.cjs.map +1 -0
- package/dist/entry-ui-embed.d.cts +87 -0
- package/dist/entry-ui-embed.d.mts +87 -0
- package/dist/entry-ui-embed.mjs +127 -0
- package/dist/entry-ui-embed.mjs.map +1 -0
- package/dist/entry-ui.cjs +795 -0
- package/dist/entry-ui.cjs.map +1 -0
- package/dist/entry-ui.d.cts +574 -0
- package/dist/entry-ui.d.mts +574 -0
- package/dist/entry-ui.mjs +731 -0
- package/dist/entry-ui.mjs.map +1 -0
- package/dist/entry-util.cjs +145 -0
- package/dist/entry-util.cjs.map +1 -0
- package/dist/entry-util.d.cts +85 -0
- package/dist/entry-util.d.mts +85 -0
- package/dist/entry-util.mjs +130 -0
- package/dist/entry-util.mjs.map +1 -0
- package/dist/http-B_rTnLW9.cjs +235 -0
- package/dist/http-B_rTnLW9.cjs.map +1 -0
- package/dist/http-CxYM7kPT.d.mts +133 -0
- package/dist/http-DVdVI6kJ.mjs +164 -0
- package/dist/http-DVdVI6kJ.mjs.map +1 -0
- package/dist/http-XBVRk8uo.d.cts +133 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json-CCyzstIm.d.cts +44 -0
- package/dist/json-CCyzstIm.d.mts +44 -0
- package/dist/json-CM7TwYQ7.cjs +92 -0
- package/dist/json-CM7TwYQ7.cjs.map +1 -0
- package/dist/json-CmM1M5Kz.mjs +63 -0
- package/dist/json-CmM1M5Kz.mjs.map +1 -0
- package/dist/keys-Bwubabk0.mjs +73 -0
- package/dist/keys-Bwubabk0.mjs.map +1 -0
- package/dist/keys-DQrwxDKI.cjs +126 -0
- package/dist/keys-DQrwxDKI.cjs.map +1 -0
- package/dist/kv-sqlite-B6iTLOx2.d.cts +20 -0
- package/dist/kv-sqlite-CHOdIMJ-.cjs +77 -0
- package/dist/kv-sqlite-CHOdIMJ-.cjs.map +1 -0
- package/dist/kv-sqlite-DIIPfflJ.mjs +66 -0
- package/dist/kv-sqlite-DIIPfflJ.mjs.map +1 -0
- package/dist/kv-sqlite-Tx4UedJs.d.mts +20 -0
- package/dist/libsql-0160BubR.d.mts +65 -0
- package/dist/libsql-BZmRZIqt.d.cts +65 -0
- package/dist/libsql-CiBfVtbS.cjs +103 -0
- package/dist/libsql-CiBfVtbS.cjs.map +1 -0
- package/dist/libsql-CkOjQINi.mjs +86 -0
- package/dist/libsql-CkOjQINi.mjs.map +1 -0
- package/dist/mongodb--Cuj7V_9.cjs +150 -0
- package/dist/mongodb--Cuj7V_9.cjs.map +1 -0
- package/dist/mongodb-DGtsolQ2.d.cts +61 -0
- package/dist/mongodb-JMizy4Wg.mjs +127 -0
- package/dist/mongodb-JMizy4Wg.mjs.map +1 -0
- package/dist/mongodb-xGEU5Gwz.d.mts +61 -0
- package/dist/node-B1Djcwfi.d.cts +57 -0
- package/dist/node-B1Djcwfi.d.mts +57 -0
- package/dist/node-BYjocCbU.mjs +167 -0
- package/dist/node-BYjocCbU.mjs.map +1 -0
- package/dist/node-DFFqYRk-.cjs +201 -0
- package/dist/node-DFFqYRk-.cjs.map +1 -0
- package/dist/none-BEY7Kc_-.mjs +33 -0
- package/dist/none-BEY7Kc_-.mjs.map +1 -0
- package/dist/none-BoQ6-30P.cjs +33 -0
- package/dist/none-BoQ6-30P.cjs.map +1 -0
- package/dist/none-CHwVkQL-.cjs +49 -0
- package/dist/none-CHwVkQL-.cjs.map +1 -0
- package/dist/none-yu3qC47E.mjs +23 -0
- package/dist/none-yu3qC47E.mjs.map +1 -0
- package/dist/peer-BIjBFzwQ.cjs +56 -0
- package/dist/peer-BIjBFzwQ.cjs.map +1 -0
- package/dist/peer-CTHMzOdn.mjs +40 -0
- package/dist/peer-CTHMzOdn.mjs.map +1 -0
- package/dist/portal-container-CJIcau3B.mjs +610 -0
- package/dist/portal-container-CJIcau3B.mjs.map +1 -0
- package/dist/portal-container-Ca1NxrLE.cjs +774 -0
- package/dist/portal-container-Ca1NxrLE.cjs.map +1 -0
- package/dist/postgres-BJzxKBk0.d.cts +72 -0
- package/dist/postgres-CA8_XcAE.cjs +164 -0
- package/dist/postgres-CA8_XcAE.cjs.map +1 -0
- package/dist/postgres-RfQMgAsj.d.mts +72 -0
- package/dist/postgres-aDiBmNzr.mjs +135 -0
- package/dist/postgres-aDiBmNzr.mjs.map +1 -0
- package/dist/redis-B2AS4xAQ.cjs +259 -0
- package/dist/redis-B2AS4xAQ.cjs.map +1 -0
- package/dist/redis-B362ofBw.d.cts +159 -0
- package/dist/redis-CahNAVTW.d.mts +159 -0
- package/dist/redis-hdoKymfG.mjs +218 -0
- package/dist/redis-hdoKymfG.mjs.map +1 -0
- package/dist/roles-7JPrQXZa.mjs +46 -0
- package/dist/roles-7JPrQXZa.mjs.map +1 -0
- package/dist/roles-B_8QqJ3j.cjs +56 -0
- package/dist/roles-B_8QqJ3j.cjs.map +1 -0
- package/dist/roles-DLISB4T3.d.mts +41 -0
- package/dist/roles-DQbbtUPW.d.cts +41 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/scope-css-BN3jf0ly.cjs +315 -0
- package/dist/scope-css-BN3jf0ly.cjs.map +1 -0
- package/dist/scope-css-BuJfRCsE.mjs +256 -0
- package/dist/scope-css-BuJfRCsE.mjs.map +1 -0
- package/dist/scoped-BRoE1W1x.cjs +175 -0
- package/dist/scoped-BRoE1W1x.cjs.map +1 -0
- package/dist/scoped-cFBbotCh.mjs +164 -0
- package/dist/scoped-cFBbotCh.mjs.map +1 -0
- package/dist/sqlite-B2g1JJz1.d.cts +47 -0
- package/dist/sqlite-BIPIlxfj.d.mts +47 -0
- package/dist/sqlite-BntoYaXZ.cjs +79 -0
- package/dist/sqlite-BntoYaXZ.cjs.map +1 -0
- package/dist/sqlite-DYJDcu7p.mjs +62 -0
- package/dist/sqlite-DYJDcu7p.mjs.map +1 -0
- package/dist/table-BrioFSra.d.cts +11 -0
- package/dist/table-BrioFSra.d.mts +11 -0
- package/dist/theme-context-DzZ1otaD.d.cts +270 -0
- package/dist/theme-context-J65pythD.d.mts +270 -0
- package/dist/ui/styles.css +239 -0
- package/dist/util-Dnj5T-yw.mjs +39 -0
- package/dist/util-Dnj5T-yw.mjs.map +1 -0
- package/dist/util-dAnTK9x-.cjs +74 -0
- package/dist/util-dAnTK9x-.cjs.map +1 -0
- package/dist/validation-B-atP968.mjs +191 -0
- package/dist/validation-B-atP968.mjs.map +1 -0
- package/dist/validation-BJifGoB2.d.mts +122 -0
- package/dist/validation-DLnzBVJr.cjs +258 -0
- package/dist/validation-DLnzBVJr.cjs.map +1 -0
- package/dist/validation-tfV2qhbD.d.cts +122 -0
- package/package.json +715 -4
- package/tsconfig/assets.d.ts +21 -0
- package/tsconfig/base.json +21 -0
- package/tsconfig/react.json +9 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { n as Principal, t as AuthProvider } from "./contract-B3UPXXLx.cjs";
|
|
2
|
+
import { r as AuthorizationProvider } from "./contract-BIVzAn4f.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/server/http.d.ts
|
|
5
|
+
/** Content type of every JSON response. */
|
|
6
|
+
declare const JSON_CONTENT_TYPE = "application/json; charset=utf-8";
|
|
7
|
+
/** A JSON response. */
|
|
8
|
+
declare const json: (data: unknown, status?: number, headers?: Record<string, string>) => Response;
|
|
9
|
+
/** A JSON error response: `{ error: message, ...extra }`. */
|
|
10
|
+
declare const error: (status: number, message: string, extra?: Record<string, unknown>, headers?: Record<string, string>) => Response;
|
|
11
|
+
/** `405` with the `Allow` header listing the methods the path supports. */
|
|
12
|
+
declare const methodNotAllowed: (allow: Iterable<string>) => Response;
|
|
13
|
+
/** An empty `204`. */
|
|
14
|
+
declare const noContent: () => Response;
|
|
15
|
+
/** Throw inside a router to short-circuit with `error(status, message, extra)`. */
|
|
16
|
+
declare class HttpError extends Error {
|
|
17
|
+
readonly status: number;
|
|
18
|
+
readonly extra?: Record<string, unknown> | undefined;
|
|
19
|
+
constructor(status: number, message: string, extra?: Record<string, unknown> | undefined);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Match `pattern` (with `:name` segments) against `path`; returns the decoded
|
|
23
|
+
* params, or `null`. A malformed `%` escape is **no match** (404), never a
|
|
24
|
+
* thrown `URIError` (500).
|
|
25
|
+
*/
|
|
26
|
+
declare function match(pattern: string, path: string): Record<string, string> | null;
|
|
27
|
+
/** Options for {@link intParam}. */
|
|
28
|
+
interface IntParamOptions {
|
|
29
|
+
/**
|
|
30
|
+
* What an unparseable value does: `"throw"` an {@link HttpError} 400
|
|
31
|
+
* (audit, entitlements) or `"ignore"` it as if absent (webhooks, flags,
|
|
32
|
+
* links). Part of a product's HTTP contract (ADR 0010). Default `"throw"`.
|
|
33
|
+
*/
|
|
34
|
+
invalid?: "throw" | "ignore";
|
|
35
|
+
/** Require a value > 0 (fractions are floored). With `false`, any integer. Default `true`. */
|
|
36
|
+
positive?: boolean;
|
|
37
|
+
/** The parameter name, for the error message. */
|
|
38
|
+
name?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Parse an integer query param; `undefined` when absent or empty. */
|
|
41
|
+
declare function intParam(value: string | null, options?: IntParamOptions): number | undefined;
|
|
42
|
+
/** How one named domain error maps to a response. */
|
|
43
|
+
type ErrorMapping = {
|
|
44
|
+
status: number;
|
|
45
|
+
code?: string;
|
|
46
|
+
extra?: (error: Error) => Record<string, unknown>;
|
|
47
|
+
} | ((error: Error) => Response);
|
|
48
|
+
/**
|
|
49
|
+
* Domain errors by `name` → response. Names, not classes, so an error thrown
|
|
50
|
+
* from another bundle's copy of the class still maps (see `isNamed`).
|
|
51
|
+
*/
|
|
52
|
+
type ErrorMap = Record<string, ErrorMapping>;
|
|
53
|
+
/**
|
|
54
|
+
* Map an error to a response:
|
|
55
|
+
*
|
|
56
|
+
* 1. {@link HttpError} → its status and extras.
|
|
57
|
+
* 2. An entry of `errors` matching the error's `name`.
|
|
58
|
+
* 3. Built-ins (each overridable by an `errors` entry of the same name):
|
|
59
|
+
* `HookDeniedError` (any bundle) → its status, `code: "HOOK_DENIED"`; a
|
|
60
|
+
* kit `TokenError`, or any error named `*TokenError` (`PortalTokenError`,
|
|
61
|
+
* `ViewerTokenError` from another bundle) → 401 `code: "TOKEN"`; `ValidationError` → 400 `code: "VALIDATION"`
|
|
62
|
+
* with `errors`; `SyntaxError` → 400 "Invalid JSON body".
|
|
63
|
+
* 4. Anything else → 500 with the error message.
|
|
64
|
+
*/
|
|
65
|
+
declare function mapError(err: unknown, errors?: ErrorMap): Response;
|
|
66
|
+
/** How a product verifies its scoped (portal / viewer) tokens. */
|
|
67
|
+
interface ScopedAuth<Grant> {
|
|
68
|
+
/** The token prefix (`"whpt_"`…). A `Bearer <prefix>…` header takes the scoped lane. */
|
|
69
|
+
prefix: string;
|
|
70
|
+
/** Verify the token; throw (e.g. a `TokenError`) when it is invalid or expired. */
|
|
71
|
+
verify(token: string, request: Request): Promise<Grant>;
|
|
72
|
+
/** The principal a verified grant acts as (e.g. `{ id: "portal:acme" }`). */
|
|
73
|
+
principal(grant: Grant): Principal;
|
|
74
|
+
}
|
|
75
|
+
/** The outcome of {@link authenticate}. */
|
|
76
|
+
interface Authenticated<Grant> {
|
|
77
|
+
principal: Principal | null;
|
|
78
|
+
/** The verified scoped-token grant, or `null` for host-authenticated (or anonymous) requests. */
|
|
79
|
+
scoped: Grant | null;
|
|
80
|
+
}
|
|
81
|
+
/** Options for {@link authenticate}. */
|
|
82
|
+
interface AuthenticateOptions<Grant> {
|
|
83
|
+
/** The host's provider. */
|
|
84
|
+
auth: AuthProvider;
|
|
85
|
+
/** The product's scoped tokens, when configured. */
|
|
86
|
+
scoped?: ScopedAuth<Grant>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Authenticate a request.
|
|
90
|
+
*
|
|
91
|
+
* - A `Bearer <prefix>…` token **short-circuits** the host's provider: a valid
|
|
92
|
+
* token yields the scoped principal; an invalid or expired one throws
|
|
93
|
+
* (→ 401 through {@link mapError}). It never falls back to the host's auth
|
|
94
|
+
* with an explicitly presented, rejected credential.
|
|
95
|
+
* - Otherwise the host's provider runs. **If it throws, the error propagates**
|
|
96
|
+
* (→ 500): a broken identity provider is a server failure, not bad
|
|
97
|
+
* credentials. `null` means "not authenticated".
|
|
98
|
+
*/
|
|
99
|
+
declare function authenticate<Grant>(request: Request, options: AuthenticateOptions<Grant>): Promise<Authenticated<Grant>>;
|
|
100
|
+
/** Options for {@link authorize}. */
|
|
101
|
+
interface AuthorizeOptions<Action extends string, Resource, Grant> {
|
|
102
|
+
/** The host's provider, consulted for host-authenticated principals only. */
|
|
103
|
+
authorization: AuthorizationProvider<Action, Resource>;
|
|
104
|
+
/**
|
|
105
|
+
* Decide what a scoped grant may do. Without it, scoped principals are denied
|
|
106
|
+
* everything.
|
|
107
|
+
*/
|
|
108
|
+
scope?: (grant: Grant, action: Action, resource: Resource) => boolean | Promise<boolean>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Authorize an authenticated request. A scoped principal is decided by
|
|
112
|
+
* `scope` alone — the host's provider is **not consulted** (defence in depth:
|
|
113
|
+
* a permissive host policy can't widen a token).
|
|
114
|
+
*/
|
|
115
|
+
declare function authorize<Action extends string, Resource, Grant>(who: Authenticated<Grant>, input: {
|
|
116
|
+
action: Action;
|
|
117
|
+
resource: Resource;
|
|
118
|
+
request: Request;
|
|
119
|
+
}, options: AuthorizeOptions<Action, Resource, Grant>): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Throw a clear error when none of `keys` is set on `options` — the "requires
|
|
122
|
+
* `storage` or a prebuilt `core`" guard every product's panel needs.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* requireOneOf("createFetchHandler", options, ["storage", "core"]);
|
|
127
|
+
* // Error: createFetchHandler requires either `storage` or `core`.
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function requireOneOf(caller: string, options: object, keys: readonly string[]): void;
|
|
131
|
+
//#endregion
|
|
132
|
+
export { methodNotAllowed as _, ErrorMapping as a, JSON_CONTENT_TYPE as c, authorize as d, error as f, match as g, mapError as h, ErrorMap as i, ScopedAuth as l, json as m, Authenticated as n, HttpError as o, intParam as p, AuthorizeOptions as r, IntParamOptions as s, AuthenticateOptions as t, authenticate as u, noContent as v, requireOneOf as y };
|
|
133
|
+
//# sourceMappingURL=http-XBVRk8uo.d.cts.map
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/version.ts
|
|
3
|
+
/** The `@xtandard/kit` version (kept in sync with package.json by the release script). */
|
|
4
|
+
const VERSION = "0.1.0";
|
|
5
|
+
//#endregion
|
|
6
|
+
exports.VERSION = VERSION;
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/** The `@xtandard/kit` version (kept in sync with package.json by the release script). */\nexport const VERSION = \"0.1.0\";\n"],"mappings":";;;AACA,MAAa,UAAU"}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/** The `@xtandard/kit` version (kept in sync with package.json by the release script). */\nexport const VERSION = \"0.1.0\";\n"],"mappings":";;AACA,MAAa,UAAU"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/internal/json.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* JSON helpers shared across the kit: canonical forms (object keys sorted recursively) for
|
|
4
|
+
* order-insensitive comparison and compare-and-swap, own-property structural equality, and the
|
|
5
|
+
* JSON value types.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** A JSON-serialisable value. */
|
|
10
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/** A JSON object. */
|
|
14
|
+
type JsonObject = {
|
|
15
|
+
[key: string]: JsonValue;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal
|
|
19
|
+
* values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are
|
|
20
|
+
* dropped, `toJSON` is honoured, non-finite numbers become `null`).
|
|
21
|
+
*/
|
|
22
|
+
declare function canonical<T>(value: T): T;
|
|
23
|
+
/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */
|
|
24
|
+
declare const canonicalJson: (value: unknown) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that
|
|
27
|
+
* must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike
|
|
28
|
+
* {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785
|
|
29
|
+
* (JCS) for strings and integers. A top-level `undefined` serialises as `null`.
|
|
30
|
+
*/
|
|
31
|
+
declare function canonicalStringify(value: JsonValue | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own
|
|
34
|
+
* properties only (`{a: undefined}` is not equal to `{b: undefined}`).
|
|
35
|
+
*/
|
|
36
|
+
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already
|
|
39
|
+
* parsed; a string is parsed defensively (and returned as-is if it is not JSON).
|
|
40
|
+
*/
|
|
41
|
+
declare function parseJsonValue<T>(value: unknown): T;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { canonicalStringify as a, canonicalJson as i, JsonValue as n, deepEqual as o, canonical as r, parseJsonValue as s, JsonObject as t };
|
|
44
|
+
//# sourceMappingURL=json-CCyzstIm.d.cts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/internal/json.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* JSON helpers shared across the kit: canonical forms (object keys sorted recursively) for
|
|
4
|
+
* order-insensitive comparison and compare-and-swap, own-property structural equality, and the
|
|
5
|
+
* JSON value types.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** A JSON-serialisable value. */
|
|
10
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
11
|
+
[key: string]: JsonValue;
|
|
12
|
+
};
|
|
13
|
+
/** A JSON object. */
|
|
14
|
+
type JsonObject = {
|
|
15
|
+
[key: string]: JsonValue;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal
|
|
19
|
+
* values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are
|
|
20
|
+
* dropped, `toJSON` is honoured, non-finite numbers become `null`).
|
|
21
|
+
*/
|
|
22
|
+
declare function canonical<T>(value: T): T;
|
|
23
|
+
/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */
|
|
24
|
+
declare const canonicalJson: (value: unknown) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that
|
|
27
|
+
* must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike
|
|
28
|
+
* {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785
|
|
29
|
+
* (JCS) for strings and integers. A top-level `undefined` serialises as `null`.
|
|
30
|
+
*/
|
|
31
|
+
declare function canonicalStringify(value: JsonValue | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own
|
|
34
|
+
* properties only (`{a: undefined}` is not equal to `{b: undefined}`).
|
|
35
|
+
*/
|
|
36
|
+
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already
|
|
39
|
+
* parsed; a string is parsed defensively (and returned as-is if it is not JSON).
|
|
40
|
+
*/
|
|
41
|
+
declare function parseJsonValue<T>(value: unknown): T;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { canonicalStringify as a, canonicalJson as i, JsonValue as n, deepEqual as o, canonical as r, parseJsonValue as s, JsonObject as t };
|
|
44
|
+
//# sourceMappingURL=json-CCyzstIm.d.mts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/internal/json.ts
|
|
2
|
+
/**
|
|
3
|
+
* A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal
|
|
4
|
+
* values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are
|
|
5
|
+
* dropped, `toJSON` is honoured, non-finite numbers become `null`).
|
|
6
|
+
*/
|
|
7
|
+
function canonical(value) {
|
|
8
|
+
if (value === void 0) return value;
|
|
9
|
+
return sortKeys(JSON.parse(JSON.stringify(value)));
|
|
10
|
+
}
|
|
11
|
+
function sortKeys(value) {
|
|
12
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
13
|
+
if (value === null || typeof value !== "object") return value;
|
|
14
|
+
const out = {};
|
|
15
|
+
for (const key of Object.keys(value).sort()) out[key] = sortKeys(value[key]);
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */
|
|
19
|
+
const canonicalJson = (value) => JSON.stringify(canonical(value));
|
|
20
|
+
/**
|
|
21
|
+
* Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that
|
|
22
|
+
* must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike
|
|
23
|
+
* {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785
|
|
24
|
+
* (JCS) for strings and integers. A top-level `undefined` serialises as `null`.
|
|
25
|
+
*/
|
|
26
|
+
function canonicalStringify(value) {
|
|
27
|
+
if (value === void 0) return "null";
|
|
28
|
+
if (value === null || typeof value !== "object") {
|
|
29
|
+
if (typeof value === "number" && !Number.isFinite(value)) throw new TypeError(`canonicalStringify: non-finite number ${value}`);
|
|
30
|
+
return JSON.stringify(value);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) return `[${value.map((v) => canonicalStringify(v)).join(",")}]`;
|
|
33
|
+
return `{${Object.keys(value).sort().filter((k) => value[k] !== void 0).map((k) => `${JSON.stringify(k)}:${canonicalStringify(value[k])}`).join(",")}}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own
|
|
37
|
+
* properties only (`{a: undefined}` is not equal to `{b: undefined}`).
|
|
38
|
+
*/
|
|
39
|
+
function deepEqual(a, b) {
|
|
40
|
+
if (a === b) return true;
|
|
41
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
42
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
43
|
+
const ka = Object.keys(a);
|
|
44
|
+
const kb = Object.keys(b);
|
|
45
|
+
if (ka.length !== kb.length) return false;
|
|
46
|
+
return ka.every((k) => Object.prototype.hasOwnProperty.call(b, k) && deepEqual(a[k], b[k]));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already
|
|
50
|
+
* parsed; a string is parsed defensively (and returned as-is if it is not JSON).
|
|
51
|
+
*/
|
|
52
|
+
function parseJsonValue(value) {
|
|
53
|
+
if (typeof value !== "string") return value;
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(value);
|
|
56
|
+
} catch {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
Object.defineProperty(exports, "canonical", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return canonical;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "canonicalJson", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function() {
|
|
70
|
+
return canonicalJson;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "canonicalStringify", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function() {
|
|
76
|
+
return canonicalStringify;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, "deepEqual", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function() {
|
|
82
|
+
return deepEqual;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "parseJsonValue", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function() {
|
|
88
|
+
return parseJsonValue;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=json-CM7TwYQ7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-CM7TwYQ7.cjs","names":[],"sources":["../src/internal/json.ts"],"sourcesContent":["/**\n * JSON helpers shared across the kit: canonical forms (object keys sorted recursively) for\n * order-insensitive comparison and compare-and-swap, own-property structural equality, and the\n * JSON value types.\n *\n * @module\n */\n\n/** A JSON-serialisable value. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\n/** A JSON object. */\nexport type JsonObject = { [key: string]: JsonValue };\n\n/**\n * A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal\n * values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are\n * dropped, `toJSON` is honoured, non-finite numbers become `null`).\n */\nexport function canonical<T>(value: T): T {\n if (value === undefined) return value;\n return sortKeys(JSON.parse(JSON.stringify(value)) as unknown) as T;\n}\n\nfunction sortKeys(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortKeys);\n if (value === null || typeof value !== \"object\") return value;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort())\n out[key] = sortKeys((value as Record<string, unknown>)[key]);\n return out;\n}\n\n/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */\nexport const canonicalJson = (value: unknown): string => JSON.stringify(canonical(value));\n\n/**\n * Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that\n * must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike\n * {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785\n * (JCS) for strings and integers. A top-level `undefined` serialises as `null`.\n */\nexport function canonicalStringify(value: JsonValue | undefined): string {\n if (value === undefined) return \"null\";\n if (value === null || typeof value !== \"object\") {\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n throw new TypeError(`canonicalStringify: non-finite number ${value}`);\n }\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) return `[${value.map((v) => canonicalStringify(v)).join(\",\")}]`;\n const entries = Object.keys(value)\n .sort()\n .filter((k) => value[k] !== undefined)\n .map((k) => `${JSON.stringify(k)}:${canonicalStringify(value[k] as JsonValue)}`);\n return `{${entries.join(\",\")}}`;\n}\n\n/**\n * Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own\n * properties only (`{a: undefined}` is not equal to `{b: undefined}`).\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== \"object\" || typeof b !== \"object\") return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n return ka.every(\n (k) =>\n Object.prototype.hasOwnProperty.call(b, k) &&\n deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]),\n );\n}\n\n/**\n * Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already\n * parsed; a string is parsed defensively (and returned as-is if it is not JSON).\n */\nexport function parseJsonValue<T>(value: unknown): T {\n if (typeof value !== \"string\") return value as T;\n try {\n return JSON.parse(value) as T;\n } catch {\n return value as T;\n }\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,UAAa,OAAa;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,SAAS,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAY;AAC9D;AAEA,SAAS,SAAS,OAAyB;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,QAAQ;CACnD,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK,GACxC,IAAI,OAAO,SAAU,MAAkC,IAAI;CAC7D,OAAO;AACT;;AAGA,MAAa,iBAAiB,UAA2B,KAAK,UAAU,UAAU,KAAK,CAAC;;;;;;;AAQxF,SAAgB,mBAAmB,OAAsC;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC/C,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GACrD,MAAM,IAAI,UAAU,yCAAyC,OAAO;EAEtE,OAAO,KAAK,UAAU,KAAK;CAC7B;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,KAAK,MAAM,mBAAmB,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE;CAKvF,OAAO,IAJS,OAAO,KAAK,KAAK,EAC9B,KAAK,EACL,QAAQ,MAAM,MAAM,OAAO,KAAA,CAAS,EACpC,KAAK,MAAM,GAAG,KAAK,UAAU,CAAC,EAAE,GAAG,mBAAmB,MAAM,EAAe,GAC7D,EAAE,KAAK,GAAG,EAAE;AAC/B;;;;;AAMA,SAAgB,UAAU,GAAY,GAAqB;CACzD,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,MAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU,OAAO;CACvF,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,MAAM,KAAK,OAAO,KAAK,CAAW;CAClC,MAAM,KAAK,OAAO,KAAK,CAAW;CAClC,IAAI,GAAG,WAAW,GAAG,QAAQ,OAAO;CACpC,OAAO,GAAG,OACP,MACC,OAAO,UAAU,eAAe,KAAK,GAAG,CAAC,KACzC,UAAW,EAA8B,IAAK,EAA8B,EAAE,CAClF;AACF;;;;;AAMA,SAAgB,eAAkB,OAAmB;CACnD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/internal/json.ts
|
|
2
|
+
/**
|
|
3
|
+
* A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal
|
|
4
|
+
* values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are
|
|
5
|
+
* dropped, `toJSON` is honoured, non-finite numbers become `null`).
|
|
6
|
+
*/
|
|
7
|
+
function canonical(value) {
|
|
8
|
+
if (value === void 0) return value;
|
|
9
|
+
return sortKeys(JSON.parse(JSON.stringify(value)));
|
|
10
|
+
}
|
|
11
|
+
function sortKeys(value) {
|
|
12
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
13
|
+
if (value === null || typeof value !== "object") return value;
|
|
14
|
+
const out = {};
|
|
15
|
+
for (const key of Object.keys(value).sort()) out[key] = sortKeys(value[key]);
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */
|
|
19
|
+
const canonicalJson = (value) => JSON.stringify(canonical(value));
|
|
20
|
+
/**
|
|
21
|
+
* Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that
|
|
22
|
+
* must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike
|
|
23
|
+
* {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785
|
|
24
|
+
* (JCS) for strings and integers. A top-level `undefined` serialises as `null`.
|
|
25
|
+
*/
|
|
26
|
+
function canonicalStringify(value) {
|
|
27
|
+
if (value === void 0) return "null";
|
|
28
|
+
if (value === null || typeof value !== "object") {
|
|
29
|
+
if (typeof value === "number" && !Number.isFinite(value)) throw new TypeError(`canonicalStringify: non-finite number ${value}`);
|
|
30
|
+
return JSON.stringify(value);
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) return `[${value.map((v) => canonicalStringify(v)).join(",")}]`;
|
|
33
|
+
return `{${Object.keys(value).sort().filter((k) => value[k] !== void 0).map((k) => `${JSON.stringify(k)}:${canonicalStringify(value[k])}`).join(",")}}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own
|
|
37
|
+
* properties only (`{a: undefined}` is not equal to `{b: undefined}`).
|
|
38
|
+
*/
|
|
39
|
+
function deepEqual(a, b) {
|
|
40
|
+
if (a === b) return true;
|
|
41
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
42
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
43
|
+
const ka = Object.keys(a);
|
|
44
|
+
const kb = Object.keys(b);
|
|
45
|
+
if (ka.length !== kb.length) return false;
|
|
46
|
+
return ka.every((k) => Object.prototype.hasOwnProperty.call(b, k) && deepEqual(a[k], b[k]));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already
|
|
50
|
+
* parsed; a string is parsed defensively (and returned as-is if it is not JSON).
|
|
51
|
+
*/
|
|
52
|
+
function parseJsonValue(value) {
|
|
53
|
+
if (typeof value !== "string") return value;
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(value);
|
|
56
|
+
} catch {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { parseJsonValue as a, deepEqual as i, canonicalJson as n, canonicalStringify as r, canonical as t };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=json-CmM1M5Kz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-CmM1M5Kz.mjs","names":[],"sources":["../src/internal/json.ts"],"sourcesContent":["/**\n * JSON helpers shared across the kit: canonical forms (object keys sorted recursively) for\n * order-insensitive comparison and compare-and-swap, own-property structural equality, and the\n * JSON value types.\n *\n * @module\n */\n\n/** A JSON-serialisable value. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\n/** A JSON object. */\nexport type JsonObject = { [key: string]: JsonValue };\n\n/**\n * A JSON-equivalent copy of `value` with object keys sorted recursively, so two structurally equal\n * values serialise identically. `JSON.stringify` semantics apply first (`undefined` members are\n * dropped, `toJSON` is honoured, non-finite numbers become `null`).\n */\nexport function canonical<T>(value: T): T {\n if (value === undefined) return value;\n return sortKeys(JSON.parse(JSON.stringify(value)) as unknown) as T;\n}\n\nfunction sortKeys(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortKeys);\n if (value === null || typeof value !== \"object\") return value;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort())\n out[key] = sortKeys((value as Record<string, unknown>)[key]);\n return out;\n}\n\n/** `JSON.stringify` of the {@link canonical} form: equal values ⇒ equal strings. */\nexport const canonicalJson = (value: unknown): string => JSON.stringify(canonical(value));\n\n/**\n * Strict canonical serialisation (keys sorted at every depth, no whitespace) for byte formats that\n * must not silently change values — e.g. integrity hashes and idempotency comparison. Unlike\n * {@link canonicalJson} it **throws** on non-finite numbers instead of writing `null`. Matches RFC 8785\n * (JCS) for strings and integers. A top-level `undefined` serialises as `null`.\n */\nexport function canonicalStringify(value: JsonValue | undefined): string {\n if (value === undefined) return \"null\";\n if (value === null || typeof value !== \"object\") {\n if (typeof value === \"number\" && !Number.isFinite(value)) {\n throw new TypeError(`canonicalStringify: non-finite number ${value}`);\n }\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) return `[${value.map((v) => canonicalStringify(v)).join(\",\")}]`;\n const entries = Object.keys(value)\n .sort()\n .filter((k) => value[k] !== undefined)\n .map((k) => `${JSON.stringify(k)}:${canonicalStringify(value[k] as JsonValue)}`);\n return `{${entries.join(\",\")}}`;\n}\n\n/**\n * Structural equality for JSON-shaped values: key order ignored, arrays ordered, and own\n * properties only (`{a: undefined}` is not equal to `{b: undefined}`).\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== \"object\" || typeof b !== \"object\") return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n return ka.every(\n (k) =>\n Object.prototype.hasOwnProperty.call(b, k) &&\n deepEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]),\n );\n}\n\n/**\n * Normalise a JSON column value: `pg`, `pglite` and Drizzle usually return `json`/`jsonb` already\n * parsed; a string is parsed defensively (and returned as-is if it is not JSON).\n */\nexport function parseJsonValue<T>(value: unknown): T {\n if (typeof value !== \"string\") return value as T;\n try {\n return JSON.parse(value) as T;\n } catch {\n return value as T;\n }\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,UAAa,OAAa;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,OAAO,SAAS,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAY;AAC9D;AAEA,SAAS,SAAS,OAAyB;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,QAAQ;CACnD,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK,GACxC,IAAI,OAAO,SAAU,MAAkC,IAAI;CAC7D,OAAO;AACT;;AAGA,MAAa,iBAAiB,UAA2B,KAAK,UAAU,UAAU,KAAK,CAAC;;;;;;;AAQxF,SAAgB,mBAAmB,OAAsC;CACvE,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAC/C,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GACrD,MAAM,IAAI,UAAU,yCAAyC,OAAO;EAEtE,OAAO,KAAK,UAAU,KAAK;CAC7B;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,IAAI,MAAM,KAAK,MAAM,mBAAmB,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE;CAKvF,OAAO,IAJS,OAAO,KAAK,KAAK,EAC9B,KAAK,EACL,QAAQ,MAAM,MAAM,OAAO,KAAA,CAAS,EACpC,KAAK,MAAM,GAAG,KAAK,UAAU,CAAC,EAAE,GAAG,mBAAmB,MAAM,EAAe,GAC7D,EAAE,KAAK,GAAG,EAAE;AAC/B;;;;;AAMA,SAAgB,UAAU,GAAY,GAAqB;CACzD,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,MAAM,QAAQ,MAAM,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU,OAAO;CACvF,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,MAAM,KAAK,OAAO,KAAK,CAAW;CAClC,MAAM,KAAK,OAAO,KAAK,CAAW;CAClC,IAAI,GAAG,WAAW,GAAG,QAAQ,OAAO;CACpC,OAAO,GAAG,OACP,MACC,OAAO,UAAU,eAAe,KAAK,GAAG,CAAC,KACzC,UAAW,EAA8B,IAAK,EAA8B,EAAE,CAClF;AACF;;;;;AAMA,SAAgB,eAAkB,OAAmB;CACnD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
export { parseSortableLeaf as a, isTransactional as c, padMillis as i, isWatchable as l, encodeSegment as n, sortableLeaf as o, lastSegment as r, isCompareAndSwap as s, decodeSegment as t };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=keys-Bwubabk0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys-Bwubabk0.mjs","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"}
|