permdock 0.3.0 → 0.4.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/dist/a2a/index.d.ts +7 -5
- package/dist/a2a/index.js +14 -21
- package/dist/ai-sdk/index.d.ts +18 -6
- package/dist/ai-sdk/index.js +8 -5
- package/dist/app-data-CV8pqqMi.js +59 -0
- package/dist/approvals/index.d.ts +2 -2
- package/dist/approvals/index.js +3 -3
- package/dist/{approvals-DbYAuNkG.js → approvals-DZL76lKW.js} +35 -19
- package/dist/{approvers-DT4AVyIg.js → approvers-CqPOLD-o.js} +1 -1
- package/dist/{arazzo-BAgw9ap6.js → arazzo-C4BcskbX.js} +6 -5
- package/dist/{arazzo-CKwwqFWz.js → arazzo-CD8d0WLb.js} +2 -2
- package/dist/authzen/index.d.ts +3 -3
- package/dist/authzen/index.js +161 -23
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/better-auth/index.js +6 -19
- package/dist/better-supabase/index.d.ts +112 -87
- package/dist/better-supabase/index.js +257 -156
- package/dist/{bind-C_ob3LKa.d.ts → bind-BzqG8SMb.d.ts} +16 -5
- package/dist/{bind-CuzGytRf.js → bind-kk-uyCwH.js} +14 -6
- package/dist/build-instance-DIIV9DbC.js +51 -0
- package/dist/{canonical-json-DemiK4Vp.js → canonical-json-CFKyFOke.js} +1 -3
- package/dist/{capability-2kYTMWDv.d.ts → capability-CksyCWDH.d.ts} +2 -2
- package/dist/{capability-4qPdO9gk.js → capability-txATtKV4.js} +3 -2
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog-6yWAX6Ps.js +2 -0
- package/dist/{catalog-dFZdWCGN.js → catalog-WHG4kBq7.js} +2 -2
- package/dist/{catalog-doc-DdGm82XT.js → catalog-doc-DWtg0gGR.js} +17 -10
- package/dist/{catalog-DWF5cYqB.js → catalog-tZUyOfOv.js} +4 -4
- package/dist/claude-agent/index.d.ts +4 -4
- package/dist/claude-agent/index.js +4 -5
- package/dist/clerk/index.d.ts +3 -3
- package/dist/clerk/index.js +8 -33
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +3 -3
- package/dist/cloud/index.d.ts +4 -4
- package/dist/cloud/index.js +9 -15
- package/dist/{cloud-CB_ELYuX.js → cloud-C7bSDgX4.js} +2 -2
- package/dist/{cloud-DWLXO2af.js → cloud-PeBN3IEn.js} +5 -5
- package/dist/{collect-DSTE3ml9.js → collect-2SrB7lfk.js} +6 -8
- package/dist/collect-Bw2Jdq1q.js +2 -0
- package/dist/{collect-DClJsheJ.js → collect-CQx4hX4N.js} +3 -3
- package/dist/{commands-DSxCqG9A.js → commands-Cpip4ULx.js} +13 -13
- package/dist/{compact-y6vfu2_f.js → compact-CAf557ZB.js} +11 -1
- package/dist/compile/index.d.ts +1 -1
- package/dist/compile/index.js +1 -1
- package/dist/{compile-Ba4blROR.js → compile-CcEu2ZQ1.js} +6 -5
- package/dist/{compile-BkRyBDBw.d.ts → compile-CtTP7eur.d.ts} +2 -2
- package/dist/{config-BJiM-xAm.js → config-BIjREpyE.js} +4 -4
- package/dist/{config-Dnszbv-6.js → config-DLt6BvV7.js} +2 -2
- package/dist/{config-report-DMvWKUxL.js → config-report--Xb9APJS.js} +5 -6
- package/dist/{connection-CU8MQxRi.js → connection-DUsczpB5.js} +3 -2
- package/dist/constants-DcJABbLW.js +20 -0
- package/dist/{context-Bcy85rGi.js → context-DieZVJXu.js} +16 -5
- package/dist/convex/index.d.ts +4 -4
- package/dist/convex/index.js +14 -16
- package/dist/create-BBO24vj6.js +324 -0
- package/dist/{credential-8P81ff4u.js → credential-kue0qpbm.js} +4 -4
- package/dist/deciding-columns-Sq12mEA6.js +123 -0
- package/dist/delegation-input-FTxMK3ji.js +19 -0
- package/dist/denied-text-DfRk15uw.d.ts +19 -0
- package/dist/{describe-DMYiCjJV.d.ts → describe-C3ldA9os.d.ts} +11 -2
- package/dist/{describe-B_gVZEVi.js → describe-Cgkp7eP0.js} +5 -4
- package/dist/{diff-DBIhz_f2.js → diff-Cnghh_Ip.js} +2 -2
- package/dist/{diff-2VaeChzX.js → diff-rpqoe7Ag.js} +9 -9
- package/dist/{doctor-BwCAMLx_.js → doctor-CuVJvhV_.js} +2 -2
- package/dist/doctor-owlv6ddh.js +2166 -0
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +6 -14
- package/dist/elysia/index.d.ts +4 -4
- package/dist/elysia/index.js +7 -7
- package/dist/{errors-DPdqI50v.d.ts → errors-OD_4c__H.d.ts} +2 -2
- package/dist/{errors-Cz5zn0mW.js → errors-drnfxYtm.js} +3 -3
- package/dist/{evaluations-tz6D9A2G.js → evaluations-C9YJsv3H.js} +45 -7
- package/dist/eve/index.d.ts +5 -5
- package/dist/eve/index.js +5 -5
- package/dist/express/index.d.ts +4 -4
- package/dist/express/index.js +8 -7
- package/dist/fastify/index.d.ts +15 -5
- package/dist/fastify/index.js +9 -29
- package/dist/fields-fwfXN01n.js +1016 -0
- package/dist/{files-DWUN9PzI.js → files-D_JIzUrP.js} +12 -3
- package/dist/{fixtures-ht28Cplr.js → fixtures-h2eG2OZV.js} +5 -6
- package/dist/{from-snapshot-CTLijvdm.js → from-snapshot-7REQZe0H.js} +32 -22
- package/dist/{generate-CH7ThJ14.js → generate-CNU1pIOo.js} +1 -3
- package/dist/grantee-CXY-0C87.js +254 -0
- package/dist/grantee-conditions-MQs5NIuX.js +270 -0
- package/dist/grantee-match-fxYp9Nmt.js +141 -0
- package/dist/{helpers-H_KARDVC.js → helpers-C9YmyBIa.js} +7 -6
- package/dist/hono/index.d.ts +4 -4
- package/dist/hono/index.js +8 -8
- package/dist/hosted-CBHgkzDl.js +655 -0
- package/dist/{http-SO7qGttf.js → http-BBoKefeS.js} +35 -2
- package/dist/{http-BIhmLfCc.js → http-BEbdMZ05.js} +2 -24
- package/dist/{rls-import-BTFVk3jH.js → import-BFIlhetD.js} +86 -80
- package/dist/{openapi-import-cmwetbzw.js → import-UHk1N7vH.js} +6 -7
- package/dist/{index-C8z4RjQV.d.ts → index-BwMe94Xq.d.ts} +1 -1
- package/dist/{index-0nNqHspG.d.ts → index-DgM7w96K.d.ts} +2 -2
- package/dist/{index-C7Tw7MaW.d.ts → index-Dz7didpC.d.ts} +3 -3
- package/dist/{index-BNc7Wer_.d.ts → index-UdVQgq48.d.ts} +105 -38
- package/dist/index.d.ts +15 -13
- package/dist/index.js +22 -22
- package/dist/{instance-options-jARdwfPN.d.ts → instance-options-plkrsAog.d.ts} +1 -1
- package/dist/{json-schema-BsAflUGW.js → json-schema-DBkdUuCO.js} +1 -3
- package/dist/jwt/index.d.ts +4 -4
- package/dist/jwt/index.js +13 -13
- package/dist/{kernel-_RRHmnMY.js → kernel-CB3LrIJM.js} +81 -32
- package/dist/kysely/index.d.ts +2 -2
- package/dist/kysely/index.js +6 -14
- package/dist/{live-options-H2eG8dfJ.js → live-options-BaAFCIiu.js} +16 -3
- package/dist/load-B_shHrmd.js +2 -0
- package/dist/{load-DhWEB9P1.js → load-C3_oTHyO.js} +11 -3
- package/dist/{manifest-iaoBXHKc.js → manifest-BngWKryL.js} +5 -18
- package/dist/{map-claims-Z4QZOiFF.js → map-claims-AVlBaJoa.js} +7 -16
- package/dist/{map-error-pgUWNNtG.js → map-error-BE27PYkE.js} +5 -5
- package/dist/{markers-B0hYLvMD.js → markers-CiwAOZtO.js} +6 -2
- package/dist/{may-use-DndQ5tQ-.js → may-use-BOn_dR_w.js} +4 -3
- package/dist/mcp/index.d.ts +26 -9
- package/dist/mcp/index.js +456 -446
- package/dist/{rls-migrate-CN4TlJTO.js → migrate-BwlB5-Wk.js} +75 -15
- package/dist/nest/index.d.ts +4 -4
- package/dist/nest/index.js +11 -12
- package/dist/next/index.d.ts +31 -8
- package/dist/next/index.js +29 -33
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +1 -1
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.js +4 -4
- package/dist/ocsf-uYFXGVw2.js +115 -0
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.js +4 -4
- package/dist/openapi/index.d.ts +3 -3
- package/dist/openapi/index.js +1 -1
- package/dist/{openapi-CqqEbHsL.js → openapi-BJdBmYDG.js} +19 -23
- package/dist/{openapi-BqRBvAng.js → openapi-DBzHQbov.js} +2 -5
- package/dist/{openapi-l0xYHkcv.js → openapi-DcQ1Kg40.js} +3 -3
- package/dist/orpc/index.d.ts +5 -5
- package/dist/orpc/index.js +9 -11
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +26 -23
- package/dist/output-files-CgIsvdSa.js +140 -0
- package/dist/{rls-ownership-RuFqaqGz.js → ownership-BgnbOJFT.js} +387 -379
- package/dist/{package-root-zGkxO3oN.js → package-root-DtNnpmUd.js} +3 -2
- package/dist/{parse-BuyjxhZV.js → parse-CVFQHk6c.js} +3 -3
- package/dist/{parse-local-manifest-BrMozJCo.js → parse-local-manifest-C-q02Pal.js} +2 -4
- package/dist/{parse-local-manifest-JLnaBH0S.d.ts → parse-local-manifest-DvYUR0QL.d.ts} +1 -1
- package/dist/pdp/index.d.ts +2 -2
- package/dist/pdp/index.js +8 -9
- package/dist/{permdock-CbgvLnuo.js → permdock-L26udHSk.js} +1387 -1220
- package/dist/{rls-fields-74oZPXWL.js → permission-keys-B26jeyUv.js} +1289 -2066
- package/dist/permission-registry-BsblpB-z.js +385 -0
- package/dist/{permissions-DttnqqxC.d.ts → permission-types-Dg39z9Kv.d.ts} +59 -31
- package/dist/{permissions-RJrovw98.js → permissions-CCJ6lmxB.js} +3 -3
- package/dist/{permissions-CDgvKG5L.d.ts → permissions-COH-KRgT.d.ts} +2 -2
- package/dist/{policy-IB6yxpC3.d.ts → policy-types-sp9P1iIV.d.ts} +661 -582
- package/dist/{policy-D2W7uv19.d.ts → policy-ur0BBK_e.d.ts} +2 -2
- package/dist/{powersync-DliZK_-y.js → powersync-BFSbSElQ.js} +2 -2
- package/dist/powersync-DCDgZgfZ.js +2 -0
- package/dist/{powersync-BylawD_U.js → powersync-cZe4kzhL.js} +26 -27
- package/dist/prisma/index.d.ts +1 -1
- package/dist/prisma/index.js +6 -12
- package/dist/{problem-B43ztKIm.js → problem-CnWraVhC.js} +8 -7
- package/dist/{problem-details-_AMOYz-w.js → problem-details-DECUnXAn.js} +2 -2
- package/dist/{problem-details-DX075l9V.d.ts → problem-details-rIIo8B2C.d.ts} +1 -1
- package/dist/{protected-BdnIEFkY.d.ts → protected-B3_P7xuw.d.ts} +9 -6
- package/dist/{protected-utU-SLuy.js → protected-BN7BUdY1.js} +20 -8
- package/dist/{provider-CSQd7m92.js → provider-Bi-0HNL3.js} +23 -10
- package/dist/{provider-DZY281jO.d.ts → provider-kwHC9CZD.d.ts} +1 -1
- package/dist/{provider-store-Cfbvo4DE.js → provider-store-Ctt-81Ni.js} +6 -3
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +5 -5
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +20 -11
- package/dist/react-native/index.js +33 -17
- package/dist/{refs-KYb4ntaz.js → refs-f3imMjNW.js} +1 -1
- package/dist/relation-walk-BXnlLtg2.js +186 -0
- package/dist/relations-CvmSpG67.js +163 -0
- package/dist/{replay-CYyiLiwO.d.ts → replay-COpmZUfx.d.ts} +1 -1
- package/dist/request-context-BVM7aWNs.js +71 -0
- package/dist/request-context-C2_1lchh.d.ts +5 -0
- package/dist/resource-relations-D1Un3pcz.js +243 -0
- package/dist/retire-BFcxL6un.js +240 -0
- package/dist/{rls-B4ur8nKQ.js → rls-55DQTuf5.js} +14 -2
- package/dist/{rls-DQtdgTHB.js → rls-BEktUaqg.js} +884 -484
- package/dist/{policy-xyWg7QdR.js → role-builder-B4GbKM-i.js} +235 -541
- package/dist/{rpc-DL9Sqvb1.js → rpc-nYC3cR_u.js} +15 -5
- package/dist/{run-DKDbM4Du.js → run-DMcNW_8T.js} +3 -3
- package/dist/{runtime-CB8gQFvS.js → runtime-D_tMXnsq.js} +1 -1
- package/dist/{saas-DhpJjnBA.js → saas-DtaA4JuW.js} +9 -8
- package/dist/{openapi-schema--ARjyfQr.js → schema-Bol6gqXA.js} +3 -5
- package/dist/{schema-D3MnDMxa.js → schema-DjQBcAP9.js} +4 -2
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scim-BFGBBAqR.js → scim-vFR1O5oG.js} +6 -12
- package/dist/{scopes-CVdPrWN-.js → scopes-tvpa34ep.js} +10 -2
- package/dist/server/index.d.ts +18 -8
- package/dist/server/index.js +8 -8
- package/dist/{server-DlZ28Oz5.js → server-ZYEHtNHS.js} +4 -4
- package/dist/{create-B1d519XK.d.ts → server-types-DdqBwZN_.d.ts} +69 -33
- package/dist/shared-1uhI-e-b.js +294 -0
- package/dist/{shared-DRu8VFVM.js → shared-JhMeOsDF.js} +1 -1
- package/dist/{sink-Bd9PSyfq.js → sink-BTtmfPnE.js} +1 -1
- package/dist/{sink-B1fZzIMf.d.ts → sink-CPN4zLfs.d.ts} +1 -1
- package/dist/{skills-Biq5uup3.js → skills-BZdRQkxs.js} +4 -3
- package/dist/{skills-Bx-U0irG.js → skills-Dle4ZoLF.js} +2 -2
- package/dist/{snapshot-Enxd0n-s.js → snapshot-Dc9CHPME.js} +116 -13
- package/dist/{snapshot-cache-D6jLelln.js → snapshot-cache-Cod40D-X.js} +1 -1
- package/dist/{snapshot-cache-B-LxUahj.d.ts → snapshot-cache-J5T7t_vD.d.ts} +1 -1
- package/dist/solid/index.d.ts +22 -22
- package/dist/solid/index.js +40 -10
- package/dist/{sources-4p0-4xQm.js → sources-B1-b-R0t.js} +25 -26
- package/dist/{sources-BdOYLw9j.d.ts → sources-Dljy06zL.d.ts} +6 -2
- package/dist/{sql-xdg5f4Fi.js → sql-t8teWOfo.js} +19 -3
- package/dist/{src-BDwEZWrZ.js → src-Bb7no-hS.js} +194 -123
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +58 -61
- package/dist/store-9KO4BlkB.d.ts +147 -0
- package/dist/{store-DMAWwAJV.js → store-ILkLUj_o.js} +4 -4
- package/dist/{store-options-ByhZq1jV.js → store-options-CbUHDoSe.js} +16 -7
- package/dist/{stores-BT2pSCub.js → stores-BHXdSbw9.js} +7 -3
- package/dist/stores-Cxz_80g-.d.ts +31 -0
- package/dist/{stream-DDpvynSB.js → stream-BMui98KK.js} +2 -1
- package/dist/{stream-D1RXubw2.d.ts → stream-Dwsg6WwE.d.ts} +2 -2
- package/dist/{subject-settings-BwBmCdTR.js → subject-settings-CkEwrw3W.js} +23 -5
- package/dist/supabase/index.d.ts +4 -4
- package/dist/supabase/index.js +3 -3
- package/dist/supabase/middleware.d.ts +11 -5
- package/dist/supabase/middleware.js +10 -7
- package/dist/{supabase-C0qESOa-.js → supabase-C1TWlnYt.js} +36 -52
- package/dist/{supabase-Boqb9a_Y.js → supabase-Dbqr141s.js} +2 -2
- package/dist/supabase-hook-BULg7Ut_.js +2 -0
- package/dist/{supabase-hook-CSLQ4zJ3.js → supabase-hook-Cva3ikXz.js} +731 -782
- package/dist/{supautils-Cn4R4cJ4.js → supautils-B6HYL9eL.js} +2 -2
- package/dist/svelte/Protected.svelte +9 -2
- package/dist/svelte/index.d.ts +6 -6
- package/dist/svelte/index.js +25 -11
- package/dist/svelte/runtime.d.ts +10 -3
- package/dist/svelte/runtime.js +4 -3
- package/dist/svelte/source.d.ts +6 -6
- package/dist/svelte/source.js +4 -4
- package/dist/{validity-uOp8UpYn.js → tenancy-DshjqY0n.js} +3 -39
- package/dist/terminal/index.d.ts +5 -5
- package/dist/terminal/index.js +18 -34
- package/dist/testing/index.d.ts +89 -77
- package/dist/testing/index.js +1276 -1262
- package/dist/testing/saas/index.d.ts +4 -4
- package/dist/testing/saas/index.js +2 -2
- package/dist/testing/saas/permissions.d.ts +1 -1
- package/dist/testing/saas/permissions.js +1 -1
- package/dist/thenable-QSmvt-vZ.js +65 -0
- package/dist/{token-CIWxJOCh.js → token-Bx9qy30p.js} +1 -1
- package/dist/tool-refusal-CQ7OEia9.js +41 -0
- package/dist/trpc/index.d.ts +5 -5
- package/dist/trpc/index.js +7 -8
- package/dist/{types-DbjRN55U.d.ts → types-7rJVLWe5.d.ts} +82 -4
- package/dist/{types-aqOHTHcp.d.ts → types-Br9IXUBG.d.ts} +1 -1
- package/dist/types-ByUo56un.d.ts +88 -0
- package/dist/{types-Cq_H8N_X.d.ts → types-C0dee0Qf.d.ts} +2 -2
- package/dist/{types-DxiCGmmd.d.ts → types-CIlTojhq.d.ts} +2 -2
- package/dist/{types-QCuYJh4q.d.ts → types-CUcFZfpU.d.ts} +1 -1
- package/dist/{types-C97IskBw.d.ts → types-CqrjB9o6.d.ts} +1 -1
- package/dist/{types-BnIEz1sU.d.ts → types-DHrmBJLH.d.ts} +24 -6
- package/dist/{types-Dnemwd77.d.ts → types-DpWfQdSh.d.ts} +5 -1
- package/dist/{types-Bvc4oWT6.d.ts → types-DvupZE0w.d.ts} +1 -1
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +1 -1
- package/dist/{usage-GTixvDDU.js → usage-4G6t643F.js} +2 -2
- package/dist/{usage-ItS7nLcl.js → usage-CG9nOYZw.js} +7 -7
- package/dist/usage-iFLJ0-rr.js +2 -0
- package/dist/{validation-error-Ba264OaJ.d.ts → validation-error-BSSw0l_8.d.ts} +1 -1
- package/dist/{validation-error-CnjZ4t92.js → validation-error-ZfUHbKvf.js} +1 -1
- package/dist/validity-dVrUEPJt.js +62 -0
- package/dist/{verifier-BxBo6I44.js → verifier-DMr_Zmb_.js} +51 -15
- package/dist/{rls-verify-CVQTHTh5.js → verify-BztUB3GX.js} +668 -239
- package/dist/{version-BvacVTZR.js → version-BEogC-rB.js} +1 -1
- package/dist/{views-Soe7bGSC.js → views-CJsrBS1f.js} +23 -1
- package/dist/{vocabulary-DA8a8zif.d.ts → vocabulary-hhEFLFoL.d.ts} +15 -6
- package/dist/vue/index.d.ts +24 -19
- package/dist/vue/index.js +24 -8
- package/dist/watch-C8TpsAl4.js +2 -0
- package/dist/{watch-DVBJ9cBq.js → watch-zeucB7eF.js} +6 -6
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +13 -37
- package/dist/wrap-Cr93qqdP.d.ts +14 -0
- package/dist/wrap-DWsU_5Bd.js +26 -0
- package/package.json +8 -8
- package/schemas/catalog-v1.json +6 -0
- package/skills/permdock-credentials/SKILL.md +1 -1
- package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
- package/skills/permdock-data/references/queries-and-rls.md +4 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -0
- package/skills/permdock-wire/SKILL.md +2 -2
- package/skills/permdock-wire/references/adapters.md +9 -1
- package/skills/permdock-wire/references/policy-options.md +10 -1
- package/dist/catalog-CRW5Mx_B.js +0 -2
- package/dist/collect-DSWOk19R.js +0 -2
- package/dist/create-CMwIl-w2.js +0 -253
- package/dist/delegation-D8pUEuce.js +0 -103
- package/dist/doctor-collect-CHk6XWOA.js +0 -665
- package/dist/doctor-igIiM_Hl.js +0 -1194
- package/dist/evaluation-items-CfCCejQd.js +0 -40
- package/dist/fields-BMl1RxoX.js +0 -26
- package/dist/grantee-Cv5Sogfv.js +0 -602
- package/dist/hosted-DJQw46hn.js +0 -266
- package/dist/instance-options-Dhhcnm3y.js +0 -22
- package/dist/load-DwJUafYN.js +0 -2
- package/dist/map-AcxK9o_D.js +0 -147
- package/dist/permissions-DVoF6dMt.js +0 -662
- package/dist/powersync-e_AZrKbg.js +0 -2
- package/dist/protected-xAr24FEC.d.ts +0 -40
- package/dist/relations-cjOL01hZ.js +0 -505
- package/dist/rls-graph-CHwx0V8q.js +0 -435
- package/dist/rls-shared-Cewd_-zI.js +0 -495
- package/dist/store-jOBYpiXC.d.ts +0 -36
- package/dist/stores-C0IMQrGI.d.ts +0 -52
- package/dist/supabase-config-BpPXt3x1.js +0 -472
- package/dist/supabase-hook-6sYLXg_u.js +0 -2
- package/dist/thenable-okc2xDsj.js +0 -10
- package/dist/types-CKNSyIf_.d.ts +0 -52
- package/dist/usage-DorAJiU_.js +0 -2
- package/dist/watch-BwxLTYMZ.js +0 -2
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Yn as Decision, er as GrantedDecision, ln as PermDock } from "./policy-IB6yxpC3.js";
|
|
2
|
-
import { f as Permission } from "./permissions-DttnqqxC.js";
|
|
3
|
-
import { t as PermissionBoundaryState } from "./boundary-BmHxVH1J.js";
|
|
4
|
-
import { s as PermissionState } from "./types-CKNSyIf_.js";
|
|
5
|
-
import { t as ClientStore } from "./store-jOBYpiXC.js";
|
|
6
|
-
import { Snippet } from "svelte";
|
|
7
|
-
//#region src/svelte/boundary.d.ts
|
|
8
|
-
type PermissionBoundaryProps = {
|
|
9
|
-
readonly children?: Snippet;
|
|
10
|
-
/** Rendered in place of the children when one throws `PermDockDeniedError`. */
|
|
11
|
-
readonly denied?: Snippet<[PermissionBoundaryState]>;
|
|
12
|
-
/** Rendered for `PermDockApprovalRequiredError`; defaults to `denied`. */
|
|
13
|
-
readonly approval?: Snippet<[PermissionBoundaryState]>;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/client/views.d.ts
|
|
17
|
-
/** What `Protected` renders: `pending` while an endpoint answer is in flight, `fallback` unless granted. */
|
|
18
|
-
type ProtectedView = (PermissionState & {
|
|
19
|
-
readonly slot: "pending" | "fallback";
|
|
20
|
-
}) | {
|
|
21
|
-
readonly allowed: true;
|
|
22
|
-
readonly status: PermissionState["status"];
|
|
23
|
-
readonly decision: GrantedDecision;
|
|
24
|
-
readonly slot: "default";
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/svelte/protected.d.ts
|
|
28
|
-
type ProtectedProps = {
|
|
29
|
-
readonly permission: Permission;
|
|
30
|
-
readonly data?: unknown;
|
|
31
|
-
readonly tenant?: string;
|
|
32
|
-
readonly children?: Snippet<[Decision]>;
|
|
33
|
-
readonly pending?: Snippet;
|
|
34
|
-
readonly fallback?: Snippet<[Decision]>;
|
|
35
|
-
};
|
|
36
|
-
/** The instance for `tenant`, built once per store change rather than once per check. */
|
|
37
|
-
declare function scopedFor(store: ClientStore, tenant: string | undefined, _generation?: number): PermDock | undefined;
|
|
38
|
-
declare function viewFor(store: ClientStore, reference: Permission, data: unknown, scoped: PermDock | undefined, _generation?: number): ProtectedView;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { PermissionBoundaryProps as i, scopedFor as n, viewFor as r, ProtectedProps as t };
|
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
import { C as restrictedStops, E as ownGet, d as isEdgeRelation, l as groupEntries, m as isPrincipalRelation, r as expandRelation, s as getRegistry, u as isComputedRelation } from "./permissions-DVoF6dMt.js";
|
|
2
|
-
import { t as idText } from "./ids-DC4V4CFu.js";
|
|
3
|
-
import { n as isThenable } from "./thenable-okc2xDsj.js";
|
|
4
|
-
function isRecord(value) {
|
|
5
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
-
}
|
|
7
|
-
function isInstant(value) {
|
|
8
|
-
return value === void 0 || typeof value === "number" && Number.isFinite(value);
|
|
9
|
-
}
|
|
10
|
-
function asChain(value) {
|
|
11
|
-
if (!isRecord(value) || !Array.isArray(value["ancestors"])) return;
|
|
12
|
-
const ancestors = [];
|
|
13
|
-
for (const item of value["ancestors"]) {
|
|
14
|
-
if (!isRecord(item) || typeof item["id"] !== "string" || item["id"] === "") return;
|
|
15
|
-
ancestors.push(item["restricted"] === true ? {
|
|
16
|
-
id: item["id"],
|
|
17
|
-
restricted: true
|
|
18
|
-
} : { id: item["id"] });
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
ancestors,
|
|
22
|
-
...value["restricted"] === true ? { restricted: true } : {},
|
|
23
|
-
...value["truncated"] === true ? { truncated: true } : {}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function asRow(value) {
|
|
27
|
-
if (value === null || value === void 0) return { row: null };
|
|
28
|
-
return isRecord(value) ? { row: value } : void 0;
|
|
29
|
-
}
|
|
30
|
-
function asGroup(value) {
|
|
31
|
-
if (!isRecord(value) || typeof value["resource"] !== "string" || typeof value["id"] !== "string" || typeof value["relation"] !== "string" || value["id"] === "") return;
|
|
32
|
-
return {
|
|
33
|
-
resource: value["resource"],
|
|
34
|
-
id: value["id"],
|
|
35
|
-
relation: value["relation"]
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function asHolders(value) {
|
|
39
|
-
if (!Array.isArray(value)) return;
|
|
40
|
-
const holders = [];
|
|
41
|
-
for (const item of value) {
|
|
42
|
-
if (!isRecord(item) || !isInstant(item["startsAt"]) || !isInstant(item["expiresAt"])) return;
|
|
43
|
-
const period = {
|
|
44
|
-
...item["startsAt"] === void 0 ? {} : { startsAt: item["startsAt"] },
|
|
45
|
-
...item["expiresAt"] === void 0 ? {} : { expiresAt: item["expiresAt"] }
|
|
46
|
-
};
|
|
47
|
-
if (isRecord(item["principal"]) && typeof item["principal"]["id"] === "string") {
|
|
48
|
-
holders.push({
|
|
49
|
-
principal: { id: item["principal"]["id"] },
|
|
50
|
-
...period
|
|
51
|
-
});
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const group = asGroup(item["group"]);
|
|
55
|
-
if (group === void 0) return;
|
|
56
|
-
holders.push({
|
|
57
|
-
group,
|
|
58
|
-
...period
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return holders;
|
|
62
|
-
}
|
|
63
|
-
function read(cache, key, call, validate) {
|
|
64
|
-
const entry = cache.get(key);
|
|
65
|
-
if (entry !== void 0) return entry.state === "ready" ? entry.value : entry.state;
|
|
66
|
-
if (call === void 0) return "failed";
|
|
67
|
-
const settle = (value) => {
|
|
68
|
-
const valid = validate(value);
|
|
69
|
-
cache.set(key, valid === void 0 ? { state: "failed" } : {
|
|
70
|
-
state: "ready",
|
|
71
|
-
value: valid
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
let result;
|
|
75
|
-
try {
|
|
76
|
-
result = call();
|
|
77
|
-
} catch {
|
|
78
|
-
cache.set(key, { state: "failed" });
|
|
79
|
-
return "failed";
|
|
80
|
-
}
|
|
81
|
-
if (isThenable(result)) {
|
|
82
|
-
const promise = Promise.resolve(result).then(settle, () => {
|
|
83
|
-
cache.set(key, { state: "failed" });
|
|
84
|
-
});
|
|
85
|
-
cache.set(key, {
|
|
86
|
-
state: "pending",
|
|
87
|
-
promise
|
|
88
|
-
});
|
|
89
|
-
return "pending";
|
|
90
|
-
}
|
|
91
|
-
settle(result);
|
|
92
|
-
const settled = cache.get(key);
|
|
93
|
-
return settled?.state === "ready" ? settled.value : "failed";
|
|
94
|
-
}
|
|
95
|
-
function relationReader(source, cache, resources) {
|
|
96
|
-
const concrete = (resource, id, relation) => read(cache, JSON.stringify([
|
|
97
|
-
"holders",
|
|
98
|
-
resource,
|
|
99
|
-
id,
|
|
100
|
-
relation
|
|
101
|
-
]), source === void 0 ? void 0 : () => source.related({
|
|
102
|
-
resource,
|
|
103
|
-
id,
|
|
104
|
-
relation
|
|
105
|
-
}), asHolders);
|
|
106
|
-
return {
|
|
107
|
-
available: source !== void 0,
|
|
108
|
-
row(query) {
|
|
109
|
-
const load = source?.row?.bind(source);
|
|
110
|
-
return read(cache, JSON.stringify([
|
|
111
|
-
"row",
|
|
112
|
-
query.resource,
|
|
113
|
-
query.id
|
|
114
|
-
]), load === void 0 ? void 0 : () => load({
|
|
115
|
-
resource: query.resource,
|
|
116
|
-
id: query.id
|
|
117
|
-
}), asRow);
|
|
118
|
-
},
|
|
119
|
-
chain(query) {
|
|
120
|
-
const through = query.through ?? "parent";
|
|
121
|
-
return read(cache, JSON.stringify([
|
|
122
|
-
"chain",
|
|
123
|
-
query.resource,
|
|
124
|
-
query.id,
|
|
125
|
-
query.depth,
|
|
126
|
-
through
|
|
127
|
-
]), source === void 0 ? void 0 : () => source.ancestors({
|
|
128
|
-
resource: query.resource,
|
|
129
|
-
id: query.id,
|
|
130
|
-
depth: query.depth,
|
|
131
|
-
through
|
|
132
|
-
}), asChain);
|
|
133
|
-
},
|
|
134
|
-
holders(query) {
|
|
135
|
-
const node = resources?.get(query.resource);
|
|
136
|
-
const names = node === void 0 ? [query.relation] : expandRelation(node, query.relation);
|
|
137
|
-
const out = [];
|
|
138
|
-
let unread;
|
|
139
|
-
for (const name of names) {
|
|
140
|
-
const answer = concrete(query.resource, query.id, name);
|
|
141
|
-
if (answer === "pending" || answer === "failed") {
|
|
142
|
-
unread = answer === "failed" || unread === "failed" ? "failed" : "pending";
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
for (const holder of answer) out.push({
|
|
146
|
-
...holder,
|
|
147
|
-
relation: name
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return unread ?? out;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
/** The loads still in flight, for an instance that awaits them before deciding. */
|
|
155
|
-
function pendingRelations(cache) {
|
|
156
|
-
const out = [];
|
|
157
|
-
for (const entry of cache.values()) if (entry.state === "pending") out.push(entry.promise);
|
|
158
|
-
return out;
|
|
159
|
-
}
|
|
160
|
-
function relationId(value) {
|
|
161
|
-
return idText(value);
|
|
162
|
-
}
|
|
163
|
-
/** Whether the holder's period covers `now`. */
|
|
164
|
-
function activeNow(holder, now) {
|
|
165
|
-
return (holder.startsAt === void 0 || holder.startsAt <= now) && (holder.expiresAt === void 0 || holder.expiresAt > now);
|
|
166
|
-
}
|
|
167
|
-
function holdsNow(holder, principalId, now) {
|
|
168
|
-
return "principal" in holder && holder.principal.id === principalId && activeNow(holder, now);
|
|
169
|
-
}
|
|
170
|
-
/** Where the walk starts after following `hops`, or why it cannot. */
|
|
171
|
-
function followHops(condition, first, reader) {
|
|
172
|
-
const hops = condition.hops ?? [];
|
|
173
|
-
let id = first;
|
|
174
|
-
for (let index = 1; index < hops.length; index += 1) {
|
|
175
|
-
const from = hops[index - 1];
|
|
176
|
-
const hop = hops[index];
|
|
177
|
-
if (from === void 0 || hop === void 0)
|
|
178
|
-
/* v8 ignore next */
|
|
179
|
-
return;
|
|
180
|
-
const chain = reader.chain({
|
|
181
|
-
resource: from.resource,
|
|
182
|
-
id,
|
|
183
|
-
depth: 1,
|
|
184
|
-
through: hop.link
|
|
185
|
-
});
|
|
186
|
-
if (chain === "pending" || chain === "failed") return "relation-unavailable";
|
|
187
|
-
const next = chain.ancestors[0]?.id;
|
|
188
|
-
if (next === void 0) return;
|
|
189
|
-
id = next;
|
|
190
|
-
}
|
|
191
|
-
return { id };
|
|
192
|
-
}
|
|
193
|
-
function restrictedAbove(condition, row, reader) {
|
|
194
|
-
const above = condition.restrictedAncestors;
|
|
195
|
-
if (above === void 0) return false;
|
|
196
|
-
const parent = relationId(ownGet(row, above.parent));
|
|
197
|
-
if (parent === void 0) return false;
|
|
198
|
-
const chain = reader.chain({
|
|
199
|
-
resource: above.resource,
|
|
200
|
-
id: parent,
|
|
201
|
-
depth: above.depth - 1
|
|
202
|
-
});
|
|
203
|
-
if (chain === "pending" || chain === "failed") return "relation-unavailable";
|
|
204
|
-
if (chain.restricted === true || chain.ancestors.some((ancestor) => ancestor.restricted === true)) return;
|
|
205
|
-
const own = relationId(ownGet(row, above.id));
|
|
206
|
-
const ids = [
|
|
207
|
-
...own === void 0 ? [] : [own],
|
|
208
|
-
parent,
|
|
209
|
-
...chain.ancestors.map((ancestor) => ancestor.id)
|
|
210
|
-
];
|
|
211
|
-
if (new Set(ids).size !== ids.length || chain.truncated === true || chain.ancestors.length > above.depth - 1) return "relation-depth";
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
/** The instances a graph relation reads: the start, then ancestors until a restricted one or `depth`. */
|
|
215
|
-
function relationWalk(condition, row, reader) {
|
|
216
|
-
if (!isRecord(row)) return;
|
|
217
|
-
const first = relationId(ownGet(row, condition.field));
|
|
218
|
-
if (first === void 0) return;
|
|
219
|
-
const rowRestricted = condition.restricted !== void 0 && ownGet(row, condition.restricted) === true;
|
|
220
|
-
const hopped = condition.hops !== void 0 && condition.hops.length > 0;
|
|
221
|
-
if ((condition.parent === true || hopped) && rowRestricted) return;
|
|
222
|
-
const above = restrictedAbove(condition, row, reader);
|
|
223
|
-
if (above !== false) return above;
|
|
224
|
-
const start = hopped ? followHops(condition, first, reader) : { id: first };
|
|
225
|
-
if (start === void 0 || start === "relation-unavailable") return start;
|
|
226
|
-
const id = start.id;
|
|
227
|
-
if (condition.depth === 0 || rowRestricted) return {
|
|
228
|
-
ids: [id],
|
|
229
|
-
truncated: false
|
|
230
|
-
};
|
|
231
|
-
const chain = reader.chain({
|
|
232
|
-
resource: condition.resource,
|
|
233
|
-
id,
|
|
234
|
-
depth: condition.depth
|
|
235
|
-
});
|
|
236
|
-
if (chain === "pending" || chain === "failed") return "relation-unavailable";
|
|
237
|
-
const ids = [id];
|
|
238
|
-
const stops = condition.passRestricted !== true;
|
|
239
|
-
let stopped = stops && chain.restricted === true;
|
|
240
|
-
if (!stopped) for (const ancestor of chain.ancestors.slice(0, condition.depth)) {
|
|
241
|
-
ids.push(ancestor.id);
|
|
242
|
-
if (stops && ancestor.restricted === true) {
|
|
243
|
-
stopped = true;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (new Set(ids).size !== ids.length) return "relation-depth";
|
|
248
|
-
return {
|
|
249
|
-
ids,
|
|
250
|
-
truncated: !stopped && (chain.ancestors.length > condition.depth || chain.truncated === true)
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Whether the subject holds the relation on the row's instance or an
|
|
255
|
-
* ancestor within `depth`. A cycle is `relation-depth`; so is a chain that
|
|
256
|
-
* goes on past `depth` with no holder below it. Any read the instance could
|
|
257
|
-
* not answer is `relation-unavailable` unless a holder was found elsewhere.
|
|
258
|
-
*/
|
|
259
|
-
function resolveRelated(condition, row, subject, now, reader, permitted) {
|
|
260
|
-
if (condition.permission !== void 0) return resolveInherited(condition, condition.permission, row, reader, permitted);
|
|
261
|
-
const principal = subject.principal;
|
|
262
|
-
if (principal === null) return false;
|
|
263
|
-
const walk = relationWalk(condition, row, reader);
|
|
264
|
-
if (walk === void 0) return false;
|
|
265
|
-
if (walk === "relation-depth" || walk === "relation-unavailable") return walk;
|
|
266
|
-
if (condition.ids !== void 0) {
|
|
267
|
-
const held = new Set(condition.ids);
|
|
268
|
-
if (walk.ids.some((id) => held.has(id))) return true;
|
|
269
|
-
return walk.truncated ? "relation-depth" : false;
|
|
270
|
-
}
|
|
271
|
-
let unavailable = false;
|
|
272
|
-
let deep = false;
|
|
273
|
-
const explored = /* @__PURE__ */ new Map();
|
|
274
|
-
for (const id of walk.ids) {
|
|
275
|
-
const verdict = holdsRelation({
|
|
276
|
-
resource: condition.resource,
|
|
277
|
-
id,
|
|
278
|
-
relation: condition.relation
|
|
279
|
-
}, principal.id, now, reader, 16, /* @__PURE__ */ new Set(), explored);
|
|
280
|
-
if (verdict === true) return true;
|
|
281
|
-
if (verdict === "relation-unavailable") unavailable = true;
|
|
282
|
-
else if (verdict === "relation-depth") deep = true;
|
|
283
|
-
}
|
|
284
|
-
if (unavailable) return "relation-unavailable";
|
|
285
|
-
return walk.truncated || deep ? "relation-depth" : false;
|
|
286
|
-
}
|
|
287
|
-
function resolveInherited(condition, permission, row, reader, permitted) {
|
|
288
|
-
const walk = relationWalk(condition, row, reader);
|
|
289
|
-
if (walk === void 0) return false;
|
|
290
|
-
if (walk === "relation-depth" || walk === "relation-unavailable") return walk;
|
|
291
|
-
if (permitted === void 0) return "relation-unavailable";
|
|
292
|
-
let unknown = false;
|
|
293
|
-
for (const id of walk.ids) {
|
|
294
|
-
const verdict = permitted(condition.resource, id, permission);
|
|
295
|
-
if (verdict === true) return true;
|
|
296
|
-
if (verdict !== false && unknown === false) unknown = verdict;
|
|
297
|
-
}
|
|
298
|
-
return unknown;
|
|
299
|
-
}
|
|
300
|
-
function groupKey(group) {
|
|
301
|
-
return JSON.stringify([
|
|
302
|
-
group.resource,
|
|
303
|
-
group.id,
|
|
304
|
-
group.relation
|
|
305
|
-
]);
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Whether the principal holds `at.relation` on one instance, directly or
|
|
309
|
-
* through a group whose members hold it. Groups of `at`'s own resource nest
|
|
310
|
-
* at most `budget` deep; a group of another resource gets a fresh budget
|
|
311
|
-
* (declarations rule out cycles across resources). A group met twice on one
|
|
312
|
-
* path, or one past the budget, is `relation-depth`. `explored` holds the
|
|
313
|
-
* budget each group was walked with across the whole walk: a group already
|
|
314
|
-
* walked with as much budget adds nothing, since its verdict already reached
|
|
315
|
-
* the caller, so shared sub-groups cost one walk rather than one per path.
|
|
316
|
-
*/
|
|
317
|
-
function holdsRelation(at, principalId, now, reader, budget, seen, explored) {
|
|
318
|
-
const key = groupKey(at);
|
|
319
|
-
const walked = explored.get(key);
|
|
320
|
-
if (walked !== void 0 && walked >= budget) return false;
|
|
321
|
-
explored.set(key, budget);
|
|
322
|
-
const holders = reader.holders(at);
|
|
323
|
-
if (holders === "pending" || holders === "failed") return "relation-unavailable";
|
|
324
|
-
if (holders.some((holder) => holdsNow(holder, principalId, now))) return true;
|
|
325
|
-
const path = new Set(seen).add(key);
|
|
326
|
-
let unavailable = false;
|
|
327
|
-
let deep = false;
|
|
328
|
-
for (const holder of holders) {
|
|
329
|
-
if (!("group" in holder) || !activeNow(holder, now)) continue;
|
|
330
|
-
const nested = holder.group.resource === at.resource;
|
|
331
|
-
if (nested && budget <= 0 || path.has(groupKey(holder.group))) {
|
|
332
|
-
deep = true;
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
const verdict = holdsRelation(holder.group, principalId, now, reader, nested ? budget - 1 : 16, path, explored);
|
|
336
|
-
if (verdict === true) return true;
|
|
337
|
-
if (verdict === "relation-unavailable") unavailable = true;
|
|
338
|
-
else if (verdict === "relation-depth") deep = true;
|
|
339
|
-
}
|
|
340
|
-
if (unavailable) return "relation-unavailable";
|
|
341
|
-
return deep ? "relation-depth" : false;
|
|
342
|
-
}
|
|
343
|
-
/** The holders one edge-table row names for `spec`: none when the row does not belong to it. */
|
|
344
|
-
function tableHolders(resourceName, spec, row, id) {
|
|
345
|
-
if (relationId(ownGet(row, spec.object ?? `${resourceName}_id`)) !== id) return [];
|
|
346
|
-
for (const [column, value] of Object.entries(spec.match ?? {})) if (ownGet(row, column) !== value) return [];
|
|
347
|
-
const expiresAt = spec.expiresAt === void 0 ? void 0 : seconds(ownGet(row, spec.expiresAt));
|
|
348
|
-
const period = expiresAt === void 0 ? {} : { expiresAt };
|
|
349
|
-
const groups = spec.groups;
|
|
350
|
-
const direct = relationId(ownGet(row, spec.subject ?? "user_id"));
|
|
351
|
-
if (groups === void 0) return direct === void 0 ? [] : [{
|
|
352
|
-
principal: { id: direct },
|
|
353
|
-
...period
|
|
354
|
-
}];
|
|
355
|
-
if (groups.column === void 0) {
|
|
356
|
-
const out = direct === void 0 ? [] : [{
|
|
357
|
-
principal: { id: direct },
|
|
358
|
-
...period
|
|
359
|
-
}];
|
|
360
|
-
for (const group of groupEntries(spec)) {
|
|
361
|
-
const groupId = relationId(ownGet(row, group.subject));
|
|
362
|
-
if (groupId !== void 0) out.push({
|
|
363
|
-
group: {
|
|
364
|
-
resource: group.resource,
|
|
365
|
-
id: groupId,
|
|
366
|
-
relation: group.relation
|
|
367
|
-
},
|
|
368
|
-
...period
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
return out;
|
|
372
|
-
}
|
|
373
|
-
const kind = ownGet(row, groups.column);
|
|
374
|
-
if (kind === null || kind === void 0 || kind === groups.direct) return direct === void 0 ? [] : [{
|
|
375
|
-
principal: { id: direct },
|
|
376
|
-
...period
|
|
377
|
-
}];
|
|
378
|
-
const group = groupEntries(spec).find((entry) => entry.resource === kind);
|
|
379
|
-
const groupId = group === void 0 ? void 0 : relationId(ownGet(row, group.subject));
|
|
380
|
-
return group === void 0 || groupId === void 0 ? [] : [{
|
|
381
|
-
group: {
|
|
382
|
-
resource: group.resource,
|
|
383
|
-
id: groupId,
|
|
384
|
-
relation: group.relation
|
|
385
|
-
},
|
|
386
|
-
...period
|
|
387
|
-
}];
|
|
388
|
-
}
|
|
389
|
-
function seconds(value) {
|
|
390
|
-
if (value instanceof Date) {
|
|
391
|
-
const time = value.getTime();
|
|
392
|
-
return Number.isNaN(time) ? void 0 : time / 1e3;
|
|
393
|
-
}
|
|
394
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
395
|
-
if (typeof value === "string") {
|
|
396
|
-
const parsed = Date.parse(value);
|
|
397
|
-
return Number.isNaN(parsed) ? void 0 : parsed / 1e3;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
function restrictedOf(node, row) {
|
|
401
|
-
return node.restricted !== void 0 && row !== void 0 && ownGet(row, node.restricted) === true;
|
|
402
|
-
}
|
|
403
|
-
function edgeHolder(edge) {
|
|
404
|
-
const holder = { principal: { id: edge.principal } };
|
|
405
|
-
if (edge.startsAt !== void 0) holder.startsAt = edge.startsAt;
|
|
406
|
-
if (edge.expiresAt !== void 0) holder.expiresAt = edge.expiresAt;
|
|
407
|
-
return holder;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* An in-process `RelationSource` over plain rows and edges, read against the
|
|
411
|
-
* resource definitions in `permissions`. For tests, fixtures and small apps.
|
|
412
|
-
*/
|
|
413
|
-
function memoryRelations(permissions, data = {}) {
|
|
414
|
-
const registry = getRegistry(permissions);
|
|
415
|
-
const byId = /* @__PURE__ */ new Map();
|
|
416
|
-
for (const [name, rows] of Object.entries(data.rows ?? {})) {
|
|
417
|
-
const node = registry.get(name);
|
|
418
|
-
const index = /* @__PURE__ */ new Map();
|
|
419
|
-
for (const row of rows) {
|
|
420
|
-
const id = relationId(ownGet(row, node?.id ?? "id"));
|
|
421
|
-
if (id !== void 0) index.set(id, row);
|
|
422
|
-
}
|
|
423
|
-
byId.set(name, index);
|
|
424
|
-
}
|
|
425
|
-
const rowOf = (resource, id) => byId.get(resource)?.get(id);
|
|
426
|
-
return {
|
|
427
|
-
row({ resource, id }) {
|
|
428
|
-
return rowOf(resource, id) ?? null;
|
|
429
|
-
},
|
|
430
|
-
ancestors({ resource, id, depth, through }) {
|
|
431
|
-
const node = registry.get(resource);
|
|
432
|
-
const start = rowOf(resource, id);
|
|
433
|
-
if (node === void 0 || start === void 0) return { ancestors: [] };
|
|
434
|
-
if (through !== "parent") {
|
|
435
|
-
const link = Object.hasOwn(node.links, through) ? node.links[through] : void 0;
|
|
436
|
-
const next = link === void 0 ? void 0 : relationId(ownGet(start, link.field));
|
|
437
|
-
if (next === void 0 || depth < 1) return { ancestors: [] };
|
|
438
|
-
return { ancestors: [{ id: next }] };
|
|
439
|
-
}
|
|
440
|
-
const restricted = restrictedOf(node, start);
|
|
441
|
-
const stops = restrictedStops(node, "parent");
|
|
442
|
-
if (restricted && stops || node.parent === void 0 || node.parent.resource !== resource) return restricted ? {
|
|
443
|
-
restricted: true,
|
|
444
|
-
ancestors: []
|
|
445
|
-
} : { ancestors: [] };
|
|
446
|
-
const field = node.parent.field;
|
|
447
|
-
const seen = /* @__PURE__ */ new Set([id]);
|
|
448
|
-
const ancestors = [];
|
|
449
|
-
let next = relationId(ownGet(start, field));
|
|
450
|
-
while (next !== void 0 && ancestors.length < depth) {
|
|
451
|
-
const row = rowOf(resource, next);
|
|
452
|
-
if (row === void 0) {
|
|
453
|
-
next = void 0;
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
const hidden = restrictedOf(node, row);
|
|
457
|
-
ancestors.push(hidden ? {
|
|
458
|
-
id: next,
|
|
459
|
-
restricted: true
|
|
460
|
-
} : { id: next });
|
|
461
|
-
if (seen.has(next) || hidden && stops) {
|
|
462
|
-
next = void 0;
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
seen.add(next);
|
|
466
|
-
next = relationId(ownGet(row, field));
|
|
467
|
-
}
|
|
468
|
-
const chain = restricted ? {
|
|
469
|
-
restricted: true,
|
|
470
|
-
ancestors
|
|
471
|
-
} : { ancestors };
|
|
472
|
-
return next === void 0 || rowOf(resource, next) === void 0 ? chain : {
|
|
473
|
-
...chain,
|
|
474
|
-
truncated: true
|
|
475
|
-
};
|
|
476
|
-
},
|
|
477
|
-
related({ resource, id, relation }) {
|
|
478
|
-
const spec = registry.get(resource)?.relations[relation];
|
|
479
|
-
if (spec === void 0 || isComputedRelation(spec)) return [];
|
|
480
|
-
if (isEdgeRelation(spec)) {
|
|
481
|
-
const table = data.tables?.[spec.edge];
|
|
482
|
-
if (table !== void 0) return table.flatMap((row) => tableHolders(resource, spec, row, id));
|
|
483
|
-
return (data.edges?.[resource]?.[relation] ?? []).filter((edge) => edge.id === id).map(edgeHolder);
|
|
484
|
-
}
|
|
485
|
-
const row = rowOf(resource, id);
|
|
486
|
-
if (row === void 0) return [];
|
|
487
|
-
if (isPrincipalRelation(spec)) {
|
|
488
|
-
const holder = relationId(ownGet(row, spec.principal));
|
|
489
|
-
if (holder === void 0) return [];
|
|
490
|
-
const startsAt = spec.period?.startsAt === void 0 ? void 0 : seconds(ownGet(row, spec.period.startsAt));
|
|
491
|
-
const expiresAt = spec.period?.expiresAt === void 0 ? void 0 : seconds(ownGet(row, spec.period.expiresAt));
|
|
492
|
-
return [{
|
|
493
|
-
principal: { id: holder },
|
|
494
|
-
...startsAt === void 0 ? {} : { startsAt },
|
|
495
|
-
...expiresAt === void 0 ? {} : { expiresAt }
|
|
496
|
-
}];
|
|
497
|
-
}
|
|
498
|
-
if (spec.memberOf !== void 0) return [];
|
|
499
|
-
const holder = relationId(ownGet(row, spec.field));
|
|
500
|
-
return holder === void 0 ? [] : [{ principal: { id: holder } }];
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
//#endregion
|
|
505
|
-
export { relationWalk as a, relationReader as i, pendingRelations as n, resolveRelated as o, relationId as r, memoryRelations as t };
|