@somewhere-cloud/cli 0.38.177 → 0.38.179
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/CHANGELOG.md +11 -0
- package/dist/lib/bundle.js +1069 -636
- package/dist/lib/bundle.js.map +3 -3
- package/dist/lib/source-lint.js +1 -1
- package/dist/types/lib/form-accounts.d.ts +8 -4
- package/dist/types/lib/test-control.d.ts +3 -1
- package/dist/types/lib/test-identities.d.ts +5 -1
- package/dist/types/lib/testing-app.d.ts +99 -2
- package/dist/types/testing.d.ts +2 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/src/testing.ts +2 -1
package/dist/lib/source-lint.js
CHANGED
|
@@ -7,7 +7,9 @@ export interface SweepControl {
|
|
|
7
7
|
previewSessionId?: string;
|
|
8
8
|
};
|
|
9
9
|
journalDir(root: string): string;
|
|
10
|
-
deleteSignups(ids: string[]
|
|
10
|
+
deleteSignups(ids: string[], options?: {
|
|
11
|
+
groups?: boolean;
|
|
12
|
+
}): Promise<SignupDeletion>;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* What one cleanup did with each listed id. The runner
|
|
@@ -79,9 +81,11 @@ export declare function accountsDir(root: string, projectId: string): string;
|
|
|
79
81
|
export declare function recordAttempt(control: SweepControl, root: string, email: string): string;
|
|
80
82
|
export declare function recordId(path: string, id: string): void;
|
|
81
83
|
export declare function forgetRecord(path: string): void;
|
|
82
|
-
/** Delete the accounts this run created together, by exact id, with the developer delete, and
|
|
83
|
-
* teams only they belong to. An id that is already gone counts as done. */
|
|
84
|
-
export declare function deleteAccounts(client: ApiClient, projectId: string, ids: string[]
|
|
84
|
+
/** Delete the accounts this run created together, by exact id, with the developer delete, and (unless
|
|
85
|
+
* `groups: false`) the teams only they belong to. An id that is already gone counts as done. */
|
|
86
|
+
export declare function deleteAccounts(client: ApiClient, projectId: string, ids: string[], { groups }?: {
|
|
87
|
+
groups?: boolean;
|
|
88
|
+
}): Promise<SignupDeletion>;
|
|
85
89
|
export interface SweepResult {
|
|
86
90
|
deleted: string[];
|
|
87
91
|
failed: string[];
|
|
@@ -20,7 +20,9 @@ export interface TestControl {
|
|
|
20
20
|
}): Promise<InboxMessage[]>;
|
|
21
21
|
/** Delete the accounts this run signed up through the app's form, together and by exact id, with
|
|
22
22
|
* the teams only they belong to (form-accounts.ts SignupDeletion). */
|
|
23
|
-
deleteSignups(ids: string[]
|
|
23
|
+
deleteSignups(ids: string[], options?: {
|
|
24
|
+
groups?: boolean;
|
|
25
|
+
}): Promise<SignupDeletion>;
|
|
24
26
|
/** Where sign-up attempts are recorded for exact-id cleanup (separate per environment and preview). */
|
|
25
27
|
journalDir(root: string): string;
|
|
26
28
|
/** Make a browser context able to reach the target (preview: the run's pinned session). */
|
|
@@ -112,7 +112,11 @@ export declare function expiryOf(issued: IssuedIdentity, receivedAt: number): {
|
|
|
112
112
|
sessionExpiresAt: number;
|
|
113
113
|
source: 'token' | 'response';
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
/** `sweep: false` (the testing kit): the platform skips its project-wide expiry of test users older than 24 h,
|
|
116
|
+
* so one run never deletes another run's users. */
|
|
117
|
+
export declare function createTestIdentities(client: ApiClient, projectId: string, role: TestRole, count: number, label: string, options?: {
|
|
118
|
+
sweep?: false;
|
|
119
|
+
}): Promise<{
|
|
116
120
|
issued: IssuedIdentity[];
|
|
117
121
|
receivedAt: number;
|
|
118
122
|
}>;
|
|
@@ -1,18 +1,60 @@
|
|
|
1
|
-
import { type InboxMessage } from './test-identities.js';
|
|
1
|
+
import { type InboxMessage, type PlaywrightStorageState } from './test-identities.js';
|
|
2
2
|
import { type TestJob, type TestJobOptions, type TestJobTarget } from './testing-jobs.js';
|
|
3
3
|
import { UserSession } from './test-session.js';
|
|
4
|
-
|
|
4
|
+
import type { DataRequest } from './test-session.js';
|
|
5
|
+
/** A person in the test: a managed test user (no sign-up form), already signed in. */
|
|
6
|
+
export interface TestActor extends Caller {
|
|
7
|
+
/** The name it was made under (`users('owner')` → 'owner'), or 'user 1', 'user 2'… for users(count). */
|
|
8
|
+
name: string;
|
|
5
9
|
id: string;
|
|
6
10
|
email: string;
|
|
11
|
+
/** App roles granted before users() returned. */
|
|
12
|
+
roles: string[];
|
|
7
13
|
session: UserSession;
|
|
8
14
|
}
|
|
15
|
+
/** users() by name: `users('owner', 'member')`, or with roles: `users({ agent: { roles: ['staff'] }, customer: {} })`. */
|
|
16
|
+
export type UserSpec = Record<string, {
|
|
17
|
+
roles?: string[];
|
|
18
|
+
}>;
|
|
19
|
+
/** `show: true` prints the reply body (or the detail) on a FAIL, with secret-shaped fields hidden. */
|
|
20
|
+
export interface ShowOptions {
|
|
21
|
+
show?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** `['DELETE', '/api/comments/1']` or `['POST', '/api/tasks/1/comments', { body: 'x' }]`. */
|
|
24
|
+
export type RefusedRequest = readonly [method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown];
|
|
25
|
+
export interface RefuseOptions {
|
|
26
|
+
status?: number | readonly number[];
|
|
27
|
+
lacks?: string | readonly string[];
|
|
28
|
+
label?: string;
|
|
29
|
+
}
|
|
30
|
+
type Named<K extends string> = {
|
|
31
|
+
[P in K]: TestActor;
|
|
32
|
+
};
|
|
9
33
|
export interface TestInboxMessage extends InboxMessage {
|
|
10
34
|
links: string[];
|
|
11
35
|
}
|
|
12
36
|
export interface TestApp {
|
|
13
37
|
origin: string;
|
|
14
38
|
anonymous: UserSession;
|
|
39
|
+
/** The same calls as a signed-out visitor. */
|
|
40
|
+
signedOut: Caller;
|
|
15
41
|
users(count: number): Promise<TestActor[]>;
|
|
42
|
+
users<K extends string>(...names: [K, ...K[]]): Promise<Named<K>>;
|
|
43
|
+
users<S extends UserSpec>(spec: S): Promise<Named<Extract<keyof S, string>>>;
|
|
44
|
+
/** Records PASS or FAIL for the run and returns ok. Never throws. A FAIL shows an Error's message or a
|
|
45
|
+
* string, scrubbed; other details only with `{ show: true }`. */
|
|
46
|
+
check(label: string, ok: unknown, detail?: unknown, options?: ShowOptions): boolean;
|
|
47
|
+
/** PASS when the reply's status is one of `status`; returns the reply's JSON body either way. A FAIL shows the
|
|
48
|
+
* status, request id and the body's error code and message; `{ show: true }` also prints the body, scrubbed. */
|
|
49
|
+
expect(reply: Reply, status: number | readonly number[], label: string, options?: ShowOptions): any;
|
|
50
|
+
/** Sends every request as every user in parallel and records one PASS or FAIL per pair: PASS when the answer is
|
|
51
|
+
* a refusal (401, 403 or 404 unless `status` says otherwise) and contains none of `lacks`. Returns whether all passed. */
|
|
52
|
+
refuse(who: Caller | readonly Caller[], requests: readonly RefusedRequest[], options?: RefuseOptions): Promise<boolean>;
|
|
53
|
+
/** A Playwright page on `path`, signed in as `user` (or signed out with null), after the app's sign-in state settles. */
|
|
54
|
+
page(user: TestActor | null, path?: string): Promise<import('@playwright/test').Page>;
|
|
55
|
+
/** Cleanup, then one summary line; sets the exit status: 2 while any cleanup is unconfirmed, else 1 if a check
|
|
56
|
+
* failed, else 0. Calling it again retries only what is still unconfirmed. */
|
|
57
|
+
done(): Promise<void>;
|
|
16
58
|
inboxAddress(name?: string): string;
|
|
17
59
|
testInbox(email: string): Promise<TestInboxMessage[]>;
|
|
18
60
|
signInWithLink(url: string): Promise<TestActor>;
|
|
@@ -27,3 +69,58 @@ export declare function openTestApp(options?: {
|
|
|
27
69
|
preview?: boolean;
|
|
28
70
|
projectDir?: string;
|
|
29
71
|
}): Promise<TestApp>;
|
|
72
|
+
/** An app's answer, already read: the status, the parsed JSON body (or null) and the raw text. */
|
|
73
|
+
export interface Reply {
|
|
74
|
+
status: number;
|
|
75
|
+
ok: boolean;
|
|
76
|
+
body: any;
|
|
77
|
+
text: string;
|
|
78
|
+
requestId: string | null;
|
|
79
|
+
}
|
|
80
|
+
/** What every person in a test can do: call the app's routes and its data endpoint as themselves. */
|
|
81
|
+
export interface Caller {
|
|
82
|
+
get(path: string): Promise<Reply>;
|
|
83
|
+
post(path: string, body?: unknown): Promise<Reply>;
|
|
84
|
+
put(path: string, body?: unknown): Promise<Reply>;
|
|
85
|
+
patch(path: string, body?: unknown): Promise<Reply>;
|
|
86
|
+
delete(path: string, body?: unknown): Promise<Reply>;
|
|
87
|
+
data(table: string, request: DataRequest): Promise<Reply>;
|
|
88
|
+
}
|
|
89
|
+
export declare function readReply(response: Response): Promise<Reply>;
|
|
90
|
+
export declare function callerOf(session: UserSession, onWrite?: () => void): Caller;
|
|
91
|
+
/** PASS/FAIL lines and the run's exit status. Checks never throw, so one run reports every result. A FAIL line
|
|
92
|
+
* never carries a raw body, headers, tokens or cookies unless the call asks with { show: true }. */
|
|
93
|
+
export declare class Results {
|
|
94
|
+
passed: number;
|
|
95
|
+
failed: number;
|
|
96
|
+
private line;
|
|
97
|
+
check(label: string, ok: unknown, detail?: unknown, options?: ShowOptions): boolean;
|
|
98
|
+
expect(reply: Reply, status: number | readonly number[], label: string, options?: ShowOptions): any;
|
|
99
|
+
}
|
|
100
|
+
/** Minimal Playwright shapes, so the CLI never depends on Playwright. */
|
|
101
|
+
interface PwLocator {
|
|
102
|
+
count(): Promise<number>;
|
|
103
|
+
waitFor(options: {
|
|
104
|
+
state: 'detached';
|
|
105
|
+
timeout: number;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
interface PwPage {
|
|
109
|
+
goto(url: string): Promise<unknown>;
|
|
110
|
+
locator(selector: string): PwLocator;
|
|
111
|
+
context(): PwContext;
|
|
112
|
+
}
|
|
113
|
+
interface PwContext {
|
|
114
|
+
newPage(): Promise<PwPage>;
|
|
115
|
+
close(): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
/** One headless browser per test app, from the app folder's own Playwright install. */
|
|
118
|
+
export declare class Pages {
|
|
119
|
+
private readonly root;
|
|
120
|
+
private readonly origin;
|
|
121
|
+
private browser?;
|
|
122
|
+
constructor(root: string, origin: string);
|
|
123
|
+
open(state: PlaywrightStorageState, path: string): Promise<PwPage>;
|
|
124
|
+
close(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
export {};
|
package/dist/types/testing.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ interface BrowserPage {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function waitForApp(page: BrowserPage, state?: 'ready' | 'signed-in' | 'signed-out'): Promise<void>;
|
|
12
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, type TestInboxMessage } from './lib/testing-app.js';
|
|
13
|
+
export { openTestApp, type TestApp, type TestActor, type TestInboxMessage, type UserSpec, type RefusedRequest, type RefuseOptions, type ShowOptions } from './lib/testing-app.js';
|
|
14
|
+
export type { Reply, Caller } from './lib/testing-app.js';
|
|
14
15
|
export { assertNoLeak, captureResponses } from './lib/test-response-capture.js';
|
|
15
16
|
export type { TestJob, TestJobOptions, TestJobTarget } from './lib/testing-jobs.js';
|
|
16
17
|
export type { FilesRequest } from './lib/test-files.js';
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@somewhere-cloud/cli",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.179",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@somewhere-cloud/cli",
|
|
9
|
-
"version": "0.38.
|
|
9
|
+
"version": "0.38.179",
|
|
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.
|
|
3
|
+
"version": "0.38.179",
|
|
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": "
|
|
70
|
+
"gitHead": "5f04206ede525e82fb317764c0d20d35ee7ac8fa"
|
|
71
71
|
}
|
package/src/testing.ts
CHANGED
|
@@ -16,7 +16,8 @@ export function waitForApp(page: BrowserPage, state: 'ready' | 'signed-in' | 'si
|
|
|
16
16
|
// Lazy project-local Playwright resolution keeps UserSession dependency-free.
|
|
17
17
|
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';
|
|
18
18
|
|
|
19
|
-
export { openTestApp, type TestApp, type TestActor, type TestInboxMessage } from './lib/testing-app.js';
|
|
19
|
+
export { openTestApp, type TestApp, type TestActor, type TestInboxMessage, type UserSpec, type RefusedRequest, type RefuseOptions, type ShowOptions } from './lib/testing-app.js';
|
|
20
|
+
export type { Reply, Caller } from './lib/testing-app.js';
|
|
20
21
|
export { assertNoLeak, captureResponses } from './lib/test-response-capture.js';
|
|
21
22
|
export type { TestJob, TestJobOptions, TestJobTarget } from './lib/testing-jobs.js';
|
|
22
23
|
export type { FilesRequest } from './lib/test-files.js';
|