permdock 0.1.0 → 0.2.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 (349) 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-cmvX2jDe.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 +206 -0
  18. package/dist/better-supabase/index.js +620 -0
  19. package/dist/bind-CVy3Espv.d.ts +25 -0
  20. package/dist/bind-VnYn2HKq.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-B68OFnZx.js → capability-4qPdO9gk.js} +7 -5
  25. package/dist/{capability-BDG_nkxt.d.ts → capability-Dq43tT1u.d.ts} +2 -2
  26. package/dist/catalog/index.d.ts +1 -1
  27. package/dist/catalog/index.js +1 -1
  28. package/dist/catalog-BjZSovXQ.js +2 -0
  29. package/dist/{catalog-doc-BSo_Q_-6.js → catalog-doc-Dsc9y7sd.js} +23 -12
  30. package/dist/{catalog-B0E6bggc.js → catalog-h2tlKFkq.js} +2 -2
  31. package/dist/{catalog-H-vFGwWK.js → catalog-z8q6bi_r.js} +4 -4
  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-BGhHS-lY.js} +2 -2
  44. package/dist/{cloud-Cuxr6Czw.js → cloud-Bo3e9Ak3.js} +7 -6
  45. package/dist/{collect-O-tOtbnk.js → collect-DDDv_ESs.js} +194 -42
  46. package/dist/collect-DLlujdHC.js +83 -0
  47. package/dist/collect-rG2IQ3t0.js +2 -0
  48. package/dist/{commands-BMh_Etm2.js → commands-DWOrSQic.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-CNnl6uIt.d.ts +94 -0
  53. package/dist/config-BJiM-xAm.js +157 -0
  54. package/dist/config-Bn00Z3ks.js +36 -0
  55. package/dist/config-report-Dw_JcUqT.js +44 -0
  56. package/dist/{connection-JvqwHODC.js → connection-CU8MQxRi.js} +1 -1
  57. package/dist/{context-CKEAabd7.js → context-Ttp0ekMT.js} +36 -27
  58. package/dist/convex/index.d.ts +9 -4
  59. package/dist/convex/index.js +14 -4
  60. package/dist/create-BWyx3jua.d.ts +245 -0
  61. package/dist/create-CPhDL6qx.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-PdoqESvg.d.ts} +9 -10
  66. package/dist/{diff-x5Il8LVa.js → diff-B8Tunc3o.js} +44 -11
  67. package/dist/{diff-BUzf5Poi.js → diff-CzqLxZ77.js} +2 -2
  68. package/dist/doctor-WpvG6p4k.js +1194 -0
  69. package/dist/doctor-collect-ByfYlNv1.js +664 -0
  70. package/dist/{doctor-Bqo6FwUa.js → doctor-rOr-4ZfS.js} +2 -2
  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-DAqevpNk.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-C3sHpZNS.js} +65 -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-LF_hS-yn.d.ts → index-A0YNL8jZ.d.ts} +1 -1
  105. package/dist/index-CtE07CBF.d.ts +6 -0
  106. package/dist/{index-xIxJLwOQ.d.ts → index-D3vbkoSI.d.ts} +75 -7
  107. package/dist/{index-CltcQ4Bf.d.ts → index-D6_cSa1z.d.ts} +68 -5
  108. package/dist/index.d.ts +14 -9
  109. package/dist/index.js +22 -17
  110. package/dist/instance-options-BK_rNOSC.d.ts +11 -0
  111. package/dist/instance-options-Dhhcnm3y.js +22 -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-GSQnMz3O.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-CwePaF7C.js → openapi-Bbg4wGVL.js} +3 -3
  144. package/dist/{openapi-DcqM8nU7.js → openapi-BqRBvAng.js} +237 -5
  145. package/dist/{openapi-DWD0Uc_4.js → openapi-CqqEbHsL.js} +5 -5
  146. package/dist/{openapi-import-BWRUNNeW.js → openapi-import-cmwetbzw.js} +1 -1
  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-BkGQNzAh.d.ts +10 -0
  153. package/dist/parse-local-manifest-BrMozJCo.js +36 -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-CzqXjCpU.js} +641 -126
  157. package/dist/{permissions-B8vCg_bI.d.ts → permissions-CDgvKG5L.d.ts} +2 -2
  158. package/dist/{permissions-CofRqesP.js → permissions-CpZrivYv.js} +3 -3
  159. package/dist/{permissions-DC7GROPA.js → permissions-DVoF6dMt.js} +77 -15
  160. package/dist/{permissions-B4apnahQ.d.ts → permissions-DttnqqxC.d.ts} +34 -5
  161. package/dist/{pins-CqE1jZuF.js → pins-8ILTftC9.js} +2 -2
  162. package/dist/{policy-CInmNGkM.d.ts → policy-CFZAr_Al.d.ts} +330 -37
  163. package/dist/{policy-Cq2fB8Q5.d.ts → policy-D8UFyERw.d.ts} +2 -2
  164. package/dist/{policy-ANp36PnI.js → policy-xyWg7QdR.js} +173 -22
  165. package/dist/powersync-A8x_Yyvh.js +2 -0
  166. package/dist/powersync-C7kLglqX.js +540 -0
  167. package/dist/powersync-yW1UUFzp.js +62 -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-CkL50EEf.d.ts +7 -0
  172. package/dist/problem-details-_AMOYz-w.js +144 -0
  173. package/dist/{protected-BuPAycJT.d.ts → protected-CNsMzrVd.d.ts} +5 -4
  174. package/dist/protected-Cs6kTaHo.js +100 -0
  175. package/dist/protected-bZs6rbT1.d.ts +40 -0
  176. package/dist/{provider-wTAUda2v.d.ts → provider-Cjr62YMV.d.ts} +1 -1
  177. package/dist/provider-DLzpb2Xz.js +52 -0
  178. package/dist/provider-store-DNyC1y48.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-sqBGMnNs.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-BMNydpHk.js +2521 -0
  192. package/dist/{rls-BOFU3chG.js → rls-CEvs64Kj.js} +8 -3
  193. package/dist/rls-fields-BMasREhR.js +3502 -0
  194. package/dist/{rls-graph-DxQ39PJj.js → rls-graph-pc9fuXYm.js} +100 -36
  195. package/dist/{rls-import-CXV6LBlS.js → rls-import-D8F7j35Q.js} +7 -6
  196. package/dist/{rls-migrate-DrFPbf8p.js → rls-migrate-7wikfrVI.js} +6 -5
  197. package/dist/rls-ownership-B5Lkq62W.js +843 -0
  198. package/dist/rls-shared-aOQ4hGTO.js +493 -0
  199. package/dist/rls-verify-D8B7dOTh.js +745 -0
  200. package/dist/{row-check-BajTgQZ-.d.ts → row-check-Dt35czLy.d.ts} +12 -15
  201. package/dist/rpc-DOK54_CS.js +89 -0
  202. package/dist/{run-CJ6UvS3a.js → run-YXCJDNYk.js} +31 -12
  203. package/dist/runtime-CB8gQFvS.js +11 -0
  204. package/dist/{saas-BRrZzJkM.js → saas-Bj_FFkjN.js} +17 -7
  205. package/dist/{schema-P8yoma__.js → schema-D3MnDMxa.js} +8 -4
  206. package/dist/scim/index.d.ts +1 -1
  207. package/dist/scim/index.js +1 -1
  208. package/dist/{scim-9NFa0XVZ.js → scim-BFGBBAqR.js} +1 -1
  209. package/dist/{scopes-cKVp_WTw.js → scopes-CVdPrWN-.js} +35 -8
  210. package/dist/server/index.d.ts +22 -11
  211. package/dist/server/index.js +11 -8
  212. package/dist/{credentials-BgRX3WEg.js → server-DlZ28Oz5.js} +1 -1
  213. package/dist/shared-DRu8VFVM.js +123 -0
  214. package/dist/{sink-Cfr9-7YC.d.ts → sink-Gs6TTVa-.d.ts} +1 -1
  215. package/dist/skills-Biq5uup3.js +192 -0
  216. package/dist/{skills-C_lpV4Jx.js → skills-JaymNCdK.js} +10 -4
  217. package/dist/{snapshot-DE8dE_hz.js → snapshot-Enxd0n-s.js} +138 -214
  218. package/dist/snapshot-cache-D6jLelln.js +44 -0
  219. package/dist/snapshot-cache-DwQH8ufx.d.ts +45 -0
  220. package/dist/solid/index.d.ts +39 -9
  221. package/dist/solid/index.js +76 -85
  222. package/dist/sources-B0UvrJ21.js +534 -0
  223. package/dist/sources-BcJgw0lt.d.ts +192 -0
  224. package/dist/{sql-Bll1d7y0.js → sql-xdg5f4Fi.js} +6 -1
  225. package/dist/{src-CTNT-PBW.js → src-CSbUiozF.js} +149 -11
  226. package/dist/ssf/index.d.ts +3 -2
  227. package/dist/ssf/index.js +3 -29
  228. package/dist/store-DMAWwAJV.js +371 -0
  229. package/dist/{store-Bq90395i.d.ts → store-D_pjn91-.d.ts} +13 -4
  230. package/dist/store-options-yO0V6gRn.js +716 -0
  231. package/dist/{stores-CkG2HrSg.js → stores-4_sqiOA1.js} +10 -63
  232. package/dist/{stores-CvOnu_2T.d.ts → stores-DVR5NHLE.d.ts} +20 -9
  233. package/dist/{stream-Q_xlB6Ko.js → stream-DDpvynSB.js} +16 -2
  234. package/dist/{stream-BhMfZOwr.d.ts → stream-DlvG2hs-.d.ts} +2 -2
  235. package/dist/subject-settings-BwBmCdTR.js +128 -0
  236. package/dist/supabase/index.d.ts +122 -6
  237. package/dist/supabase/index.js +4 -3
  238. package/dist/supabase/middleware.d.ts +32 -27
  239. package/dist/supabase/middleware.js +56 -22
  240. package/dist/{supabase-D8UlBA7Z.js → supabase-CwafwxxF.js} +3 -3
  241. package/dist/{supabase-DTxGtYdi.js → supabase-DTBaC20O.js} +345 -367
  242. package/dist/supabase-config-Bs44dare.js +472 -0
  243. package/dist/{supabase-hook-D_OqGb_V.js → supabase-hook-BuxLQLpU.js} +994 -708
  244. package/dist/supabase-hook-D5qVd_D8.js +2 -0
  245. package/dist/supautils-DYZnzRWV.js +91 -0
  246. package/dist/svelte/PermissionBoundary.svelte +37 -0
  247. package/dist/svelte/Protected.svelte +8 -2
  248. package/dist/svelte/index.d.ts +9 -6
  249. package/dist/svelte/index.js +61 -7
  250. package/dist/svelte/runtime.d.ts +4 -3
  251. package/dist/svelte/runtime.js +4 -3
  252. package/dist/svelte/source.d.ts +9 -6
  253. package/dist/svelte/source.js +7 -4
  254. package/dist/terminal/index.d.ts +6 -14
  255. package/dist/terminal/index.js +44 -32
  256. package/dist/testing/index.d.ts +105 -16
  257. package/dist/testing/index.js +504 -40
  258. package/dist/testing/saas/index.d.ts +4 -4
  259. package/dist/testing/saas/index.js +2 -2
  260. package/dist/testing/saas/permissions.d.ts +1 -1
  261. package/dist/testing/saas/permissions.js +1 -1
  262. package/dist/token-CIWxJOCh.js +50 -0
  263. package/dist/trpc/index.d.ts +7 -26
  264. package/dist/trpc/index.js +17 -100
  265. package/dist/types-9AWO9EGt.d.ts +197 -0
  266. package/dist/{types-D6Z6-rKJ.d.ts → types-BPxgszlT.d.ts} +260 -22
  267. package/dist/{types-BvBk1wgn.d.ts → types-BVyImy5I.d.ts} +5 -3
  268. package/dist/{types-CxquUByI.d.ts → types-Bvc4oWT6.d.ts} +1 -1
  269. package/dist/types-C3s9xVJG.d.ts +48 -0
  270. package/dist/{types-BBK-exvJ.d.ts → types-Dnemwd77.d.ts} +7 -1
  271. package/dist/types-kxznc7cn.d.ts +52 -0
  272. package/dist/{types-B8w5PFtS.d.ts → types-vKyAMtcX.d.ts} +17 -1
  273. package/dist/{types-B9dmiiab.d.ts → types-vNSDF7Dq.d.ts} +1 -1
  274. package/dist/{sources-DOpW5Ila.d.ts → types-yF5LmQVD.d.ts} +86 -127
  275. package/dist/unplugin/index.d.ts +1 -1
  276. package/dist/unplugin/index.js +10 -9
  277. package/dist/{usage-1ozMubLY.js → usage-D07N9QJ3.js} +2 -2
  278. package/dist/usage-D82l1CwK.js +2 -0
  279. package/dist/{usage-CUnK6Ou9.js → usage-DG1oeCca.js} +225 -62
  280. package/dist/validation-error-CnjZ4t92.js +33 -0
  281. package/dist/validation-error-CtF23SrC.d.ts +26 -0
  282. package/dist/{validity-D0uRmJKJ.js → validity-uOp8UpYn.js} +57 -36
  283. package/dist/{verifier-B90agnhl.js → verifier-BxBo6I44.js} +10 -5
  284. package/dist/version-BvacVTZR.js +17 -0
  285. package/dist/views-Soe7bGSC.js +95 -0
  286. package/dist/{vocabulary-Dk0fs-Jk.d.ts → vocabulary-DA8a8zif.d.ts} +1 -1
  287. package/dist/vue/index.d.ts +35 -13
  288. package/dist/vue/index.js +86 -93
  289. package/dist/watch-Etoa_Mvr.js +2 -0
  290. package/dist/watch-UihESpsJ.js +128 -0
  291. package/dist/webmcp/index.d.ts +2 -2
  292. package/dist/webmcp/index.js +7 -13
  293. package/package.json +62 -36
  294. package/schemas/approval-request-v1.json +175 -0
  295. package/schemas/catalog-v1.json +29 -1
  296. package/schemas/supabase-claims-v1.json +6 -1
  297. package/schemas/supabase-manifest-v1.json +150 -6
  298. package/skills/permdock/SKILL.md +7 -7
  299. package/skills/permdock-agents/SKILL.md +5 -5
  300. package/skills/permdock-agents/references/runtimes.md +12 -10
  301. package/skills/permdock-approvals/SKILL.md +4 -4
  302. package/skills/permdock-approvals/references/stores-and-resume.md +15 -4
  303. package/skills/permdock-audit/SKILL.md +3 -3
  304. package/skills/permdock-credentials/SKILL.md +4 -4
  305. package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
  306. package/skills/permdock-data/SKILL.md +4 -4
  307. package/skills/permdock-data/references/queries-and-rls.md +14 -6
  308. package/skills/permdock-data/references/relationships.md +5 -3
  309. package/skills/permdock-tenancy/SKILL.md +9 -6
  310. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +14 -8
  311. package/skills/permdock-wire/SKILL.md +4 -4
  312. package/skills/permdock-wire/references/adapters.md +42 -30
  313. package/skills/permdock-wire/references/policy-options.md +5 -3
  314. package/dist/approvers-aH0PJkmf.js +0 -20
  315. package/dist/catalog-idsHc0vo.js +0 -2
  316. package/dist/collect-B7_TIfmg.js +0 -49
  317. package/dist/collect-fRPAQIWb.js +0 -2
  318. package/dist/compile-CQbvyIBr.d.ts +0 -30
  319. package/dist/config-BPYmjTOp.js +0 -26
  320. package/dist/context-gtAwAILx.js +0 -6
  321. package/dist/create-BKF3dgFk.d.ts +0 -162
  322. package/dist/create-CSkhDU9T.js +0 -222
  323. package/dist/doctor-BGle8Gqi.js +0 -1314
  324. package/dist/helpers-DnSOrhB9.js +0 -682
  325. package/dist/index-fG6NSXlc.d.ts +0 -9
  326. package/dist/kernel-YOGCWNLf.js +0 -211
  327. package/dist/load-QOOm1z70.js +0 -2
  328. package/dist/manifest-DDQbC6K0.d.ts +0 -118
  329. package/dist/map-error-RJ3ZsUyA.js +0 -16
  330. package/dist/may-use-CnFEjVEp.js +0 -37
  331. package/dist/pg-4GJWDUxG.js +0 -953
  332. package/dist/plugin-4gr7IxFJ.js +0 -65
  333. package/dist/protected-B4K3BKoX.js +0 -138
  334. package/dist/protected-wY7nXhY9.d.ts +0 -23
  335. package/dist/provider-_wx46HpB.js +0 -48
  336. package/dist/rls-CJVja9Ww.js +0 -2119
  337. package/dist/rls-helpers-BxRuif0l.js +0 -1346
  338. package/dist/runtime-DP9ttFh1.js +0 -27
  339. package/dist/skills-Dx3QLnMY.js +0 -110
  340. package/dist/source-DoBBYJi2.js +0 -6
  341. package/dist/sources-DVHM3Mwq.js +0 -284
  342. package/dist/store-C6hFW6ta.js +0 -508
  343. package/dist/subject-settings-xt7V845g.js +0 -82
  344. package/dist/supabase-hook-DW-xP4hU.js +0 -2
  345. package/dist/types-DbWdEfcm.d.ts +0 -87
  346. package/dist/types-bva3i4Gf.d.ts +0 -98
  347. package/dist/types-i4BAOvdb.d.ts +0 -97
  348. package/dist/usage-PyEor6GA.js +0 -2
  349. package/dist/version-CnSh33Fj.js +0 -16
@@ -0,0 +1,95 @@
1
+ //#region src/client/views.ts
2
+ function permissionSet(store, permissions, data) {
3
+ const granted = [];
4
+ const byKey = {};
5
+ for (const permission of permissions) {
6
+ const state = store.permissionState(permission, data);
7
+ byKey[permission.key] = state;
8
+ if (state.allowed) granted.push(permission);
9
+ }
10
+ return new Proxy({
11
+ granted,
12
+ get(permission) {
13
+ return byKey[permission.key];
14
+ }
15
+ }, { get(target, prop, receiver) {
16
+ if (typeof prop === "string" && Object.hasOwn(byKey, prop)) return byKey[prop];
17
+ return Reflect.get(target, prop, receiver);
18
+ } });
19
+ }
20
+ function filterResult(permdock, permission, rows) {
21
+ const result = permdock.filter(permission, rows);
22
+ result.partial = permdock.where(permission).partial;
23
+ return result;
24
+ }
25
+ function tenantView(permdock) {
26
+ return {
27
+ tenant: permdock.subject.principal?.tenant ?? null,
28
+ tenants: permdock.tenants(),
29
+ switchTo: (id) => permdock.refresh({ tenant: id }),
30
+ status: permdock.status()
31
+ };
32
+ }
33
+ function rolesView(permdock, options) {
34
+ return { roles: (options.team === void 0 ? permdock : permdock.team(options.team)).heldRoles(options.tenant === void 0 ? void 0 : { tenant: options.tenant }) };
35
+ }
36
+ function subjectView(permdock) {
37
+ const snapshot = permdock.snapshot();
38
+ return {
39
+ principal: permdock.subject.principal,
40
+ actor: permdock.subject.actor,
41
+ delegation: permdock.subject.delegation,
42
+ expiresAt: permdock.subject.expiresAt,
43
+ simulated: typeof snapshot === "object" && snapshot !== null && "simulated" in snapshot && snapshot.simulated === true
44
+ };
45
+ }
46
+ /** The root's view of another tenant for a `Protected` with a `tenant` prop; `undefined` answers the active one. */
47
+ function scopedTenant(root, tenant) {
48
+ return tenant === void 0 ? void 0 : root.tenant(tenant);
49
+ }
50
+ /** An instance whose every read answers from `current()`, so a held reference follows the store. */
51
+ function livePermDock(current) {
52
+ return new Proxy({}, { get(_target, prop, _receiver) {
53
+ return Reflect.get(current(), prop);
54
+ } });
55
+ }
56
+ /**
57
+ * `local` answers the active tenant; `scoped`, the root's view of another
58
+ * tenant, is decided on the spot and shares the root's `pending` and `stale`.
59
+ */
60
+ function protectedView(local, root, permission, data, scoped) {
61
+ const state = scoped === void 0 ? local : decideIn(root, scoped, permission, data);
62
+ if (state.status === "pending") return {
63
+ ...state,
64
+ slot: "pending"
65
+ };
66
+ const decision = state.decision;
67
+ if (!state.allowed || decision.outcome !== "granted") return {
68
+ ...state,
69
+ slot: "fallback"
70
+ };
71
+ return {
72
+ allowed: true,
73
+ status: state.status,
74
+ decision,
75
+ slot: "default"
76
+ };
77
+ }
78
+ function decideIn(root, scoped, permission, data) {
79
+ const decision = scoped.decide(permission, data);
80
+ const status = root.status();
81
+ return {
82
+ allowed: decision.outcome === "granted",
83
+ status: status === "pending" || status === "stale" ? status : "ready",
84
+ decision
85
+ };
86
+ }
87
+ function approvalHandle(store, decision) {
88
+ return {
89
+ state: store.approvalState(decision),
90
+ token: decision.outcome === "approval-required" ? decision.token : void 0,
91
+ request: (note) => store.requestApproval(decision, note)
92
+ };
93
+ }
94
+ //#endregion
95
+ export { protectedView as a, subjectView as c, permissionSet as i, tenantView as l, filterResult as n, rolesView as o, livePermDock as r, scopedTenant as s, approvalHandle as t };
@@ -1,4 +1,4 @@
1
- import { n as ActionMeta } from "./permissions-B4apnahQ.js";
1
+ import { n as ActionMeta } from "./permissions-DttnqqxC.js";
2
2
  //#region src/core/vocabulary.d.ts
3
3
  declare const ROLE_KIND: "role";
4
4
  declare const PLAN_KIND: "plan";
@@ -1,9 +1,11 @@
1
- import { Et as TokenVerifier, Mn as Decision, gt as Snapshot, 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 requiredPlans, i as describe } from "../describe-DernyItf.js";
5
- import { t as approvalHeaders } from "../headers-C8SHQccD.js";
6
- import { a as FilterResult, c as PermissionState, d as TenantView, f as UseRolesOptions, i as ClientStatus, n as ApprovalState, r as ClientPermDock, s as PermissionSet, t as ApprovalHandle, u as SubjectView } from "../types-DbWdEfcm.js";
1
+ import { Ft as TokenVerifier, Mr as Membership, Tt as Snapshot, Yn as Decision } from "../policy-CFZAr_Al.js";
2
+ import { f as Permission } from "../permissions-DttnqqxC.js";
3
+ import { r as Role } from "../vocabulary-DA8a8zif.js";
4
+ import { n as requiredPlans } from "../problem-details-CkL50EEf.js";
5
+ import { i as describe } from "../describe-PdoqESvg.js";
6
+ import { t as PermissionBoundaryState } from "../boundary-BmHxVH1J.js";
7
+ import { t as approvalHeaders } from "../headers-Cf-zWvsO.js";
8
+ import { a as FilterResult, c as SubjectView, i as ClientStatus, l as TenantView, n as ApprovalState, o as PermissionSet, r as ClientPermDock, s as PermissionState, t as ApprovalHandle, u as UseRolesOptions } from "../types-kxznc7cn.js";
7
9
  import { ComputedRef, DefineComponent, MaybeRefOrGetter, Plugin } from "vue";
8
10
  //#region src/vue/types.d.ts
9
11
  type PermDockPluginOptions = {
@@ -13,13 +15,22 @@ type PermDockPluginOptions = {
13
15
  * `setup` under `<Suspense>`).
14
16
  */
15
17
  readonly snapshot: MaybeRefOrGetter<Snapshot | string> | PromiseLike<Snapshot | string>;
16
- readonly endpoint?: string;
18
+ /**
19
+ * The AuthZEN evaluations endpoint for checks the snapshot cannot answer.
20
+ * `false` never calls one: such a check is denied with reason `server-only`.
21
+ */
22
+ readonly endpoint?: string | false;
23
+ /** Where `refresh()` fetches a fresh snapshot. Defaults to `endpoint`. */
24
+ readonly snapshotUrl?: string;
17
25
  readonly approvals?: string;
18
- readonly tenant?: string;
26
+ /** A ref or getter switches the active tenant (`refresh({ tenant })`) when it changes. */
27
+ readonly tenant?: MaybeRefOrGetter<string | undefined>;
19
28
  readonly fetch?: typeof fetch;
20
- readonly headers?: Readonly<Record<string, string>>;
29
+ /** Read on every request: a ref or getter carries a rotated token without rebuilding the store. */
30
+ readonly headers?: MaybeRefOrGetter<Readonly<Record<string, string>> | undefined>;
21
31
  readonly maxAge?: number;
22
- readonly verifier?: TokenVerifier;
32
+ /** Read on every verification; set it at install to verify signed snapshots. */
33
+ readonly verifier?: MaybeRefOrGetter<TokenVerifier | undefined>;
23
34
  };
24
35
  //#endregion
25
36
  //#region src/vue/composables.d.ts
@@ -37,12 +48,23 @@ export declare function useRoles(options?: MaybeRefOrGetter<UseRolesOptions>): C
37
48
  readonly roles: readonly Role[];
38
49
  }>;
39
50
  export declare function useAssignableRoles(): ComputedRef<readonly Role[]>;
40
- export declare function useAssignablePermissions(options?: {
51
+ export declare function useAssignablePermissions(options?: MaybeRefOrGetter<{
41
52
  readonly tenant?: string;
42
- }): ComputedRef<readonly Permission[]>;
53
+ }>): ComputedRef<readonly Permission[]>;
43
54
  export declare function useSubject(): ComputedRef<SubjectView>;
44
55
  export declare function useApproval(decision: MaybeRefOrGetter<Decision>): ComputedRef<ApprovalHandle>;
45
56
  //#endregion
57
+ //#region src/vue/boundary.d.ts
58
+ /**
59
+ * Catches `PermDockDeniedError` and `PermDockApprovalRequiredError` thrown
60
+ * by a descendant and renders the `denied` slot, or the `approval` slot for
61
+ * an approval request (default `denied`). The slots receive the refused
62
+ * permission and `retry()`. Any other error propagates.
63
+ */
64
+ export declare const PermissionBoundary: DefineComponent;
65
+ /** Inside a `PermissionBoundary`: what was refused and `retry()`, or `null` while the children render. */
66
+ export declare function usePermissionBoundary(): PermissionBoundaryState | null;
67
+ //#endregion
46
68
  //#region src/vue/plugin.d.ts
47
69
  export declare const permdockPlugin: Plugin<PermDockPluginOptions>;
48
70
  //#endregion
@@ -54,4 +76,4 @@ type ProtectedProps = {
54
76
  };
55
77
  export declare const Protected: DefineComponent<ProtectedProps>;
56
78
  //#endregion
57
- export { type ApprovalHandle, type ApprovalState, type ClientPermDock, type ClientStatus, type FilterResult, type PermDockPluginOptions, type PermissionSet, type PermissionState, type SubjectView, type TenantView, type UseRolesOptions, approvalHeaders, describe, requiredPlans };
79
+ export { type ApprovalHandle, type ApprovalState, type ClientPermDock, type ClientStatus, type FilterResult, type PermDockPluginOptions, type PermissionBoundaryState, type PermissionSet, type PermissionState, type ProtectedProps, type SubjectView, type TenantView, type UseRolesOptions, approvalHeaders, describe, requiredPlans };
package/dist/vue/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import { t as compact } from "../compact-y6vfu2_f.js";
2
- import { n as requiredPlans, t as describe } from "../describe-Bt1YD5uS.js";
3
- import { t as emptySnapshot } from "../from-snapshot-BMGnhmgv.js";
4
- import { t as approvalHeaders } from "../headers-B5RRv3Xm.js";
5
- import { t as createClientStore } from "../store-C6hFW6ta.js";
6
- import { t as isPromiseLike } from "../source-DoBBYJi2.js";
7
- import { computed, defineComponent, effectScope, inject, isRef, onScopeDispose, shallowRef, toValue, watch } from "vue";
1
+ import { r as requiredPlans } from "../problem-details-_AMOYz-w.js";
2
+ import { t as describe } from "../describe-B_gVZEVi.js";
3
+ import { t as approvalHeaders } from "../headers-BZSDieNT.js";
4
+ import { i as isPromiseLike } from "../store-options-yO0V6gRn.js";
5
+ import { a as protectedView, c as subjectView, i as permissionSet, l as tenantView, n as filterResult, o as rolesView, r as livePermDock, s as scopedTenant, t as approvalHandle } from "../views-Soe7bGSC.js";
6
+ import { n as boundaryFallback, t as boundaryDigest } from "../boundary-BM8a_P6E.js";
7
+ import { n as switchTenant, t as providerStore } from "../provider-store-DNyC1y48.js";
8
+ import { computed, defineComponent, effectScope, getCurrentScope, inject, isRef, onErrorCaptured, onScopeDispose, provide, shallowRef, toValue, watch } from "vue";
8
9
  //#region src/vue/context.ts
9
10
  const permDockKey = Symbol("permdock");
10
11
  //#endregion
@@ -15,6 +16,7 @@ function useStore() {
15
16
  return store;
16
17
  }
17
18
  function useTick(store) {
19
+ if (getCurrentScope() === void 0) throw new Error("PermDock: call composables in setup() or an effectScope, which removes their store subscription.");
18
20
  const tick = shallowRef(0);
19
21
  onScopeDispose(store.subscribe(() => {
20
22
  tick.value += 1;
@@ -26,9 +28,7 @@ function useTick(store) {
26
28
  }
27
29
  function usePermDock() {
28
30
  const permdock = useTick(useStore());
29
- return new Proxy({}, { get(_target, prop, _receiver) {
30
- return Reflect.get(permdock.value, prop);
31
- } });
31
+ return livePermDock(() => permdock.value);
32
32
  }
33
33
  function usePermission(permission, data) {
34
34
  const store = useStore();
@@ -48,40 +48,16 @@ function usePermissions(permissions, data) {
48
48
  const permdock = useTick(store);
49
49
  return computed(() => {
50
50
  permdock.value;
51
- const granted = [];
52
- const byKey = {};
53
- for (const permission of toValue(permissions)) {
54
- const next = store.permissionState(permission, toValue(data));
55
- byKey[permission.key] = next;
56
- if (next.allowed) granted.push(permission);
57
- }
58
- return new Proxy({
59
- granted,
60
- get(permission) {
61
- return byKey[permission.key];
62
- }
63
- }, { get(target, prop, receiver) {
64
- if (typeof prop === "string" && Object.hasOwn(byKey, prop)) return byKey[prop];
65
- return Reflect.get(target, prop, receiver);
66
- } });
51
+ return permissionSet(store, toValue(permissions), toValue(data));
67
52
  });
68
53
  }
69
54
  function useFilter(permission, rows) {
70
55
  const permdock = useTick(useStore());
71
- return computed(() => {
72
- const result = [...permdock.value.filter(permission, toValue(rows))];
73
- result.partial = permdock.value.where(permission).partial;
74
- return result;
75
- });
56
+ return computed(() => filterResult(permdock.value, permission, toValue(rows)));
76
57
  }
77
58
  function useTenant() {
78
59
  const permdock = useTick(useStore());
79
- return computed(() => ({
80
- tenant: permdock.value.subject.principal?.tenant ?? null,
81
- tenants: permdock.value.tenants(),
82
- switchTo: (id) => permdock.value.refresh({ tenant: id }),
83
- status: permdock.value.status()
84
- }));
60
+ return computed(() => tenantView(permdock.value));
85
61
  }
86
62
  function useMemberships() {
87
63
  const permdock = useTick(useStore());
@@ -89,10 +65,7 @@ function useMemberships() {
89
65
  }
90
66
  function useRoles(options = {}) {
91
67
  const permdock = useTick(useStore());
92
- return computed(() => {
93
- const next = toValue(options);
94
- return { roles: (next.team === void 0 ? permdock.value : permdock.value.team(next.team)).heldRoles(next.tenant === void 0 ? void 0 : { tenant: next.tenant }) };
95
- });
68
+ return computed(() => rolesView(permdock.value, toValue(options)));
96
69
  }
97
70
  function useAssignableRoles() {
98
71
  const permdock = useTick(useStore());
@@ -100,62 +73,86 @@ function useAssignableRoles() {
100
73
  }
101
74
  function useAssignablePermissions(options = {}) {
102
75
  const permdock = useTick(useStore());
103
- return computed(() => permdock.value.assignablePermissions(options));
76
+ return computed(() => permdock.value.assignablePermissions(toValue(options)));
104
77
  }
105
78
  function useSubject() {
106
79
  const permdock = useTick(useStore());
107
- return computed(() => {
108
- const snapshot = permdock.value.snapshot();
109
- const simulated = typeof snapshot === "object" && snapshot !== null && "simulated" in snapshot && snapshot.simulated === true;
110
- return {
111
- principal: permdock.value.subject.principal,
112
- actor: permdock.value.subject.actor,
113
- delegation: permdock.value.subject.delegation,
114
- expiresAt: permdock.value.subject.expiresAt,
115
- simulated
116
- };
117
- });
80
+ return computed(() => subjectView(permdock.value));
118
81
  }
119
82
  function useApproval(decision) {
120
83
  const store = useStore();
121
84
  const permdock = useTick(store);
122
85
  return computed(() => {
123
86
  permdock.value;
124
- const next = toValue(decision);
125
- return {
126
- state: store.approvalState(next),
127
- token: next.outcome === "approval-required" ? next.token : void 0,
128
- request: (note) => store.requestApproval(next, note)
129
- };
87
+ return approvalHandle(store, toValue(decision));
130
88
  });
131
89
  }
132
90
  //#endregion
91
+ //#region src/vue/boundary.ts
92
+ const boundaryKey = Symbol("permdock-boundary");
93
+ /**
94
+ * Catches `PermDockDeniedError` and `PermDockApprovalRequiredError` thrown
95
+ * by a descendant and renders the `denied` slot, or the `approval` slot for
96
+ * an approval request (default `denied`). The slots receive the refused
97
+ * permission and `retry()`. Any other error propagates.
98
+ */
99
+ const PermissionBoundary = defineComponent({
100
+ name: "PermissionBoundary",
101
+ setup(_props, { slots }) {
102
+ const state = shallowRef(null);
103
+ provide(boundaryKey, state);
104
+ onErrorCaptured((error) => {
105
+ const digest = boundaryDigest(error);
106
+ if (digest === null) return;
107
+ state.value = {
108
+ ...digest,
109
+ retry: () => {
110
+ state.value = null;
111
+ }
112
+ };
113
+ return false;
114
+ });
115
+ return () => {
116
+ const current = state.value;
117
+ if (current === null) return slots["default"]?.() ?? null;
118
+ return boundaryFallback(current, {
119
+ denied: slots["denied"],
120
+ approval: slots["approval"]
121
+ })?.(current) ?? null;
122
+ };
123
+ }
124
+ });
125
+ /** Inside a `PermissionBoundary`: what was refused and `retry()`, or `null` while the children render. */
126
+ function usePermissionBoundary() {
127
+ return inject(boundaryKey, null)?.value ?? null;
128
+ }
129
+ //#endregion
133
130
  //#region src/vue/plugin.ts
134
131
  const permdockPlugin = { install(app, options) {
135
132
  const source = options.snapshot;
136
133
  const promised = isPromiseLike(source);
137
- const store = createClientStore(compact({
138
- snapshot: promised ? emptySnapshot() : toValue(source),
139
- endpoint: options.endpoint,
140
- approvals: options.approvals,
141
- tenant: options.tenant,
134
+ const store = providerStore({
135
+ ...options,
136
+ tenant: toValue(options.tenant)
137
+ }, () => ({
138
+ headers: toValue(options.headers),
142
139
  fetch: options.fetch,
143
- headers: options.headers,
144
- maxAge: options.maxAge,
145
- verifier: options.verifier
146
- }));
147
- if (promised) store.follow(source);
148
- else if (isRef(source) || typeof source === "function") {
149
- const scope = effectScope(true);
150
- scope.run(() => {
151
- watch(() => toValue(source), (next) => {
152
- store.replace(next);
153
- });
140
+ verifier: toValue(options.verifier)
141
+ }), promised ? source : toValue(source));
142
+ const scope = effectScope(true);
143
+ scope.run(() => {
144
+ if (!promised && (isRef(source) || typeof source === "function")) watch(() => toValue(source), (next) => {
145
+ store.replace(next);
154
146
  });
155
- app.onUnmount(() => {
156
- scope.stop();
147
+ const tenant = options.tenant;
148
+ if (isRef(tenant) || typeof tenant === "function") watch(() => toValue(tenant), (next) => {
149
+ switchTenant(store, next);
157
150
  });
158
- }
151
+ });
152
+ app.onUnmount(() => {
153
+ scope.stop();
154
+ store.dispose();
155
+ });
159
156
  app.provide(permDockKey, store);
160
157
  } };
161
158
  //#endregion
@@ -168,7 +165,7 @@ const Protected = defineComponent({
168
165
  required: true
169
166
  },
170
167
  data: {
171
- type: Object,
168
+ type: null,
172
169
  required: false
173
170
  },
174
171
  tenant: {
@@ -179,25 +176,21 @@ const Protected = defineComponent({
179
176
  setup(props, { slots }) {
180
177
  const local = usePermission(() => props.permission, () => props.data);
181
178
  const root = usePermDock();
179
+ const scoped = computed(() => scopedTenant(root, props.tenant));
182
180
  return () => {
183
- const scoped = props.tenant === void 0 ? {
181
+ const view = protectedView({
184
182
  allowed: local.allowed.value,
185
183
  status: local.status.value,
186
184
  decision: local.decision.value
187
- } : tenantView(root.tenant(props.tenant), props.permission, props.data);
188
- if (scoped.status === "pending") return slots["pending"]?.() ?? null;
189
- if (!scoped.allowed || scoped.decision.outcome !== "granted") return slots["fallback"]?.({ decision: scoped.decision }) ?? null;
190
- return slots["default"]?.({ decision: scoped.decision }) ?? null;
185
+ }, root, props.permission, props.data, scoped.value);
186
+ switch (view.slot) {
187
+ case "pending": return slots["pending"]?.() ?? null;
188
+ case "fallback": return slots["fallback"]?.({ decision: view.decision }) ?? null;
189
+ case "default": return slots["default"]?.({ decision: view.decision }) ?? null;
190
+ default: return view;
191
+ }
191
192
  };
192
193
  }
193
194
  });
194
- function tenantView(permdock, permission, data) {
195
- const decision = permdock.decide(permission, data);
196
- return {
197
- allowed: decision.outcome === "granted",
198
- status: "ready",
199
- decision
200
- };
201
- }
202
195
  //#endregion
203
- export { Protected, approvalHeaders, describe, permdockPlugin, requiredPlans, useApproval, useAssignablePermissions, useAssignableRoles, useFilter, useMemberships, usePermDock, usePermission, usePermissions, useRoles, useSubject, useTenant };
196
+ export { PermissionBoundary, Protected, approvalHeaders, describe, permdockPlugin, requiredPlans, useApproval, useAssignablePermissions, useAssignableRoles, useFilter, useMemberships, usePermDock, usePermission, usePermissionBoundary, usePermissions, useRoles, useSubject, useTenant };
@@ -0,0 +1,2 @@
1
+ import { n as createCollectScheduler } from "./watch-UihESpsJ.js";
2
+ export { createCollectScheduler };
@@ -0,0 +1,128 @@
1
+ import { i as describeError } from "./errors-CWfoNg9N.js";
2
+ import { t as defaultSrcPath } from "./files-DWUN9PzI.js";
3
+ import { r as runCollect } from "./collect-DDDv_ESs.js";
4
+ import { n as isConfigFile, r as loadConfig } from "./config-BJiM-xAm.js";
5
+ import { watch } from "node:fs";
6
+ import { basename, dirname, relative, resolve, sep } from "node:path";
7
+ //#region src/cli/watch.ts
8
+ const DEBOUNCE_MS = 50;
9
+ function report(message) {
10
+ if (message !== void 0) process.stderr.write(`permdock: ${message}\n`);
11
+ }
12
+ function watchRoot(cwd, entry) {
13
+ const wildcard = entry.search(/[*?[{]/u);
14
+ return resolve(cwd, wildcard === -1 ? entry : dirname(`${entry.slice(0, wildcard)}x`));
15
+ }
16
+ function within(dirs, file) {
17
+ return dirs.some((dir) => {
18
+ const path = relative(dir, file);
19
+ return path !== "" && !path.startsWith("..") && !path.startsWith(sep);
20
+ });
21
+ }
22
+ async function collectOnce(cwd, options, check, fresh, configFile) {
23
+ const config = await loadConfig(cwd, configFile, { fresh });
24
+ const collect = {
25
+ ...config.collect,
26
+ ...options?.collect
27
+ };
28
+ const result = await runCollect({
29
+ cwd,
30
+ config,
31
+ collect,
32
+ check,
33
+ now: /* @__PURE__ */ new Date(),
34
+ fresh
35
+ });
36
+ const inputs = [
37
+ configFile,
38
+ config.permissions,
39
+ config.policy
40
+ ].filter((path) => path !== void 0).map((path) => resolve(cwd, path));
41
+ const sources = (collect.srcPath ?? defaultSrcPath()).map((entry) => watchRoot(cwd, entry));
42
+ const run = {
43
+ written: result.written ?? [],
44
+ inputs,
45
+ sources
46
+ };
47
+ if (result.code === 0) return {
48
+ message: void 0,
49
+ ...run
50
+ };
51
+ if (check && options?.onDrift !== "warn" && result.code === 1) throw new Error(result.message);
52
+ return {
53
+ message: result.message,
54
+ ...run
55
+ };
56
+ }
57
+ function createCollectScheduler(cwd, options, settings) {
58
+ const log = settings?.report ?? report;
59
+ let loaded = false;
60
+ let ignored = /* @__PURE__ */ new Set();
61
+ let inputs = [];
62
+ let sources = (options?.collect?.srcPath ?? defaultSrcPath()).map((entry) => watchRoot(cwd, entry));
63
+ let running = false;
64
+ let pending = false;
65
+ let timer;
66
+ const watchers = [];
67
+ async function run(check) {
68
+ const fresh = loaded;
69
+ loaded = true;
70
+ const result = await collectOnce(cwd, options, check, fresh, settings?.configFile);
71
+ ignored = new Set(result.written);
72
+ inputs = result.inputs;
73
+ sources = result.sources;
74
+ return result.message;
75
+ }
76
+ async function drain() {
77
+ running = true;
78
+ while (pending) {
79
+ pending = false;
80
+ try {
81
+ log(await run(false));
82
+ } catch (error) {
83
+ log(describeError(error));
84
+ }
85
+ }
86
+ running = false;
87
+ }
88
+ function changed(file) {
89
+ if (file !== void 0 && ignored.has(resolve(cwd, file))) return;
90
+ pending = true;
91
+ if (running) return;
92
+ clearTimeout(timer);
93
+ timer = setTimeout(() => {
94
+ drain();
95
+ }, DEBOUNCE_MS);
96
+ }
97
+ function watchDir(dir, recursive, accept) {
98
+ try {
99
+ watchers.push(watch(dir, { recursive }, (_event, name) => {
100
+ if (name === null) {
101
+ changed(void 0);
102
+ return;
103
+ }
104
+ const file = resolve(dir, name);
105
+ if (accept(file)) changed(file);
106
+ }));
107
+ } catch {}
108
+ }
109
+ function startWatch() {
110
+ if (watchers.length > 0) return;
111
+ for (const dir of sources) watchDir(dir, true, () => true);
112
+ const loose = inputs.filter((file) => !within(sources, file));
113
+ const dirs = /* @__PURE__ */ new Set([cwd, ...loose.map((file) => dirname(file))]);
114
+ for (const dir of dirs) watchDir(dir, false, (file) => loose.includes(file) || dir === cwd && isConfigFile(basename(file)));
115
+ }
116
+ function close() {
117
+ clearTimeout(timer);
118
+ for (const watcher of watchers.splice(0)) watcher.close();
119
+ }
120
+ return {
121
+ run,
122
+ changed,
123
+ watch: startWatch,
124
+ close
125
+ };
126
+ }
127
+ //#endregion
128
+ export { createCollectScheduler as n, report as r, collectOnce as t };
@@ -1,5 +1,5 @@
1
- import { Mn as Decision, gt as Snapshot } from "../policy-CInmNGkM.js";
2
- import { d as Permission, p as PermissionTree } from "../permissions-B4apnahQ.js";
1
+ import { Tt as Snapshot, Yn as Decision } from "../policy-CFZAr_Al.js";
2
+ import { f as Permission, m as PermissionTree } from "../permissions-DttnqqxC.js";
3
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
4
4
  //#region src/webmcp/types.d.ts
5
5
  type WebMcpClientStatus = "ready" | "pending" | "stale" | "server-only";
@@ -1,8 +1,10 @@
1
1
  import { t as compact } from "../compact-y6vfu2_f.js";
2
- import { b as resourceOfNode, g as listPermissions, m as isRegistryTree, s as getRegistry, t as annotationsFor } from "../permissions-DC7GROPA.js";
3
- import { t as describe } from "../describe-Bt1YD5uS.js";
4
- import { i as PermDockValidationError, s as wireDenials } from "../errors-Iy71s7Oj.js";
2
+ import { _ as listPermissions, h as isRegistryTree, s as getRegistry, t as annotationsFor, x as resourceOfNode } from "../permissions-DVoF6dMt.js";
3
+ import { n as PermDockValidationError } from "../validation-error-CnjZ4t92.js";
4
+ import { a as wireDenials } from "../problem-details-_AMOYz-w.js";
5
+ import { t as describe } from "../describe-B_gVZEVi.js";
5
6
  import { n as isThenable, t as ignoreRejection } from "../thenable-okc2xDsj.js";
7
+ import { n as resourceRef } from "../resource-ref-CaS9yVPi.js";
6
8
  //#region src/webmcp/register.ts
7
9
  const MISSING_CONTEXT = "permdock/webmcp: document.modelContext is absent; registerTools is a no-op.";
8
10
  function isRecord(value) {
@@ -98,14 +100,6 @@ function bindTenant(input, tenantKey, tenant) {
98
100
  }
99
101
  };
100
102
  }
101
- function resourceRef(permission, data) {
102
- if (permission.kind === "collection" || !isRecord(data)) return { type: permission.resource };
103
- const id = data["id"];
104
- return typeof id === "string" || typeof id === "number" ? {
105
- type: permission.resource,
106
- id: String(id)
107
- } : { type: permission.resource };
108
- }
109
103
  function alternativesOf(decision) {
110
104
  return decision.alternatives.map((leaf) => leaf.key);
111
105
  }
@@ -122,7 +116,7 @@ function deniedResult(decision, permission, data) {
122
116
  structuredContent: compact({
123
117
  outcome: "denied",
124
118
  permission: permission.key,
125
- resource: resourceRef(permission, data),
119
+ resource: resourceRef(permission, permission.kind === "collection" ? void 0 : data),
126
120
  denials: wireDenials(decision.denials),
127
121
  alternatives,
128
122
  detail: described.detail
@@ -138,7 +132,7 @@ function approvalResult(decision, permission, data) {
138
132
  structuredContent: {
139
133
  outcome: "approval-required",
140
134
  permission: permission.key,
141
- resource: resourceRef(permission, data),
135
+ resource: resourceRef(permission, permission.kind === "collection" ? void 0 : data),
142
136
  token: decision.token
143
137
  }
144
138
  };