@revoengine/cli 1.0.11 → 1.0.13
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 +275 -479
- package/dist/src/cli.js +71 -5
- package/dist/src/client.d.ts +28 -12
- package/dist/src/client.js +234 -66
- package/dist/src/commands/component.d.ts +67 -0
- package/dist/src/commands/component.js +299 -27
- package/dist/src/commands/database-tables.d.ts +2 -0
- package/dist/src/commands/{database-schemas.js → database-tables.js} +21 -40
- package/dist/src/commands/database-views.js +21 -18
- package/dist/src/commands/endpoints.js +26 -16
- package/dist/src/commands/events.js +18 -20
- package/dist/src/commands/groups.js +13 -22
- package/dist/src/commands/index.d.ts +2 -1
- package/dist/src/commands/index.js +2 -1
- package/dist/src/commands/job-templates.js +21 -15
- package/dist/src/commands/metadata.js +58 -15
- package/dist/src/commands/migrate.d.ts +6 -0
- package/dist/src/commands/migrate.js +658 -0
- package/dist/src/commands/project.js +4 -4
- package/dist/src/commands/role-groups.js +14 -25
- package/dist/src/commands/schedules.js +19 -20
- package/dist/src/commands/terminal-browser.d.ts +16 -0
- package/dist/src/commands/terminal-browser.js +92 -0
- package/dist/src/commands/terminal-image.d.ts +7 -0
- package/dist/src/commands/terminal-image.js +40 -0
- package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
- package/dist/src/commands/terminal-patch-worker.js +24 -0
- package/dist/src/commands/terminal-patch.d.ts +2 -0
- package/dist/src/commands/terminal-patch.js +156 -0
- package/dist/src/commands/terminal-sandbox.d.ts +8 -0
- package/dist/src/commands/terminal-sandbox.js +87 -0
- package/dist/src/commands/terminal-service.js +2 -2
- package/dist/src/commands/terminal.d.ts +31 -4
- package/dist/src/commands/terminal.js +360 -45
- package/dist/src/component-lock.d.ts +12 -2
- package/dist/src/component-lock.js +60 -1
- package/dist/src/diff-details.d.ts +8 -0
- package/dist/src/diff-details.js +152 -0
- package/dist/src/env-sync.js +8 -6
- package/dist/src/http-trace.d.ts +94 -0
- package/dist/src/http-trace.js +226 -0
- package/dist/src/metadata-backfill.d.ts +5 -4
- package/dist/src/metadata-backfill.js +82 -158
- package/dist/src/migration.d.ts +141 -0
- package/dist/src/migration.js +1632 -0
- package/dist/src/resource-inventory.d.ts +28 -0
- package/dist/src/resource-inventory.js +85 -0
- package/dist/src/resource-syncs/{database-schema-sync.d.ts → database-table-sync.d.ts} +13 -3
- package/dist/src/resource-syncs/{database-schema-sync.js → database-table-sync.js} +147 -62
- package/dist/src/resource-syncs/database-view-sync.d.ts +24 -2
- package/dist/src/resource-syncs/database-view-sync.js +156 -68
- package/dist/src/resource-syncs/endpoint-sync.d.ts +27 -0
- package/dist/src/resource-syncs/endpoint-sync.js +362 -82
- package/dist/src/resource-syncs/event-sync.d.ts +27 -0
- package/dist/src/resource-syncs/event-sync.js +123 -26
- package/dist/src/resource-syncs/group-sync.d.ts +7 -0
- package/dist/src/resource-syncs/group-sync.js +60 -14
- package/dist/src/resource-syncs/job-template-sync.d.ts +21 -0
- package/dist/src/resource-syncs/job-template-sync.js +91 -30
- package/dist/src/resource-syncs/role-group-sync.d.ts +7 -0
- package/dist/src/resource-syncs/role-group-sync.js +47 -9
- package/dist/src/resource-syncs/schedule-sync.d.ts +30 -1
- package/dist/src/resource-syncs/schedule-sync.js +114 -20
- package/dist/src/resource-syncs/util.d.ts +3 -0
- package/dist/src/resource-syncs/util.js +8 -6
- package/dist/src/resource-target.d.ts +11 -0
- package/dist/src/resource-target.js +48 -0
- package/dist/src/sync-output.d.ts +29 -1
- package/dist/src/sync-output.js +139 -2
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +8 -6
- package/dist/src/types.d.ts +3 -0
- package/dist/src/ui.js +18 -9
- package/dist/src/utils.d.ts +2 -0
- package/dist/src/utils.js +17 -0
- package/dist/src/workspace-diff.d.ts +25 -0
- package/dist/src/workspace-diff.js +75 -0
- package/package.json +9 -6
- package/dist/src/commands/database-schemas.d.ts +0 -2
- /package/dist/src/{database-schema-artifacts.d.ts → database-table-artifacts.d.ts} +0 -0
- /package/dist/src/{database-schema-artifacts.js → database-table-artifacts.js} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { describeFieldChanges } from "../diff-details.js";
|
|
2
3
|
import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
3
4
|
import { NULL_CATEGORY_KEY, normalizeStableKeyValue, readConfiguredResourceMetadataStableKey, sanitizeUserMetadata } from "../resource-metadata.js";
|
|
4
5
|
import { isValidNormalizedCron, normalizeCron, readJsonFile, sanitizeSegment } from "../utils.js";
|
|
5
|
-
import { findManifestFiles, isRecord, localTargetPath, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
|
|
6
|
+
import { findManifestFiles, isRecord, localTargetPath, mapWithConcurrency, removeRelocatedManifest, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
|
|
6
7
|
export const SCHEDULES_DIRECTORY = 'Schedules';
|
|
7
8
|
export const SCHEDULE_MANIFEST_FILE = 'schedule.json';
|
|
8
9
|
function canonicalValue(value) {
|
|
@@ -180,10 +181,10 @@ function warningKey(record, stableKey) {
|
|
|
180
181
|
return stableKey || String(record.name || scheduleIdOf(record) || 'unknown schedule');
|
|
181
182
|
}
|
|
182
183
|
async function hydrateRemoteRecords(input) {
|
|
183
|
-
return
|
|
184
|
+
return mapWithConcurrency(input.summaries, async (summary) => {
|
|
184
185
|
const id = input.idOf(summary);
|
|
185
186
|
return id ? unwrapData(await input.get(id)) : summary;
|
|
186
|
-
})
|
|
187
|
+
});
|
|
187
188
|
}
|
|
188
189
|
async function loadRemoteJobTemplates(client) {
|
|
189
190
|
const { jobTemplates } = await client.listAllJobTemplates();
|
|
@@ -203,18 +204,18 @@ async function loadRemoteSchedules(client) {
|
|
|
203
204
|
}
|
|
204
205
|
async function loadJobTemplatesById(client, ids) {
|
|
205
206
|
const uniqueIds = [...new Set(ids)].filter(Boolean);
|
|
206
|
-
const entries = await
|
|
207
|
+
const entries = await mapWithConcurrency(uniqueIds, async (id) => [
|
|
207
208
|
id,
|
|
208
209
|
unwrapData(await client.getJobTemplate(id)),
|
|
209
|
-
])
|
|
210
|
+
]);
|
|
210
211
|
return new Map(entries);
|
|
211
212
|
}
|
|
212
213
|
async function loadDatabaseViewsById(client, ids) {
|
|
213
214
|
const uniqueIds = [...new Set(ids)].filter(Boolean);
|
|
214
|
-
const entries = await
|
|
215
|
+
const entries = await mapWithConcurrency(uniqueIds, async (id) => [
|
|
215
216
|
id,
|
|
216
217
|
unwrapData(await client.getDatabaseView(id)),
|
|
217
|
-
])
|
|
218
|
+
]);
|
|
218
219
|
return new Map(entries);
|
|
219
220
|
}
|
|
220
221
|
function materializedRefreshMode(record) {
|
|
@@ -377,6 +378,24 @@ export async function buildSchedulesPlan(input) {
|
|
|
377
378
|
const items = [];
|
|
378
379
|
const lockEntriesByPath = new Map(Object.values(lock.schedules).map((entry) => [entry.path, entry]));
|
|
379
380
|
const identityConflictedTargetKeys = new Set();
|
|
381
|
+
const projectedJobTemplatesByKey = input.projectedJobTemplates === undefined
|
|
382
|
+
? undefined
|
|
383
|
+
: new Map();
|
|
384
|
+
for (const dependency of input.projectedJobTemplates || []) {
|
|
385
|
+
projectedJobTemplatesByKey?.set(dependency.stableKey, [
|
|
386
|
+
...(projectedJobTemplatesByKey.get(dependency.stableKey) || []),
|
|
387
|
+
dependency,
|
|
388
|
+
]);
|
|
389
|
+
}
|
|
390
|
+
const projectedDatabaseViewsByKey = input.projectedDatabaseViews === undefined
|
|
391
|
+
? undefined
|
|
392
|
+
: new Map();
|
|
393
|
+
for (const dependency of input.projectedDatabaseViews || []) {
|
|
394
|
+
projectedDatabaseViewsByKey?.set(dependency.stableKey, [
|
|
395
|
+
...(projectedDatabaseViewsByKey.get(dependency.stableKey) || []),
|
|
396
|
+
dependency,
|
|
397
|
+
]);
|
|
398
|
+
}
|
|
380
399
|
const localByKey = new Map();
|
|
381
400
|
for (const entry of localEntries) {
|
|
382
401
|
const rawManifest = entry.manifest;
|
|
@@ -388,6 +407,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
388
407
|
? rawManifest.name
|
|
389
408
|
: path.basename(path.dirname(entry.manifestPath)),
|
|
390
409
|
reason: 'invalid Schedule manifest',
|
|
410
|
+
blocked: true,
|
|
391
411
|
});
|
|
392
412
|
continue;
|
|
393
413
|
}
|
|
@@ -400,6 +420,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
400
420
|
name: entry.manifest.name,
|
|
401
421
|
reason: `stableKey changed from "${lockEntry.stableKey}"; identity changes are not renames`,
|
|
402
422
|
desiredHash: hashPortableSchedule(entry.manifest),
|
|
423
|
+
blocked: true,
|
|
403
424
|
...planTargetDetails(entry.manifest.target),
|
|
404
425
|
});
|
|
405
426
|
identityConflictedTargetKeys.add(lockEntry.stableKey);
|
|
@@ -447,6 +468,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
447
468
|
stableKey,
|
|
448
469
|
name: String(records[0].name || stableKey),
|
|
449
470
|
reason: 'duplicate target stableKey',
|
|
471
|
+
blocked: true,
|
|
450
472
|
});
|
|
451
473
|
}
|
|
452
474
|
for (const [stableKey, records] of supportedTargetRecordsByKey) {
|
|
@@ -480,7 +502,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
480
502
|
if (entries.length > 1) {
|
|
481
503
|
const desired = entries[0].manifest;
|
|
482
504
|
blockers.push(`Duplicate desired Schedule stableKey "${desired.stableKey}".`);
|
|
483
|
-
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'duplicate desired stableKey' });
|
|
505
|
+
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'duplicate desired stableKey', blocked: true });
|
|
484
506
|
consumedTargetKeys.add(stableKey);
|
|
485
507
|
continue;
|
|
486
508
|
}
|
|
@@ -498,6 +520,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
498
520
|
name: desired.name,
|
|
499
521
|
reason: `target Schedule is excluded: ${reason}`,
|
|
500
522
|
desiredHash,
|
|
523
|
+
blocked: true,
|
|
501
524
|
...planTargetDetails(desired.target),
|
|
502
525
|
});
|
|
503
526
|
consumedTargetKeys.add(stableKey);
|
|
@@ -515,6 +538,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
515
538
|
name: desired.name,
|
|
516
539
|
reason,
|
|
517
540
|
desiredHash,
|
|
541
|
+
blocked: true,
|
|
518
542
|
...planTargetDetails(desired.target),
|
|
519
543
|
});
|
|
520
544
|
consumedTargetKeys.add(stableKey);
|
|
@@ -526,13 +550,20 @@ export async function buildSchedulesPlan(input) {
|
|
|
526
550
|
}
|
|
527
551
|
const dependencyStableKey = targetDependencyStableKey(desired.target);
|
|
528
552
|
const dependencyLabel = targetDependencyLabel(desired.target);
|
|
529
|
-
const
|
|
553
|
+
const liveDependencyMatches = desired.target.type === 'JOB_TEMPLATE'
|
|
530
554
|
? remote.jobTemplatesByStableKey.get(dependencyStableKey) || []
|
|
531
555
|
: remote.databaseViewsByStableKey.get(dependencyStableKey) || [];
|
|
556
|
+
const usesProjection = desired.target.type === 'JOB_TEMPLATE'
|
|
557
|
+
? projectedJobTemplatesByKey !== undefined
|
|
558
|
+
: projectedDatabaseViewsByKey !== undefined;
|
|
559
|
+
const projectedDependencyMatches = desired.target.type === 'JOB_TEMPLATE'
|
|
560
|
+
? projectedJobTemplatesByKey?.get(dependencyStableKey) || []
|
|
561
|
+
: projectedDatabaseViewsByKey?.get(dependencyStableKey) || [];
|
|
562
|
+
const dependencyMatches = usesProjection ? projectedDependencyMatches : liveDependencyMatches;
|
|
532
563
|
if (dependencyMatches.length !== 1) {
|
|
533
564
|
const reason = dependencyMatches.length === 0
|
|
534
|
-
? `target ${dependencyLabel} is missing`
|
|
535
|
-
: `target ${dependencyLabel} stableKey is ambiguous
|
|
565
|
+
? (usesProjection ? `${dependencyLabel} is missing from the projected source migration` : `target ${dependencyLabel} is missing`)
|
|
566
|
+
: (usesProjection ? `${dependencyLabel} stableKey is ambiguous in the projected source migration` : `target ${dependencyLabel} stableKey is ambiguous`);
|
|
536
567
|
blockers.push(`Schedule "${desired.stableKey}" dependency "${dependencyStableKey}": ${reason}.`);
|
|
537
568
|
items.push({
|
|
538
569
|
status: 'conflict',
|
|
@@ -540,13 +571,24 @@ export async function buildSchedulesPlan(input) {
|
|
|
540
571
|
name: desired.name,
|
|
541
572
|
reason,
|
|
542
573
|
desiredHash,
|
|
574
|
+
dependency: {
|
|
575
|
+
resource: desired.target.type === 'JOB_TEMPLATE' ? 'job-template' : 'database-view',
|
|
576
|
+
stableKey: dependencyStableKey,
|
|
577
|
+
expectedHash: null,
|
|
578
|
+
projectedHash: null,
|
|
579
|
+
actualHash: null,
|
|
580
|
+
readiness: 'blocked',
|
|
581
|
+
},
|
|
582
|
+
blocked: true,
|
|
543
583
|
...planTargetDetails(desired.target),
|
|
544
584
|
});
|
|
545
585
|
consumedTargetKeys.add(stableKey);
|
|
546
586
|
continue;
|
|
547
587
|
}
|
|
548
588
|
if (desired.target.type === 'MATERIALIZED_VIEW'
|
|
549
|
-
&&
|
|
589
|
+
&& (usesProjection
|
|
590
|
+
? projectedDependencyMatches[0].viewType !== 'MATERIALIZED_VIEW'
|
|
591
|
+
: liveDependencyMatches[0].type !== 'MATERIALIZED_VIEW')) {
|
|
550
592
|
const reason = 'target Database View is not a MATERIALIZED_VIEW';
|
|
551
593
|
blockers.push(`Schedule "${desired.stableKey}" dependency "${dependencyStableKey}": ${reason}.`);
|
|
552
594
|
items.push({
|
|
@@ -555,11 +597,41 @@ export async function buildSchedulesPlan(input) {
|
|
|
555
597
|
name: desired.name,
|
|
556
598
|
reason,
|
|
557
599
|
desiredHash,
|
|
600
|
+
dependency: {
|
|
601
|
+
resource: 'database-view',
|
|
602
|
+
stableKey: dependencyStableKey,
|
|
603
|
+
expectedHash: usesProjection ? projectedDependencyMatches[0]?.desiredHash || null : null,
|
|
604
|
+
projectedHash: usesProjection ? projectedDependencyMatches[0]?.desiredHash || null : null,
|
|
605
|
+
actualHash: usesProjection ? projectedDependencyMatches[0]?.actualHash || null : null,
|
|
606
|
+
readiness: 'blocked',
|
|
607
|
+
},
|
|
608
|
+
blocked: true,
|
|
558
609
|
...planTargetDetails(desired.target),
|
|
559
610
|
});
|
|
560
611
|
consumedTargetKeys.add(stableKey);
|
|
561
612
|
continue;
|
|
562
613
|
}
|
|
614
|
+
const projectedDependency = usesProjection ? projectedDependencyMatches[0] : undefined;
|
|
615
|
+
const dependencyResource = desired.target.type === 'JOB_TEMPLATE' ? 'job-template' : 'database-view';
|
|
616
|
+
const dependencyReadiness = projectedDependency?.state === 'pending-create'
|
|
617
|
+
? (desired.target.type === 'JOB_TEMPLATE' ? 'pending-job-template-create' : 'pending-database-view-create')
|
|
618
|
+
: projectedDependency?.state === 'pending-update'
|
|
619
|
+
? (desired.target.type === 'JOB_TEMPLATE' ? 'pending-job-template-update' : 'pending-database-view-update')
|
|
620
|
+
: projectedDependency?.state === 'pending-adopt'
|
|
621
|
+
? (desired.target.type === 'JOB_TEMPLATE' ? 'pending-job-template-adopt' : 'pending-database-view-adopt')
|
|
622
|
+
: 'ready';
|
|
623
|
+
const dependency = {
|
|
624
|
+
resource: dependencyResource,
|
|
625
|
+
stableKey: dependencyStableKey,
|
|
626
|
+
expectedHash: projectedDependency?.desiredHash || null,
|
|
627
|
+
projectedHash: projectedDependency?.desiredHash || null,
|
|
628
|
+
actualHash: projectedDependency?.actualHash || null,
|
|
629
|
+
readiness: dependencyReadiness,
|
|
630
|
+
};
|
|
631
|
+
if (dependencyReadiness !== 'ready') {
|
|
632
|
+
warnings.push(`Schedule "${desired.stableKey}" dependency "${dependencyStableKey}" is ${dependencyReadiness}; migration will resolve its verified target UUID after the ${dependencyLabel} phase.`);
|
|
633
|
+
}
|
|
634
|
+
const dependencyDetails = { dependency };
|
|
563
635
|
const matches = targetByKey.get(stableKey) || [];
|
|
564
636
|
if (matches.length === 0) {
|
|
565
637
|
const managedHintedKeys = [...targetByKey.entries()]
|
|
@@ -579,6 +651,8 @@ export async function buildSchedulesPlan(input) {
|
|
|
579
651
|
name: desired.name,
|
|
580
652
|
reason,
|
|
581
653
|
desiredHash,
|
|
654
|
+
blocked: true,
|
|
655
|
+
...dependencyDetails,
|
|
582
656
|
...planTargetDetails(desired.target),
|
|
583
657
|
});
|
|
584
658
|
continue;
|
|
@@ -594,6 +668,8 @@ export async function buildSchedulesPlan(input) {
|
|
|
594
668
|
name: desired.name,
|
|
595
669
|
reason,
|
|
596
670
|
desiredHash,
|
|
671
|
+
blocked: true,
|
|
672
|
+
...dependencyDetails,
|
|
597
673
|
...planTargetDetails(desired.target),
|
|
598
674
|
});
|
|
599
675
|
}
|
|
@@ -603,6 +679,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
603
679
|
stableKey: desired.stableKey,
|
|
604
680
|
name: desired.name,
|
|
605
681
|
desiredHash,
|
|
682
|
+
...dependencyDetails,
|
|
606
683
|
...planTargetDetails(desired.target),
|
|
607
684
|
});
|
|
608
685
|
}
|
|
@@ -618,8 +695,12 @@ export async function buildSchedulesPlan(input) {
|
|
|
618
695
|
stableKey: desired.stableKey,
|
|
619
696
|
name: desired.name,
|
|
620
697
|
reason,
|
|
698
|
+
forceRequirement: 'schedule-target-type-transition',
|
|
621
699
|
desiredHash,
|
|
622
700
|
currentHash: target.hash,
|
|
701
|
+
changedFields: ['target'],
|
|
702
|
+
fieldChanges: describeFieldChanges(desired, target.manifest, ['target']),
|
|
703
|
+
...dependencyDetails,
|
|
623
704
|
...planTargetDetails(desired.target),
|
|
624
705
|
});
|
|
625
706
|
continue;
|
|
@@ -630,8 +711,9 @@ export async function buildSchedulesPlan(input) {
|
|
|
630
711
|
name: desired.name,
|
|
631
712
|
desiredHash,
|
|
632
713
|
currentHash: target.hash,
|
|
714
|
+
...dependencyDetails,
|
|
633
715
|
...planTargetDetails(desired.target),
|
|
634
|
-
...(changedFields.length > 0 ? { changedFields } : {}),
|
|
716
|
+
...(changedFields.length > 0 ? { changedFields, fieldChanges: describeFieldChanges(desired, target.manifest, changedFields) } : {}),
|
|
635
717
|
};
|
|
636
718
|
const baselineHash = lock.schedules[desired.stableKey]?.environments[input.envName]?.remoteHash;
|
|
637
719
|
if (!baselineHash) {
|
|
@@ -822,6 +904,17 @@ export async function pullSchedulesToWorkspace(input) {
|
|
|
822
904
|
previousPath: existing?.manifestPath,
|
|
823
905
|
};
|
|
824
906
|
});
|
|
907
|
+
const sourceStableKeys = new Set(manifests.map((manifest) => manifest.stableKey));
|
|
908
|
+
const pruned = input.pruneOrphans === true
|
|
909
|
+
? [...existingByKey.values()]
|
|
910
|
+
.filter((entry) => !sourceStableKeys.has(entry.manifest.stableKey))
|
|
911
|
+
.map((entry) => ({
|
|
912
|
+
stableKey: entry.manifest.stableKey,
|
|
913
|
+
targetPath: localTargetPath(input.cwd, entry.manifestPath),
|
|
914
|
+
manifestPath: entry.manifestPath,
|
|
915
|
+
}))
|
|
916
|
+
.sort((left, right) => right.manifestPath.length - left.manifestPath.length || left.stableKey.localeCompare(right.stableKey))
|
|
917
|
+
: [];
|
|
825
918
|
const candidatePathCounts = new Map();
|
|
826
919
|
for (const write of writes) {
|
|
827
920
|
const identity = portablePathIdentity(write.filePath);
|
|
@@ -873,11 +966,17 @@ export async function pullSchedulesToWorkspace(input) {
|
|
|
873
966
|
}
|
|
874
967
|
lock.schedules[write.manifest.stableKey] = entry;
|
|
875
968
|
}
|
|
969
|
+
for (const removed of pruned) {
|
|
970
|
+
removeRelocatedManifest(removed.manifestPath, root);
|
|
971
|
+
delete lock.schedules[removed.stableKey];
|
|
972
|
+
lockChanged = true;
|
|
973
|
+
}
|
|
876
974
|
if (lockChanged) {
|
|
877
975
|
writeComponentLock(projectRoot, lock);
|
|
878
976
|
}
|
|
879
977
|
return {
|
|
880
978
|
pulled: writes.map((write) => ({ manifest: write.manifest, targetPath: localTargetPath(input.cwd, write.filePath) })),
|
|
979
|
+
pruned: pruned.map(({ stableKey, targetPath }) => ({ stableKey, targetPath })),
|
|
881
980
|
warnings,
|
|
882
981
|
};
|
|
883
982
|
}
|
|
@@ -950,7 +1049,7 @@ function updateScheduleEnvironmentBaseline(input) {
|
|
|
950
1049
|
function schedulePushError(error) {
|
|
951
1050
|
return error instanceof Error ? error.message : String(error);
|
|
952
1051
|
}
|
|
953
|
-
function assertSchedulesPushable(plan, force
|
|
1052
|
+
function assertSchedulesPushable(plan, force) {
|
|
954
1053
|
if (plan.blockers.length > 0) {
|
|
955
1054
|
throw new Error(`Schedule push blocked: ${plan.blockers.join(' ')}`);
|
|
956
1055
|
}
|
|
@@ -963,11 +1062,6 @@ function assertSchedulesPushable(plan, force, allowMaterialized) {
|
|
|
963
1062
|
const statuses = [...new Set(remoteConflicts.map((item) => item.status))].sort().join(', ');
|
|
964
1063
|
throw new Error(`Schedule push blocked by ${statuses}; review the plan and re-run with --force only to overwrite reviewed remote content drift.`);
|
|
965
1064
|
}
|
|
966
|
-
const materializedWrites = plan.items.filter((item) => (item.databaseViewStableKey
|
|
967
|
-
&& ['create', 'safe-update', 'remote-changed', 'conflict', 'missing-lock'].includes(item.status)));
|
|
968
|
-
if (materializedWrites.length > 0 && !allowMaterialized) {
|
|
969
|
-
throw new Error('Schedule push includes Materialized View refresh definitions; review the plan and re-run with --allow-materialized.');
|
|
970
|
-
}
|
|
971
1065
|
}
|
|
972
1066
|
async function resolveLiveScheduleWriteTarget(input) {
|
|
973
1067
|
const remote = await loadRemoteScheduleInventory(input.client, input.stableKeyName, {
|
|
@@ -1067,7 +1161,7 @@ async function verifyScheduleWrite(input) {
|
|
|
1067
1161
|
}
|
|
1068
1162
|
export async function pushSchedules(input) {
|
|
1069
1163
|
const plan = await buildSchedulesPlan(input);
|
|
1070
|
-
assertSchedulesPushable(plan, input.force === true
|
|
1164
|
+
assertSchedulesPushable(plan, input.force === true);
|
|
1071
1165
|
const localByKey = workspaceSchedulesByStableKey(input.cwd, input.stableKeyName);
|
|
1072
1166
|
const results = [];
|
|
1073
1167
|
const verifiedActivationCandidates = [];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency } from '../utils.ts';
|
|
2
|
+
export { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency };
|
|
1
3
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
4
|
export declare function unwrapData<T>(value: unknown): T;
|
|
3
5
|
export declare function requireProjectLayout(cwd: string, resourceLabel: string): {
|
|
@@ -13,6 +15,7 @@ export declare function writePulledManifest(input: {
|
|
|
13
15
|
previousPath?: string;
|
|
14
16
|
root: string;
|
|
15
17
|
force?: boolean;
|
|
18
|
+
legacyManifestNames?: readonly string[];
|
|
16
19
|
}): void;
|
|
17
20
|
export declare function removeRelocatedManifest(filePath: string, root: string): void;
|
|
18
21
|
export declare function localTargetPath(cwd: string, manifestPath: string): string;
|
|
@@ -2,8 +2,9 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { hashStable } from "../component-lock.js";
|
|
4
4
|
import { resolveProjectRoot, resolveProjectWorkspace } from "../project.js";
|
|
5
|
-
import { sanitizeSegment, writeJsonFile } from "../utils.js";
|
|
5
|
+
import { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency, sanitizeSegment, writeJsonFile } from "../utils.js";
|
|
6
6
|
import { replaceWorkspaceResourceDirectory } from "../workspace-resource.js";
|
|
7
|
+
export { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency };
|
|
7
8
|
export function isRecord(value) {
|
|
8
9
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
9
10
|
}
|
|
@@ -44,7 +45,7 @@ export function writeManifestIfChanged(filePath, manifest) {
|
|
|
44
45
|
}
|
|
45
46
|
// Nested manifests belong to separate resources (notably DB partitions).
|
|
46
47
|
// Preserve those directories until their own pull or explicit prune handles them.
|
|
47
|
-
function copyNestedResourceDirectories(source, target,
|
|
48
|
+
function copyNestedResourceDirectories(source, target, manifestNames) {
|
|
48
49
|
if (!fs.existsSync(source)) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
@@ -54,21 +55,22 @@ function copyNestedResourceDirectories(source, target, manifestName) {
|
|
|
54
55
|
}
|
|
55
56
|
const sourceDirectory = path.join(source, entry.name);
|
|
56
57
|
const targetDirectory = path.join(target, entry.name);
|
|
57
|
-
if (fs.existsSync(path.join(sourceDirectory, manifestName))) {
|
|
58
|
+
if (manifestNames.some((manifestName) => fs.existsSync(path.join(sourceDirectory, manifestName)))) {
|
|
58
59
|
fs.cpSync(sourceDirectory, targetDirectory, { recursive: true, dereference: false });
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
copyNestedResourceDirectories(sourceDirectory, targetDirectory,
|
|
62
|
+
copyNestedResourceDirectories(sourceDirectory, targetDirectory, manifestNames);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
export function writePulledManifest(input) {
|
|
66
67
|
const directory = path.dirname(input.filePath);
|
|
67
68
|
const manifestName = path.basename(input.filePath);
|
|
69
|
+
const manifestNames = [manifestName, ...(input.legacyManifestNames || [])];
|
|
68
70
|
if (input.force) {
|
|
69
71
|
const serialized = `${JSON.stringify(input.manifest, null, 2)}\n`;
|
|
70
72
|
replaceWorkspaceResourceDirectory(input.root, directory, (staged) => {
|
|
71
|
-
copyNestedResourceDirectories(directory, staged,
|
|
73
|
+
copyNestedResourceDirectories(directory, staged, manifestNames);
|
|
72
74
|
fs.writeFileSync(path.join(staged, manifestName), serialized);
|
|
73
75
|
});
|
|
74
76
|
}
|
|
@@ -86,7 +88,7 @@ export function writePulledManifest(input) {
|
|
|
86
88
|
}
|
|
87
89
|
if (input.force) {
|
|
88
90
|
replaceWorkspaceResourceDirectory(input.root, previousDirectory, (staged) => {
|
|
89
|
-
copyNestedResourceDirectories(previousDirectory, staged,
|
|
91
|
+
copyNestedResourceDirectories(previousDirectory, staged, manifestNames);
|
|
90
92
|
});
|
|
91
93
|
removeEmptyResourceParents(previousDirectory, input.root);
|
|
92
94
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RevoClient } from './client.ts';
|
|
2
|
+
import type { CommandContext } from './types.ts';
|
|
3
|
+
export declare function resolveAuthenticatedInstance(client: RevoClient, role: 'source' | 'target'): Promise<string>;
|
|
4
|
+
export declare function resolveResourceTarget(context: CommandContext, options: {
|
|
5
|
+
resource: string;
|
|
6
|
+
allowDefaultProfile?: boolean;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
client: RevoClient;
|
|
9
|
+
envName: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { extractProfileInstanceId, RevoClient } from "./client.js";
|
|
2
|
+
import { DEFAULT_ENV_NAME, resolveRuntimeConfig } from "./config.js";
|
|
3
|
+
import { readFlag } from "./utils.js";
|
|
4
|
+
export async function resolveAuthenticatedInstance(client, role) {
|
|
5
|
+
const configuredInstance = client.instance.trim();
|
|
6
|
+
const session = await client.validateSession({ force: true });
|
|
7
|
+
const authenticatedInstance = extractProfileInstanceId(session.profile).trim();
|
|
8
|
+
if (!authenticatedInstance) {
|
|
9
|
+
throw new Error(`${role === 'source' ? 'Source' : 'Target'} instance could not be resolved from --instance, REVO_INSTANCE, stored configuration, or /api/v1/me.`);
|
|
10
|
+
}
|
|
11
|
+
if (configuredInstance && configuredInstance !== authenticatedInstance) {
|
|
12
|
+
throw new Error(`Configured ${role} instance "${configuredInstance}" does not match authenticated instance "${authenticatedInstance}" returned by /api/v1/me.`);
|
|
13
|
+
}
|
|
14
|
+
client.instance = authenticatedInstance;
|
|
15
|
+
return authenticatedInstance;
|
|
16
|
+
}
|
|
17
|
+
export async function resolveResourceTarget(context, options) {
|
|
18
|
+
const selectedEnvironment = readFlag(context.args, ['env']);
|
|
19
|
+
if (context.args.env !== undefined && !selectedEnvironment) {
|
|
20
|
+
throw new Error('Missing --env <name>.');
|
|
21
|
+
}
|
|
22
|
+
if (selectedEnvironment === DEFAULT_ENV_NAME && context.args.project === DEFAULT_ENV_NAME) {
|
|
23
|
+
const instance = await resolveAuthenticatedInstance(context.client, 'target');
|
|
24
|
+
return {
|
|
25
|
+
client: context.client,
|
|
26
|
+
envName: `instance:${instance}`,
|
|
27
|
+
displayName: context.client.baseUrl,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (selectedEnvironment) {
|
|
31
|
+
if (selectedEnvironment === DEFAULT_ENV_NAME && options.allowDefaultProfile !== true) {
|
|
32
|
+
throw new Error(`${options.resource} sync requires a named environment profile; "default" is not supported.`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
client: context.componentEnvironment === selectedEnvironment
|
|
36
|
+
? context.client
|
|
37
|
+
: new RevoClient({ ...resolveRuntimeConfig({ envName: selectedEnvironment }), environmentName: selectedEnvironment }),
|
|
38
|
+
envName: selectedEnvironment,
|
|
39
|
+
displayName: selectedEnvironment,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const instance = await resolveAuthenticatedInstance(context.client, 'target');
|
|
43
|
+
return {
|
|
44
|
+
client: context.client,
|
|
45
|
+
envName: `instance:${instance}`,
|
|
46
|
+
displayName: context.client.baseUrl,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CommandContext } from './types.ts';
|
|
2
|
+
import type { FieldChange } from './diff-details.ts';
|
|
3
|
+
import type { WorkspaceDiff } from './workspace-diff.ts';
|
|
2
4
|
export type WorkspaceSyncStatus = 'pulled' | 'pruned' | 'deployed' | 'skipped' | 'failed' | 'write-unverified';
|
|
3
5
|
export type WorkspaceSyncResult = {
|
|
4
6
|
status: WorkspaceSyncStatus;
|
|
@@ -8,8 +10,22 @@ export type WorkspaceSyncResult = {
|
|
|
8
10
|
export type SyncOutputStatus = 'Pulled' | 'Pruned' | 'Skipped' | 'Deployed' | 'Activated' | 'Deactivated' | 'Failed' | 'Unverified';
|
|
9
11
|
export type SyncPlanDetail = {
|
|
10
12
|
label: string;
|
|
11
|
-
values
|
|
13
|
+
values?: string | ReadonlyArray<string>;
|
|
14
|
+
diffs?: ReadonlyArray<{
|
|
15
|
+
field: string;
|
|
16
|
+
risk?: string;
|
|
17
|
+
before: string;
|
|
18
|
+
after: string;
|
|
19
|
+
}>;
|
|
20
|
+
lines?: ReadonlyArray<string>;
|
|
12
21
|
};
|
|
22
|
+
export declare function planValueChanges(changes: ReadonlyArray<{
|
|
23
|
+
field: string;
|
|
24
|
+
risk?: string;
|
|
25
|
+
before?: unknown;
|
|
26
|
+
after?: unknown;
|
|
27
|
+
}>): SyncPlanDetail[];
|
|
28
|
+
export declare function planListChanges(label: string, removed?: ReadonlyArray<string>, added?: ReadonlyArray<string>): SyncPlanDetail[];
|
|
13
29
|
export type SyncPlanItem = {
|
|
14
30
|
status: string;
|
|
15
31
|
stableKey?: string;
|
|
@@ -17,17 +33,29 @@ export type SyncPlanItem = {
|
|
|
17
33
|
target?: string;
|
|
18
34
|
reason?: string;
|
|
19
35
|
changedFields?: ReadonlyArray<string>;
|
|
36
|
+
fieldChanges?: ReadonlyArray<FieldChange>;
|
|
20
37
|
details?: ReadonlyArray<SyncPlanDetail>;
|
|
38
|
+
hints?: ReadonlyArray<SyncPlanDetail>;
|
|
21
39
|
};
|
|
40
|
+
export declare function planDependencyHints(dependency: {
|
|
41
|
+
resource: string;
|
|
42
|
+
stableKey: string;
|
|
43
|
+
readiness: string;
|
|
44
|
+
expectedHash: string | null;
|
|
45
|
+
projectedHash: string | null;
|
|
46
|
+
actualHash: string | null;
|
|
47
|
+
}): SyncPlanDetail[];
|
|
22
48
|
export type SyncPlanOutput = {
|
|
23
49
|
title: string;
|
|
24
50
|
environment: string;
|
|
25
51
|
counts: Readonly<Record<string, number>>;
|
|
26
52
|
items: ReadonlyArray<SyncPlanItem>;
|
|
53
|
+
showHints?: boolean;
|
|
27
54
|
warnings?: ReadonlyArray<string>;
|
|
28
55
|
blockers?: ReadonlyArray<string>;
|
|
29
56
|
};
|
|
30
57
|
export declare function printSyncPlan(println: CommandContext['println'], input: SyncPlanOutput): void;
|
|
58
|
+
export declare function printWorkspaceDiff(println: CommandContext['println'], diff: WorkspaceDiff): void;
|
|
31
59
|
export declare function printSyncStatus(println: CommandContext['println'], input: {
|
|
32
60
|
status: SyncOutputStatus;
|
|
33
61
|
direction: 'pull' | 'push';
|