permdock 0.11.0 → 0.14.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 (84) hide show
  1. package/dist/a2a/index.js +1 -1
  2. package/dist/{adoption-scan-DKCOsfcF.js → adoption-scan-BGtwGfoH.js} +1 -1
  3. package/dist/agent/index.js +1 -1
  4. package/dist/ai-sdk/index.js +2 -2
  5. package/dist/{arazzo-CTH5iN--.js → arazzo-9uhbmKf5.js} +1 -1
  6. package/dist/{arazzo-BXaEhGHM.js → arazzo-Bol9OgF-.js} +1 -1
  7. package/dist/better-supabase/index.d.ts +19 -17
  8. package/dist/better-supabase/index.js +31 -16
  9. package/dist/better-supabase-83Gsetrv.js +56 -0
  10. package/dist/{casbin-BuTZnSPv.js → casbin-1PVgMHOR.js} +1 -1
  11. package/dist/{casbin-DTi6HSsl.js → casbin-CBXD5rFx.js} +1 -1
  12. package/dist/claude-agent/index.js +1 -1
  13. package/dist/cli/bin.js +1 -1
  14. package/dist/cli/index.js +2 -2
  15. package/dist/{cloud-DiAiYFRo.js → cloud-BfJVKpcN.js} +1 -1
  16. package/dist/{codemod-C1U8_Zu3.js → codemod-BXLd4K3j.js} +1 -1
  17. package/dist/{codemod-_q_ZI01S.js → codemod-DWfH-KHk.js} +2 -2
  18. package/dist/{collect-D9Tt0Bcx.js → collect-lZgCKMe_.js} +1 -1
  19. package/dist/{completion-DLTuCf53.js → completion-fJ19i8Jk.js} +1 -1
  20. package/dist/{config-CmydKZr2.js → config-BYSk3iKV.js} +1 -1
  21. package/dist/{config-BR23fL8m.js → config-ZZdtyQZy.js} +4 -1
  22. package/dist/{config-report-5AwptLr2.js → config-report-BpztJ3HP.js} +1 -1
  23. package/dist/{create-6EwRQlig.js → create-Coq5fIrq.js} +1 -1
  24. package/dist/{diff-BwR1JdP2.js → diff-CxtbOi2l.js} +1 -1
  25. package/dist/{diff-CQegtBAo.js → diff-DfmYaIhB.js} +1 -1
  26. package/dist/{doctor-DxyVeUEE.js → doctor-NxCr_hba.js} +2 -2
  27. package/dist/{doctor-ktitU5Dl.js → doctor-eNc7A_7I.js} +13 -47
  28. package/dist/eve/index.js +1 -1
  29. package/dist/{fixtures-A1_sp_tR.js → fixtures-Bm4_K1ke.js} +7 -9
  30. package/dist/{import-t1yqnCyG.js → import-efm6qPgx.js} +1 -1
  31. package/dist/{init-CY7THM2v.js → init-BtWY1L0J.js} +3 -3
  32. package/dist/{init-DFwylmiN.js → init-D6rpLPwM.js} +1 -1
  33. package/dist/{kernel-qv4cr9w8.js → kernel-BD8QuMnv.js} +9 -2
  34. package/dist/{login-C5XLYZSF.js → login-B8s6VI8Z.js} +3 -3
  35. package/dist/{login-B92-dZMK.js → login-cLflB63Z.js} +1 -1
  36. package/dist/{manifest-Cav1rjNQ.js → manifest-BWIR_EEB.js} +33 -33
  37. package/dist/mcp/index.d.ts +12 -3
  38. package/dist/mcp/index.js +60 -16
  39. package/dist/next/plugin.js +1 -1
  40. package/dist/openai/index.js +2 -2
  41. package/dist/{openapi-gMQQSzNn.js → openapi-CT55v3WD.js} +2 -2
  42. package/dist/{openapi-CuePQL4z.js → openapi-DDENzRbG.js} +1 -1
  43. package/dist/{output-CtyBwTNB.js → output-3iB3_Hfg.js} +1 -1
  44. package/dist/{powersync-CBcsEvdr.js → powersync-COjQTHRD.js} +2 -2
  45. package/dist/{powersync-CD8-Ypao.js → powersync-DVbskWD9.js} +126 -39
  46. package/dist/powersync-k8lUeC37.js +1 -0
  47. package/dist/pull-BY1METGf.js +1 -0
  48. package/dist/{pull-CAeaAioC.js → pull-Er4aBHlL.js} +1 -1
  49. package/dist/react-native/index.d.ts +7 -7
  50. package/dist/react-native/index.js +57 -16
  51. package/dist/{rls-CtRaRrn3.js → rls-DY3Fc18U.js} +30 -15
  52. package/dist/{rls-BYHN5bcJ.js → rls-DjjOHlKE.js} +1 -1
  53. package/dist/{run-B5nyNKe8.js → run-BlxXmaDS.js} +3 -3
  54. package/dist/run-DGSLvGty.js +1 -0
  55. package/dist/{scan-CvFWW_fU.js → scan-CR_xm71k.js} +1 -1
  56. package/dist/{schema-CQzIJdEd.js → schema-CnrIP94n.js} +1 -1
  57. package/dist/{skills-Bar7ZqwM.js → skills-CY-MY_Oj.js} +1 -1
  58. package/dist/{skills-BZc81VLt.js → skills-uzsVqEi9.js} +1 -1
  59. package/dist/supabase/index.js +1 -1
  60. package/dist/{supabase-CBEK6KEo.js → supabase-DYWnT800.js} +2 -2
  61. package/dist/{supabase-hook-CyuD9Wau.js → supabase-hook-HPgwYb9V.js} +2 -2
  62. package/dist/supabase-hook-qsewAVZY.js +1 -0
  63. package/dist/{supautils-C-_jqylY.js → supautils-DZ95xxW-.js} +3 -3
  64. package/dist/testing/core.js +1 -1
  65. package/dist/testing/fixtures/index.js +1 -1
  66. package/dist/testing/index.js +2 -2
  67. package/dist/unplugin/index.js +1 -1
  68. package/dist/usage-CH7oISI6.js +1 -0
  69. package/dist/{usage-heV5KOiU.js → usage-Dm2hn0pS.js} +1 -1
  70. package/dist/{usage-Y6xZUfE-.js → usage-WYRc7Kqg.js} +2 -2
  71. package/dist/{verify-6EauWrkP.js → verify-CHQgLrtS.js} +3 -3
  72. package/dist/watch-C44FtM79.js +1 -0
  73. package/dist/{watch-Bpci3hBY.js → watch-CTfSlIGD.js} +1 -1
  74. package/package.json +16 -16
  75. package/skills/permdock-credentials/references/tokens-keys-links.md +1 -1
  76. package/skills/permdock-wire/references/adapters.md +1 -1
  77. package/dist/powersync-6vgKevSi.js +0 -1
  78. package/dist/pull-DfJALUbS.js +0 -1
  79. package/dist/run-0vOholnN.js +0 -1
  80. package/dist/supabase-hook-CWvEpdCh.js +0 -1
  81. package/dist/usage-CNca1i1W.js +0 -1
  82. package/dist/watch-COuvly20.js +0 -1
  83. package/dist/{core-DzVINFbU.js → core-lxoANyai.js} +1 -1
  84. package/dist/{supabase-CC6rIri4.js → supabase-CDHMsDD0.js} +1 -1
package/dist/a2a/index.js CHANGED
@@ -8,7 +8,7 @@ import { n as resourceRef } from "../resource-ref-CaS9yVPi.js";
8
8
  import { i as challengeScope, l as withApp, o as hasScope, s as scopesReaching } from "../permdock-BvjivVb9.js";
9
9
  import { p as wwwAuthenticate, r as bearerChallenge } from "../problem-BVLHFK33.js";
10
10
  import { r as instanceOptions } from "../build-instance-BWXqwQYU.js";
11
- import { n as createAgentKernel } from "../kernel-qv4cr9w8.js";
11
+ import { n as createAgentKernel } from "../kernel-BD8QuMnv.js";
12
12
  import { t as delegationFrom } from "../delegation-input-FTxMK3ji.js";
13
13
  //#region src/a2a/create.ts
14
14
  function firstScheme(options) {
@@ -1,5 +1,5 @@
1
1
  import { r as listSourceFiles } from "./files-BSjrtIHw.js";
2
- import { t as DOCS_BASE } from "./manifest-Cav1rjNQ.js";
2
+ import { t as DOCS_BASE } from "./manifest-BWIR_EEB.js";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { relative } from "node:path";
5
5
  //#region src/cli/adoption-scan.ts
@@ -1 +1 @@
1
- export { n as createPermDock } from "../create-6EwRQlig.js";
1
+ export { n as createPermDock } from "../create-Coq5fIrq.js";
@@ -1,8 +1,8 @@
1
1
  import { t as compact } from "../compact-CAf557ZB.js";
2
2
  import { n as PermDockDeniedError, t as PermDockApprovalRequiredError } from "../errors-B6R_lg2a.js";
3
3
  import { l as withApp } from "../permdock-BvjivVb9.js";
4
- import { r as stepUpText, t as approvalTokenOf } from "../kernel-qv4cr9w8.js";
5
- import { t as agentRuntime } from "../create-6EwRQlig.js";
4
+ import { r as stepUpText, t as approvalTokenOf } from "../kernel-BD8QuMnv.js";
5
+ import { t as agentRuntime } from "../create-Coq5fIrq.js";
6
6
  //#region src/ai-sdk/create.ts
7
7
  const APPROVAL_STATUSES = /* @__PURE__ */ new Set([
8
8
  "approved",
@@ -3,7 +3,7 @@ import { c as missingInput } from "./errors-Vpu6rKHl.js";
3
3
  import { i as readJsonFile } from "./files-BSjrtIHw.js";
4
4
  import { t as ARAZZO_REPORT_SCHEMA } from "./version-DMQ0dnN5.js";
5
5
  import { a as loadModule, s as pickNamed, t as asPermissionTree } from "./load-DjSU5KXO.js";
6
- import { t as DOCS_BASE } from "./manifest-Cav1rjNQ.js";
6
+ import { t as DOCS_BASE } from "./manifest-BWIR_EEB.js";
7
7
  import { existsSync } from "node:fs";
8
8
  import { resolve } from "node:path";
9
9
  //#region src/cli/arazzo.ts
@@ -21,7 +21,7 @@ const check = defineLeaf({
21
21
  ...permissionsFlag
22
22
  },
23
23
  async run(ctx, { flags }) {
24
- return (await import("./arazzo-CTH5iN--.js")).runArazzo({
24
+ return (await import("./arazzo-9uhbmKf5.js")).runArazzo({
25
25
  cwd: ctx.cwd,
26
26
  config: ctx.config,
27
27
  doc: given(flags.doc),
@@ -162,9 +162,10 @@ type ApiKeySessionOptions = {
162
162
  readonly serviceRoles?: ServiceRoles<ApiKeySession>;
163
163
  };
164
164
  /**
165
- * better-supabase's `SessionSnapshot` (0.15 and later): one verified token,
166
- * from `bsb.getRequestSession()`, that `'use cache: private'` scopes share. Its
167
- * `issuedAt` and `authzVersion` come from the `iat` and `authz_ver` claims.
165
+ * The fields of better-supabase's `SessionSnapshot` a subject reads: one
166
+ * verified token, from `bsb.getRequestSession()`, that `'use cache: private'`
167
+ * scopes share. Its `issuedAt` and `authzVersion` come from the `iat` and
168
+ * `authz_ver` claims.
168
169
  */
169
170
  type SessionSnapshotLike = {
170
171
  readonly accessToken: string;
@@ -414,6 +415,13 @@ type AuthorizationProviderOptions = {
414
415
  * stays unset and doctor BS409 has nothing to compare.
415
416
  */
416
417
  readonly activeTenant?: BetterSupabaseActiveTenant;
418
+ /**
419
+ * Fill better-supabase's `rowsWith` (and `rowsWithFor` when the `_for`
420
+ * helpers exist) from the `rls.rowHelpers` helpers the manifest names, so a
421
+ * `config.subjects.<type>.permissions.<action>` entry with `rows` checks the
422
+ * rows the caller holds a permission on.
423
+ */
424
+ readonly rowHelpers?: boolean;
417
425
  };
418
426
  /**
419
427
  * better-supabase's `authorization` config value, built from PermDock's
@@ -477,8 +485,8 @@ type AuthorizerOptions = {
477
485
  */
478
486
  readonly version?: MembershipSource["version"];
479
487
  /**
480
- * The version cache for `memberships` when better-supabase passes none (0.13
481
- * and 0.14, or a server created without `versions`).
488
+ * The version cache for `memberships` when better-supabase passes none (a
489
+ * server created without `versions`).
482
490
  */
483
491
  readonly versions?: VersionCache;
484
492
  /**
@@ -502,7 +510,7 @@ type AuthorizerOptions = {
502
510
  * subject is mapped from the verified claims with `subjectFromBetterSupabase`;
503
511
  * the request's `context.tenant` selects the active tenant only among the
504
512
  * memberships the claims hold. A caller without claims is anonymous, and a
505
- * throw denies. With better-supabase 0.15's runtime `memo`, the checks of one
513
+ * throw denies. With better-supabase's runtime `memo`, the checks of one
506
514
  * request scope share an instance per claims, tenant and intent.
507
515
  */
508
516
  export declare function authorizer(options: AuthorizerOptions): Authorizer<Permission>;
@@ -793,20 +801,14 @@ export declare function roleOrderFromCatalog(catalog: CatalogDocument, options?:
793
801
  //#region src/better-supabase/share-links.d.ts
794
802
  /**
795
803
  * The fields of better-supabase's `ResolvedShareLink` a link subject is built
796
- * from: `subject` from better-supabase 0.14, `subjectType` and `subjectId`
797
- * before it.
804
+ * from.
798
805
  */
799
- type ShareLinkRow = ShareLinkRowFields & ({
806
+ type ShareLinkRow = {
807
+ readonly id: string;
800
808
  readonly subject: {
801
809
  readonly type: string;
802
810
  readonly id: string;
803
811
  };
804
- } | {
805
- readonly subjectType: string;
806
- readonly subjectId: string;
807
- });
808
- type ShareLinkRowFields = {
809
- readonly id: string;
810
812
  readonly organizationId: string;
811
813
  readonly role: string;
812
814
  /** Set on a link pinned to one version, which `subjectFromShareLink` refuses. */
@@ -838,8 +840,8 @@ type ShareLinkTarget = {
838
840
  type ShareLinkSubjectOptions = {
839
841
  readonly shareLinks: ShareLinkResolver;
840
842
  /**
841
- * One entry per subject type a guest page serves, keyed by better-supabase's
842
- * `subjectType`.
843
+ * One entry per subject type a guest page serves, keyed by the row's
844
+ * `subject.type`.
843
845
  */
844
846
  readonly links: Readonly<Record<string, ShareLinkTarget>>;
845
847
  /**
@@ -457,12 +457,8 @@ function supportPolicy(options) {
457
457
  }
458
458
  //#endregion
459
459
  //#region src/better-supabase/hooks.ts
460
- /**
461
- * better-supabase's claim that caps a context to the permission keys it lists:
462
- * `bs_permission_cap` before 0.15, `bsb_permission_cap` from 0.15. A run sets
463
- * both, so the cap holds on every version in the peer range.
464
- */
465
- const PERMISSION_CAP_CLAIMS = ["bs_permission_cap", "bsb_permission_cap"];
460
+ /** better-supabase's claim that caps a context to the permission keys it lists. */
461
+ const PERMISSION_CAP_CLAIM = "bsb_permission_cap";
466
462
  /**
467
463
  * Whether `permdock` is granted `key` with no row; an unknown key and
468
464
  * `approval-required` are `false`.
@@ -541,7 +537,7 @@ function authorizationHooks(options) {
541
537
  if (!isRecord(claims) || !await holdsAll(claims, ref)) return null;
542
538
  return Object.freeze({
543
539
  ...claims,
544
- ...Object.fromEntries(PERMISSION_CAP_CLAIMS.map((claim) => [claim, [...ref.permissions]]))
540
+ [PERMISSION_CAP_CLAIM]: [...ref.permissions]
545
541
  });
546
542
  } catch {
547
543
  return null;
@@ -928,6 +924,32 @@ function permittedTemplate(schema, scopes, tenantScope, catalog) {
928
924
  const otherwise = complete === void 0 ? atTenant : complete.length === 0 ? `false and ${atTenant}` : `{permission} in (${complete.join(", ")}) and ${atTenant}`;
929
925
  return `case ${branches.join(" ")} else ${otherwise} end`;
930
926
  }
927
+ /**
928
+ * better-supabase's `rowsWith` and `rowsWithFor` over the
929
+ * `permitted_<resource>_rows` helpers: `{resource}` is the resource's SQL name,
930
+ * `rowsWith` takes the candidate ids being checked, and `rowsWithFor` runs the
931
+ * helper's `_for` form, which `rls generate` writes beside it for Supabase.
932
+ */
933
+ function rowTemplatesOf(schema, manifest, requires, problems) {
934
+ const rows = Object.values(manifest.names?.resources ?? {}).flatMap((names) => names.rows === void 0 ? [] : [names.rows]);
935
+ if (rows.length === 0) {
936
+ problems.push("rowHelpers: the manifest names no permitted_<resource>_rows helper. Set rls.rowHelpers, run `permdock rls generate`, then `permdock supabase inspect --out`.");
937
+ return {};
938
+ }
939
+ for (const name of rows) requires.push({
940
+ function: `${schema}.${sqlIdent(name)}`,
941
+ args: "text, text[]",
942
+ role: "authenticated"
943
+ }, {
944
+ function: `${schema}.${sqlIdent(`${name}_for`)}`,
945
+ args: "uuid, text, jsonb",
946
+ role: "postgres"
947
+ });
948
+ return {
949
+ rowsWith: `${schema}.permitted_{resource}_rows({permission}, {ids})`,
950
+ rowsWithFor: `${schema}.permitted_{resource}_rows_for({user}, {permission})`
951
+ };
952
+ }
931
953
  const RISKS = {
932
954
  low: "low",
933
955
  medium: "medium",
@@ -1099,6 +1121,7 @@ function authorizationProvider(options) {
1099
1121
  }
1100
1122
  const permitted = listed("idsWith", tenantScope) ? permittedTemplate(schema, scopeNames.filter((scope) => listed("idsWith", scope)), tenantScope, catalog) : void 0;
1101
1123
  const functions = {
1124
+ ...options.rowHelpers === true ? rowTemplatesOf(schema, manifest, requires, problems) : {},
1102
1125
  ...optional,
1103
1126
  idsWith: `${schema}.${TEMPLATES.idsWith.sql}`,
1104
1127
  isPlatform: `${schema}.${TEMPLATES.isPlatform.sql}`,
@@ -1214,7 +1237,7 @@ const keyOf = (request) => isPermission(request.action) ? request.action.key : n
1214
1237
  * subject is mapped from the verified claims with `subjectFromBetterSupabase`;
1215
1238
  * the request's `context.tenant` selects the active tenant only among the
1216
1239
  * memberships the claims hold. A caller without claims is anonymous, and a
1217
- * throw denies. With better-supabase 0.15's runtime `memo`, the checks of one
1240
+ * throw denies. With better-supabase's runtime `memo`, the checks of one
1218
1241
  * request scope share an instance per claims, tenant and intent.
1219
1242
  */
1220
1243
  function authorizer(options) {
@@ -1647,14 +1670,6 @@ function ownEntry(record, key) {
1647
1670
  return Object.hasOwn(record, key) ? record[key] : void 0;
1648
1671
  }
1649
1672
  function rowSubject(row) {
1650
- if (!Object.hasOwn(row, "subject")) {
1651
- const type = row["subjectType"];
1652
- const id = row["subjectId"];
1653
- return isId(type) && isId(id) ? {
1654
- type,
1655
- id
1656
- } : void 0;
1657
- }
1658
1673
  const subject = row["subject"];
1659
1674
  if (typeof subject !== "object" || subject === null) return void 0;
1660
1675
  const ref = Object.fromEntries(Object.entries(subject));
@@ -0,0 +1,56 @@
1
+ import { r as isRecord } from "./compact-CAf557ZB.js";
2
+ import "./budget-BELja5A9.js";
3
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
4
+ import { resolve } from "node:path";
5
+ //#region src/cli/shared/doctor-files.ts
6
+ const nodeFiles = Object.freeze({
7
+ exists: (path) => existsSync(path),
8
+ read: (path) => readFileSync(path, "utf8"),
9
+ list: (path) => readdirSync(path),
10
+ isDirectory: (path) => statSync(path, { throwIfNoEntry: false })?.isDirectory() === true
11
+ });
12
+ function filesOf(input) {
13
+ return input.files ?? nodeFiles;
14
+ }
15
+ /** Parses the JSON file at `path`; throws when it is missing or invalid. */
16
+ function readJson(files, path) {
17
+ return JSON.parse(files.read(path));
18
+ }
19
+ //#endregion
20
+ //#region src/cli/project/better-supabase.ts
21
+ const CONFIG_FILES = [
22
+ "better-supabase.config.ts",
23
+ "better-supabase.config.mts",
24
+ "better-supabase.config.js",
25
+ "better-supabase.config.mjs"
26
+ ];
27
+ /** The default export of the project's `better-supabase.config.*`, if it loads. */
28
+ async function betterSupabaseConfig(input) {
29
+ const files = filesOf(input);
30
+ const path = CONFIG_FILES.map((name) => resolve(input.cwd, name)).find((file) => files.exists(file));
31
+ if (path === void 0) return;
32
+ try {
33
+ const { loadModule } = await import("./load-Dm0pSYH3.js");
34
+ const loaded = (await loadModule(path))["default"];
35
+ return isRecord(loaded) ? loaded : void 0;
36
+ } catch {
37
+ return;
38
+ }
39
+ }
40
+ /** Resolve the hook default once for generation, inspection and doctor. */
41
+ function betterSupabaseDefaults(config, detected) {
42
+ const hook = config.supabase?.hook;
43
+ if (!detected || hook === void 0 || hook.activeFrom !== void 0) return config;
44
+ return {
45
+ ...config,
46
+ supabase: {
47
+ ...config.supabase,
48
+ hook: {
49
+ ...hook,
50
+ activeFrom: `app_metadata.${config.rls?.tenantClaim ?? "tenant_id"}`
51
+ }
52
+ }
53
+ };
54
+ }
55
+ //#endregion
56
+ export { readJson as a, nodeFiles as i, betterSupabaseDefaults as n, filesOf as r, betterSupabaseConfig as t };
@@ -16,7 +16,7 @@ const casbinImport = defineLeaf({
16
16
  ...outFlag
17
17
  },
18
18
  async run(ctx, { flags }) {
19
- const { runCasbinImport } = await import("./casbin-DTi6HSsl.js");
19
+ const { runCasbinImport } = await import("./casbin-CBXD5rFx.js");
20
20
  return runCasbinImport({
21
21
  cwd: ctx.cwd,
22
22
  model: given(flags.model),
@@ -1,4 +1,4 @@
1
- import { a as nonEmptyOr } from "./output-CtyBwTNB.js";
1
+ import { a as nonEmptyOr } from "./output-3iB3_Hfg.js";
2
2
  import { t as applyFiles } from "./files-B3AA05f1.js";
3
3
  import { n as isIdentifier, t as emitPolicyModule } from "./policy-module-xym9fnSq.js";
4
4
  import { existsSync, readFileSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import { r as isRecord, t as compact } from "../compact-CAf557ZB.js";
2
2
  import { l as withApp } from "../permdock-BvjivVb9.js";
3
- import { t as agentRuntime } from "../create-6EwRQlig.js";
3
+ import { t as agentRuntime } from "../create-Coq5fIrq.js";
4
4
  //#region src/claude-agent/create.ts
5
5
  const MCP_PREFIX = "mcp__";
6
6
  function asInput(input) {
package/dist/cli/bin.js CHANGED
@@ -11,7 +11,7 @@ if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
11
11
  const [{ isCi }, { trapSignals }, { run }, { streamHasColors }] = await Promise.all([
12
12
  import("../env-DJZrPjRi.js"),
13
13
  import("../signals-B1vHR3fN.js"),
14
- import("../run-0vOholnN.js"),
14
+ import("../run-DGSLvGty.js"),
15
15
  import("../style-DblOtSga.js")
16
16
  ]);
17
17
  const signals = trapSignals();
package/dist/cli/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as catalogPath } from "../catalog-path-CnI0XTFK.js";
2
- import { t as defineConfig } from "../config-BR23fL8m.js";
2
+ import { t as defineConfig } from "../config-ZZdtyQZy.js";
3
3
  import { n as parsePushedPolicy, r as pushedPolicy, t as PUSHED_POLICY_SCHEMA } from "../pushed-policy-CDuOL2de.js";
4
4
  import { c as parseGrantsMarker, l as parseHookMarker } from "../markers-BeHZ4x9Q.js";
5
- import { t as run } from "../run-B5nyNKe8.js";
5
+ import { t as run } from "../run-BlxXmaDS.js";
6
6
  //#region src/cli/token-schemas.ts
7
7
  const ID = {
8
8
  type: "string",
@@ -70,7 +70,7 @@ const pull = defineLeaf({
70
70
  },
71
71
  async run(ctx, { flags }) {
72
72
  const env = await withStdinSecret(ctx, "token", flags["token-stdin"], "PERMDOCK_CLOUD_TOKEN");
73
- return (await import("./pull-DfJALUbS.js")).runCloudPull({
73
+ return (await import("./pull-BY1METGf.js")).runCloudPull({
74
74
  cwd: ctx.cwd,
75
75
  config: ctx.config,
76
76
  url: given(flags.url),
@@ -1,7 +1,7 @@
1
1
  import { n as CliError } from "./errors-Vpu6rKHl.js";
2
2
  import { a as rel } from "./files-BSjrtIHw.js";
3
3
  import { t as beforeFirst } from "./text-BMFRfBqc.js";
4
- import { n as ROOT } from "./manifest-Cav1rjNQ.js";
4
+ import { n as ROOT } from "./manifest-BWIR_EEB.js";
5
5
  import { i as renameMessage, n as DEFAULT_CHANGES, r as flagRename, t as COMMAND_MOVES } from "./renames-CGj7YwcQ.js";
6
6
  import { i as refuseDirty, t as applyFiles } from "./files-B3AA05f1.js";
7
7
  import { readFileSync, readdirSync, statSync } from "node:fs";
@@ -7,7 +7,7 @@ const codemod = defineLeaf({
7
7
  description: "The release to migrate to (0.5)",
8
8
  required: true,
9
9
  async complete() {
10
- return (await import("./codemod-C1U8_Zu3.js")).codemodVersions();
10
+ return (await import("./codemod-BXLd4K3j.js")).codemodVersions();
11
11
  }
12
12
  }, {
13
13
  name: "paths",
@@ -22,7 +22,7 @@ const codemod = defineLeaf({
22
22
  }
23
23
  },
24
24
  async run(ctx, { flags, args, rest }) {
25
- return (await import("./codemod-C1U8_Zu3.js")).runCodemod({
25
+ return (await import("./codemod-BXLd4K3j.js")).runCodemod({
26
26
  cwd: ctx.cwd,
27
27
  version: args["version"],
28
28
  paths: rest,
@@ -29,7 +29,7 @@ const collect = defineLeaf({
29
29
  };
30
30
  if (flags.watch) {
31
31
  if (flags.check) throw new CliError("usage", "collect: --watch writes the catalog; drop --check", { code: "invalid_value" });
32
- return (await import("./watch-COuvly20.js")).watchCollect(ctx, overrides);
32
+ return (await import("./watch-C44FtM79.js")).watchCollect(ctx, overrides);
33
33
  }
34
34
  const result = await (await import("./collect-D-eroIfV.js")).runCollect({
35
35
  cwd: ctx.cwd,
@@ -1,6 +1,6 @@
1
1
  import { n as CliError } from "./errors-Vpu6rKHl.js";
2
2
  import { a as suggestion, o as GLOBAL_FLAGS } from "./args-0FrVs5EH.js";
3
- import { a as resolve } from "./manifest-Cav1rjNQ.js";
3
+ import { a as resolve } from "./manifest-BWIR_EEB.js";
4
4
  import { t as defineLeaf } from "./command-L8EstFNm.js";
5
5
  //#region src/cli/core/completion.ts
6
6
  const SHELLS = [
@@ -10,7 +10,7 @@ const config = defineLeaf({
10
10
  ...failOnFlag
11
11
  },
12
12
  async run(ctx, { flags }) {
13
- const { runConfig } = await import("./config-report-5AwptLr2.js");
13
+ const { runConfig } = await import("./config-report-BpztJ3HP.js");
14
14
  return runConfig({
15
15
  cwd: ctx.cwd,
16
16
  config: ctx.config,
@@ -1,5 +1,6 @@
1
1
  import { r as isRecord } from "./compact-CAf557ZB.js";
2
2
  import { i as configError, n as CliError } from "./errors-Vpu6rKHl.js";
3
+ import { n as betterSupabaseDefaults, t as betterSupabaseConfig } from "./better-supabase-83Gsetrv.js";
3
4
  import { a as isSection, i as isModuleKey, n as MODULE_KEYS, o as kindOf, r as describeKinds, t as CONFIG_SHAPE } from "./config-shape-tsxHx71E.js";
4
5
  import { existsSync } from "node:fs";
5
6
  import { relative, resolve } from "node:path";
@@ -80,8 +81,10 @@ async function readConfig(cwd, fromFlag, options) {
80
81
  const mod = await loadModule(path, options);
81
82
  const display = relative(cwd, path).replaceAll("\\", "/");
82
83
  const raw = pickNamed(mod, ["default"]);
84
+ const parsed = parseConfig(hasModuleValue(raw) ? await traceValues(cwd, path, display, raw, options) : raw, display);
83
85
  return {
84
- ...parseConfig(hasModuleValue(raw) ? await traceValues(cwd, path, display, raw, options) : raw, display),
86
+ ...parsed,
87
+ config: betterSupabaseDefaults(parsed.config, await betterSupabaseConfig({ cwd }) !== void 0),
85
88
  file: path
86
89
  };
87
90
  }
@@ -3,7 +3,7 @@ import { r as CONFIG_REPORT_SCHEMA } from "./version-DMQ0dnN5.js";
3
3
  import { t as catalogPath } from "./catalog-path-CnI0XTFK.js";
4
4
  import { n as guessPermissions, t as barrelFile } from "./collect-WCl8cJQV.js";
5
5
  import "./sources-C4vkzZJV.js";
6
- import { t as DOCS_BASE } from "./manifest-Cav1rjNQ.js";
6
+ import { t as DOCS_BASE } from "./manifest-BWIR_EEB.js";
7
7
  import { n as MIGRATION_DIRS, t as DEFAULT_SENSITIVE_ACTIONS } from "./constants-DcJABbLW.js";
8
8
  //#region src/cli/config-report.ts
9
9
  function configReport(input) {
@@ -4,7 +4,7 @@ import { o as deniedFor } from "./where-scope-DlCdCM_8.js";
4
4
  import { l as withApp } from "./permdock-BvjivVb9.js";
5
5
  import { t as composeWraps } from "./wrap-B2wziJI_.js";
6
6
  import { r as instanceOptions } from "./build-instance-BWXqwQYU.js";
7
- import { n as createAgentKernel } from "./kernel-qv4cr9w8.js";
7
+ import { n as createAgentKernel } from "./kernel-BD8QuMnv.js";
8
8
  //#region src/agent/create.ts
9
9
  function modelRow(modelId) {
10
10
  return { id: modelId };
@@ -21,7 +21,7 @@ const diff = defineLeaf({
21
21
  }
22
22
  },
23
23
  async run(ctx, { flags, args }) {
24
- return (await import("./diff-CQegtBAo.js")).runDiff({
24
+ return (await import("./diff-DfmYaIhB.js")).runDiff({
25
25
  cwd: ctx.cwd,
26
26
  config: ctx.config,
27
27
  sources: [args["before"], args["after"]].filter((value) => value !== void 0),
@@ -8,7 +8,7 @@ import { t as buildCatalog } from "./catalog-doc-DjMKzJp9.js";
8
8
  import { a as loadModule, n as asPolicy, s as pickNamed } from "./load-DjSU5KXO.js";
9
9
  import { t as parseCatalog } from "./parse-1_ZheTW5.js";
10
10
  import { t as operationFindings } from "./operation-findings-CXtFzlKJ.js";
11
- import { n as fixtureSubject, r as loadFixtures, t as fixtureRow } from "./fixtures-A1_sp_tR.js";
11
+ import { n as fixtureSubject, r as loadFixtures, t as fixtureRow } from "./fixtures-Bm4_K1ke.js";
12
12
  import { existsSync, readFileSync } from "node:fs";
13
13
  import { resolve } from "node:path";
14
14
  //#region src/cli/diff/format.ts
@@ -10,7 +10,7 @@ const doctor = defineLeaf({
10
10
  description: "Check codes or groups to run",
11
11
  valueHint: "code",
12
12
  async complete() {
13
- const { DOCTOR_CHECKS } = await import("./doctor-ktitU5Dl.js");
13
+ const { DOCTOR_CHECKS } = await import("./doctor-eNc7A_7I.js");
14
14
  return [.../* @__PURE__ */ new Set([...DOCTOR_CHECKS.map(({ code }) => code), ...DOCTOR_CHECKS.flatMap(({ groups }) => groups)])];
15
15
  }
16
16
  },
@@ -27,7 +27,7 @@ const doctor = defineLeaf({
27
27
  if (answer === void 0) return CANCELLED;
28
28
  fix = answer;
29
29
  }
30
- return (await import("./doctor-ktitU5Dl.js")).runDoctor({
30
+ return (await import("./doctor-eNc7A_7I.js")).runDoctor({
31
31
  cwd: ctx.cwd,
32
32
  config: ctx.config,
33
33
  only: flags.only,
@@ -16,51 +16,36 @@ import { c as jsonSchemaOf, i as catalogOAuthScopes } from "./catalog-doc-DjMKzJ
16
16
  import { a as loadModule, i as loadConfiguredPolicy, n as asPolicy, s as pickNamed } from "./load-DjSU5KXO.js";
17
17
  import { t as catalogPath } from "./catalog-path-CnI0XTFK.js";
18
18
  import { r as runCollect } from "./collect-WCl8cJQV.js";
19
+ import { n as supabaseTenantClaim } from "./budget-BELja5A9.js";
20
+ import { a as readJson, i as nodeFiles, n as betterSupabaseDefaults, r as filesOf, t as betterSupabaseConfig } from "./better-supabase-83Gsetrv.js";
19
21
  import { i as qualifySqlTable, s as quoteSqlLiteral } from "./sql-0WjxIp9g.js";
20
22
  import { a as scopeMembershipTable } from "./compile-EzEMB-7v.js";
21
- import { n as supabaseTenantClaim } from "./budget-BELja5A9.js";
22
23
  import { d as keptKeys, r as PERMDOCK_SCHEMA } from "./sources-C4vkzZJV.js";
23
24
  import { t as parseCatalog } from "./parse-1_ZheTW5.js";
24
25
  import { n as activeTenantMismatch } from "./active-tenant-DVee32-T.js";
25
26
  import "./markers-BeHZ4x9Q.js";
26
27
  import { t as didYouMean } from "./args-0FrVs5EH.js";
27
- import { t as DOCS_BASE } from "./manifest-Cav1rjNQ.js";
28
+ import { t as DOCS_BASE } from "./manifest-BWIR_EEB.js";
28
29
  import { t as createStyle } from "./style-Ds11Hmk4.js";
29
- import { a as nonEmptyOr, r as findingOf } from "./output-CtyBwTNB.js";
30
- import { i as runSkillsInstall } from "./skills-Bar7ZqwM.js";
30
+ import { a as nonEmptyOr, r as findingOf } from "./output-3iB3_Hfg.js";
31
+ import { i as runSkillsInstall } from "./skills-CY-MY_Oj.js";
31
32
  import { n as MIGRATION_DIRS, t as DEFAULT_SENSITIVE_ACTIONS } from "./constants-DcJABbLW.js";
32
33
  import { l as partPath } from "./output-files-BIQ_9pIs.js";
33
- import { _ as readSupabaseConfig, a as supabaseHookManifest, c as activeSource, d as resolveSchemas, g as pd074, h as pd045, l as pd039, m as attrsPlan, n as hookOut, v as supabaseConfig } from "./supabase-hook-CyuD9Wau.js";
34
+ import { _ as readSupabaseConfig, a as supabaseHookManifest, c as activeSource, d as resolveSchemas, g as pd074, h as pd045, l as pd039, m as attrsPlan, n as hookOut, v as supabaseConfig } from "./supabase-hook-HPgwYb9V.js";
34
35
  import { G as byKey, Q as graphSqlName, n as tableNameOf, o as graphPlan, r as tableNames } from "./tables-DimBcVWY.js";
35
36
  import { a as guardedTables, p as contextRefs, r as unsatisfiedKinds, t as ownershipRules } from "./ownership-qqBuGJXr.js";
36
37
  import { t as membershipSourcesOf } from "./sources-qoIJQrJv.js";
37
38
  import { i as group, n as membershipColumns, o as sqlStatements, r as tableKey } from "./deciding-columns-NB4wcyBf.js";
38
39
  import { t as FIELD_VIEWS } from "./fields-DI8s3cPl.js";
39
40
  import { t as resolveNames } from "./resolve-names-Y1Cb22cp.js";
40
- import { a as pd010, c as pd014, d as pd038, f as pd041, i as pd008, l as pd015, n as pd001, o as pd011, p as pd057, r as pd007, s as pd013, t as runUsage, u as pd036 } from "./usage-Y6xZUfE-.js";
41
- import { d as rowConditionMessage, f as commandFor, m as tableFor, p as compileGrants, s as ROW_CONDITION_FIX, u as helperTablePolicies } from "./verify-6EauWrkP.js";
42
- import { a as streamOf, i as scopeSourcesOf, r as staleFiles, t as powersyncFiles } from "./powersync-CD8-Ypao.js";
43
- import { a as buildContext, n as generateOptions, r as isRefusal, s as inheritTargets, t as supautilsRejections } from "./supautils-C-_jqylY.js";
41
+ import { a as pd010, c as pd014, d as pd038, f as pd041, i as pd008, l as pd015, n as pd001, o as pd011, p as pd057, r as pd007, s as pd013, t as runUsage, u as pd036 } from "./usage-WYRc7Kqg.js";
42
+ import { d as rowConditionMessage, f as commandFor, m as tableFor, p as compileGrants, s as ROW_CONDITION_FIX, u as helperTablePolicies } from "./verify-CHQgLrtS.js";
43
+ import { a as streamOf, i as scopeSourcesOf, r as staleFiles, t as powersyncFiles } from "./powersync-DVbskWD9.js";
44
+ import { a as buildContext, n as generateOptions, r as isRefusal, s as inheritTargets, t as supautilsRejections } from "./supautils-DZ95xxW-.js";
44
45
  import { n as legacyHelperNames, r as retirePlan, t as legacyHelperCalls } from "./retire-B2xffQgY.js";
45
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
46
46
  import { basename, dirname, join, resolve } from "node:path";
47
47
  import { pathToFileURL } from "node:url";
48
48
  import { createRequire } from "node:module";
49
- //#region src/cli/shared/doctor-files.ts
50
- const nodeFiles = Object.freeze({
51
- exists: (path) => existsSync(path),
52
- read: (path) => readFileSync(path, "utf8"),
53
- list: (path) => readdirSync(path),
54
- isDirectory: (path) => statSync(path, { throwIfNoEntry: false })?.isDirectory() === true
55
- });
56
- function filesOf(input) {
57
- return input.files ?? nodeFiles;
58
- }
59
- /** Parses the JSON file at `path`; throws when it is missing or invalid. */
60
- function readJson(files, path) {
61
- return JSON.parse(files.read(path));
62
- }
63
- //#endregion
64
49
  //#region src/cli/project/project.ts
65
50
  function loadProject(input) {
66
51
  const { cwd, config } = input;
@@ -216,24 +201,6 @@ async function pd064(input) {
216
201
  }
217
202
  //#endregion
218
203
  //#region src/cli/doctor/better-supabase.ts
219
- const CONFIG_FILES = [
220
- "better-supabase.config.ts",
221
- "better-supabase.config.mts",
222
- "better-supabase.config.js",
223
- "better-supabase.config.mjs"
224
- ];
225
- /** The default export of the project's `better-supabase.config.*`, if it loads. */
226
- async function betterSupabaseConfig(input) {
227
- const files = filesOf(input);
228
- const path = CONFIG_FILES.map((name) => resolve(input.cwd, name)).find((file) => files.exists(file));
229
- if (path === void 0) return;
230
- try {
231
- const loaded = (await loadModule(path))["default"];
232
- return isRecord(loaded) ? loaded : void 0;
233
- } catch {
234
- return;
235
- }
236
- }
237
204
  function activeTenantOf(config) {
238
205
  const blocks = config["blocks"];
239
206
  const permissions = isRecord(blocks) ? blocks["permissions"] : void 0;
@@ -253,8 +220,7 @@ function activeTenantOf(config) {
253
220
  * `switch_organization` never changes the tenant claim.
254
221
  */
255
222
  async function pd078(input) {
256
- const hook = input.config.supabase?.hook;
257
- if (hook === void 0) return [];
223
+ if (input.config.supabase?.hook === void 0) return [];
258
224
  const config = await betterSupabaseConfig(input);
259
225
  const activeTenant = config === void 0 ? void 0 : activeTenantOf(config);
260
226
  if (activeTenant === void 0) return [];
@@ -262,7 +228,7 @@ async function pd078(input) {
262
228
  const root = policy === void 0 ? void 0 : rootScope(scopeList(policy.scopes));
263
229
  let from;
264
230
  try {
265
- from = activeSource(hook.activeFrom, root ?? "tenant");
231
+ from = activeSource(betterSupabaseDefaults(input.config, config !== void 0).supabase?.hook?.activeFrom, root ?? "tenant");
266
232
  } catch {
267
233
  return [];
268
234
  }
@@ -1086,7 +1052,7 @@ async function pd058(input) {
1086
1052
  code: "PD058",
1087
1053
  severity: "warning",
1088
1054
  message: gap,
1089
- fix: "build the source with tableMembershipSource or junctionMembershipSource, without expiresAt or disabledAt, or serve its members from the server"
1055
+ fix: "build the source with tableMembershipSource or junctionMembershipSource, without expiresAt, or serve its members from the server"
1090
1056
  }));
1091
1057
  return [...staleFiles(cwd, compiled.files).map((file) => ({
1092
1058
  code: "PD058",
package/dist/eve/index.js CHANGED
@@ -2,7 +2,7 @@ import { t as compact } from "../compact-CAf557ZB.js";
2
2
  import { l as withApp } from "../permdock-BvjivVb9.js";
3
3
  import { c as isApprovalError } from "../types-CcUXciSj.js";
4
4
  import { o as resolveApproval } from "../helpers-DJicaG6f.js";
5
- import { t as agentRuntime } from "../create-6EwRQlig.js";
5
+ import { t as agentRuntime } from "../create-Coq5fIrq.js";
6
6
  import { t as boundedMap } from "../lru-8q4WZjBV.js";
7
7
  //#region src/eve/create.ts
8
8
  const TOKENS_PER_PROCESS = 1e3;