permdock 0.30.0 → 0.32.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/README.md +2 -2
- package/dist/a2a/index.d.ts +5 -5
- package/dist/a2a/index.js +2 -2
- package/dist/{adoption-scan-EGg-hGEu.js → adoption-scan-BJMEEu7V.js} +1 -1
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/ai-sdk/index.d.ts +4 -4
- package/dist/ai-sdk/index.js +3 -3
- package/dist/annotate-dUrBHXWa.js +183 -0
- package/dist/{annotate-doc-BCOCOrq_.js → annotate-doc-BA0betEO.js} +5 -4
- package/dist/annotate-routes-CGJy1ojp.js +30 -0
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +1 -1
- package/dist/app-peer-BnMh5lqz.js +27 -0
- package/dist/approval-chain-D97rgMoA.js +431 -0
- package/dist/{approval-normalize-Cpp8R0rY.js → approval-normalize-C6je8vWN.js} +1 -1
- package/dist/{approval-prompt-C-vjNZyd.d.ts → approval-prompt-yNyhQqn8.d.ts} +2 -2
- package/dist/approvals/index.d.ts +3 -3
- package/dist/approvals/index.js +3 -3
- package/dist/{approvals-7jHYXocE.js → approvals-Bt5IQ4wR.js} +3 -3
- package/dist/{arazzo-CfjZOmVG.js → arazzo-BAgh0PT6.js} +3 -3
- package/dist/{arazzo-yiKJ4jm0.js → arazzo-C_xK2Kaa.js} +2 -2
- package/dist/{args-Bc0HLiD4.js → args-BSpXxMnb.js} +2 -1
- package/dist/ast-CAOxvn9t.js +188 -0
- package/dist/ast-Dnm2TOHN.js +434 -0
- package/dist/astro/index.d.ts +6 -6
- package/dist/astro/index.js +2 -2
- package/dist/{audience-DauhRBNg.js → audience-CARf-b-R.js} +1 -1
- package/dist/authzen/index.d.ts +6 -6
- package/dist/authzen/index.js +3 -3
- package/dist/{automation-CUcWz8uu.d.ts → automation-0VF1xe4o.d.ts} +3 -3
- package/dist/{automation-CpPdFX91.js → automation-D58PEI7Y.js} +1 -1
- package/dist/baseline-file-BQoki1O_.js +148 -0
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/better-auth/index.js +2 -2
- package/dist/better-supabase/index.d.ts +72 -19
- package/dist/better-supabase/index.js +156 -71
- package/dist/{bind-up3QptTt.js → bind-BYeoLJgN.js} +5 -4
- package/dist/{bind-B3MHrzw4.d.ts → bind-zQacwAOg.d.ts} +12 -7
- package/dist/bsb-access-Bcw6GrQm.js +74 -0
- package/dist/bsb-access-tags-CjeR7v7-.js +272 -0
- package/dist/bsb-action-keys-CYEREFMg.js +377 -0
- package/dist/bsb-actions-BHiyBxQZ.js +65 -0
- package/dist/budgets-Dpumu_Dt.js +75 -0
- package/dist/{build-instance-hLKYe3-E.js → build-instance-CFiegi_w.js} +1 -1
- package/dist/bundle-size-Ddhv_H_v.js +56 -0
- package/dist/bundle-size-DwZ4e1gu.js +1 -0
- package/dist/{capability-CVt3lpVK.d.ts → capability-BPzseilU.d.ts} +2 -2
- package/dist/{capability-_ZsyfYxU.js → capability-oxfxybFR.js} +1 -1
- package/dist/{casbin-QzddqHaV.js → casbin-BErdqy1J.js} +1 -1
- package/dist/{casbin-j_468wDU.js → casbin-EwdKipQs.js} +2 -2
- package/dist/{casl-CrltbDPa.js → casl-BSt24g-p.js} +1 -1
- package/dist/catalog/index.d.ts +5 -5
- package/dist/catalog/index.js +6 -6
- package/dist/{catalog-DXSP1we9.js → catalog-BExjL94D.js} +4 -4
- package/dist/{catalog-COoxFOoy.js → catalog-CBPFyRv7.js} +2 -2
- package/dist/{catalog-doc-Bp5khmCG.js → catalog-doc-D4g3nyFB.js} +5 -3
- package/dist/{catalog-operations-dxuOZr4J.js → catalog-operations-BqSsByIE.js} +3 -3
- package/dist/catalog-sR0m6x2g.js +1 -0
- package/dist/{challenge-CjwmjcuX.js → challenge-CRB1X3Ry.js} +1 -1
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +2 -2
- package/dist/chat-sdk/index.d.ts +3 -3
- package/dist/claims-size-B6j0Ff4Q.js +1 -0
- package/dist/{perf-token-dFGVP14-.js → claims-size-BsSDVD5u.js} +66 -1
- package/dist/claude-agent/index.d.ts +3 -3
- package/dist/claude-agent/index.js +2 -2
- package/dist/clerk/index.d.ts +3 -3
- package/dist/cli/bin.js +1 -1
- package/dist/cli/generate/watch-worker.js +2 -2
- package/dist/cli/index.d.ts +9 -9
- package/dist/cli/index.js +3 -3
- package/dist/cli/plugins/app.d.ts +1 -1
- package/dist/cli/plugins/app.js +1 -1
- package/dist/cli/plugins/better-supabase.d.ts +1 -1
- package/dist/cli/plugins/openapi.d.ts +1 -1
- package/dist/cli/plugins/openapi.js +2 -2
- package/dist/cli/plugins/powersync.d.ts +1 -1
- package/dist/cli/plugins/powersync.js +2 -2
- package/dist/cli/plugins/rls.d.ts +2 -2
- package/dist/cli/plugins/rls.js +1 -1
- package/dist/cli/plugins/schemas.d.ts +1 -1
- package/dist/cli/plugins/schemas.js +1 -1
- package/dist/cli/plugins/scim.d.ts +2 -2
- package/dist/cli/plugins/supabase-hook.d.ts +2 -2
- package/dist/cli/plugins/supabase-hook.js +1 -1
- package/dist/cli/plugins/supabase.d.ts +3 -3
- package/dist/cli/plugins/supabase.js +2 -2
- package/dist/cli/plugins/ui.d.ts +1 -1
- package/dist/cli/plugins/ui.js +1 -1
- package/dist/{client-subject-v89t811z.d.ts → client-subject-xCSkKD1C.d.ts} +2 -2
- package/dist/cloud/index.d.ts +8 -8
- package/dist/cloud/index.js +1 -1
- package/dist/{cloud-D3c4zhYr.js → cloud-DW3q3qnp.js} +3 -3
- package/dist/{codemod-BLTuDxFa.js → codemod-CF7NNDzA.js} +616 -392
- package/dist/codemod-DVDMFsTX.js +75 -0
- package/dist/{collect-BYPq-0JU.js → collect-CE5wK0AX.js} +3 -3
- package/dist/collect-CIdE3FGC.js +1 -0
- package/dist/{collect-BOh9Pxob.js → collect-CPimbkC5.js} +3 -3
- package/dist/compare-8SNJN-9U.js +12 -0
- package/dist/compile/index.d.ts +1 -1
- package/dist/{compile-B9SZiEnG.js → compile-BXKYYmT1.js} +19 -23
- package/dist/{compile-D8c1nFGy.d.ts → compile-tG1zkSgX.d.ts} +3 -3
- package/dist/{completion-CVTgFKK6.js → completion-B59uPAnZ.js} +2 -2
- package/dist/config-7QvEq57a.js +521 -0
- package/dist/{config-ClUStKUe.js → config-VCa1RLUe.js} +2 -2
- package/dist/config-paths-CQvGng3k.js +136 -0
- package/dist/{config-report-GJmQMf2K.js → config-report-CjvA6lGI.js} +7 -2
- package/dist/{config-shape-B6tdyBju.js → config-shape-BTojaD-H.js} +9 -2
- package/dist/{context-BdoA9DhS.js → context-BQHKgT1m.js} +2 -2
- package/dist/context-CAFddgb9.js +35 -0
- package/dist/convex/index.d.ts +5 -5
- package/dist/convex/index.js +2 -2
- package/dist/{core-tEfD0lwu.js → core-C5yCD-Ls.js} +6 -6
- package/dist/{core-CnC47rSf.d.ts → core-bf8qgaZf.d.ts} +3 -3
- package/dist/{coverage-DL7JCZmb.d.ts → coverage-AOeWiQ7Z.d.ts} +2 -2
- package/dist/{coverage-nFSMjFxH.js → coverage-C3jVYC9Y.js} +1 -1
- package/dist/{create-sGl1ccTp.d.ts → create-B7Xa4jSQ.d.ts} +9 -9
- package/dist/{create-D3oXoXxM.js → create-COQVXK6C.js} +22 -6
- package/dist/{create-DeQ5t8mZ.d.ts → create-Cn5EpEez.d.ts} +5 -5
- package/dist/{create-BsRcXm_m.d.ts → create-DHA0fhmi.d.ts} +7 -7
- package/dist/{create-BAMPoEga.js → create-nOWD3Joc.js} +3 -3
- package/dist/{credential-ke0KMQeB.js → credential-D9in5keC.js} +3 -3
- package/dist/{credentials-DOeqknte.js → credentials-B-hsgB4W.js} +1 -1
- package/dist/{credentials-BfzdL5kv.d.ts → credentials-COT-cjnP.d.ts} +3 -3
- package/dist/custom-role-rebuild-BK73tPib.js +181 -0
- package/dist/deciding-columns-DBZsrpdD.js +60 -0
- package/dist/deferred-sink-BZahJ8sO.js +34 -0
- package/dist/{define-permdock-CIxHBykk.js → define-permdock-D7aKxIax.js} +4 -4
- package/dist/{define-permdock-BLpQ0m95.d.ts → define-permdock-DBgwTFi1.d.ts} +6 -6
- package/dist/{delegation-BaUNCrE_.js → delegation-0DVVomzu.js} +3 -3
- package/dist/delivery/index.d.ts +4 -4
- package/dist/delivery/index.js +1 -1
- package/dist/{denied-text-D6JJTDr3.d.ts → denied-text-C_AWc0f0.d.ts} +2 -2
- package/dist/{describe-lAafaRQQ.d.ts → describe-AdETpWsn.d.ts} +2 -2
- package/dist/{diff-CXRZ6qPa.js → diff-COdwpP31.js} +7 -7
- package/dist/{diff-Cv9inVY5.js → diff-CW9eZy9X.js} +2 -2
- package/dist/{doctor-CQoP1264.js → doctor-ELj5hrVv.js} +17 -5
- package/dist/{doctor-Bn2BTr0N.js → doctor-ervtBRzG.js} +1624 -322
- package/dist/drizzle/index.d.ts +3 -3
- package/dist/edits-CqU8s2GC.js +69 -0
- package/dist/elysia/index.d.ts +5 -5
- package/dist/elysia/index.js +3 -3
- package/dist/{errors-DUJ7wLlE.d.ts → errors-COoiWqIs.d.ts} +1 -1
- package/dist/{evaluate-D8SdfP3h.js → evaluate-Dmd0bShm.js} +30 -31
- package/dist/{evaluations-BQkpE7hC.js → evaluations-DPEAu_jM.js} +2 -2
- package/dist/{evaluations-K9qglDP7.d.ts → evaluations-GW9j_ARq.d.ts} +3 -3
- package/dist/evaluator-COmATWCr.js +2 -0
- package/dist/{evaluator-eager-UuJK6NX_.js → evaluator-eager-CpVYslzY.js} +1 -1
- package/dist/eve/index.d.ts +18 -8
- package/dist/eve/index.js +13 -15
- package/dist/{execute-BLM5tpRU.js → execute-ix7AAdWg.js} +17 -41
- package/dist/explain-DRC9V5Qb.js +37 -0
- package/dist/explain-jg0KLCVt.js +74 -0
- package/dist/express/index.d.ts +5 -5
- package/dist/express/index.js +3 -3
- package/dist/fastify/index.d.ts +5 -5
- package/dist/fastify/index.js +3 -3
- package/dist/{fetch-adapter-gmTCu4FR.d.ts → fetch-adapter-CJncmsPg.d.ts} +4 -4
- package/dist/{fetch-adapter-ovZdSvlT.js → fetch-adapter-CU1DIkXu.js} +3 -3
- package/dist/{fields-CViS0EPC.js → fields-y_PSRCyJ.js} +3 -2
- package/dist/{fixtures-Bm0G0A7H.js → fixtures-3aUUP6Nx.js} +1 -1
- package/dist/flags-DQzNPxg1.js +204 -0
- package/dist/{from-snapshot-CCDF_ihX.js → from-snapshot-DGc9W4QU.js} +7 -7
- package/dist/{gen-02p5oEol.js → gen-8rW_AUG5.js} +16 -12
- package/dist/gen-BtiGMiuH.js +1 -0
- package/dist/{gen-kind-BMwPHJZ0.js → gen-kind-C9ikF8nb.js} +1 -1
- package/dist/{generate-BVcwnfoI.js → generate-BmpCt5oi.js} +4 -4
- package/dist/{generate-BtstB6iV.js → generate-CW7gNfLr.js} +244 -158
- package/dist/{generate-options-Yfh1pGyX.js → generate-options-DiR4r_sk.js} +18 -189
- package/dist/{grantee-BPUG6f0r.js → grantee-BSCdpIF3.js} +1 -1
- package/dist/{grantee-match-CFQ-LRcL.js → grantee-match-CJgQmcx4.js} +1 -1
- package/dist/h3/index.d.ts +4 -4
- package/dist/h3/index.js +3 -3
- package/dist/helper-calls-DHvgN9tr.js +106 -0
- package/dist/{helpers-DSmj6SHi.js → helpers-COh0lLc1.js} +2 -2
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +3 -3
- package/dist/{hook-sql-55514A9t.js → hook-sql-D-abRHut.js} +47 -225
- package/dist/{hosted-DUbuh0Td.d.ts → hosted-Bkw3Oyh-.d.ts} +1 -1
- package/dist/{hosted-DMJKJPoc.js → hosted-DZwCFrcy.js} +5 -5
- package/dist/{import-HzsIBAa5.js → import-BAhoTYTk.js} +1 -1
- package/dist/{import-Cm8kuezl.js → import-D_8tLF9g.js} +30 -46
- package/dist/{index-BSJoxaOi.d.ts → index-DPVeDtAO.d.ts} +5 -5
- package/dist/{index-D1msamx_.d.ts → index-DT3hOxA7.d.ts} +83 -14
- package/dist/{index-DegTwZxD.d.ts → index-DWmIuQLz.d.ts} +5 -5
- package/dist/{index-eaNHkELi.d.ts → index-Kj5S3IWE.d.ts} +6 -6
- package/dist/{index-O0qbI8Ha.d.ts → index-WOx7TBbj.d.ts} +2 -2
- package/dist/{index-D8A1d_Tt.d.ts → index-xShPsK8G.d.ts} +2 -2
- package/dist/index.d.ts +18 -18
- package/dist/index.js +25 -24
- package/dist/{init-DvsMFuau.js → init-DkRHIe8-.js} +4 -4
- package/dist/{init-BklKWywy.js → init-zxb0BVDJ.js} +1 -1
- package/dist/{instance-options-B4MD2wgl.d.ts → instance-options-DQCiBBuz.d.ts} +1 -1
- package/dist/{instance-snapshot-DdGOpSfN.js → instance-snapshot-D9kjL37B.js} +37 -20
- package/dist/{interactive-only-C_olBCPl.js → interactive-only-Dqww0ABO.js} +22 -14
- package/dist/jwt/index.d.ts +17 -13
- package/dist/jwt/index.js +14 -5
- package/dist/{kernel-Dn6pKMAF.js → kernel-C5akxw5n.js} +7 -7
- package/dist/keys-DQsHrgBM.js +42 -0
- package/dist/kysely/index.d.ts +3 -3
- package/dist/{lazy-provider-C48LDq0q.d.ts → lazy-provider-CMgFAGf8.d.ts} +1 -1
- package/dist/{lazy-provider-CVX534Kk.js → lazy-provider-DNVjY4n3.js} +2 -2
- package/dist/load-BCABUQZi.js +1 -0
- package/dist/{load-CZnlAyZ8.js → load-m7jmit3y.js} +1 -1
- package/dist/{login-CuUf-syI.js → login-C1p3gmj8.js} +1 -1
- package/dist/{login-BFvEcFnI.js → login-DOEZveP6.js} +4 -4
- package/dist/manager-chain-DdkiCw5q.js +243 -0
- package/dist/{manifest-BYzJF6xk.js → manifest-31igzVGQ.js} +70 -38
- package/dist/{manifest-Ct3eXbLR.js → manifest-B487A3po.js} +1 -1
- package/dist/{manifest-CRHphHxo.d.ts → manifest-DgsxeAsM.d.ts} +76 -0
- package/dist/{manifest-schema-Bp-eFhNZ.js → manifest-schema-D7RQbnGY.js} +90 -1
- package/dist/{map-error-DTi_JZT8.js → map-error-DYQbf-3Q.js} +1 -1
- package/dist/{may-use-Died1tNU.js → may-use-4HzzgYJ3.js} +3 -3
- package/dist/mcp/index.d.ts +9 -9
- package/dist/mcp/index.js +4 -4
- package/dist/{membership-filter-CSKH48eD.js → membership-filter-C7ZuhAqJ.js} +1 -1
- package/dist/{migrate-BcBFWFt9.js → migrate-pg-lkbDu.js} +4 -16
- package/dist/model-BXhr8gUI.js +329 -0
- package/dist/{module-values-Ddx0GLaJ.js → module-values-B09BBJIj.js} +3 -3
- package/dist/nest/index.d.ts +5 -5
- package/dist/nest/index.js +3 -3
- package/dist/next/index.d.ts +29 -12
- package/dist/next/index.js +24 -26
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +1 -1
- package/dist/node/index.d.ts +5 -5
- package/dist/node/index.js +2 -2
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.js +3 -3
- package/dist/openapi/index.d.ts +4 -4
- package/dist/openapi/index.js +3 -3
- package/dist/{openapi-BwZABlQO.js → openapi-BeMVHVY4.js} +6 -6
- package/dist/{openapi-D2dmyWZK.js → openapi-CZu6sVsP.js} +1 -1
- package/dist/{openapi-DNZv-nDu.js → openapi-DEGesHWH.js} +11 -4
- package/dist/{openapi-document-DoIe4MrZ.js → openapi-document-CEQ6jqqR.js} +1 -1
- package/dist/{operations-BS8ExH5A.d.ts → operations-DaEoGpMV.d.ts} +1 -1
- package/dist/{operations-De3F7tlf.js → operations-dJxcshJZ.js} +1 -1
- package/dist/{operations-B0yO77Zz.js → operations-id4vhwFN.js} +9 -3
- package/dist/orpc/index.d.ts +7 -7
- package/dist/orpc/index.js +4 -4
- package/dist/otel/index.d.ts +3 -3
- package/dist/{output-BI85V6hu.js → output-C7EPeSZj.js} +19 -2
- package/dist/{output-files-D5D-8-4l.js → output-files-8lfALMSU.js} +143 -11
- package/dist/output-files-DKWhL1IE.js +1 -0
- package/dist/{ownership-mprXkEHG.js → ownership-Csk9C3Js.js} +10 -6
- package/dist/{parse-nfHSt1Wy.js → parse-CUqZ_lLC.js} +1 -1
- package/dist/{parse-local-manifest-BGLWVchi.d.ts → parse-local-manifest-B92rFWnk.d.ts} +1 -1
- package/dist/pdp/index.d.ts +3 -3
- package/dist/pdp/index.js +2 -2
- package/dist/{permdock-Dz3yzWrp.d.ts → permdock-BShHM8OJ.d.ts} +11 -5
- package/dist/{permdock-BueSeg7X.js → permdock-CJPIwU1T.js} +102 -55
- package/dist/{permission-registry-DMYRZVcn.js → permission-registry-DstT40VS.js} +31 -1
- package/dist/{permissions-CQW3cr2S.js → permissions-DJ_QV9L7.js} +1 -1
- package/dist/{permissions-DWULToSb.d.ts → permissions-UyQD5nRN.d.ts} +1 -1
- package/dist/{permissions-Bj3DRIEi.js → permissions-wEkTVr_I.js} +3 -3
- package/dist/{pg-CA651850.js → pg-DmS5ITHu.js} +20 -1
- package/dist/pg-DtiDogUp.js +1 -0
- package/dist/{pipeline-Ct3YEKjx.js → pipeline-Bbu7uw28.js} +103 -32
- package/dist/{plugin-zOs9uqQj.d.ts → plugin-L3G7jPGE.d.ts} +15 -4
- package/dist/{policy-DFD2J5o_.js → policy-BBvhhH9X.js} +4 -4
- package/dist/{policy-C-Lzp3Zh.d.ts → policy-BUtwixSN.d.ts} +2 -2
- package/dist/{policy-DfvOwgtX.js → policy-CSOOQ3rR.js} +3 -3
- package/dist/{policy-bundle-pwhJJv2-.js → policy-bundle-KYI0EnrM.js} +3 -3
- package/dist/{policy-from-catalog-YKaTeaco.js → policy-from-catalog-_zwn1sNj.js} +12 -9
- package/dist/{policy-types-93NwI8iI.d.ts → policy-types-CfW4X_yX.d.ts} +155 -19
- package/dist/{postgrest-DyrYo_XT.d.ts → postgrest-PQ3zAOD2.d.ts} +2 -2
- package/dist/powersync-C1ix7CEY.js +1 -0
- package/dist/{powersync-D1Aog89p.js → powersync-CGvu6j5U.js} +2 -2
- package/dist/{powersync-CkoImqoq.js → powersync-CM6Vg4RH.js} +65 -24
- package/dist/prisma/index.d.ts +2 -2
- package/dist/program-CvarkLMS.js +10 -0
- package/dist/{protected-action-Dco5O_Kc.js → protected-action-BPN0NaRb.js} +1 -1
- package/dist/{protected-action-CEzNNtfi.d.ts → protected-action-DhCQ4bSe.d.ts} +6 -6
- package/dist/{provider-BYcoTKuS.js → provider-1xqxLVEz.js} +2 -2
- package/dist/{provider-1yWthvi5.js → provider-BV_v0JAY.js} +457 -116
- package/dist/{provider-C48LDq0q.d.ts → provider-CMgFAGf8.d.ts} +1 -1
- package/dist/{provider-store-Dq_olUjC.js → provider-store-Cf8HRNtb.js} +3 -3
- package/dist/{provider-with-fxHItxDh.js → provider-with-cpL9vRjC.js} +2 -2
- package/dist/prune-config-CdoPJIGz.js +209 -0
- package/dist/{pull-DD6YQ42X.js → pull-BaB401Bk.js} +4 -4
- package/dist/pull-Bp63vtgu.js +1 -0
- package/dist/{push-N-QI_ArC.js → push-DcjvEj0m.js} +5 -5
- package/dist/{pushed-policy-rpB6k77P.js → pushed-policy-DSjSWEAl.js} +1 -1
- package/dist/{pushed-policy-APjMbYdV.d.ts → pushed-policy-DcvO8NXy.d.ts} +1 -1
- package/dist/{conditions-ChE7zxJI.js → rbac-mblGDx-Z.js} +227 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +3 -3
- package/dist/react/lazy.d.ts +6 -6
- package/dist/react/lazy.js +3 -3
- package/dist/react/provider-client-lazy.d.ts +1 -1
- package/dist/react/provider-client-lazy.js +1 -1
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +9 -9
- package/dist/react-native/index.js +8 -8
- package/dist/rename-BZNOV8H9.js +437 -0
- package/dist/replay-BCOZifwx.d.ts +3 -0
- package/dist/report-DCAiUc5U.js +1 -0
- package/dist/report-DievqWhf.js +368 -0
- package/dist/{request-context-CVJodWx8.js → request-context-BNVY3kZ1.js} +1 -1
- package/dist/resend/index.d.ts +4 -4
- package/dist/resolve-config-9NYYVc30.js +238 -0
- package/dist/{resolve-names-B0cqvJxo.js → resolve-names-Cth1UQ-8.js} +5 -5
- package/dist/{resolver-4qxIIHcC.js → resolver-CuIY8aFD.js} +48 -30
- package/dist/{retire-BNiXnbBR.js → retire-FN4aY6-n.js} +1 -1
- package/dist/{rls-oLdqutBO.js → rls-BtkZgaZp.js} +33 -5
- package/dist/{rls-c0Z9lbyp.js → rls-DUYok5e9.js} +231 -40
- package/dist/{rls-files-Dhtn_6LH.js → rls-files-ucAI0J5j.js} +3 -3
- package/dist/{rls-options-BZxfMDFo.d.ts → rls-options-BFGRmdcH.d.ts} +1 -1
- package/dist/{role-builder-DhsGEVq-.js → role-builder-BksM3Q9O.js} +3 -3
- package/dist/{roles-B29psCem.js → roles-BeNEhv7Q.js} +2 -2
- package/dist/{rpc-DjgxFbjK.d.ts → rpc-COnquydd.d.ts} +2 -2
- package/dist/{rpc-B-4IZOiU.js → rpc-D7G7IJDa.js} +1 -1
- package/dist/run-BjMxYYTe.js +1 -0
- package/dist/{run-DkviX16y.js → run-WIqPbnjD.js} +12 -11
- package/dist/{run-ticket-DXwrko2J.d.ts → run-ticket-Mmor5sYW.d.ts} +2 -2
- package/dist/{saas-CUwmgUB8.js → saas-DcqUkynn.js} +5 -5
- package/dist/{scan-CNhvy39j.js → scan-Badcllgg.js} +1 -1
- package/dist/{schema-BeY3croo.js → schema-D2OK4RrB.js} +1 -0
- package/dist/{schema-CwNjlLBx.js → schema-DBRKgQb4.js} +1 -1
- package/dist/schema-tables-Ba9LE_XB.js +185 -0
- package/dist/scim/index.d.ts +1 -1
- package/dist/seeds/index.d.ts +1 -1
- package/dist/seeds/index.js +1 -1
- package/dist/{seeds-BDTG7xl-.js → seeds-Bs44UDS3.js} +1 -1
- package/dist/{seeds-uG196Ev4.d.ts → seeds-Cih1ztkf.d.ts} +2 -2
- package/dist/server/index.d.ts +13 -12
- package/dist/server/index.js +7 -6
- package/dist/{server-Co9CYGqk.js → server-lohbasQd.js} +2 -2
- package/dist/{server-types-BrHOGAYx.d.ts → server-types-C2XX60aF.d.ts} +16 -9
- package/dist/shared-C6_T7QUo.js +76 -0
- package/dist/{sink-BD34OS8T.d.ts → sink-BQ_6K81r.d.ts} +4 -4
- package/dist/{size-BqLd5oJ4.js → size-l1pDHE2z.js} +28 -5
- package/dist/{skills-DrY6VdtH.js → skills-Ba9hHGO6.js} +2 -2
- package/dist/{skills-B74k44ml.js → skills-CTKq3o8D.js} +2 -2
- package/dist/{snapshot-DckMnHk8.js → snapshot-Ty0uk9wZ.js} +46 -12
- package/dist/{snapshot-cache-DoP3avLl.d.ts → snapshot-cache-DGvLQW0-.d.ts} +1 -1
- package/dist/snapshot-compact-yXFxZLPo.js +596 -0
- package/dist/{snapshot-empty-DZ6sZ83n.js → snapshot-empty-pKgPDcLd.js} +1 -1
- package/dist/{snapshot-evaluate-9RGy7J3N.js → snapshot-evaluate-DSNj2rhV.js} +5 -4
- package/dist/{snapshot-reads-D775amTL.js → snapshot-reads-BnAHiuoa.js} +2 -2
- package/dist/snapshot-requires-DfUqCLEb.js +122 -0
- package/dist/{snapshot-size-CHig-Nq_.js → snapshot-size-2fkXbCkP.js} +5 -15
- package/dist/snapshot-size-DNY1MTsV.js +1 -0
- package/dist/solid/index.d.ts +6 -6
- package/dist/solid/index.js +2 -2
- package/dist/solid-start/index.d.ts +6 -6
- package/dist/solid-start/index.js +3 -3
- package/dist/{sources-NQio1yFq.d.ts → sources-CjgZns7t.d.ts} +2 -2
- package/dist/{src-BAYcigFU.js → src-HRYn4UFj.js} +148 -15
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +1 -1
- package/dist/{standard-webhooks-B3MQihcP.d.ts → standard-webhooks-Bnnrqa6d.d.ts} +2 -2
- package/dist/{store-core-DyNo_BwA.d.ts → store-core-BdFcruPm.d.ts} +5 -5
- package/dist/{store-AH8bmaxW.js → store-n3yEN7dt.js} +2 -2
- package/dist/{store-options-BtHrfJUU.js → store-options-DpCQo0vB.js} +21 -12
- package/dist/{stores-DyFCruRC.d.ts → stores-D6MIjN_-.d.ts} +6 -6
- package/dist/{stores-BIMyclLg.js → stores-KpBCaY6c.js} +1 -1
- package/dist/{shared-Cwxy5N16.js → subject-CrldGifz.js} +1 -75
- package/dist/{subject-cache-BZeSj4Xf.d.ts → subject-cache-CnJcz2K_.d.ts} +14 -6
- package/dist/supabase/index.d.ts +9 -9
- package/dist/supabase/index.js +4 -4
- package/dist/supabase/middleware.d.ts +14 -7
- package/dist/supabase/middleware.js +17 -6
- package/dist/{supabase-CakrAxMg.js → supabase-CGiB83XQ.js} +2 -2
- package/dist/supabase-dir-0lxKbrYu.js +41 -0
- package/dist/supabase-hook-CluYxKee.js +2 -0
- package/dist/{supabase-hook-0q6ohTVN.js → supabase-hook-CqO_0Koh.js} +14 -9
- package/dist/{supabase-BzK3lplm.js → supabase-kWQlkrHw.js} +4 -4
- package/dist/{supabase-config-B2sDFiwy.js → supabase-schemas-BglbAG2Z.js} +223 -34
- package/dist/{supautils-DXzJ2E2Q.js → supautils-C85NuESf.js} +2 -2
- package/dist/{support-session-B8xrW28B.js → support-session-DpzcGTuV.js} +1 -1
- package/dist/svelte/index.d.ts +5 -5
- package/dist/svelte/index.js +3 -3
- package/dist/svelte/runtime.d.ts +3 -3
- package/dist/svelte/runtime.js +1 -1
- package/dist/svelte/source.d.ts +5 -5
- package/dist/svelte/source.js +2 -2
- package/dist/sveltekit/index.d.ts +6 -6
- package/dist/sveltekit/index.js +2 -2
- package/dist/table-reads-AnHPrBp8.js +517 -0
- package/dist/table-reads-BviGc0L_.js +1 -0
- package/dist/{tables-BDqfipr1.js → tables-CDq0HVVq.js} +82 -26
- package/dist/tanstack-start/index.d.ts +6 -6
- package/dist/tanstack-start/index.js +2 -2
- package/dist/tenant-check-D7g9oNVH.js +105 -0
- package/dist/tenant-from-path-AKTSY7uR.js +65 -0
- package/dist/tenant-from-path-Dq3jkqjh.d.ts +25 -0
- package/dist/terminal/index.d.ts +6 -6
- package/dist/terminal/index.js +4 -4
- package/dist/testing/core.d.ts +1 -1
- package/dist/testing/core.js +1 -1
- package/dist/testing/fixtures/index.d.ts +5 -5
- package/dist/testing/fixtures/index.js +67 -3
- package/dist/testing/index.d.ts +31 -30
- package/dist/testing/index.js +51 -45
- package/dist/testing/saas/index.d.ts +5 -5
- 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/trpc/index.d.ts +6 -6
- package/dist/trpc/index.js +3 -3
- package/dist/{type-helpers-DHCQEPj8.d.ts → type-helpers-CUmJFGV6.d.ts} +3 -3
- package/dist/{types-PS10T9UK.d.ts → types-BKnUwgvx.d.ts} +5 -5
- package/dist/{types-CQF-oYSz.d.ts → types-BRECeQ2n.d.ts} +4 -4
- package/dist/{types-OzSal_K_.d.ts → types-BhBfMdQ5.d.ts} +3 -3
- package/dist/{types-DONLJQjY.d.ts → types-BsRf5rKk.d.ts} +3 -3
- package/dist/{types-Cakw89Wx.d.ts → types-CIzXPPV-.d.ts} +2 -2
- package/dist/{types-CWmBZtQN.d.ts → types-CbJ5mxXv.d.ts} +7 -2
- package/dist/{types-4wjWMSFM.d.ts → types-CjZscT16.d.ts} +4 -4
- package/dist/{types-XSfi6ihL.d.ts → types-DwoRXDvN.d.ts} +2 -2
- package/dist/{types-config-Cq72dArb.d.ts → types-config-DNIw_Gt5.d.ts} +82 -17
- package/dist/{types-BFtFaI1W.d.ts → types-euUv1wsO.d.ts} +1 -1
- package/dist/{types-D3tjoLwT.d.ts → types-h9W3CNC_.d.ts} +5 -5
- package/dist/{types-run-DG1H5vrX.d.ts → types-run-Bwn1MuW0.d.ts} +1 -1
- package/dist/{types-BdNdMix7.d.ts → types-vKKndyxx.d.ts} +2 -2
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +1 -1
- package/dist/{usage-DEUKhZ1n.js → usage-CW6xhRcV.js} +7 -235
- package/dist/usage-Ci7Glu-H.js +1 -0
- package/dist/{usage-B-xheuEq.js → usage-n4V2k_a6.js} +2 -2
- package/dist/{validation-error-BAO1W1yk.d.ts → validation-error-P4Z9HUuP.d.ts} +1 -1
- package/dist/{verify-BgZapMKs.js → verify-CKzngsUH.js} +16 -104
- package/dist/{version-cache-BXkl7-Fz.js → version-cache-BzK8dwJy.js} +14 -10
- package/dist/{vocabulary-FYgI_NoI.d.ts → vocabulary-DHfKPIC5.d.ts} +7 -0
- package/dist/vue/index.d.ts +6 -6
- package/dist/vue/index.js +2 -2
- package/dist/{waiter-hYLJXA7r.d.ts → waiter-BqUxSRxq.d.ts} +2 -2
- package/dist/warm-5yxlUmBh.js +32 -0
- package/dist/warm-BR-mrnY-.d.ts +16 -0
- package/dist/{watch-Bz_iEKlB.js → watch-C12Ub7x4.js} +11 -14
- package/dist/{watch-BNxvqCS4.js → watch-D-5ztqN8.js} +2 -2
- package/dist/watch-J1PfGMfb.js +1 -0
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +2 -2
- package/dist/{who-can-rUSZfLvI.js → who-can-CGVpM3fZ.js} +3 -3
- package/dist/workflow/index.d.ts +3 -3
- package/dist/workflow/index.js +4 -4
- package/dist/workflow-sdk/index.d.ts +17 -5
- package/dist/workflow-sdk/index.js +3 -1
- package/dist/{wrap-D-KvhzaC.d.ts → wrap-D8WtzrB7.d.ts} +2 -2
- package/package.json +20 -16
- package/schemas/catalog-v2.json +6 -0
- package/schemas/snapshot-v2.json +557 -0
- package/schemas/supabase-manifest-v1.json +156 -15
- package/skills/permdock/SKILL.md +1 -1
- package/skills/permdock-agents/references/runtimes.md +1 -1
- package/skills/permdock-credentials/references/tokens-keys-links.md +1 -1
- package/skills/permdock-data/references/queries-and-rls.md +2 -2
- package/skills/permdock-tenancy/SKILL.md +4 -4
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -1
- package/dist/annotate-routes-BvSuEht3.js +0 -75
- package/dist/annotate-uZVGIRym.js +0 -25
- package/dist/better-supabase-DSbs4MtQ.js +0 -201
- package/dist/catalog-DCjJIl3n.js +0 -1
- package/dist/claims-size-DcjhvUv5.js +0 -58
- package/dist/codemod-Ob71iPQh.js +0 -35
- package/dist/collect-XcoQRyiA.js +0 -1
- package/dist/config-iyy90IOU.js +0 -143
- package/dist/deciding-columns-BnglEKqU.js +0 -143
- package/dist/evaluator-Dlhn2d7D.js +0 -2
- package/dist/flags-C0e-BzGW.js +0 -112
- package/dist/gen-C_RJoGZB.js +0 -1
- package/dist/grants-Dn6zwfqo.js +0 -139
- package/dist/load-BPzIqlGB.js +0 -1
- package/dist/model-B0rrUh6J.js +0 -188
- package/dist/output-files-aPXXhV4q.js +0 -1
- package/dist/powersync-f-6y8sCk.js +0 -1
- package/dist/pull-CT7wu2uo.js +0 -1
- package/dist/rbac-BJTUGJum.js +0 -90
- package/dist/replay-ClGIMp5p.d.ts +0 -3
- package/dist/run-DKUZT8Cc.js +0 -1
- package/dist/snapshot-compact-CwAop_6C.js +0 -119
- package/dist/snapshot-size-B_chu2c1.js +0 -1
- package/dist/supabase-hook-CcmjiBsh.js +0 -2
- package/dist/usage-BRjoZ-vo.js +0 -1
- package/dist/watch-CGLmIdld.js +0 -1
- package/schemas/snapshot-v1.json +0 -329
|
@@ -1,37 +1,112 @@
|
|
|
1
|
-
import { c as listPermissions, u as renamedKeys } from "./permission-registry-
|
|
1
|
+
import { c as listPermissions, u as renamedKeys } from "./permission-registry-DstT40VS.js";
|
|
2
2
|
import { t as policyRowConditionKeys } from "./row-conditions-DwIJocfQ.js";
|
|
3
3
|
import { a as describeError, i as configError, o as exitCodeOfError } from "./errors-DgLOqc6j.js";
|
|
4
|
-
import {
|
|
4
|
+
import { i as withSchemaDefaults } from "./schema-tables-Ba9LE_XB.js";
|
|
5
|
+
import { r as isRecord, t as compact } from "./compact-C4LFuqbW.js";
|
|
6
|
+
import { n as supabaseDir } from "./supabase-dir-0lxKbrYu.js";
|
|
7
|
+
import { a as parseSqlFile, f as stringValues, g as statementRanges, l as readRelation, m as splitUndiffed, o as parseSqlLenient, t as SqlSyntaxError } from "./ast-Dnm2TOHN.js";
|
|
8
|
+
import { n as loadBsbSql, r as schemaSqlFiles } from "./bsb-access-Bcw6GrQm.js";
|
|
9
|
+
import { $ as graphSql, D as seedSql, N as guardAuthAdminGrants, P as unguardAuthAdminGrants, S as accessSql, T as helpersSql, Y as closureBackfillSql, c as permissionHelpersSql, d as permittedByPermissionHelper, i as tableNames, o as PERMISSION_HELPERS, r as tableNameOf, s as checkName, u as permissionKeysHelper } from "./tables-CDq0HVVq.js";
|
|
5
10
|
import { i as qualifySqlTable } from "./sql-T4GaBh9X.js";
|
|
6
|
-
import {
|
|
7
|
-
import { a as CANDIDATES, c as rowHelpersSql,
|
|
8
|
-
import { t as policyFromCatalog } from "./policy-from-catalog-
|
|
9
|
-
import { t as fetchProjectPolicy } from "./pull-
|
|
10
|
-
import { c as requirePolicy } from "./load-
|
|
11
|
-
import {
|
|
12
|
-
import { a as nonEmptyOr } from "./output-BI85V6hu.js";
|
|
11
|
+
import { a as tableFor, d as pruneIndexTargets, f as readTableIndexFacts, i as inferredCommand, l as indexTargets, r as compileGrants, u as indexesSql } from "./compile-BXKYYmT1.js";
|
|
12
|
+
import { a as CANDIDATES, c as rowHelpersSql, i as buildContext, l as rowSetSql, n as isRefusal, o as inheritTargets, r as splitsPart, s as levelKeys, t as generateOptions } from "./generate-options-DiR4r_sk.js";
|
|
13
|
+
import { t as policyFromCatalog } from "./policy-from-catalog-_zwn1sNj.js";
|
|
14
|
+
import { t as fetchProjectPolicy } from "./pull-BaB401Bk.js";
|
|
15
|
+
import { c as requirePolicy } from "./load-m7jmit3y.js";
|
|
16
|
+
import { o as nonEmptyOr } from "./output-C7EPeSZj.js";
|
|
13
17
|
import { i as INDEXES_MARKER, n as GRANTS_MARKER, o as SEEDS_MARKER, t as BACKFILL_MARKER } from "./markers-C-kThnKN.js";
|
|
14
|
-
import { G as graphHelper,
|
|
18
|
+
import { G as graphHelper, K as graphSqlName, U as BOOTSTRAP_PERMISSIONS, lt as scopeSources, rt as memberIdsHelper, st as permittedIdsHelper, ut as scopeTable } from "./interactive-only-Dqww0ABO.js";
|
|
15
19
|
import { a as quoteIdent, c as quoteTable, i as qualified$1, o as quoteLiteral, s as quoteQualified } from "./quote-BKrTBbcH.js";
|
|
16
|
-
import {
|
|
17
|
-
import { a as supabaseHookSql, c as asideAuthzReceive,
|
|
18
|
-
import { i as assignmentSql, n as ownershipSql } from "./ownership-
|
|
20
|
+
import { b as idTypeOf, f as subjectIdSql, l as sessionLiveHelperSql, t as SESSION_LIVE_HELPER, u as subjectClaimJsonSql, x as scopeTypeOf } from "./subject-CrldGifz.js";
|
|
21
|
+
import { a as supabaseHookSql, c as asideAuthzReceive, f as declarativeSql, t as grantsLabel, u as approvalsSql } from "./hook-sql-D-abRHut.js";
|
|
22
|
+
import { i as assignmentSql, n as ownershipSql } from "./ownership-Csk9C3Js.js";
|
|
23
|
+
import { r as rebuildPlan, t as DROPPED_LIST } from "./custom-role-rebuild-BK73tPib.js";
|
|
19
24
|
import { p as scopeField } from "./tenancy-B5Xxt9Sc.js";
|
|
20
|
-
import { i as
|
|
21
|
-
import { t as supautilsRejections } from "./supautils-
|
|
22
|
-
import { a as fieldViewsSql, c as ACTOR_MAY_WRITE, d as assemblePolicies, i as fieldViews, l as actorMayWriteCall, m as readOnlyActorPolicies, n as columnGrantSql, o as rowBranches, p as readOnlyActorKinds, r as columnRevokeSql, u as actorMayWriteSql } from "./fields-
|
|
25
|
+
import { c as breakGlassKey, i as rbacScaffold, l as collectGrants, s as breakGlassHolder } from "./rbac-mblGDx-Z.js";
|
|
26
|
+
import { t as supautilsRejections } from "./supautils-C85NuESf.js";
|
|
27
|
+
import { a as fieldViewsSql, c as ACTOR_MAY_WRITE, d as assemblePolicies, i as fieldViews, l as actorMayWriteCall, m as readOnlyActorPolicies, n as columnGrantSql, o as rowBranches, p as readOnlyActorKinds, r as columnRevokeSql, u as actorMayWriteSql } from "./fields-y_PSRCyJ.js";
|
|
23
28
|
import { l as isFieldRelation } from "./resource-relations-Ck5sjYQR.js";
|
|
24
29
|
import { c as rootScope } from "./scopes-B-KX9EI8.js";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
30
|
+
import { o as rootName, r as HELPERS, t as CUSTOM_ROLES } from "./shared-C6_T7QUo.js";
|
|
31
|
+
import { n as permissionHoldersSql } from "./resolve-names-Cth1UQ-8.js";
|
|
32
|
+
import { n as byKey } from "./compare-8SNJN-9U.js";
|
|
27
33
|
import { i as dateAt } from "./time-r0CKBm57.js";
|
|
28
|
-
import { _ as writeOutputFiles, a as isSeedsDirectory, d as pgDeltaPath, g as underSchemaDir, h as serviceRel, l as parseSplit, m as seedsMigration, n as dataMigrationFile, p as seedDeltaNote, r as driftOf, u as partPath } from "./output-files-
|
|
29
|
-
import {
|
|
30
|
-
import { a as splitUndiffed } from "./deciding-columns-BnglEKqU.js";
|
|
34
|
+
import { _ as writeOutputFiles, a as isSeedsDirectory, d as pgDeltaPath, g as underSchemaDir, h as serviceRel, l as parseSplit, m as seedsMigration, n as dataMigrationFile, p as seedDeltaNote, r as driftOf, u as partPath } from "./output-files-8lfALMSU.js";
|
|
35
|
+
import { c as readSupabaseConfig, n as resolveSchemas } from "./supabase-schemas-BglbAG2Z.js";
|
|
31
36
|
import { o as sqlFiles } from "./files-DAR51W3J.js";
|
|
32
37
|
import { n as MIGRATION_DIRS } from "./constants-PCJiir_3.js";
|
|
33
38
|
import { readFileSync } from "node:fs";
|
|
34
|
-
import { basename } from "node:path";
|
|
39
|
+
import { basename, join, relative, sep } from "node:path";
|
|
40
|
+
// src/cli/sql/schema-writes.ts
|
|
41
|
+
const WRITES = {
|
|
42
|
+
insert: ["insert"],
|
|
43
|
+
update: ["update"],
|
|
44
|
+
delete: ["delete"],
|
|
45
|
+
all: [
|
|
46
|
+
"insert",
|
|
47
|
+
"update",
|
|
48
|
+
"delete"
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
function clientRole(role) {
|
|
52
|
+
const spec = isRecord(role) ? role["RoleSpec"] : void 0;
|
|
53
|
+
if (!isRecord(spec)) return false;
|
|
54
|
+
return spec["roletype"] === "ROLESPEC_PUBLIC" || spec["rolename"] === "authenticated";
|
|
55
|
+
}
|
|
56
|
+
function writePolicy(node) {
|
|
57
|
+
if (node.kind !== "CreatePolicyStmt" || node.node["permissive"] !== true) return;
|
|
58
|
+
const commands = WRITES[String(node.node["cmd_name"])];
|
|
59
|
+
const roles = Array.isArray(node.node["roles"]) ? node.node["roles"] : [];
|
|
60
|
+
const relation = node.node["table"];
|
|
61
|
+
if (commands === void 0 || !roles.some((role) => clientRole(role)) || !isRecord(relation)) return;
|
|
62
|
+
return {
|
|
63
|
+
table: `${typeof relation["schemaname"] === "string" ? relation["schemaname"] : "public"}.${String(relation["relname"])}`,
|
|
64
|
+
commands
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** The tables whose `@bsb access` tag sets `actor-guard`. */
|
|
68
|
+
async function guardedByTag(cwd, files) {
|
|
69
|
+
const bsb = await loadBsbSql(cwd);
|
|
70
|
+
const out = /* @__PURE__ */ new Set();
|
|
71
|
+
if (bsb === void 0) return out;
|
|
72
|
+
for (const file of files) for (const entry of bsb.tableTagComments(readFileSync(file, "utf8"))) if (bsb.parseBsbComment(entry.comment).tags.some((tag) => tag.name === "access" && tag.args["actor-guard"] === true)) out.add(`${entry.schema}.${entry.name}`);
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The tables in `dir` (default `supabase/schemas`) whose permissive policies
|
|
77
|
+
* let `authenticated` or `public` write, with the write commands, sorted. On a
|
|
78
|
+
* table whose `@bsb access` tag carries `actor-guard`, only `delete` stays: the
|
|
79
|
+
* tag guards `insert` and `update`. A file that does not parse is skipped.
|
|
80
|
+
*/
|
|
81
|
+
async function schemaWrites(cwd, dir = `${supabaseDir(cwd)}/schemas`) {
|
|
82
|
+
const files = schemaSqlFiles(join(cwd, dir));
|
|
83
|
+
const found = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const file of files) {
|
|
85
|
+
let nodes;
|
|
86
|
+
try {
|
|
87
|
+
nodes = await parseSqlFile(readFileSync(file, "utf8"));
|
|
88
|
+
} catch (cause) {
|
|
89
|
+
if (cause instanceof SqlSyntaxError) continue;
|
|
90
|
+
throw cause;
|
|
91
|
+
}
|
|
92
|
+
for (const node of nodes) {
|
|
93
|
+
const write = writePolicy(node);
|
|
94
|
+
if (write !== void 0) found.set(write.table, /* @__PURE__ */ new Set([...found.get(write.table) ?? [], ...write.commands]));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const tagged = await guardedByTag(cwd, files);
|
|
98
|
+
return [...found].toSorted(([left], [right]) => left.localeCompare(right)).flatMap(([table, commands]) => {
|
|
99
|
+
const kept = [
|
|
100
|
+
"insert",
|
|
101
|
+
"update",
|
|
102
|
+
"delete"
|
|
103
|
+
].filter((command) => commands.has(command) && !(tagged.has(table) && command !== "delete"));
|
|
104
|
+
return kept.length === 0 ? [] : [{
|
|
105
|
+
table,
|
|
106
|
+
commands: kept
|
|
107
|
+
}];
|
|
108
|
+
});
|
|
109
|
+
}
|
|
35
110
|
// src/cli/rls/bindings.ts
|
|
36
111
|
/**
|
|
37
112
|
* The table each resource with row policies binds to. With `helpersOnly`, a
|
|
@@ -73,9 +148,15 @@ function missingBindings(bindings, columns) {
|
|
|
73
148
|
return bindings.filter((binding) => binding.inferred && columns[binding.table] === void 0);
|
|
74
149
|
}
|
|
75
150
|
// src/cli/rls/trigger-notes.ts
|
|
76
|
-
const
|
|
151
|
+
const IDENT$2 = String.raw`(?:"(?:[^"]|"")+"|[\w$]+)`;
|
|
152
|
+
/**
|
|
153
|
+
* A statement that is a `create [or replace] [constraint] trigger`. The input
|
|
154
|
+
* is one statement with its comments blanked, so a trigger inside a function
|
|
155
|
+
* body or a comment never matches.
|
|
156
|
+
*/
|
|
157
|
+
const CREATE = new RegExp(String.raw`^create\s+(?:or\s+replace\s+)?(?:constraint\s+)?trigger\s+(${IDENT$2})\s[\s\S]*?\bon\s+(${IDENT$2}(?:\s*\.\s*${IDENT$2})?)`, "iu");
|
|
77
158
|
function unquote(name) {
|
|
78
|
-
return name.replaceAll("\"", "");
|
|
159
|
+
return name.split(/\s*\.\s*/u).map((part) => part.startsWith("\"") ? part.slice(1, -1).replaceAll("\"\"", "\"") : part).join(".");
|
|
79
160
|
}
|
|
80
161
|
function reasonOf(name) {
|
|
81
162
|
if (name === "permdock_custom_role_name_guard") return "customRoleWrites.roles: a tenant role cannot take a declared or shared role's name";
|
|
@@ -87,15 +168,21 @@ function reasonOf(name) {
|
|
|
87
168
|
if (name.startsWith("permdock_closure")) return "the relationship closure table follows its source table";
|
|
88
169
|
return "generated by rls generate";
|
|
89
170
|
}
|
|
90
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* The triggers `sql` creates, in order, each with the option behind it. It
|
|
173
|
+
* reads statements from the lexer-correct splitter, not libpg_query, because
|
|
174
|
+
* `rls generate` calls it on every run and loading libpg_query costs the cold
|
|
175
|
+
* run about 150 ms and 110 MB.
|
|
176
|
+
*/
|
|
91
177
|
function generatedTriggers(sql) {
|
|
92
178
|
const found = [];
|
|
93
|
-
for (const
|
|
94
|
-
const
|
|
95
|
-
|
|
179
|
+
for (const statement of statementRanges(sql)) {
|
|
180
|
+
const match = CREATE.exec(statement.text);
|
|
181
|
+
if (match === null) continue;
|
|
182
|
+
const name = unquote(match[1] ?? "");
|
|
96
183
|
found.push({
|
|
97
184
|
name,
|
|
98
|
-
table,
|
|
185
|
+
table: unquote(match[2] ?? ""),
|
|
99
186
|
reason: reasonOf(name)
|
|
100
187
|
});
|
|
101
188
|
}
|
|
@@ -214,6 +301,14 @@ function describeExplain(explain) {
|
|
|
214
301
|
lines.push("", "generated triggers:");
|
|
215
302
|
for (const trigger of explain.triggers) lines.push(` ${trigger.name} on ${trigger.table} (${trigger.reason})`);
|
|
216
303
|
}
|
|
304
|
+
if (explain.tagged !== void 0) {
|
|
305
|
+
lines.push("", "@bsb access policies (rendered by better-supabase):");
|
|
306
|
+
for (const policy of explain.tagged) lines.push(` ${policy.name} on ${policy.table} (${policy.operation}): ${policy.tenantColumn} in the ids of ${policy.key}`);
|
|
307
|
+
}
|
|
308
|
+
if (explain.rowTables !== void 0) {
|
|
309
|
+
lines.push("", "tables read per user (share: row):");
|
|
310
|
+
for (const table of explain.rowTables) lines.push(` ${table.table}: ${table.rules.join(", ")}${table.reason === void 0 ? "" : `; ${table.reason}`}`);
|
|
311
|
+
}
|
|
217
312
|
return lines.join("\n");
|
|
218
313
|
}
|
|
219
314
|
// src/cli/rls/generate-load.ts
|
|
@@ -346,7 +441,7 @@ select ${fn}();
|
|
|
346
441
|
* contract.
|
|
347
442
|
*/
|
|
348
443
|
const BREAK_GLASS_AUDIT = "permdock_break_glass_audit";
|
|
349
|
-
const IDENT$
|
|
444
|
+
const IDENT$1 = /^[a-z][a-z0-9_]*$/u;
|
|
350
445
|
/**
|
|
351
446
|
* The resources a `breakGlass` grant targets, with the table each reads. A
|
|
352
447
|
* break-glass grant is non-portable, so `compileGrants` never turns it into a
|
|
@@ -403,7 +498,7 @@ function rowsFilter(ctx, entry) {
|
|
|
403
498
|
return arms.length === 0 ? "false" : [...new Set(arms)].join("\n or ");
|
|
404
499
|
}
|
|
405
500
|
function functionName$1(resource) {
|
|
406
|
-
if (!IDENT$
|
|
501
|
+
if (!IDENT$1.test(resource)) throw configError(`PermDock CLI: unsafe break-glass resource '${resource}'`);
|
|
407
502
|
return `permdock_break_glass_${resource}`;
|
|
408
503
|
}
|
|
409
504
|
function auditSql$1(ctx) {
|
|
@@ -675,11 +770,11 @@ function defaultOut(target) {
|
|
|
675
770
|
function isOwner$1(entry) {
|
|
676
771
|
return typeof entry === "object" && !("tableOf" in entry);
|
|
677
772
|
}
|
|
678
|
-
function bare
|
|
773
|
+
function bare(table) {
|
|
679
774
|
return table.slice(table.lastIndexOf(".") + 1);
|
|
680
775
|
}
|
|
681
776
|
function policyName$1(table, command) {
|
|
682
|
-
const full = `permdock_follow_${bare
|
|
777
|
+
const full = `permdock_follow_${bare(table).replaceAll(/[^A-Za-z0-9]+/gu, "_").replaceAll(/^_|_$/gu, "")}_${command}`;
|
|
683
778
|
if (new TextEncoder().encode(full).length > 63) throw configError(`PermDock CLI: the follows policy name ${full} is longer than Postgres's 63 bytes; shorten '${table}'`);
|
|
684
779
|
return full;
|
|
685
780
|
}
|
|
@@ -698,7 +793,7 @@ function followPolicies(ctx, policy, tables) {
|
|
|
698
793
|
if (node === void 0) throw configError(`PermDock CLI: rls.tables.${resource}.follows names a resource the policy does not declare`);
|
|
699
794
|
if (graphSqlName(resource) === void 0) throw configError(`PermDock CLI: rls.tables.${resource} is not a SQL name, so follows cannot call can_${resource}`);
|
|
700
795
|
for (const [child, fk] of Object.entries(entry.follows)) {
|
|
701
|
-
const childName = quoteIdent(bare
|
|
796
|
+
const childName = quoteIdent(bare(child));
|
|
702
797
|
const column = quoteIdent(fk);
|
|
703
798
|
const exists = (action) => `${childName}.${column} = any(array(${rowSetSql(ctx, policy, node, `${resource}.${action}`)}))`;
|
|
704
799
|
for (const [command, action, place] of [
|
|
@@ -819,7 +914,7 @@ function folderOf$1(policy, tables, table) {
|
|
|
819
914
|
first ??= resource;
|
|
820
915
|
if (node.parent?.resource === resource) folders.push(resource);
|
|
821
916
|
}
|
|
822
|
-
if (resource === bare
|
|
917
|
+
if (resource === bare(table)) byName = resource;
|
|
823
918
|
}
|
|
824
919
|
if (folders.length > 1) throw configError(`PermDock CLI: rls.treeValues.${table} maps to more than one self-parented resource (${folders.join(", ")}), so the folder is ambiguous`);
|
|
825
920
|
return folders[0] ?? first ?? byName;
|
|
@@ -1086,9 +1181,17 @@ function withHelperTables(sql, helperTables) {
|
|
|
1086
1181
|
* `rls.tables` names. A resource it does not name has no known table, so its
|
|
1087
1182
|
* write commands get a warning instead.
|
|
1088
1183
|
*/
|
|
1089
|
-
function helpersOnlyActorGuards(guards, tables, actorMayWrite, warnings) {
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1184
|
+
function helpersOnlyActorGuards(guards, tables, writes, passes, actorMayWrite, warnings) {
|
|
1185
|
+
const fromSchema = readOnlyActorPolicies(writes.flatMap((write) => write.commands.map((command) => ({
|
|
1186
|
+
name: "",
|
|
1187
|
+
table: write.table,
|
|
1188
|
+
command,
|
|
1189
|
+
effect: "allow",
|
|
1190
|
+
roles: ["authenticated"]
|
|
1191
|
+
}))), passes);
|
|
1192
|
+
const named = /* @__PURE__ */ new Set([...Object.values(tableNames(tables) ?? {}).map((table) => qualifySqlTable(table)), ...writes.map((write) => write.table)]);
|
|
1193
|
+
const seen = new Set(fromSchema.map((guard) => `${qualifySqlTable(guard.table)}\u0000${guard.command}`));
|
|
1194
|
+
const kept = [...guards.filter((guard) => named.has(qualifySqlTable(guard.table)) && !seen.has(`${qualifySqlTable(guard.table)}\u0000${guard.command}`)), ...fromSchema];
|
|
1092
1195
|
const unmapped = [...new Set(guards.filter((guard) => !named.has(qualifySqlTable(guard.table))).map((guard) => qualifySqlTable(guard.table)))].toSorted();
|
|
1093
1196
|
if (unmapped.length > 0) warnings.push(`rls.readOnlyActors with --helpers-only writes read-only actor policies only on tables rls.tables names; for ${unmapped.join(", ")}, name the table in rls.tables, or add \`and (select ${actorMayWrite}())\` to each hand-written insert, update and delete policy`);
|
|
1094
1197
|
return kept;
|
|
@@ -1122,7 +1225,7 @@ function generatePolicies(input, policy, options, built, warnings) {
|
|
|
1122
1225
|
...policyName === void 0 ? {} : { name: policyName }
|
|
1123
1226
|
});
|
|
1124
1227
|
const actorKinds = readOnlyActorKinds(rls?.readOnlyActors);
|
|
1125
|
-
const actorGuards = actorKinds === void 0 || !helpersOnly ? [] : helpersOnlyActorGuards(readOnlyActorPolicies(assembled, actorMayWriteCall(ctx)), rls?.tables, qualified$1(ctx, ACTOR_MAY_WRITE), warnings);
|
|
1228
|
+
const actorGuards = actorKinds === void 0 || !helpersOnly ? [] : helpersOnlyActorGuards(readOnlyActorPolicies(assembled, actorMayWriteCall(ctx)), rls?.tables, input.schemaWrites ?? [], actorMayWriteCall(ctx), qualified$1(ctx, ACTOR_MAY_WRITE), warnings);
|
|
1126
1229
|
const withActors = (items) => actorKinds === void 0 ? items : [...items, ...readOnlyActorPolicies(items, actorMayWriteCall(ctx))];
|
|
1127
1230
|
let tablePolicies;
|
|
1128
1231
|
try {
|
|
@@ -1191,11 +1294,11 @@ function bitsetSql(indexes, bytes) {
|
|
|
1191
1294
|
* helper it calls answers for the caller only. Execute belongs to
|
|
1192
1295
|
* `authenticated`.
|
|
1193
1296
|
*/
|
|
1194
|
-
function bootstrapPermissionsSql(ctx, keys
|
|
1297
|
+
function bootstrapPermissionsSql(ctx, keys) {
|
|
1195
1298
|
const fn = qualified$1(ctx, BOOTSTRAP_PERMISSIONS);
|
|
1196
1299
|
const root = rootName(ctx);
|
|
1197
1300
|
const bytes = Math.ceil(keys.length / 8);
|
|
1198
|
-
const
|
|
1301
|
+
const view = qualified$1(ctx, PERMISSION_HELPERS.keys);
|
|
1199
1302
|
const memberIds = qualified$1(ctx, memberIdsHelper(root));
|
|
1200
1303
|
const held = qualified$1(ctx, checkName(permissionKeysHelper(root)));
|
|
1201
1304
|
return `-- the caller's permissions in better-supabase's compact BootstrapPermissionsWire: the policy's keys once, a bitset per ${root} the caller is a member of (p_tenant alone when given) and one for platform
|
|
@@ -1216,12 +1319,15 @@ as $$
|
|
|
1216
1319
|
),
|
|
1217
1320
|
pdk_p(n) as (
|
|
1218
1321
|
select k.n from ${held}(null::${scopeTypeOf(ctx, root)}) h(key) join pdk_k k on k.key = h.key
|
|
1219
|
-
where
|
|
1322
|
+
where exists (
|
|
1323
|
+
select 1 from ${view} v
|
|
1324
|
+
where v.permission = k.key and v.scope = 'global' and v.effect = 'allow' and not v.conditioned
|
|
1325
|
+
)
|
|
1220
1326
|
)
|
|
1221
1327
|
select jsonb_strip_nulls(jsonb_build_object(
|
|
1222
1328
|
'apiVersion', 1,
|
|
1223
1329
|
'form', 'compact',
|
|
1224
|
-
'keys',
|
|
1330
|
+
'keys', coalesce((select jsonb_agg(k.key order by k.n) from pdk_k k), '[]'::jsonb),
|
|
1225
1331
|
'tenants', coalesce((
|
|
1226
1332
|
select jsonb_object_agg(t.id::text, ${bitsetSql(`select k.n from ${held}(t.id) h(key) join pdk_k k on k.key = h.key`, bytes)})
|
|
1227
1333
|
from pdk_t t
|
|
@@ -1265,7 +1371,8 @@ function ruleIndexTargets(policy, config) {
|
|
|
1265
1371
|
if (managers !== void 0) {
|
|
1266
1372
|
const tenant = managers.tenant === void 0 ? [] : [managers.tenant];
|
|
1267
1373
|
add(managers.table, [managers.user, ...tenant]);
|
|
1268
|
-
add(managers.table, [managers.
|
|
1374
|
+
if ("reportsTo" in managers) add(managers.table, [managers.reportsTo, ...tenant]);
|
|
1375
|
+
else add(managers.table, [managers.manager, ...tenant]);
|
|
1269
1376
|
}
|
|
1270
1377
|
return out;
|
|
1271
1378
|
}
|
|
@@ -1286,7 +1393,7 @@ function mergeIndexTargets(...lists) {
|
|
|
1286
1393
|
});
|
|
1287
1394
|
}
|
|
1288
1395
|
// src/cli/rls/shims.ts
|
|
1289
|
-
const NAME
|
|
1396
|
+
const NAME = /^[a-z_][a-z0-9_]*$/u;
|
|
1290
1397
|
/**
|
|
1291
1398
|
* The key a legacy caller passes, mapped the way `rls migrate` maps it: `keys`
|
|
1292
1399
|
* and `renamed` exactly, then the longest `prefixes` entry.
|
|
@@ -1437,7 +1544,7 @@ function shimsSql(ctx, config, shims, renamed, grants) {
|
|
|
1437
1544
|
};
|
|
1438
1545
|
const chunks = [`-- permdock shims: legacy helper names over the permdock helpers; drop each once doctor reports no caller (PD056)`];
|
|
1439
1546
|
for (const [name, helper] of Object.entries(config.helpers).toSorted(byKey)) {
|
|
1440
|
-
if (!NAME
|
|
1547
|
+
if (!NAME.test(name)) throw configError(`PermDock CLI: unsafe rls.migrate helper name '${name}'`);
|
|
1441
1548
|
chunks.push(shim(ctx, config, keys, `${quoteIdent(schema)}.${name}`, helper));
|
|
1442
1549
|
}
|
|
1443
1550
|
return `${chunks.join("\n\n")}\n`;
|
|
@@ -1455,7 +1562,7 @@ const AUDITED = [
|
|
|
1455
1562
|
CUSTOM_ROLES.includes,
|
|
1456
1563
|
"user_roles"
|
|
1457
1564
|
];
|
|
1458
|
-
const IDENT
|
|
1565
|
+
const IDENT = /^[a-z_][a-z0-9_$]*$/u;
|
|
1459
1566
|
/** The tables `sql` creates in `schema`, by name without the schema. */
|
|
1460
1567
|
function generatedTables(sql, schema) {
|
|
1461
1568
|
const prefix = `create table if not exists ${quoteIdent(schema)}.`;
|
|
@@ -1517,7 +1624,7 @@ function auditSql(audit, schema, tables) {
|
|
|
1517
1624
|
if (listed !== void 0) for (const table of listed) knownTable(table, tables, "rls.audit.tables");
|
|
1518
1625
|
const targets = listed ?? AUDITED.filter((table) => tables.includes(table));
|
|
1519
1626
|
const args = Object.entries(audit.args ?? {}).map(([name, value]) => {
|
|
1520
|
-
if (!IDENT
|
|
1627
|
+
if (!IDENT.test(name)) throw configError(`${PREFIX}: rls.audit.args names ${JSON.stringify(name)}, which is not a lower-case parameter name`);
|
|
1521
1628
|
return `, ${quoteIdent(name)} => ${quoteLiteral(value)}`;
|
|
1522
1629
|
});
|
|
1523
1630
|
if (targets.length === 0) return "";
|
|
@@ -1665,7 +1772,7 @@ function preambleSql(input, policy, options, built, generated, jsonSchema, warni
|
|
|
1665
1772
|
...rls?.trustedReaders === void 0 ? {} : { trustedReaders: rls.trustedReaders }
|
|
1666
1773
|
}),
|
|
1667
1774
|
permissionHelpersSql(ctx, grants, renamed, anonExecute),
|
|
1668
|
-
ctx.dialect === "supabase" ? bootstrapPermissionsSql(ctx, listPermissions(policy.permissions).map((leaf) => leaf.key).toSorted()
|
|
1775
|
+
ctx.dialect === "supabase" ? bootstrapPermissionsSql(ctx, listPermissions(policy.permissions).map((leaf) => leaf.key).toSorted()) : void 0,
|
|
1669
1776
|
nonEmptyOr(permissionHoldersSql(ctx), void 0),
|
|
1670
1777
|
actorKinds === void 0 ? void 0 : actorMayWriteSql(ctx, actorKinds),
|
|
1671
1778
|
usesLiveSession ? sessionLiveHelperSql(ctx) : void 0,
|
|
@@ -1803,7 +1910,8 @@ function generateSql(input, policy, options, built, warnings) {
|
|
|
1803
1910
|
...childPolicies.length === 0 ? {} : { follows: dialectRoles(emitSql(childPolicies, "", force, []), ctx.dialect) },
|
|
1804
1911
|
...realtimePolicies === void 0 ? {} : { realtimePolicies: dialectRoles(realtimePolicies, ctx.dialect) },
|
|
1805
1912
|
...storagePolicies === void 0 ? {} : { storagePolicies: dialectRoles(storagePolicies, ctx.dialect) },
|
|
1806
|
-
helpers: dialectRoles(
|
|
1913
|
+
helpers: dialectRoles(emitSql([], preamble, false, helpersOnly ? views : []), ctx.dialect),
|
|
1914
|
+
...actorGuards === void 0 ? {} : { readOnlyActors: dialectRoles(actorGuards, ctx.dialect) },
|
|
1807
1915
|
seeds: `${SEEDS_MARKER} schema=${built.schema}\n${seedsBody(ctx, built.schema, generated.compiled.rolePermissions, closureBackfillSql(ctx, built.graph, tableNames(rls?.tables)))}\n${seedsSplit ? audit : ""}`,
|
|
1808
1916
|
indexes: `${INDEXES_MARKER}\n${indexesSql(indexes)}\n`
|
|
1809
1917
|
})
|
|
@@ -1901,7 +2009,13 @@ function outputFiles(plan) {
|
|
|
1901
2009
|
const grants = [];
|
|
1902
2010
|
for (const part of split) switch (part) {
|
|
1903
2011
|
case "helpers": {
|
|
1904
|
-
const
|
|
2012
|
+
const ownFile = pgDelta !== void 0 && !placeholder && sql.readOnlyActors !== void 0;
|
|
2013
|
+
if (ownFile) files.push({
|
|
2014
|
+
part: "readOnlyActors",
|
|
2015
|
+
rel: `${pgDelta.schemaDir.replace(/\/$/u, "")}/permdock/read_only_actors.sql`,
|
|
2016
|
+
text: sql.readOnlyActors
|
|
2017
|
+
});
|
|
2018
|
+
const helpers = unguardAuthAdminGrants(ownFile ? sql.helpers : withHelperTables(sql.helpers, sql.readOnlyActors));
|
|
1905
2019
|
if (label === void 0) {
|
|
1906
2020
|
files.push({
|
|
1907
2021
|
part,
|
|
@@ -1923,11 +2037,11 @@ function outputFiles(plan) {
|
|
|
1923
2037
|
if (input.noSeeds === true) break;
|
|
1924
2038
|
const out = input.seedsOut;
|
|
1925
2039
|
if (out !== void 0 && isSeedsDirectory(input.cwd, out)) {
|
|
1926
|
-
const planned = seedsMigration(input.cwd, out, SEEDS_MARKER, seeds, input.io.now?.() ?? dateAt());
|
|
2040
|
+
const planned = seedsMigration(input.cwd, out, SEEDS_MARKER, seeds, input.io.now?.() ?? dateAt(), "seeds", [], { delta: true });
|
|
1927
2041
|
if (!planned.current || input.check) files.push({
|
|
1928
2042
|
part,
|
|
1929
2043
|
rel: planned.rel,
|
|
1930
|
-
text:
|
|
2044
|
+
text: planned.text
|
|
1931
2045
|
});
|
|
1932
2046
|
if (!planned.current && planned.delta !== void 0) input.io.stderr(`${seedDeltaNote(planned.delta)}\n`);
|
|
1933
2047
|
break;
|
|
@@ -2093,135 +2207,101 @@ function writeGenerated(plan) {
|
|
|
2093
2207
|
* indexes part or in a migration derived from it: it never counts as serving
|
|
2094
2208
|
* its own target.
|
|
2095
2209
|
*/
|
|
2096
|
-
const GENERATED_INDEX =
|
|
2097
|
-
const
|
|
2098
|
-
const NAME = String.raw`${IDENT}(?:\s*\.\s*${IDENT})?`;
|
|
2099
|
-
const CREATE_INDEX = new RegExp(String.raw`\bcreate\s+(?:unique\s+)?index\s+(?:concurrently\s+)?(?:if\s+not\s+exists\s+)?(?:${IDENT}\s+)?on\s+(?:only\s+)?(${NAME})\s*(?:using\s+\w+\s*)?\(`, "giu");
|
|
2100
|
-
const ADD_KEY = new RegExp(String.raw`\balter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(${NAME})\s+add\s+(?:constraint\s+${IDENT}\s+)?(?:unique|primary\s+key)\s*(?:nulls\s+not\s+distinct\s*)?\(`, "giu");
|
|
2101
|
-
const CREATE_TABLE = new RegExp(String.raw`\bcreate\s+(?:unlogged\s+|temp(?:orary)?\s+)?table\s+(?:if\s+not\s+exists\s+)?(${NAME})\s*\(`, "giu");
|
|
2102
|
-
const TABLE_NAME = new RegExp(String.raw`\bcreate\s+(?:unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(${NAME})`, "giu");
|
|
2103
|
-
const TABLE_KEY = new RegExp(String.raw`^(?:constraint\s+${IDENT}\s+)?(?:unique|primary\s+key)\s*(?:nulls\s+not\s+distinct\s*)?\(`, "iu");
|
|
2104
|
-
const COLUMN_KEY = new RegExp(String.raw`^(${IDENT})\s+[^,]*?\b(?:primary\s+key|unique)\b`, "iu");
|
|
2105
|
-
const NOT_A_COLUMN = /^(?:constraint|check|foreign|exclude|like)\b/iu;
|
|
2106
|
-
function bare(part) {
|
|
2107
|
-
const trimmed = part.trim();
|
|
2108
|
-
return trimmed.startsWith("\"") ? trimmed.slice(1, -1).replaceAll("\"\"", "\"") : trimmed.toLowerCase();
|
|
2109
|
-
}
|
|
2210
|
+
const GENERATED_INDEX = /^permdock_\w*_idx$/u;
|
|
2211
|
+
const KEY_CONSTRAINTS = /* @__PURE__ */ new Set(["CONSTR_PRIMARY", "CONSTR_UNIQUE"]);
|
|
2110
2212
|
/** `schema.table`, with `public` for an unqualified name. */
|
|
2111
|
-
function qualified(
|
|
2112
|
-
|
|
2113
|
-
return parts.length === 1 ? `public.${parts.join("")}` : parts.join(".");
|
|
2114
|
-
}
|
|
2115
|
-
function stripComments(sql) {
|
|
2116
|
-
return sql.replaceAll(/\/\*[\s\S]*?\*\//gu, " ").replaceAll(/--[^\n]*/gu, " ");
|
|
2117
|
-
}
|
|
2118
|
-
/**
|
|
2119
|
-
* The text between the `(` that ends `match` and its closing `)`, and the index
|
|
2120
|
-
* after it.
|
|
2121
|
-
*/
|
|
2122
|
-
function group(text, open) {
|
|
2123
|
-
let depth = 1;
|
|
2124
|
-
for (let index = open; index < text.length; index += 1) {
|
|
2125
|
-
const char = text[index];
|
|
2126
|
-
if (char === "'" || char === "\"") {
|
|
2127
|
-
const close = text.indexOf(char, index + 1);
|
|
2128
|
-
if (close === -1) return;
|
|
2129
|
-
index = close;
|
|
2130
|
-
} else if (char === "(") depth += 1;
|
|
2131
|
-
else if (char === ")") {
|
|
2132
|
-
depth -= 1;
|
|
2133
|
-
if (depth === 0) return {
|
|
2134
|
-
body: text.slice(open, index),
|
|
2135
|
-
end: index + 1
|
|
2136
|
-
};
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
function splitTop(body) {
|
|
2141
|
-
const items = [];
|
|
2142
|
-
let depth = 0;
|
|
2143
|
-
let from = 0;
|
|
2144
|
-
for (let index = 0; index < body.length; index += 1) {
|
|
2145
|
-
const char = body[index];
|
|
2146
|
-
if (char === "'" || char === "\"") index = Math.max(body.indexOf(char, index + 1), index);
|
|
2147
|
-
else if (char === "(") depth += 1;
|
|
2148
|
-
else if (char === ")") depth -= 1;
|
|
2149
|
-
else if (char === "," && depth === 0) {
|
|
2150
|
-
items.push(body.slice(from, index));
|
|
2151
|
-
from = index + 1;
|
|
2152
|
-
}
|
|
2153
|
-
}
|
|
2154
|
-
items.push(body.slice(from));
|
|
2155
|
-
return items.map((item) => item.trim());
|
|
2156
|
-
}
|
|
2157
|
-
/** The first capture group of a match; every pattern here captures it. */
|
|
2158
|
-
function captured(match) {
|
|
2159
|
-
return match.slice(1, 2).join("");
|
|
2160
|
-
}
|
|
2161
|
-
/** The index just past a match. */
|
|
2162
|
-
function endOf(match) {
|
|
2163
|
-
return match.index + match[0].length;
|
|
2213
|
+
function qualified(relation) {
|
|
2214
|
+
return `${relation.schema ?? "public"}.${relation.name}`;
|
|
2164
2215
|
}
|
|
2165
2216
|
/** The plain key columns of an index column list, cut at the first expression. */
|
|
2166
|
-
function
|
|
2217
|
+
function indexColumns(params) {
|
|
2167
2218
|
const columns = [];
|
|
2168
|
-
for (const item of
|
|
2169
|
-
const
|
|
2170
|
-
if (
|
|
2171
|
-
columns.push(
|
|
2219
|
+
for (const item of Array.isArray(params) ? params : []) {
|
|
2220
|
+
const element = isRecord(item) ? item["IndexElem"] : void 0;
|
|
2221
|
+
if (!isRecord(element) || typeof element["name"] !== "string") break;
|
|
2222
|
+
columns.push(element["name"]);
|
|
2172
2223
|
}
|
|
2173
2224
|
return columns;
|
|
2174
2225
|
}
|
|
2226
|
+
/** The key columns of a `primary key` or `unique` constraint node. */
|
|
2227
|
+
function constraintKeys(value) {
|
|
2228
|
+
const constraint = isRecord(value) ? value["Constraint"] : void 0;
|
|
2229
|
+
if (!isRecord(constraint) || !KEY_CONSTRAINTS.has(String(constraint["contype"]))) return;
|
|
2230
|
+
return [...stringValues(constraint["keys"])];
|
|
2231
|
+
}
|
|
2232
|
+
/** The `[table, columns]` keys one statement creates. */
|
|
2233
|
+
function statementKeys(statement) {
|
|
2234
|
+
const { node } = statement;
|
|
2235
|
+
const relation = readRelation(node["relation"]);
|
|
2236
|
+
if (relation === void 0) return [];
|
|
2237
|
+
const table = qualified(relation);
|
|
2238
|
+
switch (statement.kind) {
|
|
2239
|
+
case "IndexStmt": {
|
|
2240
|
+
const name = node["idxname"];
|
|
2241
|
+
return typeof name === "string" && GENERATED_INDEX.test(name) ? [] : [[table, indexColumns(node["indexParams"])]];
|
|
2242
|
+
}
|
|
2243
|
+
case "AlterTableStmt": return (Array.isArray(node["cmds"]) ? node["cmds"] : []).flatMap((item) => {
|
|
2244
|
+
const command = isRecord(item) ? item["AlterTableCmd"] : void 0;
|
|
2245
|
+
const keys = isRecord(command) && command["subtype"] === "AT_AddConstraint" ? constraintKeys(command["def"]) : void 0;
|
|
2246
|
+
return keys === void 0 ? [] : [[table, keys]];
|
|
2247
|
+
});
|
|
2248
|
+
case "CreateStmt": return (Array.isArray(node["tableElts"]) ? node["tableElts"] : []).flatMap((item) => {
|
|
2249
|
+
const tableKeys = constraintKeys(item);
|
|
2250
|
+
if (tableKeys !== void 0) return [[table, tableKeys]];
|
|
2251
|
+
const column = isRecord(item) ? item["ColumnDef"] : void 0;
|
|
2252
|
+
if (!isRecord(column) || typeof column["colname"] !== "string") return [];
|
|
2253
|
+
const name = column["colname"];
|
|
2254
|
+
return (Array.isArray(column["constraints"]) ? column["constraints"] : []).some((constraint) => constraintKeys(constraint) !== void 0) ? [[table, [name]]] : [];
|
|
2255
|
+
});
|
|
2256
|
+
default: return [];
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2175
2259
|
/**
|
|
2176
2260
|
* Key columns of each index, unique constraint and primary key the SQL creates,
|
|
2177
|
-
* per `schema.table`.
|
|
2261
|
+
* per `schema.table`. Indexes PermDock generated are left out.
|
|
2178
2262
|
*/
|
|
2179
|
-
function indexKeysFromSql(sql) {
|
|
2180
|
-
const text = stripComments(sql);
|
|
2263
|
+
async function indexKeysFromSql(sql) {
|
|
2181
2264
|
const keys = {};
|
|
2182
|
-
const
|
|
2183
|
-
if (columns.length > 0) (keys[qualified(table)] ??= []).push(columns);
|
|
2184
|
-
};
|
|
2185
|
-
for (const pattern of [CREATE_INDEX, ADD_KEY]) for (const match of text.matchAll(pattern)) {
|
|
2186
|
-
const found = group(text, endOf(match));
|
|
2187
|
-
if (found !== void 0) add(captured(match), keyColumns(found.body));
|
|
2188
|
-
}
|
|
2189
|
-
for (const match of text.matchAll(CREATE_TABLE)) {
|
|
2190
|
-
const found = group(text, endOf(match));
|
|
2191
|
-
if (found === void 0) continue;
|
|
2192
|
-
for (const item of splitTop(found.body)) if (TABLE_KEY.test(item)) {
|
|
2193
|
-
const inner = group(item, item.indexOf("(") + 1);
|
|
2194
|
-
if (inner !== void 0) add(captured(match), keyColumns(inner.body));
|
|
2195
|
-
} else if (!NOT_A_COLUMN.test(item)) {
|
|
2196
|
-
const column = COLUMN_KEY.exec(item)?.[1];
|
|
2197
|
-
if (column !== void 0) add(captured(match), [bare(column)]);
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2265
|
+
for (const statement of await parseSqlLenient(sql)) for (const [table, columns] of statementKeys(statement)) if (columns.length > 0) (keys[table] ??= []).push(columns);
|
|
2200
2266
|
return keys;
|
|
2201
2267
|
}
|
|
2202
2268
|
/**
|
|
2269
|
+
* The SQL files under the migration and schema folders of `cwd`, without the
|
|
2270
|
+
* `permdock` folders: other `generate` plugins write those during the same run,
|
|
2271
|
+
* so reading them would make the result depend on plugin order.
|
|
2272
|
+
*/
|
|
2273
|
+
function appSqlFiles(cwd) {
|
|
2274
|
+
return sqlFiles(cwd, [...MIGRATION_DIRS]).filter((file) => !relative(cwd, file).split(sep).includes("permdock"));
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2203
2277
|
* The index keys of the SQL files under the migration and schema folders of
|
|
2204
2278
|
* `cwd`.
|
|
2205
2279
|
*/
|
|
2206
|
-
function indexKeysFromProject(cwd) {
|
|
2280
|
+
async function indexKeysFromProject(cwd) {
|
|
2207
2281
|
const all = {};
|
|
2208
|
-
for (const file of
|
|
2209
|
-
const keys = indexKeysFromSql(readFileSync(file, "utf8")
|
|
2282
|
+
for (const file of appSqlFiles(cwd)) {
|
|
2283
|
+
const keys = await indexKeysFromSql(readFileSync(file, "utf8"));
|
|
2210
2284
|
for (const [table, list] of Object.entries(keys)) (all[table] ??= []).push(...list);
|
|
2211
2285
|
}
|
|
2212
2286
|
return all;
|
|
2213
2287
|
}
|
|
2214
2288
|
/** Every `schema.table` the SQL creates, temporary tables left out. */
|
|
2215
|
-
function tablesFromSql(sql) {
|
|
2216
|
-
|
|
2289
|
+
async function tablesFromSql(sql) {
|
|
2290
|
+
const tables = /* @__PURE__ */ new Set();
|
|
2291
|
+
for (const statement of await parseSqlLenient(sql)) {
|
|
2292
|
+
const into = statement.node["into"];
|
|
2293
|
+
const relation = statement.kind === "CreateStmt" ? readRelation(statement.node["relation"]) : statement.kind === "CreateTableAsStmt" && isRecord(into) ? readRelation(into["rel"]) : void 0;
|
|
2294
|
+
if (relation !== void 0 && relation.persistence !== "t") tables.add(qualified(relation));
|
|
2295
|
+
}
|
|
2296
|
+
return tables;
|
|
2217
2297
|
}
|
|
2218
2298
|
/**
|
|
2219
2299
|
* Every `schema.table` the SQL files under the migration and schema folders of
|
|
2220
2300
|
* `cwd` create.
|
|
2221
2301
|
*/
|
|
2222
|
-
function tablesFromProject(cwd) {
|
|
2302
|
+
async function tablesFromProject(cwd) {
|
|
2223
2303
|
const all = /* @__PURE__ */ new Set();
|
|
2224
|
-
for (const file of
|
|
2304
|
+
for (const file of appSqlFiles(cwd)) for (const table of await tablesFromSql(readFileSync(file, "utf8"))) all.add(table);
|
|
2225
2305
|
return all;
|
|
2226
2306
|
}
|
|
2227
2307
|
/**
|
|
@@ -2239,12 +2319,18 @@ function refused(output) {
|
|
|
2239
2319
|
text: ""
|
|
2240
2320
|
};
|
|
2241
2321
|
}
|
|
2242
|
-
async function runRlsGenerate(
|
|
2243
|
-
const options = generateOptions(
|
|
2322
|
+
async function runRlsGenerate(given) {
|
|
2323
|
+
const options = generateOptions(given);
|
|
2244
2324
|
if (isRefusal(options)) return refused(options.refusal);
|
|
2245
|
-
const loaded = await loadGeneratePolicy(
|
|
2325
|
+
const loaded = await loadGeneratePolicy(given);
|
|
2246
2326
|
if (isPolicyLoadFailure(loaded)) return loaded;
|
|
2247
2327
|
const policy = loaded;
|
|
2328
|
+
const guardsSchema = (given.helpersOnly === true || given.config.rls?.helpersOnly === true) && readOnlyActorKinds(given.config.rls?.readOnlyActors) !== void 0;
|
|
2329
|
+
const input = {
|
|
2330
|
+
...given,
|
|
2331
|
+
config: await withSchemaDefaults(given.cwd, given.config, policy),
|
|
2332
|
+
...guardsSchema && given.schemaWrites === void 0 ? { schemaWrites: await schemaWrites(given.cwd) } : {}
|
|
2333
|
+
};
|
|
2248
2334
|
const built = buildContext(input, policy, options);
|
|
2249
2335
|
if (isRefusal(built)) return refused(built.refusal);
|
|
2250
2336
|
const warnings = [];
|
|
@@ -2258,8 +2344,8 @@ async function runRlsGenerate(input) {
|
|
|
2258
2344
|
warnings.push(...triggerNotes(text));
|
|
2259
2345
|
if (ctx.seeds === "function") warnings.push(`run select ${built.schema}.seed(); after each deploy`);
|
|
2260
2346
|
if (input.db === void 0) {
|
|
2261
|
-
indexes = withoutServedTargets(indexes, indexKeysFromProject(input.cwd));
|
|
2262
|
-
warnings.push(...unknownTableNotes(bindings, tablesFromProject(input.cwd)));
|
|
2347
|
+
indexes = withoutServedTargets(indexes, await indexKeysFromProject(input.cwd));
|
|
2348
|
+
warnings.push(...unknownTableNotes(bindings, await tablesFromProject(input.cwd)));
|
|
2263
2349
|
}
|
|
2264
2350
|
if (input.db !== void 0) try {
|
|
2265
2351
|
const facts = await readTableIndexFacts(input.db, [.../* @__PURE__ */ new Set([...indexes.map((target) => target.table), ...bindings.map((binding) => binding.table)])], input.connect);
|