@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.
Files changed (111) hide show
  1. package/README.md +13 -0
  2. package/dist/base-command.d.ts +14 -1
  3. package/dist/base-command.js +166 -46
  4. package/dist/commands/agent/message/send.d.ts +1 -0
  5. package/dist/commands/agent/message/send.js +3 -0
  6. package/dist/commands/agents/mini-computer/app/set.js +1 -1
  7. package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
  8. package/dist/commands/apps/check.js +3 -8
  9. package/dist/commands/apps/data/batch.d.ts +1 -0
  10. package/dist/commands/apps/data/batch.js +19 -2
  11. package/dist/commands/apps/data/delete.d.ts +1 -0
  12. package/dist/commands/apps/data/delete.js +14 -2
  13. package/dist/commands/apps/data/patch.d.ts +1 -0
  14. package/dist/commands/apps/data/patch.js +11 -2
  15. package/dist/commands/apps/data/put.d.ts +1 -0
  16. package/dist/commands/apps/data/put.js +17 -3
  17. package/dist/commands/apps/install.js +7 -2
  18. package/dist/commands/apps/installations/compatibility.d.ts +13 -0
  19. package/dist/commands/apps/installations/compatibility.js +60 -0
  20. package/dist/commands/apps/installations/migrate/abort.d.ts +13 -0
  21. package/dist/commands/apps/installations/migrate/abort.js +45 -0
  22. package/dist/commands/apps/installations/migrate/cutover.d.ts +15 -0
  23. package/dist/commands/apps/installations/migrate/cutover.js +102 -0
  24. package/dist/commands/apps/installations/migrate/plan.d.ts +13 -0
  25. package/dist/commands/apps/installations/migrate/plan.js +51 -0
  26. package/dist/commands/apps/installations/migrate/rollback.d.ts +16 -0
  27. package/dist/commands/apps/installations/migrate/rollback.js +103 -0
  28. package/dist/commands/apps/installations/migrate/stage.d.ts +15 -0
  29. package/dist/commands/apps/installations/migrate/stage.js +96 -0
  30. package/dist/commands/apps/installations/migrate/status.d.ts +12 -0
  31. package/dist/commands/apps/installations/migrate/status.js +52 -0
  32. package/dist/commands/apps/installations/migrate/validate.d.ts +14 -0
  33. package/dist/commands/apps/installations/migrate/validate.js +58 -0
  34. package/dist/commands/apps/installations/show.js +14 -9
  35. package/dist/commands/apps/installations/snapshot.js +5 -2
  36. package/dist/commands/apps/operations/check.d.ts +16 -0
  37. package/dist/commands/apps/operations/check.js +127 -0
  38. package/dist/commands/apps/publish/propose.js +33 -4
  39. package/dist/commands/apps/reconsent.js +7 -1
  40. package/dist/commands/apps/reference.d.ts +4 -2
  41. package/dist/commands/apps/reference.js +7 -4
  42. package/dist/commands/apps/resume.js +1 -1
  43. package/dist/commands/apps/rollback.d.ts +9 -0
  44. package/dist/commands/apps/rollback.js +81 -2
  45. package/dist/commands/apps/settings/set.js +22 -10
  46. package/dist/commands/apps/upgrade.d.ts +8 -0
  47. package/dist/commands/apps/upgrade.js +67 -2
  48. package/dist/commands/apps/version/cat.d.ts +22 -0
  49. package/dist/commands/apps/version/cat.js +220 -0
  50. package/dist/commands/apps/version/show.js +3 -1
  51. package/dist/commands/commerce/incidents/release.d.ts +24 -0
  52. package/dist/commands/commerce/incidents/release.js +46 -0
  53. package/dist/commands/duties/cases.js +12 -1
  54. package/dist/commands/duties/hypotheses.js +10 -3
  55. package/dist/commands/duties/observations.d.ts +4 -0
  56. package/dist/commands/duties/observations.js +14 -3
  57. package/dist/commands/outbox/list.d.ts +11 -4
  58. package/dist/commands/outbox/list.js +56 -9
  59. package/dist/commands/outbox/retry.d.ts +8 -2
  60. package/dist/commands/outbox/retry.js +76 -16
  61. package/dist/commands/outbox/show.d.ts +20 -0
  62. package/dist/commands/outbox/show.js +83 -0
  63. package/dist/commands/proposals/list.js +13 -9
  64. package/dist/commands/requests/show.d.ts +12 -0
  65. package/dist/commands/requests/show.js +42 -23
  66. package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
  67. package/dist/commands/spaces/deletion/cancel.js +70 -0
  68. package/dist/commands/spaces/workflows/run.js +12 -0
  69. package/dist/commands/widgets/check.d.ts +9 -0
  70. package/dist/commands/widgets/check.js +16 -3
  71. package/dist/generated/agent-guides.json +17 -17
  72. package/dist/lib/api-fetch.d.ts +5 -0
  73. package/dist/lib/api-fetch.js +81 -22
  74. package/dist/lib/appCompatibility.d.ts +31 -0
  75. package/dist/lib/appCompatibility.js +66 -0
  76. package/dist/lib/appData.d.ts +46 -4
  77. package/dist/lib/appData.js +161 -32
  78. package/dist/lib/appDataMigration.d.ts +204 -0
  79. package/dist/lib/appDataMigration.js +753 -0
  80. package/dist/lib/appDataMigrationCommand.d.ts +39 -0
  81. package/dist/lib/appDataMigrationCommand.js +90 -0
  82. package/dist/lib/appInstallations.d.ts +40 -5
  83. package/dist/lib/appInstallations.js +251 -35
  84. package/dist/lib/appVersionFile.d.ts +82 -0
  85. package/dist/lib/appVersionFile.js +195 -0
  86. package/dist/lib/apps-command.d.ts +14 -3
  87. package/dist/lib/apps-command.js +80 -65
  88. package/dist/lib/appsCheck.js +16 -2
  89. package/dist/lib/commerce.d.ts +6 -0
  90. package/dist/lib/commerce.js +9 -0
  91. package/dist/lib/duties.d.ts +15 -1
  92. package/dist/lib/duties.js +21 -3
  93. package/dist/lib/json-output.d.ts +2 -0
  94. package/dist/lib/json-output.js +8 -4
  95. package/dist/lib/node-adapter.js +69 -38
  96. package/dist/lib/outbox.d.ts +110 -1
  97. package/dist/lib/outbox.js +261 -35
  98. package/dist/lib/rate-limit-retry.d.ts +4 -5
  99. package/dist/lib/rate-limit-retry.js +6 -10
  100. package/dist/lib/refresh.d.ts +2 -0
  101. package/dist/lib/refresh.js +6 -0
  102. package/dist/lib/space-deletion-cancel.d.ts +47 -0
  103. package/dist/lib/space-deletion-cancel.js +141 -0
  104. package/dist/lib/widgetCheck.js +1 -1
  105. package/dist/lib/widgetStaticScan.d.ts +11 -5
  106. package/dist/lib/widgetStaticScan.js +73 -165
  107. package/dist/lib/write-outcome.d.ts +76 -0
  108. package/dist/lib/write-outcome.js +190 -0
  109. package/dist/node_modules/@skrr-ai/data-provider/index.js +11955 -11231
  110. package/oclif.manifest.json +3019 -499
  111. package/package.json +12 -3
@@ -13,6 +13,7 @@ export default class AppsDataPut extends AppsCommand {
13
13
  'from-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
14
  stdin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
15
  'expected-rev': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'idempotency-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
17
  };
17
18
  run(): Promise<void>;
18
19
  }
@@ -39,14 +39,27 @@ class AppsDataPut extends apps_command_1.AppsCommand {
39
39
  description: 'The revision you last read: 0 creates (refused if the document is there), N replaces only if it is still at N; left out, it overwrites whatever is there',
40
40
  min: 0,
41
41
  }),
42
+ 'idempotency-key': core_1.Flags.string({
43
+ description: "A key for THIS write (1 to 200 characters: letters, digits and . _ : / -). Default: a fresh one per run, shown if the outcome is unknown. The same key with the same request is answered from the server's operation receipt, when it keeps one, instead of writing again; without a receipt, sending it again writes again",
44
+ }),
42
45
  };
43
46
  async run() {
44
47
  this.requireAuth();
45
48
  const { args, flags } = await this.parse(AppsDataPut);
46
- const target = { installation: args.installation, collection: args.collection, id: args.id, verb: 'put' };
49
+ const target = {
50
+ installation: args.installation,
51
+ collection: args.collection,
52
+ id: args.id,
53
+ verb: 'put',
54
+ };
47
55
  let requestStarted = false;
48
56
  let responseConfirmed = false;
57
+ let idempotencyKey;
49
58
  try {
59
+ idempotencyKey =
60
+ flags['idempotency-key'] === undefined
61
+ ? (0, appData_1.mintDataWriteKey)()
62
+ : (0, appData_1.checkIdempotencyKey)(flags['idempotency-key']);
50
63
  const doc = await (0, appData_1.readDocumentInput)({
51
64
  doc: flags.doc,
52
65
  fromFile: flags['from-file'],
@@ -56,7 +69,7 @@ class AppsDataPut extends apps_command_1.AppsCommand {
56
69
  const result = await data_provider_1.dataService.putAppInstallationData(args.installation, args.collection, args.id, {
57
70
  doc: doc,
58
71
  ...(flags['expected-rev'] === undefined ? {} : { expectedRev: flags['expected-rev'] }),
59
- });
72
+ }, { idempotencyKey });
60
73
  (0, appData_1.assertAppDataWriteResult)(result, { verb: 'put', id: args.id });
61
74
  if (result.written !== true) {
62
75
  // the route answers a conflict with a 409, which fails above; a 2xx that says "not written" is read the same way
@@ -68,11 +81,12 @@ class AppsDataPut extends apps_command_1.AppsCommand {
68
81
  return;
69
82
  }
70
83
  this.log(`wrote ${args.collection}/${result.id} (rev ${result.rev}, ${result.created ? 'created' : 'replaced'})`);
84
+ this.logOperationReference(result);
71
85
  }
72
86
  catch (error) {
73
87
  if (responseConfirmed)
74
88
  return this.failConfirmedDataOutput();
75
- return this.failPersonData(error, { ...target, requestStarted });
89
+ return this.failPersonData(error, { ...target, requestStarted, idempotencyKey });
76
90
  }
77
91
  }
78
92
  }
@@ -53,9 +53,13 @@ class AppsInstall extends apps_command_1.AppsCommand {
53
53
  this.requireAuth();
54
54
  const { args, flags } = await this.parse(AppsInstall);
55
55
  const appId = await this.appId(args.app);
56
+ // what a refusal's words may say about this install, as far as it got: the version and who it is for
57
+ const refused = { action: 'install' };
56
58
  try {
57
59
  const target = await (0, appInstallations_1.resolveInstallTarget)({ appId, versionId: flags.version });
60
+ refused.versionId = target.versionId;
58
61
  const principal = await (0, appInstallations_1.resolveInstallPrincipal)({ agent: flags.agent, me: flags.me });
62
+ refused.principal = principal;
59
63
  const shown = await data_provider_1.dataService.getAppGrantDisclosure({
60
64
  versionId: target.versionId,
61
65
  principalKind: principal.kind,
@@ -63,7 +67,8 @@ class AppsInstall extends apps_command_1.AppsCommand {
63
67
  ...(flags['host-machine'] ? { hostMachineId: flags['host-machine'] } : {}),
64
68
  });
65
69
  const disclosure = (0, data_provider_1.parseAppDisclosure)(shown.disclosure);
66
- if (flags['settings-file'] && !data_provider_1.AppSettingsManifestSchema.safeParse(shown.configuration).success)
70
+ if (flags['settings-file'] &&
71
+ !data_provider_1.AppSettingsManifestSchema.safeParse(shown.configuration).success)
67
72
  throw new Error('This server did not provide readable config fields. Nothing was installed.');
68
73
  const settings = flags['settings-file']
69
74
  ? (0, appSettings_1.readAppSettingsFile)(flags['settings-file'], shown.configuration ?? {})
@@ -146,7 +151,7 @@ class AppsInstall extends apps_command_1.AppsCommand {
146
151
  retryable: false,
147
152
  });
148
153
  }
149
- this.failInstallation(error);
154
+ this.failInstallation(error, refused);
150
155
  }
151
156
  }
152
157
  }
@@ -0,0 +1,13 @@
1
+ import { AppsCommand } from '../../../lib/apps-command';
2
+ export default class AppsInstallationsCompatibility extends AppsCommand {
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,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const apps_command_1 = require("../../../lib/apps-command");
6
+ const appCompatibility_1 = require("../../../lib/appCompatibility");
7
+ const drain_stdio_1 = require("../../../lib/drain-stdio");
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 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
+ static examples = [
11
+ '<%= config.bin %> apps installations compatibility appi_abc --version appv_new',
12
+ '<%= config.bin %> apps installations compatibility appi_abc --version appv_new --json',
13
+ ];
14
+ static args = {
15
+ installation: core_1.Args.string({
16
+ description: 'The installation id (appi_...)',
17
+ required: true,
18
+ ignoreStdin: true,
19
+ }),
20
+ };
21
+ static flags = {
22
+ version: core_1.Flags.string({
23
+ description: 'The version to check the data against (appv_...)',
24
+ required: true,
25
+ }),
26
+ json: core_1.Flags.boolean({ description: 'Output the verdict as JSON' }),
27
+ };
28
+ async run() {
29
+ this.requireAuth();
30
+ const { args, flags } = await this.parse(AppsInstallationsCompatibility);
31
+ let view;
32
+ try {
33
+ view = (0, appCompatibility_1.readCompatibility)(await data_provider_1.dataService.getAppInstallationCompatibility(args.installation, flags.version), args.installation, flags.version);
34
+ }
35
+ catch (error) {
36
+ return this.failInstallation(error, {
37
+ subject: args.installation,
38
+ versionId: flags.version,
39
+ });
40
+ }
41
+ if (view === null) {
42
+ return this.failWithCliError({
43
+ message: appCompatibility_1.COMPATIBILITY_UNREADABLE_MESSAGE,
44
+ code: 'APP_COMPATIBILITY_UNREADABLE',
45
+ exit: 5,
46
+ retryable: false,
47
+ });
48
+ }
49
+ if (flags.json) {
50
+ this.printJsonResult(view, { ok: view.verdict === 'compatible' });
51
+ }
52
+ else {
53
+ for (const line of (0, appCompatibility_1.formatCompatibility)(view))
54
+ this.log(line);
55
+ }
56
+ await (0, drain_stdio_1.drainStdio)();
57
+ this.exit((0, appCompatibility_1.compatibilityExit)(view));
58
+ }
59
+ }
60
+ exports.default = AppsInstallationsCompatibility;
@@ -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
+ }