@skrr-ai/cli 0.1.165 → 0.1.166
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/commands/apps/installations/compatibility.js +1 -1
- package/dist/commands/apps/installations/migrate/abort.d.ts +13 -0
- package/dist/commands/apps/installations/migrate/abort.js +45 -0
- package/dist/commands/apps/installations/migrate/cutover.d.ts +15 -0
- package/dist/commands/apps/installations/migrate/cutover.js +102 -0
- package/dist/commands/apps/installations/migrate/plan.d.ts +13 -0
- package/dist/commands/apps/installations/migrate/plan.js +51 -0
- package/dist/commands/apps/installations/migrate/rollback.d.ts +16 -0
- package/dist/commands/apps/installations/migrate/rollback.js +103 -0
- package/dist/commands/apps/installations/migrate/stage.d.ts +15 -0
- package/dist/commands/apps/installations/migrate/stage.js +96 -0
- package/dist/commands/apps/installations/migrate/status.d.ts +12 -0
- package/dist/commands/apps/installations/migrate/status.js +52 -0
- package/dist/commands/apps/installations/migrate/validate.d.ts +14 -0
- package/dist/commands/apps/installations/migrate/validate.js +58 -0
- package/dist/commands/apps/installations/show.js +5 -6
- package/dist/commands/apps/operations/check.js +1 -1
- package/dist/commands/apps/resume.js +1 -1
- package/dist/commands/apps/settings/set.js +22 -10
- package/dist/lib/api-fetch.js +32 -5
- package/dist/lib/appCompatibility.js +1 -1
- package/dist/lib/appData.d.ts +1 -1
- package/dist/lib/appData.js +6 -2
- package/dist/lib/appDataMigration.d.ts +204 -0
- package/dist/lib/appDataMigration.js +753 -0
- package/dist/lib/appDataMigrationCommand.d.ts +39 -0
- package/dist/lib/appDataMigrationCommand.js +90 -0
- package/dist/lib/appInstallations.d.ts +8 -0
- package/dist/lib/appInstallations.js +54 -1
- package/dist/lib/apps-command.js +17 -10
- package/dist/lib/node-adapter.d.ts +0 -2
- package/dist/lib/node-adapter.js +46 -42
- package/dist/lib/rate-limit-retry.d.ts +4 -5
- package/dist/lib/rate-limit-retry.js +6 -10
- package/dist/lib/refresh.d.ts +2 -0
- package/dist/lib/refresh.js +6 -0
- package/dist/lib/write-outcome.d.ts +2 -0
- package/dist/lib/write-outcome.js +14 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +10041 -9838
- package/oclif.manifest.json +599 -3
- package/package.json +5 -2
|
@@ -35,13 +35,12 @@ class AppsInstallationsShow extends apps_command_1.AppsCommand {
|
|
|
35
35
|
this.log(`${installation.id} ${app.slug} v${version.version}`);
|
|
36
36
|
this.log(`on ${installation.principal.kind} ${installation.principal.id}; ${(0, appInstallations_1.describeAvailability)(installation.availability)}`);
|
|
37
37
|
if (installation.availability === 'suspended') {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// who suspended it, when the server says (the installation read does not today; the host view does): a moderation and a data
|
|
39
|
+
// migration are told apart, and one that is not known gets the words that are true of both
|
|
40
|
+
const source = installation.suspension?.by;
|
|
41
|
+
for (const line of (0, appInstallations_1.describeSuspensionNote)(installation.id, source, this.config.bin)) {
|
|
42
|
+
this.log(line);
|
|
40
43
|
}
|
|
41
|
-
else {
|
|
42
|
-
this.log('If you can manage this installation, find its valid installation ID before trying to resume it. Resuming may enable its jobs.');
|
|
43
|
-
}
|
|
44
|
-
this.log('Otherwise ask someone who can manage it. A moderation suspension must be lifted by the platform.');
|
|
45
44
|
}
|
|
46
45
|
this.log(`trust: ${(0, appInstallations_1.describeTrust)(installation.trust)}`);
|
|
47
46
|
const distribution = version.distribution;
|
|
@@ -23,7 +23,7 @@ function describeApplied(applied) {
|
|
|
23
23
|
return [`settings of version ${(0, appData_1.safeForTerminal)(applied.versionId)}`];
|
|
24
24
|
}
|
|
25
25
|
class AppsOperationsCheck extends apps_command_1.AppsCommand {
|
|
26
|
-
static description = 'Ask the server what became of a write to an installed app\'s data that you sent with an idempotency key and lost the answer to. The server answers "completed" (with what it applied: the collection, the document ids and revisions, for a batch every step, including the IDs it named) when it kept a receipt of that write for YOU, or "unknown" when it did not. "unknown" is NEVER "not applied": it only means no receipt is on record (the write may never have arrived, may have been refused, may still be running, may have run where no receipt is kept, or the receipt may have expired after 24 hours). It writes nothing. The key is sent in a header and never appears in a URL. `apps data put | patch | delete | batch` print the key when the outcome of a write is unknown; a write you sent yourself with --idempotency-key is asked about the same way. Only the
|
|
26
|
+
static description = 'Ask the server what became of a write to an installed app\'s data that you sent with an idempotency key and lost the answer to. The server answers "completed" (with what it applied: the collection, the document ids and revisions, for a batch every step, including the IDs it named) when it kept a receipt of that write for YOU, or "unknown" when it did not. "unknown" is NEVER "not applied": it only means no receipt is on record (the write may never have arrived, may have been refused, may still be running, may have run where no receipt is kept, or the receipt may have expired after 24 hours). It writes nothing. The key is sent in a header and never appears in a URL. `apps data put | patch | delete | batch` print the key when the outcome of a write is unknown; a write you sent yourself with --idempotency-key is asked about the same way. Only the user who made the write, with the kind of credential that made it (a person\'s sign-in, or an Agent\'s), can find its receipt.';
|
|
27
27
|
static examples = [
|
|
28
28
|
'<%= config.bin %> apps operations check appi_abc put goals main --key skrr-data:3f2b8c1e-7d44-4b1a-9a52-0c6e1d2f9a10',
|
|
29
29
|
'<%= config.bin %> apps operations check appi_abc batch --key my-nightly-import-2026-11-10 --json',
|
|
@@ -29,7 +29,7 @@ class AppsResume extends apps_command_1.AppsCommand {
|
|
|
29
29
|
this.log(`${result.installation.id} is ${(0, appInstallations_1.describeAvailability)(result.installation.availability)}`);
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
this.failInstallation(error);
|
|
32
|
+
this.failInstallation(error, { subject: args.installation });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -36,14 +36,18 @@ class AppsSettingsSet extends apps_command_1.AppsCommand {
|
|
|
36
36
|
...(0, appSettings_1.formatAppSettings)(current.configuration, settings, current.timezone),
|
|
37
37
|
...(0, appSettings_1.formatInstallDefaults)(current.configuration, settings),
|
|
38
38
|
...(current.canEdit === false
|
|
39
|
-
? [
|
|
39
|
+
? [
|
|
40
|
+
'At the time of this read, the server says settings are not editable under the current access and approval state. This may change.',
|
|
41
|
+
]
|
|
40
42
|
: current.canEdit !== true
|
|
41
43
|
? ['The server did not say whether settings are currently editable.']
|
|
42
44
|
: []),
|
|
43
45
|
...(current.canEdit === false && current.canReviewBundleApproval === true
|
|
44
|
-
? [
|
|
46
|
+
? [
|
|
47
|
+
installationForDisplay === '<installation-id>'
|
|
45
48
|
? 'To review the current version, first find a valid installation ID, then use apps reconsent without --yes.'
|
|
46
|
-
: `To review the current version, run \`${this.config.bin} apps reconsent ${installationForDisplay}\` without --yes using the same account, deployment, profile and workspace
|
|
49
|
+
: `To review the current version, run \`${this.config.bin} apps reconsent ${installationForDisplay}\` without --yes using the same account, deployment, profile and workspace.`,
|
|
50
|
+
]
|
|
47
51
|
: []),
|
|
48
52
|
];
|
|
49
53
|
if (!flags.yes)
|
|
@@ -65,9 +69,11 @@ class AppsSettingsSet extends apps_command_1.AppsCommand {
|
|
|
65
69
|
expectedGrantedAt: current.expectedGrantedAt,
|
|
66
70
|
consent: { versionId: current.expectedVersionId, bundleHash: current.bundleHash, settings },
|
|
67
71
|
});
|
|
68
|
-
if (!result ||
|
|
72
|
+
if (!result ||
|
|
73
|
+
!data_provider_1.AppSettingsSchema.safeParse(result.settings).success ||
|
|
69
74
|
!(0, data_provider_1.appSettingsEqual)(result.settings, settings) ||
|
|
70
|
-
result.expectedVersionId !== current.expectedVersionId ||
|
|
75
|
+
result.expectedVersionId !== current.expectedVersionId ||
|
|
76
|
+
result.bundleHash !== current.bundleHash ||
|
|
71
77
|
typeof result.expectedGrantedAt !== 'string' ||
|
|
72
78
|
!(Date.parse(result.expectedGrantedAt) > Date.parse(current.expectedGrantedAt)) ||
|
|
73
79
|
!data_provider_1.AppSettingsManifestSchema.safeParse(result.configuration).success) {
|
|
@@ -79,13 +85,17 @@ class AppsSettingsSet extends apps_command_1.AppsCommand {
|
|
|
79
85
|
this.log(`Saved settings for ${args.installation}. Schedule reconciliation was requested; use apps installations show to inspect job state.`);
|
|
80
86
|
}
|
|
81
87
|
catch (error) {
|
|
82
|
-
if (error instanceof Error &&
|
|
83
|
-
|
|
88
|
+
if (error instanceof Error &&
|
|
89
|
+
((0, base_command_1.isOclifExitError)(error) ||
|
|
90
|
+
typeof error.oclif?.exit === 'number'))
|
|
84
91
|
throw error;
|
|
85
92
|
if (responseValidated)
|
|
86
93
|
return this.failConfirmedDataOutput();
|
|
87
94
|
const refusal = (0, apps_1.readAppsRefusal)(error);
|
|
88
|
-
if (refusal?.error === 'consent_mismatch' &&
|
|
95
|
+
if (refusal?.error === 'consent_mismatch' &&
|
|
96
|
+
writeStarted &&
|
|
97
|
+
refusal.status === 409 &&
|
|
98
|
+
refusal.reason === 'installation_reconsent_required') {
|
|
89
99
|
return this.failWithCliError({
|
|
90
100
|
message: `This installation's current version needs approval again. Settings were not changed. Review it with \`${this.config.bin} apps reconsent ${installationForDisplay}\` (without --yes); after approving it, preview the settings again.`,
|
|
91
101
|
code: 'APP_CONSENT_MISMATCH',
|
|
@@ -95,7 +105,9 @@ class AppsSettingsSet extends apps_command_1.AppsCommand {
|
|
|
95
105
|
details: {
|
|
96
106
|
reason: refusal.reason,
|
|
97
107
|
...(refusal.docCount === undefined ? {} : { docCount: refusal.docCount }),
|
|
98
|
-
...(refusal.installationId === undefined
|
|
108
|
+
...(refusal.installationId === undefined
|
|
109
|
+
? {}
|
|
110
|
+
: { installationId: refusal.installationId }),
|
|
99
111
|
...(refusal.current ? { current: refusal.current } : {}),
|
|
100
112
|
},
|
|
101
113
|
});
|
|
@@ -124,7 +136,7 @@ class AppsSettingsSet extends apps_command_1.AppsCommand {
|
|
|
124
136
|
retryable: false,
|
|
125
137
|
});
|
|
126
138
|
}
|
|
127
|
-
this.failInstallation(error);
|
|
139
|
+
this.failInstallation(error, { subject: args.installation });
|
|
128
140
|
}
|
|
129
141
|
}
|
|
130
142
|
}
|
package/dist/lib/api-fetch.js
CHANGED
|
@@ -189,6 +189,32 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
189
189
|
(0, node_adapter_1.getAdapterCredentialOverride)() ??
|
|
190
190
|
(await (0, credential_resolver_1.resolveCredential)());
|
|
191
191
|
}
|
|
192
|
+
if (method !== 'GET' &&
|
|
193
|
+
!historyRead &&
|
|
194
|
+
!isAuthEndpoint(pathOrUrl) &&
|
|
195
|
+
cred.source !== 'flag' &&
|
|
196
|
+
(0, refresh_1.cliCredentialNeedsRefresh)(cred.token)) {
|
|
197
|
+
if (delegatedCli) {
|
|
198
|
+
const fresh = await (0, delegated_cli_1.fetchDelegatedCliCredential)(process.env, { forceRefresh: true });
|
|
199
|
+
if (fresh?.token)
|
|
200
|
+
cred = fresh;
|
|
201
|
+
}
|
|
202
|
+
else if (!autonomousCredential && (0, daemonBroker_1.isBrokeredHandoffToken)(cred.token)) {
|
|
203
|
+
const fresh = await (0, daemonBroker_1.redeemBrokeredHandoffToken)(true);
|
|
204
|
+
if (fresh?.accessToken) {
|
|
205
|
+
cred = { token: fresh.accessToken, source: 'env-token', kind: (0, credential_resolver_1.kindOf)(fresh.accessToken) };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else if (!autonomousCredential) {
|
|
209
|
+
const fresh = await (0, refresh_1.ensureFreshCliCredential)({ credential: cred });
|
|
210
|
+
if (fresh.refreshed && fresh.credential.token)
|
|
211
|
+
cred = fresh.credential;
|
|
212
|
+
}
|
|
213
|
+
// Explicit per-call authority stays local to this request.
|
|
214
|
+
if (!opts.credential)
|
|
215
|
+
(0, node_adapter_1.setAdapterCredentialOverride)(cred);
|
|
216
|
+
}
|
|
217
|
+
const replaySafe = !opts.singleAttempt && (0, write_outcome_1.isRequestReplaySafe)(method, url, callerHeaders);
|
|
192
218
|
const fetchWithCredential = async (credential) => {
|
|
193
219
|
const headers = {
|
|
194
220
|
Accept: 'application/json',
|
|
@@ -228,16 +254,17 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
228
254
|
fetched = await (0, rate_limit_retry_1.fetchWithRateLimitRetry)(() => fetch(url, {
|
|
229
255
|
method,
|
|
230
256
|
headers: sent,
|
|
231
|
-
...(historyRead ||
|
|
257
|
+
...(historyRead || !replaySafe || method !== 'GET'
|
|
232
258
|
? { redirect: 'error' }
|
|
233
259
|
: (0, task_runtime_headers_1.taskRuntimeRedirectOptions)(sent)),
|
|
234
260
|
body,
|
|
235
261
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
236
262
|
}), {
|
|
237
263
|
method,
|
|
264
|
+
url,
|
|
238
265
|
headers: sent,
|
|
239
266
|
signal: opts.signal,
|
|
240
|
-
...(
|
|
267
|
+
...(!replaySafe ? { maxRetries: 0 } : {}),
|
|
241
268
|
});
|
|
242
269
|
}
|
|
243
270
|
catch (transportError) {
|
|
@@ -251,7 +278,7 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
251
278
|
let lastRetryAfterMs;
|
|
252
279
|
let res = await fetchWithCredential(cred);
|
|
253
280
|
let brokerFailure = null;
|
|
254
|
-
if (
|
|
281
|
+
if (replaySafe && res.status === 401 && delegatedCli) {
|
|
255
282
|
// Deliberately terminal on broker failure: an Agent whose daemon cannot
|
|
256
283
|
// rotate its family must surface the 401, never fall through to
|
|
257
284
|
// `ensureFreshCliCredential` and adopt the human's stored refresh family.
|
|
@@ -262,7 +289,7 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
262
289
|
res = await fetchWithCredential(cred);
|
|
263
290
|
}
|
|
264
291
|
}
|
|
265
|
-
else if (
|
|
292
|
+
else if (replaySafe &&
|
|
266
293
|
res.status === 401 &&
|
|
267
294
|
!historyRead &&
|
|
268
295
|
(0, daemonBroker_1.isBrokeredHandoffToken)(cred.token) &&
|
|
@@ -282,7 +309,7 @@ async function apiFetch(pathOrUrl, opts = {}) {
|
|
|
282
309
|
res = await fetchWithCredential(cred);
|
|
283
310
|
}
|
|
284
311
|
}
|
|
285
|
-
else if (
|
|
312
|
+
else if (replaySafe &&
|
|
286
313
|
res.status === 401 &&
|
|
287
314
|
!autonomousCredential &&
|
|
288
315
|
!isAuthEndpoint(pathOrUrl)) {
|
|
@@ -57,7 +57,7 @@ function formatCompatibility(view) {
|
|
|
57
57
|
else {
|
|
58
58
|
lines.push(`unknown: ${where}. This is NOT a pass: ${data_provider_1.APP_COMPATIBILITY_UNKNOWN_WORDS[view.reason ?? 'database_error']}.`);
|
|
59
59
|
}
|
|
60
|
-
lines.push(`checked at ${(0, appData_1.safeForTerminal)(view.computedAt)}, installation generation ${view.lifecycleGen}, data epoch ${view.dataEpoch}${view.epochEnforced ? '' : ' (
|
|
60
|
+
lines.push(`checked at ${(0, appData_1.safeForTerminal)(view.computedAt)}, installation generation ${view.lifecycleGen}, data epoch ${view.dataEpoch}${view.epochEnforced ? '' : ' (the data epoch is not known to be enforced by every writer)'}`);
|
|
61
61
|
for (const sentence of view.disclaimers)
|
|
62
62
|
lines.push(sentence);
|
|
63
63
|
return lines;
|
package/dist/lib/appData.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export type PersonDataFailure = {
|
|
|
88
88
|
status?: number;
|
|
89
89
|
message?: string;
|
|
90
90
|
/** A state proven by the same authorized request, when a newer server provides it. */
|
|
91
|
-
reason?: 'installation_suspended' | typeof APP_STORE_CURSOR_INVALID_REASON | typeof APP_STORE_CURSOR_MISMATCH_REASON;
|
|
91
|
+
reason?: 'installation_suspended' | 'installation_changed' | typeof APP_STORE_CURSOR_INVALID_REASON | typeof APP_STORE_CURSOR_MISMATCH_REASON;
|
|
92
92
|
/** Zero-based index of the batch operation, when the server can identify one. */
|
|
93
93
|
index?: number;
|
|
94
94
|
retryAfterMs?: number;
|
package/dist/lib/appData.js
CHANGED
|
@@ -298,8 +298,9 @@ function readPersonDataFailure(error) {
|
|
|
298
298
|
code,
|
|
299
299
|
...status,
|
|
300
300
|
...(typeof body.message === 'string' ? { message: body.message } : {}),
|
|
301
|
-
...(code === 'unavailable' &&
|
|
302
|
-
|
|
301
|
+
...(code === 'unavailable' &&
|
|
302
|
+
(body.reason === 'installation_suspended' || body.reason === 'installation_changed')
|
|
303
|
+
? { reason: body.reason }
|
|
303
304
|
: {}),
|
|
304
305
|
...(code === 'schema' && cursorRefusalReason(body.reason) !== undefined
|
|
305
306
|
? { reason: cursorRefusalReason(body.reason) }
|
|
@@ -352,6 +353,9 @@ function describePersonDataRefusal(failure, bin, operation) {
|
|
|
352
353
|
if (failure.code === 'unavailable' && failure.reason === 'installation_suspended') {
|
|
353
354
|
return `This installation is paused, so the operation was not run. If you paused it, resume it with \`${bin} apps resume <installation>\`. A platform pause can only be lifted by the platform.`;
|
|
354
355
|
}
|
|
356
|
+
if (failure.code === 'unavailable' && failure.reason === 'installation_changed') {
|
|
357
|
+
return 'The installation changed before the write could be applied. Refresh the installation and document revision before deciding whether to try again.';
|
|
358
|
+
}
|
|
355
359
|
if (operation === 'query' && failure.code === 'schema') {
|
|
356
360
|
if (typeof data_provider_1.APP_STORE_CURSOR_INVALID_MESSAGE === 'string' &&
|
|
357
361
|
data_provider_1.APP_STORE_CURSOR_INVALID_MESSAGE.length > 0 &&
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { AppDataMigrationView } from '@skrr-ai/data-provider';
|
|
2
|
+
/**
|
|
3
|
+
* The installer's explicit DATA MIGRATION of an installation, from a terminal: `apps installations migrate plan | status | stage |
|
|
4
|
+
* validate | abort | cutover | rollback` (docs/architecture/apps-installation-lifecycle-2026-11-10.md, section 11, steps 6b-1 and 6b-2,
|
|
5
|
+
* OSK-23687). The contract and every sentence it says (states, findings, refusals, the disclaimers) are `@skrr-ai/data-provider`'s
|
|
6
|
+
* `appDataMigration.ts`; this file only reads the server's answer through that contract and decides what a terminal prints and which exit
|
|
7
|
+
* code a script gets.
|
|
8
|
+
*
|
|
9
|
+
* WHAT CHANGES LIVE DATA. Only `cutover` and `rollback`, and each needs `--yes`: without it they change nothing and say what they would do.
|
|
10
|
+
* `cutover` copies the installation's documents to an archive (kept for 14 days after it completes, outside the storage quota), replaces
|
|
11
|
+
* them with the converted ones and moves the app to the new version; `rollback` puts the archived ones back and moves the app back.
|
|
12
|
+
*
|
|
13
|
+
* EXIT CODES (distinct on purpose, so a script can tell "it failed" from "it was refused" from "nobody can tell"):
|
|
14
|
+
*
|
|
15
|
+
* 0 the step did what it says: planned, staged, validated, aborted, cut over (`completed`), rolled back, or a status (with or without a migration
|
|
16
|
+
* open)
|
|
17
|
+
* 1 the migration is `failed` (a status of one too), or a finding stopped it: the bounded findings are printed. A cutover that could not
|
|
18
|
+
* finish and undid itself from the archive (`rolled_back`) is also 1: the app is as it was, and the cutover did not happen
|
|
19
|
+
* 4 the server REFUSED the request: `migration_refused` (the reason's words), `forbidden`, a stranger or a missing installation, a
|
|
20
|
+
* `changed` migration, a bad request. A refusal changes nothing the person has not already been told about
|
|
21
|
+
* 5 UNKNOWN: an answer this client cannot read, a loop that made no progress or hit its cap, a validation that could not judge, or a
|
|
22
|
+
* request that may have reached the server and got no readable answer. It is never a success: run `status`
|
|
23
|
+
* 6 NOT ENABLED: HTTP 503 `APP_DATA_MIGRATION_UNAVAILABLE`. A deployment setting, not an outage: nothing was changed and retrying
|
|
24
|
+
* will not help
|
|
25
|
+
*
|
|
26
|
+
* A request that fails in the ordinary way (a sign-in that expired, a rate limit, the server being down on a READ) is the CLI's ordinary
|
|
27
|
+
* failure and keeps its own code. A transport failure on a WRITE is 5, because the write may have landed.
|
|
28
|
+
*
|
|
29
|
+
* WHAT A TERMINAL SHOWS. The state in words, the plan's counts (a collection, a number, the kinds of step: never a step's values), the freeze
|
|
30
|
+
* and staging counts, the validation, the failure's words, the findings (`collection/documentId code at path`: the document id is shown
|
|
31
|
+
* because the person who asks can already list it with `apps data query`; it is printed in the findings and nowhere else, never in an
|
|
32
|
+
* error and never in a hint) and, always, the contract's three sentences. Every value that came from the server is written out safely.
|
|
33
|
+
*/
|
|
34
|
+
export declare const APPS_MIGRATION_EXIT: {
|
|
35
|
+
readonly ok: 0;
|
|
36
|
+
readonly failed: 1;
|
|
37
|
+
readonly refused: 4;
|
|
38
|
+
readonly unknown: 5;
|
|
39
|
+
readonly notEnabled: 6;
|
|
40
|
+
};
|
|
41
|
+
/** The machine codes this command family prints under (`--json` `error.code`), next to the exit each has. */
|
|
42
|
+
export declare const APPS_MIGRATION_CODES: {
|
|
43
|
+
readonly unreadable: "APP_MIGRATION_UNREADABLE";
|
|
44
|
+
readonly outcomeUnknown: "APP_MIGRATION_OUTCOME_UNKNOWN";
|
|
45
|
+
readonly noProgress: "APP_MIGRATION_NO_PROGRESS";
|
|
46
|
+
readonly unfinished: "APP_MIGRATION_UNFINISHED";
|
|
47
|
+
readonly validationGap: "APP_MIGRATION_VALIDATION_GAP";
|
|
48
|
+
readonly freezeNotConfirmed: "APP_MIGRATION_FREEZE_NOT_CONFIRMED";
|
|
49
|
+
readonly cutoverNotConfirmed: "APP_MIGRATION_CUTOVER_NOT_CONFIRMED";
|
|
50
|
+
readonly rollbackNotConfirmed: "APP_MIGRATION_ROLLBACK_NOT_CONFIRMED";
|
|
51
|
+
readonly refused: "APP_MIGRATION_REFUSED";
|
|
52
|
+
readonly forbidden: "APP_MIGRATION_FORBIDDEN";
|
|
53
|
+
readonly notFound: "APP_MIGRATION_NOT_FOUND";
|
|
54
|
+
readonly changed: "APP_MIGRATION_CHANGED";
|
|
55
|
+
readonly rejected: "APP_MIGRATION_REQUEST_REJECTED";
|
|
56
|
+
readonly failed: "APP_MIGRATION_FAILED";
|
|
57
|
+
readonly notEnabled: "APP_DATA_MIGRATION_UNAVAILABLE";
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The most calls one `stage` or `validate` makes. The server carries a bounded batch per call (100 documents, within an 8 second budget) and
|
|
61
|
+
* a migration holds at most 60,000 documents, so about 600 calls is the most a real migration needs; this leaves room above it and still
|
|
62
|
+
* stops a loop that is somehow advancing one document at a time forever. Reaching it is "not finished", never a success.
|
|
63
|
+
*/
|
|
64
|
+
export declare const APPS_MIGRATION_CALLS_MAX = 700;
|
|
65
|
+
/** The installation as a command argument: the id when it is one, else a placeholder (never a string that was not an id). */
|
|
66
|
+
export declare function installationRef(value: unknown): string;
|
|
67
|
+
export interface MigrationExpectation {
|
|
68
|
+
installationId: string;
|
|
69
|
+
/** The migration the caller pinned, when it did: an answer about another one is not the answer. */
|
|
70
|
+
migrationId?: string;
|
|
71
|
+
/** For a plan: the version it was asked for. */
|
|
72
|
+
targetVersionId?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read the server's answer as a migration of THIS installation (and of THIS migration and version, when the call pinned them), through
|
|
76
|
+
* the contract's reader. `null` is an answer this client does not understand: it then knows nothing and says so, and never calls it a
|
|
77
|
+
* success. A state, a failure code or a finding code the contract does not list is unreadable by the contract's own rule.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readMigration(raw: unknown, expected: MigrationExpectation): AppDataMigrationView | null;
|
|
80
|
+
/** The answer of the status read: `{ migration: view | null }`, or `null` when it is not an answer this client understands. */
|
|
81
|
+
export declare function readMigrationState(raw: unknown, installationId: string): {
|
|
82
|
+
migration: AppDataMigrationView | null;
|
|
83
|
+
} | null;
|
|
84
|
+
/** What is said when the server's answer is not a migration this client understands. It is not a success. */
|
|
85
|
+
export declare function migrationUnreadableMessage(step: MigrationStep, installation: string): string;
|
|
86
|
+
export type MigrationStep = 'plan' | 'status' | 'stage' | 'validate' | 'abort' | 'cutover' | 'rollback';
|
|
87
|
+
export declare const migrationCalls: {
|
|
88
|
+
status: (installation: string) => Promise<unknown>;
|
|
89
|
+
plan: (installation: string, targetVersionId: string) => Promise<unknown>;
|
|
90
|
+
stage: (installation: string, body: {
|
|
91
|
+
migrationId?: string;
|
|
92
|
+
confirmFreeze?: boolean;
|
|
93
|
+
}) => Promise<unknown>;
|
|
94
|
+
validate: (installation: string, body: {
|
|
95
|
+
migrationId?: string;
|
|
96
|
+
}) => Promise<unknown>;
|
|
97
|
+
abort: (installation: string, body: {
|
|
98
|
+
migrationId?: string;
|
|
99
|
+
}) => Promise<unknown>;
|
|
100
|
+
cutover: (installation: string, body: {
|
|
101
|
+
migrationId: string;
|
|
102
|
+
confirmCutover: boolean;
|
|
103
|
+
}) => Promise<unknown>;
|
|
104
|
+
rollback: (installation: string, body: {
|
|
105
|
+
migrationId: string;
|
|
106
|
+
confirmRollback: boolean;
|
|
107
|
+
discardWritesSinceCutover?: boolean;
|
|
108
|
+
}) => Promise<unknown>;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The migration as the lines a person reads. Document ids appear in the findings and nowhere else. Every value from the server is
|
|
112
|
+
* written out safely, and the three sentences of the contract close it, always.
|
|
113
|
+
*/
|
|
114
|
+
export declare function formatMigration(view: AppDataMigrationView, bin: string): string[];
|
|
115
|
+
/** The status of an installation with no migration open, in lines. */
|
|
116
|
+
export declare function formatNoMigration(installation: string, bin: string): string[];
|
|
117
|
+
/** One line per call of a loop, in the words of what that call moved. */
|
|
118
|
+
export declare function progressLine(step: LoopStep, call: number, view: AppDataMigrationView): string;
|
|
119
|
+
export type LoopStep = 'stage' | 'validate' | 'cutover' | 'rollback';
|
|
120
|
+
export type LoopStop = 'done' | 'failed' | 'once' | 'no_progress' | 'call_cap' | 'gap' | 'undone';
|
|
121
|
+
export interface LoopResult {
|
|
122
|
+
view: AppDataMigrationView;
|
|
123
|
+
/** How many server calls this run made. */
|
|
124
|
+
calls: number;
|
|
125
|
+
stopped: LoopStop;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A call of a loop failed or was unreadable after `calls - 1` calls had been answered. The command says "unknown, run status" for a write
|
|
129
|
+
* it cannot prove did not land, and what it knows of the migration from the calls before.
|
|
130
|
+
*/
|
|
131
|
+
export declare class MigrationLoopError extends Error {
|
|
132
|
+
readonly error: unknown;
|
|
133
|
+
readonly calls: number;
|
|
134
|
+
readonly last: AppDataMigrationView | null;
|
|
135
|
+
readonly unreadable: boolean;
|
|
136
|
+
constructor(input: {
|
|
137
|
+
error?: unknown;
|
|
138
|
+
calls: number;
|
|
139
|
+
last: AppDataMigrationView | null;
|
|
140
|
+
unreadable?: boolean;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Repeat a step that carries a bounded slice of work per call. Stops at the first of: the step's goal (`done`), a `failed` migration,
|
|
145
|
+
* a validation that ended without an answer (`gap`), an answer equal to the one before it (`no_progress`), the cap (`call_cap`), or, with
|
|
146
|
+
* `once`, the first answer. The first call pins no migration unless the caller did; every later one pins the migration the first answer
|
|
147
|
+
* named, so the loop can never carry on with a different one.
|
|
148
|
+
*/
|
|
149
|
+
export declare function runUntilSettled(input: {
|
|
150
|
+
step: LoopStep;
|
|
151
|
+
installationId: string;
|
|
152
|
+
migrationId?: string;
|
|
153
|
+
once: boolean;
|
|
154
|
+
maxCalls?: number;
|
|
155
|
+
call: (migrationId: string | undefined) => Promise<unknown>;
|
|
156
|
+
onProgress?: (line: string) => void;
|
|
157
|
+
}): Promise<LoopResult>;
|
|
158
|
+
/** The exit code a loop's result has. A `once` call that moved the migration along is a step that did what it says. */
|
|
159
|
+
export declare function loopExit(result: LoopResult): number;
|
|
160
|
+
/** What a loop that did not reach its goal says on stderr, so the exit code is never the only thing a person has. */
|
|
161
|
+
export declare function loopStopNote(step: LoopStep, result: LoopResult, bin: string): string | null;
|
|
162
|
+
/**
|
|
163
|
+
* What `stage` says, instead of calling the server, when the migration is only planned and the person has not said `--yes`: staging
|
|
164
|
+
* FREEZES the app, which is theirs to confirm. Names the plan's counts, the three sentences and the command that goes on.
|
|
165
|
+
*/
|
|
166
|
+
export declare function describeFreezeGate(view: AppDataMigrationView, bin: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* What `cutover` says, instead of calling the server, when the migration is validated and the person has not said `--yes`: the cutover REPLACES the
|
|
169
|
+
* installation's stored documents and moves the app to the new version, which is theirs to confirm. States what changes and what is kept.
|
|
170
|
+
*/
|
|
171
|
+
export declare function describeCutoverGate(view: AppDataMigrationView, bin: string): string;
|
|
172
|
+
/** What `rollback` says, instead of calling the server, when the person has not said `--yes`. */
|
|
173
|
+
export declare function describeRollbackGate(view: AppDataMigrationView, bin: string): string;
|
|
174
|
+
export interface MigrationFailureContext {
|
|
175
|
+
step: MigrationStep;
|
|
176
|
+
/** The installation the person named. */
|
|
177
|
+
installation: string;
|
|
178
|
+
/** For a plan: the version it was for. */
|
|
179
|
+
versionId?: string;
|
|
180
|
+
bin: string;
|
|
181
|
+
/** Calls of a loop answered before this one, and the last migration they showed. */
|
|
182
|
+
calls?: number;
|
|
183
|
+
last?: AppDataMigrationView | null;
|
|
184
|
+
}
|
|
185
|
+
export interface MigrationFailure {
|
|
186
|
+
message: string;
|
|
187
|
+
code: string;
|
|
188
|
+
exit: number;
|
|
189
|
+
retryable: false;
|
|
190
|
+
status?: number;
|
|
191
|
+
details?: Record<string, unknown>;
|
|
192
|
+
}
|
|
193
|
+
/** A refusal this client makes itself, from what a read of the migration showed, with the words the server's own would have. Nothing was sent. */
|
|
194
|
+
export declare function describeLocalRefusal(reason: 'no_active_migration', ctx: MigrationFailureContext): MigrationFailure;
|
|
195
|
+
/** What is said when the open migration is not the one the person named. Nothing was sent. */
|
|
196
|
+
export declare function describeNamedMigrationNotOpen(ctx: MigrationFailureContext): MigrationFailure;
|
|
197
|
+
/**
|
|
198
|
+
* Say what a failed request means, in the exit table's terms, or `null` when it is the CLI's ordinary failure (a sign-in that expired, a rate
|
|
199
|
+
* limit, the server being down on a READ): the caller then hands it to the base command, which words those.
|
|
200
|
+
*
|
|
201
|
+
* `write` says the request was one that changes state (plan, stage, validate, abort): for one, a transport failure or a 5xx proves
|
|
202
|
+
* nothing, so it is UNKNOWN (5) and says to run `status`. For a read it is not.
|
|
203
|
+
*/
|
|
204
|
+
export declare function describeMigrationFailure(error: unknown, ctx: MigrationFailureContext, write: boolean): MigrationFailure | null;
|