@somewhere-cloud/cli 0.38.161 → 0.38.162

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,14 +1,5 @@
1
1
  import { loadEntry } from "./bundle.js";
2
2
  const entry = loadEntry("lib/declared-data.js");
3
3
  export const { DATA_DECLARATION_FILE, DATA_MODULE, DATA_VIRTUAL_ID, FILES_DECLARATION_FILE, GENERATED_DATA_HEADER, declaredDataPlugin, localFilesContract, prepareDeclaredData } = entry;
4
- const SW_ENDPOINT_GLOBAL = `declare const sw: {
5
- // docs({ topic: 'sw.endpoint' }). Throw an Error with .status and .code
6
- // for a typed error response; anything else is 500 HANDLER_ERROR.
7
- // Roles imply a signed-in caller: with roles and auth left out, the user is typed as signed in.
8
- endpoint<const Schema extends SomewhereEndpointBodySchema | undefined = undefined, Auth extends SomewhereEndpointAuth = 'none',
9
- const Roles extends readonly string[] | undefined = undefined>(
10
- config: SomewhereEndpointConfig<[Roles] extends [readonly string[]] ? ([Auth] extends ['none'] ? 'required' : Auth) : Auth, Schema>
11
- & { auth?: Auth; roles?: Roles },
12
- ): (req: Request, sw: SomewhereRuntimeContext) => Promise<Response>;
13
- };
4
+ const SW_ENDPOINT_GLOBAL = `declare const sw: SomewhereEndpointGlobal;
14
5
  `;
@@ -2,6 +2,11 @@ import { type FilesRequest } from './test-files.js';
2
2
  import { type TestTarget } from './test-target.js';
3
3
  import { type PlaywrightStorageState } from './test-identities.js';
4
4
  export declare function managedFileSession(session: UserSession, root: string, userId: string): void;
5
+ type RefusalControl = {
6
+ allowed?: UserSession | {
7
+ session: UserSession;
8
+ };
9
+ };
5
10
  export declare class UserSession {
6
11
  readonly origin: string;
7
12
  private cookies;
@@ -21,12 +26,8 @@ export declare class UserSession {
21
26
  post(path: string, body: unknown): Promise<Response>;
22
27
  /** Prove a refusal against a table or a METHOD /path endpoint. Use an allowed session
23
28
  * as the positive control for hidden rows or a 404. */
24
- expectRefused(table: string, request: DataRequest, options?: {
25
- allowed?: UserSession;
26
- }): Promise<void>;
27
- expectRefused(endpoint: `${string} /${string}`, body?: unknown, options?: {
28
- allowed?: UserSession;
29
- }): Promise<void>;
29
+ expectRefused(table: string, request: DataRequest, options?: RefusalControl): Promise<void>;
30
+ expectRefused(endpoint: `${string} /${string}`, body?: unknown, options?: RefusalControl): Promise<void>;
30
31
  /** Exercise the declared file door as a managed test user. */
31
32
  files(collection: string, request: FilesRequest): Promise<Response>;
32
33
  /** Use this session's cookies and the linked app's declared data contract. */
@@ -53,3 +54,4 @@ export declare function expectStatus(response: Response, expected: number): Prom
53
54
  export declare function expectRefusal(response: Response, status: 401 | 403, code: string): Promise<void>;
54
55
  export declare function signIn(baseUrl: string, email: string, password: string): Promise<UserSession>;
55
56
  export declare function createUser(baseUrl: string): Promise<UserSession>;
57
+ export {};
@@ -13,6 +13,7 @@ export interface TestApp {
13
13
  origin: string;
14
14
  anonymous: UserSession;
15
15
  users(count: number): Promise<TestActor[]>;
16
+ inboxAddress(name?: string): string;
16
17
  testInbox(email: string): Promise<TestInboxMessage[]>;
17
18
  signInWithLink(url: string): Promise<TestActor>;
18
19
  create(user: TestActor, table: string, values: Record<string, unknown>, key?: string): Promise<string | number>;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.161",
3
+ "version": "0.38.162",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.161",
9
+ "version": "0.38.162",
10
10
  "license": "MIT",
11
11
  "bin": {
12
12
  "somewhere": "bin/somewhere.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.161",
3
+ "version": "0.38.162",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",
@@ -67,5 +67,5 @@
67
67
  },
68
68
  "bundleDependencies": [],
69
69
  "bundledDependencies": [],
70
- "gitHead": "e44d906c70477d45fe053834fb9ef529487ee121"
70
+ "gitHead": "8be06a131526985ded5c3b0155a6c0126d8c086e"
71
71
  }
@@ -1,20 +1,20 @@
1
1
  {
2
- "source_commit": "c49f40389a7e5789f3fafd2467e0c5e9d55f201b",
2
+ "source_commit": "c28e5e9391b22cb870687d160eae0e64ff344ffe",
3
3
  "esbuild": "0.24.0",
4
4
  "source_files": {
5
5
  "shared/app-model-catalog.ts": "c9a0119366beabb10157fcc9866f4d32b320b680f1c5717d837a5ca99875fa13",
6
6
  "shared/cloud-dev-entitlement.ts": "1993a9e1c781d9daed29b3cfef0e8a370e150ce06d2acc7c408c2a24c50b4960",
7
7
  "shared/d1-region.ts": "71cda96cfead241b4f4e35b8cd6b1d8e577f072257e91a8dbe0deaa1b142b378",
8
8
  "shared/d1-session.ts": "2ae29b74bba68016c86d25fa2a58f8c2fce4aca8fe57fafc253d380c47a3c0ab",
9
- "shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
9
+ "shared/transient-read.ts": "7c10de219ee4b910cb2e35d9aeb7a0974ae3eeaeea7c4b5983b89f3c403db1cb",
10
10
  "shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
11
- "worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
12
- "worker/containers/compile/consumer-contract.cjs": "d3c526407fa492b41048472fda63343e1e0af14ec9127815af3f58b461f9a96f",
11
+ "worker/containers/compile/checker-contract.cjs": "732cb5a886548f91499031fc1f0727ae05e824ab8d482693f2ad04de4868595b",
12
+ "worker/containers/compile/consumer-contract.cjs": "068b92efb226e74af8979557c7dc2b7f06787efb151f74c7593b0525995c8baa",
13
13
  "worker/containers/compile/declared-data-contract.cjs": "ebdc7dbc12283a7218c28e0e912e736ac27a8e9d513b82c097ebff6df3c1dd91",
14
14
  "worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
15
15
  "worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
16
- "worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
17
- "worker/containers/compile/runtime-types.cjs": "5866b2cb5e0d95a2f8779f90a9e981ec30070482bf3f595f6ec2f78d8e3ea382",
16
+ "worker/containers/compile/groups-types.cjs": "7681d2adf0c7761a4971d7ba8287b238e464fd2768c878477e32794538675b33",
17
+ "worker/containers/compile/runtime-types.cjs": "a952608ea438a616bd21b444c5f0681abf3c2e3308df287065c72464ca2e7e6f",
18
18
  "worker/containers/compile/schema-types.cjs": "806147ad7224356734020c62441123db16b50ef6456db974c573b226d517e6cc",
19
19
  "worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
20
20
  "worker/containers/compile/typed-files.cjs": "f2568567a53994575ede91f9a0839965e64f94eb92ae11315650189b6de0f79c",
@@ -33,7 +33,7 @@
33
33
  "worker/src/services/jobs/limits.ts": "2d0d73de8752ad4fb84d281bac6c3049bb34a7d0b08c7cda76634c19c303c529",
34
34
  "worker/src/utils/alert-audit.ts": "318ce8cd45954f50a77bf0782efa4cc433016e923431e3a4042d2294f31610f8",
35
35
  "worker/src/utils/alert-streak.ts": "cc15ff03920821cb4b2c6758fdd29508b24b29f258287e977c23a8ae28c14cbd",
36
- "worker/src/utils/authority.ts": "e757b33b6467698d59670b565b57c916a02ad6e21a8463f416f1771702097b36",
36
+ "worker/src/utils/authority.ts": "71b7605de8bdb32229f24a7cde42d6f253d4e2f7ae7e6d772f1179dfaf1c8c10",
37
37
  "worker/src/utils/authority/client-contract-schema.ts": "c1b433d2b09d7c1e98adae70b5754fe704fabb2ecc8e20347518a633e31f99d0",
38
38
  "worker/src/utils/authority/intake-bake.ts": "7216e288e40673819295d999b3bdbf5e4319e1e21608e3b81eda9d102ff8d636",
39
39
  "worker/src/utils/authority/role-domain-map.ts": "dc1b6abba79278a970cc5a07c4eb7ea73acac262425b489670e90508b95a5ff1",
@@ -69,10 +69,10 @@
69
69
  "worker/src/utils/platform-compile-failure.ts": "eb4cea8a54599e2ca852b67f576a4402fb0281da4c7f45a7ed735bc36a684883",
70
70
  "worker/src/utils/project-custom-hosts.ts": "ef693b4ea70f93fd66f3b3cda88ce68664540366caa33fa0169bf7bcfce80b2a",
71
71
  "worker/src/utils/public-urls.ts": "44e455118f85c111316f6d8346d61e736ffcd1971c4539ea146100084aa6f21e",
72
- "worker/src/utils/reference-check-inputs.ts": "32f01f67fd971cf526af13385fbe6ae3d7876d0d15c4e8098069203eefa5e22e",
72
+ "worker/src/utils/reference-check-inputs.ts": "5ce10ee8feb59a7f31878243a6a4899d41f4e60e7af0687399693aeab7914b9a",
73
73
  "worker/src/utils/telegram-attempt-receipts.ts": "a9ba55ae71f63ada44a105f1ceae04b0491bda0d6e77e5762db2dbecdd2981dd",
74
74
  "worker/src/utils/telegram.ts": "9aaaa2597c366da1eeee9e2252e9b73e611ea97ed9558f7e07e694d9b393f053",
75
75
  "worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
76
76
  },
77
- "sha256": "707f1cbb28d25f458c8d6938d00e6a45c8a8838d6e303dde2d326f842bed3320"
77
+ "sha256": "bb7edd3ef9072fe1592f11bf8072e6d1fba6b9b8fd860db8e026cdcb7b64cbe8"
78
78
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "sha256": "37e114576bc4188cfc2335171afd96d20f497fd24dffee3980bdb15781816a68"
2
+ "sha256": "7a4000e22e1b52be006384bed8cc384e38b5126714790eb591b3bcc47d077789"
3
3
  }
@@ -886,6 +886,8 @@ var require_groups_types = __commonJS({
886
886
  const appRoles = (roles.appRoles || []).length ? literal(roles.appRoles) : "never";
887
887
  return `
888
888
  type SomewhereGroupRole = ${groupRoles};
889
+ // These methods validate role strings at runtime. Keep the known names in completions.
890
+ type SomewhereGroupRoleInput = SomewhereGroupRole | (string & {});
889
891
  type SomewhereAppRole = ${appRoles};
890
892
 
891
893
  interface SomewhereGroup {
@@ -1005,7 +1007,7 @@ interface SomewhereGroups {
1005
1007
  * that verified email (the link, or any sign-in). The answer is the same in
1006
1008
  * every case; no app call is needed. Inviting an address that already has a
1007
1009
  * pending invitation sends nothing. */
1008
- invite(req: Request, groupId: string, input: { email: string; role: SomewhereGroupRole; redirect_uri: string; expires_in?: number }): Promise<SomewhereGroupsResult<SomewhereGroupInvitation>>;
1010
+ invite(req: Request, groupId: string, input: { email: string; role: SomewhereGroupRoleInput; redirect_uri: string; expires_in?: number }): Promise<SomewhereGroupsResult<SomewhereGroupInvitation>>;
1009
1011
  /** Pending invitations of one group (oldest first) that the signed-in member could revoke:
1010
1012
  * ones they sent, and ones whose role they may grant. A non-member gets GROUP_NOT_FOUND. */
1011
1013
  invitations(req: Request, groupId: string, opts?: SomewhereGroupsPageOptions): Promise<SomewhereGroupsResult<SomewhereGroupsPage<SomewhereGroupPendingInvitation>>>;
@@ -1013,9 +1015,9 @@ interface SomewhereGroups {
1013
1015
  revokeInvitation(req: Request, inviteId: string): Promise<SomewhereGroupsResult<{ revoked: true }>>;
1014
1016
  leave(req: Request, groupId: string): Promise<SomewhereGroupsResult<{ left: true }>>;
1015
1017
  delete(req: Request, groupId: string): Promise<SomewhereGroupsResult<{ deleted: true }>>;
1016
- add(req: Request, groupId: string, userId: string, role: SomewhereGroupRole): Promise<SomewhereGroupsResult<{ user_id: string; role: SomewhereGroupRole }>>;
1018
+ add(req: Request, groupId: string, userId: string, role: SomewhereGroupRoleInput): Promise<SomewhereGroupsResult<{ user_id: string; role: SomewhereGroupRole }>>;
1017
1019
  remove(req: Request, groupId: string, userId: string): Promise<SomewhereGroupsResult<{ removed: true }>>;
1018
- setRole(req: Request, groupId: string, userId: string, role: SomewhereGroupRole): Promise<SomewhereGroupsResult<{ user_id: string; role: SomewhereGroupRole }>>;
1020
+ setRole(req: Request, groupId: string, userId: string, role: SomewhereGroupRoleInput): Promise<SomewhereGroupsResult<{ user_id: string; role: SomewhereGroupRole }>>;
1019
1021
  appRoles: {
1020
1022
  list(req: Request, userId?: string, opts?: SomewhereGroupsPageOptions): Promise<SomewhereGroupsResult<SomewhereGroupsPage<SomewhereAppRoleGrant>>>;
1021
1023
  grant(req: Request, userId: string, role: SomewhereAppRole): Promise<SomewhereGroupsResult<SomewhereAppRoleGrant>>;
@@ -3247,6 +3249,7 @@ interface SomewhereEmailSendResult {
3247
3249
  // A new send is 'sent' | 'pending' | 'captured'; a duplicate replays the stored state.
3248
3250
  status: SomewhereEmailStatus;
3249
3251
  duplicate?: true;
3252
+ environment?: 'preview';
3250
3253
  sender?: { from: string; mode: 'platform_managed'; note: string };
3251
3254
  test_inbox?: { address: string; delivered: false };
3252
3255
  }
@@ -4026,13 +4029,24 @@ interface SomewhereEndpointConfig<Auth extends SomewhereEndpointAuth, Schema ext
4026
4029
  annotations?: { readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean };
4027
4030
  } : never;
4028
4031
  body?: Schema;
4029
- rateLimit?: \`\${number}/\${'second' | 'minute' | 'hour' | 'day'}\${'' | 's'}\`;
4032
+ /** Rate limit such as '30/minute'. The runtime accepts spaces and ignores case. */
4033
+ rateLimit?: string;
4030
4034
  cors?: 'same-origin' | '*' | readonly string[];
4031
4035
  handler(
4032
4036
  input: SomewhereEndpointInput<Auth, Schema extends SomewhereEndpointBodySchema ? __SomewhereEndpointBody<Schema> : null>,
4033
4037
  sw: SomewhereRuntimeContext,
4034
4038
  ): unknown;
4035
4039
  }
4040
+ interface SomewhereEndpointGlobal {
4041
+ endpoint<const Schema extends SomewhereEndpointBodySchema | undefined = undefined, Auth extends SomewhereEndpointAuth = 'none',
4042
+ const Roles extends readonly string[] | undefined = undefined>(
4043
+ config: SomewhereEndpointConfig<undefined extends Roles ? Auth : ([Auth] extends ['none'] ? 'required' : Auth), Schema>
4044
+ & { auth?: Auth; roles?: Roles },
4045
+ ): (req: Request, sw: SomewhereRuntimeContext) => Promise<Response>;
4046
+ }
4047
+ declare module 'somewhere:runtime-endpoint' {
4048
+ export const sw: SomewhereEndpointGlobal;
4049
+ }
4036
4050
  `;
4037
4051
  var DECLARED_COLUMN_TYPES = { integer: "number", bigint: "string", number: "number", text: "string", timestamp: "string", boolean: "boolean", json: "__SomewhereJson", blob: "number[]" };
4038
4052
  function declaredOwnerColumn2(name, table, scopes) {
@@ -4364,7 +4378,7 @@ var require_checker_contract = __commonJS({
4364
4378
  var REFERENCE_SOURCE = /\.(?:tsx?|jsx?|mjs|cjs)$/;
4365
4379
  var IGNORED_CODES = Object.freeze([2307, 7016, 2792, 6053]);
4366
4380
  var REFERENCE_CODES = Object.freeze([2304, 2552, 2448, 2454, 18004]);
4367
- var TYPE_SHAPE_CODES = Object.freeze([2339, 2551, 2345, 2322, 2554]);
4381
+ var TYPE_SHAPE_CODES = Object.freeze([2339, 2551, 2345, 2322, 2554, 2353, 2561, 2741, 2769, 18047]);
4368
4382
  var PROJECT_TYPE_ROOTS = Object.freeze(["./node_modules/@types"]);
4369
4383
  var ignored = new Set(IGNORED_CODES);
4370
4384
  var reference = new Set(REFERENCE_CODES);
@@ -4400,6 +4414,22 @@ var require_checker_contract = __commonJS({
4400
4414
  function localCheckCompilerOptions(projectCompilerOptions) {
4401
4415
  return referenceCheckCompilerOptions(projectTsconfigCompilerOptions(projectCompilerOptions));
4402
4416
  }
4417
+ function withEndpointBinding(ts, source, options) {
4418
+ if (!source || !ts.isExternalModule(source) || !/\bsw\b/.test(source.text)) return source;
4419
+ function usesEndpoint(node) {
4420
+ if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "sw" && node.name.text === "endpoint") return true;
4421
+ return ts.forEachChild(node, usesEndpoint);
4422
+ }
4423
+ if (!usesEndpoint(source)) return source;
4424
+ ts.bindSourceFile(source, options);
4425
+ if (source.locals?.has("sw")) return source;
4426
+ return ts.createSourceFile(
4427
+ source.fileName,
4428
+ source.text + "\nimport { sw } from 'somewhere:runtime-endpoint';\n",
4429
+ options.target ?? ts.ScriptTarget.ES2022,
4430
+ true
4431
+ );
4432
+ }
4403
4433
  function diagnosticNumber(code) {
4404
4434
  if (typeof code === "number") return code;
4405
4435
  const parsed = Number(String(code).replace(/^TS/i, ""));
@@ -4437,6 +4467,7 @@ var require_checker_contract = __commonJS({
4437
4467
  referenceCheckCompilerOptions,
4438
4468
  projectTsconfigCompilerOptions,
4439
4469
  localCheckCompilerOptions,
4470
+ withEndpointBinding,
4440
4471
  isIgnoredDiagnostic,
4441
4472
  classifyDiagnostic,
4442
4473
  diagnosticMessage
@@ -4525,8 +4556,8 @@ var require_consumer_contract = __commonJS({
4525
4556
  "worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
4526
4557
  "use strict";
4527
4558
  var CONSUMER_CONTRACT2 = Object.freeze({
4528
- version: 43,
4529
- digest: "0d081302e1723dadf797a11876f1aeed00e95e1daf55a4bc647ca1a99b21e1e5"
4559
+ version: 44,
4560
+ digest: "07384f39fd3d7d3b4a2f19ec55a6c309476402fc2af096ae0cd47b46780cbd46"
4530
4561
  });
4531
4562
  var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
4532
4563
  var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
@@ -8673,7 +8704,7 @@ function referenceCheckDeclaredTables(graphFiles, schemaOptions = {}) {
8673
8704
  }
8674
8705
  function referenceCheckDeclarations(graphFiles) {
8675
8706
  return (0, import_generated_declarations_render.renderGeneratedDeclarationFiles)({
8676
- declaredRoles: void 0,
8707
+ declaredRoles: declaredRolesFromSource(graphFiles),
8677
8708
  declaredTables: referenceCheckDeclaredTables(graphFiles),
8678
8709
  hasSchema: graphFiles["db/schema.ts"] !== void 0
8679
8710
  });