@forgecart/cli 2.202610141814.0 → 2.202610141948.0
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/src/admin-api/admin-api.answer.d.ts +26 -0
- package/dist/src/admin-api/admin-api.answer.js +43 -0
- package/dist/src/admin-api/admin-api.answer.js.map +1 -0
- package/dist/src/admin-api/admin-api.client.d.ts +6 -4
- package/dist/src/admin-api/admin-api.client.js +19 -15
- package/dist/src/admin-api/admin-api.client.js.map +1 -1
- package/dist/src/admin-api/admin-api.result.d.ts +15 -9
- package/dist/src/admin-api/admin-api.result.js +45 -30
- package/dist/src/admin-api/admin-api.result.js.map +1 -1
- package/dist/src/authorization/cli-authorization.client.d.ts +4 -3
- package/dist/src/authorization/cli-authorization.client.js +18 -13
- package/dist/src/authorization/cli-authorization.client.js.map +1 -1
- package/dist/src/commands/sync.js +1 -1
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/sync/sync-bundle-push.d.ts +15 -3
- package/dist/src/sync/sync-bundle-push.js +45 -2
- package/dist/src/sync/sync-bundle-push.js.map +1 -1
- package/dist/src/sync/sync-record.file.d.ts +27 -3
- package/dist/src/sync/sync-record.file.js +77 -25
- package/dist/src/sync/sync-record.file.js.map +1 -1
- package/dist/src/sync/sync-rejection.d.ts +24 -0
- package/dist/src/sync/sync-rejection.js +58 -0
- package/dist/src/sync/sync-rejection.js.map +1 -0
- package/dist/src/sync/sync-repository.d.ts +9 -1
- package/dist/src/sync/sync-repository.js +23 -1
- package/dist/src/sync/sync-repository.js.map +1 -1
- package/dist/src/sync/sync-round-follow.d.ts +42 -0
- package/dist/src/sync/sync-round-follow.js +128 -0
- package/dist/src/sync/sync-round-follow.js.map +1 -0
- package/dist/src/sync/sync-round.d.ts +49 -8
- package/dist/src/sync/sync-round.js +134 -27
- package/dist/src/sync/sync-round.js.map +1 -1
- package/dist/src/sync/sync.runner.d.ts +4 -2
- package/dist/src/sync/sync.runner.js +6 -3
- package/dist/src/sync/sync.runner.js.map +1 -1
- package/dist/src/sync/type/sync.types.d.ts +78 -2
- package/dist/src/sync/type/sync.types.js +31 -0
- package/dist/src/sync/type/sync.types.js.map +1 -1
- package/dist/src/sync/workspace-sync.client.d.ts +29 -6
- package/dist/src/sync/workspace-sync.client.js +141 -21
- package/dist/src/sync/workspace-sync.client.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AdminApiResponse } from './type/admin-api.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One HTTP answer of the admin API to one operation (factory task 2481), as an
|
|
4
|
+
* error names it when the CLI cannot take it: the endpoint, the operation, the
|
|
5
|
+
* HTTP status the answer came with and the first bytes of its body. An answer
|
|
6
|
+
* that is no GraphQL response — the page or the JSON body an edge in front of
|
|
7
|
+
* the admin API answers a request it held past its own bound with — is so
|
|
8
|
+
* named for what it is, never as a result the CLI could not read.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AdminApiAnswer {
|
|
11
|
+
readonly endpoint: string;
|
|
12
|
+
readonly field: string;
|
|
13
|
+
/** The answer's whole body, as text. */
|
|
14
|
+
readonly text: string;
|
|
15
|
+
private readonly status;
|
|
16
|
+
/**
|
|
17
|
+
* @param endpoint the admin API the answer came from.
|
|
18
|
+
* @param field the root field of the operation it answers.
|
|
19
|
+
* @param response the answer's HTTP status and its whole body.
|
|
20
|
+
*/
|
|
21
|
+
constructor(endpoint: string, field: string, response: AdminApiResponse);
|
|
22
|
+
/** The error an answer the CLI cannot take ends the run with: what it carries, its HTTP status and its body's first bytes. */
|
|
23
|
+
unusable(carrying: string, options?: ErrorOptions): Error;
|
|
24
|
+
/** The body's first bytes — at most {@link BODY_HEAD_BYTES} of them — or that it is empty. */
|
|
25
|
+
private bodyHead;
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The most bytes of an answer's body an error names. */
|
|
2
|
+
const BODY_HEAD_BYTES = 300;
|
|
3
|
+
/**
|
|
4
|
+
* One HTTP answer of the admin API to one operation (factory task 2481), as an
|
|
5
|
+
* error names it when the CLI cannot take it: the endpoint, the operation, the
|
|
6
|
+
* HTTP status the answer came with and the first bytes of its body. An answer
|
|
7
|
+
* that is no GraphQL response — the page or the JSON body an edge in front of
|
|
8
|
+
* the admin API answers a request it held past its own bound with — is so
|
|
9
|
+
* named for what it is, never as a result the CLI could not read.
|
|
10
|
+
*/
|
|
11
|
+
export class AdminApiAnswer {
|
|
12
|
+
endpoint;
|
|
13
|
+
field;
|
|
14
|
+
/** The answer's whole body, as text. */
|
|
15
|
+
text;
|
|
16
|
+
status;
|
|
17
|
+
/**
|
|
18
|
+
* @param endpoint the admin API the answer came from.
|
|
19
|
+
* @param field the root field of the operation it answers.
|
|
20
|
+
* @param response the answer's HTTP status and its whole body.
|
|
21
|
+
*/
|
|
22
|
+
constructor(endpoint, field, response) {
|
|
23
|
+
this.endpoint = endpoint;
|
|
24
|
+
this.field = field;
|
|
25
|
+
this.text = response.text;
|
|
26
|
+
this.status = response.status;
|
|
27
|
+
}
|
|
28
|
+
/** The error an answer the CLI cannot take ends the run with: what it carries, its HTTP status and its body's first bytes. */
|
|
29
|
+
unusable(carrying, options) {
|
|
30
|
+
return new Error(`The admin API at ${this.endpoint} answered ${this.field} with HTTP ${String(this.status)} and ${carrying}; ${this.bodyHead()}`, options);
|
|
31
|
+
}
|
|
32
|
+
/** The body's first bytes — at most {@link BODY_HEAD_BYTES} of them — or that it is empty. */
|
|
33
|
+
bodyHead() {
|
|
34
|
+
const body = Buffer.from(this.text, 'utf8');
|
|
35
|
+
if (body.length === 0)
|
|
36
|
+
return 'its body is empty.';
|
|
37
|
+
const head = body.subarray(0, BODY_HEAD_BYTES).toString('utf8');
|
|
38
|
+
if (body.length <= BODY_HEAD_BYTES)
|
|
39
|
+
return `its body: ${head}`;
|
|
40
|
+
return `the first ${String(BODY_HEAD_BYTES)} of its ${String(body.length)} body bytes: ${head}`;
|
|
41
|
+
}
|
|
42
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,CAAC,eAAe,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC;IAClG,CAAC;CACF"}
|
|
@@ -9,7 +9,10 @@ import type { AdminApiRequest } from './type/admin-api.types.js';
|
|
|
9
9
|
* exchange is bounded by `--timeout` and ends when the interrupt it is given
|
|
10
10
|
* fires. Credentials the API refuses are a {@link CliCredentialsRefusal}, which
|
|
11
11
|
* the credential step answers by authorizing. Any other refusal is an
|
|
12
|
-
* {@link AdminApiRefusal} carrying its code.
|
|
12
|
+
* {@link AdminApiRefusal} carrying its code. An answer that is no GraphQL
|
|
13
|
+
* response — no JSON, JSON with neither `data` nor `errors`, or `data` without
|
|
14
|
+
* the operation's root field — ends the run naming the HTTP status it came
|
|
15
|
+
* with and the first bytes of its body ({@link AdminApiAnswer}).
|
|
13
16
|
*/
|
|
14
17
|
export declare class AdminApiClient {
|
|
15
18
|
private readonly credentials;
|
|
@@ -33,9 +36,9 @@ export declare class AdminApiClient {
|
|
|
33
36
|
private post;
|
|
34
37
|
/** Why an exchange ended without an answer: the interrupt, `--timeout`, or the network. */
|
|
35
38
|
private exchangeFailure;
|
|
36
|
-
/** The
|
|
39
|
+
/** The answer's GraphQL body — an answer that is not one is named by its status and its first bytes. */
|
|
37
40
|
private parseBody;
|
|
38
|
-
/** The root field, once the body carries no error. */
|
|
41
|
+
/** The root field, once the body carries no error and data that holds it. */
|
|
39
42
|
private rootField;
|
|
40
43
|
/**
|
|
41
44
|
* A GraphQL error ends the call. Refused credentials end it as a
|
|
@@ -49,7 +52,6 @@ export declare class AdminApiClient {
|
|
|
49
52
|
private messageOf;
|
|
50
53
|
/** The variables a typed error carries, as text — none when it carries none. */
|
|
51
54
|
private errorVariables;
|
|
52
|
-
private notGraphQlMessage;
|
|
53
55
|
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
54
56
|
private failureDetail;
|
|
55
57
|
}
|
|
@@ -2,6 +2,7 @@ import { CliCredentialsRefusal } from '../authorization/cli-unauthorized-refusal
|
|
|
2
2
|
import { isJsonObject } from '../json.js';
|
|
3
3
|
import { AdminApiInterruption } from './admin-api-interruption.error.js';
|
|
4
4
|
import { AdminApiRefusal } from './admin-api-refusal.error.js';
|
|
5
|
+
import { AdminApiAnswer } from './admin-api.answer.js';
|
|
5
6
|
import { AdminApiResult } from './admin-api.result.js';
|
|
6
7
|
/** Milliseconds in a second — `--timeout` is given in seconds. */
|
|
7
8
|
const MS_PER_SECOND = 1000;
|
|
@@ -13,7 +14,10 @@ const MS_PER_SECOND = 1000;
|
|
|
13
14
|
* exchange is bounded by `--timeout` and ends when the interrupt it is given
|
|
14
15
|
* fires. Credentials the API refuses are a {@link CliCredentialsRefusal}, which
|
|
15
16
|
* the credential step answers by authorizing. Any other refusal is an
|
|
16
|
-
* {@link AdminApiRefusal} carrying its code.
|
|
17
|
+
* {@link AdminApiRefusal} carrying its code. An answer that is no GraphQL
|
|
18
|
+
* response — no JSON, JSON with neither `data` nor `errors`, or `data` without
|
|
19
|
+
* the operation's root field — ends the run naming the HTTP status it came
|
|
20
|
+
* with and the first bytes of its body ({@link AdminApiAnswer}).
|
|
17
21
|
*/
|
|
18
22
|
export class AdminApiClient {
|
|
19
23
|
credentials;
|
|
@@ -58,8 +62,8 @@ export class AdminApiClient {
|
|
|
58
62
|
if (interrupt?.aborted === true)
|
|
59
63
|
bound.abort();
|
|
60
64
|
try {
|
|
61
|
-
const
|
|
62
|
-
return this.rootField(this.
|
|
65
|
+
const response = await this.post(request, bound.signal, field, interrupt);
|
|
66
|
+
return this.rootField(new AdminApiAnswer(this.endpoint, field, response));
|
|
63
67
|
}
|
|
64
68
|
finally {
|
|
65
69
|
clearTimeout(timer);
|
|
@@ -93,24 +97,27 @@ export class AdminApiClient {
|
|
|
93
97
|
}
|
|
94
98
|
return new Error(`Could not reach the admin API at ${this.endpoint}: ${this.failureDetail(error)}.`, { cause: error });
|
|
95
99
|
}
|
|
96
|
-
/** The
|
|
97
|
-
parseBody(
|
|
100
|
+
/** The answer's GraphQL body — an answer that is not one is named by its status and its first bytes. */
|
|
101
|
+
parseBody(answer) {
|
|
98
102
|
let parsed;
|
|
99
103
|
try {
|
|
100
|
-
parsed = JSON.parse(text);
|
|
104
|
+
parsed = JSON.parse(answer.text);
|
|
101
105
|
}
|
|
102
106
|
catch (error) {
|
|
103
|
-
throw
|
|
107
|
+
throw answer.unusable('a body that is no GraphQL response', { cause: error });
|
|
104
108
|
}
|
|
105
109
|
if (!isJsonObject(parsed))
|
|
106
|
-
throw
|
|
110
|
+
throw answer.unusable('a body that is no GraphQL response');
|
|
107
111
|
return parsed;
|
|
108
112
|
}
|
|
109
|
-
/** The root field, once the body carries no error. */
|
|
110
|
-
rootField(
|
|
111
|
-
this.
|
|
113
|
+
/** The root field, once the body carries no error and data that holds it. */
|
|
114
|
+
rootField(answer) {
|
|
115
|
+
const body = this.parseBody(answer);
|
|
116
|
+
this.assertNoErrors(body.errors, answer.field);
|
|
117
|
+
if (!('data' in body))
|
|
118
|
+
throw answer.unusable('a body carrying neither data nor errors');
|
|
112
119
|
const data = body.data;
|
|
113
|
-
return AdminApiResult.of(
|
|
120
|
+
return AdminApiResult.of(answer, isJsonObject(data) ? data[answer.field] : undefined);
|
|
114
121
|
}
|
|
115
122
|
/**
|
|
116
123
|
* A GraphQL error ends the call. Refused credentials end it as a
|
|
@@ -145,9 +152,6 @@ export class AdminApiClient {
|
|
|
145
152
|
typeof value === 'string' ? value : JSON.stringify(value),
|
|
146
153
|
]));
|
|
147
154
|
}
|
|
148
|
-
notGraphQlMessage(status) {
|
|
149
|
-
return `The admin API at ${this.endpoint} answered HTTP ${String(status)} without a GraphQL response.`;
|
|
150
|
-
}
|
|
151
155
|
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
152
156
|
failureDetail(error) {
|
|
153
157
|
const cause = error instanceof Error ? error.cause : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-api.client.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,kEAAkE;AAClE,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B
|
|
1
|
+
{"version":3,"file":"admin-api.client.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,kEAAkE;AAClE,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAc;IAMN;IACA;IANnB;;;OAGG;IACH,YACmB,WAA2B,EAC3B,cAAsB;QADtB,gBAAW,GAAX,WAAW,CAAgB;QAC3B,mBAAc,GAAd,cAAc,CAAQ;IACtC,CAAC;IAEJ,iCAAiC;IACjC,WAAW,CAAC,QAAgB,EAAE,SAAkC;QAC9D,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;YACpD,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,cAAc,EAAE,k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,aAAa,CAAC,KAAc;QAClC,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/D,IAAI,KAAK,YAAY,KAAK;YAAE,OAAO,KAAK,CAAC,OAAO,CAAC;QACjD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import type { AdminApiAnswer } from './admin-api.answer.js';
|
|
1
2
|
/**
|
|
2
3
|
* One operation's root field as the admin API answered it (#2781, #411), read
|
|
3
|
-
* field by field: a value the CLI cannot
|
|
4
|
-
* and the
|
|
4
|
+
* field by field: a value the CLI cannot take is an error naming the endpoint,
|
|
5
|
+
* the operation, the field, the HTTP status and the first bytes of the answer
|
|
6
|
+
* (factory task 2481) — never a guess.
|
|
5
7
|
*/
|
|
6
8
|
export declare class AdminApiResult {
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly field;
|
|
9
|
+
private readonly answer;
|
|
9
10
|
private readonly record;
|
|
10
11
|
private constructor();
|
|
11
|
-
/** The root field
|
|
12
|
-
static of(
|
|
13
|
-
/** The error an answer the CLI cannot read ends the run with. */
|
|
14
|
-
private static unreadable;
|
|
12
|
+
/** The root field the answer carries — it must be an object. */
|
|
13
|
+
static of(answer: AdminApiAnswer, value: unknown): AdminApiResult;
|
|
15
14
|
/** A string field that must carry text. */
|
|
16
15
|
readString(key: string): string;
|
|
17
16
|
/** A string field that may be empty. */
|
|
@@ -20,12 +19,19 @@ export declare class AdminApiResult {
|
|
|
20
19
|
readStringList(key: string): string[];
|
|
21
20
|
/** A string field that must carry one of the values `accepts` admits. */
|
|
22
21
|
readMember<T extends string>(key: string, accepts: (value: string) => value is T): T;
|
|
22
|
+
/** An object field, read field by field as a result of the same operation. */
|
|
23
|
+
readObject(key: string): AdminApiResult;
|
|
24
|
+
/** An object field that may be null — null when it is. */
|
|
25
|
+
readNullableObject(key: string): AdminApiResult | null;
|
|
23
26
|
/** A list of objects, each read field by field as a result of the same operation. */
|
|
24
27
|
readObjectList(key: string): AdminApiResult[];
|
|
25
28
|
readCount(key: string): number;
|
|
29
|
+
/** A whole number of zero or more that may be null — null when it is. */
|
|
30
|
+
readNullableCount(key: string): number | null;
|
|
26
31
|
readCountList(key: string): number[];
|
|
27
32
|
readBoolean(key: string): boolean;
|
|
28
33
|
/** A whole number of zero or more. */
|
|
29
34
|
private isCount;
|
|
30
|
-
|
|
35
|
+
/** The error a field the CLI cannot take ends the run with, naming the field. */
|
|
36
|
+
private unusable;
|
|
31
37
|
}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
1
|
import { isJsonObject } from '../json.js';
|
|
2
2
|
/**
|
|
3
3
|
* One operation's root field as the admin API answered it (#2781, #411), read
|
|
4
|
-
* field by field: a value the CLI cannot
|
|
5
|
-
* and the
|
|
4
|
+
* field by field: a value the CLI cannot take is an error naming the endpoint,
|
|
5
|
+
* the operation, the field, the HTTP status and the first bytes of the answer
|
|
6
|
+
* (factory task 2481) — never a guess.
|
|
6
7
|
*/
|
|
7
8
|
export class AdminApiResult {
|
|
8
|
-
|
|
9
|
-
field;
|
|
9
|
+
answer;
|
|
10
10
|
record;
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.field = field;
|
|
11
|
+
constructor(answer, record) {
|
|
12
|
+
this.answer = answer;
|
|
14
13
|
this.record = record;
|
|
15
14
|
}
|
|
16
|
-
/** The root field
|
|
17
|
-
static of(
|
|
15
|
+
/** The root field the answer carries — it must be an object. */
|
|
16
|
+
static of(answer, value) {
|
|
18
17
|
if (!isJsonObject(value))
|
|
19
|
-
throw
|
|
20
|
-
return new AdminApiResult(
|
|
21
|
-
}
|
|
22
|
-
/** The error an answer the CLI cannot read ends the run with. */
|
|
23
|
-
static unreadable(endpoint, field) {
|
|
24
|
-
return new Error(`The admin API at ${endpoint} answered a ${field} result the CLI cannot read.`);
|
|
18
|
+
throw answer.unusable(`no ${answer.field} result in its data`);
|
|
19
|
+
return new AdminApiResult(answer, value);
|
|
25
20
|
}
|
|
26
21
|
/** A string field that must carry text. */
|
|
27
22
|
readString(key) {
|
|
28
23
|
const value = this.record[key];
|
|
29
24
|
if (typeof value !== 'string' || value === '')
|
|
30
|
-
throw this.
|
|
25
|
+
throw this.unusable(key);
|
|
31
26
|
return value;
|
|
32
27
|
}
|
|
33
28
|
/** A string field that may be empty. */
|
|
34
29
|
readText(key) {
|
|
35
30
|
const value = this.record[key];
|
|
36
31
|
if (typeof value !== 'string')
|
|
37
|
-
throw this.
|
|
32
|
+
throw this.unusable(key);
|
|
38
33
|
return value;
|
|
39
34
|
}
|
|
40
35
|
readNullableString(key) {
|
|
@@ -42,16 +37,16 @@ export class AdminApiResult {
|
|
|
42
37
|
if (value === null)
|
|
43
38
|
return null;
|
|
44
39
|
if (typeof value !== 'string')
|
|
45
|
-
throw this.
|
|
40
|
+
throw this.unusable(key);
|
|
46
41
|
return value;
|
|
47
42
|
}
|
|
48
43
|
readStringList(key) {
|
|
49
44
|
const value = this.record[key];
|
|
50
45
|
if (!Array.isArray(value))
|
|
51
|
-
throw this.
|
|
46
|
+
throw this.unusable(key);
|
|
52
47
|
const items = value;
|
|
53
48
|
if (!items.every((item) => typeof item === 'string')) {
|
|
54
|
-
throw this.
|
|
49
|
+
throw this.unusable(key);
|
|
55
50
|
}
|
|
56
51
|
return items;
|
|
57
52
|
}
|
|
@@ -59,46 +54,66 @@ export class AdminApiResult {
|
|
|
59
54
|
readMember(key, accepts) {
|
|
60
55
|
const value = this.readString(key);
|
|
61
56
|
if (!accepts(value))
|
|
62
|
-
throw this.
|
|
57
|
+
throw this.unusable(key);
|
|
63
58
|
return value;
|
|
64
59
|
}
|
|
60
|
+
/** An object field, read field by field as a result of the same operation. */
|
|
61
|
+
readObject(key) {
|
|
62
|
+
const value = this.record[key];
|
|
63
|
+
if (!isJsonObject(value))
|
|
64
|
+
throw this.unusable(key);
|
|
65
|
+
return new AdminApiResult(this.answer, value);
|
|
66
|
+
}
|
|
67
|
+
/** An object field that may be null — null when it is. */
|
|
68
|
+
readNullableObject(key) {
|
|
69
|
+
if (this.record[key] === null)
|
|
70
|
+
return null;
|
|
71
|
+
return this.readObject(key);
|
|
72
|
+
}
|
|
65
73
|
/** A list of objects, each read field by field as a result of the same operation. */
|
|
66
74
|
readObjectList(key) {
|
|
67
75
|
const value = this.record[key];
|
|
68
76
|
if (!Array.isArray(value))
|
|
69
|
-
throw this.
|
|
77
|
+
throw this.unusable(key);
|
|
70
78
|
const items = value;
|
|
71
79
|
if (!items.every(isJsonObject))
|
|
72
|
-
throw this.
|
|
73
|
-
return items.map((item) => new AdminApiResult(this.
|
|
80
|
+
throw this.unusable(key);
|
|
81
|
+
return items.map((item) => new AdminApiResult(this.answer, item));
|
|
74
82
|
}
|
|
75
83
|
readCount(key) {
|
|
76
84
|
const value = this.record[key];
|
|
77
85
|
if (!this.isCount(value))
|
|
78
|
-
throw this.
|
|
86
|
+
throw this.unusable(key);
|
|
79
87
|
return value;
|
|
80
88
|
}
|
|
89
|
+
/** A whole number of zero or more that may be null — null when it is. */
|
|
90
|
+
readNullableCount(key) {
|
|
91
|
+
if (this.record[key] === null)
|
|
92
|
+
return null;
|
|
93
|
+
return this.readCount(key);
|
|
94
|
+
}
|
|
81
95
|
readCountList(key) {
|
|
82
96
|
const value = this.record[key];
|
|
83
97
|
if (!Array.isArray(value))
|
|
84
|
-
throw this.
|
|
98
|
+
throw this.unusable(key);
|
|
85
99
|
const items = value;
|
|
86
100
|
if (!items.every((item) => this.isCount(item)))
|
|
87
|
-
throw this.
|
|
101
|
+
throw this.unusable(key);
|
|
88
102
|
return items;
|
|
89
103
|
}
|
|
90
104
|
readBoolean(key) {
|
|
91
105
|
const value = this.record[key];
|
|
92
106
|
if (typeof value !== 'boolean')
|
|
93
|
-
throw this.
|
|
107
|
+
throw this.unusable(key);
|
|
94
108
|
return value;
|
|
95
109
|
}
|
|
96
110
|
/** A whole number of zero or more. */
|
|
97
111
|
isCount(value) {
|
|
98
112
|
return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
|
|
99
113
|
}
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
/** The error a field the CLI cannot take ends the run with, naming the field. */
|
|
115
|
+
unusable(key) {
|
|
116
|
+
return this.answer.unusable(`a ${this.answer.field} result whose ${key} the CLI does not take`);
|
|
102
117
|
}
|
|
103
118
|
}
|
|
104
119
|
//# sourceMappingURL=admin-api.result.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-api.result.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"admin-api.result.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAEN;IACA;IAFnB,YACmB,MAAsB,EACtB,MAA+B;QAD/B,WAAM,GAAN,MAAM,CAAgB;QACtB,WAAM,GAAN,MAAM,CAAyB;IAC/C,CAAC;IAEJ,gEAAgE;IAChE,MAAM,CAAC,EAAE,CAAC,MAAsB,EAAE,KAAc;QAC9C,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,MAAM,CAAC,KAAK,qBAAqB,CAAC,CAAC;QACzF,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,2CAA2C;IAC3C,UAAU,CAAC,GAAW;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,OAAO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MAAM,CAAC,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,CAAC;IAClG,CAAC;CACF"}
|
|
@@ -3,7 +3,9 @@ import { type CliAuthorizationRequestInput, type CliAuthorizationRequestResult,
|
|
|
3
3
|
* The admin API's two Public CLI authorization operations, over GraphQL on
|
|
4
4
|
* HTTP — the CLI ships no WebSocket client, and both operations are single
|
|
5
5
|
* request/response exchanges. Every answer is read field by field: a result
|
|
6
|
-
* the CLI
|
|
6
|
+
* the CLI does not take is an error naming the endpoint, never a guess, and an
|
|
7
|
+
* answer that is no GraphQL response names its HTTP status and the first bytes
|
|
8
|
+
* of its body (factory task 2481).
|
|
7
9
|
*/
|
|
8
10
|
export declare class CliAuthorizationClient {
|
|
9
11
|
private readonly endpoint;
|
|
@@ -19,7 +21,7 @@ export declare class CliAuthorizationClient {
|
|
|
19
21
|
/** POST one operation and answer its root field's object. */
|
|
20
22
|
private send;
|
|
21
23
|
private post;
|
|
22
|
-
/** The
|
|
24
|
+
/** The answer's GraphQL body — an answer that is not one is named by its HTTP status and its first bytes. */
|
|
23
25
|
private readBody;
|
|
24
26
|
/** A GraphQL error ends the call: a CLI authorization refusal on exit 3, anything else as an error. */
|
|
25
27
|
private assertNoErrors;
|
|
@@ -36,7 +38,6 @@ export declare class CliAuthorizationClient {
|
|
|
36
38
|
private readOptionalString;
|
|
37
39
|
private isState;
|
|
38
40
|
private unreadable;
|
|
39
|
-
private notGraphQlMessage;
|
|
40
41
|
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
41
42
|
private failureDetail;
|
|
42
43
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AdminApiAnswer } from '../admin-api/admin-api.answer.js';
|
|
1
2
|
import { isJsonObject } from '../json.js';
|
|
2
3
|
import { CliUnauthorizedReason, CliUnauthorizedRefusal } from './cli-unauthorized-refusal.js';
|
|
3
4
|
import { CliAuthorizationState, } from './type/cli-authorization.types.js';
|
|
@@ -42,7 +43,9 @@ const REFUSAL_REASONS = {
|
|
|
42
43
|
* The admin API's two Public CLI authorization operations, over GraphQL on
|
|
43
44
|
* HTTP — the CLI ships no WebSocket client, and both operations are single
|
|
44
45
|
* request/response exchanges. Every answer is read field by field: a result
|
|
45
|
-
* the CLI
|
|
46
|
+
* the CLI does not take is an error naming the endpoint, never a guess, and an
|
|
47
|
+
* answer that is no GraphQL response names its HTTP status and the first bytes
|
|
48
|
+
* of its body (factory task 2481).
|
|
46
49
|
*/
|
|
47
50
|
export class CliAuthorizationClient {
|
|
48
51
|
endpoint;
|
|
@@ -82,12 +85,18 @@ export class CliAuthorizationClient {
|
|
|
82
85
|
/** POST one operation and answer its root field's object. */
|
|
83
86
|
async send(document, variables, field) {
|
|
84
87
|
const response = await this.post(document, variables);
|
|
85
|
-
const
|
|
88
|
+
const answer = new AdminApiAnswer(this.endpoint, field, {
|
|
89
|
+
status: response.status,
|
|
90
|
+
text: await response.text(),
|
|
91
|
+
});
|
|
92
|
+
const body = this.readBody(answer);
|
|
86
93
|
this.assertNoErrors(body.errors, field);
|
|
94
|
+
if (!('data' in body))
|
|
95
|
+
throw answer.unusable('a body carrying neither data nor errors');
|
|
87
96
|
const data = body.data;
|
|
88
97
|
const result = isJsonObject(data) ? data[field] : undefined;
|
|
89
98
|
if (!isJsonObject(result))
|
|
90
|
-
throw
|
|
99
|
+
throw answer.unusable(`no ${field} result in its data`);
|
|
91
100
|
return result;
|
|
92
101
|
}
|
|
93
102
|
async post(document, variables) {
|
|
@@ -102,18 +111,17 @@ export class CliAuthorizationClient {
|
|
|
102
111
|
throw new Error(`Could not reach the admin API at ${this.endpoint}: ${this.failureDetail(error)}.`, { cause: error });
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
|
-
/** The
|
|
106
|
-
|
|
107
|
-
const text = await response.text();
|
|
114
|
+
/** The answer's GraphQL body — an answer that is not one is named by its HTTP status and its first bytes. */
|
|
115
|
+
readBody(answer) {
|
|
108
116
|
let parsed;
|
|
109
117
|
try {
|
|
110
|
-
parsed = JSON.parse(text);
|
|
118
|
+
parsed = JSON.parse(answer.text);
|
|
111
119
|
}
|
|
112
120
|
catch (error) {
|
|
113
|
-
throw
|
|
121
|
+
throw answer.unusable('a body that is no GraphQL response', { cause: error });
|
|
114
122
|
}
|
|
115
123
|
if (!isJsonObject(parsed))
|
|
116
|
-
throw
|
|
124
|
+
throw answer.unusable('a body that is no GraphQL response');
|
|
117
125
|
return parsed;
|
|
118
126
|
}
|
|
119
127
|
/** A GraphQL error ends the call: a CLI authorization refusal on exit 3, anything else as an error. */
|
|
@@ -179,10 +187,7 @@ export class CliAuthorizationClient {
|
|
|
179
187
|
return Object.values(CliAuthorizationState).includes(value);
|
|
180
188
|
}
|
|
181
189
|
unreadable(field) {
|
|
182
|
-
return new Error(`The admin API at ${this.endpoint} answered a ${field} result the CLI
|
|
183
|
-
}
|
|
184
|
-
notGraphQlMessage(status) {
|
|
185
|
-
return `The admin API at ${this.endpoint} answered HTTP ${String(status)} without a GraphQL response.`;
|
|
190
|
+
return new Error(`The admin API at ${this.endpoint} answered a ${field} result the CLI does not take.`);
|
|
186
191
|
}
|
|
187
192
|
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
188
193
|
failureDetail(error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-authorization.client.js","sourceRoot":"","sources":["../../../src/authorization/cli-authorization.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EACL,qBAAqB,GAMtB,MAAM,mCAAmC,CAAC;AAE3C,0GAA0G;AAC1G,MAAM,gBAAgB,GAAG;;;;;;;;EAQvB,CAAC;AAEH;;;GAGG;AACH,MAAM,eAAe,GAAG;;;;;;;;;;;;EAYtB,CAAC;AAEH;;;;GAIG;AACH,MAAM,eAAe,GAA6D;IAChF,wBAAwB,E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AK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;YAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oFAAoF;IAC5E,kBAAkB,CAAC,KAAc,EAAE,KAAa;QACtD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QACvE,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,OAAO,CAAC,KAAc;QAC5B,OAAO,MAAM,CAAC,MAAM,CAAU,qBAAqB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAEO,UAAU,CAAC,KAAa;QAC9B,OAAO,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,QAAQ,eAAe,KAAK,gCAAgC,CAAC,CAAC;IAC1G,CAAC;IAED,mGAAmG;IAC3F,aAAa,CAAC,KAAc;QAClC,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/D,IAAI,KAAK,YAAY,KAAK;YAAE,OAAO,KAAK,CAAC,OAAO,CAAC;QACjD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -16,7 +16,7 @@ export function createSyncCommand() {
|
|
|
16
16
|
.option('--pull', "Take the workspace's tree onto this storefront; never push")
|
|
17
17
|
.option('--watch', 'Keep syncing until Ctrl-C: local edits push, workspace landings pull')
|
|
18
18
|
.option('--dry-run', 'Print the plan and every path a push would send; move nothing')
|
|
19
|
-
.addOption(new Option('--timeout <seconds>',
|
|
19
|
+
.addOption(new Option('--timeout <seconds>', "Seconds one exchange with the admin API may take before sync exits 1 — a push's landing is a round sync follows, each read its own exchange")
|
|
20
20
|
.argParser(parseTimeoutSeconds)
|
|
21
21
|
.default(SYNC_EXCHANGE_TIMEOUT_SECONDS))
|
|
22
22
|
.action(async (name, options) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;SAChC,WAAW,CACV,kKAAkK,CACnK;SACA,QAAQ,CAAC,QAAQ,EAAE,0DAA0D,CAAC;SAC9E,MAAM,CAAC,QAAQ,EAAE,4DAA4D,CAAC;SAC9E,MAAM,CAAC,SAAS,EAAE,sEAAsE,CAAC;SACzF,MAAM,CAAC,WAAW,EAAE,+DAA+D,CAAC;SACpF,SAAS,CACR,IAAI,MAAM,CACR,qBAAqB,EACrB,
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,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 +1,4 @@
|
|
|
1
|
-
import type { SyncEnvFileLines,
|
|
1
|
+
import type { SyncEnvFileLines, SyncPushRound, SyncTopLevelEntry } from './type/sync.types.js';
|
|
2
2
|
import type { WorkspaceSyncClient } from './workspace-sync.client.js';
|
|
3
3
|
/**
|
|
4
4
|
* How `forgecart sync` sends a push's bundle (factory task 2375). A bundle
|
|
@@ -10,12 +10,24 @@ import type { WorkspaceSyncClient } from './workspace-sync.client.js';
|
|
|
10
10
|
* each printed as it is sent; and ONE push naming the upload lands them as one
|
|
11
11
|
* bundle. A run cut off mid-way leaves the parts it sent on the workspace: the
|
|
12
12
|
* next run cuts the same bundle, begins it again, and sends only the rest.
|
|
13
|
+
* Either way the push answers the round it lands as (factory task 2481), and
|
|
14
|
+
* before a byte of it is sent the push prints the bundle's size and the pushed
|
|
15
|
+
* tree's top-level entries by the bytes they hold, the largest first — what
|
|
16
|
+
* makes a push large is named before it is paid for.
|
|
13
17
|
*/
|
|
14
18
|
export declare class SyncBundlePush {
|
|
15
19
|
private readonly client;
|
|
16
20
|
constructor(client: WorkspaceSyncClient);
|
|
17
|
-
/**
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Push `bundle` — its tree's top-level entries `contents` — with the merchant
|
|
23
|
+
* lines of the env files `envFiles`, whole or in parts, and answer its round.
|
|
24
|
+
*/
|
|
25
|
+
send(bundle: Buffer, contents: readonly SyncTopLevelEntry[], envFiles: readonly SyncEnvFileLines[]): Promise<SyncPushRound>;
|
|
26
|
+
/** The bundle's size, then the pushed tree's top-level entries by the bytes they hold, the largest first. */
|
|
27
|
+
private printContents;
|
|
28
|
+
/** `bytes` in the largest unit that keeps it at one or more, to one decimal — bytes as they are. */
|
|
29
|
+
private size;
|
|
30
|
+
private line;
|
|
19
31
|
/**
|
|
20
32
|
* Send every part the upload does not hold, in order, one request each, and
|
|
21
33
|
* print each as it goes — its place among the parts, and the bytes the
|