permdock 0.0.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 (344) hide show
  1. package/README.md +327 -1
  2. package/dist/a2a/index.d.ts +169 -0
  3. package/dist/a2a/index.js +232 -0
  4. package/dist/adapter-context-mlWsVGGg.js +23 -0
  5. package/dist/ai-sdk/index.d.ts +95 -0
  6. package/dist/ai-sdk/index.js +154 -0
  7. package/dist/approval-required-TzNB9oQA.js +6 -0
  8. package/dist/approvals/index.d.ts +3 -0
  9. package/dist/approvals/index.js +5 -0
  10. package/dist/approvals-DbYAuNkG.js +224 -0
  11. package/dist/approvers-DT4AVyIg.js +52 -0
  12. package/dist/arazzo-BAgw9ap6.js +70 -0
  13. package/dist/arazzo-cmvX2jDe.js +54 -0
  14. package/dist/authzen/index.d.ts +39 -0
  15. package/dist/authzen/index.js +302 -0
  16. package/dist/better-auth/index.d.ts +109 -0
  17. package/dist/better-auth/index.js +344 -0
  18. package/dist/better-supabase/index.d.ts +206 -0
  19. package/dist/better-supabase/index.js +620 -0
  20. package/dist/bind-CVy3Espv.d.ts +25 -0
  21. package/dist/bind-VnYn2HKq.js +97 -0
  22. package/dist/boundary-BM8a_P6E.js +13 -0
  23. package/dist/boundary-BmHxVH1J.d.ts +15 -0
  24. package/dist/budget-JqcRqyhK.d.ts +11 -0
  25. package/dist/budget-NbEtbJC_.js +11 -0
  26. package/dist/canonical-json-DemiK4Vp.js +26 -0
  27. package/dist/capability-4qPdO9gk.js +173 -0
  28. package/dist/capability-Dq43tT1u.d.ts +99 -0
  29. package/dist/catalog/index.d.ts +12 -0
  30. package/dist/catalog/index.js +2 -0
  31. package/dist/catalog-BjZSovXQ.js +2 -0
  32. package/dist/catalog-doc-Dsc9y7sd.js +309 -0
  33. package/dist/catalog-h2tlKFkq.js +48 -0
  34. package/dist/catalog-path-CnI0XTFK.js +12 -0
  35. package/dist/catalog-z8q6bi_r.js +55 -0
  36. package/dist/claude-agent/index.d.ts +72 -0
  37. package/dist/claude-agent/index.js +77 -0
  38. package/dist/clerk/index.d.ts +65 -0
  39. package/dist/clerk/index.js +301 -0
  40. package/dist/cli/bin.d.ts +1 -0
  41. package/dist/cli/bin.js +20 -0
  42. package/dist/cli/index.d.ts +46 -0
  43. package/dist/cli/index.js +5 -0
  44. package/dist/clients-C7zLFuWT.d.ts +12 -0
  45. package/dist/clients-DjU5ABMy.js +23 -0
  46. package/dist/cloud/index.d.ts +90 -0
  47. package/dist/cloud/index.js +404 -0
  48. package/dist/cloud-BGhHS-lY.js +50 -0
  49. package/dist/cloud-Bo3e9Ak3.js +118 -0
  50. package/dist/collect-DDDv_ESs.js +502 -0
  51. package/dist/collect-DLlujdHC.js +83 -0
  52. package/dist/collect-rG2IQ3t0.js +2 -0
  53. package/dist/commands-DWOrSQic.js +97 -0
  54. package/dist/compact-y6vfu2_f.js +19 -0
  55. package/dist/compare-pfyVnBjE.js +12 -0
  56. package/dist/compile/index.d.ts +3 -0
  57. package/dist/compile/index.js +2 -0
  58. package/dist/compile-Ba4blROR.js +613 -0
  59. package/dist/compile-CNnl6uIt.d.ts +94 -0
  60. package/dist/config-BJiM-xAm.js +157 -0
  61. package/dist/config-Bn00Z3ks.js +36 -0
  62. package/dist/config-report-Dw_JcUqT.js +44 -0
  63. package/dist/connection-CU8MQxRi.js +194 -0
  64. package/dist/context-Ttp0ekMT.js +82 -0
  65. package/dist/convex/index.d.ts +45 -0
  66. package/dist/convex/index.js +65 -0
  67. package/dist/create-BWyx3jua.d.ts +245 -0
  68. package/dist/create-CPhDL6qx.js +253 -0
  69. package/dist/credential-8P81ff4u.js +306 -0
  70. package/dist/delegation-D8pUEuce.js +103 -0
  71. package/dist/describe-B_gVZEVi.js +94 -0
  72. package/dist/describe-PdoqESvg.d.ts +36 -0
  73. package/dist/diff-B8Tunc3o.js +451 -0
  74. package/dist/diff-CzqLxZ77.js +48 -0
  75. package/dist/digest-B3kc_PgQ.d.ts +19 -0
  76. package/dist/digest-BI-6aa6d.js +27 -0
  77. package/dist/doctor-WpvG6p4k.js +1194 -0
  78. package/dist/doctor-collect-ByfYlNv1.js +664 -0
  79. package/dist/doctor-rOr-4ZfS.js +53 -0
  80. package/dist/drizzle/index.d.ts +73 -0
  81. package/dist/drizzle/index.js +160 -0
  82. package/dist/duration-xK2jGFVc.js +25 -0
  83. package/dist/elysia/index.d.ts +49 -0
  84. package/dist/elysia/index.js +59 -0
  85. package/dist/errors-CWfoNg9N.js +47 -0
  86. package/dist/errors-Cz5zn0mW.js +123 -0
  87. package/dist/errors-DAqevpNk.d.ts +125 -0
  88. package/dist/errors-DRnGZHzF.js +30 -0
  89. package/dist/evaluation-items-CfCCejQd.js +40 -0
  90. package/dist/evaluations-tz6D9A2G.js +461 -0
  91. package/dist/eve/index.d.ts +86 -0
  92. package/dist/eve/index.js +176 -0
  93. package/dist/expiry-BoBJ8Tvc.js +7 -0
  94. package/dist/express/index.d.ts +23 -0
  95. package/dist/express/index.js +78 -0
  96. package/dist/fastify/index.d.ts +33 -0
  97. package/dist/fastify/index.js +92 -0
  98. package/dist/fields-BMl1RxoX.js +26 -0
  99. package/dist/files-DWUN9PzI.js +125 -0
  100. package/dist/fixtures-ht28Cplr.js +67 -0
  101. package/dist/freeze-CrU8nQeX.js +60 -0
  102. package/dist/from-snapshot-C3sHpZNS.js +569 -0
  103. package/dist/generate-CH7ThJ14.js +173 -0
  104. package/dist/grantee-Cv5Sogfv.js +602 -0
  105. package/dist/graph-sql-B-dsAT6j.d.ts +29 -0
  106. package/dist/headers-BZSDieNT.js +6 -0
  107. package/dist/headers-Cf-zWvsO.d.ts +6 -0
  108. package/dist/helpers-H_KARDVC.js +421 -0
  109. package/dist/hono/index.d.ts +48 -0
  110. package/dist/hono/index.js +99 -0
  111. package/dist/hosted-DJQw46hn.js +266 -0
  112. package/dist/http-BIhmLfCc.js +95 -0
  113. package/dist/http-DPuDaChb.d.ts +13 -0
  114. package/dist/http-SO7qGttf.js +44 -0
  115. package/dist/ids-DC4V4CFu.js +18 -0
  116. package/dist/index-A0YNL8jZ.d.ts +177 -0
  117. package/dist/index-CtE07CBF.d.ts +6 -0
  118. package/dist/index-D3vbkoSI.d.ts +483 -0
  119. package/dist/index-D6_cSa1z.d.ts +201 -0
  120. package/dist/index.d.ts +16 -0
  121. package/dist/index.js +26 -0
  122. package/dist/instance-options-BK_rNOSC.d.ts +11 -0
  123. package/dist/instance-options-Dhhcnm3y.js +22 -0
  124. package/dist/json-schema-BsAflUGW.js +106 -0
  125. package/dist/jwt/index.d.ts +91 -0
  126. package/dist/jwt/index.js +590 -0
  127. package/dist/kernel-GSQnMz3O.js +208 -0
  128. package/dist/kysely/index.d.ts +78 -0
  129. package/dist/kysely/index.js +129 -0
  130. package/dist/live-options-H2eG8dfJ.js +60 -0
  131. package/dist/load-DhWEB9P1.js +75 -0
  132. package/dist/load-DwJUafYN.js +2 -0
  133. package/dist/load-jose-BL6LH4bL.js +11 -0
  134. package/dist/lru-8q4WZjBV.js +28 -0
  135. package/dist/manifest-iaoBXHKc.js +783 -0
  136. package/dist/manifest-uDS9y5de.d.ts +206 -0
  137. package/dist/map-AcxK9o_D.js +147 -0
  138. package/dist/map-claims-Z4QZOiFF.js +369 -0
  139. package/dist/map-error-pgUWNNtG.js +23 -0
  140. package/dist/markers-B0hYLvMD.js +60 -0
  141. package/dist/may-use-DndQ5tQ-.js +77 -0
  142. package/dist/mcp/index.d.ts +159 -0
  143. package/dist/mcp/index.js +603 -0
  144. package/dist/nest/index.d.ts +75 -0
  145. package/dist/nest/index.js +261 -0
  146. package/dist/next/client.d.ts +23 -0
  147. package/dist/next/client.js +33 -0
  148. package/dist/next/index.d.ts +93 -0
  149. package/dist/next/index.js +180 -0
  150. package/dist/next/plugin.d.ts +14 -0
  151. package/dist/next/plugin.js +33 -0
  152. package/dist/node/index.d.ts +24 -0
  153. package/dist/node/index.js +34 -0
  154. package/dist/openai/index.d.ts +62 -0
  155. package/dist/openai/index.js +92 -0
  156. package/dist/openapi/index.d.ts +176 -0
  157. package/dist/openapi/index.js +3 -0
  158. package/dist/openapi-Bbg4wGVL.js +164 -0
  159. package/dist/openapi-BqRBvAng.js +538 -0
  160. package/dist/openapi-CqqEbHsL.js +250 -0
  161. package/dist/openapi-import-cmwetbzw.js +5959 -0
  162. package/dist/openapi-schema--ARjyfQr.js +6902 -0
  163. package/dist/orpc/index.d.ts +51 -0
  164. package/dist/orpc/index.js +145 -0
  165. package/dist/otel/index.d.ts +13 -0
  166. package/dist/otel/index.js +202 -0
  167. package/dist/package-root-zGkxO3oN.js +30 -0
  168. package/dist/parse-BuyjxhZV.js +53 -0
  169. package/dist/parse-local-manifest-BkGQNzAh.d.ts +10 -0
  170. package/dist/parse-local-manifest-BrMozJCo.js +36 -0
  171. package/dist/pdp/index.d.ts +22 -0
  172. package/dist/pdp/index.js +682 -0
  173. package/dist/peer-BOr_kJE1.js +31 -0
  174. package/dist/permdock-CzqXjCpU.js +3471 -0
  175. package/dist/permissions-CDgvKG5L.d.ts +52 -0
  176. package/dist/permissions-CpZrivYv.js +142 -0
  177. package/dist/permissions-DVoF6dMt.js +662 -0
  178. package/dist/permissions-DttnqqxC.d.ts +214 -0
  179. package/dist/pins-8ILTftC9.js +12 -0
  180. package/dist/policy-CFZAr_Al.d.ts +2252 -0
  181. package/dist/policy-D8UFyERw.d.ts +20 -0
  182. package/dist/policy-xyWg7QdR.js +1122 -0
  183. package/dist/powersync-A8x_Yyvh.js +2 -0
  184. package/dist/powersync-C7kLglqX.js +540 -0
  185. package/dist/powersync-yW1UUFzp.js +62 -0
  186. package/dist/prisma/index.d.ts +136 -0
  187. package/dist/prisma/index.js +455 -0
  188. package/dist/problem-B43ztKIm.js +191 -0
  189. package/dist/problem-details-CkL50EEf.d.ts +7 -0
  190. package/dist/problem-details-_AMOYz-w.js +144 -0
  191. package/dist/prompt-CXYhLfsS.js +32 -0
  192. package/dist/protected-CNsMzrVd.d.ts +27 -0
  193. package/dist/protected-Cs6kTaHo.js +100 -0
  194. package/dist/protected-bZs6rbT1.d.ts +40 -0
  195. package/dist/provider-Cjr62YMV.d.ts +6 -0
  196. package/dist/provider-DLzpb2Xz.js +52 -0
  197. package/dist/provider-store-DNyC1y48.js +43 -0
  198. package/dist/react/index.d.ts +8 -0
  199. package/dist/react/index.js +7 -0
  200. package/dist/react/provider-client.d.ts +2 -0
  201. package/dist/react/provider-client.js +3 -0
  202. package/dist/react-native/index.d.ts +198 -0
  203. package/dist/react-native/index.js +696 -0
  204. package/dist/refs-KYb4ntaz.js +91 -0
  205. package/dist/relations-cjOL01hZ.js +505 -0
  206. package/dist/replay-BsOyTrdV.js +28 -0
  207. package/dist/replay-sqBGMnNs.d.ts +5 -0
  208. package/dist/resource-ref-CaS9yVPi.js +20 -0
  209. package/dist/revocations-Bhr0aMIC.js +27 -0
  210. package/dist/revocations-Cy06JNx2.d.ts +21 -0
  211. package/dist/rls-BMNydpHk.js +2521 -0
  212. package/dist/rls-CEvs64Kj.js +238 -0
  213. package/dist/rls-fields-BMasREhR.js +3502 -0
  214. package/dist/rls-graph-pc9fuXYm.js +435 -0
  215. package/dist/rls-import-D8F7j35Q.js +943 -0
  216. package/dist/rls-migrate-7wikfrVI.js +367 -0
  217. package/dist/rls-ownership-B5Lkq62W.js +843 -0
  218. package/dist/rls-shared-aOQ4hGTO.js +493 -0
  219. package/dist/rls-verify-D8B7dOTh.js +745 -0
  220. package/dist/row-check-Dt35czLy.d.ts +40 -0
  221. package/dist/rpc-DOK54_CS.js +89 -0
  222. package/dist/run-YXCJDNYk.js +174 -0
  223. package/dist/runtime-CB8gQFvS.js +11 -0
  224. package/dist/saas-Bj_FFkjN.js +1203 -0
  225. package/dist/schema-D3MnDMxa.js +300 -0
  226. package/dist/scim/index.d.ts +2 -0
  227. package/dist/scim/index.js +2 -0
  228. package/dist/scim-BFGBBAqR.js +1445 -0
  229. package/dist/scopes-CVdPrWN-.js +239 -0
  230. package/dist/server/index.d.ts +134 -0
  231. package/dist/server/index.js +11 -0
  232. package/dist/server-DlZ28Oz5.js +268 -0
  233. package/dist/sha256-BO0swRXL.js +150 -0
  234. package/dist/shared-DRu8VFVM.js +123 -0
  235. package/dist/sink-Bd9PSyfq.js +141 -0
  236. package/dist/sink-Gs6TTVa-.d.ts +104 -0
  237. package/dist/skills-Biq5uup3.js +192 -0
  238. package/dist/skills-JaymNCdK.js +56 -0
  239. package/dist/snapshot-Enxd0n-s.js +975 -0
  240. package/dist/snapshot-cache-D6jLelln.js +44 -0
  241. package/dist/snapshot-cache-DwQH8ufx.d.ts +45 -0
  242. package/dist/solid/index.d.ts +93 -0
  243. package/dist/solid/index.js +188 -0
  244. package/dist/sources-B0UvrJ21.js +534 -0
  245. package/dist/sources-BcJgw0lt.d.ts +192 -0
  246. package/dist/sql-xdg5f4Fi.js +27 -0
  247. package/dist/src-CSbUiozF.js +568 -0
  248. package/dist/ssf/index.d.ts +4 -0
  249. package/dist/ssf/index.js +596 -0
  250. package/dist/store-DMAWwAJV.js +371 -0
  251. package/dist/store-D_pjn91-.d.ts +36 -0
  252. package/dist/store-options-yO0V6gRn.js +716 -0
  253. package/dist/stores-4_sqiOA1.js +87 -0
  254. package/dist/stores-DVR5NHLE.d.ts +52 -0
  255. package/dist/stream-DDpvynSB.js +66 -0
  256. package/dist/stream-DlvG2hs-.d.ts +12 -0
  257. package/dist/style-CTm1AXDT.js +22 -0
  258. package/dist/subject-C6dLxqHU.js +24 -0
  259. package/dist/subject-settings-BwBmCdTR.js +128 -0
  260. package/dist/supabase/index.d.ts +183 -0
  261. package/dist/supabase/index.js +5 -0
  262. package/dist/supabase/middleware.d.ts +82 -0
  263. package/dist/supabase/middleware.js +102 -0
  264. package/dist/supabase-CwafwxxF.js +83 -0
  265. package/dist/supabase-DTBaC20O.js +774 -0
  266. package/dist/supabase-config-Bs44dare.js +472 -0
  267. package/dist/supabase-hook-BuxLQLpU.js +1814 -0
  268. package/dist/supabase-hook-D5qVd_D8.js +2 -0
  269. package/dist/supautils-DYZnzRWV.js +91 -0
  270. package/dist/svelte/PermissionBoundary.svelte +37 -0
  271. package/dist/svelte/Protected.svelte +40 -0
  272. package/dist/svelte/index.d.ts +13 -0
  273. package/dist/svelte/index.js +107 -0
  274. package/dist/svelte/runtime.d.ts +7 -0
  275. package/dist/svelte/runtime.js +4 -0
  276. package/dist/svelte/source.d.ts +13 -0
  277. package/dist/svelte/source.js +11 -0
  278. package/dist/terminal/index.d.ts +163 -0
  279. package/dist/terminal/index.js +833 -0
  280. package/dist/testing/index.d.ts +745 -0
  281. package/dist/testing/index.js +3672 -0
  282. package/dist/testing/saas/index.d.ts +194 -0
  283. package/dist/testing/saas/index.js +3 -0
  284. package/dist/testing/saas/permissions.d.ts +2 -0
  285. package/dist/testing/saas/permissions.js +2 -0
  286. package/dist/text-diff-BdkkYSbi.js +15 -0
  287. package/dist/thenable-okc2xDsj.js +10 -0
  288. package/dist/timeout-D51niuQP.js +8 -0
  289. package/dist/token-CIWxJOCh.js +50 -0
  290. package/dist/trpc/index.d.ts +61 -0
  291. package/dist/trpc/index.js +122 -0
  292. package/dist/types-9AWO9EGt.d.ts +197 -0
  293. package/dist/types-BPxgszlT.d.ts +550 -0
  294. package/dist/types-BVyImy5I.d.ts +120 -0
  295. package/dist/types-Bvc4oWT6.d.ts +9 -0
  296. package/dist/types-C3s9xVJG.d.ts +48 -0
  297. package/dist/types-Dnemwd77.d.ts +183 -0
  298. package/dist/types-kxznc7cn.d.ts +52 -0
  299. package/dist/types-vKyAMtcX.d.ts +157 -0
  300. package/dist/types-vNSDF7Dq.d.ts +66 -0
  301. package/dist/types-yF5LmQVD.d.ts +306 -0
  302. package/dist/unplugin/index.d.ts +7 -0
  303. package/dist/unplugin/index.js +31 -0
  304. package/dist/usage-D07N9QJ3.js +42 -0
  305. package/dist/usage-D82l1CwK.js +2 -0
  306. package/dist/usage-DG1oeCca.js +693 -0
  307. package/dist/validation-error-CnjZ4t92.js +33 -0
  308. package/dist/validation-error-CtF23SrC.d.ts +26 -0
  309. package/dist/validity-uOp8UpYn.js +245 -0
  310. package/dist/verifier-BxBo6I44.js +466 -0
  311. package/dist/version-BvacVTZR.js +17 -0
  312. package/dist/views-Soe7bGSC.js +95 -0
  313. package/dist/vocabulary-DA8a8zif.d.ts +56 -0
  314. package/dist/vue/index.d.ts +79 -0
  315. package/dist/vue/index.js +196 -0
  316. package/dist/watch-Etoa_Mvr.js +2 -0
  317. package/dist/watch-UihESpsJ.js +128 -0
  318. package/dist/webmcp/index.d.ts +75 -0
  319. package/dist/webmcp/index.js +307 -0
  320. package/package.json +450 -5
  321. package/rulesets/permdock.yaml +29 -0
  322. package/schemas/approval-request-v1.json +175 -0
  323. package/schemas/catalog-v1.json +535 -0
  324. package/schemas/openapi/oas-3.1.json +1298 -0
  325. package/schemas/openapi/oas-3.2.json +1516 -0
  326. package/schemas/openapi/overlay-1.1.json +79 -0
  327. package/schemas/supabase-claims-v1.json +144 -0
  328. package/schemas/supabase-manifest-v1.json +361 -0
  329. package/skills/permdock/SKILL.md +66 -0
  330. package/skills/permdock-agents/SKILL.md +77 -0
  331. package/skills/permdock-agents/references/runtimes.md +213 -0
  332. package/skills/permdock-approvals/SKILL.md +80 -0
  333. package/skills/permdock-approvals/references/stores-and-resume.md +94 -0
  334. package/skills/permdock-audit/SKILL.md +67 -0
  335. package/skills/permdock-credentials/SKILL.md +55 -0
  336. package/skills/permdock-credentials/references/tokens-keys-links.md +132 -0
  337. package/skills/permdock-data/SKILL.md +57 -0
  338. package/skills/permdock-data/references/queries-and-rls.md +62 -0
  339. package/skills/permdock-data/references/relationships.md +67 -0
  340. package/skills/permdock-tenancy/SKILL.md +80 -0
  341. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +89 -0
  342. package/skills/permdock-wire/SKILL.md +116 -0
  343. package/skills/permdock-wire/references/adapters.md +492 -0
  344. package/skills/permdock-wire/references/policy-options.md +45 -0
@@ -0,0 +1,550 @@
1
+ import { n as RoleThrough } from "./types-yF5LmQVD.js";
2
+ import { o as SqlMembershipSource } from "./sources-BcJgw0lt.js";
3
+ //#region src/cli/types.d.ts
4
+ type CollectConfig = {
5
+ readonly srcPath?: readonly string[];
6
+ readonly out?: string;
7
+ readonly barrel?: boolean | string;
8
+ };
9
+ type CatalogConfig = {
10
+ readonly out?: string;
11
+ };
12
+ type RlsDialect = "supabase" | "neon" | "guc";
13
+ type RlsTarget = "sql" | "drizzle" | "prisma";
14
+ type RlsMembershipTable = {
15
+ readonly table: string;
16
+ readonly user: string;
17
+ /**
18
+ * The role key column, a reference to a roles table that holds the key, or
19
+ * several of them: the row holds every non-null key.
20
+ */
21
+ readonly role: string | RoleThrough | readonly (string | RoleThrough)[];
22
+ /** Per scope name, the column holding that scope's id: the table's own scope and its ancestors. */
23
+ readonly columns?: Readonly<Record<string, string>>;
24
+ /** Column of the first scope's id; shorthand for `columns[<first scope>]`. */
25
+ readonly tenant?: string;
26
+ /** Column of the second scope's id; shorthand for `columns[<second scope>]`. */
27
+ readonly team?: string;
28
+ readonly id?: string;
29
+ readonly expiresAt?: string;
30
+ readonly disabledAt?: string;
31
+ /**
32
+ * The membership kind (`Membership.via`) roles with `for` match: a column
33
+ * holding it, or `{ value }` when every row has the same kind.
34
+ */
35
+ readonly via?: string | {
36
+ readonly value: string;
37
+ };
38
+ };
39
+ type RlsMemberships = {
40
+ /** The membership table of each named scope. */
41
+ readonly scopes?: Readonly<Record<string, RlsMembershipTable>>;
42
+ /** The first scope's table; shorthand for `scopes[<first scope>]`. */
43
+ readonly tenant?: RlsMembershipTable;
44
+ /** The second scope's table; shorthand for `scopes[<second scope>]`. */
45
+ readonly team?: RlsMembershipTable;
46
+ readonly resource?: Readonly<Record<string, RlsMembershipTable>>;
47
+ };
48
+ /** A table whose row says whether a user or a scope instance is active. A missing row counts as suspended. */
49
+ type RlsActiveRow = {
50
+ readonly table: string;
51
+ /** Column holding the user id or the scope instance id. */
52
+ readonly id: string;
53
+ /** Nullable timestamp column; a row with a value is suspended. */
54
+ readonly disabledAt?: string;
55
+ /** Status column; only a row whose value is in `active` counts as active. */
56
+ readonly status?: string;
57
+ readonly active?: readonly string[];
58
+ };
59
+ /** A scope's active-row table, with the permissions its suspended instances keep. */
60
+ type RlsSuspendedScope = RlsActiveRow & {
61
+ /**
62
+ * Permissions (references or keys) members of a suspended instance, and of
63
+ * every instance nested in it, still hold: restoring it, cancelling a
64
+ * scheduled deletion, exporting before a purge.
65
+ */
66
+ readonly keep?: readonly (string | {
67
+ readonly key: string;
68
+ })[];
69
+ };
70
+ type RlsSuspendedMembership = {
71
+ readonly keep?: readonly (string | {
72
+ readonly key: string;
73
+ })[];
74
+ };
75
+ type RlsSuspension = {
76
+ /** A suspended user holds no role and no membership. */
77
+ readonly users?: RlsActiveRow;
78
+ /** Per scope name: a suspended instance voids its memberships and every membership nested under it, except for `keep`. */
79
+ readonly scopes?: Readonly<Record<string, RlsSuspendedScope>>;
80
+ readonly memberships?: RlsSuspendedMembership;
81
+ };
82
+ type RlsFunctionMapping = {
83
+ readonly twin: unknown;
84
+ readonly args?: readonly string[];
85
+ };
86
+ type RlsConfig = {
87
+ readonly tables?: Readonly<Record<string, string>>;
88
+ readonly dialect?: RlsDialect;
89
+ readonly memberships?: RlsMemberships;
90
+ /**
91
+ * `database` mode: the `fromTable` / `fromJunction` sources the helpers
92
+ * read for every scope `memberships` maps no table for. Default
93
+ * `supabase.hook.memberships`, so the helpers and the token hook run the
94
+ * same SQL. Setting it selects `database` mode.
95
+ */
96
+ readonly membershipSources?: readonly SqlMembershipSource[];
97
+ /** Tables the helpers, `authorize()` and the token hook read to drop suspended users and scope instances. */
98
+ readonly suspension?: RlsSuspension;
99
+ readonly functions?: Readonly<Record<string, RlsFunctionMapping>>;
100
+ readonly inlineFunctions?: boolean;
101
+ /** Emit FORCE ROW LEVEL SECURITY so the table owner is subject to the policies. */
102
+ readonly force?: boolean;
103
+ readonly fixtures?: string;
104
+ readonly tenantClaim?: string;
105
+ /**
106
+ * Which tenants the helpers and `memberOf` checks admit. `'active'`
107
+ * (default): when the token carries a non-empty `tenantClaim`, only that
108
+ * tenant; without one, every tenant the subject is a member of. `'all'`:
109
+ * every such tenant whatever the claim says, for apps whose tenant comes
110
+ * from the URL or the query.
111
+ */
112
+ readonly tenants?: "active" | "all";
113
+ /** Postgres type of tenant columns (`uuid` by default); the tenant claim and helper results are cast to it. */
114
+ readonly tenantType?: string;
115
+ /** Postgres type of team columns; defaults to `tenantType`. */
116
+ readonly teamType?: string;
117
+ /** Postgres type of each named scope's id column; overrides `tenantType` / `teamType`. */
118
+ readonly scopeTypes?: Readonly<Record<string, string>>;
119
+ readonly roleClaim?: string;
120
+ readonly gucPrefix?: string;
121
+ readonly out?: string;
122
+ /** `--target drizzle`: where each policy's `.link()` finds its table. */
123
+ readonly drizzle?: {
124
+ /** Module exporting the tables, as imported from `out`. Default `./schema`. */
125
+ readonly schema?: string;
126
+ /** Export name per table name; defaults to the camelCased table name without its schema. */
127
+ readonly exports?: Readonly<Record<string, string>>;
128
+ };
129
+ /** `--target prisma`: the model each table maps to. */
130
+ readonly prisma?: {
131
+ /** Model name per table name; defaults to the PascalCased table name without its schema. */
132
+ readonly models?: Readonly<Record<string, string>>;
133
+ };
134
+ /** Schema of `role_permissions` and the RLS helpers (`permdock_has`, `permitted_<scope>_ids`, `member_<scope>_ids`) (and the RBAC scaffold). Default `permdock`; keep it out of `[api] schemas`. */
135
+ readonly schema?: string;
136
+ /** Where the helpers read roles and memberships: `database` tables or `jwt` claims. */
137
+ readonly authorize?: "database" | "jwt";
138
+ /** One policy per role and permission instead of one per table and command. */
139
+ readonly policyPerRole?: boolean;
140
+ /**
141
+ * Resolve tenant-defined custom roles in the helpers: `custom_role_permissions` and
142
+ * `custom_role_includes` in `database` mode, the `memberships[].grants` claim in `jwt` mode,
143
+ * always intersected with the `permdock_ceiling` view. Off by default.
144
+ */
145
+ readonly customRoles?: boolean;
146
+ /** How the generated custom-role write functions check the caller (`database` mode with `customRoles`). */
147
+ readonly customRoleWrites?: {
148
+ /**
149
+ * Who may change custom roles at all, checked before the hand-out check:
150
+ * permission keys of which the caller must hold one in the tenant (or
151
+ * through a global role; only through a global role for a platform custom
152
+ * role), or `'manageRoles'` for any permission with `meta.manageRoles`.
153
+ * Unset, any member may write a role within what they may hand out.
154
+ */
155
+ readonly requires?: "manageRoles" | readonly string[];
156
+ /**
157
+ * The application's own roles table, one row per custom role. A trigger
158
+ * on it moves a role's grants and includes when the row's name, tenant,
159
+ * scope or instance changes, and deletes them with the row. A signed-in
160
+ * caller goes through the same checks as the write functions; a trusted
161
+ * path (a migration, a job, a nested trigger) moves the rows directly.
162
+ */
163
+ readonly roles?: RlsCustomRoleTable;
164
+ };
165
+ /**
166
+ * Let link capabilities reach resource-scoped grants: `anon` policies that call
167
+ * `permdock_capability_ids`, which reads the `capability` claim `exchangeCapability`
168
+ * mints. Off by default.
169
+ */
170
+ readonly capabilities?: boolean;
171
+ /**
172
+ * `'deny'` (Supabase only): a token with `is_anonymous: true` reaches no grant
173
+ * but those to `anyone()`. Supabase gives an anonymous sign-in the
174
+ * `authenticated` role, so without it the grants to roles and to
175
+ * `authenticated()` reach it. The subject mapper has to refuse it in process
176
+ * too. Off by default.
177
+ */
178
+ readonly anonymousSignIns?: "deny";
179
+ /**
180
+ * Grant `anon` usage on the helper schema and `execute` on the helpers, for
181
+ * hand-written policies that apply to `public` or `anon` and call them. They
182
+ * find no subject for `anon` and return nothing. Off by default: a policy
183
+ * that calls a helper says `to authenticated`.
184
+ */
185
+ readonly anonExecute?: boolean;
186
+ /**
187
+ * Check role assignments in the database: a trigger on each scope's
188
+ * `rls.memberships` table, the global-roles table `rls.roles` and each
189
+ * table in `tables` (such as invitations) refuses a client write that
190
+ * assigns, changes or removes a role the caller may not assign there, by
191
+ * the policy's `assigns` graph or, for a custom role, by what the caller may
192
+ * hand out. Writes that do not run as a client role (the table owner, a
193
+ * `security definer` function, a backend role) are trusted. Needs a role
194
+ * that declares `assigns`.
195
+ */
196
+ readonly assignments?: true | {
197
+ readonly tables?: readonly RlsAssignmentTable[];
198
+ /**
199
+ * `'refuse'`: a client write to a row whose user is the caller is
200
+ * refused on every guarded table with a user column, whatever the
201
+ * role. A map refuses it on the tables it names (`schema.table` as
202
+ * configured). Unset, a caller may change their own row within what
203
+ * they may assign.
204
+ */
205
+ readonly ownRole?: "refuse" | Readonly<Record<string, "refuse">>;
206
+ };
207
+ /**
208
+ * Add the approval store `supabaseApprovalStore` reads and writes: the
209
+ * `approval_requests` table and one function per `ApprovalStore` method, in
210
+ * the helper schema, executable by no client role. Off by default. An
211
+ * object adopts a table the app already has instead.
212
+ */
213
+ readonly approvals?: boolean | RlsApprovalsAdopt;
214
+ /**
215
+ * A pg_jsonschema check constraint on generated `jsonb` columns: the
216
+ * approval store's `body` must match `approval-request-v1.json`. `true`
217
+ * installs the extension into `extensions`; `'auto'` adds the constraint
218
+ * only where `pg_available_extensions` lists it. Off by default.
219
+ */
220
+ readonly jsonSchema?: "auto" | boolean;
221
+ /**
222
+ * `false` leaves out the holder-count and transfer-only triggers `min`,
223
+ * `max` and `transferOnly` put on the membership tables; a map with
224
+ * `<scope>: false` leaves them out for those scopes only. Those rules are
225
+ * then checked by `decideRoleChange` alone. On by default.
226
+ */
227
+ readonly ownershipTriggers?: false | Readonly<Record<string, false>>;
228
+ /**
229
+ * Make a session acting for a user read-only in the database: one
230
+ * restrictive policy per table and write command the generated policies
231
+ * allow, refusing the write when the token's `act` claim names one of these
232
+ * actor kinds, unless `act.read_only` is `false`. `true` is
233
+ * `['support', 'impersonation']`; with `support`, an `act` with a
234
+ * `session_id` and no `kind` counts too. Off by default.
235
+ */
236
+ readonly readOnlyActors?: boolean | readonly string[];
237
+ readonly apiKeys?: true | RlsApiKeys;
238
+ /** Supabase Realtime: policies on `realtime.messages` for private channels. Supabase dialect only. */
239
+ readonly realtime?: RlsRealtime;
240
+ /** Supabase Storage: policies on `storage.objects` for buckets keyed by a scope folder. Supabase dialect only. */
241
+ readonly storage?: RlsStorage;
242
+ /**
243
+ * `'views'`: one `security_invoker` view `<table>_visible` per table with field-limited
244
+ * read grants, whose restricted columns are `case when <permitted> then col end`. Off by default.
245
+ */
246
+ readonly fields?: "views";
247
+ /**
248
+ * With `fields: 'views'`, grant `anon` and `authenticated` only the unrestricted columns of
249
+ * the base table, so restricted columns are read through the view. Breaks `select *`.
250
+ */
251
+ readonly revokeColumns?: boolean;
252
+ /** Policy name template: `{table}`, `{op}`, plus `{role}` and `{permission}` with `policyPerRole`. */
253
+ readonly policyName?: string;
254
+ /** `rls generate --rbac supabase` defaults; flags override. */
255
+ readonly rbac?: {
256
+ readonly schema?: string;
257
+ readonly authorize?: "database" | "jwt";
258
+ };
259
+ /** The global-roles table `permdock_has` reads in `database` mode. Default `<schema>.user_roles (user_id, role)`, which the helpers create. */
260
+ readonly roles?: GlobalRoles;
261
+ /**
262
+ * The SQL command each action verb compiles to, merged over the defaults
263
+ * (`read`, `list`, `get` → `select`; `create` → `insert`; `update`; `delete`).
264
+ * `'none'` compiles no policy. Every granted action is seeded into
265
+ * `role_permissions` either way, so `permdock_has` answers for it.
266
+ */
267
+ readonly actions?: RlsActions;
268
+ /** Emit only the helpers, their seeds and the scaffold; the table policies stay hand-written. */
269
+ readonly helpersOnly?: boolean;
270
+ /**
271
+ * Emit `permitted_<resource>_rows(p_permission)` and its `_for` form for
272
+ * these resources, or for every resource a grant reaches with `true`: the
273
+ * row ids the caller may act on, as the generated policies decide them.
274
+ */
275
+ readonly rowHelpers?: true | readonly string[];
276
+ readonly trustedReaders?: readonly string[];
277
+ readonly treeValues?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
278
+ /** `rls migrate`: how existing helper calls map onto the generated helpers. */
279
+ readonly migrate?: RlsMigrateConfig;
280
+ /**
281
+ * Emit a wrapper under each `migrate.helpers` name that answers from the
282
+ * generated helpers, for legacy SQL `rls migrate` leaves alone. `true` puts
283
+ * them in `public`. Off by default; `--shims` turns it on.
284
+ */
285
+ readonly shims?: boolean | RlsShimsConfig;
286
+ };
287
+ /**
288
+ * `rls.approvals` on a table the app already has: the store functions keep
289
+ * each request's body in `body` and its token in `token` (both added when
290
+ * missing) and read every field from the body; `mirror` copies request
291
+ * fields into the app's own columns on each write, converted to their types.
292
+ */
293
+ type RlsApprovalsAdopt = {
294
+ /** `table` or `schema.table`. */
295
+ readonly table: string;
296
+ /** A text column unique per request. Default `token`. */
297
+ readonly token?: string;
298
+ /** A jsonb column holding the `ApprovalRequest`. Default `body`. */
299
+ readonly body?: string;
300
+ readonly open?: "insert" | "attach";
301
+ readonly schema?: string;
302
+ /** Request fields copied into the app's columns, field to column. */
303
+ readonly mirror?: {
304
+ readonly status?: string;
305
+ readonly permission?: string;
306
+ readonly tenant?: string;
307
+ readonly principalId?: string;
308
+ readonly actorId?: string;
309
+ readonly session?: string;
310
+ readonly approvals?: string;
311
+ readonly createdAt?: string;
312
+ readonly expiresAt?: string;
313
+ readonly resolvedAt?: string;
314
+ readonly resolvedBy?: string;
315
+ readonly consumedAt?: string;
316
+ };
317
+ };
318
+ type RlsApiKeys = {
319
+ readonly claim?: string;
320
+ readonly scopes?: string;
321
+ readonly tenant?: string;
322
+ readonly roles?: string;
323
+ readonly serviceRoles?: readonly string[];
324
+ };
325
+ /** One more table whose rows assign a role, such as invitations (`rls.assignments.tables`). */
326
+ type RlsAssignmentTable = {
327
+ readonly table: string;
328
+ /** The declared scope the row assigns the role at. */
329
+ readonly scope: string;
330
+ /** The column holding the scope instance id. */
331
+ readonly id: string;
332
+ /** The tenant column for a scope below the first; defaults to `id` at the first scope. */
333
+ readonly tenant?: string;
334
+ /** The role key column, a reference to a roles table that holds the key, or several of them. */
335
+ readonly role: string | RoleThrough | readonly (string | RoleThrough)[];
336
+ /** The column holding the user the row assigns to, which `ownRole` compares with the caller. */
337
+ readonly user?: string;
338
+ };
339
+ /** `rls.customRoleWrites.roles`: the application's table of custom roles. */
340
+ type RlsCustomRoleTable = {
341
+ readonly table: string;
342
+ /** The column holding the role name. */
343
+ readonly key: string;
344
+ /** The tenant column; a row with no tenant is a platform custom role (`scope: 'global'`). Without it every row is a platform role. */
345
+ readonly tenant?: string;
346
+ /** A text column holding the scope name; without it a row with a tenant lives at the first scope. */
347
+ readonly scope?: string;
348
+ /** A column pinning the role to one instance of its scope. */
349
+ readonly id?: string;
350
+ /** A boolean column marking rows that are not custom roles (declared or system roles); those rows are skipped. */
351
+ readonly skip?: string;
352
+ };
353
+ /** `rls.shims`: where the legacy-named wrappers go. */
354
+ type RlsShimsConfig = {
355
+ /** Schema of the legacy helpers. Default `public`. */
356
+ readonly schema?: string;
357
+ };
358
+ /** An action verb's SQL command, or `'none'` for a verb that only `permdock_has` answers. */
359
+ type RlsActions = Readonly<Record<string, "select" | "insert" | "update" | "delete" | "none">>;
360
+ /**
361
+ * One existing SQL helper `rls migrate` rewrites. `form` names its arguments:
362
+ * `ids(key)` returns scope ids, `row(id, key)` and `membership(id)` test one id,
363
+ * `scoped(scope, id, key)` takes the scope as a literal, `global(key)` returns a boolean.
364
+ */
365
+ type RlsMigrateHelper = {
366
+ readonly form: "ids" | "row" | "membership";
367
+ readonly scope: string;
368
+ } | {
369
+ readonly form: "scoped";
370
+ } | {
371
+ readonly form: "global";
372
+ };
373
+ type RlsMigrateConfig = {
374
+ /** By function name, without the schema. */
375
+ readonly helpers: Readonly<Record<string, RlsMigrateHelper>>;
376
+ /** Exact key renames, checked before `prefixes`. */
377
+ readonly keys?: Readonly<Record<string, string>>;
378
+ /** Key prefix renames, longest first: `{ 'organization.': '' }`. */
379
+ readonly prefixes?: Readonly<Record<string, string>>;
380
+ /** For `scoped` helpers, the scope literals that mean a global check, such as `system`. */
381
+ readonly globalScopes?: readonly string[];
382
+ /** For `scoped` helpers, a scope literal's PermDock scope when the names differ. */
383
+ readonly scopes?: Readonly<Record<string, string>>;
384
+ };
385
+ /** Where global roles live: `table (user, role)`. Defaults `user_id` and `role`. */
386
+ type GlobalRoles = {
387
+ readonly table: string;
388
+ readonly user?: string;
389
+ readonly role?: string | RoleThrough;
390
+ };
391
+ /** A permission reference from the app's definitions; only its `key` is read. */
392
+ type RlsPermissionRef = {
393
+ readonly key: string;
394
+ };
395
+ /**
396
+ * One private Realtime topic pattern, such as `org:{organization}:chat`:
397
+ * `:`-separated segments, one of them `{<scope>}`, which holds the id of a
398
+ * scope instance.
399
+ */
400
+ type RlsRealtimeTopic = {
401
+ /** Receive broadcast and presence messages: `select` on `realtime.messages`. */
402
+ readonly read: RlsPermissionRef;
403
+ /** Send broadcast messages and track presence: `insert`. Absent: nobody may. */
404
+ readonly write?: RlsPermissionRef;
405
+ };
406
+ type RlsRealtime = {
407
+ readonly topics: Readonly<Record<string, RlsRealtimeTopic>>;
408
+ };
409
+ /** One Storage bucket whose object paths start with a scope instance id. */
410
+ type RlsStorageBucket = {
411
+ readonly scope: string;
412
+ /** The 1-based `storage.foldername(name)` entry that holds the id. Default 1. */
413
+ readonly folder?: number;
414
+ /** Download and list: `select` on `storage.objects`. */
415
+ readonly read?: RlsPermissionRef;
416
+ /** Upload and overwrite: `insert` and `update`. */
417
+ readonly write?: RlsPermissionRef;
418
+ readonly delete?: RlsPermissionRef;
419
+ };
420
+ type RlsStorage = {
421
+ readonly buckets: Readonly<Record<string, RlsStorageBucket>>;
422
+ };
423
+ /** `permdock supabase hook generate` input. */
424
+ type SupabaseHookConfig = {
425
+ /** The same `fromTable` / `fromJunction` sources the app passes as `memberships`. */
426
+ readonly memberships: readonly SqlMembershipSource[];
427
+ /** Schema of the hook and the version table. Default `rls.schema`, else `permdock`. */
428
+ readonly schema?: string;
429
+ /** Global roles: `user_role` and `roles`. Default `rls.roles`, else the `<schema>.user_roles (user_id, role)` table; `false` for none. */
430
+ readonly roles?: GlobalRoles | false;
431
+ /**
432
+ * Where the active first-scope id comes from: `app_metadata.<key>` (default
433
+ * `app_metadata.active_<first scope>`), `<table>.<column>` joined on `id`, or
434
+ * `{ table, id, column }`.
435
+ */
436
+ readonly activeFrom?: string | {
437
+ readonly table: string;
438
+ readonly id?: string;
439
+ readonly column: string;
440
+ };
441
+ /**
442
+ * The `attrs` claim, for attribute conditions such as
443
+ * `principal.claims.attrs.region`: allow-listed columns of a server-owned
444
+ * table (`table`, joined on `id`), and `app_metadata.<key>` entries. Never
445
+ * `user_metadata`; the migration fails when clients can write a column.
446
+ */
447
+ readonly attrs?: {
448
+ readonly table?: string;
449
+ readonly id?: string;
450
+ readonly columns: readonly string[];
451
+ };
452
+ /**
453
+ * Claims other packages own, each `claim: '<schema>.<function>'`, for
454
+ * example `{ features: 'public.feature_claims' }`. The function
455
+ * takes the user id (`uuid`) and returns `jsonb`; `null` omits the claim.
456
+ * Reserved names are refused, the claims sit outside `budget`, and a
457
+ * suspended user gets none.
458
+ */
459
+ readonly claims?: Readonly<Record<string, string>>;
460
+ readonly before?: string | readonly string[];
461
+ /**
462
+ * Check the claims the hook wrote against `supabase-claims-v1.json` with
463
+ * pg_jsonschema, and drop them all on a mismatch so the user signs in with
464
+ * no PermDock access instead of an error. Needs the extension. Default `false`.
465
+ */
466
+ readonly validate?: boolean;
467
+ /** Bytes of JSON the `memberships` claim may use. Default `supabaseMembershipsBudget` (1024). */
468
+ readonly budget?: number;
469
+ /** Keep `permdock_authz_version` and write the `authz_ver` claim. Default `true`. */
470
+ readonly version?: boolean;
471
+ /** The `jwt_expiry` the printed `config.toml` block sets. Default 900. */
472
+ readonly jwtExpiry?: number;
473
+ /** Suspended users get empty claims. Default `rls.suspension`. */
474
+ readonly suspension?: RlsSuspension;
475
+ readonly out?: string;
476
+ };
477
+ type SupabaseConfig = {
478
+ readonly hook?: SupabaseHookConfig;
479
+ };
480
+ type DoctorConfig = {
481
+ /**
482
+ * Directories or globs the source checks read (PD001, PD002, PD007 to
483
+ * PD015, PD044 and the other checks over files), default `collect.srcPath`.
484
+ * The catalog `collect` writes still comes from `collect.srcPath`, and PD004
485
+ * compares the catalog on disk with that one.
486
+ */
487
+ readonly srcPath?: readonly string[];
488
+ readonly sensitiveActions?: readonly string[];
489
+ readonly memberships?: string;
490
+ /** A JSON fixture `{ credentials?, settings? }` of API-key credentials and per-tenant settings (the `memorySettings` input) for PD029. */
491
+ readonly credentials?: string;
492
+ /** Globs or directories whose files are client entries for PD001, for frameworks with no `'use client'` convention. */
493
+ readonly clientEntries?: readonly string[];
494
+ /** Globs or directories of SQL migrations PD022 scans for views; defaults to the usual migration folders. */
495
+ readonly migrations?: readonly string[];
496
+ /** A JSON array of sample decoded token claims; PD039 measures each `supabase.hook.claims` entry in it. */
497
+ readonly claims?: string;
498
+ };
499
+ type PermDockConfig = {
500
+ readonly permissions?: string;
501
+ readonly policy?: string;
502
+ readonly collect?: CollectConfig;
503
+ readonly catalog?: CatalogConfig;
504
+ readonly openapi?: {
505
+ readonly doc?: readonly string[];
506
+ };
507
+ readonly rls?: RlsConfig;
508
+ readonly supabase?: SupabaseConfig;
509
+ readonly powersync?: PowerSyncConfig;
510
+ readonly doctor?: DoctorConfig;
511
+ };
512
+ /** `permdock powersync generate` and `verify` input. Tables and memberships come from `rls`. */
513
+ type PowerSyncConfig = {
514
+ /** The Sync Streams file; default `sync-config.yaml`. */
515
+ readonly out?: string;
516
+ /** Resources that get a stream; default every resource with a grant of `action`. */
517
+ readonly resources?: readonly string[];
518
+ /** The action whose grants decide which rows sync; default `read`. */
519
+ readonly action?: string;
520
+ /** Where `generate` writes `localSnapshotManifest(policy)` as JSON for `localSnapshot` and `powersyncSource`; none by default. */
521
+ readonly manifest?: string;
522
+ };
523
+ type CliIo = {
524
+ readonly stdout: (text: string) => void;
525
+ readonly stderr: (text: string) => void;
526
+ readonly now?: () => Date;
527
+ readonly fetch?: typeof fetch;
528
+ readonly env?: Readonly<Record<string, string | undefined>>;
529
+ /** Styled human output; `--no-color` turns it off. Unset is plain. */
530
+ readonly color?: boolean;
531
+ /** A person at a terminal: commands may prompt. Unset never prompts. */
532
+ readonly interactive?: boolean;
533
+ };
534
+ type RunResult = {
535
+ readonly code: 0 | 1 | 2;
536
+ readonly stdout: string;
537
+ readonly stderr: string;
538
+ };
539
+ type PermDockPluginOptions = {
540
+ readonly collect?: CollectConfig;
541
+ readonly onDrift?: "error" | "warn";
542
+ /**
543
+ * Unplugin only: compare instead of write in `buildStart`, failing the
544
+ * build on drift (as `permdock collect --check` does). The Next plugin
545
+ * checks in `phase-production-build` unless `PERMDOCK_COLLECT=write`.
546
+ */
547
+ readonly check?: boolean;
548
+ };
549
+ //#endregion
550
+ export { RunResult as _, PermDockPluginOptions as a, RlsConfig as c, RlsMembershipTable as d, RlsMemberships as f, RlsTarget as g, RlsSuspension as h, PermDockConfig as i, RlsDialect as l, RlsSuspendedScope as m, CliIo as n, RlsActiveRow as o, RlsSuspendedMembership as p, CollectConfig as r, RlsApiKeys as s, CatalogConfig as t, RlsFunctionMapping as u };
@@ -0,0 +1,120 @@
1
+ import { $n as ExplainedDecision, C as Policy, D as PolicyVocabulary, In as ArazzoPlan, Ln as ArazzoSimulateInput, Mr as Membership, Nr as Principal, Pr as Subject, Yn as Decision, cn as DeriveOptions, fn as SimulateOptions, ln as PermDock, mn as WhereResult, sn as DecideOptions, un as PermDockOptions } from "./policy-CFZAr_Al.js";
2
+ import { f as Permission, m as PermissionTree } from "./permissions-DttnqqxC.js";
3
+ //#region src/pdp/types.d.ts
4
+ type RemotePdpAuth = {
5
+ readonly bearer: string | (() => string | Promise<string>);
6
+ };
7
+ type RemotePdpMapping = {
8
+ readonly subject?: (subject: Subject) => {
9
+ readonly type?: string;
10
+ readonly id?: string;
11
+ readonly properties?: Readonly<Record<string, unknown>>;
12
+ };
13
+ readonly resource?: (permission: Permission, data: unknown) => {
14
+ readonly type?: string;
15
+ readonly id?: string;
16
+ readonly properties?: unknown;
17
+ };
18
+ readonly action?: (permission: Permission) => {
19
+ readonly name?: string;
20
+ };
21
+ };
22
+ type RemotePdpEndpoints = {
23
+ readonly evaluation?: string;
24
+ readonly evaluations?: string;
25
+ readonly searchResource?: string;
26
+ };
27
+ type RemotePdpCache = {
28
+ readonly ttl: number | `${number}s` | `${number}ms`;
29
+ };
30
+ type RemotePdpOptions = {
31
+ readonly url: string;
32
+ readonly auth?: RemotePdpAuth;
33
+ readonly permissions?: readonly (Permission | PermissionTree)[];
34
+ readonly mapping?: RemotePdpMapping;
35
+ readonly timeout?: number;
36
+ readonly cache?: RemotePdpCache;
37
+ readonly endpoints?: RemotePdpEndpoints;
38
+ readonly fetch?: typeof fetch;
39
+ };
40
+ /**
41
+ * One tuple callback per delegated permission. The callback receives the
42
+ * row for a check and `undefined` for a listing; returning `null` denies
43
+ * with `pdp-denied`, throwing denies with `pdp-invalid-response`.
44
+ */
45
+ type RelationMap<T> = readonly (readonly [Permission, (subject: Subject, data: unknown) => T | null])[];
46
+ type OpenFgaTuple = {
47
+ /** `user:anne`, `team:eng#member`. */
48
+ readonly user: string;
49
+ readonly relation: string;
50
+ readonly type: string;
51
+ /** Required for a check; ignored for `list-objects`. */
52
+ readonly id?: string;
53
+ };
54
+ type OpenFgaOptions = {
55
+ readonly url: string;
56
+ readonly storeId: string;
57
+ readonly authorizationModelId?: string;
58
+ readonly map: RelationMap<OpenFgaTuple>;
59
+ readonly auth?: RemotePdpAuth;
60
+ readonly timeout?: number;
61
+ readonly cache?: RemotePdpCache;
62
+ readonly fetch?: typeof fetch;
63
+ };
64
+ type SpiceDbCheck = {
65
+ readonly subject: {
66
+ readonly type: string;
67
+ readonly id: string;
68
+ readonly relation?: string;
69
+ };
70
+ readonly permission: string;
71
+ /** `id` is required for a check; ignored for `LookupResources`. */
72
+ readonly resource: {
73
+ readonly type: string;
74
+ readonly id?: string;
75
+ };
76
+ };
77
+ type SpiceDbOptions = {
78
+ /** The SpiceDB HTTP gateway origin. */
79
+ readonly url: string;
80
+ readonly token: RemotePdpAuth["bearer"];
81
+ readonly map: RelationMap<SpiceDbCheck>;
82
+ readonly consistency?: "minimize-latency" | "fully-consistent";
83
+ readonly timeout?: number;
84
+ readonly cache?: RemotePdpCache;
85
+ readonly fetch?: typeof fetch;
86
+ };
87
+ type PdpPermDock<V extends PolicyVocabulary = PolicyVocabulary> = Omit<PermDock<V>, "can" | "decide" | "assert" | "explain" | "filter" | "where" | "simulate" | "tenant" | "team" | "derive"> & {
88
+ /** `permdock.derive` with the same providers: the result asks the PDP too. */
89
+ readonly derive: (options: DeriveOptions) => PdpPermDock<V> | Promise<PdpPermDock<V>>;
90
+ /**
91
+ * For a delegated permission whose provider lists ids, an `in` over them
92
+ * (AND the local condition when local grants exist); otherwise the local
93
+ * `where`, or an always-false `partial` result.
94
+ */
95
+ readonly where: (permission: Permission) => Promise<WhereResult>;
96
+ readonly can: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<boolean>;
97
+ readonly decide: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<Decision>;
98
+ readonly assert: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<Extract<Decision, {
99
+ readonly outcome: "granted";
100
+ }>>;
101
+ /** `decide` with a trace of the local grants; a decision the remote PDP made carries an empty trace. */
102
+ readonly explain: (permission: Permission, data?: unknown, options?: Omit<DecideOptions, "explain">) => Promise<ExplainedDecision>;
103
+ readonly filter: <T>(permission: Permission<string, T, "instance">, rows: readonly T[], options?: DecideOptions) => Promise<T[]>;
104
+ readonly simulate: {
105
+ (checks: readonly (readonly [Permission, unknown?])[], options?: SimulateOptions): Promise<readonly Decision[]>;
106
+ (plan: ArazzoSimulateInput): ArazzoPlan;
107
+ (preview: {
108
+ readonly roles?: readonly (string | {
109
+ readonly key: string;
110
+ })[];
111
+ readonly memberships?: readonly Membership[];
112
+ readonly tenant?: string;
113
+ }): PdpPermDock<V>;
114
+ };
115
+ readonly tenant: (id: string) => PdpPermDock<V>;
116
+ readonly team: (id: string) => PdpPermDock<V>;
117
+ };
118
+ type PdpFactory = <TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, user: TUser | null, options?: PermDockOptions) => Promise<PdpPermDock<V>>;
119
+ //#endregion
120
+ export { RelationMap as a, RemotePdpEndpoints as c, SpiceDbCheck as d, SpiceDbOptions as f, PdpPermDock as i, RemotePdpMapping as l, OpenFgaTuple as n, RemotePdpAuth as o, PdpFactory as r, RemotePdpCache as s, OpenFgaOptions as t, RemotePdpOptions as u };
@@ -0,0 +1,9 @@
1
+ import { f as Permission } from "./permissions-DttnqqxC.js";
2
+ //#region src/agent/types.d.ts
3
+ type ToolBinding = {
4
+ readonly permission: Permission;
5
+ readonly data?: (args: unknown) => unknown;
6
+ };
7
+ type ToolMap = Readonly<Record<string, ToolBinding>>;
8
+ //#endregion
9
+ export { ToolMap as t };