@somewhere-cloud/cli 0.38.152 → 0.38.154

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.
package/dist/testing.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { loadEntry } from "./lib/bundle.js";
2
2
  const entry = loadEntry("testing.js");
3
- export const { UserSession, createUser, data, expect, expectRefusal, expectRefused, expectStatus, ready, signIn, test, waitForApp } = entry;
3
+ export const { UserSession, assertNoLeak, captureResponses, createUser, data, expect, expectRefusal, expectRefused, expectStatus, openTestApp, ready, signIn, test, waitForApp } = entry;
@@ -143,26 +143,7 @@ export declare class AppTest {
143
143
  }
144
144
  /** Open a linked project for a plain script: reads its live origin, release and data contract. */
145
145
  export declare function openAppTest(options?: OpenOptions): Promise<AppTest>;
146
- export interface Captured {
147
- url: string;
148
- status: number;
149
- contentType: string;
150
- body: string;
151
- }
152
- /** Record every response this page receives (documents, scripts, data) with its body, so a
153
- * privacy check can wait for all of them and say exactly where a secret appeared. */
154
- export declare function captureResponses(page: Page): {
155
- /** Every captured response, after each body has been read. */
156
- all(): Promise<Captured[]>;
157
- /** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
158
- find(secret: string): Promise<{
159
- url: string;
160
- status: number;
161
- contentType: string;
162
- around: string;
163
- }[]>;
164
- stop(): void;
165
- };
146
+ export { captureResponses, type Captured } from './test-response-capture.js';
166
147
  /** Wait until the page's data views have finished loading: the starter marks each with
167
148
  * data-sw-data="loading" | "ready" | "error". Signed-in is not "the list has loaded". */
168
149
  export declare function dataReady(scope: Page | Locator, timeout?: number): Promise<'ready' | 'error'>;
@@ -49,6 +49,7 @@ export declare class ApiClient {
49
49
  baseUrl?: string;
50
50
  refresh?: false;
51
51
  signal?: AbortSignal;
52
+ onRetryAfter?: (ms: number) => void;
52
53
  }): Promise<T>;
53
54
  /** Authenticated request whose body and response remain streams. The body is
54
55
  * supplied by a factory so a file can be reopened if an expired access key
@@ -5,7 +5,9 @@ export declare function forgetPreviewCredential(projectId: string, previewSessio
5
5
  export declare function mintPreviewCredential(client: ApiClient, projectId: string, previewSessionId: string): Promise<string>;
6
6
  /** A client that carries ONLY the preview credential: no stored-login refresh, no fallback. */
7
7
  export declare function previewToolClient(credential: string): {
8
- call<T>(method: string, path: string, body?: unknown, query?: Record<string, string | number | undefined>): Promise<T>;
8
+ call: <T>(method: string, path: string, body?: unknown, query?: Record<string, string | number | undefined>, opts?: {
9
+ onRetryAfter?: (ms: number) => void;
10
+ }) => Promise<T>;
9
11
  };
10
12
  /** True when the platform refused the credential itself (closed, promoted, expired or revoked preview). */
11
13
  export declare function isDeadPreviewCredential(err: unknown): boolean;
@@ -30,6 +30,11 @@ export interface TestControl {
30
30
  /** End anything the control itself holds open (the preview browser session). */
31
31
  close(): Promise<void>;
32
32
  /** Preview only: a managed test user through the preview's developer tool, and its removal by id. */
33
+ previewCookie?(): Promise<{
34
+ name: string;
35
+ value: string;
36
+ expiresAt: number;
37
+ }>;
33
38
  createManagedUser?(): Promise<ManagedUser>;
34
39
  deleteManagedUser?(id: string): Promise<string | null>;
35
40
  }
@@ -4,6 +4,8 @@ export declare const TEST_STATE_GITIGNORE_LINE = ".somewhere/test/";
4
4
  export declare const MANIFEST_FILE = "manifest.json";
5
5
  export declare const CLEANUP_RECEIPT_FILE = "cleanup-receipt.json";
6
6
  export declare const MAX_PER_CREATE = 5;
7
+ export declare const ACCESS_COOKIE = "__Host-token";
8
+ export declare const REFRESH_COOKIE = "__Host-sw_refresh_token";
7
9
  export type TestRole = 'user' | 'admin';
8
10
  export interface ActorSpec {
9
11
  name: string;
@@ -49,16 +51,21 @@ export declare function ensureGitignored(root: string): 'present' | 'added' | 'c
49
51
  * `<name>.state.json` for a valid actor name, so cleanup can never delete outside .somewhere/test/. */
50
52
  export declare function readManifest(root: string): TestManifest | null;
51
53
  /** Read the prepared actor's app session for this exact linked target. */
52
- export declare function preparedActorSession(root: string, target: {
54
+ export declare function preparedActorState(root: string, target: {
53
55
  projectId: string;
54
56
  origin: string;
55
- }, name: string): string;
57
+ }, name: string): {
58
+ path: string;
59
+ state: PlaywrightStorageState;
60
+ access: string;
61
+ };
56
62
  export declare function writeManifest(root: string, manifest: TestManifest): void;
57
63
  /** The server's own times, read from the access token (not verified here; the server does that). */
58
64
  export declare function tokenTimes(accessToken: string): {
59
65
  iat: number;
60
66
  exp: number;
61
67
  } | null;
68
+ export declare function testAccessNeedsRefresh(token: string | undefined, now?: number): boolean;
62
69
  export interface IssuedIdentity {
63
70
  user: {
64
71
  id: string;
@@ -0,0 +1,24 @@
1
+ import type { Page } from '@playwright/test';
2
+ export declare function privateMarker(): string;
3
+ export interface Captured {
4
+ url: string;
5
+ status: number;
6
+ contentType: string;
7
+ body: string;
8
+ }
9
+ /** Record every response this page receives (documents, scripts, data) with its body, so a
10
+ * privacy check can wait for all of them and say exactly where a secret appeared. */
11
+ export declare function captureResponses(page: Page): {
12
+ /** Every captured response, after each body has been read. */
13
+ all(): Promise<Captured[]>;
14
+ /** Where `secret` appeared: URL, status, content type and the text around it. Use a unique value you planted. */
15
+ find(secret: string): Promise<{
16
+ url: string;
17
+ status: number;
18
+ contentType: string;
19
+ around: string;
20
+ }[]>;
21
+ stop(): void;
22
+ };
23
+ /** Report where a marker appeared without embedding response bodies in test output. */
24
+ export declare function assertNoLeak(marker: string, responses: Iterable<Response | Captured>): Promise<void>;
@@ -0,0 +1,43 @@
1
+ import { type TestTarget } from './test-target.js';
2
+ import { type PlaywrightStorageState } from './test-identities.js';
3
+ export declare class UserSession {
4
+ readonly origin: string;
5
+ private cookies;
6
+ private target?;
7
+ private readonly seed;
8
+ private refreshing?;
9
+ constructor(baseUrl: string, options?: {
10
+ target?: TestTarget;
11
+ storageState?: PlaywrightStorageState;
12
+ });
13
+ /** Standard Playwright state. Treat this value like a signed-in session. */
14
+ storageState(): Promise<PlaywrightStorageState>;
15
+ request(path: string, init?: RequestInit): Promise<Response>;
16
+ private ensureFresh;
17
+ private refresh;
18
+ private send;
19
+ post(path: string, body: unknown): Promise<Response>;
20
+ /** Use this session's cookies and the linked app's declared data contract. */
21
+ data(table: string, request: DataRequest): Promise<Response>;
22
+ data(table: string, contract: string, request: DataRequest): Promise<Response>;
23
+ }
24
+ export type DataRequest = {
25
+ operation: 'list';
26
+ limit?: number;
27
+ after?: string | number;
28
+ where?: Record<string, unknown>;
29
+ } | {
30
+ operation: 'get' | 'delete';
31
+ id: string | number;
32
+ } | {
33
+ operation: 'create';
34
+ values: Record<string, unknown>;
35
+ } | {
36
+ operation: 'update';
37
+ id: string | number;
38
+ values: Record<string, unknown>;
39
+ };
40
+ export declare function expectStatus(response: Response, expected: number): Promise<void>;
41
+ export declare function expectRefusal(response: Response, status: 401 | 403, code: string): Promise<void>;
42
+ export declare function signIn(baseUrl: string, email: string, password: string): Promise<UserSession>;
43
+ export declare function createUser(baseUrl: string): Promise<UserSession>;
@@ -0,0 +1,22 @@
1
+ import { type TestJob, type TestJobOptions, type TestJobTarget } from './testing-jobs.js';
2
+ import { UserSession } from './test-session.js';
3
+ export interface TestActor {
4
+ id: string;
5
+ email: string;
6
+ session: UserSession;
7
+ }
8
+ export interface TestApp {
9
+ origin: string;
10
+ anonymous: UserSession;
11
+ users(count: number): Promise<TestActor[]>;
12
+ create(user: TestActor, table: string, values: Record<string, unknown>, key?: string): Promise<string | number>;
13
+ plantMarker(user: TestActor, table: string, field: string, values?: Record<string, unknown>): Promise<string>;
14
+ onCleanup(label: string, action: () => Promise<void>): void;
15
+ runJob(job: TestJobTarget, options?: TestJobOptions): Promise<TestJob>;
16
+ cleanup(): Promise<void>;
17
+ }
18
+ /** Open the linked deployment or this folder's exact saved preview. */
19
+ export declare function openTestApp(options?: {
20
+ preview?: boolean;
21
+ projectDir?: string;
22
+ }): Promise<TestApp>;
@@ -0,0 +1,20 @@
1
+ import type { TestTarget } from './test-target.js';
2
+ export type TestJobTarget = {
3
+ schedule: string;
4
+ } | {
5
+ handler: string;
6
+ payload?: unknown;
7
+ };
8
+ export interface TestJobOptions {
9
+ timeoutSeconds?: number;
10
+ }
11
+ export interface TestJob {
12
+ job_id?: string;
13
+ request_id?: string;
14
+ status: string;
15
+ timed_out: boolean;
16
+ duration_ms?: number | null;
17
+ error_code?: string | null;
18
+ }
19
+ export declare function testingDeveloperToken(): string;
20
+ export declare function runTestJob(target: TestTarget, job: TestJobTarget, options?: TestJobOptions, previewCredential?: string): Promise<TestJob>;
@@ -1,40 +1,15 @@
1
- export declare class UserSession {
2
- readonly origin: string;
3
- private cookies;
4
- private target?;
5
- constructor(baseUrl: string);
6
- request(path: string, init?: RequestInit): Promise<Response>;
7
- post(path: string, body: unknown): Promise<Response>;
8
- /** Use this session's cookies and the linked app's declared data contract. */
9
- data(table: string, request: DataRequest): Promise<Response>;
10
- data(table: string, contract: string, request: DataRequest): Promise<Response>;
1
+ export { UserSession, signIn, createUser, expectStatus, expectRefusal, type DataRequest } from './lib/test-session.js';
2
+ interface ReadyLocator {
3
+ first?(): ReadyLocator;
4
+ waitFor(options: {
5
+ state: 'visible';
6
+ }): Promise<void>;
11
7
  }
12
- export type DataRequest = {
13
- operation: 'list';
14
- limit?: number;
15
- after?: string | number;
16
- where?: Record<string, unknown>;
17
- } | {
18
- operation: 'get' | 'delete';
19
- id: string | number;
20
- } | {
21
- operation: 'create';
22
- values: Record<string, unknown>;
23
- } | {
24
- operation: 'update';
25
- id: string | number;
26
- values: Record<string, unknown>;
27
- };
28
- export declare function expectStatus(response: Response, expected: number): Promise<void>;
29
- export declare function expectRefusal(response: Response, status: 401 | 403, code: string): Promise<void>;
30
- export declare function signIn(baseUrl: string, email: string, password: string): Promise<UserSession>;
31
- export declare function createUser(baseUrl: string): Promise<UserSession>;
32
8
  interface BrowserPage {
33
- locator(selector: string): {
34
- waitFor(options: {
35
- state: 'visible';
36
- }): Promise<void>;
37
- };
9
+ locator(selector: string): ReadyLocator;
38
10
  }
39
11
  export declare function waitForApp(page: BrowserPage, state?: 'ready' | 'signed-in' | 'signed-out'): Promise<void>;
40
12
  export { test, expect, expectRefused, data, ready, type RefusalOptions, type TestUser, type NewUserOptions, type Person, type SignUpOptions, type SignInOptions, type FormSteps, type CodeSteps } from './lib/playwright-fixtures.js';
13
+ export { openTestApp, type TestApp, type TestActor } from './lib/testing-app.js';
14
+ export { assertNoLeak, captureResponses } from './lib/test-response-capture.js';
15
+ export type { TestJob, TestJobOptions, TestJobTarget } from './lib/testing-jobs.js';
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@somewhere-cloud/cli",
3
- "version": "0.38.152",
3
+ "version": "0.38.154",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@somewhere-cloud/cli",
9
- "version": "0.38.152",
9
+ "version": "0.38.154",
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.152",
3
+ "version": "0.38.154",
4
4
  "description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
5
5
  "keywords": [
6
6
  "somewhere",
@@ -56,7 +56,8 @@
56
56
  "exports": {
57
57
  "./testing": {
58
58
  "types": "./dist/types/testing.d.ts",
59
- "import": "./dist/testing.js"
59
+ "import": "./dist/testing.js",
60
+ "default": "./dist/testing.js"
60
61
  },
61
62
  "./package.json": "./package.json",
62
63
  "./script": {
@@ -66,5 +67,5 @@
66
67
  },
67
68
  "bundleDependencies": [],
68
69
  "bundledDependencies": [],
69
- "gitHead": "7ba42b6b038a584e68e46796d7c8c5c42f1540d2"
70
+ "gitHead": "dd332ef7dca4adf2cce29311573c9904b72e74e5"
70
71
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "source_commit": "3fd5f988ec49589e943fca1f3471ad136a738444",
2
+ "source_commit": "a9b03532309404fb5db700ad613485b1924044dc",
3
3
  "esbuild": "0.24.0",
4
4
  "source_files": {
5
5
  "shared/app-model-catalog.ts": "c9a0119366beabb10157fcc9866f4d32b320b680f1c5717d837a5ca99875fa13",
@@ -9,13 +9,13 @@
9
9
  "shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
10
10
  "shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
11
11
  "worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
12
- "worker/containers/compile/consumer-contract.cjs": "2255630f2db257db723570007542d6a5aebce0dd5efbe82117d3d7c8db485d2f",
12
+ "worker/containers/compile/consumer-contract.cjs": "d3d1b735edce04defe198fa806141987ca77a780140d22068a7ffbbff879eaa4",
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
16
  "worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
17
17
  "worker/containers/compile/runtime-types.cjs": "a74ee2d726c395f2216528e070813293d08ee7340fbca63f94e015ede1ee6df1",
18
- "worker/containers/compile/schema-types.cjs": "6bd92695cd275b0c6bc7dc79daaf3189fb275449321342c967a2030f287cfdfa",
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",
21
21
  "worker/node_modules/entities/dist/decode-codepoint.js": "f09dbc23d35abbf96718dfdd04def3c1d3444495541d050c69a12706ee76dbb1",
@@ -54,7 +54,7 @@
54
54
  "worker/src/utils/db-schema-deploy/extract-schema-parents.ts": "623a0034c5196e7655574387493574ce59555d0a1cffd88ff696ce85b9f56228",
55
55
  "worker/src/utils/db-schema-deploy/extract-schema-relations.ts": "f5deac350ee915758f61d4be33711d23bad51ab20abcf153a463f0c90bfc3e27",
56
56
  "worker/src/utils/db-schema-deploy/extract-schema-roles.ts": "a5cc7524108c19121445ea2feb85c155067b790075eb823a5d5f8c2a12e92e78",
57
- "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "6ece9f185e2de72b720c6c5fb942609701874ea3951b679b8c8dc7c92b10aba3",
57
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "5f56bd9ea9a54a089705baf1e976ad0815e5d15841eb403f48f9666b462ddcea",
58
58
  "worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
59
59
  "worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
60
60
  "worker/src/utils/dev-health-class.ts": "fd430f31b9c8469f3d90e118fd8c75d1836ebcf705c1f9e93915ffa53a4cb066",
@@ -74,5 +74,5 @@
74
74
  "worker/src/utils/telegram.ts": "9aaaa2597c366da1eeee9e2252e9b73e611ea97ed9558f7e07e694d9b393f053",
75
75
  "worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
76
76
  },
77
- "sha256": "bc5bfcd5f4cb91e55691654bfe11f21a37a2efae763de4db56810c96c9c99425"
77
+ "sha256": "cf2d3dc90521be56b6fac77e5c524f62ce1b3f020b8d3d61a3a3acb8289db279"
78
78
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "sha256": "8a8d3ab2c5326736228ddc800ca30824916562461d581c1ba96dc5eb6f9bbf50"
2
+ "sha256": "b772a41a2cff4357ec5ff47dbf6b7d1ec648d043e16b22ecadff31088437ffe5"
3
3
  }
@@ -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": "6ece9f185e2de72b720c6c5fb942609701874ea3951b679b8c8dc7c92b10aba3",
28
+ "worker/src/utils/db-schema-deploy/extract-schema-ts.ts": "5f56bd9ea9a54a089705baf1e976ad0815e5d15841eb403f48f9666b462ddcea",
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": "06b04ae4ef754320bf441d74986d74b6b44ac298d6dcc8ec24d8373875dda34f",
36
+ "sha256": "4027e00501358b4f2292e80d2531f1c27a3a4beec9293433090f9d1f733f2726",
37
37
  "fixtures_sha256": "908827d1430f4af5a83cae59ed476abc51dc9648757eac0089fe6e6db95f66c5"
38
38
  }
@@ -4267,6 +4267,10 @@ var require_schema_types = __commonJS({
4267
4267
  interface Scope { readonly __somewhereScope: unique symbol }
4268
4268
  interface OwnerScope extends Scope { readonly __somewhereOwner: unique symbol }
4269
4269
  interface MemberScope extends Scope { readonly __somewhereMember: unique symbol }
4270
+ interface MemberJoin {
4271
+ group: string | string[]; membership: string; member_user: string; member_group: string | string[];
4272
+ operations?: Array<'read' | 'create' | 'update' | 'delete' | 'upload' | 'replace'>;
4273
+ }
4270
4274
  interface GrantScope extends Scope { readonly __somewhereGrant: unique symbol }
4271
4275
  interface GroupScope extends Scope { readonly __somewhereGroup: unique symbol }
4272
4276
  interface AppRoleScope extends Scope { readonly __somewhereAppRole: unique symbol }
@@ -4323,7 +4327,8 @@ function blob(options?: SomewhereSchemaDeclaration.ColumnOptions<never>): Somewh
4323
4327
  function owner(options?: { column?: string; visitors?: boolean; read?: string[] }): SomewhereSchemaDeclaration.OwnerScope;
4324
4328
  function shared(): SomewhereSchemaDeclaration.Scope;
4325
4329
  function serverOnly(): SomewhereSchemaDeclaration.Scope;
4326
- function member(options: { group: string | string[]; membership: string; member_user: string; member_group: string | string[]; where?: Record<string, string | string[]>; operations?: Array<'read' | 'create' | 'update' | 'delete' | 'upload' | 'replace'>; read?: string[] }): SomewhereSchemaDeclaration.MemberScope;
4330
+ function member(options: SomewhereSchemaDeclaration.MemberJoin & { where?: Record<string, string | string[]>; read?: string[]; deleteWhere?: never }): SomewhereSchemaDeclaration.MemberScope;
4331
+ function member(options: SomewhereSchemaDeclaration.MemberJoin & { deleteWhere: Record<string, string | string[]>; where?: never }): SomewhereSchemaDeclaration.Scope;
4327
4332
  function files(options: SomewhereSchemaDeclaration.FileCollectionOptions): SomewhereSchemaDeclaration.FileCollection;
4328
4333
  function hasMany(table: string, foreignKey: string): SomewhereSchemaDeclaration.Relation;
4329
4334
  function belongsTo(table: string, foreignKey: string): SomewhereSchemaDeclaration.Relation;
@@ -4518,8 +4523,8 @@ var require_consumer_contract = __commonJS({
4518
4523
  "worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
4519
4524
  "use strict";
4520
4525
  var CONSUMER_CONTRACT2 = Object.freeze({
4521
- version: 41,
4522
- digest: "f452cd4f0c1387cd4f77d2a5371baf563a93e1307e75dbef61dbad29bf0435a3"
4526
+ version: 42,
4527
+ digest: "a2e64aea9f363bd48107929ab7896d5be267a0e998010222913001f7fe47056c"
4523
4528
  });
4524
4529
  var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
4525
4530
  var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
@@ -7689,7 +7694,7 @@ function readMemberOperations(r, tableName) {
7689
7694
  const normalized = MEMBER_OPERATIONS.filter((operation) => seen.has(operation));
7690
7695
  return normalized.length === MEMBER_OPERATIONS.length ? void 0 : normalized;
7691
7696
  }
7692
- function readMemberScope(r, tableName, scopeLine) {
7697
+ function readMemberScope(r, tableName, scopeLine, context) {
7693
7698
  r.expectPunct("{", `in member() options for table "${tableName}" \u2014 member() needs { group, membership, member_user, member_group }`);
7694
7699
  let group = null;
7695
7700
  let membership = null;
@@ -7697,6 +7702,7 @@ function readMemberScope(r, tableName, scopeLine) {
7697
7702
  let memberGroup = null;
7698
7703
  let operations, operationsSeen = false;
7699
7704
  let selector;
7705
+ let selectorOption;
7700
7706
  let read;
7701
7707
  while (!r.tryPunct("}")) {
7702
7708
  const key = r.readKey(`for a member() option of table "${tableName}"`);
@@ -7713,35 +7719,43 @@ function readMemberScope(r, tableName, scopeLine) {
7713
7719
  if (operationsSeen) throw new SchemaTsError(`line ${key.line}: member() on table "${tableName}" declares operations more than once.`);
7714
7720
  operationsSeen = true;
7715
7721
  operations = readMemberOperations(r, tableName);
7716
- } else if (key.name === "where") {
7717
- if (selector) throw new SchemaTsError("member() declares where more than once.");
7718
- r.expectPunct("{", "opening member where");
7719
- const column = r.readKey("member where column").name;
7720
- validateMemberColumns([column], "where", tableName, key.line);
7721
- r.expectPunct(":", "after member where column");
7722
+ } else if (key.name === "where" || key.name === "deleteWhere") {
7723
+ const option = key.name;
7724
+ if (option === "deleteWhere" && context !== "standalone") {
7725
+ throw new SchemaTsError(`line ${key.line}: deleteWhere on table "${tableName}" requires a standalone member() scope.`);
7726
+ }
7727
+ if (selectorOption && selectorOption !== option) {
7728
+ throw new SchemaTsError(`line ${key.line}: member() on table "${tableName}" accepts either where or deleteWhere.`);
7729
+ }
7730
+ if (selectorOption) throw new SchemaTsError(`member() declares ${option} more than once.`);
7731
+ selectorOption = option;
7732
+ r.expectPunct("{", `opening member ${option}`);
7733
+ const column = r.readKey(`member ${option} column`).name;
7734
+ validateMemberColumns([column], option, tableName, key.line);
7735
+ r.expectPunct(":", `after member ${option} column`);
7722
7736
  let value;
7723
7737
  if (r.tryPunct("[")) {
7724
7738
  const list = [];
7725
7739
  while (!r.tryPunct("]")) {
7726
- list.push(r.readLiteral("member where value"));
7740
+ list.push(r.readLiteral(`member ${option} value`));
7727
7741
  if (!r.tryPunct(",")) {
7728
- r.expectPunct("]", "closing member where list");
7742
+ r.expectPunct("]", `closing member ${option} list`);
7729
7743
  break;
7730
7744
  }
7731
7745
  }
7732
7746
  value = list;
7733
- } else value = r.readLiteral("member where literal");
7747
+ } else value = r.readLiteral(`member ${option} literal`);
7734
7748
  const values = typeof value === "string" ? [value] : value;
7735
- if (!Array.isArray(values) || !values.length || values.some((v) => typeof v !== "string")) throw new SchemaTsError("member where needs one text column and a nonempty string literal or list.");
7749
+ if (!Array.isArray(values) || !values.length || values.some((v) => typeof v !== "string")) throw new SchemaTsError(`member ${option} needs one text column and a nonempty string literal or list.`);
7736
7750
  r.tryPunct(",");
7737
- r.expectPunct("}", "member where accepts exactly one column");
7751
+ r.expectPunct("}", `member ${option} accepts exactly one column`);
7738
7752
  selector = { column, values: [...new Set(values)].sort() };
7739
7753
  } else if (key.name === "read") {
7740
7754
  if (read) throw new SchemaTsError(`line ${key.line}: member() on table "${tableName}" declares read more than once.`);
7741
7755
  read = readBranchReadColumns(r, `member({ read }) on table "${tableName}"`);
7742
7756
  } else {
7743
7757
  throw new SchemaTsError(
7744
- `line ${key.line}: member() on table "${tableName}" has an unknown option "${key.name}". Allowed: group, membership, member_user, member_group, operations, read.`
7758
+ `line ${key.line}: member() on table "${tableName}" has an unknown option "${key.name}". Allowed: group, membership, member_user, member_group, operations, where, read${context === "standalone" ? ", deleteWhere" : ""}.`
7745
7759
  );
7746
7760
  }
7747
7761
  if (!r.tryPunct(",")) {
@@ -7771,7 +7785,11 @@ function readMemberScope(r, tableName, scopeLine) {
7771
7785
  `line ${scopeLine}: member() on table "${tableName}" has a ${group.length}-column group but a ${memberGroup.length}-column member_group. The group key must have the same number of columns on both sides.`
7772
7786
  );
7773
7787
  }
7774
- const node = { kind: "member", group, membership, memberUser, memberGroup, ...selector ? { restriction: { ...selector, operations: operations ?? [...MEMBER_OPERATIONS] } } : {}, ...operations !== void 0 ? { operations } : {}, ...read ? { read } : {} };
7788
+ if (selectorOption === "deleteWhere" && operations && !operations.includes("delete")) {
7789
+ throw new SchemaTsError(`line ${scopeLine}: member() on table "${tableName}" uses deleteWhere, so operations must include 'delete'.`);
7790
+ }
7791
+ const restrictedOperations = selectorOption === "deleteWhere" ? ["delete"] : operations ?? [...MEMBER_OPERATIONS];
7792
+ const node = { kind: "member", group, membership, memberUser, memberGroup, ...selector ? { restriction: { ...selector, operations: restrictedOperations } } : {}, ...operations !== void 0 ? { operations } : {}, ...read ? { read } : {} };
7775
7793
  if (operationsSeen) explicitMemberOperations.add(node);
7776
7794
  return node;
7777
7795
  }
@@ -7832,7 +7850,7 @@ function refuseBranchRead(node, line, tableName, where) {
7832
7850
  }
7833
7851
  function readPolicyMember(r, tableName, line) {
7834
7852
  r.expectPunct("(", 'after "member"');
7835
- const scope = readMemberScope(r, tableName, line);
7853
+ const scope = readMemberScope(r, tableName, line, "composed");
7836
7854
  r.tryPunct(",");
7837
7855
  r.expectPunct(")", "closing member()");
7838
7856
  if (scope.kind !== "member") throw new SchemaTsError(`line ${line}: invalid member() policy.`);
@@ -8049,7 +8067,7 @@ function readScope(r, tableName) {
8049
8067
  }
8050
8068
  if (tok.value === "member") {
8051
8069
  r.expectPunct("(", 'after "member"');
8052
- const scope = readMemberScope(r, tableName, tok.line);
8070
+ const scope = readMemberScope(r, tableName, tok.line, "standalone");
8053
8071
  r.tryPunct(",");
8054
8072
  r.expectPunct(")", "closing member()");
8055
8073
  if (scope.kind === "member") refuseBranchRead(scope, tok.line, tableName, "the member() scope");