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.
Files changed (479) hide show
  1. package/README.md +2 -2
  2. package/dist/a2a/index.d.ts +5 -5
  3. package/dist/a2a/index.js +2 -2
  4. package/dist/{adoption-scan-EGg-hGEu.js → adoption-scan-BJMEEu7V.js} +1 -1
  5. package/dist/agent/index.d.ts +2 -2
  6. package/dist/agent/index.js +1 -1
  7. package/dist/ai-sdk/index.d.ts +4 -4
  8. package/dist/ai-sdk/index.js +3 -3
  9. package/dist/annotate-dUrBHXWa.js +183 -0
  10. package/dist/{annotate-doc-BCOCOrq_.js → annotate-doc-BA0betEO.js} +5 -4
  11. package/dist/annotate-routes-CGJy1ojp.js +30 -0
  12. package/dist/app/index.d.ts +1 -1
  13. package/dist/app/index.js +1 -1
  14. package/dist/app-peer-BnMh5lqz.js +27 -0
  15. package/dist/approval-chain-D97rgMoA.js +431 -0
  16. package/dist/{approval-normalize-Cpp8R0rY.js → approval-normalize-C6je8vWN.js} +1 -1
  17. package/dist/{approval-prompt-C-vjNZyd.d.ts → approval-prompt-yNyhQqn8.d.ts} +2 -2
  18. package/dist/approvals/index.d.ts +3 -3
  19. package/dist/approvals/index.js +3 -3
  20. package/dist/{approvals-7jHYXocE.js → approvals-Bt5IQ4wR.js} +3 -3
  21. package/dist/{arazzo-CfjZOmVG.js → arazzo-BAgh0PT6.js} +3 -3
  22. package/dist/{arazzo-yiKJ4jm0.js → arazzo-C_xK2Kaa.js} +2 -2
  23. package/dist/{args-Bc0HLiD4.js → args-BSpXxMnb.js} +2 -1
  24. package/dist/ast-CAOxvn9t.js +188 -0
  25. package/dist/ast-Dnm2TOHN.js +434 -0
  26. package/dist/astro/index.d.ts +6 -6
  27. package/dist/astro/index.js +2 -2
  28. package/dist/{audience-DauhRBNg.js → audience-CARf-b-R.js} +1 -1
  29. package/dist/authzen/index.d.ts +6 -6
  30. package/dist/authzen/index.js +3 -3
  31. package/dist/{automation-CUcWz8uu.d.ts → automation-0VF1xe4o.d.ts} +3 -3
  32. package/dist/{automation-CpPdFX91.js → automation-D58PEI7Y.js} +1 -1
  33. package/dist/baseline-file-BQoki1O_.js +148 -0
  34. package/dist/better-auth/index.d.ts +2 -2
  35. package/dist/better-auth/index.js +2 -2
  36. package/dist/better-supabase/index.d.ts +72 -19
  37. package/dist/better-supabase/index.js +156 -71
  38. package/dist/{bind-up3QptTt.js → bind-BYeoLJgN.js} +5 -4
  39. package/dist/{bind-B3MHrzw4.d.ts → bind-zQacwAOg.d.ts} +12 -7
  40. package/dist/bsb-access-Bcw6GrQm.js +74 -0
  41. package/dist/bsb-access-tags-CjeR7v7-.js +272 -0
  42. package/dist/bsb-action-keys-CYEREFMg.js +377 -0
  43. package/dist/bsb-actions-BHiyBxQZ.js +65 -0
  44. package/dist/budgets-Dpumu_Dt.js +75 -0
  45. package/dist/{build-instance-hLKYe3-E.js → build-instance-CFiegi_w.js} +1 -1
  46. package/dist/bundle-size-Ddhv_H_v.js +56 -0
  47. package/dist/bundle-size-DwZ4e1gu.js +1 -0
  48. package/dist/{capability-CVt3lpVK.d.ts → capability-BPzseilU.d.ts} +2 -2
  49. package/dist/{capability-_ZsyfYxU.js → capability-oxfxybFR.js} +1 -1
  50. package/dist/{casbin-QzddqHaV.js → casbin-BErdqy1J.js} +1 -1
  51. package/dist/{casbin-j_468wDU.js → casbin-EwdKipQs.js} +2 -2
  52. package/dist/{casl-CrltbDPa.js → casl-BSt24g-p.js} +1 -1
  53. package/dist/catalog/index.d.ts +5 -5
  54. package/dist/catalog/index.js +6 -6
  55. package/dist/{catalog-DXSP1we9.js → catalog-BExjL94D.js} +4 -4
  56. package/dist/{catalog-COoxFOoy.js → catalog-CBPFyRv7.js} +2 -2
  57. package/dist/{catalog-doc-Bp5khmCG.js → catalog-doc-D4g3nyFB.js} +5 -3
  58. package/dist/{catalog-operations-dxuOZr4J.js → catalog-operations-BqSsByIE.js} +3 -3
  59. package/dist/catalog-sR0m6x2g.js +1 -0
  60. package/dist/{challenge-CjwmjcuX.js → challenge-CRB1X3Ry.js} +1 -1
  61. package/dist/chat/index.d.ts +1 -1
  62. package/dist/chat/index.js +2 -2
  63. package/dist/chat-sdk/index.d.ts +3 -3
  64. package/dist/claims-size-B6j0Ff4Q.js +1 -0
  65. package/dist/{perf-token-dFGVP14-.js → claims-size-BsSDVD5u.js} +66 -1
  66. package/dist/claude-agent/index.d.ts +3 -3
  67. package/dist/claude-agent/index.js +2 -2
  68. package/dist/clerk/index.d.ts +3 -3
  69. package/dist/cli/bin.js +1 -1
  70. package/dist/cli/generate/watch-worker.js +2 -2
  71. package/dist/cli/index.d.ts +9 -9
  72. package/dist/cli/index.js +3 -3
  73. package/dist/cli/plugins/app.d.ts +1 -1
  74. package/dist/cli/plugins/app.js +1 -1
  75. package/dist/cli/plugins/better-supabase.d.ts +1 -1
  76. package/dist/cli/plugins/openapi.d.ts +1 -1
  77. package/dist/cli/plugins/openapi.js +2 -2
  78. package/dist/cli/plugins/powersync.d.ts +1 -1
  79. package/dist/cli/plugins/powersync.js +2 -2
  80. package/dist/cli/plugins/rls.d.ts +2 -2
  81. package/dist/cli/plugins/rls.js +1 -1
  82. package/dist/cli/plugins/schemas.d.ts +1 -1
  83. package/dist/cli/plugins/schemas.js +1 -1
  84. package/dist/cli/plugins/scim.d.ts +2 -2
  85. package/dist/cli/plugins/supabase-hook.d.ts +2 -2
  86. package/dist/cli/plugins/supabase-hook.js +1 -1
  87. package/dist/cli/plugins/supabase.d.ts +3 -3
  88. package/dist/cli/plugins/supabase.js +2 -2
  89. package/dist/cli/plugins/ui.d.ts +1 -1
  90. package/dist/cli/plugins/ui.js +1 -1
  91. package/dist/{client-subject-v89t811z.d.ts → client-subject-xCSkKD1C.d.ts} +2 -2
  92. package/dist/cloud/index.d.ts +8 -8
  93. package/dist/cloud/index.js +1 -1
  94. package/dist/{cloud-D3c4zhYr.js → cloud-DW3q3qnp.js} +3 -3
  95. package/dist/{codemod-BLTuDxFa.js → codemod-CF7NNDzA.js} +616 -392
  96. package/dist/codemod-DVDMFsTX.js +75 -0
  97. package/dist/{collect-BYPq-0JU.js → collect-CE5wK0AX.js} +3 -3
  98. package/dist/collect-CIdE3FGC.js +1 -0
  99. package/dist/{collect-BOh9Pxob.js → collect-CPimbkC5.js} +3 -3
  100. package/dist/compare-8SNJN-9U.js +12 -0
  101. package/dist/compile/index.d.ts +1 -1
  102. package/dist/{compile-B9SZiEnG.js → compile-BXKYYmT1.js} +19 -23
  103. package/dist/{compile-D8c1nFGy.d.ts → compile-tG1zkSgX.d.ts} +3 -3
  104. package/dist/{completion-CVTgFKK6.js → completion-B59uPAnZ.js} +2 -2
  105. package/dist/config-7QvEq57a.js +521 -0
  106. package/dist/{config-ClUStKUe.js → config-VCa1RLUe.js} +2 -2
  107. package/dist/config-paths-CQvGng3k.js +136 -0
  108. package/dist/{config-report-GJmQMf2K.js → config-report-CjvA6lGI.js} +7 -2
  109. package/dist/{config-shape-B6tdyBju.js → config-shape-BTojaD-H.js} +9 -2
  110. package/dist/{context-BdoA9DhS.js → context-BQHKgT1m.js} +2 -2
  111. package/dist/context-CAFddgb9.js +35 -0
  112. package/dist/convex/index.d.ts +5 -5
  113. package/dist/convex/index.js +2 -2
  114. package/dist/{core-tEfD0lwu.js → core-C5yCD-Ls.js} +6 -6
  115. package/dist/{core-CnC47rSf.d.ts → core-bf8qgaZf.d.ts} +3 -3
  116. package/dist/{coverage-DL7JCZmb.d.ts → coverage-AOeWiQ7Z.d.ts} +2 -2
  117. package/dist/{coverage-nFSMjFxH.js → coverage-C3jVYC9Y.js} +1 -1
  118. package/dist/{create-sGl1ccTp.d.ts → create-B7Xa4jSQ.d.ts} +9 -9
  119. package/dist/{create-D3oXoXxM.js → create-COQVXK6C.js} +22 -6
  120. package/dist/{create-DeQ5t8mZ.d.ts → create-Cn5EpEez.d.ts} +5 -5
  121. package/dist/{create-BsRcXm_m.d.ts → create-DHA0fhmi.d.ts} +7 -7
  122. package/dist/{create-BAMPoEga.js → create-nOWD3Joc.js} +3 -3
  123. package/dist/{credential-ke0KMQeB.js → credential-D9in5keC.js} +3 -3
  124. package/dist/{credentials-DOeqknte.js → credentials-B-hsgB4W.js} +1 -1
  125. package/dist/{credentials-BfzdL5kv.d.ts → credentials-COT-cjnP.d.ts} +3 -3
  126. package/dist/custom-role-rebuild-BK73tPib.js +181 -0
  127. package/dist/deciding-columns-DBZsrpdD.js +60 -0
  128. package/dist/deferred-sink-BZahJ8sO.js +34 -0
  129. package/dist/{define-permdock-CIxHBykk.js → define-permdock-D7aKxIax.js} +4 -4
  130. package/dist/{define-permdock-BLpQ0m95.d.ts → define-permdock-DBgwTFi1.d.ts} +6 -6
  131. package/dist/{delegation-BaUNCrE_.js → delegation-0DVVomzu.js} +3 -3
  132. package/dist/delivery/index.d.ts +4 -4
  133. package/dist/delivery/index.js +1 -1
  134. package/dist/{denied-text-D6JJTDr3.d.ts → denied-text-C_AWc0f0.d.ts} +2 -2
  135. package/dist/{describe-lAafaRQQ.d.ts → describe-AdETpWsn.d.ts} +2 -2
  136. package/dist/{diff-CXRZ6qPa.js → diff-COdwpP31.js} +7 -7
  137. package/dist/{diff-Cv9inVY5.js → diff-CW9eZy9X.js} +2 -2
  138. package/dist/{doctor-CQoP1264.js → doctor-ELj5hrVv.js} +17 -5
  139. package/dist/{doctor-Bn2BTr0N.js → doctor-ervtBRzG.js} +1624 -322
  140. package/dist/drizzle/index.d.ts +3 -3
  141. package/dist/edits-CqU8s2GC.js +69 -0
  142. package/dist/elysia/index.d.ts +5 -5
  143. package/dist/elysia/index.js +3 -3
  144. package/dist/{errors-DUJ7wLlE.d.ts → errors-COoiWqIs.d.ts} +1 -1
  145. package/dist/{evaluate-D8SdfP3h.js → evaluate-Dmd0bShm.js} +30 -31
  146. package/dist/{evaluations-BQkpE7hC.js → evaluations-DPEAu_jM.js} +2 -2
  147. package/dist/{evaluations-K9qglDP7.d.ts → evaluations-GW9j_ARq.d.ts} +3 -3
  148. package/dist/evaluator-COmATWCr.js +2 -0
  149. package/dist/{evaluator-eager-UuJK6NX_.js → evaluator-eager-CpVYslzY.js} +1 -1
  150. package/dist/eve/index.d.ts +18 -8
  151. package/dist/eve/index.js +13 -15
  152. package/dist/{execute-BLM5tpRU.js → execute-ix7AAdWg.js} +17 -41
  153. package/dist/explain-DRC9V5Qb.js +37 -0
  154. package/dist/explain-jg0KLCVt.js +74 -0
  155. package/dist/express/index.d.ts +5 -5
  156. package/dist/express/index.js +3 -3
  157. package/dist/fastify/index.d.ts +5 -5
  158. package/dist/fastify/index.js +3 -3
  159. package/dist/{fetch-adapter-gmTCu4FR.d.ts → fetch-adapter-CJncmsPg.d.ts} +4 -4
  160. package/dist/{fetch-adapter-ovZdSvlT.js → fetch-adapter-CU1DIkXu.js} +3 -3
  161. package/dist/{fields-CViS0EPC.js → fields-y_PSRCyJ.js} +3 -2
  162. package/dist/{fixtures-Bm0G0A7H.js → fixtures-3aUUP6Nx.js} +1 -1
  163. package/dist/flags-DQzNPxg1.js +204 -0
  164. package/dist/{from-snapshot-CCDF_ihX.js → from-snapshot-DGc9W4QU.js} +7 -7
  165. package/dist/{gen-02p5oEol.js → gen-8rW_AUG5.js} +16 -12
  166. package/dist/gen-BtiGMiuH.js +1 -0
  167. package/dist/{gen-kind-BMwPHJZ0.js → gen-kind-C9ikF8nb.js} +1 -1
  168. package/dist/{generate-BVcwnfoI.js → generate-BmpCt5oi.js} +4 -4
  169. package/dist/{generate-BtstB6iV.js → generate-CW7gNfLr.js} +244 -158
  170. package/dist/{generate-options-Yfh1pGyX.js → generate-options-DiR4r_sk.js} +18 -189
  171. package/dist/{grantee-BPUG6f0r.js → grantee-BSCdpIF3.js} +1 -1
  172. package/dist/{grantee-match-CFQ-LRcL.js → grantee-match-CJgQmcx4.js} +1 -1
  173. package/dist/h3/index.d.ts +4 -4
  174. package/dist/h3/index.js +3 -3
  175. package/dist/helper-calls-DHvgN9tr.js +106 -0
  176. package/dist/{helpers-DSmj6SHi.js → helpers-COh0lLc1.js} +2 -2
  177. package/dist/hono/index.d.ts +5 -5
  178. package/dist/hono/index.js +3 -3
  179. package/dist/{hook-sql-55514A9t.js → hook-sql-D-abRHut.js} +47 -225
  180. package/dist/{hosted-DUbuh0Td.d.ts → hosted-Bkw3Oyh-.d.ts} +1 -1
  181. package/dist/{hosted-DMJKJPoc.js → hosted-DZwCFrcy.js} +5 -5
  182. package/dist/{import-HzsIBAa5.js → import-BAhoTYTk.js} +1 -1
  183. package/dist/{import-Cm8kuezl.js → import-D_8tLF9g.js} +30 -46
  184. package/dist/{index-BSJoxaOi.d.ts → index-DPVeDtAO.d.ts} +5 -5
  185. package/dist/{index-D1msamx_.d.ts → index-DT3hOxA7.d.ts} +83 -14
  186. package/dist/{index-DegTwZxD.d.ts → index-DWmIuQLz.d.ts} +5 -5
  187. package/dist/{index-eaNHkELi.d.ts → index-Kj5S3IWE.d.ts} +6 -6
  188. package/dist/{index-O0qbI8Ha.d.ts → index-WOx7TBbj.d.ts} +2 -2
  189. package/dist/{index-D8A1d_Tt.d.ts → index-xShPsK8G.d.ts} +2 -2
  190. package/dist/index.d.ts +18 -18
  191. package/dist/index.js +25 -24
  192. package/dist/{init-DvsMFuau.js → init-DkRHIe8-.js} +4 -4
  193. package/dist/{init-BklKWywy.js → init-zxb0BVDJ.js} +1 -1
  194. package/dist/{instance-options-B4MD2wgl.d.ts → instance-options-DQCiBBuz.d.ts} +1 -1
  195. package/dist/{instance-snapshot-DdGOpSfN.js → instance-snapshot-D9kjL37B.js} +37 -20
  196. package/dist/{interactive-only-C_olBCPl.js → interactive-only-Dqww0ABO.js} +22 -14
  197. package/dist/jwt/index.d.ts +17 -13
  198. package/dist/jwt/index.js +14 -5
  199. package/dist/{kernel-Dn6pKMAF.js → kernel-C5akxw5n.js} +7 -7
  200. package/dist/keys-DQsHrgBM.js +42 -0
  201. package/dist/kysely/index.d.ts +3 -3
  202. package/dist/{lazy-provider-C48LDq0q.d.ts → lazy-provider-CMgFAGf8.d.ts} +1 -1
  203. package/dist/{lazy-provider-CVX534Kk.js → lazy-provider-DNVjY4n3.js} +2 -2
  204. package/dist/load-BCABUQZi.js +1 -0
  205. package/dist/{load-CZnlAyZ8.js → load-m7jmit3y.js} +1 -1
  206. package/dist/{login-CuUf-syI.js → login-C1p3gmj8.js} +1 -1
  207. package/dist/{login-BFvEcFnI.js → login-DOEZveP6.js} +4 -4
  208. package/dist/manager-chain-DdkiCw5q.js +243 -0
  209. package/dist/{manifest-BYzJF6xk.js → manifest-31igzVGQ.js} +70 -38
  210. package/dist/{manifest-Ct3eXbLR.js → manifest-B487A3po.js} +1 -1
  211. package/dist/{manifest-CRHphHxo.d.ts → manifest-DgsxeAsM.d.ts} +76 -0
  212. package/dist/{manifest-schema-Bp-eFhNZ.js → manifest-schema-D7RQbnGY.js} +90 -1
  213. package/dist/{map-error-DTi_JZT8.js → map-error-DYQbf-3Q.js} +1 -1
  214. package/dist/{may-use-Died1tNU.js → may-use-4HzzgYJ3.js} +3 -3
  215. package/dist/mcp/index.d.ts +9 -9
  216. package/dist/mcp/index.js +4 -4
  217. package/dist/{membership-filter-CSKH48eD.js → membership-filter-C7ZuhAqJ.js} +1 -1
  218. package/dist/{migrate-BcBFWFt9.js → migrate-pg-lkbDu.js} +4 -16
  219. package/dist/model-BXhr8gUI.js +329 -0
  220. package/dist/{module-values-Ddx0GLaJ.js → module-values-B09BBJIj.js} +3 -3
  221. package/dist/nest/index.d.ts +5 -5
  222. package/dist/nest/index.js +3 -3
  223. package/dist/next/index.d.ts +29 -12
  224. package/dist/next/index.js +24 -26
  225. package/dist/next/plugin.d.ts +1 -1
  226. package/dist/next/plugin.js +1 -1
  227. package/dist/node/index.d.ts +5 -5
  228. package/dist/node/index.js +2 -2
  229. package/dist/openai/index.d.ts +5 -5
  230. package/dist/openai/index.js +3 -3
  231. package/dist/openapi/index.d.ts +4 -4
  232. package/dist/openapi/index.js +3 -3
  233. package/dist/{openapi-BwZABlQO.js → openapi-BeMVHVY4.js} +6 -6
  234. package/dist/{openapi-D2dmyWZK.js → openapi-CZu6sVsP.js} +1 -1
  235. package/dist/{openapi-DNZv-nDu.js → openapi-DEGesHWH.js} +11 -4
  236. package/dist/{openapi-document-DoIe4MrZ.js → openapi-document-CEQ6jqqR.js} +1 -1
  237. package/dist/{operations-BS8ExH5A.d.ts → operations-DaEoGpMV.d.ts} +1 -1
  238. package/dist/{operations-De3F7tlf.js → operations-dJxcshJZ.js} +1 -1
  239. package/dist/{operations-B0yO77Zz.js → operations-id4vhwFN.js} +9 -3
  240. package/dist/orpc/index.d.ts +7 -7
  241. package/dist/orpc/index.js +4 -4
  242. package/dist/otel/index.d.ts +3 -3
  243. package/dist/{output-BI85V6hu.js → output-C7EPeSZj.js} +19 -2
  244. package/dist/{output-files-D5D-8-4l.js → output-files-8lfALMSU.js} +143 -11
  245. package/dist/output-files-DKWhL1IE.js +1 -0
  246. package/dist/{ownership-mprXkEHG.js → ownership-Csk9C3Js.js} +10 -6
  247. package/dist/{parse-nfHSt1Wy.js → parse-CUqZ_lLC.js} +1 -1
  248. package/dist/{parse-local-manifest-BGLWVchi.d.ts → parse-local-manifest-B92rFWnk.d.ts} +1 -1
  249. package/dist/pdp/index.d.ts +3 -3
  250. package/dist/pdp/index.js +2 -2
  251. package/dist/{permdock-Dz3yzWrp.d.ts → permdock-BShHM8OJ.d.ts} +11 -5
  252. package/dist/{permdock-BueSeg7X.js → permdock-CJPIwU1T.js} +102 -55
  253. package/dist/{permission-registry-DMYRZVcn.js → permission-registry-DstT40VS.js} +31 -1
  254. package/dist/{permissions-CQW3cr2S.js → permissions-DJ_QV9L7.js} +1 -1
  255. package/dist/{permissions-DWULToSb.d.ts → permissions-UyQD5nRN.d.ts} +1 -1
  256. package/dist/{permissions-Bj3DRIEi.js → permissions-wEkTVr_I.js} +3 -3
  257. package/dist/{pg-CA651850.js → pg-DmS5ITHu.js} +20 -1
  258. package/dist/pg-DtiDogUp.js +1 -0
  259. package/dist/{pipeline-Ct3YEKjx.js → pipeline-Bbu7uw28.js} +103 -32
  260. package/dist/{plugin-zOs9uqQj.d.ts → plugin-L3G7jPGE.d.ts} +15 -4
  261. package/dist/{policy-DFD2J5o_.js → policy-BBvhhH9X.js} +4 -4
  262. package/dist/{policy-C-Lzp3Zh.d.ts → policy-BUtwixSN.d.ts} +2 -2
  263. package/dist/{policy-DfvOwgtX.js → policy-CSOOQ3rR.js} +3 -3
  264. package/dist/{policy-bundle-pwhJJv2-.js → policy-bundle-KYI0EnrM.js} +3 -3
  265. package/dist/{policy-from-catalog-YKaTeaco.js → policy-from-catalog-_zwn1sNj.js} +12 -9
  266. package/dist/{policy-types-93NwI8iI.d.ts → policy-types-CfW4X_yX.d.ts} +155 -19
  267. package/dist/{postgrest-DyrYo_XT.d.ts → postgrest-PQ3zAOD2.d.ts} +2 -2
  268. package/dist/powersync-C1ix7CEY.js +1 -0
  269. package/dist/{powersync-D1Aog89p.js → powersync-CGvu6j5U.js} +2 -2
  270. package/dist/{powersync-CkoImqoq.js → powersync-CM6Vg4RH.js} +65 -24
  271. package/dist/prisma/index.d.ts +2 -2
  272. package/dist/program-CvarkLMS.js +10 -0
  273. package/dist/{protected-action-Dco5O_Kc.js → protected-action-BPN0NaRb.js} +1 -1
  274. package/dist/{protected-action-CEzNNtfi.d.ts → protected-action-DhCQ4bSe.d.ts} +6 -6
  275. package/dist/{provider-BYcoTKuS.js → provider-1xqxLVEz.js} +2 -2
  276. package/dist/{provider-1yWthvi5.js → provider-BV_v0JAY.js} +457 -116
  277. package/dist/{provider-C48LDq0q.d.ts → provider-CMgFAGf8.d.ts} +1 -1
  278. package/dist/{provider-store-Dq_olUjC.js → provider-store-Cf8HRNtb.js} +3 -3
  279. package/dist/{provider-with-fxHItxDh.js → provider-with-cpL9vRjC.js} +2 -2
  280. package/dist/prune-config-CdoPJIGz.js +209 -0
  281. package/dist/{pull-DD6YQ42X.js → pull-BaB401Bk.js} +4 -4
  282. package/dist/pull-Bp63vtgu.js +1 -0
  283. package/dist/{push-N-QI_ArC.js → push-DcjvEj0m.js} +5 -5
  284. package/dist/{pushed-policy-rpB6k77P.js → pushed-policy-DSjSWEAl.js} +1 -1
  285. package/dist/{pushed-policy-APjMbYdV.d.ts → pushed-policy-DcvO8NXy.d.ts} +1 -1
  286. package/dist/{conditions-ChE7zxJI.js → rbac-mblGDx-Z.js} +227 -6
  287. package/dist/react/index.d.ts +6 -6
  288. package/dist/react/index.js +3 -3
  289. package/dist/react/lazy.d.ts +6 -6
  290. package/dist/react/lazy.js +3 -3
  291. package/dist/react/provider-client-lazy.d.ts +1 -1
  292. package/dist/react/provider-client-lazy.js +1 -1
  293. package/dist/react/provider-client.d.ts +1 -1
  294. package/dist/react/provider-client.js +1 -1
  295. package/dist/react-native/index.d.ts +9 -9
  296. package/dist/react-native/index.js +8 -8
  297. package/dist/rename-BZNOV8H9.js +437 -0
  298. package/dist/replay-BCOZifwx.d.ts +3 -0
  299. package/dist/report-DCAiUc5U.js +1 -0
  300. package/dist/report-DievqWhf.js +368 -0
  301. package/dist/{request-context-CVJodWx8.js → request-context-BNVY3kZ1.js} +1 -1
  302. package/dist/resend/index.d.ts +4 -4
  303. package/dist/resolve-config-9NYYVc30.js +238 -0
  304. package/dist/{resolve-names-B0cqvJxo.js → resolve-names-Cth1UQ-8.js} +5 -5
  305. package/dist/{resolver-4qxIIHcC.js → resolver-CuIY8aFD.js} +48 -30
  306. package/dist/{retire-BNiXnbBR.js → retire-FN4aY6-n.js} +1 -1
  307. package/dist/{rls-oLdqutBO.js → rls-BtkZgaZp.js} +33 -5
  308. package/dist/{rls-c0Z9lbyp.js → rls-DUYok5e9.js} +231 -40
  309. package/dist/{rls-files-Dhtn_6LH.js → rls-files-ucAI0J5j.js} +3 -3
  310. package/dist/{rls-options-BZxfMDFo.d.ts → rls-options-BFGRmdcH.d.ts} +1 -1
  311. package/dist/{role-builder-DhsGEVq-.js → role-builder-BksM3Q9O.js} +3 -3
  312. package/dist/{roles-B29psCem.js → roles-BeNEhv7Q.js} +2 -2
  313. package/dist/{rpc-DjgxFbjK.d.ts → rpc-COnquydd.d.ts} +2 -2
  314. package/dist/{rpc-B-4IZOiU.js → rpc-D7G7IJDa.js} +1 -1
  315. package/dist/run-BjMxYYTe.js +1 -0
  316. package/dist/{run-DkviX16y.js → run-WIqPbnjD.js} +12 -11
  317. package/dist/{run-ticket-DXwrko2J.d.ts → run-ticket-Mmor5sYW.d.ts} +2 -2
  318. package/dist/{saas-CUwmgUB8.js → saas-DcqUkynn.js} +5 -5
  319. package/dist/{scan-CNhvy39j.js → scan-Badcllgg.js} +1 -1
  320. package/dist/{schema-BeY3croo.js → schema-D2OK4RrB.js} +1 -0
  321. package/dist/{schema-CwNjlLBx.js → schema-DBRKgQb4.js} +1 -1
  322. package/dist/schema-tables-Ba9LE_XB.js +185 -0
  323. package/dist/scim/index.d.ts +1 -1
  324. package/dist/seeds/index.d.ts +1 -1
  325. package/dist/seeds/index.js +1 -1
  326. package/dist/{seeds-BDTG7xl-.js → seeds-Bs44UDS3.js} +1 -1
  327. package/dist/{seeds-uG196Ev4.d.ts → seeds-Cih1ztkf.d.ts} +2 -2
  328. package/dist/server/index.d.ts +13 -12
  329. package/dist/server/index.js +7 -6
  330. package/dist/{server-Co9CYGqk.js → server-lohbasQd.js} +2 -2
  331. package/dist/{server-types-BrHOGAYx.d.ts → server-types-C2XX60aF.d.ts} +16 -9
  332. package/dist/shared-C6_T7QUo.js +76 -0
  333. package/dist/{sink-BD34OS8T.d.ts → sink-BQ_6K81r.d.ts} +4 -4
  334. package/dist/{size-BqLd5oJ4.js → size-l1pDHE2z.js} +28 -5
  335. package/dist/{skills-DrY6VdtH.js → skills-Ba9hHGO6.js} +2 -2
  336. package/dist/{skills-B74k44ml.js → skills-CTKq3o8D.js} +2 -2
  337. package/dist/{snapshot-DckMnHk8.js → snapshot-Ty0uk9wZ.js} +46 -12
  338. package/dist/{snapshot-cache-DoP3avLl.d.ts → snapshot-cache-DGvLQW0-.d.ts} +1 -1
  339. package/dist/snapshot-compact-yXFxZLPo.js +596 -0
  340. package/dist/{snapshot-empty-DZ6sZ83n.js → snapshot-empty-pKgPDcLd.js} +1 -1
  341. package/dist/{snapshot-evaluate-9RGy7J3N.js → snapshot-evaluate-DSNj2rhV.js} +5 -4
  342. package/dist/{snapshot-reads-D775amTL.js → snapshot-reads-BnAHiuoa.js} +2 -2
  343. package/dist/snapshot-requires-DfUqCLEb.js +122 -0
  344. package/dist/{snapshot-size-CHig-Nq_.js → snapshot-size-2fkXbCkP.js} +5 -15
  345. package/dist/snapshot-size-DNY1MTsV.js +1 -0
  346. package/dist/solid/index.d.ts +6 -6
  347. package/dist/solid/index.js +2 -2
  348. package/dist/solid-start/index.d.ts +6 -6
  349. package/dist/solid-start/index.js +3 -3
  350. package/dist/{sources-NQio1yFq.d.ts → sources-CjgZns7t.d.ts} +2 -2
  351. package/dist/{src-BAYcigFU.js → src-HRYn4UFj.js} +148 -15
  352. package/dist/ssf/index.d.ts +3 -3
  353. package/dist/ssf/index.js +1 -1
  354. package/dist/{standard-webhooks-B3MQihcP.d.ts → standard-webhooks-Bnnrqa6d.d.ts} +2 -2
  355. package/dist/{store-core-DyNo_BwA.d.ts → store-core-BdFcruPm.d.ts} +5 -5
  356. package/dist/{store-AH8bmaxW.js → store-n3yEN7dt.js} +2 -2
  357. package/dist/{store-options-BtHrfJUU.js → store-options-DpCQo0vB.js} +21 -12
  358. package/dist/{stores-DyFCruRC.d.ts → stores-D6MIjN_-.d.ts} +6 -6
  359. package/dist/{stores-BIMyclLg.js → stores-KpBCaY6c.js} +1 -1
  360. package/dist/{shared-Cwxy5N16.js → subject-CrldGifz.js} +1 -75
  361. package/dist/{subject-cache-BZeSj4Xf.d.ts → subject-cache-CnJcz2K_.d.ts} +14 -6
  362. package/dist/supabase/index.d.ts +9 -9
  363. package/dist/supabase/index.js +4 -4
  364. package/dist/supabase/middleware.d.ts +14 -7
  365. package/dist/supabase/middleware.js +17 -6
  366. package/dist/{supabase-CakrAxMg.js → supabase-CGiB83XQ.js} +2 -2
  367. package/dist/supabase-dir-0lxKbrYu.js +41 -0
  368. package/dist/supabase-hook-CluYxKee.js +2 -0
  369. package/dist/{supabase-hook-0q6ohTVN.js → supabase-hook-CqO_0Koh.js} +14 -9
  370. package/dist/{supabase-BzK3lplm.js → supabase-kWQlkrHw.js} +4 -4
  371. package/dist/{supabase-config-B2sDFiwy.js → supabase-schemas-BglbAG2Z.js} +223 -34
  372. package/dist/{supautils-DXzJ2E2Q.js → supautils-C85NuESf.js} +2 -2
  373. package/dist/{support-session-B8xrW28B.js → support-session-DpzcGTuV.js} +1 -1
  374. package/dist/svelte/index.d.ts +5 -5
  375. package/dist/svelte/index.js +3 -3
  376. package/dist/svelte/runtime.d.ts +3 -3
  377. package/dist/svelte/runtime.js +1 -1
  378. package/dist/svelte/source.d.ts +5 -5
  379. package/dist/svelte/source.js +2 -2
  380. package/dist/sveltekit/index.d.ts +6 -6
  381. package/dist/sveltekit/index.js +2 -2
  382. package/dist/table-reads-AnHPrBp8.js +517 -0
  383. package/dist/table-reads-BviGc0L_.js +1 -0
  384. package/dist/{tables-BDqfipr1.js → tables-CDq0HVVq.js} +82 -26
  385. package/dist/tanstack-start/index.d.ts +6 -6
  386. package/dist/tanstack-start/index.js +2 -2
  387. package/dist/tenant-check-D7g9oNVH.js +105 -0
  388. package/dist/tenant-from-path-AKTSY7uR.js +65 -0
  389. package/dist/tenant-from-path-Dq3jkqjh.d.ts +25 -0
  390. package/dist/terminal/index.d.ts +6 -6
  391. package/dist/terminal/index.js +4 -4
  392. package/dist/testing/core.d.ts +1 -1
  393. package/dist/testing/core.js +1 -1
  394. package/dist/testing/fixtures/index.d.ts +5 -5
  395. package/dist/testing/fixtures/index.js +67 -3
  396. package/dist/testing/index.d.ts +31 -30
  397. package/dist/testing/index.js +51 -45
  398. package/dist/testing/saas/index.d.ts +5 -5
  399. package/dist/testing/saas/index.js +2 -2
  400. package/dist/testing/saas/permissions.d.ts +1 -1
  401. package/dist/testing/saas/permissions.js +1 -1
  402. package/dist/trpc/index.d.ts +6 -6
  403. package/dist/trpc/index.js +3 -3
  404. package/dist/{type-helpers-DHCQEPj8.d.ts → type-helpers-CUmJFGV6.d.ts} +3 -3
  405. package/dist/{types-PS10T9UK.d.ts → types-BKnUwgvx.d.ts} +5 -5
  406. package/dist/{types-CQF-oYSz.d.ts → types-BRECeQ2n.d.ts} +4 -4
  407. package/dist/{types-OzSal_K_.d.ts → types-BhBfMdQ5.d.ts} +3 -3
  408. package/dist/{types-DONLJQjY.d.ts → types-BsRf5rKk.d.ts} +3 -3
  409. package/dist/{types-Cakw89Wx.d.ts → types-CIzXPPV-.d.ts} +2 -2
  410. package/dist/{types-CWmBZtQN.d.ts → types-CbJ5mxXv.d.ts} +7 -2
  411. package/dist/{types-4wjWMSFM.d.ts → types-CjZscT16.d.ts} +4 -4
  412. package/dist/{types-XSfi6ihL.d.ts → types-DwoRXDvN.d.ts} +2 -2
  413. package/dist/{types-config-Cq72dArb.d.ts → types-config-DNIw_Gt5.d.ts} +82 -17
  414. package/dist/{types-BFtFaI1W.d.ts → types-euUv1wsO.d.ts} +1 -1
  415. package/dist/{types-D3tjoLwT.d.ts → types-h9W3CNC_.d.ts} +5 -5
  416. package/dist/{types-run-DG1H5vrX.d.ts → types-run-Bwn1MuW0.d.ts} +1 -1
  417. package/dist/{types-BdNdMix7.d.ts → types-vKKndyxx.d.ts} +2 -2
  418. package/dist/unplugin/index.d.ts +1 -1
  419. package/dist/unplugin/index.js +1 -1
  420. package/dist/{usage-DEUKhZ1n.js → usage-CW6xhRcV.js} +7 -235
  421. package/dist/usage-Ci7Glu-H.js +1 -0
  422. package/dist/{usage-B-xheuEq.js → usage-n4V2k_a6.js} +2 -2
  423. package/dist/{validation-error-BAO1W1yk.d.ts → validation-error-P4Z9HUuP.d.ts} +1 -1
  424. package/dist/{verify-BgZapMKs.js → verify-CKzngsUH.js} +16 -104
  425. package/dist/{version-cache-BXkl7-Fz.js → version-cache-BzK8dwJy.js} +14 -10
  426. package/dist/{vocabulary-FYgI_NoI.d.ts → vocabulary-DHfKPIC5.d.ts} +7 -0
  427. package/dist/vue/index.d.ts +6 -6
  428. package/dist/vue/index.js +2 -2
  429. package/dist/{waiter-hYLJXA7r.d.ts → waiter-BqUxSRxq.d.ts} +2 -2
  430. package/dist/warm-5yxlUmBh.js +32 -0
  431. package/dist/warm-BR-mrnY-.d.ts +16 -0
  432. package/dist/{watch-Bz_iEKlB.js → watch-C12Ub7x4.js} +11 -14
  433. package/dist/{watch-BNxvqCS4.js → watch-D-5ztqN8.js} +2 -2
  434. package/dist/watch-J1PfGMfb.js +1 -0
  435. package/dist/webmcp/index.d.ts +2 -2
  436. package/dist/webmcp/index.js +2 -2
  437. package/dist/{who-can-rUSZfLvI.js → who-can-CGVpM3fZ.js} +3 -3
  438. package/dist/workflow/index.d.ts +3 -3
  439. package/dist/workflow/index.js +4 -4
  440. package/dist/workflow-sdk/index.d.ts +17 -5
  441. package/dist/workflow-sdk/index.js +3 -1
  442. package/dist/{wrap-D-KvhzaC.d.ts → wrap-D8WtzrB7.d.ts} +2 -2
  443. package/package.json +20 -16
  444. package/schemas/catalog-v2.json +6 -0
  445. package/schemas/snapshot-v2.json +557 -0
  446. package/schemas/supabase-manifest-v1.json +156 -15
  447. package/skills/permdock/SKILL.md +1 -1
  448. package/skills/permdock-agents/references/runtimes.md +1 -1
  449. package/skills/permdock-credentials/references/tokens-keys-links.md +1 -1
  450. package/skills/permdock-data/references/queries-and-rls.md +2 -2
  451. package/skills/permdock-tenancy/SKILL.md +4 -4
  452. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -1
  453. package/dist/annotate-routes-BvSuEht3.js +0 -75
  454. package/dist/annotate-uZVGIRym.js +0 -25
  455. package/dist/better-supabase-DSbs4MtQ.js +0 -201
  456. package/dist/catalog-DCjJIl3n.js +0 -1
  457. package/dist/claims-size-DcjhvUv5.js +0 -58
  458. package/dist/codemod-Ob71iPQh.js +0 -35
  459. package/dist/collect-XcoQRyiA.js +0 -1
  460. package/dist/config-iyy90IOU.js +0 -143
  461. package/dist/deciding-columns-BnglEKqU.js +0 -143
  462. package/dist/evaluator-Dlhn2d7D.js +0 -2
  463. package/dist/flags-C0e-BzGW.js +0 -112
  464. package/dist/gen-C_RJoGZB.js +0 -1
  465. package/dist/grants-Dn6zwfqo.js +0 -139
  466. package/dist/load-BPzIqlGB.js +0 -1
  467. package/dist/model-B0rrUh6J.js +0 -188
  468. package/dist/output-files-aPXXhV4q.js +0 -1
  469. package/dist/powersync-f-6y8sCk.js +0 -1
  470. package/dist/pull-CT7wu2uo.js +0 -1
  471. package/dist/rbac-BJTUGJum.js +0 -90
  472. package/dist/replay-ClGIMp5p.d.ts +0 -3
  473. package/dist/run-DKUZT8Cc.js +0 -1
  474. package/dist/snapshot-compact-CwAop_6C.js +0 -119
  475. package/dist/snapshot-size-B_chu2c1.js +0 -1
  476. package/dist/supabase-hook-CcmjiBsh.js +0 -2
  477. package/dist/usage-BRjoZ-vo.js +0 -1
  478. package/dist/watch-CGLmIdld.js +0 -1
  479. package/schemas/snapshot-v1.json +0 -329
@@ -3,6 +3,107 @@ import { t as applyFiles } from "./files-DuV7wRim.js";
3
3
  import { t as shortDiff } from "./text-diff-DxKRNFlx.js";
4
4
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
5
5
  import { basename, dirname, resolve } from "node:path";
6
+ // src/cli/core/seed-delta.ts
7
+ /** The second line of a seeds migration that holds only the changed rows. */
8
+ const DELTA_PREFIX = "-- permdock seeds delta since ";
9
+ /** Ends the changed rows in a delta migration; the closure backfill follows. */
10
+ const DELTA_END = "-- end of the changed role_permissions rows";
11
+ const LITERAL = /'(?:[^']|'')*'/gu;
12
+ const INSERT = /^insert into (\S+) \(role, permission, grant_key, scope, effect\) values$/u;
13
+ function literals(line) {
14
+ return line.startsWith(" (") ? [...line.matchAll(LITERAL)].map((m) => m[0]) : [];
15
+ }
16
+ function keyOf(values) {
17
+ return values.join(", ");
18
+ }
19
+ /**
20
+ * The upsert statement, the keys deleted, and what follows the statement, read
21
+ * from a seeds text `seedSql` wrote; `undefined` for any other shape.
22
+ */
23
+ function parts(text) {
24
+ const lines = text.split("\n");
25
+ const delta = (lines[1] ?? "").startsWith(DELTA_PREFIX);
26
+ const tableLine = lines.find((line) => INSERT.test(line) || line.startsWith("delete from "));
27
+ const table = INSERT.exec(tableLine ?? "")?.[1] ?? /^delete from (\S+)$/u.exec(tableLine ?? "")?.[1];
28
+ const start = delta ? 1 : lines.findIndex((line) => INSERT.test(line));
29
+ const end = delta ? lines.indexOf(DELTA_END) : lines.findIndex((line, index) => index > start && line === ");");
30
+ if (!delta && table === void 0 || start === -1 || end === -1) return;
31
+ const rows = /* @__PURE__ */ new Map();
32
+ const deleted = [];
33
+ for (const line of lines.slice(start + 1, end)) {
34
+ const values = literals(line);
35
+ if (values.length === 5) rows.set(keyOf([
36
+ values[0] ?? "",
37
+ values[2] ?? "",
38
+ values[3] ?? ""
39
+ ]), keyOf(values));
40
+ else if (values.length === 3) deleted.push(keyOf(values));
41
+ }
42
+ return {
43
+ table: table ?? "",
44
+ rows,
45
+ deleted,
46
+ rest: lines.slice(end + 1).join("\n"),
47
+ delta
48
+ };
49
+ }
50
+ /**
51
+ * The rows the seeds migrations leave in place, replayed oldest first: a full
52
+ * migration sets them, a delta one upserts and deletes. `undefined` when a
53
+ * migration has another shape.
54
+ */
55
+ function replayedSeeds(texts) {
56
+ let rows = /* @__PURE__ */ new Map();
57
+ for (const text of texts) {
58
+ const read = parts(text);
59
+ if (read === void 0) return;
60
+ if (!read.delta) {
61
+ rows = new Map(read.rows);
62
+ continue;
63
+ }
64
+ for (const [key, row] of read.rows) rows.set(key, row);
65
+ for (const key of read.deleted) rows.delete(key);
66
+ }
67
+ return rows;
68
+ }
69
+ /**
70
+ * The delta migration from `applied` to the full seeds `text`: the marker line,
71
+ * the rows added or changed, the keys removed, then whatever `text` runs after
72
+ * its upsert. `undefined` when `text` has another shape.
73
+ */
74
+ function seedDeltaSql(applied, text, since) {
75
+ const next = parts(text);
76
+ if (next === void 0 || next.delta) return;
77
+ const upserts = [...next.rows].filter(([key, row]) => applied.get(key) !== row);
78
+ const removed = [...applied.keys()].filter((key) => !next.rows.has(key));
79
+ const [marker = ""] = text.split("\n");
80
+ return {
81
+ text: `${[
82
+ marker,
83
+ `${DELTA_PREFIX}${since}: +${String(upserts.length)}, -${String(removed.length)}`,
84
+ ...upserts.length === 0 ? [] : [
85
+ `insert into ${next.table} (role, permission, grant_key, scope, effect) values`,
86
+ upserts.map(([, row]) => ` (${row})`).join(",\n"),
87
+ "on conflict (role, grant_key, scope) do update",
88
+ " set permission = excluded.permission, effect = excluded.effect;"
89
+ ],
90
+ ...removed.length === 0 ? [] : [
91
+ `delete from ${next.table}`,
92
+ "where (role, grant_key, scope) in (values",
93
+ removed.map((key) => ` (${key})`).join(",\n"),
94
+ ");"
95
+ ],
96
+ DELTA_END
97
+ ].join("\n")}\n${next.rest}`,
98
+ added: upserts.length,
99
+ removed: removed.length,
100
+ same: upserts.length === 0 && removed.length === 0
101
+ };
102
+ }
103
+ /** What follows the upsert in a seeds text: the closure backfill and audit. */
104
+ function seedRest(text) {
105
+ return parts(text)?.rest;
106
+ }
6
107
  /** How `path` on disk differs from `expected`; `undefined` when `same` holds. */
7
108
  function fileDrift(path, expected, same = (a, b) => a === b) {
8
109
  if (!existsSync(path)) return { kind: "missing" };
@@ -164,7 +265,7 @@ function nextMigrationVersion(names, now) {
164
265
  const stamp = VERSION_PREFIX.exec(name)?.[0];
165
266
  return stamp === void 0 ? [] : [Date.UTC(Number(stamp.slice(0, 4)), Number(stamp.slice(4, 6)) - 1, Number(stamp.slice(6, 8)), Number(stamp.slice(8, 10)), Number(stamp.slice(10, 12)), Number(stamp.slice(12, 14)))];
166
267
  });
167
- return times.length === 0 ? migrationVersion(now) : migrationVersion(dateAt({ epochMilliseconds: Math.max(...times) + 1e3 }));
268
+ return migrationVersion(dateAt({ epochMilliseconds: Math.max(now.getTime(), ...times.map((time) => time + 1e3)) }));
168
269
  }
169
270
  /**
170
271
  * The seeds part in a migrations directory: the newest migration there that
@@ -176,22 +277,53 @@ function nextMigrationVersion(names, now) {
176
277
  * \`reserved\` holds paths, relative to \`cwd\`, that this run writes; the ones
177
278
  * in \`dir\` count as migrations already there.
178
279
  */
179
- function seedsMigration(cwd, dir, marker, text, now, label = "seeds", reserved = []) {
280
+ function seedsMigration(cwd, dir, marker, text, now, label = "seeds", reserved = [], options = {}) {
180
281
  const base = dir.endsWith("/") ? dir.slice(0, -1) : dir;
181
282
  const path = resolve(cwd, base);
182
- const latest = existsSync(path) ? readdirSync(path).filter((name) => name.endsWith(".sql")).toSorted().toReversed().find((name) => readFileSync(resolve(path, name), "utf8").startsWith(marker)) : void 0;
183
- if (latest !== void 0 && readFileSync(resolve(path, latest), "utf8") === text) return {
184
- rel: `${base}/${latest}`,
185
- current: true
283
+ const marked = existsSync(path) ? readdirSync(path).filter((name) => name.endsWith(".sql")).toSorted().flatMap((name) => {
284
+ const contents = readFileSync(resolve(path, name), "utf8");
285
+ return contents.startsWith(marker) ? [{
286
+ name,
287
+ contents
288
+ }] : [];
289
+ }) : [];
290
+ const latest = marked.at(-1);
291
+ if (latest?.contents === text) return {
292
+ rel: `${base}/${latest.name}`,
293
+ current: true,
294
+ text
295
+ };
296
+ const rel = `${base}/${nextMigrationVersion([...existsSync(path) ? readdirSync(path) : [], ...reserved.filter((rel) => resolve(cwd, dirname(rel)) === path).map((rel) => basename(rel))], now)}_permdock_${label}.sql`;
297
+ if (latest === void 0) return {
298
+ rel,
299
+ current: false,
300
+ text
301
+ };
302
+ const applied = options.delta === true ? replayedSeeds(marked.map((item) => item.contents)) : void 0;
303
+ const changed = applied === void 0 ? void 0 : seedDeltaSql(applied, text, latest.name);
304
+ if (changed === void 0) return {
305
+ rel,
306
+ current: false,
307
+ text,
308
+ delta: {
309
+ ...seedDelta(latest.contents, text),
310
+ since: latest.name
311
+ }
186
312
  };
187
- const delta = latest === void 0 ? void 0 : {
188
- ...seedDelta(readFileSync(resolve(path, latest), "utf8"), text),
189
- since: latest
313
+ if (changed.same && seedRest(latest.contents) === seedRest(text)) return {
314
+ rel: `${base}/${latest.name}`,
315
+ current: true,
316
+ text: latest.contents
190
317
  };
191
318
  return {
192
- rel: `${base}/${nextMigrationVersion([...existsSync(path) ? readdirSync(path) : [], ...reserved.filter((rel) => resolve(cwd, dirname(rel)) === path).map((rel) => basename(rel))], now)}_permdock_${label}.sql`,
319
+ rel,
193
320
  current: false,
194
- ...delta === void 0 ? {} : { delta }
321
+ text: changed.text,
322
+ delta: {
323
+ added: changed.added,
324
+ removed: changed.removed,
325
+ since: latest.name
326
+ }
195
327
  };
196
328
  }
197
329
  export { writeOutputFiles as _, isSeedsDirectory as a, outFiles as c, pgDeltaPath as d, seedDelta as f, underSchemaDir as g, serviceRel as h, fileDrift as i, parseSplit as l, seedsMigration as m, dataMigrationFile as n, migrationVersion as o, seedDeltaNote as p, driftOf as r, nextMigrationVersion as s, SPLIT_PARTS as t, partPath as u };
@@ -0,0 +1 @@
1
+ export { t as SPLIT_PARTS } from "./output-files-8lfALMSU.js";
@@ -1,12 +1,13 @@
1
1
  import { l as scopeChain, s as resolveScope } from "./scopes-B-KX9EI8.js";
2
2
  import { r as findRole } from "./vocabulary-CE2k7s1a.js";
3
- import { C as sourcesKeep, O as membershipRows, P as hasCustomRoleChecksFor, T as globalRoleRows, a as interactiveSessionSql, at as memberRoleOf, k as roleRows, l as disabledColumn, lt as scopeSources, nt as memberForTable, p as memberColumn, s as claimKeptLines, ut as scopeTable, y as sourceFilters, z as storedTenant } from "./interactive-only-C_olBCPl.js";
4
- import { A as tenantTypeOf, f as kindFilterSql, m as memberVia, s as signedIn, t as CUSTOM_ROLES, u as globalKindFilterSql, y as subjectIdSql } from "./shared-Cwxy5N16.js";
3
+ import { A as membershipRows, D as globalRoleRows, I as hasCustomRoleChecksFor, T as sourcesKeep, V as storedTenant, at as memberRoleOf, d as disabledColumn, h as memberColumn, j as roleRows, l as claimKeptLines, lt as scopeSources, n as delegatedGlobalSql, nt as memberForTable, o as interactiveSessionSql, ut as scopeTable, x as sourceFilters } from "./interactive-only-Dqww0ABO.js";
4
+ import { C as tenantTypeOf, a as kindFilterSql, f as subjectIdSql, r as globalKindFilterSql, s as memberVia } from "./subject-CrldGifz.js";
5
5
  import { i as qualifySqlTable } from "./sql-T4GaBh9X.js";
6
6
  import { l as roleColumn } from "./sources-DnjJPGfb.js";
7
7
  import { i as configError } from "./errors-DgLOqc6j.js";
8
8
  import { a as quoteIdent, i as qualified, n as declaredArray, o as quoteLiteral, s as quoteQualified } from "./quote-BKrTBbcH.js";
9
- import { _ as sourceTransferTriggerSql, b as ASSIGNMENTS, g as sourceRowsSql, h as sourceHoldersTriggerSql, m as pairsSql, p as holderSources, v as holdersTriggerSql, x as OWNERSHIP, y as transferTriggerSql } from "./tables-BDqfipr1.js";
9
+ import { s as signedIn, t as CUSTOM_ROLES } from "./shared-C6_T7QUo.js";
10
+ import { _ as sourceTransferTriggerSql, b as ASSIGNMENTS, g as sourceRowsSql, h as sourceHoldersTriggerSql, m as pairsSql, p as holderSources, v as holdersTriggerSql, x as OWNERSHIP, y as transferTriggerSql } from "./tables-CDq0HVVq.js";
10
11
  // src/cli/rls/assignments.ts
11
12
  /**
12
13
  * The client roles whose writes the assignment triggers check; any other role
@@ -244,7 +245,8 @@ function canAssignSql(base, own, forUser = false) {
244
245
  const ctx = forUser ? {
245
246
  ...base,
246
247
  subjectId: "p_user",
247
- tenants: "all"
248
+ tenants: "all",
249
+ namedUser: true
248
250
  } : base;
249
251
  const fn = qualified(ctx, forUser ? OWNERSHIP.canAssignFor : OWNERSHIP.canAssign);
250
252
  const parts = [];
@@ -254,19 +256,21 @@ function canAssignSql(base, own, forUser = false) {
254
256
  return `v_user_${String(index)}`;
255
257
  };
256
258
  const global = own.assigns.filter((pair) => pair.scope === "global");
259
+ const delegated = delegatedGlobalSql(ctx);
260
+ const gate = delegated === void 0 ? "" : ` and ${delegated}`;
257
261
  for (const [instance, pairs] of [["p_scope_id is not null", global.filter((pair) => pair.at !== "global")], ["p_scope_id is null", global.filter((pair) => pair.at === "global")]]) {
258
262
  if (pairs.length === 0) continue;
259
263
  if (ctx.authorize === "database") {
260
264
  const ur = globalRoleRows(ctx);
261
265
  const kind = globalKindFilterSql(ctx, ur.roleSql);
262
- parts.push(`${instance} and exists (
266
+ parts.push(`${instance}${gate} and exists (
263
267
  select 1 from ${ur.from}
264
268
  where ${ur.userSql} = ${subjectIdSql(ctx)}
265
269
  and (${ur.roleSql}, p_role) in (${pairsSql(pairs)})${kind === void 0 ? "" : `\n and ${kind}`}
266
270
  )`);
267
271
  } else {
268
272
  const kind = globalKindFilterSql(ctx, "r.role");
269
- parts.push(`${instance} and exists (
273
+ parts.push(`${instance}${gate} and exists (
270
274
  select 1 from ${roleRows(ctx)}
271
275
  where (r.role, p_role) in (${pairsSql(pairs)})${kind === void 0 ? "" : `\n and ${kind}`}
272
276
  )`);
@@ -3,7 +3,7 @@ import { n as copyJson, t as checkSchema } from "./json-schema-jtX26ydD.js";
3
3
  import { n as PermDockValidationError } from "./validation-error-CgDOA6VS.js";
4
4
  import { r as isRecord } from "./compact-C4LFuqbW.js";
5
5
  import { d as scopeList, s as resolveScope } from "./scopes-B-KX9EI8.js";
6
- import { t as catalogSchema } from "./schema-BeY3croo.js";
6
+ import { t as catalogSchema } from "./schema-D2OK4RrB.js";
7
7
  // src/catalog/references.ts
8
8
  function duplicates(issues, list, name, field) {
9
9
  const seen = /* @__PURE__ */ new Set();
@@ -1,4 +1,4 @@
1
- import { $t as LocalSnapshotManifest } from "./policy-types-93NwI8iI.js";
1
+ import { en as LocalSnapshotManifest } from "./policy-types-CfW4X_yX.js";
2
2
  /**
3
3
  * Whether `value` has the shape `localSnapshotManifest(policy)` writes, with no
4
4
  * prototype keys. A JSON import widens `v: 1` to `number`; this narrows it back
@@ -1,6 +1,6 @@
1
- import { o as PermDockOptions } from "../permdock-Dz3yzWrp.js";
2
- import { D as Policy, N as PolicyVocabulary, Sr as Principal, Y as DecisionProvider } from "../policy-types-93NwI8iI.js";
3
- import { a as RelationMap, c as RemotePdpEndpoints, d as SpiceDbCheck, f as SpiceDbOptions, i as PdpPermDock, l as RemotePdpMapping, n as OpenFgaTuple, o as RemotePdpAuth, r as PdpFactory, s as RemotePdpCache, t as OpenFgaOptions, u as RemotePdpOptions } from "../types-DONLJQjY.js";
1
+ import { o as PermDockOptions } from "../permdock-BShHM8OJ.js";
2
+ import { D as Policy, Er as Principal, N as PolicyVocabulary, Y as DecisionProvider } from "../policy-types-CfW4X_yX.js";
3
+ import { a as RelationMap, c as RemotePdpEndpoints, d as SpiceDbCheck, f as SpiceDbOptions, i as PdpPermDock, l as RemotePdpMapping, n as OpenFgaTuple, o as RemotePdpAuth, r as PdpFactory, s as RemotePdpCache, t as OpenFgaOptions, u as RemotePdpOptions } from "../types-BsRf5rKk.js";
4
4
  /**
5
5
  * The PDP-aware instance, built synchronously like core `getPermDockSync`; use
6
6
  * `getPermDock` for asynchronous inputs.
package/dist/pdp/index.js CHANGED
@@ -4,8 +4,8 @@ import { n as PermDockValidationError } from "../validation-error-CgDOA6VS.js";
4
4
  import { a as deniedMessage, i as approvalMessage, n as PermDockDeniedError, t as PermDockApprovalRequiredError } from "../errors-DOSkVeTC.js";
5
5
  import { n as freezeDeep } from "../freeze-DGfJq_j2.js";
6
6
  import { n as internalsOf, t as attachInternals } from "../internals-D58TnmDB.js";
7
- import { n as getPermDockSync$1, t as getPermDock$1 } from "../permdock-BueSeg7X.js";
8
- import { a as getResource, c as listPermissions } from "../permission-registry-DMYRZVcn.js";
7
+ import { n as getPermDockSync$1, t as getPermDock$1 } from "../permdock-CJPIwU1T.js";
8
+ import { a as getResource, c as listPermissions } from "../permission-registry-DstT40VS.js";
9
9
  import { a as postJson, c as ttlMs, i as joinUrl, n as denied, o as resourceIdOf, r as granted, s as ttlCache, t as cacheKey } from "../shared-BOsJIQf4.js";
10
10
  import { n as toWireDelegation } from "../wire-delegation-DC5Cyec4.js";
11
11
  // src/pdp/create.ts
@@ -1,7 +1,7 @@
1
- import { D as Policy, Dr as AdapterId, J as CustomRoleSourceFactory, N as PolicyVocabulary, Q as Intent, Qn as Decision, Sr as Principal, Tn as Scope, X as DecisionSink, Z as EntitlementSource, _ as Grant, _t as TokenSigner, ar as LimitDetail, cn as SnapshotTenants, cr as Quota, ct as RelationSource, fr as Actor, it as MembershipSource, kr as Condition, lt as SettingsSource, nt as LimitStore, o as ApprovalOption, pn as DecisionEvent, q as CustomRoleSource, qt as Instant, rr as ExplainedDecision, sr as Obligation, tn as Snapshot, un as AuthEvent, vr as Delegation, wr as Subject, xr as Membership, y as GrantLimit } from "./policy-types-93NwI8iI.js";
2
- import { K as AppData, P as ResourceNode, V as RowOf, a as RoleTree, n as PlanTree, r as Role, w as Permission } from "./vocabulary-FYgI_NoI.js";
3
- import { i as OperationEffect, s as OperationMeta, t as Operation, u as OperationRisk } from "./operations-BS8ExH5A.js";
4
- import { a as HostedPolicies } from "./hosted-DUbuh0Td.js";
1
+ import { D as Policy, Er as Principal, J as CustomRoleSourceFactory, N as PolicyVocabulary, Nr as Condition, Or as Subject, Q as Intent, Sr as Delegation, Tr as Membership, X as DecisionSink, Z as EntitlementSource, _ as Grant, _n as DecisionEvent, _t as TokenSigner, ct as RelationSource, dn as SnapshotTenants, dr as Obligation, fr as Quota, gr as Actor, it as MembershipSource, jr as AdapterId, kn as Scope, lr as LimitDetail, lt as SettingsSource, mn as AuthEvent, nn as Snapshot, nr as Decision, nt as LimitStore, o as ApprovalOption, q as CustomRoleSource, qt as Instant, sr as ExplainedDecision, y as GrantLimit } from "./policy-types-CfW4X_yX.js";
2
+ import { K as AppData, P as ResourceNode, V as RowOf, a as RoleTree, n as PlanTree, r as Role, w as Permission } from "./vocabulary-DHfKPIC5.js";
3
+ import { i as OperationEffect, s as OperationMeta, t as Operation, u as OperationRisk } from "./operations-DaEoGpMV.js";
4
+ import { a as HostedPolicies } from "./hosted-Bkw3Oyh-.js";
5
5
  /**
6
6
  * One approval requirement kept as data, for a tenant or the whole platform. It
7
7
  * adds to what the code requires and never removes a requirement.
@@ -187,7 +187,7 @@ type InstanceCacheKey = {
187
187
  * an edit of a role moves the key, so the instance is rebuilt.
188
188
  */
189
189
  readonly customRolesVersion?: number;
190
- readonly intent: "read" | "write";
190
+ readonly intent: Intent;
191
191
  readonly parts: unknown;
192
192
  };
193
193
  /**
@@ -514,6 +514,12 @@ type SnapshotOptions = {
514
514
  * inline. Without the bundle on the client those roles grant nothing.
515
515
  */
516
516
  readonly omitStatic?: boolean;
517
+ /**
518
+ * The most grants one tenant may carry. A tenant over it keeps none and is
519
+ * listed in `truncated`; the client denies a check there, so it asks the
520
+ * server.
521
+ */
522
+ readonly maxGrantsPerTenant?: number;
517
523
  readonly signer?: TokenSigner;
518
524
  readonly audience?: string | readonly string[];
519
525
  };
@@ -1,14 +1,14 @@
1
1
  import { n as isReadonlyArray, r as isRecord, t as compact } from "./compact-C4LFuqbW.js";
2
- import { D as emptyListeners, E as emitSafe, N as contactMemberships, O as finish, P as isContact, _ as indexCustomRoles, i as customRolesFor, o as roleSourceFor, r as assignableNamesFor, s as sourceName, t as evaluate } from "./evaluate-D8SdfP3h.js";
2
+ import { A as emptyListeners, I as contactMemberships, L as isContact, a as assignableNamesFor, c as roleSourceFor, j as finish, k as emitSafe, l as sourceName, o as customRolesFor, t as evaluate, y as indexCustomRoles } from "./evaluate-Dmd0bShm.js";
3
3
  import { n as PermDockValidationError } from "./validation-error-CgDOA6VS.js";
4
4
  import { n as isThenable } from "./thenable-BxMy2v8w.js";
5
- import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, m as roleMeta, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot-DdGOpSfN.js";
5
+ import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, m as roleMeta, n as snapshotScopes, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot-D9kjL37B.js";
6
6
  import { i as readAppData } from "./app-data-DbSPSPIl.js";
7
7
  import { n as pickVisible, r as sanitizeContext } from "./fields-C0L2FoZk.js";
8
8
  import { n as freezeDeep, t as freezeCopy } from "./freeze-DGfJq_j2.js";
9
9
  import { t as byCodePoint } from "./compare-dfHDj8kT.js";
10
- import { _ as keyToScope, a as getResource, c as listPermissions, g as formerScopes, n as findPermission } from "./permission-registry-DMYRZVcn.js";
11
- import { f as policyX, n as declaredRoleNames } from "./policy-DFD2J5o_.js";
10
+ import { _ as keyToScope, a as getResource, c as listPermissions, g as formerScopes, n as findPermission } from "./permission-registry-DstT40VS.js";
11
+ import { f as policyX, n as declaredRoleNames } from "./policy-BBvhhH9X.js";
12
12
  import { d as scopeList, o as normalizeMemberships, p as tenantOf, s as resolveScope } from "./scopes-B-KX9EI8.js";
13
13
  import { r as isSubject, t as anonymousSubject } from "./subject-DkxY-AhF.js";
14
14
  import { c as nowSeconds, d as resolveActiveTenant, m as tenantsOf, p as scopeField, t as heldRoleNamesIn, u as relatesTo } from "./tenancy-B5Xxt9Sc.js";
@@ -16,14 +16,15 @@ import { a as deniedMessage, i as approvalMessage, n as PermDockDeniedError, t a
16
16
  import { i as decideAllWith, n as canAllWith } from "./checks-DSm45qH7.js";
17
17
  import { t as canonicalJson } from "./canonical-json-BibZkXtE.js";
18
18
  import { r as sha256Digest } from "./sha256-DFsnyVPo.js";
19
- import { i as internGrants, t as compactSnapshot } from "./snapshot-compact-CwAop_6C.js";
19
+ import { a as internGrants, n as compactSnapshot } from "./snapshot-compact-yXFxZLPo.js";
20
+ import { i as withoutRequirement } from "./snapshot-requires-DfUqCLEb.js";
21
+ import { a as snapshotVocabulary, i as snapshotGrant, s as subjectFromSnapshot } from "./snapshot-Ty0uk9wZ.js";
20
22
  import { r as findRole } from "./vocabulary-CE2k7s1a.js";
21
- import { a as permittedScopeIds, c as deniedFor, i as permittedIds, n as filterIds, o as withExpandedView, r as mayUseOf, s as decideForTarget } from "./may-use-Died1tNU.js";
22
- import { o as flattenGrantee } from "./grantee-BPUG6f0r.js";
23
- import { i as whereFromGrants, r as subjectInTenant, t as evaluateSnapshot } from "./snapshot-evaluate-9RGy7J3N.js";
24
- import { i as snapshotGrant, o as subjectFromSnapshot } from "./snapshot-DckMnHk8.js";
23
+ import { a as permittedScopeIds, c as deniedFor, i as permittedIds, n as filterIds, o as withExpandedView, r as mayUseOf, s as decideForTarget } from "./may-use-4HzzgYJ3.js";
24
+ import { o as flattenGrantee } from "./grantee-BSCdpIF3.js";
25
+ import { i as whereFromGrants, r as subjectInTenant, t as evaluateSnapshot } from "./snapshot-evaluate-DSNj2rhV.js";
25
26
  import { t as attachInternals } from "./internals-D58TnmDB.js";
26
- import { n as signSnapshot, t as filterMemberships } from "./membership-filter-CSKH48eD.js";
27
+ import { n as signSnapshot, t as filterMemberships } from "./membership-filter-C7ZuhAqJ.js";
27
28
  import { r as relationReader, t as pendingRelations } from "./relations-CIgB5KPJ.js";
28
29
  // src/core/granted-permissions.ts
29
30
  /**
@@ -78,15 +79,19 @@ function teamOf(policy, options) {
78
79
  // src/core/client-bundle.ts
79
80
  /** What a role holder is checked against; no real id can equal it. */
80
81
  const PROBE = "$probe";
81
- function termsOf(grant) {
82
+ /**
83
+ * A grant's terms as the wire writes them: without its membership, and without
84
+ * the requirement its subject's `requires` table places.
85
+ */
86
+ function wireTerms(grant, snapshot) {
82
87
  const { permission, membership: _membership, ...terms } = grant;
83
88
  return {
84
89
  permission,
85
- terms
90
+ ...withoutRequirement(terms, snapshot.requires, snapshot.subject.principal?.memberships ?? [])
86
91
  };
87
92
  }
88
- function canonOf(grant) {
89
- const { permission, terms } = termsOf(grant);
93
+ function canonOf(grant, snapshot) {
94
+ const { permission, ...terms } = wireTerms(grant, snapshot);
90
95
  return canonicalJson([permission, terms]);
91
96
  }
92
97
  /** The membership a probe holder of `role` has on `scope`, with its ancestors. */
@@ -106,26 +111,39 @@ function probeMembership(policy, role, scope) {
106
111
  roles: [role]
107
112
  };
108
113
  }
109
- /** The grants a holder of only `role` receives, or `undefined` when none. */
110
- function roleGrants(policy, role) {
111
- const on = policy.rolesByName.get(role)?.on ?? findRole(policy.vocabulary?.roles, role)?.on;
112
- const scope = on === void 0 ? void 0 : resolveScope(scopeList(policy.scopes), on);
113
- if (on !== void 0 && scope === void 0) return;
114
- const membership = scope === void 0 ? void 0 : probeMembership(policy, role, scope);
115
- const grants = snapshotOf(policy, {
116
- principal: {
117
- id: PROBE,
118
- roles: membership === void 0 ? [role] : [],
119
- ...membership === void 0 ? {} : { memberships: [membership] }
120
- },
114
+ function probeSnapshot(policy, principal) {
115
+ return snapshotOf(policy, {
116
+ principal,
121
117
  context: {}
122
118
  }, {
123
119
  customRoles: [],
124
120
  omitAssignable: true,
125
121
  omitTypeLevel: true,
126
122
  tenants: "all"
127
- }).grants.filter((grant) => grant.role === role);
128
- return grants.length === 0 ? void 0 : grants;
123
+ });
124
+ }
125
+ function probeGroup(snapshot, keep) {
126
+ const grants = snapshot.grants.filter(keep);
127
+ return grants.length === 0 ? void 0 : {
128
+ terms: grants.map((grant) => wireTerms(grant, snapshot)),
129
+ canon: grants.map((grant) => canonOf(grant, snapshot))
130
+ };
131
+ }
132
+ /** The grants a holder of only `role` receives, or `undefined` when none. */
133
+ function roleGrants(policy, role) {
134
+ const on = policy.rolesByName.get(role)?.on ?? findRole(policy.vocabulary?.roles, role)?.on;
135
+ const scope = on === void 0 ? void 0 : resolveScope(scopeList(policy.scopes), on);
136
+ if (on !== void 0 && scope === void 0) return;
137
+ const membership = scope === void 0 ? void 0 : probeMembership(policy, role, scope);
138
+ return probeGroup(probeSnapshot(policy, {
139
+ id: PROBE,
140
+ roles: membership === void 0 ? [role] : [],
141
+ ...membership === void 0 ? {} : { memberships: [membership] }
142
+ }), (grant) => grant.role === role);
143
+ }
144
+ /** A grant held without a role or membership: the bundle's shared group. */
145
+ function isShared(grant) {
146
+ return grant.role === null && grant.membership === void 0;
129
147
  }
130
148
  /**
131
149
  * The static grants of every declared role, as a document the app ships as a
@@ -144,13 +162,8 @@ function memoOf(policy) {
144
162
  const index = /* @__PURE__ */ new Map();
145
163
  const roles = {};
146
164
  const expected = /* @__PURE__ */ new Map();
147
- for (const name of names) {
148
- const grants = roleGrants(policy, name);
149
- if (grants === void 0) continue;
150
- const interned = internGrants(grants.map((grant) => {
151
- const { membership: _membership, ...bare } = grant;
152
- return bare;
153
- }));
165
+ const pooled = (group) => {
166
+ const interned = internGrants(group.terms);
154
167
  const remap = interned.conditions.map((terms) => {
155
168
  const key = canonicalJson(terms);
156
169
  let at = index.get(key);
@@ -161,24 +174,46 @@ function memoOf(policy) {
161
174
  }
162
175
  return at;
163
176
  });
164
- const mapped = interned.grants.map((grant) => ({
165
- permission: grant.permission,
166
- cond: Array.isArray(grant.cond) ? grant.cond.map((at) => remap[at] ?? at) : remap[grant.cond] ?? grant.cond
167
- }));
168
- const canon = grants.map(canonOf);
169
- expected.set(name, canon);
170
- roles[name] = {
171
- digest: sha256Digest(canonicalJson(canon)),
172
- grants: mapped
177
+ return {
178
+ digest: sha256Digest(canonicalJson(group.canon)),
179
+ grants: interned.grants.map((grant) => ({
180
+ permission: grant.permission,
181
+ cond: Array.isArray(grant.cond) ? grant.cond.map((at) => remap[at] ?? at) : remap[grant.cond] ?? grant.cond
182
+ }))
173
183
  };
184
+ };
185
+ for (const name of names) {
186
+ const group = roleGrants(policy, name);
187
+ if (group !== void 0) {
188
+ expected.set(name, group.canon);
189
+ roles[name] = pooled(group);
190
+ }
174
191
  }
192
+ const sharedGroup = probeGroup(probeSnapshot(policy, {
193
+ id: PROBE,
194
+ roles: []
195
+ }), isShared);
196
+ const shared = sharedGroup === void 0 ? void 0 : pooled(sharedGroup);
197
+ const scopes = snapshotScopes(policy);
198
+ const vocabulary = snapshotVocabulary(policy.vocabulary);
199
+ const keys = listPermissions(policy.permissions).map((leaf) => leaf.key).toSorted();
175
200
  const memo = {
176
- bundle: Object.freeze({
177
- v: 1,
178
- conditions: Object.freeze(pool),
179
- roles: Object.freeze(roles)
201
+ bundle: freezeDeep({
202
+ v: 2,
203
+ digest: sha256Digest(canonicalJson({
204
+ vocabulary,
205
+ scopes,
206
+ keys
207
+ })),
208
+ keys,
209
+ conditions: pool,
210
+ roles,
211
+ ...shared === void 0 ? {} : { shared },
212
+ ...vocabulary === void 0 ? {} : { vocabulary },
213
+ ...scopes === void 0 ? {} : { scopes }
180
214
  }),
181
- expected
215
+ expected,
216
+ ...sharedGroup === void 0 ? {} : { shared: sharedGroup.canon }
182
217
  };
183
218
  policy.index.bundle.set(policy, memo);
184
219
  return memo;
@@ -193,7 +228,7 @@ function sameList(a, b) {
193
228
  * `include`) stays inline, so the client never rebuilds a rule.
194
229
  */
195
230
  function compactWithBundle(policy, expanded) {
196
- const { bundle, expected: expectedByRole } = memoOf(policy);
231
+ const { bundle, expected: expectedByRole, shared } = memoOf(policy);
197
232
  const memberships = expanded.subject.principal?.memberships ?? [];
198
233
  const memberAt = /* @__PURE__ */ new Map();
199
234
  for (const [at, membership] of memberships.entries()) {
@@ -202,8 +237,15 @@ function compactWithBundle(policy, expanded) {
202
237
  }
203
238
  const keys = /* @__PURE__ */ new WeakMap();
204
239
  const groups = /* @__PURE__ */ new Map();
240
+ const sharedAt = [];
241
+ const sharedCanon = [];
205
242
  for (const [at, grant] of expanded.grants.entries()) {
206
243
  const role = grant.role;
244
+ if (isShared(grant)) {
245
+ sharedAt.push(at);
246
+ sharedCanon.push(canonOf(grant, expanded));
247
+ continue;
248
+ }
207
249
  if (role === null || !expectedByRole.has(role)) continue;
208
250
  let member = "";
209
251
  if (grant.membership !== void 0) {
@@ -218,7 +260,7 @@ function compactWithBundle(policy, expanded) {
218
260
  canon: []
219
261
  };
220
262
  group.at.push(at);
221
- group.canon.push(canonOf(grant));
263
+ group.canon.push(canonOf(grant, expanded));
222
264
  groups.set(id, group);
223
265
  }
224
266
  const removed = /* @__PURE__ */ new Set();
@@ -234,15 +276,18 @@ function compactWithBundle(policy, expanded) {
234
276
  held.push([group.role, index]);
235
277
  digests[group.role] = entry.digest;
236
278
  }
237
- if (held.length === 0) return compactSnapshot(expanded);
279
+ const sharedDigest = shared !== void 0 && bundle.shared !== void 0 && sameList(sharedCanon, shared) ? bundle.shared.digest : void 0;
280
+ if (sharedDigest !== void 0) for (const at of sharedAt) removed.add(at);
281
+ if (held.length === 0 && sharedDigest === void 0) return compactSnapshot(expanded, void 0, bundle);
238
282
  const wire = {
239
283
  held,
240
- digests
284
+ digests,
285
+ ...sharedDigest === void 0 ? {} : { shared: sharedDigest }
241
286
  };
242
287
  return compactSnapshot({
243
288
  ...expanded,
244
289
  grants: expanded.grants.filter((_, at) => !removed.has(at))
245
- }, wire);
290
+ }, wire, bundle);
246
291
  }
247
292
  // src/core/app.ts
248
293
  const APP = Symbol.for("permdock.app");
@@ -550,7 +595,8 @@ function assemblePrincipal(policy, user, options, auth, memo) {
550
595
  kind: of.kind
551
596
  }), compact({
552
597
  tenant: options.tenant,
553
- memo
598
+ memo,
599
+ reason: from.claimsFirst === true ? of.membershipsTruncated === true ? "truncated" : "stale" : void 0
554
600
  }));
555
601
  } catch {
556
602
  auth.push({
@@ -1279,6 +1325,7 @@ function buildInstance(policy, subject, envBase, team) {
1279
1325
  include: options?.include,
1280
1326
  tenants: options?.tenants,
1281
1327
  omitAssignable: options?.omitAssignable,
1328
+ maxGrantsPerTenant: options?.maxGrantsPerTenant,
1282
1329
  simulated: envBase.simulated
1283
1330
  }));
1284
1331
  const snapshot = options?.omitStatic === true ? compactWithBundle(policy, expanded) : compactSnapshot(expanded);
@@ -10,6 +10,35 @@ const NODE_RESOURCE = Symbol.for("permdock.resource");
10
10
  const TREE_LEAVES = Symbol.for("permdock.leaves");
11
11
  const TREE_LOOKUP = Symbol.for("permdock.lookup");
12
12
  const LEAF_FORMER = Symbol.for("permdock.former");
13
+ // src/core/action-answers.ts
14
+ /** The maps of better-supabase's `actionKeys`, as an answer's first segment. */
15
+ const ANSWER_KINDS = [
16
+ "blocks",
17
+ "recordTypes",
18
+ "buckets",
19
+ "topics"
20
+ ];
21
+ const ANSWER = /^(blocks|recordTypes|buckets|topics)\.([^.\s]+)\.([^.\s]+)$/u;
22
+ function isAnswerKind(value) {
23
+ return ANSWER_KINDS.some((kind) => kind === value);
24
+ }
25
+ /** `entry` split into its parts, or `undefined` when it is not an answer. */
26
+ function parseAnswer(entry) {
27
+ if (typeof entry !== "string") return;
28
+ const match = ANSWER.exec(entry);
29
+ const [, kind = "", name = "", action = ""] = match ?? [];
30
+ return match !== null && isAnswerKind(kind) ? {
31
+ kind,
32
+ name,
33
+ action
34
+ } : void 0;
35
+ }
36
+ /** Throws unless `value` is absent or a list of answers. */
37
+ function checkAnswers(value, action) {
38
+ if (value === void 0) return;
39
+ if (!Array.isArray(value)) throw new TypeError(`PermDock: meta.answers of action '${action}' must be an array`);
40
+ for (const entry of value) if (parseAnswer(entry) === void 0) throw new TypeError(`PermDock: meta.answers of action '${action}' has ${JSON.stringify(entry)}; write <${ANSWER_KINDS.join("|")}>.<name>.<action>`);
41
+ }
13
42
  // src/core/permission-leaf.ts
14
43
  function isStandardSchema(value) {
15
44
  return value !== null && typeof value === "object" && "~standard" in value && typeof value["~standard"]?.version === "number";
@@ -23,6 +52,7 @@ function isResourceOptions(value) {
23
52
  function metaFor(list, action, schema) {
24
53
  if (list === void 0 || Array.isArray(list)) return freezeDeep({});
25
54
  const meta = list[action];
55
+ checkAnswers(meta?.answers, action);
26
56
  if (meta?.x === void 0) return freezeDeep({ ...meta });
27
57
  return freezeDeep({
28
58
  ...meta,
@@ -410,4 +440,4 @@ function renamedKeys(tree) {
410
440
  for (const leaf of listPermissions(tree)) for (const old of formerKeys(leaf)) map.set(old, leaf.key);
411
441
  return map;
412
442
  }
413
- export { keyToScope as _, getResource as a, listPermissions as c, attachRegistry as d, resourceOfNode as f, formerScopes as g, formerKeys as h, getRegistry as i, mergePermissions as l, annotationsFor as m, findPermission as n, isPermission as o, walk as p, formerByKey as r, isRegistryTree as s, assertKeys as t, renamedKeys as u, resource as v };
443
+ export { keyToScope as _, getResource as a, listPermissions as c, attachRegistry as d, resourceOfNode as f, formerScopes as g, formerKeys as h, getRegistry as i, mergePermissions as l, annotationsFor as m, findPermission as n, isPermission as o, walk as p, formerByKey as r, isRegistryTree as s, assertKeys as t, renamedKeys as u, resource as v, parseAnswer as y };
@@ -1,5 +1,5 @@
1
1
  import { n as freezeDeep } from "./freeze-DGfJq_j2.js";
2
- import { d as attachRegistry, p as walk, r as formerByKey, t as assertKeys } from "./permission-registry-DMYRZVcn.js";
2
+ import { d as attachRegistry, p as walk, r as formerByKey, t as assertKeys } from "./permission-registry-DstT40VS.js";
3
3
  import { r as assertGraphTargets } from "./resource-relations-Ck5sjYQR.js";
4
4
  // src/core/permissions.ts
5
5
  function definePermissions(input, options) {
@@ -1,4 +1,4 @@
1
- import { A as ResourceInit, C as InferPermissionTree, r as Role, t as Plan } from "./vocabulary-FYgI_NoI.js";
1
+ import { A as ResourceInit, C as InferPermissionTree, r as Role, t as Plan } from "./vocabulary-DHfKPIC5.js";
2
2
  import { StandardSchemaV1 } from "@standard-schema/spec";
3
3
  declare const SaasProjectSchema: StandardSchemaV1<SaasProject>;
4
4
  declare const SaasDocSchema: StandardSchemaV1<SaasDoc>;