permdock 0.32.0 → 0.34.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 (378) hide show
  1. package/dist/a2a/index.d.ts +4 -4
  2. package/dist/a2a/index.js +2 -2
  3. package/dist/{adoption-scan-BJMEEu7V.js → adoption-scan-BPW1eWy5.js} +1 -1
  4. package/dist/agent/index.d.ts +2 -2
  5. package/dist/agent/index.js +1 -1
  6. package/dist/ai-sdk/index.d.ts +3 -3
  7. package/dist/ai-sdk/index.js +3 -3
  8. package/dist/app/index.d.ts +1 -1
  9. package/dist/app/index.js +1 -1
  10. package/dist/{approval-chain-D97rgMoA.js → approval-chain-BEeExHpb.js} +15 -10
  11. package/dist/{approval-prompt-yNyhQqn8.d.ts → approval-prompt-CJvYBdja.d.ts} +1 -1
  12. package/dist/approvals/index.d.ts +3 -3
  13. package/dist/{arazzo-C_xK2Kaa.js → arazzo-BUXKjylF.js} +1 -1
  14. package/dist/{arazzo-BAgh0PT6.js → arazzo-DqzmZG-x.js} +2 -2
  15. package/dist/astro/index.d.ts +4 -4
  16. package/dist/astro/index.js +1 -1
  17. package/dist/{audience-CARf-b-R.js → audience-B6DQ5wQu.js} +1 -1
  18. package/dist/authzen/index.d.ts +6 -6
  19. package/dist/authzen/index.js +1 -1
  20. package/dist/{automation-0VF1xe4o.d.ts → automation-BqUmdFfe.d.ts} +1 -1
  21. package/dist/better-auth/index.d.ts +1 -1
  22. package/dist/better-supabase/index.d.ts +34 -13
  23. package/dist/better-supabase/index.js +21 -21
  24. package/dist/{bind-zQacwAOg.d.ts → bind-Bwk9tt1z.d.ts} +7 -7
  25. package/dist/{bind-BYeoLJgN.js → bind-DPptdk31.js} +2 -2
  26. package/dist/{bsb-access-tags-CjeR7v7-.js → bsb-access-tags-Nv4nDQ2U.js} +11 -2
  27. package/dist/{budgets-Dpumu_Dt.js → budgets-hi-ecgEd.js} +3 -3
  28. package/dist/{build-instance-CFiegi_w.js → build-instance-DZEWYO-A.js} +1 -1
  29. package/dist/bundle-size-BRFeBvuv.js +1 -0
  30. package/dist/{bundle-size-Ddhv_H_v.js → bundle-size-DbXV65Ix.js} +2 -2
  31. package/dist/{capability-BPzseilU.d.ts → capability-qoD_jlcI.d.ts} +1 -1
  32. package/dist/{casbin-EwdKipQs.js → casbin-CM9mWO1V.js} +1 -1
  33. package/dist/{casbin-BErdqy1J.js → casbin-qEW6RfXA.js} +1 -1
  34. package/dist/catalog/index.d.ts +4 -4
  35. package/dist/catalog/index.js +4 -4
  36. package/dist/{challenge-CRB1X3Ry.js → challenge-E9sicsCA.js} +1 -1
  37. package/dist/chat/index.d.ts +1 -1
  38. package/dist/chat/index.js +1 -1
  39. package/dist/chat-sdk/index.d.ts +3 -3
  40. package/dist/{claims-size-BsSDVD5u.js → claims-size-BUhCWS88.js} +18 -3
  41. package/dist/claims-size-C6oKGuOM.js +1 -0
  42. package/dist/claude-agent/index.d.ts +3 -3
  43. package/dist/claude-agent/index.js +2 -2
  44. package/dist/clerk/index.d.ts +2 -2
  45. package/dist/cli/bin.js +1 -1
  46. package/dist/cli/generate/watch-worker.js +1 -1
  47. package/dist/cli/index.d.ts +6 -6
  48. package/dist/cli/index.js +2 -2
  49. package/dist/cli/plugins/app.d.ts +1 -1
  50. package/dist/cli/plugins/app.js +1 -1
  51. package/dist/cli/plugins/better-supabase.d.ts +1 -1
  52. package/dist/cli/plugins/openapi.d.ts +1 -1
  53. package/dist/cli/plugins/openapi.js +1 -1
  54. package/dist/cli/plugins/powersync.d.ts +1 -1
  55. package/dist/cli/plugins/powersync.js +1 -1
  56. package/dist/cli/plugins/rls.d.ts +2 -2
  57. package/dist/cli/plugins/rls.js +1 -1
  58. package/dist/cli/plugins/schemas.d.ts +1 -1
  59. package/dist/cli/plugins/schemas.js +1 -1
  60. package/dist/cli/plugins/scim.d.ts +2 -2
  61. package/dist/cli/plugins/supabase-hook.d.ts +2 -2
  62. package/dist/cli/plugins/supabase-hook.js +1 -1
  63. package/dist/cli/plugins/supabase.d.ts +3 -3
  64. package/dist/cli/plugins/supabase.js +2 -2
  65. package/dist/cli/plugins/ui.d.ts +1 -1
  66. package/dist/cli/plugins/ui.js +1 -1
  67. package/dist/{client-subject-xCSkKD1C.d.ts → client-subject-Dzo49nco.d.ts} +2 -2
  68. package/dist/cloud/index.d.ts +8 -8
  69. package/dist/cloud/index.js +1 -1
  70. package/dist/{cloud-DW3q3qnp.js → cloud-CNGblWX0.js} +2 -2
  71. package/dist/{codemod-DVDMFsTX.js → codemod-BtJFcsD7.js} +5 -5
  72. package/dist/{codemod-CF7NNDzA.js → codemod-Dlhxov9D.js} +1 -1
  73. package/dist/compile/index.d.ts +1 -1
  74. package/dist/{compile-tG1zkSgX.d.ts → compile-DNgpHgcK.d.ts} +2 -2
  75. package/dist/{compile-BXKYYmT1.js → compile-nR1gQhXo.js} +10 -9
  76. package/dist/{completion-B59uPAnZ.js → completion-BIN9YXIe.js} +1 -1
  77. package/dist/{config-VCa1RLUe.js → config-CoYhD6ur.js} +1 -1
  78. package/dist/{config-report-CjvA6lGI.js → config-report-D_L1HXDb.js} +3 -3
  79. package/dist/{context-CAFddgb9.js → context-D8tN3SZm.js} +1 -1
  80. package/dist/{context-BQHKgT1m.js → context-Nr3nknZX.js} +2 -2
  81. package/dist/convex/index.d.ts +4 -4
  82. package/dist/convex/index.js +2 -2
  83. package/dist/{core-C5yCD-Ls.js → core-DIUrkFNL.js} +5 -5
  84. package/dist/{core-bf8qgaZf.d.ts → core-DPuDmlbL.d.ts} +2 -2
  85. package/dist/{create-Cn5EpEez.d.ts → create-BKrKxipb.d.ts} +4 -4
  86. package/dist/{create-COQVXK6C.js → create-BMRnaZel.js} +3 -3
  87. package/dist/{create-nOWD3Joc.js → create-BRY0OtFV.js} +3 -3
  88. package/dist/{create-B7Xa4jSQ.d.ts → create-CdB9FCZh.d.ts} +7 -7
  89. package/dist/{create-DHA0fhmi.d.ts → create-CdbVXh5I.d.ts} +6 -6
  90. package/dist/{credentials-COT-cjnP.d.ts → credentials-Dl0-R2aB.d.ts} +2 -2
  91. package/dist/{custom-role-rebuild-BK73tPib.js → custom-role-rebuild-wzN8pqDk.js} +5 -5
  92. package/dist/{define-permdock-DBgwTFi1.d.ts → define-permdock-4IkoNaB3.d.ts} +6 -6
  93. package/dist/{define-permdock-D7aKxIax.js → define-permdock-CO7YNrOF.js} +2 -2
  94. package/dist/{definition-options-9o8Hdww3.js → definition-options-DO0kIrB9.js} +7 -1
  95. package/dist/delivery/index.d.ts +4 -4
  96. package/dist/delivery/index.js +1 -1
  97. package/dist/{denied-text-C_AWc0f0.d.ts → denied-text-CllTzVJM.d.ts} +1 -1
  98. package/dist/{describe-AdETpWsn.d.ts → describe-FT1oVN_o.d.ts} +1 -1
  99. package/dist/{diff-CW9eZy9X.js → diff-CS8ks9h3.js} +1 -1
  100. package/dist/{diff-COdwpP31.js → diff-CkSZF7LO.js} +2 -2
  101. package/dist/{doctor-ervtBRzG.js → doctor-Bn5OPJMB.js} +94 -35
  102. package/dist/{doctor-ELj5hrVv.js → doctor-C9lLeLp2.js} +2 -2
  103. package/dist/drizzle/index.d.ts +3 -3
  104. package/dist/elysia/index.d.ts +4 -4
  105. package/dist/elysia/index.js +1 -1
  106. package/dist/{errors-COoiWqIs.d.ts → errors-BGosrHl8.d.ts} +1 -1
  107. package/dist/{evaluate-Dmd0bShm.js → evaluate-DNz6wMYv.js} +1 -1
  108. package/dist/{evaluations-GW9j_ARq.d.ts → evaluations-CaXNkxTp.d.ts} +3 -3
  109. package/dist/{evaluator-eager-CpVYslzY.js → evaluator-eager-BLNVbEAC.js} +1 -1
  110. package/dist/evaluator-zpeC7zel.js +2 -0
  111. package/dist/eve/index.d.ts +4 -4
  112. package/dist/eve/index.js +2 -2
  113. package/dist/{execute-ix7AAdWg.js → execute-DsHFIBuO.js} +4 -4
  114. package/dist/{explain-DRC9V5Qb.js → explain-D4ipf8IH.js} +1 -1
  115. package/dist/{explain-jg0KLCVt.js → explain-DISCeeYS.js} +2 -2
  116. package/dist/express/index.d.ts +4 -4
  117. package/dist/express/index.js +1 -1
  118. package/dist/fastify/index.d.ts +4 -4
  119. package/dist/fastify/index.js +1 -1
  120. package/dist/{fetch-adapter-CU1DIkXu.js → fetch-adapter-BXQc4NoV.js} +1 -1
  121. package/dist/{fetch-adapter-CJncmsPg.d.ts → fetch-adapter-Dci9NnyZ.d.ts} +2 -2
  122. package/dist/{fields-y_PSRCyJ.js → fields-CwFej4gp.js} +3 -3
  123. package/dist/{from-snapshot-DGc9W4QU.js → from-snapshot-DZ4D2sLa.js} +14 -9
  124. package/dist/gen-CpS9JkCb.js +1 -0
  125. package/dist/{gen-8rW_AUG5.js → gen-Fi4GcvIY.js} +3 -3
  126. package/dist/{gen-kind-C9ikF8nb.js → gen-kind-DR2-to9P.js} +1 -1
  127. package/dist/{generate-CW7gNfLr.js → generate-BSD_eI61.js} +18 -17
  128. package/dist/{generate-BmpCt5oi.js → generate-QEHCJSyv.js} +3 -3
  129. package/dist/{generate-options-DiR4r_sk.js → generate-options-BZ2nqy28.js} +14 -13
  130. package/dist/h3/index.d.ts +4 -4
  131. package/dist/h3/index.js +2 -2
  132. package/dist/{helper-calls-DHvgN9tr.js → helper-calls-B5MOl99d.js} +1 -1
  133. package/dist/hono/index.d.ts +4 -4
  134. package/dist/hono/index.js +1 -1
  135. package/dist/{hook-sql-D-abRHut.js → hook-sql-CbkH78FC.js} +267 -223
  136. package/dist/{hosted-Bkw3Oyh-.d.ts → hosted-BISipW6F.d.ts} +1 -1
  137. package/dist/{hosted-DZwCFrcy.js → hosted-D3USbpS6.js} +1 -1
  138. package/dist/{import-D_8tLF9g.js → import-Bz6IKoMM.js} +3 -3
  139. package/dist/{import-BAhoTYTk.js → import-DppjSugv.js} +1 -1
  140. package/dist/{index-DT3hOxA7.d.ts → index-BDJ2OZvV.d.ts} +34 -11
  141. package/dist/{index-Kj5S3IWE.d.ts → index-BF4IlvkT.d.ts} +4 -4
  142. package/dist/{index-DWmIuQLz.d.ts → index-BO5f180f.d.ts} +4 -4
  143. package/dist/{index-WOx7TBbj.d.ts → index-CWwWkz10.d.ts} +2 -2
  144. package/dist/{index-xShPsK8G.d.ts → index-Co_e22iJ.d.ts} +1 -1
  145. package/dist/{index-DPVeDtAO.d.ts → index-giCl-aQY.d.ts} +4 -4
  146. package/dist/index.d.ts +16 -16
  147. package/dist/index.js +13 -13
  148. package/dist/{init-DkRHIe8-.js → init-BOYIObRF.js} +3 -3
  149. package/dist/{init-zxb0BVDJ.js → init-DJYSpo-H.js} +1 -1
  150. package/dist/inspect-functions-CwEAQpVF.js +34 -0
  151. package/dist/{instance-options-DQCiBBuz.d.ts → instance-options-hq5Cp2Ih.d.ts} +1 -1
  152. package/dist/{instance-snapshot-D9kjL37B.js → instance-snapshot-D03srwnf.js} +9 -8
  153. package/dist/{interactive-only-Dqww0ABO.js → interactive-only-Bbq9e61G.js} +10 -182
  154. package/dist/jwt/index.d.ts +4 -4
  155. package/dist/{kernel-C5akxw5n.js → kernel-DSnWVZ0O.js} +5 -5
  156. package/dist/{keys-DQsHrgBM.js → keys-U2V0maaq.js} +1 -1
  157. package/dist/kysely/index.d.ts +3 -3
  158. package/dist/{lazy-provider-CMgFAGf8.d.ts → lazy-provider-W8KwlWJU.d.ts} +1 -1
  159. package/dist/{lazy-provider-DNVjY4n3.js → lazy-provider-b8UHGi8P.js} +2 -2
  160. package/dist/{login-C1p3gmj8.js → login-Dv8TFykx.js} +1 -1
  161. package/dist/{login-DOEZveP6.js → login-xgjt0a5o.js} +3 -3
  162. package/dist/{manager-chain-DdkiCw5q.js → manager-chain-FggG63qD.js} +1 -1
  163. package/dist/{manifest-31igzVGQ.js → manifest-BUeAHWDT.js} +44 -37
  164. package/dist/{manifest-DgsxeAsM.d.ts → manifest-BwhZ1s5b.d.ts} +35 -3
  165. package/dist/{manifest-B487A3po.js → manifest-CIWOmdlP.js} +1 -1
  166. package/dist/{manifest-schema-D7RQbnGY.js → manifest-schema-N3v2RVL-.js} +24 -0
  167. package/dist/{may-use-4HzzgYJ3.js → may-use-ikNCnNgZ.js} +1 -1
  168. package/dist/mcp/index.d.ts +8 -8
  169. package/dist/mcp/index.js +2 -2
  170. package/dist/measure-DZtly0oE.js +272 -0
  171. package/dist/membership-claim-sql-DGfhIn__.js +33 -0
  172. package/dist/{membership-filter-C7ZuhAqJ.js → membership-filter-Bz9QX6E9.js} +1 -1
  173. package/dist/memberships-4e6qi8Uv.js +1 -0
  174. package/dist/memberships-CNoAlsma.js +180 -0
  175. package/dist/{migrate-pg-lkbDu.js → migrate-BXk_rUmb.js} +2 -2
  176. package/dist/{model-BXhr8gUI.js → model-D0EKt-ED.js} +3 -3
  177. package/dist/names-DBxKx2bz.js +182 -0
  178. package/dist/nest/index.d.ts +4 -4
  179. package/dist/nest/index.js +1 -1
  180. package/dist/next/index.d.ts +11 -11
  181. package/dist/next/index.js +3 -3
  182. package/dist/next/plugin.d.ts +1 -1
  183. package/dist/node/index.d.ts +4 -4
  184. package/dist/node/index.js +1 -1
  185. package/dist/openai/index.d.ts +4 -4
  186. package/dist/openai/index.js +3 -3
  187. package/dist/openapi/index.d.ts +2 -2
  188. package/dist/{openapi-DEGesHWH.js → openapi-Bfakk4cF.js} +1 -1
  189. package/dist/{openapi-document-CEQ6jqqR.js → openapi-document-ZWpur4f1.js} +1 -1
  190. package/dist/{openapi-BeMVHVY4.js → openapi-g58VVrsc.js} +2 -2
  191. package/dist/orpc/index.d.ts +5 -5
  192. package/dist/orpc/index.js +2 -2
  193. package/dist/otel/index.d.ts +3 -3
  194. package/dist/{output-C7EPeSZj.js → output-D4FLF3_v.js} +1 -1
  195. package/dist/{ownership-Csk9C3Js.js → ownership-DvmaGcup.js} +7 -6
  196. package/dist/{parse-local-manifest-B92rFWnk.d.ts → parse-local-manifest-AJWs3pkW.d.ts} +1 -1
  197. package/dist/pdp/index.d.ts +3 -3
  198. package/dist/pdp/index.js +1 -1
  199. package/dist/{permdock-CJPIwU1T.js → permdock-JM9TKevZ.js} +14 -14
  200. package/dist/{permdock-BShHM8OJ.d.ts → permdock-V86uejcm.d.ts} +2 -2
  201. package/dist/{permissions-wEkTVr_I.js → permissions-xPyAmuXi.js} +1 -1
  202. package/dist/{pipeline-Bbu7uw28.js → pipeline-DCERGTTY.js} +2 -2
  203. package/dist/{plugin-L3G7jPGE.d.ts → plugin-BnvEp5tS.d.ts} +2 -2
  204. package/dist/{policy-BBvhhH9X.js → policy-CZBJDcTx.js} +2 -1
  205. package/dist/{policy-BUtwixSN.d.ts → policy-DZORR-Fw.d.ts} +1 -1
  206. package/dist/{policy-CSOOQ3rR.js → policy-DoHkOOTQ.js} +1 -1
  207. package/dist/{policy-bundle-KYI0EnrM.js → policy-bundle-CsnNAo-n.js} +3 -3
  208. package/dist/{policy-from-catalog-_zwn1sNj.js → policy-from-catalog-BohzTN3J.js} +3 -3
  209. package/dist/{policy-types-CfW4X_yX.d.ts → policy-types-BnBZvh7N.d.ts} +50 -1
  210. package/dist/{postgrest-PQ3zAOD2.d.ts → postgrest-BG0ipED3.d.ts} +9 -2
  211. package/dist/{powersync-CM6Vg4RH.js → powersync-CTKfjnPT.js} +12 -12
  212. package/dist/{powersync-CGvu6j5U.js → powersync-Cz3MUw6R.js} +1 -1
  213. package/dist/{powersync-C1ix7CEY.js → powersync-Dbpn-n0o.js} +1 -1
  214. package/dist/prisma/index.d.ts +2 -2
  215. package/dist/{protected-action-BPN0NaRb.js → protected-action-DDYvU-9Z.js} +1 -1
  216. package/dist/{protected-action-DhCQ4bSe.d.ts → protected-action-aGL_gT4j.d.ts} +5 -5
  217. package/dist/{provider-BV_v0JAY.js → provider-BwqzED5h.js} +83 -50
  218. package/dist/{provider-1xqxLVEz.js → provider-NQwLSlgb.js} +2 -2
  219. package/dist/{provider-CMgFAGf8.d.ts → provider-W8KwlWJU.d.ts} +1 -1
  220. package/dist/{provider-store-Cf8HRNtb.js → provider-store-BizF6jyu.js} +2 -2
  221. package/dist/{provider-with-cpL9vRjC.js → provider-with-DtBgCCV_.js} +1 -1
  222. package/dist/{prune-config-CdoPJIGz.js → prune-config--x-cEF8G.js} +5 -5
  223. package/dist/{pull-BaB401Bk.js → pull-BQELP7aV.js} +2 -2
  224. package/dist/pull-C_ZiPZ5X.js +1 -0
  225. package/dist/{push-DcjvEj0m.js → push-D5so0ptb.js} +2 -2
  226. package/dist/{pushed-policy-DcvO8NXy.d.ts → pushed-policy-CQaXRDe3.d.ts} +1 -1
  227. package/dist/{pushed-policy-DSjSWEAl.js → pushed-policy-dm_hFstN.js} +1 -1
  228. package/dist/{quote-BKrTBbcH.js → quote-LNaBdCGA.js} +1 -1
  229. package/dist/{rbac-mblGDx-Z.js → rbac-BRMnQ9Rl.js} +5 -4
  230. package/dist/react/index.d.ts +6 -6
  231. package/dist/react/index.js +3 -3
  232. package/dist/react/lazy.d.ts +6 -6
  233. package/dist/react/lazy.js +3 -3
  234. package/dist/react/provider-client-lazy.d.ts +1 -1
  235. package/dist/react/provider-client-lazy.js +1 -1
  236. package/dist/react/provider-client.d.ts +1 -1
  237. package/dist/react/provider-client.js +1 -1
  238. package/dist/react-native/index.d.ts +8 -8
  239. package/dist/react-native/index.js +5 -5
  240. package/dist/read-memberships-DVBitJZG.js +164 -0
  241. package/dist/{rename-BZNOV8H9.js → rename-BjP2CFUY.js} +5 -5
  242. package/dist/replay-Dg5-l7xu.d.ts +3 -0
  243. package/dist/{report-DCAiUc5U.js → report-DF0zUNut.js} +1 -1
  244. package/dist/{report-DievqWhf.js → report-XdCm1y_J.js} +1 -1
  245. package/dist/{request-context-BNVY3kZ1.js → request-context-CqqdiVp4.js} +1 -1
  246. package/dist/resend/index.d.ts +4 -4
  247. package/dist/{resolve-config-9NYYVc30.js → resolve-config-Cu_mE2wt.js} +1 -1
  248. package/dist/{resolve-names-Cth1UQ-8.js → resolve-names-xBg9s2IJ.js} +7 -6
  249. package/dist/{resolver-CuIY8aFD.js → resolver-C_a-bddD.js} +99 -15
  250. package/dist/{rls-BtkZgaZp.js → rls-BzCz7ZV0.js} +51 -4
  251. package/dist/{rls-files-ucAI0J5j.js → rls-files-Bu0O7cZ6.js} +1 -1
  252. package/dist/{rls-options-BFGRmdcH.d.ts → rls-options-f1wRhXSG.d.ts} +1 -1
  253. package/dist/{rls-DUYok5e9.js → rls-rk-QH4fc.js} +13 -13
  254. package/dist/{rpc-D7G7IJDa.js → rpc-BQPa7tLP.js} +1 -1
  255. package/dist/{rpc-COnquydd.d.ts → rpc-DyCWVn6C.d.ts} +1 -1
  256. package/dist/run-BvtApZDp.js +1 -0
  257. package/dist/{run-WIqPbnjD.js → run-DTz-e3Od.js} +2 -2
  258. package/dist/{run-ticket-Mmor5sYW.d.ts → run-ticket-mVPqm6M6.d.ts} +2 -2
  259. package/dist/{saas-DcqUkynn.js → saas-DSeazNrN.js} +3 -3
  260. package/dist/{scan-Badcllgg.js → scan-Cn79IAJs.js} +1 -1
  261. package/dist/{schema-DBRKgQb4.js → schema-CbzVUpWv.js} +1 -1
  262. package/dist/scim/index.d.ts +1 -1
  263. package/dist/seeds/index.d.ts +1 -1
  264. package/dist/{seeds-Cih1ztkf.d.ts → seeds-DLjPbhvM.d.ts} +1 -1
  265. package/dist/server/index.d.ts +11 -11
  266. package/dist/server/index.js +1 -1
  267. package/dist/{server-types-C2XX60aF.d.ts → server-types-BlMijUtb.d.ts} +8 -8
  268. package/dist/share-key-claims-CZGAeVqa.js +28 -0
  269. package/dist/{shared-C6_T7QUo.js → shared-DnVY767H.js} +2 -1
  270. package/dist/{sink-BQ_6K81r.d.ts → sink-DhrVLPSJ.d.ts} +2 -2
  271. package/dist/{size-l1pDHE2z.js → size-CY6rK6l9.js} +3 -3
  272. package/dist/{skills-Ba9hHGO6.js → skills-BKrN1qej.js} +1 -1
  273. package/dist/{skills-CTKq3o8D.js → skills-oZ8Ng2e7.js} +1 -1
  274. package/dist/{snapshot-Ty0uk9wZ.js → snapshot-Dzi4LR6n.js} +8 -1
  275. package/dist/{snapshot-cache-DGvLQW0-.d.ts → snapshot-cache-CVYqOThu.d.ts} +1 -1
  276. package/dist/{snapshot-compact-yXFxZLPo.js → snapshot-compact-BWMLnIXK.js} +35 -4
  277. package/dist/{snapshot-evaluate-DSNj2rhV.js → snapshot-evaluate-C382Z1mQ.js} +1 -1
  278. package/dist/{snapshot-reads-BnAHiuoa.js → snapshot-reads-JxcUSUfW.js} +2 -2
  279. package/dist/{snapshot-size-DNY1MTsV.js → snapshot-size-D6ixbYvH.js} +1 -1
  280. package/dist/{snapshot-size-2fkXbCkP.js → snapshot-size-NklqBKcV.js} +1 -1
  281. package/dist/solid/index.d.ts +5 -5
  282. package/dist/solid/index.js +2 -2
  283. package/dist/solid-start/index.d.ts +4 -4
  284. package/dist/solid-start/index.js +2 -2
  285. package/dist/{sources-CjgZns7t.d.ts → sources-Bq7k7g34.d.ts} +7 -2
  286. package/dist/{sources-DnjJPGfb.js → sources-C6Id63F8.js} +2 -1
  287. package/dist/{src-HRYn4UFj.js → src-BXDohWNO.js} +154 -11
  288. package/dist/ssf/index.d.ts +3 -3
  289. package/dist/{standard-webhooks-Bnnrqa6d.d.ts → standard-webhooks-D6SPYjSQ.d.ts} +2 -2
  290. package/dist/{store-core-BdFcruPm.d.ts → store-core-Bq7Qc9QM.d.ts} +4 -4
  291. package/dist/{store-options-DpCQo0vB.js → store-options-DgOuhUSn.js} +4 -4
  292. package/dist/{stores-D6MIjN_-.d.ts → stores-Dn7TpQFa.d.ts} +5 -5
  293. package/dist/{stores-KpBCaY6c.js → stores-jgDndNHa.js} +1 -1
  294. package/dist/{subject-CrldGifz.js → subject-B7p94Y0s.js} +1 -1
  295. package/dist/{subject-cache-CnJcz2K_.d.ts → subject-cache-UKUgQCEX.d.ts} +3 -1
  296. package/dist/supabase/index.d.ts +36 -9
  297. package/dist/supabase/index.js +8 -7
  298. package/dist/supabase/middleware.d.ts +5 -5
  299. package/dist/supabase/middleware.js +4 -4
  300. package/dist/{supabase-CGiB83XQ.js → supabase-BNPS-Gr1.js} +15 -1
  301. package/dist/{supabase-kWQlkrHw.js → supabase-DrazwRER.js} +14 -7
  302. package/dist/supabase-hook-D0Yzbl19.js +2 -0
  303. package/dist/{supabase-hook-CqO_0Koh.js → supabase-hook-t1HnQf8U.js} +7 -7
  304. package/dist/{supabase-schemas-BglbAG2Z.js → supabase-schemas-_ubYYw9i.js} +2 -2
  305. package/dist/svelte/index.d.ts +5 -5
  306. package/dist/svelte/index.js +5 -3
  307. package/dist/svelte/runtime.d.ts +3 -3
  308. package/dist/svelte/runtime.js +1 -1
  309. package/dist/svelte/source.d.ts +5 -5
  310. package/dist/svelte/source.js +2 -2
  311. package/dist/sveltekit/index.d.ts +4 -4
  312. package/dist/sveltekit/index.js +1 -1
  313. package/dist/{table-reads-AnHPrBp8.js → table-reads-B7z40Yu-.js} +297 -48
  314. package/dist/{table-reads-BviGc0L_.js → table-reads-Ci-ZVo5m.js} +1 -1
  315. package/dist/{tables-CDq0HVVq.js → tables-Bxmf2beb.js} +102 -8
  316. package/dist/tanstack-start/index.d.ts +4 -4
  317. package/dist/tanstack-start/index.js +1 -1
  318. package/dist/{tenant-check-D7g9oNVH.js → tenant-check-DW0kbH-a.js} +4 -4
  319. package/dist/terminal/index.d.ts +5 -5
  320. package/dist/terminal/index.js +3 -3
  321. package/dist/testing/core.d.ts +1 -1
  322. package/dist/testing/core.js +1 -1
  323. package/dist/testing/fixtures/index.d.ts +4 -4
  324. package/dist/testing/fixtures/index.js +29 -11
  325. package/dist/testing/index.d.ts +23 -23
  326. package/dist/testing/index.js +13 -13
  327. package/dist/testing/saas/index.d.ts +3 -3
  328. package/dist/testing/saas/index.js +2 -2
  329. package/dist/testing/saas/permissions.js +1 -1
  330. package/dist/trpc/index.d.ts +5 -5
  331. package/dist/trpc/index.js +2 -2
  332. package/dist/{type-helpers-CUmJFGV6.d.ts → type-helpers-CVN-p62O.d.ts} +1 -1
  333. package/dist/{types-vKKndyxx.d.ts → types-5cvjmHTG.d.ts} +1 -1
  334. package/dist/{types-DwoRXDvN.d.ts → types-BMKDvcXc.d.ts} +2 -2
  335. package/dist/{types-CIzXPPV-.d.ts → types-B_I8TBA9.d.ts} +2 -2
  336. package/dist/{types-h9W3CNC_.d.ts → types-BmTW35E5.d.ts} +4 -4
  337. package/dist/{types-BhBfMdQ5.d.ts → types-CDkJNA3a.d.ts} +3 -3
  338. package/dist/{types-euUv1wsO.d.ts → types-CgaGxF5q.d.ts} +1 -1
  339. package/dist/{types-BsRf5rKk.d.ts → types-CrUguLsE.d.ts} +2 -2
  340. package/dist/{types-BRECeQ2n.d.ts → types-DNOJRhyn.d.ts} +3 -3
  341. package/dist/{types-BKnUwgvx.d.ts → types-Dl2jRkyq.d.ts} +4 -4
  342. package/dist/{types-config-DNIw_Gt5.d.ts → types-config-CyawIkMF.d.ts} +2 -2
  343. package/dist/{types-CjZscT16.d.ts → types-gp1w86cV.d.ts} +4 -4
  344. package/dist/{types-run-Bwn1MuW0.d.ts → types-run-ByHuYUen.d.ts} +1 -1
  345. package/dist/unplugin/index.d.ts +1 -1
  346. package/dist/{usage-CW6xhRcV.js → usage-B8ca_Nj_.js} +2 -2
  347. package/dist/usage-CKTsomEq.js +1 -0
  348. package/dist/{usage-n4V2k_a6.js → usage-Do7LQ4i4.js} +1 -1
  349. package/dist/{validation-error-P4Z9HUuP.d.ts → validation-error-BKgVVMc1.d.ts} +1 -1
  350. package/dist/{verify-CKzngsUH.js → verify-ZojGAC3f.js} +12 -12
  351. package/dist/{version-cache-BzK8dwJy.js → version-cache-Ccrfu2A4.js} +6 -1
  352. package/dist/vue/index.d.ts +5 -5
  353. package/dist/vue/index.js +2 -2
  354. package/dist/{waiter-BqUxSRxq.d.ts → waiter-Bov7Cig6.d.ts} +2 -2
  355. package/dist/{warm-BR-mrnY-.d.ts → warm-BKD3FN6k.d.ts} +1 -1
  356. package/dist/{warm-5yxlUmBh.js → warm-BZ0ZwSmO.js} +1 -1
  357. package/dist/{watch-C12Ub7x4.js → watch-EzX_aG73.js} +1 -1
  358. package/dist/webmcp/index.d.ts +1 -1
  359. package/dist/webmcp/index.js +1 -1
  360. package/dist/{who-can-CGVpM3fZ.js → who-can-CIgYpEvy.js} +1 -1
  361. package/dist/workflow/index.d.ts +3 -3
  362. package/dist/workflow/index.js +1 -1
  363. package/dist/workflow-sdk/index.d.ts +4 -4
  364. package/dist/{wrap-D8WtzrB7.d.ts → wrap-CaAA3ubO.d.ts} +2 -2
  365. package/package.json +11 -11
  366. package/schemas/snapshot-v2.json +20 -0
  367. package/schemas/supabase-claims-v1.json +48 -2
  368. package/schemas/supabase-manifest-v1.json +28 -0
  369. package/dist/bundle-size-DwZ4e1gu.js +0 -1
  370. package/dist/claims-size-B6j0Ff4Q.js +0 -1
  371. package/dist/evaluator-COmATWCr.js +0 -2
  372. package/dist/gen-BtiGMiuH.js +0 -1
  373. package/dist/pull-Bp63vtgu.js +0 -1
  374. package/dist/read-memberships-BkePIa1F.js +0 -63
  375. package/dist/replay-BCOZifwx.d.ts +0 -3
  376. package/dist/run-BjMxYYTe.js +0 -1
  377. package/dist/supabase-hook-CluYxKee.js +0 -2
  378. package/dist/usage-Ci7Glu-H.js +0 -1
@@ -1,13 +1,13 @@
1
1
  import { r as isRecord } from "./compact-C4LFuqbW.js";
2
2
  import { d as scopeList } from "./scopes-B-KX9EI8.js";
3
- import { n as parseSupabaseManifest } from "./manifest-B487A3po.js";
3
+ import { n as parseSupabaseManifest } from "./manifest-CIWOmdlP.js";
4
4
  import { i as readJsonFile } from "./files-DAR51W3J.js";
5
5
  import { t as MANIFEST_FILE } from "./manifest-json-DMaBWmcG.js";
6
6
  import { i as loadConfiguredPolicy } from "./load-m7jmit3y.js";
7
7
  import { a as parseSqlFile, c as readPolicy, d as sqlCalls, f as stringValues, t as SqlSyntaxError } from "./ast-Dnm2TOHN.js";
8
8
  import { i as taggedAccessPolicies } from "./bsb-access-Bcw6GrQm.js";
9
- import { a as droppedPolicy, s as reportFiles, u as isPlatformSchema } from "./report-DievqWhf.js";
10
- import { a as tryKeyReasons, n as tenantCheck, r as keyReason } from "./tenant-check-D7g9oNVH.js";
9
+ import { a as droppedPolicy, s as reportFiles, u as isPlatformSchema } from "./report-XdCm1y_J.js";
10
+ import { a as tryKeyReasons, n as tenantCheck, r as keyReason, t as svals } from "./tenant-check-DW0kbH-a.js";
11
11
  import { existsSync, readFileSync } from "node:fs";
12
12
  import { join, relative } from "node:path";
13
13
  // src/cli/rls/shared-functions.ts
@@ -78,56 +78,71 @@ function definitionOf(node) {
78
78
  const security = defs["security"];
79
79
  const definer = isRecord(security) ? isRecord(security["Boolean"]) && security["Boolean"]["boolval"] === true : false;
80
80
  const volatility = sval(defs["volatility"]);
81
+ const language = sval(defs["language"]);
81
82
  return {
82
83
  schema: schema.toLowerCase(),
83
84
  name: name.toLowerCase(),
84
85
  body: bodyOf(defs["as"]),
86
+ header: `language ${language ?? "unstated"}, security ${definer ? "definer" : "invoker"}, ${volatility ?? "volatile"}`,
85
87
  eligible: sval(defs["language"]) === "sql" && !definer && (volatility === "stable" || volatility === "immutable")
86
88
  };
87
89
  }
88
90
  /**
89
- * The tables a body reads and the functions it calls, or `undefined` when it
90
- * reads the caller, calls a function outside `known`, or reads a relation that
91
- * is not a table in `reads`.
91
+ * The tables a body reads and the functions it calls, or why it is not shared:
92
+ * it reads the caller, calls a function outside `known`, or reads a relation
93
+ * that is not a table in `reads`.
92
94
  */
93
- async function readsOf(definition, defined, reads, helperSchema) {
95
+ async function readsOf$1(definition, defined, reads, helperSchema) {
94
96
  let statements;
95
97
  try {
96
98
  statements = await parseSqlFile(definition.body);
97
99
  } catch (error) {
98
- if (error instanceof SqlSyntaxError) return;
100
+ if (error instanceof SqlSyntaxError) return "the body does not parse";
99
101
  throw error;
100
102
  }
101
103
  const tables = /* @__PURE__ */ new Set();
102
104
  const calls = /* @__PURE__ */ new Set();
105
+ const keys = /* @__PURE__ */ new Set();
103
106
  for (const statement of statements) {
104
- if (statement.kind !== "SelectStmt") return;
105
- if (collect(statement.node, "SQLValueFunction").some((value) => isRecord(value) && typeof value["op"] === "string" && IDENTITY_VALUES.has(value["op"]))) return;
107
+ if (statement.kind !== "SelectStmt") return `the body holds a ${statement.kind}, not a select`;
108
+ if (collect(statement.node, "SQLValueFunction").some((value) => isRecord(value) && typeof value["op"] === "string" && IDENTITY_VALUES.has(value["op"]))) return "it reads current_user, session_user or user";
106
109
  const ctes = new Set(collect(statement.node, "CommonTableExpr").flatMap((value) => isRecord(value) && typeof value["ctename"] === "string" ? [value["ctename"].toLowerCase()] : []));
107
110
  for (const value of collect(statement.node, "RangeVar")) {
108
- if (!isRecord(value) || typeof value["relname"] !== "string") return;
111
+ if (!isRecord(value) || typeof value["relname"] !== "string") return "it reads a relation inspect cannot name";
109
112
  const relname = value["relname"].toLowerCase();
110
113
  const explicit = typeof value["schemaname"] === "string" ? value["schemaname"].toLowerCase() : void 0;
111
114
  if (explicit === void 0 && ctes.has(relname)) continue;
112
- const found = (explicit === void 0 ? [definition.schema, DEFAULT_SCHEMA] : [explicit]).map((schema) => `${schema}.${relname}`).find((table) => reads.has(table));
113
- if (found === void 0) return;
115
+ const candidates = (explicit === void 0 ? [definition.schema, DEFAULT_SCHEMA] : [explicit]).map((schema) => `${schema}.${relname}`);
116
+ const found = candidates.find((table) => reads.has(table));
117
+ if (found === void 0) return `it reads ${candidates[0] ?? relname}, which is no table the schema files create`;
114
118
  tables.add(found);
115
119
  }
116
120
  for (const call of sqlCalls(statement.node)) {
117
121
  const last = call.name.at(-1);
118
122
  const schema = call.name.length > 1 ? call.name[0] : void 0;
119
- if (last === void 0 || IDENTITY_FUNCTIONS.has(last) || schema === "auth") return;
120
- if (schema === helperSchema) return;
123
+ if (last === void 0 || IDENTITY_FUNCTIONS.has(last) || schema === "auth") return `it reads the caller through ${call.name.join(".")}()`;
124
+ if (schema === helperSchema) {
125
+ const key = permissionFilterKey(call, helperSchema);
126
+ if (key === void 0) return `it calls the helper ${call.name.join(".")}(), which is not a permissionFilters helper`;
127
+ if (typeof key !== "string") return `it calls ${call.name.join(".")}() with a permission key that is not a string literal, so the key cannot join the share key`;
128
+ keys.add(key);
129
+ continue;
130
+ }
121
131
  const target = (schema === void 0 ? [`${definition.schema}.${last}`, `${DEFAULT_SCHEMA}.${last}`] : [`${schema}.${last}`]).find((name) => defined.has(name));
122
132
  if (target !== void 0) calls.add(target);
123
- else if (schema !== void 0 && schema !== "pg_catalog") return;
133
+ else if (schema !== void 0 && schema !== "pg_catalog") return `it calls ${call.name.join(".")}(), which no schema file defines`;
124
134
  }
125
135
  }
126
136
  return {
127
137
  tables,
128
- calls
138
+ calls,
139
+ keys
129
140
  };
130
141
  }
142
+ /** Why `definition` fails the header checks, or `undefined`. */
143
+ function headerReason(definition) {
144
+ return definition.eligible ? void 0 : `it is not language sql, security invoker and stable or immutable (${definition.header})`;
145
+ }
131
146
  /**
132
147
  * `rls.sharedFunctions`: the functions better-supabase's doctor BS430 accepts
133
148
  * in a `share: "tenant"` fill, read from the same SQL files as `tableReads`. A
@@ -140,6 +155,37 @@ async function readsOf(definition, defined, reads, helperSchema) {
140
155
  * function wins.
141
156
  */
142
157
  async function sharedFunctionsOf(input) {
158
+ const outcomes = await analyse(input);
159
+ return [...outcomes.keys()].toSorted().flatMap((name) => {
160
+ const shared = outcomes.get(name)?.shared;
161
+ return shared === void 0 ? [] : [shared];
162
+ });
163
+ }
164
+ /** `*` matches any run of characters, every other character itself. */
165
+ function matcher(pattern) {
166
+ const source = pattern.split("*").map((part) => part.replaceAll(/[.+?^${}()|[\]\\]/gu, String.raw`\$&`)).join(".*");
167
+ const regex = new RegExp(`^${source}$`, "u");
168
+ return (name) => regex.test(name);
169
+ }
170
+ /**
171
+ * For each function the schema files define whose `schema.name` matches
172
+ * `pattern` (`public.*_payload`), a pass or every reason `sharedFunctionsOf`
173
+ * does not list it: a header it fails, a read of the caller, an unknown call,
174
+ * or the `row` table it reads with the rules that make it so.
175
+ */
176
+ async function functionShares(input, pattern) {
177
+ const matches = matcher(pattern.toLowerCase());
178
+ const outcomes = await analyse(input);
179
+ return [...outcomes.keys()].filter((name) => matches(name)).toSorted().map((name) => {
180
+ const outcome = outcomes.get(name);
181
+ return {
182
+ function: name,
183
+ shared: outcome?.shared !== void 0,
184
+ reasons: outcome?.reasons ?? []
185
+ };
186
+ });
187
+ }
188
+ async function analyse(input) {
143
189
  const reads = new Map(input.tableReads.map((read) => [read.table, read]));
144
190
  const byArity = /* @__PURE__ */ new Map();
145
191
  for (const file of reportFiles(input.cwd, input.config)) {
@@ -165,23 +211,31 @@ async function sharedFunctionsOf(input) {
165
211
  }
166
212
  const helperSchema = input.schema.toLowerCase();
167
213
  const analysed = /* @__PURE__ */ new Map();
214
+ const reasons = /* @__PURE__ */ new Map();
168
215
  for (const [name, overloads] of defined) {
169
216
  const merged = [];
217
+ const why = [];
170
218
  for (const definition of overloads) {
171
- const found = definition.eligible ? await readsOf(definition, defined, reads, helperSchema) : void 0;
172
- if (found === void 0) break;
173
- merged.push(found);
219
+ const found = headerReason(definition) ?? await readsOf$1(definition, defined, reads, helperSchema);
220
+ if (typeof found === "string") why.push(found);
221
+ else merged.push(found);
174
222
  }
175
- if (merged.length === overloads.length && merged.length > 0) analysed.set(name, {
223
+ reasons.set(name, why);
224
+ if (why.length === 0 && merged.length > 0) analysed.set(name, {
176
225
  tables: new Set(merged.flatMap((entry) => [...entry.tables])),
177
- calls: new Set(merged.flatMap((entry) => [...entry.calls]))
226
+ calls: new Set(merged.flatMap((entry) => [...entry.calls])),
227
+ keys: new Set(merged.flatMap((entry) => [...entry.keys]))
178
228
  });
179
229
  }
180
230
  for (let changed = true; changed;) {
181
231
  changed = false;
182
- for (const [name, entry] of analysed) if ([...entry.calls].some((call) => !analysed.has(call))) {
183
- analysed.delete(name);
184
- changed = true;
232
+ for (const [name, entry] of analysed) {
233
+ const gone = [...entry.calls].filter((call) => !analysed.has(call));
234
+ if (gone.length > 0) {
235
+ analysed.delete(name);
236
+ reasons.set(name, gone.map((call) => `it calls ${call}, which is not shared`));
237
+ changed = true;
238
+ }
185
239
  }
186
240
  }
187
241
  const close = (name, seen) => {
@@ -189,18 +243,56 @@ async function sharedFunctionsOf(input) {
189
243
  seen.add(name);
190
244
  for (const call of analysed.get(name)?.calls ?? []) close(call, seen);
191
245
  };
192
- return [...analysed.keys()].toSorted().flatMap((name) => {
246
+ const outcomes = /* @__PURE__ */ new Map();
247
+ for (const name of defined.keys()) {
248
+ if (!analysed.has(name)) {
249
+ outcomes.set(name, { reasons: reasons.get(name) ?? [] });
250
+ continue;
251
+ }
193
252
  const reached = /* @__PURE__ */ new Set();
194
253
  close(name, reached);
195
254
  const tables = /* @__PURE__ */ new Set();
196
- for (const member of reached) for (const table of analysed.get(member)?.tables ?? []) tables.add(table);
197
- if (tables.size === 0 || [...tables].some((table) => reads.get(table)?.share !== "tenant")) return [];
198
- return [{
199
- function: name,
200
- tables: [...tables].toSorted(),
201
- permissions: [...new Set([...tables].flatMap((table) => reads.get(table)?.permissions ?? []))].toSorted()
202
- }];
203
- });
255
+ const filterKeys = /* @__PURE__ */ new Set();
256
+ for (const member of reached) {
257
+ const entry = analysed.get(member);
258
+ for (const table of entry?.tables ?? []) tables.add(table);
259
+ for (const key of entry?.keys ?? []) filterKeys.add(key);
260
+ }
261
+ const rows = [...tables].toSorted().filter((table) => reads.get(table)?.share !== "tenant");
262
+ if (tables.size === 0 || rows.length > 0) {
263
+ outcomes.set(name, { reasons: tables.size === 0 ? ["it reads no table"] : rows.map((table) => rowReason(table, reads.get(table))) });
264
+ continue;
265
+ }
266
+ outcomes.set(name, {
267
+ reasons: [],
268
+ shared: {
269
+ function: name,
270
+ tables: [...tables].toSorted(),
271
+ permissions: [.../* @__PURE__ */ new Set([...[...tables].flatMap((table) => reads.get(table)?.permissions ?? []), ...filterKeys])].toSorted()
272
+ }
273
+ });
274
+ }
275
+ return outcomes;
276
+ }
277
+ /**
278
+ * The string literal a call passes to a `permissionFilters` helper, `false`
279
+ * when the helper is one but the key is not a string literal, or `undefined`
280
+ * when the call is not such a helper. Better-supabase 0.87 adds only a string
281
+ * literal to the share key.
282
+ */
283
+ function permissionFilterKey(call, helperSchema) {
284
+ const name = call.name.at(-1);
285
+ if ((call.name.length > 1 ? call.name[0] : void 0) !== helperSchema || name === void 0 || !name.endsWith("_has_active") && !name.endsWith("_permission_keys_active")) return;
286
+ const [first] = Array.isArray(call.node["args"]) ? call.node["args"] : [];
287
+ const cast = isRecord(first) ? first["TypeCast"] : void 0;
288
+ const inner = isRecord(cast) && isRecord(cast["arg"]) ? cast["arg"] : first;
289
+ const constant = isRecord(inner) ? inner["A_Const"] : void 0;
290
+ const value = isRecord(constant) && isRecord(constant["sval"]) ? constant["sval"]["sval"] : void 0;
291
+ return typeof value === "string" ? value : false;
292
+ }
293
+ /** The `row` table a function reads, under which rule and why. */
294
+ function rowReason(table, read) {
295
+ return `it reads ${table}, a row table (rule ${read?.rules?.join(", ") ?? "unknown"})${read?.reason === void 0 ? "" : `: ${read.reason}`}`;
204
296
  }
205
297
  /**
206
298
  * `rls.tenantPureHelpers`: the helpers of the root scope that answer from the
@@ -225,16 +317,126 @@ function tenantPureHelpersOf(manifest) {
225
317
  return [{
226
318
  name: `permdock_${root}_has`,
227
319
  keyArgument: "p_grant",
320
+ keyPosition: 0,
228
321
  tenantArgument: "p_tenant"
229
322
  }, {
230
323
  name: `${prefix}_permission_keys`,
231
324
  keyArgument: "p_keys",
325
+ keyPosition: 1,
232
326
  tenantArgument: "p_id"
233
327
  }].map((candidate) => ({
234
328
  ...candidate,
235
329
  name: `${manifest.rls.schema}.${candidate.name}`
236
330
  }));
237
331
  }
332
+ /**
333
+ * `rls.permissionFilters`: the one-argument forms of the tenant-pure helpers.
334
+ * Each reads the tenant from the token, so a call with a literal key depends
335
+ * only on the caller's grants of that key in the active tenant. The
336
+ * two-argument helpers stay in `tenantPureHelpers` and are never filters:
337
+ * better-supabase 0.87 checks the key argument only.
338
+ */
339
+ function permissionFiltersOf(manifest) {
340
+ const root = manifest.rls.scopes[0]?.name;
341
+ if (root === void 0) return [];
342
+ const schema = manifest.rls.schema;
343
+ return [{
344
+ name: `${schema}.permdock_${root}_has_active`,
345
+ keyPosition: 0
346
+ }, {
347
+ name: `${schema}.permitted_${root}_permission_keys_active`,
348
+ keyPosition: 0
349
+ }];
350
+ }
351
+ // src/cli/rls/table-reasons.ts
352
+ /** `policy <name>` with the file that defines it. */
353
+ function policyLabel(policy) {
354
+ return `policy ${policy.name}${policy.file === void 0 ? "" : ` in ${policy.file}`}`;
355
+ }
356
+ /** The column names an expression reads, in order of first appearance. */
357
+ function columnsOf(expr) {
358
+ const found = /* @__PURE__ */ new Set();
359
+ const visit = (value) => {
360
+ if (Array.isArray(value)) {
361
+ for (const item of value) visit(item);
362
+ return;
363
+ }
364
+ if (!isRecord(value)) return;
365
+ for (const [key, child] of Object.entries(value)) if (key === "ColumnRef" && isRecord(child)) found.add(svals(child["fields"]).join("."));
366
+ else visit(child);
367
+ };
368
+ visit(expr);
369
+ return [...found].filter((name) => name !== "");
370
+ }
371
+ const list = (items) => items.length === 0 ? "none" : items.join(", ");
372
+ /** The function calls and columns of a policy's `using`, as one phrase. */
373
+ function readsOf(policy) {
374
+ const calls = [...new Set(sqlCalls(policy.using).map((call) => `${call.name.join(".")}()`))];
375
+ const columns = columnsOf(policy.using);
376
+ return `calls ${list(calls)} and reads ${columns.length === 0 ? "no column" : `column ${list(columns)}`}`;
377
+ }
378
+ /**
379
+ * Whether a policy file is a migration, which `codemod bsb-access-tags` leaves
380
+ * alone.
381
+ */
382
+ function inMigration(policy) {
383
+ return policy.file?.split(/[/\\]/u).includes("migrations") === true;
384
+ }
385
+ /**
386
+ * What keeps the codemod `bsb-access-tags` from moving a `form` select policy
387
+ * to an `@bsb access` tag: the policy, the tenant column or the migration. The
388
+ * codemod rewrites only declarative schema files, and only a policy that is
389
+ * `<column> in (select <helper>('<key>'))` for `authenticated` alone, with no
390
+ * other policy on the same operation and one tenant column on the table.
391
+ */
392
+ function formBlockers(policy, others, helpers) {
393
+ const label = policyLabel(policy);
394
+ const blockers = [];
395
+ if (inMigration(policy)) blockers.push(`${label} is a migration, which the codemod does not rewrite: move the policy to the schema files`);
396
+ if (policy.roles.length !== 1 || policy.roles[0] !== "authenticated") blockers.push(`${label} applies to ${list(policy.roles)}, not authenticated alone`);
397
+ if (policy.command === "all") blockers.push(`${label} covers all commands: split it into one policy per command`);
398
+ if (tenantCheck(policy.using, helpers.plain) === void 0) blockers.push(`${label} uses ${helpers.plain} inside a larger expression, not as "<column> in (select ${helpers.plain}('<key>'))"`);
399
+ const selects = others.filter((other) => other !== policy && (other.command === "select" || other.command === "all"));
400
+ if (selects.length > 0) {
401
+ const named = selects.map((other) => `${other.permissive ? "" : "restrictive "}${other.name}`);
402
+ blockers.push(`${named.join(", ")} also ${selects.length === 1 ? "applies" : "apply"} to select on the table`);
403
+ }
404
+ const columns = /* @__PURE__ */ new Map();
405
+ for (const other of [policy, ...others]) {
406
+ const found = tenantCheck(other.using, helpers.plain) ?? tenantCheck(other.check, helpers.plain);
407
+ if (found !== void 0 && !columns.has(found.column)) columns.set(found.column, other.name);
408
+ }
409
+ if (columns.size > 1) blockers.push(`the tenant column differs between policies: ${[...columns].map(([column, name]) => `${name} uses ${column}`).join(", ")}`);
410
+ return blockers;
411
+ }
412
+ /** Why a permissive select policy that is no tenant form makes its table `row`. */
413
+ function ruleReason(rule, policy, helpers) {
414
+ const label = policyLabel(policy);
415
+ switch (rule) {
416
+ case "owner": return `${label} is an owner rule: it ${readsOf(policy)}, so a row is read by the user it names, not by a tenant grant`;
417
+ case "condition": return policy.using === void 0 ? `${label} has no using clause` : `${label} is a row condition: it ${readsOf(policy)}, which no tenant check of ${helpers.byPermission} covers`;
418
+ case "follows":
419
+ case "via":
420
+ case "walk": return `${label} resolves rows through a ${rule} helper: it ${readsOf(policy)}`;
421
+ default: return `${label} is a ${rule} rule`;
422
+ }
423
+ }
424
+ /** A restrictive select policy that reads a column of the row. */
425
+ function restrictiveReason(policy) {
426
+ return `restrictive ${policyLabel(policy)} reads ${columnsOf(policy.using).length === 0 ? "the row" : `column ${list(columnsOf(policy.using))}`}, so the rows it hides differ per row, not per tenant`;
427
+ }
428
+ /** Why a table with no readable policy is `unknown`. */
429
+ function unknownReason(state, policies) {
430
+ switch (state) {
431
+ case "no-facts": return "no policy or enable row level security statement for the table in the files inspect read; the table may exist only in a file libpg_query rejects, or be created by a function";
432
+ case "no-rls": return "no alter table ... enable row level security statement for the table in the files inspect read";
433
+ case "no-select": {
434
+ const named = policies.map((policy) => policy.name);
435
+ return `row level security is on and no permissive select policy applies to authenticated or public${named.length === 0 ? "" : ` (policies: ${list(named)})`}, so the table is not read through PostgREST by a signed-in role; inspect does not read grants, so a table grant is not checked`;
436
+ }
437
+ default: throw new Error(state);
438
+ }
439
+ }
238
440
  // src/cli/rls/table-reads.ts
239
441
  /** better-supabase's own tables, which its block SQL owns. */
240
442
  const LIBRARY_SCHEMAS = /* @__PURE__ */ new Set(["better_supabase"]);
@@ -296,6 +498,17 @@ function ruleOf(policy, plainHelper) {
296
498
  if (names.some((name) => name === "auth.uid" || name.endsWith("permdock_user_id"))) return "owner";
297
499
  return policy.using === void 0 ? "unknown" : "condition";
298
500
  }
501
+ /**
502
+ * The tenant checks a permissive policy ORs in: the expression itself or an
503
+ * argument of its top-level `or`. Other disjuncts only add rows.
504
+ */
505
+ function tenantDisjuncts(expr, helper) {
506
+ const bool = isRecord(expr) ? expr["BoolExpr"] : void 0;
507
+ return (isRecord(bool) && bool["boolop"] === "OR_EXPR" && Array.isArray(bool["args"]) ? bool["args"] : [expr]).flatMap((arg) => {
508
+ const check = tenantCheck(arg, helper);
509
+ return check === void 0 ? [] : [check];
510
+ });
511
+ }
299
512
  function keysOf(expr, helper) {
300
513
  return sqlCalls(expr).flatMap((call) => {
301
514
  if (call.name.join(".") !== helper) return [];
@@ -312,46 +525,78 @@ function readOf(table, facts, helpers, fieldTables, reasons) {
312
525
  if (facts === void 0 || !facts.rls) return {
313
526
  table,
314
527
  share: "row",
315
- rules: ["unknown"]
528
+ rules: ["unknown"],
529
+ reason: unknownReason(facts === void 0 ? "no-facts" : "no-rls", facts === void 0 ? [] : [...facts.policies.values()])
316
530
  };
317
- const selects = [...facts.policies.values()].filter(appliesToSelect);
531
+ const all = [...facts.policies.values()];
532
+ const selects = all.filter(appliesToSelect);
318
533
  const permissive = selects.filter((policy) => policy.permissive);
319
534
  const rules = /* @__PURE__ */ new Set();
320
- const columns = /* @__PURE__ */ new Set();
535
+ const columns = /* @__PURE__ */ new Map();
321
536
  const keys = /* @__PURE__ */ new Set();
322
537
  const formKeys = /* @__PURE__ */ new Set();
538
+ const formPolicies = [];
539
+ const parts = [];
540
+ const widenKeys = /* @__PURE__ */ new Set();
541
+ const widenColumns = /* @__PURE__ */ new Set();
323
542
  const stale = [];
324
- const hasTag = [...facts.policies.values()].some((p) => p.tagged !== void 0);
325
- if (fieldTables.has(table)) rules.add("fields");
326
- if (permissive.length === 0) rules.add("unknown");
543
+ const hasTag = all.some((p) => p.tagged !== void 0);
544
+ if (fieldTables.has(table)) {
545
+ rules.add("fields");
546
+ parts.push("the table has a field view, which reads rows per field grant");
547
+ }
548
+ if (permissive.length === 0) {
549
+ rules.add("unknown");
550
+ parts.push(unknownReason("no-select", all));
551
+ }
327
552
  for (const policy of permissive) {
328
553
  const check = policy.tagged ?? tenantCheck(policy.using, helpers.byPermission);
329
554
  for (const key of policy.tagged === void 0 ? keysOf(policy.using, helpers.byPermission) : [policy.tagged.key]) keys.add(key);
555
+ for (const found of policy.tagged === void 0 ? tenantDisjuncts(policy.using, helpers.byPermission) : [policy.tagged]) {
556
+ widenKeys.add(found.key);
557
+ widenColumns.add(found.column);
558
+ }
330
559
  if (check === void 0) {
331
560
  const rule = ruleOf(policy, helpers.plain);
332
561
  rules.add(rule);
333
562
  if (rule === "form") {
563
+ formPolicies.push(policy);
334
564
  if (hasTag) stale.push(policy);
335
565
  for (const key of keysOf(policy.using, helpers.plain)) formKeys.add(key);
336
- }
337
- } else columns.add(check.column);
566
+ } else parts.push(ruleReason(rule, policy, helpers));
567
+ } else if (!columns.has(check.column)) columns.set(check.column, policy.name);
568
+ }
569
+ for (const policy of selects) if (!policy.permissive && readsColumn(policy.using)) {
570
+ rules.add("restrictive");
571
+ parts.push(restrictiveReason(policy));
572
+ }
573
+ if (rules.size === 0 && columns.size > 1) {
574
+ rules.add("condition");
575
+ parts.push(`tenant checks on ${columns.size} columns: ${[...columns].map(([column, name]) => `${name} on ${column}`).join(", ")}`);
338
576
  }
339
- if (selects.some((policy) => !policy.permissive && readsColumn(policy.using))) rules.add("restrictive");
340
- if (rules.size === 0 && columns.size > 1) rules.add("condition");
341
577
  const permissions = [...keys].toSorted();
342
578
  const listed = permissions.length === 0 ? {} : { permissions };
343
579
  if (rules.size > 0) {
344
- const parts = [...stale.map((policy) => `policy ${policy.name} is still defined${policy.file === void 0 ? "" : ` in ${policy.file}`} next to an @bsb access tag that renders the table's policy: write a migration that drops it`), ...reasons === void 0 || stale.length > 0 ? [] : [...formKeys].toSorted().map((key) => `key ${key}: ${keyReason(reasons, key)}`)];
580
+ for (const policy of formPolicies) {
581
+ const blockers = stale.includes(policy) ? [`policy ${policy.name} is still defined${policy.file === void 0 ? "" : ` in ${policy.file}`} next to an @bsb access tag that renders the table's policy: write a migration that drops it`] : formBlockers(policy, all, helpers);
582
+ parts.push(...blockers);
583
+ if (blockers.length === 0 && reasons !== void 0 && keysOf(policy.using, helpers.plain).every((key) => reasons.swappable.has(key))) parts.push(`policy ${policy.name} is movable: nothing on the table blocks permdock codemod bsb-access-tags`);
584
+ }
585
+ if (reasons !== void 0 && stale.length === 0) parts.push(...[...formKeys].toSorted().map((key) => `key ${key}: ${keyReason(reasons, key)}`));
345
586
  const why = parts.length === 0 ? void 0 : parts.join("; ");
587
+ const [widened] = widenColumns;
588
+ const holds = widenColumns.size === 1 && widened !== void 0 && widenKeys.size > 0 && !rules.has("restrictive") && !rules.has("fields") && !rules.has("unknown");
346
589
  return {
347
590
  table,
348
591
  share: "row",
592
+ ...holds ? { column: widened } : {},
349
593
  ...listed,
350
594
  rules: [...rules].toSorted(),
595
+ ...holds ? { tenantFor: [...widenKeys].toSorted() } : {},
351
596
  ...why === void 0 ? {} : { reason: why }
352
597
  };
353
598
  }
354
- const [column] = columns;
599
+ const [column] = columns.keys();
355
600
  return {
356
601
  table,
357
602
  share: "tenant",
@@ -456,7 +701,11 @@ function manifestTableReads(cwd, config, manifest, reasons) {
456
701
  async function withTableReads(cwd, config, manifest, reasons) {
457
702
  const reads = await manifestTableReads(cwd, config, manifest, reasons);
458
703
  const tenantPureHelpers = tenantPureHelpersOf(manifest);
459
- const pure = tenantPureHelpers.length === 0 ? {} : { tenantPureHelpers };
704
+ const permissionFilters = permissionFiltersOf(manifest);
705
+ const pure = {
706
+ ...tenantPureHelpers.length === 0 ? {} : { tenantPureHelpers },
707
+ ...permissionFilters.length === 0 ? {} : { permissionFilters }
708
+ };
460
709
  if (reads.length === 0) return {
461
710
  ...manifest,
462
711
  rls: {
@@ -514,4 +763,4 @@ async function configuredTableReads(cwd, config) {
514
763
  ...reasons === void 0 ? {} : { reasons }
515
764
  });
516
765
  }
517
- export { withTableReads as a, tableReads as i, configuredTableReads as n, sharedFunctionsOf as o, manifestTableReads as r, committedManifest as t };
766
+ export { withTableReads as a, tableReads as i, configuredTableReads as n, functionShares as o, manifestTableReads as r, sharedFunctionsOf as s, committedManifest as t };
@@ -1 +1 @@
1
- export { t as committedManifest, n as configuredTableReads, r as manifestTableReads, i as tableReads, a as withTableReads } from "./table-reads-AnHPrBp8.js";
1
+ export { t as committedManifest, n as configuredTableReads, r as manifestTableReads, i as tableReads, a as withTableReads } from "./table-reads-B7z40Yu-.js";