permdock 0.1.0 → 0.3.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 (350) hide show
  1. package/README.md +106 -47
  2. package/dist/a2a/index.d.ts +7 -16
  3. package/dist/a2a/index.js +59 -98
  4. package/dist/adapter-context-mlWsVGGg.js +23 -0
  5. package/dist/ai-sdk/index.d.ts +37 -16
  6. package/dist/ai-sdk/index.js +30 -13
  7. package/dist/approvals/index.d.ts +3 -3
  8. package/dist/approvals/index.js +5 -4
  9. package/dist/{approvals-DaxY-Bdg.js → approvals-DbYAuNkG.js} +17 -11
  10. package/dist/approvers-DT4AVyIg.js +52 -0
  11. package/dist/{arazzo-CTeVuXr5.js → arazzo-BAgw9ap6.js} +2 -2
  12. package/dist/{arazzo-aoTkqYsJ.js → arazzo-CKwwqFWz.js} +2 -2
  13. package/dist/authzen/index.d.ts +4 -13
  14. package/dist/authzen/index.js +16 -50
  15. package/dist/better-auth/index.d.ts +20 -3
  16. package/dist/better-auth/index.js +27 -7
  17. package/dist/better-supabase/index.d.ts +223 -0
  18. package/dist/better-supabase/index.js +648 -0
  19. package/dist/bind-C_ob3LKa.d.ts +25 -0
  20. package/dist/bind-CuzGytRf.js +97 -0
  21. package/dist/boundary-BM8a_P6E.js +13 -0
  22. package/dist/boundary-BmHxVH1J.d.ts +15 -0
  23. package/dist/canonical-json-DemiK4Vp.js +26 -0
  24. package/dist/{capability-BDG_nkxt.d.ts → capability-2kYTMWDv.d.ts} +2 -2
  25. package/dist/{capability-B68OFnZx.js → capability-4qPdO9gk.js} +7 -5
  26. package/dist/catalog/index.d.ts +1 -1
  27. package/dist/catalog/index.js +1 -1
  28. package/dist/catalog-CRW5Mx_B.js +2 -0
  29. package/dist/{catalog-H-vFGwWK.js → catalog-DWF5cYqB.js} +4 -4
  30. package/dist/{catalog-B0E6bggc.js → catalog-dFZdWCGN.js} +2 -2
  31. package/dist/{catalog-doc-BSo_Q_-6.js → catalog-doc-DdGm82XT.js} +20 -32
  32. package/dist/claude-agent/index.d.ts +5 -14
  33. package/dist/claude-agent/index.js +4 -10
  34. package/dist/clerk/index.d.ts +12 -3
  35. package/dist/clerk/index.js +26 -5
  36. package/dist/cli/bin.js +1 -1
  37. package/dist/cli/index.d.ts +3 -3
  38. package/dist/cli/index.js +2 -2
  39. package/dist/clients-C7zLFuWT.d.ts +12 -0
  40. package/dist/clients-DjU5ABMy.js +23 -0
  41. package/dist/cloud/index.d.ts +4 -5
  42. package/dist/cloud/index.js +20 -6
  43. package/dist/{cloud-BNQTrmrr.js → cloud-CB_ELYuX.js} +2 -2
  44. package/dist/{cloud-Cuxr6Czw.js → cloud-DWLXO2af.js} +7 -6
  45. package/dist/collect-DClJsheJ.js +83 -0
  46. package/dist/{collect-O-tOtbnk.js → collect-DSTE3ml9.js} +194 -42
  47. package/dist/collect-DSWOk19R.js +2 -0
  48. package/dist/{commands-BMh_Etm2.js → commands-DSxCqG9A.js} +16 -12
  49. package/dist/compile/index.d.ts +3 -0
  50. package/dist/compile/index.js +2 -0
  51. package/dist/{compile-D22iwvuV.js → compile-Ba4blROR.js} +85 -30
  52. package/dist/compile-BkRyBDBw.d.ts +94 -0
  53. package/dist/config-BJiM-xAm.js +157 -0
  54. package/dist/config-Dnszbv-6.js +36 -0
  55. package/dist/config-report-DMvWKUxL.js +44 -0
  56. package/dist/{connection-JvqwHODC.js → connection-CU8MQxRi.js} +1 -1
  57. package/dist/{context-CKEAabd7.js → context-Bcy85rGi.js} +36 -27
  58. package/dist/convex/index.d.ts +9 -4
  59. package/dist/convex/index.js +14 -4
  60. package/dist/create-B1d519XK.d.ts +245 -0
  61. package/dist/create-CMwIl-w2.js +253 -0
  62. package/dist/{credential-B_rkUNlY.js → credential-8P81ff4u.js} +26 -46
  63. package/dist/delegation-D8pUEuce.js +103 -0
  64. package/dist/{describe-Bt1YD5uS.js → describe-B_gVZEVi.js} +10 -15
  65. package/dist/{describe-DernyItf.d.ts → describe-DMYiCjJV.d.ts} +9 -10
  66. package/dist/{diff-x5Il8LVa.js → diff-2VaeChzX.js} +44 -11
  67. package/dist/{diff-BUzf5Poi.js → diff-DBIhz_f2.js} +2 -2
  68. package/dist/{doctor-Bqo6FwUa.js → doctor-BwCAMLx_.js} +2 -2
  69. package/dist/doctor-collect-CHk6XWOA.js +665 -0
  70. package/dist/doctor-igIiM_Hl.js +1194 -0
  71. package/dist/drizzle/index.d.ts +4 -3
  72. package/dist/drizzle/index.js +3 -3
  73. package/dist/elysia/index.d.ts +6 -28
  74. package/dist/elysia/index.js +16 -60
  75. package/dist/{errors-DSMnAVNa.js → errors-CWfoNg9N.js} +8 -4
  76. package/dist/{errors-Iy71s7Oj.js → errors-Cz5zn0mW.js} +17 -71
  77. package/dist/{errors-DbZ1YOnb.d.ts → errors-DPdqI50v.d.ts} +8 -21
  78. package/dist/{errors-m3u9TmDu.js → errors-DRnGZHzF.js} +4 -1
  79. package/dist/evaluation-items-CfCCejQd.js +40 -0
  80. package/dist/{evaluations-DsAU9ppl.js → evaluations-tz6D9A2G.js} +28 -46
  81. package/dist/eve/index.d.ts +6 -15
  82. package/dist/eve/index.js +7 -12
  83. package/dist/expiry-BoBJ8Tvc.js +7 -0
  84. package/dist/express/index.d.ts +6 -29
  85. package/dist/express/index.js +28 -58
  86. package/dist/fastify/index.d.ts +6 -29
  87. package/dist/fastify/index.js +16 -65
  88. package/dist/fields-BMl1RxoX.js +26 -0
  89. package/dist/{files-B_wAGYmt.js → files-DWUN9PzI.js} +5 -1
  90. package/dist/{fixtures-Cvaw0gDG.js → fixtures-ht28Cplr.js} +5 -2
  91. package/dist/{freeze-y1_jQL4v.js → freeze-CrU8nQeX.js} +31 -2
  92. package/dist/{from-snapshot-BMGnhmgv.js → from-snapshot-CTLijvdm.js} +66 -48
  93. package/dist/{grantee-Bv04_Vzf.js → grantee-Cv5Sogfv.js} +88 -7
  94. package/dist/graph-sql-B-dsAT6j.d.ts +29 -0
  95. package/dist/{headers-B5RRv3Xm.js → headers-BZSDieNT.js} +1 -1
  96. package/dist/{headers-C8SHQccD.d.ts → headers-Cf-zWvsO.d.ts} +1 -1
  97. package/dist/helpers-H_KARDVC.js +421 -0
  98. package/dist/hono/index.d.ts +6 -28
  99. package/dist/hono/index.js +11 -43
  100. package/dist/{hosted-BwKQ1BTA.js → hosted-DJQw46hn.js} +6 -5
  101. package/dist/{http-GgVApX1k.js → http-BIhmLfCc.js} +4 -20
  102. package/dist/http-SO7qGttf.js +44 -0
  103. package/dist/ids-DC4V4CFu.js +18 -0
  104. package/dist/index-0nNqHspG.d.ts +6 -0
  105. package/dist/{index-xIxJLwOQ.d.ts → index-BNc7Wer_.d.ts} +75 -7
  106. package/dist/{index-CltcQ4Bf.d.ts → index-C7Tw7MaW.d.ts} +68 -5
  107. package/dist/{index-LF_hS-yn.d.ts → index-C8z4RjQV.d.ts} +1 -1
  108. package/dist/index.d.ts +14 -9
  109. package/dist/index.js +22 -17
  110. package/dist/instance-options-Dhhcnm3y.js +22 -0
  111. package/dist/instance-options-jARdwfPN.d.ts +11 -0
  112. package/dist/{parse-DPfIvFMU.js → json-schema-BsAflUGW.js} +28 -57
  113. package/dist/jwt/index.d.ts +10 -6
  114. package/dist/jwt/index.js +32 -13
  115. package/dist/kernel-_RRHmnMY.js +208 -0
  116. package/dist/kysely/index.d.ts +4 -3
  117. package/dist/kysely/index.js +3 -3
  118. package/dist/live-options-H2eG8dfJ.js +60 -0
  119. package/dist/{load-BZ24CpZP.js → load-DhWEB9P1.js} +16 -10
  120. package/dist/load-DwJUafYN.js +2 -0
  121. package/dist/manifest-iaoBXHKc.js +783 -0
  122. package/dist/manifest-uDS9y5de.d.ts +206 -0
  123. package/dist/{map-DowSO96j.js → map-AcxK9o_D.js} +4 -15
  124. package/dist/{map-claims-B_6I1Rn-.js → map-claims-Z4QZOiFF.js} +13 -4
  125. package/dist/map-error-pgUWNNtG.js +23 -0
  126. package/dist/may-use-DndQ5tQ-.js +77 -0
  127. package/dist/mcp/index.d.ts +54 -22
  128. package/dist/mcp/index.js +218 -178
  129. package/dist/nest/index.d.ts +26 -31
  130. package/dist/nest/index.js +75 -84
  131. package/dist/next/client.d.ts +7 -8
  132. package/dist/next/client.js +11 -9
  133. package/dist/next/index.d.ts +30 -47
  134. package/dist/next/index.js +45 -60
  135. package/dist/next/plugin.d.ts +1 -1
  136. package/dist/next/plugin.js +32 -1
  137. package/dist/node/index.d.ts +9 -28
  138. package/dist/node/index.js +11 -43
  139. package/dist/openai/index.d.ts +6 -15
  140. package/dist/openai/index.js +7 -20
  141. package/dist/openapi/index.d.ts +87 -4
  142. package/dist/openapi/index.js +3 -3
  143. package/dist/{openapi-DcqM8nU7.js → openapi-BqRBvAng.js} +237 -5
  144. package/dist/{openapi-DWD0Uc_4.js → openapi-CqqEbHsL.js} +5 -5
  145. package/dist/{openapi-import-BWRUNNeW.js → openapi-import-cmwetbzw.js} +1 -1
  146. package/dist/{openapi-CwePaF7C.js → openapi-l0xYHkcv.js} +3 -3
  147. package/dist/{openapi-schema-D8j_T9tO.js → openapi-schema--ARjyfQr.js} +2 -2
  148. package/dist/orpc/index.d.ts +15 -28
  149. package/dist/orpc/index.js +74 -117
  150. package/dist/otel/index.d.ts +2 -2
  151. package/dist/parse-BuyjxhZV.js +53 -0
  152. package/dist/parse-local-manifest-BrMozJCo.js +36 -0
  153. package/dist/parse-local-manifest-JLnaBH0S.d.ts +10 -0
  154. package/dist/pdp/index.d.ts +2 -2
  155. package/dist/pdp/index.js +14 -127
  156. package/dist/{permdock-yoZ7EjxX.js → permdock-CbgvLnuo.js} +672 -149
  157. package/dist/{permissions-B8vCg_bI.d.ts → permissions-CDgvKG5L.d.ts} +2 -2
  158. package/dist/{permissions-DC7GROPA.js → permissions-DVoF6dMt.js} +77 -15
  159. package/dist/{permissions-B4apnahQ.d.ts → permissions-DttnqqxC.d.ts} +34 -5
  160. package/dist/{permissions-CofRqesP.js → permissions-RJrovw98.js} +3 -3
  161. package/dist/{pins-CqE1jZuF.js → pins-8ILTftC9.js} +2 -2
  162. package/dist/{policy-Cq2fB8Q5.d.ts → policy-D2W7uv19.d.ts} +2 -2
  163. package/dist/{policy-CInmNGkM.d.ts → policy-IB6yxpC3.d.ts} +351 -42
  164. package/dist/{policy-ANp36PnI.js → policy-xyWg7QdR.js} +173 -22
  165. package/dist/powersync-BylawD_U.js +540 -0
  166. package/dist/powersync-DliZK_-y.js +62 -0
  167. package/dist/powersync-e_AZrKbg.js +2 -0
  168. package/dist/prisma/index.d.ts +3 -2
  169. package/dist/prisma/index.js +45 -20
  170. package/dist/{problem-Cgp9-KZA.js → problem-B43ztKIm.js} +74 -109
  171. package/dist/problem-details-DX075l9V.d.ts +7 -0
  172. package/dist/problem-details-_AMOYz-w.js +144 -0
  173. package/dist/{protected-BuPAycJT.d.ts → protected-BdnIEFkY.d.ts} +5 -4
  174. package/dist/protected-utU-SLuy.js +100 -0
  175. package/dist/protected-xAr24FEC.d.ts +40 -0
  176. package/dist/provider-CSQd7m92.js +52 -0
  177. package/dist/{provider-wTAUda2v.d.ts → provider-DZY281jO.d.ts} +1 -1
  178. package/dist/provider-store-Cfbvo4DE.js +43 -0
  179. package/dist/react/index.d.ts +7 -5
  180. package/dist/react/index.js +5 -4
  181. package/dist/react/provider-client.d.ts +1 -1
  182. package/dist/react/provider-client.js +1 -1
  183. package/dist/react-native/index.d.ts +166 -10
  184. package/dist/react-native/index.js +607 -85
  185. package/dist/{refs-ChLSxbST.js → refs-KYb4ntaz.js} +4 -3
  186. package/dist/{relations-r4soIFZB.js → relations-cjOL01hZ.js} +110 -31
  187. package/dist/replay-BsOyTrdV.js +28 -0
  188. package/dist/replay-CYyiLiwO.d.ts +5 -0
  189. package/dist/resource-ref-CaS9yVPi.js +20 -0
  190. package/dist/revocations-Bhr0aMIC.js +27 -0
  191. package/dist/{rls-BOFU3chG.js → rls-B4ur8nKQ.js} +8 -3
  192. package/dist/rls-DQtdgTHB.js +2521 -0
  193. package/dist/rls-fields-74oZPXWL.js +3582 -0
  194. package/dist/{rls-graph-DxQ39PJj.js → rls-graph-CHwx0V8q.js} +100 -36
  195. package/dist/{rls-import-CXV6LBlS.js → rls-import-BTFVk3jH.js} +7 -6
  196. package/dist/{rls-migrate-DrFPbf8p.js → rls-migrate-CN4TlJTO.js} +6 -5
  197. package/dist/rls-ownership-RuFqaqGz.js +843 -0
  198. package/dist/rls-shared-Cewd_-zI.js +495 -0
  199. package/dist/rls-verify-CVQTHTh5.js +746 -0
  200. package/dist/{row-check-BajTgQZ-.d.ts → row-check-Dt35czLy.d.ts} +12 -15
  201. package/dist/row-conditions-h2HythXQ.js +27 -0
  202. package/dist/rpc-DL9Sqvb1.js +89 -0
  203. package/dist/{run-CJ6UvS3a.js → run-DKDbM4Du.js} +31 -12
  204. package/dist/runtime-CB8gQFvS.js +11 -0
  205. package/dist/{saas-BRrZzJkM.js → saas-DhpJjnBA.js} +17 -7
  206. package/dist/{schema-P8yoma__.js → schema-D3MnDMxa.js} +8 -4
  207. package/dist/scim/index.d.ts +1 -1
  208. package/dist/scim/index.js +1 -1
  209. package/dist/{scim-9NFa0XVZ.js → scim-BFGBBAqR.js} +1 -1
  210. package/dist/{scopes-cKVp_WTw.js → scopes-CVdPrWN-.js} +35 -8
  211. package/dist/server/index.d.ts +22 -11
  212. package/dist/server/index.js +11 -8
  213. package/dist/{credentials-BgRX3WEg.js → server-DlZ28Oz5.js} +1 -1
  214. package/dist/shared-DRu8VFVM.js +123 -0
  215. package/dist/{sink-Cfr9-7YC.d.ts → sink-B1fZzIMf.d.ts} +1 -1
  216. package/dist/skills-Biq5uup3.js +192 -0
  217. package/dist/{skills-C_lpV4Jx.js → skills-Bx-U0irG.js} +10 -4
  218. package/dist/{snapshot-DE8dE_hz.js → snapshot-Enxd0n-s.js} +138 -214
  219. package/dist/snapshot-cache-B-LxUahj.d.ts +45 -0
  220. package/dist/snapshot-cache-D6jLelln.js +44 -0
  221. package/dist/solid/index.d.ts +39 -9
  222. package/dist/solid/index.js +76 -85
  223. package/dist/sources-4p0-4xQm.js +545 -0
  224. package/dist/sources-BdOYLw9j.d.ts +192 -0
  225. package/dist/{sql-Bll1d7y0.js → sql-xdg5f4Fi.js} +6 -1
  226. package/dist/{src-CTNT-PBW.js → src-BDwEZWrZ.js} +149 -11
  227. package/dist/ssf/index.d.ts +3 -2
  228. package/dist/ssf/index.js +3 -29
  229. package/dist/store-DMAWwAJV.js +371 -0
  230. package/dist/{store-Bq90395i.d.ts → store-jOBYpiXC.d.ts} +13 -4
  231. package/dist/store-options-ByhZq1jV.js +716 -0
  232. package/dist/{stores-CkG2HrSg.js → stores-BT2pSCub.js} +10 -63
  233. package/dist/{stores-CvOnu_2T.d.ts → stores-C0IMQrGI.d.ts} +20 -9
  234. package/dist/{stream-BhMfZOwr.d.ts → stream-D1RXubw2.d.ts} +2 -2
  235. package/dist/{stream-Q_xlB6Ko.js → stream-DDpvynSB.js} +16 -2
  236. package/dist/subject-settings-BwBmCdTR.js +128 -0
  237. package/dist/supabase/index.d.ts +133 -6
  238. package/dist/supabase/index.js +4 -3
  239. package/dist/supabase/middleware.d.ts +32 -27
  240. package/dist/supabase/middleware.js +56 -22
  241. package/dist/{supabase-D8UlBA7Z.js → supabase-Boqb9a_Y.js} +3 -3
  242. package/dist/{supabase-DTxGtYdi.js → supabase-C0qESOa-.js} +347 -367
  243. package/dist/supabase-config-BpPXt3x1.js +472 -0
  244. package/dist/supabase-hook-6sYLXg_u.js +2 -0
  245. package/dist/{supabase-hook-D_OqGb_V.js → supabase-hook-CSLQ4zJ3.js} +1037 -705
  246. package/dist/supautils-Cn4R4cJ4.js +91 -0
  247. package/dist/svelte/PermissionBoundary.svelte +37 -0
  248. package/dist/svelte/Protected.svelte +8 -2
  249. package/dist/svelte/index.d.ts +9 -6
  250. package/dist/svelte/index.js +61 -7
  251. package/dist/svelte/runtime.d.ts +4 -3
  252. package/dist/svelte/runtime.js +4 -3
  253. package/dist/svelte/source.d.ts +9 -6
  254. package/dist/svelte/source.js +7 -4
  255. package/dist/terminal/index.d.ts +6 -14
  256. package/dist/terminal/index.js +44 -32
  257. package/dist/testing/index.d.ts +105 -16
  258. package/dist/testing/index.js +504 -40
  259. package/dist/testing/saas/index.d.ts +4 -4
  260. package/dist/testing/saas/index.js +2 -2
  261. package/dist/testing/saas/permissions.d.ts +1 -1
  262. package/dist/testing/saas/permissions.js +1 -1
  263. package/dist/token-CIWxJOCh.js +50 -0
  264. package/dist/trpc/index.d.ts +7 -26
  265. package/dist/trpc/index.js +17 -100
  266. package/dist/types-BnIEz1sU.d.ts +48 -0
  267. package/dist/{types-CxquUByI.d.ts → types-Bvc4oWT6.d.ts} +1 -1
  268. package/dist/{sources-DOpW5Ila.d.ts → types-C97IskBw.d.ts} +86 -127
  269. package/dist/types-CKNSyIf_.d.ts +52 -0
  270. package/dist/types-Cq_H8N_X.d.ts +197 -0
  271. package/dist/{types-D6Z6-rKJ.d.ts → types-DbjRN55U.d.ts} +273 -22
  272. package/dist/{types-BBK-exvJ.d.ts → types-Dnemwd77.d.ts} +7 -1
  273. package/dist/{types-BvBk1wgn.d.ts → types-DxiCGmmd.d.ts} +5 -3
  274. package/dist/{types-B9dmiiab.d.ts → types-QCuYJh4q.d.ts} +1 -1
  275. package/dist/{types-B8w5PFtS.d.ts → types-aqOHTHcp.d.ts} +17 -1
  276. package/dist/unplugin/index.d.ts +1 -1
  277. package/dist/unplugin/index.js +10 -9
  278. package/dist/usage-DorAJiU_.js +2 -0
  279. package/dist/{usage-1ozMubLY.js → usage-GTixvDDU.js} +2 -2
  280. package/dist/{usage-CUnK6Ou9.js → usage-ItS7nLcl.js} +225 -62
  281. package/dist/validation-error-Ba264OaJ.d.ts +26 -0
  282. package/dist/validation-error-CnjZ4t92.js +33 -0
  283. package/dist/{validity-D0uRmJKJ.js → validity-uOp8UpYn.js} +57 -36
  284. package/dist/{verifier-B90agnhl.js → verifier-BxBo6I44.js} +10 -5
  285. package/dist/version-BvacVTZR.js +17 -0
  286. package/dist/views-Soe7bGSC.js +95 -0
  287. package/dist/{vocabulary-Dk0fs-Jk.d.ts → vocabulary-DA8a8zif.d.ts} +1 -1
  288. package/dist/vue/index.d.ts +35 -13
  289. package/dist/vue/index.js +86 -93
  290. package/dist/watch-BwxLTYMZ.js +2 -0
  291. package/dist/watch-DVBJ9cBq.js +128 -0
  292. package/dist/webmcp/index.d.ts +2 -2
  293. package/dist/webmcp/index.js +7 -13
  294. package/package.json +62 -36
  295. package/schemas/approval-request-v1.json +175 -0
  296. package/schemas/catalog-v1.json +29 -1
  297. package/schemas/supabase-claims-v1.json +6 -1
  298. package/schemas/supabase-manifest-v1.json +150 -6
  299. package/skills/permdock/SKILL.md +7 -7
  300. package/skills/permdock-agents/SKILL.md +5 -5
  301. package/skills/permdock-agents/references/runtimes.md +12 -10
  302. package/skills/permdock-approvals/SKILL.md +4 -4
  303. package/skills/permdock-approvals/references/stores-and-resume.md +15 -4
  304. package/skills/permdock-audit/SKILL.md +3 -3
  305. package/skills/permdock-credentials/SKILL.md +4 -4
  306. package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
  307. package/skills/permdock-data/SKILL.md +4 -4
  308. package/skills/permdock-data/references/queries-and-rls.md +14 -6
  309. package/skills/permdock-data/references/relationships.md +5 -3
  310. package/skills/permdock-tenancy/SKILL.md +9 -6
  311. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +14 -8
  312. package/skills/permdock-wire/SKILL.md +4 -4
  313. package/skills/permdock-wire/references/adapters.md +42 -30
  314. package/skills/permdock-wire/references/policy-options.md +5 -3
  315. package/dist/approvers-aH0PJkmf.js +0 -20
  316. package/dist/catalog-idsHc0vo.js +0 -2
  317. package/dist/collect-B7_TIfmg.js +0 -49
  318. package/dist/collect-fRPAQIWb.js +0 -2
  319. package/dist/compile-CQbvyIBr.d.ts +0 -30
  320. package/dist/config-BPYmjTOp.js +0 -26
  321. package/dist/context-gtAwAILx.js +0 -6
  322. package/dist/create-BKF3dgFk.d.ts +0 -162
  323. package/dist/create-CSkhDU9T.js +0 -222
  324. package/dist/doctor-BGle8Gqi.js +0 -1314
  325. package/dist/helpers-DnSOrhB9.js +0 -682
  326. package/dist/index-fG6NSXlc.d.ts +0 -9
  327. package/dist/kernel-YOGCWNLf.js +0 -211
  328. package/dist/load-QOOm1z70.js +0 -2
  329. package/dist/manifest-DDQbC6K0.d.ts +0 -118
  330. package/dist/map-error-RJ3ZsUyA.js +0 -16
  331. package/dist/may-use-CnFEjVEp.js +0 -37
  332. package/dist/pg-4GJWDUxG.js +0 -953
  333. package/dist/plugin-4gr7IxFJ.js +0 -65
  334. package/dist/protected-B4K3BKoX.js +0 -138
  335. package/dist/protected-wY7nXhY9.d.ts +0 -23
  336. package/dist/provider-_wx46HpB.js +0 -48
  337. package/dist/rls-CJVja9Ww.js +0 -2119
  338. package/dist/rls-helpers-BxRuif0l.js +0 -1346
  339. package/dist/runtime-DP9ttFh1.js +0 -27
  340. package/dist/skills-Dx3QLnMY.js +0 -110
  341. package/dist/source-DoBBYJi2.js +0 -6
  342. package/dist/sources-DVHM3Mwq.js +0 -284
  343. package/dist/store-C6hFW6ta.js +0 -508
  344. package/dist/subject-settings-xt7V845g.js +0 -82
  345. package/dist/supabase-hook-DW-xP4hU.js +0 -2
  346. package/dist/types-DbWdEfcm.d.ts +0 -87
  347. package/dist/types-bva3i4Gf.d.ts +0 -98
  348. package/dist/types-i4BAOvdb.d.ts +0 -97
  349. package/dist/usage-PyEor6GA.js +0 -2
  350. package/dist/version-CnSh33Fj.js +0 -16
@@ -1,9 +1,9 @@
1
1
  import { t as compact } from "../compact-y6vfu2_f.js";
2
- import { n as freezeDeep } from "../freeze-y1_jQL4v.js";
3
- import { x as assertSafeKey } from "../permissions-DC7GROPA.js";
4
- import { i as PermDockValidationError } from "../errors-Iy71s7Oj.js";
5
- import { a as relatedRowGuard, l as renderGraphSql, n as escapeLike, s as relatedTargetsSql, t as compileWhere } from "../compile-D22iwvuV.js";
6
- import { a as rowCheckOf, n as statementText, r as subjectStatements } from "../subject-settings-xt7V845g.js";
2
+ import { n as freezeDeep } from "../freeze-CrU8nQeX.js";
3
+ import { w as assertSafeKey } from "../permissions-DVoF6dMt.js";
4
+ import { n as PermDockValidationError } from "../validation-error-CnjZ4t92.js";
5
+ import { a as relatedRowGuard, l as renderGraphSql, n as escapeLike, s as relatedTargetsSql, t as compileWhere, u as restrictedRowsSql } from "../compile-Ba4blROR.js";
6
+ import { a as rowCheckOf, n as statementText, r as subjectStatements } from "../subject-settings-BwBmCdTR.js";
7
7
  //#region src/prisma/to-where.ts
8
8
  function fieldTests(options) {
9
9
  const mapped = (field) => fieldName(field, options.fields);
@@ -129,8 +129,10 @@ function permdockExtension() {
129
129
  query: { $allModels: {
130
130
  findMany: wrap,
131
131
  findFirst: wrap,
132
+ findFirstOrThrow: wrap,
132
133
  count: wrap,
133
134
  aggregate: wrap,
135
+ groupBy: wrap,
134
136
  updateMany: wrap,
135
137
  deleteMany: wrap
136
138
  } }
@@ -349,10 +351,42 @@ async function resolveRelated(where, options) {
349
351
  async function resolveNode(node) {
350
352
  if (resources === void 0) throw refused("related: the where() result carries no resource graph");
351
353
  if (node.ids === void 0 && (subject === void 0 || subject === "")) return NOTHING;
352
- const query = renderGraphSql(relatedTargetsSql(node, {
354
+ const mapping = {
353
355
  ...options.relations,
354
356
  resources
355
- }), {
357
+ };
358
+ const ids = await readIds(relatedTargetsSql(node, mapping), node.field);
359
+ if (ids.length === 0) return NOTHING;
360
+ const reach = {
361
+ op: "in",
362
+ field: node.field,
363
+ value: ids
364
+ };
365
+ const guard = relatedRowGuard(node);
366
+ const conditions = [reach, ...guard === void 0 ? [] : [notRestricted(guard)]];
367
+ const above = node.restrictedAncestors;
368
+ if (above !== void 0) {
369
+ const closed = await readIds(restrictedRowsSql(above, mapping), above.parent);
370
+ if (closed.length > 0) conditions.push({
371
+ op: "or",
372
+ conditions: [{
373
+ op: "isNull",
374
+ field: above.parent,
375
+ value: true
376
+ }, {
377
+ op: "notIn",
378
+ field: above.parent,
379
+ value: closed
380
+ }]
381
+ });
382
+ }
383
+ return conditions.length === 1 ? reach : {
384
+ op: "and",
385
+ conditions
386
+ };
387
+ }
388
+ async function readIds(parts, field) {
389
+ const query = renderGraphSql(parts, {
356
390
  subject: subject ?? "",
357
391
  placeholder: (index) => `$${String(index)}`,
358
392
  /* v8 ignore next 3 */
@@ -360,26 +394,16 @@ async function resolveRelated(where, options) {
360
394
  throw refused(`related: no row column '${name}' in an id query`);
361
395
  }
362
396
  });
363
- const ids = (await options.run({
397
+ return (await options.run({
364
398
  sql: `select distinct r.id from (${query.sql}) r where r.id is not null`,
365
399
  values: query.values
366
400
  })).flatMap((row) => {
367
401
  const id = row["id"];
368
402
  if (typeof id !== "string" && typeof id !== "number") return [];
369
403
  const text = String(id);
370
- const parsed = options.parse === void 0 ? text : options.parse(text, node.field);
404
+ const parsed = options.parse === void 0 ? text : options.parse(text, field);
371
405
  return typeof parsed === "string" || typeof parsed === "number" || typeof parsed === "boolean" ? [parsed] : [];
372
406
  });
373
- const reach = ids.length === 0 ? NOTHING : {
374
- op: "in",
375
- field: node.field,
376
- value: ids
377
- };
378
- const guard = relatedRowGuard(node);
379
- return guard === void 0 || ids.length === 0 ? reach : {
380
- op: "and",
381
- conditions: [reach, notRestricted(guard)]
382
- };
383
407
  }
384
408
  async function resolve(node) {
385
409
  switch (node.op) {
@@ -408,7 +432,8 @@ async function resolveRelated(where, options) {
408
432
  case "notIn":
409
433
  case "isNull":
410
434
  case "memberOf":
411
- case "opaque": return node;
435
+ case "opaque":
436
+ case "liveSession": return node;
412
437
  default: return node;
413
438
  }
414
439
  }
@@ -1,8 +1,8 @@
1
1
  import { t as compact } from "./compact-y6vfu2_f.js";
2
- import { n as requiredPlans } from "./describe-Bt1YD5uS.js";
3
- import { a as approvalMessage, i as PermDockValidationError, n as PermDockDeniedError, o as deniedMessage, t as PermDockApprovalRequiredError } from "./errors-Iy71s7Oj.js";
2
+ import { n as PermDockValidationError, t as PROBLEM_BASE } from "./validation-error-CnjZ4t92.js";
3
+ import { i as stepUpOf, n as problemDetails, t as notFoundDetails } from "./problem-details-_AMOYz-w.js";
4
+ import { a as deniedMessage, i as approvalMessage } from "./errors-Cz5zn0mW.js";
4
5
  //#region src/server/problem.ts
5
- const PROBLEM_BASE = "https://permdock.dev/problems";
6
6
  function quoted(value) {
7
7
  return `"${value.replaceAll(/["\\]/gu, "")}"`;
8
8
  }
@@ -29,28 +29,12 @@ function protectedResourceMetadataUrl(resource) {
29
29
  const path = resource.pathname === "/" ? "" : resource.pathname;
30
30
  return `${resource.origin}/.well-known/oauth-protected-resource${path}`;
31
31
  }
32
- /** The `acr` values and the tightest `maxAge` the failing assurance grants ask for. */
33
- function stepUpOf(decision) {
34
- if (decision.outcome !== "denied") return {};
35
- const acr = /* @__PURE__ */ new Set();
36
- let maxAge;
37
- for (const denial of decision.denials) {
38
- if (denial.reason !== "insufficient-user-authentication") continue;
39
- const grantees = denial.to === void 0 ? [] : Array.isArray(denial.to) ? denial.to : [denial.to];
40
- for (const grantee of grantees) {
41
- if (grantee.kind !== "assurance") continue;
42
- for (const value of grantee.acr ?? []) acr.add(value);
43
- if (grantee.maxAge !== void 0) maxAge = maxAge === void 0 ? grantee.maxAge : Math.min(maxAge, grantee.maxAge);
44
- }
45
- }
46
- return compact({
47
- acrValues: acr.size === 0 ? void 0 : [...acr],
48
- maxAge
49
- });
50
- }
51
32
  /** The `error_description` of every `invalid_token` challenge (RFC 6750 section 3.1). */
52
33
  const INVALID_TOKEN = "The access token is invalid";
53
34
  function wwwAuthenticate(decision, permission, credentials = true) {
35
+ return challengeFor(decision, permission?.scope, credentials);
36
+ }
37
+ function challengeFor(decision, scope, credentials = true) {
54
38
  if (decision.outcome !== "denied") return;
55
39
  const reasons = new Set(decision.denials.map((denial) => denial.reason));
56
40
  if (reasons.has("insufficient-user-authentication")) return bearerChallenge({
@@ -63,7 +47,7 @@ function wwwAuthenticate(decision, permission, credentials = true) {
63
47
  }) : "Bearer";
64
48
  if (reasons.has("not-delegated") || reasons.has("no-delegation")) return bearerChallenge(compact({
65
49
  error: "insufficient_scope",
66
- scopes: permission === void 0 ? void 0 : [permission.scope]
50
+ scopes: scope === void 0 ? void 0 : [scope]
67
51
  }));
68
52
  }
69
53
  function problemResponse(details, permission, decision, extra, credentials) {
@@ -97,12 +81,8 @@ function validationProblem(detail) {
97
81
  detail
98
82
  }));
99
83
  }
100
- function resourceRef(permission, data) {
101
- const id = data !== null && typeof data === "object" && "id" in data ? data.id : void 0;
102
- return compact({
103
- type: permission.resource,
104
- id: typeof id === "string" || typeof id === "number" ? String(id) : void 0
105
- });
84
+ function resourceRef(permission) {
85
+ return { type: permission.resource };
106
86
  }
107
87
  function isLimitDetail(value) {
108
88
  if (value === null || typeof value !== "object") return false;
@@ -133,94 +113,79 @@ function rateLimitHeaders(decision, now = Date.now() / 1e3) {
133
113
  "RateLimit-Policy": entries.map((entry) => `${entry.name};q=${entry.detail.count};w=${entry.detail.window}`).join(", ")
134
114
  };
135
115
  }
136
- /** Reasons that only arise once a matching grant was found, so they reveal nothing hidden. */
137
- const HOLDS_GRANT = /* @__PURE__ */ new Set([
138
- "insufficient-user-authentication",
139
- "limit",
140
- "limit-unavailable"
141
- ]);
116
+ /**
117
+ * The response for a decision's Problem Details: `WWW-Authenticate` for a
118
+ * `401` or a missing delegation, and the rate-limit fields for a `429`. A
119
+ * hidden row's `404` carries neither, so it reads like a missing one.
120
+ */
121
+ function decisionResponse(details, decision, options = {}) {
122
+ const headers = new Headers({
123
+ ...details.status === 429 ? rateLimitHeaders(decision) : {},
124
+ "content-type": "application/problem+json"
125
+ });
126
+ const challenge = details.status === 404 ? void 0 : challengeFor(decision, options.scope, options.credentials);
127
+ if (challenge !== void 0) headers.set("WWW-Authenticate", challenge);
128
+ return new Response(JSON.stringify(details), {
129
+ status: details.status,
130
+ headers
131
+ });
132
+ }
142
133
  function problemFromDecision(decision, permission, subject, options = {}) {
143
- const base = PROBLEM_BASE;
144
134
  if (decision.outcome === "granted") return new Response(null, { status: 204 });
145
- if (decision.outcome === "approval-required") {
146
- const details = new PermDockApprovalRequiredError({
147
- decision,
148
- permission: permission.key,
149
- scope: permission.scope,
150
- resource: resourceRef(permission, void 0),
151
- message: approvalMessage(permission.key, decision.reason, decision.token)
152
- }).toProblemDetails(compact({ instance: options.instance }));
153
- const approval = options.approval === void 0 || options.approval.at === void 0 && options.approval.hint === void 0 ? void 0 : compact({
154
- at: options.approval.at,
155
- hint: options.approval.hint
156
- });
157
- return problemResponse(compact({
158
- ...details,
159
- type: `${base}/approval-required`,
160
- approval
161
- }), permission, decision);
162
- }
163
- const reasons = new Set(decision.denials.map((denial) => denial.reason));
164
- if (options.disclosure === "hide" && ![...reasons].every((reason) => HOLDS_GRANT.has(reason))) return notFoundProblem(options.instance);
165
- if (decision.denials.some((denial) => denial.detail instanceof PermDockValidationError)) {
166
- const validation = decision.denials[0]?.detail;
167
- if (validation instanceof PermDockValidationError) return problemResponse(validation.toProblemDetails(), permission, decision);
168
- }
169
- const details = new PermDockDeniedError({
135
+ const validation = decision.outcome === "denied" ? decision.denials[0]?.detail : void 0;
136
+ if (options.disclosure !== "hide" && validation instanceof PermDockValidationError) return problemResponse(validation.toProblemDetails(), options.scope === void 0 ? permission : {
137
+ ...permission,
138
+ scope: options.scope
139
+ }, decision);
140
+ const details = problemDetails(compact({
170
141
  decision,
142
+ detail: decision.outcome === "approval-required" ? approvalMessage(permission.key, decision.reason, decision.token) : deniedMessage(permission.key, subject?.principal?.id, decision.denials, decision.alternatives.map((leaf) => leaf.key), subject !== void 0),
143
+ instance: options.instance,
171
144
  permission: permission.key,
172
145
  scope: permission.scope,
173
- resource: resourceRef(permission, void 0),
174
- subject,
175
- message: deniedMessage(permission.key, subject.principal?.id, decision.denials, decision.alternatives.map((leaf) => leaf.key))
176
- }).toProblemDetails(compact({ instance: options.instance }));
177
- if (reasons.has("anonymous")) return problemResponse(compact({
178
- type: `${base}/unauthenticated`,
179
- title: "Authentication required",
180
- status: 401,
181
- detail: "Authenticate and repeat the request",
182
- instance: options.instance,
183
- permission: permission.key
184
- }), permission, decision, void 0, options.credentials);
185
- if (reasons.has("insufficient-user-authentication")) return problemResponse(compact({
186
- ...details,
187
- status: 401,
188
- type: `${base}/step-up-required`,
189
- ...stepUpOf(decision)
190
- }), permission, decision);
191
- const plans = requiredPlans(decision);
192
- if (plans.length > 0) return problemResponse({
193
- ...details,
194
- type: `${base}/not-entitled`,
195
- title: "Plan upgrade required",
196
- plans
197
- }, permission, decision);
198
- if (reasons.size > 0 && [...reasons].every((reason) => reason === "limit")) return problemResponse({
199
- ...details,
200
- status: 429,
201
- type: `${base}/rate-limited`,
202
- title: "Rate limit exceeded"
203
- }, permission, decision, rateLimitHeaders(decision));
204
- if (reasons.has("limit-unavailable") && [...reasons].every((reason) => reason === "limit" || reason === "limit-unavailable")) return problemResponse({
205
- ...details,
206
- status: 503,
207
- type: `${base}/limit-unavailable`,
208
- title: "Rate limit unavailable"
209
- }, permission, decision);
210
- return problemResponse({
146
+ resource: resourceRef(permission),
147
+ disclosure: options.disclosure
148
+ }));
149
+ const approval = decision.outcome !== "approval-required" || options.approval === void 0 || options.approval.at === void 0 && options.approval.hint === void 0 ? void 0 : compact({
150
+ at: options.approval.at,
151
+ hint: options.approval.hint
152
+ });
153
+ return decisionResponse(approval === void 0 ? details : {
211
154
  ...details,
212
- type: `${base}/denied`
213
- }, permission, decision);
155
+ approval
156
+ }, decision, compact({
157
+ scope: options.scope ?? permission.scope,
158
+ credentials: options.credentials
159
+ }));
214
160
  }
215
161
  /** The `404` a missing row and a hidden one share, so the two read the same. */
216
162
  function notFoundProblem(instance) {
217
- return problemResponse(compact({
218
- type: `${PROBLEM_BASE}/not-found`,
219
- title: "Not found",
220
- status: 404,
221
- detail: "No such resource",
222
- instance
223
- }));
163
+ return problemResponse(notFoundDetails(instance));
164
+ }
165
+ const ANONYMOUS = {
166
+ outcome: "denied",
167
+ denials: [{
168
+ role: null,
169
+ reason: "anonymous"
170
+ }],
171
+ alternatives: []
172
+ };
173
+ /** The `401` for a request with no subject, with the RFC 6750 challenge its credentials call for. */
174
+ function unauthenticatedProblem(credentials) {
175
+ return decisionResponse(problemDetails({
176
+ decision: ANONYMOUS,
177
+ detail: "anonymous"
178
+ }), ANONYMOUS, { credentials });
179
+ }
180
+ function methodNotAllowed(allow) {
181
+ const response = problemResponse({
182
+ type: `${PROBLEM_BASE}/method-not-allowed`,
183
+ title: "Method not allowed",
184
+ status: 405,
185
+ detail: `use ${allow}`
186
+ });
187
+ response.headers.set("Allow", allow);
188
+ return response;
224
189
  }
225
190
  //#endregion
226
- export { problemFromDecision as a, stepUpOf as c, notFoundProblem as i, validationProblem as l, batchTooLarge as n, problemResponse as o, bearerChallenge as r, protectedResourceMetadataUrl as s, PROBLEM_BASE as t, wwwAuthenticate as u };
191
+ export { notFoundProblem as a, protectedResourceMetadataUrl as c, wwwAuthenticate as d, methodNotAllowed as i, unauthenticatedProblem as l, bearerChallenge as n, problemFromDecision as o, decisionResponse as r, problemResponse as s, batchTooLarge as t, validationProblem as u };
@@ -0,0 +1,7 @@
1
+ import { Yn as Decision } from "./policy-IB6yxpC3.js";
2
+ //#region src/core/problem-details.d.ts
3
+ type Disclosure = "hide" | "reveal";
4
+ /** The plans a `not-entitled` denial asks for; empty unless every denial is `not-entitled`. */
5
+ declare function requiredPlans(decision: Decision): readonly string[];
6
+ //#endregion
7
+ export { requiredPlans as n, Disclosure as t };
@@ -0,0 +1,144 @@
1
+ import { t as compact } from "./compact-y6vfu2_f.js";
2
+ import { t as PROBLEM_BASE } from "./validation-error-CnjZ4t92.js";
3
+ //#region src/core/wire-denial.ts
4
+ const IN_PROCESS = /* @__PURE__ */ new Set(["closure-error", "validation"]);
5
+ function jsonDetail(value) {
6
+ if (value === void 0 || value === null || value instanceof Error) return;
7
+ if (typeof value === "string" || typeof value === "boolean") return value;
8
+ if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
9
+ if (typeof value !== "object") return;
10
+ try {
11
+ return JSON.parse(JSON.stringify(value));
12
+ } catch {
13
+ return;
14
+ }
15
+ }
16
+ function wireDenial(denial) {
17
+ return compact({
18
+ role: denial.role,
19
+ reason: denial.reason,
20
+ to: denial.to,
21
+ detail: IN_PROCESS.has(denial.reason) ? void 0 : jsonDetail(denial.detail)
22
+ });
23
+ }
24
+ function wireDenials(denials) {
25
+ return denials.map(wireDenial);
26
+ }
27
+ //#endregion
28
+ //#region src/core/problem-details.ts
29
+ /** Reasons that only arise once a matching grant was found, so they reveal nothing hidden. */
30
+ const HOLDS_GRANT = /* @__PURE__ */ new Set([
31
+ "insufficient-user-authentication",
32
+ "limit",
33
+ "limit-unavailable"
34
+ ]);
35
+ function granteesOf(to) {
36
+ if (to === void 0) return [];
37
+ return Array.isArray(to) ? to : [to];
38
+ }
39
+ /** The plans a `not-entitled` denial asks for; empty unless every denial is `not-entitled`. */
40
+ function requiredPlans(decision) {
41
+ if (decision.outcome !== "denied" || decision.denials.length === 0 || decision.denials.some((denial) => denial.reason !== "not-entitled")) return [];
42
+ const plans = /* @__PURE__ */ new Set();
43
+ for (const denial of decision.denials) for (const item of granteesOf(denial.to)) if (item.kind === "plan") plans.add(item.plan);
44
+ return [...plans];
45
+ }
46
+ /** The `acr` values and the tightest `maxAge` the failing assurance grants ask for. */
47
+ function stepUpOf(decision) {
48
+ if (decision.outcome !== "denied") return {};
49
+ const acr = /* @__PURE__ */ new Set();
50
+ let maxAge;
51
+ for (const denial of decision.denials) {
52
+ if (denial.reason !== "insufficient-user-authentication") continue;
53
+ for (const grantee of granteesOf(denial.to)) {
54
+ if (grantee.kind !== "assurance") continue;
55
+ for (const value of grantee.acr ?? []) acr.add(value);
56
+ if (grantee.maxAge !== void 0) maxAge = maxAge === void 0 ? grantee.maxAge : Math.min(maxAge, grantee.maxAge);
57
+ }
58
+ }
59
+ return compact({
60
+ acrValues: acr.size === 0 ? void 0 : [...acr],
61
+ maxAge
62
+ });
63
+ }
64
+ /** The `404` a missing row and a hidden one share, so the two read the same. */
65
+ function notFoundDetails(instance) {
66
+ return compact({
67
+ type: `${PROBLEM_BASE}/not-found`,
68
+ title: "Not found",
69
+ status: 404,
70
+ detail: "No such resource",
71
+ instance
72
+ });
73
+ }
74
+ /**
75
+ * The RFC 9457 body for a decision that is not `granted`. One status matrix
76
+ * serves `protect`, a thrown `assert` and `problemFromError`: `401` for an
77
+ * anonymous subject or a step-up, `404` for a hidden row, `429` for an
78
+ * exhausted limit, `503` for an unavailable limit store, `403` otherwise.
79
+ */
80
+ function problemDetails(input) {
81
+ const { decision } = input;
82
+ const base = compact({
83
+ instance: input.instance,
84
+ permission: input.permission,
85
+ scope: input.scope,
86
+ resource: input.resource
87
+ });
88
+ if (decision.outcome === "approval-required") return compact({
89
+ type: `${PROBLEM_BASE}/approval-required`,
90
+ title: "Approval required",
91
+ status: 403,
92
+ detail: input.detail,
93
+ ...base,
94
+ reason: decision.reason,
95
+ token: decision.token
96
+ });
97
+ const reasons = new Set(decision.denials.map((denial) => denial.reason));
98
+ if (input.disclosure === "hide" && ![...reasons].every((reason) => HOLDS_GRANT.has(reason))) return notFoundDetails(input.instance);
99
+ if (reasons.has("anonymous")) return compact({
100
+ type: `${PROBLEM_BASE}/unauthenticated`,
101
+ title: "Authentication required",
102
+ status: 401,
103
+ detail: "Authenticate and repeat the request",
104
+ instance: input.instance,
105
+ permission: input.permission
106
+ });
107
+ const denied = compact({
108
+ type: `${PROBLEM_BASE}/denied`,
109
+ title: "Permission denied",
110
+ status: 403,
111
+ detail: input.detail,
112
+ ...base,
113
+ denials: wireDenials(decision.denials),
114
+ alternatives: decision.alternatives.map((leaf) => leaf.key)
115
+ });
116
+ if (reasons.has("insufficient-user-authentication")) return {
117
+ ...denied,
118
+ status: 401,
119
+ type: `${PROBLEM_BASE}/step-up-required`,
120
+ ...stepUpOf(decision)
121
+ };
122
+ const plans = requiredPlans(decision);
123
+ if (plans.length > 0) return {
124
+ ...denied,
125
+ type: `${PROBLEM_BASE}/not-entitled`,
126
+ title: "Plan upgrade required",
127
+ plans
128
+ };
129
+ if (reasons.size > 0 && [...reasons].every((reason) => reason === "limit")) return {
130
+ ...denied,
131
+ status: 429,
132
+ type: `${PROBLEM_BASE}/rate-limited`,
133
+ title: "Rate limit exceeded"
134
+ };
135
+ if (reasons.has("limit-unavailable") && [...reasons].every((reason) => reason === "limit" || reason === "limit-unavailable")) return {
136
+ ...denied,
137
+ status: 503,
138
+ type: `${PROBLEM_BASE}/limit-unavailable`,
139
+ title: "Rate limit unavailable"
140
+ };
141
+ return denied;
142
+ }
143
+ //#endregion
144
+ export { wireDenials as a, stepUpOf as i, problemDetails as n, requiredPlans as r, notFoundDetails as t };
@@ -1,7 +1,8 @@
1
- import { E as PolicyVocabulary, Mn as Decision, pr as Membership } from "./policy-CInmNGkM.js";
2
- import { d as Permission } from "./permissions-B4apnahQ.js";
3
- import { r as Role } from "./vocabulary-Dk0fs-Jk.js";
4
- import { a as FilterResult, c as PermissionState, d as TenantView, f as UseRolesOptions, l as ProtectedProps, r as ClientPermDock, s as PermissionSet, t as ApprovalHandle, u as SubjectView } from "./types-DbWdEfcm.js";
1
+ import { D as PolicyVocabulary, Mr as Membership, Yn as Decision } from "./policy-IB6yxpC3.js";
2
+ import { f as Permission } from "./permissions-DttnqqxC.js";
3
+ import { r as Role } from "./vocabulary-DA8a8zif.js";
4
+ import { a as FilterResult, c as SubjectView, l as TenantView, o as PermissionSet, r as ClientPermDock, s as PermissionState, t as ApprovalHandle, u as UseRolesOptions } from "./types-CKNSyIf_.js";
5
+ import { n as ProtectedProps } from "./types-BnIEz1sU.js";
5
6
  import { ReactNode } from "react";
6
7
  //#region src/react/hooks.d.ts
7
8
  declare function usePermDock<V extends PolicyVocabulary = PolicyVocabulary>(): ClientPermDock<V>;
@@ -0,0 +1,100 @@
1
+ import { n as storeOf } from "./store-options-ByhZq1jV.js";
2
+ import { a as protectedView, c as subjectView, i as permissionSet, l as tenantView, n as filterResult, o as rolesView, s as scopedTenant, t as approvalHandle } from "./views-Soe7bGSC.js";
3
+ import { i as PermDockStoreContext, r as PermDockSnapshotPromiseContext } from "./live-options-H2eG8dfJ.js";
4
+ import { Suspense, use, useMemo, useSyncExternalStore } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/react/hooks.ts
7
+ function useStore() {
8
+ const store = use(PermDockStoreContext);
9
+ if (store === null) throw new Error("PermDock: hooks require <PermDockProvider>.");
10
+ const pending = use(PermDockSnapshotPromiseContext);
11
+ if (pending !== null) store.adopt(use(pending), pending);
12
+ return store;
13
+ }
14
+ function usePermDock() {
15
+ const store = useStore();
16
+ return useSyncExternalStore((listener) => store.subscribe(listener), () => store.get(), () => store.get());
17
+ }
18
+ function usePermission(permission, data) {
19
+ const permdock = usePermDock();
20
+ return useMemo(() => storeOf(permdock).permissionState(permission, data), [
21
+ permdock,
22
+ permission,
23
+ data
24
+ ]);
25
+ }
26
+ function usePermissions(permissions, data) {
27
+ const permdock = usePermDock();
28
+ return useMemo(() => permissionSet(storeOf(permdock), permissions, data), [
29
+ permdock,
30
+ permissions,
31
+ data
32
+ ]);
33
+ }
34
+ function useFilter(permission, rows) {
35
+ const permdock = usePermDock();
36
+ return useMemo(() => filterResult(permdock, permission, rows), [
37
+ permdock,
38
+ permission,
39
+ rows
40
+ ]);
41
+ }
42
+ function useTenant() {
43
+ const permdock = usePermDock();
44
+ return useMemo(() => tenantView(permdock), [permdock]);
45
+ }
46
+ function useMemberships() {
47
+ const permdock = usePermDock();
48
+ return useMemo(() => permdock.memberships(), [permdock]);
49
+ }
50
+ function useRoles(options = {}) {
51
+ const permdock = usePermDock();
52
+ const { tenant, team } = options;
53
+ return useMemo(() => rolesView(permdock, {
54
+ ...tenant === void 0 ? {} : { tenant },
55
+ ...team === void 0 ? {} : { team }
56
+ }), [
57
+ permdock,
58
+ tenant,
59
+ team
60
+ ]);
61
+ }
62
+ function useAssignableRoles() {
63
+ const permdock = usePermDock();
64
+ return useMemo(() => permdock.assignableRoles(), [permdock]);
65
+ }
66
+ function useAssignablePermissions(options = {}) {
67
+ const permdock = usePermDock();
68
+ const { tenant } = options;
69
+ return useMemo(() => permdock.assignablePermissions(tenant === void 0 ? {} : { tenant }), [permdock, tenant]);
70
+ }
71
+ function useSubject() {
72
+ const permdock = usePermDock();
73
+ return useMemo(() => subjectView(permdock), [permdock]);
74
+ }
75
+ function useApproval(decision) {
76
+ return approvalHandle(storeOf(usePermDock()), decision);
77
+ }
78
+ //#endregion
79
+ //#region src/react/protected.tsx
80
+ function Protected(props) {
81
+ if (props.pending === void 0) return /* @__PURE__ */ jsx(Guard, { ...props });
82
+ return /* @__PURE__ */ jsx(Suspense, {
83
+ fallback: props.pending,
84
+ children: /* @__PURE__ */ jsx(Guard, { ...props })
85
+ });
86
+ }
87
+ function Guard(props) {
88
+ const root = usePermDock();
89
+ const local = usePermission(props.permission, props.data);
90
+ const scoped = useMemo(() => scopedTenant(root, props.tenant), [root, props.tenant]);
91
+ const view = protectedView(local, root, props.permission, props.data, scoped);
92
+ switch (view.slot) {
93
+ case "pending": return props.pending ?? null;
94
+ case "fallback": return typeof props.fallback === "function" ? props.fallback(view.decision) : props.fallback ?? null;
95
+ case "default": return typeof props.children === "function" ? props.children(view.decision) : props.children;
96
+ default: return view;
97
+ }
98
+ }
99
+ //#endregion
100
+ export { useFilter as a, usePermission as c, useSubject as d, useTenant as f, useAssignableRoles as i, usePermissions as l, useApproval as n, useMemberships as o, useAssignablePermissions as r, usePermDock as s, Protected as t, useRoles as u };
@@ -0,0 +1,40 @@
1
+ import { Yn as Decision, er as GrantedDecision, ln as PermDock } from "./policy-IB6yxpC3.js";
2
+ import { f as Permission } from "./permissions-DttnqqxC.js";
3
+ import { t as PermissionBoundaryState } from "./boundary-BmHxVH1J.js";
4
+ import { s as PermissionState } from "./types-CKNSyIf_.js";
5
+ import { t as ClientStore } from "./store-jOBYpiXC.js";
6
+ import { Snippet } from "svelte";
7
+ //#region src/svelte/boundary.d.ts
8
+ type PermissionBoundaryProps = {
9
+ readonly children?: Snippet;
10
+ /** Rendered in place of the children when one throws `PermDockDeniedError`. */
11
+ readonly denied?: Snippet<[PermissionBoundaryState]>;
12
+ /** Rendered for `PermDockApprovalRequiredError`; defaults to `denied`. */
13
+ readonly approval?: Snippet<[PermissionBoundaryState]>;
14
+ };
15
+ //#endregion
16
+ //#region src/client/views.d.ts
17
+ /** What `Protected` renders: `pending` while an endpoint answer is in flight, `fallback` unless granted. */
18
+ type ProtectedView = (PermissionState & {
19
+ readonly slot: "pending" | "fallback";
20
+ }) | {
21
+ readonly allowed: true;
22
+ readonly status: PermissionState["status"];
23
+ readonly decision: GrantedDecision;
24
+ readonly slot: "default";
25
+ };
26
+ //#endregion
27
+ //#region src/svelte/protected.d.ts
28
+ type ProtectedProps = {
29
+ readonly permission: Permission;
30
+ readonly data?: unknown;
31
+ readonly tenant?: string;
32
+ readonly children?: Snippet<[Decision]>;
33
+ readonly pending?: Snippet;
34
+ readonly fallback?: Snippet<[Decision]>;
35
+ };
36
+ /** The instance for `tenant`, built once per store change rather than once per check. */
37
+ declare function scopedFor(store: ClientStore, tenant: string | undefined, _generation?: number): PermDock | undefined;
38
+ declare function viewFor(store: ClientStore, reference: Permission, data: unknown, scoped: PermDock | undefined, _generation?: number): ProtectedView;
39
+ //#endregion
40
+ export { PermissionBoundaryProps as i, scopedFor as n, viewFor as r, ProtectedProps as t };