permdock 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/a2a/index.d.ts +4 -4
  2. package/dist/a2a/index.js +3 -3
  3. package/dist/{action-result-CL-QCITA.d.ts → action-result-BcudBQOF.d.ts} +1 -1
  4. package/dist/{adoption-scan-BLs67P1l.js → adoption-scan-Ch07MdxN.js} +1 -1
  5. package/dist/agent/index.d.ts +2 -2
  6. package/dist/agent/index.js +1 -1
  7. package/dist/ai-sdk/index.d.ts +3 -3
  8. package/dist/ai-sdk/index.js +3 -3
  9. package/dist/{approval-prompt-PYagyQUj.d.ts → approval-prompt-3BqWczTt.d.ts} +1 -1
  10. package/dist/approvals/index.d.ts +3 -3
  11. package/dist/{arazzo-3RhGfkAK.js → arazzo-BpS7LnV0.js} +1 -1
  12. package/dist/{arazzo-B5-ulWif.js → arazzo-CmQaGPkM.js} +2 -2
  13. package/dist/astro/index.d.ts +4 -4
  14. package/dist/astro/index.js +1 -1
  15. package/dist/{audience-BAkBDMqn.js → audience-DTjR8xet.js} +1 -1
  16. package/dist/authzen/index.d.ts +5 -5
  17. package/dist/authzen/index.js +1 -1
  18. package/dist/{automation-DqEoWHBc.d.ts → automation-C6Jg75xq.d.ts} +1 -1
  19. package/dist/better-auth/index.d.ts +1 -1
  20. package/dist/better-supabase/index.d.ts +6 -6
  21. package/dist/better-supabase/index.js +3 -3
  22. package/dist/{bind-D_sZSVA3.js → bind-BNQA9JK9.js} +7 -3
  23. package/dist/{bind-Cp2hBHzP.d.ts → bind-YYjvfpB9.d.ts} +12 -7
  24. package/dist/{build-instance-CNWaYJyr.js → build-instance-BWXqwQYU.js} +1 -1
  25. package/dist/{capability-ChuiONQU.d.ts → capability-Di9tiUvi.d.ts} +1 -1
  26. package/dist/{casbin-cbSbhT_k.js → casbin-B7_yS-oo.js} +1 -1
  27. package/dist/{casbin-H0rKxBx2.js → casbin-bHyIxTNQ.js} +1 -1
  28. package/dist/catalog/index.d.ts +4 -4
  29. package/dist/catalog/index.js +2 -2
  30. package/dist/{catalog-BFpz2EmT.js → catalog-CGlSwU6j.js} +2 -2
  31. package/dist/catalog-D3oS2GH3.js +1 -0
  32. package/dist/{catalog-DCspHDc8.js → catalog-amPDr0JQ.js} +1 -1
  33. package/dist/{catalog-operations-Dadrl7Z-.js → catalog-operations-DeHTrJSV.js} +1 -1
  34. package/dist/chat/index.d.ts +1 -1
  35. package/dist/chat/index.js +1 -1
  36. package/dist/chat-sdk/index.d.ts +3 -3
  37. package/dist/claude-agent/index.d.ts +3 -3
  38. package/dist/claude-agent/index.js +2 -2
  39. package/dist/clerk/index.d.ts +2 -2
  40. package/dist/cli/bin.js +1 -1
  41. package/dist/cli/index.d.ts +4 -4
  42. package/dist/cli/index.js +2 -2
  43. package/dist/cloud/index.d.ts +8 -8
  44. package/dist/{cloud-BFlGMaak.js → cloud-3kWfjnYy.js} +2 -2
  45. package/dist/{codemod-DWSN2erG.js → codemod-Bv5i-Mzo.js} +1 -1
  46. package/dist/{codemod-DLQ9Zpo4.js → codemod-D9Aiii1r.js} +2 -2
  47. package/dist/{collect-Bzv3le0A.js → collect-B80GYEot.js} +2 -2
  48. package/dist/collect-D-eroIfV.js +1 -0
  49. package/dist/{collect-B7ZFAJU3.js → collect-WCl8cJQV.js} +1 -1
  50. package/dist/compile/index.d.ts +1 -1
  51. package/dist/{compile-BFzysW3o.d.ts → compile-BEklRUYo.d.ts} +2 -2
  52. package/dist/{completion-saoYiRFO.js → completion-_bc0OUQ-.js} +1 -1
  53. package/dist/{config-DBeXXmBF.js → config-D5XrLWpk.js} +1 -1
  54. package/dist/{config-report-BipSWA6V.js → config-report-BmWIskD7.js} +2 -2
  55. package/dist/convex/index.d.ts +4 -4
  56. package/dist/convex/index.js +2 -2
  57. package/dist/{core-hWIARPDz.d.ts → core-CFepFiDP.d.ts} +2 -2
  58. package/dist/{core-H-mbhpZc.js → core-DzVINFbU.js} +3 -3
  59. package/dist/{create-Cq4Uox0f.js → create-6EwRQlig.js} +3 -3
  60. package/dist/{create-_noSrY1T.js → create-BLPKnJKa.js} +23 -7
  61. package/dist/{create-BSNrVuxh.d.ts → create-BPUopdfL.d.ts} +7 -7
  62. package/dist/{create-CM1FciYG.d.ts → create-BamXmeob.d.ts} +6 -6
  63. package/dist/{create-BVq1lNQE.d.ts → create-DBvUsgzK.d.ts} +4 -4
  64. package/dist/delivery/index.d.ts +4 -4
  65. package/dist/delivery/index.js +1 -1
  66. package/dist/{denied-text-CHNlVInN.d.ts → denied-text-DHldhVUv.d.ts} +1 -1
  67. package/dist/{describe-ByS9LgHK.d.ts → describe-BbFPBSms.d.ts} +1 -1
  68. package/dist/{diff-CN8IYhC_.js → diff-BwR1JdP2.js} +1 -1
  69. package/dist/{diff-iZWV65nC.js → diff-CQegtBAo.js} +2 -2
  70. package/dist/{doctor-CHD1M9R5.js → doctor-ClRVAtXQ.js} +13 -13
  71. package/dist/{doctor-D3wo-yuz.js → doctor-LPMYjSqO.js} +2 -2
  72. package/dist/drizzle/index.d.ts +3 -3
  73. package/dist/elysia/index.d.ts +4 -4
  74. package/dist/elysia/index.js +1 -1
  75. package/dist/{errors-zi_4T-rx.d.ts → errors-BIM4MFsJ.d.ts} +1 -1
  76. package/dist/{evaluate-Dd8Ta0Ie.js → evaluate-BAmf_AQd.js} +13 -4
  77. package/dist/{evaluations-z8dQFDaN.d.ts → evaluations-DOWuBpWv.d.ts} +3 -3
  78. package/dist/eve/index.d.ts +4 -4
  79. package/dist/eve/index.js +2 -2
  80. package/dist/express/index.d.ts +4 -4
  81. package/dist/express/index.js +1 -1
  82. package/dist/fastify/index.d.ts +4 -4
  83. package/dist/fastify/index.js +1 -1
  84. package/dist/{fetch-adapter-C1DCvpqV.d.ts → fetch-adapter-BIbBAtPZ.d.ts} +2 -2
  85. package/dist/{fetch-adapter-JL43jD3E.js → fetch-adapter-dPTgJVHd.js} +1 -1
  86. package/dist/{gen-B5kvbAoZ.js → gen-BFfzZSLH.js} +1 -1
  87. package/dist/{gen-DWCYcMQM.js → gen-BtfFWGbz.js} +2 -2
  88. package/dist/h3/index.d.ts +4 -4
  89. package/dist/h3/index.js +2 -2
  90. package/dist/hono/index.d.ts +4 -4
  91. package/dist/hono/index.js +1 -1
  92. package/dist/{hosted-Cmtxogd0.d.ts → hosted-DVxlLZMe.d.ts} +1 -1
  93. package/dist/{import-_YqhhwvX.js → import-ACkOrv6g.js} +1 -1
  94. package/dist/{index-BhxEUY9J.d.ts → index-BinlXeU-.d.ts} +2 -2
  95. package/dist/{index-B8s204GL.d.ts → index-CV-7DWeD.d.ts} +4 -4
  96. package/dist/{index-_9UiQIkt.d.ts → index-DJwEgYzA.d.ts} +4 -4
  97. package/dist/{index-BT5-1VsX.d.ts → index-Dj2qF9VC.d.ts} +1 -1
  98. package/dist/{index-BW_0MZOS.d.ts → index-vYjMrXyK.d.ts} +62 -9
  99. package/dist/{index-Bv5iXPqU.d.ts → index-ymept53A.d.ts} +4 -4
  100. package/dist/index.d.ts +15 -15
  101. package/dist/index.js +6 -6
  102. package/dist/{init-cE3A8aXq.js → init-BjuFDYT1.js} +1 -1
  103. package/dist/{init-Dz_PsHdv.js → init-txYTuW9u.js} +3 -3
  104. package/dist/{instance-options-B0KXqTrJ.d.ts → instance-options-CoHn-0e8.d.ts} +1 -1
  105. package/dist/{instance-snapshot--JWiTrvO.js → instance-snapshot-DuWf1cT3.js} +13 -8
  106. package/dist/jwt/index.d.ts +4 -4
  107. package/dist/jwt/index.js +1 -1
  108. package/dist/{kernel-C-fYydV2.js → kernel-qv4cr9w8.js} +4 -4
  109. package/dist/kysely/index.d.ts +3 -3
  110. package/dist/{login-D-8tMqzo.js → login-CfImTJGb.js} +3 -3
  111. package/dist/{login-DplQ0s84.js → login-CgfCTO3F.js} +1 -1
  112. package/dist/{manifest-Cgiq5oqc.js → manifest-B2QPh19C.js} +35 -35
  113. package/dist/{map-claims-BNWCJtmP.js → map-claims-C-nv08_n.js} +2 -1
  114. package/dist/mcp/index.d.ts +8 -8
  115. package/dist/mcp/index.js +4 -4
  116. package/dist/nest/index.d.ts +4 -4
  117. package/dist/nest/index.js +1 -1
  118. package/dist/next/index.d.ts +16 -9
  119. package/dist/next/index.js +14 -7
  120. package/dist/next/plugin.d.ts +1 -1
  121. package/dist/next/plugin.js +1 -1
  122. package/dist/node/index.d.ts +4 -4
  123. package/dist/node/index.js +1 -1
  124. package/dist/openai/index.d.ts +4 -4
  125. package/dist/openai/index.js +3 -3
  126. package/dist/openapi/index.d.ts +2 -2
  127. package/dist/{openapi-VeHHU2l9.js → openapi-BGeuunWC.js} +1 -1
  128. package/dist/{openapi-CBZUhA3l.js → openapi-BIpw3Mb7.js} +2 -2
  129. package/dist/orpc/index.d.ts +5 -5
  130. package/dist/orpc/index.js +2 -2
  131. package/dist/otel/index.d.ts +3 -3
  132. package/dist/{output-tkju6U7R.js → output-DV5dwOTs.js} +1 -1
  133. package/dist/{ownership-B4L59T9u.js → ownership-DA5YdYTm.js} +9 -4
  134. package/dist/{parse-local-manifest-BQhTlLQS.d.ts → parse-local-manifest-CCmbhnxP.d.ts} +1 -1
  135. package/dist/pdp/index.d.ts +3 -3
  136. package/dist/pdp/index.js +1 -1
  137. package/dist/{permdock-L-_I_3zP.js → permdock-BvjivVb9.js} +143 -107
  138. package/dist/{permdock-B6Sf4T_S.d.ts → permdock-CprAPN3w.d.ts} +9 -2
  139. package/dist/{permissions-mDcTWoBs.js → permissions-CYcHj_w7.js} +1 -1
  140. package/dist/{policy-Ba4bDhaj.d.ts → policy-BycVKnXv.d.ts} +1 -1
  141. package/dist/{policy-from-catalog-CJgOm6aq.js → policy-from-catalog-CU3An8uP.js} +1 -1
  142. package/dist/{policy-types-CCiDRZBH.d.ts → policy-types-DGIO_gxq.d.ts} +54 -18
  143. package/dist/{postgrest-D4nuPXIQ.js → postgrest-5Dr3W64L.js} +34 -55
  144. package/dist/{postgrest-DicQyqm-.d.ts → postgrest-D5nUGm-c.d.ts} +4 -3
  145. package/dist/powersync-B701tvhE.js +1 -0
  146. package/dist/{powersync-DXqGuq9A.js → powersync-Bg8u-JcR.js} +2 -2
  147. package/dist/{powersync-DHNQX06W.js → powersync-CJrT1DSc.js} +5 -5
  148. package/dist/prisma/index.d.ts +2 -2
  149. package/dist/{protected-action-BE7N_Luo.d.ts → protected-action-D8x73IGm.d.ts} +6 -6
  150. package/dist/{provider-DXfq5c2d.d.ts → provider-DfLeek9O.d.ts} +1 -1
  151. package/dist/{pull-CwpGaQSi.js → pull-2nJr0qg_.js} +1 -1
  152. package/dist/pull-C3EEGzSw.js +1 -0
  153. package/dist/{push-DgssgzkK.js → push-Bn-lMEmI.js} +2 -2
  154. package/dist/{pushed-policy-ITwYKvvH.js → pushed-policy-CDuOL2de.js} +1 -1
  155. package/dist/{pushed-policy-D1Eoi6NM.d.ts → pushed-policy-CryQheKq.d.ts} +1 -1
  156. package/dist/react/index.d.ts +7 -7
  157. package/dist/react/provider-client.d.ts +1 -1
  158. package/dist/react-native/index.d.ts +9 -9
  159. package/dist/{replay-DNftIb_R.d.ts → replay-Bs9Df2fQ.d.ts} +1 -1
  160. package/dist/{request-context-C25ilqiJ.js → request-context-Duzdf0cd.js} +1 -1
  161. package/dist/resend/index.d.ts +4 -4
  162. package/dist/{resolve-names-CF7xXLSG.js → resolve-names-ConCSj1y.js} +1 -1
  163. package/dist/{rls-Ca8Jz9b5.js → rls-Ba9wN0SP.js} +1 -1
  164. package/dist/{rls-CNEH2_BG.js → rls-Cx0dtsB7.js} +20 -13
  165. package/dist/{rpc-fNqAIqQk.js → rpc-vHIwyXCp.js} +1 -1
  166. package/dist/run-Ck22anC2.js +1 -0
  167. package/dist/{run-Bz26OTfO.js → run-PbRlXTfh.js} +2 -2
  168. package/dist/{run-ticket-DbWI9f99.d.ts → run-ticket-B2o2Kxz8.d.ts} +2 -2
  169. package/dist/{saas-iWnUdwCt.js → saas-DK4V-3Is.js} +2 -2
  170. package/dist/{scan-DCj1KQfn.js → scan-CRTj6fke.js} +1 -1
  171. package/dist/{schema-Dst9I9Gs.js → schema-BTsE1WRT.js} +1 -1
  172. package/dist/scim/index.d.ts +1 -1
  173. package/dist/server/index.d.ts +10 -10
  174. package/dist/server/index.js +1 -1
  175. package/dist/{server-types-CIlpSA2G.d.ts → server-types-CyRN0-Cd.d.ts} +15 -8
  176. package/dist/{sink-Dvi7YZG_.d.ts → sink-B5zoUW_O.d.ts} +2 -2
  177. package/dist/{skills-OuoMR49L.js → skills-C9uKfSF5.js} +1 -1
  178. package/dist/{skills-Bjj7BNEQ.js → skills-CQQcuGBi.js} +1 -1
  179. package/dist/{snapshot-cache-BAXZ0KOp.d.ts → snapshot-cache-BjAWkchD.d.ts} +1 -1
  180. package/dist/solid/index.d.ts +6 -6
  181. package/dist/solid-start/index.d.ts +4 -4
  182. package/dist/solid-start/index.js +2 -2
  183. package/dist/{sources-B1Os_YUu.d.ts → sources-CWG32C0G.d.ts} +2 -2
  184. package/dist/{src-DZ0l9UAg.js → src-C_pi2Rnh.js} +106 -5
  185. package/dist/ssf/index.d.ts +3 -3
  186. package/dist/{standard-webhooks-C-qX4mJW.d.ts → standard-webhooks-DOYEuOLx.d.ts} +2 -2
  187. package/dist/{stores-C0Kta5Ft.d.ts → stores-DZJvxFIZ.d.ts} +6 -6
  188. package/dist/{stream-ltuLdtTG.d.ts → stream-9y9qw51m.d.ts} +1 -1
  189. package/dist/supabase/index.d.ts +5 -5
  190. package/dist/supabase/index.js +2 -2
  191. package/dist/supabase/middleware.d.ts +5 -5
  192. package/dist/supabase/middleware.js +4 -4
  193. package/dist/{supabase-BL1qJzzY.js → supabase-DnMMg5Fn.js} +1 -1
  194. package/dist/{supabase-D39cuGPt.js → supabase-SBs3MYUE.js} +2 -2
  195. package/dist/supabase-hook-C0FyEACZ.js +1 -0
  196. package/dist/{supabase-hook-B-yXnzUl.js → supabase-hook-CrgU06WH.js} +5 -5
  197. package/dist/{supautils-BU-pAEpf.js → supautils-ByezN3b8.js} +244 -197
  198. package/dist/svelte/index.d.ts +6 -6
  199. package/dist/svelte/runtime.d.ts +3 -3
  200. package/dist/svelte/source.d.ts +6 -6
  201. package/dist/sveltekit/index.d.ts +4 -4
  202. package/dist/sveltekit/index.js +1 -1
  203. package/dist/{tables-DeMNEy6V.js → tables-BqrxBCir.js} +1 -1
  204. package/dist/tanstack-start/index.d.ts +4 -4
  205. package/dist/tanstack-start/index.js +1 -1
  206. package/dist/terminal/index.d.ts +5 -5
  207. package/dist/terminal/index.js +2 -2
  208. package/dist/testing/core.d.ts +1 -1
  209. package/dist/testing/core.js +1 -1
  210. package/dist/testing/index.d.ts +21 -20
  211. package/dist/testing/index.js +61 -8
  212. package/dist/testing/saas/index.d.ts +3 -3
  213. package/dist/testing/saas/index.js +2 -2
  214. package/dist/testing/saas/permissions.js +1 -1
  215. package/dist/trpc/index.d.ts +5 -5
  216. package/dist/trpc/index.js +2 -2
  217. package/dist/{type-helpers-BIPIDa6a.d.ts → type-helpers-c7Xo_2Cu.d.ts} +1 -1
  218. package/dist/{types-B2mlGuhW.d.ts → types-B2efzoSX.d.ts} +1 -1
  219. package/dist/{types-DHKPcqzr.d.ts → types-B6ExllNo.d.ts} +2 -2
  220. package/dist/{types-AMJ5qoU_.d.ts → types-BB-zWDcR.d.ts} +4 -4
  221. package/dist/{types-ah9NlU6j.d.ts → types-BMVDHvI0.d.ts} +1 -1
  222. package/dist/{types-djVzLlIV.d.ts → types-CEinc15V.d.ts} +4 -4
  223. package/dist/{types-yUuPR5Hy.d.ts → types-CN0LsqbK.d.ts} +3 -3
  224. package/dist/{types-HzqOtvsJ.d.ts → types-CWBsAwqn.d.ts} +4 -4
  225. package/dist/{types-DC1Loeh3.d.ts → types-CzOeVvcC.d.ts} +5 -3
  226. package/dist/{types-B_tiYvk8.d.ts → types-DLvhVm1r.d.ts} +1 -1
  227. package/dist/{types-B4uqKDnp.d.ts → types-DlelvQk4.d.ts} +2 -2
  228. package/dist/{types-DjuMBNF9.d.ts → types-DsHGPtkR.d.ts} +2 -2
  229. package/dist/{types-BJk0BKRX.d.ts → types-rCRV4Ge-.d.ts} +4 -4
  230. package/dist/{types-B_d_g7T3.d.ts → types-tQB2CEnY.d.ts} +4 -4
  231. package/dist/unplugin/index.d.ts +1 -1
  232. package/dist/unplugin/index.js +1 -1
  233. package/dist/usage-0hjZPIRX.js +1 -0
  234. package/dist/{usage-CxEzS4ey.js → usage-B9EtHWLa.js} +3 -3
  235. package/dist/{usage-ab0PdusX.js → usage-CBzgwfIs.js} +1 -1
  236. package/dist/{validation-error-YGg2mXyH.d.ts → validation-error-uvp-kyfO.d.ts} +1 -1
  237. package/dist/{verify-DZeqoWu5.js → verify-DlUcTDBz.js} +6 -6
  238. package/dist/vue/index.d.ts +6 -6
  239. package/dist/{waiter-Bu9zAlE0.d.ts → waiter-CqUKX6CY.d.ts} +2 -2
  240. package/dist/{watch-Cx_WciLE.js → watch-BFDKqmUa.js} +1 -1
  241. package/dist/watch-ClLuO2TL.js +1 -0
  242. package/dist/webmcp/index.d.ts +1 -1
  243. package/dist/{who-can-rI7dCR9Q.js → who-can-BoDJm0Nc.js} +1 -1
  244. package/dist/workflow/index.d.ts +3 -3
  245. package/dist/workflow/index.js +1 -1
  246. package/dist/workflow-sdk/index.d.ts +4 -4
  247. package/dist/{wrap-DlJE3gS_.d.ts → wrap-DxXB54Wu.d.ts} +2 -2
  248. package/package.json +2 -2
  249. package/skills/permdock-data/references/queries-and-rls.md +1 -1
  250. package/skills/permdock-wire/references/adapters.md +2 -1
  251. package/dist/catalog-mRQQQhNK.js +0 -1
  252. package/dist/collect-B5BL3klN.js +0 -1
  253. package/dist/powersync-Djf-zCpB.js +0 -1
  254. package/dist/pull-B65ndFNZ.js +0 -1
  255. package/dist/run-D-JE8QWb.js +0 -1
  256. package/dist/supabase-hook-H-MtE9Wd.js +0 -1
  257. package/dist/usage-CYeXek0p.js +0 -1
  258. package/dist/watch-DB42U1ib.js +0 -1
@@ -80,7 +80,7 @@ const emit = defineLeaf({
80
80
  }
81
81
  },
82
82
  async run(ctx, { flags }) {
83
- return (await import("./openapi-VeHHU2l9.js")).runOpenapi({
83
+ return (await import("./openapi-BGeuunWC.js")).runOpenapi({
84
84
  cwd: ctx.cwd,
85
85
  config: ctx.config,
86
86
  rest: ["emit"],
@@ -122,7 +122,7 @@ const importDocument = defineLeaf({
122
122
  async run(ctx, { flags }) {
123
123
  const doc = given(flags.doc);
124
124
  if (doc === void 0) throw missingInput("openapi import", ["--doc"], "the OpenAPI document to import");
125
- return (await import("./import-_YqhhwvX.js")).runOpenapiImport({
125
+ return (await import("./import-ACkOrv6g.js")).runOpenapiImport({
126
126
  cwd: ctx.cwd,
127
127
  doc,
128
128
  out: fileOut("openapi import", flags.out),
@@ -1,11 +1,11 @@
1
- import { T as Policy, j as PolicyVocabulary, sr as Principal } from "../policy-types-CCiDRZBH.js";
1
+ import { T as Policy, j as PolicyVocabulary, pr as Principal } from "../policy-types-DGIO_gxq.js";
2
2
  import { u as Permission } from "../permission-types-CAY-GU7e.js";
3
3
  import { a as OperationInput, t as Operation } from "../operations-Ci_rT6Uo.js";
4
- import { a as PermDock } from "../permdock-B6Sf4T_S.js";
4
+ import { a as PermDock } from "../permdock-CprAPN3w.js";
5
5
  import { n as RevocationFeed } from "../revocations-BaUXHM1N.js";
6
- import { D as ConnectionOptions, T as Connection, i as OpenApiHooks } from "../server-types-CIlpSA2G.js";
7
- import { t as ServerAdapterOptions } from "../bind-Cp2hBHzP.js";
8
- import { t as StreamProtectOptions } from "../stream-ltuLdtTG.js";
6
+ import { D as ConnectionOptions, T as Connection, i as OpenApiHooks } from "../server-types-CyRN0-Cd.js";
7
+ import { t as ServerAdapterOptions } from "../bind-YYjvfpB9.js";
8
+ import { t as StreamProtectOptions } from "../stream-9y9qw51m.js";
9
9
  import { AnySchema, MetaPlugin, Middleware, Procedure, Schema } from "@orpc/server";
10
10
  import { StandardSchemaV1 } from "@standard-schema/spec";
11
11
  //#region src/orpc/operations.d.ts
@@ -2,9 +2,9 @@ import { t as compact } from "../compact-CAf557ZB.js";
2
2
  import { o as isPermission } from "../permission-registry-B8tYxPIt.js";
3
3
  import { o as problemMessage } from "../http-DKLXrFGk.js";
4
4
  import { t as problemFromError } from "../map-error-pasIGqMT.js";
5
- import { n as attached } from "../bind-D_sZSVA3.js";
5
+ import { n as attached } from "../bind-BNQA9JK9.js";
6
6
  import { i as isAsyncIterable, o as reloadAfter } from "../stream-CDvF0sJm.js";
7
- import { i as rpcCode, n as guardStream, r as problemBody, t as bindRpcKernel } from "../rpc-fNqAIqQk.js";
7
+ import { i as rpcCode, n as guardStream, r as problemBody, t as bindRpcKernel } from "../rpc-vHIwyXCp.js";
8
8
  import { ORPCError, os } from "@orpc/server";
9
9
  //#region src/orpc/operations.ts
10
10
  const root = os;
@@ -1,6 +1,6 @@
1
- import { j as PolicyVocabulary } from "../policy-types-CCiDRZBH.js";
2
- import { a as PermDock } from "../permdock-B6Sf4T_S.js";
3
- import { a as OtelOptions, i as OtelApi, n as GEN_AI_TOOL_CALL_ID, o as OtelWrap, r as GEN_AI_TOOL_NAME, s as StructuralLogger, t as GENAI_SEMCONV_PIN } from "../types-DHKPcqzr.js";
1
+ import { j as PolicyVocabulary } from "../policy-types-DGIO_gxq.js";
2
+ import { a as PermDock } from "../permdock-CprAPN3w.js";
3
+ import { a as OtelOptions, i as OtelApi, n as GEN_AI_TOOL_CALL_ID, o as OtelWrap, r as GEN_AI_TOOL_NAME, s as StructuralLogger, t as GENAI_SEMCONV_PIN } from "../types-B6ExllNo.js";
4
4
  //#region src/otel/instrument.d.ts
5
5
  /**
6
6
  * Listens on one instance. Spans carry no duration and no histogram is
@@ -1,5 +1,5 @@
1
1
  import { s as cliVersion } from "./version-DMQ0dnN5.js";
2
- import { t as DOCS_BASE } from "./manifest-Cgiq5oqc.js";
2
+ import { t as DOCS_BASE } from "./manifest-B2QPh19C.js";
3
3
  //#region src/cli/core/output.ts
4
4
  const CLI_RESULT_SCHEMA = "https://permdock.com/schemas/cli-result-v1.json";
5
5
  function envelope(input) {
@@ -11,7 +11,7 @@ import { i as qualifySqlTable } from "./sql-0WjxIp9g.js";
11
11
  import { a as scopeMembershipTable, i as scopeColumn, s as relatedSql } from "./compile-EzEMB-7v.js";
12
12
  import { l as roleColumn } from "./sources-CMAM-2A3.js";
13
13
  import { A as quoteQualified, D as qualified, E as helperSchema, L as sqlType, M as textArrayLiteral, O as quoteIdent, R as tenantTypeOf, S as CLAIM, T as declaredArray, _ as subjectClaimJsonSql, b as tenantClaimSql, d as keyTenantSql, f as kindFilterSql, h as roleKindSql, j as quoteTable, k as quoteLiteral, m as memberVia, p as liveSessionSql, s as signedIn, t as CUSTOM_ROLES, u as globalKindFilterSql, v as subjectClaimSql, y as subjectIdSql } from "./shared-Afctg7B0.js";
14
- import { $ as graphSqlText, A as claimKeptLines, B as hasCustomRoleChecksFor, F as globalRoleRows, I as membershipRows, L as roleRows, M as memberColumn, N as sourceFilters, P as sourcesKeep, U as storedTenant, X as CLOSURE, Z as graphHelper, _t as activeMembershipSql, c as holderSources, ct as memberIdsHelper, d as sourceRowsSql, f as sourceTransferTriggerSql, g as OWNERSHIP, gt as activeInstancesSql, h as ASSIGNMENTS, ht as scopeTable, it as linkHelper, j as disabledColumn, l as pairsSql, m as transferTriggerSql, mt as scopeSources, nt as inheritedRowsHelper, p as holdersTriggerSql, pt as restrictedHelper, st as memberForTable, u as sourceHoldersTriggerSql, ut as memberRoleOf, yt as activeUserSql } from "./tables-DeMNEy6V.js";
14
+ import { $ as graphSqlText, A as claimKeptLines, B as hasCustomRoleChecksFor, F as globalRoleRows, I as membershipRows, L as roleRows, M as memberColumn, N as sourceFilters, P as sourcesKeep, U as storedTenant, X as CLOSURE, Z as graphHelper, _t as activeMembershipSql, c as holderSources, ct as memberIdsHelper, d as sourceRowsSql, f as sourceTransferTriggerSql, g as OWNERSHIP, gt as activeInstancesSql, h as ASSIGNMENTS, ht as scopeTable, it as linkHelper, j as disabledColumn, l as pairsSql, m as transferTriggerSql, mt as scopeSources, nt as inheritedRowsHelper, p as holdersTriggerSql, pt as restrictedHelper, st as memberForTable, u as sourceHoldersTriggerSql, ut as memberRoleOf, yt as activeUserSql } from "./tables-BqrxBCir.js";
15
15
  //#region src/cli/sql/conditions.ts
16
16
  const MAX_CLAIM_DEPTH = 8;
17
17
  /**
@@ -319,6 +319,10 @@ function sqlFunctionNames(condition) {
319
319
  default: return condition;
320
320
  }
321
321
  }
322
+ function candidateIds(ctx, field, wrap) {
323
+ return ctx.candidates === void 0 ? "" : wrap(`array(select ${quoteIdent(field)}::text from ${ctx.candidates})`);
324
+ }
325
+ const idsArgument = (ids) => `, ${ids}`;
322
326
  /**
323
327
  * A `related` condition as uncorrelated subqueries, so Postgres runs the helper
324
328
  * once per statement: the row's field in the closure's descendants of the ids
@@ -331,12 +335,13 @@ function compileRelatedSql(condition, ctx) {
331
335
  const type = ctx.columnTypes?.[condition.field];
332
336
  const cast = type === void 0 || type === "text" ? "" : `::${type}`;
333
337
  const column = type === void 0 ? `${quoteIdent(condition.field)}::text` : quoteIdent(condition.field);
334
- const helper = condition.permission === void 0 ? `${qualified(ctx, graphHelper(condition.resource))}(${quoteLiteral(condition.relation)})` : `${qualified(ctx, inheritedRowsHelper(condition.resource))}(${quoteLiteral(condition.permission)})`;
338
+ const helper = condition.permission === void 0 ? `${qualified(ctx, graphHelper(condition.resource))}(${quoteLiteral(condition.relation)})` : `${qualified(ctx, inheritedRowsHelper(condition.resource))}(${quoteLiteral(condition.permission)}${condition.depth === 0 ? candidateIds(ctx, condition.field, idsArgument) : ""})`;
335
339
  const cap = ctx.graph?.closures[condition.resource];
336
340
  let inner;
337
341
  if (condition.depth > 0 && cap !== void 0) {
338
342
  const depth = condition.depth < cap ? ` and depth <= ${String(condition.depth)}` : "";
339
- inner = `select descendant${cast} from ${qualified(ctx, CLOSURE.table)} where resource = ${quoteLiteral(condition.resource)}${depth} and ancestor = any (array(select ${helper}))`;
343
+ const narrowed = candidateIds(ctx, condition.field, (ids) => ` and descendant = any (${ids})`);
344
+ inner = `select descendant${cast} from ${qualified(ctx, CLOSURE.table)} where resource = ${quoteLiteral(condition.resource)}${depth}${narrowed} and ancestor = any (array(select ${helper}))`;
340
345
  } else inner = cast === "" ? `select ${helper}` : `select p.id${cast} from ${helper} as p(id)`;
341
346
  const reach = `${column} in (${inner})`;
342
347
  if (condition.parent === true && condition.restricted !== void 0) return `(${reach} and ${quoteIdent(condition.restricted)} is not true)`;
@@ -358,7 +363,7 @@ function compileHoppedSql(condition, ctx) {
358
363
  closureDepths: ctx.graph?.closures ?? {},
359
364
  qualify: qualifySqlTable,
360
365
  holders: (resource, relation) => [{ text: `select ${schema}.${graphHelper(resource)}(${quoteLiteral(relation)})` }],
361
- permitted: (resource, permission) => [{ text: `select ${schema}.${inheritedRowsHelper(resource)}(${quoteLiteral(permission)})` }],
366
+ permitted: (resource, permission) => [{ text: `select ${schema}.${inheritedRowsHelper(resource)}(${quoteLiteral(permission)}${condition.hops?.length === 1 ? candidateIds(ctx, condition.field, idsArgument) : ""})` }],
362
367
  restrictedRows: (resource) => [{ text: `select ${schema}.${restrictedHelper(resource)}()` }],
363
368
  linked: (resource, link, targets) => [
364
369
  { text: `select ${schema}.${linkHelper(resource, link)}(array(` },
@@ -1,4 +1,4 @@
1
- import { Ut as LocalSnapshotManifest } from "./policy-types-CCiDRZBH.js";
1
+ import { Yt as LocalSnapshotManifest } from "./policy-types-DGIO_gxq.js";
2
2
  //#region src/core/parse-local-manifest.d.ts
3
3
  /**
4
4
  * Whether `value` has the shape `localSnapshotManifest(policy)` writes, with no
@@ -1,6 +1,6 @@
1
- import { K as DecisionProvider, T as Policy, j as PolicyVocabulary, sr as Principal } from "../policy-types-CCiDRZBH.js";
2
- import { o as PermDockOptions } from "../permdock-B6Sf4T_S.js";
3
- import { a as RelationMap, c as RemotePdpEndpoints, d as SpiceDbCheck, f as SpiceDbOptions, i as PdpPermDock, l as RemotePdpMapping, n as OpenFgaTuple, o as RemotePdpAuth, r as PdpFactory, s as RemotePdpCache, t as OpenFgaOptions, u as RemotePdpOptions } from "../types-B4uqKDnp.js";
1
+ import { T as Policy, j as PolicyVocabulary, pr as Principal, q as DecisionProvider } from "../policy-types-DGIO_gxq.js";
2
+ import { o as PermDockOptions } from "../permdock-CprAPN3w.js";
3
+ import { a as RelationMap, c as RemotePdpEndpoints, d as SpiceDbCheck, f as SpiceDbOptions, i as PdpPermDock, l as RemotePdpMapping, n as OpenFgaTuple, o as RemotePdpAuth, r as PdpFactory, s as RemotePdpCache, t as OpenFgaOptions, u as RemotePdpOptions } from "../types-DlelvQk4.js";
4
4
  //#region src/pdp/create.d.ts
5
5
  /**
6
6
  * The PDP-aware instance, built synchronously like core `getPermDockSync`; use
package/dist/pdp/index.js CHANGED
@@ -6,7 +6,7 @@ import { n as internalsOf, t as attachInternals } from "../internals-B3IgHrvo.js
6
6
  import { a as getResource, c as listPermissions } from "../permission-registry-B8tYxPIt.js";
7
7
  import { n as toWireDelegation } from "../wire-delegation-Cv3W2eaM.js";
8
8
  import { r as decideAllAsync, t as canAllAsync } from "../checks-CGkP3Z7A.js";
9
- import { n as getPermDockSync$1, t as getPermDock$1 } from "../permdock-L-_I_3zP.js";
9
+ import { n as getPermDockSync$1, t as getPermDock$1 } from "../permdock-BvjivVb9.js";
10
10
  import { a as postJson, c as ttlMs, i as joinUrl, n as denied, o as resourceIdOf, r as granted, s as ttlCache, t as cacheKey } from "../shared-l0oGGetg.js";
11
11
  //#region src/pdp/create.ts
12
12
  function withoutProviders(policy) {
@@ -11,8 +11,8 @@ import { o as pickVisible, s as sanitizeContext } from "./validity-Buc7w8E9.js";
11
11
  import { t as byCodePoint } from "./compare-DTfyUunF.js";
12
12
  import { c as nowSeconds, d as resolveActiveTenant, m as tenantsOf, p as scopeField, t as heldRoleNamesIn, u as relatesTo } from "./tenancy-5d1zVBvK.js";
13
13
  import { d as policyX } from "./policy-CLQ8__GF.js";
14
- import { D as emptyListeners, E as emitSafe, N as contactMemberships, O as finish, P as isContact, i as customRolesFor, o as roleSourceFor, r as assignableNamesFor, s as sourceName, t as evaluate, u as customGrantsFor, w as unknownLevelsFor } from "./evaluate-Dd8Ta0Ie.js";
15
- import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot--JWiTrvO.js";
14
+ import { D as emptyListeners, E as emitSafe, N as contactMemberships, O as finish, P as isContact, i as customRolesFor, o as roleSourceFor, r as assignableNamesFor, s as sourceName, t as evaluate, u as customGrantsFor, w as unknownLevelsFor } from "./evaluate-BAmf_AQd.js";
15
+ import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot-DuWf1cT3.js";
16
16
  import { r as relationReader, t as pendingRelations } from "./relations-BxvRvDHK.js";
17
17
  import { i as snapshotGrant } from "./snapshot-CXlzi69u.js";
18
18
  import { a as decideForTarget, i as permittedIds, o as deniedFor, r as mayUse, s as signSnapshot, t as whereFromGrants } from "./where-scope-DlCdCM_8.js";
@@ -512,6 +512,96 @@ function buildInstance(policy, subject, envBase, team) {
512
512
  return Object.freeze(instance);
513
513
  }
514
514
  //#endregion
515
+ //#region src/core/freshness.ts
516
+ function versionQuery(principal, issuedAt) {
517
+ return compact({
518
+ id: principal.id,
519
+ roles: principal.roles,
520
+ memberships: principal.memberships,
521
+ authzVersion: principal.authzVersion,
522
+ issuedAt
523
+ });
524
+ }
525
+ function threw(source, auth) {
526
+ auth.push({
527
+ reason: "source-threw",
528
+ source: "memberships",
529
+ ...sourceName(source)
530
+ });
531
+ }
532
+ /**
533
+ * `onStale: 'reread'`: a token behind the source's version has its memberships
534
+ * (and global roles, with `readRoles`) read live; a version that cannot be read
535
+ * keeps the claims and marks the subject stale.
536
+ */
537
+ function rereadStale(source, principal, issuedAt, context, read, auth, readRoles) {
538
+ const claims = principal.memberships ?? [];
539
+ const claimed = principal.authzVersion;
540
+ const judge = (current) => typeof claimed === "number" && current !== void 0 && claimed >= current ? "fresh" : "reread";
541
+ const unknown = () => {
542
+ threw(source, auth);
543
+ return "unknown";
544
+ };
545
+ let freshness;
546
+ try {
547
+ const current = source.version?.(versionQuery(principal, issuedAt), context);
548
+ freshness = isThenable(current) ? Promise.resolve(current).then(judge, unknown) : judge(current);
549
+ } catch {
550
+ freshness = unknown();
551
+ }
552
+ const failed = () => {
553
+ threw(source, auth);
554
+ return [];
555
+ };
556
+ const rolesOf = (found) => {
557
+ if (found !== "reread" || readRoles === void 0) return;
558
+ try {
559
+ const roles = readRoles();
560
+ return isThenable(roles) ? Promise.resolve(roles).catch(failed) : roles;
561
+ } catch {
562
+ return failed();
563
+ }
564
+ };
565
+ if (isThenable(freshness)) {
566
+ const settled = freshness.then((found) => ({
567
+ found,
568
+ roles: rolesOf(found)
569
+ }));
570
+ return {
571
+ memberships: settled.then(({ found }) => found === "reread" ? read() : claims),
572
+ stale: settled.then(({ found }) => found === "unknown"),
573
+ roles: settled.then(({ roles }) => roles)
574
+ };
575
+ }
576
+ return compact({
577
+ memberships: freshness === "reread" ? read() : claims,
578
+ stale: freshness === "unknown",
579
+ roles: rolesOf(freshness)
580
+ });
581
+ }
582
+ /**
583
+ * Whether the token's memberships are behind the source for `fresh`
584
+ * permissions. Live memberships are never stale; token memberships are stale
585
+ * unless a source reports a version the token's `authzVersion` has reached.
586
+ */
587
+ function staleness(policy, principal, source, given, auth) {
588
+ if ((policy.fresh ?? []).length === 0 || principal === null || given.live) return false;
589
+ if (given.stale !== void 0) return given.stale;
590
+ const claimed = principal.authzVersion;
591
+ if (source?.version === void 0 || typeof claimed !== "number") return true;
592
+ const compare = (current) => current === void 0 || claimed < current;
593
+ try {
594
+ const current = source.version(versionQuery(principal, given.issuedAt), given.context);
595
+ return isThenable(current) ? Promise.resolve(current).then(compare, () => {
596
+ threw(source, auth);
597
+ return true;
598
+ }) : compare(current);
599
+ } catch {
600
+ threw(source, auth);
601
+ return true;
602
+ }
603
+ }
604
+ //#endregion
515
605
  //#region src/core/oauth-scopes.ts
516
606
  /**
517
607
  * Every OAuth scope a token may carry to the permission keys it reaches: each
@@ -585,6 +675,21 @@ function hasScope(granted, scopes) {
585
675
  return scopes.some((scope) => granted?.includes(scope) === true);
586
676
  }
587
677
  //#endregion
678
+ //#region src/core/source-memo.ts
679
+ /**
680
+ * One memo per `getPermDock` call. A read that throws is not kept, so the next
681
+ * caller tries again.
682
+ */
683
+ function sourceMemo() {
684
+ const answers = /* @__PURE__ */ new Map();
685
+ return (key, read) => {
686
+ if (answers.has(key)) return answers.get(key);
687
+ const answer = read();
688
+ answers.set(key, answer);
689
+ return answer;
690
+ };
691
+ }
692
+ //#endregion
588
693
  //#region src/core/resolve-subject.ts
589
694
  /**
590
695
  * The tenant a user API key holds its owner to (`Credential.tenant`): only the
@@ -599,13 +704,14 @@ function heldTenantOf(principal) {
599
704
  function outsideHeld(held, options) {
600
705
  return held !== void 0 && options.tenant !== void 0 && options.tenant !== held;
601
706
  }
602
- function assemblePrincipal(policy, user, options, auth) {
707
+ function assemblePrincipal(policy, user, options, auth, memo) {
603
708
  let principal;
604
709
  let context = {};
605
710
  let actor = options.actor;
606
711
  let delegation = options.delegation;
607
712
  let session = options.session;
608
713
  let expiresAt = options.expiresAt;
714
+ let issuedAt;
609
715
  let liveSession;
610
716
  try {
611
717
  if (user === null || user === void 0) principal = policy.subject(user);
@@ -616,6 +722,7 @@ function assemblePrincipal(policy, user, options, auth) {
616
722
  delegation = user.delegation ?? delegation;
617
723
  session = user.session ?? session;
618
724
  expiresAt = user.expiresAt ?? expiresAt;
725
+ issuedAt = typeof user.issuedAt === "number" && Number.isFinite(user.issuedAt) ? user.issuedAt : void 0;
619
726
  liveSession = user.liveSession === true ? true : void 0;
620
727
  } else principal = policy.subject(user);
621
728
  } catch {
@@ -631,7 +738,10 @@ function assemblePrincipal(policy, user, options, auth) {
631
738
  return from.membershipsFor(compact({
632
739
  id: of.id,
633
740
  kind: of.kind
634
- }), compact({ tenant: options.tenant }));
741
+ }), compact({
742
+ tenant: options.tenant,
743
+ memo
744
+ }));
635
745
  } catch {
636
746
  auth.push({
637
747
  reason: "source-threw",
@@ -647,10 +757,13 @@ function assemblePrincipal(policy, user, options, auth) {
647
757
  live = true;
648
758
  memberships = read(source, principal);
649
759
  } else if (principal?.memberships !== void 0 && fromClaims && source.onStale === "reread" && source.version !== void 0) {
650
- const reread = rereadStale(source, principal, principal.memberships, () => read(source, principal), auth, source.globalRolesFor === void 0 ? void 0 : () => source.globalRolesFor?.(compact({
760
+ const reread = rereadStale(source, principal, issuedAt, {
761
+ memo,
762
+ intent: options.intent ?? "write"
763
+ }, () => read(source, principal), auth, source.globalRolesFor === void 0 ? void 0 : () => source.globalRolesFor?.(compact({
651
764
  id: principal.id,
652
765
  kind: principal.kind
653
- })) ?? []);
766
+ }), { memo }) ?? []);
654
767
  memberships = reread.memberships;
655
768
  stale = reread.stale;
656
769
  roles = reread.roles;
@@ -663,78 +776,21 @@ function assemblePrincipal(policy, user, options, auth) {
663
776
  delegation: expandOAuthScopes(policy, delegation),
664
777
  session,
665
778
  expiresAt,
779
+ issuedAt,
666
780
  memberships,
667
781
  live,
668
782
  stale,
669
783
  liveSession: principal === null ? void 0 : liveSession
670
784
  });
671
785
  }
672
- function versionQuery(principal) {
673
- return compact({
674
- id: principal.id,
675
- roles: principal.roles,
676
- memberships: principal.memberships
677
- });
678
- }
679
- function rereadStale(source, principal, claims, read, auth, readRoles) {
680
- const claimed = principal.authzVersion;
681
- const judge = (current) => typeof claimed === "number" && current !== void 0 && claimed >= current ? "fresh" : "reread";
682
- const unknown = () => {
683
- auth.push({
684
- reason: "source-threw",
685
- source: "memberships",
686
- ...sourceName(source)
687
- });
688
- return "unknown";
689
- };
690
- let freshness;
691
- try {
692
- const current = source.version?.(versionQuery(principal));
693
- freshness = isThenable(current) ? Promise.resolve(current).then(judge, unknown) : judge(current);
694
- } catch {
695
- freshness = unknown();
696
- }
697
- const failed = () => {
698
- auth.push({
699
- reason: "source-threw",
700
- source: "memberships",
701
- ...sourceName(source)
702
- });
703
- return [];
704
- };
705
- const rolesOf = (found) => {
706
- if (found !== "reread" || readRoles === void 0) return;
707
- try {
708
- const roles = readRoles();
709
- return isThenable(roles) ? Promise.resolve(roles).catch(failed) : roles;
710
- } catch {
711
- return failed();
712
- }
713
- };
714
- if (isThenable(freshness)) {
715
- const settled = freshness.then((found) => ({
716
- found,
717
- roles: rolesOf(found)
718
- }));
719
- return {
720
- memberships: settled.then(({ found }) => found === "reread" ? read() : claims),
721
- stale: settled.then(({ found }) => found === "unknown"),
722
- roles: settled.then(({ roles }) => roles)
723
- };
724
- }
725
- return compact({
726
- memberships: freshness === "reread" ? read() : claims,
727
- stale: freshness === "unknown",
728
- roles: rolesOf(freshness)
729
- });
730
- }
731
786
  function finishSubject(policy, assembled, context, input, options, extra) {
732
787
  if (assembled.principal === null) return freezeCopy(compact({
733
788
  ...anonymousSubject(context),
734
789
  actor: assembled.actor,
735
790
  delegation: assembled.delegation,
736
791
  session: assembled.session,
737
- expiresAt: assembled.expiresAt
792
+ expiresAt: assembled.expiresAt,
793
+ issuedAt: assembled.issuedAt
738
794
  }));
739
795
  const scopes = scopeList(policy.scopes);
740
796
  const held = heldTenantOf(assembled.principal);
@@ -760,6 +816,7 @@ function finishSubject(policy, assembled, context, input, options, extra) {
760
816
  context: freezeCopy(context),
761
817
  session: assembled.session,
762
818
  expiresAt: assembled.expiresAt,
819
+ issuedAt: assembled.issuedAt,
763
820
  stale: extra.stale ? true : void 0,
764
821
  liveSession: assembled.liveSession
765
822
  }));
@@ -807,37 +864,6 @@ function settle(value, fallback, onError) {
807
864
  });
808
865
  return value;
809
866
  }
810
- /**
811
- * Whether the token's memberships are behind the source for `fresh`
812
- * permissions. Live memberships are never stale; token memberships are stale
813
- * unless a source reports a version the token's `authzVersion` has reached.
814
- */
815
- function staleness(policy, assembled, options, auth) {
816
- const principal = assembled.principal;
817
- if ((policy.fresh ?? []).length === 0 || principal === null || assembled.live) return false;
818
- if (assembled.stale !== void 0) return assembled.stale;
819
- const source = options.memberships === void 0 ? void 0 : asMembershipSource(options.memberships);
820
- const claimed = principal.authzVersion;
821
- if (source?.version === void 0 || typeof claimed !== "number") return true;
822
- const compare = (current) => current === void 0 || claimed < current;
823
- try {
824
- const current = source.version(versionQuery(principal));
825
- return isThenable(current) ? settle(Promise.resolve(current).then(compare), true, () => {
826
- auth.push({
827
- reason: "source-threw",
828
- source: "memberships",
829
- ...sourceName(source)
830
- });
831
- }) : compare(current);
832
- } catch {
833
- auth.push({
834
- reason: "source-threw",
835
- source: "memberships",
836
- ...sourceName(source)
837
- });
838
- return true;
839
- }
840
- }
841
867
  function cleanNames(list) {
842
868
  return Array.isArray(list) ? list.filter((item) => typeof item === "string" && item !== "") : [];
843
869
  }
@@ -891,25 +917,33 @@ function withRequestContext(request, resolved) {
891
917
  ...resolved
892
918
  };
893
919
  }
894
- function resolveSubject(policy, user, options, auth) {
895
- const first = assemblePrincipal(policy, user, options, auth);
920
+ function resolveSubject(policy, user, options, auth, memo = sourceMemo()) {
921
+ const first = assemblePrincipal(policy, user, options, auth, memo);
896
922
  const apply = (roles) => resolveAssembled(policy, roles === void 0 || first.principal === null ? first : {
897
923
  ...first,
898
924
  principal: {
899
925
  ...first.principal,
900
926
  roles
901
927
  }
902
- }, options, auth);
928
+ }, options, auth, memo);
903
929
  return isThenable(first.roles) ? Promise.resolve(first.roles).then(apply) : apply(first.roles);
904
930
  }
905
- function resolveAssembled(policy, assembled, options, auth) {
931
+ function resolveAssembled(policy, assembled, options, auth, memo) {
906
932
  const memberships = settle(assembled.memberships, [], () => {
907
933
  auth.push({
908
934
  reason: "source-threw",
909
935
  source: "memberships"
910
936
  });
911
937
  });
912
- const stale = staleness(policy, assembled, options, auth);
938
+ const stale = staleness(policy, assembled.principal, options.memberships === void 0 ? void 0 : asMembershipSource(options.memberships), {
939
+ live: assembled.live,
940
+ stale: assembled.stale,
941
+ issuedAt: assembled.issuedAt,
942
+ context: {
943
+ memo,
944
+ intent: options.intent ?? "write"
945
+ }
946
+ }, auth);
913
947
  const withPlans = (resolved) => entitlementsOf(assembled, activeTenantOf(policy, assembled, applyRoleKinds(policy, assembled.principal?.roles, normalizeMemberships(resolved, scopeList(policy.scopes))).memberships, options), options, auth);
914
948
  if (isThenable(assembled.context) || isThenable(memberships) || isThenable(stale)) return Promise.all([
915
949
  Promise.resolve(assembled.context),
@@ -934,7 +968,7 @@ function resolveAssembled(policy, assembled, options, auth) {
934
968
  }
935
969
  //#endregion
936
970
  //#region src/core/permdock.ts
937
- function instantiate(codePolicy, subject, options, auth) {
971
+ function instantiate(codePolicy, subject, options, auth, memo) {
938
972
  const { policy, errors } = options.policies?.apply(codePolicy) ?? {
939
973
  policy: codePolicy,
940
974
  errors: []
@@ -942,7 +976,7 @@ function instantiate(codePolicy, subject, options, auth) {
942
976
  const scopes = scopeList(policy.scopes);
943
977
  const tenants = tenantsOf(subject.principal, scopes);
944
978
  const roleSource = roleSourceFor(options.customRoles, subject, auth);
945
- const customRoles = customRolesFor(roleSource, tenants, auth, subject.principal === null ? void 0 : subject.principal.roles ?? [], (tenant) => heldRoleNamesIn(subject.principal, scopes, tenant));
979
+ const customRoles = customRolesFor(roleSource, tenants, auth, subject.principal === null ? void 0 : subject.principal.roles ?? [], (tenant) => heldRoleNamesIn(subject.principal, scopes, tenant), memo);
946
980
  const assignable = assignableNamesFor(roleSource, tenants, auth);
947
981
  const approvals = options.approvalPolicies?.load(policy, tenants, auth);
948
982
  const build = (roles, names, approvalPolicies) => {
@@ -971,6 +1005,7 @@ function instantiate(codePolicy, subject, options, auth) {
971
1005
  context: {}
972
1006
  }, compact({
973
1007
  tenant,
1008
+ intent: options.intent,
974
1009
  memberships: options.memberships,
975
1010
  customRoles: options.customRoles,
976
1011
  entitlements: options.entitlements,
@@ -991,9 +1026,10 @@ function instantiate(codePolicy, subject, options, auth) {
991
1026
  function create(policy, user, given) {
992
1027
  const options = withApp(policy, given);
993
1028
  const auth = [];
994
- const subject = resolveSubject(policy, user, options, auth);
995
- if (isThenable(subject)) return subject.then((resolved) => instantiate(policy, resolved, options, auth));
996
- return instantiate(policy, subject, options, auth);
1029
+ const memo = sourceMemo();
1030
+ const subject = resolveSubject(policy, user, options, auth, memo);
1031
+ if (isThenable(subject)) return subject.then((resolved) => instantiate(policy, resolved, options, auth, memo));
1032
+ return instantiate(policy, subject, options, auth, memo);
997
1033
  }
998
1034
  /**
999
1035
  * The instance for `user`, built synchronously. Every input must answer
@@ -1,8 +1,8 @@
1
- import { G as CustomRoleSourceFactory, Gt as Snapshot, Hn as ExplainedDecision, J as EntitlementSource, Kn as Obligation, Ln as Decision, Q as LimitStore, Rt as Instant, T as Policy, W as CustomRoleSource, Wn as LimitDetail, Zn as Actor, Zt as AuthEvent, _ as GrantLimit, at as SettingsSource, en as DecisionEvent, et as MembershipSource, fn as Scope, fr as AdapterId, h as Grant, i as ApprovalOption, it as RelationSource, j as PolicyVocabulary, lr as Subject, mr as Condition, or as Membership, q as DecisionSink, qn as Quota, rr as Delegation, sr as Principal, ut as TokenSigner } from "./policy-types-CCiDRZBH.js";
1
+ import { $n as Quota, G as CustomRoleSource, J as DecisionSink, Jn as ExplainedDecision, K as CustomRoleSourceFactory, Qn as Obligation, T as Policy, Un as Decision, Wt as Instant, X as Intent, Xn as LimitDetail, Y as EntitlementSource, Zt as Snapshot, _ as GrantLimit, br as Condition, et as LimitStore, fr as Membership, h as Grant, hr as Subject, i as ApprovalOption, j as PolicyVocabulary, lr as Delegation, mt as TokenSigner, nt as MembershipSource, on as DecisionEvent, ot as RelationSource, pr as Principal, rn as AuthEvent, rr as Actor, st as SettingsSource, vn as Scope, vr as AdapterId } from "./policy-types-DGIO_gxq.js";
2
2
  import { D as RowOf, M as AppData, b as ResourceNode, u as Permission } from "./permission-types-CAY-GU7e.js";
3
3
  import { a as RoleTree, n as PlanTree, r as Role } from "./vocabulary-DEJ5j4mR.js";
4
4
  import { i as OperationEffect, s as OperationMeta, t as Operation, u as OperationRisk } from "./operations-Ci_rT6Uo.js";
5
- import { a as HostedPolicies } from "./hosted-Cmtxogd0.js";
5
+ import { a as HostedPolicies } from "./hosted-DVxlLZMe.js";
6
6
  //#region src/core/approval-policies.d.ts
7
7
  /**
8
8
  * One approval requirement kept as data, for a tenant or the whole platform. It
@@ -595,6 +595,13 @@ type PermDockOptions = {
595
595
  readonly tenant?: string;
596
596
  /** One source, or several composed with `composeMemberships`. */
597
597
  readonly memberships?: MembershipSource | readonly MembershipSource[];
598
+ /**
599
+ * `'read'` lets `claimsFirst(source, { versions })` judge the token from the
600
+ * shared version cache, at most its `maxStaleMs` stale; `'write'` (the
601
+ * default) reads the version live. Pick `'read'` for rendering and `GET`
602
+ * handlers, never for a mutation.
603
+ */
604
+ readonly intent?: Intent;
598
605
  readonly customRoles?: CustomRoleSource | CustomRoleSourceFactory;
599
606
  /**
600
607
  * Plans and seats from billing, merged into `principal.plans` for the active
@@ -1,4 +1,4 @@
1
- import { c as crud } from "./src-DZ0l9UAg.js";
1
+ import { c as crud } from "./src-C_pi2Rnh.js";
2
2
  import { v as resource } from "./permission-registry-B8tYxPIt.js";
3
3
  import { f as definePlans, p as defineRoles } from "./grantee-Dke-9rd1.js";
4
4
  import { t as definePermissions } from "./permissions-CVXmRILq.js";
@@ -1,4 +1,4 @@
1
- import { T as Policy, lr as Subject, sr as Principal } from "./policy-types-CCiDRZBH.js";
1
+ import { T as Policy, hr as Subject, pr as Principal } from "./policy-types-DGIO_gxq.js";
2
2
  import { c as saasPlans, l as saasRoles, s as saasPermissions } from "./permissions-Bx6UI8n1.js";
3
3
  //#region src/testing/saas/policy.d.ts
4
4
  /** Daily API-key quota per subject; the bucket should be per tenant too. */
@@ -11,7 +11,7 @@ import { o as isPortableCondition } from "./hosted-D0IzESu_.js";
11
11
  import { t as definePermissions } from "./permissions-CVXmRILq.js";
12
12
  import { n as copyJson, t as checkSchema } from "./json-schema-BPGa-RjQ.js";
13
13
  import { t as parseCatalog } from "./parse-1_ZheTW5.js";
14
- import { n as parsePushedPolicy } from "./pushed-policy-ITwYKvvH.js";
14
+ import { n as parsePushedPolicy } from "./pushed-policy-CDuOL2de.js";
15
15
  //#region src/catalog/json-schema-validator.ts
16
16
  const ANNOTATIONS = /* @__PURE__ */ new Set([
17
17
  "$schema",