@skrr-ai/cli 0.1.164 → 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/README.md +13 -0
- package/dist/base-command.d.ts +14 -1
- package/dist/base-command.js +166 -46
- package/dist/commands/agent/message/send.d.ts +1 -0
- package/dist/commands/agent/message/send.js +3 -0
- package/dist/commands/agents/mini-computer/app/set.js +1 -1
- package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
- package/dist/commands/apps/check.js +3 -8
- package/dist/commands/apps/data/batch.d.ts +1 -0
- package/dist/commands/apps/data/batch.js +19 -2
- package/dist/commands/apps/data/delete.d.ts +1 -0
- package/dist/commands/apps/data/delete.js +14 -2
- package/dist/commands/apps/data/patch.d.ts +1 -0
- package/dist/commands/apps/data/patch.js +11 -2
- package/dist/commands/apps/data/put.d.ts +1 -0
- package/dist/commands/apps/data/put.js +17 -3
- package/dist/commands/apps/install.js +7 -2
- package/dist/commands/apps/installations/compatibility.d.ts +13 -0
- package/dist/commands/apps/installations/compatibility.js +60 -0
- 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 +14 -9
- package/dist/commands/apps/installations/snapshot.js +5 -2
- package/dist/commands/apps/operations/check.d.ts +16 -0
- package/dist/commands/apps/operations/check.js +127 -0
- package/dist/commands/apps/publish/propose.js +33 -4
- package/dist/commands/apps/reconsent.js +7 -1
- package/dist/commands/apps/reference.d.ts +4 -2
- package/dist/commands/apps/reference.js +7 -4
- package/dist/commands/apps/resume.js +1 -1
- package/dist/commands/apps/rollback.d.ts +9 -0
- package/dist/commands/apps/rollback.js +81 -2
- package/dist/commands/apps/settings/set.js +22 -10
- package/dist/commands/apps/upgrade.d.ts +8 -0
- package/dist/commands/apps/upgrade.js +67 -2
- package/dist/commands/apps/version/cat.d.ts +22 -0
- package/dist/commands/apps/version/cat.js +220 -0
- package/dist/commands/apps/version/show.js +3 -1
- package/dist/commands/commerce/incidents/release.d.ts +24 -0
- package/dist/commands/commerce/incidents/release.js +46 -0
- package/dist/commands/duties/cases.js +12 -1
- package/dist/commands/duties/hypotheses.js +10 -3
- package/dist/commands/duties/observations.d.ts +4 -0
- package/dist/commands/duties/observations.js +14 -3
- package/dist/commands/outbox/list.d.ts +11 -4
- package/dist/commands/outbox/list.js +56 -9
- package/dist/commands/outbox/retry.d.ts +8 -2
- package/dist/commands/outbox/retry.js +76 -16
- package/dist/commands/outbox/show.d.ts +20 -0
- package/dist/commands/outbox/show.js +83 -0
- package/dist/commands/proposals/list.js +13 -9
- package/dist/commands/requests/show.d.ts +12 -0
- package/dist/commands/requests/show.js +42 -23
- package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
- package/dist/commands/spaces/deletion/cancel.js +70 -0
- package/dist/commands/spaces/workflows/run.js +12 -0
- package/dist/commands/widgets/check.d.ts +9 -0
- package/dist/commands/widgets/check.js +16 -3
- package/dist/generated/agent-guides.json +17 -17
- package/dist/lib/api-fetch.d.ts +5 -0
- package/dist/lib/api-fetch.js +81 -22
- package/dist/lib/appCompatibility.d.ts +31 -0
- package/dist/lib/appCompatibility.js +66 -0
- package/dist/lib/appData.d.ts +46 -4
- package/dist/lib/appData.js +161 -32
- 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 +40 -5
- package/dist/lib/appInstallations.js +251 -35
- package/dist/lib/appVersionFile.d.ts +82 -0
- package/dist/lib/appVersionFile.js +195 -0
- package/dist/lib/apps-command.d.ts +14 -3
- package/dist/lib/apps-command.js +80 -65
- package/dist/lib/appsCheck.js +16 -2
- package/dist/lib/commerce.d.ts +6 -0
- package/dist/lib/commerce.js +9 -0
- package/dist/lib/duties.d.ts +15 -1
- package/dist/lib/duties.js +21 -3
- package/dist/lib/json-output.d.ts +2 -0
- package/dist/lib/json-output.js +8 -4
- package/dist/lib/node-adapter.js +69 -38
- package/dist/lib/outbox.d.ts +110 -1
- package/dist/lib/outbox.js +261 -35
- 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/space-deletion-cancel.d.ts +47 -0
- package/dist/lib/space-deletion-cancel.js +141 -0
- package/dist/lib/widgetCheck.js +1 -1
- package/dist/lib/widgetStaticScan.d.ts +11 -5
- package/dist/lib/widgetStaticScan.js +73 -165
- package/dist/lib/write-outcome.d.ts +76 -0
- package/dist/lib/write-outcome.js +190 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +11955 -11231
- package/oclif.manifest.json +3019 -499
- package/package.json +12 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AppDataMigrationView } from '@skrr-ai/data-provider';
|
|
2
|
+
import { AppsCommand } from './apps-command';
|
|
3
|
+
import { MigrationLoopError } from './appDataMigration';
|
|
4
|
+
import type { MigrationFailureContext, MigrationStep } from './appDataMigration';
|
|
5
|
+
/**
|
|
6
|
+
* What the five `apps installations migrate` commands share: saying what a failed request means in the exit table's terms
|
|
7
|
+
* (`appDataMigration.ts`), saying that an answer is unreadable (exit 5, never a success), and printing a migration, in text or as
|
|
8
|
+
* `--json`, under the exit its state has. It declares no static `args` or `flags`: oclif reads those from the concrete command's own
|
|
9
|
+
* class, and one inherited from here would be lost (see `command-inherited-statics.spec.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class AppsMigrationCommand extends AppsCommand {
|
|
12
|
+
/**
|
|
13
|
+
* Say what a failed request means. A refusal, a stranger, a bad request, a switched-off feature and a write whose outcome is unknown get
|
|
14
|
+
* the migration's own words and exit code; what it does not know (a sign-in that expired, a rate limit, the server being down on a read) is
|
|
15
|
+
* the CLI's ordinary failure. Never returns.
|
|
16
|
+
*/
|
|
17
|
+
protected failMigration(error: unknown, ctx: Omit<MigrationFailureContext, 'bin'>, write: boolean): never;
|
|
18
|
+
/** A call of a loop failed or was unreadable. Never returns. */
|
|
19
|
+
protected failLoop(error: MigrationLoopError, ctx: Omit<MigrationFailureContext, 'bin'>): never;
|
|
20
|
+
/** The server answered, but not with a migration this client understands. Exit 5, never a success. Never returns. */
|
|
21
|
+
protected failUnreadable(step: MigrationStep, installation: string): never;
|
|
22
|
+
/**
|
|
23
|
+
* The server answered with a migration this client reads, but not in the state the step says it leaves it in (a plan that is not
|
|
24
|
+
* `planned`, an abort that is not `aborted`). Exit 5: the step did not provably do what it says. Never returns.
|
|
25
|
+
*/
|
|
26
|
+
protected failUnexpectedState(step: MigrationStep, view: AppDataMigrationView, expected: string): never;
|
|
27
|
+
/**
|
|
28
|
+
* Print a migration under the exit its state has. Text: the lines of `formatMigration`, then any `notes` on STDERR (why a loop stopped).
|
|
29
|
+
* `--json`: the one document on stdout (`json` is what to print, `ok` only for exit 0), the notes still on stderr. A non-zero exit is
|
|
30
|
+
* taken after the output has been handed to the operating system.
|
|
31
|
+
*/
|
|
32
|
+
protected report(view: AppDataMigrationView, options: {
|
|
33
|
+
json: boolean;
|
|
34
|
+
exit: number;
|
|
35
|
+
/** What `--json` prints; defaults to the migration itself. */
|
|
36
|
+
jsonValue?: unknown;
|
|
37
|
+
notes?: Array<string | null>;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppsMigrationCommand = void 0;
|
|
4
|
+
const apps_command_1 = require("./apps-command");
|
|
5
|
+
const drain_stdio_1 = require("./drain-stdio");
|
|
6
|
+
const appDataMigration_1 = require("./appDataMigration");
|
|
7
|
+
/**
|
|
8
|
+
* What the five `apps installations migrate` commands share: saying what a failed request means in the exit table's terms
|
|
9
|
+
* (`appDataMigration.ts`), saying that an answer is unreadable (exit 5, never a success), and printing a migration, in text or as
|
|
10
|
+
* `--json`, under the exit its state has. It declares no static `args` or `flags`: oclif reads those from the concrete command's own
|
|
11
|
+
* class, and one inherited from here would be lost (see `command-inherited-statics.spec.ts`).
|
|
12
|
+
*/
|
|
13
|
+
class AppsMigrationCommand extends apps_command_1.AppsCommand {
|
|
14
|
+
/**
|
|
15
|
+
* Say what a failed request means. A refusal, a stranger, a bad request, a switched-off feature and a write whose outcome is unknown get
|
|
16
|
+
* the migration's own words and exit code; what it does not know (a sign-in that expired, a rate limit, the server being down on a read) is
|
|
17
|
+
* the CLI's ordinary failure. Never returns.
|
|
18
|
+
*/
|
|
19
|
+
failMigration(error, ctx, write) {
|
|
20
|
+
const failure = (0, appDataMigration_1.describeMigrationFailure)(error, { ...ctx, bin: this.config.bin }, write);
|
|
21
|
+
if (failure === null) {
|
|
22
|
+
return this.failInstallation(error, {
|
|
23
|
+
subject: ctx.installation,
|
|
24
|
+
...(ctx.versionId === undefined ? {} : { versionId: ctx.versionId }),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return this.failWithCliError(failure);
|
|
28
|
+
}
|
|
29
|
+
/** A call of a loop failed or was unreadable. Never returns. */
|
|
30
|
+
failLoop(error, ctx) {
|
|
31
|
+
if (error.unreadable) {
|
|
32
|
+
return this.failWithCliError({
|
|
33
|
+
message: `${(0, appDataMigration_1.migrationUnreadableMessage)(ctx.step, ctx.installation)}${error.calls > 1
|
|
34
|
+
? ` ${error.calls - 1} earlier call${error.calls - 1 === 1 ? '' : 's'} in this run ${error.calls - 1 === 1 ? 'was' : 'were'} answered${error.last ? ` (the migration was ${error.last.state} then)` : ''}.`
|
|
35
|
+
: ''}`,
|
|
36
|
+
code: appDataMigration_1.APPS_MIGRATION_CODES.unreadable,
|
|
37
|
+
exit: appDataMigration_1.APPS_MIGRATION_EXIT.unknown,
|
|
38
|
+
retryable: false,
|
|
39
|
+
details: { outcome: 'unknown', step: ctx.step, calls: error.calls },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return this.failMigration(error.error, { ...ctx, calls: error.calls, last: error.last }, true);
|
|
43
|
+
}
|
|
44
|
+
/** The server answered, but not with a migration this client understands. Exit 5, never a success. Never returns. */
|
|
45
|
+
failUnreadable(step, installation) {
|
|
46
|
+
return this.failWithCliError({
|
|
47
|
+
message: (0, appDataMigration_1.migrationUnreadableMessage)(step, installation),
|
|
48
|
+
code: appDataMigration_1.APPS_MIGRATION_CODES.unreadable,
|
|
49
|
+
exit: appDataMigration_1.APPS_MIGRATION_EXIT.unknown,
|
|
50
|
+
retryable: false,
|
|
51
|
+
details: { outcome: 'unknown', step },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The server answered with a migration this client reads, but not in the state the step says it leaves it in (a plan that is not
|
|
56
|
+
* `planned`, an abort that is not `aborted`). Exit 5: the step did not provably do what it says. Never returns.
|
|
57
|
+
*/
|
|
58
|
+
failUnexpectedState(step, view, expected) {
|
|
59
|
+
const inst = (0, appDataMigration_1.installationRef)(view.installationId);
|
|
60
|
+
return this.failWithCliError({
|
|
61
|
+
message: `The server answered with a migration that is ${view.state}, not ${expected}, so it is not known that the ${step} did what it says. This is not a success.\n→ Read where it stands with: ${this.config.bin} apps installations migrate status ${inst}`,
|
|
62
|
+
code: appDataMigration_1.APPS_MIGRATION_CODES.unreadable,
|
|
63
|
+
exit: appDataMigration_1.APPS_MIGRATION_EXIT.unknown,
|
|
64
|
+
retryable: false,
|
|
65
|
+
details: { outcome: 'unknown', step, state: view.state },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Print a migration under the exit its state has. Text: the lines of `formatMigration`, then any `notes` on STDERR (why a loop stopped).
|
|
70
|
+
* `--json`: the one document on stdout (`json` is what to print, `ok` only for exit 0), the notes still on stderr. A non-zero exit is
|
|
71
|
+
* taken after the output has been handed to the operating system.
|
|
72
|
+
*/
|
|
73
|
+
async report(view, options) {
|
|
74
|
+
if (options.json) {
|
|
75
|
+
this.printJsonResult(options.jsonValue ?? view, { ok: options.exit === 0 });
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
for (const line of (0, appDataMigration_1.formatMigration)(view, this.config.bin))
|
|
79
|
+
this.log(line);
|
|
80
|
+
}
|
|
81
|
+
for (const note of options.notes ?? []) {
|
|
82
|
+
if (note)
|
|
83
|
+
this.logToStderr(note);
|
|
84
|
+
}
|
|
85
|
+
await (0, drain_stdio_1.drainStdio)();
|
|
86
|
+
if (options.exit !== 0)
|
|
87
|
+
this.exit(options.exit);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.AppsMigrationCommand = AppsMigrationCommand;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppInstallationVersionsView, AppVersionDiff, AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
|
|
1
|
+
import type { AppGrantReasonFacts, AppInstallationVersionsView, AppVersionDiff, AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
|
|
2
2
|
import type { AppsRefusal } from './apps';
|
|
3
3
|
/**
|
|
4
4
|
* The words for an availability the contract names. One this CLI does not know (a server newer than the CLI) is said
|
|
@@ -30,8 +30,13 @@ export declare function describeJobScheduling(jobState: {
|
|
|
30
30
|
} | null;
|
|
31
31
|
/** The lines `skrr apps installations show` prints for the jobs' states: one per job, the reason and the next step under a job that is not scheduled. */
|
|
32
32
|
export declare function formatJobStates(jobStates: readonly AppInstallationJobState[] | undefined, installationId: string, jobTriggers?: Record<string, unknown>): string[];
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The words for each reason a grant stopped covering a version; a kind it does not know is said as it came. A reason that
|
|
35
|
+
* carries facts says them: `store_writers_expanded` lists, for each kind of writer a version adds, the collections it can now
|
|
36
|
+
* change (`digest:app` is "the app's own code ... "digest""), from the `items` the server sent, and says the neutral
|
|
37
|
+
* sentence when it sent none. All the store-writer reasons of a list are said together, once.
|
|
38
|
+
*/
|
|
39
|
+
export declare function describeGrantReasons(reasons: readonly AppGrantReasonFacts[]): string[];
|
|
35
40
|
/**
|
|
36
41
|
* A disclosure as the lines a person reads before they approve. `null` (a disclosure this CLI cannot read) is
|
|
37
42
|
* said plainly: "cannot show what you would be approving" is never "nothing to approve".
|
|
@@ -79,8 +84,38 @@ export declare function resolveInstallTarget(input: {
|
|
|
79
84
|
appId: string;
|
|
80
85
|
versionId?: string;
|
|
81
86
|
}): Promise<InstallTarget>;
|
|
82
|
-
/**
|
|
83
|
-
|
|
87
|
+
/**
|
|
88
|
+
* What `apps installations show` says about WHY an installation is suspended, and what the person can do about it, by who suspended it
|
|
89
|
+
* (`suspension.by`: `moderation` or `migration`; absent for a pause the person chose and from a server that does not say). The two
|
|
90
|
+
* sources must never be worded as each other: a moderation is the platform's decision and only the platform lifts it, while a migration
|
|
91
|
+
* is the installer's own and is closed by `apps installations migrate abort`. A source this client does not know, or none given, gets
|
|
92
|
+
* the words that are true of all of them.
|
|
93
|
+
*/
|
|
94
|
+
export declare function describeSuspensionNote(installationId: string, source: unknown, bin: string): string[];
|
|
95
|
+
/**
|
|
96
|
+
* What the command that was refused knows, for the words of its refusal. Every field is optional: a command that knows
|
|
97
|
+
* less gets words that name less (a placeholder in angle brackets where an argument is unknown), never a command printed
|
|
98
|
+
* with a required argument missing and never an outcome it did not have.
|
|
99
|
+
*/
|
|
100
|
+
export interface InstallationConflictContext {
|
|
101
|
+
/** The installation the command was about (`appi_...`), when it was about one. */
|
|
102
|
+
subject?: string;
|
|
103
|
+
/** The version the command was installing, moving an installation to, or approving (`appv_...`). */
|
|
104
|
+
versionId?: string;
|
|
105
|
+
/** What the command was doing, so "nothing was ..." says what did not happen. */
|
|
106
|
+
action?: 'install' | 'reconsent' | 'upgrade';
|
|
107
|
+
/** For an install: who it was for (the signed-in person, or an agent). */
|
|
108
|
+
principal?: {
|
|
109
|
+
kind: 'agent' | 'user';
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The sentence for a refusal the server made on an installation call, or null for one that is not. `context` is what the
|
|
115
|
+
* command knows (the installation it was about, the version, what it was doing); a bare string is the installation, as
|
|
116
|
+
* the callers that only ever had that pass it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function describeInstallationConflict(refusal: AppsRefusal, bin: string, context?: string | InstallationConflictContext): string | null;
|
|
84
119
|
/** The machine code of every installation refusal: `APP_<REASON>`. */
|
|
85
120
|
export declare const ALL_INSTALLATION_REFUSAL_CODES: Record<string, string>;
|
|
86
121
|
export declare const INSTALLATION_REFUSAL_CODES: Record<string, string>;
|
|
@@ -16,6 +16,7 @@ exports.formatHosting = formatHosting;
|
|
|
16
16
|
exports.describeBindingRefusal = describeBindingRefusal;
|
|
17
17
|
exports.describeDisclosureCheck = describeDisclosureCheck;
|
|
18
18
|
exports.resolveInstallTarget = resolveInstallTarget;
|
|
19
|
+
exports.describeSuspensionNote = describeSuspensionNote;
|
|
19
20
|
exports.describeInstallationConflict = describeInstallationConflict;
|
|
20
21
|
exports.formatScopeIssues = formatScopeIssues;
|
|
21
22
|
exports.resolveInstallPrincipal = resolveInstallPrincipal;
|
|
@@ -146,8 +147,43 @@ const STORE_WRITER_WORDS = {
|
|
|
146
147
|
agent: "only agents acting for people with edit access can change it; the app's own code can only read it",
|
|
147
148
|
person: "only people can change it; the app's own code can only read it",
|
|
148
149
|
};
|
|
150
|
+
/** Names as a sentence lists them, each in quotes: "a", "a" and "b", "a", "b" and "c". */
|
|
151
|
+
function quotedList(names) {
|
|
152
|
+
const quoted = names.map((name) => `"${name}"`);
|
|
153
|
+
const last = quoted.pop();
|
|
154
|
+
if (last === undefined) {
|
|
155
|
+
return '';
|
|
156
|
+
}
|
|
157
|
+
return quoted.length === 0 ? last : `${quoted.join(', ')} and ${last}`;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* What can wake a job declared as `on@change:<collection>`, said from the writers THE COLLECTION DECLARES (`appChangeWakeFacts`),
|
|
161
|
+
* so the line cannot name a source the "keep its own data" line above it says is impossible (OSK-23757: "an app-window write"
|
|
162
|
+
* over a collection the app's own code could only read). `declared` is `undefined` when this disclosure does not list the
|
|
163
|
+
* collection's writers (an older server, or a collection the app cannot read), and the line then says it does not know.
|
|
164
|
+
*/
|
|
165
|
+
function describeChangeWake(name, declared) {
|
|
166
|
+
const target = `"${name}"`;
|
|
167
|
+
const never = 'agent writes and webhook deliveries never wake it this way';
|
|
168
|
+
const facts = (0, data_provider_1.appChangeWakeFacts)(declared);
|
|
169
|
+
if (!facts.known) {
|
|
170
|
+
return `can wake on a permitted write by a person or the app's own code to ${target} (who may write it is not shown here; ${never}; not on a clock)`;
|
|
171
|
+
}
|
|
172
|
+
const person = facts.sources.includes('person');
|
|
173
|
+
const app = facts.sources.includes('app');
|
|
174
|
+
if (person && app) {
|
|
175
|
+
return `can wake when a person or the app's own code changes ${target} (${never}; not on a clock)`;
|
|
176
|
+
}
|
|
177
|
+
if (person) {
|
|
178
|
+
return `can wake when a person changes ${target} (the app's own code cannot write it; ${never}; not on a clock)`;
|
|
179
|
+
}
|
|
180
|
+
if (app) {
|
|
181
|
+
return `can wake when the app's own code changes ${target} (people cannot write it; ${never}; not on a clock)`;
|
|
182
|
+
}
|
|
183
|
+
return `cannot be woken by a change to ${target} (no writer it declares can start a wake: an agent's writes never do; not on a clock)`;
|
|
184
|
+
}
|
|
149
185
|
/** A job's schedule in words, beside the text the author wrote (which is always still shown). */
|
|
150
|
-
function describeSchedule(schedule) {
|
|
186
|
+
function describeSchedule(schedule, collectionWriters) {
|
|
151
187
|
const reading = (0, data_provider_1.readAppJobSchedule)(schedule);
|
|
152
188
|
switch (reading.kind) {
|
|
153
189
|
case 'daily':
|
|
@@ -157,7 +193,7 @@ function describeSchedule(schedule) {
|
|
|
157
193
|
case 'event':
|
|
158
194
|
return reading.source === 'webhook'
|
|
159
195
|
? `can wake when the app's "${reading.name}" webhook delivers an event (not on a clock)`
|
|
160
|
-
:
|
|
196
|
+
: describeChangeWake(reading.name, collectionWriters?.get(reading.name));
|
|
161
197
|
case 'configured':
|
|
162
198
|
return "on a schedule set in the app's settings";
|
|
163
199
|
default:
|
|
@@ -390,7 +426,7 @@ function jobNextLine(job) {
|
|
|
390
426
|
}
|
|
391
427
|
return [` next: ${stateReason.next.replace(FORMAT_JOB_STATES_RE, '<installation id>')}`];
|
|
392
428
|
}
|
|
393
|
-
function itemLines(item) {
|
|
429
|
+
function itemLines(item, collectionWriters) {
|
|
394
430
|
switch (item.kind) {
|
|
395
431
|
case 'store':
|
|
396
432
|
return item.collections.map((collection) => {
|
|
@@ -438,17 +474,16 @@ function itemLines(item) {
|
|
|
438
474
|
return [
|
|
439
475
|
`run these jobs automatically, unattended. ${item.statement} That is accepted when you install it, and each job is listed so you can weigh it:`,
|
|
440
476
|
...item.jobs.flatMap((job) => [
|
|
441
|
-
` - ${(0, data_provider_1.plainAppLabel)(job.title)} (${job.schedule}): ${describeSchedule(job.schedule)}${job.guide ? `, following ${job.guide}` : ''}${mark(job.consent)}${describeJobState(job)}`,
|
|
477
|
+
` - ${(0, data_provider_1.plainAppLabel)(job.title)} (${job.schedule}): ${describeSchedule(job.schedule, collectionWriters)}${job.guide ? `, following ${job.guide}` : ''}${mark(job.consent)}${describeJobState(job)}`,
|
|
442
478
|
...jobNextLine(job),
|
|
443
479
|
]),
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
})
|
|
448
|
-
? [' If a job is event-triggered, limits or delivery failures can cause it to miss events. A recorded change or webhook delivery does not guarantee a run.']
|
|
449
|
-
: []),
|
|
480
|
+
// how a wake is delivered, said once and only for an app with a job an event can start (OSK-23917); the sentence is the
|
|
481
|
+
// contract's, the same one the web draws and the reference prints
|
|
482
|
+
...((0, data_provider_1.appDisclosureHasEventWake)(item.jobs) ? [` ${data_provider_1.APP_EVENT_WAKE_BEST_EFFORT}`] : []),
|
|
450
483
|
...(item.jobs.some((job) => (0, data_provider_1.readAppJobSchedule)(job.schedule).kind === 'configured')
|
|
451
|
-
? [
|
|
484
|
+
? [
|
|
485
|
+
' If a settings-based schedule resolves to an event, the job may not wake at all. A scheduled status does not confirm it can wake.',
|
|
486
|
+
]
|
|
452
487
|
: []),
|
|
453
488
|
...(item.notices?.some((notice) => notice.kind === 'trigger_detached')
|
|
454
489
|
? [
|
|
@@ -466,12 +501,52 @@ const REASON_WORDS = {
|
|
|
466
501
|
capability_expanded: 'this version asks for more than was approved',
|
|
467
502
|
egress_code_changed: `the app changed, and what it may send out of ${data_provider_1.BRAND.displayName} is approved only for the code you saw`,
|
|
468
503
|
jobs_changed: 'a job was added or changed',
|
|
469
|
-
|
|
504
|
+
// The fallback for a reason that names no writer (`items` absent or unreadable): it names none either. It used to say
|
|
505
|
+
// "such as the app's own code" over every version, including one that added only an Agent writer (OSK-23751).
|
|
506
|
+
store_writers_expanded: 'this version lets a kind of writer you have not approved change data the app already keeps',
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Who a version newly lets change a collection, as a noun phrase a sentence can take. A `Record` over the contract's writers, so
|
|
510
|
+
* a writer added there does not compile here until it has words. The same three phrases as the web's
|
|
511
|
+
* `com_app_reason_store_writers_added_*` sentences, which read the same facts (`appStoreWritersAdded`).
|
|
512
|
+
*/
|
|
513
|
+
const STORE_WRITER_ADDED_WORDS = {
|
|
514
|
+
app: "the app's own code",
|
|
515
|
+
agent: 'agents acting for people with edit access',
|
|
516
|
+
person: 'people with edit access',
|
|
470
517
|
};
|
|
471
|
-
/**
|
|
472
|
-
function
|
|
518
|
+
/** One line of the new writers a version adds, for one kind of writer: which collections it can now change. */
|
|
519
|
+
function storeWritersAddedLine(added) {
|
|
520
|
+
const who = added.known
|
|
521
|
+
? STORE_WRITER_ADDED_WORDS[added.writer]
|
|
522
|
+
: `a kind of writer this CLI does not know ("${(0, data_provider_1.plainAppLabel)(added.writer, 40)}")`;
|
|
523
|
+
return `this version lets ${who} change ${quotedList(added.collections)} (you have not approved that)`;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* The words for each reason a grant stopped covering a version; a kind it does not know is said as it came. A reason that
|
|
527
|
+
* carries facts says them: `store_writers_expanded` lists, for each kind of writer a version adds, the collections it can now
|
|
528
|
+
* change (`digest:app` is "the app's own code ... "digest""), from the `items` the server sent, and says the neutral
|
|
529
|
+
* sentence when it sent none. All the store-writer reasons of a list are said together, once.
|
|
530
|
+
*/
|
|
531
|
+
function describeGrantReasons(reasons) {
|
|
473
532
|
const words = REASON_WORDS;
|
|
474
|
-
|
|
533
|
+
const lines = [];
|
|
534
|
+
let writersSaid = false;
|
|
535
|
+
for (const reason of reasons) {
|
|
536
|
+
if (reason.kind === 'store_writers_expanded') {
|
|
537
|
+
if (writersSaid) {
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
writersSaid = true;
|
|
541
|
+
const added = (0, data_provider_1.appStoreWritersAdded)(reasons);
|
|
542
|
+
if (added.length > 0) {
|
|
543
|
+
lines.push(...added.map(storeWritersAddedLine));
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
lines.push(words[reason.kind] ?? reason.kind);
|
|
548
|
+
}
|
|
549
|
+
return lines;
|
|
475
550
|
}
|
|
476
551
|
/**
|
|
477
552
|
* The sentences of the note on an app installed on a PERSON that are true of this app, and none of the others (OSK-23975).
|
|
@@ -547,13 +622,15 @@ function formatDisclosure(raw, facts) {
|
|
|
547
622
|
lines.push(`For an installation on ${disclosure.scope.principal.kind} ${disclosure.scope.principal.id}.`);
|
|
548
623
|
}
|
|
549
624
|
}
|
|
625
|
+
// a job woken by a change to a collection is said from who that collection lets write (OSK-23757)
|
|
626
|
+
const collectionWriters = (0, data_provider_1.appDisclosureCollectionWriters)(disclosure.can);
|
|
550
627
|
if (disclosure.can.length === 0) {
|
|
551
628
|
lines.push('It asks for nothing: it can only draw itself.');
|
|
552
629
|
}
|
|
553
630
|
else {
|
|
554
631
|
lines.push('It can:');
|
|
555
632
|
for (const item of disclosure.can) {
|
|
556
|
-
const [first, ...rest] = itemLines(item);
|
|
633
|
+
const [first, ...rest] = itemLines(item, collectionWriters);
|
|
557
634
|
if (first !== undefined) {
|
|
558
635
|
lines.push(` - ${first}`);
|
|
559
636
|
lines.push(...rest.map((line) => ` ${line.replace(FORMAT_DISCLOSURE_RE, '')}`.replace(FORMAT_DISCLOSURE_RE_2, ' ')));
|
|
@@ -562,7 +639,7 @@ function formatDisclosure(raw, facts) {
|
|
|
562
639
|
}
|
|
563
640
|
if (disclosure.consent.status === 'needs_reconsent') {
|
|
564
641
|
lines.push('Why it needs approving again:');
|
|
565
|
-
for (const reason of describeGrantReasons(disclosure.consent.reasons
|
|
642
|
+
for (const reason of describeGrantReasons(disclosure.consent.reasons)) {
|
|
566
643
|
lines.push(` - ${reason}`);
|
|
567
644
|
}
|
|
568
645
|
}
|
|
@@ -907,7 +984,94 @@ const FORBIDDEN_REASON_WORDS = {
|
|
|
907
984
|
unknown_actor: 'The platform could not tell who is asking.',
|
|
908
985
|
// the installation was suspended by the platform, not by the person: resuming it is not theirs to do
|
|
909
986
|
suspended_by_moderation: 'The platform suspended this app, not you, and only the platform can lift that. There is nothing to resume from here.',
|
|
987
|
+
// a data migration (step 6b-1) runs under the installer's own approval; another editor starts one only by approving the app again
|
|
988
|
+
installer_only: 'Only the installer (the person whose approval this installation runs under) can do this. Another editor has to approve the app again first.',
|
|
910
989
|
};
|
|
990
|
+
/**
|
|
991
|
+
* The words of a `forbidden` that name a command, so they need the binary's name and the installation asked about. The installation is
|
|
992
|
+
* frozen by its OWN data migration (step 6b-1): that is not a moderation, nobody at the platform lifts it, and the way out is the
|
|
993
|
+
* migration's own `abort`. A resume, a move and a settings write are refused with this reason until it is closed.
|
|
994
|
+
*/
|
|
995
|
+
const FORBIDDEN_REASON_COMMAND_WORDS = {
|
|
996
|
+
suspended_by_migration: (bin, context) => {
|
|
997
|
+
const installation = idOf(INSTALLATION_ID_PATTERN, context.subject) ?? '<installation>';
|
|
998
|
+
return `This app is frozen while its data is being migrated to another version, so it cannot be resumed, moved or changed until that migration is closed. Nothing was changed. \`${bin} apps installations migrate status ${installation}\` says where the migration stands; \`${bin} apps installations migrate abort ${installation}\` ends it and puts the app back as it was.`;
|
|
999
|
+
},
|
|
1000
|
+
};
|
|
1001
|
+
/** The words of a `forbidden` refusal, by its reason. */
|
|
1002
|
+
function describeForbiddenReason(reason, bin, context, fallback) {
|
|
1003
|
+
const named = FORBIDDEN_REASON_COMMAND_WORDS[reason ?? ''];
|
|
1004
|
+
return named ? named(bin, context) : (FORBIDDEN_REASON_WORDS[reason ?? ''] ?? fallback);
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* What `apps installations show` says about WHY an installation is suspended, and what the person can do about it, by who suspended it
|
|
1008
|
+
* (`suspension.by`: `moderation` or `migration`; absent for a pause the person chose and from a server that does not say). The two
|
|
1009
|
+
* sources must never be worded as each other: a moderation is the platform's decision and only the platform lifts it, while a migration
|
|
1010
|
+
* is the installer's own and is closed by `apps installations migrate abort`. A source this client does not know, or none given, gets
|
|
1011
|
+
* the words that are true of all of them.
|
|
1012
|
+
*/
|
|
1013
|
+
function describeSuspensionNote(installationId, source, bin) {
|
|
1014
|
+
const valid = INSTALLATION_ID_PATTERN.test(installationId);
|
|
1015
|
+
const inst = valid ? installationId : '<installation>';
|
|
1016
|
+
if (source === 'migration') {
|
|
1017
|
+
return [
|
|
1018
|
+
'Its data is being migrated to another version, which freezes it. It cannot be resumed, moved or changed until that migration is closed, and nothing live has changed.',
|
|
1019
|
+
`\`${bin} apps installations migrate status ${inst}\` says where the migration stands; \`${bin} apps installations migrate abort ${inst}\` ends it and puts the app back as it was.`,
|
|
1020
|
+
];
|
|
1021
|
+
}
|
|
1022
|
+
if (source === 'moderation') {
|
|
1023
|
+
return [
|
|
1024
|
+
'The platform suspended this app, not you, and only the platform can lift that. There is nothing to resume from here.',
|
|
1025
|
+
];
|
|
1026
|
+
}
|
|
1027
|
+
return [
|
|
1028
|
+
valid
|
|
1029
|
+
? `If you can manage this installation, you can try \`${bin} apps resume ${installationId}\` using the same account, deployment, profile and workspace as this command. Resuming may enable its jobs.`
|
|
1030
|
+
: 'If you can manage this installation, find its valid installation ID before trying to resume it. Resuming may enable its jobs.',
|
|
1031
|
+
`Otherwise ask someone who can manage it. A suspension the platform made (moderation) must be lifted by the platform, and a freeze held by a data migration is refused a resume until that migration is closed: \`${bin} apps installations migrate status ${inst}\` says whether one is open.`,
|
|
1032
|
+
];
|
|
1033
|
+
}
|
|
1034
|
+
const INSTALLATION_ID_PATTERN = /^appi_[A-Za-z0-9_-]{1,60}(?![\s\S])/;
|
|
1035
|
+
const VERSION_ID_PATTERN = /^appv_[A-Za-z0-9_-]{1,60}(?![\s\S])/;
|
|
1036
|
+
const AGENT_ID_PATTERN = /^agent_[A-Za-z0-9_-]{1,60}(?![\s\S])/;
|
|
1037
|
+
/** An id of the shape a command takes, or null. A refusal's ids come from the server, and none goes into a command unread. */
|
|
1038
|
+
function idOf(pattern, value) {
|
|
1039
|
+
return typeof value === 'string' && pattern.test(value) ? value : null;
|
|
1040
|
+
}
|
|
1041
|
+
/** What did not happen, by what the command was doing. A refusal is made before anything is written, so "changed" is true of every command. */
|
|
1042
|
+
function nothingWas(context) {
|
|
1043
|
+
switch (context.action) {
|
|
1044
|
+
case 'install':
|
|
1045
|
+
return 'Nothing was installed.';
|
|
1046
|
+
case 'reconsent':
|
|
1047
|
+
return 'Nothing was approved.';
|
|
1048
|
+
default:
|
|
1049
|
+
return 'Nothing was changed.';
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* The command that shows a version's disclosure, with the argument it requires (the version) and the option that makes
|
|
1054
|
+
* its answer about the place in question: the installation being approved again or moved, or who an install is for.
|
|
1055
|
+
*/
|
|
1056
|
+
function disclosureCommand(bin, context, versionId) {
|
|
1057
|
+
const version = idOf(VERSION_ID_PATTERN, versionId) ?? '<version>';
|
|
1058
|
+
const installation = idOf(INSTALLATION_ID_PATTERN, context.subject);
|
|
1059
|
+
if (installation) {
|
|
1060
|
+
return `${bin} apps disclosure ${version} --installation ${installation}`;
|
|
1061
|
+
}
|
|
1062
|
+
if (context.principal?.kind === 'user') {
|
|
1063
|
+
return `${bin} apps disclosure ${version} --me`;
|
|
1064
|
+
}
|
|
1065
|
+
const agent = idOf(AGENT_ID_PATTERN, context.principal?.id);
|
|
1066
|
+
if (context.principal?.kind === 'agent' && agent) {
|
|
1067
|
+
return `${bin} apps disclosure ${version} --agent ${agent}`;
|
|
1068
|
+
}
|
|
1069
|
+
return `${bin} apps disclosure ${version}`;
|
|
1070
|
+
}
|
|
1071
|
+
/** The version a refusal says an installation runs now (`current.versionId`), or null. */
|
|
1072
|
+
function currentVersionOf(refusal) {
|
|
1073
|
+
return idOf(VERSION_ID_PATTERN, refusal.current?.versionId);
|
|
1074
|
+
}
|
|
911
1075
|
/**
|
|
912
1076
|
* Every reason an installation call is refused, with the sentence and the next step. A `Record` over the
|
|
913
1077
|
* contract's list, so a reason added there does not compile here until it has words.
|
|
@@ -916,25 +1080,43 @@ const CONFLICT_WORDS = {
|
|
|
916
1080
|
invalid_input: () => 'The request was not understood. Check the ids and try again.',
|
|
917
1081
|
principal_kind_not_enabled: () => 'Apps can be installed on an agent or on yourself today; installing on a space is not available yet.',
|
|
918
1082
|
principal_not_found: () => 'There is no such agent that you can see (and an app on a person can be put there only by that person). Check the id (and that you have access to it).',
|
|
919
|
-
forbidden: (refusal) =>
|
|
1083
|
+
forbidden: (refusal, bin, context) => describeForbiddenReason(refusal.reason, bin, context, 'You may not do this.'),
|
|
920
1084
|
app_not_found: () => 'There is no such app that you can use. Check the id, or ask its owner to share it.',
|
|
921
1085
|
version_not_found: () => 'There is no such version of that app that you can use.',
|
|
922
1086
|
version_not_installable: () => 'That version is not available for this action. If an install or version change was attempted, check the installation list for the same account and destination, then inspect its current state and data before deciding what to do next; do not retry blindly.',
|
|
923
1087
|
manifest_invalid: () => "That version's manifest is not one this platform will run, so it was not installed.",
|
|
924
|
-
consent_mismatch: (_refusal, bin) => `The bundle you were shown is not the one on record for that version.
|
|
925
|
-
version_changed: (refusal, bin) =>
|
|
1088
|
+
consent_mismatch: (_refusal, bin, context) => `The bundle you were shown is not the one on record for that version. ${nothingWas(context)} Run \`${disclosureCommand(bin, context, context.versionId)}\` again and approve what it shows.`,
|
|
1089
|
+
version_changed: (refusal, bin, context) => {
|
|
1090
|
+
const installation = idOf(INSTALLATION_ID_PATTERN, context.subject);
|
|
1091
|
+
const now = currentVersionOf(refusal);
|
|
1092
|
+
return `The installation moved to another version while you were deciding${refusal.current ? ` (now ${refusal.current.versionId})` : ''}. Nothing was changed. Read \`${disclosureCommand(bin, context, now ?? context.versionId)}\` again and approve what it shows${installation ? ` with \`${bin} apps reconsent ${installation} --yes\`` : ''}.`;
|
|
1093
|
+
},
|
|
926
1094
|
invalid_update_policy: () => 'That update policy is not one of manual, auto_minor or beta.',
|
|
927
1095
|
binding_required: (refusal) => describeBindingRefusal(refusal),
|
|
928
|
-
already_installed: (refusal, bin) =>
|
|
1096
|
+
already_installed: (refusal, bin, context) => {
|
|
1097
|
+
const where = context.principal === undefined
|
|
1098
|
+
? ''
|
|
1099
|
+
: context.principal.kind === 'user'
|
|
1100
|
+
? ' on you'
|
|
1101
|
+
: ' on this agent';
|
|
1102
|
+
const prior = idOf(INSTALLATION_ID_PATTERN, refusal.installationId);
|
|
1103
|
+
const wanted = idOf(VERSION_ID_PATTERN, context.versionId);
|
|
1104
|
+
return `That app is already installed${where}${refusal.installationId ? ` (${refusal.installationId})` : ''}. To ${wanted ? `run the version you asked for (${wanted}) instead` : 'move it to another version'}, use \`${bin} apps upgrade ${prior ?? '<installation>'} --version ${wanted ?? '<version>'}\`${prior ? `; \`${bin} apps installations show ${prior}\` says which version it runs now` : ''}.`;
|
|
1105
|
+
},
|
|
929
1106
|
not_found: () => 'There is no such installation that you can see.',
|
|
930
1107
|
changed: () => 'The installation changed while this was running. Read its current state before deciding what to do next.',
|
|
931
1108
|
not_auto_updatable: () => 'That installation does not update on its own.',
|
|
932
1109
|
data_deletion_not_confirmed: (refusal) => `Removing this app also deletes its data (${refusal.docCount ?? 'some'} document${refusal.docCount === 1 ? '' : 's'}), which is yours to confirm. Nothing was removed. Say it, with --delete-data, if you mean it.`,
|
|
933
1110
|
installation_incomplete: () => 'This installation points at a version that can no longer be read. It can be removed, not run.',
|
|
934
|
-
principal_scope_unserved: (refusal) => `This app asks for ${describeScopeIssues(refusal.unserved)}, which cannot work for the place it would be installed (an app installed on a person reaches that person's own data, never an agent's or a space's, and has no agent to run it yet).${needsOperator(refusal.unserved)
|
|
1111
|
+
principal_scope_unserved: (refusal, _bin, context) => `This app asks for ${describeScopeIssues(refusal.unserved)}, which cannot work for the place it would be installed (an app installed on a person reaches that person's own data, never an agent's or a space's, and has no agent to run it yet).${needsOperator(refusal.unserved)
|
|
935
1112
|
? ' An app that needs an agent to run it can, for now, only be installed on one of your agents.'
|
|
936
|
-
: ''}
|
|
1113
|
+
: ''} ${nothingWas(context)}`,
|
|
937
1114
|
no_previous_version: () => 'This installation has never been moved onto the version it runs, so there is no earlier version to go back to. Nothing was changed.',
|
|
1115
|
+
// the installer's data migration holds the app frozen (step 6b): nothing about the installation's lifecycle is written until it is closed
|
|
1116
|
+
installation_being_migrated: (_refusal, bin, context) => {
|
|
1117
|
+
const installation = idOf(INSTALLATION_ID_PATTERN, context.subject) ?? '<installation>';
|
|
1118
|
+
return `This app is frozen while its data is being migrated to another version, so its update channel, its settings, its approval, its version and its existence cannot be changed until that migration is closed. Nothing was changed. The person who started it can read where it stands with \`${bin} apps installations migrate status ${installation}\` and end it with \`${bin} apps installations migrate abort ${installation}\` (a cutover that has begun can only finish or be rolled back).`;
|
|
1119
|
+
},
|
|
938
1120
|
job_schedule_invalid: (refusal, bin) => {
|
|
939
1121
|
const issues = Array.isArray(refusal.issues)
|
|
940
1122
|
? refusal.issues.length
|
|
@@ -942,15 +1124,25 @@ const CONFLICT_WORDS = {
|
|
|
942
1124
|
return `${issues > 0 ? `${issues} of this app's scheduled jobs have` : 'A scheduled job has'} a schedule or event target that cannot be used. Review the selected settings and declared targets; \`${bin} apps check\` checks the app package.`;
|
|
943
1125
|
},
|
|
944
1126
|
};
|
|
945
|
-
/**
|
|
946
|
-
|
|
1127
|
+
/**
|
|
1128
|
+
* The sentence for a refusal the server made on an installation call, or null for one that is not. `context` is what the
|
|
1129
|
+
* command knows (the installation it was about, the version, what it was doing); a bare string is the installation, as
|
|
1130
|
+
* the callers that only ever had that pass it.
|
|
1131
|
+
*/
|
|
1132
|
+
function describeInstallationConflict(refusal, bin, context) {
|
|
947
1133
|
if (!(0, data_provider_1.isAppInstallationConflict)(refusal.error)) {
|
|
948
1134
|
return null;
|
|
949
1135
|
}
|
|
950
|
-
|
|
951
|
-
|
|
1136
|
+
const known = typeof context === 'string' ? { subject: context } : (context ?? {});
|
|
1137
|
+
if (refusal.error === 'changed' && refusal.reason === 'rollback_target_changed') {
|
|
1138
|
+
// refused before anything was written: the server compares the target first, so this one can say nothing was moved
|
|
1139
|
+
const named = known.subject && /^appi_[A-Za-z0-9_-]{1,60}(?![\s\S])/.test(known.subject);
|
|
1140
|
+
return `The version this rollback would go back to is no longer the one you expected, so nothing was moved. Read the installation's versions again${named ? ` with \`${bin} apps installations versions ${known.subject}\`` : ''} before deciding what to do next.`;
|
|
1141
|
+
}
|
|
1142
|
+
if (refusal.error === 'changed' && idOf(INSTALLATION_ID_PATTERN, known.subject)) {
|
|
1143
|
+
return `The installation changed while this was running. Read its current state with \`${bin} apps installations show ${known.subject}\` using the same account, deployment, profile and workspace before deciding what to do next.`;
|
|
952
1144
|
}
|
|
953
|
-
return CONFLICT_WORDS[refusal.error](refusal, bin);
|
|
1145
|
+
return CONFLICT_WORDS[refusal.error](refusal, bin, known);
|
|
954
1146
|
}
|
|
955
1147
|
/** The machine code of every installation refusal: `APP_<REASON>`. */
|
|
956
1148
|
exports.ALL_INSTALLATION_REFUSAL_CODES = Object.fromEntries(Object.keys(CONFLICT_WORDS).map((conflict) => [conflict, `APP_${conflict.toUpperCase()}`]));
|
|
@@ -1100,9 +1292,12 @@ function installationRefusalExit(conflict) {
|
|
|
1100
1292
|
/** Why a version that needs no new approval was still not applied by the opt-in, in a clause. */
|
|
1101
1293
|
const AUTO_APPLY_HOLD_WORDS = {
|
|
1102
1294
|
installation_suspended: 'the installation is paused',
|
|
1103
|
-
|
|
1295
|
+
installation_being_migrated: 'the installation is frozen while its data is migrated (see `apps installations migrate status`)',
|
|
1296
|
+
cut_by_another_person: 'it was not made by the person who enabled automatic updates or their own agents (apply it yourself if you trust it)',
|
|
1104
1297
|
version_not_installable: 'the version was rejected or withdrawn',
|
|
1105
1298
|
principal_scope_unserved: 'it declares something this installation cannot serve',
|
|
1299
|
+
data_incompatible: 'the installation holds data that version’s schemas do not fit (see `apps installations compatibility`)',
|
|
1300
|
+
data_unproven: 'it could not be proven that the installation’s stored data fits that version’s schemas (see `apps installations compatibility`); unknown is not a pass',
|
|
1106
1301
|
};
|
|
1107
1302
|
/** Names come from an app's version; show a bounded summary and keep the full disclosure as the review step. */
|
|
1108
1303
|
function pendingReasonDetails(reason) {
|
|
@@ -1124,6 +1319,17 @@ function pendingReasonDetails(reason) {
|
|
|
1124
1319
|
}
|
|
1125
1320
|
return lines;
|
|
1126
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* A pending notice (`pending.notices`), in a line. It is worth reading before the version is applied and it is NOT a reason
|
|
1324
|
+
* for approving again: the version's `status` and the instructions beside it are exactly what they were, and nothing here reads
|
|
1325
|
+
* a document (OSK-23684).
|
|
1326
|
+
*/
|
|
1327
|
+
function describePendingNotice(notice) {
|
|
1328
|
+
switch (notice.kind) {
|
|
1329
|
+
case 'interface_major_changed':
|
|
1330
|
+
return `note: this version changes the app's data interface from major ${notice.from} to major ${notice.to}, so its collections may have a new shape. Applying it does not check or migrate documents the installation already holds, and some may not satisfy the new schema. This is a notice, not a block.`;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1127
1333
|
/**
|
|
1128
1334
|
* What the versions view says, as lines a person reads: which version is installed, what is waiting and what it needs,
|
|
1129
1335
|
* the opt-in and the currently observed rollback target. `needs_reconsent` is said as "asks for more than you approved", never as a verdict on the
|
|
@@ -1134,10 +1340,16 @@ function formatInstallationVersions(view, bin, requestedInstallationId) {
|
|
|
1134
1340
|
// commands unless they match the requested installation and are safe as unquoted arguments.
|
|
1135
1341
|
const safeId = (value) => typeof value === 'string' && /^[A-Za-z0-9_][A-Za-z0-9_-]{0,63}(?![\s\S])/.test(value);
|
|
1136
1342
|
const safeVersion = (value) => Number.isSafeInteger(value) && Number(value) > 0;
|
|
1137
|
-
if (!view ||
|
|
1138
|
-
!safeId(
|
|
1139
|
-
|
|
1140
|
-
|
|
1343
|
+
if (!view ||
|
|
1344
|
+
!safeId(requestedInstallationId) ||
|
|
1345
|
+
view.installationId !== requestedInstallationId ||
|
|
1346
|
+
!safeId(view.installationId) ||
|
|
1347
|
+
!/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}(?![\s\S])/.test(bin) ||
|
|
1348
|
+
!view.current ||
|
|
1349
|
+
!safeId(view.current.versionId) ||
|
|
1350
|
+
!safeVersion(view.current.version) ||
|
|
1351
|
+
typeof view.viewer?.canManage !== 'boolean' ||
|
|
1352
|
+
typeof view.autoApply?.enabled !== 'boolean' ||
|
|
1141
1353
|
!Array.isArray(view.history) ||
|
|
1142
1354
|
(view.pending && (!safeId(view.pending.versionId) || !safeVersion(view.pending.version))) ||
|
|
1143
1355
|
(view.rollback && (!safeId(view.rollback.versionId) || !safeVersion(view.rollback.version)))) {
|
|
@@ -1156,10 +1368,14 @@ function formatInstallationVersions(view, bin, requestedInstallationId) {
|
|
|
1156
1368
|
if (view.pending) {
|
|
1157
1369
|
const pending = view.pending;
|
|
1158
1370
|
lines.push(`waiting: v${pending.version} (${pending.versionId})${pending.changelog ? ` - ${(0, data_provider_1.plainAppLabel)(pending.changelog, 120)}` : ''}`);
|
|
1371
|
+
// said whatever its status: a version that asks for nothing new can still change what the installation's documents must be
|
|
1372
|
+
for (const notice of (0, data_provider_1.readAppPendingNotices)(pending.notices)) {
|
|
1373
|
+
lines.push(` ${describePendingNotice(notice)}`);
|
|
1374
|
+
}
|
|
1159
1375
|
if (pending.status === 'needs_reconsent') {
|
|
1160
1376
|
lines.push(' it asks for more than you approved, so it does not run until you approve it:');
|
|
1161
1377
|
for (const reason of pending.reasons) {
|
|
1162
|
-
for (const line of describeGrantReasons([reason
|
|
1378
|
+
for (const line of describeGrantReasons([reason]))
|
|
1163
1379
|
lines.push(` ${line}`);
|
|
1164
1380
|
for (const line of pendingReasonDetails(reason))
|
|
1165
1381
|
lines.push(` ${line}`);
|
|
@@ -1181,7 +1397,7 @@ function formatInstallationVersions(view, bin, requestedInstallationId) {
|
|
|
1181
1397
|
lines.push('waiting: no newer version is shown as waiting; the installed version may still need approval.');
|
|
1182
1398
|
}
|
|
1183
1399
|
lines.push(view.rollback
|
|
1184
|
-
? `going back: the currently observed previous version is v${view.rollback.version} (${view.rollback.versionId}). Run \`${bin} apps rollback ${view.installationId} --expected-version ${view.current.versionId}\` to request a rollback. The server selects the target from its history when it handles the request; --expected-version checks the current version, not the target or history.`
|
|
1400
|
+
? `going back: the currently observed previous version is v${view.rollback.version} (${view.rollback.versionId}). Run \`${bin} apps rollback ${view.installationId} --expected-version ${view.current.versionId} --expected-target ${view.rollback.versionId}\` to request a rollback to that version only. The server selects the target from its history when it handles the request; --expected-version checks the current version, not the target or history, and --expected-target refuses the rollback, moving nothing, if the target is a different version by then.`
|
|
1185
1401
|
: 'going back: no rollback option is available right now');
|
|
1186
1402
|
for (const move of view.history.slice(-5)) {
|
|
1187
1403
|
lines.push(` ${move.at} ${move.cause}${move.by === 'policy' ? ' (by the platform, on your opt-in)' : ` (${move.by})`} ${move.from} -> ${move.to}`);
|