@somewhere-cloud/cli 0.38.148 → 0.38.150
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 +9 -0
- package/README.md +12 -7
- package/dist/lib/bundle.js +2556 -2213
- package/dist/lib/bundle.js.map +3 -3
- package/dist/types/lib/app-test.d.ts +7 -2
- package/dist/types/lib/test-identities.d.ts +5 -0
- package/dist/types/testing.d.ts +3 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/runtime/DECLARED-DATA-VENDOR.json +10 -9
- package/runtime/PLATFORM-SOURCE.json +1 -1
- package/runtime/declared-data.cjs +15 -4
- package/src/testing.ts +17 -3
|
@@ -18,16 +18,21 @@ export interface DataRequest {
|
|
|
18
18
|
* - empty: a list with no rows or a get with null (a missing row and a hidden row look the same);
|
|
19
19
|
* - refused: 401/403;
|
|
20
20
|
* - missing-or-refused: 404 DATA_NOT_FOUND on update/delete (a missing row and a refused write look the same);
|
|
21
|
+
* - missing-contract: 400 DATA_CONTRACT_MISSING (the request did not supply a digest);
|
|
21
22
|
* - malformed: 400/405/413/415, or 403 DATA_ORIGIN_FORBIDDEN (the request is wrong; it proves nothing about access);
|
|
22
23
|
* - stale-contract: 409 DATA_CONTRACT_MISMATCH (the app changed since the contract was read; it proves nothing);
|
|
23
24
|
* - error: anything else, such as 409 DATA_CONFLICT (a unique-key conflict). */
|
|
24
|
-
export type DataKind = 'ok' | 'empty' | 'refused' | 'missing-or-refused' | 'malformed' | 'stale-contract' | 'error';
|
|
25
|
+
export type DataKind = 'ok' | 'empty' | 'refused' | 'missing-or-refused' | 'missing-contract' | 'malformed' | 'stale-contract' | 'error';
|
|
25
26
|
export interface DataResult {
|
|
26
27
|
status: number;
|
|
27
28
|
kind: DataKind;
|
|
28
29
|
data: unknown;
|
|
29
30
|
error: string | null;
|
|
30
31
|
message: string | null;
|
|
32
|
+
access?: {
|
|
33
|
+
filtered: true;
|
|
34
|
+
};
|
|
35
|
+
current_contract_digest?: string;
|
|
31
36
|
}
|
|
32
37
|
type Who = Page | BrowserContext | APIRequestContext;
|
|
33
38
|
/** One check's outcome, including whether a prerequisite kept it from running. */
|
|
@@ -77,7 +82,7 @@ export declare function undeployedChanges(root: string, projectId: string, previ
|
|
|
77
82
|
changed: string[];
|
|
78
83
|
} | null;
|
|
79
84
|
/** What a data-endpoint answer means (see DataKind). */
|
|
80
|
-
export declare function classifyData(status: number, raw: unknown): DataResult;
|
|
85
|
+
export declare function classifyData(status: number, raw: unknown, operation?: string): DataResult;
|
|
81
86
|
export declare class AppTest {
|
|
82
87
|
readonly root: string;
|
|
83
88
|
private readonly control;
|
|
@@ -48,6 +48,11 @@ export declare function ensureGitignored(root: string): 'present' | 'added' | 'c
|
|
|
48
48
|
* to touch the filesystem or the API is validated here: an actor's state file is always exactly
|
|
49
49
|
* `<name>.state.json` for a valid actor name, so cleanup can never delete outside .somewhere/test/. */
|
|
50
50
|
export declare function readManifest(root: string): TestManifest | null;
|
|
51
|
+
/** Read the prepared actor's app session for this exact linked target. */
|
|
52
|
+
export declare function preparedActorSession(root: string, target: {
|
|
53
|
+
projectId: string;
|
|
54
|
+
origin: string;
|
|
55
|
+
}, name: string): string;
|
|
51
56
|
export declare function writeManifest(root: string, manifest: TestManifest): void;
|
|
52
57
|
/** The server's own times, read from the access token (not verified here; the server does that). */
|
|
53
58
|
export declare function tokenTimes(accessToken: string): {
|
package/dist/types/testing.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export declare class UserSession {
|
|
2
2
|
readonly origin: string;
|
|
3
3
|
private cookies;
|
|
4
|
+
private target?;
|
|
4
5
|
constructor(baseUrl: string);
|
|
5
6
|
request(path: string, init?: RequestInit): Promise<Response>;
|
|
6
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>;
|
|
7
10
|
data(table: string, contract: string, request: DataRequest): Promise<Response>;
|
|
8
11
|
}
|
|
9
12
|
export type DataRequest = {
|
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.150",
|
|
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.150",
|
|
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.150",
|
|
4
4
|
"description": "CLI for somewhere.cloud — auth, projects, deploy, pull, promote, db, logs, env, MCP bridge.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"somewhere",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
},
|
|
67
67
|
"bundleDependencies": [],
|
|
68
68
|
"bundledDependencies": [],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "a6ed5dcef34a2f6a099440149a0cf341d15e4495"
|
|
70
70
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
+
"source_commit": "4a65c43c7dbb317dab97c8716b004ddba32da243",
|
|
2
3
|
"esbuild": "0.24.0",
|
|
3
4
|
"source_files": {
|
|
4
|
-
"shared/app-model-catalog.ts": "
|
|
5
|
+
"shared/app-model-catalog.ts": "c9a0119366beabb10157fcc9866f4d32b320b680f1c5717d837a5ca99875fa13",
|
|
5
6
|
"shared/cloud-dev-entitlement.ts": "1993a9e1c781d9daed29b3cfef0e8a370e150ce06d2acc7c408c2a24c50b4960",
|
|
6
7
|
"shared/d1-region.ts": "71cda96cfead241b4f4e35b8cd6b1d8e577f072257e91a8dbe0deaa1b142b378",
|
|
7
8
|
"shared/d1-session.ts": "2ae29b74bba68016c86d25fa2a58f8c2fce4aca8fe57fafc253d380c47a3c0ab",
|
|
8
9
|
"shared/transient-read.ts": "2f22daebdc74fed6255a29df7deda0db307f9165c1d9988dba3ee872b2584ffd",
|
|
9
10
|
"shared/types/placeholder-identity.ts": "089a46e2474a21193d3611eddd9c94b6bbe62441b3039ed80fc8499bada447ca",
|
|
10
11
|
"worker/containers/compile/checker-contract.cjs": "c6d4ebc9ec058b3562655cc4f18dc1cea7e4492eb35b7f0fd0d87e974c26b492",
|
|
11
|
-
"worker/containers/compile/consumer-contract.cjs": "
|
|
12
|
+
"worker/containers/compile/consumer-contract.cjs": "3827f2fcd4bb5a3cd6682f07ae63c3cee6f48411b0bd9afe2baaa0664d808e47",
|
|
12
13
|
"worker/containers/compile/declared-data-contract.cjs": "1261275ab4ff75b3001456a30b041a7c639578ffff0b67b42706d7b0ff11d744",
|
|
13
14
|
"worker/containers/compile/generated-declarations-render.cjs": "7ffdb34645cc9eccac6eba39dc86b646a41c4de8a1a038d2b5b46f42df9f1157",
|
|
14
15
|
"worker/containers/compile/generated-declarations.cjs": "6e9902e054c5c784fd9b3c3fafc1869e79954100a45014e1132247cd82833ec4",
|
|
15
16
|
"worker/containers/compile/groups-types.cjs": "7c22b4bb96c9391005d434852600dc02bc8a6bbb99d78d2b8e3eb152f7b72c58",
|
|
16
|
-
"worker/containers/compile/runtime-types.cjs": "
|
|
17
|
+
"worker/containers/compile/runtime-types.cjs": "ab8d1ff84c1a671e8206e23f5bab351f8f1ccc9c8c159694d71b09b195d0a276",
|
|
17
18
|
"worker/containers/compile/schema-types.cjs": "6bd92695cd275b0c6bc7dc79daaf3189fb275449321342c967a2030f287cfdfa",
|
|
18
19
|
"worker/containers/compile/typed-data.cjs": "1c8bec853fbee4ffd34c651076a4e1f4d8b18c0c2be5e99e31df7c9283207627",
|
|
19
20
|
"worker/containers/compile/typed-files.cjs": "f2568567a53994575ede91f9a0839965e64f94eb92ae11315650189b6de0f79c",
|
|
@@ -57,10 +58,10 @@
|
|
|
57
58
|
"worker/src/utils/db-schema-deploy/schema-constants.ts": "9742bc649f494963af4ae2039a1d6062cc6dbe087285bdf470f6ee71d9f76aac",
|
|
58
59
|
"worker/src/utils/db-schema-deploy/schema-ownership.ts": "e6c811a87bc657707be3518dfe547c6d97718ac073108b126eb7f791c9c08202",
|
|
59
60
|
"worker/src/utils/dev-health-class.ts": "fd430f31b9c8469f3d90e118fd8c75d1836ebcf705c1f9e93915ffa53a4cb066",
|
|
60
|
-
"worker/src/utils/errors.ts": "
|
|
61
|
-
"worker/src/utils/event-log.ts": "
|
|
62
|
-
"worker/src/utils/feed-kinds.ts": "
|
|
63
|
-
"worker/src/utils/journey-segment.ts": "
|
|
61
|
+
"worker/src/utils/errors.ts": "f57505fc7cb515abb2e2e62fc8211f359200df1183689dc621dec10c8c7f03e3",
|
|
62
|
+
"worker/src/utils/event-log.ts": "167a2ac478ff9b8b58c4f22ae39aa20ff25331c22a9e8f21d96e374b04458c78",
|
|
63
|
+
"worker/src/utils/feed-kinds.ts": "a2f4a77707c09f04397cc2d67665b10c9303951e713c2ceb9d3c4f22cbfabe8d",
|
|
64
|
+
"worker/src/utils/journey-segment.ts": "623837dec9b24c211b1f3be4908f6780bb4cdba175f2dfa5f34ccccfe5a1a5fc",
|
|
64
65
|
"worker/src/utils/json-exact-integers.ts": "e2eb8d3b2e17da363eb14fb46d876208579e2e92bfac173fb27527e6c4fb575e",
|
|
65
66
|
"worker/src/utils/log-sanitize.ts": "f4591089c16a34e4cbc271ec22b48566b970a62e30d3e9856b7dcd9c479fb0e8",
|
|
66
67
|
"worker/src/utils/managed-groups/errors.ts": "18d952edd7f46bb7e459d4e6678226f4bd6e040ab40073ee5a8d0802be2f3721",
|
|
@@ -68,10 +69,10 @@
|
|
|
68
69
|
"worker/src/utils/platform-compile-failure.ts": "eb4cea8a54599e2ca852b67f576a4402fb0281da4c7f45a7ed735bc36a684883",
|
|
69
70
|
"worker/src/utils/project-custom-hosts.ts": "ef693b4ea70f93fd66f3b3cda88ce68664540366caa33fa0169bf7bcfce80b2a",
|
|
70
71
|
"worker/src/utils/public-urls.ts": "44e455118f85c111316f6d8346d61e736ffcd1971c4539ea146100084aa6f21e",
|
|
71
|
-
"worker/src/utils/reference-check-inputs.ts": "
|
|
72
|
+
"worker/src/utils/reference-check-inputs.ts": "32f01f67fd971cf526af13385fbe6ae3d7876d0d15c4e8098069203eefa5e22e",
|
|
72
73
|
"worker/src/utils/telegram-attempt-receipts.ts": "a9ba55ae71f63ada44a105f1ceae04b0491bda0d6e77e5762db2dbecdd2981dd",
|
|
73
74
|
"worker/src/utils/telegram.ts": "9aaaa2597c366da1eeee9e2252e9b73e611ea97ed9558f7e07e694d9b393f053",
|
|
74
75
|
"worker/src/utils/workers-ai-comparison.ts": "18b5d5ea96f817387a5ef49733ba611c99cbb14987143c28118b1c90f3b637d4"
|
|
75
76
|
},
|
|
76
|
-
"sha256": "
|
|
77
|
+
"sha256": "38338fa7baa58d409e17b7ce199c1088437734d1397d8384d0ee965ce26f864e"
|
|
77
78
|
}
|
|
@@ -1123,9 +1123,13 @@ type SomewhereDbColumn<T extends string> = Extract<keyof SomewhereDbRow<T>, stri
|
|
|
1123
1123
|
type SomewhereDbRelations<T extends string> = __SomewhereDeclared<T, 'relations', Record<string, unknown>>;
|
|
1124
1124
|
type SomewhereDbRelationName<T extends string> = Extract<keyof SomewhereDbRelations<T>, string>;
|
|
1125
1125
|
// A column list narrows the rows to those columns; each included relation adds
|
|
1126
|
-
// its related rows under its name.
|
|
1126
|
+
// its related rows under its name. An empty list selects all columns, just as
|
|
1127
|
+
// the structured query does when columns is omitted.
|
|
1128
|
+
type __SomewhereDbSelectedColumns<T extends string, C> = [C] extends [readonly []]
|
|
1129
|
+
? keyof SomewhereDbRow<T>
|
|
1130
|
+
: Extract<C extends readonly (infer K)[] ? K : never, keyof SomewhereDbRow<T>>;
|
|
1127
1131
|
type SomewhereDbReadRow<T extends string, C, I> = T extends keyof SomewhereDeclaredTables
|
|
1128
|
-
? Pick<SomewhereDbRow<T>,
|
|
1132
|
+
? Pick<SomewhereDbRow<T>, __SomewhereDbSelectedColumns<T, C>>
|
|
1129
1133
|
& Pick<SomewhereDbRelations<T>, Extract<I extends readonly (infer K)[] ? K : never, keyof SomewhereDbRelations<T>>>
|
|
1130
1134
|
: Record<string, unknown>;
|
|
1131
1135
|
type SomewhereDbReadOptionsFor<T extends string, C, I> = Omit<SomewhereDbReadOptions, 'columns' | 'include'> & {
|
|
@@ -4511,8 +4515,8 @@ var require_consumer_contract = __commonJS({
|
|
|
4511
4515
|
"worker/containers/compile/consumer-contract.cjs"(exports2, module2) {
|
|
4512
4516
|
"use strict";
|
|
4513
4517
|
var CONSUMER_CONTRACT2 = Object.freeze({
|
|
4514
|
-
version:
|
|
4515
|
-
digest: "
|
|
4518
|
+
version: 40,
|
|
4519
|
+
digest: "5a319ea5f381a0b3a0847d0b7a1ee3504b434c364fa7dfa338ebf71da502e329"
|
|
4516
4520
|
});
|
|
4517
4521
|
var MEMBERSHIPS = "memberships: table({ id: id(), team_id: text(), member_id: text() }, { scope: owner(), client: { read: true } }),";
|
|
4518
4522
|
var SHARES = "shares: table({ id: id(), grantee_id: text() }, { scope: owner(), client: { read: true, create: ['grantee_id'], delete: true }, unique: [['user_id', 'grantee_id']] }),";
|
|
@@ -4629,6 +4633,7 @@ __export(declared_data_vendor_entry_exports, {
|
|
|
4629
4633
|
declaredTablesFromFiles: () => declaredTablesFromFiles,
|
|
4630
4634
|
filesDeclarationFromFiles: () => filesDeclarationFromFiles,
|
|
4631
4635
|
generateFromFiles: () => generateFromFiles,
|
|
4636
|
+
isPlainPageScript: () => isPlainPageScript,
|
|
4632
4637
|
isRuntimeEndpointGlobal: () => isRuntimeEndpointGlobal,
|
|
4633
4638
|
localDeclarationFromFiles: () => localDeclarationFromFiles,
|
|
4634
4639
|
parseConsumerContractHeader: () => import_consumer_contract.parseConsumerContractHeader,
|
|
@@ -8648,6 +8653,11 @@ function referenceCheckDeclarations(graphFiles) {
|
|
|
8648
8653
|
hasSchema: graphFiles["db/schema.ts"] !== void 0
|
|
8649
8654
|
});
|
|
8650
8655
|
}
|
|
8656
|
+
function isPlainPageScript(file, functions) {
|
|
8657
|
+
if (!/\.(?:js|jsx|mjs|cjs)$/i.test(file)) return false;
|
|
8658
|
+
if (typeof functions?.[file] === "string") return false;
|
|
8659
|
+
return !file.startsWith("functions/");
|
|
8660
|
+
}
|
|
8651
8661
|
var RUNTIME_ENDPOINT_ACCESS = /^sw(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*\??\.(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*endpoint(?![\w$])/;
|
|
8652
8662
|
function isRuntimeEndpointGlobal(diag, functions) {
|
|
8653
8663
|
if (!/^Cannot find name 'sw'\./.test(diag.message)) return false;
|
|
@@ -8692,6 +8702,7 @@ function filesDeclarationFromFiles(files) {
|
|
|
8692
8702
|
declaredTablesFromFiles,
|
|
8693
8703
|
filesDeclarationFromFiles,
|
|
8694
8704
|
generateFromFiles,
|
|
8705
|
+
isPlainPageScript,
|
|
8695
8706
|
isRuntimeEndpointGlobal,
|
|
8696
8707
|
localDeclarationFromFiles,
|
|
8697
8708
|
parseConsumerContractHeader,
|
package/src/testing.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { ApiClient } from './lib/client.js';
|
|
2
|
+
import { getToken, loadProjectConfig } from './lib/config.js';
|
|
3
|
+
import { fixtureTestTarget, type TestTarget } from './lib/test-target.js';
|
|
4
|
+
|
|
1
5
|
// Node 22.19+: native fetch, cookie storage and TypeScript; no test dependencies.
|
|
2
6
|
export class UserSession {
|
|
3
7
|
readonly origin: string;
|
|
4
8
|
private cookies = new Map<string, string>();
|
|
9
|
+
private target?: Promise<TestTarget>;
|
|
5
10
|
constructor(baseUrl: string) { this.origin = new URL(baseUrl).origin; }
|
|
6
11
|
async request(path: string, init: RequestInit = {}): Promise<Response> {
|
|
7
12
|
const url = new URL(path, this.origin);
|
|
@@ -20,9 +25,18 @@ export class UserSession {
|
|
|
20
25
|
post(path: string, body: unknown): Promise<Response> {
|
|
21
26
|
return this.request(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
data(table: string,
|
|
25
|
-
|
|
28
|
+
/** Use this session's cookies and the linked app's declared data contract. */
|
|
29
|
+
data(table: string, request: DataRequest): Promise<Response>;
|
|
30
|
+
data(table: string, contract: string, request: DataRequest): Promise<Response>;
|
|
31
|
+
async data(table: string, requestOrContract: DataRequest | string, request?: DataRequest): Promise<Response> {
|
|
32
|
+
if (typeof requestOrContract === 'string') {
|
|
33
|
+
return this.post('/__sw/data', { ...request, table, contract: requestOrContract });
|
|
34
|
+
}
|
|
35
|
+
const projectId = loadProjectConfig()?.project_id;
|
|
36
|
+
if (!projectId) throw new Error('Use the data helper from a linked project folder.');
|
|
37
|
+
const target = await (this.target ??= fixtureTestTarget(new ApiClient(process.env.SW_TEST_TARGET ? null : getToken()), projectId));
|
|
38
|
+
if (target.origin !== this.origin) throw new Error('This session belongs to a different app than the linked test target.');
|
|
39
|
+
return this.post('/__sw/data', { ...requestOrContract, table, contract: target.contractDigest ?? '' });
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
export type DataRequest =
|