@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 @@
|
|
|
1
|
+
{"version":3,"file":"contract-BEdfGTPs.mjs","names":[],"sources":["../src/hooks/contract.ts"],"sourcesContent":["/**\n * The hooks runner shared by every product: `before` hooks run before a write\n * commits and may deny it, `after` hooks run once it has committed.\n *\n * - `before` runs **sequentially**. Throw to deny (e.g. {@link HookDeniedError});\n * the first throw aborts the remaining hooks and propagates to the caller.\n * - `after` runs **concurrently**. Errors are isolated and reported through a\n * {@link HookErrorReporter}; they never reach the caller.\n *\n * The event unions are product data: the runner is generic over\n * `Before extends { type: string }` and `After extends { type: string }`.\n *\n * @module\n */\n\n/** Throw from a `before` hook to deny with a status (default 403). */\nexport class HookDeniedError extends Error {\n /** HTTP status the API layer should respond with. Default `403`. */\n readonly status: number;\n constructor(message: string, options?: { status?: number; cause?: unknown }) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = \"HookDeniedError\";\n this.status = options?.status ?? 403;\n }\n}\n\n/** The minimum shape of a hook event: a `type` discriminant. */\nexport interface HookEvent {\n type: string;\n}\n\n/** A hook: implement either side or both. */\nexport interface Hooks<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> {\n before?(event: Before): void | Promise<void>;\n after?(event: After): void | Promise<void>;\n}\n\n/** Accepts a single hook, an array, or nothing. */\nexport type HooksInput<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> =\n | Hooks<Before, After>\n | readonly Hooks<Before, After>[]\n | undefined;\n\n/** Reports an error thrown by an `after` hook. */\nexport type HookErrorReporter<After extends HookEvent = HookEvent> = (\n error: unknown,\n event: After,\n) => void;\n\n/** Normalize the `hooks` option into a flat array (empty when unset). */\nexport function normalizeHooks<Before extends HookEvent, After extends HookEvent>(\n input: HooksInput<Before, After>,\n): Hooks<Before, After>[] {\n if (!input) return [];\n return Array.isArray(input) ? [...input] : [input as Hooks<Before, After>];\n}\n\n/** Run `before` hooks sequentially; the first throw denies. */\nexport async function runBefore<Before extends HookEvent>(\n hooks: readonly Hooks<Before, never>[],\n event: Before,\n): Promise<void> {\n for (const hook of hooks) {\n if (hook.before) await hook.before(event);\n }\n}\n\n/** Run `after` hooks concurrently; errors go to `onError`, never to the caller. */\nexport async function runAfter<After extends HookEvent>(\n hooks: readonly Hooks<never, After>[],\n event: After,\n onError: HookErrorReporter<After>,\n): Promise<void> {\n await Promise.all(\n hooks.map(async (hook) => {\n if (!hook.after) return;\n try {\n await hook.after(event);\n } catch (error) {\n onError(error, event);\n }\n }),\n );\n}\n\n/**\n * Build an `after`-hook error reporter that warns with `[source]` as the log\n * prefix and never throws. Products pass their package name:\n * `createHookErrorReporter(\"@xtandard/webhooks\")`.\n */\nexport function createHookErrorReporter(source: string): HookErrorReporter {\n return (error, event) => {\n console.warn(`[${source}] after-hook for \"${event.type}\" threw:`, error);\n };\n}\n\n/** Default `after`-hook error reporter: warns with the `[@xtandard/kit]` prefix, never throws. */\nexport const defaultHookErrorReporter: HookErrorReporter = createHookErrorReporter(\"@xtandard/kit\");\n\n/**\n * True when `error` is an error object whose `name` is `name`. Use it instead\n * of `instanceof` to map domain errors to HTTP statuses: an error class loaded\n * from a separate bundle (another subpath's copy of the class, or another\n * realm) fails `instanceof` but keeps its `name`.\n *\n * @example\n * ```ts\n * if (isNamed(err, \"NotFoundError\")) return error(404, err.message, { code: \"NOT_FOUND\" });\n * ```\n */\nexport function isNamed(error: unknown, name: string): error is Error {\n return typeof error === \"object\" && error !== null && (error as { name?: unknown }).name === name;\n}\n\n/**\n * The status of a hook denial — a {@link HookDeniedError}, or a foreign-bundle\n * copy of it recognised by name (default 403 when it carries no numeric\n * `status`) — or `null` when `error` is not a denial.\n */\nexport function hookDeniedStatus(error: unknown): number | null {\n if (!isNamed(error, \"HookDeniedError\")) return null;\n const status = (error as { status?: unknown }).status;\n return typeof status === \"number\" ? status : 403;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,cAAqC,MAAM;;CAEzC;CACA,YAAY,SAAiB,SAAgD;EAC3E,MAAM,SAAS,SAAS,UAAU,KAAA,IAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAA,CAAS;EAClF,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS,UAAU;CACnC;AACF;;AA0BA,SAAgB,eACd,OACwB;CACxB,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,OAAO,MAAM,QAAQ,KAAK,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,KAA6B;AAC3E;;AAGA,eAAsB,UACpB,OACA,OACe;CACf,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,QAAQ,MAAM,KAAK,OAAO,KAAK;AAE5C;;AAGA,eAAsB,SACpB,OACA,OACA,SACe;CACf,MAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;EACxB,IAAI,CAAC,KAAK,OAAO;EACjB,IAAI;GACF,MAAM,KAAK,MAAM,KAAK;EACxB,SAAS,OAAO;GACd,QAAQ,OAAO,KAAK;EACtB;CACF,CAAC,CACH;AACF;;;;;;AAOA,SAAgB,wBAAwB,QAAmC;CACzE,QAAQ,OAAO,UAAU;EACvB,QAAQ,KAAK,IAAI,OAAO,oBAAoB,MAAM,KAAK,WAAW,KAAK;CACzE;AACF;;AAGA,MAAa,2BAA8C,wBAAwB,eAAe;;;;;;;;;;;;AAalG,SAAgB,QAAQ,OAAgB,MAA8B;CACpE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAS,MAA6B,SAAS;AAC/F;;;;;;AAOA,SAAgB,iBAAiB,OAA+B;CAC9D,IAAI,CAAC,QAAQ,OAAO,iBAAiB,GAAG,OAAO;CAC/C,MAAM,SAAU,MAA+B;CAC/C,OAAO,OAAO,WAAW,WAAW,SAAS;AAC/C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { n as Principal } from "./contract-B3UPXXLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/authorization/contract.d.ts
|
|
4
|
+
/** Input passed to {@link AuthorizationProvider.authorize}. */
|
|
5
|
+
interface AuthorizeInput<Action extends string = string, Resource = unknown> {
|
|
6
|
+
/** The authenticated principal, or `null` for an anonymous request. */
|
|
7
|
+
principal: Principal | null;
|
|
8
|
+
/** The action the request performs (e.g. `"endpoint:write"`). */
|
|
9
|
+
action: Action;
|
|
10
|
+
/** The resource the action targets (a product's discriminated union). */
|
|
11
|
+
resource: Resource;
|
|
12
|
+
/** The incoming request. */
|
|
13
|
+
request: Request;
|
|
14
|
+
}
|
|
15
|
+
/** Decides whether an action is permitted. */
|
|
16
|
+
interface AuthorizationProvider<Action extends string = string, Resource = unknown> {
|
|
17
|
+
authorize(input: AuthorizeInput<Action, Resource>): Promise<boolean>;
|
|
18
|
+
}
|
|
19
|
+
/** Input to {@link defineActions}. */
|
|
20
|
+
interface ActionsDefinition<A extends string> {
|
|
21
|
+
/** Every action, in a stable order (role presets, docs, the UI). */
|
|
22
|
+
all: readonly A[];
|
|
23
|
+
/**
|
|
24
|
+
* Actions that write state. They are blocked when the panel, or the roles
|
|
25
|
+
* provider, is readonly. Leave out actions that must keep working in a
|
|
26
|
+
* readonly panel (e.g. runtime metering).
|
|
27
|
+
*/
|
|
28
|
+
mutating: readonly A[];
|
|
29
|
+
/** Actions a scoped (portal / viewer) token may be granted, when the product has such tokens. */
|
|
30
|
+
portal?: readonly A[];
|
|
31
|
+
}
|
|
32
|
+
/** What {@link defineActions} returns. */
|
|
33
|
+
interface ActionsDefinitionResult<A extends string> {
|
|
34
|
+
/** Every action, in the order given. */
|
|
35
|
+
ALL_ACTIONS: readonly A[];
|
|
36
|
+
/** The mutating actions. */
|
|
37
|
+
MUTATING_ACTIONS: ReadonlySet<A>;
|
|
38
|
+
/** True if `action` writes state. */
|
|
39
|
+
isMutatingAction: (action: A) => boolean;
|
|
40
|
+
/** The actions a scoped token may be granted (empty when `portal` is not given). */
|
|
41
|
+
PORTAL_ACTIONS: readonly A[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Build a product's action constants from its lists. The `const` type
|
|
45
|
+
* parameter keeps the literal union, so a product can derive its action type
|
|
46
|
+
* from the list instead of writing it twice.
|
|
47
|
+
*
|
|
48
|
+
* Throws if `mutating` or `portal` names an action that is not in `all`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { defineActions } from "@xtandard/kit/authorization";
|
|
53
|
+
*
|
|
54
|
+
* export const { ALL_ACTIONS, MUTATING_ACTIONS, isMutatingAction } = defineActions({
|
|
55
|
+
* all: ["endpoint:read", "endpoint:write", "message:read", "message:send"],
|
|
56
|
+
* mutating: ["endpoint:write", "message:send"],
|
|
57
|
+
* });
|
|
58
|
+
* export type WebhooksAction = (typeof ALL_ACTIONS)[number];
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function defineActions<const A extends string>(definition: ActionsDefinition<A>): ActionsDefinitionResult<A>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { defineActions as a, AuthorizeInput as i, ActionsDefinitionResult as n, AuthorizationProvider as r, ActionsDefinition as t };
|
|
64
|
+
//# sourceMappingURL=contract-BIVzAn4f.d.cts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/storage/contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The key/value storage contract shared by every xtandard product. The base {@link KvStorage} is
|
|
4
|
+
* intentionally tiny (four async methods) so users can bring their own backend. Optional
|
|
5
|
+
* capabilities (`watch`, `compareAndSwap`) are separate interfaces that drivers may implement and
|
|
6
|
+
* callers feature-detect with {@link isWatchable} / {@link isCompareAndSwap}.
|
|
7
|
+
*
|
|
8
|
+
* Products alias these under their own names (`type WebhooksStorage = KvStorage`, …).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** The minimal key/value contract every storage backend must satisfy. */
|
|
13
|
+
interface KvStorage {
|
|
14
|
+
/** Read a value, or `null` if absent. */
|
|
15
|
+
getItem<T>(key: string): Promise<T | null>;
|
|
16
|
+
/** Write a value (overwriting any existing). */
|
|
17
|
+
setItem<T>(key: string, value: T): Promise<void>;
|
|
18
|
+
/** Delete a key (no-op if absent). */
|
|
19
|
+
removeItem(key: string): Promise<void>;
|
|
20
|
+
/** List all keys beginning with `prefix` (a plain, case-sensitive string prefix). */
|
|
21
|
+
getKeys(prefix: string): Promise<string[]>;
|
|
22
|
+
}
|
|
23
|
+
/** A storage change event delivered to {@link WatchableKvStorage.watch} callbacks. */
|
|
24
|
+
interface StorageChangeEvent {
|
|
25
|
+
/** `update` for a write, `remove` for a delete. */
|
|
26
|
+
type: "update" | "remove";
|
|
27
|
+
/** The changed key. */
|
|
28
|
+
key: string;
|
|
29
|
+
}
|
|
30
|
+
/** Storage that can push change notifications (e.g. Redis keyspace events, `fs.watch`). */
|
|
31
|
+
interface WatchableKvStorage extends KvStorage {
|
|
32
|
+
/** Subscribe to changes under `prefix`. Resolves to an unsubscribe function. */
|
|
33
|
+
watch(prefix: string, callback: (event: StorageChangeEvent) => void): Promise<() => void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Storage that supports atomic multi-key transactions.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Declared for API compatibility only: no driver implements it and nothing calls it.
|
|
39
|
+
* Use {@link CompareAndSwapKvStorage} for optimistic concurrency.
|
|
40
|
+
*/
|
|
41
|
+
interface TransactionalKvStorage extends KvStorage {
|
|
42
|
+
/** Run `callback` atomically against a transactional view of the storage. */
|
|
43
|
+
transaction<T>(callback: (tx: KvStorage) => Promise<T>): Promise<T>;
|
|
44
|
+
}
|
|
45
|
+
/** Input of {@link CompareAndSwapKvStorage.compareAndSwap}. */
|
|
46
|
+
interface CompareAndSwapInput<T> {
|
|
47
|
+
/** The key to swap. */
|
|
48
|
+
key: string;
|
|
49
|
+
/** The value the key must hold (structurally), or `null` to require that it is absent. */
|
|
50
|
+
expected: T | null;
|
|
51
|
+
/** The value to write when the expectation holds. */
|
|
52
|
+
next: T;
|
|
53
|
+
}
|
|
54
|
+
/** Storage that supports optimistic concurrency via compare-and-swap. */
|
|
55
|
+
interface CompareAndSwapKvStorage extends KvStorage {
|
|
56
|
+
/**
|
|
57
|
+
* Atomically write `next` when the key currently holds a value structurally equal to `expected`
|
|
58
|
+
* (object key order ignored), or is absent when `expected` is `null`. Resolves `true` when the
|
|
59
|
+
* write happened. Of several concurrent swaps from the same `expected`, exactly one wins.
|
|
60
|
+
*/
|
|
61
|
+
compareAndSwap<T>(input: CompareAndSwapInput<T>): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
/** Runtime feature-detection: does this storage implement `watch`? */
|
|
64
|
+
declare function isWatchable(storage: KvStorage): storage is WatchableKvStorage;
|
|
65
|
+
/**
|
|
66
|
+
* Runtime feature-detection: does this storage implement `transaction`?
|
|
67
|
+
*
|
|
68
|
+
* @deprecated No driver implements {@link TransactionalKvStorage}; kept for API compatibility.
|
|
69
|
+
*/
|
|
70
|
+
declare function isTransactional(storage: KvStorage): storage is TransactionalKvStorage;
|
|
71
|
+
/** Runtime feature-detection: does this storage implement `compareAndSwap`? */
|
|
72
|
+
declare function isCompareAndSwap(storage: KvStorage): storage is CompareAndSwapKvStorage;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { TransactionalKvStorage as a, isTransactional as c, StorageChangeEvent as i, isWatchable as l, CompareAndSwapKvStorage as n, WatchableKvStorage as o, KvStorage as r, isCompareAndSwap as s, CompareAndSwapInput as t };
|
|
75
|
+
//# sourceMappingURL=contract-BvgtswLX.d.cts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/storage/contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The key/value storage contract shared by every xtandard product. The base {@link KvStorage} is
|
|
4
|
+
* intentionally tiny (four async methods) so users can bring their own backend. Optional
|
|
5
|
+
* capabilities (`watch`, `compareAndSwap`) are separate interfaces that drivers may implement and
|
|
6
|
+
* callers feature-detect with {@link isWatchable} / {@link isCompareAndSwap}.
|
|
7
|
+
*
|
|
8
|
+
* Products alias these under their own names (`type WebhooksStorage = KvStorage`, …).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** The minimal key/value contract every storage backend must satisfy. */
|
|
13
|
+
interface KvStorage {
|
|
14
|
+
/** Read a value, or `null` if absent. */
|
|
15
|
+
getItem<T>(key: string): Promise<T | null>;
|
|
16
|
+
/** Write a value (overwriting any existing). */
|
|
17
|
+
setItem<T>(key: string, value: T): Promise<void>;
|
|
18
|
+
/** Delete a key (no-op if absent). */
|
|
19
|
+
removeItem(key: string): Promise<void>;
|
|
20
|
+
/** List all keys beginning with `prefix` (a plain, case-sensitive string prefix). */
|
|
21
|
+
getKeys(prefix: string): Promise<string[]>;
|
|
22
|
+
}
|
|
23
|
+
/** A storage change event delivered to {@link WatchableKvStorage.watch} callbacks. */
|
|
24
|
+
interface StorageChangeEvent {
|
|
25
|
+
/** `update` for a write, `remove` for a delete. */
|
|
26
|
+
type: "update" | "remove";
|
|
27
|
+
/** The changed key. */
|
|
28
|
+
key: string;
|
|
29
|
+
}
|
|
30
|
+
/** Storage that can push change notifications (e.g. Redis keyspace events, `fs.watch`). */
|
|
31
|
+
interface WatchableKvStorage extends KvStorage {
|
|
32
|
+
/** Subscribe to changes under `prefix`. Resolves to an unsubscribe function. */
|
|
33
|
+
watch(prefix: string, callback: (event: StorageChangeEvent) => void): Promise<() => void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Storage that supports atomic multi-key transactions.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Declared for API compatibility only: no driver implements it and nothing calls it.
|
|
39
|
+
* Use {@link CompareAndSwapKvStorage} for optimistic concurrency.
|
|
40
|
+
*/
|
|
41
|
+
interface TransactionalKvStorage extends KvStorage {
|
|
42
|
+
/** Run `callback` atomically against a transactional view of the storage. */
|
|
43
|
+
transaction<T>(callback: (tx: KvStorage) => Promise<T>): Promise<T>;
|
|
44
|
+
}
|
|
45
|
+
/** Input of {@link CompareAndSwapKvStorage.compareAndSwap}. */
|
|
46
|
+
interface CompareAndSwapInput<T> {
|
|
47
|
+
/** The key to swap. */
|
|
48
|
+
key: string;
|
|
49
|
+
/** The value the key must hold (structurally), or `null` to require that it is absent. */
|
|
50
|
+
expected: T | null;
|
|
51
|
+
/** The value to write when the expectation holds. */
|
|
52
|
+
next: T;
|
|
53
|
+
}
|
|
54
|
+
/** Storage that supports optimistic concurrency via compare-and-swap. */
|
|
55
|
+
interface CompareAndSwapKvStorage extends KvStorage {
|
|
56
|
+
/**
|
|
57
|
+
* Atomically write `next` when the key currently holds a value structurally equal to `expected`
|
|
58
|
+
* (object key order ignored), or is absent when `expected` is `null`. Resolves `true` when the
|
|
59
|
+
* write happened. Of several concurrent swaps from the same `expected`, exactly one wins.
|
|
60
|
+
*/
|
|
61
|
+
compareAndSwap<T>(input: CompareAndSwapInput<T>): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
/** Runtime feature-detection: does this storage implement `watch`? */
|
|
64
|
+
declare function isWatchable(storage: KvStorage): storage is WatchableKvStorage;
|
|
65
|
+
/**
|
|
66
|
+
* Runtime feature-detection: does this storage implement `transaction`?
|
|
67
|
+
*
|
|
68
|
+
* @deprecated No driver implements {@link TransactionalKvStorage}; kept for API compatibility.
|
|
69
|
+
*/
|
|
70
|
+
declare function isTransactional(storage: KvStorage): storage is TransactionalKvStorage;
|
|
71
|
+
/** Runtime feature-detection: does this storage implement `compareAndSwap`? */
|
|
72
|
+
declare function isCompareAndSwap(storage: KvStorage): storage is CompareAndSwapKvStorage;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { TransactionalKvStorage as a, isTransactional as c, StorageChangeEvent as i, isWatchable as l, CompareAndSwapKvStorage as n, WatchableKvStorage as o, KvStorage as r, isCompareAndSwap as s, CompareAndSwapInput as t };
|
|
75
|
+
//# sourceMappingURL=contract-BvgtswLX.d.mts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/hooks/contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The hooks runner shared by every product: `before` hooks run before a write
|
|
4
|
+
* commits and may deny it, `after` hooks run once it has committed.
|
|
5
|
+
*
|
|
6
|
+
* - `before` runs **sequentially**. Throw to deny (e.g. {@link HookDeniedError});
|
|
7
|
+
* the first throw aborts the remaining hooks and propagates to the caller.
|
|
8
|
+
* - `after` runs **concurrently**. Errors are isolated and reported through a
|
|
9
|
+
* {@link HookErrorReporter}; they never reach the caller.
|
|
10
|
+
*
|
|
11
|
+
* The event unions are product data: the runner is generic over
|
|
12
|
+
* `Before extends { type: string }` and `After extends { type: string }`.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
/** Throw from a `before` hook to deny with a status (default 403). */
|
|
17
|
+
declare class HookDeniedError extends Error {
|
|
18
|
+
/** HTTP status the API layer should respond with. Default `403`. */
|
|
19
|
+
readonly status: number;
|
|
20
|
+
constructor(message: string, options?: {
|
|
21
|
+
status?: number;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** The minimum shape of a hook event: a `type` discriminant. */
|
|
26
|
+
interface HookEvent {
|
|
27
|
+
type: string;
|
|
28
|
+
}
|
|
29
|
+
/** A hook: implement either side or both. */
|
|
30
|
+
interface Hooks<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> {
|
|
31
|
+
before?(event: Before): void | Promise<void>;
|
|
32
|
+
after?(event: After): void | Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Accepts a single hook, an array, or nothing. */
|
|
35
|
+
type HooksInput<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> = Hooks<Before, After> | readonly Hooks<Before, After>[] | undefined;
|
|
36
|
+
/** Reports an error thrown by an `after` hook. */
|
|
37
|
+
type HookErrorReporter<After extends HookEvent = HookEvent> = (error: unknown, event: After) => void;
|
|
38
|
+
/** Normalize the `hooks` option into a flat array (empty when unset). */
|
|
39
|
+
declare function normalizeHooks<Before extends HookEvent, After extends HookEvent>(input: HooksInput<Before, After>): Hooks<Before, After>[];
|
|
40
|
+
/** Run `before` hooks sequentially; the first throw denies. */
|
|
41
|
+
declare function runBefore<Before extends HookEvent>(hooks: readonly Hooks<Before, never>[], event: Before): Promise<void>;
|
|
42
|
+
/** Run `after` hooks concurrently; errors go to `onError`, never to the caller. */
|
|
43
|
+
declare function runAfter<After extends HookEvent>(hooks: readonly Hooks<never, After>[], event: After, onError: HookErrorReporter<After>): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Build an `after`-hook error reporter that warns with `[source]` as the log
|
|
46
|
+
* prefix and never throws. Products pass their package name:
|
|
47
|
+
* `createHookErrorReporter("@xtandard/webhooks")`.
|
|
48
|
+
*/
|
|
49
|
+
declare function createHookErrorReporter(source: string): HookErrorReporter;
|
|
50
|
+
/** Default `after`-hook error reporter: warns with the `[@xtandard/kit]` prefix, never throws. */
|
|
51
|
+
declare const defaultHookErrorReporter: HookErrorReporter;
|
|
52
|
+
/**
|
|
53
|
+
* True when `error` is an error object whose `name` is `name`. Use it instead
|
|
54
|
+
* of `instanceof` to map domain errors to HTTP statuses: an error class loaded
|
|
55
|
+
* from a separate bundle (another subpath's copy of the class, or another
|
|
56
|
+
* realm) fails `instanceof` but keeps its `name`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* if (isNamed(err, "NotFoundError")) return error(404, err.message, { code: "NOT_FOUND" });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare function isNamed(error: unknown, name: string): error is Error;
|
|
64
|
+
/**
|
|
65
|
+
* The status of a hook denial — a {@link HookDeniedError}, or a foreign-bundle
|
|
66
|
+
* copy of it recognised by name (default 403 when it carries no numeric
|
|
67
|
+
* `status`) — or `null` when `error` is not a denial.
|
|
68
|
+
*/
|
|
69
|
+
declare function hookDeniedStatus(error: unknown): number | null;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { HooksInput as a, hookDeniedStatus as c, runAfter as d, runBefore as f, Hooks as i, isNamed as l, HookErrorReporter as n, createHookErrorReporter as o, HookEvent as r, defaultHookErrorReporter as s, HookDeniedError as t, normalizeHooks as u };
|
|
72
|
+
//# sourceMappingURL=contract-DUj9P3Vt.d.cts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/hooks/contract.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The hooks runner shared by every product: `before` hooks run before a write
|
|
4
|
+
* commits and may deny it, `after` hooks run once it has committed.
|
|
5
|
+
*
|
|
6
|
+
* - `before` runs **sequentially**. Throw to deny (e.g. {@link HookDeniedError});
|
|
7
|
+
* the first throw aborts the remaining hooks and propagates to the caller.
|
|
8
|
+
* - `after` runs **concurrently**. Errors are isolated and reported through a
|
|
9
|
+
* {@link HookErrorReporter}; they never reach the caller.
|
|
10
|
+
*
|
|
11
|
+
* The event unions are product data: the runner is generic over
|
|
12
|
+
* `Before extends { type: string }` and `After extends { type: string }`.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
/** Throw from a `before` hook to deny with a status (default 403). */
|
|
17
|
+
declare class HookDeniedError extends Error {
|
|
18
|
+
/** HTTP status the API layer should respond with. Default `403`. */
|
|
19
|
+
readonly status: number;
|
|
20
|
+
constructor(message: string, options?: {
|
|
21
|
+
status?: number;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** The minimum shape of a hook event: a `type` discriminant. */
|
|
26
|
+
interface HookEvent {
|
|
27
|
+
type: string;
|
|
28
|
+
}
|
|
29
|
+
/** A hook: implement either side or both. */
|
|
30
|
+
interface Hooks<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> {
|
|
31
|
+
before?(event: Before): void | Promise<void>;
|
|
32
|
+
after?(event: After): void | Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** Accepts a single hook, an array, or nothing. */
|
|
35
|
+
type HooksInput<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> = Hooks<Before, After> | readonly Hooks<Before, After>[] | undefined;
|
|
36
|
+
/** Reports an error thrown by an `after` hook. */
|
|
37
|
+
type HookErrorReporter<After extends HookEvent = HookEvent> = (error: unknown, event: After) => void;
|
|
38
|
+
/** Normalize the `hooks` option into a flat array (empty when unset). */
|
|
39
|
+
declare function normalizeHooks<Before extends HookEvent, After extends HookEvent>(input: HooksInput<Before, After>): Hooks<Before, After>[];
|
|
40
|
+
/** Run `before` hooks sequentially; the first throw denies. */
|
|
41
|
+
declare function runBefore<Before extends HookEvent>(hooks: readonly Hooks<Before, never>[], event: Before): Promise<void>;
|
|
42
|
+
/** Run `after` hooks concurrently; errors go to `onError`, never to the caller. */
|
|
43
|
+
declare function runAfter<After extends HookEvent>(hooks: readonly Hooks<never, After>[], event: After, onError: HookErrorReporter<After>): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Build an `after`-hook error reporter that warns with `[source]` as the log
|
|
46
|
+
* prefix and never throws. Products pass their package name:
|
|
47
|
+
* `createHookErrorReporter("@xtandard/webhooks")`.
|
|
48
|
+
*/
|
|
49
|
+
declare function createHookErrorReporter(source: string): HookErrorReporter;
|
|
50
|
+
/** Default `after`-hook error reporter: warns with the `[@xtandard/kit]` prefix, never throws. */
|
|
51
|
+
declare const defaultHookErrorReporter: HookErrorReporter;
|
|
52
|
+
/**
|
|
53
|
+
* True when `error` is an error object whose `name` is `name`. Use it instead
|
|
54
|
+
* of `instanceof` to map domain errors to HTTP statuses: an error class loaded
|
|
55
|
+
* from a separate bundle (another subpath's copy of the class, or another
|
|
56
|
+
* realm) fails `instanceof` but keeps its `name`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* if (isNamed(err, "NotFoundError")) return error(404, err.message, { code: "NOT_FOUND" });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare function isNamed(error: unknown, name: string): error is Error;
|
|
64
|
+
/**
|
|
65
|
+
* The status of a hook denial — a {@link HookDeniedError}, or a foreign-bundle
|
|
66
|
+
* copy of it recognised by name (default 403 when it carries no numeric
|
|
67
|
+
* `status`) — or `null` when `error` is not a denial.
|
|
68
|
+
*/
|
|
69
|
+
declare function hookDeniedStatus(error: unknown): number | null;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { HooksInput as a, hookDeniedStatus as c, runAfter as d, runBefore as f, Hooks as i, isNamed as l, HookErrorReporter as n, createHookErrorReporter as o, HookEvent as r, defaultHookErrorReporter as s, HookDeniedError as t, normalizeHooks as u };
|
|
72
|
+
//# sourceMappingURL=contract-DUj9P3Vt.d.mts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//#region src/hooks/contract.ts
|
|
2
|
+
/**
|
|
3
|
+
* The hooks runner shared by every product: `before` hooks run before a write
|
|
4
|
+
* commits and may deny it, `after` hooks run once it has committed.
|
|
5
|
+
*
|
|
6
|
+
* - `before` runs **sequentially**. Throw to deny (e.g. {@link HookDeniedError});
|
|
7
|
+
* the first throw aborts the remaining hooks and propagates to the caller.
|
|
8
|
+
* - `after` runs **concurrently**. Errors are isolated and reported through a
|
|
9
|
+
* {@link HookErrorReporter}; they never reach the caller.
|
|
10
|
+
*
|
|
11
|
+
* The event unions are product data: the runner is generic over
|
|
12
|
+
* `Before extends { type: string }` and `After extends { type: string }`.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
/** Throw from a `before` hook to deny with a status (default 403). */
|
|
17
|
+
var HookDeniedError = class extends Error {
|
|
18
|
+
/** HTTP status the API layer should respond with. Default `403`. */
|
|
19
|
+
status;
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super(message, options?.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
22
|
+
this.name = "HookDeniedError";
|
|
23
|
+
this.status = options?.status ?? 403;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/** Normalize the `hooks` option into a flat array (empty when unset). */
|
|
27
|
+
function normalizeHooks(input) {
|
|
28
|
+
if (!input) return [];
|
|
29
|
+
return Array.isArray(input) ? [...input] : [input];
|
|
30
|
+
}
|
|
31
|
+
/** Run `before` hooks sequentially; the first throw denies. */
|
|
32
|
+
async function runBefore(hooks, event) {
|
|
33
|
+
for (const hook of hooks) if (hook.before) await hook.before(event);
|
|
34
|
+
}
|
|
35
|
+
/** Run `after` hooks concurrently; errors go to `onError`, never to the caller. */
|
|
36
|
+
async function runAfter(hooks, event, onError) {
|
|
37
|
+
await Promise.all(hooks.map(async (hook) => {
|
|
38
|
+
if (!hook.after) return;
|
|
39
|
+
try {
|
|
40
|
+
await hook.after(event);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
onError(error, event);
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build an `after`-hook error reporter that warns with `[source]` as the log
|
|
48
|
+
* prefix and never throws. Products pass their package name:
|
|
49
|
+
* `createHookErrorReporter("@xtandard/webhooks")`.
|
|
50
|
+
*/
|
|
51
|
+
function createHookErrorReporter(source) {
|
|
52
|
+
return (error, event) => {
|
|
53
|
+
console.warn(`[${source}] after-hook for "${event.type}" threw:`, error);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Default `after`-hook error reporter: warns with the `[@xtandard/kit]` prefix, never throws. */
|
|
57
|
+
const defaultHookErrorReporter = createHookErrorReporter("@xtandard/kit");
|
|
58
|
+
/**
|
|
59
|
+
* True when `error` is an error object whose `name` is `name`. Use it instead
|
|
60
|
+
* of `instanceof` to map domain errors to HTTP statuses: an error class loaded
|
|
61
|
+
* from a separate bundle (another subpath's copy of the class, or another
|
|
62
|
+
* realm) fails `instanceof` but keeps its `name`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* if (isNamed(err, "NotFoundError")) return error(404, err.message, { code: "NOT_FOUND" });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
function isNamed(error, name) {
|
|
70
|
+
return typeof error === "object" && error !== null && error.name === name;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The status of a hook denial — a {@link HookDeniedError}, or a foreign-bundle
|
|
74
|
+
* copy of it recognised by name (default 403 when it carries no numeric
|
|
75
|
+
* `status`) — or `null` when `error` is not a denial.
|
|
76
|
+
*/
|
|
77
|
+
function hookDeniedStatus(error) {
|
|
78
|
+
if (!isNamed(error, "HookDeniedError")) return null;
|
|
79
|
+
const status = error.status;
|
|
80
|
+
return typeof status === "number" ? status : 403;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
Object.defineProperty(exports, "HookDeniedError", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function() {
|
|
86
|
+
return HookDeniedError;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "createHookErrorReporter", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return createHookErrorReporter;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "defaultHookErrorReporter", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function() {
|
|
98
|
+
return defaultHookErrorReporter;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "hookDeniedStatus", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function() {
|
|
104
|
+
return hookDeniedStatus;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "isNamed", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function() {
|
|
110
|
+
return isNamed;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "normalizeHooks", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function() {
|
|
116
|
+
return normalizeHooks;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, "runAfter", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function() {
|
|
122
|
+
return runAfter;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "runBefore", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return runBefore;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=contract-wAEMDmYG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-wAEMDmYG.cjs","names":[],"sources":["../src/hooks/contract.ts"],"sourcesContent":["/**\n * The hooks runner shared by every product: `before` hooks run before a write\n * commits and may deny it, `after` hooks run once it has committed.\n *\n * - `before` runs **sequentially**. Throw to deny (e.g. {@link HookDeniedError});\n * the first throw aborts the remaining hooks and propagates to the caller.\n * - `after` runs **concurrently**. Errors are isolated and reported through a\n * {@link HookErrorReporter}; they never reach the caller.\n *\n * The event unions are product data: the runner is generic over\n * `Before extends { type: string }` and `After extends { type: string }`.\n *\n * @module\n */\n\n/** Throw from a `before` hook to deny with a status (default 403). */\nexport class HookDeniedError extends Error {\n /** HTTP status the API layer should respond with. Default `403`. */\n readonly status: number;\n constructor(message: string, options?: { status?: number; cause?: unknown }) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = \"HookDeniedError\";\n this.status = options?.status ?? 403;\n }\n}\n\n/** The minimum shape of a hook event: a `type` discriminant. */\nexport interface HookEvent {\n type: string;\n}\n\n/** A hook: implement either side or both. */\nexport interface Hooks<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> {\n before?(event: Before): void | Promise<void>;\n after?(event: After): void | Promise<void>;\n}\n\n/** Accepts a single hook, an array, or nothing. */\nexport type HooksInput<Before extends HookEvent = HookEvent, After extends HookEvent = HookEvent> =\n | Hooks<Before, After>\n | readonly Hooks<Before, After>[]\n | undefined;\n\n/** Reports an error thrown by an `after` hook. */\nexport type HookErrorReporter<After extends HookEvent = HookEvent> = (\n error: unknown,\n event: After,\n) => void;\n\n/** Normalize the `hooks` option into a flat array (empty when unset). */\nexport function normalizeHooks<Before extends HookEvent, After extends HookEvent>(\n input: HooksInput<Before, After>,\n): Hooks<Before, After>[] {\n if (!input) return [];\n return Array.isArray(input) ? [...input] : [input as Hooks<Before, After>];\n}\n\n/** Run `before` hooks sequentially; the first throw denies. */\nexport async function runBefore<Before extends HookEvent>(\n hooks: readonly Hooks<Before, never>[],\n event: Before,\n): Promise<void> {\n for (const hook of hooks) {\n if (hook.before) await hook.before(event);\n }\n}\n\n/** Run `after` hooks concurrently; errors go to `onError`, never to the caller. */\nexport async function runAfter<After extends HookEvent>(\n hooks: readonly Hooks<never, After>[],\n event: After,\n onError: HookErrorReporter<After>,\n): Promise<void> {\n await Promise.all(\n hooks.map(async (hook) => {\n if (!hook.after) return;\n try {\n await hook.after(event);\n } catch (error) {\n onError(error, event);\n }\n }),\n );\n}\n\n/**\n * Build an `after`-hook error reporter that warns with `[source]` as the log\n * prefix and never throws. Products pass their package name:\n * `createHookErrorReporter(\"@xtandard/webhooks\")`.\n */\nexport function createHookErrorReporter(source: string): HookErrorReporter {\n return (error, event) => {\n console.warn(`[${source}] after-hook for \"${event.type}\" threw:`, error);\n };\n}\n\n/** Default `after`-hook error reporter: warns with the `[@xtandard/kit]` prefix, never throws. */\nexport const defaultHookErrorReporter: HookErrorReporter = createHookErrorReporter(\"@xtandard/kit\");\n\n/**\n * True when `error` is an error object whose `name` is `name`. Use it instead\n * of `instanceof` to map domain errors to HTTP statuses: an error class loaded\n * from a separate bundle (another subpath's copy of the class, or another\n * realm) fails `instanceof` but keeps its `name`.\n *\n * @example\n * ```ts\n * if (isNamed(err, \"NotFoundError\")) return error(404, err.message, { code: \"NOT_FOUND\" });\n * ```\n */\nexport function isNamed(error: unknown, name: string): error is Error {\n return typeof error === \"object\" && error !== null && (error as { name?: unknown }).name === name;\n}\n\n/**\n * The status of a hook denial — a {@link HookDeniedError}, or a foreign-bundle\n * copy of it recognised by name (default 403 when it carries no numeric\n * `status`) — or `null` when `error` is not a denial.\n */\nexport function hookDeniedStatus(error: unknown): number | null {\n if (!isNamed(error, \"HookDeniedError\")) return null;\n const status = (error as { status?: unknown }).status;\n return typeof status === \"number\" ? status : 403;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,cAAqC,MAAM;;CAEzC;CACA,YAAY,SAAiB,SAAgD;EAC3E,MAAM,SAAS,SAAS,UAAU,KAAA,IAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAA,CAAS;EAClF,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS,UAAU;CACnC;AACF;;AA0BA,SAAgB,eACd,OACwB;CACxB,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,OAAO,MAAM,QAAQ,KAAK,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,KAA6B;AAC3E;;AAGA,eAAsB,UACpB,OACA,OACe;CACf,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,QAAQ,MAAM,KAAK,OAAO,KAAK;AAE5C;;AAGA,eAAsB,SACpB,OACA,OACA,SACe;CACf,MAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;EACxB,IAAI,CAAC,KAAK,OAAO;EACjB,IAAI;GACF,MAAM,KAAK,MAAM,KAAK;EACxB,SAAS,OAAO;GACd,QAAQ,OAAO,KAAK;EACtB;CACF,CAAC,CACH;AACF;;;;;;AAOA,SAAgB,wBAAwB,QAAmC;CACzE,QAAQ,OAAO,UAAU;EACvB,QAAQ,KAAK,IAAI,OAAO,oBAAoB,MAAM,KAAK,WAAW,KAAK;CACzE;AACF;;AAGA,MAAa,2BAA8C,wBAAwB,eAAe;;;;;;;;;;;;AAalG,SAAgB,QAAQ,OAAgB,MAA8B;CACpE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAS,MAA6B,SAAS;AAC/F;;;;;;AAOA,SAAgB,iBAAiB,OAA+B;CAC9D,IAAI,CAAC,QAAQ,OAAO,iBAAiB,GAAG,OAAO;CAC/C,MAAM,SAAU,MAA+B;CAC/C,OAAO,OAAO,WAAW,WAAW,SAAS;AAC/C"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { t as DrizzleKvTable } from "./table-BrioFSra.mjs";
|
|
2
|
+
import { n as CompareAndSwapKvStorage } from "./contract-BvgtswLX.mjs";
|
|
3
|
+
import { Column, SQL, Table } from "drizzle-orm";
|
|
4
|
+
|
|
5
|
+
//#region src/storage/drizzle.d.ts
|
|
6
|
+
/** The SQL dialect of a Drizzle database. */
|
|
7
|
+
type DrizzleDialect = "pg" | "mysql" | "sqlite";
|
|
8
|
+
/**
|
|
9
|
+
* Minimal structural view of a Drizzle database (the query-builder entry points the driver uses).
|
|
10
|
+
* The public `db` option is `unknown` because a dialect-agnostic type cannot match every dialect's
|
|
11
|
+
* builders.
|
|
12
|
+
*/
|
|
13
|
+
interface DrizzleLikeDatabase {
|
|
14
|
+
/** The dialect object (its class chain names the dialect). */
|
|
15
|
+
dialect?: unknown;
|
|
16
|
+
/** `select(fields).from(table).where(sql)`. */
|
|
17
|
+
select(fields: Record<string, unknown>): {
|
|
18
|
+
from(table: Table): {
|
|
19
|
+
where(where: SQL): PromiseLike<unknown[]>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** `insert(table)`. */
|
|
23
|
+
insert(table: Table): DrizzleInsert;
|
|
24
|
+
/** `update(table).set(values).where(sql)`. */
|
|
25
|
+
update(table: Table): {
|
|
26
|
+
set(values: Record<string, unknown>): {
|
|
27
|
+
where(where: SQL): PromiseLike<unknown> & {
|
|
28
|
+
returning?(fields: Record<string, Column>): PromiseLike<unknown[]>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** `delete(table).where(sql)`. */
|
|
33
|
+
delete(table: Table): {
|
|
34
|
+
where(where: SQL): PromiseLike<unknown>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The insert builder surface (upsert methods differ by dialect). */
|
|
38
|
+
interface DrizzleInsert {
|
|
39
|
+
ignore?(): DrizzleInsert;
|
|
40
|
+
values(row: Record<string, unknown>): PromiseLike<unknown> & {
|
|
41
|
+
onConflictDoUpdate?(config: {
|
|
42
|
+
target: Column;
|
|
43
|
+
set: Record<string, unknown>;
|
|
44
|
+
}): DrizzleReturning;
|
|
45
|
+
onConflictDoNothing?(config?: {
|
|
46
|
+
target?: Column;
|
|
47
|
+
}): DrizzleReturning;
|
|
48
|
+
onDuplicateKeyUpdate?(config: {
|
|
49
|
+
set: Record<string, unknown>;
|
|
50
|
+
}): PromiseLike<unknown>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
type DrizzleReturning = PromiseLike<unknown> & {
|
|
54
|
+
returning(fields: Record<string, Column>): PromiseLike<unknown[]>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Detect a Drizzle database's dialect from its `dialect` object's class chain (`PgDialect` /
|
|
58
|
+
* `MySqlDialect` / `SQLite{Sync,Async}Dialect`). Semi-public (ADR 0004).
|
|
59
|
+
*/
|
|
60
|
+
declare function detectDrizzleDialect(db: unknown): DrizzleDialect;
|
|
61
|
+
/** Rows affected by a MySQL write, across driver result shapes (mysql2, PlanetScale…). Semi-public. */
|
|
62
|
+
declare function affectedRows(result: unknown): number;
|
|
63
|
+
type SqlTag = typeof import("drizzle-orm").sql;
|
|
64
|
+
/** The `sql` template tag of `drizzle-orm`, imported once (lazily). Semi-public. */
|
|
65
|
+
declare function drizzleSql(): Promise<SqlTag>;
|
|
66
|
+
/**
|
|
67
|
+
* The smallest string greater than every string that starts with `prefix`, in code-point (=
|
|
68
|
+
* `utf8mb4_bin` byte) order: the last code point incremented (skipping surrogates), dropping
|
|
69
|
+
* trailing U+10FFFF. `undefined` when there is none (empty prefix, or all U+10FFFF).
|
|
70
|
+
*/
|
|
71
|
+
declare function prefixSuccessor(prefix: string): string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Thrown by `setItem` on MySQL when the key column's collation is PAD SPACE (`utf8mb4_bin`) and the
|
|
74
|
+
* key differs from a stored key only by trailing spaces (`"a "` vs `"a"`): the write is refused
|
|
75
|
+
* instead of overwriting the other key. The message carries the migration SQL to a NO PAD
|
|
76
|
+
* collation (`utf8mb4_0900_bin`).
|
|
77
|
+
*/
|
|
78
|
+
declare class KeyCollisionError extends Error {
|
|
79
|
+
/** The key that was written. */
|
|
80
|
+
readonly key: string;
|
|
81
|
+
/** The stored key it collides with (when it could be read back). */
|
|
82
|
+
readonly storedKey: string | undefined;
|
|
83
|
+
constructor(key: string, storedKey: string | undefined, table: DrizzleKvTable);
|
|
84
|
+
}
|
|
85
|
+
/** Options for {@link createDrizzleStorage}. */
|
|
86
|
+
interface DrizzleStorageOptions {
|
|
87
|
+
/** Your Drizzle database (node-postgres, postgres-js, mysql2, bun:sqlite, libsql, pglite, …). */
|
|
88
|
+
db: unknown;
|
|
89
|
+
/** The KV table, built with a `@xtandard/kit/drizzle/*` factory (or matching its shape). */
|
|
90
|
+
table: DrizzleKvTable;
|
|
91
|
+
/** Override dialect detection (normally read from `db`). */
|
|
92
|
+
dialect?: DrizzleDialect;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A compare-and-swap capable storage over a Drizzle table. For change notifications, compose it with
|
|
96
|
+
* `withWatch` and a change source such as `pgListenNotify`.
|
|
97
|
+
*/
|
|
98
|
+
type DrizzleKvStorage = CompareAndSwapKvStorage;
|
|
99
|
+
/**
|
|
100
|
+
* Create a Drizzle-backed {@link DrizzleKvStorage}. No DDL, no connection ownership.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { drizzle } from "drizzle-orm/node-postgres";
|
|
105
|
+
* import { createDrizzleStorage } from "@xtandard/kit/storage/drizzle";
|
|
106
|
+
* import { pgKvTable } from "@xtandard/kit/drizzle/pg";
|
|
107
|
+
*
|
|
108
|
+
* export const kv = pgKvTable("xtandard_kv"); // add to your schema + migrate
|
|
109
|
+
* const storage = createDrizzleStorage({ db: drizzle(pool), table: kv });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function createDrizzleStorage(options: DrizzleStorageOptions): DrizzleKvStorage;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { KeyCollisionError as a, detectDrizzleDialect as c, DrizzleStorageOptions as i, drizzleSql as l, DrizzleKvStorage as n, affectedRows as o, DrizzleLikeDatabase as r, createDrizzleStorage as s, DrizzleDialect as t, prefixSuccessor as u };
|
|
115
|
+
//# sourceMappingURL=drizzle-BElCHWri.d.mts.map
|