permdock 0.20.1 → 0.22.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 (359) hide show
  1. package/README.md +2 -1
  2. package/dist/a2a/index.d.ts +5 -5
  3. package/dist/a2a/index.js +5 -4
  4. package/dist/{adoption-scan-BTG9Noyy.js → adoption-scan-_bHLMnVQ.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/app/index.d.ts +85 -0
  10. package/dist/app/index.js +91 -0
  11. package/dist/app-DIvM65Mv.js +24 -0
  12. package/dist/{approval-policies-CKlByf5o.d.ts → approval-policies-UnDSxT__.d.ts} +2 -2
  13. package/dist/{approval-prompt-CQFiO1KE.d.ts → approval-prompt-2hTqo6IM.d.ts} +2 -2
  14. package/dist/approvals/index.d.ts +3 -3
  15. package/dist/approvals/index.js +3 -3
  16. package/dist/{approvals-CuXILe52.js → approvals-B_sn4Wrn.js} +6 -6
  17. package/dist/{arazzo-CDXfX4u0.js → arazzo-BXD-VJU_.js} +1 -1
  18. package/dist/{arazzo-D4mKdaWI.js → arazzo-Ct0PGblq.js} +3 -3
  19. package/dist/astro/index.d.ts +6 -6
  20. package/dist/astro/index.js +2 -2
  21. package/dist/{audience-BUonniPx.js → audience-5Xx1hdIv.js} +1 -1
  22. package/dist/{auth-j3Eu-j4h.js → auth-BxXHxWRy.js} +1 -1
  23. package/dist/authzen/index.d.ts +5 -5
  24. package/dist/authzen/index.js +4 -4
  25. package/dist/{automation-CpOk7Tlu.d.ts → automation-B20_8UoT.d.ts} +3 -3
  26. package/dist/{automation-x3KEUusw.js → automation-BueW05db.js} +2 -2
  27. package/dist/better-auth/index.d.ts +2 -2
  28. package/dist/better-auth/index.js +1 -1
  29. package/dist/better-supabase/index.d.ts +113 -56
  30. package/dist/better-supabase/index.js +200 -62
  31. package/dist/better-supabase-DF8f8oly.js +194 -0
  32. package/dist/{bind-gwEbe9hL.js → bind-B4Z0U2Gr.js} +5 -5
  33. package/dist/{bind-CW7nsZ86.d.ts → bind-CnOMjazH.d.ts} +7 -7
  34. package/dist/{build-instance-DaBdCRiz.js → build-instance-B0vsViF5.js} +3 -25
  35. package/dist/{capability-zN6T9fxe.js → capability-CenWwTMR.js} +1 -1
  36. package/dist/{capability-v2xZB7us.d.ts → capability-YkRMUAsF.d.ts} +2 -2
  37. package/dist/{casbin-COUi09Ti.js → casbin-D5evU3lX.js} +1 -1
  38. package/dist/{casbin-BXlRcCdU.js → casbin-imBS3UIf.js} +1 -1
  39. package/dist/catalog/index.d.ts +5 -5
  40. package/dist/catalog/index.js +5 -5
  41. package/dist/catalog-C462QC3A.js +1 -0
  42. package/dist/{catalog-DjDc87R2.js → catalog-CoyKnU5c.js} +1 -1
  43. package/dist/{catalog-s0waIrfY.js → catalog-Y4CjN8NA.js} +4 -4
  44. package/dist/{catalog-operations-BD22drQf.js → catalog-operations-Do1eD-Rt.js} +1 -1
  45. package/dist/{challenge-DbkpCx_v.js → challenge-B__LcNve.js} +3 -3
  46. package/dist/chat/index.d.ts +1 -1
  47. package/dist/chat/index.js +3 -2
  48. package/dist/chat-sdk/index.d.ts +3 -3
  49. package/dist/claude-agent/index.d.ts +3 -3
  50. package/dist/claude-agent/index.js +2 -2
  51. package/dist/clerk/index.d.ts +3 -3
  52. package/dist/cli/bin.js +1 -1
  53. package/dist/cli/index.d.ts +8 -7
  54. package/dist/cli/index.js +3 -3
  55. package/dist/cloud/index.d.ts +8 -8
  56. package/dist/cloud/index.js +3 -3
  57. package/dist/{cloud-BW7JKfrF.js → cloud-DWCeStPH.js} +2 -2
  58. package/dist/{codemod-6CBQaT0x.js → codemod-B7QKJ_ak.js} +2 -2
  59. package/dist/{codemod-CR9EQBVd.js → codemod-BaPmaCYQ.js} +13 -6
  60. package/dist/{collect-DN_x7hvV.js → collect-Cr71JA7z.js} +8 -7
  61. package/dist/{collect-DMQ6Sxr6.js → collect-ScSG05VJ.js} +2 -2
  62. package/dist/collect-W9i7REKT.js +1 -0
  63. package/dist/compile/index.d.ts +1 -1
  64. package/dist/compile/index.js +1 -1
  65. package/dist/{compile-B_oJqmIg.js → compile-Cvru58id.js} +2 -2
  66. package/dist/{compile-DZftFfXc.d.ts → compile-DC-BrhH1.d.ts} +3 -3
  67. package/dist/{completion-CYRlOJzv.js → completion-DOUMyCwa.js} +1 -1
  68. package/dist/{delegation-aK4T_5WU.js → condition-evaluate-bVVRSdzq.js} +159 -159
  69. package/dist/{config-6iLK155o.js → config-DRp-E8Ly.js} +1 -1
  70. package/dist/{config-D2oXUwos.js → config-DyNanTjZ.js} +10 -8
  71. package/dist/{config-report-BLroaWCe.js → config-report-Bh_nLdAE.js} +2 -2
  72. package/dist/{config-shape-D9paLhEX.js → config-shape-C4zqzG2K.js} +9 -2
  73. package/dist/{context-YhyXyqBI.js → context-Cem4QafV.js} +2 -2
  74. package/dist/convex/index.d.ts +5 -5
  75. package/dist/convex/index.js +2 -2
  76. package/dist/{core-BwVkrpsi.js → core-CUjhfz0W.js} +6 -6
  77. package/dist/{core-BOeGWbcR.d.ts → core-D2JNg5jA.d.ts} +3 -3
  78. package/dist/coverage-D8jBJdgD.d.ts +114 -0
  79. package/dist/coverage-Dh2W_DmF.js +211 -0
  80. package/dist/{create-BezeYFcT.d.ts → create-B2tdOygC.d.ts} +7 -7
  81. package/dist/{create-C0R8omeF.js → create-BJ2_8NDO.js} +5 -5
  82. package/dist/{create-DDUFG1ul.js → create-BsL5lCWR.js} +10 -8
  83. package/dist/{create-DYSYYiLr.d.ts → create-CPDSbK1a.d.ts} +5 -5
  84. package/dist/{create-DMCC5ZOi.d.ts → create-oMCcZV4X.d.ts} +9 -9
  85. package/dist/{credential-B3Hj4puZ.js → credential-Bap3HClV.js} +4 -4
  86. package/dist/{server-D0PW6ZCw.js → credentials-BXV0oz56.js} +3 -146
  87. package/dist/credentials-DPX140fN.d.ts +125 -0
  88. package/dist/delivery/index.d.ts +4 -4
  89. package/dist/delivery/index.js +1 -1
  90. package/dist/{denied-text-De8cw3MW.d.ts → denied-text-BXQkWU7d.d.ts} +2 -2
  91. package/dist/{describe-DibQM6g-.d.ts → describe-DVobr5FX.d.ts} +2 -2
  92. package/dist/{diff-Bd1-VCe5.js → diff-BR9JArxz.js} +6 -6
  93. package/dist/{diff-DXRNcjpg.js → diff-Jc_kbDz-.js} +1 -1
  94. package/dist/{doctor-CJcS0Mrq.js → doctor-BBMW5ZT_.js} +310 -36
  95. package/dist/{doctor-DYTgibLC.js → doctor-DhqSiPkq.js} +3 -3
  96. package/dist/drizzle/index.d.ts +3 -3
  97. package/dist/drizzle/index.js +1 -1
  98. package/dist/elysia/index.d.ts +5 -5
  99. package/dist/elysia/index.js +3 -3
  100. package/dist/{errors-OTE9u4Wk.d.ts → errors-D_JIQJYb.d.ts} +1 -1
  101. package/dist/{evaluate-Dcq_U2TV.js → evaluate-B5yZHmts.js} +16 -16
  102. package/dist/{evaluations-CNMVJVD6.js → evaluations-BzTDWO4m.js} +57 -57
  103. package/dist/{evaluations-BgxEfPL7.d.ts → evaluations-DQYfh4Jh.d.ts} +3 -3
  104. package/dist/eve/index.d.ts +5 -5
  105. package/dist/eve/index.js +3 -3
  106. package/dist/express/index.d.ts +5 -5
  107. package/dist/express/index.js +3 -3
  108. package/dist/fastify/index.d.ts +5 -5
  109. package/dist/fastify/index.js +3 -3
  110. package/dist/{fetch-adapter-DCQ4pZxf.d.ts → fetch-adapter-DxqsIXSO.d.ts} +4 -4
  111. package/dist/{fetch-adapter-acq4dPX3.js → fetch-adapter-MoYZ-vF5.js} +5 -4
  112. package/dist/{fields-D_TfExiI.js → fields-CVyOk-f1.js} +2 -2
  113. package/dist/{fixtures-Cemqurt8.js → fixtures-BVZc7OCF.js} +1 -1
  114. package/dist/{from-snapshot-DHnb8Fh4.js → from-snapshot-oR_N97dM.js} +346 -14
  115. package/dist/{gen-gv_WHBIG.js → gen-DXXoFjyf.js} +1 -1
  116. package/dist/{gen-CH50v9VI.js → gen-WdycZ_-b.js} +5 -5
  117. package/dist/{grantee-conditions-DX4K_gGI.js → grantee-conditions-Dzprappv.js} +1 -1
  118. package/dist/{grantee-match-BP-k4vRJ.js → grantee-match-8J2y60MF.js} +3 -3
  119. package/dist/h3/index.d.ts +4 -4
  120. package/dist/h3/index.js +3 -3
  121. package/dist/{helpers-D-MXwkOF.js → helpers-DzBIfL1N.js} +25 -25
  122. package/dist/hono/index.d.ts +5 -5
  123. package/dist/hono/index.js +3 -3
  124. package/dist/{hosted-C2Pmhy2x.js → hosted-C5I2TSXm.js} +4 -4
  125. package/dist/{hosted-yhyAuQkL.d.ts → hosted-DXq1plaP.d.ts} +1 -1
  126. package/dist/{http-DhMWeB_h.js → http-dptLQzPP.js} +1 -1
  127. package/dist/{expiry-6XByK0dm.js → ids-DzhJaCUj.js} +23 -23
  128. package/dist/{import-BlwuuZkr.js → import-BE5sDazm.js} +2 -2
  129. package/dist/{import-C2ExjVvv.js → import-CvXswHDy.js} +2 -2
  130. package/dist/index-BcS8c_2S.d.ts +101 -0
  131. package/dist/{index--AwSBzJC.d.ts → index-BdZpqhJK.d.ts} +2 -2
  132. package/dist/{index-CLbGOPBr.d.ts → index-C-R8lBPb.d.ts} +3 -3
  133. package/dist/{index-CruReRkB.d.ts → index-C_8uxAlv.d.ts} +5 -5
  134. package/dist/{index-D7xGi1LS.d.ts → index-Cjfa1Uwr.d.ts} +22 -40
  135. package/dist/{index-Bt37QovT.d.ts → index-iIsqXFVu.d.ts} +6 -6
  136. package/dist/index.d.ts +19 -20
  137. package/dist/index.js +25 -24
  138. package/dist/{init-CalppFAI.js → init-B_S8Xdz1.js} +4 -4
  139. package/dist/{init-B62H9Kyx.js → init-CqGHcvyR.js} +2 -2
  140. package/dist/{instance-options-VPsNQsTH.d.ts → instance-options-C6gEDOts.d.ts} +1 -1
  141. package/dist/instance-options-URVwqpMW.js +24 -0
  142. package/dist/{instance-snapshot-SX8zH_1t.js → instance-snapshot-D_dGTq--.js} +10 -10
  143. package/dist/jwt/index.d.ts +4 -4
  144. package/dist/jwt/index.js +2 -2
  145. package/dist/{kernel-_QEUOSU0.js → kernel-NmxiWII2.js} +8 -8
  146. package/dist/kysely/index.d.ts +3 -3
  147. package/dist/kysely/index.js +1 -1
  148. package/dist/limits-CAhpRrhk.js +167 -0
  149. package/dist/{load-BaEamml-.js → load-C4p4VgwR.js} +2 -2
  150. package/dist/load-DiBUJx77.js +1 -0
  151. package/dist/{login-dDb_8muO.js → login-CzwlsBEO.js} +4 -4
  152. package/dist/{login-MxQV1BLh.js → login-DoLxv1s5.js} +3 -3
  153. package/dist/{manifest-DvDzxhy6.js → manifest-BAf7cgRx.js} +35 -35
  154. package/dist/{map-claims-PQwHynxV.js → map-claims-CAa_bQt9.js} +1 -1
  155. package/dist/{map-error-EOhahOVA.js → map-error-p4ROJ_26.js} +1 -1
  156. package/dist/mcp/index.d.ts +9 -9
  157. package/dist/mcp/index.js +9 -8
  158. package/dist/{migrate-CkLHdwuH.js → migrate-DVsxeE0y.js} +1 -1
  159. package/dist/{module-values-BYuNtdK5.js → module-values-BLiVlO1X.js} +3 -3
  160. package/dist/nest/index.d.ts +5 -5
  161. package/dist/nest/index.js +3 -3
  162. package/dist/next/index.d.ts +46 -17
  163. package/dist/next/index.js +58 -23
  164. package/dist/next/plugin.d.ts +1 -1
  165. package/dist/next/plugin.js +1 -1
  166. package/dist/node/index.d.ts +5 -5
  167. package/dist/node/index.js +2 -2
  168. package/dist/openai/index.d.ts +5 -5
  169. package/dist/openai/index.js +3 -3
  170. package/dist/openapi/index.d.ts +5 -59
  171. package/dist/openapi/index.js +3 -2
  172. package/dist/{openapi-BOsx0xn9.js → openapi-Cc-aS9xC.js} +6 -135
  173. package/dist/{openapi-BkGtE5kX.js → openapi-DroBcLJZ.js} +2 -2
  174. package/dist/{openapi-DKePsnln.js → openapi-EmvKwuWj.js} +4 -4
  175. package/dist/{operations-Ci_rT6Uo.d.ts → operations-BMPx7HyO.d.ts} +1 -1
  176. package/dist/optional-8TKc-0j4.js +47 -0
  177. package/dist/orpc/index.d.ts +7 -7
  178. package/dist/orpc/index.js +4 -4
  179. package/dist/otel/index.d.ts +3 -3
  180. package/dist/otel/index.js +1 -1
  181. package/dist/{output-B2h-2g3F.js → output-CYgfpT6o.js} +1 -1
  182. package/dist/{ownership-MGHa5vfX.js → ownership-adPAsUwY.js} +15 -13
  183. package/dist/{parse-CXTT7hBq.js → parse-CORUNcCo.js} +1 -1
  184. package/dist/{parse-local-manifest-CE4tgFsj.d.ts → parse-local-manifest-BaCqsqwC.d.ts} +1 -1
  185. package/dist/pdp/index.d.ts +3 -3
  186. package/dist/pdp/index.js +4 -3
  187. package/dist/{permdock-C1DN_7a-.js → permdock-B5LyNVgn.js} +71 -34
  188. package/dist/{permdock-D4F2p5J8.d.ts → permdock-BaB-KQqn.d.ts} +51 -9
  189. package/dist/{permissions-8N2yFsUM.js → permissions-COpRGKt7.js} +1 -1
  190. package/dist/{permissions-Bx6UI8n1.d.ts → permissions-DriWkV7q.d.ts} +1 -2
  191. package/dist/{policy-from-catalog-CUNlpgz0.js → policy-from-catalog-Cy103lsm.js} +8 -8
  192. package/dist/{policy-types-BI9C5Sp5.d.ts → policy-types-rNfz7t0M.d.ts} +9 -3
  193. package/dist/{policy-CaAME-Rh.js → policy-wGzbAPQF.js} +7 -7
  194. package/dist/{policy-Dh9WVSVz.d.ts → policy-x8RBKW8d.d.ts} +2 -2
  195. package/dist/{postgrest-CWCCbaxm.d.ts → postgrest-Cn0Res25.d.ts} +9 -21
  196. package/dist/powersync-BdoR7nwS.js +1 -0
  197. package/dist/{powersync-Deim9O47.js → powersync-BeI0VmEK.js} +2 -2
  198. package/dist/{powersync-CB8RwcB4.js → powersync-Dpa5AnnN.js} +11 -11
  199. package/dist/preset/index.js +1 -1
  200. package/dist/{preset-pPrVyGU5.js → preset-Bn5Z54cH.js} +5 -6
  201. package/dist/prisma/index.d.ts +2 -2
  202. package/dist/prisma/index.js +1 -1
  203. package/dist/{protected-action-ua0cx5cW.d.ts → protected-action-C4aj1KjO.d.ts} +6 -7
  204. package/dist/{protected-action-CD1HXwQK.js → protected-action-E7Sdt_Dt.js} +1 -1
  205. package/dist/{provider-D_hgjZRa.d.ts → provider-B-1DlOGM.d.ts} +1 -1
  206. package/dist/{provider-qESIf_C0.js → provider-DKO9KHua.js} +2 -2
  207. package/dist/{provider-store-BTHGJH9j.js → provider-store-D4PU1my_.js} +2 -2
  208. package/dist/{pull-BxqVL4Es.js → pull-3tkn25ll.js} +5 -5
  209. package/dist/pull-D90HqWNP.js +1 -0
  210. package/dist/{push-D2SsRW0U.js → push-dMyKdlEm.js} +6 -6
  211. package/dist/{pushed-policy-BERO0x9O.js → pushed-policy-Bi5-il4C.js} +2 -2
  212. package/dist/{pushed-policy-P0hgyLBh.d.ts → pushed-policy-P55cJNx5.d.ts} +1 -1
  213. package/dist/react/index.d.ts +6 -6
  214. package/dist/react/index.js +3 -3
  215. package/dist/react/provider-client.d.ts +1 -1
  216. package/dist/react/provider-client.js +1 -1
  217. package/dist/react-native/index.d.ts +9 -9
  218. package/dist/react-native/index.js +7 -7
  219. package/dist/{relation-walk-DK_gkgL7.js → relation-walk-BDTaTKTM.js} +1 -1
  220. package/dist/{relations-BxvRvDHK.js → relations-CMsJ1ARY.js} +1 -1
  221. package/dist/{replay-DYXI4gRN.d.ts → replay-DKhFvt0L.d.ts} +1 -1
  222. package/dist/{request-context-BPTi68z5.js → request-context-5gl_oxO1.js} +2 -2
  223. package/dist/resend/index.d.ts +4 -4
  224. package/dist/resend/index.js +2 -2
  225. package/dist/{resolve-names-BZQZRnMH.js → resolve-names-BnGJU88N.js} +4 -4
  226. package/dist/{rls-DpoJ5gCg.js → rls-DIYSRnDZ.js} +1 -1
  227. package/dist/{rls-OPorg_2G.js → rls-qrehUPf_.js} +45 -18
  228. package/dist/{role-builder-C5AgaC1x.js → role-builder-boQiUvfo.js} +3 -3
  229. package/dist/{rpc-D2LnFELm.d.ts → rpc-BqRiVpbP.d.ts} +2 -2
  230. package/dist/{rpc-DdkbQVlT.js → rpc-Dhi55Whd.js} +2 -2
  231. package/dist/run-elFdnSZx.js +1 -0
  232. package/dist/{run-YCpANf1B.js → run-oNqBe0gc.js} +3 -3
  233. package/dist/{run-ticket-CjvXr6wj.js → run-ticket-Ddxt9OuU.js} +2 -2
  234. package/dist/{run-ticket-94DOS9Cd.d.ts → run-ticket-Dulj4RQk.d.ts} +2 -2
  235. package/dist/{saas-BEXnrH9H.js → saas-DABv6vjy.js} +6 -5
  236. package/dist/{scan-COvn7ZjN.js → scan-BYXqcgON.js} +1 -1
  237. package/dist/{schema-BfSDo7Xj.js → schema-Wf-SvlHG.js} +1 -1
  238. package/dist/scim/index.d.ts +1 -1
  239. package/dist/scim/index.js +1 -1
  240. package/dist/{scopes-BSdYaGHs.js → scopes-gdH__vDZ.js} +1 -1
  241. package/dist/server/index.d.ts +11 -10
  242. package/dist/server/index.js +7 -6
  243. package/dist/server-CKjFooaJ.js +147 -0
  244. package/dist/{server-types-ChzXWU4Y.d.ts → server-types--_Hann81.d.ts} +10 -9
  245. package/dist/{shared-sW3VYchq.js → shared-DfaIWvIJ.js} +11 -2
  246. package/dist/{sink-RwmP7ZHs.d.ts → sink-Cs6z34AX.d.ts} +4 -4
  247. package/dist/{skills-N2Hd8KN8.js → skills-417bOj4o.js} +1 -1
  248. package/dist/{skills-Ce4C2dq1.js → skills-B9U465B7.js} +2 -2
  249. package/dist/{snapshot-DHPih65J.js → snapshot-C2j96x97.js} +4 -4
  250. package/dist/{snapshot-cache-MPinwwgZ.d.ts → snapshot-cache-Cc7VNabe.d.ts} +1 -1
  251. package/dist/solid/index.d.ts +6 -7
  252. package/dist/solid/index.js +2 -2
  253. package/dist/solid-start/index.d.ts +6 -6
  254. package/dist/solid-start/index.js +3 -3
  255. package/dist/{sources-sgQlMfmz.d.ts → sources-BfTza0zT.d.ts} +1 -1
  256. package/dist/{src-B8SQNsvw.js → src-BG9YJM3Q.js} +97 -247
  257. package/dist/ssf/index.d.ts +3 -3
  258. package/dist/ssf/index.js +3 -3
  259. package/dist/{standard-webhooks-CFZIYtBF.d.ts → standard-webhooks-CJBgfl7y.d.ts} +2 -2
  260. package/dist/{store-CSOsXd5s.js → store-BpKH-pLm.js} +2 -2
  261. package/dist/{store-Dpg_fSNQ.d.ts → store-DSyjHD5-.d.ts} +5 -5
  262. package/dist/{store-options-CDvoX52-.js → store-options-CXv6BHH6.js} +5 -6
  263. package/dist/{stores-PpYVQ5yF.js → stores-BuqAHjp_.js} +1 -1
  264. package/dist/{stores-C2A6KsxE.d.ts → stores-C6-7TPTV.d.ts} +6 -7
  265. package/dist/{postgrest-BrjrckDG.js → subject-BqFwS6l3.js} +214 -319
  266. package/dist/subject-cache-BT1fGuea.js +193 -0
  267. package/dist/subject-cache-d_Z4KAnm.d.ts +144 -0
  268. package/dist/supabase/index.d.ts +6 -5
  269. package/dist/supabase/index.js +3 -2
  270. package/dist/supabase/middleware.d.ts +6 -6
  271. package/dist/supabase/middleware.js +6 -6
  272. package/dist/{supabase-zL7PC3RG.js → supabase-D0J99yqL.js} +2 -2
  273. package/dist/{supabase-CVZuytCC.js → supabase-DnazO6W4.js} +3 -3
  274. package/dist/{supabase-hook-BCSwK5x-.js → supabase-hook-Bh5syR9N.js} +174 -62
  275. package/dist/supabase-hook-CVAenq-w.js +1 -0
  276. package/dist/{supautils-7UES0i4a.js → supautils-ChXR-4Or.js} +302 -43
  277. package/dist/{support-session-BsmPCbz8.js → support-session-BGeEYDSq.js} +2 -2
  278. package/dist/svelte/index.d.ts +5 -5
  279. package/dist/svelte/index.js +3 -3
  280. package/dist/svelte/runtime.d.ts +3 -3
  281. package/dist/svelte/runtime.js +1 -1
  282. package/dist/svelte/source.d.ts +5 -5
  283. package/dist/svelte/source.js +2 -2
  284. package/dist/sveltekit/index.d.ts +6 -6
  285. package/dist/sveltekit/index.js +2 -2
  286. package/dist/{tables-DSX_Ma_n.js → tables-CbEOy2Ma.js} +137 -55
  287. package/dist/tanstack-start/index.d.ts +6 -6
  288. package/dist/tanstack-start/index.js +2 -2
  289. package/dist/{tenancy-DvOHHk3-.js → tenancy-BlxY5T0q.js} +2 -2
  290. package/dist/terminal/index.d.ts +6 -6
  291. package/dist/terminal/index.js +6 -6
  292. package/dist/testing/core.d.ts +1 -1
  293. package/dist/testing/core.js +1 -1
  294. package/dist/testing/fixtures/index.d.ts +35 -2
  295. package/dist/testing/fixtures/index.js +39 -2
  296. package/dist/testing/index.d.ts +41 -25
  297. package/dist/testing/index.js +114 -26
  298. package/dist/testing/saas/index.d.ts +5 -5
  299. package/dist/testing/saas/index.js +2 -2
  300. package/dist/testing/saas/permissions.d.ts +1 -1
  301. package/dist/testing/saas/permissions.js +1 -1
  302. package/dist/trpc/index.d.ts +6 -6
  303. package/dist/trpc/index.js +4 -4
  304. package/dist/{type-helpers-BjOLGVy1.d.ts → type-helpers-iXJEIDe7.d.ts} +3 -4
  305. package/dist/{types-p8mhWTcR.d.ts → types-B9F0EZAF.d.ts} +3 -3
  306. package/dist/{types-DZwEOsK1.d.ts → types-BSNZMp5b.d.ts} +1 -1
  307. package/dist/{types-DnzRZjEu.d.ts → types-BpxdxaRD.d.ts} +5 -5
  308. package/dist/{types-C5p2hoBR.d.ts → types-CD1qmxdx.d.ts} +4 -4
  309. package/dist/{types-D1NjjwI4.d.ts → types-CS1DI_Ke.d.ts} +40 -9
  310. package/dist/{types-CMclYgSk.d.ts → types-C_a44wSr.d.ts} +3 -3
  311. package/dist/{types-DBVSljAx.d.ts → types-Cq2rvv-C.d.ts} +3 -3
  312. package/dist/{types--_lpWUGV.d.ts → types-CuDXvyIT.d.ts} +5 -5
  313. package/dist/{types-7Vlz1Wi2.d.ts → types-DAyp592k.d.ts} +2 -2
  314. package/dist/{types-Drs3OOAy.d.ts → types-NikV1pND.d.ts} +4 -4
  315. package/dist/{types-BzxA2OAD.d.ts → types-ZfjQB0KC.d.ts} +2 -2
  316. package/dist/{types-D8JVDWOr.d.ts → types-_pi9kxS2.d.ts} +2 -2
  317. package/dist/unplugin/index.d.ts +1 -1
  318. package/dist/unplugin/index.js +1 -1
  319. package/dist/{usage-CUnw73Y-.js → usage-0wsl83uw.js} +10 -10
  320. package/dist/{usage-BcAqmjkj.js → usage-Bl-BkXEq.js} +1 -1
  321. package/dist/usage-CmyGbo4e.js +1 -0
  322. package/dist/{validation-error-DkOK9zUE.d.ts → validation-error-DLAYFlkr.d.ts} +1 -1
  323. package/dist/{verify-V08pirDB.js → verify-BSLotSa0.js} +41 -24
  324. package/dist/version-sources-BC3hf2ME.js +34 -0
  325. package/dist/{permission-types-CAY-GU7e.d.ts → vocabulary-DeZvUaTw.d.ts} +69 -1
  326. package/dist/vue/index.d.ts +6 -7
  327. package/dist/vue/index.js +2 -2
  328. package/dist/{waiter-BjVI_Byg.d.ts → waiter-cbK1CBhT.d.ts} +2 -2
  329. package/dist/{watch-Dz2LNM1R.js → watch-BigZ260i.js} +2 -2
  330. package/dist/watch-CHURMgrv.js +1 -0
  331. package/dist/webmcp/index.d.ts +2 -2
  332. package/dist/{who-can-CZeAwQZD.js → who-can-CjfMP9a4.js} +8 -8
  333. package/dist/workflow/index.d.ts +3 -3
  334. package/dist/workflow/index.js +6 -5
  335. package/dist/workflow-sdk/index.d.ts +5 -5
  336. package/dist/{wrap-CE5lxje7.d.ts → wrap-B-k2qHJx.d.ts} +2 -2
  337. package/package.json +16 -4
  338. package/skills/permdock-wire/references/presets-and-recipes.md +2 -2
  339. package/dist/better-supabase-ayun1IKE.js +0 -122
  340. package/dist/catalog-BTPySmbp.js +0 -1
  341. package/dist/collect-eSTXOZDC.js +0 -1
  342. package/dist/index-B_I6N8Ju.d.ts +0 -222
  343. package/dist/load-CjnlPxpL.js +0 -1
  344. package/dist/powersync-Cs1E04s6.js +0 -1
  345. package/dist/pull-BLT25Y5C.js +0 -1
  346. package/dist/run-CW0QsyA9.js +0 -1
  347. package/dist/supabase-hook-7XxWGHQF.js +0 -1
  348. package/dist/usage-BdIS9NfN.js +0 -1
  349. package/dist/version-cache-q5cpaDSt.d.ts +0 -57
  350. package/dist/vocabulary-DEJ5j4mR.d.ts +0 -70
  351. package/dist/watch-CS69ftMP.js +0 -1
  352. package/dist/where-scope-BAyOsPQW.js +0 -332
  353. package/dist/{approval-normalize-hlfO9BJv.js → approval-normalize-DNLW0zOM.js} +1 -1
  354. package/dist/{body-C9JbIoqb.js → body-B3ylkmmE.js} +1 -1
  355. package/dist/{catalog-doc-nrgfbh8I.js → catalog-doc-Zi0jRpyH.js} +2 -2
  356. package/dist/{device-BwbJNmb2.js → device-BkSynWdg.js} +1 -1
  357. package/dist/{prompt-BYc6drYW.js → prompt-D1Gj1W4Y.js} +1 -1
  358. package/dist/{scim-C30QBBoF.js → scim-BG6uPUeW.js} +1 -1
  359. package/dist/{wrap-C5PWzgkq.js → wrap-BKU5Arsu.js} +1 -1
@@ -1,15 +1,15 @@
1
1
  import { c as listPermissions, h as formerKeys } from "./permission-registry-B8tYxPIt.js";
2
2
  import { a as expandRelation, c as isEdgeRelation, d as isSelfParented, l as isFieldRelation, o as groupEntries, p as restrictedFor, u as isPrincipalRelation } from "./resource-relations-8-pCScBO.js";
3
- import { c as rootScope, d as scopeList, l as scopeChain, s as resolveScope } from "./scopes-BSdYaGHs.js";
4
3
  import { o as flattenGrantee } from "./grantee-Dke-9rd1.js";
5
- import { r as relationCondition, t as inheritCondition } from "./grantee-conditions-DX4K_gGI.js";
6
- import { l as partitionsOf, p as scopeField } from "./tenancy-DvOHHk3-.js";
7
- import { a as delegatedScopeMap } from "./permdock-C1DN_7a-.js";
4
+ import { c as rootScope, d as scopeList, l as scopeChain, s as resolveScope } from "./scopes-gdH__vDZ.js";
5
+ import { r as relationCondition, t as inheritCondition } from "./grantee-conditions-Dzprappv.js";
6
+ import { l as partitionsOf, p as scopeField } from "./tenancy-BlxY5T0q.js";
7
+ import { a as delegatedScopeMap } from "./permdock-B5LyNVgn.js";
8
8
  import { i as configError } from "./errors-BhRkoNS7.js";
9
9
  import { d as sqlTextArray, i as qualifySqlTable, t as SQL_IDENT } from "./sql-0WjxIp9g.js";
10
- import { a as scopeMembershipTable, d as restrictedRowsSql, i as scopeColumn, l as relationArmSql } from "./compile-B_oJqmIg.js";
10
+ import { a as scopeMembershipTable, d as restrictedRowsSql, i as scopeColumn, l as relationArmSql } from "./compile-Cvru58id.js";
11
11
  import { d as keptKeys, l as roleColumn, t as AUTHZ_VERSION_TABLE, u as roleManifest } from "./sources-C4vkzZJV.js";
12
- import { A as quoteQualified, D as qualified, E as helperSchema, I as scopeTypeOf, O as quoteIdent, R as tenantTypeOf, _ as subjectClaimJsonSql, d as keyTenantSql, f as kindFilterSql, h as roleKindSql, i as allowEntry, j as quoteTable, k as quoteLiteral, m as memberVia, n as GLOBAL_ROLES, o as rootName, r as HELPERS, s as signedIn, t as CUSTOM_ROLES, u as globalKindFilterSql, v as subjectClaimSql, w as CLI, x as userIdHelperSql, y as subjectIdSql } from "./shared-sW3VYchq.js";
12
+ import { A as quoteQualified, D as qualified, E as helperSchema, L as scopeTypeOf, O as quoteIdent, _ as subjectClaimJsonSql, d as keyTenantSql, f as kindFilterSql, h as roleKindSql, i as allowEntry, j as quoteTable, k as quoteLiteral, m as memberVia, n as GLOBAL_ROLES, o as rootName, r as HELPERS, s as signedIn, t as CUSTOM_ROLES, u as globalKindFilterSql, v as subjectClaimSql, w as CLI, x as userIdHelperSql, y as subjectIdSql, z as tenantTypeOf } from "./shared-DfaIWvIJ.js";
13
13
  //#region src/cli/sql/active.ts
14
14
  function checkActiveRow(label, row) {
15
15
  quoteTable(row.table);
@@ -1373,14 +1373,34 @@ function sourcesBodyOf(sql, sources, user) {
1373
1373
  vars: sources.map((source, index) => `${sourceUser(index)} ${source.sql.userType} := ${user};`)
1374
1374
  };
1375
1375
  }
1376
+ /** SQL reading the memo at `key`: a text value, or null when unset. */
1377
+ function memoReadSql(api, key) {
1378
+ return api === "better-supabase" ? `better_supabase.memo_get(${key})` : `nullif(current_setting(${key}, true), '')`;
1379
+ }
1380
+ /** SQL writing `value` to the memo at `key`. */
1381
+ function memoWriteSql(api, key, value) {
1382
+ return api === "better-supabase" ? `better_supabase.memo_set(${key}, ${value})` : `set_config(${key}, ${value}, true)`;
1383
+ }
1384
+ function memoDiscriminatorSql(user, key) {
1385
+ return `md5(concat_ws('|',
1386
+ ${user},
1387
+ ${key},
1388
+ coalesce((select auth.jwt()) ->> 'authz_ver', ''),
1389
+ coalesce(nullif(current_setting('permdock.m.gen', true), ''), '0'),
1390
+ statement_timestamp()::text,
1391
+ md5(coalesce((select auth.jwt())::text, ''))
1392
+ ))`;
1393
+ }
1376
1394
  /**
1377
1395
  * `language sql`, or `plpgsql` returning the query when the body declares
1378
1396
  * variables.
1379
1397
  */
1380
- function functionBody(body) {
1398
+ function functionBody(body, parallelSafe = false) {
1399
+ const planner = `cost 1000${parallelSafe ? "\nparallel safe" : ""}`;
1381
1400
  if (body.memo !== void 0) return `language plpgsql
1382
1401
  volatile
1383
1402
  security definer
1403
+ cost 1000
1384
1404
  set search_path = ''
1385
1405
  as $$
1386
1406
  declare
@@ -1388,15 +1408,8 @@ ${[
1388
1408
  ...body.vars,
1389
1409
  `v_user text := ${body.memo.user}::text;`,
1390
1410
  `v_key text := 'permdock.m.' || ${quoteLiteral(body.memo.scope)} || '.k' || (hashtext(p_grant) & 1023)::text;`,
1391
- `v_disc text := md5(concat_ws('|',
1392
- v_user,
1393
- p_grant,
1394
- coalesce((select auth.jwt()) ->> 'authz_ver', ''),
1395
- coalesce(nullif(current_setting('permdock.m.gen', true), ''), '0'),
1396
- statement_timestamp()::text,
1397
- md5(coalesce((select auth.jwt())::text, ''))
1398
- ));`,
1399
- `v_memo text := nullif(current_setting(v_key, true), '');`,
1411
+ `v_disc text := ${memoDiscriminatorSql("v_user", "p_grant")};`,
1412
+ `v_memo text := ${memoReadSql(body.memo.api, "v_key")};`,
1400
1413
  `v_ids ${body.memo.type}[];`
1401
1414
  ].map((line) => ` ${line}`).join("\n")}
1402
1415
  begin
@@ -1406,7 +1419,7 @@ begin
1406
1419
  v_ids := array(
1407
1420
  ${body.sql}
1408
1421
  );
1409
- perform set_config(v_key, jsonb_build_object('k', v_disc, 'ids', to_jsonb(v_ids))::text, true);
1422
+ perform ${memoWriteSql(body.memo.api, "v_key", "jsonb_build_object('k', v_disc, 'ids', to_jsonb(v_ids))::text")};
1410
1423
  end if;
1411
1424
  return query select unnest(v_ids);
1412
1425
  end;
@@ -1414,6 +1427,7 @@ $$;`;
1414
1427
  if (body.vars.length === 0) return `language sql
1415
1428
  stable
1416
1429
  security definer
1430
+ ${planner}
1417
1431
  set search_path = ''
1418
1432
  as $$
1419
1433
  ${body.sql}
@@ -1421,6 +1435,7 @@ $$;`;
1421
1435
  return `language plpgsql
1422
1436
  stable
1423
1437
  security definer
1438
+ ${planner}
1424
1439
  set search_path = ''
1425
1440
  as $$
1426
1441
  declare
@@ -2432,13 +2447,25 @@ function suspensionTargets(targets, row) {
2432
2447
  const columns = [...row.disabledAt === void 0 ? [] : [row.disabledAt], ...row.status === void 0 ? [] : [row.status]];
2433
2448
  add(targets, row.table, columns);
2434
2449
  }
2435
- /**
2436
- * The triggers that invalidate the memo when a write changes permitted ids
2437
- * without changing a membership: the permission map, a custom role's grants and
2438
- * a suspended user or scope. The hook's version triggers call the same bump.
2439
- */
2440
- function memoGenerationSql(ctx) {
2441
- if (!memoizes(ctx)) return "";
2450
+ const IDENT = String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)`;
2451
+ const READ = new RegExp(String.raw`(?<!\bdistinct\s+)(?<!\bextract\s*\([^()]*)\b(?:from|join)\s+(${IDENT})\.(${IDENT})(?![\w$]|\s*[.(])`, "gu");
2452
+ const SYSTEM = /* @__PURE__ */ new Set([
2453
+ "auth",
2454
+ "pg_catalog",
2455
+ "information_schema"
2456
+ ]);
2457
+ function unquote(name) {
2458
+ return name.startsWith("\"") ? name.slice(1, -1).replaceAll("\"\"", "\"") : name;
2459
+ }
2460
+ function readTables(sql) {
2461
+ const out = /* @__PURE__ */ new Set();
2462
+ for (const [, schema = "", table = ""] of sql.matchAll(READ)) {
2463
+ const name = unquote(schema);
2464
+ if (!SYSTEM.has(name)) out.add(`${name}.${unquote(table)}`);
2465
+ }
2466
+ return [...out];
2467
+ }
2468
+ function memoTargets(ctx, reads) {
2442
2469
  const schema = helperSchema(ctx);
2443
2470
  const targets = /* @__PURE__ */ new Map();
2444
2471
  add(targets, `${schema}.role_permissions`);
@@ -2454,9 +2481,36 @@ function memoGenerationSql(ctx) {
2454
2481
  }
2455
2482
  suspensionTargets(targets, ctx.suspension?.users);
2456
2483
  for (const row of Object.values(ctx.suspension?.scopes ?? {})) suspensionTargets(targets, row);
2484
+ for (const table of readTables(reads)) if (!targets.has(qualifySqlTable(table))) add(targets, table);
2485
+ return targets;
2486
+ }
2487
+ function triggersSql(ctx, targets) {
2488
+ const trigger = qualified(ctx, TRIGGER);
2489
+ return [...targets].map(({ table, columns }) => {
2490
+ const target = quoteTable(qualifySqlTable(table));
2491
+ const update = columns === void 0 ? "update" : `update of ${[...columns].map((column) => quoteIdent(column)).join(", ")}`;
2492
+ return `drop trigger if exists ${quoteIdent(TRIGGER)} on ${target};
2493
+ create trigger ${quoteIdent(TRIGGER)}
2494
+ after insert or ${update} or delete on ${target}
2495
+ for each statement execute function ${trigger}();
2496
+ drop trigger if exists ${quoteIdent(`${TRIGGER}_truncate`)} on ${target};
2497
+ create trigger ${quoteIdent(`${TRIGGER}_truncate`)}
2498
+ after truncate on ${target}
2499
+ for each statement execute function ${trigger}();`;
2500
+ }).join("\n");
2501
+ }
2502
+ /**
2503
+ * The triggers that invalidate the memo when a write changes permitted ids
2504
+ * inside the statement: the permission map, a custom role's grants, a suspended
2505
+ * user or scope, and every table `reads` (the memoized helper bodies) selects
2506
+ * from, such as the membership sources and the global roles. The hook's version
2507
+ * triggers call the same bump.
2508
+ */
2509
+ function memoGenerationSql(ctx, reads = "") {
2510
+ if (!memoizes(ctx)) return "";
2457
2511
  const bump = qualified(ctx, BUMP);
2458
2512
  const trigger = qualified(ctx, TRIGGER);
2459
- return `-- a permission, custom-role or suspension write changes permitted ids inside the statement
2513
+ return `-- a permission, custom-role, suspension or membership write changes permitted ids inside the statement
2460
2514
  create or replace function ${bump}()
2461
2515
  returns void
2462
2516
  language sql
@@ -2485,18 +2539,13 @@ begin
2485
2539
  end;
2486
2540
  $$;
2487
2541
  revoke execute on function ${trigger}() from public, anon, authenticated;
2488
- ${[...targets.values()].map(({ table, columns }) => {
2489
- const target = quoteTable(qualifySqlTable(table));
2490
- const update = columns === void 0 ? "update" : `update of ${[...columns].map((column) => quoteIdent(column)).join(", ")}`;
2491
- return `drop trigger if exists ${quoteIdent(TRIGGER)} on ${target};
2492
- create trigger ${quoteIdent(TRIGGER)}
2493
- after insert or ${update} or delete on ${target}
2494
- for each statement execute function ${trigger}();
2495
- drop trigger if exists ${quoteIdent(`${TRIGGER}_truncate`)} on ${target};
2496
- create trigger ${quoteIdent(`${TRIGGER}_truncate`)}
2497
- after truncate on ${target}
2498
- for each statement execute function ${trigger}();`;
2499
- }).join("\n")}`;
2542
+ ${triggersSql(ctx, memoTargets(ctx, reads).values())}`;
2543
+ }
2544
+ function memoReadTriggersSql(ctx, reads, covered) {
2545
+ const done = memoTargets(ctx, covered);
2546
+ const targets = /* @__PURE__ */ new Map();
2547
+ for (const table of readTables(reads)) if (!done.has(qualifySqlTable(table))) add(targets, table);
2548
+ return targets.size === 0 ? "" : triggersSql(ctx, targets.values());
2500
2549
  }
2501
2550
  //#endregion
2502
2551
  //#region src/cli/rls/token-scopes.ts
@@ -2665,7 +2714,7 @@ grant execute on function ${fn}(text) to anon, authenticated;` : `revoke execute
2665
2714
  grant execute on function ${fn}(text) to authenticated;`;
2666
2715
  return `create or replace function ${fn}(p_grant text)
2667
2716
  returns ${returns}
2668
- ${functionBody(body)}
2717
+ ${functionBody(body, !memoizes(ctx))}
2669
2718
  ${grants}`;
2670
2719
  }
2671
2720
  /**
@@ -2686,7 +2735,7 @@ function forUserSql(ctx) {
2686
2735
  const qualifiedName = qualified(ctx, name);
2687
2736
  return `create or replace function ${qualifiedName}(p_user ${type}, p_grant text)
2688
2737
  returns ${returns}
2689
- ${functionBody(body)}
2738
+ ${functionBody(body, !memoizes(ctx))}
2690
2739
  revoke execute on function ${qualifiedName}(${type}, text) from public, anon, authenticated;`;
2691
2740
  };
2692
2741
  return [`-- the helpers for a user the caller names: trusted SQL acting for a stored user; no client role may execute them
@@ -2803,7 +2852,7 @@ revoke all on table ${ur} from anon, authenticated, public;`);
2803
2852
  }
2804
2853
  const custom = customRolesSql(ctx);
2805
2854
  if (custom !== "") chunks.push(custom);
2806
- const memoGeneration = memoGenerationSql(ctx);
2855
+ const memoGeneration = memoGenerationSql(ctx, memoReadsSql(ctx));
2807
2856
  if (memoGeneration !== "") chunks.push(memoGeneration);
2808
2857
  const anon = options.anonExecute === true;
2809
2858
  const keys = ctx.apiKeys;
@@ -2848,10 +2897,15 @@ function memoBody(ctx, scope, type, body) {
2848
2897
  memo: {
2849
2898
  type,
2850
2899
  scope,
2851
- user: subjectIdSql(ctx)
2900
+ user: subjectIdSql(ctx),
2901
+ ...ctx.memo === void 0 ? {} : { api: ctx.memo }
2852
2902
  }
2853
2903
  };
2854
2904
  }
2905
+ function memoReadsSql(ctx) {
2906
+ const bodies = grantBodies(ctx);
2907
+ return [bodies.has.sql, ...ctx.scopes.map((scope) => bodies.ids(scope.name).sql)].join("\n");
2908
+ }
2855
2909
  function grantBodies(ctx) {
2856
2910
  const keys = ctx.apiKeys;
2857
2911
  const scoped = ctx.tokenScopes !== void 0;
@@ -2969,12 +3023,13 @@ function grantsSql(fn, args, anonExecute) {
2969
3023
  grant execute on function ${fn}(${args}) to anon, authenticated;` : `revoke execute on function ${fn}(${args}) from public, anon;
2970
3024
  grant execute on function ${fn}(${args}) to authenticated;`;
2971
3025
  }
2972
- function definer(fn, params, returns, sql) {
3026
+ function definerSql(fn, params, returns, sql, parallelSafe) {
2973
3027
  return `create or replace function ${fn}(${params})
2974
3028
  returns ${returns}
2975
3029
  language sql
2976
3030
  stable
2977
3031
  security definer
3032
+ cost 1000${parallelSafe ? "\nparallel safe" : ""}
2978
3033
  set search_path = ''
2979
3034
  as $$
2980
3035
  ${sql}
@@ -2983,10 +3038,10 @@ $$;`;
2983
3038
  function heldSql(at, effect) {
2984
3039
  return `select 1 from pdk_h where pdk_h.key = pdk_k.key and pdk_h.scope = ${quoteLiteral(at)} and pdk_h.effect = '${effect}'`;
2985
3040
  }
2986
- function keysFunction(fn, params, body, access) {
3041
+ function keysFunction(fn, params, body, access, parallelSafe) {
2987
3042
  return `create or replace function ${fn}(${params})
2988
3043
  returns setof text
2989
- ${functionBody(body).replace("set search_path = ''", "set search_path = ''\nset jit = off")}
3044
+ ${functionBody(body, parallelSafe).replace("set search_path = ''", "set search_path = ''\nset jit = off")}
2990
3045
  ${access}`;
2991
3046
  }
2992
3047
  /**
@@ -3004,6 +3059,8 @@ ${access}`;
3004
3059
  * as `permittedIds(..., { conditioned: true })` does in process.
3005
3060
  */
3006
3061
  function permissionHelpersSql(ctx, grants, renamed, anonExecute) {
3062
+ const parallel = !memoizes(ctx);
3063
+ const definer = (fn, params, returns, sql) => definerSql(fn, params, returns, sql, parallel);
3007
3064
  const keys = qualified(ctx, PERMISSION_HELPERS.grantKeys);
3008
3065
  const allowKeys = (scope) => `${keys}(p_permission, ${quoteLiteral(scope)}) g(grant_key)`;
3009
3066
  const denyKeys = (scope) => `${keys}(p_permission, ${quoteLiteral(scope)}, 'deny') g(grant_key)`;
@@ -3093,8 +3150,8 @@ ${grantsSql(fn, "text", anonExecute)}`);
3093
3150
  grantSet: true
3094
3151
  });
3095
3152
  chunks.push(`-- the permission keys the caller holds on one ${scope.name}: what permdock_has_permission or permitted_${scope.name}_ids_by_permission answers for each key, in one call
3096
- ${keysFunction(keysFn, `p_id ${type}`, keysBody(scope.name, caller, false), grantsSql(keysFn, type, anonExecute))}
3097
- ${keysFunction(keysFn, `p_id ${type}, p_keys text[]`, keysBody(scope.name, caller, true), grantsSql(keysFn, `${type}, text[]`, anonExecute))}`);
3153
+ ${keysFunction(keysFn, `p_id ${type}`, keysBody(scope.name, caller, false), grantsSql(keysFn, type, anonExecute), parallel)}
3154
+ ${keysFunction(keysFn, `p_id ${type}, p_keys text[]`, keysBody(scope.name, caller, true), grantsSql(keysFn, `${type}, text[]`, anonExecute), parallel)}`);
3098
3155
  chunks.push(`-- with p_conditioned true, also the instances a conditioned allow reaches, minus only unconditional denies: the caller applies the row condition
3099
3156
  ${definer(fn, "p_permission text, p_conditioned boolean", `setof ${scopeTypeOf(ctx, scope.name)}`, conditionedIds(qualified(ctx, permittedIdsHelper(scope.name)), scope.name, ""))}
3100
3157
  ${grantsSql(fn, "text, boolean", anonExecute)}`);
@@ -3118,8 +3175,8 @@ revoke execute on function ${fn}(${user}, text, boolean) from public, anon, auth
3118
3175
  ...forUserContext(ctx),
3119
3176
  grantSet: true
3120
3177
  });
3121
- chunks.push(`${keysFunction(keysFor, `p_user ${user}, p_id ${type}`, keysBody(scope.name, named, false), `revoke execute on function ${keysFor}(${user}, ${type}) from public, anon, authenticated;`)}
3122
- ${keysFunction(keysFor, `p_user ${user}, p_id ${type}, p_keys text[]`, keysBody(scope.name, named, true), `revoke execute on function ${keysFor}(${user}, ${type}, text[]) from public, anon, authenticated;`)}`);
3178
+ chunks.push(`${keysFunction(keysFor, `p_user ${user}, p_id ${type}`, keysBody(scope.name, named, false), `revoke execute on function ${keysFor}(${user}, ${type}) from public, anon, authenticated;`, parallel)}
3179
+ ${keysFunction(keysFor, `p_user ${user}, p_id ${type}, p_keys text[]`, keysBody(scope.name, named, true), `revoke execute on function ${keysFor}(${user}, ${type}, text[]) from public, anon, authenticated;`, parallel)}`);
3123
3180
  }
3124
3181
  return `${chunks.join("\n\n")}\n`;
3125
3182
  }
@@ -3593,6 +3650,7 @@ returns setof text
3593
3650
  language sql
3594
3651
  stable
3595
3652
  security definer
3653
+ cost 1000
3596
3654
  set search_path = ''
3597
3655
  as $$
3598
3656
  ${arms.join("\n union\n")}
@@ -3614,6 +3672,7 @@ returns setof text
3614
3672
  language sql
3615
3673
  stable
3616
3674
  security definer
3675
+ cost 1000
3617
3676
  set search_path = ''
3618
3677
  as $$
3619
3678
  select t.${quoteIdent(node.id)}::text from ${quoteQualified(tableFor(node.name, tables))} t
@@ -3778,6 +3837,7 @@ returns setof text
3778
3837
  language sql
3779
3838
  stable
3780
3839
  security definer
3840
+ cost 1000
3781
3841
  set search_path = ''
3782
3842
  as $$
3783
3843
  ${body}
@@ -3812,6 +3872,9 @@ function dependencyOrder(plan) {
3812
3872
  for (const name of [...plan.keys()].toSorted()) visit(name);
3813
3873
  return out;
3814
3874
  }
3875
+ function graphIdsSql(ctx, plan, tables) {
3876
+ return dependencyOrder(plan).filter((entry) => entry.relations.size > 0 || entry.closure !== void 0).map((entry) => permittedSql(ctx, plan, entry, tables)).join("\n");
3877
+ }
3815
3878
  /**
3816
3879
  * The graph preamble: `permitted_<resource>_ids` for every resource a graph
3817
3880
  * grant reads, and the closure table with its triggers for every self-parented
@@ -3847,20 +3910,39 @@ function graphSql(ctx, plan, tables) {
3847
3910
  * The `schema.table` an `rls.tables` entry names, or `resource` when it names
3848
3911
  * none or is `false`.
3849
3912
  */
3850
- function tableNameOf(entry, resource) {
3913
+ function tableNameOf(entry, resource, tables) {
3851
3914
  if (entry === void 0 || entry === false) return resource;
3852
- return typeof entry === "string" ? entry : entry.table ?? resource;
3915
+ if (typeof entry === "string") return entry;
3916
+ if ("tableOf" in entry) {
3917
+ const owner = tables?.[entry.tableOf];
3918
+ return typeof owner === "object" && "tableOf" in owner ? entry.tableOf : tableNameOf(owner, entry.tableOf);
3919
+ }
3920
+ return entry.table ?? resource;
3853
3921
  }
3854
3922
  /**
3855
3923
  * `rls.tables` as resource to table name, the `via` objects reduced to their
3856
3924
  * `table` and the `false` entries left out.
3857
3925
  */
3858
3926
  function tableNames(tables) {
3859
- return tables === void 0 ? void 0 : Object.fromEntries(Object.entries(tables).filter(([, entry]) => entry !== false).map(([resource, entry]) => [resource, tableNameOf(entry, resource)]));
3927
+ return tables === void 0 ? void 0 : Object.fromEntries(Object.entries(tables).filter(([, entry]) => entry !== false).map(([resource, entry]) => [resource, tableNameOf(entry, resource, tables)]));
3860
3928
  }
3861
- /** The resources `rls.tables` marks `false`: no table, so no policies. */
3929
+ /**
3930
+ * The resources `rls.tables` marks `false` or `{ tableOf }`: no policies of
3931
+ * their own, their grants only seeded.
3932
+ */
3862
3933
  function tablelessResources(tables) {
3863
- return new Set(Object.entries(tables ?? {}).filter(([, entry]) => entry === false).map(([resource]) => resource));
3934
+ return new Set(Object.entries(tables ?? {}).filter(([, entry]) => entry === false || typeof entry === "object" && "tableOf" in entry).map(([resource]) => resource));
3935
+ }
3936
+ /**
3937
+ * Rejects a `{ tableOf }` entry that names its own resource, a `false` entry or
3938
+ * another `{ tableOf }` entry: the owner must have a table of its own.
3939
+ */
3940
+ function checkSharedTables(tables) {
3941
+ for (const [resource, entry] of Object.entries(tables ?? {})) {
3942
+ if (typeof entry === "string" || entry === false || !("tableOf" in entry)) continue;
3943
+ const owner = tables?.[entry.tableOf];
3944
+ if (entry.tableOf === resource || owner === false || typeof owner === "object" && "tableOf" in owner) throw configError(`PermDock CLI: rls.tables.${resource}.tableOf names ${entry.tableOf}, which must be another resource with a table of its own`);
3945
+ }
3864
3946
  }
3865
3947
  function singular(name) {
3866
3948
  if (name.endsWith("ies")) return `${name.slice(0, -3)}y`;
@@ -3871,7 +3953,7 @@ function singular(name) {
3871
3953
  function resolveVias(tables, scopes, dialect) {
3872
3954
  const out = {};
3873
3955
  for (const [resource, entry] of Object.entries(tables ?? {})) {
3874
- if (typeof entry === "string" || entry === false) continue;
3956
+ if (typeof entry === "string" || entry === false || "tableOf" in entry) continue;
3875
3957
  const { via } = entry;
3876
3958
  const scope = via.scope ?? scopes[0]?.name;
3877
3959
  if (scope === void 0 || !scopes.some((item) => item.name === scope)) throw configError(`PermDock CLI: rls.tables.${resource}.via.scope '${scope ?? ""}' is not a scope of the policy (${scopes.map((item) => item.name).join(", ")})`);
@@ -3895,4 +3977,4 @@ function resolveVias(tables, scopes, dialect) {
3895
3977
  return Object.keys(out).length === 0 ? void 0 : out;
3896
3978
  }
3897
3979
  //#endregion
3898
- export { graphSqlText as $, claimKeptLines as A, hasCustomRoleChecksFor as B, accessSql as C, tokenScopeAllowsCall as D, TOKEN_SCOPE_ALLOWS as E, globalRoleRows as F, byKey as G, rolesTableScope as H, membershipRows as I, apiKeyFields as J, API_KEY_ALLOWS as K, roleRows as L, memberColumn as M, sourceFilters as N, tokenScopesPlan as O, sourcesKeep as P, graphSqlName as Q, globalRoleSource as R, requiresSql as S, seedSql as T, storedTenant as U, raiseSql as V, byCodeUnit as W, CLOSURE as X, apiKeysPlan as Y, graphHelper as Z, PERMISSION_HELPERS as _, activeMembershipSql as _t, closureDepths as a, memberForHelper as at, permissionKeysForHelper as b, checkSuspension as bt, holderSources as c, memberIdsHelper as ct, sourceRowsSql as d, permittedForHelper as dt, hasMemberFor as et, sourceTransferTriggerSql as f, permittedIdsHelper as ft, OWNERSHIP as g, activeInstancesSql as gt, ASSIGNMENTS as h, scopeTable as ht, tablelessResources as i, linkHelper as it, disabledColumn as j, capabilityAccessSql as k, pairsSql as l, memberOfHelper as lt, transferTriggerSql as m, scopeSources as mt, tableNameOf as n, inheritedRowsHelper as nt, graphPlan as o, memberForSources as ot, holdersTriggerSql as p, restrictedHelper as pt, apiKeyAllowsCall as q, tableNames as r, isTeamScope as rt, graphSql as s, memberForTable as st, resolveVias as t, hasPermittedUsers as tt, sourceHoldersTriggerSql as u, memberRoleOf as ut, checkName as v, activeRowSql as vt, helpersSql as w, permittedByPermissionHelper as x, permissionHelpersSql as y, activeUserSql as yt, currentKeyExpr as z };
3980
+ export { byKey as $, tokenScopeAllowsCall as A, memoizes as B, permittedByPermissionHelper as C, scopeTable as Ct, memoReadsSql as D, activeUserSql as Dt, helpersSql as E, activeRowSql as Et, disabledColumn as F, roleRows as G, sourcesKeep as H, memberColumn as I, hasCustomRoleChecksFor as J, globalRoleSource as K, memoDiscriminatorSql as L, memoReadTriggersSql as M, capabilityAccessSql as N, seedSql as O, checkSuspension as Ot, claimKeptLines as P, byCodeUnit as Q, memoReadSql as R, permissionKeysForHelper as S, scopeSources as St, accessSql as T, activeMembershipSql as Tt, globalRoleRows as U, sourceFilters as V, membershipRows as W, rolesTableScope as X, raiseSql as Y, storedTenant as Z, ASSIGNMENTS as _, memberOfHelper as _t, tablelessResources as a, graphHelper as at, checkName as b, permittedIdsHelper as bt, graphPlan as c, hasMemberFor as ct, pairsSql as d, isTeamScope as dt, API_KEY_ALLOWS as et, sourceHoldersTriggerSql as f, linkHelper as ft, transferTriggerSql as g, memberIdsHelper as gt, holdersTriggerSql as h, memberForTable as ht, tableNames as i, CLOSURE as it, tokenScopesPlan as j, TOKEN_SCOPE_ALLOWS as k, graphSql as l, hasPermittedUsers as lt, sourceTransferTriggerSql as m, memberForSources as mt, resolveVias as n, apiKeyFields as nt, closureDepths as o, graphSqlName as ot, sourceRowsSql as p, memberForHelper as pt, currentKeyExpr as q, tableNameOf as r, apiKeysPlan as rt, graphIdsSql as s, graphSqlText as st, checkSharedTables as t, apiKeyAllowsCall as tt, holderSources as u, inheritedRowsHelper as ut, OWNERSHIP as v, memberRoleOf as vt, requiresSql as w, activeInstancesSql as wt, permissionHelpersSql as x, restrictedHelper as xt, PERMISSION_HELPERS as y, permittedForHelper as yt, memoWriteSql as z };
@@ -1,9 +1,9 @@
1
- import { D as Policy, N as PolicyVocabulary, en as Snapshot, yr as Principal } from "../policy-types-BI9C5Sp5.js";
2
- import { u as Permission } from "../permission-types-CAY-GU7e.js";
3
- import { a as OperationInput, t as Operation } from "../operations-Ci_rT6Uo.js";
4
- import { a as PermDock } from "../permdock-D4F2p5J8.js";
5
- import { D as ConnectionOptions, T as Connection, f as InvalidSignatureError, i as OpenApiHooks, o as ProtectOptions, u as SnapshotQuery, v as discoverViaSignatureAgent, x as webBotAuthVerifier } from "../server-types-ChzXWU4Y.js";
6
- import { a as ProtectTarget, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-DCQ4pZxf.js";
1
+ import { D as Policy, N as PolicyVocabulary, en as Snapshot, yr as Principal } from "../policy-types-rNfz7t0M.js";
2
+ import { w as Permission } from "../vocabulary-DeZvUaTw.js";
3
+ import { a as OperationInput, t as Operation } from "../operations-BMPx7HyO.js";
4
+ import { a as PermDock } from "../permdock-BaB-KQqn.js";
5
+ import { D as ConnectionOptions, T as Connection, f as InvalidSignatureError, i as OpenApiHooks, o as ProtectOptions, u as SnapshotQuery, v as discoverViaSignatureAgent, x as webBotAuthVerifier } from "../server-types--_Hann81.js";
6
+ import { a as ProtectTarget, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-DxqsIXSO.js";
7
7
  import { RequestMiddleware, RequestMiddlewareAfterServer, createMiddleware } from "@tanstack/react-start";
8
8
  //#region src/tanstack-start/create.d.ts
9
9
  type TanStackStartPermDockOptions<TUser = unknown> = FetchAdapterOptions<Request, TUser>;
@@ -1,5 +1,5 @@
1
- import { l as InvalidSignatureError, p as webBotAuthVerifier, u as discoverViaSignatureAgent } from "../evaluations-CNMVJVD6.js";
2
- import { t as fetchAdapter } from "../fetch-adapter-acq4dPX3.js";
1
+ import { f as InvalidSignatureError, g as webBotAuthVerifier, p as discoverViaSignatureAgent } from "../evaluations-BzTDWO4m.js";
2
+ import { t as fetchAdapter } from "../fetch-adapter-MoYZ-vF5.js";
3
3
  import { createMiddleware } from "@tanstack/react-start";
4
4
  //#region src/tanstack-start/create.ts
5
5
  function createPermDock(policy, options) {
@@ -1,7 +1,7 @@
1
- import { o as sameId, t as expiredAt } from "./expiry-6XByK0dm.js";
2
1
  import { l as isFieldRelation } from "./resource-relations-8-pCScBO.js";
3
2
  import { o as epochSeconds } from "./time-nR1JesoH.js";
4
- import { c as rootScope, l as scopeChain, p as tenantOf, r as findScope, s as resolveScope, t as activeFor, u as scopeIdOf } from "./scopes-BSdYaGHs.js";
3
+ import { a as expiredAt, i as sameId } from "./ids-DzhJaCUj.js";
4
+ import { c as rootScope, l as scopeChain, p as tenantOf, r as findScope, s as resolveScope, t as activeFor, u as scopeIdOf } from "./scopes-gdH__vDZ.js";
5
5
  //#region src/core/tenancy.ts
6
6
  function nowSeconds(now) {
7
7
  return now ?? epochSeconds();
@@ -1,9 +1,9 @@
1
- import { D as Policy, N as PolicyVocabulary, Yn as Decision, qt as Instant, xr as Subject, yr as Principal } from "../policy-types-BI9C5Sp5.js";
2
- import { u as Permission } from "../permission-types-CAY-GU7e.js";
3
- import { a as PermDock } from "../permdock-D4F2p5J8.js";
4
- import { m as ApprovalStore } from "../types-BzxA2OAD.js";
5
- import { a as ProblemDetails, t as ApprovalHint } from "../errors-OTE9u4Wk.js";
6
- import { t as InstanceOptions } from "../instance-options-VPsNQsTH.js";
1
+ import { D as Policy, N as PolicyVocabulary, Yn as Decision, qt as Instant, xr as Subject, yr as Principal } from "../policy-types-rNfz7t0M.js";
2
+ import { w as Permission } from "../vocabulary-DeZvUaTw.js";
3
+ import { a as PermDock } from "../permdock-BaB-KQqn.js";
4
+ import { m as ApprovalStore } from "../types-ZfjQB0KC.js";
5
+ import { a as ProblemDetails, t as ApprovalHint } from "../errors-D_JIQJYb.js";
6
+ import { t as InstanceOptions } from "../instance-options-C6gEDOts.js";
7
7
  //#region src/terminal/types.d.ts
8
8
  type TokenSourceName = "device" | "keychain" | "env" | "ci-oidc";
9
9
  type TokenSource = TokenSourceName | {
@@ -1,14 +1,14 @@
1
1
  import { t as compact } from "../compact-CAf557ZB.js";
2
2
  import { a as deniedMessage, i as approvalMessage, n as PermDockDeniedError, t as PermDockApprovalRequiredError } from "../errors-ynga1EQy.js";
3
3
  import { h as secondsAt } from "../time-nR1JesoH.js";
4
- import { r as isSubject } from "../subject-C7RddW0G.js";
5
4
  import { n as resourceRef } from "../resource-ref-CaS9yVPi.js";
6
- import { l as withApp } from "../permdock-C1DN_7a-.js";
7
- import { n as readBodyText } from "../body-text-DQhcmqdY.js";
8
- import { l as storedApprovalToken, s as resumeDecision } from "../helpers-D-MXwkOF.js";
5
+ import { r as isSubject } from "../subject-C7RddW0G.js";
6
+ import { r as withApp } from "../app-DIvM65Mv.js";
7
+ import { n as resolveOrNull, t as buildInstance } from "../build-instance-B0vsViF5.js";
9
8
  import { t as timeoutSignal } from "../timeout-D51niuQP.js";
10
- import { n as resolveOrNull, t as buildInstance } from "../build-instance-DaBdCRiz.js";
11
- import { a as refreshCredential, o as revokeCredential, s as runDeviceFlow, t as TERMINAL_TIMEOUT_MS } from "../device-BwbJNmb2.js";
9
+ import { l as storedApprovalToken, s as resumeDecision } from "../helpers-DzBIfL1N.js";
10
+ import { n as readBodyText } from "../body-text-DQhcmqdY.js";
11
+ import { a as refreshCredential, o as revokeCredential, s as runDeviceFlow, t as TERMINAL_TIMEOUT_MS } from "../device-BkSynWdg.js";
12
12
  import { i as writeCredentials, n as deleteCredentials, r as readCredentials } from "../storage-C2bWdvJH.js";
13
13
  import { createInterface } from "node:readline";
14
14
  //#region src/terminal/exit.ts
@@ -1,2 +1,2 @@
1
- import { S as policyMatrix, _ as DescribePolicyConfig, a as OrmParityScenario, b as PolicyMatrixCell, c as RlsFieldsOutcome, d as RlsParityOptions, f as RlsParityReport, g as testRlsParity, h as RlsQueryResult, i as OrmParityRunInput, l as RlsParityCase, m as RlsQueryFn, n as OrmParityOptions, o as testOrmParity, p as RlsParitySubject, r as OrmParityReport, s as RlsDbOutcome, t as OrmParityCase, u as RlsParityFixture, v as MatrixCell, x as PolicyMatrixReport, y as MatrixOutcome } from "../core-BOeGWbcR.js";
1
+ import { S as policyMatrix, _ as DescribePolicyConfig, a as OrmParityScenario, b as PolicyMatrixCell, c as RlsFieldsOutcome, d as RlsParityOptions, f as RlsParityReport, g as testRlsParity, h as RlsQueryResult, i as OrmParityRunInput, l as RlsParityCase, m as RlsQueryFn, n as OrmParityOptions, o as testOrmParity, p as RlsParitySubject, r as OrmParityReport, s as RlsDbOutcome, t as OrmParityCase, u as RlsParityFixture, v as MatrixCell, x as PolicyMatrixReport, y as MatrixOutcome } from "../core-D2JNg5jA.js";
2
2
  export { type DescribePolicyConfig, type MatrixCell, type MatrixOutcome, type OrmParityCase, type OrmParityOptions, type OrmParityReport, type OrmParityRunInput, type OrmParityScenario, type PolicyMatrixCell, type PolicyMatrixReport, type RlsDbOutcome, type RlsFieldsOutcome, type RlsParityCase, type RlsParityFixture, type RlsParityOptions, type RlsParityReport, type RlsParitySubject, type RlsQueryFn, type RlsQueryResult, policyMatrix, testOrmParity, testRlsParity };
@@ -1 +1 @@
1
- export { r as policyMatrix, t as testOrmParity, n as testRlsParity } from "../core-BwVkrpsi.js";
1
+ export { r as policyMatrix, t as testOrmParity, n as testRlsParity } from "../core-CUjhfz0W.js";
@@ -1,5 +1,37 @@
1
- import { a as CatalogDocument } from "../../types-7Vlz1Wi2.js";
1
+ import { rt as MemberEntry } from "../../policy-types-rNfz7t0M.js";
2
+ import { r as SubjectRecord } from "../../subject-cache-d_Z4KAnm.js";
3
+ import { i as SupabaseRpcClient } from "../../postgrest-Cn0Res25.js";
4
+ import { a as CatalogDocument } from "../../types-DAyp592k.js";
2
5
  import { i as SupabaseManifest } from "../../manifest-B5yF3CIq.js";
6
+ //#region src/testing/fixtures/postgrest.d.ts
7
+ type PostgrestFixtureOptions = {
8
+ /** The users `subject_for` knows, by id. An unknown user answers `null`. */
9
+ readonly subjects: Readonly<Record<string, SubjectRecord>>;
10
+ /**
11
+ * `authz_version_for` by id. A user missing here answers the `authzVersion`
12
+ * of its record.
13
+ */
14
+ readonly versions?: Readonly<Record<string, number>>;
15
+ /** What `members_of` returns for the entries whose scope and id match. */
16
+ readonly members?: readonly MemberEntry[];
17
+ };
18
+ type PostgrestFixtureCall = {
19
+ readonly schema: string;
20
+ readonly fn: string;
21
+ readonly args: Readonly<Record<string, unknown>>;
22
+ };
23
+ type PostgrestFixture = SupabaseRpcClient & {
24
+ /** Every RPC the code under test made, in order. */
25
+ readonly calls: readonly PostgrestFixtureCall[];
26
+ };
27
+ /**
28
+ * A Supabase client double that answers the three functions `postgrestSources`
29
+ * calls, `subject_for`, `authz_version_for` and `members_of`, under any schema
30
+ * and any wrapper prefix (`permdock_subject_for` answers as `subject_for`). Any
31
+ * other function answers an error.
32
+ */
33
+ export declare function postgrestFixture(options: PostgrestFixtureOptions): PostgrestFixture;
34
+ //#endregion
3
35
  //#region src/testing/fixtures/index.d.ts
4
36
  /**
5
37
  * The `permissions.catalog.json` of `apps/examples/next-better-supabase`, a
@@ -12,4 +44,5 @@ export declare const betterSupabaseCatalog: CatalogDocument;
12
44
  * document.
13
45
  */
14
46
  export declare const betterSupabaseManifest: SupabaseManifest;
15
- //#endregion
47
+ //#endregion
48
+ export type { PostgrestFixture, PostgrestFixtureCall, PostgrestFixtureOptions };
@@ -1,5 +1,5 @@
1
1
  import { n as parseSupabaseManifest } from "../../manifest-BdzBobNK.js";
2
- import { t as parseCatalog } from "../../parse-CXTT7hBq.js";
2
+ import { t as parseCatalog } from "../../parse-CORUNcCo.js";
3
3
  //#region src/testing/fixtures/better-supabase.catalog.json
4
4
  var better_supabase_catalog_default = {
5
5
  $schema: "https://permdock.com/schemas/catalog-v1.json",
@@ -813,6 +813,43 @@ var better_supabase_manifest_default = {
813
813
  }
814
814
  };
815
815
  //#endregion
816
+ //#region src/testing/fixtures/postgrest.ts
817
+ const answer = (data) => ({
818
+ data,
819
+ error: null
820
+ });
821
+ /**
822
+ * A Supabase client double that answers the three functions `postgrestSources`
823
+ * calls, `subject_for`, `authz_version_for` and `members_of`, under any schema
824
+ * and any wrapper prefix (`permdock_subject_for` answers as `subject_for`). Any
825
+ * other function answers an error.
826
+ */
827
+ function postgrestFixture(options) {
828
+ const calls = [];
829
+ const read = (fn, args) => {
830
+ const user = String(args["p_user"]);
831
+ const record = options.subjects[user];
832
+ if (fn.endsWith("authz_version_for")) return answer(options.versions?.[user] ?? record?.authzVersion ?? null);
833
+ if (fn.endsWith("subject_for")) return answer(record ?? null);
834
+ if (fn.endsWith("members_of")) return answer((options.members ?? []).filter(({ membership }) => membership.scope === args["p_scope"] && membership.id === args["p_id"]));
835
+ return {
836
+ data: null,
837
+ error: { message: `unknown function ${fn}` }
838
+ };
839
+ };
840
+ return {
841
+ calls,
842
+ schema: (schema) => ({ rpc: async (fn, args) => {
843
+ calls.push({
844
+ schema,
845
+ fn,
846
+ args
847
+ });
848
+ return read(fn, args);
849
+ } })
850
+ };
851
+ }
852
+ //#endregion
816
853
  //#region src/testing/fixtures/index.ts
817
854
  /**
818
855
  * The `permissions.catalog.json` of `apps/examples/next-better-supabase`, a
@@ -826,4 +863,4 @@ const betterSupabaseCatalog = parseCatalog(better_supabase_catalog_default);
826
863
  */
827
864
  const betterSupabaseManifest = parseSupabaseManifest(better_supabase_manifest_default);
828
865
  //#endregion
829
- export { betterSupabaseCatalog, betterSupabaseManifest };
866
+ export { betterSupabaseCatalog, betterSupabaseManifest, postgrestFixture };