permdock 0.9.0 → 0.10.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 (108) hide show
  1. package/dist/active-tenant-DVee32-T.js +39 -0
  2. package/dist/{adoption-scan-Ch07MdxN.js → adoption-scan-0oFt2RD5.js} +1 -1
  3. package/dist/{arazzo-BpS7LnV0.js → arazzo-DA9PCXew.js} +1 -1
  4. package/dist/{arazzo-CmQaGPkM.js → arazzo-DhxDfYt-.js} +1 -1
  5. package/dist/better-supabase/index.d.ts +188 -23
  6. package/dist/better-supabase/index.js +246 -62
  7. package/dist/{casbin-bHyIxTNQ.js → casbin-BJu2liqU.js} +1 -1
  8. package/dist/{casbin-B7_yS-oo.js → casbin-BkhqGh2z.js} +1 -1
  9. package/dist/cli/bin.js +1 -1
  10. package/dist/cli/index.d.ts +6 -1
  11. package/dist/cli/index.js +10 -2
  12. package/dist/{cloud-3kWfjnYy.js → cloud-3RIuS4E9.js} +2 -2
  13. package/dist/{codemod-D9Aiii1r.js → codemod-DLcp-B6v.js} +2 -2
  14. package/dist/{codemod-Bv5i-Mzo.js → codemod-DRl_w-bY.js} +1 -1
  15. package/dist/{collect-B80GYEot.js → collect-D9Tt0Bcx.js} +1 -1
  16. package/dist/{completion-_bc0OUQ-.js → completion-VSWvaaPO.js} +1 -1
  17. package/dist/{config-BwPBfN0t.js → config-BR23fL8m.js} +2 -2
  18. package/dist/{config-D5XrLWpk.js → config-kL36AxkE.js} +1 -1
  19. package/dist/{config-report-BmWIskD7.js → config-report-osnfUNg5.js} +2 -2
  20. package/dist/{config-shape-ykV0Vm2n.js → config-shape-tsxHx71E.js} +2 -1
  21. package/dist/{create-BamXmeob.d.ts → create-CDd9c22W.d.ts} +10 -1
  22. package/dist/{doctor-LPMYjSqO.js → doctor-B9FY9H0F.js} +2 -2
  23. package/dist/{doctor-ClRVAtXQ.js → doctor-DfTnMaUt.js} +142 -14
  24. package/dist/{fields-D0vUI6dq.js → fields-DI8s3cPl.js} +1 -1
  25. package/dist/{gen-BtfFWGbz.js → gen-DuAhghDw.js} +1 -1
  26. package/dist/{gen-BFfzZSLH.js → gen-DwgCSC6V.js} +1 -1
  27. package/dist/{import-CST57XLp.js → import-CNBF96hB.js} +2 -2
  28. package/dist/{import-ACkOrv6g.js → import-Iuk9mx8A.js} +1 -1
  29. package/dist/{index-vYjMrXyK.d.ts → index-Cay5-Kvx.d.ts} +3 -51
  30. package/dist/index.d.ts +2 -1
  31. package/dist/{init-BjuFDYT1.js → init-DeoSvkh2.js} +1 -1
  32. package/dist/{init-txYTuW9u.js → init-fNF_XmTa.js} +3 -3
  33. package/dist/{login-CgfCTO3F.js → login-CutVtcmQ.js} +1 -1
  34. package/dist/{login-CfImTJGb.js → login-DYazeWc9.js} +3 -3
  35. package/dist/{manifest-B2QPh19C.js → manifest-B4ENCp2I.js} +33 -33
  36. package/dist/{manifest-CzzWtnAb.d.ts → manifest-B5yF3CIq.d.ts} +19 -0
  37. package/dist/{manifest-wg8WkkpD.js → manifest-BXTbHNIV.js} +1 -1
  38. package/dist/{manifest-schema-2r37XRhD.js → manifest-schema-DQkBK2Mr.js} +28 -1
  39. package/dist/{migrate-B7oP_sQU.js → migrate-BJHxQqT5.js} +2 -2
  40. package/dist/{module-values-BJTBdo6y.js → module-values-B1EVTkHP.js} +1 -1
  41. package/dist/next/index.d.ts +16 -3
  42. package/dist/next/index.js +1 -1
  43. package/dist/next/plugin.d.ts +1 -1
  44. package/dist/next/plugin.js +1 -1
  45. package/dist/{openapi-BGeuunWC.js → openapi-C-ADypaY.js} +1 -1
  46. package/dist/{openapi-BIpw3Mb7.js → openapi-DFj0cirS.js} +2 -2
  47. package/dist/{output-DV5dwOTs.js → output-LsbLe41I.js} +1 -1
  48. package/dist/{ownership-DA5YdYTm.js → ownership-qqBuGJXr.js} +3 -3
  49. package/dist/{postgrest-5Dr3W64L.js → postgrest-DAxFltvO.js} +1 -1
  50. package/dist/{powersync-Bg8u-JcR.js → powersync-B_8uwz7f.js} +2 -2
  51. package/dist/powersync-CSzDCHRu.js +1 -0
  52. package/dist/{powersync-CJrT1DSc.js → powersync-DUT-UKgw.js} +188 -36
  53. package/dist/{pull-2nJr0qg_.js → pull-DQCgvJSC.js} +2 -2
  54. package/dist/pull-DYbyod1f.js +1 -0
  55. package/dist/{push-Bn-lMEmI.js → push-Dq_ca4-j.js} +1 -1
  56. package/dist/{resolve-names-ConCSj1y.js → resolve-names-Y1Cb22cp.js} +4 -4
  57. package/dist/{rls-Cx0dtsB7.js → rls-B57mIeVq.js} +22 -15
  58. package/dist/{rls-Ba9wN0SP.js → rls-j0YrFPpW.js} +1 -1
  59. package/dist/run-BATawNVH.js +1 -0
  60. package/dist/{run-PbRlXTfh.js → run-CLP_fQUF.js} +3 -3
  61. package/dist/{run-ticket-Dv7aF7Dk.js → run-ticket-DfnZCh-u.js} +19 -6
  62. package/dist/{run-ticket-B2o2Kxz8.d.ts → run-ticket-ylovhyFQ.d.ts} +16 -1
  63. package/dist/{scan-CRTj6fke.js → scan-B7xrAvRm.js} +1 -1
  64. package/dist/{schema-BTsE1WRT.js → schema-3PJ8wAeL.js} +1 -1
  65. package/dist/server/index.d.ts +2 -2
  66. package/dist/server/index.js +1 -1
  67. package/dist/{shared-Afctg7B0.js → shared-DrGLwM3s.js} +1 -1
  68. package/dist/{skills-C9uKfSF5.js → skills-BUI8DMqy.js} +1 -1
  69. package/dist/{skills-CQQcuGBi.js → skills-iwbRxavw.js} +1 -1
  70. package/dist/{sources-CMAM-2A3.js → sources-C4vkzZJV.js} +12 -7
  71. package/dist/{types-BMVDHvI0.d.ts → sources-oB1Hg1Fm.d.ts} +316 -2
  72. package/dist/supabase/index.d.ts +2 -3
  73. package/dist/supabase/index.js +4 -4
  74. package/dist/{supabase-DnMMg5Fn.js → supabase-B1EfuD47.js} +2 -2
  75. package/dist/{supabase-SBs3MYUE.js → supabase-BaizG0n7.js} +2 -2
  76. package/dist/{supabase-hook-CrgU06WH.js → supabase-hook-BT2P9wah.js} +110 -47
  77. package/dist/supabase-hook-CbvGAutK.js +1 -0
  78. package/dist/{supautils-ByezN3b8.js → supautils-DBKOoyjn.js} +8 -8
  79. package/dist/{tables-BqrxBCir.js → tables-DimBcVWY.js} +2 -2
  80. package/dist/testing/fixtures/index.d.ts +1 -1
  81. package/dist/testing/fixtures/index.js +26 -28
  82. package/dist/testing/index.d.ts +4 -3
  83. package/dist/testing/index.js +3 -2
  84. package/dist/{types-CzOeVvcC.d.ts → types-Cklw5hJo.d.ts} +23 -2
  85. package/dist/unplugin/index.d.ts +1 -1
  86. package/dist/unplugin/index.js +1 -1
  87. package/dist/{usage-CBzgwfIs.js → usage-B1ZJOUdr.js} +1 -1
  88. package/dist/{usage-B9EtHWLa.js → usage-t_nXnwCW.js} +2 -2
  89. package/dist/usage-weohzv2f.js +1 -0
  90. package/dist/{verify-DlUcTDBz.js → verify-jHrbmn-E.js} +6 -6
  91. package/dist/version-cache-Df11C2Qp.d.ts +51 -0
  92. package/dist/{watch-BFDKqmUa.js → watch-Bpci3hBY.js} +1 -1
  93. package/dist/watch-COuvly20.js +1 -0
  94. package/dist/workflow/index.d.ts +1 -1
  95. package/dist/workflow/index.js +22 -6
  96. package/dist/workflow-sdk/index.d.ts +1 -1
  97. package/package.json +2 -2
  98. package/schemas/run-v1.json +16 -0
  99. package/schemas/supabase-manifest-v1.json +28 -0
  100. package/skills/permdock-agents/references/operations-automations-chat.md +1 -0
  101. package/skills/permdock-wire/references/adapters.md +2 -2
  102. package/dist/powersync-B701tvhE.js +0 -1
  103. package/dist/pull-C3EEGzSw.js +0 -1
  104. package/dist/run-Ck22anC2.js +0 -1
  105. package/dist/sources-CWG32C0G.d.ts +0 -312
  106. package/dist/supabase-hook-C0FyEACZ.js +0 -1
  107. package/dist/usage-0hjZPIRX.js +0 -1
  108. package/dist/watch-ClLuO2TL.js +0 -1
@@ -9,5 +9,5 @@ import { l as ReplayStore } from "../types-DsHGPtkR.js";
9
9
  import { a as WebhookInput, c as WebhookMessage, d as WebhookSigningKey, f as WebhookVerifier, h as webhookVerifier, i as WebhookHeaders, l as WebhookSigner, m as webhookSigner, n as WebhookAlgorithm, o as WebhookJwk, p as WebhookVerifierOptions, r as WebhookFailureCause, s as WebhookJwks, t as VerifiedWebhookMessage, u as WebhookSignerOptions } from "../standard-webhooks-DOYEuOLx.js";
10
10
  import { t as memoryReplayStore } from "../replay-Bs9Df2fQ.js";
11
11
  import { a as snapshotHeaders, i as cacheLifeFor, n as SnapshotHeaders, o as snapshotTag, r as SnapshotHeadersOptions, t as CacheLifeForOptions } from "../snapshot-cache-BjAWkchD.js";
12
- import { a as RunContext, c as RunTicket, d as RunTicketInput, f as RunTicketOptions, g as subjectFromRunTicket, h as signRunTicket, i as RunBinding, l as RunTicketAutomations, m as parseRunTicket, n as RunActClaim, o as RunKind, p as RunTicketSubjectOptions, r as RunAutomation, s as RunPrincipal, t as RUN_TICKET_CLAIMS, u as RunTicketFailureCause } from "../run-ticket-B2o2Kxz8.js";
13
- export { type ApiKeyFailureCause, type ApiKeyParts, type ApiKeySubjectOptions, type ApprovalHint, type CacheLifeForOptions, type Connection, type ConnectionData, type ConnectionOptions, type DeniedResponse, type DeniedResponseEvent, type DiscoverViaSignatureAgentOptions, type Guard, InvalidSignatureError, type MemoryCredentialStore, type OpenApiHooks, type OperationScopes, PROBLEM_BASE, PermDockApprovalRequiredError, PermDockDeniedError, PermDockRevokedError, PermDockValidationError, type ProblemFromErrorOptions, type ProtectOptions, RUN_TICKET_CLAIMS, type ReplayStore, type RequestContext, type RevocationEvent, type RevocationFeed, type RunActClaim, type RunAutomation, type RunBinding, type RunContext, type RunKind, type RunPrincipal, type RunTicket, type RunTicketAutomations, type RunTicketFailureCause, type RunTicketInput, type RunTicketOptions, type RunTicketSubjectOptions, type ScopeGuard, type ServerPermDock, type ServerPermDockOptions, type SnapshotHeaders, type SnapshotHeadersOptions, type SnapshotQuery, type StoredCredential, type SupportSessionContext, type SupportSessionFailureCause, type SupportSessionSource, type SupportSessionSubjectOptions, type TenantOption, type TenantScope, type VerifiedWebhookMessage, type WebBotAuthJwk, type WebBotAuthKeyLookup, type WebBotAuthKeys, type WebBotAuthOptions, type WebBotAuthVerifier, type WebhookAlgorithm, type WebhookFailureCause, type WebhookHeaders, type WebhookInput, type WebhookJwk, type WebhookJwks, type WebhookMessage, type WebhookSigner, type WebhookSignerOptions, type WebhookSigningKey, type WebhookVerifier, type WebhookVerifierOptions, apiKeyVerifier, cacheLifeFor, createPermDock, discoverViaSignatureAgent, evaluationsHandler, generateApiKey, generateFeedKey, hashApiKey, invalidSignatureProblem, invalidSignatureResponse, memoryCredentialStore, memoryReplayStore, memoryRevocationFeed, parseApiKey, parseFeedKey, parseRunTicket, problemFromDecision, problemFromError, problemResponse, signRunTicket, signSupportSession, snapshotHeaders, snapshotTag, subjectFromApiKey, subjectFromRunTicket, subjectFromSupportSession, tenantScope, validationProblem, webBotAuthVerifier, webhookSigner, webhookVerifier, wwwAuthenticate };
12
+ import { _ as subjectFromRunTicket, a as RunContext, c as RunResource, d as RunTicketFailureCause, f as RunTicketInput, g as signRunTicket, h as parseRunTicket, i as RunBinding, l as RunTicket, m as RunTicketSubjectOptions, n as RunActClaim, o as RunKind, p as RunTicketOptions, r as RunAutomation, s as RunPrincipal, t as RUN_TICKET_CLAIMS, u as RunTicketAutomations } from "../run-ticket-ylovhyFQ.js";
13
+ export { type ApiKeyFailureCause, type ApiKeyParts, type ApiKeySubjectOptions, type ApprovalHint, type CacheLifeForOptions, type Connection, type ConnectionData, type ConnectionOptions, type DeniedResponse, type DeniedResponseEvent, type DiscoverViaSignatureAgentOptions, type Guard, InvalidSignatureError, type MemoryCredentialStore, type OpenApiHooks, type OperationScopes, PROBLEM_BASE, PermDockApprovalRequiredError, PermDockDeniedError, PermDockRevokedError, PermDockValidationError, type ProblemFromErrorOptions, type ProtectOptions, RUN_TICKET_CLAIMS, type ReplayStore, type RequestContext, type RevocationEvent, type RevocationFeed, type RunActClaim, type RunAutomation, type RunBinding, type RunContext, type RunKind, type RunPrincipal, type RunResource, type RunTicket, type RunTicketAutomations, type RunTicketFailureCause, type RunTicketInput, type RunTicketOptions, type RunTicketSubjectOptions, type ScopeGuard, type ServerPermDock, type ServerPermDockOptions, type SnapshotHeaders, type SnapshotHeadersOptions, type SnapshotQuery, type StoredCredential, type SupportSessionContext, type SupportSessionFailureCause, type SupportSessionSource, type SupportSessionSubjectOptions, type TenantOption, type TenantScope, type VerifiedWebhookMessage, type WebBotAuthJwk, type WebBotAuthKeyLookup, type WebBotAuthKeys, type WebBotAuthOptions, type WebBotAuthVerifier, type WebhookAlgorithm, type WebhookFailureCause, type WebhookHeaders, type WebhookInput, type WebhookJwk, type WebhookJwks, type WebhookMessage, type WebhookSigner, type WebhookSignerOptions, type WebhookSigningKey, type WebhookVerifier, type WebhookVerifierOptions, apiKeyVerifier, cacheLifeFor, createPermDock, discoverViaSignatureAgent, evaluationsHandler, generateApiKey, generateFeedKey, hashApiKey, invalidSignatureProblem, invalidSignatureResponse, memoryCredentialStore, memoryReplayStore, memoryRevocationFeed, parseApiKey, parseFeedKey, parseRunTicket, problemFromDecision, problemFromError, problemResponse, signRunTicket, signSupportSession, snapshotHeaders, snapshotTag, subjectFromApiKey, subjectFromRunTicket, subjectFromSupportSession, tenantScope, validationProblem, webBotAuthVerifier, webhookSigner, webhookVerifier, wwwAuthenticate };
@@ -8,7 +8,7 @@ import { d as invalidSignatureProblem, f as invalidSignatureResponse, l as Inval
8
8
  import { n as tenantScope } from "../adapter-context-CIQpQxbE.js";
9
9
  import { t as createPermDock } from "../create-BLPKnJKa.js";
10
10
  import { a as generateFeedKey, c as parseApiKey, i as generateApiKey, l as parseFeedKey, n as subjectFromSupportSession, o as hashApiKey, r as apiKeyVerifier, s as memoryCredentialStore, t as signSupportSession, u as subjectFromApiKey } from "../server-3cVlTLde.js";
11
- import { i as subjectFromRunTicket, n as parseRunTicket, r as signRunTicket, t as RUN_TICKET_CLAIMS } from "../run-ticket-Dv7aF7Dk.js";
11
+ import { i as subjectFromRunTicket, n as parseRunTicket, r as signRunTicket, t as RUN_TICKET_CLAIMS } from "../run-ticket-DfnZCh-u.js";
12
12
  import { t as problemFromError } from "../map-error-pasIGqMT.js";
13
13
  import { n as webhookVerifier, t as webhookSigner } from "../standard-webhooks-D67a3nzk.js";
14
14
  export { InvalidSignatureError, PROBLEM_BASE, PermDockApprovalRequiredError, PermDockDeniedError, PermDockRevokedError, PermDockValidationError, RUN_TICKET_CLAIMS, apiKeyVerifier, cacheLifeFor, createPermDock, discoverViaSignatureAgent, evaluationsHandler, generateApiKey, generateFeedKey, hashApiKey, invalidSignatureProblem, invalidSignatureResponse, memoryCredentialStore, memoryReplayStore, memoryRevocationFeed, parseApiKey, parseFeedKey, parseRunTicket, problemFromDecision, problemFromError, problemResponse, signRunTicket, signSupportSession, snapshotHeaders, snapshotTag, subjectFromApiKey, subjectFromRunTicket, subjectFromSupportSession, tenantScope, validationProblem, webBotAuthVerifier, webhookSigner, webhookVerifier, wwwAuthenticate };
@@ -4,7 +4,7 @@ import { t as byCodePoint } from "./compare-DTfyUunF.js";
4
4
  import { i as configError } from "./errors-Vpu6rKHl.js";
5
5
  import { a as quoteQualifiedTable, c as quoteSqlTable, o as quoteSqlIdent, s as quoteSqlLiteral, t as SQL_IDENT } from "./sql-0WjxIp9g.js";
6
6
  import { t as byScope } from "./compile-EzEMB-7v.js";
7
- import "./sources-CMAM-2A3.js";
7
+ import "./sources-C4vkzZJV.js";
8
8
  //#region src/cli/sql/columns.ts
9
9
  /**
10
10
  * The Postgres type a JSON Schema property compares as; `undefined` for text or
@@ -1,7 +1,7 @@
1
1
  import { t as defineLeaf } from "./command-L8EstFNm.js";
2
2
  import { t as checkFlag } from "./flags-DXjoTVbS.js";
3
3
  import { r as pick, t as CANCELLED } from "./prompt-BYc6drYW.js";
4
- import { n as detectedAgents, r as runSkills, t as SKILL_AGENTS } from "./skills-CQQcuGBi.js";
4
+ import { n as detectedAgents, r as runSkills, t as SKILL_AGENTS } from "./skills-iwbRxavw.js";
5
5
  //#region src/cli/commands/skills.ts
6
6
  const forFlag = { for: {
7
7
  type: "string",
@@ -2,7 +2,7 @@ import { t as byCodePoint } from "./compare-DTfyUunF.js";
2
2
  import { i as readJsonFile } from "./files-BSjrtIHw.js";
3
3
  import { l as packageRoot } from "./version-DMQ0dnN5.js";
4
4
  import { t as didYouMean } from "./args-0FrVs5EH.js";
5
- import { a as nonEmptyOr } from "./output-DV5dwOTs.js";
5
+ import { a as nonEmptyOr } from "./output-LsbLe41I.js";
6
6
  import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, realpathSync, writeFileSync } from "node:fs";
7
7
  import { basename, dirname, join, relative, resolve } from "node:path";
8
8
  import { pathToFileURL } from "node:url";
@@ -228,7 +228,7 @@ function singleRole(role, table, alias, options) {
228
228
  }
229
229
  const pairs = Object.entries(role.on);
230
230
  const [pair] = pairs;
231
- if (pair === void 0 || pairs.length !== 1) throw new TypeError(`${prefix}: ${options.label}.on must map exactly one column of ${table} to ${role.through}, for example ${options.example ?? "{ role_id: 'id' }"}`);
231
+ if (pair === void 0 || pairs.length !== 1 && options.composite !== true) throw new TypeError(options.composite === true ? `${prefix}: ${options.label}.on must map at least one column of ${table} to ${role.through}, for example ${options.example ?? "{ role_id: 'id' }"}` : `${prefix}: ${options.label}.on must map exactly one column of ${table} to ${role.through}, for example ${options.example ?? "{ role_id: 'id' }"}`);
232
232
  const [ref, id] = pair;
233
233
  const schema = table.includes(".") ? table.split(".")[0] ?? "public" : "public";
234
234
  const through = role.through.includes(".") ? role.through : `${schema}.${role.through}`;
@@ -238,18 +238,20 @@ function singleRole(role, table, alias, options) {
238
238
  table: through,
239
239
  id,
240
240
  key: role.column,
241
- ref
241
+ ref,
242
+ match: pairs
242
243
  };
244
+ const on = pairs.map(([from, to]) => `${keys}.${q(to)} = ${alias}.${q(from)}`).join(" and ");
243
245
  const plain = `${keys}.${q(role.column)}::text`;
244
246
  const guard = options.guard;
245
247
  const key = guard !== void 0 && qualifySqlTable(guard.table) === through ? `case when ${keys}.${q(guard.tenant)} is not null${guard.skip === void 0 ? "" : ` and not coalesce(${keys}.${q(guard.skip)}, false)`} and ${plain} = any(${sqlTextArray(guard.declared)}) then null else ${plain} end` : plain;
246
248
  return {
247
249
  column: ref,
248
250
  sql: key,
249
- join: `${options.indent === void 0 ? " " : `\n${options.indent}`}join ${target} ${keys} on ${keys}.${q(id)} = ${alias}.${q(ref)}`,
250
- lookup: `(select ${key} from ${target} ${keys} where ${keys}.${q(id)} = ${alias}.${q(ref)})`,
251
+ join: `${options.indent === void 0 ? " " : `\n${options.indent}`}join ${target} ${keys} on ${on}`,
252
+ lookup: `(select ${key} from ${target} ${keys} where ${on})`,
251
253
  through: keyed,
252
- columns: [ref],
254
+ columns: pairs.map(([from]) => from),
253
255
  throughs: [keyed],
254
256
  lateral: false,
255
257
  nullable: false
@@ -264,12 +266,14 @@ function sourceManifest(column, through, map) {
264
266
  column,
265
267
  map
266
268
  };
267
- return through === void 0 ? { column } : {
269
+ if (through === void 0) return { column };
270
+ return {
268
271
  column,
269
272
  through: {
270
273
  table: through.table,
271
274
  id: through.id,
272
- column: through.key
275
+ column: through.key,
276
+ ...through.match.length > 1 ? { on: Object.fromEntries(through.match) } : {}
273
277
  }
274
278
  };
275
279
  }
@@ -300,6 +304,7 @@ function memberRole(role, table, label, guard) {
300
304
  return roleColumn(role, qualifySqlTable(table), "m", {
301
305
  label,
302
306
  indent: "",
307
+ composite: true,
303
308
  ...guard === void 0 ? {} : { guard }
304
309
  });
305
310
  }
@@ -1,6 +1,8 @@
1
- import { pr as Principal, rn as AuthEvent } from "./policy-types-DGIO_gxq.js";
1
+ import { nt as MembershipSource, pr as Principal, rn as AuthEvent } from "./policy-types-DGIO_gxq.js";
2
2
  import { t as ClaimsMap } from "./claims-map-D1Pb5oRq.js";
3
3
  import { t as ClientNames } from "./clients-C_NOET3z.js";
4
+ import { c as SupabaseManifestMembership } from "./manifest-B5yF3CIq.js";
5
+ import { t as SqlQuery } from "./sql-B80DFdpG.js";
4
6
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
7
  //#region src/supabase/claims.d.ts
6
8
  /**
@@ -404,4 +406,316 @@ type SupabaseDelegation = {
404
406
  readonly scopes: readonly string[];
405
407
  };
406
408
  //#endregion
407
- export { SupabaseClaims as C, SupabasePermDockClaims as D, SupabaseMembershipClaim as E, supabaseClaims as O, SupabaseActClaim as S, SupabaseClaimsSchema as T, SupabaseStorage as _, SupabaseActor as a, SupabaseSuspendedScope as b, SupabaseInclude as c, SupabasePrincipal as d, SupabaseRealtime as f, SupabaseSessionLike as g, SupabaseRlsOptions as h, SupabaseActiveRow as i, SupabaseMembershipTable as l, SupabaseRlsMembershipTable as m, RoleMap as n, SupabaseActorResult as o, SupabaseRlsConfig as p, RoleThrough as r, SupabaseDelegation as s, AuthorizeSqlOptions as t, SupabasePermissionRef as u, SupabaseSubjectOptions as v, SupabaseClaimsOptions as w, SupabaseSuspension as x, SupabaseSuspendedMembership as y };
409
+ //#region src/supabase/roles.d.ts
410
+ /** A roles table a role column references, by `schema.table`. */
411
+ type RoleKeys = {
412
+ readonly table: string;
413
+ /** The roles table column the reference points at. */
414
+ readonly id: string;
415
+ /** The roles table column holding the role key. */
416
+ readonly key: string;
417
+ /** The referencing table's column. */
418
+ readonly ref: string;
419
+ /**
420
+ * Every referencing column and the column of `table` it matches, `ref` and
421
+ * `id` first; more than one pair for a composite reference.
422
+ */
423
+ readonly match: readonly (readonly [ref: string, id: string])[];
424
+ };
425
+ /**
426
+ * One role source of a membership row: a key column, or a reference to a roles
427
+ * table.
428
+ */
429
+ type RoleSource = string | RoleThrough | RoleMap;
430
+ /** A role source, or several the row holds at once. */
431
+ type RoleSpec = RoleSource | readonly RoleSource[];
432
+ /**
433
+ * A roles table whose tenant rows are written by tenants. A role key read
434
+ * through it from a tenant row that is one of `declared` reads as null, so a
435
+ * tenant cannot claim the grants of a declared role by naming a role after it.
436
+ */
437
+ type RoleGuard = {
438
+ /** `schema.table`, or `public`. */
439
+ readonly table: string;
440
+ /** The tenant column of the roles table. */
441
+ readonly tenant: string;
442
+ /**
443
+ * A tenant row with this column true is the application's own copy of a
444
+ * declared role.
445
+ */
446
+ readonly skip?: string | undefined;
447
+ readonly declared: readonly string[];
448
+ };
449
+ //#endregion
450
+ //#region src/supabase/sources.d.ts
451
+ type Common = {
452
+ readonly table: string;
453
+ /**
454
+ * Runs the lookups; without it the source only describes SQL (for `permdock
455
+ * supabase hook generate`).
456
+ */
457
+ readonly query?: SqlQuery;
458
+ /**
459
+ * Drop suspended users and memberships under suspended instances, like
460
+ * `rls.suspension`.
461
+ */
462
+ readonly suspension?: SupabaseSuspension;
463
+ };
464
+ type MembershipTableOptions = Common & {
465
+ /**
466
+ * Column names; `user`, `scope`, `id` and `role` default to `user_id`,
467
+ * `scope`, `scope_id`, `role`.
468
+ */
469
+ readonly columns?: {
470
+ /** The user id column, or a reference to a table that holds the user id. */
471
+ readonly user?: string | RoleThrough;
472
+ readonly scope?: string;
473
+ readonly id?: string;
474
+ /** A `jsonb` column of ancestor ids keyed by scope name. */
475
+ readonly within?: string;
476
+ /**
477
+ * The role key column, a reference to a roles table that holds the key, or
478
+ * several of them: the row holds every non-null key.
479
+ */
480
+ readonly role?: RoleSpec;
481
+ readonly via?: string;
482
+ readonly expiresAt?: string;
483
+ readonly disabledAt?: string;
484
+ /** The principal id that wrote the membership (`grantedBy`). */
485
+ readonly grantedBy?: string;
486
+ /** Free-text justification recorded on the membership (`reason`). */
487
+ readonly reason?: string;
488
+ /** A subgroup column filling `member.group`. */
489
+ readonly group?: string;
490
+ /**
491
+ * A text column; the value `idp` marks the row as owned by the identity
492
+ * provider.
493
+ */
494
+ readonly managedBy?: string;
495
+ /** A `text[]` column of seats. */
496
+ readonly seats?: string;
497
+ /** A `jsonb` column of app data (`Membership.x`); never written into claims. */
498
+ readonly x?: string;
499
+ };
500
+ };
501
+ type MembershipJunctionOptions = Common & {
502
+ /** The declared scope every row is a membership of. */
503
+ readonly scope: string;
504
+ /**
505
+ * The user id column (default `user_id`), or a reference to a table that
506
+ * holds the user id.
507
+ */
508
+ readonly user?: string | RoleThrough;
509
+ /** The column holding the scope instance id. Default `<scope>_id`. */
510
+ readonly id?: string;
511
+ /** Ancestor id columns keyed by scope name. */
512
+ readonly within?: Readonly<Record<string, string>>;
513
+ /**
514
+ * A role column, a reference to a roles table that holds the key, fixed roles
515
+ * every row holds (a contact table with no role column), or `{ sources }`:
516
+ * several role columns whose non-null keys the row holds.
517
+ */
518
+ readonly roles: string | RoleThrough | RoleMap | readonly string[] | {
519
+ readonly sources: readonly RoleSource[];
520
+ };
521
+ /** The membership kind every row has (`contact`, `staff`, `partner`). */
522
+ readonly via?: string;
523
+ readonly expiresAt?: string;
524
+ readonly disabledAt?: string;
525
+ /** The principal id that wrote the membership (`grantedBy`). */
526
+ readonly grantedBy?: string;
527
+ /** Free-text justification recorded on the membership (`reason`). */
528
+ readonly reason?: string;
529
+ /** A subgroup filling `member.group`: a fixed name every row has, or a column. */
530
+ readonly group?: string | {
531
+ readonly column: string;
532
+ };
533
+ /**
534
+ * `idp` when the identity provider owns every row, or a text column holding
535
+ * `idp` per row.
536
+ */
537
+ readonly managedBy?: "idp" | {
538
+ readonly column: string;
539
+ };
540
+ /** A `text[]` column of seats. */
541
+ readonly seats?: string;
542
+ /** A `jsonb` column of app data (`Membership.x`); never written into claims. */
543
+ readonly x?: string;
544
+ };
545
+ /**
546
+ * What `permdock supabase hook generate` compiles; the same SQL the source
547
+ * runs.
548
+ */
549
+ type MembershipSql = {
550
+ readonly table: string;
551
+ /**
552
+ * The table's user column: the user id, or with `userThrough` the reference
553
+ * to the row holding it.
554
+ */
555
+ readonly user: string;
556
+ /**
557
+ * The table that holds the user id when `user` references it; a change of
558
+ * that id bumps the old and the new user.
559
+ */
560
+ readonly userThrough?: RoleKeys;
561
+ /**
562
+ * `<table>.<user>%type`: the PL/pgSQL type of the user id column, for a
563
+ * variable `select` compares with.
564
+ */
565
+ readonly userType: string;
566
+ /**
567
+ * The `select` of claim rows for one user, with every filter applied. `user`
568
+ * must have the column's type (a `userType` variable, or an untyped `$1`
569
+ * Postgres infers): the column is compared uncast so its index applies.
570
+ * `keep` adds the `keep` column; it defaults to `keeps`, and a `union` with a
571
+ * source that keeps passes `true`.
572
+ */
573
+ select: (user: string, keep?: boolean) => string;
574
+ /** The `select` of member rows for one scope instance (`$1` scope, `$2` id). */
575
+ list: (keep?: boolean) => string;
576
+ /**
577
+ * A suspended scope on the source keeps permissions: rows of its suspended
578
+ * instances stay, with a `keep` column.
579
+ */
580
+ readonly keeps: boolean;
581
+ /**
582
+ * A text column holding `idp` for rows the identity provider owns; `''` when
583
+ * every row is owned.
584
+ */
585
+ readonly managed?: string;
586
+ /** Other tables the `select` reads (suspension tables). */
587
+ readonly reads: readonly string[];
588
+ /**
589
+ * The roles table the role column references; a key change bumps every
590
+ * holder's authorization version.
591
+ */
592
+ readonly through?: RoleKeys;
593
+ /** Every roles table the role columns reference, `through` first. */
594
+ readonly throughs: readonly RoleKeys[];
595
+ /**
596
+ * Every column that decides who holds which membership: user, scope, id,
597
+ * `within`, role, `via` and expiry.
598
+ */
599
+ readonly columns: readonly string[];
600
+ /**
601
+ * For a single-scope source: its scope and the scopes whose ids each row
602
+ * carries.
603
+ */
604
+ readonly scope?: string;
605
+ readonly holds?: readonly string[];
606
+ /** The source's entry in the hook manifest's `memberships`. */
607
+ readonly manifest: SupabaseManifestMembership;
608
+ /** What the ownership triggers count; absent on a source that is not a table. */
609
+ readonly holders?: MembershipHolders;
610
+ /**
611
+ * The rows as plain columns, for Sync Streams and `powerSyncSource`; a source
612
+ * without it does not sync.
613
+ */
614
+ readonly stream?: MembershipStream;
615
+ };
616
+ /**
617
+ * One membership source as columns a Sync Streams query can filter on. Tables
618
+ * are `schema.table`; a `through` table is qualified in the source's schema
619
+ * when it names none.
620
+ */
621
+ type MembershipStream = {
622
+ readonly table: string;
623
+ /** The user id column, or the reference to the table that holds the user id. */
624
+ readonly user: string | RoleThrough;
625
+ /** The scope column, or the scope every row is a membership of. */
626
+ readonly scope: {
627
+ readonly column: string;
628
+ } | {
629
+ readonly value: string;
630
+ };
631
+ readonly id: string;
632
+ /**
633
+ * The role sources (the row holds every non-null key), or the fixed roles
634
+ * every row holds.
635
+ */
636
+ readonly roles: RoleSpec | {
637
+ readonly value: readonly string[];
638
+ };
639
+ /** The membership kind column, or the kind every row has. */
640
+ readonly via?: {
641
+ readonly column: string;
642
+ } | {
643
+ readonly value: string;
644
+ };
645
+ readonly expiresAt?: string;
646
+ readonly disabledAt?: string;
647
+ /**
648
+ * A row may hold no role key: such a row is no membership, and a reader drops
649
+ * it.
650
+ */
651
+ readonly nullableRoles: boolean;
652
+ /**
653
+ * The guard the source reads its roles table with: a tenant row named like a
654
+ * declared role is no role.
655
+ */
656
+ readonly guard?: RoleGuard;
657
+ };
658
+ /**
659
+ * The rows of a membership table, for the holder-count and transfer-only
660
+ * triggers `permdock rls generate` puts on it. No suspension filter: a
661
+ * suspended holder still holds the role.
662
+ */
663
+ type MembershipHolders = {
664
+ /**
665
+ * `<table>.<id column>%type`: the type of a variable `rows` compares the id
666
+ * column with.
667
+ */
668
+ readonly idType: string;
669
+ /**
670
+ * The instance id of scope `scope` the PL/pgSQL record `row` holds, as text;
671
+ * null on a row of another scope.
672
+ */
673
+ id: (scope: string, row: string) => string;
674
+ /**
675
+ * `select id, user_id, role, via, live` over the rows of scope `scope` in
676
+ * `from` (default the table): one row per held role key, `live` false once
677
+ * expired. `id` is an expression of `idType` the id column must equal.
678
+ */
679
+ rows: (scope: string, options?: {
680
+ readonly id?: string;
681
+ readonly from?: string;
682
+ }) => string;
683
+ };
684
+ type SqlMembershipSource = MembershipSource & {
685
+ readonly sql: MembershipSql;
686
+ /**
687
+ * The same source with the role keys of tenant rows of `guard.table` named
688
+ * like a declared role read as null.
689
+ */
690
+ readonly guarded?: (guard: RoleGuard) => SqlMembershipSource;
691
+ };
692
+ /** The part of `@supabase/server`'s `PostgresApi` a `SqlQuery` needs. */
693
+ type SupabasePostgres = {
694
+ readonly queryRaw: (text: string, params?: unknown[]) => Promise<readonly Record<string, unknown>[]>;
695
+ };
696
+ declare function supabasePostgresQuery(postgres: SupabasePostgres): SqlQuery;
697
+ /**
698
+ * Memberships from one table holding every scope: a row per user, scope,
699
+ * instance and role (`user_id, scope, scope_id, role`), with optional `within`,
700
+ * `via`, expiry, owner and seat columns. Rows of the same instance merge into
701
+ * one membership.
702
+ */
703
+ declare function tableMembershipSource(options: MembershipTableOptions): SqlMembershipSource;
704
+ /**
705
+ * Memberships from a table of one scope (`customer_contacts`): every row is a
706
+ * membership of `scope`, with roles from a column or fixed (`['contact']`), a
707
+ * fixed `via`, and ancestor ids from `within` columns.
708
+ */
709
+ declare function junctionMembershipSource(options: MembershipJunctionOptions): SqlMembershipSource;
710
+ declare const AUTHZ_VERSION_TABLE = "permdock_authz_version";
711
+ /**
712
+ * Reads the authorization version `permdock supabase hook generate` keeps in
713
+ * `<schema>.permdock_authz_version`: pass it to `claimsFirst(sources, { version
714
+ * })`.
715
+ */
716
+ declare function authzVersion(options: {
717
+ readonly query: SqlQuery;
718
+ readonly schema?: string;
719
+ }): NonNullable<MembershipSource["version"]>;
720
+ //#endregion
721
+ export { SupabaseSubjectOptions as A, supabaseClaims as B, SupabasePrincipal as C, SupabaseRlsOptions as D, SupabaseRlsMembershipTable as E, SupabaseClaims as F, SupabaseClaimsOptions as I, SupabaseClaimsSchema as L, SupabaseSuspendedScope as M, SupabaseSuspension as N, SupabaseSessionLike as O, SupabaseActClaim as P, SupabaseMembershipClaim as R, SupabasePermissionRef as S, SupabaseRlsConfig as T, SupabaseActor as _, MembershipStream as a, SupabaseInclude as b, SupabasePostgres as c, supabasePostgresQuery as d, tableMembershipSource as f, SupabaseActiveRow as g, RoleThrough as h, MembershipSql as i, SupabaseSuspendedMembership as j, SupabaseStorage as k, authzVersion as l, RoleMap as m, MembershipHolders as n, MembershipTableOptions as o, AuthorizeSqlOptions as p, MembershipJunctionOptions as r, SqlMembershipSource as s, AUTHZ_VERSION_TABLE as t, junctionMembershipSource as u, SupabaseActorResult as v, SupabaseRealtime as w, SupabaseMembershipTable as x, SupabaseDelegation as y, SupabasePermDockClaims as z };
@@ -1,10 +1,9 @@
1
1
  import { Wt as Instant, hr as Subject } from "../policy-types-DGIO_gxq.js";
2
2
  import { a as ApprovalDelegationSource, m as ApprovalStore, u as ApprovalRequest } from "../types-DLvhVm1r.js";
3
3
  import { a as SupabaseRpcClient, c as readSubjectRecord, i as SupabaseRpcCaller, n as PostgrestSourcesOptions, o as SupabaseRpcResult, r as SubjectRecord, s as postgrestSources, t as PostgrestSources } from "../postgrest-D5nUGm-c.js";
4
- import { C as SupabaseClaims, D as SupabasePermDockClaims, E as SupabaseMembershipClaim, O as supabaseClaims, S as SupabaseActClaim, T as SupabaseClaimsSchema, _ as SupabaseStorage, a as SupabaseActor, b as SupabaseSuspendedScope, c as SupabaseInclude, d as SupabasePrincipal, f as SupabaseRealtime, g as SupabaseSessionLike, h as SupabaseRlsOptions, i as SupabaseActiveRow, l as SupabaseMembershipTable, m as SupabaseRlsMembershipTable, o as SupabaseActorResult, p as SupabaseRlsConfig, r as RoleThrough, s as SupabaseDelegation, t as AuthorizeSqlOptions, u as SupabasePermissionRef, v as SupabaseSubjectOptions, w as SupabaseClaimsOptions, x as SupabaseSuspension, y as SupabaseSuspendedMembership } from "../types-BMVDHvI0.js";
4
+ import { A as SupabaseSubjectOptions, B as supabaseClaims, C as SupabasePrincipal, D as SupabaseRlsOptions, E as SupabaseRlsMembershipTable, F as SupabaseClaims, I as SupabaseClaimsOptions, L as SupabaseClaimsSchema, M as SupabaseSuspendedScope, N as SupabaseSuspension, O as SupabaseSessionLike, P as SupabaseActClaim, R as SupabaseMembershipClaim, S as SupabasePermissionRef, T as SupabaseRlsConfig, _ as SupabaseActor, a as MembershipStream, b as SupabaseInclude, c as SupabasePostgres, d as supabasePostgresQuery, f as tableMembershipSource, g as SupabaseActiveRow, h as RoleThrough, i as MembershipSql, j as SupabaseSuspendedMembership, k as SupabaseStorage, l as authzVersion, n as MembershipHolders, o as MembershipTableOptions, p as AuthorizeSqlOptions, r as MembershipJunctionOptions, s as SqlMembershipSource, t as AUTHZ_VERSION_TABLE, u as junctionMembershipSource, v as SupabaseActorResult, w as SupabaseRealtime, x as SupabaseMembershipTable, y as SupabaseDelegation, z as SupabasePermDockClaims } from "../sources-oB1Hg1Fm.js";
5
+ import { _ as hasTokenHook, a as SupabaseManifestActiveRow, c as SupabaseManifestMembership, d as SupabaseManifestResourceNames, f as SupabaseManifestRls, g as SupabaseManifestValue, h as SupabaseManifestThrough, i as SupabaseManifest, l as SupabaseManifestNames, m as SupabaseManifestScopeNames, n as SupabaseHookClaim, o as SupabaseManifestColumn, p as SupabaseManifestRole, r as SupabaseHookManifest, s as SupabaseManifestHelper, t as SupabaseDatabaseManifest, u as SupabaseManifestRequires, v as parseSupabaseManifest } from "../manifest-B5yF3CIq.js";
5
6
  import { t as SqlQuery } from "../sql-B80DFdpG.js";
6
- import { _ as hasTokenHook, a as SupabaseManifestActiveRow, c as SupabaseManifestMembership, d as SupabaseManifestResourceNames, f as SupabaseManifestRls, g as SupabaseManifestValue, h as SupabaseManifestThrough, i as SupabaseManifest, l as SupabaseManifestNames, m as SupabaseManifestScopeNames, n as SupabaseHookClaim, o as SupabaseManifestColumn, p as SupabaseManifestRole, r as SupabaseHookManifest, s as SupabaseManifestHelper, t as SupabaseDatabaseManifest, u as SupabaseManifestRequires, v as parseSupabaseManifest } from "../manifest-CzzWtnAb.js";
7
- import { a as MembershipStream, c as SupabasePostgres, d as supabasePostgresQuery, f as tableMembershipSource, i as MembershipSql, l as authzVersion, n as MembershipHolders, o as MembershipTableOptions, r as MembershipJunctionOptions, s as SqlMembershipSource, t as AUTHZ_VERSION_TABLE, u as junctionMembershipSource } from "../sources-CWG32C0G.js";
8
7
  import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-hYsPz_yE.js";
9
8
  //#region src/supabase/capability.d.ts
10
9
  type ExchangeCapabilityOptions = {
@@ -1,6 +1,6 @@
1
- import { a as supabaseClaims, i as supabaseApprovalStore, n as supabaseRls, o as exchangeCapability, r as tableApprovalDelegationSource, t as authorizeSql } from "../supabase-DnMMg5Fn.js";
1
+ import { a as supabaseClaims, i as supabaseApprovalStore, n as supabaseRls, o as exchangeCapability, r as tableApprovalDelegationSource, t as authorizeSql } from "../supabase-B1EfuD47.js";
2
2
  import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-BELja5A9.js";
3
- import { c as tableMembershipSource, i as authzVersion, o as junctionMembershipSource, s as supabasePostgresQuery, t as AUTHZ_VERSION_TABLE } from "../sources-CMAM-2A3.js";
4
- import { a as delegationOf, c as subjectFromSupabaseSession, i as actorOf, n as postgrestSources, r as readSubjectRecord, s as subjectFromSupabase } from "../postgrest-5Dr3W64L.js";
5
- import { n as parseSupabaseManifest, t as hasTokenHook } from "../manifest-wg8WkkpD.js";
3
+ import { c as tableMembershipSource, i as authzVersion, o as junctionMembershipSource, s as supabasePostgresQuery, t as AUTHZ_VERSION_TABLE } from "../sources-C4vkzZJV.js";
4
+ import { a as delegationOf, c as subjectFromSupabaseSession, i as actorOf, n as postgrestSources, r as readSubjectRecord, s as subjectFromSupabase } from "../postgrest-DAxFltvO.js";
5
+ import { n as parseSupabaseManifest, t as hasTokenHook } from "../manifest-BXTbHNIV.js";
6
6
  export { AUTHZ_VERSION_TABLE, actorOf, authorizeSql, authzVersion, delegationOf, exchangeCapability, hasTokenHook, junctionMembershipSource, parseSupabaseManifest, postgrestSources, readSubjectRecord, subjectFromSupabase, subjectFromSupabaseSession, supabaseApprovalStore, supabaseClaims, supabaseMembershipsBudget, supabasePostgresQuery, supabaseRls, supabaseTenantClaim, tableApprovalDelegationSource, tableMembershipSource };
@@ -7,8 +7,8 @@ import { a as parseCapability } from "./capability-BqX94r07.js";
7
7
  import { t as loadJose } from "./load-jose-DZ4dnjri.js";
8
8
  import { a as quoteQualifiedTable, c as quoteSqlTable, d as sqlTextArray, i as qualifySqlTable, o as quoteSqlIdent, s as quoteSqlLiteral } from "./sql-0WjxIp9g.js";
9
9
  import "./budget-BELja5A9.js";
10
- import { d as keptKeys, l as roleColumn } from "./sources-CMAM-2A3.js";
11
- import { t as callRpc } from "./postgrest-5Dr3W64L.js";
10
+ import { d as keptKeys, l as roleColumn } from "./sources-C4vkzZJV.js";
11
+ import { t as callRpc } from "./postgrest-DAxFltvO.js";
12
12
  //#region src/supabase/capability.ts
13
13
  const DEFAULT_TTL = 300;
14
14
  const MAX_TTL = 3600;
@@ -47,7 +47,7 @@ const hookGenerate = defineLeaf({
47
47
  const budget = given(flags.budget);
48
48
  const schema = given(flags.schema);
49
49
  const grantsOut = given(flags["grants-out"]);
50
- const { runSupabase } = await import("./supabase-hook-C0FyEACZ.js");
50
+ const { runSupabase } = await import("./supabase-hook-CbvGAutK.js");
51
51
  return runSupabase({
52
52
  cwd: ctx.cwd,
53
53
  config: ctx.config,
@@ -76,7 +76,7 @@ const inspect = defineLeaf({
76
76
  },
77
77
  async run(ctx, { flags }) {
78
78
  const out = flags.out === "" ? true : flags.out === "-" ? void 0 : flags.out;
79
- const { runSupabase } = await import("./supabase-hook-C0FyEACZ.js");
79
+ const { runSupabase } = await import("./supabase-hook-CbvGAutK.js");
80
80
  return runSupabase({
81
81
  cwd: ctx.cwd,
82
82
  config: ctx.config,