@xtandard/permissions 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 +362 -2
- package/bin/xtandard-permissions.mjs +3 -0
- package/dist/better-auth-Bp9YVyQa.d.cts +56 -0
- package/dist/better-auth-DHyW5-yt.cjs +91 -0
- package/dist/better-auth-DHyW5-yt.cjs.map +1 -0
- package/dist/better-auth-NO40ZqSM.mjs +74 -0
- package/dist/better-auth-NO40ZqSM.mjs.map +1 -0
- package/dist/better-auth-NSXgt6ZU.d.mts +56 -0
- package/dist/catalog-DA_d1SdC.d.cts +153 -0
- package/dist/catalog-DJcJ3ycq.d.mts +153 -0
- package/dist/catalog.cjs +198 -0
- package/dist/catalog.cjs.map +1 -0
- package/dist/catalog.d.cts +3 -0
- package/dist/catalog.d.mts +3 -0
- package/dist/catalog.mjs +141 -0
- package/dist/catalog.mjs.map +1 -0
- package/dist/chunk-DakpK96I.cjs +43 -0
- package/dist/cli.cjs +548 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +28 -0
- package/dist/cli.d.mts +28 -0
- package/dist/cli.mjs +544 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/contract-BMiOmg2f.d.cts +50 -0
- package/dist/contract-Bpy8yPrS.cjs +70 -0
- package/dist/contract-Bpy8yPrS.cjs.map +1 -0
- package/dist/contract-CNgMXr2u.d.cts +46 -0
- package/dist/contract-CNgMXr2u.d.mts +46 -0
- package/dist/contract-CPmJVoRx.cjs +70 -0
- package/dist/contract-CPmJVoRx.cjs.map +1 -0
- package/dist/contract-D32H1t0u.d.mts +50 -0
- package/dist/contract-DTdTXZtJ.mjs +47 -0
- package/dist/contract-DTdTXZtJ.mjs.map +1 -0
- package/dist/contract-DUzgB-He.d.mts +375 -0
- package/dist/contract-Dk6d2ylD.d.cts +375 -0
- package/dist/contract-RMkmERhT.d.cts +2 -0
- package/dist/contract-RMkmERhT.d.mts +2 -0
- package/dist/contract-Yc5AZuvv.mjs +47 -0
- package/dist/contract-Yc5AZuvv.mjs.map +1 -0
- package/dist/create-fetch-handler-BHDU4chu.d.mts +77 -0
- package/dist/create-fetch-handler-BtX64_rS.d.cts +77 -0
- package/dist/create-fetch-handler-C-WyaRCR.cjs +653 -0
- package/dist/create-fetch-handler-C-WyaRCR.cjs.map +1 -0
- package/dist/create-fetch-handler-ojjpk1Iw.mjs +636 -0
- package/dist/create-fetch-handler-ojjpk1Iw.mjs.map +1 -0
- package/dist/elysia-shared-BM6cPoCU.mjs +78 -0
- package/dist/elysia-shared-BM6cPoCU.mjs.map +1 -0
- package/dist/elysia-shared-BUTFTeal.cjs +101 -0
- package/dist/elysia-shared-BUTFTeal.cjs.map +1 -0
- package/dist/elysia-shared-DtKViycb.d.cts +58 -0
- package/dist/elysia-shared-g8zsb_pU.d.mts +58 -0
- package/dist/engine-Bufv0TbD.mjs +574 -0
- package/dist/engine-Bufv0TbD.mjs.map +1 -0
- package/dist/engine-CGGVDCqi.d.cts +296 -0
- package/dist/engine-DpFIcbgh.d.mts +296 -0
- package/dist/engine-bMoz3iW-.cjs +587 -0
- package/dist/engine-bMoz3iW-.cjs.map +1 -0
- package/dist/entry-auth-basic.cjs +40 -0
- package/dist/entry-auth-basic.cjs.map +1 -0
- package/dist/entry-auth-basic.d.cts +24 -0
- package/dist/entry-auth-basic.d.mts +24 -0
- package/dist/entry-auth-basic.mjs +26 -0
- package/dist/entry-auth-basic.mjs.map +1 -0
- package/dist/entry-auth-better-auth.cjs +12 -0
- package/dist/entry-auth-better-auth.d.cts +5 -0
- package/dist/entry-auth-better-auth.d.mts +5 -0
- package/dist/entry-auth-better-auth.mjs +4 -0
- package/dist/entry-auth-delegated.cjs +8 -0
- package/dist/entry-auth-delegated.d.cts +2 -0
- package/dist/entry-auth-delegated.d.mts +2 -0
- package/dist/entry-auth-delegated.mjs +2 -0
- package/dist/entry-auth-jwt.cjs +116 -0
- package/dist/entry-auth-jwt.cjs.map +1 -0
- package/dist/entry-auth-jwt.d.cts +65 -0
- package/dist/entry-auth-jwt.d.mts +65 -0
- package/dist/entry-auth-jwt.mjs +108 -0
- package/dist/entry-auth-jwt.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +14 -0
- package/dist/entry-auth-none.d.cts +2 -0
- package/dist/entry-auth-none.d.mts +2 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-auth-session.cjs +82 -0
- package/dist/entry-auth-session.cjs.map +1 -0
- package/dist/entry-auth-session.d.cts +20 -0
- package/dist/entry-auth-session.d.mts +20 -0
- package/dist/entry-auth-session.mjs +75 -0
- package/dist/entry-auth-session.mjs.map +1 -0
- package/dist/entry-authorization-delegated.cjs +31 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +27 -0
- package/dist/entry-authorization-delegated.d.mts +27 -0
- package/dist/entry-authorization-delegated.mjs +30 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +29 -0
- package/dist/entry-authorization-none.cjs.map +1 -0
- package/dist/entry-authorization-none.d.cts +17 -0
- package/dist/entry-authorization-none.d.mts +17 -0
- package/dist/entry-authorization-none.mjs +28 -0
- package/dist/entry-authorization-none.mjs.map +1 -0
- package/dist/entry-authorization-permissions.cjs +4 -0
- package/dist/entry-authorization-permissions.d.cts +49 -0
- package/dist/entry-authorization-permissions.d.mts +49 -0
- package/dist/entry-authorization-permissions.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +9 -0
- package/dist/entry-authorization-roles.d.cts +37 -0
- package/dist/entry-authorization-roles.d.mts +37 -0
- package/dist/entry-authorization-roles.mjs +3 -0
- package/dist/entry-better-auth-client.cjs +31 -0
- package/dist/entry-better-auth-client.cjs.map +1 -0
- package/dist/entry-better-auth-client.d.cts +63 -0
- package/dist/entry-better-auth-client.d.mts +63 -0
- package/dist/entry-better-auth-client.mjs +29 -0
- package/dist/entry-better-auth-client.mjs.map +1 -0
- package/dist/entry-better-auth.cjs +289 -0
- package/dist/entry-better-auth.cjs.map +1 -0
- package/dist/entry-better-auth.d.cts +3 -0
- package/dist/entry-better-auth.d.mts +3 -0
- package/dist/entry-better-auth.mjs +284 -0
- package/dist/entry-better-auth.mjs.map +1 -0
- package/dist/entry-bridges-audit.cjs +106 -0
- package/dist/entry-bridges-audit.cjs.map +1 -0
- package/dist/entry-bridges-audit.d.cts +58 -0
- package/dist/entry-bridges-audit.d.mts +58 -0
- package/dist/entry-bridges-audit.mjs +105 -0
- package/dist/entry-bridges-audit.mjs.map +1 -0
- package/dist/entry-bridges-webhooks.cjs +90 -0
- package/dist/entry-bridges-webhooks.cjs.map +1 -0
- package/dist/entry-bridges-webhooks.d.cts +46 -0
- package/dist/entry-bridges-webhooks.d.mts +46 -0
- package/dist/entry-bridges-webhooks.mjs +88 -0
- package/dist/entry-bridges-webhooks.mjs.map +1 -0
- package/dist/entry-bun.cjs +33 -0
- package/dist/entry-bun.cjs.map +1 -0
- package/dist/entry-bun.d.cts +31 -0
- package/dist/entry-bun.d.mts +31 -0
- package/dist/entry-bun.mjs +30 -0
- package/dist/entry-bun.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +34 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +20 -0
- package/dist/entry-drizzle-mysql.d.mts +20 -0
- package/dist/entry-drizzle-mysql.mjs +33 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +44 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +20 -0
- package/dist/entry-drizzle-pg.d.mts +20 -0
- package/dist/entry-drizzle-pg.mjs +43 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +34 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +15 -0
- package/dist/entry-drizzle-sqlite.d.mts +15 -0
- package/dist/entry-drizzle-sqlite.mjs +33 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-elysia.cjs +117 -0
- package/dist/entry-elysia.cjs.map +1 -0
- package/dist/entry-elysia.d.cts +446 -0
- package/dist/entry-elysia.d.mts +446 -0
- package/dist/entry-elysia.mjs +113 -0
- package/dist/entry-elysia.mjs.map +1 -0
- package/dist/entry-elysia2.cjs +117 -0
- package/dist/entry-elysia2.cjs.map +1 -0
- package/dist/entry-elysia2.d.cts +571 -0
- package/dist/entry-elysia2.d.mts +571 -0
- package/dist/entry-elysia2.mjs +113 -0
- package/dist/entry-elysia2.mjs.map +1 -0
- package/dist/entry-express.cjs +101 -0
- package/dist/entry-express.cjs.map +1 -0
- package/dist/entry-express.d.cts +36 -0
- package/dist/entry-express.d.mts +36 -0
- package/dist/entry-express.mjs +97 -0
- package/dist/entry-express.mjs.map +1 -0
- package/dist/entry-hono.cjs +63 -0
- package/dist/entry-hono.cjs.map +1 -0
- package/dist/entry-hono.d.cts +40 -0
- package/dist/entry-hono.d.mts +40 -0
- package/dist/entry-hono.mjs +60 -0
- package/dist/entry-hono.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +39 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +19 -0
- package/dist/entry-hooks-log.d.mts +19 -0
- package/dist/entry-hooks-log.mjs +36 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-next.cjs +67 -0
- package/dist/entry-next.cjs.map +1 -0
- package/dist/entry-next.d.cts +60 -0
- package/dist/entry-next.d.mts +60 -0
- package/dist/entry-next.mjs +57 -0
- package/dist/entry-next.mjs.map +1 -0
- package/dist/entry-react.cjs +401 -0
- package/dist/entry-react.cjs.map +1 -0
- package/dist/entry-react.d.cts +206 -0
- package/dist/entry-react.d.mts +206 -0
- package/dist/entry-react.mjs +388 -0
- package/dist/entry-react.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +8 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +2 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +2 -0
- package/dist/entry-storage-cloudflare-kv.mjs +2 -0
- package/dist/entry-storage-drizzle.cjs +71 -0
- package/dist/entry-storage-drizzle.cjs.map +1 -0
- package/dist/entry-storage-drizzle.d.cts +27 -0
- package/dist/entry-storage-drizzle.d.mts +27 -0
- package/dist/entry-storage-drizzle.mjs +68 -0
- package/dist/entry-storage-drizzle.mjs.map +1 -0
- package/dist/entry-storage-file.cjs +54 -0
- package/dist/entry-storage-file.cjs.map +1 -0
- package/dist/entry-storage-file.d.cts +24 -0
- package/dist/entry-storage-file.d.mts +24 -0
- package/dist/entry-storage-file.mjs +46 -0
- package/dist/entry-storage-file.mjs.map +1 -0
- package/dist/entry-storage-libsql.cjs +64 -0
- package/dist/entry-storage-libsql.cjs.map +1 -0
- package/dist/entry-storage-libsql.d.cts +28 -0
- package/dist/entry-storage-libsql.d.mts +28 -0
- package/dist/entry-storage-libsql.mjs +61 -0
- package/dist/entry-storage-libsql.mjs.map +1 -0
- package/dist/entry-storage-memory.cjs +3 -0
- package/dist/entry-storage-memory.d.cts +25 -0
- package/dist/entry-storage-memory.d.mts +25 -0
- package/dist/entry-storage-memory.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +61 -0
- package/dist/entry-storage-mongodb.cjs.map +1 -0
- package/dist/entry-storage-mongodb.d.cts +25 -0
- package/dist/entry-storage-mongodb.d.mts +25 -0
- package/dist/entry-storage-mongodb.mjs +58 -0
- package/dist/entry-storage-mongodb.mjs.map +1 -0
- package/dist/entry-storage-postgres.cjs +62 -0
- package/dist/entry-storage-postgres.cjs.map +1 -0
- package/dist/entry-storage-postgres.d.cts +29 -0
- package/dist/entry-storage-postgres.d.mts +29 -0
- package/dist/entry-storage-postgres.mjs +58 -0
- package/dist/entry-storage-postgres.mjs.map +1 -0
- package/dist/entry-storage-redis.cjs +76 -0
- package/dist/entry-storage-redis.cjs.map +1 -0
- package/dist/entry-storage-redis.d.cts +29 -0
- package/dist/entry-storage-redis.d.mts +29 -0
- package/dist/entry-storage-redis.mjs +72 -0
- package/dist/entry-storage-redis.mjs.map +1 -0
- package/dist/entry-storage-sqlite.cjs +46 -0
- package/dist/entry-storage-sqlite.cjs.map +1 -0
- package/dist/entry-storage-sqlite.d.cts +22 -0
- package/dist/entry-storage-sqlite.d.mts +22 -0
- package/dist/entry-storage-sqlite.mjs +43 -0
- package/dist/entry-storage-sqlite.mjs.map +1 -0
- package/dist/entry-storage-unstorage.cjs +8 -0
- package/dist/entry-storage-unstorage.d.cts +2 -0
- package/dist/entry-storage-unstorage.d.mts +2 -0
- package/dist/entry-storage-unstorage.mjs +2 -0
- package/dist/error-codes-9MRMSSMQ.cjs +49 -0
- package/dist/error-codes-9MRMSSMQ.cjs.map +1 -0
- package/dist/error-codes-CCKuDDu7.mjs +44 -0
- package/dist/error-codes-CCKuDDu7.mjs.map +1 -0
- package/dist/errors-bL3XQLfE.mjs +54 -0
- package/dist/errors-bL3XQLfE.mjs.map +1 -0
- package/dist/errors-vVYic8gz.cjs +89 -0
- package/dist/errors-vVYic8gz.cjs.map +1 -0
- package/dist/events-AE4Ytqmz.d.cts +6 -0
- package/dist/events-AE4Ytqmz.d.mts +6 -0
- package/dist/events-DYZShrYB.mjs +15 -0
- package/dist/events-DYZShrYB.mjs.map +1 -0
- package/dist/events-FJ2K0wly.cjs +26 -0
- package/dist/events-FJ2K0wly.cjs.map +1 -0
- package/dist/guard-BOx5cnMP.mjs +141 -0
- package/dist/guard-BOx5cnMP.mjs.map +1 -0
- package/dist/guard-C3o7V14m.d.cts +62 -0
- package/dist/guard-DCbTnqPz.d.mts +62 -0
- package/dist/guard-nwdOYe90.cjs +188 -0
- package/dist/guard-nwdOYe90.cjs.map +1 -0
- package/dist/index-BVVgDSdq.d.cts +1 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.cjs +240 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +195 -0
- package/dist/index.d.mts +195 -0
- package/dist/index.mjs +60 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kit-C7tepDB2.cjs +76 -0
- package/dist/kit-C7tepDB2.cjs.map +1 -0
- package/dist/kit-DMVBLBI9.d.mts +57 -0
- package/dist/kit-fzXHYb1l.mjs +65 -0
- package/dist/kit-fzXHYb1l.mjs.map +1 -0
- package/dist/kit-qAROuhOI.d.cts +57 -0
- package/dist/memory-BbBbbY8-.mjs +32 -0
- package/dist/memory-BbBbbY8-.mjs.map +1 -0
- package/dist/memory-knijqKw_.cjs +39 -0
- package/dist/memory-knijqKw_.cjs.map +1 -0
- package/dist/permissions-C9PjftY6.mjs +59 -0
- package/dist/permissions-C9PjftY6.mjs.map +1 -0
- package/dist/permissions-Cxri_P_k.cjs +70 -0
- package/dist/permissions-Cxri_P_k.cjs.map +1 -0
- package/dist/policy-BQmlo2lu.mjs +3 -0
- package/dist/policy-CGA6QD0a.d.mts +4 -0
- package/dist/policy-DFq_SYR3.d.cts +4 -0
- package/dist/react-embed.js +18710 -0
- package/dist/react.css +1 -0
- package/dist/relationships-BLYEJ9tc.cjs +907 -0
- package/dist/relationships-BLYEJ9tc.cjs.map +1 -0
- package/dist/relationships-BfLonEMI.mjs +756 -0
- package/dist/relationships-BfLonEMI.mjs.map +1 -0
- package/dist/roles-DBk4i8b5.mjs +69 -0
- package/dist/roles-DBk4i8b5.mjs.map +1 -0
- package/dist/roles-a8B5uZ35.cjs +104 -0
- package/dist/roles-a8B5uZ35.cjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/routes-DtRb3EO0.mjs +1001 -0
- package/dist/routes-DtRb3EO0.mjs.map +1 -0
- package/dist/routes-irNuuZqo.cjs +1049 -0
- package/dist/routes-irNuuZqo.cjs.map +1 -0
- package/dist/server-C2F4H6bR.d.cts +886 -0
- package/dist/server-CJ7AIJpO.d.mts +886 -0
- package/dist/table-DA98mVVT.d.cts +2 -0
- package/dist/table-DA98mVVT.d.mts +2 -0
- package/dist/testing.cjs +59 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +37 -0
- package/dist/testing.d.mts +37 -0
- package/dist/testing.mjs +57 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-elysia2/adapters/elysia-shared.d.ts +71 -0
- package/dist/types-elysia2/adapters/elysia2.d.ts +432 -0
- package/dist/types-elysia2/adapters/guard.d.ts +140 -0
- package/dist/types-elysia2/auth/contract.d.ts +9 -0
- package/dist/types-elysia2/auth-provider/contract.d.ts +57 -0
- package/dist/types-elysia2/auth-provider/kit.d.ts +57 -0
- package/dist/types-elysia2/authorization/contract.d.ts +53 -0
- package/dist/types-elysia2/authorization/permissions.d.ts +54 -0
- package/dist/types-elysia2/catalog.d.ts +197 -0
- package/dist/types-elysia2/engine.d.ts +192 -0
- package/dist/types-elysia2/entry-elysia2.d.ts +9 -0
- package/dist/types-elysia2/errors.d.ts +47 -0
- package/dist/types-elysia2/hooks/contract.d.ts +100 -0
- package/dist/types-elysia2/keys.d.ts +78 -0
- package/dist/types-elysia2/policy.d.ts +13 -0
- package/dist/types-elysia2/relationships.d.ts +162 -0
- package/dist/types-elysia2/schema.d.ts +299 -0
- package/dist/types-elysia2/server/cors.d.ts +8 -0
- package/dist/types-elysia2/server/create-fetch-handler.d.ts +87 -0
- package/dist/types-elysia2/server/openapi.d.ts +29 -0
- package/dist/types-elysia2/server/routes.d.ts +132 -0
- package/dist/types-elysia2/server/validation.d.ts +205 -0
- package/dist/types-elysia2/storage/contract.d.ts +18 -0
- package/dist/types-react/catalog.d.ts +197 -0
- package/dist/types-react/engine.d.ts +192 -0
- package/dist/types-react/entry-react-embed.d.ts +20 -0
- package/dist/types-react/errors.d.ts +47 -0
- package/dist/types-react/hooks/contract.d.ts +100 -0
- package/dist/types-react/keys.d.ts +78 -0
- package/dist/types-react/policy.d.ts +13 -0
- package/dist/types-react/react-embed.d.ts +37 -0
- package/dist/types-react/relationships.d.ts +162 -0
- package/dist/types-react/schema.d.ts +299 -0
- package/dist/types-react/storage/contract.d.ts +18 -0
- package/dist/types-react/ui/App.d.ts +23 -0
- package/dist/types-react/ui/api.d.ts +73 -0
- package/dist/types-react/ui/components/perm-bits.d.ts +64 -0
- package/dist/types-react/ui/lib/queries.d.ts +46 -0
- package/dist/types-react/ui/theme.d.ts +10 -0
- package/dist/types-react/ui/types.d.ts +109 -0
- package/dist/types-react/ui/views/CatalogView.d.ts +3 -0
- package/dist/types-react/ui/views/HistoryView.d.ts +6 -0
- package/dist/types-react/ui/views/PlaygroundView.d.ts +14 -0
- package/dist/types-react/ui/views/RelationshipsView.d.ts +6 -0
- package/dist/types-react/ui/views/SubjectDetailView.d.ts +7 -0
- package/dist/types-react/ui/views/SubjectsView.d.ts +6 -0
- package/dist/ui/apple-touch-icon.png +0 -0
- package/dist/ui/assets/index-DCPZRo-Z.css +1 -0
- package/dist/ui/assets/index-uXGOtyuj.js +104 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/favicon.svg +15 -0
- package/dist/ui/index.html +20 -0
- package/package.json +587 -4
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/memory";
|
|
2
|
+
|
|
3
|
+
//#region src/storage/memory.d.ts
|
|
4
|
+
/** Options for {@link createMemoryStorage}. */
|
|
5
|
+
type MemoryStorageOptions = kit.MemoryStorageOptions;
|
|
6
|
+
/** The memory storage: watchable and compare-and-swap capable. */
|
|
7
|
+
type MemoryPermissionsStorage = kit.MemoryKvStorage;
|
|
8
|
+
/**
|
|
9
|
+
* Create an in-memory storage implementing both `watch` (callbacks fire on the
|
|
10
|
+
* next microtask after a write/remove) and `compareAndSwap` (structural
|
|
11
|
+
* equality; race-free in-process).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createMemoryStorage } from "@xtandard/permissions/storage/memory";
|
|
16
|
+
*
|
|
17
|
+
* const storage = createMemoryStorage();
|
|
18
|
+
* // Optionally seed with pre-existing data:
|
|
19
|
+
* // const storage = createMemoryStorage({ initial: { "my-key": { value: 1 } } });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function createMemoryStorage(options?: MemoryStorageOptions): MemoryPermissionsStorage;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { type MemoryPermissionsStorage, type MemoryStorageOptions, createMemoryStorage };
|
|
25
|
+
//# sourceMappingURL=entry-storage-memory.d.mts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
3
|
+
let _xtandard_kit_storage_mongodb = require("@xtandard/kit/storage/mongodb");
|
|
4
|
+
_xtandard_kit_storage_mongodb = require_chunk.__toESM(_xtandard_kit_storage_mongodb, 1);
|
|
5
|
+
//#region src/storage/mongodb.ts
|
|
6
|
+
/**
|
|
7
|
+
* MongoDB storage adapter built on the [`mongodb`](https://github.com/mongodb/node-mongodb-native)
|
|
8
|
+
* driver, an optional peer dependency. You can either pass a pre-constructed
|
|
9
|
+
* (optionally pre-connected) `MongoClient`, or a connection `url` to create and
|
|
10
|
+
* connect a client lazily on first use.
|
|
11
|
+
*
|
|
12
|
+
* The backend is a single collection of `{ _id: <key>, value: <any> }` documents.
|
|
13
|
+
* The storage key is stored verbatim as the document `_id`, and the value is
|
|
14
|
+
* stored directly as a BSON field — MongoDB persists arbitrary objects, arrays,
|
|
15
|
+
* and primitives, so no JSON (de)serialisation round-trip is needed. Object
|
|
16
|
+
* keys are written in sorted (canonical) order, because BSON document equality
|
|
17
|
+
* is field-order sensitive and `compareAndSwap` relies on it.
|
|
18
|
+
*
|
|
19
|
+
* `getKeys(prefix)` matches `_id` against an anchored, escaped regular
|
|
20
|
+
* expression (`^<prefix>`; case-sensitive), projecting only `_id` so the server
|
|
21
|
+
* never ships values back for a key listing.
|
|
22
|
+
*
|
|
23
|
+
* `compareAndSwap` is one `updateOne({ _id, $expr: { $eq: ["$value", expected] } })`
|
|
24
|
+
* (or an `insertOne` guarded by the unique `_id` when absence is expected), so it
|
|
25
|
+
* is atomic on any deployment, standalone included.
|
|
26
|
+
*
|
|
27
|
+
* ## Why no `watch`
|
|
28
|
+
*
|
|
29
|
+
* MongoDB change streams (the natural way to back a watchable storage) require
|
|
30
|
+
* a replica set or sharded cluster — they are unavailable on a standalone
|
|
31
|
+
* `mongod`. To keep this adapter usable against any deployment, `watch` is
|
|
32
|
+
* intentionally **not** implemented; the engine feature-detects its absence via
|
|
33
|
+
* `isWatchable` and relies on its cache TTL instead.
|
|
34
|
+
*
|
|
35
|
+
* The driver is `@xtandard/kit/storage/mongodb`.
|
|
36
|
+
*
|
|
37
|
+
* @module
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is
|
|
41
|
+
* created and connected lazily when only a `url` is given.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { createMongoStorage } from "@xtandard/permissions/storage/mongodb";
|
|
46
|
+
*
|
|
47
|
+
* const storage = createMongoStorage({ url: process.env.MONGO_URL });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function createMongoStorage(options) {
|
|
51
|
+
return _xtandard_kit_storage_mongodb.createMongoStorage({
|
|
52
|
+
subpath: "@xtandard/permissions/storage/mongodb",
|
|
53
|
+
...options,
|
|
54
|
+
dbName: options.dbName ?? "xtandard_permissions",
|
|
55
|
+
collectionName: options.collectionName ?? "permissions_kv"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.createMongoStorage = createMongoStorage;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=entry-storage-mongodb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-storage-mongodb.cjs","names":["kit"],"sources":["../src/storage/mongodb.ts"],"sourcesContent":["/**\n * MongoDB storage adapter built on the [`mongodb`](https://github.com/mongodb/node-mongodb-native)\n * driver, an optional peer dependency. You can either pass a pre-constructed\n * (optionally pre-connected) `MongoClient`, or a connection `url` to create and\n * connect a client lazily on first use.\n *\n * The backend is a single collection of `{ _id: <key>, value: <any> }` documents.\n * The storage key is stored verbatim as the document `_id`, and the value is\n * stored directly as a BSON field — MongoDB persists arbitrary objects, arrays,\n * and primitives, so no JSON (de)serialisation round-trip is needed. Object\n * keys are written in sorted (canonical) order, because BSON document equality\n * is field-order sensitive and `compareAndSwap` relies on it.\n *\n * `getKeys(prefix)` matches `_id` against an anchored, escaped regular\n * expression (`^<prefix>`; case-sensitive), projecting only `_id` so the server\n * never ships values back for a key listing.\n *\n * `compareAndSwap` is one `updateOne({ _id, $expr: { $eq: [\"$value\", expected] } })`\n * (or an `insertOne` guarded by the unique `_id` when absence is expected), so it\n * is atomic on any deployment, standalone included.\n *\n * ## Why no `watch`\n *\n * MongoDB change streams (the natural way to back a watchable storage) require\n * a replica set or sharded cluster — they are unavailable on a standalone\n * `mongod`. To keep this adapter usable against any deployment, `watch` is\n * intentionally **not** implemented; the engine feature-detects its absence via\n * `isWatchable` and relies on its cache TTL instead.\n *\n * The driver is `@xtandard/kit/storage/mongodb`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/mongodb\";\n\n/**\n * Options for {@link createMongoStorage}. `dbName` defaults to\n * `\"xtandard_permissions\"` and `collectionName` to `\"permissions_kv\"`.\n */\nexport type MongoStorageOptions = kit.MongoStorageOptions;\n\n/** A compare-and-swap capable storage backed by MongoDB, plus `close()`. */\nexport type MongoPermissionsStorage = kit.MongoKvStorage;\n\n/**\n * Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is\n * created and connected lazily when only a `url` is given.\n *\n * @example\n * ```ts\n * import { createMongoStorage } from \"@xtandard/permissions/storage/mongodb\";\n *\n * const storage = createMongoStorage({ url: process.env.MONGO_URL });\n * ```\n */\nexport function createMongoStorage(options: MongoStorageOptions): MongoPermissionsStorage {\n return kit.createMongoStorage({\n subpath: \"@xtandard/permissions/storage/mongodb\",\n ...options,\n dbName: options.dbName ?? \"xtandard_permissions\",\n collectionName: options.collectionName ?? \"permissions_kv\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,mBAAmB,SAAuD;CACxF,OAAOA,8BAAI,mBAAmB;EAC5B,SAAS;EACT,GAAG;EACH,QAAQ,QAAQ,UAAU;EAC1B,gBAAgB,QAAQ,kBAAkB;CAC5C,CAAC;AACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/mongodb";
|
|
2
|
+
|
|
3
|
+
//#region src/storage/mongodb.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link createMongoStorage}. `dbName` defaults to
|
|
6
|
+
* `"xtandard_permissions"` and `collectionName` to `"permissions_kv"`.
|
|
7
|
+
*/
|
|
8
|
+
type MongoStorageOptions = kit.MongoStorageOptions;
|
|
9
|
+
/** A compare-and-swap capable storage backed by MongoDB, plus `close()`. */
|
|
10
|
+
type MongoPermissionsStorage = kit.MongoKvStorage;
|
|
11
|
+
/**
|
|
12
|
+
* Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is
|
|
13
|
+
* created and connected lazily when only a `url` is given.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createMongoStorage } from "@xtandard/permissions/storage/mongodb";
|
|
18
|
+
*
|
|
19
|
+
* const storage = createMongoStorage({ url: process.env.MONGO_URL });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function createMongoStorage(options: MongoStorageOptions): MongoPermissionsStorage;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { type MongoPermissionsStorage, type MongoStorageOptions, createMongoStorage };
|
|
25
|
+
//# sourceMappingURL=entry-storage-mongodb.d.cts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/mongodb";
|
|
2
|
+
|
|
3
|
+
//#region src/storage/mongodb.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link createMongoStorage}. `dbName` defaults to
|
|
6
|
+
* `"xtandard_permissions"` and `collectionName` to `"permissions_kv"`.
|
|
7
|
+
*/
|
|
8
|
+
type MongoStorageOptions = kit.MongoStorageOptions;
|
|
9
|
+
/** A compare-and-swap capable storage backed by MongoDB, plus `close()`. */
|
|
10
|
+
type MongoPermissionsStorage = kit.MongoKvStorage;
|
|
11
|
+
/**
|
|
12
|
+
* Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is
|
|
13
|
+
* created and connected lazily when only a `url` is given.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createMongoStorage } from "@xtandard/permissions/storage/mongodb";
|
|
18
|
+
*
|
|
19
|
+
* const storage = createMongoStorage({ url: process.env.MONGO_URL });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function createMongoStorage(options: MongoStorageOptions): MongoPermissionsStorage;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { type MongoPermissionsStorage, type MongoStorageOptions, createMongoStorage };
|
|
25
|
+
//# sourceMappingURL=entry-storage-mongodb.d.mts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/mongodb";
|
|
2
|
+
//#region src/storage/mongodb.ts
|
|
3
|
+
/**
|
|
4
|
+
* MongoDB storage adapter built on the [`mongodb`](https://github.com/mongodb/node-mongodb-native)
|
|
5
|
+
* driver, an optional peer dependency. You can either pass a pre-constructed
|
|
6
|
+
* (optionally pre-connected) `MongoClient`, or a connection `url` to create and
|
|
7
|
+
* connect a client lazily on first use.
|
|
8
|
+
*
|
|
9
|
+
* The backend is a single collection of `{ _id: <key>, value: <any> }` documents.
|
|
10
|
+
* The storage key is stored verbatim as the document `_id`, and the value is
|
|
11
|
+
* stored directly as a BSON field — MongoDB persists arbitrary objects, arrays,
|
|
12
|
+
* and primitives, so no JSON (de)serialisation round-trip is needed. Object
|
|
13
|
+
* keys are written in sorted (canonical) order, because BSON document equality
|
|
14
|
+
* is field-order sensitive and `compareAndSwap` relies on it.
|
|
15
|
+
*
|
|
16
|
+
* `getKeys(prefix)` matches `_id` against an anchored, escaped regular
|
|
17
|
+
* expression (`^<prefix>`; case-sensitive), projecting only `_id` so the server
|
|
18
|
+
* never ships values back for a key listing.
|
|
19
|
+
*
|
|
20
|
+
* `compareAndSwap` is one `updateOne({ _id, $expr: { $eq: ["$value", expected] } })`
|
|
21
|
+
* (or an `insertOne` guarded by the unique `_id` when absence is expected), so it
|
|
22
|
+
* is atomic on any deployment, standalone included.
|
|
23
|
+
*
|
|
24
|
+
* ## Why no `watch`
|
|
25
|
+
*
|
|
26
|
+
* MongoDB change streams (the natural way to back a watchable storage) require
|
|
27
|
+
* a replica set or sharded cluster — they are unavailable on a standalone
|
|
28
|
+
* `mongod`. To keep this adapter usable against any deployment, `watch` is
|
|
29
|
+
* intentionally **not** implemented; the engine feature-detects its absence via
|
|
30
|
+
* `isWatchable` and relies on its cache TTL instead.
|
|
31
|
+
*
|
|
32
|
+
* The driver is `@xtandard/kit/storage/mongodb`.
|
|
33
|
+
*
|
|
34
|
+
* @module
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is
|
|
38
|
+
* created and connected lazily when only a `url` is given.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createMongoStorage } from "@xtandard/permissions/storage/mongodb";
|
|
43
|
+
*
|
|
44
|
+
* const storage = createMongoStorage({ url: process.env.MONGO_URL });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function createMongoStorage(options) {
|
|
48
|
+
return kit.createMongoStorage({
|
|
49
|
+
subpath: "@xtandard/permissions/storage/mongodb",
|
|
50
|
+
...options,
|
|
51
|
+
dbName: options.dbName ?? "xtandard_permissions",
|
|
52
|
+
collectionName: options.collectionName ?? "permissions_kv"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createMongoStorage };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=entry-storage-mongodb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-storage-mongodb.mjs","names":[],"sources":["../src/storage/mongodb.ts"],"sourcesContent":["/**\n * MongoDB storage adapter built on the [`mongodb`](https://github.com/mongodb/node-mongodb-native)\n * driver, an optional peer dependency. You can either pass a pre-constructed\n * (optionally pre-connected) `MongoClient`, or a connection `url` to create and\n * connect a client lazily on first use.\n *\n * The backend is a single collection of `{ _id: <key>, value: <any> }` documents.\n * The storage key is stored verbatim as the document `_id`, and the value is\n * stored directly as a BSON field — MongoDB persists arbitrary objects, arrays,\n * and primitives, so no JSON (de)serialisation round-trip is needed. Object\n * keys are written in sorted (canonical) order, because BSON document equality\n * is field-order sensitive and `compareAndSwap` relies on it.\n *\n * `getKeys(prefix)` matches `_id` against an anchored, escaped regular\n * expression (`^<prefix>`; case-sensitive), projecting only `_id` so the server\n * never ships values back for a key listing.\n *\n * `compareAndSwap` is one `updateOne({ _id, $expr: { $eq: [\"$value\", expected] } })`\n * (or an `insertOne` guarded by the unique `_id` when absence is expected), so it\n * is atomic on any deployment, standalone included.\n *\n * ## Why no `watch`\n *\n * MongoDB change streams (the natural way to back a watchable storage) require\n * a replica set or sharded cluster — they are unavailable on a standalone\n * `mongod`. To keep this adapter usable against any deployment, `watch` is\n * intentionally **not** implemented; the engine feature-detects its absence via\n * `isWatchable` and relies on its cache TTL instead.\n *\n * The driver is `@xtandard/kit/storage/mongodb`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/mongodb\";\n\n/**\n * Options for {@link createMongoStorage}. `dbName` defaults to\n * `\"xtandard_permissions\"` and `collectionName` to `\"permissions_kv\"`.\n */\nexport type MongoStorageOptions = kit.MongoStorageOptions;\n\n/** A compare-and-swap capable storage backed by MongoDB, plus `close()`. */\nexport type MongoPermissionsStorage = kit.MongoKvStorage;\n\n/**\n * Create a MongoDB-backed {@link MongoPermissionsStorage}. The client is\n * created and connected lazily when only a `url` is given.\n *\n * @example\n * ```ts\n * import { createMongoStorage } from \"@xtandard/permissions/storage/mongodb\";\n *\n * const storage = createMongoStorage({ url: process.env.MONGO_URL });\n * ```\n */\nexport function createMongoStorage(options: MongoStorageOptions): MongoPermissionsStorage {\n return kit.createMongoStorage({\n subpath: \"@xtandard/permissions/storage/mongodb\",\n ...options,\n dbName: options.dbName ?? \"xtandard_permissions\",\n collectionName: options.collectionName ?? \"permissions_kv\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,mBAAmB,SAAuD;CACxF,OAAO,IAAI,mBAAmB;EAC5B,SAAS;EACT,GAAG;EACH,QAAQ,QAAQ,UAAU;EAC1B,gBAAgB,QAAQ,kBAAkB;CAC5C,CAAC;AACH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
3
|
+
let _xtandard_kit_storage_postgres = require("@xtandard/kit/storage/postgres");
|
|
4
|
+
_xtandard_kit_storage_postgres = require_chunk.__toESM(_xtandard_kit_storage_postgres, 1);
|
|
5
|
+
//#region src/storage/postgres.ts
|
|
6
|
+
/**
|
|
7
|
+
* Postgres storage adapter backed by a single key/value table
|
|
8
|
+
* (`key text COLLATE "C" PRIMARY KEY, value jsonb`). It works with any client
|
|
9
|
+
* exposing a `query(text, params?)` method that resolves to `{ rows }` — this
|
|
10
|
+
* covers [`pg`](https://github.com/brianc/node-postgres) (`Pool`/`Client`) and
|
|
11
|
+
* the in-process [`@electric-sql/pglite`](https://github.com/electric-sql/pglite)
|
|
12
|
+
* alike. You can pass a pre-built `client`, or a `connectionString`/`url` to
|
|
13
|
+
* lazily create a `pg` `Pool` on first use.
|
|
14
|
+
*
|
|
15
|
+
* The table is created on demand (`CREATE TABLE IF NOT EXISTS`) the first time
|
|
16
|
+
* any operation runs, guarded by a single promise so concurrent callers only
|
|
17
|
+
* issue the DDL once. The key column uses the `"C"` collation so ordering and
|
|
18
|
+
* `LIKE` prefixes are bytewise (case-sensitive) whatever the database default.
|
|
19
|
+
* Values are stored as `jsonb`; both `pg` and `pglite` return `jsonb` already
|
|
20
|
+
* parsed to JS, but a string is JSON-parsed defensively so either driver works.
|
|
21
|
+
*
|
|
22
|
+
* `compareAndSwap` is a single statement — `UPDATE … WHERE key = $1 AND value =
|
|
23
|
+
* $2::jsonb` (jsonb equality is structural) or `INSERT … ON CONFLICT DO
|
|
24
|
+
* NOTHING` when absence is expected — so it is atomic across connections.
|
|
25
|
+
*
|
|
26
|
+
* The driver is `@xtandard/kit/storage/postgres`.
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
/** The persisted default table name. */
|
|
31
|
+
const DEFAULT_TABLE = "xtandard_permissions_kv";
|
|
32
|
+
/**
|
|
33
|
+
* The DDL {@link createPostgresStorage} runs on first use — for migrations when
|
|
34
|
+
* the runtime role may not create tables.
|
|
35
|
+
*/
|
|
36
|
+
function postgresStorageSchema(table = DEFAULT_TABLE) {
|
|
37
|
+
return _xtandard_kit_storage_postgres.postgresStorageSchema(table);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and
|
|
41
|
+
* table creation are lazy.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { createPostgresStorage } from "@xtandard/permissions/storage/postgres";
|
|
46
|
+
*
|
|
47
|
+
* const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });
|
|
48
|
+
* // or: createPostgresStorage({ client: new PGlite() })
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
function createPostgresStorage(options = {}) {
|
|
52
|
+
return _xtandard_kit_storage_postgres.createPostgresStorage({
|
|
53
|
+
subpath: "@xtandard/permissions/storage/postgres",
|
|
54
|
+
...options,
|
|
55
|
+
table: options.table ?? DEFAULT_TABLE
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.createPostgresStorage = createPostgresStorage;
|
|
60
|
+
exports.postgresStorageSchema = postgresStorageSchema;
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=entry-storage-postgres.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-storage-postgres.cjs","names":["kit"],"sources":["../src/storage/postgres.ts"],"sourcesContent":["/**\n * Postgres storage adapter backed by a single key/value table\n * (`key text COLLATE \"C\" PRIMARY KEY, value jsonb`). It works with any client\n * exposing a `query(text, params?)` method that resolves to `{ rows }` — this\n * covers [`pg`](https://github.com/brianc/node-postgres) (`Pool`/`Client`) and\n * the in-process [`@electric-sql/pglite`](https://github.com/electric-sql/pglite)\n * alike. You can pass a pre-built `client`, or a `connectionString`/`url` to\n * lazily create a `pg` `Pool` on first use.\n *\n * The table is created on demand (`CREATE TABLE IF NOT EXISTS`) the first time\n * any operation runs, guarded by a single promise so concurrent callers only\n * issue the DDL once. The key column uses the `\"C\"` collation so ordering and\n * `LIKE` prefixes are bytewise (case-sensitive) whatever the database default.\n * Values are stored as `jsonb`; both `pg` and `pglite` return `jsonb` already\n * parsed to JS, but a string is JSON-parsed defensively so either driver works.\n *\n * `compareAndSwap` is a single statement — `UPDATE … WHERE key = $1 AND value =\n * $2::jsonb` (jsonb equality is structural) or `INSERT … ON CONFLICT DO\n * NOTHING` when absence is expected — so it is atomic across connections.\n *\n * The driver is `@xtandard/kit/storage/postgres`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/postgres\";\n\nexport type { ClosableSqlClient, SqlClient } from \"@xtandard/kit/storage/postgres\";\n\n/** Options for {@link createPostgresStorage}. `table` defaults to `\"xtandard_permissions_kv\"`. */\nexport type PostgresStorageOptions = kit.PostgresStorageOptions;\n\n/** A compare-and-swap capable storage backed by Postgres, plus `close()`. */\nexport type PostgresPermissionsStorage = kit.PostgresKvStorage;\n\n/** The persisted default table name. */\nconst DEFAULT_TABLE = \"xtandard_permissions_kv\";\n\n/**\n * The DDL {@link createPostgresStorage} runs on first use — for migrations when\n * the runtime role may not create tables.\n */\nexport function postgresStorageSchema(table = DEFAULT_TABLE): string {\n return kit.postgresStorageSchema(table);\n}\n\n/**\n * Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and\n * table creation are lazy.\n *\n * @example\n * ```ts\n * import { createPostgresStorage } from \"@xtandard/permissions/storage/postgres\";\n *\n * const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });\n * // or: createPostgresStorage({ client: new PGlite() })\n * ```\n */\nexport function createPostgresStorage(\n options: PostgresStorageOptions = {},\n): PostgresPermissionsStorage {\n return kit.createPostgresStorage({\n subpath: \"@xtandard/permissions/storage/postgres\",\n ...options,\n table: options.table ?? DEFAULT_TABLE,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,gBAAgB;;;;;AAMtB,SAAgB,sBAAsB,QAAQ,eAAuB;CACnE,OAAOA,+BAAI,sBAAsB,KAAK;AACxC;;;;;;;;;;;;;AAcA,SAAgB,sBACd,UAAkC,CAAC,GACP;CAC5B,OAAOA,+BAAI,sBAAsB;EAC/B,SAAS;EACT,GAAG;EACH,OAAO,QAAQ,SAAS;CAC1B,CAAC;AACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/postgres";
|
|
2
|
+
import { ClosableSqlClient, SqlClient } from "@xtandard/kit/storage/postgres";
|
|
3
|
+
|
|
4
|
+
//#region src/storage/postgres.d.ts
|
|
5
|
+
/** Options for {@link createPostgresStorage}. `table` defaults to `"xtandard_permissions_kv"`. */
|
|
6
|
+
type PostgresStorageOptions = kit.PostgresStorageOptions;
|
|
7
|
+
/** A compare-and-swap capable storage backed by Postgres, plus `close()`. */
|
|
8
|
+
type PostgresPermissionsStorage = kit.PostgresKvStorage;
|
|
9
|
+
/**
|
|
10
|
+
* The DDL {@link createPostgresStorage} runs on first use — for migrations when
|
|
11
|
+
* the runtime role may not create tables.
|
|
12
|
+
*/
|
|
13
|
+
declare function postgresStorageSchema(table?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and
|
|
16
|
+
* table creation are lazy.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createPostgresStorage } from "@xtandard/permissions/storage/postgres";
|
|
21
|
+
*
|
|
22
|
+
* const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });
|
|
23
|
+
* // or: createPostgresStorage({ client: new PGlite() })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function createPostgresStorage(options?: PostgresStorageOptions): PostgresPermissionsStorage;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type ClosableSqlClient, type PostgresPermissionsStorage, type PostgresStorageOptions, type SqlClient, createPostgresStorage, postgresStorageSchema };
|
|
29
|
+
//# sourceMappingURL=entry-storage-postgres.d.cts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/postgres";
|
|
2
|
+
import { ClosableSqlClient, SqlClient } from "@xtandard/kit/storage/postgres";
|
|
3
|
+
|
|
4
|
+
//#region src/storage/postgres.d.ts
|
|
5
|
+
/** Options for {@link createPostgresStorage}. `table` defaults to `"xtandard_permissions_kv"`. */
|
|
6
|
+
type PostgresStorageOptions = kit.PostgresStorageOptions;
|
|
7
|
+
/** A compare-and-swap capable storage backed by Postgres, plus `close()`. */
|
|
8
|
+
type PostgresPermissionsStorage = kit.PostgresKvStorage;
|
|
9
|
+
/**
|
|
10
|
+
* The DDL {@link createPostgresStorage} runs on first use — for migrations when
|
|
11
|
+
* the runtime role may not create tables.
|
|
12
|
+
*/
|
|
13
|
+
declare function postgresStorageSchema(table?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and
|
|
16
|
+
* table creation are lazy.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createPostgresStorage } from "@xtandard/permissions/storage/postgres";
|
|
21
|
+
*
|
|
22
|
+
* const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });
|
|
23
|
+
* // or: createPostgresStorage({ client: new PGlite() })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function createPostgresStorage(options?: PostgresStorageOptions): PostgresPermissionsStorage;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type ClosableSqlClient, type PostgresPermissionsStorage, type PostgresStorageOptions, type SqlClient, createPostgresStorage, postgresStorageSchema };
|
|
29
|
+
//# sourceMappingURL=entry-storage-postgres.d.mts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/postgres";
|
|
2
|
+
//#region src/storage/postgres.ts
|
|
3
|
+
/**
|
|
4
|
+
* Postgres storage adapter backed by a single key/value table
|
|
5
|
+
* (`key text COLLATE "C" PRIMARY KEY, value jsonb`). It works with any client
|
|
6
|
+
* exposing a `query(text, params?)` method that resolves to `{ rows }` — this
|
|
7
|
+
* covers [`pg`](https://github.com/brianc/node-postgres) (`Pool`/`Client`) and
|
|
8
|
+
* the in-process [`@electric-sql/pglite`](https://github.com/electric-sql/pglite)
|
|
9
|
+
* alike. You can pass a pre-built `client`, or a `connectionString`/`url` to
|
|
10
|
+
* lazily create a `pg` `Pool` on first use.
|
|
11
|
+
*
|
|
12
|
+
* The table is created on demand (`CREATE TABLE IF NOT EXISTS`) the first time
|
|
13
|
+
* any operation runs, guarded by a single promise so concurrent callers only
|
|
14
|
+
* issue the DDL once. The key column uses the `"C"` collation so ordering and
|
|
15
|
+
* `LIKE` prefixes are bytewise (case-sensitive) whatever the database default.
|
|
16
|
+
* Values are stored as `jsonb`; both `pg` and `pglite` return `jsonb` already
|
|
17
|
+
* parsed to JS, but a string is JSON-parsed defensively so either driver works.
|
|
18
|
+
*
|
|
19
|
+
* `compareAndSwap` is a single statement — `UPDATE … WHERE key = $1 AND value =
|
|
20
|
+
* $2::jsonb` (jsonb equality is structural) or `INSERT … ON CONFLICT DO
|
|
21
|
+
* NOTHING` when absence is expected — so it is atomic across connections.
|
|
22
|
+
*
|
|
23
|
+
* The driver is `@xtandard/kit/storage/postgres`.
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
/** The persisted default table name. */
|
|
28
|
+
const DEFAULT_TABLE = "xtandard_permissions_kv";
|
|
29
|
+
/**
|
|
30
|
+
* The DDL {@link createPostgresStorage} runs on first use — for migrations when
|
|
31
|
+
* the runtime role may not create tables.
|
|
32
|
+
*/
|
|
33
|
+
function postgresStorageSchema(table = DEFAULT_TABLE) {
|
|
34
|
+
return kit.postgresStorageSchema(table);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and
|
|
38
|
+
* table creation are lazy.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createPostgresStorage } from "@xtandard/permissions/storage/postgres";
|
|
43
|
+
*
|
|
44
|
+
* const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });
|
|
45
|
+
* // or: createPostgresStorage({ client: new PGlite() })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
function createPostgresStorage(options = {}) {
|
|
49
|
+
return kit.createPostgresStorage({
|
|
50
|
+
subpath: "@xtandard/permissions/storage/postgres",
|
|
51
|
+
...options,
|
|
52
|
+
table: options.table ?? DEFAULT_TABLE
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createPostgresStorage, postgresStorageSchema };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=entry-storage-postgres.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-storage-postgres.mjs","names":[],"sources":["../src/storage/postgres.ts"],"sourcesContent":["/**\n * Postgres storage adapter backed by a single key/value table\n * (`key text COLLATE \"C\" PRIMARY KEY, value jsonb`). It works with any client\n * exposing a `query(text, params?)` method that resolves to `{ rows }` — this\n * covers [`pg`](https://github.com/brianc/node-postgres) (`Pool`/`Client`) and\n * the in-process [`@electric-sql/pglite`](https://github.com/electric-sql/pglite)\n * alike. You can pass a pre-built `client`, or a `connectionString`/`url` to\n * lazily create a `pg` `Pool` on first use.\n *\n * The table is created on demand (`CREATE TABLE IF NOT EXISTS`) the first time\n * any operation runs, guarded by a single promise so concurrent callers only\n * issue the DDL once. The key column uses the `\"C\"` collation so ordering and\n * `LIKE` prefixes are bytewise (case-sensitive) whatever the database default.\n * Values are stored as `jsonb`; both `pg` and `pglite` return `jsonb` already\n * parsed to JS, but a string is JSON-parsed defensively so either driver works.\n *\n * `compareAndSwap` is a single statement — `UPDATE … WHERE key = $1 AND value =\n * $2::jsonb` (jsonb equality is structural) or `INSERT … ON CONFLICT DO\n * NOTHING` when absence is expected — so it is atomic across connections.\n *\n * The driver is `@xtandard/kit/storage/postgres`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/postgres\";\n\nexport type { ClosableSqlClient, SqlClient } from \"@xtandard/kit/storage/postgres\";\n\n/** Options for {@link createPostgresStorage}. `table` defaults to `\"xtandard_permissions_kv\"`. */\nexport type PostgresStorageOptions = kit.PostgresStorageOptions;\n\n/** A compare-and-swap capable storage backed by Postgres, plus `close()`. */\nexport type PostgresPermissionsStorage = kit.PostgresKvStorage;\n\n/** The persisted default table name. */\nconst DEFAULT_TABLE = \"xtandard_permissions_kv\";\n\n/**\n * The DDL {@link createPostgresStorage} runs on first use — for migrations when\n * the runtime role may not create tables.\n */\nexport function postgresStorageSchema(table = DEFAULT_TABLE): string {\n return kit.postgresStorageSchema(table);\n}\n\n/**\n * Create a Postgres-backed {@link PostgresPermissionsStorage}. Connection and\n * table creation are lazy.\n *\n * @example\n * ```ts\n * import { createPostgresStorage } from \"@xtandard/permissions/storage/postgres\";\n *\n * const storage = createPostgresStorage({ connectionString: process.env.DATABASE_URL });\n * // or: createPostgresStorage({ client: new PGlite() })\n * ```\n */\nexport function createPostgresStorage(\n options: PostgresStorageOptions = {},\n): PostgresPermissionsStorage {\n return kit.createPostgresStorage({\n subpath: \"@xtandard/permissions/storage/postgres\",\n ...options,\n table: options.table ?? DEFAULT_TABLE,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,gBAAgB;;;;;AAMtB,SAAgB,sBAAsB,QAAQ,eAAuB;CACnE,OAAO,IAAI,sBAAsB,KAAK;AACxC;;;;;;;;;;;;;AAcA,SAAgB,sBACd,UAAkC,CAAC,GACP;CAC5B,OAAO,IAAI,sBAAsB;EAC/B,SAAS;EACT,GAAG;EACH,OAAO,QAAQ,SAAS;CAC1B,CAAC;AACH"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
3
|
+
let _xtandard_kit_storage_redis = require("@xtandard/kit/storage/redis");
|
|
4
|
+
_xtandard_kit_storage_redis = require_chunk.__toESM(_xtandard_kit_storage_redis, 1);
|
|
5
|
+
//#region src/storage/redis.ts
|
|
6
|
+
/**
|
|
7
|
+
* Redis storage adapters built on the [`redis`](https://github.com/redis/node-redis)
|
|
8
|
+
* package (node-redis v4/v5), an optional peer dependency. You can either pass a
|
|
9
|
+
* pre-connected `client` or a `url` to connect lazily on first use. An optional
|
|
10
|
+
* `prefix` is prepended (with a `:` separator) to every key so multiple
|
|
11
|
+
* deployments can share a Redis instance without collisions; the prefix is
|
|
12
|
+
* stripped from keys returned by {@link RedisPermissionsStorage.getKeys}.
|
|
13
|
+
*
|
|
14
|
+
* Two variants over the same plumbing, differing only in the value encoding:
|
|
15
|
+
*
|
|
16
|
+
* - {@link createRedisStorage} — values are plain **strings** containing JSON
|
|
17
|
+
* (`SET`/`GET`). Works on any Redis; the default choice.
|
|
18
|
+
* - {@link createRedisJSONStorage} — values are native **RedisJSON** documents
|
|
19
|
+
* (`JSON.SET`/`JSON.GET`), so the stored data is queryable with JSONPath and
|
|
20
|
+
* indexable with RediSearch. Requires the JSON module (Redis 8 / Redis Stack).
|
|
21
|
+
* Do NOT point both variants at the same keys — the types are incompatible
|
|
22
|
+
* (`WRONGTYPE`).
|
|
23
|
+
*
|
|
24
|
+
* `getKeys` uses a non-blocking `SCAN` cursor (never the blocking `KEYS`
|
|
25
|
+
* command) with the prefix glob-escaped, so `*`, `?`, `[` and `\` in a prefix
|
|
26
|
+
* match literally. `watch` is implemented with Redis keyspace notifications; it
|
|
27
|
+
* requires the server to be configured with `notify-keyspace-events` covering
|
|
28
|
+
* generic + string + expiry events (e.g. `KEA` — whose `A` class also covers the
|
|
29
|
+
* module events that RedisJSON writes emit, e.g. `json.set`).
|
|
30
|
+
*
|
|
31
|
+
* ## Compare-and-swap
|
|
32
|
+
*
|
|
33
|
+
* Both variants implement `compareAndSwap` with a small Lua script: it decodes
|
|
34
|
+
* the stored value and the expectation with `cjson`, compares them
|
|
35
|
+
* structurally (object key order is irrelevant) and writes `next` only on a
|
|
36
|
+
* match — one atomic server-side step, safe across any number of instances.
|
|
37
|
+
* The engine uses it for insert-if-absent grant writes.
|
|
38
|
+
*
|
|
39
|
+
* The driver is `@xtandard/kit/storage/redis`.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
42
|
+
*/
|
|
43
|
+
const SUBPATH = "@xtandard/permissions/storage/redis";
|
|
44
|
+
/**
|
|
45
|
+
* Create a Redis storage that stores values as JSON **strings**. Works on any
|
|
46
|
+
* Redis. Connection is lazy (first operation).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { createRedisStorage } from "@xtandard/permissions/storage/redis";
|
|
51
|
+
*
|
|
52
|
+
* const storage = createRedisStorage({ url: process.env.REDIS_URL, prefix: "permissions" });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function createRedisStorage(options) {
|
|
56
|
+
return _xtandard_kit_storage_redis.createRedisStorage({
|
|
57
|
+
subpath: SUBPATH,
|
|
58
|
+
...options
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a Redis storage that stores values as native **RedisJSON** documents.
|
|
63
|
+
* Needs Redis 8+ or Redis Stack. Never point it at keys written by
|
|
64
|
+
* {@link createRedisStorage}.
|
|
65
|
+
*/
|
|
66
|
+
function createRedisJSONStorage(options) {
|
|
67
|
+
return _xtandard_kit_storage_redis.createRedisJSONStorage({
|
|
68
|
+
subpath: SUBPATH,
|
|
69
|
+
...options
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.createRedisJSONStorage = createRedisJSONStorage;
|
|
74
|
+
exports.createRedisStorage = createRedisStorage;
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=entry-storage-redis.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-storage-redis.cjs","names":["kit"],"sources":["../src/storage/redis.ts"],"sourcesContent":["/**\n * Redis storage adapters built on the [`redis`](https://github.com/redis/node-redis)\n * package (node-redis v4/v5), an optional peer dependency. You can either pass a\n * pre-connected `client` or a `url` to connect lazily on first use. An optional\n * `prefix` is prepended (with a `:` separator) to every key so multiple\n * deployments can share a Redis instance without collisions; the prefix is\n * stripped from keys returned by {@link RedisPermissionsStorage.getKeys}.\n *\n * Two variants over the same plumbing, differing only in the value encoding:\n *\n * - {@link createRedisStorage} — values are plain **strings** containing JSON\n * (`SET`/`GET`). Works on any Redis; the default choice.\n * - {@link createRedisJSONStorage} — values are native **RedisJSON** documents\n * (`JSON.SET`/`JSON.GET`), so the stored data is queryable with JSONPath and\n * indexable with RediSearch. Requires the JSON module (Redis 8 / Redis Stack).\n * Do NOT point both variants at the same keys — the types are incompatible\n * (`WRONGTYPE`).\n *\n * `getKeys` uses a non-blocking `SCAN` cursor (never the blocking `KEYS`\n * command) with the prefix glob-escaped, so `*`, `?`, `[` and `\\` in a prefix\n * match literally. `watch` is implemented with Redis keyspace notifications; it\n * requires the server to be configured with `notify-keyspace-events` covering\n * generic + string + expiry events (e.g. `KEA` — whose `A` class also covers the\n * module events that RedisJSON writes emit, e.g. `json.set`).\n *\n * ## Compare-and-swap\n *\n * Both variants implement `compareAndSwap` with a small Lua script: it decodes\n * the stored value and the expectation with `cjson`, compares them\n * structurally (object key order is irrelevant) and writes `next` only on a\n * match — one atomic server-side step, safe across any number of instances.\n * The engine uses it for insert-if-absent grant writes.\n *\n * The driver is `@xtandard/kit/storage/redis`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/redis\";\n\nexport type { RedisLike } from \"@xtandard/kit/storage/redis\";\n\n/** Options for {@link createRedisStorage} and {@link createRedisJSONStorage}. */\nexport type RedisStorageOptions = kit.RedisStorageOptions;\n\n/** A watchable, compare-and-swap capable storage backed by Redis, plus `close()`. */\nexport type RedisPermissionsStorage = kit.RedisKvStorage;\n\nconst SUBPATH = \"@xtandard/permissions/storage/redis\";\n\n/**\n * Create a Redis storage that stores values as JSON **strings**. Works on any\n * Redis. Connection is lazy (first operation).\n *\n * @example\n * ```ts\n * import { createRedisStorage } from \"@xtandard/permissions/storage/redis\";\n *\n * const storage = createRedisStorage({ url: process.env.REDIS_URL, prefix: \"permissions\" });\n * ```\n */\nexport function createRedisStorage(options: RedisStorageOptions): RedisPermissionsStorage {\n return kit.createRedisStorage({ subpath: SUBPATH, ...options });\n}\n\n/**\n * Create a Redis storage that stores values as native **RedisJSON** documents.\n * Needs Redis 8+ or Redis Stack. Never point it at keys written by\n * {@link createRedisStorage}.\n */\nexport function createRedisJSONStorage(options: RedisStorageOptions): RedisPermissionsStorage {\n return kit.createRedisJSONStorage({ subpath: SUBPATH, ...options });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,UAAU;;;;;;;;;;;;AAahB,SAAgB,mBAAmB,SAAuD;CACxF,OAAOA,4BAAI,mBAAmB;EAAE,SAAS;EAAS,GAAG;CAAQ,CAAC;AAChE;;;;;;AAOA,SAAgB,uBAAuB,SAAuD;CAC5F,OAAOA,4BAAI,uBAAuB;EAAE,SAAS;EAAS,GAAG;CAAQ,CAAC;AACpE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/redis";
|
|
2
|
+
import { RedisLike } from "@xtandard/kit/storage/redis";
|
|
3
|
+
|
|
4
|
+
//#region src/storage/redis.d.ts
|
|
5
|
+
/** Options for {@link createRedisStorage} and {@link createRedisJSONStorage}. */
|
|
6
|
+
type RedisStorageOptions = kit.RedisStorageOptions;
|
|
7
|
+
/** A watchable, compare-and-swap capable storage backed by Redis, plus `close()`. */
|
|
8
|
+
type RedisPermissionsStorage = kit.RedisKvStorage;
|
|
9
|
+
/**
|
|
10
|
+
* Create a Redis storage that stores values as JSON **strings**. Works on any
|
|
11
|
+
* Redis. Connection is lazy (first operation).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createRedisStorage } from "@xtandard/permissions/storage/redis";
|
|
16
|
+
*
|
|
17
|
+
* const storage = createRedisStorage({ url: process.env.REDIS_URL, prefix: "permissions" });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function createRedisStorage(options: RedisStorageOptions): RedisPermissionsStorage;
|
|
21
|
+
/**
|
|
22
|
+
* Create a Redis storage that stores values as native **RedisJSON** documents.
|
|
23
|
+
* Needs Redis 8+ or Redis Stack. Never point it at keys written by
|
|
24
|
+
* {@link createRedisStorage}.
|
|
25
|
+
*/
|
|
26
|
+
declare function createRedisJSONStorage(options: RedisStorageOptions): RedisPermissionsStorage;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type RedisLike, type RedisPermissionsStorage, type RedisStorageOptions, createRedisJSONStorage, createRedisStorage };
|
|
29
|
+
//# sourceMappingURL=entry-storage-redis.d.cts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/redis";
|
|
2
|
+
import { RedisLike } from "@xtandard/kit/storage/redis";
|
|
3
|
+
|
|
4
|
+
//#region src/storage/redis.d.ts
|
|
5
|
+
/** Options for {@link createRedisStorage} and {@link createRedisJSONStorage}. */
|
|
6
|
+
type RedisStorageOptions = kit.RedisStorageOptions;
|
|
7
|
+
/** A watchable, compare-and-swap capable storage backed by Redis, plus `close()`. */
|
|
8
|
+
type RedisPermissionsStorage = kit.RedisKvStorage;
|
|
9
|
+
/**
|
|
10
|
+
* Create a Redis storage that stores values as JSON **strings**. Works on any
|
|
11
|
+
* Redis. Connection is lazy (first operation).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createRedisStorage } from "@xtandard/permissions/storage/redis";
|
|
16
|
+
*
|
|
17
|
+
* const storage = createRedisStorage({ url: process.env.REDIS_URL, prefix: "permissions" });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function createRedisStorage(options: RedisStorageOptions): RedisPermissionsStorage;
|
|
21
|
+
/**
|
|
22
|
+
* Create a Redis storage that stores values as native **RedisJSON** documents.
|
|
23
|
+
* Needs Redis 8+ or Redis Stack. Never point it at keys written by
|
|
24
|
+
* {@link createRedisStorage}.
|
|
25
|
+
*/
|
|
26
|
+
declare function createRedisJSONStorage(options: RedisStorageOptions): RedisPermissionsStorage;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type RedisLike, type RedisPermissionsStorage, type RedisStorageOptions, createRedisJSONStorage, createRedisStorage };
|
|
29
|
+
//# sourceMappingURL=entry-storage-redis.d.mts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/redis";
|
|
2
|
+
//#region src/storage/redis.ts
|
|
3
|
+
/**
|
|
4
|
+
* Redis storage adapters built on the [`redis`](https://github.com/redis/node-redis)
|
|
5
|
+
* package (node-redis v4/v5), an optional peer dependency. You can either pass a
|
|
6
|
+
* pre-connected `client` or a `url` to connect lazily on first use. An optional
|
|
7
|
+
* `prefix` is prepended (with a `:` separator) to every key so multiple
|
|
8
|
+
* deployments can share a Redis instance without collisions; the prefix is
|
|
9
|
+
* stripped from keys returned by {@link RedisPermissionsStorage.getKeys}.
|
|
10
|
+
*
|
|
11
|
+
* Two variants over the same plumbing, differing only in the value encoding:
|
|
12
|
+
*
|
|
13
|
+
* - {@link createRedisStorage} — values are plain **strings** containing JSON
|
|
14
|
+
* (`SET`/`GET`). Works on any Redis; the default choice.
|
|
15
|
+
* - {@link createRedisJSONStorage} — values are native **RedisJSON** documents
|
|
16
|
+
* (`JSON.SET`/`JSON.GET`), so the stored data is queryable with JSONPath and
|
|
17
|
+
* indexable with RediSearch. Requires the JSON module (Redis 8 / Redis Stack).
|
|
18
|
+
* Do NOT point both variants at the same keys — the types are incompatible
|
|
19
|
+
* (`WRONGTYPE`).
|
|
20
|
+
*
|
|
21
|
+
* `getKeys` uses a non-blocking `SCAN` cursor (never the blocking `KEYS`
|
|
22
|
+
* command) with the prefix glob-escaped, so `*`, `?`, `[` and `\` in a prefix
|
|
23
|
+
* match literally. `watch` is implemented with Redis keyspace notifications; it
|
|
24
|
+
* requires the server to be configured with `notify-keyspace-events` covering
|
|
25
|
+
* generic + string + expiry events (e.g. `KEA` — whose `A` class also covers the
|
|
26
|
+
* module events that RedisJSON writes emit, e.g. `json.set`).
|
|
27
|
+
*
|
|
28
|
+
* ## Compare-and-swap
|
|
29
|
+
*
|
|
30
|
+
* Both variants implement `compareAndSwap` with a small Lua script: it decodes
|
|
31
|
+
* the stored value and the expectation with `cjson`, compares them
|
|
32
|
+
* structurally (object key order is irrelevant) and writes `next` only on a
|
|
33
|
+
* match — one atomic server-side step, safe across any number of instances.
|
|
34
|
+
* The engine uses it for insert-if-absent grant writes.
|
|
35
|
+
*
|
|
36
|
+
* The driver is `@xtandard/kit/storage/redis`.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
const SUBPATH = "@xtandard/permissions/storage/redis";
|
|
41
|
+
/**
|
|
42
|
+
* Create a Redis storage that stores values as JSON **strings**. Works on any
|
|
43
|
+
* Redis. Connection is lazy (first operation).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { createRedisStorage } from "@xtandard/permissions/storage/redis";
|
|
48
|
+
*
|
|
49
|
+
* const storage = createRedisStorage({ url: process.env.REDIS_URL, prefix: "permissions" });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function createRedisStorage(options) {
|
|
53
|
+
return kit.createRedisStorage({
|
|
54
|
+
subpath: SUBPATH,
|
|
55
|
+
...options
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a Redis storage that stores values as native **RedisJSON** documents.
|
|
60
|
+
* Needs Redis 8+ or Redis Stack. Never point it at keys written by
|
|
61
|
+
* {@link createRedisStorage}.
|
|
62
|
+
*/
|
|
63
|
+
function createRedisJSONStorage(options) {
|
|
64
|
+
return kit.createRedisJSONStorage({
|
|
65
|
+
subpath: SUBPATH,
|
|
66
|
+
...options
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createRedisJSONStorage, createRedisStorage };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=entry-storage-redis.mjs.map
|