@rebasepro/server 0.31.0-canary.g902a0ce → 0.31.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 (34) hide show
  1. package/dist/{access-CCsVee6z.js → access-D1CTJSLK.js} +3 -1
  2. package/dist/access-D1CTJSLK.js.map +1 -0
  3. package/dist/{access-CSfmyM87.js → access-Dtu87BMj.js} +2 -2
  4. package/dist/{access-CSfmyM87.js.map → access-Dtu87BMj.js.map} +1 -1
  5. package/dist/{auth-Blo1R8rc.js → auth-BOz84vIr.js} +3 -3
  6. package/dist/{auth-Blo1R8rc.js.map → auth-BOz84vIr.js.map} +1 -1
  7. package/dist/auth-secrets-BZUH9916.js +60 -0
  8. package/dist/auth-secrets-BZUH9916.js.map +1 -0
  9. package/dist/{contract-routes-WwMWHWS9.js → contract-routes-o5oqNhfc.js} +2 -2
  10. package/dist/{contract-routes-WwMWHWS9.js.map → contract-routes-o5oqNhfc.js.map} +1 -1
  11. package/dist/{cron-routes-Cqm5wQsK.js → cron-routes-BOu-bY7I.js} +2 -2
  12. package/dist/{cron-routes-Cqm5wQsK.js.map → cron-routes-BOu-bY7I.js.map} +1 -1
  13. package/dist/{dist-CDIqWaSr.js → dist-fBcYxf4h.js} +2 -2
  14. package/dist/{dist-CDIqWaSr.js.map → dist-fBcYxf4h.js.map} +1 -1
  15. package/dist/index.es.js +21 -21
  16. package/dist/{load-schema-CtyLeq-H.js → load-schema-Cv5XLVjW.js} +2 -37
  17. package/dist/load-schema-Cv5XLVjW.js.map +1 -0
  18. package/dist/{openapi-generator-mn6hsEmw.js → openapi-generator-CoAFACMx.js} +2 -2
  19. package/dist/{openapi-generator-mn6hsEmw.js.map → openapi-generator-CoAFACMx.js.map} +1 -1
  20. package/dist/{query-parser-CkKSbs1s.js → query-parser-D9Uf8aha.js} +2 -2
  21. package/dist/{query-parser-CkKSbs1s.js.map → query-parser-D9Uf8aha.js.map} +1 -1
  22. package/dist/{rls-simulator-routes-BxzeNXmI.js → rls-simulator-routes-BvH6wI64.js} +2 -2
  23. package/dist/{rls-simulator-routes-BxzeNXmI.js.map → rls-simulator-routes-BvH6wI64.js.map} +1 -1
  24. package/dist/{schema-editor-routes-mPCyks4X.js → schema-editor-routes-CzITcAgt.js} +2 -2
  25. package/dist/{schema-editor-routes-mPCyks4X.js.map → schema-editor-routes-CzITcAgt.js.map} +1 -1
  26. package/dist/{schema-tables-D4MEBZFi.js → schema-tables-lJHnyqj4.js} +2 -2
  27. package/dist/{schema-tables-D4MEBZFi.js.map → schema-tables-lJHnyqj4.js.map} +1 -1
  28. package/dist/{schema-tables-routes-D3iLb5XU.js → schema-tables-routes-Uss-ljon.js} +3 -3
  29. package/dist/{schema-tables-routes-D3iLb5XU.js.map → schema-tables-routes-Uss-ljon.js.map} +1 -1
  30. package/dist/{table-source-editor-xvccIOH1.js → table-source-editor-qmyi5vxX.js} +2 -2
  31. package/dist/{table-source-editor-xvccIOH1.js.map → table-source-editor-qmyi5vxX.js.map} +1 -1
  32. package/package.json +5 -5
  33. package/dist/access-CCsVee6z.js.map +0 -1
  34. package/dist/load-schema-CtyLeq-H.js.map +0 -1
@@ -2,6 +2,7 @@ import { createRequire as __rebaseCreateRequire } from "module";
2
2
  import __rebaseProcess from "process";
3
3
  globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
+ import { t as AUTH_SECRET_NAMES } from "./auth-secrets-BZUH9916.js";
5
6
  /**
6
7
  * Does a caller holding `roles` satisfy `allowed`?
7
8
  *
@@ -317,6 +318,7 @@ function namesWhere(table, restricted, joins) {
317
318
  restrict(column.key);
318
319
  refused.add(column.column);
319
320
  }
321
+ if (table.auth !== void 0) for (const name of AUTH_SECRET_NAMES) refused.add(name);
320
322
  for (const relation of table.relations) {
321
323
  const read = joins ? relationJoinColumns(table, relation, joins === NO_RELATED ? void 0 : joins) : [boundKeyColumn(table, relation)];
322
324
  if (!restricted(relation) && !read.some((column) => column !== void 0 && restricted(column))) continue;
@@ -335,4 +337,4 @@ function restrictForeignKey(table, relation, restrict, refused) {
335
337
  //#endregion
336
338
  export { canReadRelation as a, columnAccess as c, canReadWithAccess as d, canReadColumn as i, relationJoinColumns as l, apiHiddenKeys as n, canWriteColumn as o, boundKeyColumn as r, canWriteRelation as s, UNSERVED_TABLE as t, restrictedKeys as u };
337
339
 
338
- //# sourceMappingURL=access-CCsVee6z.js.map
340
+ //# sourceMappingURL=access-D1CTJSLK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-D1CTJSLK.js","names":[],"sources":["../../common/src/collections/field-access.ts","../../common/src/table/access.ts"],"sourcesContent":["\n/**\n * Field-level access control: the one predicate every enforcement point reads.\n *\n * A table's `rls` decides which *rows* a caller reaches; a column's `access`\n * decides which *fields* of a reached row they see and may set. The two are\n * independent — a field rule never widens row access, and a row a caller\n * cannot read has no fields to talk about. `.private()` is `access: { read: [],\n * write: [] }` (`table/access.ts` expands it); the panel reads its property\n * view model through the same predicates.\n *\n * @module\n */\n\n/**\n * The caller a field rule is judged against: whatever the call context carries\n * as the user's application roles.\n *\n * `undefined` is the trusted server plane — an in-process `rebase.data` call\n * with no request behind it, the auth adapter writing a password hash, a\n * migration. Every API boundary has a viewer: an unauthenticated REST request is\n * scoped as `{ uid: ANONYMOUS_USER_ID, roles: [\"anon\"] }` before it reaches a\n * driver, so \"no viewer\" cannot be reached from outside.\n */\nexport interface FieldViewer {\n roles?: readonly string[];\n}\n\n/**\n * The role that satisfies any non-empty list.\n *\n * The same arm every baseline policy carries: `security_rules` injects\n * `rolesOverlap(['admin'])` into the default read and write policies, and\n * `rebase.dataAsAdmin` is scoped with `{ uid: \"service\", roles: [\"admin\"] }`.\n * Without this an author could declare `access: { read: [\"hr\"] }` and lock the\n * administrator out of a column of their own database — and lock the Studio out\n * of rendering it.\n */\nexport const ADMIN_ROLE = \"admin\";\n\n/**\n * Does a caller holding `roles` satisfy `allowed`?\n *\n * Three cases, and the middle one is the one worth stating out loud:\n *\n * - `allowed` omitted — the field carries no rule of its own, so the row's\n * policies have already answered. True.\n * - `allowed` empty — nobody, at any privilege, through any API. Not the admin,\n * not the service key, not the trusted plane reading on a caller's behalf.\n * This is what `excludeFromApi` has always meant on the read side, and\n * collapsing the two spellings means the empty list has to keep meaning it.\n * - `allowed` non-empty — one of the named roles, or `admin`, or no viewer at\n * all (the trusted server plane, which is not an API caller).\n */\nfunction satisfies(allowed: readonly string[] | undefined, viewer: FieldViewer | undefined): boolean {\n if (allowed === undefined) return true;\n if (allowed.length === 0) return false;\n if (!viewer) return true;\n const roles = viewer.roles;\n if (!roles || roles.length === 0) return false;\n return roles.includes(ADMIN_ROLE) || allowed.some(role => roles.includes(role));\n}\n\n/**\n * May this caller receive a value whose read rule is `access`? The same\n * predicate the panel's `canReadField` applies to a property, and the one a\n * column's or a relation's `access` in a table descriptor is judged by.\n */\nexport function canReadWithAccess(access: { read?: readonly string[] } | undefined, viewer: FieldViewer | undefined): boolean {\n return satisfies(access?.read, viewer);\n}\n\n/**\n * May this caller set a value whose write rule is `access`? The write half of\n * {@link canReadWithAccess}.\n */\nexport function canWriteWithAccess(access: { write?: readonly string[] } | undefined, viewer: FieldViewer | undefined): boolean {\n return satisfies(access?.write, viewer);\n}\n","import type { ColumnAccess, ColumnDescriptor, RelationDescriptor, TableDescriptor } from \"@rebasepro/types\";\n\nimport { canReadWithAccess, canWriteWithAccess, type FieldViewer } from \"../collections/field-access\";\nimport { AUTH_SECRET_NAMES } from \"../collections/auth-secrets\";\n\n/**\n * Column- and relation-level access over a {@link TableDescriptor}: the same\n * rules as `collections/field-access.ts`, read from the descriptor instead of\n * from `property.access` / `excludeFromApi`.\n *\n * - `.private()` (`private: true`) is `{ read: [], write: [] }`: nobody, through\n * any API — exactly what `excludeFromApi` expanded to.\n * - A list that is absent leaves that direction to the row's policies.\n * - An empty list closes it to every caller, the admin and the trusted plane\n * included.\n * - A non-empty list admits its roles, `admin`, and no viewer at all (the\n * trusted server plane).\n *\n * The predicate itself is common's `canReadWithAccess`, so the two models\n * cannot answer differently while both exist.\n *\n * @module\n */\n\n/** What carries access rules: a column, or a relation (which has no `readOnly`). */\ntype AccessTarget = Pick<ColumnDescriptor, \"private\" | \"access\"> & { readOnly?: true };\n\n/** The rule `.private()` expands to. Frozen: it is shared by every caller. */\nconst PRIVATE_ACCESS: ColumnAccess = Object.freeze({ read: Object.freeze([]), write: Object.freeze([]) });\n\n/**\n * What a column's or relation's access rules actually are, with `private`\n * expanded, or `undefined` when it constrains nothing.\n *\n * Replaces `effectiveAccess(property)`.\n *\n * @group Table\n */\nexport function columnAccess(target: Pick<ColumnDescriptor, \"private\" | \"access\">): ColumnAccess | undefined {\n if (target.private) return PRIVATE_ACCESS;\n const access = target.access;\n if (!access || (access.read === undefined && access.write === undefined)) return undefined;\n return access;\n}\n\n/**\n * May this caller receive the column's (or relation's) value?\n *\n * Replaces `canReadField(property, viewer)`.\n *\n * @group Table\n */\nexport function canReadColumn(target: Pick<ColumnDescriptor, \"private\" | \"access\">, viewer: FieldViewer | undefined): boolean {\n return canReadWithAccess(columnAccess(target), viewer);\n}\n\n/**\n * May this caller set the column's (or relation's) value?\n *\n * Replaces `canWriteField(property, viewer)`. The write list is judged by the\n * same predicate as a read list. A `readOnly` column (`.readOnly()`, a\n * generated column — what the lift makes of `access.write: []`) is written by\n * nobody through any API: the database or the server's own stamps fill it.\n *\n * @group Table\n */\nexport function canWriteColumn(target: AccessTarget, viewer: FieldViewer | undefined): boolean {\n if (\"readOnly\" in target && target.readOnly) return false;\n const access = columnAccess(target);\n return canWriteWithAccess(access, viewer);\n}\n\n/**\n * The column a `belongsTo` is bound to on its own table — the declared (or\n * derived) column its `localKey` names — or `undefined` for any other kind, or\n * a link whose key the table does not describe.\n *\n * The two are one fact under two names: `{ reviewer: 7 }` sets the column\n * `{ reviewerId: 7 }` sets, and `?include=reviewer` hands over the value the\n * column holds. So every rule of one is a rule of the other — see\n * {@link canReadRelation} and {@link canWriteRelation}.\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server's OpenAPI generator; not part of the public API.\n */\nexport function boundKeyColumn(table: TableDescriptor, relation: RelationDescriptor): ColumnDescriptor | undefined {\n if (relation.kind !== \"belongsTo\") return undefined;\n return table.columns.find(column => column.key === relation.localField);\n}\n\n/**\n * May this caller be handed the rows of this relation?\n *\n * The relation's own rules, and the rules of every column its join reads\n * ({@link relationJoinColumns}): a relation is exactly as readable as what it\n * is joined on. `?include=handler` embeds the staff row whose key `handlerId`\n * holds; `staff?include=handledCases` groups each case under the staff row\n * that same key points at; a `via` over `handler_id` does both. A caller\n * `handlerId`'s `access.read` withholds may do none of them.\n *\n * `related` resolves the other tables a join passes through (by slug or SQL\n * name). Without it, only this table's join columns are judged — enough for a\n * `belongsTo`, not for a `hasMany` / `hasOne` (whose key is the target's) or a\n * `via` past its first step.\n *\n * @param table - the table that declares the relation.\n * @param relation - one of `table.relations`.\n * @param viewer - the caller; `undefined` is the trusted server plane.\n * @param related - the other tables, by slug or SQL name; pass it whenever the\n * relation may join through another table's columns.\n *\n * @group Table\n */\nexport function canReadRelation(\n table: TableDescriptor,\n relation: RelationDescriptor,\n viewer: FieldViewer | undefined,\n related?: RelatedTables\n): boolean {\n if (!canReadColumn(relation, viewer)) return false;\n return relationJoinColumns(table, relation, related).every(column => canReadColumn(column, viewer));\n}\n\n/**\n * May this caller set this relation?\n *\n * The relation's own rules, and — for a `belongsTo` — its key column's\n * (`.readOnly()`, `.private()`, `access.write`): writing a link by name sets\n * that column, so it is closed exactly when writing the column is.\n *\n * @group Table\n */\nexport function canWriteRelation(table: TableDescriptor, relation: RelationDescriptor, viewer: FieldViewer | undefined): boolean {\n if (!canWriteColumn(relation, viewer)) return false;\n const bound = boundKeyColumn(table, relation);\n return bound === undefined || canWriteColumn(bound, viewer);\n}\n\n/**\n * Whether the API does not have this relation at all: it is `.private()`, or\n * it is a `belongsTo` bound to a `.private()` key column — the link would\n * otherwise put the hidden column back on the surface under another name.\n *\n * @group Table\n */\nexport function isPrivateRelation(table: TableDescriptor, relation: RelationDescriptor, related?: RelatedTables): boolean {\n return relation.private === true || relationJoinColumns(table, relation, related).some(column => column.private === true);\n}\n\n/**\n * Any table's descriptor, by slug or by SQL table name: what a relation's\n * target and a `via` step name. Answers `undefined` for a table it does not\n * know (an implicit junction, a table this caller is not served).\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server and @rebasepro/server-postgres; not part of the public API.\n */\nexport type RelatedTables = (slugOrTable: string) => TableDescriptor | typeof UNSERVED_TABLE | undefined;\n\n/**\n * What a {@link RelatedTables} lookup answers for a table the server does not\n * serve: one it withheld (`TABLE_WITHHELD`), or a name no table of its\n * database has. A `via` whose steps pass through such a table is readable and\n * writable by nobody ({@link relationJoinColumns}): the join would read a\n * table the server refuses everyone, and whose column rules it cannot judge.\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server-postgres; not part of the public API.\n */\nexport const UNSERVED_TABLE: unique symbol = Symbol(\"rebase.unservedTable\");\n\n/**\n * The join column a `via` reads on a table the server does not serve\n * ({@link UNSERVED_TABLE}): closed to every caller, the admin and the trusted\n * plane included, so every gate that judges a relation by its join columns\n * refuses it.\n */\nconst UNSERVED_JOIN_COLUMN: ColumnDescriptor = {\n key: \"\",\n column: \"\",\n type: { kind: \"text\" },\n nullable: true,\n readOnly: true,\n access: PRIVATE_ACCESS\n};\n\n/**\n * The declared columns a relation's join condition reads, on every table it\n * passes through — the one answer every read gate asks:\n *\n * - `belongsTo` — its key column on this table;\n * - `hasMany` / `hasOne` — this table's source key (the primary key unless\n * `sourceKey` says otherwise) and the target's `foreignKey`;\n * - `manyToMany` — this table's and the target's primary keys, and the\n * junction's two link columns when the junction is a declared table;\n * - `via` — every column every step joins on, `from` on the table before the\n * step and `to` on the step's table (a `table.column` spelling names its\n * own table).\n *\n * A column a table does not describe (an implicit key, an implicit junction)\n * has no rules and is not listed; so is a table `related` cannot find. A\n * `via` step (or a `table.column` qualifier) `related` answers\n * {@link UNSERVED_TABLE} for lists a column nobody may read or write: the\n * relation is closed whole.\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server and @rebasepro/server-postgres; not part of the public API.\n */\nexport function relationJoinColumns(table: TableDescriptor, relation: RelationDescriptor, related?: RelatedTables): ColumnDescriptor[] {\n const out: ColumnDescriptor[] = [];\n const add = (on: TableDescriptor | undefined, name: string | undefined): void => {\n if (!on || name === undefined) return;\n const column = on.columns.find(candidate => candidate.column === name || candidate.key === name);\n if (column && !out.includes(column)) out.push(column);\n };\n const target = (): TableDescriptor | undefined => described(related?.(relation.target));\n const primaryKey = (on: TableDescriptor | undefined): void => {\n for (const key of on?.primaryKey ?? []) add(on, key);\n };\n switch (relation.kind) {\n case \"belongsTo\": {\n const bound = boundKeyColumn(table, relation);\n if (bound) out.push(bound);\n break;\n }\n case \"hasMany\":\n case \"hasOne\":\n if (relation.sourceKey !== undefined) add(table, relation.sourceKey);\n else primaryKey(table);\n add(target(), relation.foreignKey);\n break;\n case \"manyToMany\": {\n primaryKey(table);\n const junction = described(related?.(relation.through.table));\n add(junction, relation.through.sourceKey);\n add(junction, relation.through.targetKey);\n primaryKey(target());\n break;\n }\n case \"via\": {\n const tableNamed = (name: string): TableDescriptor | undefined => {\n if (name === table.table || name === table.slug) return table;\n const found = related?.(name);\n if (found === UNSERVED_TABLE) {\n if (!out.includes(UNSERVED_JOIN_COLUMN)) out.push(UNSERVED_JOIN_COLUMN);\n return undefined;\n }\n if (found) return found;\n const end = target();\n return end && end.table === name ? end : undefined;\n };\n let previous: TableDescriptor | undefined = table;\n for (const step of relation.steps) {\n const here = tableNamed(step.table);\n for (const condition of Array.isArray(step.on) ? step.on : [step.on]) {\n for (const name of Array.isArray(condition.from) ? condition.from : [condition.from]) {\n const [qualifier, column] = splitQualified(name);\n add(qualifier === undefined ? previous : tableNamed(qualifier), column);\n }\n for (const name of Array.isArray(condition.to) ? condition.to : [condition.to]) {\n const [qualifier, column] = splitQualified(name);\n add(qualifier === undefined ? here : tableNamed(qualifier), column);\n }\n }\n previous = here;\n }\n break;\n }\n }\n return out;\n}\n\n/**\n * Every table a `via` relation's join passes through, by the name its steps\n * use: each step's table, and each table a `table.column` in a join\n * condition names. In step order, each name once.\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server-postgres; not part of the public API.\n */\nexport function viaJoinTableNames(relation: Extract<RelationDescriptor, { kind: \"via\" }>): string[] {\n const out: string[] = [];\n const add = (name: string | undefined): void => {\n if (name !== undefined && !out.includes(name)) out.push(name);\n };\n for (const step of relation.steps) {\n add(step.table);\n for (const condition of Array.isArray(step.on) ? step.on : [step.on]) {\n for (const name of [condition.from, condition.to].flat()) add(splitQualified(name)[0]);\n }\n }\n return out;\n}\n\n/** A lookup's answer as a descriptor: a table it does not serve has none to judge. */\nfunction described(found: TableDescriptor | typeof UNSERVED_TABLE | undefined): TableDescriptor | undefined {\n return found === UNSERVED_TABLE ? undefined : found;\n}\n\n/** `table.column` as its two parts; a bare column has no table. */\nfunction splitQualified(name: string): [string | undefined, string] {\n const dot = name.lastIndexOf(\".\");\n return dot < 0 ? [undefined, name] : [name.slice(0, dot), name.slice(dot + 1)];\n}\n\n/**\n * Whether any relation of this table joins on a column with access rules —\n * on this table or, through `related`, on the others it passes through. The\n * check a read makes before it judges a relation path at all.\n *\n * @group Table\n *\n * @internal Shared with @rebasepro/server-postgres; not part of the public API.\n */\nexport function hasJoinAccessRules(table: TableDescriptor, related?: RelatedTables): boolean {\n return table.relations.some(relation =>\n relationJoinColumns(table, relation, related).some(column => columnAccess(column) !== undefined));\n}\n\n/**\n * The names on this table a caller may not touch, in both spellings a caller\n * can write them in: `declared` holds column keys and relation names, `refused`\n * those plus the SQL names behind the columns.\n *\n * A column and the `belongsTo` bound to it are one fact under two names, so a\n * restriction on either restricts both: a restricted relation takes its foreign\n * key with it (`bandId: 7` names the band exactly as `band: 7` does), and a\n * restricted key column takes its link with it (`reviewer: 7` sets the\n * `.readOnly()` `reviewerId`; `?include=handler` reads the `access.read`-closed\n * `handlerId`). On a read, a relation is listed when any column its join reads\n * is ({@link relationJoinColumns}; pass `related` to judge the other tables'\n * columns — `staff.handledCases` reads `cases.handlerId`).\n *\n * Replaces `restrictedFieldNames(collection, viewer, kind)`.\n *\n * @group Table\n */\nexport function restrictedKeys(\n table: TableDescriptor,\n viewer: FieldViewer | undefined,\n kind: \"read\" | \"write\",\n related?: RelatedTables\n): { declared: string[]; refused: Set<string> } {\n const allowed = kind === \"read\" ? canReadColumn : canWriteColumn;\n // A write sets a link's own key column alone; a read reads every column\n // the join does.\n return namesWhere(table, target => !allowed(target, viewer), kind === \"read\" ? related ?? NO_RELATED : undefined);\n}\n\n/**\n * The names the API does not have, in every spelling: the private columns,\n * their SQL names, the private relations, the foreign key of a private\n * `belongsTo` and every relation whose join reads a private column (with\n * `related`, on the other tables too). A query naming one is answered as a\n * query naming nothing.\n *\n * Not {@link restrictedKeys}: a column restricted by role is public by name\n * (OpenAPI and MCP describe it); a private one is described nowhere.\n *\n * Replaces `apiHiddenFieldNames(collection)`.\n *\n * @group Table\n */\nexport function apiHiddenKeys(table: TableDescriptor, related?: RelatedTables): Set<string> {\n return namesWhere(table, target => target.private === true, related ?? NO_RELATED).refused;\n}\n\n/** No other table known: a join is judged by this table's columns alone. */\nconst NO_RELATED: RelatedTables = () => undefined;\n\n/**\n * Whether anything on the table restricts a column or relation, either way —\n * the check a per-row strip makes before doing any work.\n *\n * Replaces `hasFieldAccessRules(collection)`.\n *\n * @group Table\n */\nexport function hasColumnAccessRules(table: TableDescriptor): boolean {\n return table.auth !== undefined\n || table.columns.some(column => columnAccess(column) !== undefined)\n || table.relations.some(relation => columnAccess(relation) !== undefined);\n}\n\nfunction namesWhere(\n table: TableDescriptor,\n restricted: (target: AccessTarget) => boolean,\n /** Judge a relation by every column its join reads; absent, by its bound key column alone (a write). */\n joins?: RelatedTables\n): { declared: string[]; refused: Set<string> } {\n const declared: string[] = [];\n const refused = new Set<string>();\n const restrict = (name: string): void => {\n if (!declared.includes(name)) declared.push(name);\n refused.add(name);\n };\n for (const column of table.columns) {\n if (!restricted(column)) continue;\n restrict(column.key);\n refused.add(column.column);\n }\n // The auth table's secrets are closed to every caller, declared or not:\n // auth creates the columns on any auth table and the runtime reads every\n // physical column, so the descriptor alone would serve the ones a table\n // never mentions (see `AUTH_SECRET_NAMES`).\n if (table.auth !== undefined) {\n for (const name of AUTH_SECRET_NAMES) refused.add(name);\n }\n for (const relation of table.relations) {\n const read = joins ? relationJoinColumns(table, relation, joins === NO_RELATED ? undefined : joins) : [boundKeyColumn(table, relation)];\n if (!restricted(relation) && !read.some(column => column !== undefined && restricted(column))) continue;\n restrict(relation.name);\n if (relation.kind === \"belongsTo\") restrictForeignKey(table, relation, restrict, refused);\n }\n return { declared, refused };\n}\n\nfunction restrictForeignKey(\n table: TableDescriptor,\n relation: Extract<RelationDescriptor, { kind: \"belongsTo\" }>,\n restrict: (name: string) => void,\n refused: Set<string>\n): void {\n const column = table.columns.find(candidate => candidate.key === relation.localField);\n restrict(column?.key ?? relation.localField);\n refused.add(relation.localKey);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,SAAS,UAAU,SAAwC,QAA0C;CACjG,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAQ,OAAO;CACrB,IAAI,CAAC,SAAS,MAAM,WAAW,GAAG,OAAO;CACzC,OAAO,MAAM,SAAA,OAAmB,KAAK,QAAQ,MAAK,SAAQ,MAAM,SAAS,IAAI,CAAC;AAClF;;;;;;AAOA,SAAgB,kBAAkB,QAAkD,QAA0C;CAC1H,OAAO,UAAU,QAAQ,MAAM,MAAM;AACzC;;;;;AAMA,SAAgB,mBAAmB,QAAmD,QAA0C;CAC5H,OAAO,UAAU,QAAQ,OAAO,MAAM;AAC1C;;;;AClDA,IAAM,iBAA+B,OAAO,OAAO;CAAE,MAAM,OAAO,OAAO,CAAC,CAAC;CAAG,OAA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ID_HEADER, St as validateScopes, Tt as SIMULATED_CONTEXT_HEADER, ct as intersectScopes, dn as ANONYMOUS_USER_ID, dt as isDataPlaneScope, gt as scopeGrantsAny, ht as scopeGrants, it as EMPTY_ACCESS_MODEL, kt as formatSimulatedContext, mt as roleNameProblem, nt as ADMIN_SCOPES, pt as parseScope, rt as BUILT_IN_SCOPES, st as hasAdminRole, tt as ADMIN_ROLE, vt as scopesBeyond, wt as IMPERSONATE_HEADER, yt as scopesForRoles } from "./src-DLIb1O9l.js";
6
6
  import { a as logger } from "./logger-SigQ2oZJ.js";
7
- import { n as apiHiddenKeys, u as restrictedKeys } from "./access-CCsVee6z.js";
7
+ import { n as apiHiddenKeys, u as restrictedKeys } from "./access-D1CTJSLK.js";
8
8
  import { E as sha256Hex, S as constantTimeEqual, h as processJwtService, m as jwtOf } from "./jwt-JtQiewBW.js";
9
9
  import { a as isDataException, i as errorHandler, l as warnIfDatabaseClosed, o as isDatabaseUnreachable, t as ApiError } from "./errors-DpTMfX77.js";
10
10
  import { a as canonicalStorageId, o as canonicalStorageKey, r as InvalidStorageKeyError } from "./keys-BTPoSvUs.js";
@@ -1789,4 +1789,4 @@ function assertMayGrantRoles(c, roles) {
1789
1789
  //#endregion
1790
1790
  export { supportsRlsScoping as $, isDownloadTokenGrant as A, decideSimulation as B, publicObjectAuth as C, requireAuth as D, requireAdmin as E, applyImpersonation as F, createTusScopeGuard as G, reportSimulatedContext as H, decideImpersonation as I, validateApiKey as J, isApiKeyToken as K, refuseUnhonouredImpersonation as L, requestedStorageObject as M, storageObjectOfPath as N, userFromToken as O, storageRequestWildcard as P, scopeDataDriver as Q, applySimulation as R, optionalAuth as S, refuse as T, createApiKeyPreAuth as U, maskedFieldsFor as V, createFunctionScopeGuard as W, safeCompare as X, extractBearerToken as Y, SERVICE_IDENTITY as Z, setDefaultAccessControl as _, assertMayManageAccount as a, refuseSimulatedWrite as at, extractUserFromToken as b, configureAccess as c, keyOwnerResolverFor as d, accessTokenRefusalError as et, processAccessControl as f, scopeMissing as g, requireScopeByMethod as h, assertMayGrantRoles as i, revokeAllSessions as it, isPublicObjectGrant as j, PUBLIC_OBJECT_PRINCIPAL as k, getAccessModel as l, requireScope as m, accessModelFromAuthTable as n, judgeAccessToken as nt, callerIsAdmin as o, httpMethodToOperation as ot, readRoleNames as p, resolveApiKey as q, accessOf as r, replaceUserPassword as rt, callerScopes as s, AccessModelError as t, isAccessTokenRevoked as tt, hasScope as u, createAuthMiddleware as v, queryTokenAuth as w, fileTokenAuth as x, createRequireAuth as y, callerOf$1 as z };
1791
1791
 
1792
- //# sourceMappingURL=access-CSfmyM87.js.map
1792
+ //# sourceMappingURL=access-Dtu87BMj.js.map