permdock 0.28.1 → 0.29.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 (98) hide show
  1. package/dist/{adoption-scan-6eUACbvC.js → adoption-scan-obbSy73c.js} +1 -1
  2. package/dist/{arazzo-DSzOxgr1.js → arazzo-D9Fv_ZEV.js} +1 -1
  3. package/dist/{arazzo-Du3koIf5.js → arazzo-rxj2pNN3.js} +1 -1
  4. package/dist/better-supabase/index.d.ts +7 -0
  5. package/dist/better-supabase/index.js +2 -2
  6. package/dist/{casbin-CW2uo-Jt.js → casbin-D3PH6-AJ.js} +1 -1
  7. package/dist/{casbin-B5UnU9nM.js → casbin-p8yi9Py5.js} +1 -1
  8. package/dist/cli/bin.js +1 -1
  9. package/dist/cli/generate/watch-worker.js +1 -1
  10. package/dist/cli/index.js +1 -1
  11. package/dist/cli/plugins/app.js +1 -1
  12. package/dist/cli/plugins/openapi.js +1 -1
  13. package/dist/cli/plugins/powersync.js +1 -1
  14. package/dist/cli/plugins/rls.js +1 -1
  15. package/dist/cli/plugins/schemas.js +1 -1
  16. package/dist/cli/plugins/supabase-hook.js +1 -1
  17. package/dist/cli/plugins/supabase.js +2 -2
  18. package/dist/cli/plugins/ui.js +1 -1
  19. package/dist/{cloud-DhpR9oxl.js → cloud-DnTSKTYr.js} +2 -2
  20. package/dist/{codemod-BRY1780A.js → codemod-C4xmPHZU.js} +1 -1
  21. package/dist/{codemod-DEsebwQn.js → codemod-DwJ1I9er.js} +2 -2
  22. package/dist/{compile-CT7x66_U.js → compile-B9SZiEnG.js} +6 -6
  23. package/dist/{completion-CW1poYOM.js → completion-CHOgUToS.js} +1 -1
  24. package/dist/{conditions-VlAMOm20.js → conditions-ChE7zxJI.js} +2 -2
  25. package/dist/{config-DP7Stalz.js → config-StFKj2S0.js} +1 -1
  26. package/dist/{config-report-CnuPIG_V.js → config-report-DFj3emJp.js} +1 -1
  27. package/dist/{doctor-CkaAS-Uk.js → doctor-BSYAl2XG.js} +20 -20
  28. package/dist/{doctor-B3rZsURs.js → doctor-CjCJ_U2a.js} +2 -2
  29. package/dist/{execute-CdqPJ6SP.js → execute-BzQKrYqL.js} +3 -3
  30. package/dist/{fields-6d1j-q3c.js → fields-CViS0EPC.js} +1 -1
  31. package/dist/{gen-DCmo0Irk.js → gen-BVDN_Hqx.js} +2 -2
  32. package/dist/gen-D13YdBQP.js +1 -0
  33. package/dist/{gen-kind-10IxFLdl.js → gen-kind-BK6bb0gj.js} +1 -1
  34. package/dist/{generate-CYUj-cvA.js → generate-DNAoLMj1.js} +14 -14
  35. package/dist/{generate-options-AvKV0IXA.js → generate-options-Yfh1pGyX.js} +9 -9
  36. package/dist/{generate-BuNebxmi.js → generate-p7cdH1ac.js} +3 -3
  37. package/dist/{grants-C7bGZFPa.js → grants-Dn6zwfqo.js} +1 -1
  38. package/dist/{hook-sql-Cunsdk5x.js → hook-sql-55514A9t.js} +13 -11
  39. package/dist/{import-CDCWY5Ou.js → import-B0nUIp2b.js} +1 -1
  40. package/dist/{import-BqoDHpFt.js → import-Cm8kuezl.js} +2 -2
  41. package/dist/{init-QA12XZy5.js → init-CjlVWrBE.js} +3 -3
  42. package/dist/{init-erhwH2o6.js → init-Ck4PIu9F.js} +1 -1
  43. package/dist/{interactive-only-CQsgMc1E.js → interactive-only-C_olBCPl.js} +28 -2
  44. package/dist/{login-OBqLmoA2.js → login-BdWIAsFT.js} +1 -1
  45. package/dist/{login-BJmDn5p2.js → login-BhSLL8Pn.js} +3 -3
  46. package/dist/{manifest-BY70KZmp.js → manifest-CXK3krNu.js} +30 -30
  47. package/dist/{manifest-B-8d2lhG.js → manifest-Ct3eXbLR.js} +1 -1
  48. package/dist/{manifest-schema-DJY5Q_pR.js → manifest-schema-Bp-eFhNZ.js} +1 -1
  49. package/dist/{migrate-BwXtXUtE.js → migrate-BcBFWFt9.js} +1 -1
  50. package/dist/{model-BkQLENu6.js → model-B0rrUh6J.js} +1 -1
  51. package/dist/{openapi-DmEgZ9X8.js → openapi-D595qUYF.js} +1 -1
  52. package/dist/{openapi-B9Lpb4Px.js → openapi-E2411VYb.js} +1 -1
  53. package/dist/{openapi-document-BJDwMJRO.js → openapi-document-DDzA3CrT.js} +1 -1
  54. package/dist/{output-Cqtb8lW_.js → output-BhNN-hvv.js} +1 -1
  55. package/dist/{ownership-fYxdtYs0.js → ownership-mprXkEHG.js} +3 -3
  56. package/dist/{pipeline-CGctXudd.js → pipeline-Ct3YEKjx.js} +1 -1
  57. package/dist/{policy-gS3zexF5.js → policy-DfvOwgtX.js} +1 -1
  58. package/dist/{policy-bundle-AFVba7nt.js → policy-bundle-pwhJJv2-.js} +3 -3
  59. package/dist/{powersync-TraBGEw2.js → powersync-BdqLK59r.js} +1 -1
  60. package/dist/{powersync-WvWQh2kU.js → powersync-CMu40wtz.js} +1 -1
  61. package/dist/{powersync-d4eoYO3I.js → powersync-Da9op2Zo.js} +7 -7
  62. package/dist/{provider-BnnFjtWI.js → provider-1yWthvi5.js} +14 -4
  63. package/dist/{pull-xhMWizWH.js → pull-AXzbc_kg.js} +2 -2
  64. package/dist/pull-B0ju22jJ.js +1 -0
  65. package/dist/{push-DXh936bz.js → push-N-QI_ArC.js} +1 -1
  66. package/dist/{rbac-ir19O-e-.js → rbac-BJTUGJum.js} +1 -1
  67. package/dist/{resolve-names-B3PM0l3J.js → resolve-names-B0cqvJxo.js} +4 -4
  68. package/dist/{rls-DEPAx9uQ.js → rls-BC1IFnfu.js} +1 -1
  69. package/dist/{rls-CYbk1UmD.js → rls-DfzVlo1q.js} +9 -9
  70. package/dist/{rls-files-CxdOxMKl.js → rls-files-BpMqBdji.js} +1 -1
  71. package/dist/{run-CI5opYjC.js → run-CqAur1Y3.js} +2 -2
  72. package/dist/run-X_cWRiUV.js +1 -0
  73. package/dist/{scan-BrILYXP9.js → scan-C_YtxPxn.js} +1 -1
  74. package/dist/{schema-C-Nn6M1P.js → schema-BVhiZyY-.js} +1 -1
  75. package/dist/{shared-BdF5DJDQ.js → shared-Cwxy5N16.js} +2 -1
  76. package/dist/{skills-C2SqRGXy.js → skills-CQ3B9vuz.js} +1 -1
  77. package/dist/{skills-Cuf4gcfr.js → skills-DBvXLSo7.js} +1 -1
  78. package/dist/supabase/index.js +1 -1
  79. package/dist/{supabase-V_yr_spa.js → supabase-CakrAxMg.js} +1 -1
  80. package/dist/{supabase-config-BrhSp-U7.js → supabase-config-B2sDFiwy.js} +1 -1
  81. package/dist/{supabase-hook-C7v1wRUV.js → supabase-hook-0q6ohTVN.js} +3 -3
  82. package/dist/supabase-hook-CcmjiBsh.js +2 -0
  83. package/dist/{tables-D-tmMHww.js → tables-BDqfipr1.js} +2 -2
  84. package/dist/testing/fixtures/index.js +7 -1
  85. package/dist/testing/index.js +1 -1
  86. package/dist/usage-Cayjfw1S.js +1 -0
  87. package/dist/{usage-XS56d_Kx.js → usage-CnCNB6XN.js} +2 -2
  88. package/dist/{usage-Bh-VP8co.js → usage-Dodo7Sjb.js} +1 -1
  89. package/dist/{verify-aCeiREkh.js → verify-DTlATzWK.js} +5 -5
  90. package/dist/{watch-CnRyGEtp.js → watch-Bz_iEKlB.js} +1 -1
  91. package/package.json +1 -1
  92. package/schemas/supabase-manifest-v1.json +1 -1
  93. package/skills/permdock-wire/references/adapters.md +1 -1
  94. package/dist/gen-DnaCR5w3.js +0 -1
  95. package/dist/pull-Bn9a5g9Q.js +0 -1
  96. package/dist/run-BtTQlk1R.js +0 -1
  97. package/dist/supabase-hook-BJImmLmb.js +0 -2
  98. package/dist/usage-DpmLPRRx.js +0 -1
@@ -8,21 +8,21 @@ import { i as fileDrift } from "./output-files-D5D-8-4l.js";
8
8
  import { n as fixtureSubject, r as loadFixtures, t as fixtureRow } from "./fixtures-Bm0G0A7H.js";
9
9
  import { n as pgConnector } from "./pg-CA651850.js";
10
10
  import { c as requirePolicy } from "./load-CZnlAyZ8.js";
11
- import { t as canFixture } from "./verify-aCeiREkh.js";
12
- import { a as roleNames, i as collectGrants, t as assignableRoles } from "./grants-C7bGZFPa.js";
11
+ import { t as canFixture } from "./verify-DTlATzWK.js";
12
+ import { a as roleNames, i as collectGrants, t as assignableRoles } from "./grants-Dn6zwfqo.js";
13
13
  import { a as quoteIdent, s as quoteQualified } from "./quote-BKrTBbcH.js";
14
14
  import { a as scopeMembershipTable, i as scopeColumn } from "./compile-BUKXrueE.js";
15
15
  import { r as isRecord, t as compact } from "./compact-C4LFuqbW.js";
16
16
  import { d as scopeList, s as resolveScope } from "./scopes-B-KX9EI8.js";
17
17
  import { d as keptKeys, t as AUTHZ_VERSION_TABLE } from "./sources-DnjJPGfb.js";
18
- import { a as customRolesOn, t as CUSTOM_ROLES } from "./shared-BdF5DJDQ.js";
18
+ import { a as customRolesOn, t as CUSTOM_ROLES } from "./shared-Cwxy5N16.js";
19
19
  import { t as membershipSourcesOf } from "./sources-BbSUNmFX.js";
20
20
  import { s as quoteSqlLiteral, t as SQL_IDENT } from "./sql-T4GaBh9X.js";
21
- import { t as ownershipRules } from "./ownership-fYxdtYs0.js";
22
- import { i as tableFor } from "./compile-CT7x66_U.js";
23
- import { i as tableNames, r as tableNameOf } from "./tables-D-tmMHww.js";
21
+ import { t as ownershipRules } from "./ownership-mprXkEHG.js";
22
+ import { i as tableFor } from "./compile-B9SZiEnG.js";
23
+ import { i as tableNames, r as tableNameOf } from "./tables-BDqfipr1.js";
24
24
  import { l as policyLevels } from "./policy-DFD2J5o_.js";
25
- import { r as contextRefs, t as andConditions } from "./conditions-VlAMOm20.js";
25
+ import { r as contextRefs, t as andConditions } from "./conditions-ChE7zxJI.js";
26
26
  import { p as scopeField } from "./tenancy-B5Xxt9Sc.js";
27
27
  import { t as requiresApproval } from "./approval-required-B-R4Yw3J.js";
28
28
  import { resolve } from "node:path";
@@ -2,7 +2,7 @@ import { t as parseCatalog } from "./parse-nfHSt1Wy.js";
2
2
  import { n as freezeDeep } from "./freeze-DGfJq_j2.js";
3
3
  import { a as delegatedScopeMap } from "./permdock-BueSeg7X.js";
4
4
  import { i as qualifySqlTable, l as sqlIdent, s as quoteSqlLiteral } from "./sql-T4GaBh9X.js";
5
- import { n as parseSupabaseManifest, t as hasTokenHook } from "./manifest-B-8d2lhG.js";
5
+ import { n as parseSupabaseManifest, t as hasTokenHook } from "./manifest-Ct3eXbLR.js";
6
6
  import { o as holder, r as approverLeaves } from "./approvers-BkY_ZfWl.js";
7
7
  import { n as asApprover } from "./approval-normalize-Cpp8R0rY.js";
8
8
  // src/better-supabase/active-tenant.ts
@@ -208,6 +208,11 @@ const TEAM_SCOPE = /^teams?$/u;
208
208
  const ACTOR_MAY_WRITE = "permdock_actor_may_write";
209
209
  const APPROVER_FOR = "permdock_approver_for_ids";
210
210
  const MANAGED_USERS = "permdock_managed_user_ids";
211
+ /**
212
+ * Whether a role is the tenant's, for better-supabase's `membership_roles`
213
+ * trigger.
214
+ */
215
+ const ROLE_IN = "permdock_role_in";
211
216
  const OPTIONAL = [
212
217
  "idsWithFor",
213
218
  "isPlatformFor",
@@ -280,8 +285,9 @@ function rowTemplatesOf(schema, manifest, requires, problems) {
280
285
  * lists their helper, which `rls.mode: 'database'` writes. `subject` and
281
286
  * `subjectForTenant` name `permdock_subject()` and `permdock_subject(p_tenant)`
282
287
  * unless `subject: false`; `subjectForTenant`, `bootstrapPermissions`
283
- * (`permdock_bootstrap_permissions(p_tenant)`) and `canIn` (the tenant scope's
284
- * ids by permission, as a set) answer at the root scope only.
288
+ * (`permdock_bootstrap_permissions(p_tenant)`), `canIn` (the tenant scope's ids
289
+ * by permission, as a set) and `roleIn` (`permdock_role_in`) answer at the root
290
+ * scope only.
285
291
  */
286
292
  function providerFunctions(input) {
287
293
  const { manifest, catalog, options, tenantScope, rootTenant, problems } = input;
@@ -347,6 +353,9 @@ function providerFunctions(input) {
347
353
  };
348
354
  const approverFor = setTemplate(APPROVER_FOR);
349
355
  const managedUsers = /\bp_tenant\b/u.test(helpers.get(MANAGED_USERS)?.args ?? "") ? setTemplate(MANAGED_USERS, "{tenant}") : void 0;
356
+ const roleInHelper = options.roleIn === true && rootTenant ? helpers.get(ROLE_IN) : void 0;
357
+ if (options.roleIn === true && roleInHelper === void 0) problems.push(`roleIn: the manifest's rls.helpers has no ${rls.schema}.${ROLE_IN} at the root tenant scope. Set rls.customRoles in database mode, run \`permdock rls generate\`, then \`permdock supabase inspect --out\`.`);
358
+ const roleIn = roleInHelper === void 0 ? void 0 : call(ROLE_IN, "{role}, {tenant}", "postgres", argTypes(roleInHelper.args));
350
359
  return {
351
360
  functions: {
352
361
  ...rowTemplates,
@@ -363,7 +372,8 @@ function providerFunctions(input) {
363
372
  ...subjectForTenant === void 0 ? {} : { subjectForTenant },
364
373
  ...bootstrapPermissions === void 0 ? {} : { bootstrapPermissions },
365
374
  ...approverFor === void 0 ? {} : { approverFor },
366
- ...managedUsers === void 0 ? {} : { managedUsers }
375
+ ...managedUsers === void 0 ? {} : { managedUsers },
376
+ ...roleIn === void 0 ? {} : { roleIn }
367
377
  },
368
378
  requires,
369
379
  canAssign: listed("canAssign", tenantScope)
@@ -1,10 +1,10 @@
1
1
  import { t as parseCatalog } from "./parse-nfHSt1Wy.js";
2
2
  import { t as catalogFingerprint } from "./catalog-fingerprint-DAWZARy6.js";
3
- import { n as parseSupabaseManifest } from "./manifest-B-8d2lhG.js";
3
+ import { n as parseSupabaseManifest } from "./manifest-Ct3eXbLR.js";
4
4
  import { o as formatCatalogJson } from "./catalog-doc-Bp5khmCG.js";
5
5
  import { t as catalogPath } from "./catalog-path-bG0XxHMu.js";
6
6
  import { a as describeError } from "./errors-DgLOqc6j.js";
7
- import { a as nonEmptyOr } from "./output-Cqtb8lW_.js";
7
+ import { a as nonEmptyOr } from "./output-BhNN-hvv.js";
8
8
  import { s as cliVersion } from "./version-D-jWyJb9.js";
9
9
  import { s as writeFileEnsuringDir } from "./files-DAR51W3J.js";
10
10
  import { n as formatManifestJson } from "./manifest-json-DMaBWmcG.js";
@@ -0,0 +1 @@
1
+ export { n as runCloudPull } from "./pull-AXzbc_kg.js";
@@ -3,7 +3,7 @@ import { r as pushedPolicy } from "./pushed-policy-rpB6k77P.js";
3
3
  import { r as isRecord } from "./compact-C4LFuqbW.js";
4
4
  import { n as PermDockValidationError } from "./validation-error-CgDOA6VS.js";
5
5
  import { t as catalogFingerprint } from "./catalog-fingerprint-DAWZARy6.js";
6
- import { n as parseSupabaseManifest } from "./manifest-B-8d2lhG.js";
6
+ import { n as parseSupabaseManifest } from "./manifest-Ct3eXbLR.js";
7
7
  import { n as runCatalog } from "./catalog-DXSP1we9.js";
8
8
  import { a as describeError, n as CliError } from "./errors-DgLOqc6j.js";
9
9
  import { n as httpRequest, t as authFailure } from "./http-BbX_Ou3_.js";
@@ -1,6 +1,6 @@
1
1
  import { n as authorizeSql } from "./supabase-BzK3lplm.js";
2
2
  import { i as configError } from "./errors-DgLOqc6j.js";
3
- import { a as roleNames } from "./grants-C7bGZFPa.js";
3
+ import { a as roleNames } from "./grants-Dn6zwfqo.js";
4
4
  import { a as quoteIdent, c as quoteTable, o as quoteLiteral, s as quoteQualified } from "./quote-BKrTBbcH.js";
5
5
  // src/cli/rls/rbac.ts
6
6
  /**
@@ -4,10 +4,10 @@ import { d as scopeList } from "./scopes-B-KX9EI8.js";
4
4
  import "./budget-BH81q2cj.js";
5
5
  import "./sources-DnjJPGfb.js";
6
6
  import { i as configError } from "./errors-DgLOqc6j.js";
7
- import { t as FIELD_VIEWS } from "./fields-6d1j-q3c.js";
8
- import { C as forUserContext, Q as graphPlan, d as permittedByPermissionHelper, i as tableNames, o as PERMISSION_HELPERS, p as holderSources, s as checkName, w as grantBodies } from "./tables-D-tmMHww.js";
9
- import { D as idTypeOf, O as scopeTypeOf } from "./shared-BdF5DJDQ.js";
10
- import { G as graphHelper, K as graphSqlName, Q as isTeamScope, T as globalRoleRows, X as hasPermittedUsers, Z as inheritedRowsHelper, ct as restrictedHelper, et as memberForHelper, f as holderBody, it as memberOfHelper, ot as permittedForHelper, rt as memberIdsHelper, st as permittedIdsHelper, ut as scopeTable } from "./interactive-only-CQsgMc1E.js";
7
+ import { t as FIELD_VIEWS } from "./fields-CViS0EPC.js";
8
+ import { C as forUserContext, Q as graphPlan, d as permittedByPermissionHelper, i as tableNames, o as PERMISSION_HELPERS, p as holderSources, s as checkName, w as grantBodies } from "./tables-BDqfipr1.js";
9
+ import { D as idTypeOf, O as scopeTypeOf } from "./shared-Cwxy5N16.js";
10
+ import { G as graphHelper, K as graphSqlName, Q as isTeamScope, T as globalRoleRows, X as hasPermittedUsers, Z as inheritedRowsHelper, ct as restrictedHelper, et as memberForHelper, f as holderBody, it as memberOfHelper, ot as permittedForHelper, rt as memberIdsHelper, st as permittedIdsHelper, ut as scopeTable } from "./interactive-only-C_olBCPl.js";
11
11
  import { a as quoteIdent, i as qualified, o as quoteLiteral, s as quoteQualified } from "./quote-BKrTBbcH.js";
12
12
  // src/cli/rls/permission-holders.ts
13
13
  /**
@@ -192,7 +192,7 @@ async function rlsInput(ctx, verb, shape, options) {
192
192
  };
193
193
  }
194
194
  async function runRls(input) {
195
- return (await import("./rls-CYbk1UmD.js")).runRls(input);
195
+ return (await import("./rls-DfzVlo1q.js")).runRls(input);
196
196
  }
197
197
  ({
198
198
  ...shapeFlags,
@@ -2,15 +2,15 @@ import "./sources-DnjJPGfb.js";
2
2
  import { a as describeError, f as usageResult, o as exitCodeOfError } from "./errors-DgLOqc6j.js";
3
3
  import { i as requirePeer, n as packageManagerOf, t as addLine } from "./peer-D77JpXe-.js";
4
4
  import { n as pgConnector, t as connectPgPool } from "./pg-CA651850.js";
5
- import { f as isSupabaseSchemas, m as schemasRefusal } from "./hook-sql-Cunsdk5x.js";
6
- import { a as nonEmptyOr } from "./output-Cqtb8lW_.js";
7
- import { n as describeExplain, t as runRlsGenerate } from "./generate-CYUj-cvA.js";
8
- import { a as COLUMNS_SQL, o as INDEX_COLUMNS_SQL, u as readTableIndexFacts } from "./compile-CT7x66_U.js";
5
+ import { f as isSupabaseSchemas, m as schemasRefusal } from "./hook-sql-55514A9t.js";
6
+ import { a as nonEmptyOr } from "./output-BhNN-hvv.js";
7
+ import { n as describeExplain, t as runRlsGenerate } from "./generate-DNAoLMj1.js";
8
+ import { a as COLUMNS_SQL, o as INDEX_COLUMNS_SQL, u as readTableIndexFacts } from "./compile-B9SZiEnG.js";
9
9
  import { r as escapeSqlIdent } from "./sql-T4GaBh9X.js";
10
10
  import { t as beforeFirst } from "./text-D704xHVl.js";
11
- import { a as verifyResult, c as callsHelper, i as verifyIgnores, l as helperCallKeys, n as runRlsVerify, o as HELPER_TABLES, r as rlsFinding } from "./verify-aCeiREkh.js";
12
- import { c as ACTOR_MAY_WRITE, p as readOnlyActorKinds } from "./fields-6d1j-q3c.js";
13
- import { r as parseRbacAuthorize } from "./rbac-ir19O-e-.js";
11
+ import { a as verifyResult, c as callsHelper, i as verifyIgnores, l as helperCallKeys, n as runRlsVerify, o as HELPER_TABLES, r as rlsFinding } from "./verify-DTlATzWK.js";
12
+ import { c as ACTOR_MAY_WRITE, p as readOnlyActorKinds } from "./fields-CViS0EPC.js";
13
+ import { r as parseRbacAuthorize } from "./rbac-BJTUGJum.js";
14
14
  import { delimiter, join } from "node:path";
15
15
  import { spawn } from "node:child_process";
16
16
  // src/cli/rls/grant-calls.ts
@@ -770,7 +770,7 @@ async function migrate(input) {
770
770
  output: generated.output
771
771
  };
772
772
  await requirePeer(() => import("pgsql-parser"), "pgsql-parser", "permdock rls migrate", input.cwd, PGSQL_PARSER_MAJOR);
773
- const { migrateTarget, runRlsMigrate } = await import("./migrate-BwXtXUtE.js");
773
+ const { migrateTarget, runRlsMigrate } = await import("./migrate-BcBFWFt9.js");
774
774
  return runRlsMigrate({
775
775
  cwd: input.cwd,
776
776
  sql: input.sql,
@@ -886,7 +886,7 @@ async function runRls(input) {
886
886
  }
887
887
  case "import": {
888
888
  await requirePeer(() => import("pgsql-parser"), "pgsql-parser", "permdock rls import", input.cwd, PGSQL_PARSER_MAJOR);
889
- const { runRlsImport } = await import("./import-BqoDHpFt.js");
889
+ const { runRlsImport } = await import("./import-Cm8kuezl.js");
890
890
  return runRlsImport({
891
891
  cwd: input.cwd,
892
892
  config: input.config,
@@ -3,7 +3,7 @@ import { i as dateAt } from "./time-r0CKBm57.js";
3
3
  import { n as CliError } from "./errors-DgLOqc6j.js";
4
4
  import { m as seedsMigration, p as seedDeltaNote } from "./output-files-D5D-8-4l.js";
5
5
  import { a as fixturesPresent, i as defaultsSeedSql, o as fixturesSeedSql, r as FIXTURES_PATH, t as DEFAULTS_MARKER } from "./seed-sql-CjF7u0aX.js";
6
- import { t as runRlsGenerate } from "./generate-CYUj-cvA.js";
6
+ import { t as runRlsGenerate } from "./generate-DNAoLMj1.js";
7
7
  import { a as quietIo, r as noted } from "./plugin-MQVfUBUS.js";
8
8
  // src/cli/generate/plugins/rls-options.ts
9
9
  function seedMode(seeds) {
@@ -3,9 +3,9 @@ import { a as resolveCwd, i as readConfig, o as withPluginOutputs } from "./conf
3
3
  import { t as beforeFirst } from "./text-D704xHVl.js";
4
4
  import { a as describeError, n as CliError, r as cliFailure, s as failureOf, u as kindOfCode } from "./errors-DgLOqc6j.js";
5
5
  import { a as suggestion, i as parseLeaf, o as GLOBAL_FLAGS, r as parseFlags } from "./args-Bc0HLiD4.js";
6
- import { c as confirmationRequired, d as quote, f as replayArgv, i as githubAnnotations, l as consentDigest, n as errorDocument, o as resultDocument, s as sarifLog, t as dataOf, u as consentReasons } from "./output-Cqtb8lW_.js";
6
+ import { c as confirmationRequired, d as quote, f as replayArgv, i as githubAnnotations, l as consentDigest, n as errorDocument, o as resultDocument, s as sarifLog, t as dataOf, u as consentReasons } from "./output-BhNN-hvv.js";
7
7
  import { r as progressReporter, t as redact } from "./credentials-6ZWbJ-Re.js";
8
- import { a as resolve, i as leaves, n as ROOT, r as SECTIONS, t as DOCS_BASE } from "./manifest-BY70KZmp.js";
8
+ import { a as resolve, i as leaves, n as ROOT, r as SECTIONS, t as DOCS_BASE } from "./manifest-CXK3krNu.js";
9
9
  import { t as createStyle } from "./style-CQDaLJtP.js";
10
10
  import { s as cliVersion } from "./version-D-jWyJb9.js";
11
11
  import { n as isPermDockPlugin } from "./plugin-MQVfUBUS.js";
@@ -0,0 +1 @@
1
+ export { t as run } from "./run-CqAur1Y3.js";
@@ -16,7 +16,7 @@ const scan = defineLeaf({
16
16
  }
17
17
  },
18
18
  async run(ctx, { flags }) {
19
- const { runAdoptionScan } = await import("./adoption-scan-6eUACbvC.js");
19
+ const { runAdoptionScan } = await import("./adoption-scan-obbSy73c.js");
20
20
  return runAdoptionScan({
21
21
  cwd: ctx.cwd,
22
22
  srcPath: flags.src.length > 0 ? flags.src : ctx.config.collect?.srcPath ?? ["src"],
@@ -1,7 +1,7 @@
1
1
  import { t as require__2020 } from "./2020-DBXhfpuK.js";
2
2
  import { r as isRecord } from "./compact-C4LFuqbW.js";
3
3
  import { t as DRAFT_PINS } from "./pins-CXXkVEiD.js";
4
- import { a as nonEmptyOr } from "./output-Cqtb8lW_.js";
4
+ import { a as nonEmptyOr } from "./output-BhNN-hvv.js";
5
5
  import { l as packageRoot } from "./version-D-jWyJb9.js";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { join } from "node:path";
@@ -306,7 +306,8 @@ const CUSTOM_ROLES = {
306
306
  compile: "permdock_compile_custom_role",
307
307
  compileFor: "permdock_compile_custom_roles_for",
308
308
  compileStatement: "permdock_compile_custom_roles",
309
- recompile: "permdock_recompile_custom_roles"
309
+ recompile: "permdock_recompile_custom_roles",
310
+ roleIn: "permdock_role_in"
310
311
  };
311
312
  /** The function `rls.roles` adds. The name is part of the SQL contract. */
312
313
  const GLOBAL_ROLES = { replace: "permdock_replace_global_roles" };
@@ -1,7 +1,7 @@
1
1
  import { t as defineLeaf } from "./command-9GAzSI7E.js";
2
2
  import { t as checkFlag } from "./flags-C0e-BzGW.js";
3
3
  import { r as pick, t as CANCELLED } from "./prompt-CPlJn_4-.js";
4
- import { n as detectedAgents, r as runSkills, t as SKILL_AGENTS } from "./skills-Cuf4gcfr.js";
4
+ import { n as detectedAgents, r as runSkills, t as SKILL_AGENTS } from "./skills-DBvXLSo7.js";
5
5
  // src/cli/commands/skills.ts
6
6
  const forFlag = { for: {
7
7
  type: "string",
@@ -1,6 +1,6 @@
1
1
  import { t as byCodePoint } from "./compare-dfHDj8kT.js";
2
2
  import { t as didYouMean } from "./args-Bc0HLiD4.js";
3
- import { a as nonEmptyOr } from "./output-Cqtb8lW_.js";
3
+ import { a as nonEmptyOr } from "./output-BhNN-hvv.js";
4
4
  import { i as readJsonFile, s as writeFileEnsuringDir } from "./files-DAR51W3J.js";
5
5
  import { l as packageRoot } from "./version-D-jWyJb9.js";
6
6
  import { cpSync, existsSync, lstatSync, readFileSync, readdirSync, readlinkSync, realpathSync } from "node:fs";
@@ -5,5 +5,5 @@ import { a as tableApprovalPolicySource, c as exchangeCapability, i as tableAppr
5
5
  import { c as tableMembershipSource, i as authzVersion, o as junctionMembershipSource, s as supabasePostgresQuery, t as AUTHZ_VERSION_TABLE } from "../sources-DnjJPGfb.js";
6
6
  import { r as subjectFromSupabaseClient, s as postgrestSources } from "../resolver-4qxIIHcC.js";
7
7
  import { a as delegationOf, i as actorOf, o as subjectFromSupabase, s as subjectFromSupabaseSession } from "../definition-options-9o8Hdww3.js";
8
- import { n as parseSupabaseManifest, t as hasTokenHook } from "../manifest-B-8d2lhG.js";
8
+ import { n as parseSupabaseManifest, t as hasTokenHook } from "../manifest-Ct3eXbLR.js";
9
9
  export { AUTHZ_EVENT, AUTHZ_TOPIC, AUTHZ_VERSION_TABLE, actorOf, authorizeSql, authzUserTopic, authzVersion, definePermDock, delegationOf, exchangeCapability, hasTokenHook, junctionMembershipSource, parseSupabaseManifest, postgrestSources, readSubjectRecord, subjectFromSupabase, subjectFromSupabaseClient, subjectFromSupabaseSession, supabaseApprovalStore, supabaseClaims, supabaseMembershipsBudget, supabasePostgresQuery, supabaseRls, supabaseTenantClaim, tableApprovalDelegationSource, tableApprovalPolicySource, tableMembershipSource };
@@ -15,7 +15,7 @@ const inspect = defineLeaf({
15
15
  },
16
16
  async run(ctx, { flags }) {
17
17
  const out = flags.out === "" ? true : flags.out === "-" ? void 0 : flags.out;
18
- const { runSupabase } = await import("./supabase-hook-BJImmLmb.js");
18
+ const { runSupabase } = await import("./supabase-hook-CcmjiBsh.js");
19
19
  return runSupabase({
20
20
  cwd: ctx.cwd,
21
21
  config: ctx.config,
@@ -1,6 +1,6 @@
1
1
  import "./sources-DnjJPGfb.js";
2
2
  import { a as describeError } from "./errors-DgLOqc6j.js";
3
- import { n as hookUri } from "./rbac-ir19O-e-.js";
3
+ import { n as hookUri } from "./rbac-BJTUGJum.js";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import { join, posix } from "node:path";
6
6
  // ../../node_modules/.pnpm/smol-toml@1.9.1/node_modules/smol-toml/dist/error.js
@@ -5,10 +5,10 @@ import { _ as writeOutputFiles, d as pgDeltaPath, g as underSchemaDir, h as serv
5
5
  import { i as readJsonFile, o as sqlFiles, s as writeFileEnsuringDir } from "./files-DAR51W3J.js";
6
6
  import { n as formatManifestJson, t as MANIFEST_FILE } from "./manifest-json-DMaBWmcG.js";
7
7
  import { c as requirePolicy } from "./load-CZnlAyZ8.js";
8
- import { n as hookUri } from "./rbac-ir19O-e-.js";
9
- import { a as supabaseHookSql, c as asideAuthzReceive, f as isSupabaseSchemas, h as declarativeSql, i as supabaseHookManifest, l as configToml, m as schemasRefusal, n as hooklessDatabase, o as defaultOut, p as resolveSchemas, r as supabaseDatabaseManifest, s as hookMarker, t as grantsLabel } from "./hook-sql-Cunsdk5x.js";
8
+ import { n as hookUri } from "./rbac-BJTUGJum.js";
9
+ import { a as supabaseHookSql, c as asideAuthzReceive, f as isSupabaseSchemas, h as declarativeSql, i as supabaseHookManifest, l as configToml, m as schemasRefusal, n as hooklessDatabase, o as defaultOut, p as resolveSchemas, r as supabaseDatabaseManifest, s as hookMarker, t as grantsLabel } from "./hook-sql-55514A9t.js";
10
10
  import { r as HOOK_MARKER, s as hookMarkerFields } from "./markers-C-kThnKN.js";
11
- import { a as supabaseConfig } from "./supabase-config-BrhSp-U7.js";
11
+ import { a as supabaseConfig } from "./supabase-config-B2sDFiwy.js";
12
12
  import { t as readMemberships } from "./read-memberships-BkePIa1F.js";
13
13
  import { n as pgConnector } from "./pg-CA651850.js";
14
14
  import { n as MIGRATION_DIRS } from "./constants-PCJiir_3.js";
@@ -0,0 +1,2 @@
1
+ import "./hook-sql-55514A9t.js";
2
+ export { r as runSupabase } from "./supabase-hook-0q6ohTVN.js";
@@ -11,8 +11,8 @@ import { d as sqlTextArray, i as qualifySqlTable, t as SQL_IDENT } from "./sql-T
11
11
  import { d as restrictedRowsSql, i as scopeColumn, l as relationArmSql } from "./compile-BUKXrueE.js";
12
12
  import { t as AUTHZ_VERSION_TABLE } from "./sources-DnjJPGfb.js";
13
13
  import { a as quoteIdent, c as quoteTable, i as qualified, o as quoteLiteral, r as helperSchema, s as quoteQualified } from "./quote-BKrTBbcH.js";
14
- import { A as tenantTypeOf, D as idTypeOf, O as scopeTypeOf, _ as subjectClaimJsonSql, d as keyTenantSql, f as kindFilterSql, h as roleKindSql, i as allowEntry, m as memberVia, n as GLOBAL_ROLES, o as rootName, r as HELPERS, s as signedIn, t as CUSTOM_ROLES, v as subjectClaimSql, x as userIdHelperSql, y as subjectIdSql } from "./shared-BdF5DJDQ.js";
15
- import { $ as linkHelper, A as userActive, B as trustedReaderGrants, C as sourcesKeep, D as keyTenantLine, E as instancesActive, F as perScope, G as graphHelper, H as byKey, I as raiseSql, J as hasMemberFor, K as graphSqlName, L as roleReadersSql, M as currentKeyExpr, N as customRolesSql, P as hasCustomRoleChecksFor, Q as isTeamScope, R as rolesTableScope, S as sourcesBodyOf, V as byCodeUnit, W as CLOSURE, Y as hasMemberOf, _ as memoizes, a as interactiveSessionSql, at as memberRoleOf, b as sourceIdOf, c as claimTenant, ct as restrictedHelper, d as hasBody, dt as activeInstancesSql, et as memberForHelper, ft as activeMembershipSql, g as memoizedSetofSql, gt as grantPermissionSql, h as memoWriteSql, it as memberOfHelper, j as globalRoleSource, l as disabledColumn, lt as scopeSources, m as memoHitList, mt as activeUserSql, n as interactiveAllowsCall, o as memoUserSql, ot as permittedForHelper, p as memberColumn, pt as activeRowSql, q as graphSqlText, r as interactiveAllowsSql, rt as memberIdsHelper, s as claimKeptLines, st as permittedIdsHelper, tt as memberForSources, u as functionBody, ut as scopeTable, v as scopedBody, w as sqlBody, x as sourceRows, y as sourceFilters, z as storedTenant } from "./interactive-only-CQsgMc1E.js";
14
+ import { A as tenantTypeOf, D as idTypeOf, O as scopeTypeOf, _ as subjectClaimJsonSql, d as keyTenantSql, f as kindFilterSql, h as roleKindSql, i as allowEntry, m as memberVia, n as GLOBAL_ROLES, o as rootName, r as HELPERS, s as signedIn, t as CUSTOM_ROLES, v as subjectClaimSql, x as userIdHelperSql, y as subjectIdSql } from "./shared-Cwxy5N16.js";
15
+ import { $ as linkHelper, A as userActive, B as trustedReaderGrants, C as sourcesKeep, D as keyTenantLine, E as instancesActive, F as perScope, G as graphHelper, H as byKey, I as raiseSql, J as hasMemberFor, K as graphSqlName, L as roleReadersSql, M as currentKeyExpr, N as customRolesSql, P as hasCustomRoleChecksFor, Q as isTeamScope, R as rolesTableScope, S as sourcesBodyOf, V as byCodeUnit, W as CLOSURE, Y as hasMemberOf, _ as memoizes, a as interactiveSessionSql, at as memberRoleOf, b as sourceIdOf, c as claimTenant, ct as restrictedHelper, d as hasBody, dt as activeInstancesSql, et as memberForHelper, ft as activeMembershipSql, g as memoizedSetofSql, gt as grantPermissionSql, h as memoWriteSql, it as memberOfHelper, j as globalRoleSource, l as disabledColumn, lt as scopeSources, m as memoHitList, mt as activeUserSql, n as interactiveAllowsCall, o as memoUserSql, ot as permittedForHelper, p as memberColumn, pt as activeRowSql, q as graphSqlText, r as interactiveAllowsSql, rt as memberIdsHelper, s as claimKeptLines, st as permittedIdsHelper, tt as memberForSources, u as functionBody, ut as scopeTable, v as scopedBody, w as sqlBody, x as sourceRows, y as sourceFilters, z as storedTenant } from "./interactive-only-C_olBCPl.js";
16
16
  import { createHash } from "node:crypto";
17
17
  // src/cli/rls/graph.ts
18
18
  function tableFor(resource, tables) {
@@ -1,5 +1,5 @@
1
1
  import { t as parseCatalog } from "../../parse-nfHSt1Wy.js";
2
- import { n as parseSupabaseManifest } from "../../manifest-B-8d2lhG.js";
2
+ import { n as parseSupabaseManifest } from "../../manifest-Ct3eXbLR.js";
3
3
  // src/testing/fixtures/better-supabase.catalog.json
4
4
  var better_supabase_catalog_default = {
5
5
  $schema: "https://permdock.com/schemas/catalog-v2.json",
@@ -742,6 +742,12 @@ var better_supabase_manifest_default = {
742
742
  "args": "p_permission text, p_id uuid",
743
743
  "returns": "setof uuid",
744
744
  "execute": []
745
+ },
746
+ {
747
+ "name": "permdock_role_in",
748
+ "args": "p_role text, p_tenant uuid",
749
+ "returns": "boolean",
750
+ "execute": []
745
751
  }
746
752
  ],
747
753
  "memberships": [{
@@ -33,7 +33,7 @@ import { t as PUSHED_POLICY_SCHEMA } from "../pushed-policy-rpB6k77P.js";
33
33
  import { n as supabaseMembershipsBudget } from "../budget-BH81q2cj.js";
34
34
  import { t as catalogSchema } from "../schema-BeY3croo.js";
35
35
  import { t as CONNECTOR_SCHEMA } from "../connector-schema-BSRMyq4M.js";
36
- import { t as supabaseManifestSchema } from "../manifest-schema-DJY5Q_pR.js";
36
+ import { t as supabaseManifestSchema } from "../manifest-schema-Bp-eFhNZ.js";
37
37
  import { n as freezeDeep } from "../freeze-DGfJq_j2.js";
38
38
  import { c as evaluateCondition } from "../delegation-BaUNCrE_.js";
39
39
  import { s as parseCredential } from "../credential-ke0KMQeB.js";
@@ -0,0 +1 @@
1
+ export { t as runUsage } from "./usage-CnCNB6XN.js";
@@ -2,8 +2,8 @@ import { a as getResource } from "./permission-registry-DMYRZVcn.js";
2
2
  import { c as jsonSchemaOf } from "./catalog-doc-Bp5khmCG.js";
3
3
  import { r as runCollect } from "./collect-BOh9Pxob.js";
4
4
  import { f as usageResult } from "./errors-DgLOqc6j.js";
5
- import { t as DOCS_BASE } from "./manifest-BY70KZmp.js";
6
- import { r as findingOf } from "./output-Cqtb8lW_.js";
5
+ import { t as DOCS_BASE } from "./manifest-CXK3krNu.js";
6
+ import { r as findingOf } from "./output-BhNN-hvv.js";
7
7
  import { o as USAGE_REPORT_SCHEMA } from "./version-D-jWyJb9.js";
8
8
  import { n as jiti, r as parseSync, t as createVisitor } from "./optional-CaQWp9HA.js";
9
9
  import { a as rel, r as listSourceFiles } from "./files-DAR51W3J.js";
@@ -16,7 +16,7 @@ const usage = defineLeaf({
16
16
  }
17
17
  },
18
18
  async run(ctx, { flags }) {
19
- return (await import("./usage-DpmLPRRx.js")).runUsage({
19
+ return (await import("./usage-Cayjfw1S.js")).runUsage({
20
20
  cwd: ctx.cwd,
21
21
  config: ctx.config,
22
22
  ignore: flags.ignore,
@@ -7,16 +7,16 @@ import { s as writeFileEnsuringDir } from "./files-DAR51W3J.js";
7
7
  import { n as fixtureSubject, r as loadFixtures, t as fixtureRow } from "./fixtures-Bm0G0A7H.js";
8
8
  import { n as pgConnector } from "./pg-CA651850.js";
9
9
  import { o as loadPolicyAt } from "./load-CZnlAyZ8.js";
10
- import { t as commandFor } from "./compile-CT7x66_U.js";
10
+ import { t as commandFor } from "./compile-B9SZiEnG.js";
11
11
  import { r as isRecord } from "./compact-C4LFuqbW.js";
12
12
  import { t as policyRowConditionKeys } from "./row-conditions-DwIJocfQ.js";
13
13
  import { c as rootScope, d as scopeList, o as normalizeMemberships } from "./scopes-B-KX9EI8.js";
14
14
  import { t as beforeFirst } from "./text-D704xHVl.js";
15
- import { T as columnTypesOf, a as customRolesOn, r as HELPERS } from "./shared-BdF5DJDQ.js";
15
+ import { T as columnTypesOf, a as customRolesOn, r as HELPERS } from "./shared-Cwxy5N16.js";
16
16
  import { a as quoteIdent, c as quoteTable, o as quoteLiteral, s as quoteQualified } from "./quote-BKrTBbcH.js";
17
- import { Q as graphPlan, i as tableNames, r as tableNameOf } from "./tables-D-tmMHww.js";
18
- import { s as viewName, t as FIELD_VIEWS } from "./fields-6d1j-q3c.js";
19
- import { t as DOCS_BASE } from "./manifest-BY70KZmp.js";
17
+ import { Q as graphPlan, i as tableNames, r as tableNameOf } from "./tables-BDqfipr1.js";
18
+ import { s as viewName, t as FIELD_VIEWS } from "./fields-CViS0EPC.js";
19
+ import { t as DOCS_BASE } from "./manifest-CXK3krNu.js";
20
20
  import { b as membershipsClaim, m as customRoleScope } from "./evaluate-D8SdfP3h.js";
21
21
  import { n as defaultSqlCommand, t as SQL_IDENT } from "./sql-T4GaBh9X.js";
22
22
  import "./budget-BH81q2cj.js";
@@ -2,7 +2,7 @@ import { r as isRecord } from "./compact-C4LFuqbW.js";
2
2
  import { i as dateAt } from "./time-r0CKBm57.js";
3
3
  import { a as describeError, n as CliError } from "./errors-DgLOqc6j.js";
4
4
  import { n as createChangeScheduler } from "./watch-BNxvqCS4.js";
5
- import { t as receiptRows } from "./pipeline-CGctXudd.js";
5
+ import { t as receiptRows } from "./pipeline-Ct3YEKjx.js";
6
6
  import { existsSync } from "node:fs";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { Worker } from "node:worker_threads";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permdock",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "description": "Typed permissions for TypeScript apps, APIs, databases, and AI agents, with the permdock CLI and test runners.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -525,7 +525,7 @@
525
525
  },
526
526
  "helperName": {
527
527
  "type": "string",
528
- "pattern": "^(permdock_has(_for)?|permitted_[a-z][a-z0-9_]*_(ids|permission_keys)(_for)?|permitted_[a-z][a-z0-9_]*_users|member_[a-z][a-z0-9_]*_ids(_for|_of)?|permdock_can_assign(_any|_custom_role)?(_for)?|permdock_api_key_allows|permdock_token_scope_allows|permdock_interactive_allows|permdock_actor_may_write|permdock_is_approver|permdock_manages|permdock_user_id|permdock_subject|permdock_approver_for_ids|permdock_managed_user_ids|permdock_bootstrap_permissions)$"
528
+ "pattern": "^(permdock_has(_for)?|permitted_[a-z][a-z0-9_]*_(ids|permission_keys)(_for)?|permitted_[a-z][a-z0-9_]*_users|member_[a-z][a-z0-9_]*_ids(_for|_of)?|permdock_can_assign(_any|_custom_role)?(_for)?|permdock_api_key_allows|permdock_token_scope_allows|permdock_interactive_allows|permdock_actor_may_write|permdock_is_approver|permdock_manages|permdock_user_id|permdock_subject|permdock_approver_for_ids|permdock_managed_user_ids|permdock_bootstrap_permissions|permdock_role_in)$"
529
529
  },
530
530
  "column": {
531
531
  "type": "object",
@@ -509,7 +509,7 @@ const subject = subjectFromSupabase(claims, {
509
509
 
510
510
  Write the claims with `permdock supabase hook generate`; `permdock supabase inspect --out` writes the manifest (helper names, tenant claim, budget, claims written) that `authorizationProvider` from `permdock/better-supabase` turns into better-supabase's `authorization` config. No `@supabase/supabase-js` peer. Pair with `permdock rls generate`, or keep SQL as authority and run `permdock rls verify --db-url-stdin` against `sqlFunction` twins ([database-first](https://permdock.com/docs/adapters/rls)); the generic RLS workflow is in the `permdock-data` skill.
511
511
 
512
- With better-supabase, set `auth.authorization: authorizationProvider({ manifest, catalog })` in `better-supabase.config.ts` (with `rls.customRoles` its `canAssign` and `canAssignFor` call `permdock_can_assign_any` and its `_for` form, so custom roles are assignable through better-supabase; regenerate the manifest after turning custom roles on), pass `authorizer({ policy })` (or `authorizer({ policy, permdockFor })` to share one instance cache with `permdockFor(...).sources(versions)` in oRPC, MCP and `permdock/next`) to the server (`createNext`, `createHono`, `createMcp`) so every `permission` a resource, action, route guard or tool declares is decided by PermDock from the verified claims (`operations` maps tables for `permissions: true`; a missing or anonymous claim denies), build bucket and topic `access` policies with `bucketPolicy` and `topicPolicy`, and map its session with `subjectFromBetterSupabase(session)` (all from `permdock/better-supabase`): the active tenant's `features` become `principal.plans`. Pass `plans: { keys }` when better-supabase's `entitlements.claim.keys` shortens feature keys, and `apiKeys: { permissions, manifest }` so an `apiKey` session maps to the key's credential subject instead of the anonymous one. For `createMcp` tools, put the permission in `meta` and spread `toolPolicy({ permdock })` into the options: tools without one are hidden and refused, and approval-required calls are refused because `createMcp` collects no approvals. Wrap a `CredentialProvider` with `credentialGuard(provider, { permdock, use, revoke? })` so PermDock decides each token use. `authorizationProvider({ ..., approver })` lets holders of that permission approve AI tool calls, never their own. `approvers: { 'ai-tool': holder(p), 'support-session': ..., 'invoice.send': ... }` fills `isApprover` through `permdock_is_approver` (needs `rls.approvals`); only `user()`, `holder()` and `anyOf()` approvers, and a kind it does not name has no approver. `requestApprovers: true` also passes better-supabase's `{approvers}` (the request's current step) to the five-argument `permdock_is_approver`, so a cover from `rls.approvals.delegations` reaches users and managers a block policy names; it needs a better-supabase release that fills `{approvers}`. `rls.approvals: { store: false, delegations: true }` writes the covers without PermDock's store. `blockApprovalStore(approvals, { tenantless })` resolves through the block's `approve` and `reject` with `decidedBy`, and `blockApprovalPolicySource(approvals, { platform, permissions, effects })` maps conditions, effects, `*` and platform policies, dropping what it cannot express so a policy only gets stricter. `accessReviewApplier({ client, reviews, policy, demoteTo?, email?, permdockFor? })` applies a review's revoked items: `update_member_role` to the `demoteTo` role when that role lacks the permission, else `remove_member`, plus `revoke_invitation` for the member's matching invitations, then `markApplied`; pass the reviewer's client so the blocks' own checks run. better-supabase's `createAgentRuntime({ toolApproval })` takes `toolApproval` from `permdock/ai-sdk` as it is. Validate its claims with `betterSupabase.claims(supabaseClaims().extend(appSchema))` (`supabaseClaims` from `permdock/supabase`, any Standard Schema as `appSchema`) instead of a hand-written copy of the claim shape. A `supabase.hook.claims` function that needs the user's organizations calls `<schema>.member_organization_ids_for(user_id)` (generated by `rls generate`, executable by `supabase_auth_admin` only) instead of querying the membership tables itself. With a scope named `team` or `teams`, `authorizationProvider` fills better-supabase's `teamIdsOf` with `<schema>.member_team_ids_of(user)`, which answers only for the caller, so with `blocks.permissions.model: 'provider'` better-supabase's `team_ids_of()` and team-sharing policies read PermDock's memberships. A token Supabase's OAuth server issued to a third-party app (`client_id`) becomes an `oauth-client` actor limited to its `scope`; `deny(permission, { to: actor('oauth-client') })` keeps such apps out, in the app and, through `rls generate`, in Postgres. A better-supabase support session (`act.kind: 'support'`) is actor kind `support` with `sessionId` and `readOnly`, and `actingAs` (`act.kind: 'impersonation'`) is kind `impersonation`; neither has a delegation, so they reach nothing until a policy delegation names `actor('support')` or `actor('impersonation')`, and `readOnly: true` (also when `read_only` is absent) narrows that to read-only permissions. Generated RLS reads memberships, not `act`, so a support token sent to the Data API writes as the user: add a restrictive `for update` (and `insert` / `delete`) policy per writable table that requires `act ->> 'read_only' = 'false'` when `act` is a support or session level ([support access](https://permdock.com/docs/guides/support-access)). With `rls.anonymousSignIns: 'deny'`, pass `anonymousSignIns: 'deny'` to the subject mapper too (doctor PD057). Check a deployed database against the generated policies with `permdock rls verify --introspect`.
512
+ With better-supabase, set `auth.authorization: authorizationProvider({ manifest, catalog })` in `better-supabase.config.ts` (with `rls.customRoles` its `canAssign` and `canAssignFor` call `permdock_can_assign_any` and its `_for` form, so custom roles are assignable through better-supabase; regenerate the manifest after turning custom roles on; `roleIn: true` also fills `functions.roleIn` with `permdock_role_in`, so better-supabase 0.77's `membership_roles` trigger refuses another tenant's custom role), pass `authorizer({ policy })` (or `authorizer({ policy, permdockFor })` to share one instance cache with `permdockFor(...).sources(versions)` in oRPC, MCP and `permdock/next`) to the server (`createNext`, `createHono`, `createMcp`) so every `permission` a resource, action, route guard or tool declares is decided by PermDock from the verified claims (`operations` maps tables for `permissions: true`; a missing or anonymous claim denies), build bucket and topic `access` policies with `bucketPolicy` and `topicPolicy`, and map its session with `subjectFromBetterSupabase(session)` (all from `permdock/better-supabase`): the active tenant's `features` become `principal.plans`. Pass `plans: { keys }` when better-supabase's `entitlements.claim.keys` shortens feature keys, and `apiKeys: { permissions, manifest }` so an `apiKey` session maps to the key's credential subject instead of the anonymous one. For `createMcp` tools, put the permission in `meta` and spread `toolPolicy({ permdock })` into the options: tools without one are hidden and refused, and approval-required calls are refused because `createMcp` collects no approvals. Wrap a `CredentialProvider` with `credentialGuard(provider, { permdock, use, revoke? })` so PermDock decides each token use. `authorizationProvider({ ..., approver })` lets holders of that permission approve AI tool calls, never their own. `approvers: { 'ai-tool': holder(p), 'support-session': ..., 'invoice.send': ... }` fills `isApprover` through `permdock_is_approver` (needs `rls.approvals`); only `user()`, `holder()` and `anyOf()` approvers, and a kind it does not name has no approver. `requestApprovers: true` also passes better-supabase's `{approvers}` (the request's current step) to the five-argument `permdock_is_approver`, so a cover from `rls.approvals.delegations` reaches users and managers a block policy names; it needs a better-supabase release that fills `{approvers}`. `rls.approvals: { store: false, delegations: true }` writes the covers without PermDock's store. `blockApprovalStore(approvals, { tenantless })` resolves through the block's `approve` and `reject` with `decidedBy`, and `blockApprovalPolicySource(approvals, { platform, permissions, effects })` maps conditions, effects, `*` and platform policies, dropping what it cannot express so a policy only gets stricter. `accessReviewApplier({ client, reviews, policy, demoteTo?, email?, permdockFor? })` applies a review's revoked items: `update_member_role` to the `demoteTo` role when that role lacks the permission, else `remove_member`, plus `revoke_invitation` for the member's matching invitations, then `markApplied`; pass the reviewer's client so the blocks' own checks run. better-supabase's `createAgentRuntime({ toolApproval })` takes `toolApproval` from `permdock/ai-sdk` as it is. Validate its claims with `betterSupabase.claims(supabaseClaims().extend(appSchema))` (`supabaseClaims` from `permdock/supabase`, any Standard Schema as `appSchema`) instead of a hand-written copy of the claim shape. A `supabase.hook.claims` function that needs the user's organizations calls `<schema>.member_organization_ids_for(user_id)` (generated by `rls generate`, executable by `supabase_auth_admin` only) instead of querying the membership tables itself. With a scope named `team` or `teams`, `authorizationProvider` fills better-supabase's `teamIdsOf` with `<schema>.member_team_ids_of(user)`, which answers only for the caller, so with `blocks.permissions.model: 'provider'` better-supabase's `team_ids_of()` and team-sharing policies read PermDock's memberships. A token Supabase's OAuth server issued to a third-party app (`client_id`) becomes an `oauth-client` actor limited to its `scope`; `deny(permission, { to: actor('oauth-client') })` keeps such apps out, in the app and, through `rls generate`, in Postgres. A better-supabase support session (`act.kind: 'support'`) is actor kind `support` with `sessionId` and `readOnly`, and `actingAs` (`act.kind: 'impersonation'`) is kind `impersonation`; neither has a delegation, so they reach nothing until a policy delegation names `actor('support')` or `actor('impersonation')`, and `readOnly: true` (also when `read_only` is absent) narrows that to read-only permissions. Generated RLS reads memberships, not `act`, so a support token sent to the Data API writes as the user: add a restrictive `for update` (and `insert` / `delete`) policy per writable table that requires `act ->> 'read_only' = 'false'` when `act` is a support or session level ([support access](https://permdock.com/docs/guides/support-access)). With `rls.anonymousSignIns: 'deny'`, pass `anonymousSignIns: 'deny'` to the subject mapper too (doctor PD057). Check a deployed database against the generated policies with `permdock rls verify --introspect`.
513
513
 
514
514
  The other better-supabase slots, all from `permdock/better-supabase` ([better-supabase](https://permdock.com/docs/adapters/better-supabase)): `hookCan(permdock)` and `handlerCan({ getPermDock })` are the `can` options of `authorizeHook` and `protectWebHandler` in `better-supabase/workflow-sdk`; they decide with no row unless the `data` option loads one (`hookCan(permdock, { data: (tenant, key) => row })`, `handlerCan(source, { data: (request, key) => row })`), so without it a permission with a row condition denies, and `handlerCan` answers `undefined` (401) without a signed-in principal. `supportPolicy({ policy, options?, writable?, approval?, approved? })` is the `authorize` option of `supportSessions`; it decides each start with `decideSupportSession` as the admin, and an `approval-required` start passes only once `approved(input, pending)` returns `{ approvedBy }` for an approver other than the admin. `subscriberPolicy({ policy, principals, events, row?, sender? })` filters outbox, webhook or realtime subscribers to those who may read the event (exact type, then the longest `prefix.*`, then `*`; a type with no entry reaches no one). `principalSource({ claims, identities? })` is a `PrincipalSource` over the claims better-supabase mints, for `decideFor`, `subscribersFor` and delivery; only links the app created through a signed-in flow or a verified address go in `identities`. `authorizationHooks({ policy, claims, service?, principals?, events?, approvers?, support?, tickets? })` is the `authorization` option of `createServer`: it answers automation publish and run-as, delegated OAuth scopes, `approverOf`, identities, delivery audiences, support sessions and run tickets from the claims better-supabase mints now, never from the request.
515
515
 
@@ -1 +0,0 @@
1
- export { t as renderKinds } from "./gen-DCmo0Irk.js";
@@ -1 +0,0 @@
1
- export { n as runCloudPull } from "./pull-xhMWizWH.js";
@@ -1 +0,0 @@
1
- export { t as run } from "./run-CI5opYjC.js";
@@ -1,2 +0,0 @@
1
- import "./hook-sql-Cunsdk5x.js";
2
- export { r as runSupabase } from "./supabase-hook-C7v1wRUV.js";
@@ -1 +0,0 @@
1
- export { t as runUsage } from "./usage-XS56d_Kx.js";