@lunora/server 1.0.0-alpha.7 → 1.0.0-alpha.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE.md +219 -0
  2. package/README.md +46 -0
  3. package/dist/data-model.d.mts +260 -164
  4. package/dist/data-model.d.ts +260 -164
  5. package/dist/data-model.mjs +0 -1
  6. package/dist/drizzle.mjs +1 -1
  7. package/dist/index.d.mts +1837 -1163
  8. package/dist/index.d.ts +1837 -1163
  9. package/dist/index.mjs +1 -28
  10. package/dist/otel.d.mts +543 -0
  11. package/dist/otel.d.ts +543 -0
  12. package/dist/otel.mjs +1 -0
  13. package/dist/packem_shared/DEFAULT_LIMIT-yHJ5O96W.mjs +1 -0
  14. package/dist/packem_shared/LunoraEnvError-CgpI2Mm_.mjs +3 -0
  15. package/dist/packem_shared/LunoraError-LVhdU0Lo.mjs +1 -0
  16. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-C24x2Cox.mjs +1 -0
  17. package/dist/packem_shared/allowAll-BnyNbJZT.mjs +1 -0
  18. package/dist/packem_shared/asBucketStorage-BthCnWop.mjs +1 -0
  19. package/dist/packem_shared/bindOrm-Bp9hsM2q.mjs +1 -0
  20. package/dist/packem_shared/buildMaskRegistry-BCIzKxdK.mjs +1 -0
  21. package/dist/packem_shared/buildRlsReadRegistry-CE5k6akj.mjs +1 -0
  22. package/dist/packem_shared/composePluginMiddleware-ByhCqIGt.mjs +1 -0
  23. package/dist/packem_shared/context-identity-GunnA6La.mjs +1 -0
  24. package/dist/packem_shared/createPolicyDsl-sV1swpkD.mjs +1 -0
  25. package/dist/packem_shared/createSecrets-CgVPiW2C.mjs +1 -0
  26. package/dist/packem_shared/defineAggregateIndex-BoiwhUKL.mjs +1 -0
  27. package/dist/packem_shared/defineIdentity-B7gfAgxx.mjs +1 -0
  28. package/dist/packem_shared/defineMigration-Bfpwxv2f.mjs +1 -0
  29. package/dist/packem_shared/defineMutator-BgpQ-xUo.mjs +1 -0
  30. package/dist/packem_shared/defineShape-Ds8uNqzX.mjs +1 -0
  31. package/dist/packem_shared/defineStorageRule-BDu01PUn.mjs +1 -0
  32. package/dist/packem_shared/functions-CDC08CWY.mjs +1 -0
  33. package/dist/packem_shared/httpAction-BpEJYwzV.mjs +5 -0
  34. package/dist/packem_shared/initLunora-BilEHyNs.mjs +1 -0
  35. package/dist/packem_shared/mask-CD7SWEvR.mjs +1 -0
  36. package/dist/packem_shared/middleware-D9_39C5C.mjs +1 -0
  37. package/dist/packem_shared/onConnect-CEtRmUpJ.mjs +1 -0
  38. package/dist/packem_shared/plugin-184MITA3.mjs +1 -0
  39. package/dist/packem_shared/policy-tag-Dprt9JWo.mjs +1 -0
  40. package/dist/packem_shared/protectPublic-BhKewPqm.mjs +1 -0
  41. package/dist/packem_shared/rls-CI2149Ve.mjs +1 -0
  42. package/dist/packem_shared/run-middleware-BeEEqmdE.mjs +1 -0
  43. package/dist/packem_shared/storageRules-6_G8JpCv.mjs +1 -0
  44. package/dist/packem_shared/types.d-B-pIn8rE.d.mts +141 -0
  45. package/dist/packem_shared/types.d-CdPDEjhz.d.ts +141 -0
  46. package/dist/rls/testing.d.mts +31 -31
  47. package/dist/rls/testing.d.ts +31 -31
  48. package/dist/rls/testing.mjs +1 -49
  49. package/dist/types.d.mts +1478 -479
  50. package/dist/types.d.ts +1478 -479
  51. package/dist/types.mjs +1 -31
  52. package/package.json +17 -4
  53. package/dist/packem_shared/LunoraEnvError-DjFkpkSP.mjs +0 -187
  54. package/dist/packem_shared/LunoraError-DhggBJZF.mjs +0 -51
  55. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-DH9zLyXa.mjs +0 -114
  56. package/dist/packem_shared/asBucketStorage-Cnxd9y2q.mjs +0 -11
  57. package/dist/packem_shared/bindOrm-Ce57S3N9.mjs +0 -128
  58. package/dist/packem_shared/buildRlsReadRegistry-CkxuS69B.mjs +0 -107
  59. package/dist/packem_shared/composePluginMiddleware-Ck5_TUO8.mjs +0 -100
  60. package/dist/packem_shared/createPolicyDsl-De67zPDS.mjs +0 -29
  61. package/dist/packem_shared/createSecrets-TsIP9lOa.mjs +0 -55
  62. package/dist/packem_shared/defineAggregateIndex-C2gT1GzM.mjs +0 -252
  63. package/dist/packem_shared/defineMigration-CAJLr6fx.mjs +0 -8
  64. package/dist/packem_shared/defineMutator-EIXAWhs9.mjs +0 -11
  65. package/dist/packem_shared/defineShape-CJ27Wx7o.mjs +0 -17
  66. package/dist/packem_shared/defineStorageRule-qu0mpilX.mjs +0 -20
  67. package/dist/packem_shared/functions-Di9FUNkf.mjs +0 -5
  68. package/dist/packem_shared/httpAction-B7FYUEgr.mjs +0 -340
  69. package/dist/packem_shared/initLunora-lxwHTEV3.mjs +0 -100
  70. package/dist/packem_shared/mask-eCUYOwhd.mjs +0 -211
  71. package/dist/packem_shared/onConnect-CIPXKPyw.mjs +0 -13
  72. package/dist/packem_shared/policy-tag-DvpVH2tv.mjs +0 -13
  73. package/dist/packem_shared/protectPublic-BjFkQ_Or.mjs +0 -15
  74. package/dist/packem_shared/rls-ClmjkkxZ.mjs +0 -569
  75. package/dist/packem_shared/run-middleware-CYQOuoV6.mjs +0 -18
  76. package/dist/packem_shared/storageRules-4a30FSpI.mjs +0 -88
  77. package/dist/packem_shared/types.d-BDY0FYHK.d.ts +0 -135
  78. package/dist/packem_shared/types.d-DmvyEMD6.d.mts +0 -135
@@ -1,49 +1 @@
1
- import { indexRolePermissions, computeReadBaseWhere, matchesWhere, evaluateWrite, permissionName } from '../packem_shared/rls-ClmjkkxZ.mjs';
2
-
3
- const expectPolicy = (policies, options = {}) => {
4
- const rolePermissions = indexRolePermissions(options.roles);
5
- const context = options.ctx ?? {};
6
- return {
7
- as: (identity) => {
8
- const auth = identity ?? {};
9
- const roles = auth.roles ?? [];
10
- const granted = /* @__PURE__ */ new Set();
11
- for (const roleName of roles) {
12
- for (const name of rolePermissions.get(roleName) ?? []) {
13
- granted.add(name);
14
- }
15
- }
16
- const baseContext = {
17
- auth: {
18
- can: (permission) => granted.has(permissionName(permission)),
19
- // eslint-disable-next-line unicorn/no-null -- PolicyContext.auth.identity is a public `… | null` type, mirroring the middleware
20
- identity: auth.identity ?? null,
21
- roles,
22
- // eslint-disable-next-line unicorn/no-null -- PolicyContext.auth.userId is a public `null | string` type, mirroring the middleware
23
- userId: auth.userId ?? null
24
- },
25
- ctx: context
26
- };
27
- const can = (op, table, row, nextRow) => {
28
- const tablePolicies = policies.filter((policy) => policy.table === table);
29
- if (tablePolicies.length === 0) {
30
- return true;
31
- }
32
- if (op === "read") {
33
- if (!tablePolicies.some((policy) => policy.on === "read")) {
34
- return true;
35
- }
36
- const baseWhere = computeReadBaseWhere(tablePolicies, baseContext);
37
- return baseWhere === void 0 || matchesWhere(row ?? {}, baseWhere);
38
- }
39
- return evaluateWrite(tablePolicies, op, { ...baseContext, row }, nextRow);
40
- };
41
- return {
42
- can,
43
- cannot: (op, table, row, nextRow) => !can(op, table, row, nextRow)
44
- };
45
- }
46
- };
47
- };
48
-
49
- export { expectPolicy };
1
+ import{T as p,F as I,E as h,P,I as b}from"../packem_shared/middleware-D9_39C5C.mjs";const v=(d,s={})=>{const f=p(s.roles),x=s.ctx??{};return{as:y=>{const o=y??{},c=o.roles??[],i={auth:{can:I(c,f),identity:o.identity??null,roles:c,userId:o.userId??null},ctx:x},a=(t,u,r,l)=>{const e=d.filter(n=>n.table===u);if(e.length===0)return!0;if(t==="read"){if(!e.some(m=>m.on==="read"))return!0;const n=h(e,i);return n===void 0||P(r??{},n)}return b(e,t,{...i,row:r},l)};return{can:a,cannot:(t,u,r,l)=>!a(t,u,r,l)}}}};export{v as expectPolicy};