@somewhere-cloud/cli 0.38.137 → 0.38.139

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.
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.137",
3
+ "version": "0.38.139",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.137",
9
+ "version": "0.38.139",
10
10
  "license": "MIT",
11
11
  "bin": {
12
- "cli": "bin/somewhere.js",
13
12
  "somewhere": "bin/somewhere.js",
14
13
  "sw": "bin/somewhere.js"
15
14
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.137",
3
+ "version": "0.38.139",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",
@@ -21,7 +21,6 @@
21
21
  },
22
22
  "type": "module",
23
23
  "bin": {
24
- "cli": "bin/somewhere.js",
25
24
  "somewhere": "bin/somewhere.js",
26
25
  "sw": "bin/somewhere.js"
27
26
  },
@@ -67,5 +66,5 @@
67
66
  },
68
67
  "bundleDependencies": [],
69
68
  "bundledDependencies": [],
70
- "gitHead": "b2275a6b1f015916b109866b11d381fd9bc41c52"
69
+ "gitHead": "bf41a4d553376d6863ab26507b5e913b0fdfa368"
71
70
  }
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "esbuild": "0.24.0",
3
3
  "source_files": {
4
- "shared/app-model-catalog.ts": "6c3bdb81fd45c298cc4404e4891c2b465895bbb18ccabdc149c9eb39d79b1101",
4
+ "shared/app-model-catalog.ts": "1cb77b922c8ea3d2d85f100b087c538684eedc440e8cdf15b77e5704d8759376",
5
5
  "shared/cloud-dev-entitlement.ts": "1993a9e1c781d9daed29b3cfef0e8a370e150ce06d2acc7c408c2a24c50b4960",
6
6
  "shared/d1-region.ts": "71cda96cfead241b4f4e35b8cd6b1d8e577f072257e91a8dbe0deaa1b142b378",
7
7
  "shared/d1-session.ts": "2ae29b74bba68016c86d25fa2a58f8c2fce4aca8fe57fafc253d380c47a3c0ab",
8
8
  "shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
9
9
  "shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
10
10
  "worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
11
- "worker/containers/compile/consumer-contract.cjs": "5cbf5ee0c4a936b9bce6b62d0f27bf7729126d47d02a3cd3a0ff28db86dfd987",
11
+ "worker/containers/compile/consumer-contract.cjs": "4d4aeba51e4b65543bba54f5e026a9e5905ef717a2e623fe7d6327d2d5d81565",
12
12
  "worker/containers/compile/declared-data-contract.cjs": "1261275ab4ff75b3001456a30b041a7c639578ffff0b67b42706d7b0ff11d744",
13
13
  "worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
14
14
  "worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
15
15
  "worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
16
- "worker/containers/compile/runtime-types.cjs": "9f2633dcca852c35bc20147bbb260d2c79969da33668f2bd9b1f5bbfcf21bc7f",
17
- "worker/containers/compile/schema-types.cjs": "4cd8d79a9401271bcb948865069b90d3d5f13a10c96c51cb084e22e63cbb57d8",
16
+ "worker/containers/compile/runtime-types.cjs": "388596318b94236bf76634e935fb763676a4156f4aa93f9ec952fd42f66f8d29",
17
+ "worker/containers/compile/schema-types.cjs": "6bd92695cd275b0c6bc7dc79daaf3189fb275449321342c967a2030f287cfdfa",
18
18
  "worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
19
19
  "worker/containers/compile/typed-files.cjs": "f2568567a53994575ede91f9a0839965e64f94eb92ae11315650189b6de0f79c",
20
20
  "worker/node_modules/entities/dist/decode-codepoint.js": "f09dbc23d35abbf96718dfdd04def3c1d3444495541d050c69a12706ee76dbb1",
@@ -41,7 +41,7 @@
41
41
  "worker/src/utils/db-schema-deploy/bigint-text.ts": "ef3f581daeecb234d2c1e288bc09495a6facd7b0354b300134918f6c0cf10cc2",
42
42
  "worker/src/utils/db-schema-deploy/client-contract-source.ts": "b0a3b5e6e32a3269e6911c4f5c90d93457d8d93d5486678a9be082049f937be8",
43
43
  "worker/src/utils/db-schema-deploy/client-permissions.ts": "3db42f781ca6bb4f763a33be9470d43d74c58c7d3339a46d1271689d5100b64e",
44
- "worker/src/utils/db-schema-deploy/extract-schema-app-roles.ts": "3c410e107c8770f296d153caefd25932fbef8b0509a09c33851ee3009ba7a5f8",
44
+ "worker/src/utils/db-schema-deploy/extract-schema-app-roles.ts": "04e2b1b92838c38085283c9b1983c6911b96afecdb33d2c07b68d256d951dfe8",
45
45
  "worker/src/utils/db-schema-deploy/extract-schema-bindings.ts": "f323bb7d4f27b74270bccfe7e3e14e7d3b00d8464ca7a42ea726eae8ca208c7d",
46
46
  "worker/src/utils/db-schema-deploy/extract-schema-column-rules.ts": "736cf931d3e98e51a00337e359859396a39e95f154520ad9d97fd541f3ebc4a1",
47
47
  "worker/src/utils/db-schema-deploy/extract-schema-files.ts": "00bea24e28a90d1deff83bab4ca92f5e17929281b4f63c3617d95b38f4384677",
@@ -53,14 +53,14 @@
53
53
  "worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
54
54
  "worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
55
55
  "worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
56
- "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "c8ceb60bd384e8e0afea958eacb19ed224290786abaa61712adf238ee4738f83",
56
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "e84d3dd48731e6b6dbb2cfa33006aab1e420059d7a67e863941d62ade3ca8167",
57
57
  "worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
58
58
  "worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
59
59
  "worker/src/utils/dev-health-class.ts": "fd430f31b9c8469f3d90e118fd8c75d1836ebcf705c1f9e93915ffa53a4cb066",
60
60
  "worker/src/utils/errors.ts": "f9d22810c285d2a512d258853bdd17cf9c1445c3983d51f3adbbcede273ac07d",
61
61
  "worker/src/utils/event-log.ts": "1f878064deef5ca490b7b84bed9c1fc50a8b7fc84b3d55a9eeada86f570e37b0",
62
- "worker/src/utils/feed-kinds.ts": "b7315ca703ce08b8c796033d2e91039580fcc4cf3d43be06599f2baaa86334f0",
63
- "worker/src/utils/journey-segment.ts": "7b73ff51d30d904d4588aede4fe6cb83e0bf4adc6bab47bc644b979e6a933e95",
62
+ "worker/src/utils/feed-kinds.ts": "9fca06b277f02324444fee2cc267d03811707e262232382d5b5e40d9035d2def",
63
+ "worker/src/utils/journey-segment.ts": "fc92c196b5368a2aa07b205d12b1bf4344e8d5dcde875c66400b79729207ad96",
64
64
  "worker/src/utils/json-exact-integers.ts": "e2eb8d3b2e17da363eb14fb46d876208579e2e92bfac173fb27527e6c4fb575e",
65
65
  "worker/src/utils/log-sanitize.ts": "f4591089c16a34e4cbc271ec22b48566b970a62e30d3e9856b7dcd9c479fb0e8",
66
66
  "worker/src/utils/managed-groups/errors.ts": "18d952edd7f46bb7e459d4e6678226f4bd6e040ab40073ee5a8d0802be2f3721",
@@ -73,5 +73,5 @@
73
73
  "worker/src/utils/telegram.ts": "dfbc9e756b44b445b3c3504c90a1094a94e6f9853ff9c0e0a84fba0e8c4518da",
74
74
  "worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
75
75
  },
76
- "sha256": "5752380cef1c84e07eda378872a79119e01f051c8a331ce1d384d3e1818c18c7"
76
+ "sha256": "1e90ceb52d16c135e1e1dd8864d7c098f53cbfee9d08b775add70f47ac5ef988"
77
77
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "sha256": "bc86fb6c013c3f890053c6f9a1eb9bac31fac41e5381a43422d7e85127b8436c"
2
+ "sha256": "b91dc8dd58f9666ee0f10cc6eb47a5c144a3d6906302239d9c900c64bb5178d1"
3
3
  }
@@ -13,7 +13,7 @@
13
13
  "worker/src/utils/authority/role-domain-map.ts": "dc1b6abba79278a970cc5a07c4eb7ea73acac262425b489670e90508b95a5ff1",
14
14
  "worker/src/utils/db-schema-deploy/bigint-text.ts": "ef3f581daeecb234d2c1e288bc09495a6facd7b0354b300134918f6c0cf10cc2",
15
15
  "worker/src/utils/db-schema-deploy/client-permissions.ts": "3db42f781ca6bb4f763a33be9470d43d74c58c7d3339a46d1271689d5100b64e",
16
- "worker/src/utils/db-schema-deploy/extract-schema-app-roles.ts": "3c410e107c8770f296d153caefd25932fbef8b0509a09c33851ee3009ba7a5f8",
16
+ "worker/src/utils/db-schema-deploy/extract-schema-app-roles.ts": "04e2b1b92838c38085283c9b1983c6911b96afecdb33d2c07b68d256d951dfe8",
17
17
  "worker/src/utils/db-schema-deploy/extract-schema-bindings.ts": "f323bb7d4f27b74270bccfe7e3e14e7d3b00d8464ca7a42ea726eae8ca208c7d",
18
18
  "worker/src/utils/db-schema-deploy/extract-schema-column-rules.ts": "736cf931d3e98e51a00337e359859396a39e95f154520ad9d97fd541f3ebc4a1",
19
19
  "worker/src/utils/db-schema-deploy/extract-schema-files.ts": "00bea24e28a90d1deff83bab4ca92f5e17929281b4f63c3617d95b38f4384677",
@@ -25,7 +25,7 @@
25
25
  "worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
26
26
  "worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
27
27
  "worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
28
- "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "c8ceb60bd384e8e0afea958eacb19ed224290786abaa61712adf238ee4738f83",
28
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "e84d3dd48731e6b6dbb2cfa33006aab1e420059d7a67e863941d62ade3ca8167",
29
29
  "worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
30
30
  "worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
31
31
  "worker/src/utils/deploy-classify.ts": "d565b3c1d7628932ba69a1d93a82364319b66cfed1147b8639fff567a1e63b88",
@@ -33,6 +33,6 @@
33
33
  "worker/src/utils/managed-groups/errors.ts": "18d952edd7f46bb7e459d4e6678226f4bd6e040ab40073ee5a8d0802be2f3721",
34
34
  "worker/src/utils/managed-groups/policy.ts": "2c5b48479a2925bea9a820022c63ca5fa827e2ff5531fe1ab6c0b058b7212b39"
35
35
  },
36
- "sha256": "a832caef3d73433a23322539b3bd5490748e072311278ebbbb36d55610b0ffd5",
36
+ "sha256": "b8175e05ebb059ff4c0d4b06bdbad78e6111901987e15e06c9101f24741c64c3",
37
37
  "fixtures_sha256": "908827d1430f4af5a83cae59ed476abc51dc9648757eac0089fe6e6db95f66c5"
38
38
  }
@@ -1407,6 +1407,8 @@ interface SomewhereAuthProfileUser extends SomewhereAuthUser {
1407
1407
  locale?: string | null;
1408
1408
  timezone?: string | null;
1409
1409
  agent?: SomewhereJsonObject;
1410
+ /** True when this user is the app's owner: their verified email is the project owner's (appOwner() in db/schema.ts). */
1411
+ is_owner: boolean;
1410
1412
  /** Present when read with { appRoles: true }: the caller's own app-role names, read fresh. */
1411
1413
  appRoles?: string[];
1412
1414
  }
@@ -3932,6 +3934,8 @@ interface SomewhereEndpointUser {
3932
3934
  email?: string | null;
3933
3935
  display_name?: string | null;
3934
3936
  role?: string;
3937
+ /** True when the caller is the app's owner: their verified email is the project owner's. */
3938
+ is_owner: boolean;
3935
3939
  /** The caller's own app roles, read fresh for this request. Present on an endpoint that declares roles. */
3936
3940
  appRoles?: string[];
3937
3941
  [key: string]: unknown;
@@ -4288,6 +4292,8 @@ function allOf(gate: SomewhereSchemaDeclaration.MemberScope | SomewhereSchemaDec
4288
4292
  function parent(options: { via: string; table?: string; author?: string; update?: Array<'author' | 'parent'>; delete?: Array<'author' | 'parent'> }): SomewhereSchemaDeclaration.Scope;
4289
4293
  function group(options?: { column?: string; roles?: Partial<Record<'read' | 'create' | 'update' | 'delete', string[]>>; read?: string[] }): SomewhereSchemaDeclaration.GroupScope;
4290
4294
  function appRole(options: { roles: Partial<Record<'read' | 'create' | 'update' | 'delete', string[]>>; read?: string[] }): SomewhereSchemaDeclaration.AppRoleScope;
4295
+ /** The app's owner: the signed-in user whose verified email is the project owner's. Reads, creates, updates and deletes every row. */
4296
+ function appOwner(): SomewhereSchemaDeclaration.AppRoleScope;
4291
4297
  `;
4292
4298
  var SCHEMA_DECLARATION2 = types + signatures.replace(/^function /gm, "declare function ") + `declare module 'somewhere/db' {
4293
4299
  ${(signatures + policySignatures).replace(/^function /gm, " export function ")}}
@@ -4465,8 +4471,8 @@ var require_consumer_contract = __commonJS({
4465
4471
  "worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
4466
4472
  "use strict";
4467
4473
  var CONSUMER_CONTRACT2 = Object.freeze({
4468
- version: 28,
4469
- digest: "e4a7b324f259d0bc92b20434ff153cdfadebf865dd96dfa3e19e8b9811d43692"
4474
+ version: 30,
4475
+ digest: "6b27b36b315bece1e2cd83950720930286ed19b8858b7e8cd8f5f5bf7566797b"
4470
4476
  });
4471
4477
  var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
4472
4478
  var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
@@ -6748,6 +6754,23 @@ function readAppRoleScope(r, tableName, line, fail) {
6748
6754
  declaredLines.set(node, { line, names });
6749
6755
  return node;
6750
6756
  }
6757
+ var APP_OWNER_ROLE_NAME = "app_owner";
6758
+ function readAppOwnerScope(r, tableName, line, fail) {
6759
+ r.expectPunct("(", 'after "appOwner"');
6760
+ if (!r.tryPunct(")")) fail(line, `appOwner() on table "${tableName}" takes no options: the app's owner may read, create, update and delete every row.`);
6761
+ const all = [APP_OWNER_ROLE_NAME];
6762
+ return { kind: "app_role", roles: { read: [...all], create: [...all], update: [...all], delete: [...all] } };
6763
+ }
6764
+ function usesAppOwner(tables) {
6765
+ const visit = (value) => {
6766
+ if (!value || typeof value !== "object") return false;
6767
+ if (Array.isArray(value)) return value.some(visit);
6768
+ const node = value;
6769
+ if (node.kind === "app_role" && node.roles && APP_ROLE_OPERATIONS.some((op) => Array.isArray(node.roles[op]) && node.roles[op].includes(APP_OWNER_ROLE_NAME))) return true;
6770
+ return Object.values(value).some(visit);
6771
+ };
6772
+ return tables.some((t) => visit(t.scope));
6773
+ }
6751
6774
  function resolveAppRoleScopes(tables, appRoles, errors) {
6752
6775
  const vocabulary = new Set((appRoles ?? []).map((role) => role.name));
6753
6776
  for (const t of tables) {
@@ -7172,7 +7195,7 @@ var COLUMN_HELPERS = new Set([
7172
7195
  "json",
7173
7196
  "blob"
7174
7197
  ]);
7175
- var SCOPE_HELPERS = new Set(["owner", "shared", "serverOnly", "member", "anyOf", "allOf", "parent", "group", "appRole"]);
7198
+ var SCOPE_HELPERS = new Set(["owner", "shared", "serverOnly", "member", "anyOf", "allOf", "parent", "group", "appRole", "appOwner"]);
7176
7199
  var TABLE_MARKER_HELPERS = new Set(["removedTable", "exported"]);
7177
7200
  var SCHEMA_CALLABLE = new Set([
7178
7201
  ...COLUMN_HELPERS,
@@ -7778,6 +7801,7 @@ function readAnyOfBranch(r, tableName, which) {
7778
7801
  if (tok.value === "grant") return readGrantScope(r, tableName, tok.line, failAt);
7779
7802
  if (tok.value === "group") return readGroupScope(r, tableName, tok.line, failAt);
7780
7803
  if (tok.value === "appRole") return readAppRoleScope(r, tableName, tok.line, failAt);
7804
+ if (tok.value === "appOwner") return readAppOwnerScope(r, tableName, tok.line, failAt);
7781
7805
  throw new SchemaTsError(`line ${tok.line}: ${ANY_OF_FORMS}`);
7782
7806
  }
7783
7807
  function readAnyOfScope(r, tableName, line) {
@@ -7824,6 +7848,7 @@ function readAllOfScope(r, tableName, line) {
7824
7848
  if (gateTok.value === "member") gate = readPolicyMember(r, tableName, gateTok.line);
7825
7849
  else if (gateTok.value === "group") gate = readGroupScope(r, tableName, gateTok.line, failAt);
7826
7850
  else if (gateTok.value === "appRole") gate = readAppRoleScope(r, tableName, gateTok.line, failAt);
7851
+ else if (gateTok.value === "appOwner") gate = readAppOwnerScope(r, tableName, gateTok.line, failAt);
7827
7852
  else throw new SchemaTsError(`line ${gateTok.line}: ${ALL_OF_FORMS}`);
7828
7853
  r.expectPunct(",", `between the gate and who in allOf() on table "${tableName}"`);
7829
7854
  const whoTok = r.expectIdent(`for who in allOf() on table "${tableName}"`);
@@ -7960,7 +7985,7 @@ function readScope(r, tableName) {
7960
7985
  const tok = r.expectIdent(`for the scope of table "${tableName}"`);
7961
7986
  if (!SCOPE_HELPERS.has(tok.value)) {
7962
7987
  throw new SchemaTsError(
7963
- `line ${tok.line}: unknown scope "${tok.value}" on table "${tableName}". Table scopes are owner(), group(), appRole(), member(), anyOf(), allOf(), parent(), shared(), and serverOnly().`
7988
+ `line ${tok.line}: unknown scope "${tok.value}" on table "${tableName}". Table scopes are owner(), group(), appRole(), appOwner(), member(), anyOf(), allOf(), parent(), shared(), and serverOnly().`
7964
7989
  );
7965
7990
  }
7966
7991
  if (tok.value === "anyOf") return readAnyOfScope(r, tableName, tok.line);
@@ -7969,8 +7994,8 @@ function readScope(r, tableName) {
7969
7994
  const failAt = (line, message) => {
7970
7995
  throw new SchemaTsError(`line ${line}: ${message}`);
7971
7996
  };
7972
- if (tok.value === "group" || tok.value === "appRole") {
7973
- const policy = tok.value === "group" ? readGroupScope(r, tableName, tok.line, failAt) : readAppRoleScope(r, tableName, tok.line, failAt);
7997
+ if (tok.value === "group" || tok.value === "appRole" || tok.value === "appOwner") {
7998
+ const policy = tok.value === "group" ? readGroupScope(r, tableName, tok.line, failAt) : tok.value === "appOwner" ? readAppOwnerScope(r, tableName, tok.line, failAt) : readAppRoleScope(r, tableName, tok.line, failAt);
7974
7999
  refuseBranchRead(policy, tok.line, tableName, `the ${tok.value}() scope`);
7975
8000
  return { kind: "policy", policy };
7976
8001
  }
@@ -8368,7 +8393,13 @@ function extractSchemaTs(source, options = {}) {
8368
8393
  const fail = (line, message) => {
8369
8394
  throw new SchemaTsError(`line ${line}: ${message}`);
8370
8395
  };
8371
- const { managedSearch, fileCollections, groupRoles, appRoles, payments, jobs, serviceRoles } = readSchemaOptions(reader, fail, fileErrors);
8396
+ const { managedSearch, fileCollections, groupRoles, appRoles: declaredAppRoles, payments, jobs, serviceRoles } = readSchemaOptions(reader, fail, fileErrors);
8397
+ const appOwnerErrors = [];
8398
+ for (const role of declaredAppRoles ?? []) {
8399
+ if (role.name === APP_OWNER_ROLE_NAME) appOwnerErrors.push(`appRoles declares "${APP_OWNER_ROLE_NAME}", which is built in: use appOwner() in a table's scope for the app's owner.`);
8400
+ if (role.grantableBy.includes(APP_OWNER_ROLE_NAME)) appOwnerErrors.push(`appRoles.${role.name}.grantableBy names "${APP_OWNER_ROLE_NAME}". The app's owner holds no grant, so it cannot be a grantor; grant from a function that checks user.is_owner instead.`);
8401
+ }
8402
+ const appRoles = !appOwnerErrors.length && usesAppOwner(tables) ? [...declaredAppRoles ?? [], { name: APP_OWNER_ROLE_NAME, grantableBy: [] }].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0) : declaredAppRoles;
8372
8403
  reader.expectPunct(")", "closing schema(\u2026)");
8373
8404
  reader.tryPunct(";");
8374
8405
  if (!reader.atEof()) {
@@ -8382,7 +8413,7 @@ function extractSchemaTs(source, options = {}) {
8382
8413
  if (tables.length > MAX_TABLES) {
8383
8414
  return { ok: false, errors: [`db/schema.ts declares ${tables.length} tables (max ${MAX_TABLES}).`] };
8384
8415
  }
8385
- const errors = [];
8416
+ const errors = [...appOwnerErrors];
8386
8417
  const names = new Set(tables.map((t) => t.name));
8387
8418
  for (const t of tables) {
8388
8419
  for (const c of t.columns) {