@memberjunction/cli 6.3.0-edge.1 → 6.3.0-edge.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1047 -359
- package/dist/baseline/connection.d.ts.map +1 -1
- package/dist/baseline/connection.js +12 -1
- package/dist/baseline/connection.js.map +1 -1
- package/dist/commands/agent/usage.d.ts +7 -0
- package/dist/commands/agent/usage.d.ts.map +1 -0
- package/dist/commands/agent/usage.js +10 -0
- package/dist/commands/agent/usage.js.map +1 -0
- package/dist/commands/codegen/manifest.d.ts +40 -0
- package/dist/commands/codegen/manifest.d.ts.map +1 -1
- package/dist/commands/codegen/manifest.js +124 -3
- package/dist/commands/codegen/manifest.js.map +1 -1
- package/dist/commands/diag/usage.d.ts +7 -0
- package/dist/commands/diag/usage.d.ts.map +1 -0
- package/dist/commands/diag/usage.js +10 -0
- package/dist/commands/diag/usage.js.map +1 -0
- package/dist/commands/doctor/index.d.ts +6 -0
- package/dist/commands/doctor/index.d.ts.map +1 -1
- package/dist/commands/doctor/index.js +42 -0
- package/dist/commands/doctor/index.js.map +1 -1
- package/dist/commands/explorer/postbuild.d.ts +14 -0
- package/dist/commands/explorer/postbuild.d.ts.map +1 -0
- package/dist/commands/explorer/postbuild.js +49 -0
- package/dist/commands/explorer/postbuild.js.map +1 -0
- package/dist/commands/explorer/usage.d.ts +7 -0
- package/dist/commands/explorer/usage.d.ts.map +1 -0
- package/dist/commands/explorer/usage.js +10 -0
- package/dist/commands/explorer/usage.js.map +1 -0
- package/dist/commands/harness/account/add.d.ts +22 -0
- package/dist/commands/harness/account/add.d.ts.map +1 -0
- package/dist/commands/harness/account/add.js +100 -0
- package/dist/commands/harness/account/add.js.map +1 -0
- package/dist/commands/harness/account/clear-cooldown.d.ts +13 -0
- package/dist/commands/harness/account/clear-cooldown.d.ts.map +1 -0
- package/dist/commands/harness/account/clear-cooldown.js +32 -0
- package/dist/commands/harness/account/clear-cooldown.js.map +1 -0
- package/dist/commands/harness/account/disable.d.ts +13 -0
- package/dist/commands/harness/account/disable.d.ts.map +1 -0
- package/dist/commands/harness/account/disable.js +34 -0
- package/dist/commands/harness/account/disable.js.map +1 -0
- package/dist/commands/harness/account/enable.d.ts +13 -0
- package/dist/commands/harness/account/enable.d.ts.map +1 -0
- package/dist/commands/harness/account/enable.js +34 -0
- package/dist/commands/harness/account/enable.js.map +1 -0
- package/dist/commands/harness/account/index.d.ts +7 -0
- package/dist/commands/harness/account/index.d.ts.map +1 -0
- package/dist/commands/harness/account/index.js +23 -0
- package/dist/commands/harness/account/index.js.map +1 -0
- package/dist/commands/harness/account/list.d.ts +15 -0
- package/dist/commands/harness/account/list.d.ts.map +1 -0
- package/dist/commands/harness/account/list.js +58 -0
- package/dist/commands/harness/account/list.js.map +1 -0
- package/dist/commands/harness/account/login.d.ts +16 -0
- package/dist/commands/harness/account/login.d.ts.map +1 -0
- package/dist/commands/harness/account/login.js +50 -0
- package/dist/commands/harness/account/login.js.map +1 -0
- package/dist/commands/harness/account/remove.d.ts +14 -0
- package/dist/commands/harness/account/remove.d.ts.map +1 -0
- package/dist/commands/harness/account/remove.js +43 -0
- package/dist/commands/harness/account/remove.js.map +1 -0
- package/dist/commands/harness/account/set-strategy.d.ts +13 -0
- package/dist/commands/harness/account/set-strategy.d.ts.map +1 -0
- package/dist/commands/harness/account/set-strategy.js +38 -0
- package/dist/commands/harness/account/set-strategy.js.map +1 -0
- package/dist/commands/harness/index.d.ts +7 -0
- package/dist/commands/harness/index.d.ts.map +1 -0
- package/dist/commands/harness/index.js +22 -0
- package/dist/commands/harness/index.js.map +1 -0
- package/dist/commands/harness/usage.d.ts +7 -0
- package/dist/commands/harness/usage.d.ts.map +1 -0
- package/dist/commands/harness/usage.js +10 -0
- package/dist/commands/harness/usage.js.map +1 -0
- package/dist/commands/migrate/convert.d.ts +25 -1
- package/dist/commands/migrate/convert.d.ts.map +1 -1
- package/dist/commands/migrate/convert.js +156 -38
- package/dist/commands/migrate/convert.js.map +1 -1
- package/dist/commands/migrate/index.d.ts +8 -0
- package/dist/commands/migrate/index.d.ts.map +1 -1
- package/dist/commands/migrate/index.js +41 -2
- package/dist/commands/migrate/index.js.map +1 -1
- package/dist/commands/migrate/rebake.d.ts +13 -0
- package/dist/commands/migrate/rebake.d.ts.map +1 -1
- package/dist/commands/migrate/rebake.js +45 -6
- package/dist/commands/migrate/rebake.js.map +1 -1
- package/dist/commands/queue/export-topology.d.ts +2 -0
- package/dist/commands/queue/export-topology.d.ts.map +1 -1
- package/dist/commands/queue/export-topology.js +3 -1
- package/dist/commands/queue/export-topology.js.map +1 -1
- package/dist/commands/queue/import-bindings.d.ts +2 -0
- package/dist/commands/queue/import-bindings.d.ts.map +1 -1
- package/dist/commands/queue/import-bindings.js +3 -1
- package/dist/commands/queue/import-bindings.js.map +1 -1
- package/dist/commands/queue/index.js +1 -1
- package/dist/commands/queue/index.js.map +1 -1
- package/dist/commands/queue/sweep.d.ts +4 -6
- package/dist/commands/queue/sweep.d.ts.map +1 -1
- package/dist/commands/queue/sweep.js +15 -23
- package/dist/commands/queue/sweep.js.map +1 -1
- package/dist/commands/queue/validate-bindings.d.ts +2 -0
- package/dist/commands/queue/validate-bindings.d.ts.map +1 -1
- package/dist/commands/queue/validate-bindings.js +3 -1
- package/dist/commands/queue/validate-bindings.js.map +1 -1
- package/dist/commands/queue/work.d.ts +2 -19
- package/dist/commands/queue/work.d.ts.map +1 -1
- package/dist/commands/queue/work.js +9 -29
- package/dist/commands/queue/work.js.map +1 -1
- package/dist/commands/rubric/usage.d.ts +7 -0
- package/dist/commands/rubric/usage.d.ts.map +1 -0
- package/dist/commands/rubric/usage.js +10 -0
- package/dist/commands/rubric/usage.js.map +1 -0
- package/dist/commands/test/regression/index.d.ts.map +1 -1
- package/dist/commands/test/regression/index.js +2 -0
- package/dist/commands/test/regression/index.js.map +1 -1
- package/dist/commands/test/regression/new.d.ts +21 -0
- package/dist/commands/test/regression/new.d.ts.map +1 -0
- package/dist/commands/test/regression/new.js +82 -0
- package/dist/commands/test/regression/new.js.map +1 -0
- package/dist/commands/test/regression/up.d.ts +1 -0
- package/dist/commands/test/regression/up.d.ts.map +1 -1
- package/dist/commands/test/regression/up.js +17 -0
- package/dist/commands/test/regression/up.js.map +1 -1
- package/dist/commands/test/scripts.d.ts +6 -4
- package/dist/commands/test/scripts.d.ts.map +1 -1
- package/dist/commands/test/scripts.js +14 -0
- package/dist/commands/test/scripts.js.map +1 -1
- package/dist/commands/test/suite.d.ts +1 -0
- package/dist/commands/test/suite.d.ts.map +1 -1
- package/dist/commands/test/suite.js +6 -0
- package/dist/commands/test/suite.js.map +1 -1
- package/dist/commands/usage.js +2 -1
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/user/usage.d.ts +7 -0
- package/dist/commands/user/usage.d.ts.map +1 -0
- package/dist/commands/user/usage.js +10 -0
- package/dist/commands/user/usage.js.map +1 -0
- package/dist/config.d.ts +119 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +43 -1
- package/dist/config.js.map +1 -1
- package/dist/init-templates/citizen-builder/.env.example +1 -0
- package/dist/init-templates/citizen-builder/docker-compose.yml +2 -0
- package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +2 -1
- package/dist/lib/db-preflight.d.ts.map +1 -1
- package/dist/lib/db-preflight.js +22 -0
- package/dist/lib/db-preflight.js.map +1 -1
- package/dist/lib/derived-usage.d.ts +8 -0
- package/dist/lib/derived-usage.d.ts.map +1 -1
- package/dist/lib/derived-usage.js +30 -20
- package/dist/lib/derived-usage.js.map +1 -1
- package/dist/lib/domain-profiles.d.ts.map +1 -1
- package/dist/lib/domain-profiles.js +24 -0
- package/dist/lib/domain-profiles.js.map +1 -1
- package/dist/lib/domain-usage-command.js +2 -1
- package/dist/lib/domain-usage-command.js.map +1 -1
- package/dist/lib/explorer-postbuild/public-page-html.d.ts +48 -0
- package/dist/lib/explorer-postbuild/public-page-html.d.ts.map +1 -0
- package/dist/lib/explorer-postbuild/public-page-html.js +284 -0
- package/dist/lib/explorer-postbuild/public-page-html.js.map +1 -0
- package/dist/lib/explorer-postbuild/service-worker-check.d.ts +13 -0
- package/dist/lib/explorer-postbuild/service-worker-check.d.ts.map +1 -0
- package/dist/lib/explorer-postbuild/service-worker-check.js +41 -0
- package/dist/lib/explorer-postbuild/service-worker-check.js.map +1 -0
- package/dist/lib/harness-account.d.ts +34 -0
- package/dist/lib/harness-account.d.ts.map +1 -0
- package/dist/lib/harness-account.js +105 -0
- package/dist/lib/harness-account.js.map +1 -0
- package/dist/lib/pg-preflight/checks.d.ts +28 -0
- package/dist/lib/pg-preflight/checks.d.ts.map +1 -0
- package/dist/lib/pg-preflight/checks.js +94 -0
- package/dist/lib/pg-preflight/checks.js.map +1 -0
- package/dist/lib/pg-preflight/extension-check.d.ts +28 -0
- package/dist/lib/pg-preflight/extension-check.d.ts.map +1 -0
- package/dist/lib/pg-preflight/extension-check.js +86 -0
- package/dist/lib/pg-preflight/extension-check.js.map +1 -0
- package/dist/lib/pg-preflight/extension-scan.d.ts +24 -0
- package/dist/lib/pg-preflight/extension-scan.d.ts.map +1 -0
- package/dist/lib/pg-preflight/extension-scan.js +58 -0
- package/dist/lib/pg-preflight/extension-scan.js.map +1 -0
- package/dist/lib/pg-preflight/pending-migrations.d.ts +28 -0
- package/dist/lib/pg-preflight/pending-migrations.d.ts.map +1 -0
- package/dist/lib/pg-preflight/pending-migrations.js +48 -0
- package/dist/lib/pg-preflight/pending-migrations.js.map +1 -0
- package/dist/lib/pg-preflight/preflight.d.ts +18 -0
- package/dist/lib/pg-preflight/preflight.d.ts.map +1 -0
- package/dist/lib/pg-preflight/preflight.js +43 -0
- package/dist/lib/pg-preflight/preflight.js.map +1 -0
- package/dist/lib/pg-preflight/remediation.d.ts +27 -0
- package/dist/lib/pg-preflight/remediation.d.ts.map +1 -0
- package/dist/lib/pg-preflight/remediation.js +82 -0
- package/dist/lib/pg-preflight/remediation.js.map +1 -0
- package/dist/lib/pg-preflight/render.d.ts +15 -0
- package/dist/lib/pg-preflight/render.d.ts.map +1 -0
- package/dist/lib/pg-preflight/render.js +48 -0
- package/dist/lib/pg-preflight/render.js.map +1 -0
- package/dist/lib/pg-preflight/run-for-config.d.ts +23 -0
- package/dist/lib/pg-preflight/run-for-config.d.ts.map +1 -0
- package/dist/lib/pg-preflight/run-for-config.js +45 -0
- package/dist/lib/pg-preflight/run-for-config.js.map +1 -0
- package/dist/lib/pg-preflight/types.d.ts +67 -0
- package/dist/lib/pg-preflight/types.d.ts.map +1 -0
- package/dist/lib/pg-preflight/types.js +8 -0
- package/dist/lib/pg-preflight/types.js.map +1 -0
- package/dist/lib/regression/test-scaffold.d.ts +52 -0
- package/dist/lib/regression/test-scaffold.d.ts.map +1 -0
- package/dist/lib/regression/test-scaffold.js +237 -0
- package/dist/lib/regression/test-scaffold.js.map +1 -0
- package/dist/lib/work-queue/queue-format.d.ts +4 -0
- package/dist/lib/work-queue/queue-format.d.ts.map +1 -1
- package/dist/lib/work-queue/queue-format.js +15 -0
- package/dist/lib/work-queue/queue-format.js.map +1 -1
- package/dist/lib/work-queue/queue-worker.d.ts +16 -1
- package/dist/lib/work-queue/queue-worker.d.ts.map +1 -1
- package/dist/lib/work-queue/queue-worker.js +18 -0
- package/dist/lib/work-queue/queue-worker.js.map +1 -1
- package/dist/light-commands.d.ts.map +1 -1
- package/dist/light-commands.js +34 -0
- package/dist/light-commands.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/open-app-context.d.ts +1 -0
- package/dist/utils/open-app-context.d.ts.map +1 -1
- package/dist/utils/open-app-context.js +7 -2
- package/dist/utils/open-app-context.js.map +1 -1
- package/oclif.manifest.json +2261 -1382
- package/package.json +31 -28
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { HARNESS_ACCOUNT_SELECTION_STRATEGIES, HarnessAccountPoolService, } from '@memberjunction/ai-agent-harness';
|
|
3
|
+
import { BuildPoolOptionsFromFlag, RequireHarnessStrategy } from '../../../lib/harness-account.js';
|
|
4
|
+
export default class HarnessAccountSetStrategy extends Command {
|
|
5
|
+
static { this.description = 'Set the default multi-account CLI pool balancing strategy'; }
|
|
6
|
+
static { this.examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %> least-in-flight',
|
|
8
|
+
'<%= config.bin %> <%= command.id %> round-robin',
|
|
9
|
+
'<%= config.bin %> <%= command.id %> weighted',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> priority-failover',
|
|
11
|
+
]; }
|
|
12
|
+
static { this.args = {
|
|
13
|
+
strategy: Args.string({
|
|
14
|
+
description: `Selection strategy (${HARNESS_ACCOUNT_SELECTION_STRATEGIES.join(', ')})`,
|
|
15
|
+
required: true,
|
|
16
|
+
}),
|
|
17
|
+
}; }
|
|
18
|
+
static { this.flags = {
|
|
19
|
+
'pool-dir': Flags.string({
|
|
20
|
+
description: 'Override account pool storage directory',
|
|
21
|
+
}),
|
|
22
|
+
}; }
|
|
23
|
+
async run() {
|
|
24
|
+
const { args, flags } = await this.parse(HarnessAccountSetStrategy);
|
|
25
|
+
const poolOpts = BuildPoolOptionsFromFlag(flags['pool-dir']);
|
|
26
|
+
let strategy;
|
|
27
|
+
try {
|
|
28
|
+
strategy = RequireHarnessStrategy(args.strategy);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
this.error(err instanceof Error ? err.message : String(err), { exit: 1 });
|
|
32
|
+
}
|
|
33
|
+
const service = HarnessAccountPoolService.Instance;
|
|
34
|
+
service.SetStrategy(strategy, poolOpts);
|
|
35
|
+
this.log(`Harness account pool default strategy set to '${strategy}'.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=set-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-strategy.js","sourceRoot":"","sources":["../../../../src/commands/harness/account/set-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,E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QAAQ,CAAC;QACnD,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,CAAC,iDAAiD,QAAQ,IAAI,CAAC,CAAC;IAC5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/harness/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAuF;IAEzG,MAAM,CAAC,QAAQ,WAIb;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Harness extends Command {
|
|
3
|
+
static { this.description = 'Manage external agent harness runtime settings and CLI subscription account pools'; }
|
|
4
|
+
static { this.examples = [
|
|
5
|
+
'<%= config.bin %> <%= command.id %> account list',
|
|
6
|
+
'<%= config.bin %> <%= command.id %> account add claude --label "Pro #2"',
|
|
7
|
+
'<%= config.bin %> <%= command.id %> account set-strategy least-in-flight',
|
|
8
|
+
]; }
|
|
9
|
+
async run() {
|
|
10
|
+
this.log('MemberJunction Agent Harness\n');
|
|
11
|
+
this.log(' mj harness account list - List enrolled and OS-default CLI accounts');
|
|
12
|
+
this.log(' mj harness account add <vendor> - Enroll an isolated CLI subscription slot');
|
|
13
|
+
this.log(' mj harness account login <slotId> - Re-authenticate an existing slot');
|
|
14
|
+
this.log(' mj harness account remove <slotId> - Remove an enrolled slot');
|
|
15
|
+
this.log(' mj harness account set-strategy <strategy> - Set default pool balancing strategy');
|
|
16
|
+
this.log(' mj harness account enable <slotId> - Enable a slot for balancing');
|
|
17
|
+
this.log(' mj harness account disable <slotId> - Disable a slot from balancing');
|
|
18
|
+
this.log(' mj harness account clear-cooldown <slotId> - Clear active quota cooldown on a slot');
|
|
19
|
+
this.log('\nRun "mj harness account COMMAND --help" for details.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/harness/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;aACjC,gBAAW,GAAG,mFAAmF,CAAC;aAElG,aAAQ,GAAG;QACd,kDAAkD;QAClD,yEAAyE;QACzE,0EAA0E;KAC7E,CAAC;IAEK,KAAK,CAAC,GAAG;QACZ,IAAI,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,+FAA+F,CAAC,CAAC;QAC1G,IAAI,CAAC,GAAG,CAAC,8FAA8F,CAAC,CAAC;QACzG,IAAI,CAAC,GAAG,CAAC,sFAAsF,CAAC,CAAC;QACjG,IAAI,CAAC,GAAG,CAAC,6EAA6E,CAAC,CAAC;QACxF,IAAI,CAAC,GAAG,CAAC,yFAAyF,CAAC,CAAC;QACpG,IAAI,CAAC,GAAG,CAAC,iFAAiF,CAAC,CAAC;QAC5F,IAAI,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;QAC9F,IAAI,CAAC,GAAG,CAAC,2FAA2F,CAAC,CAAC;QACtG,IAAI,CAAC,GAAG,CAAC,wDAAwD,CAAC,CAAC;IACvE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DomainUsageCommand } from '../../lib/domain-usage-command.js';
|
|
2
|
+
/** Tier-2 usage for the `harness` domain (`mj harness usage`). */
|
|
3
|
+
export default class HarnessUsage extends DomainUsageCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
protected Domain: string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/commands/harness/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,kEAAkE;AAClE,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,kBAAkB;IACxD,MAAM,CAAC,WAAW,SAAoF;IACtG,SAAS,CAAC,MAAM,SAAa;CAChC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DomainUsageCommand } from '../../lib/domain-usage-command.js';
|
|
2
|
+
/** Tier-2 usage for the `harness` domain (`mj harness usage`). */
|
|
3
|
+
export default class HarnessUsage extends DomainUsageCommand {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.Domain = 'harness';
|
|
7
|
+
}
|
|
8
|
+
static { this.description = 'Show usage, flags, examples, and runtime hints for every `mj harness` command.'; }
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/commands/harness/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,kEAAkE;AAClE,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,kBAAkB;IAA5D;;QAEc,WAAM,GAAG,SAAS,CAAC;IACjC,CAAC;aAFU,gBAAW,GAAG,gFAAgF,AAAnF,CAAoF"}
|
|
@@ -6,7 +6,7 @@ import type { MigrationConversionResult, BakedMigrationResult } from '@memberjun
|
|
|
6
6
|
* `mode`). An INTERSECTION (not a bare `Pick`) because `MigrationConversionResult` has no `mode`
|
|
7
7
|
* field — the baker's `mode`/`reconciliation` are optional here (issue #3252 Phase 4b).
|
|
8
8
|
*/
|
|
9
|
-
type ConvertedShape = Pick<MigrationConversionResult, 'status' | 'pgSQL' | 'unhandled' | 'handProcedural'> & {
|
|
9
|
+
type ConvertedShape = Pick<MigrationConversionResult, 'status' | 'pgSQL' | 'unhandled' | 'handProcedural' | 'warnings'> & {
|
|
10
10
|
mode?: BakedMigrationResult['mode'];
|
|
11
11
|
reconciliation?: MigrationConversionResult['reconciliation'];
|
|
12
12
|
};
|
|
@@ -90,6 +90,19 @@ export declare function decideLegacyConvertExit(args: {
|
|
|
90
90
|
fail: false;
|
|
91
91
|
message: null;
|
|
92
92
|
};
|
|
93
|
+
/** The newest T-SQL baseline among `files`, or undefined. */
|
|
94
|
+
export declare function LatestBaseline(files: string[]): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Splits T-SQL migration files into those to consider for conversion and the `V…` files older than
|
|
97
|
+
* the oldest baseline (#3345 item 1). A baseline is a cumulative snapshot, so a migration below the
|
|
98
|
+
* oldest one is already inside it and has no counterpart to write; counting it as unconverted halted
|
|
99
|
+
* every bake chain. Baselines and every file at or after the oldest baseline are kept; with no
|
|
100
|
+
* baseline in the folder, every file is kept. Pure.
|
|
101
|
+
*/
|
|
102
|
+
export declare function FilterPreBaselineMigrations(files: string[]): {
|
|
103
|
+
kept: string[];
|
|
104
|
+
skipped: string[];
|
|
105
|
+
};
|
|
93
106
|
/**
|
|
94
107
|
* Names of the CodeGen CRUD procedures (`spCreate*`, `spUpdate*`, `spDelete*`) in a migration's
|
|
95
108
|
* CodeGen block, in file order. Hand-written procedures above the block are not included.
|
|
@@ -163,6 +176,12 @@ export default class MigrateConvert extends Command {
|
|
|
163
176
|
* See plans/pg-migration-architecture/SPLIT_AND_REGENERATE_PROPOSAL.md.
|
|
164
177
|
*/
|
|
165
178
|
private runSplit;
|
|
179
|
+
/**
|
|
180
|
+
* The legacy path's run-wide boolean-column registry, seeded from the latest baseline in
|
|
181
|
+
* `sourceDir` (a cumulative schema snapshot, so it declares every table that exists before the
|
|
182
|
+
* files being converted). Empty when the folder has no baseline.
|
|
183
|
+
*/
|
|
184
|
+
private buildLegacyColumnRegistry;
|
|
166
185
|
/**
|
|
167
186
|
* Construct the AST transpiler with the cross-file BIT/BOOLEAN column registry
|
|
168
187
|
* collected from the baselines (they declare the core tables, e.g. User.IsActive),
|
|
@@ -182,6 +201,11 @@ export default class MigrateConvert extends Command {
|
|
|
182
201
|
* matching `import type` at the top is erased at runtime, so it does not defeat the deferral.
|
|
183
202
|
*/
|
|
184
203
|
private buildBaker;
|
|
204
|
+
/**
|
|
205
|
+
* Print the named, non-blocking warnings (issue #5649): work the converter cannot do that a
|
|
206
|
+
* person finishes by hand. They do not fail the run or stop a bake.
|
|
207
|
+
*/
|
|
208
|
+
private printWarnings;
|
|
185
209
|
/** Warn when the legacy path is about to transpile CodeGen CRUD procedures. */
|
|
186
210
|
private warnOnCodeGenProcedures;
|
|
187
211
|
/** Print the split-and-regenerate run summary and the mandatory next steps. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/commands/migrate/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAiB7C,OAAO,KAAK,EAIV,yBAAyB,EACzB,oBAAoB,EAIrB,MAAM,+BAA+B,CAAC;AAYvC;;;;;GAKG;AACH,KAAK,cAAc,GAAG,IAAI,CAAC,yBAAyB,EAAE,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,gBAAgB,GAAG,UAAU,CAAC,GAAG;IACxH,IAAI,CAAC,EAAE,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACpC,cAAc,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAIhC,M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AAiB;IAwCzB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;IAuD3B,OAAO,CAAC,UAAU;CAsBnB"}
|
|
@@ -2,7 +2,7 @@ import { Command, Flags } from '@oclif/core';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { convertFile, getRulesForDialects, createConversionStats, deduplicateEntityFieldSequences, convertMigration, IncrementalBaker, BakeApplyError, SelectBakeableEntities, SplitMigration, } from '@memberjunction/sql-converter';
|
|
5
|
+
import { convertFile, getRulesForDialects, createConversionStats, deduplicateEntityFieldSequences, convertMigration, IncrementalBaker, BakeApplyError, SelectBakeableEntities, DiffFieldDefaults, SplitMigration, CollectTSQLBitColumns, } from '@memberjunction/sql-converter';
|
|
6
6
|
import { MJPostgresTranspiler } from '@memberjunction/sqlglot-ts';
|
|
7
7
|
/**
|
|
8
8
|
* MJ core's schema — where the boolean columns an Open App migration seeds (EntityField.AllowsNull
|
|
@@ -102,6 +102,41 @@ export function DecideLegacyConvertExit(args) {
|
|
|
102
102
|
export function decideLegacyConvertExit(args) {
|
|
103
103
|
return DecideLegacyConvertExit(args);
|
|
104
104
|
}
|
|
105
|
+
/** A T-SQL baseline migration file (`B<version>__….sql`), not a PG counterpart. */
|
|
106
|
+
function isBaselineSource(file) {
|
|
107
|
+
return /^B\d.*\.sql$/.test(file) && !file.endsWith('.pg.sql') && !file.endsWith('.pg-only.sql');
|
|
108
|
+
}
|
|
109
|
+
/** The newest T-SQL baseline among `files`, or undefined. */
|
|
110
|
+
export function LatestBaseline(files) {
|
|
111
|
+
return files.filter(isBaselineSource).sort().at(-1);
|
|
112
|
+
}
|
|
113
|
+
/** The version key of a migration file name: `V202602131500__…` → `202602131500`. */
|
|
114
|
+
function migrationVersion(file) {
|
|
115
|
+
return (file.match(/^[VB](\d+)/) ?? [])[1] ?? '';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Splits T-SQL migration files into those to consider for conversion and the `V…` files older than
|
|
119
|
+
* the oldest baseline (#3345 item 1). A baseline is a cumulative snapshot, so a migration below the
|
|
120
|
+
* oldest one is already inside it and has no counterpart to write; counting it as unconverted halted
|
|
121
|
+
* every bake chain. Baselines and every file at or after the oldest baseline are kept; with no
|
|
122
|
+
* baseline in the folder, every file is kept. Pure.
|
|
123
|
+
*/
|
|
124
|
+
export function FilterPreBaselineMigrations(files) {
|
|
125
|
+
const baselines = files.filter(isBaselineSource).map(migrationVersion).filter((v) => v).sort();
|
|
126
|
+
const floor = baselines[0];
|
|
127
|
+
if (!floor)
|
|
128
|
+
return { kept: [...files], skipped: [] };
|
|
129
|
+
const kept = [];
|
|
130
|
+
const skipped = [];
|
|
131
|
+
for (const f of files) {
|
|
132
|
+
const version = migrationVersion(f);
|
|
133
|
+
if (/^V/.test(f) && version && version < floor)
|
|
134
|
+
skipped.push(f);
|
|
135
|
+
else
|
|
136
|
+
kept.push(f);
|
|
137
|
+
}
|
|
138
|
+
return { kept, skipped };
|
|
139
|
+
}
|
|
105
140
|
/** A CodeGen CRUD procedure definition, e.g. `CREATE PROCEDURE [${flyway:defaultSchema}].[spCreateX]`. */
|
|
106
141
|
const CODEGEN_CRUD_PROCEDURE = /\bCREATE\s+(?:OR\s+ALTER\s+)?PROC(?:EDURE)?\s+(?:\S*\.)?\[?(sp(?:Create|Update|Delete)\w+)\]?/gi;
|
|
107
142
|
/**
|
|
@@ -199,8 +234,8 @@ export default class MigrateConvert extends Command {
|
|
|
199
234
|
}),
|
|
200
235
|
split: Flags.boolean({
|
|
201
236
|
description: 'Split-and-regenerate (the standard path): transpile only hand-written DDL via the AST ' +
|
|
202
|
-
'dialect; CodeGen objects are regenerated by `mj codegen
|
|
203
|
-
'
|
|
237
|
+
'dialect; CodeGen objects are regenerated by `mj codegen`; an mj-sync log converts inline ' +
|
|
238
|
+
'(one DO block per save); every conversion gap is surfaced and fails the run unless --allow-gaps.',
|
|
204
239
|
default: false,
|
|
205
240
|
}),
|
|
206
241
|
'allow-gaps': Flags.boolean({
|
|
@@ -265,6 +300,9 @@ export default class MigrateConvert extends Command {
|
|
|
265
300
|
return;
|
|
266
301
|
}
|
|
267
302
|
this.log('');
|
|
303
|
+
// One boolean-column registry for the whole run (#5016): the latest baseline's tables, then each
|
|
304
|
+
// converted file's own, so a view over a table an earlier migration created converts `= 1`.
|
|
305
|
+
const tableColumns = this.buildLegacyColumnRegistry(sourceDir);
|
|
268
306
|
// Convert each file
|
|
269
307
|
let successCount = 0;
|
|
270
308
|
let errorCount = 0;
|
|
@@ -283,6 +321,7 @@ export default class MigrateConvert extends Command {
|
|
|
283
321
|
IncludeHeader: !flags['no-header'],
|
|
284
322
|
EnablePostProcess: true,
|
|
285
323
|
OnProgress: flags.verbose ? (msg) => this.log(` ${msg}`) : undefined,
|
|
324
|
+
TableColumns: tableColumns,
|
|
286
325
|
};
|
|
287
326
|
const result = convertFile(config);
|
|
288
327
|
this.mergeStats(totalStats, result.Stats);
|
|
@@ -320,17 +359,25 @@ export default class MigrateConvert extends Command {
|
|
|
320
359
|
this.log(` Indexes: ${totalStats.IndexesCreated}`);
|
|
321
360
|
this.log(` Inserts: ${totalStats.InsertsConverted}`);
|
|
322
361
|
this.log(` Grants: ${totalStats.GrantsConverted}`);
|
|
362
|
+
this.printWarnings(totalStats.Warnings);
|
|
323
363
|
// Post-conversion: deduplicate EntityField Sequence values across files
|
|
324
364
|
// to prevent UQ_EntityField_EntityID_Sequence violations on PG
|
|
365
|
+
// Only the files written by THIS run may be edited: every other .pg.sql in the folder is
|
|
366
|
+
// committed history that may already be applied, so a fix lands on the side of a collision
|
|
367
|
+
// that this run produced (issue #3166).
|
|
325
368
|
this.log('\nRunning EntityField Sequence deduplication...');
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
369
|
+
const writtenThisRun = new Set(unconverted.map((m) => path.basename(m.OutputFile)));
|
|
370
|
+
const dedupResult = deduplicateEntityFieldSequences(outputDir, false, writtenThisRun);
|
|
371
|
+
if (dedupResult.fixes.length > 0) {
|
|
372
|
+
this.log(` Fixed ${dedupResult.fixes.length} sequence collision(s) in files written by this run:`);
|
|
329
373
|
for (const fix of dedupResult.fixes) {
|
|
330
374
|
this.log(` ${fix.file} line ${fix.line}: ${fix.originalSequence} → ${fix.newSequence}`);
|
|
331
375
|
}
|
|
332
376
|
}
|
|
333
|
-
|
|
377
|
+
if (dedupResult.committedCollisions.length > 0) {
|
|
378
|
+
this.log(` Left ${dedupResult.committedCollisions.length} collision(s) between committed files unchanged.`);
|
|
379
|
+
}
|
|
380
|
+
if (dedupResult.totalCollisions === 0) {
|
|
334
381
|
this.log(` No collisions found (${dedupResult.totalInserts} EntityField INSERTs scanned).`);
|
|
335
382
|
}
|
|
336
383
|
// Gate LAST, after the sequence dedup fixup. `this.error` throws, and the files are already
|
|
@@ -375,7 +422,8 @@ export default class MigrateConvert extends Command {
|
|
|
375
422
|
// Select the per-migration conversion: inline-baking (live DB, CodeGen baked natively) or
|
|
376
423
|
// the default transpile-only path (CodeGen regenerated by `mj codegen` at deploy).
|
|
377
424
|
const bakeCodegen = flags['bake-codegen'];
|
|
378
|
-
const
|
|
425
|
+
const bakeDriver = bakeCodegen ? await this.buildBaker(transpiler, flags.schema, flags['core-schema']) : null;
|
|
426
|
+
const baker = bakeDriver?.baker ?? null;
|
|
379
427
|
const convertOne = (sql, fileName) => baker
|
|
380
428
|
? baker.bakeMigration(sql, fileName)
|
|
381
429
|
: convertMigration(sql, fileName, {
|
|
@@ -390,6 +438,7 @@ export default class MigrateConvert extends Command {
|
|
|
390
438
|
const regenReseed = [];
|
|
391
439
|
const needsHand = [];
|
|
392
440
|
const withUnhandled = [];
|
|
441
|
+
const warnings = [];
|
|
393
442
|
const gapReport = [];
|
|
394
443
|
// Set when a bake-mode gap or a conversion failure halts the batch: the working DB was
|
|
395
444
|
// NOT advanced past this migration, so later bakes must not run against a stale schema.
|
|
@@ -428,7 +477,11 @@ export default class MigrateConvert extends Command {
|
|
|
428
477
|
halted = { file: m.SourceFile, reason: msg };
|
|
429
478
|
break;
|
|
430
479
|
}
|
|
480
|
+
warnings.push(...result.warnings);
|
|
431
481
|
const decision = DecideConvertWrite(result, bakeCodegen);
|
|
482
|
+
// The working DB advanced past this file: pick up the boolean columns it added (#6348).
|
|
483
|
+
if (bakeDriver && !decision.haltBake)
|
|
484
|
+
await bakeDriver.refreshBitColumns();
|
|
432
485
|
// A needs-hand / gap-no-bake migration is NEVER written as a discoverable .pg.sql — that
|
|
433
486
|
// would mark it converted forever and let Skyway apply an incomplete file. The .needs-hand
|
|
434
487
|
// artifact carries the transpiled DDL + gap comments for a human (or LLM pass) to finish.
|
|
@@ -487,6 +540,7 @@ export default class MigrateConvert extends Command {
|
|
|
487
540
|
}
|
|
488
541
|
}
|
|
489
542
|
this.printSplitSummary(converted, regenReseed, needsHand, withUnhandled, flags['dry-run'], bakeCodegen);
|
|
543
|
+
this.printWarnings(warnings);
|
|
490
544
|
// A halt (bake-mode gap or a conversion failure) ALWAYS ends the run non-zero, BEFORE the
|
|
491
545
|
// unconditional `process.exit(0)` below — otherwise a bake run could exit 0 despite a gap
|
|
492
546
|
// (issue #3252 Phase 4d, MAJOR-2). this.error throws a CLIError → non-zero exit.
|
|
@@ -508,6 +562,17 @@ export default class MigrateConvert extends Command {
|
|
|
508
562
|
if (bakeCodegen)
|
|
509
563
|
process.exit(0);
|
|
510
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* The legacy path's run-wide boolean-column registry, seeded from the latest baseline in
|
|
567
|
+
* `sourceDir` (a cumulative schema snapshot, so it declares every table that exists before the
|
|
568
|
+
* files being converted). Empty when the folder has no baseline.
|
|
569
|
+
*/
|
|
570
|
+
buildLegacyColumnRegistry(sourceDir) {
|
|
571
|
+
const latest = LatestBaseline(fs.readdirSync(sourceDir));
|
|
572
|
+
if (!latest)
|
|
573
|
+
return new Map();
|
|
574
|
+
return CollectTSQLBitColumns(fs.readFileSync(path.join(sourceDir, latest), 'utf8'));
|
|
575
|
+
}
|
|
511
576
|
/**
|
|
512
577
|
* Construct the AST transpiler with the cross-file BIT/BOOLEAN column registry
|
|
513
578
|
* collected from the baselines (they declare the core tables, e.g. User.IsActive),
|
|
@@ -532,11 +597,7 @@ export default class MigrateConvert extends Command {
|
|
|
532
597
|
// once enough baselines accumulate, making every spawn fail with `spawn E2BIG`.
|
|
533
598
|
// (Threshold first crossed at v5.46: 5 baselines = 4060 entries ≈ 134 KB. Latest
|
|
534
599
|
// baseline alone ≈ 1023 entries ≈ 34 KB.)
|
|
535
|
-
const
|
|
536
|
-
.readdirSync(sourceDir)
|
|
537
|
-
.filter((f) => /^B\d.*\.sql$/.test(f) && !f.endsWith('.pg.sql') && !f.endsWith('.pg-only.sql'))
|
|
538
|
-
.sort();
|
|
539
|
-
const latestBaseline = baselines.at(-1);
|
|
600
|
+
const latestBaseline = LatestBaseline(fs.readdirSync(sourceDir));
|
|
540
601
|
const bitColumns = [];
|
|
541
602
|
if (latestBaseline) {
|
|
542
603
|
try {
|
|
@@ -562,7 +623,7 @@ export default class MigrateConvert extends Command {
|
|
|
562
623
|
* matching `import type` at the top is erased at runtime, so it does not defeat the deferral.
|
|
563
624
|
*/
|
|
564
625
|
async buildBaker(transpiler, schema, coreSchema) {
|
|
565
|
-
const { RunCodeGenBase, SQLCodeGenBase, initializeConfig, dbPlatform, configInfo } = await import('@memberjunction/codegen-lib');
|
|
626
|
+
const { RunCodeGenBase, SQLCodeGenBase, PostgreSQLCodeGenProvider, initializeConfig, dbPlatform, configInfo } = await import('@memberjunction/codegen-lib');
|
|
566
627
|
if (dbPlatform() !== 'postgresql') {
|
|
567
628
|
this.error('--bake-codegen requires DB_PLATFORM=postgresql with PG_* connection env (the working DB CodeGen objects are captured from).');
|
|
568
629
|
}
|
|
@@ -595,28 +656,33 @@ export default class MigrateConvert extends Command {
|
|
|
595
656
|
// not: the copies in the bizapps repos are generated against core 5.37 and already miss columns
|
|
596
657
|
// that exist in 6.x. Failure to read the catalog degrades coercion rather than stopping the
|
|
597
658
|
// run, so it warns loudly instead of aborting.
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
659
|
+
// The catalog is read again after every applied migration (#6348): a column a migration in this
|
|
660
|
+
// run adds is boolean in the working DB from then on, and a later file's view compares it.
|
|
661
|
+
const refreshBitColumns = async (initial) => {
|
|
662
|
+
try {
|
|
663
|
+
// `CodeGenConnection.query` takes SQL only — no parameter array — so the two schema names are
|
|
664
|
+
// inlined as literals. They are configuration identifiers rather than user input, and are
|
|
665
|
+
// escaped by doubling any single quote so a schema name cannot terminate the literal.
|
|
666
|
+
const schemaList = [MJ_CORE_SCHEMA, schema].map((n) => `'${n.replaceAll("'", "''")}'`).join(', ');
|
|
667
|
+
const { recordset } = await ds.connection.query(`SELECT table_name, column_name
|
|
668
|
+
FROM information_schema.columns
|
|
669
|
+
WHERE data_type = 'boolean' AND table_schema IN (${schemaList})`);
|
|
670
|
+
// The dialect's registry keys are LOWERCASED [table, column] pairs.
|
|
671
|
+
const catalogBitCols = recordset.map((r) => [
|
|
672
|
+
String(r.table_name).toLowerCase(),
|
|
673
|
+
String(r.column_name).toLowerCase(),
|
|
674
|
+
]);
|
|
675
|
+
transpiler.addExtraBitColumns(catalogBitCols);
|
|
676
|
+
if (initial && catalogBitCols.length === 0) {
|
|
677
|
+
this.warn('No boolean columns found in the working database — bit/boolean coercion will rely on the baseline registry alone.');
|
|
678
|
+
}
|
|
614
679
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
680
|
+
catch (err) {
|
|
681
|
+
this.warn(`Could not read boolean columns from the working database (${err instanceof Error ? err.message : String(err)}). ` +
|
|
682
|
+
'Seed INSERT/UPDATE values targeting core boolean columns may not be coerced.');
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
await refreshBitColumns(true);
|
|
620
686
|
const sqlGen = new SQLCodeGenBase();
|
|
621
687
|
const db = {
|
|
622
688
|
apply: async (sql) => {
|
|
@@ -653,8 +719,50 @@ export default class MigrateConvert extends Command {
|
|
|
653
719
|
// generateSingleEntitySQLToSeparateFiles, so this only gates at the entity level.
|
|
654
720
|
// Provider order is name-sorted (PostProcessEntityMetadata), matching a full run.
|
|
655
721
|
listBakeableEntities: async (targetSchema) => SelectBakeableEntities(ds.provider.Entities, targetSchema, configInfo.excludeSchemas ?? []),
|
|
722
|
+
// PostgreSQL's field sync for the migration's entities, between apply and capture (issue
|
|
723
|
+
// #5650): a default added to an existing column reaches the metadata the baked spCreate is
|
|
724
|
+
// generated from. CodeGen's support objects are ensured first, as `mj codegen` does, since
|
|
725
|
+
// the sync with an entity-ID scope is one of them.
|
|
726
|
+
syncFieldDefaults: async (entityNames) => {
|
|
727
|
+
const ids = entityNames
|
|
728
|
+
.map((n) => ds.provider.EntityByName(n)?.ID)
|
|
729
|
+
.filter((id) => typeof id === 'string');
|
|
730
|
+
if (ids.length === 0)
|
|
731
|
+
return [];
|
|
732
|
+
const lit = (v) => `'${v.replaceAll("'", "''")}'`;
|
|
733
|
+
const support = new PostgreSQLCodeGenProvider().getMetadataSupportObjectsSQL(coreSchema);
|
|
734
|
+
if (support)
|
|
735
|
+
await ds.connection.query(support);
|
|
736
|
+
const snapshot = async () => {
|
|
737
|
+
const { recordset } = await ds.connection.query(`SELECT f."ID", e."Name" AS "EntityName", f."Name" AS "FieldName", f."DefaultValue"
|
|
738
|
+
FROM ${coreSchema}."EntityField" f JOIN ${coreSchema}."Entity" e ON e."ID" = f."EntityID"
|
|
739
|
+
WHERE f."EntityID" IN (${ids.map(lit).join(', ')})
|
|
740
|
+
ORDER BY e."Name", f."Sequence"`);
|
|
741
|
+
return recordset.map((r) => ({
|
|
742
|
+
ID: String(r.ID),
|
|
743
|
+
EntityName: String(r.EntityName),
|
|
744
|
+
FieldName: String(r.FieldName),
|
|
745
|
+
DefaultValue: r.DefaultValue === null || r.DefaultValue === undefined ? null : String(r.DefaultValue),
|
|
746
|
+
}));
|
|
747
|
+
};
|
|
748
|
+
const before = await snapshot();
|
|
749
|
+
const excluded = (configInfo.excludeSchemas ?? []).join(',');
|
|
750
|
+
await ds.connection.query(`SELECT * FROM ${coreSchema}."spUpdateExistingEntityFieldsFromSchema"(${lit(excluded)}, ${lit(ids.join(','))})`);
|
|
751
|
+
return DiffFieldDefaults(before, await snapshot());
|
|
752
|
+
},
|
|
656
753
|
};
|
|
657
|
-
return new IncrementalBaker({ transpiler, db, schema, coreSchema });
|
|
754
|
+
return { baker: new IncrementalBaker({ transpiler, db, schema, coreSchema }), refreshBitColumns: () => refreshBitColumns(false) };
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Print the named, non-blocking warnings (issue #5649): work the converter cannot do that a
|
|
758
|
+
* person finishes by hand. They do not fail the run or stop a bake.
|
|
759
|
+
*/
|
|
760
|
+
printWarnings(warnings) {
|
|
761
|
+
if (warnings.length === 0)
|
|
762
|
+
return;
|
|
763
|
+
this.logToStderr(`\n ⚠ ${warnings.length} warning(s) to finish by hand (the run is not failed):`);
|
|
764
|
+
for (const w of warnings)
|
|
765
|
+
this.logToStderr(` ${w}`);
|
|
658
766
|
}
|
|
659
767
|
/** Warn when the legacy path is about to transpile CodeGen CRUD procedures. */
|
|
660
768
|
warnOnCodeGenProcedures(sourceDir, migrations) {
|
|
@@ -712,12 +820,21 @@ export default class MigrateConvert extends Command {
|
|
|
712
820
|
* unconverted until its gaps are resolved and the file is renamed to `.pg.sql`.
|
|
713
821
|
*/
|
|
714
822
|
discoverUnconverted(sourceDir, outputDir, specificFile) {
|
|
715
|
-
const
|
|
823
|
+
const allSourceFiles = fs.readdirSync(sourceDir)
|
|
716
824
|
.filter((f) => f.endsWith('.sql') && !f.endsWith('.pg.sql') && !f.endsWith('.pg-only.sql'))
|
|
717
825
|
.sort();
|
|
718
|
-
if (specificFile && !
|
|
826
|
+
if (specificFile && !allSourceFiles.includes(specificFile)) {
|
|
719
827
|
this.error(`--file ${specificFile} not found in ${sourceDir}`);
|
|
720
828
|
}
|
|
829
|
+
// A named --file is converted as asked; otherwise migrations older than the oldest baseline
|
|
830
|
+
// are already inside it and are not candidates (#3345 item 1).
|
|
831
|
+
const { kept, skipped } = specificFile
|
|
832
|
+
? { kept: allSourceFiles, skipped: [] }
|
|
833
|
+
: FilterPreBaselineMigrations(allSourceFiles);
|
|
834
|
+
if (skipped.length > 0) {
|
|
835
|
+
this.log(`Skipped ${skipped.length} migration(s) older than the oldest baseline (already inside it).`);
|
|
836
|
+
}
|
|
837
|
+
const sourceFiles = kept;
|
|
721
838
|
const outputFiles = new Set(fs.readdirSync(outputDir)
|
|
722
839
|
.filter((f) => f.endsWith('.pg.sql') || f.endsWith('.pg-only.sql')));
|
|
723
840
|
const unconverted = [];
|
|
@@ -762,6 +879,7 @@ export default class MigrateConvert extends Command {
|
|
|
762
879
|
target.ErrorBatches.push(...source.ErrorBatches);
|
|
763
880
|
target.SkippedBatches.push(...source.SkippedBatches);
|
|
764
881
|
target.GapBatches.push(...source.GapBatches);
|
|
882
|
+
target.Warnings.push(...source.Warnings);
|
|
765
883
|
}
|
|
766
884
|
}
|
|
767
885
|
//# sourceMappingURL=convert.js.map
|