@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.
Files changed (41) hide show
  1. package/dist/commands/apps/installations/compatibility.js +1 -1
  2. package/dist/commands/apps/installations/migrate/abort.d.ts +13 -0
  3. package/dist/commands/apps/installations/migrate/abort.js +45 -0
  4. package/dist/commands/apps/installations/migrate/cutover.d.ts +15 -0
  5. package/dist/commands/apps/installations/migrate/cutover.js +102 -0
  6. package/dist/commands/apps/installations/migrate/plan.d.ts +13 -0
  7. package/dist/commands/apps/installations/migrate/plan.js +51 -0
  8. package/dist/commands/apps/installations/migrate/rollback.d.ts +16 -0
  9. package/dist/commands/apps/installations/migrate/rollback.js +103 -0
  10. package/dist/commands/apps/installations/migrate/stage.d.ts +15 -0
  11. package/dist/commands/apps/installations/migrate/stage.js +96 -0
  12. package/dist/commands/apps/installations/migrate/status.d.ts +12 -0
  13. package/dist/commands/apps/installations/migrate/status.js +52 -0
  14. package/dist/commands/apps/installations/migrate/validate.d.ts +14 -0
  15. package/dist/commands/apps/installations/migrate/validate.js +58 -0
  16. package/dist/commands/apps/installations/show.js +5 -6
  17. package/dist/commands/apps/operations/check.js +1 -1
  18. package/dist/commands/apps/resume.js +1 -1
  19. package/dist/commands/apps/settings/set.js +22 -10
  20. package/dist/lib/api-fetch.js +32 -5
  21. package/dist/lib/appCompatibility.js +1 -1
  22. package/dist/lib/appData.d.ts +1 -1
  23. package/dist/lib/appData.js +6 -2
  24. package/dist/lib/appDataMigration.d.ts +204 -0
  25. package/dist/lib/appDataMigration.js +753 -0
  26. package/dist/lib/appDataMigrationCommand.d.ts +39 -0
  27. package/dist/lib/appDataMigrationCommand.js +90 -0
  28. package/dist/lib/appInstallations.d.ts +8 -0
  29. package/dist/lib/appInstallations.js +54 -1
  30. package/dist/lib/apps-command.js +17 -10
  31. package/dist/lib/node-adapter.d.ts +0 -2
  32. package/dist/lib/node-adapter.js +46 -42
  33. package/dist/lib/rate-limit-retry.d.ts +4 -5
  34. package/dist/lib/rate-limit-retry.js +6 -10
  35. package/dist/lib/refresh.d.ts +2 -0
  36. package/dist/lib/refresh.js +6 -0
  37. package/dist/lib/write-outcome.d.ts +2 -0
  38. package/dist/lib/write-outcome.js +14 -0
  39. package/dist/node_modules/@skrr-ai/data-provider/index.js +10041 -9838
  40. package/oclif.manifest.json +599 -3
  41. package/package.json +5 -2
@@ -6,7 +6,7 @@ const apps_command_1 = require("../../../lib/apps-command");
6
6
  const appCompatibility_1 = require("../../../lib/appCompatibility");
7
7
  const drain_stdio_1 = require("../../../lib/drain-stdio");
8
8
  class AppsInstallationsCompatibility extends apps_command_1.AppsCommand {
9
- static description = 'Check whether an installation’s stored data is compatible with another version of its app, before you move it: the server reads the installation’s documents and holds each to the data schema that version declares for its collection. The answer is compatible, incompatible (a document does not fit, or lives in a collection the version no longer declares; the findings name the collection, the document id, a code and where, never a value) or unknown (it could not be proven: the data changed while it was read, a schema could not be read, the installation holds more than one check reads, or the server cannot prove the data epoch is enforced). Unknown is NOT a pass. It proves conformance to the DECLARED schemas, not that the app will work; it is a snapshot, not a guarantee; and it is separate from approval of what the app may do. It writes nothing and no move depends on it: `apps upgrade` and `apps rollback` are never blocked by it. For a person who can edit the installation (a token or an agent’s credential is refused). Exit codes: 0 compatible, 1 incompatible, 5 unknown.';
9
+ static description = 'Check whether an installation’s stored data is compatible with another version of its app, before you move it: the server reads the installation’s documents and holds each to the data schema that version declares for its collection. The answer is compatible, incompatible (a document does not fit, or lives in a collection the version no longer declares; the findings name the collection, the document id, a code and where, never a value) or unknown (it could not be proven: the data changed while it was read, a schema could not be read, the installation holds more than one check reads, or the data epoch is not known to be enforced by every writer). Unknown is NOT a pass. It proves conformance to the DECLARED schemas, not that the app will work; it is a snapshot, not a guarantee; and it is separate from approval of what the app may do. It writes nothing and no move depends on it: `apps upgrade` and `apps rollback` are never blocked by it. For a person who can edit the installation (a token or an agent’s credential is refused). Exit codes: 0 compatible, 1 incompatible, 5 unknown.';
10
10
  static examples = [
11
11
  '<%= config.bin %> apps installations compatibility appi_abc --version appv_new',
12
12
  '<%= config.bin %> apps installations compatibility appi_abc --version appv_new --json',
@@ -0,0 +1,13 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateAbort extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ migration: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateAbort extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'Close the installation’s data migration: erase its staging and lift ONLY this migration’s own freeze, so the app runs again as it did before. Nothing live had changed (no stored document, no version, no old row), so there is nothing to restore. It is the way out of every state before the cutover, including `failed` and `validated`. Once a cutover has begun (`cutting_over`) it is refused (exit 4): the documents are being replaced, so the cutover can only finish (`cutover --yes`) or be rolled back, and a cutover that has finished is undone with `rollback`. It is safe to repeat: aborting a migration that is already aborted answers `aborted` again (name it with --migration; with none open and none named, the server refuses with "no migration open"). A freeze a platform moderation holds is not lifted by it. Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 aborted, 4 the server refused it, 5 unknown (an answer this client cannot read, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate abort appi_abc',
10
+ '<%= config.bin %> apps installations migrate abort appi_abc --migration mig_xyz --json',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ migration: core_1.Flags.string({
21
+ description: 'Abort this migration (the id `status` shows); it may already be aborted. Without it, the open one',
22
+ }),
23
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
24
+ };
25
+ async run() {
26
+ this.requireAuth();
27
+ const { args, flags } = await this.parse(AppsInstallationsMigrateAbort);
28
+ let view;
29
+ try {
30
+ view = (0, appDataMigration_1.readMigration)(await appDataMigration_1.migrationCalls.abort(args.installation, flags.migration === undefined ? {} : { migrationId: flags.migration }), {
31
+ installationId: args.installation,
32
+ ...(flags.migration === undefined ? {} : { migrationId: flags.migration }),
33
+ });
34
+ }
35
+ catch (error) {
36
+ return this.failMigration(error, { step: 'abort', installation: args.installation }, true);
37
+ }
38
+ if (view === null)
39
+ return this.failUnreadable('abort', args.installation);
40
+ if (view.state !== 'aborted')
41
+ return this.failUnexpectedState('abort', view, 'aborted');
42
+ await this.report(view, { json: flags.json, exit: appDataMigration_1.APPS_MIGRATION_EXIT.ok });
43
+ }
44
+ }
45
+ exports.default = AppsInstallationsMigrateAbort;
@@ -0,0 +1,15 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateCutover extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ migration: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ once: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateCutover extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'CUT OVER a validated data migration: copy the installation’s stored documents to an ARCHIVE, replace them with the converted ones, and move the app to the target version in one last write that also lifts the freeze. THIS REPLACES THE INSTALLATION’S LIVE DOCUMENTS, so it needs --yes; without it nothing is sent and the command only says what will change and what is kept (exit 4). What is kept: the old documents stay in the archive, outside your storage quota, for 14 days after the cutover completes (the date is printed), and `migrate rollback` puts them back within that time; after it they are erased for good. The version move follows the ordinary rules: a target that asks for more than you approved lands the app waiting for your approval (`needs_reconsent`), and the migration still completes; a migration never grants anything. The call is repeated while the migration is `cutting_over` and each call moves it on (one progress line per call; --once makes one call). From the first call the cutover can only finish or be rolled back, never aborted; if this terminal is closed the platform resumes it by itself, and a cutover that cannot finish after it replaced documents undoes itself from the archive (that is exit 1: it did not happen). Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 completed (or, with --once, one call answered), 1 the migration failed or the cutover undid itself, 4 the server refused it (or --yes is missing), 5 unknown (an answer this client cannot read, no progress, the call cap, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate cutover appi_abc --yes',
10
+ '<%= config.bin %> apps installations migrate cutover appi_abc --yes --once --json',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ migration: core_1.Flags.string({
21
+ description: 'Only act on this migration (the id `status` shows); refused if another one is open',
22
+ }),
23
+ yes: core_1.Flags.boolean({
24
+ description: 'Confirm that the cutover may REPLACE the installation’s stored documents and move the app to the new version (the old documents are archived for 14 days). Needed for every call',
25
+ default: false,
26
+ }),
27
+ once: core_1.Flags.boolean({
28
+ description: 'Make one call and stop, instead of repeating while it makes progress',
29
+ default: false,
30
+ }),
31
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
32
+ };
33
+ async run() {
34
+ this.requireAuth();
35
+ const { args, flags } = await this.parse(AppsInstallationsMigrateCutover);
36
+ const installation = args.installation;
37
+ const ctx = { step: 'cutover', installation };
38
+ const bin = this.config.bin;
39
+ // The cutover is the person's to confirm. The request names the migration they saw, so READ it first (a read changes nothing).
40
+ let state;
41
+ try {
42
+ state = (0, appDataMigration_1.readMigrationState)(await appDataMigration_1.migrationCalls.status(installation), installation);
43
+ }
44
+ catch (error) {
45
+ return this.failMigration(error, { step: 'status', installation }, false);
46
+ }
47
+ if (state === null)
48
+ return this.failUnreadable('status', installation);
49
+ const open = state.migration;
50
+ if (open === null) {
51
+ return this.failWithCliError((0, appDataMigration_1.describeLocalRefusal)('no_active_migration', { ...ctx, bin }));
52
+ }
53
+ if (flags.migration !== undefined && flags.migration !== open.id) {
54
+ return this.failWithCliError((0, appDataMigration_1.describeNamedMigrationNotOpen)({ ...ctx, bin }));
55
+ }
56
+ if (!flags.yes) {
57
+ if (open.state === 'validated') {
58
+ return this.failWithCliError({
59
+ message: (0, appDataMigration_1.describeCutoverGate)(open, bin),
60
+ code: appDataMigration_1.APPS_MIGRATION_CODES.cutoverNotConfirmed,
61
+ exit: appDataMigration_1.APPS_MIGRATION_EXIT.refused,
62
+ retryable: false,
63
+ details: { reason: 'cutover_not_confirmed', disclaimers: open.disclaimers },
64
+ });
65
+ }
66
+ // a cutover that has begun is resumed only by a confirmed call as well; one that is not validated has nothing to cut over
67
+ return this.failWithCliError({
68
+ message: `The cutover needs --yes (it replaces the installation’s documents). The migration is ${open.state}.\n→ ${bin} apps installations migrate status ${installation}`,
69
+ code: appDataMigration_1.APPS_MIGRATION_CODES.cutoverNotConfirmed,
70
+ exit: appDataMigration_1.APPS_MIGRATION_EXIT.refused,
71
+ retryable: false,
72
+ details: { reason: 'cutover_not_confirmed' },
73
+ });
74
+ }
75
+ let result;
76
+ try {
77
+ result = await (0, appDataMigration_1.runUntilSettled)({
78
+ step: 'cutover',
79
+ installationId: installation,
80
+ migrationId: open.id,
81
+ once: flags.once,
82
+ call: (pinned) => appDataMigration_1.migrationCalls.cutover(installation, {
83
+ migrationId: pinned ?? open.id,
84
+ confirmCutover: true,
85
+ }),
86
+ onProgress: (line) => (flags.json ? this.logToStderr(line) : this.log(line)),
87
+ });
88
+ }
89
+ catch (error) {
90
+ if (error instanceof appDataMigration_1.MigrationLoopError)
91
+ return this.failLoop(error, ctx);
92
+ throw error;
93
+ }
94
+ await this.report(result.view, {
95
+ json: flags.json,
96
+ exit: (0, appDataMigration_1.loopExit)(result),
97
+ jsonValue: { ...result.view, calls: result.calls, stopped: result.stopped },
98
+ notes: [(0, appDataMigration_1.loopStopNote)('cutover', result, bin)],
99
+ });
100
+ }
101
+ }
102
+ exports.default = AppsInstallationsMigrateCutover;
@@ -0,0 +1,13 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigratePlan extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ version: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigratePlan extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'Plan a migration of an installation’s stored data to another version of its app, for data that `apps installations compatibility` says does not fit it. The server runs that check again, and plans only if the target version declares the steps (rename, default, drop, convert) its documents need; it records the plan and nothing else. It freezes nothing, writes no document and moves no version. A plan is the first step of plan -> stage -> validate -> cutover; `abort` drops it. Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 planned, 4 the server refused it (the reason is printed in words), 5 unknown (an answer this client cannot read, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate plan appi_abc --version appv_new',
10
+ '<%= config.bin %> apps installations migrate plan appi_abc --version appv_new --json',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ version: core_1.Flags.string({
21
+ description: 'The version to migrate the installation’s data to (appv_...)',
22
+ required: true,
23
+ }),
24
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
25
+ };
26
+ async run() {
27
+ this.requireAuth();
28
+ const { args, flags } = await this.parse(AppsInstallationsMigratePlan);
29
+ const ctx = {
30
+ step: 'plan',
31
+ installation: args.installation,
32
+ versionId: flags.version,
33
+ };
34
+ let view;
35
+ try {
36
+ view = (0, appDataMigration_1.readMigration)(await appDataMigration_1.migrationCalls.plan(args.installation, flags.version), {
37
+ installationId: args.installation,
38
+ targetVersionId: flags.version,
39
+ });
40
+ }
41
+ catch (error) {
42
+ return this.failMigration(error, ctx, true);
43
+ }
44
+ if (view === null)
45
+ return this.failUnreadable('plan', args.installation);
46
+ if (view.state !== 'planned')
47
+ return this.failUnexpectedState('plan', view, 'planned');
48
+ await this.report(view, { json: flags.json, exit: appDataMigration_1.APPS_MIGRATION_EXIT.ok });
49
+ }
50
+ }
51
+ exports.default = AppsInstallationsMigratePlan;
@@ -0,0 +1,16 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateRollback extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ migration: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ 'discard-writes-since-cutover': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ once: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateRollback extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'ROLL BACK a completed data migration within its 14-day archive: freeze the app again, put the archived documents back over the live ones exactly as they were, move the app back to the version it ran before and lift the freeze. THIS REPLACES THE INSTALLATION’S LIVE DOCUMENTS, so it needs --yes; without it nothing is sent and the command only says what will change (exit 4). It first COUNTS the documents written since the cutover (the app is frozen, so none is missed): if there are any it refuses, changes nothing and prints how many per collection, because restoring would discard them; add --discard-writes-since-cutover to roll back anyway and lose them for good. It is also refused when the archive is past its 14 days (the old documents are erased), when the app was moved to another version or migrated again since the cutover, and when another migration is open. The call is repeated while the migration is `rolling_back` and each call moves it on (--once makes one call); if this terminal is closed the platform resumes it by itself. Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 rolled back (or, with --once, one call answered), 1 the migration failed, 4 the server refused it (or --yes is missing, or documents were written since and you did not say to discard them), 5 unknown (an answer this client cannot read, no progress, the call cap, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate rollback appi_abc --yes',
10
+ '<%= config.bin %> apps installations migrate rollback appi_abc --yes --discard-writes-since-cutover',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ migration: core_1.Flags.string({
21
+ description: 'The completed migration to roll back (the id `status` shows); without it, the one `status` shows',
22
+ }),
23
+ yes: core_1.Flags.boolean({
24
+ description: 'Confirm that the rollback may REPLACE the installation’s stored documents with the archived ones and move the app back. Needed for every call',
25
+ default: false,
26
+ }),
27
+ 'discard-writes-since-cutover': core_1.Flags.boolean({
28
+ description: 'Roll back even if documents were written since the cutover: they are discarded for good. Without it such a rollback is refused with the counts',
29
+ default: false,
30
+ }),
31
+ once: core_1.Flags.boolean({
32
+ description: 'Make one call and stop, instead of repeating while it makes progress',
33
+ default: false,
34
+ }),
35
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
36
+ };
37
+ async run() {
38
+ this.requireAuth();
39
+ const { args, flags } = await this.parse(AppsInstallationsMigrateRollback);
40
+ const installation = args.installation;
41
+ const ctx = { step: 'rollback', installation };
42
+ const bin = this.config.bin;
43
+ let state;
44
+ try {
45
+ state = (0, appDataMigration_1.readMigrationState)(await appDataMigration_1.migrationCalls.status(installation), installation);
46
+ }
47
+ catch (error) {
48
+ return this.failMigration(error, { step: 'status', installation }, false);
49
+ }
50
+ if (state === null)
51
+ return this.failUnreadable('status', installation);
52
+ const shown = state.migration;
53
+ if (shown === null) {
54
+ return this.failWithCliError((0, appDataMigration_1.describeLocalRefusal)('no_active_migration', { ...ctx, bin }));
55
+ }
56
+ if (flags.migration !== undefined && flags.migration !== shown.id) {
57
+ return this.failWithCliError({
58
+ message: `The migration you named is not the one this installation shows (it was closed or replaced). Nothing was changed.\n→ ${bin} apps installations migrate status ${installation}`,
59
+ code: appDataMigration_1.APPS_MIGRATION_CODES.changed,
60
+ exit: appDataMigration_1.APPS_MIGRATION_EXIT.refused,
61
+ retryable: false,
62
+ });
63
+ }
64
+ if (!flags.yes) {
65
+ return this.failWithCliError({
66
+ message: shown.state === 'completed' || shown.state === 'rolling_back'
67
+ ? (0, appDataMigration_1.describeRollbackGate)(shown, bin)
68
+ : `The rollback needs --yes (it replaces the installation’s documents). The migration is ${shown.state}, which cannot be rolled back.\n→ ${bin} apps installations migrate status ${installation}`,
69
+ code: appDataMigration_1.APPS_MIGRATION_CODES.rollbackNotConfirmed,
70
+ exit: appDataMigration_1.APPS_MIGRATION_EXIT.refused,
71
+ retryable: false,
72
+ details: { reason: 'rollback_not_confirmed', disclaimers: shown.disclaimers },
73
+ });
74
+ }
75
+ let result;
76
+ try {
77
+ result = await (0, appDataMigration_1.runUntilSettled)({
78
+ step: 'rollback',
79
+ installationId: installation,
80
+ migrationId: shown.id,
81
+ once: flags.once,
82
+ call: (pinned) => appDataMigration_1.migrationCalls.rollback(installation, {
83
+ migrationId: pinned ?? shown.id,
84
+ confirmRollback: true,
85
+ ...(flags['discard-writes-since-cutover'] ? { discardWritesSinceCutover: true } : {}),
86
+ }),
87
+ onProgress: (line) => (flags.json ? this.logToStderr(line) : this.log(line)),
88
+ });
89
+ }
90
+ catch (error) {
91
+ if (error instanceof appDataMigration_1.MigrationLoopError)
92
+ return this.failLoop(error, ctx);
93
+ throw error;
94
+ }
95
+ await this.report(result.view, {
96
+ json: flags.json,
97
+ exit: (0, appDataMigration_1.loopExit)(result),
98
+ jsonValue: { ...result.view, calls: result.calls, stopped: result.stopped },
99
+ notes: [(0, appDataMigration_1.loopStopNote)('rollback', result, bin)],
100
+ });
101
+ }
102
+ }
103
+ exports.default = AppsInstallationsMigrateRollback;
@@ -0,0 +1,15 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateStage extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ migration: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ once: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateStage extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'Freeze the installation and convert its stored documents, with the steps the target version declares, into a STAGING area, a bounded batch at a time, repeating the call while it is `frozen` or `staging` and each call moves it on (one progress line per call; --once makes one call). STAGING FREEZES THE APP: while a migration is open the app does not run and nothing can write its data, until `abort` puts it back. So the first call on a planned migration needs --yes; without it nothing is frozen and the command only says what will happen, with the three sentences every migration view carries, and exits 4. Nothing live changes: no stored document, no version, no old row is touched. It stops at `staged`, at `failed` (a finding stopped it: they are printed) or when a call moves nothing. Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 staged (or, with --once, one call answered), 1 the migration failed or a finding stopped it, 4 the server refused it (or --yes is missing), 5 unknown (an answer this client cannot read, no progress, the call cap, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate stage appi_abc --yes',
10
+ '<%= config.bin %> apps installations migrate stage appi_abc --yes --once',
11
+ '<%= config.bin %> apps installations migrate stage appi_abc --migration mig_xyz --yes --json',
12
+ ];
13
+ static args = {
14
+ installation: core_1.Args.string({
15
+ description: 'The installation id (appi_...)',
16
+ required: true,
17
+ ignoreStdin: true,
18
+ }),
19
+ };
20
+ static flags = {
21
+ migration: core_1.Flags.string({
22
+ description: 'Only act on this migration (the id `status` shows); refused if another one is open',
23
+ }),
24
+ yes: core_1.Flags.boolean({
25
+ description: 'Confirm that staging may FREEZE the app (it stops running and nothing can write its data until the migration is aborted). Needed for the first call on a planned migration',
26
+ default: false,
27
+ }),
28
+ once: core_1.Flags.boolean({
29
+ description: 'Make one call and stop, instead of repeating while it makes progress',
30
+ default: false,
31
+ }),
32
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
33
+ };
34
+ async run() {
35
+ this.requireAuth();
36
+ const { args, flags } = await this.parse(AppsInstallationsMigrateStage);
37
+ const installation = args.installation;
38
+ const ctx = { step: 'stage', installation };
39
+ const bin = this.config.bin;
40
+ // Staging freezes the app, which is the person's to confirm. Without --yes, READ where the migration stands (a read changes nothing): a
41
+ // planned one is the one thing that would freeze, so that is said and not sent; one already frozen or staging carries on.
42
+ if (!flags.yes) {
43
+ let state;
44
+ try {
45
+ state = (0, appDataMigration_1.readMigrationState)(await appDataMigration_1.migrationCalls.status(installation), installation);
46
+ }
47
+ catch (error) {
48
+ return this.failMigration(error, { step: 'status', installation }, false);
49
+ }
50
+ if (state === null)
51
+ return this.failUnreadable('status', installation);
52
+ const open = state.migration;
53
+ if (open === null) {
54
+ return this.failWithCliError((0, appDataMigration_1.describeLocalRefusal)('no_active_migration', { ...ctx, bin }));
55
+ }
56
+ if (flags.migration !== undefined && flags.migration !== open.id) {
57
+ return this.failWithCliError((0, appDataMigration_1.describeNamedMigrationNotOpen)({ ...ctx, bin }));
58
+ }
59
+ if (open.state === 'planned') {
60
+ return this.failWithCliError({
61
+ message: (0, appDataMigration_1.describeFreezeGate)(open, bin),
62
+ code: appDataMigration_1.APPS_MIGRATION_CODES.freezeNotConfirmed,
63
+ exit: appDataMigration_1.APPS_MIGRATION_EXIT.refused,
64
+ retryable: false,
65
+ details: { reason: 'freeze_not_confirmed', disclaimers: open.disclaimers },
66
+ });
67
+ }
68
+ }
69
+ let result;
70
+ try {
71
+ result = await (0, appDataMigration_1.runUntilSettled)({
72
+ step: 'stage',
73
+ installationId: installation,
74
+ ...(flags.migration === undefined ? {} : { migrationId: flags.migration }),
75
+ once: flags.once,
76
+ call: (pinned) => appDataMigration_1.migrationCalls.stage(installation, {
77
+ ...(pinned === undefined ? {} : { migrationId: pinned }),
78
+ ...(flags.yes ? { confirmFreeze: true } : {}),
79
+ }),
80
+ onProgress: (line) => (flags.json ? this.logToStderr(line) : this.log(line)),
81
+ });
82
+ }
83
+ catch (error) {
84
+ if (error instanceof appDataMigration_1.MigrationLoopError)
85
+ return this.failLoop(error, ctx);
86
+ throw error;
87
+ }
88
+ await this.report(result.view, {
89
+ json: flags.json,
90
+ exit: (0, appDataMigration_1.loopExit)(result),
91
+ jsonValue: { ...result.view, calls: result.calls, stopped: result.stopped },
92
+ notes: [(0, appDataMigration_1.loopStopNote)('stage', result, bin)],
93
+ });
94
+ }
95
+ }
96
+ exports.default = AppsInstallationsMigrateStage;
@@ -0,0 +1,12 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateStatus extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateStatus extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'Show an installation’s open data migration, or say there is none: its state in words, the plan’s counts, the freeze, how many documents are staged and checked, the cutover’s or the rollback’s progress, and the bounded findings (a collection, a document id, a code and where, never a value), with the three sentences every migration view carries (before the cutover: the app is frozen, nothing live has changed, and a validated staging is a snapshot, not a guarantee; after it: what changed and what is kept). When none is open but a cutover COMPLETED inside its archive window, that migration is shown with the day its archive of the old documents is erased, so you can still roll back. It reads and writes nothing. No migration open is a normal answer (exit 0). Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 a migration that is not failed, or none; 1 the migration is failed (abort it); 4 the server refused it; 5 unknown (an answer this client cannot read: that is NOT "there is none"); 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate status appi_abc',
10
+ '<%= config.bin %> apps installations migrate status appi_abc --json',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ json: core_1.Flags.boolean({ description: 'Output the migration state as JSON' }),
21
+ };
22
+ async run() {
23
+ this.requireAuth();
24
+ const { args, flags } = await this.parse(AppsInstallationsMigrateStatus);
25
+ let state;
26
+ try {
27
+ state = (0, appDataMigration_1.readMigrationState)(await appDataMigration_1.migrationCalls.status(args.installation), args.installation);
28
+ }
29
+ catch (error) {
30
+ return this.failMigration(error, { step: 'status', installation: args.installation }, false);
31
+ }
32
+ if (state === null)
33
+ return this.failUnreadable('status', args.installation);
34
+ const view = state.migration;
35
+ if (view === null) {
36
+ if (flags.json) {
37
+ this.printJsonResult({ object: 'app_data_migration_state', migration: null });
38
+ }
39
+ else {
40
+ for (const line of (0, appDataMigration_1.formatNoMigration)(args.installation, this.config.bin))
41
+ this.log(line);
42
+ }
43
+ return;
44
+ }
45
+ await this.report(view, {
46
+ json: flags.json,
47
+ exit: view.state === 'failed' ? appDataMigration_1.APPS_MIGRATION_EXIT.failed : appDataMigration_1.APPS_MIGRATION_EXIT.ok,
48
+ jsonValue: { object: 'app_data_migration_state', migration: view },
49
+ });
50
+ }
51
+ }
52
+ exports.default = AppsInstallationsMigrateStatus;
@@ -0,0 +1,14 @@
1
+ import { AppsMigrationCommand } from '../../../../lib/appDataMigrationCommand';
2
+ export default class AppsInstallationsMigrateValidate extends AppsMigrationCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ installation: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ migration: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ once: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const appDataMigrationCommand_1 = require("../../../../lib/appDataMigrationCommand");
5
+ const appDataMigration_1 = require("../../../../lib/appDataMigration");
6
+ class AppsInstallationsMigrateValidate extends appDataMigrationCommand_1.AppsMigrationCommand {
7
+ static description = 'Hold every staged document to the data schemas the target version declares, a bounded slice at a time, repeating the call while the migration is `staged` and validation is not finished (one progress line per call; --once makes one call). `validated` means every converted document fits those schemas as of the time shown: a snapshot, not a guarantee, and not a promise that the app will work with them. A document that does not fit stops it as `failed` and is printed as a finding; something it could not judge (a schema it could not read or enforce, a document too complex for its budget) leaves it `staged` and is NOT a pass. It changes no live document and no version; the app stays frozen until you `abort`. Only a signed-in person who is the installation’s installer (the person whose approval it runs under) may run it: a token or an agent’s credential is refused. It is off unless the deployment has it enabled (SKRR_APP_DATA_MIGRATION), which exit 6 says. Exit codes: 0 validated (or, with --once, one call answered), 1 the migration failed or a finding stopped it, 4 the server refused it, 5 unknown (an answer this client cannot read, no progress, the call cap, a validation that could not judge, or a request that may have landed: run `status`), 6 not enabled on this server.';
8
+ static examples = [
9
+ '<%= config.bin %> apps installations migrate validate appi_abc',
10
+ '<%= config.bin %> apps installations migrate validate appi_abc --once --json',
11
+ ];
12
+ static args = {
13
+ installation: core_1.Args.string({
14
+ description: 'The installation id (appi_...)',
15
+ required: true,
16
+ ignoreStdin: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ migration: core_1.Flags.string({
21
+ description: 'Only act on this migration (the id `status` shows); refused if another one is open',
22
+ }),
23
+ once: core_1.Flags.boolean({
24
+ description: 'Make one call and stop, instead of repeating while it makes progress',
25
+ default: false,
26
+ }),
27
+ json: core_1.Flags.boolean({ description: 'Output the migration as JSON' }),
28
+ };
29
+ async run() {
30
+ this.requireAuth();
31
+ const { args, flags } = await this.parse(AppsInstallationsMigrateValidate);
32
+ const installation = args.installation;
33
+ const ctx = { step: 'validate', installation };
34
+ let result;
35
+ try {
36
+ result = await (0, appDataMigration_1.runUntilSettled)({
37
+ step: 'validate',
38
+ installationId: installation,
39
+ ...(flags.migration === undefined ? {} : { migrationId: flags.migration }),
40
+ once: flags.once,
41
+ call: (pinned) => appDataMigration_1.migrationCalls.validate(installation, pinned === undefined ? {} : { migrationId: pinned }),
42
+ onProgress: (line) => (flags.json ? this.logToStderr(line) : this.log(line)),
43
+ });
44
+ }
45
+ catch (error) {
46
+ if (error instanceof appDataMigration_1.MigrationLoopError)
47
+ return this.failLoop(error, ctx);
48
+ throw error;
49
+ }
50
+ await this.report(result.view, {
51
+ json: flags.json,
52
+ exit: (0, appDataMigration_1.loopExit)(result),
53
+ jsonValue: { ...result.view, calls: result.calls, stopped: result.stopped },
54
+ notes: [(0, appDataMigration_1.loopStopNote)('validate', result, this.config.bin)],
55
+ });
56
+ }
57
+ }
58
+ exports.default = AppsInstallationsMigrateValidate;