permdock 0.3.1 → 0.4.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 (323) hide show
  1. package/dist/a2a/index.d.ts +7 -5
  2. package/dist/a2a/index.js +14 -21
  3. package/dist/ai-sdk/index.d.ts +18 -6
  4. package/dist/ai-sdk/index.js +8 -5
  5. package/dist/app-data-CV8pqqMi.js +59 -0
  6. package/dist/approvals/index.d.ts +2 -2
  7. package/dist/approvals/index.js +3 -3
  8. package/dist/{approvals-DbYAuNkG.js → approvals-DZL76lKW.js} +35 -19
  9. package/dist/{approvers-DT4AVyIg.js → approvers-CqPOLD-o.js} +1 -1
  10. package/dist/{arazzo-BAgw9ap6.js → arazzo-C4BcskbX.js} +6 -5
  11. package/dist/{arazzo-C9chp3ST.js → arazzo-CD8d0WLb.js} +2 -2
  12. package/dist/authzen/index.d.ts +3 -3
  13. package/dist/authzen/index.js +161 -23
  14. package/dist/better-auth/index.d.ts +2 -2
  15. package/dist/better-auth/index.js +6 -19
  16. package/dist/better-supabase/index.d.ts +112 -87
  17. package/dist/better-supabase/index.js +257 -156
  18. package/dist/{bind-C_ob3LKa.d.ts → bind-BzqG8SMb.d.ts} +16 -5
  19. package/dist/{bind-CuzGytRf.js → bind-kk-uyCwH.js} +14 -6
  20. package/dist/build-instance-DIIV9DbC.js +51 -0
  21. package/dist/{canonical-json-DemiK4Vp.js → canonical-json-CFKyFOke.js} +1 -3
  22. package/dist/{capability-2kYTMWDv.d.ts → capability-CksyCWDH.d.ts} +2 -2
  23. package/dist/{capability-4qPdO9gk.js → capability-txATtKV4.js} +3 -2
  24. package/dist/catalog/index.d.ts +1 -1
  25. package/dist/catalog/index.js +1 -1
  26. package/dist/catalog-6yWAX6Ps.js +2 -0
  27. package/dist/{catalog-CYj-mX2O.js → catalog-WHG4kBq7.js} +2 -2
  28. package/dist/{catalog-doc-DdGm82XT.js → catalog-doc-DWtg0gGR.js} +17 -10
  29. package/dist/{catalog-DWF5cYqB.js → catalog-tZUyOfOv.js} +4 -4
  30. package/dist/claude-agent/index.d.ts +4 -4
  31. package/dist/claude-agent/index.js +4 -5
  32. package/dist/clerk/index.d.ts +3 -3
  33. package/dist/clerk/index.js +8 -33
  34. package/dist/cli/bin.js +1 -1
  35. package/dist/cli/index.d.ts +3 -3
  36. package/dist/cli/index.js +3 -3
  37. package/dist/cloud/index.d.ts +4 -4
  38. package/dist/cloud/index.js +9 -15
  39. package/dist/{cloud-CfwZ39Rl.js → cloud-C7bSDgX4.js} +2 -2
  40. package/dist/{cloud-DWLXO2af.js → cloud-PeBN3IEn.js} +5 -5
  41. package/dist/{collect-DSTE3ml9.js → collect-2SrB7lfk.js} +6 -8
  42. package/dist/collect-Bw2Jdq1q.js +2 -0
  43. package/dist/{collect-CHB22Sx4.js → collect-CQx4hX4N.js} +3 -3
  44. package/dist/{commands-BeaGNj_o.js → commands-Cpip4ULx.js} +13 -13
  45. package/dist/{compact-y6vfu2_f.js → compact-CAf557ZB.js} +11 -1
  46. package/dist/compile/index.d.ts +1 -1
  47. package/dist/compile/index.js +1 -1
  48. package/dist/{compile-Ba4blROR.js → compile-CcEu2ZQ1.js} +6 -5
  49. package/dist/{compile-BkRyBDBw.d.ts → compile-CtTP7eur.d.ts} +2 -2
  50. package/dist/{config-BJiM-xAm.js → config-BIjREpyE.js} +4 -4
  51. package/dist/{config-ir40y8m0.js → config-DLt6BvV7.js} +2 -2
  52. package/dist/{config-report-CdCgbRnV.js → config-report--Xb9APJS.js} +5 -6
  53. package/dist/{connection-CU8MQxRi.js → connection-DUsczpB5.js} +3 -2
  54. package/dist/constants-DcJABbLW.js +20 -0
  55. package/dist/{context-Bcy85rGi.js → context-DieZVJXu.js} +16 -5
  56. package/dist/convex/index.d.ts +4 -4
  57. package/dist/convex/index.js +14 -16
  58. package/dist/create-BBO24vj6.js +324 -0
  59. package/dist/{credential-8P81ff4u.js → credential-kue0qpbm.js} +4 -4
  60. package/dist/deciding-columns-Sq12mEA6.js +123 -0
  61. package/dist/delegation-input-FTxMK3ji.js +19 -0
  62. package/dist/denied-text-DfRk15uw.d.ts +19 -0
  63. package/dist/{describe-DMYiCjJV.d.ts → describe-C3ldA9os.d.ts} +11 -2
  64. package/dist/{describe-B_gVZEVi.js → describe-Cgkp7eP0.js} +5 -4
  65. package/dist/{diff-C9RDjjhs.js → diff-Cnghh_Ip.js} +2 -2
  66. package/dist/{diff-2VaeChzX.js → diff-rpqoe7Ag.js} +9 -9
  67. package/dist/{doctor-Djh6JDEk.js → doctor-CuVJvhV_.js} +2 -2
  68. package/dist/doctor-owlv6ddh.js +2166 -0
  69. package/dist/drizzle/index.d.ts +2 -2
  70. package/dist/drizzle/index.js +6 -14
  71. package/dist/elysia/index.d.ts +4 -4
  72. package/dist/elysia/index.js +7 -7
  73. package/dist/{errors-DPdqI50v.d.ts → errors-OD_4c__H.d.ts} +2 -2
  74. package/dist/{errors-Cz5zn0mW.js → errors-drnfxYtm.js} +3 -3
  75. package/dist/{evaluations-tz6D9A2G.js → evaluations-C9YJsv3H.js} +45 -7
  76. package/dist/eve/index.d.ts +5 -5
  77. package/dist/eve/index.js +5 -5
  78. package/dist/express/index.d.ts +4 -4
  79. package/dist/express/index.js +8 -7
  80. package/dist/fastify/index.d.ts +15 -5
  81. package/dist/fastify/index.js +9 -29
  82. package/dist/fields-fwfXN01n.js +1016 -0
  83. package/dist/{files-DWUN9PzI.js → files-D_JIzUrP.js} +12 -3
  84. package/dist/{fixtures-ht28Cplr.js → fixtures-h2eG2OZV.js} +5 -6
  85. package/dist/{from-snapshot-CTLijvdm.js → from-snapshot-7REQZe0H.js} +32 -22
  86. package/dist/{generate-CH7ThJ14.js → generate-CNU1pIOo.js} +1 -3
  87. package/dist/grantee-CXY-0C87.js +254 -0
  88. package/dist/grantee-conditions-MQs5NIuX.js +270 -0
  89. package/dist/grantee-match-fxYp9Nmt.js +141 -0
  90. package/dist/{helpers-H_KARDVC.js → helpers-C9YmyBIa.js} +7 -6
  91. package/dist/hono/index.d.ts +4 -4
  92. package/dist/hono/index.js +8 -8
  93. package/dist/hosted-CBHgkzDl.js +655 -0
  94. package/dist/{http-SO7qGttf.js → http-BBoKefeS.js} +35 -2
  95. package/dist/{http-BIhmLfCc.js → http-BEbdMZ05.js} +2 -24
  96. package/dist/{rls-import-4lLW_pbb.js → import-BFIlhetD.js} +86 -80
  97. package/dist/{openapi-import-cmwetbzw.js → import-UHk1N7vH.js} +6 -7
  98. package/dist/{index-C8z4RjQV.d.ts → index-BwMe94Xq.d.ts} +1 -1
  99. package/dist/{index-0nNqHspG.d.ts → index-DgM7w96K.d.ts} +2 -2
  100. package/dist/{index-C7Tw7MaW.d.ts → index-Dz7didpC.d.ts} +3 -3
  101. package/dist/{index-BNc7Wer_.d.ts → index-UdVQgq48.d.ts} +105 -38
  102. package/dist/index.d.ts +15 -13
  103. package/dist/index.js +22 -22
  104. package/dist/{instance-options-jARdwfPN.d.ts → instance-options-plkrsAog.d.ts} +1 -1
  105. package/dist/{json-schema-BsAflUGW.js → json-schema-DBkdUuCO.js} +1 -3
  106. package/dist/jwt/index.d.ts +4 -4
  107. package/dist/jwt/index.js +13 -13
  108. package/dist/{kernel-_RRHmnMY.js → kernel-CB3LrIJM.js} +81 -32
  109. package/dist/kysely/index.d.ts +2 -2
  110. package/dist/kysely/index.js +6 -14
  111. package/dist/{live-options-H2eG8dfJ.js → live-options-BaAFCIiu.js} +16 -3
  112. package/dist/load-B_shHrmd.js +2 -0
  113. package/dist/{load-DhWEB9P1.js → load-C3_oTHyO.js} +11 -3
  114. package/dist/{manifest-iaoBXHKc.js → manifest-BngWKryL.js} +5 -18
  115. package/dist/{map-claims-Z4QZOiFF.js → map-claims-AVlBaJoa.js} +7 -16
  116. package/dist/{map-error-pgUWNNtG.js → map-error-BE27PYkE.js} +5 -5
  117. package/dist/{markers-B0hYLvMD.js → markers-CiwAOZtO.js} +6 -2
  118. package/dist/{may-use-DndQ5tQ-.js → may-use-BOn_dR_w.js} +4 -3
  119. package/dist/mcp/index.d.ts +26 -9
  120. package/dist/mcp/index.js +456 -446
  121. package/dist/{rls-migrate-CN4TlJTO.js → migrate-BwlB5-Wk.js} +75 -15
  122. package/dist/nest/index.d.ts +4 -4
  123. package/dist/nest/index.js +11 -12
  124. package/dist/next/index.d.ts +31 -8
  125. package/dist/next/index.js +29 -33
  126. package/dist/next/plugin.d.ts +1 -1
  127. package/dist/next/plugin.js +1 -1
  128. package/dist/node/index.d.ts +4 -4
  129. package/dist/node/index.js +4 -4
  130. package/dist/ocsf-uYFXGVw2.js +115 -0
  131. package/dist/openai/index.d.ts +5 -5
  132. package/dist/openai/index.js +4 -4
  133. package/dist/openapi/index.d.ts +3 -3
  134. package/dist/openapi/index.js +1 -1
  135. package/dist/{openapi-CqqEbHsL.js → openapi-BJdBmYDG.js} +19 -23
  136. package/dist/{openapi-BqRBvAng.js → openapi-DBzHQbov.js} +2 -5
  137. package/dist/{openapi-CQTsgKoB.js → openapi-DcQ1Kg40.js} +3 -3
  138. package/dist/orpc/index.d.ts +5 -5
  139. package/dist/orpc/index.js +9 -11
  140. package/dist/otel/index.d.ts +2 -2
  141. package/dist/otel/index.js +26 -23
  142. package/dist/output-files-CgIsvdSa.js +140 -0
  143. package/dist/{rls-ownership-DcYlZ09B.js → ownership-BgnbOJFT.js} +387 -379
  144. package/dist/{package-root-zGkxO3oN.js → package-root-DtNnpmUd.js} +3 -2
  145. package/dist/{parse-BuyjxhZV.js → parse-CVFQHk6c.js} +3 -3
  146. package/dist/{parse-local-manifest-BrMozJCo.js → parse-local-manifest-C-q02Pal.js} +2 -4
  147. package/dist/{parse-local-manifest-JLnaBH0S.d.ts → parse-local-manifest-DvYUR0QL.d.ts} +1 -1
  148. package/dist/pdp/index.d.ts +2 -2
  149. package/dist/pdp/index.js +8 -9
  150. package/dist/{permdock-CbgvLnuo.js → permdock-L26udHSk.js} +1387 -1220
  151. package/dist/{rls-fields-CZOMlwHl.js → permission-keys-B26jeyUv.js} +1268 -2053
  152. package/dist/permission-registry-BsblpB-z.js +385 -0
  153. package/dist/{permissions-DttnqqxC.d.ts → permission-types-Dg39z9Kv.d.ts} +59 -31
  154. package/dist/{permissions-RJrovw98.js → permissions-CCJ6lmxB.js} +3 -3
  155. package/dist/{permissions-CDgvKG5L.d.ts → permissions-COH-KRgT.d.ts} +2 -2
  156. package/dist/{policy-IB6yxpC3.d.ts → policy-types-sp9P1iIV.d.ts} +661 -582
  157. package/dist/{policy-D2W7uv19.d.ts → policy-ur0BBK_e.d.ts} +2 -2
  158. package/dist/{powersync-DE19b9dT.js → powersync-BFSbSElQ.js} +2 -2
  159. package/dist/powersync-DCDgZgfZ.js +2 -0
  160. package/dist/{powersync-Dv1_aWF7.js → powersync-cZe4kzhL.js} +26 -27
  161. package/dist/prisma/index.d.ts +1 -1
  162. package/dist/prisma/index.js +6 -12
  163. package/dist/{problem-B43ztKIm.js → problem-CnWraVhC.js} +8 -7
  164. package/dist/{problem-details-_AMOYz-w.js → problem-details-DECUnXAn.js} +2 -2
  165. package/dist/{problem-details-DX075l9V.d.ts → problem-details-rIIo8B2C.d.ts} +1 -1
  166. package/dist/{protected-BdnIEFkY.d.ts → protected-B3_P7xuw.d.ts} +9 -6
  167. package/dist/{protected-utU-SLuy.js → protected-BN7BUdY1.js} +20 -8
  168. package/dist/{provider-CSQd7m92.js → provider-Bi-0HNL3.js} +23 -10
  169. package/dist/{provider-DZY281jO.d.ts → provider-kwHC9CZD.d.ts} +1 -1
  170. package/dist/{provider-store-Cfbvo4DE.js → provider-store-Ctt-81Ni.js} +6 -3
  171. package/dist/react/index.d.ts +7 -7
  172. package/dist/react/index.js +5 -5
  173. package/dist/react/provider-client.d.ts +1 -1
  174. package/dist/react/provider-client.js +1 -1
  175. package/dist/react-native/index.d.ts +20 -11
  176. package/dist/react-native/index.js +33 -17
  177. package/dist/{refs-KYb4ntaz.js → refs-f3imMjNW.js} +1 -1
  178. package/dist/relation-walk-BXnlLtg2.js +186 -0
  179. package/dist/relations-CvmSpG67.js +163 -0
  180. package/dist/{replay-CYyiLiwO.d.ts → replay-COpmZUfx.d.ts} +1 -1
  181. package/dist/request-context-BVM7aWNs.js +71 -0
  182. package/dist/request-context-C2_1lchh.d.ts +5 -0
  183. package/dist/resource-relations-D1Un3pcz.js +243 -0
  184. package/dist/retire-BFcxL6un.js +240 -0
  185. package/dist/{rls-P-BeBx0n.js → rls-55DQTuf5.js} +14 -2
  186. package/dist/{rls-DiinlRML.js → rls-BEktUaqg.js} +884 -484
  187. package/dist/{policy-xyWg7QdR.js → role-builder-B4GbKM-i.js} +235 -541
  188. package/dist/{rpc-DL9Sqvb1.js → rpc-nYC3cR_u.js} +15 -5
  189. package/dist/{run-BWc9qqvE.js → run-DMcNW_8T.js} +3 -3
  190. package/dist/{runtime-CB8gQFvS.js → runtime-D_tMXnsq.js} +1 -1
  191. package/dist/{saas-DhpJjnBA.js → saas-DtaA4JuW.js} +9 -8
  192. package/dist/{openapi-schema--ARjyfQr.js → schema-Bol6gqXA.js} +3 -5
  193. package/dist/{schema-D3MnDMxa.js → schema-DjQBcAP9.js} +4 -2
  194. package/dist/scim/index.d.ts +1 -1
  195. package/dist/scim/index.js +1 -1
  196. package/dist/{scim-BFGBBAqR.js → scim-vFR1O5oG.js} +6 -12
  197. package/dist/{scopes-CVdPrWN-.js → scopes-tvpa34ep.js} +10 -2
  198. package/dist/server/index.d.ts +18 -8
  199. package/dist/server/index.js +8 -8
  200. package/dist/{server-DlZ28Oz5.js → server-ZYEHtNHS.js} +4 -4
  201. package/dist/{create-B1d519XK.d.ts → server-types-DdqBwZN_.d.ts} +69 -33
  202. package/dist/shared-1uhI-e-b.js +294 -0
  203. package/dist/{shared-DRu8VFVM.js → shared-JhMeOsDF.js} +1 -1
  204. package/dist/{sink-Bd9PSyfq.js → sink-BTtmfPnE.js} +1 -1
  205. package/dist/{sink-B1fZzIMf.d.ts → sink-CPN4zLfs.d.ts} +1 -1
  206. package/dist/{skills-Biq5uup3.js → skills-BZdRQkxs.js} +4 -3
  207. package/dist/{skills-C5CbhhpG.js → skills-Dle4ZoLF.js} +2 -2
  208. package/dist/{snapshot-Enxd0n-s.js → snapshot-Dc9CHPME.js} +116 -13
  209. package/dist/{snapshot-cache-D6jLelln.js → snapshot-cache-Cod40D-X.js} +1 -1
  210. package/dist/{snapshot-cache-B-LxUahj.d.ts → snapshot-cache-J5T7t_vD.d.ts} +1 -1
  211. package/dist/solid/index.d.ts +22 -22
  212. package/dist/solid/index.js +40 -10
  213. package/dist/{sources-4p0-4xQm.js → sources-B1-b-R0t.js} +25 -26
  214. package/dist/{sources-BdOYLw9j.d.ts → sources-Dljy06zL.d.ts} +6 -2
  215. package/dist/{sql-xdg5f4Fi.js → sql-t8teWOfo.js} +19 -3
  216. package/dist/{src-BDwEZWrZ.js → src-Bb7no-hS.js} +194 -123
  217. package/dist/ssf/index.d.ts +3 -3
  218. package/dist/ssf/index.js +58 -61
  219. package/dist/store-9KO4BlkB.d.ts +147 -0
  220. package/dist/{store-DMAWwAJV.js → store-ILkLUj_o.js} +4 -4
  221. package/dist/{store-options-ByhZq1jV.js → store-options-CbUHDoSe.js} +16 -7
  222. package/dist/{stores-BT2pSCub.js → stores-BHXdSbw9.js} +7 -3
  223. package/dist/stores-Cxz_80g-.d.ts +31 -0
  224. package/dist/{stream-DDpvynSB.js → stream-BMui98KK.js} +2 -1
  225. package/dist/{stream-D1RXubw2.d.ts → stream-Dwsg6WwE.d.ts} +2 -2
  226. package/dist/{subject-settings-BwBmCdTR.js → subject-settings-CkEwrw3W.js} +23 -5
  227. package/dist/supabase/index.d.ts +4 -4
  228. package/dist/supabase/index.js +3 -3
  229. package/dist/supabase/middleware.d.ts +11 -5
  230. package/dist/supabase/middleware.js +10 -7
  231. package/dist/{supabase-C0qESOa-.js → supabase-C1TWlnYt.js} +36 -52
  232. package/dist/{supabase-s4o9s1O1.js → supabase-Dbqr141s.js} +2 -2
  233. package/dist/supabase-hook-BULg7Ut_.js +2 -0
  234. package/dist/{supabase-hook-ntETYCQu.js → supabase-hook-Cva3ikXz.js} +730 -781
  235. package/dist/{supautils-u8jXTGrt.js → supautils-B6HYL9eL.js} +2 -2
  236. package/dist/svelte/Protected.svelte +9 -2
  237. package/dist/svelte/index.d.ts +6 -6
  238. package/dist/svelte/index.js +25 -11
  239. package/dist/svelte/runtime.d.ts +10 -3
  240. package/dist/svelte/runtime.js +4 -3
  241. package/dist/svelte/source.d.ts +6 -6
  242. package/dist/svelte/source.js +4 -4
  243. package/dist/{validity-uOp8UpYn.js → tenancy-DshjqY0n.js} +3 -39
  244. package/dist/terminal/index.d.ts +5 -5
  245. package/dist/terminal/index.js +18 -34
  246. package/dist/testing/index.d.ts +89 -77
  247. package/dist/testing/index.js +1276 -1262
  248. package/dist/testing/saas/index.d.ts +4 -4
  249. package/dist/testing/saas/index.js +2 -2
  250. package/dist/testing/saas/permissions.d.ts +1 -1
  251. package/dist/testing/saas/permissions.js +1 -1
  252. package/dist/thenable-QSmvt-vZ.js +65 -0
  253. package/dist/{token-CIWxJOCh.js → token-Bx9qy30p.js} +1 -1
  254. package/dist/tool-refusal-CQ7OEia9.js +41 -0
  255. package/dist/trpc/index.d.ts +5 -5
  256. package/dist/trpc/index.js +7 -8
  257. package/dist/{types-DbjRN55U.d.ts → types-7rJVLWe5.d.ts} +82 -4
  258. package/dist/{types-aqOHTHcp.d.ts → types-Br9IXUBG.d.ts} +1 -1
  259. package/dist/types-ByUo56un.d.ts +88 -0
  260. package/dist/{types-Cq_H8N_X.d.ts → types-C0dee0Qf.d.ts} +2 -2
  261. package/dist/{types-DxiCGmmd.d.ts → types-CIlTojhq.d.ts} +2 -2
  262. package/dist/{types-QCuYJh4q.d.ts → types-CUcFZfpU.d.ts} +1 -1
  263. package/dist/{types-C97IskBw.d.ts → types-CqrjB9o6.d.ts} +1 -1
  264. package/dist/{types-BnIEz1sU.d.ts → types-DHrmBJLH.d.ts} +24 -6
  265. package/dist/{types-Dnemwd77.d.ts → types-DpWfQdSh.d.ts} +5 -1
  266. package/dist/{types-Bvc4oWT6.d.ts → types-DvupZE0w.d.ts} +1 -1
  267. package/dist/unplugin/index.d.ts +1 -1
  268. package/dist/unplugin/index.js +1 -1
  269. package/dist/{usage-B0YuTQRO.js → usage-4G6t643F.js} +2 -2
  270. package/dist/{usage-ItS7nLcl.js → usage-CG9nOYZw.js} +7 -7
  271. package/dist/usage-iFLJ0-rr.js +2 -0
  272. package/dist/{validation-error-Ba264OaJ.d.ts → validation-error-BSSw0l_8.d.ts} +1 -1
  273. package/dist/{validation-error-CnjZ4t92.js → validation-error-ZfUHbKvf.js} +1 -1
  274. package/dist/validity-dVrUEPJt.js +62 -0
  275. package/dist/{verifier-BxBo6I44.js → verifier-DMr_Zmb_.js} +51 -15
  276. package/dist/{rls-verify-CMv9H3wV.js → verify-BztUB3GX.js} +668 -239
  277. package/dist/{version-BvacVTZR.js → version-BEogC-rB.js} +1 -1
  278. package/dist/{views-Soe7bGSC.js → views-CJsrBS1f.js} +23 -1
  279. package/dist/{vocabulary-DA8a8zif.d.ts → vocabulary-hhEFLFoL.d.ts} +15 -6
  280. package/dist/vue/index.d.ts +24 -19
  281. package/dist/vue/index.js +24 -8
  282. package/dist/watch-C8TpsAl4.js +2 -0
  283. package/dist/{watch-DVBJ9cBq.js → watch-zeucB7eF.js} +6 -6
  284. package/dist/webmcp/index.d.ts +2 -2
  285. package/dist/webmcp/index.js +13 -37
  286. package/dist/wrap-Cr93qqdP.d.ts +14 -0
  287. package/dist/wrap-DWsU_5Bd.js +26 -0
  288. package/package.json +8 -8
  289. package/schemas/catalog-v1.json +6 -0
  290. package/skills/permdock-credentials/SKILL.md +1 -1
  291. package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
  292. package/skills/permdock-data/references/queries-and-rls.md +4 -0
  293. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -0
  294. package/skills/permdock-wire/SKILL.md +2 -2
  295. package/skills/permdock-wire/references/adapters.md +9 -1
  296. package/skills/permdock-wire/references/policy-options.md +10 -1
  297. package/dist/catalog-CRW5Mx_B.js +0 -2
  298. package/dist/collect-DSWOk19R.js +0 -2
  299. package/dist/create-CMwIl-w2.js +0 -253
  300. package/dist/delegation-D8pUEuce.js +0 -103
  301. package/dist/doctor-DvH0IQff.js +0 -1194
  302. package/dist/doctor-collect-CjdO0wQX.js +0 -665
  303. package/dist/evaluation-items-CfCCejQd.js +0 -40
  304. package/dist/fields-BMl1RxoX.js +0 -26
  305. package/dist/grantee-Cv5Sogfv.js +0 -602
  306. package/dist/hosted-DJQw46hn.js +0 -266
  307. package/dist/instance-options-Dhhcnm3y.js +0 -22
  308. package/dist/load-DwJUafYN.js +0 -2
  309. package/dist/map-AcxK9o_D.js +0 -147
  310. package/dist/permissions-DVoF6dMt.js +0 -662
  311. package/dist/powersync-CrBX8hY6.js +0 -2
  312. package/dist/protected-xAr24FEC.d.ts +0 -40
  313. package/dist/relations-cjOL01hZ.js +0 -505
  314. package/dist/rls-graph-CHwx0V8q.js +0 -435
  315. package/dist/rls-shared-Cewd_-zI.js +0 -495
  316. package/dist/store-jOBYpiXC.d.ts +0 -36
  317. package/dist/stores-C0IMQrGI.d.ts +0 -52
  318. package/dist/supabase-config-Bj3iDH2I.js +0 -472
  319. package/dist/supabase-hook-gd3s8bxB.js +0 -2
  320. package/dist/thenable-okc2xDsj.js +0 -10
  321. package/dist/types-CKNSyIf_.d.ts +0 -52
  322. package/dist/usage-DorAJiU_.js +0 -2
  323. package/dist/watch-BwxLTYMZ.js +0 -2
@@ -1,8 +1,8 @@
1
- import { t as compact } from "./compact-y6vfu2_f.js";
2
- import { c as rowIdOf, n as parseSnapshot } from "./snapshot-Enxd0n-s.js";
3
- import { u as nowSeconds } from "./validity-uOp8UpYn.js";
4
- import { n as payloadDigest } from "./token-CIWxJOCh.js";
5
- import { n as fromSnapshot, t as emptySnapshot } from "./from-snapshot-CTLijvdm.js";
1
+ import { t as compact } from "./compact-CAf557ZB.js";
2
+ import { f as rowIdOf, n as parseSnapshot } from "./snapshot-Dc9CHPME.js";
3
+ import { c as nowSeconds } from "./tenancy-DshjqY0n.js";
4
+ import { n as payloadDigest } from "./token-Bx9qy30p.js";
5
+ import { n as fromSnapshot, t as emptySnapshot } from "./from-snapshot-7REQZe0H.js";
6
6
  import { t as timeoutSignal } from "./timeout-D51niuQP.js";
7
7
  //#region src/client/approvals.ts
8
8
  /** Ceiling for the approval poll backoff after a failed status request. */
@@ -692,6 +692,14 @@ function hintOnce() {
692
692
  console.info(`PermDock: ${permission.key} needs the server (a closure, graph relation or period grant) and endpoint is false, so it is denied with reason server-only; check it on the server instead`);
693
693
  };
694
694
  }
695
+ /** Runs both hooks: the one the adapter needs first, then the provider option. */
696
+ function both(first, second) {
697
+ if (first === void 0 || second === void 0) return first ?? second;
698
+ return (...args) => {
699
+ first(...args);
700
+ second(...args);
701
+ };
702
+ }
695
703
  function adapterStore(options, snapshot, native) {
696
704
  return createClientStore(compact({
697
705
  snapshot,
@@ -708,8 +716,9 @@ function adapterStore(options, snapshot, native) {
708
716
  passCache: options.passCache,
709
717
  server: native?.server,
710
718
  stale: native?.stale,
711
- onSnapshot: native?.onSnapshot,
712
- onClear: native?.onClear
719
+ onSnapshot: both(native?.onSnapshot, options.onSnapshot),
720
+ onClear: both(native?.onClear, options.onClear),
721
+ approvalInterval: options.approvalInterval
713
722
  }));
714
723
  }
715
724
  //#endregion
@@ -1,5 +1,5 @@
1
- import { c as subjectView, i as permissionSet, l as tenantView, n as filterResult, o as rolesView, r as livePermDock, t as approvalHandle } from "./views-Soe7bGSC.js";
2
- import { n as providePermDock, t as getStore } from "./context-Bcy85rGi.js";
1
+ import { a as permissionSet, d as tenantView, i as livePermDock, n as describeWith, r as filterResult, s as rolesView, t as approvalHandle, u as subjectView } from "./views-CJsrBS1f.js";
2
+ import { n as getUi, r as providePermDock, t as getStore } from "./context-DieZVJXu.js";
3
3
  import { readable, toStore } from "svelte/store";
4
4
  //#region src/svelte/stores.ts
5
5
  function fromStore(store, compute) {
@@ -23,6 +23,10 @@ function setPermDock(options) {
23
23
  function getPermDock() {
24
24
  return sveltePermDock(getStore());
25
25
  }
26
+ /** `describe` with the provider's `messages`; a call's own `messages` win. Call it during component init. */
27
+ function getDescribe() {
28
+ return describeWith(getUi().messages);
29
+ }
26
30
  function permission(reference, data) {
27
31
  return permissionFor(getStore(), reference, data);
28
32
  }
@@ -84,4 +88,4 @@ function approvalFor(store, decision) {
84
88
  return fromStore(store, () => approvalHandle(store, decision()));
85
89
  }
86
90
  //#endregion
87
- export { getPermDock as a, permissions as c, subject as d, tenant as f, filtered as i, roles as l, assignable as n, memberships as o, assignablePermissions as r, permission as s, approval as t, setPermDock as u };
91
+ export { getDescribe as a, permission as c, setPermDock as d, subject as f, filtered as i, permissions as l, assignable as n, getPermDock as o, tenant as p, assignablePermissions as r, memberships as s, approval as t, roles as u };
@@ -0,0 +1,31 @@
1
+ import { Dr as Membership, ir as Decision } from "./policy-types-sp9P1iIV.js";
2
+ import { d as Permission } from "./permission-types-Dg39z9Kv.js";
3
+ import { r as Role } from "./vocabulary-hhEFLFoL.js";
4
+ import { r as DescribeOptions, t as DecisionDescription } from "./describe-C3ldA9os.js";
5
+ import { a as ClientPermDock, c as PermissionSet, d as SubjectView, f as TenantView, l as PermissionState, p as UseRolesOptions, r as ApprovalHandle, s as FilterResult } from "./store-9KO4BlkB.js";
6
+ import { n as PermDockSvelteOptions } from "./types-ByUo56un.js";
7
+ import { Readable } from "svelte/store";
8
+ //#region src/svelte/stores.d.ts
9
+ declare function setPermDock(options: PermDockSvelteOptions): ClientPermDock;
10
+ declare function getPermDock(): ClientPermDock;
11
+ /** `describe` with the provider's `messages`; a call's own `messages` win. Call it during component init. */
12
+ declare function getDescribe(): (decision: Decision, options?: DescribeOptions) => DecisionDescription;
13
+ declare function permission(reference: Permission, data?: () => unknown): Readable<PermissionState>;
14
+ declare function permissions(references: () => readonly Permission[], data?: () => unknown): Readable<PermissionSet>;
15
+ declare function filtered<T>(reference: Permission<string, T, "instance">, rows: () => readonly T[]): Readable<FilterResult<T>>;
16
+ declare function tenant(): Readable<TenantView>;
17
+ declare function memberships(): Readable<readonly Membership[]>;
18
+ declare function roles(options?: () => UseRolesOptions): Readable<{
19
+ readonly roles: readonly Role[];
20
+ }>;
21
+ declare function assignable(): Readable<readonly Role[]>;
22
+ type AssignableOptions = {
23
+ readonly tenant?: string;
24
+ } | (() => {
25
+ readonly tenant?: string;
26
+ });
27
+ declare function assignablePermissions(options?: AssignableOptions): Readable<readonly Permission[]>;
28
+ declare function subject(): Readable<SubjectView>;
29
+ declare function approval(decision: () => Decision): Readable<ApprovalHandle>;
30
+ //#endregion
31
+ export { getDescribe as a, permission as c, setPermDock as d, subject as f, filtered as i, permissions as l, assignable as n, getPermDock as o, tenant as p, assignablePermissions as r, memberships as s, approval as t, roles as u };
@@ -1,4 +1,4 @@
1
- import { r as PermDockRevokedError } from "./errors-Cz5zn0mW.js";
1
+ import { r as PermDockRevokedError } from "./errors-drnfxYtm.js";
2
2
  //#region src/server/stream.ts
3
3
  function isAsyncIterable(value) {
4
4
  return value !== null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
@@ -22,6 +22,7 @@ async function* guardIterable(source, connection, options) {
22
22
  const next = await Promise.race([iterator.next(), aborted]);
23
23
  if (next.done === true) return next.value;
24
24
  const row = options.unwrap === void 0 ? next.value : options.unwrap(next.value);
25
+ await Promise.race([connection.settled(), aborted]);
25
26
  if (options.items === void 0 || connection.check(options.items, row).outcome === "granted") yield next.value;
26
27
  }
27
28
  } catch (error) {
@@ -1,5 +1,5 @@
1
- import { f as Permission } from "./permissions-DttnqqxC.js";
2
- import { i as ProtectOptions } from "./create-B1d519XK.js";
1
+ import { d as Permission } from "./permission-types-Dg39z9Kv.js";
2
+ import { o as ProtectOptions } from "./server-types-DdqBwZN_.js";
3
3
  //#region src/server/stream.d.ts
4
4
  type StreamProtectOptions = ProtectOptions & {
5
5
  /**
@@ -1,3 +1,20 @@
1
+ import { r as isRecord } from "./compact-CAf557ZB.js";
2
+ //#region src/conditions/peer.ts
3
+ /**
4
+ * Requires an optional peer through `node:module`. Feature-detected so the
5
+ * entry loads on runtimes without a Node module loader; there the caller
6
+ * injects the peer and `message` names the option that does it.
7
+ */
8
+ function loadPeer(id, message) {
9
+ const loader = globalThis.process?.getBuiltinModule?.("node:module");
10
+ try {
11
+ if (loader === void 0) throw new Error("no module loader");
12
+ return loader.createRequire(import.meta.url)(id);
13
+ } catch {
14
+ throw new Error(message);
15
+ }
16
+ }
17
+ //#endregion
1
18
  //#region src/conditions/row-check.ts
2
19
  const MISSING = Object.freeze({ found: false });
3
20
  const GRANTED = Object.freeze({
@@ -24,9 +41,6 @@ function settingName(name, what) {
24
41
  if (!NAME.test(name)) throw new Error(`PermDock: unsafe ${what} '${name}'`);
25
42
  return name;
26
43
  }
27
- function isRecord(value) {
28
- return typeof value === "object" && value !== null && !Array.isArray(value);
29
- }
30
44
  function strings(value) {
31
45
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
32
46
  }
@@ -120,9 +134,13 @@ function statementText(statement) {
120
134
  for (const [index, part] of statement.strings.entries()) text = index === 0 ? part : `${text}$${String(index)}${part}`;
121
135
  return text;
122
136
  }
137
+ /** Strings as a template-strings array, for calling a `sql` tag directly. */
138
+ function templateOf(parts) {
139
+ return Object.assign([...parts], { raw: [...parts] });
140
+ }
123
141
  /** A statement as a template-strings array, for `sql` tags. */
124
142
  function statementTemplate(statement) {
125
- return Object.assign([...statement.strings], { raw: [...statement.strings] });
143
+ return templateOf(statement.strings);
126
144
  }
127
145
  //#endregion
128
- export { rowCheckOf as a, rowCheckFrom as i, statementText as n, subjectStatements as r, statementTemplate as t };
146
+ export { rowCheckFrom as a, templateOf as i, statementText as n, rowCheckOf as o, subjectStatements as r, loadPeer as s, statementTemplate as t };
@@ -1,8 +1,8 @@
1
- import { C as Policy, Dr as CustomRole, Mr as Membership, Pr as Subject, gt as MembershipSource, mt as MemberEntry, xt as RoleSource } from "../policy-IB6yxpC3.js";
2
- import { c as ApprovalRequest, f as ApprovalStore } from "../types-aqOHTHcp.js";
3
- import { C as SupabaseClaimsSchema, E as supabaseClaims, S as SupabaseClaimsOptions, T as SupabasePermDockClaims, _ as SupabaseSuspendedMembership, a as SupabaseActorResult, b as SupabaseActClaim, c as SupabaseMembershipTable, d as SupabaseRealtime, f as SupabaseRlsConfig, g as SupabaseSubjectOptions, h as SupabaseStorage, i as SupabaseActor, l as SupabasePermissionRef, m as SupabaseSessionLike, n as RoleThrough, o as SupabaseDelegation, p as SupabaseRlsOptions, r as SupabaseActiveRow, s as SupabaseInclude, t as AuthorizeSqlOptions, u as SupabasePrincipal, v as SupabaseSuspendedScope, w as SupabaseMembershipClaim, x as SupabaseClaims, y as SupabaseSuspension } from "../types-C97IskBw.js";
1
+ import { Dr as Membership, E as Policy, Sr as CustomRole, X as MemberEntry, Z as MembershipSource, kr as Subject, nt as RoleSource } from "../policy-types-sp9P1iIV.js";
2
+ import { c as ApprovalRequest, f as ApprovalStore } from "../types-Br9IXUBG.js";
3
+ import { C as SupabaseClaimsSchema, E as supabaseClaims, S as SupabaseClaimsOptions, T as SupabasePermDockClaims, _ as SupabaseSuspendedMembership, a as SupabaseActorResult, b as SupabaseActClaim, c as SupabaseMembershipTable, d as SupabaseRealtime, f as SupabaseRlsConfig, g as SupabaseSubjectOptions, h as SupabaseStorage, i as SupabaseActor, l as SupabasePermissionRef, m as SupabaseSessionLike, n as RoleThrough, o as SupabaseDelegation, p as SupabaseRlsOptions, r as SupabaseActiveRow, s as SupabaseInclude, t as AuthorizeSqlOptions, u as SupabasePrincipal, v as SupabaseSuspendedScope, w as SupabaseMembershipClaim, x as SupabaseClaims, y as SupabaseSuspension } from "../types-CqrjB9o6.js";
4
4
  import { a as SupabaseManifestHelper, c as SupabaseManifestRls, d as SupabaseManifestValue, f as parseSupabaseManifest, i as SupabaseManifestColumn, l as SupabaseManifestRole, n as SupabaseHookManifest, o as SupabaseManifestMembership, r as SupabaseManifestActiveRow, s as SupabaseManifestRequires, t as SupabaseHookClaim, u as SupabaseManifestThrough } from "../manifest-uDS9y5de.js";
5
- import { a as MembershipTableOptions, c as SupabasePostgres, d as fromSupabasePostgres, f as fromTable, i as MembershipSql, l as authzVersion, n as MembershipHolders, o as SqlMembershipSource, r as MembershipJunctionOptions, s as SqlQuery, t as AUTHZ_VERSION_TABLE, u as fromJunction } from "../sources-BdOYLw9j.js";
5
+ import { a as MembershipTableOptions, c as SupabasePostgres, d as fromSupabasePostgres, f as fromTable, i as MembershipSql, l as authzVersion, n as MembershipHolders, o as SqlMembershipSource, r as MembershipJunctionOptions, s as SqlQuery, t as AUTHZ_VERSION_TABLE, u as fromJunction } from "../sources-Dljy06zL.js";
6
6
  import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-JqcRqyhK.js";
7
7
  //#region src/supabase/capability.d.ts
8
8
  type ExchangeCapabilityOptions = {
@@ -1,5 +1,5 @@
1
- import { a as readSubjectRecord, i as postgrestSources, n as supabaseRls, o as supabaseClaims, r as supabaseApprovalStore, s as exchangeCapability, t as authorizeSql } from "../supabase-C0qESOa-.js";
1
+ import { a as readSubjectRecord, i as postgrestSources, n as supabaseRls, o as supabaseClaims, r as supabaseApprovalStore, s as exchangeCapability, t as authorizeSql } from "../supabase-C1TWlnYt.js";
2
2
  import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-NbEtbJC_.js";
3
- import { a as fromJunction, i as authzVersion, o as fromSupabasePostgres, s as fromTable, t as AUTHZ_VERSION_TABLE } from "../sources-4p0-4xQm.js";
4
- import { a as subjectFromSupabase, n as actorOf, o as subjectFromSupabaseSession, r as delegationOf, t as parseSupabaseManifest } from "../manifest-iaoBXHKc.js";
3
+ import { a as fromJunction, i as authzVersion, o as fromSupabasePostgres, s as fromTable, t as AUTHZ_VERSION_TABLE } from "../sources-B1-b-R0t.js";
4
+ import { a as subjectFromSupabase, n as actorOf, o as subjectFromSupabaseSession, r as delegationOf, t as parseSupabaseManifest } from "../manifest-BngWKryL.js";
5
5
  export { AUTHZ_VERSION_TABLE, actorOf, authorizeSql, authzVersion, delegationOf, exchangeCapability, fromJunction, fromSupabasePostgres, fromTable, parseSupabaseManifest, postgrestSources, readSubjectRecord, subjectFromSupabase, subjectFromSupabaseSession, supabaseApprovalStore, supabaseClaims, supabaseMembershipsBudget, supabaseRls, supabaseTenantClaim };
@@ -1,8 +1,9 @@
1
- import { C as Policy, D as PolicyVocabulary, Nr as Principal, Pr as Subject, ln as PermDock } from "../policy-IB6yxpC3.js";
2
- import { f as Permission } from "../permissions-DttnqqxC.js";
3
- import { t as InstanceOptions } from "../instance-options-jARdwfPN.js";
4
- import { n as OpenApiHooks } from "../create-B1d519XK.js";
5
- import { n as ServerAdapterServices } from "../bind-C_ob3LKa.js";
1
+ import { E as Policy, Or as Principal, j as PolicyVocabulary, jt as PermDock, kr as Subject } from "../policy-types-sp9P1iIV.js";
2
+ import { d as Permission } from "../permission-types-Dg39z9Kv.js";
3
+ import { t as InstanceOptions } from "../instance-options-plkrsAog.js";
4
+ import { t as RequestContext } from "../request-context-C2_1lchh.js";
5
+ import { i as OpenApiHooks } from "../server-types-DdqBwZN_.js";
6
+ import { n as ServerAdapterServices } from "../bind-BzqG8SMb.js";
6
7
  import { Middleware } from "@supabase/middleware";
7
8
  //#region src/supabase/middleware.d.ts
8
9
  /**
@@ -52,6 +53,11 @@ export type SupabaseMiddlewarePermDockOptions<TUser = unknown> = InstanceOptions
52
53
  readonly secretKeys?: Readonly<Record<string, SupabaseSecretKey>>;
53
54
  readonly subject: (ctx: SupabaseMiddlewareContext, request: Request) => TUser | Subject | null | Promise<TUser | Subject | null>;
54
55
  readonly tenant?: string | ((ctx: SupabaseMiddlewareContext, request: Request) => string | undefined | Promise<string | undefined>);
56
+ /**
57
+ * Request values merged into `subject.context`, under `policy.context`.
58
+ * Only values the server derived belong here, never client input.
59
+ */
60
+ readonly context?: (ctx: SupabaseMiddlewareContext, request: Request) => RequestContext | undefined | Promise<RequestContext | undefined>;
55
61
  };
56
62
  export type WithPermDockConfig = {
57
63
  /** Run `protect` before the handler; a denial short-circuits with Problem Details. */
@@ -1,9 +1,10 @@
1
- import { t as compact } from "../compact-y6vfu2_f.js";
2
- import { r as credentialSubject } from "../credential-8P81ff4u.js";
3
- import { i as methodNotAllowed } from "../problem-B43ztKIm.js";
4
- import { t as instanceOptions } from "../instance-options-Dhhcnm3y.js";
5
- import { n as createServerKernel } from "../create-CMwIl-w2.js";
6
- import { n as attached } from "../bind-CuzGytRf.js";
1
+ import { t as compact } from "../compact-CAf557ZB.js";
2
+ import { t as composeWraps } from "../wrap-DWsU_5Bd.js";
3
+ import { r as credentialSubject } from "../credential-kue0qpbm.js";
4
+ import { a as methodNotAllowed } from "../problem-CnWraVhC.js";
5
+ import { r as instanceOptions } from "../build-instance-DIIV9DbC.js";
6
+ import { n as createServerKernel } from "../create-BBO24vj6.js";
7
+ import { n as attached } from "../bind-kk-uyCwH.js";
7
8
  import { defineMiddleware } from "@supabase/middleware";
8
9
  //#region src/supabase/middleware.ts
9
10
  const SECRET_KEY_NAME = /^[A-Za-z0-9_-]+$/u;
@@ -53,12 +54,14 @@ function createPermDock(policy, options) {
53
54
  return secretKeySubject(secretKeys, ctx) ?? options.subject(ctx, request);
54
55
  },
55
56
  tenant: typeof tenantOption === "function" ? (request) => tenantOption(contextFor(request), request) : tenantOption,
57
+ context: options.context === void 0 ? void 0 : (request) => options.context?.(contextFor(request), request),
56
58
  ...instanceOptions(options),
57
59
  store: options.store,
58
60
  pdp: options.pdp,
59
61
  webBotAuth: options.webBotAuth,
60
62
  adapter: "supabase-middleware",
61
- wrap: options.otel
63
+ wrap: composeWraps(options.otel, options.wrap),
64
+ onDenied: options.onDenied
62
65
  }));
63
66
  const bind = (request, ctx) => {
64
67
  contexts.set(request, ctx);
@@ -1,13 +1,13 @@
1
- import { t as compact } from "./compact-y6vfu2_f.js";
2
- import { t as canonicalJson } from "./canonical-json-DemiK4Vp.js";
3
- import { o as parseCapability } from "./capability-4qPdO9gk.js";
1
+ import { r as isRecord, t as compact } from "./compact-CAf557ZB.js";
2
+ import { t as canonicalJson } from "./canonical-json-CFKyFOke.js";
3
+ import { o as parseCapability } from "./capability-txATtKV4.js";
4
4
  import { t as ApprovalError } from "./errors-DRnGZHzF.js";
5
- import { a as decodeApprovalCursor, i as approvalPageSize, o as encodeApprovalCursor, t as applyApprovalVerdict } from "./store-DMAWwAJV.js";
5
+ import { a as decodeApprovalCursor, i as approvalPageSize, o as encodeApprovalCursor, t as applyApprovalVerdict } from "./store-ILkLUj_o.js";
6
6
  import { t as loadJose } from "./load-jose-BL6LH4bL.js";
7
7
  import "./budget-NbEtbJC_.js";
8
- import { a as quoteSqlTable, i as quoteSqlLiteral, r as quoteSqlIdent } from "./sql-xdg5f4Fi.js";
9
- import { c as hookApiNames, d as keptKeys, l as roleColumn } from "./sources-4p0-4xQm.js";
10
- import { i as readMemberships } from "./manifest-iaoBXHKc.js";
8
+ import { a as quoteSqlIdent, i as quoteQualifiedTable, l as sqlTextArray, o as quoteSqlLiteral, r as qualifySqlTable, s as quoteSqlTable } from "./sql-t8teWOfo.js";
9
+ import { c as hookApiNames, d as keptKeys, l as roleColumn } from "./sources-B1-b-R0t.js";
10
+ import { i as readMemberships } from "./manifest-BngWKryL.js";
11
11
  //#region src/supabase/capability.ts
12
12
  const DEFAULT_TTL = 300;
13
13
  const MAX_TTL = 3600;
@@ -63,9 +63,6 @@ const KNOWN = /* @__PURE__ */ new Set([
63
63
  "act",
64
64
  "app_metadata"
65
65
  ]);
66
- function isRecord$2(value) {
67
- return value !== null && typeof value === "object" && !Array.isArray(value);
68
- }
69
66
  function own(record, key) {
70
67
  return Object.hasOwn(record, key) ? record[key] : void 0;
71
68
  }
@@ -84,7 +81,7 @@ function optional(record, key, path, issues, check, expected) {
84
81
  }
85
82
  const isString = (value) => typeof value === "string";
86
83
  function checkMembership(item, path, issues) {
87
- if (!isRecord$2(item)) {
84
+ if (!isRecord(item)) {
88
85
  issue(issues, path, "Expected a membership object");
89
86
  return;
90
87
  }
@@ -99,14 +96,14 @@ function checkMembership(item, path, issues) {
99
96
  "grantedBy",
100
97
  "reason"
101
98
  ]) optional(item, key, path, issues, isString, "a string");
102
- optional(item, "within", path, issues, (value) => isRecord$2(value) && Object.values(value).every((id) => typeof id === "string"), "an object of string ids");
103
- optional(item, "on", path, issues, (value) => isRecord$2(value) && typeof own(value, "resource") === "string" && typeof own(value, "id") === "string", "an object with string resource and id");
99
+ optional(item, "within", path, issues, (value) => isRecord(value) && Object.values(value).every((id) => typeof id === "string"), "an object of string ids");
100
+ optional(item, "on", path, issues, (value) => isRecord(value) && typeof own(value, "resource") === "string" && typeof own(value, "id") === "string", "an object with string resource and id");
104
101
  optional(item, "expiresAt", path, issues, (value) => typeof value === "number" && Number.isFinite(value), "a number of seconds since the epoch");
105
- optional(item, "member", path, issues, (value) => isRecord$2(value) && typeof own(value, "group") === "string" && own(value, "group") !== "", "an object with a non-empty string group");
102
+ optional(item, "member", path, issues, (value) => isRecord(value) && typeof own(value, "group") === "string" && own(value, "group") !== "", "an object with a non-empty string group");
106
103
  optional(item, "managedBy", path, issues, (value) => value === "idp", "'idp'");
107
104
  optional(item, "entitlements", path, issues, isStrings, "an array of strings");
108
105
  optional(item, "keep", path, issues, isStrings, "an array of strings");
109
- optional(item, "grants", path, issues, isRecord$2, "an object");
106
+ optional(item, "grants", path, issues, isRecord, "an object");
110
107
  if (!(own(item, "scope") !== void 0 && own(item, "id") !== void 0 || own(item, "tenant") !== void 0 || own(item, "team") !== void 0 || own(item, "on") !== void 0)) issue(issues, path, "Expected scope and id, tenant, team or on");
111
108
  }
112
109
  function checkPermDockClaims(record, tenantClaim, path, issues) {
@@ -123,7 +120,7 @@ function checkPermDockClaims(record, tenantClaim, path, issues) {
123
120
  }
124
121
  optional(record, "memberships_truncated", path, issues, (value) => typeof value === "boolean", "a boolean");
125
122
  optional(record, tenantClaim, path, issues, isString, "a string");
126
- optional(record, "attrs", path, issues, isRecord$2, "an object");
123
+ optional(record, "attrs", path, issues, isRecord, "an object");
127
124
  optional(record, "authz_ver", path, issues, (value) => Number.isInteger(value), "an integer");
128
125
  }
129
126
  /** The outer level's `kind`: none, `support` with a `session_id`, or `impersonation`. */
@@ -144,7 +141,7 @@ function checkAct(value, issues) {
144
141
  let current = value;
145
142
  const path = ["act"];
146
143
  while (current !== void 0) {
147
- if (!isRecord$2(current)) {
144
+ if (!isRecord(current)) {
148
145
  issue(issues, path, "Expected an object");
149
146
  return;
150
147
  }
@@ -157,7 +154,7 @@ function checkAct(value, issues) {
157
154
  }
158
155
  function checkClaims(value, tenantClaim) {
159
156
  const issues = [];
160
- if (!isRecord$2(value)) {
157
+ if (!isRecord(value)) {
161
158
  issue(issues, [], "Expected a claims object");
162
159
  return issues;
163
160
  }
@@ -168,7 +165,7 @@ function checkClaims(value, tenantClaim) {
168
165
  if (act !== void 0) checkAct(act, issues);
169
166
  const meta = own(value, "app_metadata");
170
167
  if (meta !== void 0) {
171
- if (isRecord$2(meta)) checkPermDockClaims(meta, tenantClaim, ["app_metadata"], issues);
168
+ if (isRecord(meta)) checkPermDockClaims(meta, tenantClaim, ["app_metadata"], issues);
172
169
  else issue(issues, ["app_metadata"], "Expected an object");
173
170
  }
174
171
  return issues;
@@ -178,8 +175,8 @@ function merge(base, app) {
178
175
  if (issues.length > 0) return { issues };
179
176
  const baseValue = base.value;
180
177
  const appValue = app.value;
181
- if (!isRecord$2(appValue)) return { issues: [{ message: "Expected the extension to output an object" }] };
182
- return { value: isRecord$2(baseValue) ? {
178
+ if (!isRecord(appValue)) return { issues: [{ message: "Expected the extension to output an object" }] };
179
+ return { value: isRecord(baseValue) ? {
183
180
  ...baseValue,
184
181
  ...appValue
185
182
  } : appValue };
@@ -192,9 +189,9 @@ function schemaOf(validate) {
192
189
  validate
193
190
  }),
194
191
  extend(app) {
195
- if (!isRecord$2(app) && typeof app !== "function") throw new TypeError("PermDock: supabaseClaims().extend needs a Standard Schema");
192
+ if (!isRecord(app) && typeof app !== "function") throw new TypeError("PermDock: supabaseClaims().extend needs a Standard Schema");
196
193
  const props = Reflect.get(app, "~standard");
197
- if (!isRecord$2(props) || typeof props["validate"] !== "function") throw new TypeError("PermDock: supabaseClaims().extend needs a Standard Schema");
194
+ if (!isRecord(props) || typeof props["validate"] !== "function") throw new TypeError("PermDock: supabaseClaims().extend needs a Standard Schema");
198
195
  const run = app["~standard"].validate.bind(app["~standard"]);
199
196
  return schemaOf((value) => {
200
197
  const base = validate(value);
@@ -229,14 +226,11 @@ function supabaseClaims(options = {}) {
229
226
  function callRpc(client, schema, fn, args) {
230
227
  return client.schema(schema).rpc(fn, args);
231
228
  }
232
- function isRecord$1(value) {
233
- return value !== null && typeof value === "object" && !Array.isArray(value);
234
- }
235
229
  function strings(value) {
236
230
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
237
231
  }
238
232
  function grantOf(value) {
239
- if (!isRecord$1(value) || typeof value["permission"] !== "string") return;
233
+ if (!isRecord(value) || typeof value["permission"] !== "string") return;
240
234
  return compact({
241
235
  permission: value["permission"],
242
236
  effect: value["effect"] === "deny" ? "deny" : "allow",
@@ -244,7 +238,7 @@ function grantOf(value) {
244
238
  });
245
239
  }
246
240
  function customRoleOf(value) {
247
- if (!isRecord$1(value) || typeof value["name"] !== "string") return;
241
+ if (!isRecord(value) || typeof value["name"] !== "string") return;
248
242
  const grants = Array.isArray(value["grants"]) ? value["grants"].flatMap((item) => {
249
243
  const grant = grantOf(item);
250
244
  return grant === void 0 ? [] : [grant];
@@ -270,7 +264,7 @@ function customRoleOf(value) {
270
264
  function readMemberEntries(value) {
271
265
  if (!Array.isArray(value)) return [];
272
266
  return value.flatMap((item) => {
273
- if (!isRecord$1(item) || !isRecord$1(item["principal"])) return [];
267
+ if (!isRecord(item) || !isRecord(item["principal"])) return [];
274
268
  const id = item["principal"]["id"];
275
269
  const [membership] = readMemberships([item["membership"]]).memberships;
276
270
  return typeof id === "string" && id !== "" && membership !== void 0 ? [{
@@ -285,7 +279,7 @@ function versionOf(value) {
285
279
  }
286
280
  /** Reads `subject_for`'s JSON; anything it cannot read is left out, and a malformed record is no record. */
287
281
  function readSubjectRecord(value) {
288
- if (!isRecord$1(value) || typeof value["id"] !== "string") return;
282
+ if (!isRecord(value) || typeof value["id"] !== "string") return;
289
283
  if (value["active"] !== true) return {
290
284
  id: value["id"],
291
285
  active: false,
@@ -410,9 +404,6 @@ function postgrestSources(client, options = {}) {
410
404
  }
411
405
  //#endregion
412
406
  //#region src/supabase/approval-store.ts
413
- function isRecord(value) {
414
- return value !== null && typeof value === "object" && !Array.isArray(value);
415
- }
416
407
  /** A stored body as the request it is; the store wrote it from an `ApprovalRequest`. */
417
408
  function requestOf(value) {
418
409
  if (!isRecord(value) || value["v"] !== 1 || typeof value["token"] !== "string") return null;
@@ -527,30 +518,23 @@ function supabaseRls(options = {}) {
527
518
  });
528
519
  }
529
520
  const ident = (name) => quoteSqlIdent(name);
530
- const table = (name) => quoteSqlTable(name);
531
521
  const literal = quoteSqlLiteral;
532
- function qualifiedTable(name) {
533
- return table(name.includes(".") ? name : `public.${name}`);
534
- }
535
522
  /** The memberships table's role key over alias `m`, joined to its roles table when it holds a reference. */
536
523
  function tenantRole(memberships) {
537
- return roleColumn(memberships.role, memberships.table.includes(".") ? memberships.table : `public.${memberships.table}`, "m", {
524
+ return roleColumn(memberships.role, qualifySqlTable(memberships.table), "m", {
538
525
  label: "authorizeSql tenant.role",
539
526
  indent: " "
540
527
  });
541
528
  }
542
- function textArray(values) {
543
- return values.length === 0 ? `'{}'::text[]` : `array[${values.map(literal).join(", ")}]::text[]`;
544
- }
545
529
  function activeRow(row, id, text = false) {
546
530
  const parts = [`s.${ident(row.id)}${text ? "::text" : ""} = ${id}`];
547
531
  if (row.disabledAt !== void 0) parts.push(`s.${ident(row.disabledAt)} is null`);
548
532
  if (row.status !== void 0) {
549
533
  if (row.active === void 0 || row.active.length === 0) throw new TypeError("PermDock: a suspension status column needs its active values");
550
- parts.push(`s.${ident(row.status)}::text = any(${textArray(row.active)})`);
534
+ parts.push(`s.${ident(row.status)}::text = any(${sqlTextArray(row.active)})`);
551
535
  }
552
536
  if (row.disabledAt === void 0 && row.status === void 0) throw new TypeError("PermDock: a suspension table needs disabledAt or status");
553
- return `exists (select 1 from ${qualifiedTable(row.table)} s where ${parts.join(" and ")})`;
537
+ return `exists (select 1 from ${quoteQualifiedTable(row.table)} s where ${parts.join(" and ")})`;
554
538
  }
555
539
  /**
556
540
  * Early `return false` for a suspended user, or a tenant request for a
@@ -565,7 +549,7 @@ function suspendedGuards(suspension, scope, uid) {
565
549
  const tenant = suspension?.scopes?.[scope];
566
550
  if (tenant !== void 0) {
567
551
  const keep = keptKeys(tenant);
568
- const kept = keep.length === 0 ? "" : ` and not (requested_permission::text = any(${textArray(keep)}))`;
552
+ const kept = keep.length === 0 ? "" : ` and not (requested_permission::text = any(${sqlTextArray(keep)}))`;
569
553
  lines.push(` if requested_tenant is not null and not ${activeRow(tenant, "requested_tenant", true)}${kept} then
570
554
  return false; -- suspended ${scope}
571
555
  end if;`);
@@ -594,7 +578,7 @@ function disabledLine(memberships, suspension) {
594
578
  if (memberships.disabledAt === void 0) return "";
595
579
  const column = `m.${ident(memberships.disabledAt)}`;
596
580
  const keep = keptKeys(suspension?.memberships);
597
- return keep.length === 0 ? `\n and ${column} is null` : `\n and (${column} is null or requested_permission::text = any(${textArray(keep)}))`;
581
+ return keep.length === 0 ? `\n and ${column} is null` : `\n and (${column} is null or requested_permission::text = any(${sqlTextArray(keep)}))`;
598
582
  }
599
583
  function claimKept(suspension) {
600
584
  return keptKeys(suspension?.memberships).length === 0 ? "" : `\n and case coalesce(jsonb_typeof(m -> 'keep'), 'null') when 'null' then true when 'array' then m -> 'keep' @> jsonb_build_array(requested_permission::text) else false end`;
@@ -605,10 +589,10 @@ function customDatabaseBranch(q, scope, memberships, declared, levels, suspensio
605
589
  const rows = (source, value, extra) => `array(select c.${value} from ${q(source)} c where ${match}${extra})`;
606
590
  return ` or exists (
607
591
  select 1
608
- from ${qualifiedTable(memberships.table)} m${role.join}
592
+ from ${quoteQualifiedTable(memberships.table)} m${role.join}
609
593
  where m.${ident(memberships.user)} = v_member_user
610
594
  and m.${ident(memberships.tenant)} = v_member_tenant
611
- and not (${role.sql} = any(${textArray(declared)}))${memberships.expiresAt === void 0 ? "" : `\n and (m.${ident(memberships.expiresAt)} is null or m.${ident(memberships.expiresAt)} > now())`}${disabledLine(memberships, suspension)}
595
+ and not (${role.sql} = any(${sqlTextArray(declared)}))${memberships.expiresAt === void 0 ? "" : `\n and (m.${ident(memberships.expiresAt)} is null or m.${ident(memberships.expiresAt)} > now())`}${disabledLine(memberships, suspension)}
612
596
  and ${customHolds(q, scope, rows("custom_role_permissions", levels ? "permission || coalesce('@' || c.level, '')" : "permission", " and c.effect = 'allow'"), rows("custom_role_permissions", "permission", " and c.effect = 'deny'"), rows("custom_role_includes", "include_role", ""))}
613
597
  )`;
614
598
  }
@@ -638,7 +622,7 @@ function databaseBody(q, scope, memberships, custom, suspension) {
638
622
  const role = tenantRole(memberships);
639
623
  const held = (effect) => `exists (
640
624
  select 1
641
- from ${qualifiedTable(memberships.table)} m${role.join}
625
+ from ${quoteQualifiedTable(memberships.table)} m${role.join}
642
626
  join ${q("role_permissions")} rp on rp.role = ${role.sql}
643
627
  where m.${ident(memberships.user)} = v_member_user
644
628
  and m.${ident(tenantColumn)} = v_member_tenant
@@ -661,8 +645,8 @@ function databaseBody(q, scope, memberships, custom, suspension) {
661
645
  }
662
646
  return `declare
663
647
  uid uuid := (select auth.uid());${memberships !== void 0 && tenantColumn !== void 0 ? `
664
- v_member_user ${qualifiedTable(memberships.table)}.${ident(memberships.user)}%type;
665
- v_member_tenant ${qualifiedTable(memberships.table)}.${ident(tenantColumn)}%type;` : ""}
648
+ v_member_user ${quoteQualifiedTable(memberships.table)}.${ident(memberships.user)}%type;
649
+ v_member_tenant ${quoteQualifiedTable(memberships.table)}.${ident(tenantColumn)}%type;` : ""}
666
650
  begin
667
651
  if uid is null then
668
652
  return false;
@@ -695,7 +679,7 @@ function jwtBody(q, scope, custom, suspension) {
695
679
  and m ->> 'id' = requested_tenant
696
680
  and ${CLAIM_UNEXPIRED}${claimKept(suspension)}
697
681
  and jsonb_typeof(cg.g) = 'array'
698
- and not (r.role = any(${textArray(custom.declared)}))
682
+ and not (r.role = any(${sqlTextArray(custom.declared)}))
699
683
  and ${customHolds(q, scope, claimEntries("left(e, 1) not in ('-', '@')", "e"), claimEntries("left(e, 1) = '-'", "substr(e, 2)"), claimEntries("left(e, 1) = '@'", "substr(e, 2)"))}
700
684
  )`;
701
685
  const held = (effect) => `exists (
@@ -750,7 +734,7 @@ end;`;
750
734
  */
751
735
  function authorizeSql(options = {}) {
752
736
  const schema = options.schema ?? "permdock";
753
- const q = (name) => table(`${schema}.${name}`);
737
+ const q = (name) => quoteSqlTable(`${schema}.${name}`);
754
738
  const memberships = typeof options.tenant === "object" ? options.tenant : void 0;
755
739
  const scope = options.scope ?? "tenant";
756
740
  if (!/^[a-z][a-z0-9_]*$/u.test(scope)) throw new TypeError(`PermDock: unsafe scope name '${scope}'`);
@@ -1,4 +1,4 @@
1
- import { i as globalArgs, s as stringArg, t as COMMAND_DESCRIPTIONS } from "./commands-BeaGNj_o.js";
1
+ import { i as globalArgs, s as stringArg, t as COMMAND_DESCRIPTIONS } from "./commands-Cpip4ULx.js";
2
2
  import { defineCommand } from "citty";
3
3
  //#region src/cli/commands/supabase.ts
4
4
  function supabase(ctx) {
@@ -61,7 +61,7 @@ function supabase(ctx) {
61
61
  const budget = stringArg(parsed.budget);
62
62
  const schema = stringArg(parsed.schema);
63
63
  const grantsOut = stringArg(parsed["grants-out"]);
64
- const { runSupabase } = await import("./supabase-hook-gd3s8bxB.js");
64
+ const { runSupabase } = await import("./supabase-hook-BULg7Ut_.js");
65
65
  ctx.report(await runSupabase({
66
66
  cwd: ctx.cwd,
67
67
  config: ctx.config,
@@ -0,0 +1,2 @@
1
+ import { i as runSupabase } from "./supabase-hook-Cva3ikXz.js";
2
+ export { runSupabase };