permdock 0.8.0 → 0.9.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 (258) hide show
  1. package/dist/a2a/index.d.ts +4 -4
  2. package/dist/a2a/index.js +3 -3
  3. package/dist/{action-result-CL-QCITA.d.ts → action-result-BcudBQOF.d.ts} +1 -1
  4. package/dist/{adoption-scan-BLs67P1l.js → adoption-scan-Ch07MdxN.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 +3 -3
  8. package/dist/ai-sdk/index.js +3 -3
  9. package/dist/{approval-prompt-PYagyQUj.d.ts → approval-prompt-3BqWczTt.d.ts} +1 -1
  10. package/dist/approvals/index.d.ts +3 -3
  11. package/dist/{arazzo-3RhGfkAK.js → arazzo-BpS7LnV0.js} +1 -1
  12. package/dist/{arazzo-B5-ulWif.js → arazzo-CmQaGPkM.js} +2 -2
  13. package/dist/astro/index.d.ts +4 -4
  14. package/dist/astro/index.js +1 -1
  15. package/dist/{audience-BAkBDMqn.js → audience-DTjR8xet.js} +1 -1
  16. package/dist/authzen/index.d.ts +5 -5
  17. package/dist/authzen/index.js +1 -1
  18. package/dist/{automation-DqEoWHBc.d.ts → automation-C6Jg75xq.d.ts} +1 -1
  19. package/dist/better-auth/index.d.ts +1 -1
  20. package/dist/better-supabase/index.d.ts +6 -6
  21. package/dist/better-supabase/index.js +3 -3
  22. package/dist/{bind-D_sZSVA3.js → bind-BNQA9JK9.js} +7 -3
  23. package/dist/{bind-Cp2hBHzP.d.ts → bind-YYjvfpB9.d.ts} +12 -7
  24. package/dist/{build-instance-CNWaYJyr.js → build-instance-BWXqwQYU.js} +1 -1
  25. package/dist/{capability-ChuiONQU.d.ts → capability-Di9tiUvi.d.ts} +1 -1
  26. package/dist/{casbin-cbSbhT_k.js → casbin-B7_yS-oo.js} +1 -1
  27. package/dist/{casbin-H0rKxBx2.js → casbin-bHyIxTNQ.js} +1 -1
  28. package/dist/catalog/index.d.ts +4 -4
  29. package/dist/catalog/index.js +2 -2
  30. package/dist/{catalog-BFpz2EmT.js → catalog-CGlSwU6j.js} +2 -2
  31. package/dist/catalog-D3oS2GH3.js +1 -0
  32. package/dist/{catalog-DCspHDc8.js → catalog-amPDr0JQ.js} +1 -1
  33. package/dist/{catalog-operations-Dadrl7Z-.js → catalog-operations-DeHTrJSV.js} +1 -1
  34. package/dist/chat/index.d.ts +1 -1
  35. package/dist/chat/index.js +1 -1
  36. package/dist/chat-sdk/index.d.ts +3 -3
  37. package/dist/claude-agent/index.d.ts +3 -3
  38. package/dist/claude-agent/index.js +2 -2
  39. package/dist/clerk/index.d.ts +2 -2
  40. package/dist/cli/bin.js +1 -1
  41. package/dist/cli/index.d.ts +4 -4
  42. package/dist/cli/index.js +2 -2
  43. package/dist/cloud/index.d.ts +8 -8
  44. package/dist/{cloud-BFlGMaak.js → cloud-3kWfjnYy.js} +2 -2
  45. package/dist/{codemod-DWSN2erG.js → codemod-Bv5i-Mzo.js} +1 -1
  46. package/dist/{codemod-DLQ9Zpo4.js → codemod-D9Aiii1r.js} +2 -2
  47. package/dist/{collect-Bzv3le0A.js → collect-B80GYEot.js} +2 -2
  48. package/dist/collect-D-eroIfV.js +1 -0
  49. package/dist/{collect-B7ZFAJU3.js → collect-WCl8cJQV.js} +1 -1
  50. package/dist/compile/index.d.ts +1 -1
  51. package/dist/{compile-BFzysW3o.d.ts → compile-BEklRUYo.d.ts} +2 -2
  52. package/dist/{completion-saoYiRFO.js → completion-_bc0OUQ-.js} +1 -1
  53. package/dist/{config-DBeXXmBF.js → config-D5XrLWpk.js} +1 -1
  54. package/dist/{config-report-BipSWA6V.js → config-report-BmWIskD7.js} +2 -2
  55. package/dist/convex/index.d.ts +4 -4
  56. package/dist/convex/index.js +2 -2
  57. package/dist/{core-hWIARPDz.d.ts → core-CFepFiDP.d.ts} +2 -2
  58. package/dist/{core-H-mbhpZc.js → core-DzVINFbU.js} +3 -3
  59. package/dist/{create-Cq4Uox0f.js → create-6EwRQlig.js} +3 -3
  60. package/dist/{create-_noSrY1T.js → create-BLPKnJKa.js} +23 -7
  61. package/dist/{create-BSNrVuxh.d.ts → create-BPUopdfL.d.ts} +7 -7
  62. package/dist/{create-CM1FciYG.d.ts → create-BamXmeob.d.ts} +6 -6
  63. package/dist/{create-BVq1lNQE.d.ts → create-DBvUsgzK.d.ts} +4 -4
  64. package/dist/delivery/index.d.ts +4 -4
  65. package/dist/delivery/index.js +1 -1
  66. package/dist/{denied-text-CHNlVInN.d.ts → denied-text-DHldhVUv.d.ts} +1 -1
  67. package/dist/{describe-ByS9LgHK.d.ts → describe-BbFPBSms.d.ts} +1 -1
  68. package/dist/{diff-CN8IYhC_.js → diff-BwR1JdP2.js} +1 -1
  69. package/dist/{diff-iZWV65nC.js → diff-CQegtBAo.js} +2 -2
  70. package/dist/{doctor-CHD1M9R5.js → doctor-ClRVAtXQ.js} +13 -13
  71. package/dist/{doctor-D3wo-yuz.js → doctor-LPMYjSqO.js} +2 -2
  72. package/dist/drizzle/index.d.ts +3 -3
  73. package/dist/elysia/index.d.ts +4 -4
  74. package/dist/elysia/index.js +1 -1
  75. package/dist/{errors-zi_4T-rx.d.ts → errors-BIM4MFsJ.d.ts} +1 -1
  76. package/dist/{evaluate-Dd8Ta0Ie.js → evaluate-BAmf_AQd.js} +13 -4
  77. package/dist/{evaluations-z8dQFDaN.d.ts → evaluations-DOWuBpWv.d.ts} +3 -3
  78. package/dist/eve/index.d.ts +4 -4
  79. package/dist/eve/index.js +2 -2
  80. package/dist/express/index.d.ts +4 -4
  81. package/dist/express/index.js +1 -1
  82. package/dist/fastify/index.d.ts +4 -4
  83. package/dist/fastify/index.js +1 -1
  84. package/dist/{fetch-adapter-C1DCvpqV.d.ts → fetch-adapter-BIbBAtPZ.d.ts} +2 -2
  85. package/dist/{fetch-adapter-JL43jD3E.js → fetch-adapter-dPTgJVHd.js} +1 -1
  86. package/dist/{gen-B5kvbAoZ.js → gen-BFfzZSLH.js} +1 -1
  87. package/dist/{gen-DWCYcMQM.js → gen-BtfFWGbz.js} +2 -2
  88. package/dist/h3/index.d.ts +4 -4
  89. package/dist/h3/index.js +2 -2
  90. package/dist/hono/index.d.ts +4 -4
  91. package/dist/hono/index.js +1 -1
  92. package/dist/{hosted-Cmtxogd0.d.ts → hosted-DVxlLZMe.d.ts} +1 -1
  93. package/dist/{import-_YqhhwvX.js → import-ACkOrv6g.js} +1 -1
  94. package/dist/{index-BhxEUY9J.d.ts → index-BinlXeU-.d.ts} +2 -2
  95. package/dist/{index-B8s204GL.d.ts → index-CV-7DWeD.d.ts} +4 -4
  96. package/dist/{index-_9UiQIkt.d.ts → index-DJwEgYzA.d.ts} +4 -4
  97. package/dist/{index-BT5-1VsX.d.ts → index-Dj2qF9VC.d.ts} +1 -1
  98. package/dist/{index-BW_0MZOS.d.ts → index-vYjMrXyK.d.ts} +62 -9
  99. package/dist/{index-Bv5iXPqU.d.ts → index-ymept53A.d.ts} +4 -4
  100. package/dist/index.d.ts +15 -15
  101. package/dist/index.js +6 -6
  102. package/dist/{init-cE3A8aXq.js → init-BjuFDYT1.js} +1 -1
  103. package/dist/{init-Dz_PsHdv.js → init-txYTuW9u.js} +3 -3
  104. package/dist/{instance-options-B0KXqTrJ.d.ts → instance-options-CoHn-0e8.d.ts} +1 -1
  105. package/dist/{instance-snapshot--JWiTrvO.js → instance-snapshot-DuWf1cT3.js} +13 -8
  106. package/dist/jwt/index.d.ts +4 -4
  107. package/dist/jwt/index.js +1 -1
  108. package/dist/{kernel-C-fYydV2.js → kernel-qv4cr9w8.js} +4 -4
  109. package/dist/kysely/index.d.ts +3 -3
  110. package/dist/{login-D-8tMqzo.js → login-CfImTJGb.js} +3 -3
  111. package/dist/{login-DplQ0s84.js → login-CgfCTO3F.js} +1 -1
  112. package/dist/{manifest-Cgiq5oqc.js → manifest-B2QPh19C.js} +35 -35
  113. package/dist/{map-claims-BNWCJtmP.js → map-claims-C-nv08_n.js} +2 -1
  114. package/dist/mcp/index.d.ts +8 -8
  115. package/dist/mcp/index.js +4 -4
  116. package/dist/nest/index.d.ts +4 -4
  117. package/dist/nest/index.js +1 -1
  118. package/dist/next/index.d.ts +16 -9
  119. package/dist/next/index.js +14 -7
  120. package/dist/next/plugin.d.ts +1 -1
  121. package/dist/next/plugin.js +1 -1
  122. package/dist/node/index.d.ts +4 -4
  123. package/dist/node/index.js +1 -1
  124. package/dist/openai/index.d.ts +4 -4
  125. package/dist/openai/index.js +3 -3
  126. package/dist/openapi/index.d.ts +2 -2
  127. package/dist/{openapi-VeHHU2l9.js → openapi-BGeuunWC.js} +1 -1
  128. package/dist/{openapi-CBZUhA3l.js → openapi-BIpw3Mb7.js} +2 -2
  129. package/dist/orpc/index.d.ts +5 -5
  130. package/dist/orpc/index.js +2 -2
  131. package/dist/otel/index.d.ts +3 -3
  132. package/dist/{output-tkju6U7R.js → output-DV5dwOTs.js} +1 -1
  133. package/dist/{ownership-B4L59T9u.js → ownership-DA5YdYTm.js} +9 -4
  134. package/dist/{parse-local-manifest-BQhTlLQS.d.ts → parse-local-manifest-CCmbhnxP.d.ts} +1 -1
  135. package/dist/pdp/index.d.ts +3 -3
  136. package/dist/pdp/index.js +1 -1
  137. package/dist/{permdock-L-_I_3zP.js → permdock-BvjivVb9.js} +143 -107
  138. package/dist/{permdock-B6Sf4T_S.d.ts → permdock-CprAPN3w.d.ts} +9 -2
  139. package/dist/{permissions-mDcTWoBs.js → permissions-CYcHj_w7.js} +1 -1
  140. package/dist/{policy-Ba4bDhaj.d.ts → policy-BycVKnXv.d.ts} +1 -1
  141. package/dist/{policy-from-catalog-CJgOm6aq.js → policy-from-catalog-CU3An8uP.js} +1 -1
  142. package/dist/{policy-types-CCiDRZBH.d.ts → policy-types-DGIO_gxq.d.ts} +54 -18
  143. package/dist/{postgrest-D4nuPXIQ.js → postgrest-5Dr3W64L.js} +34 -55
  144. package/dist/{postgrest-DicQyqm-.d.ts → postgrest-D5nUGm-c.d.ts} +4 -3
  145. package/dist/powersync-B701tvhE.js +1 -0
  146. package/dist/{powersync-DXqGuq9A.js → powersync-Bg8u-JcR.js} +2 -2
  147. package/dist/{powersync-DHNQX06W.js → powersync-CJrT1DSc.js} +5 -5
  148. package/dist/prisma/index.d.ts +2 -2
  149. package/dist/{protected-action-BE7N_Luo.d.ts → protected-action-D8x73IGm.d.ts} +6 -6
  150. package/dist/{provider-DXfq5c2d.d.ts → provider-DfLeek9O.d.ts} +1 -1
  151. package/dist/{pull-CwpGaQSi.js → pull-2nJr0qg_.js} +1 -1
  152. package/dist/pull-C3EEGzSw.js +1 -0
  153. package/dist/{push-DgssgzkK.js → push-Bn-lMEmI.js} +2 -2
  154. package/dist/{pushed-policy-ITwYKvvH.js → pushed-policy-CDuOL2de.js} +1 -1
  155. package/dist/{pushed-policy-D1Eoi6NM.d.ts → pushed-policy-CryQheKq.d.ts} +1 -1
  156. package/dist/react/index.d.ts +7 -7
  157. package/dist/react/provider-client.d.ts +1 -1
  158. package/dist/react-native/index.d.ts +9 -9
  159. package/dist/{replay-DNftIb_R.d.ts → replay-Bs9Df2fQ.d.ts} +1 -1
  160. package/dist/{request-context-C25ilqiJ.js → request-context-Duzdf0cd.js} +1 -1
  161. package/dist/resend/index.d.ts +4 -4
  162. package/dist/{resolve-names-CF7xXLSG.js → resolve-names-ConCSj1y.js} +1 -1
  163. package/dist/{rls-Ca8Jz9b5.js → rls-Ba9wN0SP.js} +1 -1
  164. package/dist/{rls-CNEH2_BG.js → rls-Cx0dtsB7.js} +20 -13
  165. package/dist/{rpc-fNqAIqQk.js → rpc-vHIwyXCp.js} +1 -1
  166. package/dist/run-Ck22anC2.js +1 -0
  167. package/dist/{run-Bz26OTfO.js → run-PbRlXTfh.js} +2 -2
  168. package/dist/{run-ticket-DbWI9f99.d.ts → run-ticket-B2o2Kxz8.d.ts} +2 -2
  169. package/dist/{saas-iWnUdwCt.js → saas-DK4V-3Is.js} +2 -2
  170. package/dist/{scan-DCj1KQfn.js → scan-CRTj6fke.js} +1 -1
  171. package/dist/{schema-Dst9I9Gs.js → schema-BTsE1WRT.js} +1 -1
  172. package/dist/scim/index.d.ts +1 -1
  173. package/dist/server/index.d.ts +10 -10
  174. package/dist/server/index.js +1 -1
  175. package/dist/{server-types-CIlpSA2G.d.ts → server-types-CyRN0-Cd.d.ts} +15 -8
  176. package/dist/{sink-Dvi7YZG_.d.ts → sink-B5zoUW_O.d.ts} +2 -2
  177. package/dist/{skills-OuoMR49L.js → skills-C9uKfSF5.js} +1 -1
  178. package/dist/{skills-Bjj7BNEQ.js → skills-CQQcuGBi.js} +1 -1
  179. package/dist/{snapshot-cache-BAXZ0KOp.d.ts → snapshot-cache-BjAWkchD.d.ts} +1 -1
  180. package/dist/solid/index.d.ts +6 -6
  181. package/dist/solid-start/index.d.ts +4 -4
  182. package/dist/solid-start/index.js +2 -2
  183. package/dist/{sources-B1Os_YUu.d.ts → sources-CWG32C0G.d.ts} +2 -2
  184. package/dist/{src-DZ0l9UAg.js → src-C_pi2Rnh.js} +106 -5
  185. package/dist/ssf/index.d.ts +3 -3
  186. package/dist/{standard-webhooks-C-qX4mJW.d.ts → standard-webhooks-DOYEuOLx.d.ts} +2 -2
  187. package/dist/{stores-C0Kta5Ft.d.ts → stores-DZJvxFIZ.d.ts} +6 -6
  188. package/dist/{stream-ltuLdtTG.d.ts → stream-9y9qw51m.d.ts} +1 -1
  189. package/dist/supabase/index.d.ts +5 -5
  190. package/dist/supabase/index.js +2 -2
  191. package/dist/supabase/middleware.d.ts +5 -5
  192. package/dist/supabase/middleware.js +4 -4
  193. package/dist/{supabase-BL1qJzzY.js → supabase-DnMMg5Fn.js} +1 -1
  194. package/dist/{supabase-D39cuGPt.js → supabase-SBs3MYUE.js} +2 -2
  195. package/dist/supabase-hook-C0FyEACZ.js +1 -0
  196. package/dist/{supabase-hook-B-yXnzUl.js → supabase-hook-CrgU06WH.js} +5 -5
  197. package/dist/{supautils-BU-pAEpf.js → supautils-ByezN3b8.js} +244 -197
  198. package/dist/svelte/index.d.ts +6 -6
  199. package/dist/svelte/runtime.d.ts +3 -3
  200. package/dist/svelte/source.d.ts +6 -6
  201. package/dist/sveltekit/index.d.ts +4 -4
  202. package/dist/sveltekit/index.js +1 -1
  203. package/dist/{tables-DeMNEy6V.js → tables-BqrxBCir.js} +1 -1
  204. package/dist/tanstack-start/index.d.ts +4 -4
  205. package/dist/tanstack-start/index.js +1 -1
  206. package/dist/terminal/index.d.ts +5 -5
  207. package/dist/terminal/index.js +2 -2
  208. package/dist/testing/core.d.ts +1 -1
  209. package/dist/testing/core.js +1 -1
  210. package/dist/testing/index.d.ts +21 -20
  211. package/dist/testing/index.js +61 -8
  212. package/dist/testing/saas/index.d.ts +3 -3
  213. package/dist/testing/saas/index.js +2 -2
  214. package/dist/testing/saas/permissions.js +1 -1
  215. package/dist/trpc/index.d.ts +5 -5
  216. package/dist/trpc/index.js +2 -2
  217. package/dist/{type-helpers-BIPIDa6a.d.ts → type-helpers-c7Xo_2Cu.d.ts} +1 -1
  218. package/dist/{types-B2mlGuhW.d.ts → types-B2efzoSX.d.ts} +1 -1
  219. package/dist/{types-DHKPcqzr.d.ts → types-B6ExllNo.d.ts} +2 -2
  220. package/dist/{types-AMJ5qoU_.d.ts → types-BB-zWDcR.d.ts} +4 -4
  221. package/dist/{types-ah9NlU6j.d.ts → types-BMVDHvI0.d.ts} +1 -1
  222. package/dist/{types-djVzLlIV.d.ts → types-CEinc15V.d.ts} +4 -4
  223. package/dist/{types-yUuPR5Hy.d.ts → types-CN0LsqbK.d.ts} +3 -3
  224. package/dist/{types-HzqOtvsJ.d.ts → types-CWBsAwqn.d.ts} +4 -4
  225. package/dist/{types-DC1Loeh3.d.ts → types-CzOeVvcC.d.ts} +5 -3
  226. package/dist/{types-B_tiYvk8.d.ts → types-DLvhVm1r.d.ts} +1 -1
  227. package/dist/{types-B4uqKDnp.d.ts → types-DlelvQk4.d.ts} +2 -2
  228. package/dist/{types-DjuMBNF9.d.ts → types-DsHGPtkR.d.ts} +2 -2
  229. package/dist/{types-BJk0BKRX.d.ts → types-rCRV4Ge-.d.ts} +4 -4
  230. package/dist/{types-B_d_g7T3.d.ts → types-tQB2CEnY.d.ts} +4 -4
  231. package/dist/unplugin/index.d.ts +1 -1
  232. package/dist/unplugin/index.js +1 -1
  233. package/dist/usage-0hjZPIRX.js +1 -0
  234. package/dist/{usage-CxEzS4ey.js → usage-B9EtHWLa.js} +3 -3
  235. package/dist/{usage-ab0PdusX.js → usage-CBzgwfIs.js} +1 -1
  236. package/dist/{validation-error-YGg2mXyH.d.ts → validation-error-uvp-kyfO.d.ts} +1 -1
  237. package/dist/{verify-DZeqoWu5.js → verify-DlUcTDBz.js} +6 -6
  238. package/dist/vue/index.d.ts +6 -6
  239. package/dist/{waiter-Bu9zAlE0.d.ts → waiter-CqUKX6CY.d.ts} +2 -2
  240. package/dist/{watch-Cx_WciLE.js → watch-BFDKqmUa.js} +1 -1
  241. package/dist/watch-ClLuO2TL.js +1 -0
  242. package/dist/webmcp/index.d.ts +1 -1
  243. package/dist/{who-can-rI7dCR9Q.js → who-can-BoDJm0Nc.js} +1 -1
  244. package/dist/workflow/index.d.ts +3 -3
  245. package/dist/workflow/index.js +1 -1
  246. package/dist/workflow-sdk/index.d.ts +4 -4
  247. package/dist/{wrap-DlJE3gS_.d.ts → wrap-DxXB54Wu.d.ts} +2 -2
  248. package/package.json +2 -2
  249. package/skills/permdock-data/references/queries-and-rls.md +1 -1
  250. package/skills/permdock-wire/references/adapters.md +2 -1
  251. package/dist/catalog-mRQQQhNK.js +0 -1
  252. package/dist/collect-B5BL3klN.js +0 -1
  253. package/dist/powersync-Djf-zCpB.js +0 -1
  254. package/dist/pull-B65ndFNZ.js +0 -1
  255. package/dist/run-D-JE8QWb.js +0 -1
  256. package/dist/supabase-hook-H-MtE9Wd.js +0 -1
  257. package/dist/usage-CYeXek0p.js +0 -1
  258. package/dist/watch-DB42U1ib.js +0 -1
@@ -8,7 +8,7 @@ import { t as loadJose } from "./load-jose-DZ4dnjri.js";
8
8
  import { a as quoteQualifiedTable, c as quoteSqlTable, d as sqlTextArray, i as qualifySqlTable, o as quoteSqlIdent, s as quoteSqlLiteral } from "./sql-0WjxIp9g.js";
9
9
  import "./budget-BELja5A9.js";
10
10
  import { d as keptKeys, l as roleColumn } from "./sources-CMAM-2A3.js";
11
- import { t as callRpc } from "./postgrest-D4nuPXIQ.js";
11
+ import { t as callRpc } from "./postgrest-5Dr3W64L.js";
12
12
  //#region src/supabase/capability.ts
13
13
  const DEFAULT_TTL = 300;
14
14
  const MAX_TTL = 3600;
@@ -47,7 +47,7 @@ const hookGenerate = defineLeaf({
47
47
  const budget = given(flags.budget);
48
48
  const schema = given(flags.schema);
49
49
  const grantsOut = given(flags["grants-out"]);
50
- const { runSupabase } = await import("./supabase-hook-H-MtE9Wd.js");
50
+ const { runSupabase } = await import("./supabase-hook-C0FyEACZ.js");
51
51
  return runSupabase({
52
52
  cwd: ctx.cwd,
53
53
  config: ctx.config,
@@ -76,7 +76,7 @@ const inspect = defineLeaf({
76
76
  },
77
77
  async run(ctx, { flags }) {
78
78
  const out = flags.out === "" ? true : flags.out === "-" ? void 0 : flags.out;
79
- const { runSupabase } = await import("./supabase-hook-H-MtE9Wd.js");
79
+ const { runSupabase } = await import("./supabase-hook-C0FyEACZ.js");
80
80
  return runSupabase({
81
81
  cwd: ctx.cwd,
82
82
  config: ctx.config,
@@ -0,0 +1 @@
1
+ export { i as runSupabase } from "./supabase-hook-CrgU06WH.js";
@@ -8,22 +8,22 @@ import { a as SUPABASE_MANIFEST_SCHEMA } from "./version-DMQ0dnN5.js";
8
8
  import { c as requirePolicy } from "./load-DjSU5KXO.js";
9
9
  import { i as qualifySqlTable } from "./sql-0WjxIp9g.js";
10
10
  import { i as scopeColumn } from "./compile-EzEMB-7v.js";
11
- import { t as authorizeSql } from "./supabase-BL1qJzzY.js";
11
+ import { t as authorizeSql } from "./supabase-DnMMg5Fn.js";
12
12
  import "./budget-BELja5A9.js";
13
13
  import { a as hookApiNames, d as keptKeys, t as AUTHZ_VERSION_TABLE, u as roleManifest } from "./sources-CMAM-2A3.js";
14
- import { o as readMemberships } from "./postgrest-D4nuPXIQ.js";
14
+ import { o as readMemberships } from "./postgrest-5Dr3W64L.js";
15
15
  import { t as beforeFirst } from "./text-BMFRfBqc.js";
16
16
  import { n as GRANTS_MARKER, r as HOOK_MARKER, s as hookMarkerFields } from "./markers-BeHZ4x9Q.js";
17
17
  import { n as formatManifestJson, t as MANIFEST_FILE } from "./manifest-json-CAGzls-C.js";
18
18
  import { n as MIGRATION_DIRS } from "./constants-DcJABbLW.js";
19
19
  import { f as writeOutputFiles, l as partPath, r as driftOf, u as pgDeltaPath } from "./output-files-BIQ_9pIs.js";
20
20
  import { A as quoteQualified, D as qualified, F as firstScopeType, I as scopeTypeOf, O as quoteIdent, R as tenantTypeOf, a as customRolesOn, j as quoteTable, k as quoteLiteral, l as USER_ID_HELPER, r as HELPERS, y as subjectIdSql } from "./shared-Afctg7B0.js";
21
- import { E as TOKEN_SCOPE_ALLOWS, J as apiKeyFields, K as API_KEY_ALLOWS, R as globalRoleSource, _ as PERMISSION_HELPERS, at as memberForHelper, b as permissionKeysForHelper, bt as checkSuspension, ct as memberIdsHelper, dt as permittedForHelper, et as hasMemberFor, ft as permittedIdsHelper, g as OWNERSHIP, h as ASSIGNMENTS, lt as memberOfHelper, ot as memberForSources, rt as isTeamScope, st as memberForTable, tt as hasPermittedUsers, ut as memberRoleOf, v as checkName, vt as activeRowSql, x as permittedByPermissionHelper } from "./tables-DeMNEy6V.js";
22
- import { a as guardedTables, t as ownershipRules, u as roleNames } from "./ownership-B4L59T9u.js";
21
+ import { E as TOKEN_SCOPE_ALLOWS, J as apiKeyFields, K as API_KEY_ALLOWS, R as globalRoleSource, _ as PERMISSION_HELPERS, at as memberForHelper, b as permissionKeysForHelper, bt as checkSuspension, ct as memberIdsHelper, dt as permittedForHelper, et as hasMemberFor, ft as permittedIdsHelper, g as OWNERSHIP, h as ASSIGNMENTS, lt as memberOfHelper, ot as memberForSources, rt as isTeamScope, st as memberForTable, tt as hasPermittedUsers, ut as memberRoleOf, v as checkName, vt as activeRowSql, x as permittedByPermissionHelper } from "./tables-BqrxBCir.js";
22
+ import { a as guardedTables, t as ownershipRules, u as roleNames } from "./ownership-DA5YdYTm.js";
23
23
  import { t as membershipSourcesOf } from "./sources-qoIJQrJv.js";
24
24
  import { a as splitUndiffed, r as tableKey, t as decidingColumns } from "./deciding-columns-NB4wcyBf.js";
25
25
  import { n as pgConnector } from "./pg-DQTqRrou.js";
26
- import { r as permittedUsersHelper, t as resolveNames } from "./resolve-names-CF7xXLSG.js";
26
+ import { r as permittedUsersHelper, t as resolveNames } from "./resolve-names-ConCSj1y.js";
27
27
  import { c as ACTOR_MAY_WRITE, f as readOnlyActorKinds } from "./fields-D0vUI6dq.js";
28
28
  import { existsSync, readFileSync, readdirSync } from "node:fs";
29
29
  import { dirname, join, posix, resolve } from "node:path";
@@ -8,15 +8,15 @@ import "./budget-BELja5A9.js";
8
8
  import { l as roleColumn } from "./sources-CMAM-2A3.js";
9
9
  import { t as beforeFirst } from "./text-BMFRfBqc.js";
10
10
  import { c as parseSplit } from "./output-files-BIQ_9pIs.js";
11
- import { b as resolveAuthorize } from "./supabase-hook-B-yXnzUl.js";
11
+ import { b as resolveAuthorize } from "./supabase-hook-CrgU06WH.js";
12
12
  import { A as quoteQualified, C as parseMembershipsFlag, D as qualified, F as firstScopeType, O as quoteIdent, R as tenantTypeOf, a as customRolesOn, j as quoteTable, k as quoteLiteral, s as signedIn, t as CUSTOM_ROLES } from "./shared-Afctg7B0.js";
13
- import { G as byKey, H as rolesTableScope, O as tokenScopesPlan, Q as graphSqlName, V as raiseSql, W as byCodeUnit, Y as apiKeysPlan, a as closureDepths, bt as checkSuspension, i as tablelessResources, o as graphPlan, r as tableNames, t as resolveVias, z as currentKeyExpr } from "./tables-DeMNEy6V.js";
14
- import { o as assignableRoles, r as unsatisfiedKinds, t as ownershipRules, u as roleNames } from "./ownership-B4L59T9u.js";
13
+ import { G as byKey, H as rolesTableScope, O as tokenScopesPlan, Q as graphSqlName, V as raiseSql, W as byCodeUnit, Y as apiKeysPlan, a as closureDepths, bt as checkSuspension, i as tablelessResources, o as graphPlan, r as tableNames, t as resolveVias, z as currentKeyExpr } from "./tables-BqrxBCir.js";
14
+ import { o as assignableRoles, r as unsatisfiedKinds, t as ownershipRules, u as roleNames } from "./ownership-DA5YdYTm.js";
15
15
  import { t as membershipSourcesOf } from "./sources-qoIJQrJv.js";
16
16
  import { i as group, o as sqlStatements } from "./deciding-columns-NB4wcyBf.js";
17
- import { t as resolveNames } from "./resolve-names-CF7xXLSG.js";
17
+ import { t as resolveNames } from "./resolve-names-ConCSj1y.js";
18
18
  import { d as orSql, h as branchClauses } from "./fields-D0vUI6dq.js";
19
- import { m as tableFor } from "./verify-DZeqoWu5.js";
19
+ import { m as tableFor } from "./verify-DlUcTDBz.js";
20
20
  //#region src/cli/rls/custom-role-rebuild.ts
21
21
  const PREFIX = "PermDock CLI";
22
22
  /** A column of the roles-table row `r`. */
@@ -330,6 +330,243 @@ create trigger ${quoteIdent(trigger)}
330
330
  return `${chunks.join("\n\n")}\n`;
331
331
  }
332
332
  //#endregion
333
+ //#region src/cli/rls/rows.ts
334
+ /**
335
+ * `permitted_<resource>_rows(p_permission)`: the resource's row ids the subject
336
+ * may act on with one permission.
337
+ */
338
+ function rowsHelper(resource) {
339
+ const name = graphSqlName(resource);
340
+ const helper = `permitted_${name ?? resource}_rows`;
341
+ if (name === void 0 || new TextEncoder().encode(`${helper}_for`).length > 63) throw configError(`PermDock CLI: rls.rowHelpers cannot name a helper for resource '${resource}'; use a SQL name of at most 45 bytes`);
342
+ return helper;
343
+ }
344
+ /**
345
+ * Every declared `<permission>@<level>` of an instance permission on a resource
346
+ * with levels.
347
+ */
348
+ function levelKeys(policy) {
349
+ const out = [];
350
+ for (const leaf of listPermissions(policy.vocabulary.permissions)) {
351
+ if (leaf.kind !== "instance") continue;
352
+ for (const [level, condition] of policyLevels(policy, leaf.resource)) out.push({
353
+ key: `${leaf.key}@${level}`,
354
+ permission: leaf.key,
355
+ conditioned: !(condition.op === "and" && condition.conditions.length === 0),
356
+ rowHelper: `permitted_${graphSqlName(leaf.resource) ?? leaf.resource}_row`
357
+ });
358
+ }
359
+ return out;
360
+ }
361
+ /**
362
+ * The branches a row check of a permission reads: its allows and denies,
363
+ * inserts included, for signed-in callers.
364
+ */
365
+ function rowBranchesOf(branches, resource) {
366
+ const out = /* @__PURE__ */ new Map();
367
+ for (const branch of branches) {
368
+ if (branch.resource !== resource || branch.coverage === true || !branch.roles.includes("authenticated")) continue;
369
+ out.set(branch.permissionKey, [...out.get(branch.permissionKey) ?? [], branch]);
370
+ }
371
+ return out;
372
+ }
373
+ /**
374
+ * What a branch asks of a row: the `with check` of an insert, which sees the
375
+ * new row, the `using` of every other command.
376
+ */
377
+ function clauseOf(branch) {
378
+ const clauses = branchClauses(branch);
379
+ return (branch.command === "insert" ? clauses.check : clauses.using) ?? "true";
380
+ }
381
+ function usingOf(branches) {
382
+ const parts = branches.map(clauseOf);
383
+ return parts.length === 0 ? void 0 : orSql(parts);
384
+ }
385
+ function permissionCase(key, branches) {
386
+ const allow = usingOf(branches.filter((branch) => branch.effect === "allow"));
387
+ if (allow === void 0) return;
388
+ const deny = usingOf(branches.filter((branch) => branch.effect === "deny"));
389
+ const granted = `coalesce((${allow}), false)`;
390
+ return ` when ${quoteLiteral(key)} then ${deny === void 0 ? granted : `${granted} and (${deny}) is not true`}`;
391
+ }
392
+ function forUserSql(ctx, fn, helper) {
393
+ const user = ctx.dialect === "supabase" ? "uuid" : "text";
394
+ const signature = `${user}, text, jsonb`;
395
+ const head = `create or replace function ${fn}(p_user ${user}, p_permission text, p_claims jsonb default '{}')
396
+ returns setof text
397
+ language plpgsql
398
+ volatile
399
+ security definer
400
+ set search_path = ''
401
+ as $$`;
402
+ const tail = `revoke execute on function ${fn}(${signature}) from public, anon, authenticated;`;
403
+ if (ctx.dialect === "supabase") return `${head}
404
+ declare
405
+ v_claims text := pg_catalog.current_setting('request.jwt.claims', true);
406
+ begin
407
+ perform pg_catalog.set_config(
408
+ 'request.jwt.claims',
409
+ (coalesce(p_claims, '{}'::jsonb) || pg_catalog.jsonb_build_object('sub', p_user::text, 'role', 'authenticated'))::text,
410
+ true
411
+ );
412
+ return query select r.id from ${helper}(p_permission) r(id);
413
+ perform pg_catalog.set_config('request.jwt.claims', coalesce(v_claims, ''), true);
414
+ end
415
+ $$;
416
+ ${tail}`;
417
+ const prefix = ctx.gucPrefix;
418
+ return `${head}
419
+ declare
420
+ v_saved jsonb := '{}'::jsonb;
421
+ v_key text;
422
+ v_value text;
423
+ begin
424
+ for v_key, v_value in
425
+ select 'user_id', p_user
426
+ union all
427
+ select c.key, c.value from pg_catalog.jsonb_each_text(coalesce(p_claims, '{}'::jsonb)) c where c.key <> 'user_id'
428
+ loop
429
+ v_saved := v_saved || pg_catalog.jsonb_build_object(v_key, coalesce(pg_catalog.current_setting(${quoteLiteral(`${prefix}.`)} || v_key, true), ''));
430
+ perform pg_catalog.set_config(${quoteLiteral(`${prefix}.`)} || v_key, v_value, true);
431
+ end loop;
432
+ return query select r.id from ${helper}(p_permission) r(id);
433
+ for v_key, v_value in select s.key, s.value from pg_catalog.jsonb_each_text(v_saved) s loop
434
+ perform pg_catalog.set_config(${quoteLiteral(`${prefix}.`)} || v_key, v_value, true);
435
+ end loop;
436
+ end
437
+ $$;
438
+ ${tail}`;
439
+ }
440
+ function inheritTargets(policy) {
441
+ const out = /* @__PURE__ */ new Set();
442
+ for (const grant of policy.grants) for (const item of flattenGrantee(grant.to)) if (item.kind === "inherit") out.add(item.resource);
443
+ return [...out].toSorted();
444
+ }
445
+ const CANDIDATES = "permdock_candidates";
446
+ function stubSql(ctx, resource) {
447
+ const fn = qualified(ctx, rowsHelper(resource));
448
+ return ["p_permission text", "p_permission text, p_ids text[]"].map((parameters) => `create or replace function ${fn}(${parameters})
449
+ returns setof text
450
+ language sql
451
+ stable
452
+ security definer
453
+ set search_path = ''
454
+ as $$
455
+ select null::text where false
456
+ $$;`).join("\n");
457
+ }
458
+ function rowSql(ctx, rows, table, where) {
459
+ const fn = qualified(ctx, rows.replace(/_rows$/u, "_row"));
460
+ return `create or replace function ${fn}(p_row ${table}, p_permission text)
461
+ returns boolean
462
+ language sql
463
+ stable
464
+ security definer
465
+ set search_path = ''
466
+ as $$
467
+ with ${CANDIDATES} as (select (p_row).*)
468
+ select exists (select 1 from ${CANDIDATES} where ${where})
469
+ $$;
470
+ revoke execute on function ${fn}(${table}, text) from public, anon;
471
+ grant execute on function ${fn}(${table}, text) to authenticated;`;
472
+ }
473
+ function whereOf(branches) {
474
+ const cases = [...branches.keys()].toSorted().flatMap((key) => {
475
+ const sql = permissionCase(key, branches.get(key) ?? []);
476
+ return sql === void 0 ? [] : [sql];
477
+ });
478
+ return cases.length === 0 ? "false" : `case p_permission\n${cases.join("\n")}\n else false\n end`;
479
+ }
480
+ function candidatesSql(fn, table, id, where) {
481
+ const assign = (indent) => `${indent}v_row.${id} := v_id;\n${indent}v_rows := pg_catalog.array_append(v_rows, v_row);`;
482
+ return `create or replace function ${fn}(p_permission text, p_ids text[])
483
+ returns setof text
484
+ language plpgsql
485
+ stable
486
+ security definer
487
+ set search_path = ''
488
+ as $$
489
+ declare
490
+ v_row ${table};
491
+ v_rows ${table}[] := '{}';
492
+ v_id text;
493
+ begin
494
+ begin
495
+ foreach v_id in array coalesce(p_ids, '{}') loop
496
+ ${assign(" ")}
497
+ end loop;
498
+ exception when data_exception then
499
+ v_rows := '{}';
500
+ foreach v_id in array p_ids loop
501
+ begin
502
+ ${assign(" ")}
503
+ exception when data_exception then
504
+ null;
505
+ end;
506
+ end loop;
507
+ end;
508
+ return query
509
+ with ${CANDIDATES} as materialized (
510
+ select * from ${table} where ${id} = any (array(select (r).${id} from pg_catalog.unnest(v_rows) r))
511
+ )
512
+ select ${id}::text from ${CANDIDATES}
513
+ where ${where};
514
+ end
515
+ $$;
516
+ revoke execute on function ${fn}(text, text[]) from public, anon;
517
+ grant execute on function ${fn}(text, text[]) to authenticated;`;
518
+ }
519
+ function resourceSql(ctx, node, branches, narrowed, tables) {
520
+ const name = rowsHelper(node.name);
521
+ const fn = qualified(ctx, name);
522
+ const table = quoteQualified(tableFor(node.name, tables));
523
+ const where = whereOf(branches);
524
+ const near = whereOf(narrowed);
525
+ const rows = `-- ${node.name}: ids of the rows the caller may act on with p_permission, as the table's policies decide it
526
+ create or replace function ${fn}(p_permission text)
527
+ returns setof text
528
+ language sql
529
+ stable
530
+ security definer
531
+ set search_path = ''
532
+ as $$
533
+ select ${quoteIdent(node.id)}::text from ${table}
534
+ where ${where}
535
+ $$;
536
+ revoke execute on function ${fn}(text) from public, anon;
537
+ grant execute on function ${fn}(text) to authenticated;
538
+ ${candidatesSql(fn, table, quoteIdent(node.id), near)}
539
+ ${rowSql(ctx, name, table, near)}`;
540
+ if (ctx.dialect === "neon") return rows;
541
+ return `${rows}
542
+ -- the same rows for a user the caller names, with claims it supplies; no client role may execute it
543
+ ${forUserSql(ctx, qualified(ctx, `${name}_for`), fn)}`;
544
+ }
545
+ /**
546
+ * `permitted_<resource>_rows(p_permission)` for each resource `select` names
547
+ * (or every resource a grant reaches with `true`): the ids of its rows the
548
+ * caller may read, update or delete with that permission, from the same
549
+ * compiled allows and denies the table policies use, so closure walks, link
550
+ * hops, the restricted stop, `includes`, groups and `requires` all apply. A
551
+ * `security definer` helper, so hand-written policies and functions call it
552
+ * without restating the graph. Outside the `neon` dialect a
553
+ * `permitted_<resource>_rows_for(p_user, p_permission, p_claims)` form runs it
554
+ * as the named user, with the claims the caller supplies, for trusted SQL.
555
+ */
556
+ function rowHelpersSql(ctx, policy, branches, select, tables, warnings, narrowed = branches) {
557
+ const names = select === true ? [...new Set(branches.flatMap((branch) => branch.resource === void 0 ? [] : [branch.resource]))].toSorted() : [...new Set(select)];
558
+ const called = inheritTargets(policy);
559
+ for (const name of called) if (!names.includes(name)) names.push(name);
560
+ const chunks = called.map((name) => stubSql(ctx, name));
561
+ for (const name of names) {
562
+ const node = policy.resources.get(name);
563
+ if (node === void 0) throw configError(`PermDock CLI: rls.rowHelpers names '${name}', which the policy does not declare`);
564
+ chunks.push(resourceSql(ctx, node, rowBranchesOf(branches, name), rowBranchesOf(narrowed, name), tables));
565
+ }
566
+ if (chunks.length > 0 && ctx.dialect === "neon") warnings.push("rls.rowHelpers: the neon dialect reads the subject from auth.session(), which SQL cannot set, so no permitted_<resource>_rows_for is written");
567
+ return chunks.length === 0 ? "" : `${chunks.join("\n\n")}\n`;
568
+ }
569
+ //#endregion
333
570
  //#region src/cli/rls/generate-context.ts
334
571
  /**
335
572
  * The scopes an `rls.migrate` `role` helper names, so `rls generate` writes
@@ -460,7 +697,7 @@ function buildContext(input, policy, options) {
460
697
  } },
461
698
  ...options.fieldsMode === void 0 ? {} : { fields: options.fieldsMode },
462
699
  ...vias === void 0 ? {} : { vias },
463
- ...graph.size === 0 ? {} : { graph: {
700
+ ...graph.size === 0 && inheritTargets(policy).length === 0 ? {} : { graph: {
464
701
  closures: closureDepths(graph),
465
702
  resources: policy.resources,
466
703
  ...rls?.tables === void 0 ? {} : { tables: tableNames(rls.tables) ?? {} }
@@ -520,196 +757,6 @@ function splitsPart(raw, part) {
520
757
  return typeof split !== "string" && split?.includes(part) === true;
521
758
  }
522
759
  //#endregion
523
- //#region src/cli/rls/rows.ts
524
- /**
525
- * `permitted_<resource>_rows(p_permission)`: the resource's row ids the subject
526
- * may act on with one permission.
527
- */
528
- function rowsHelper(resource) {
529
- const name = graphSqlName(resource);
530
- const helper = `permitted_${name ?? resource}_rows`;
531
- if (name === void 0 || new TextEncoder().encode(`${helper}_for`).length > 63) throw configError(`PermDock CLI: rls.rowHelpers cannot name a helper for resource '${resource}'; use a SQL name of at most 45 bytes`);
532
- return helper;
533
- }
534
- /**
535
- * Every declared `<permission>@<level>` of an instance permission on a resource
536
- * with levels.
537
- */
538
- function levelKeys(policy) {
539
- const out = [];
540
- for (const leaf of listPermissions(policy.vocabulary.permissions)) {
541
- if (leaf.kind !== "instance") continue;
542
- for (const [level, condition] of policyLevels(policy, leaf.resource)) out.push({
543
- key: `${leaf.key}@${level}`,
544
- permission: leaf.key,
545
- conditioned: !(condition.op === "and" && condition.conditions.length === 0),
546
- rowHelper: `permitted_${graphSqlName(leaf.resource) ?? leaf.resource}_row`
547
- });
548
- }
549
- return out;
550
- }
551
- /**
552
- * The branches a row check of a permission reads: its allows and denies,
553
- * inserts included, for signed-in callers.
554
- */
555
- function rowBranchesOf(branches, resource) {
556
- const out = /* @__PURE__ */ new Map();
557
- for (const branch of branches) {
558
- if (branch.resource !== resource || branch.coverage === true || !branch.roles.includes("authenticated")) continue;
559
- out.set(branch.permissionKey, [...out.get(branch.permissionKey) ?? [], branch]);
560
- }
561
- return out;
562
- }
563
- /**
564
- * What a branch asks of a row: the `with check` of an insert, which sees the
565
- * new row, the `using` of every other command.
566
- */
567
- function clauseOf(branch) {
568
- const clauses = branchClauses(branch);
569
- return (branch.command === "insert" ? clauses.check : clauses.using) ?? "true";
570
- }
571
- function usingOf(branches) {
572
- const parts = branches.map(clauseOf);
573
- return parts.length === 0 ? void 0 : orSql(parts);
574
- }
575
- function permissionCase(key, branches) {
576
- const allow = usingOf(branches.filter((branch) => branch.effect === "allow"));
577
- if (allow === void 0) return;
578
- const deny = usingOf(branches.filter((branch) => branch.effect === "deny"));
579
- const granted = `coalesce((${allow}), false)`;
580
- return ` when ${quoteLiteral(key)} then ${deny === void 0 ? granted : `${granted} and (${deny}) is not true`}`;
581
- }
582
- function forUserSql(ctx, fn, helper) {
583
- const user = ctx.dialect === "supabase" ? "uuid" : "text";
584
- const signature = `${user}, text, jsonb`;
585
- const head = `create or replace function ${fn}(p_user ${user}, p_permission text, p_claims jsonb default '{}')
586
- returns setof text
587
- language plpgsql
588
- volatile
589
- security definer
590
- set search_path = ''
591
- as $$`;
592
- const tail = `revoke execute on function ${fn}(${signature}) from public, anon, authenticated;`;
593
- if (ctx.dialect === "supabase") return `${head}
594
- declare
595
- v_claims text := pg_catalog.current_setting('request.jwt.claims', true);
596
- begin
597
- perform pg_catalog.set_config(
598
- 'request.jwt.claims',
599
- (coalesce(p_claims, '{}'::jsonb) || pg_catalog.jsonb_build_object('sub', p_user::text, 'role', 'authenticated'))::text,
600
- true
601
- );
602
- return query select r.id from ${helper}(p_permission) r(id);
603
- perform pg_catalog.set_config('request.jwt.claims', coalesce(v_claims, ''), true);
604
- end
605
- $$;
606
- ${tail}`;
607
- const prefix = ctx.gucPrefix;
608
- return `${head}
609
- declare
610
- v_saved jsonb := '{}'::jsonb;
611
- v_key text;
612
- v_value text;
613
- begin
614
- for v_key, v_value in
615
- select 'user_id', p_user
616
- union all
617
- select c.key, c.value from pg_catalog.jsonb_each_text(coalesce(p_claims, '{}'::jsonb)) c where c.key <> 'user_id'
618
- loop
619
- v_saved := v_saved || pg_catalog.jsonb_build_object(v_key, coalesce(pg_catalog.current_setting(${quoteLiteral(`${prefix}.`)} || v_key, true), ''));
620
- perform pg_catalog.set_config(${quoteLiteral(`${prefix}.`)} || v_key, v_value, true);
621
- end loop;
622
- return query select r.id from ${helper}(p_permission) r(id);
623
- for v_key, v_value in select s.key, s.value from pg_catalog.jsonb_each_text(v_saved) s loop
624
- perform pg_catalog.set_config(${quoteLiteral(`${prefix}.`)} || v_key, v_value, true);
625
- end loop;
626
- end
627
- $$;
628
- ${tail}`;
629
- }
630
- function inheritTargets(policy) {
631
- const out = /* @__PURE__ */ new Set();
632
- for (const grant of policy.grants) for (const item of flattenGrantee(grant.to)) if (item.kind === "inherit") out.add(item.resource);
633
- return [...out].toSorted();
634
- }
635
- function stubSql(ctx, resource) {
636
- return `create or replace function ${qualified(ctx, rowsHelper(resource))}(p_permission text)
637
- returns setof text
638
- language sql
639
- stable
640
- security definer
641
- set search_path = ''
642
- as $$
643
- select null::text where false
644
- $$;`;
645
- }
646
- function rowSql(ctx, rows, table, where) {
647
- const fn = qualified(ctx, rows.replace(/_rows$/u, "_row"));
648
- return `create or replace function ${fn}(p_row ${table}, p_permission text)
649
- returns boolean
650
- language sql
651
- stable
652
- security definer
653
- set search_path = ''
654
- as $$
655
- select exists (select 1 from (select (p_row).*) r where ${where})
656
- $$;
657
- revoke execute on function ${fn}(${table}, text) from public, anon;
658
- grant execute on function ${fn}(${table}, text) to authenticated;`;
659
- }
660
- function resourceSql(ctx, node, branches, tables) {
661
- const name = rowsHelper(node.name);
662
- const fn = qualified(ctx, name);
663
- const table = quoteQualified(tableFor(node.name, tables));
664
- const cases = [...branches.keys()].toSorted().flatMap((key) => {
665
- const sql = permissionCase(key, branches.get(key) ?? []);
666
- return sql === void 0 ? [] : [sql];
667
- });
668
- const where = cases.length === 0 ? "false" : `case p_permission\n${cases.join("\n")}\n else false\n end`;
669
- const rows = `-- ${node.name}: ids of the rows the caller may act on with p_permission, as the table's policies decide it
670
- create or replace function ${fn}(p_permission text)
671
- returns setof text
672
- language sql
673
- stable
674
- security definer
675
- set search_path = ''
676
- as $$
677
- select ${quoteIdent(node.id)}::text from ${table}
678
- where ${where}
679
- $$;
680
- revoke execute on function ${fn}(text) from public, anon;
681
- grant execute on function ${fn}(text) to authenticated;
682
- ${rowSql(ctx, name, table, where)}`;
683
- if (ctx.dialect === "neon") return rows;
684
- return `${rows}
685
- -- the same rows for a user the caller names, with claims it supplies; no client role may execute it
686
- ${forUserSql(ctx, qualified(ctx, `${name}_for`), fn)}`;
687
- }
688
- /**
689
- * `permitted_<resource>_rows(p_permission)` for each resource `select` names
690
- * (or every resource a grant reaches with `true`): the ids of its rows the
691
- * caller may read, update or delete with that permission, from the same
692
- * compiled allows and denies the table policies use, so closure walks, link
693
- * hops, the restricted stop, `includes`, groups and `requires` all apply. A
694
- * `security definer` helper, so hand-written policies and functions call it
695
- * without restating the graph. Outside the `neon` dialect a
696
- * `permitted_<resource>_rows_for(p_user, p_permission, p_claims)` form runs it
697
- * as the named user, with the claims the caller supplies, for trusted SQL.
698
- */
699
- function rowHelpersSql(ctx, policy, branches, select, tables, warnings) {
700
- const names = select === true ? [...new Set(branches.flatMap((branch) => branch.resource === void 0 ? [] : [branch.resource]))].toSorted() : [...new Set(select)];
701
- const called = inheritTargets(policy);
702
- for (const name of called) if (!names.includes(name)) names.push(name);
703
- const chunks = called.map((name) => stubSql(ctx, name));
704
- for (const name of names) {
705
- const node = policy.resources.get(name);
706
- if (node === void 0) throw configError(`PermDock CLI: rls.rowHelpers names '${name}', which the policy does not declare`);
707
- chunks.push(resourceSql(ctx, node, rowBranchesOf(branches, name), tables));
708
- }
709
- if (chunks.length > 0 && ctx.dialect === "neon") warnings.push("rls.rowHelpers: the neon dialect reads the subject from auth.session(), which SQL cannot set, so no permitted_<resource>_rows_for is written");
710
- return chunks.length === 0 ? "" : `${chunks.join("\n\n")}\n`;
711
- }
712
- //#endregion
713
760
  //#region src/cli/sql/supautils.ts
714
761
  /**
715
762
  * `supautils.reserved_roles` of supabase/postgres 17.11.0.002 (supautils
@@ -805,4 +852,4 @@ function supautilsRejections(sql) {
805
852
  });
806
853
  }
807
854
  //#endregion
808
- export { generateOptions as a, buildContext as c, rowHelpersSql as i, DROPPED_LIST as l, inheritTargets as n, isRefusal as o, levelKeys as r, splitsPart as s, supautilsRejections as t, rebuildPlan as u };
855
+ export { buildContext as a, levelKeys as c, rebuildPlan as d, splitsPart as i, rowHelpersSql as l, generateOptions as n, CANDIDATES as o, isRefusal as r, inheritTargets as s, supautilsRejections as t, DROPPED_LIST as u };
@@ -1,11 +1,11 @@
1
- import { c as requiredPlans } from "../errors-zi_4T-rx.js";
2
- import { i as describe } from "../describe-ByS9LgHK.js";
1
+ import { c as requiredPlans } from "../errors-BIM4MFsJ.js";
2
+ import { i as describe } from "../describe-BbFPBSms.js";
3
3
  import { t as PermissionBoundaryState } from "../boundary-C9ck-3uK.js";
4
- import { n as ProtectedAction, t as ActionResult } from "../action-result-CL-QCITA.js";
4
+ import { n as ProtectedAction, t as ActionResult } from "../action-result-BcudBQOF.js";
5
5
  import { t as approvalHeaders } from "../headers-B9jQxjtW.js";
6
- import { a as FilterResult, b as eventSourceRefresh, c as PermissionSet, d as ProtectedActionView, h as TenantView, i as ClientStatus, l as PermissionState, m as SubjectView, n as ApprovalState, o as GateMode, p as RolesOptions, r as ClientPermDock, s as GateView, t as ApprovalHandle, v as EventSourceRefreshOptions, y as RefreshTrigger } from "../types-B_d_g7T3.js";
7
- import { i as ProtectedProps, n as ProtectedActionReadable, r as SveltePermDockOptions, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-djVzLlIV.js";
8
- import { a as gate, c as memberships, d as protectedAction, f as roles, h as tenant, i as filtered, l as permission, m as subject, n as assignable, o as getDescribe, p as setPermDock, r as assignablePermissions, s as getPermDock, t as approval, u as permissions } from "../stores-C0Kta5Ft.js";
6
+ import { a as FilterResult, b as eventSourceRefresh, c as PermissionSet, d as ProtectedActionView, h as TenantView, i as ClientStatus, l as PermissionState, m as SubjectView, n as ApprovalState, o as GateMode, p as RolesOptions, r as ClientPermDock, s as GateView, t as ApprovalHandle, v as EventSourceRefreshOptions, y as RefreshTrigger } from "../types-tQB2CEnY.js";
7
+ import { i as ProtectedProps, n as ProtectedActionReadable, r as SveltePermDockOptions, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-CEinc15V.js";
8
+ import { a as gate, c as memberships, d as protectedAction, f as roles, h as tenant, i as filtered, l as permission, m as subject, n as assignable, o as getDescribe, p as setPermDock, r as assignablePermissions, s as getPermDock, t as approval, u as permissions } from "../stores-DZJvxFIZ.js";
9
9
  import { Component } from "svelte";
10
10
  //#region src/svelte/index.d.ts
11
11
  export declare const Protected: Component<ProtectedProps>;
@@ -1,7 +1,7 @@
1
- import { n as DescribeMessages } from "../describe-ByS9LgHK.js";
1
+ import { n as DescribeMessages } from "../describe-BbFPBSms.js";
2
2
  import { n as boundaryDigest, r as boundaryFallback, t as PermissionBoundaryState } from "../boundary-C9ck-3uK.js";
3
- import { g as ClientStore } from "../types-B_d_g7T3.js";
4
- import { a as scopedFor, c as slotContent, i as ProtectedProps, o as viewFor, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-djVzLlIV.js";
3
+ import { g as ClientStore } from "../types-tQB2CEnY.js";
4
+ import { a as scopedFor, c as slotContent, i as ProtectedProps, o as viewFor, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-CEinc15V.js";
5
5
  //#region src/svelte/context.d.ts
6
6
  /** The provider's `defaults` and `messages`. */
7
7
  type PermDockUi = {
@@ -1,11 +1,11 @@
1
- import { c as requiredPlans } from "../errors-zi_4T-rx.js";
2
- import { i as describe } from "../describe-ByS9LgHK.js";
1
+ import { c as requiredPlans } from "../errors-BIM4MFsJ.js";
2
+ import { i as describe } from "../describe-BbFPBSms.js";
3
3
  import { t as PermissionBoundaryState } from "../boundary-C9ck-3uK.js";
4
- import { n as ProtectedAction, t as ActionResult } from "../action-result-CL-QCITA.js";
4
+ import { n as ProtectedAction, t as ActionResult } from "../action-result-BcudBQOF.js";
5
5
  import { t as approvalHeaders } from "../headers-B9jQxjtW.js";
6
- import { a as FilterResult, b as eventSourceRefresh, c as PermissionSet, d as ProtectedActionView, h as TenantView, i as ClientStatus, l as PermissionState, m as SubjectView, n as ApprovalState, o as GateMode, p as RolesOptions, r as ClientPermDock, s as GateView, t as ApprovalHandle, v as EventSourceRefreshOptions, y as RefreshTrigger } from "../types-B_d_g7T3.js";
7
- import { i as ProtectedProps, n as ProtectedActionReadable, r as SveltePermDockOptions, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-djVzLlIV.js";
8
- import { a as gate, c as memberships, d as protectedAction, f as roles, h as tenant, i as filtered, l as permission, m as subject, n as assignable, o as getDescribe, p as setPermDock, r as assignablePermissions, s as getPermDock, t as approval, u as permissions } from "../stores-C0Kta5Ft.js";
6
+ import { a as FilterResult, b as eventSourceRefresh, c as PermissionSet, d as ProtectedActionView, h as TenantView, i as ClientStatus, l as PermissionState, m as SubjectView, n as ApprovalState, o as GateMode, p as RolesOptions, r as ClientPermDock, s as GateView, t as ApprovalHandle, v as EventSourceRefreshOptions, y as RefreshTrigger } from "../types-tQB2CEnY.js";
7
+ import { i as ProtectedProps, n as ProtectedActionReadable, r as SveltePermDockOptions, s as PermissionBoundaryProps, t as PermDockDefaults } from "../types-CEinc15V.js";
8
+ import { a as gate, c as memberships, d as protectedAction, f as roles, h as tenant, i as filtered, l as permission, m as subject, n as assignable, o as getDescribe, p as setPermDock, r as assignablePermissions, s as getPermDock, t as approval, u as permissions } from "../stores-DZJvxFIZ.js";
9
9
  import { Component } from "svelte";
10
10
  //#region src/svelte/source.d.ts
11
11
  export declare const Protected: Component<ProtectedProps>;
@@ -1,9 +1,9 @@
1
- import { Gt as Snapshot, T as Policy, j as PolicyVocabulary, sr as Principal } from "../policy-types-CCiDRZBH.js";
1
+ import { T as Policy, Zt as Snapshot, j as PolicyVocabulary, pr as Principal } from "../policy-types-DGIO_gxq.js";
2
2
  import { u as Permission } from "../permission-types-CAY-GU7e.js";
3
3
  import { a as OperationInput, t as Operation } from "../operations-Ci_rT6Uo.js";
4
- import { a as PermDock } from "../permdock-B6Sf4T_S.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-CIlpSA2G.js";
6
- import { a as ProtectTarget, i as PermDockHandlers, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-C1DCvpqV.js";
4
+ import { a as PermDock } from "../permdock-CprAPN3w.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-CyRN0-Cd.js";
6
+ import { a as ProtectTarget, i as PermDockHandlers, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-BIbBAtPZ.js";
7
7
  import { RequestEvent } from "@sveltejs/kit";
8
8
  //#region src/sveltekit/create.d.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  import { l as InvalidSignatureError, p as webBotAuthVerifier, u as discoverViaSignatureAgent } from "../evaluations-IBceAeKT.js";
2
- import { n as guardedRoute, r as instanceRoute, t as fetchAdapter } from "../fetch-adapter-JL43jD3E.js";
2
+ import { n as guardedRoute, r as instanceRoute, t as fetchAdapter } from "../fetch-adapter-dPTgJVHd.js";
3
3
  //#region src/sveltekit/create.ts
4
4
  const route = {
5
5
  context: (event) => event,
@@ -4,7 +4,7 @@ import { f as scopeList, l as rootScope, s as resolveScope, u as scopeChain } fr
4
4
  import { o as flattenGrantee } from "./grantee-Dke-9rd1.js";
5
5
  import { r as relationCondition, t as inheritCondition } from "./grantee-conditions-BrYPe-w0.js";
6
6
  import { l as partitionsOf, p as scopeField } from "./tenancy-5d1zVBvK.js";
7
- import { a as delegatedScopeMap } from "./permdock-L-_I_3zP.js";
7
+ import { a as delegatedScopeMap } from "./permdock-BvjivVb9.js";
8
8
  import { i as configError } from "./errors-Vpu6rKHl.js";
9
9
  import { d as sqlTextArray, i as qualifySqlTable, t as SQL_IDENT } from "./sql-0WjxIp9g.js";
10
10
  import { a as scopeMembershipTable, d as restrictedRowsSql, i as scopeColumn, l as relationArmSql } from "./compile-EzEMB-7v.js";
@@ -1,9 +1,9 @@
1
- import { Gt as Snapshot, T as Policy, j as PolicyVocabulary, sr as Principal } from "../policy-types-CCiDRZBH.js";
1
+ import { T as Policy, Zt as Snapshot, j as PolicyVocabulary, pr as Principal } from "../policy-types-DGIO_gxq.js";
2
2
  import { u as Permission } from "../permission-types-CAY-GU7e.js";
3
3
  import { a as OperationInput, t as Operation } from "../operations-Ci_rT6Uo.js";
4
- import { a as PermDock } from "../permdock-B6Sf4T_S.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-CIlpSA2G.js";
6
- import { a as ProtectTarget, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-C1DCvpqV.js";
4
+ import { a as PermDock } from "../permdock-CprAPN3w.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-CyRN0-Cd.js";
6
+ import { a as ProtectTarget, n as FetchAdapterOptions, t as ContextReader } from "../fetch-adapter-BIbBAtPZ.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
1
  import { l as InvalidSignatureError, p as webBotAuthVerifier, u as discoverViaSignatureAgent } from "../evaluations-IBceAeKT.js";
2
- import { t as fetchAdapter } from "../fetch-adapter-JL43jD3E.js";
2
+ import { t as fetchAdapter } from "../fetch-adapter-dPTgJVHd.js";
3
3
  import { createMiddleware } from "@tanstack/react-start";
4
4
  //#region src/tanstack-start/create.ts
5
5
  function createPermDock(policy, options) {