@memberjunction/cli 6.2.0-edge.3 → 6.2.0-edge.4

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 (51) hide show
  1. package/README.md +9 -0
  2. package/dist/commands/artifacts/reclassify.d.ts.map +1 -1
  3. package/dist/commands/artifacts/reclassify.js +4 -2
  4. package/dist/commands/artifacts/reclassify.js.map +1 -1
  5. package/dist/commands/cache/clear.d.ts +25 -0
  6. package/dist/commands/cache/clear.d.ts.map +1 -0
  7. package/dist/commands/cache/clear.js +79 -0
  8. package/dist/commands/cache/clear.js.map +1 -0
  9. package/dist/commands/cache/usage.d.ts +7 -0
  10. package/dist/commands/cache/usage.d.ts.map +1 -0
  11. package/dist/commands/cache/usage.js +10 -0
  12. package/dist/commands/cache/usage.js.map +1 -0
  13. package/dist/commands/codegen/index.d.ts +15 -6
  14. package/dist/commands/codegen/index.d.ts.map +1 -1
  15. package/dist/commands/codegen/index.js +35 -4
  16. package/dist/commands/codegen/index.js.map +1 -1
  17. package/dist/commands/install/index.d.ts.map +1 -1
  18. package/dist/commands/install/index.js +7 -1
  19. package/dist/commands/install/index.js.map +1 -1
  20. package/dist/commands/migrate/index.d.ts +10 -0
  21. package/dist/commands/migrate/index.d.ts.map +1 -1
  22. package/dist/commands/migrate/index.js +42 -0
  23. package/dist/commands/migrate/index.js.map +1 -1
  24. package/dist/commands/sync/push.d.ts +33 -8
  25. package/dist/commands/sync/push.d.ts.map +1 -1
  26. package/dist/commands/sync/push.js +94 -6
  27. package/dist/commands/sync/push.js.map +1 -1
  28. package/dist/commands/user/clone.d.ts +27 -0
  29. package/dist/commands/user/clone.d.ts.map +1 -0
  30. package/dist/commands/user/clone.js +106 -0
  31. package/dist/commands/user/clone.js.map +1 -0
  32. package/dist/hooks/prerun.d.ts.map +1 -1
  33. package/dist/hooks/prerun.js +9 -0
  34. package/dist/hooks/prerun.js.map +1 -1
  35. package/dist/lib/domain-profiles.d.ts.map +1 -1
  36. package/dist/lib/domain-profiles.js +4 -0
  37. package/dist/lib/domain-profiles.js.map +1 -1
  38. package/dist/lib/keep-awake.d.ts +45 -0
  39. package/dist/lib/keep-awake.d.ts.map +1 -0
  40. package/dist/lib/keep-awake.js +71 -0
  41. package/dist/lib/keep-awake.js.map +1 -0
  42. package/dist/lib/shared-cache.d.ts +84 -0
  43. package/dist/lib/shared-cache.d.ts.map +1 -0
  44. package/dist/lib/shared-cache.js +160 -0
  45. package/dist/lib/shared-cache.js.map +1 -0
  46. package/dist/light-commands.d.ts +8 -0
  47. package/dist/light-commands.d.ts.map +1 -1
  48. package/dist/light-commands.js +33 -0
  49. package/dist/light-commands.js.map +1 -1
  50. package/oclif.manifest.json +2181 -1977
  51. package/package.json +29 -27
@@ -1,9 +1,34 @@
1
- /**
2
- * Thin oclif shim — the real logic lives in {@link SyncPushPlugin} in
3
- * `@memberjunction/metadata-sync/plugins` (plan §3, open-question #2 "shim"
4
- * approach). oclif discovers this default export and routes `mj sync push` to it;
5
- * the plugin inherits `--format`/`--verbose`/`--no-banner`, the runtime advisory,
6
- * and uniform result emission from BaseCLIPlugin.
7
- */
8
- export { SyncPushPlugin as default } from '@memberjunction/metadata-sync/plugins';
1
+ import type { MJCLIResult, PluginUsage } from '@memberjunction/cli-core';
2
+ import { SyncPushPlugin } from '@memberjunction/metadata-sync/plugins';
3
+ export default class SyncPush extends SyncPushPlugin {
4
+ static flags: {
5
+ 'skip-cache-clear': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
6
+ dir: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ 'dry-run': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
8
+ ci: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
+ 'no-validate': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
+ 'delete-db-only': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
+ 'isolated-transactions': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
+ 'parallel-batch-size': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ include: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
14
+ exclude: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
+ incremental: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
16
+ 'change-detail': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
17
+ };
18
+ static Usage: PluginUsage;
19
+ protected Execute(): Promise<MJCLIResult>;
20
+ /**
21
+ * Whether a failed push left rows in the database. False only when the outcome positively says
22
+ * the push rolled back and committed nothing; anything unreadable counts as "it may have".
23
+ */
24
+ private failedPushLeftWrites;
25
+ /**
26
+ * Whether a successful push positively reports that it wrote nothing: it was cancelled before
27
+ * writing, or it created, updated and deleted no rows. A result without those counts counts as
28
+ * "it may have written".
29
+ */
30
+ private successfulPushWroteNothing;
31
+ /** Clears the shared cache unless this was a dry run (which writes nothing). */
32
+ private clearSharedCache;
33
+ }
9
34
  //# sourceMappingURL=push.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/push.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/push.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAOvE,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,cAAc;IAClD,MAAM,CAAC,KAAK;;;;;;;;;;;;;MAKV;IAEF,MAAM,CAAC,KAAK,EAAE,WAAW,CAMvB;cAEuB,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAwBxD;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAc5B;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAWlC,gFAAgF;YAClE,gBAAgB;CAI/B"}
@@ -1,9 +1,97 @@
1
1
  /**
2
- * Thin oclif shim — the real logic lives in {@link SyncPushPlugin} in
3
- * `@memberjunction/metadata-sync/plugins` (plan §3, open-question #2 "shim"
4
- * approach). oclif discovers this default export and routes `mj sync push` to it;
5
- * the plugin inherits `--format`/`--verbose`/`--no-banner`, the runtime advisory,
6
- * and uniform result emission from BaseCLIPlugin.
2
+ * oclif entry for `mj sync push`. The logic lives in {@link SyncPushPlugin} in
3
+ * `@memberjunction/metadata-sync/plugins`; this subclass only adds the shared-cache clear that must
4
+ * follow a database write, before the plugin's Cleanup() ends the process. Running servers never
5
+ * hear about rows written here, so without the clear they keep serving the old ones.
6
+ *
7
+ * The clear runs only when the push may have changed the database:
8
+ * - A successful push clears unless it reports that it wrote nothing: it was cancelled before
9
+ * writing, or it created, updated and deleted no rows. Clearing after a no-op push would drop
10
+ * every server's cache on every deploy for nothing.
11
+ * - A failed push clears only when it left something behind. An atomic push (the default) rolls its
12
+ * writes back, and `PushAbortedError` says so: `rolledBack`, plus the rows a non-atomic push
13
+ * committed anyway.
14
+ * - When the outcome cannot be read, the clear still runs: a needless reload is cheaper than a fleet
15
+ * serving rows that are no longer in the database.
7
16
  */
8
- export { SyncPushPlugin as default } from '@memberjunction/metadata-sync/plugins';
17
+ import { Flags } from '@oclif/core';
18
+ import { SyncPushPlugin } from '@memberjunction/metadata-sync/plugins';
19
+ import { PushAbortedError } from '@memberjunction/metadata-sync';
20
+ import { AppendSharedCacheClear, ClearSharedCacheAfterWrite, SKIP_CACHE_CLEAR_ENV } from '../../lib/shared-cache.js';
21
+ export default class SyncPush extends SyncPushPlugin {
22
+ static { this.flags = {
23
+ ...SyncPushPlugin.flags,
24
+ 'skip-cache-clear': Flags.boolean({
25
+ description: `Do not clear the shared Redis cache (REDIS_URL) after pushing. Also: ${SKIP_CACHE_CLEAR_ENV}=1`,
26
+ }),
27
+ }; }
28
+ static { this.Usage = {
29
+ ...SyncPushPlugin.Usage,
30
+ flags: [
31
+ ...(SyncPushPlugin.Usage?.flags ?? []),
32
+ { name: '--skip-cache-clear', type: 'boolean', description: 'Do not clear the shared Redis cache after pushing' },
33
+ ],
34
+ }; }
35
+ async Execute() {
36
+ let result;
37
+ try {
38
+ result = await super.Execute();
39
+ }
40
+ catch (error) {
41
+ // Runs after the plugin's rollback, so servers reload whatever the push did commit.
42
+ if (this.failedPushLeftWrites(undefined, error)) {
43
+ const report = await this.clearSharedCache('mj sync push (failed)');
44
+ if (report) {
45
+ this.Host.Log(report.Message, report.Ok ? 'info' : 'warn');
46
+ }
47
+ }
48
+ throw error;
49
+ }
50
+ if (!result.success && !this.failedPushLeftWrites(result, undefined)) {
51
+ return result; // rolled back cleanly: nothing in the database changed, so nothing is stale
52
+ }
53
+ if (result.success && this.successfulPushWroteNothing(result)) {
54
+ return result; // cancelled, or a no-op: nothing in the database changed
55
+ }
56
+ const report = await this.clearSharedCache(result.success ? 'mj sync push' : 'mj sync push (failed)');
57
+ return AppendSharedCacheClear(result, report, this.Host);
58
+ }
59
+ /**
60
+ * Whether a failed push left rows in the database. False only when the outcome positively says
61
+ * the push rolled back and committed nothing; anything unreadable counts as "it may have".
62
+ */
63
+ failedPushLeftWrites(result, error) {
64
+ if (error instanceof PushAbortedError) {
65
+ return !error.rolledBack || error.committedWrites.length > 0;
66
+ }
67
+ if (error) {
68
+ return true; // an error the push did not describe
69
+ }
70
+ const data = result?.data;
71
+ if (typeof data?.rolledBack !== 'boolean') {
72
+ return true;
73
+ }
74
+ return !data.rolledBack || (data.committedOutsideTransaction ?? 0) > 0;
75
+ }
76
+ /**
77
+ * Whether a successful push positively reports that it wrote nothing: it was cancelled before
78
+ * writing, or it created, updated and deleted no rows. A result without those counts counts as
79
+ * "it may have written".
80
+ */
81
+ successfulPushWroteNothing(result) {
82
+ const data = result.data;
83
+ if (data?.cancelled === true) {
84
+ return true;
85
+ }
86
+ if (typeof data?.created !== 'number' || typeof data.updated !== 'number' || typeof data.deleted !== 'number') {
87
+ return false;
88
+ }
89
+ return data.created + data.updated + data.deleted === 0;
90
+ }
91
+ /** Clears the shared cache unless this was a dry run (which writes nothing). */
92
+ async clearSharedCache(commandName) {
93
+ const flags = this.GetFlags();
94
+ return flags['dry-run'] ? null : ClearSharedCacheAfterWrite(commandName, flags['skip-cache-clear']);
95
+ }
96
+ }
9
97
  //# sourceMappingURL=push.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/commands/sync/push.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"push.js","sourceRoot":"","sources":["../../../src/commands/sync/push.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKrH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,cAAc;aAC3C,UAAK,GAAG;QACb,GAAG,cAAc,CAAC,KAAK;QACvB,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC;YAChC,WAAW,EAAE,wEAAwE,oBAAoB,IAAI;SAC9G,CAAC;KACH,CAAC;aAEK,UAAK,GAAgB;QAC1B,GA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AC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,WAAW,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACtG,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * CLI command: `mj user clone`.
4
+ *
5
+ * Creates a new user as a copy of an existing one through the `MJ: Users` clone configuration. From a
6
+ * template user (IsTemplate) the default `template` preset copies everything the template was set up
7
+ * with, dashboards and conversations included; from an ordinary user, choose one of the other presets.
8
+ * Runs as the system user, so it needs no sign-in; it is meant for administrators and install scripts
9
+ * (an app's post-install hook pre-provisions the person who will sign in).
10
+ */
11
+ export default class UserClone extends Command {
12
+ static description: string;
13
+ static examples: string[];
14
+ static flags: {
15
+ from: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
16
+ email: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
+ first: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
18
+ last: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
19
+ preset: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
20
+ inactive: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
21
+ 'dry-run': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
22
+ };
23
+ run(): Promise<void>;
24
+ /** The user with this email, if any. */
25
+ private findUser;
26
+ }
27
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/commands/user/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAc7C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;IAC5C,MAAM,CAAC,WAAW,SAAqE;IAEvF,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,KAAK;;;;;;;;MAWV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA4D1B,wCAAwC;YAC1B,QAAQ;CAavB"}
@@ -0,0 +1,106 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import chalk from 'chalk';
3
+ import { CompositeKey, RunView } from '@memberjunction/core';
4
+ import { RecordCloneEngine } from '@memberjunction/record-cloning';
5
+ import { BuildContextUser, EnsureProviderInitialized } from '../../utils/open-app-context.js';
6
+ /**
7
+ * CLI command: `mj user clone`.
8
+ *
9
+ * Creates a new user as a copy of an existing one through the `MJ: Users` clone configuration. From a
10
+ * template user (IsTemplate) the default `template` preset copies everything the template was set up
11
+ * with, dashboards and conversations included; from an ordinary user, choose one of the other presets.
12
+ * Runs as the system user, so it needs no sign-in; it is meant for administrators and install scripts
13
+ * (an app's post-install hook pre-provisions the person who will sign in).
14
+ */
15
+ export default class UserClone extends Command {
16
+ static { this.description = 'Create a user as a copy of another (a template user by default)'; }
17
+ static { this.examples = [
18
+ '<%= config.bin %> user clone --from demo.user@example.org --email jane@example.com --first Jane --last Doe',
19
+ '<%= config.bin %> user clone --from alice@example.com --email bob@example.com --first Bob --last Lee --preset with-settings',
20
+ '<%= config.bin %> user clone --from demo.user@example.org --email jane@example.com --first Jane --last Doe --dry-run',
21
+ ]; }
22
+ static { this.flags = {
23
+ from: Flags.string({ description: 'Email of the user to copy', required: true }),
24
+ email: Flags.string({ description: 'Email of the new user (the identity they sign in with)', required: true }),
25
+ first: Flags.string({ description: 'First name of the new user', required: true }),
26
+ last: Flags.string({ description: 'Last name of the new user', required: true }),
27
+ preset: Flags.string({
28
+ description: "MJ: Users clone preset: 'template' (template users only), 'with-views', 'with-settings', or none for the base copy",
29
+ default: 'template',
30
+ }),
31
+ inactive: Flags.boolean({ description: 'Leave the new user inactive for review instead of activating it', default: false }),
32
+ 'dry-run': Flags.boolean({ description: 'Show what would be copied without creating anything', default: false }),
33
+ }; }
34
+ async run() {
35
+ const { flags } = await this.parse(UserClone);
36
+ try {
37
+ const provider = await EnsureProviderInitialized();
38
+ const contextUser = await BuildContextUser();
39
+ const source = await this.findUser(flags.from, contextUser);
40
+ if (!source)
41
+ this.error(`No user has the email ${flags.from}.`);
42
+ if (await this.findUser(flags.email, contextUser)) {
43
+ this.error(`A user with the email ${flags.email} already exists. Cloning creates a new user; choose another email.`);
44
+ }
45
+ const preset = flags.preset === 'none' ? undefined : flags.preset;
46
+ if (preset === 'template' && !source.IsTemplate) {
47
+ this.error(`${flags.from} is not a template user. Mark it IsTemplate, or pass --preset with-views, with-settings or none.`);
48
+ }
49
+ const result = await new RecordCloneEngine(provider).Clone({
50
+ EntityName: 'MJ: Users',
51
+ SourceRecordKey: CompositeKey.FromID(source.ID),
52
+ Preset: preset,
53
+ PromptedValues: { Email: flags.email, FirstName: flags.first, LastName: flags.last },
54
+ Options: { DryRun: flags['dry-run'], Reason: `mj user clone from ${flags.from}` },
55
+ }, contextUser);
56
+ for (const w of result.Warnings.filter((w) => w.Severity !== 'Info')) {
57
+ this.log(chalk[w.Severity === 'Error' ? 'red' : 'yellow'](` ${w.Severity}: ${w.Message}`));
58
+ }
59
+ if (!result.Success) {
60
+ this.error(`Clone ${result.ResultCode === 'BLOCKED' ? 'was blocked' : 'failed'}${result.ErrorMessage ? `: ${result.ErrorMessage}` : ''}.`);
61
+ }
62
+ // A dry run reports the plan's counts; a real run, the rows it actually created.
63
+ const byEntity = new Map();
64
+ if (flags['dry-run']) {
65
+ for (const [entity, counts] of Object.entries(result.Counts?.ByEntity ?? {}))
66
+ byEntity.set(entity, counts.Create);
67
+ }
68
+ else {
69
+ for (const row of result.Created ?? [])
70
+ byEntity.set(row.EntityName, (byEntity.get(row.EntityName) ?? 0) + 1);
71
+ }
72
+ this.log(chalk.bold(flags['dry-run'] ? '\nWould copy:' : '\nCopied:'));
73
+ for (const [entity, count] of byEntity) {
74
+ if (count > 0)
75
+ this.log(` ${String(count).padStart(5)} ${entity}`);
76
+ }
77
+ if (flags['dry-run'])
78
+ return;
79
+ const newID = result.Roots?.[0]?.TargetKey.KeyValuePairs.find((kvp) => kvp.FieldName === 'ID')?.Value;
80
+ if (!flags.inactive && newID) {
81
+ const user = await provider.GetEntityObject('MJ: Users', contextUser);
82
+ if (!(await user.Load(String(newID))))
83
+ this.error(`The new user ${flags.email} was created but could not be loaded to activate it.`);
84
+ user.IsActive = true;
85
+ if (!(await user.Save()))
86
+ this.error(`The new user ${flags.email} was created but not activated: ${user.LatestResult?.CompleteMessage ?? 'unknown error'}`);
87
+ }
88
+ this.log(chalk.green(`\n✓ Created ${flags.email} from ${flags.from}${flags.inactive ? ' (inactive: activate it after review)' : ''}.`));
89
+ }
90
+ catch (error) {
91
+ this.error(error instanceof Error ? error.message : String(error));
92
+ }
93
+ }
94
+ /** The user with this email, if any. */
95
+ async findUser(email, contextUser) {
96
+ const result = await new RunView().RunView({
97
+ EntityName: 'MJ: Users',
98
+ ExtraFilter: `Email = '${email.replace(/'/g, "''")}'`,
99
+ Fields: ['ID', 'Email', 'IsTemplate'],
100
+ ResultType: 'simple',
101
+ MaxRows: 1,
102
+ }, contextUser);
103
+ return result.Success ? result.Results[0] : undefined;
104
+ }
105
+ }
106
+ //# sourceMappingURL=clone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/commands/user/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAA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AC,uCAAuC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC1I,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED,wCAAwC;IAChC,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,WAAqB;QACzD,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,OAAO,CACxC;YACE,UAAU,EAAE,WAAW;YACvB,WAAW,EAAE,YAAY,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;YACrD,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC;YACrC,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,CAAC;SACX,EACD,WAAW,CACZ,CAAC;QACF,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prerun.d.ts","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AA6BnE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,QAAQ,CAqFxB,CAAC;AA0BF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"prerun.d.ts","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAOnC;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;AA6BnE,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,QAAQ,CA6FxB,CAAC;AA0BF,eAAe,IAAI,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import figlet from 'figlet';
2
2
  import { INTERACTIVE_ENV, ResolveOutputFormat, ShouldSuppressChrome } from '@memberjunction/cli-core';
3
3
  import { LIGHT_COMMANDS } from '../light-commands.js';
4
+ import chalk from 'chalk';
5
+ import { KeepAwakeForCommand, SleepNoticeForCommand } from '../lib/keep-awake.js';
4
6
  /**
5
7
  * Mirror of `DYNAMIC_PACKAGES_MODE_ENV_VAR` from @memberjunction/dynamic-packages, inlined so
6
8
  * LIGHT commands (version, help, migrate, …) do not pay for that package — and its cosmiconfig
@@ -35,6 +37,8 @@ function readFormatArg(argv) {
35
37
  }
36
38
  const hook = async function (options) {
37
39
  const argv = options.argv ?? [];
40
+ // Long database commands must not be interrupted by the machine sleeping — see keep-awake.ts.
41
+ const keptAwake = KeepAwakeForCommand(options.Command.id ?? '');
38
42
  // `--interactive` / `--no-interactive` override the terminal detection that decides
39
43
  // whether a command may prompt. Like `--no-banner` they must work on every command,
40
44
  // including the ~80 that don't declare them, so they are consumed here and forwarded
@@ -106,6 +110,11 @@ const hook = async function (options) {
106
110
  if (options.Command.id !== 'version' && !isUsageCommand) {
107
111
  options.context.log(options.config.userAgent + '\n');
108
112
  }
113
+ // Said once, up front, while the user is still watching. stderr, so it never mixes into output.
114
+ const sleepNotice = SleepNoticeForCommand(options.Command.id ?? '', keptAwake);
115
+ if (sleepNotice) {
116
+ process.stderr.write(chalk.yellow(`\u26a0 ${sleepNotice}\n\n`));
117
+ }
109
118
  await maybeLoadBootstrap(options, verbose);
110
119
  };
111
120
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EA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kB,CAAC,OAAqC,EAAE,OAAO,GAAG,KAAK;IACtF,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,sFAAsF;QACtF,2DAA2D;QAC3D,MAAM,MAAM,CAAC,8DAA8D,CAAC,CAAC;QAC7E,MAAM,EAAE,6BAA6B,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;QACrF,MAAM,6BAA6B,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"domain-profiles.d.ts","sourceRoot":"","sources":["../../src/lib/domain-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAiGnE,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE9D;AAED,gDAAgD;AAChD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE9D"}
1
+ {"version":3,"file":"domain-profiles.d.ts","sourceRoot":"","sources":["../../src/lib/domain-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAqGnE,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE9D;AAED,gDAAgD;AAChD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAE9D"}
@@ -58,6 +58,10 @@ export const DOMAIN_PROFILES = {
58
58
  Summary: 'Bundle interactive component source for distribution.',
59
59
  Runtime: { class: 'moderate', typicalSeconds: 20 },
60
60
  },
61
+ cache: {
62
+ Summary: 'Inspect and clear the shared (Redis) server cache.',
63
+ Runtime: { class: 'fast', note: 'one SCAN per category; scales with the Redis keyspace' },
64
+ },
61
65
  clean: {
62
66
  Summary: 'Remove build artifacts and generated output.',
63
67
  Runtime: { class: 'fast' },
@@ -1 +1 @@
1
- {"version":3,"file":"domain-profiles.js","sourceRoot":"","sources":["../../src/lib/domain-profiles.ts"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,6CAA6C,EAAE;CACpF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAA4C;IACtE,OAAO,EAAE;QACP,OAAO,EAAE,uEAAuE;QAChF,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,IAAI,EAAE,+DA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U,EAAE,cAAc,EAAE,EAAE,EAAE;KACnD;IACD,SAAS,EAAE;QACT,OAAO,EAAE,yDAAyD;QAClE,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,mDAAmD,EAAE;KAC9G;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,kDAAkD;QAC3D,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,iEAAiE,EAAE;KACxG;IACD,eAAe,EAAE;QACf,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE;KACnD;IACD,MAAM,EAAE;QACN,OAAO,EAAE,8DAA8D;QACvE,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,4CAA4C,EAAE;KACvG;IACD,KAAK,EAAE;QACL,OAAO,EAAE,uEAAuE;QAChF,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;KAC3B;CACF,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,sBAAsB,CAAC;AAC3D,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Keeps the machine awake while a long-running database command runs.
3
+ *
4
+ * `mj install` and `mj app install` run for many minutes, and a laptop left alone in that time
5
+ * idles into sleep. Sleep pauses everything at once — the CLI, the local database (often a Docker
6
+ * VM), and every socket between them — and on wake each in-flight request's timer fires together:
7
+ * a migration batch that was doing nothing wrong reports `Timeout: Request failed to complete in
8
+ * 300000ms`, a GitHub download reports `read ECONNRESET`, and the app being installed is rolled
9
+ * back. Clean end-user installs of MJ + a multi-app Open App chain failed this way repeatedly.
10
+ *
11
+ * On macOS this holds a `caffeinate` assertion tied to the CLI's own pid, so it ends the moment
12
+ * the command does — no cleanup, nothing left behind. Elsewhere it is a no-op. Set
13
+ * {@link KEEP_AWAKE_OPT_OUT_ENV_VAR} to opt out.
14
+ *
15
+ * Either way, {@link SleepNoticeForCommand} tells the user at the start: no assertion survives
16
+ * a closed lid, and on Windows and Linux nothing holds the machine awake at all.
17
+ */
18
+ import { spawn } from 'node:child_process';
19
+ /** Set to `1` (or `true`) to let the machine sleep during long commands. */
20
+ export declare const KEEP_AWAKE_OPT_OUT_ENV_VAR = "MJ_ALLOW_SLEEP";
21
+ /** Commands long and database-bound enough that sleeping mid-run breaks them. */
22
+ export declare const KEEP_AWAKE_COMMANDS: ReadonlySet<string>;
23
+ /** The pieces of the environment this depends on, injectable for tests. */
24
+ export interface KeepAwakeEnvironment {
25
+ Platform: NodeJS.Platform;
26
+ Env: NodeJS.ProcessEnv;
27
+ Pid: number;
28
+ Spawn: typeof spawn;
29
+ }
30
+ /**
31
+ * Starts the keep-awake assertion for `commandId` when it applies.
32
+ *
33
+ * @returns true when an assertion was started. Never throws: failing to keep the machine awake
34
+ * must not fail the command it was meant to protect.
35
+ */
36
+ export declare function KeepAwakeForCommand(commandId: string, environment?: KeepAwakeEnvironment): boolean;
37
+ /**
38
+ * The one-line warning to show when a long database command starts, or `undefined` for commands
39
+ * that are not long enough to need it.
40
+ *
41
+ * @param commandId - The oclif command id.
42
+ * @param keptAwake - Whether {@link KeepAwakeForCommand} started an assertion for this run.
43
+ */
44
+ export declare function SleepNoticeForCommand(commandId: string, keptAwake: boolean): string | undefined;
45
+ //# sourceMappingURL=keep-awake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keep-awake.d.ts","sourceRoot":"","sources":["../../src/lib/keep-awake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAE3D,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAKlD,CAAC;AAEH,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB;AASD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,oBAA0C,GAAG,OAAO,CAavH;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK/F"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Keeps the machine awake while a long-running database command runs.
3
+ *
4
+ * `mj install` and `mj app install` run for many minutes, and a laptop left alone in that time
5
+ * idles into sleep. Sleep pauses everything at once — the CLI, the local database (often a Docker
6
+ * VM), and every socket between them — and on wake each in-flight request's timer fires together:
7
+ * a migration batch that was doing nothing wrong reports `Timeout: Request failed to complete in
8
+ * 300000ms`, a GitHub download reports `read ECONNRESET`, and the app being installed is rolled
9
+ * back. Clean end-user installs of MJ + a multi-app Open App chain failed this way repeatedly.
10
+ *
11
+ * On macOS this holds a `caffeinate` assertion tied to the CLI's own pid, so it ends the moment
12
+ * the command does — no cleanup, nothing left behind. Elsewhere it is a no-op. Set
13
+ * {@link KEEP_AWAKE_OPT_OUT_ENV_VAR} to opt out.
14
+ *
15
+ * Either way, {@link SleepNoticeForCommand} tells the user at the start: no assertion survives
16
+ * a closed lid, and on Windows and Linux nothing holds the machine awake at all.
17
+ */
18
+ import { spawn } from 'node:child_process';
19
+ /** Set to `1` (or `true`) to let the machine sleep during long commands. */
20
+ export const KEEP_AWAKE_OPT_OUT_ENV_VAR = 'MJ_ALLOW_SLEEP';
21
+ /** Commands long and database-bound enough that sleeping mid-run breaks them. */
22
+ export const KEEP_AWAKE_COMMANDS = new Set([
23
+ 'install',
24
+ 'app:install',
25
+ 'app:upgrade',
26
+ 'migrate',
27
+ ]);
28
+ const DEFAULT_ENVIRONMENT = {
29
+ Platform: process.platform,
30
+ Env: process.env,
31
+ Pid: process.pid,
32
+ Spawn: spawn,
33
+ };
34
+ /**
35
+ * Starts the keep-awake assertion for `commandId` when it applies.
36
+ *
37
+ * @returns true when an assertion was started. Never throws: failing to keep the machine awake
38
+ * must not fail the command it was meant to protect.
39
+ */
40
+ export function KeepAwakeForCommand(commandId, environment = DEFAULT_ENVIRONMENT) {
41
+ if (!KEEP_AWAKE_COMMANDS.has(commandId) || environment.Platform !== 'darwin')
42
+ return false;
43
+ const optOut = (environment.Env[KEEP_AWAKE_OPT_OUT_ENV_VAR] ?? '').trim().toLowerCase();
44
+ if (optOut === '1' || optOut === 'true')
45
+ return false;
46
+ try {
47
+ // -i: no idle sleep. -s: no system sleep while on AC power. -w: exit when the CLI exits.
48
+ const child = environment.Spawn('caffeinate', ['-i', '-s', '-w', String(environment.Pid)], { stdio: 'ignore' });
49
+ child.on('error', () => undefined); // caffeinate missing or refused — carry on without it
50
+ child.unref(); // never keep the CLI alive for its sake
51
+ return true;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ }
57
+ /**
58
+ * The one-line warning to show when a long database command starts, or `undefined` for commands
59
+ * that are not long enough to need it.
60
+ *
61
+ * @param commandId - The oclif command id.
62
+ * @param keptAwake - Whether {@link KeepAwakeForCommand} started an assertion for this run.
63
+ */
64
+ export function SleepNoticeForCommand(commandId, keptAwake) {
65
+ if (!KEEP_AWAKE_COMMANDS.has(commandId))
66
+ return undefined;
67
+ return keptAwake
68
+ ? 'This can take 15 minutes or more. MJ is keeping this Mac awake until it finishes, but closing the lid will still put it to sleep and can make the command fail partway.'
69
+ : "This can take 15 minutes or more. Don't let this machine sleep until it finishes: sleep pauses the database connection and can make the command fail partway.";
70
+ }
71
+ //# sourceMappingURL=keep-awake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keep-awake.js","sourceRoot":"","sources":["../../src/lib/keep-awake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAE3D,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC;IAC9D,SAAS;IACT,aAAa;IACb,aAAa;IACb,SAAS;CACV,CAAC,CAAC;AAUH,MAAM,mBAAmB,GAAyB;IAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,KAAK,EAAE,KAAK;CACb,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,cAAoC,mBAAmB;IAC5G,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3F,MAAM,MAAM,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxF,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,CAAC;QACH,yFAAyF;QACzF,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,sDAAsD;QAC1F,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB,EAAE,SAAkB;IACzE,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1D,OAAO,SAAS;QACd,CAAC,CAAC,yKAAyK;QAC3K,CAAC,CAAC,+JAA+J,CAAC;AACtK,CAAC"}
@@ -0,0 +1,84 @@
1
+ import type { RedisProviderConfig, SharedCacheCategoryClear } from '@memberjunction/redis-provider';
2
+ /** Setting this to `1`/`true` disables the automatic clear (the explicit command still works). */
3
+ export declare const SKIP_CACHE_CLEAR_ENV = "MJ_SKIP_SHARED_CACHE_CLEAR";
4
+ /** What the user asked to clear, mapped onto the names the cache actually uses. */
5
+ export type ResolvedCacheCategories = {
6
+ /** Canonical category names, safe to hand to the store. */
7
+ Categories: string[];
8
+ /** Anything that matched no known category, in the spelling the user gave. */
9
+ Unknown: string[];
10
+ };
11
+ /**
12
+ * Maps requested category names onto their canonical spelling.
13
+ *
14
+ * Names are accepted case-insensitively because nobody should have to remember that it is
15
+ * `RunViewCache` and not `runviewcache`. But Redis keys ARE case-sensitive, so accepting a
16
+ * spelling and then using it verbatim scanned `{prefix}:runviewcache:*`, matched nothing, and
17
+ * reported a successful clear of 0 keys — the operator is told the fleet will reload and it never
18
+ * does. Accept the spelling, then hand the store the canonical name.
19
+ */
20
+ export declare function ResolveCacheCategories(requested: readonly string[] | undefined): ResolvedCacheCategories;
21
+ /** What a `mj migrate` run did, as far as the command can tell. */
22
+ export type MigrationOutcome = {
23
+ /** The migration engine threw instead of returning a result. */
24
+ Threw: boolean;
25
+ /** The run reported success. */
26
+ Succeeded: boolean;
27
+ /** Migrations the run reports as applied. Meaningful only on success. */
28
+ MigrationsApplied: number;
29
+ /** At least one migration began executing — the only reliable "the database may have changed". */
30
+ StartedApplying: boolean;
31
+ };
32
+ /**
33
+ * Whether a migration run may have changed the database, and so whether the fleet's cache is stale.
34
+ *
35
+ * On success the count is authoritative: a run that found nothing pending must NOT make every server
36
+ * drop its cache and reload every engine for nothing.
37
+ *
38
+ * On a failure — including one that threw rather than returning — the count is not trustworthy and
39
+ * neither is the detail list, which can be empty precisely because the run died before assembling
40
+ * it. What IS known is whether a migration started executing. DDL is not transactional across
41
+ * batches on SQL Server, so a migration that began and failed can still have committed statements;
42
+ * a run that never started one cannot have. That makes "did anything start" the honest gate: a bad
43
+ * connection string or a config error leaves the fleet alone, and anything that touched the database
44
+ * clears.
45
+ */
46
+ export declare function MigrationChangedDatabase(outcome: MigrationOutcome): boolean;
47
+ /** The category names a clear can be asked for, for error messages and help text. */
48
+ export declare function KnownCacheCategories(): string[];
49
+ /** The shared cache the environment points at, or null when none is configured. */
50
+ export interface SharedCacheTarget {
51
+ Connection: RedisProviderConfig;
52
+ /** Host, port and key prefix — never credentials. For messages. */
53
+ Description: string;
54
+ }
55
+ /** What an automatic clear did, for the command's log and result. */
56
+ export interface SharedCacheClearReport {
57
+ Ok: boolean;
58
+ Message: string;
59
+ Categories: SharedCacheCategoryClear[];
60
+ }
61
+ /** Resolves the shared cache from `REDIS_URL` / `REDIS_KEY_PREFIX`, the variables MJAPI reads. */
62
+ export declare function ResolveSharedCacheTarget(env?: NodeJS.ProcessEnv): SharedCacheTarget | null;
63
+ /** `host:port/db` of a Redis URL, without user or password. */
64
+ export declare function DescribeRedisUrl(url: string): string;
65
+ /** True when the automatic clear has been switched off by flag or environment. */
66
+ export declare function IsAutomaticClearDisabled(skipFlag: boolean | undefined, env?: NodeJS.ProcessEnv): boolean;
67
+ /**
68
+ * Clears the shared cache after `commandName` changed the database. Returns null when there is
69
+ * nothing to do (no `REDIS_URL`, or disabled).
70
+ */
71
+ export declare function ClearSharedCacheAfterWrite(commandName: string, skipFlag?: boolean): Promise<SharedCacheClearReport | null>;
72
+ /** The subset of the CLI runtime host a clear report is logged through. */
73
+ export interface SharedCacheReportSink {
74
+ Log(message: string, level?: 'info' | 'warn' | 'error'): void;
75
+ }
76
+ /**
77
+ * Logs a clear report and folds it into a plugin command's result: `data.sharedCacheClear`
78
+ * always, and a warning when the clear failed. Returns the result unchanged when there is no report.
79
+ */
80
+ export declare function AppendSharedCacheClear<R extends {
81
+ data?: Record<string, unknown>;
82
+ warnings?: string[];
83
+ }>(result: R, report: SharedCacheClearReport | null, sink: SharedCacheReportSink): R;
84
+ //# sourceMappingURL=shared-cache.d.ts.map