@revoengine/cli 1.0.31 → 1.0.34
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/CHANGELOG.md +25 -0
- package/README.md +152 -24
- package/dist/src/argument-contract.d.ts +17 -0
- package/dist/src/argument-contract.js +359 -0
- package/dist/src/automation-contract.generated.d.ts +56 -22
- package/dist/src/automation-contract.generated.js +68 -26
- package/dist/src/cli.js +15 -13
- package/dist/src/client.d.ts +34 -2
- package/dist/src/client.js +76 -13
- package/dist/src/commands/agents.js +5 -1
- package/dist/src/commands/auth.js +2 -0
- package/dist/src/commands/component.js +34 -17
- package/dist/src/commands/database-tables.js +15 -4
- package/dist/src/commands/database-views.js +5 -1
- package/dist/src/commands/endpoints.js +5 -1
- package/dist/src/commands/env.js +5 -1
- package/dist/src/commands/events.js +5 -1
- package/dist/src/commands/groups.js +5 -1
- package/dist/src/commands/info.js +2 -0
- package/dist/src/commands/job-templates.js +5 -1
- package/dist/src/commands/metadata.js +2 -0
- package/dist/src/commands/migrate.d.ts +2 -2
- package/dist/src/commands/migrate.js +33 -7
- package/dist/src/commands/project.js +19 -14
- package/dist/src/commands/request.js +2 -0
- package/dist/src/commands/role-groups.js +5 -1
- package/dist/src/commands/schedules.js +5 -1
- package/dist/src/commands/search.js +2 -0
- package/dist/src/commands/service-accounts.js +5 -1
- package/dist/src/commands/studio.js +2 -0
- package/dist/src/commands/terminal-browser-central-profile.d.ts +65 -0
- package/dist/src/commands/terminal-browser-central-profile.js +203 -0
- package/dist/src/commands/terminal-browser-human-input.d.ts +3 -1
- package/dist/src/commands/terminal-browser-human-input.js +3 -1
- package/dist/src/commands/terminal-browser-interaction.js +1 -1
- package/dist/src/commands/terminal-browser-live-protocol.d.ts +34 -2
- package/dist/src/commands/terminal-browser-live-protocol.js +28 -12
- package/dist/src/commands/terminal-browser-live-transport.d.ts +1 -0
- package/dist/src/commands/terminal-browser-live-transport.js +9 -5
- package/dist/src/commands/terminal-browser-live.d.ts +24 -3
- package/dist/src/commands/terminal-browser-live.js +199 -30
- package/dist/src/commands/terminal-browser-page-input.d.ts +4 -1
- package/dist/src/commands/terminal-browser-page-input.js +46 -1
- package/dist/src/commands/terminal-browser-profile-crypto.d.ts +30 -0
- package/dist/src/commands/terminal-browser-profile-crypto.js +101 -0
- package/dist/src/commands/terminal-browser-profile-import-runner.d.ts +31 -0
- package/dist/src/commands/terminal-browser-profile-import-runner.js +112 -0
- package/dist/src/commands/terminal-browser-profile-import.d.ts +28 -0
- package/dist/src/commands/terminal-browser-profile-import.js +125 -0
- package/dist/src/commands/terminal-browser-profile-import.protocol.d.ts +50 -0
- package/dist/src/commands/terminal-browser-profile-import.protocol.js +52 -0
- package/dist/src/commands/terminal-browser-profile-preferences.d.ts +1 -0
- package/dist/src/commands/terminal-browser-profile-preferences.js +16 -0
- package/dist/src/commands/terminal-browser-profile-sync.d.ts +14 -0
- package/dist/src/commands/terminal-browser-profile-sync.js +169 -0
- package/dist/src/commands/terminal-browser-profile-sync.protocol.d.ts +50 -0
- package/dist/src/commands/terminal-browser-profile-sync.protocol.js +19 -0
- package/dist/src/commands/terminal-browser-profile.d.ts +10 -1
- package/dist/src/commands/terminal-browser-profile.js +30 -4
- package/dist/src/commands/terminal-browser-recording.d.ts +39 -0
- package/dist/src/commands/terminal-browser-recording.js +74 -0
- package/dist/src/commands/terminal-browser-recording.protocol.d.ts +49 -0
- package/dist/src/commands/terminal-browser-recording.protocol.js +16 -0
- package/dist/src/commands/terminal-browser.d.ts +14 -1
- package/dist/src/commands/terminal-browser.js +98 -33
- package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
- package/dist/src/commands/terminal-file-descriptor.js +39 -0
- package/dist/src/commands/terminal-file.js +41 -6
- package/dist/src/commands/terminal-image.js +3 -31
- package/dist/src/commands/terminal-output-buffer.d.ts +18 -1
- package/dist/src/commands/terminal-output-buffer.js +95 -8
- package/dist/src/commands/terminal-process-group.d.ts +25 -0
- package/dist/src/commands/terminal-process-group.js +144 -0
- package/dist/src/commands/terminal.d.ts +3 -1
- package/dist/src/commands/terminal.js +366 -80
- package/dist/src/commands/tests.js +2 -0
- package/dist/src/component-lock.d.ts +15 -1
- package/dist/src/component-lock.js +96 -10
- package/dist/src/env-sync.js +12 -6
- package/dist/src/migration.d.ts +7 -0
- package/dist/src/migration.js +39 -21
- package/dist/src/planning-snapshot.d.ts +3 -0
- package/dist/src/planning-snapshot.js +60 -2
- package/dist/src/project.d.ts +1 -0
- package/dist/src/project.js +7 -8
- package/dist/src/resource-syncs/agent-sync.js +76 -24
- package/dist/src/resource-syncs/database-table-sync.d.ts +8 -1
- package/dist/src/resource-syncs/database-table-sync.js +66 -32
- package/dist/src/resource-syncs/database-view-sync.js +41 -28
- package/dist/src/resource-syncs/endpoint-sync.js +90 -18
- package/dist/src/resource-syncs/event-sync.js +33 -14
- package/dist/src/resource-syncs/group-sync.js +21 -11
- package/dist/src/resource-syncs/job-template-sync.js +98 -37
- package/dist/src/resource-syncs/role-group-sync.js +22 -11
- package/dist/src/resource-syncs/schedule-sync.js +26 -11
- package/dist/src/resource-syncs/service-account-sync.js +22 -11
- package/dist/src/reviewed-plan.js +3 -0
- package/dist/src/runtime-view.js +2 -18
- package/dist/src/sync-omit-command.d.ts +6 -0
- package/dist/src/sync-omit-command.js +49 -0
- package/dist/src/sync-omit-write-fence.d.ts +10 -0
- package/dist/src/sync-omit-write-fence.js +134 -0
- package/dist/src/sync-omit.d.ts +59 -0
- package/dist/src/sync-omit.js +469 -0
- package/dist/src/sync-output.d.ts +3 -3
- package/dist/src/ui.js +11 -5
- package/dist/src/update-notifier.d.ts +1 -1
- package/dist/src/update-notifier.js +2 -1
- package/dist/src/utils.js +46 -17
- package/dist/src/workspace-prune.js +11 -3
- package/dist/src/workspace-write-lock.d.ts +7 -0
- package/dist/src/workspace-write-lock.js +144 -0
- package/package.json +6 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { describeFieldChanges } from "../diff-details.js";
|
|
3
4
|
import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
@@ -143,11 +144,14 @@ function eventHashShape(manifest, extensions) {
|
|
|
143
144
|
function unsupportedEventExtensions(manifest) {
|
|
144
145
|
return Object.fromEntries(Object.entries(manifest.extensions || {}).filter(([field]) => !AUTOMATION_INPUT_FIELDS.has(field)));
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
return
|
|
147
|
+
function eventContentShape(manifest) {
|
|
148
|
+
return {
|
|
148
149
|
...eventHashShape(manifest, unsupportedEventExtensions(manifest)),
|
|
149
150
|
...automationInputHashFields(manifest, true),
|
|
150
|
-
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export function hashEventContent(manifest) {
|
|
154
|
+
return hashSyncDefinition('event', eventContentShape(manifest));
|
|
151
155
|
}
|
|
152
156
|
/** Recognize an old lock representation without discarding any live non-default input. */
|
|
153
157
|
function legacyEventBaselineHash(manifest, layout) {
|
|
@@ -164,10 +168,10 @@ function legacyEventBaselineHash(manifest, layout) {
|
|
|
164
168
|
return hashStable({ content: hashStable(eventHashShape(manifest, extensions)), active: manifest.active });
|
|
165
169
|
}
|
|
166
170
|
export function hashPortableEvent(manifest) {
|
|
167
|
-
return hashStable({ content:
|
|
171
|
+
return hashSyncDefinition('event', { ...eventContentShape(manifest), active: manifest.active }, hashStable({ content: hashStable(eventContentShape(manifest)), active: manifest.active }));
|
|
168
172
|
}
|
|
169
173
|
export function hashEventManifest(manifest) {
|
|
170
|
-
return
|
|
174
|
+
return hashSyncDefinition('event', canonicalValue(manifest));
|
|
171
175
|
}
|
|
172
176
|
async function hydrate(records, idOf, get) {
|
|
173
177
|
return mapWithConcurrency(records, async (record) => {
|
|
@@ -219,6 +223,7 @@ function emptyPlanCounts() {
|
|
|
219
223
|
};
|
|
220
224
|
}
|
|
221
225
|
function diffEvents(desired, current) {
|
|
226
|
+
desired = preserveOmittedProperties('event', desired, current);
|
|
222
227
|
const desiredInput = readAutomationInput(desired, true);
|
|
223
228
|
const currentInput = readAutomationInput(current, true);
|
|
224
229
|
const fields = [
|
|
@@ -360,7 +365,10 @@ export async function buildEventsPlan(input) {
|
|
|
360
365
|
if (localEvents.length !== 1) {
|
|
361
366
|
continue;
|
|
362
367
|
}
|
|
363
|
-
const
|
|
368
|
+
const matchingTargets = targetsByStableKey.get(stableKey) || [];
|
|
369
|
+
const desired = matchingTargets.length === 1
|
|
370
|
+
? preserveOmittedProperties('event', localEvents[0].manifest, matchingTargets[0].manifest)
|
|
371
|
+
: localEvents[0].manifest;
|
|
364
372
|
const dependencyStableKey = desired.target.jobTemplateStableKey;
|
|
365
373
|
const liveTemplates = templatesByStableKey.get(dependencyStableKey) || [];
|
|
366
374
|
const usesProjection = projectedJobTemplatesByKey !== undefined;
|
|
@@ -443,7 +451,7 @@ export async function buildEventsPlan(input) {
|
|
|
443
451
|
const current = targets[0];
|
|
444
452
|
const fieldChanges = describeFieldChanges({ ...desired, ...readAutomationInput(desired, true) }, current.manifest, diffEvents(desired, current.manifest));
|
|
445
453
|
const currentHash = current.hash;
|
|
446
|
-
const baselineHash = lock.events[stableKey]?.environments[input.envName]
|
|
454
|
+
const baselineHash = syncBaselineHash('event', lock.events[stableKey]?.environments[input.envName]);
|
|
447
455
|
const currentContentHash = current.contentHash;
|
|
448
456
|
const desiredContentHash = hashEventContent(desired);
|
|
449
457
|
if (desiredContentHash === currentContentHash && desired.active !== current.manifest.active) {
|
|
@@ -561,7 +569,7 @@ function updateEventEnvironmentBaseline(input) {
|
|
|
561
569
|
lock.events[stableKey] = {
|
|
562
570
|
stableKey,
|
|
563
571
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
564
|
-
sourceHash: hashEventManifest(input.manifest),
|
|
572
|
+
sourceHash: withoutSyncOmit(() => hashEventManifest(input.manifest)),
|
|
565
573
|
environments: {
|
|
566
574
|
...(existing?.environments || {}),
|
|
567
575
|
[input.envName]: previousBaseline?.remoteHash === input.remoteHash
|
|
@@ -638,6 +646,7 @@ async function resolveLiveEventWriteTarget(input) {
|
|
|
638
646
|
event,
|
|
639
647
|
eventId,
|
|
640
648
|
currentHash: hashPortableEvent(currentManifest),
|
|
649
|
+
currentManifest,
|
|
641
650
|
active: currentManifest.active,
|
|
642
651
|
};
|
|
643
652
|
}
|
|
@@ -669,6 +678,10 @@ async function verifyEventWrite(input) {
|
|
|
669
678
|
if (verifiedManifest.active !== input.expectedActive) {
|
|
670
679
|
throw new Error('written Event did not preserve the expected target activation state');
|
|
671
680
|
}
|
|
681
|
+
if (input.verifyFullSource && !withoutSyncOmit(() => hashEventContent(verifiedManifest) === hashEventContent(input.manifest)))
|
|
682
|
+
throw new Error('Created Event did not initialize the complete source definition.');
|
|
683
|
+
if (input.preservedTargetManifest)
|
|
684
|
+
assertOmittedPropertiesPreserved('event', input.preservedTargetManifest, verifiedManifest);
|
|
672
685
|
return hashPortableEvent(verifiedManifest);
|
|
673
686
|
}
|
|
674
687
|
export async function pushEvents(input) {
|
|
@@ -734,7 +747,7 @@ export async function pushEvents(input) {
|
|
|
734
747
|
if (live.currentHash !== item.currentHash) {
|
|
735
748
|
throw new Error('target Event changed after planning');
|
|
736
749
|
}
|
|
737
|
-
await input.client.updateEvent(live.eventId, buildEventUpdatePayload(local.manifest, live.jobTemplateId, live.event.version));
|
|
750
|
+
await input.client.updateEvent(live.eventId, buildEventUpdatePayload(preserveOmittedProperties('event', local.manifest, live.currentManifest), live.jobTemplateId, live.event.version));
|
|
738
751
|
eventId = live.eventId;
|
|
739
752
|
expectedActive = live.active;
|
|
740
753
|
}
|
|
@@ -746,6 +759,8 @@ export async function pushEvents(input) {
|
|
|
746
759
|
jobTemplateId: live.jobTemplateId,
|
|
747
760
|
expectedActive,
|
|
748
761
|
jobTemplatesById: liveInventory?.jobTemplatesById,
|
|
762
|
+
preservedTargetManifest: action === 'update' ? live.currentManifest : undefined,
|
|
763
|
+
verifyFullSource: action === 'create',
|
|
749
764
|
});
|
|
750
765
|
updateEventEnvironmentBaseline({
|
|
751
766
|
cwd: input.cwd,
|
|
@@ -894,6 +909,8 @@ export async function activateVerifiedEvents(input) {
|
|
|
894
909
|
jobTemplateId: String(current.targetId || ''),
|
|
895
910
|
expectedActive: candidate.manifest.active,
|
|
896
911
|
jobTemplatesById: jobTemplatesCache,
|
|
912
|
+
preservedTargetManifest: manifestFromRecord({ record: current, stableKey: candidate.stableKey,
|
|
913
|
+
jobTemplateStableKey: candidate.manifest.target.jobTemplateStableKey, stableKeyName: candidate.stableKeyName }),
|
|
897
914
|
});
|
|
898
915
|
updateEventEnvironmentBaseline({
|
|
899
916
|
cwd: candidate.cwd,
|
|
@@ -980,14 +997,16 @@ export async function pullEventsToWorkspace(input) {
|
|
|
980
997
|
const pathIdentity = portablePathIdentity(entry.manifestPath);
|
|
981
998
|
existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), localEntry]);
|
|
982
999
|
}
|
|
983
|
-
const writes = manifests.map((
|
|
984
|
-
const
|
|
985
|
-
const remoteHash = hashPortableEvent(
|
|
986
|
-
const existing = existingByKey.get(
|
|
1000
|
+
const writes = manifests.map((incoming) => {
|
|
1001
|
+
const incomingHash = hashEventManifest(incoming);
|
|
1002
|
+
const remoteHash = hashPortableEvent(incoming);
|
|
1003
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
1004
|
+
const manifest = existing ? preserveOmittedProperties('event', incoming, existing.manifest) : incoming;
|
|
1005
|
+
const sourceHash = withoutSyncOmit(() => hashEventManifest(manifest));
|
|
987
1006
|
if (existing && !input.force) {
|
|
988
1007
|
const localHash = hashEventManifest(existing.manifest);
|
|
989
1008
|
const baseline = lock.events[manifest.stableKey];
|
|
990
|
-
if (localHash !==
|
|
1009
|
+
if (localHash !== incomingHash && (!baseline || localHash !== syncSourceBaselineHash('event', baseline))) {
|
|
991
1010
|
throw new Error(`Cannot pull Event "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force to overwrite.`);
|
|
992
1011
|
}
|
|
993
1012
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { accountPrincipal, serviceAccountMatches, ownerIsAvailable } from "./account-principal.js";
|
|
3
4
|
import { ownerFromPrincipal, resolveSystemAccount } from "./account-principal.js";
|
|
@@ -65,13 +66,14 @@ export function groupManifestFromRecord(record, stableKeyName) {
|
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
export function hashPortableGroup(manifest) {
|
|
68
|
-
return
|
|
69
|
+
return hashSyncDefinition('group', {
|
|
69
70
|
...manifest,
|
|
70
71
|
category: manifest.category ?? null,
|
|
71
72
|
description: manifest.description ?? '',
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
function diffGroups(desired, target) {
|
|
76
|
+
desired = preserveOmittedProperties('group', desired, target);
|
|
75
77
|
return ['name', 'category', 'description', 'metadata', 'owner']
|
|
76
78
|
.filter((field) => {
|
|
77
79
|
const desiredValue = field === 'category'
|
|
@@ -327,9 +329,11 @@ export async function buildGroupsPlan(input) {
|
|
|
327
329
|
items.push({ status: 'collision', stableKey, name: desired.name, reason: 'duplicate desired stableKey' });
|
|
328
330
|
continue;
|
|
329
331
|
}
|
|
330
|
-
const
|
|
332
|
+
const matches = remoteByKey.get(entries[0].manifest.stableKey) || [];
|
|
333
|
+
const desired = matches.length === 1
|
|
334
|
+
? preserveOmittedProperties('group', entries[0].manifest, matches[0].manifest)
|
|
335
|
+
: entries[0].manifest;
|
|
331
336
|
const desiredHash = hashPortableGroup(desired);
|
|
332
|
-
const matches = remoteByKey.get(desired.stableKey) || [];
|
|
333
337
|
if (matches.length > 1) {
|
|
334
338
|
blockers.push(`Duplicate target Group stableKey "${desired.stableKey}".`);
|
|
335
339
|
consumedRemoteKeys.add(desired.stableKey);
|
|
@@ -503,7 +507,7 @@ export async function buildGroupsPlan(input) {
|
|
|
503
507
|
items.push({ status: 'safe-update', ...common, reason: 'target GROUP owner differs from source owner Stable Key' });
|
|
504
508
|
continue;
|
|
505
509
|
}
|
|
506
|
-
const baselineHash = lockEntry?.environments[input.envName]
|
|
510
|
+
const baselineHash = syncBaselineHash('group', lockEntry?.environments[input.envName]);
|
|
507
511
|
if (!baselineHash) {
|
|
508
512
|
items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
|
|
509
513
|
}
|
|
@@ -647,13 +651,15 @@ export async function pullGroupsToWorkspace(input) {
|
|
|
647
651
|
const writes = [];
|
|
648
652
|
const outputPaths = new Set();
|
|
649
653
|
for (const managedGroup of managed) {
|
|
650
|
-
const { manifest, owner } = managedGroup;
|
|
651
|
-
const hash = hashPortableGroup(
|
|
652
|
-
const existing = existingByStableKey.get(
|
|
654
|
+
const { manifest: incoming, owner } = managedGroup;
|
|
655
|
+
const hash = hashPortableGroup(incoming);
|
|
656
|
+
const existing = existingByStableKey.get(incoming.stableKey);
|
|
657
|
+
const manifest = existing ? preserveOmittedProperties('group', incoming, existing.manifest) : incoming;
|
|
658
|
+
const sourceHash = withoutSyncOmit(() => hashPortableGroup(manifest));
|
|
653
659
|
if (existing && !input.force) {
|
|
654
660
|
const localHash = hashPortableGroup(existing.manifest);
|
|
655
661
|
const lockEntry = lock.groups[manifest.stableKey];
|
|
656
|
-
if (localHash !== hash && (!lockEntry || localHash !== lockEntry
|
|
662
|
+
if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('group', lockEntry))) {
|
|
657
663
|
throw new Error(`Cannot pull Group "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
658
664
|
}
|
|
659
665
|
}
|
|
@@ -673,6 +679,7 @@ export async function pullGroupsToWorkspace(input) {
|
|
|
673
679
|
...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
|
|
674
680
|
manifest,
|
|
675
681
|
hash,
|
|
682
|
+
sourceHash,
|
|
676
683
|
owner,
|
|
677
684
|
});
|
|
678
685
|
}
|
|
@@ -703,7 +710,7 @@ export async function pullGroupsToWorkspace(input) {
|
|
|
703
710
|
const entry = {
|
|
704
711
|
stableKey: write.manifest.stableKey,
|
|
705
712
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
706
|
-
sourceHash: write.
|
|
713
|
+
sourceHash: write.sourceHash,
|
|
707
714
|
owner: write.owner,
|
|
708
715
|
environments: {
|
|
709
716
|
...(previous?.environments || {}),
|
|
@@ -777,7 +784,7 @@ function updateEnvironmentBaseline(input) {
|
|
|
777
784
|
const nextEntry = {
|
|
778
785
|
stableKey: local.manifest.stableKey,
|
|
779
786
|
path: toPortableRelativePath(projectRoot, local.manifestPath),
|
|
780
|
-
sourceHash: hashPortableGroup(local.manifest),
|
|
787
|
+
sourceHash: withoutSyncOmit(() => hashPortableGroup(local.manifest)),
|
|
781
788
|
...(entry?.owner ? { owner: entry.owner } : {}),
|
|
782
789
|
environments: {
|
|
783
790
|
...(entry?.environments || {}),
|
|
@@ -909,6 +916,8 @@ export async function pushGroups(input) {
|
|
|
909
916
|
if (!verifiedManifest || hashPortableGroup(verifiedManifest) !== liveDesiredHash) {
|
|
910
917
|
throw new Error('created Group did not match desired portable hash');
|
|
911
918
|
}
|
|
919
|
+
if (!withoutSyncOmit(() => hashPortableGroup(verifiedManifest) === hashPortableGroup(local.manifest)))
|
|
920
|
+
throw new Error('Created resource did not initialize the complete source definition.');
|
|
912
921
|
if (String(verified.ownerType || '').toUpperCase() !== (item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP') || verified.ownerId !== ownerId) {
|
|
913
922
|
throw new Error('created Group did not retain the resolved target owner');
|
|
914
923
|
}
|
|
@@ -978,7 +987,7 @@ export async function pushGroups(input) {
|
|
|
978
987
|
throw new Error('live target owner Group did not include groupId');
|
|
979
988
|
}
|
|
980
989
|
}
|
|
981
|
-
await input.client.updateGroup(targetId, buildUpdatePayload(local.manifest, target, desiredOwnerId, item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP'));
|
|
990
|
+
await input.client.updateGroup(targetId, buildUpdatePayload(preserveOmittedProperties('group', local.manifest, targetManifest), target, desiredOwnerId, item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP'));
|
|
982
991
|
const verified = unwrapData(await input.client.getGroup(targetId));
|
|
983
992
|
const verifiedManifest = groupManifestFromRecord(verified, input.stableKeyName);
|
|
984
993
|
if (verifiedManifest && local.manifest.owner && verified.ownerType === 'USER' && verified.ownerId) {
|
|
@@ -990,6 +999,7 @@ export async function pushGroups(input) {
|
|
|
990
999
|
if (!verifiedManifest || hashPortableGroup(verifiedManifest) !== liveDesiredHash) {
|
|
991
1000
|
throw new Error('updated Group did not match desired portable hash');
|
|
992
1001
|
}
|
|
1002
|
+
assertOmittedPropertiesPreserved('group', targetManifest, verifiedManifest);
|
|
993
1003
|
if (desiredOwnerId && (String(verified.ownerType || '').toUpperCase() !== (item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP')
|
|
994
1004
|
|| verified.ownerId !== desiredOwnerId)) {
|
|
995
1005
|
throw new Error('updated Group did not retain the resolved target owner');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, projectSyncDefinition, omitPaths } from "../sync-omit.js";
|
|
1
2
|
import { loadComponentSources } from "../component-manifests.js";
|
|
2
3
|
import { componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
|
|
3
4
|
import path from 'node:path';
|
|
@@ -36,8 +37,9 @@ function canonicalJobTemplateOptions(value, inputs, normalizeDefaults = true) {
|
|
|
36
37
|
// definition: missing memory follows input overlays, then the isolate default.
|
|
37
38
|
const canonicalInputs = canonicalJobTemplateInputs(inputs);
|
|
38
39
|
const inputIsEmpty = isRecord(normalized.input) && Object.keys(normalized.input).length === 0;
|
|
40
|
+
const comparable = projectSyncDefinition('job-template', { options: normalized, inputs: canonicalInputs });
|
|
39
41
|
const inputDuplicatesLegacyInputs = inputs !== undefined
|
|
40
|
-
&& JSON.stringify(
|
|
42
|
+
&& JSON.stringify(comparable.options?.input) === JSON.stringify(comparable.inputs);
|
|
41
43
|
if ((inputIsEmpty && (canonicalInputs === undefined || (isRecord(canonicalInputs) && Object.keys(canonicalInputs).length === 0))) || inputDuplicatesLegacyInputs)
|
|
42
44
|
delete normalized.input;
|
|
43
45
|
return Object.keys(normalized).length === 0 ? undefined : normalized;
|
|
@@ -244,14 +246,53 @@ function buildUpdatePayload(manifest, componentId, version) {
|
|
|
244
246
|
version,
|
|
245
247
|
};
|
|
246
248
|
}
|
|
249
|
+
/** Predict the API's option materialization before a write can change an ignored legacy field. */
|
|
250
|
+
function assertJobTemplateOmitWriteSafe(target, desired, payload) {
|
|
251
|
+
if (!omitPaths('job-template').some(parts => ['options', 'inputs'].includes(parts[0])))
|
|
252
|
+
return;
|
|
253
|
+
if (!Object.hasOwn(payload, 'options') && !Object.hasOwn(payload, 'inputs'))
|
|
254
|
+
return;
|
|
255
|
+
const options = isRecord(payload.options) ? structuredClone(payload.options) : {};
|
|
256
|
+
if (options.input === null)
|
|
257
|
+
options.input = {};
|
|
258
|
+
if (!Object.hasOwn(options, 'input') && Object.hasOwn(payload, 'inputs'))
|
|
259
|
+
options.input = payload.inputs ?? {};
|
|
260
|
+
const concurrency = isRecord(options.concurrency) ? { ...options.concurrency } : {};
|
|
261
|
+
for (const field of ['key', 'limit', 'ttl'])
|
|
262
|
+
if (!concurrency[field])
|
|
263
|
+
concurrency[field] = null;
|
|
264
|
+
options.concurrency = concurrency;
|
|
265
|
+
const rawRetry = isRecord(options.retry) ? options.retry : {};
|
|
266
|
+
const retry = { ...requestContractDefaults.retry, ...rawRetry };
|
|
267
|
+
retry.enabled = retry.enabled === true;
|
|
268
|
+
retry.bypassConcurrencyOnRetry = retry.bypassConcurrencyOnRetry === true;
|
|
269
|
+
retry.maxAttempts = Object.hasOwn(rawRetry, 'maxAttempts') ? rawRetry.maxAttempts ?? (rawRetry.maxAttempts === null ? null : requestContractDefaults.retry.maxAttempts) : requestContractDefaults.retry.maxAttempts;
|
|
270
|
+
for (const field of ['minBackoffSeconds', 'maxBackoffSeconds', 'maxDoublings'])
|
|
271
|
+
retry[field] = Math.trunc(Number(retry[field]));
|
|
272
|
+
options.retry = retry;
|
|
273
|
+
const predicted = { ...desired, options, ...(Object.hasOwn(payload, 'inputs') ? { inputs: payload.inputs ?? {} } : {}) };
|
|
274
|
+
try {
|
|
275
|
+
assertOmittedPropertiesPreserved('job-template', target, predicted);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
throw new Error('Job Template options cannot be updated without normalizing an omitted property; align target defaults or omit the complete options envelope.');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
247
281
|
export function hashPortableJobTemplate(manifest) {
|
|
248
282
|
return jobTemplateDefinitionHash(manifest, true);
|
|
249
283
|
}
|
|
250
284
|
function jobTemplateDefinitionHash(manifest, normalizeDefaults) {
|
|
285
|
+
const shape = jobTemplateDefinitionShape(manifest, normalizeDefaults);
|
|
286
|
+
const rawHash = omitPaths('job-template').length > 0
|
|
287
|
+
? withoutSyncOmit(() => hashStable(jobTemplateDefinitionShape(manifest, normalizeDefaults)))
|
|
288
|
+
: hashStable(shape);
|
|
289
|
+
return hashSyncDefinition('job-template', shape, rawHash);
|
|
290
|
+
}
|
|
291
|
+
function jobTemplateDefinitionShape(manifest, normalizeDefaults) {
|
|
251
292
|
const options = canonicalJobTemplateOptions(manifest.options, manifest.inputs, normalizeDefaults);
|
|
252
293
|
const rawInputs = canonicalJobTemplateInputs(manifest.inputs);
|
|
253
294
|
const inputs = normalizeDefaults && isRecord(rawInputs) && Object.keys(rawInputs).length === 0 ? undefined : rawInputs;
|
|
254
|
-
return
|
|
295
|
+
return {
|
|
255
296
|
kind: 'job-template',
|
|
256
297
|
stableKey: manifest.stableKey,
|
|
257
298
|
name: manifest.name,
|
|
@@ -265,9 +306,10 @@ function jobTemplateDefinitionHash(manifest, normalizeDefaults) {
|
|
|
265
306
|
: manifest.timeout === undefined ? {} : { timeout: manifest.timeout }),
|
|
266
307
|
...(options === undefined ? {} : { options }),
|
|
267
308
|
...(inputs === undefined ? {} : { inputs }),
|
|
268
|
-
}
|
|
309
|
+
};
|
|
269
310
|
}
|
|
270
311
|
function diffJobTemplates(desired, target) {
|
|
312
|
+
desired = preserveOmittedProperties('job-template', desired, target);
|
|
271
313
|
const fields = [
|
|
272
314
|
['name', desired.name, target.name],
|
|
273
315
|
['category', desired.category ?? null, target.category ?? null],
|
|
@@ -362,25 +404,6 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
362
404
|
matches.push(record);
|
|
363
405
|
targetRecordsByName.set(record.name, matches);
|
|
364
406
|
}
|
|
365
|
-
const nameCollisionKeys = new Set();
|
|
366
|
-
const localNames = new Map();
|
|
367
|
-
for (const [stableKey, entries] of localByKey) {
|
|
368
|
-
const desired = entries[0].manifest;
|
|
369
|
-
const previous = localNames.get(desired.name);
|
|
370
|
-
if (previous && previous !== stableKey) {
|
|
371
|
-
blockers.push(`Duplicate local job-template name "${desired.name}" for "${previous}" and "${stableKey}".`);
|
|
372
|
-
nameCollisionKeys.add(previous);
|
|
373
|
-
nameCollisionKeys.add(stableKey);
|
|
374
|
-
}
|
|
375
|
-
localNames.set(desired.name, stableKey);
|
|
376
|
-
for (const record of targetRecordsByName.get(desired.name) || []) {
|
|
377
|
-
if (readConfiguredResourceMetadataStableKey(record, input.stableKeyName) === stableKey
|
|
378
|
-
|| input.pruneBeforeUpsertIds?.includes(jobTemplateIdOf(record)))
|
|
379
|
-
continue;
|
|
380
|
-
blockers.push(`Job-template name "${desired.name}" is already used by target "${jobTemplateIdOf(record)}" with a different or missing Stable Key; review its identity or an explicit workspace prune.`);
|
|
381
|
-
nameCollisionKeys.add(stableKey);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
407
|
for (const record of targetRecords) {
|
|
385
408
|
const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
|
|
386
409
|
if (!stableKey) {
|
|
@@ -431,6 +454,28 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
431
454
|
pinned: (typeof record.componentVersion === 'number' && !record.componentDigest),
|
|
432
455
|
}]);
|
|
433
456
|
}
|
|
457
|
+
const nameCollisionKeys = new Set();
|
|
458
|
+
const localNames = new Map();
|
|
459
|
+
for (const [stableKey, entries] of localByKey) {
|
|
460
|
+
const matches = targetByKey.get(stableKey) || [];
|
|
461
|
+
const desired = matches.length === 1
|
|
462
|
+
? preserveOmittedProperties('job-template', entries[0].manifest, matches[0].manifest)
|
|
463
|
+
: entries[0].manifest;
|
|
464
|
+
const previous = localNames.get(desired.name);
|
|
465
|
+
if (previous && previous !== stableKey) {
|
|
466
|
+
blockers.push(`Duplicate local job-template name "${desired.name}" for "${previous}" and "${stableKey}".`);
|
|
467
|
+
nameCollisionKeys.add(previous);
|
|
468
|
+
nameCollisionKeys.add(stableKey);
|
|
469
|
+
}
|
|
470
|
+
localNames.set(desired.name, stableKey);
|
|
471
|
+
for (const record of targetRecordsByName.get(desired.name) || []) {
|
|
472
|
+
if (readConfiguredResourceMetadataStableKey(record, input.stableKeyName) === stableKey
|
|
473
|
+
|| input.pruneBeforeUpsertIds?.includes(jobTemplateIdOf(record)))
|
|
474
|
+
continue;
|
|
475
|
+
blockers.push(`Job-template name "${desired.name}" is already used by target "${jobTemplateIdOf(record)}" with a different or missing Stable Key; review its identity or an explicit workspace prune.`);
|
|
476
|
+
nameCollisionKeys.add(stableKey);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
434
479
|
const consumedTargetKeys = new Set();
|
|
435
480
|
for (const [stableKeyIdentity, entries] of localByKey) {
|
|
436
481
|
if (entries.length > 1) {
|
|
@@ -439,7 +484,10 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
439
484
|
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'duplicate desired stableKey' });
|
|
440
485
|
continue;
|
|
441
486
|
}
|
|
442
|
-
const
|
|
487
|
+
const targetMatches = targetByKey.get(stableKeyIdentity) || [];
|
|
488
|
+
const desired = targetMatches.length === 1
|
|
489
|
+
? preserveOmittedProperties('job-template', entries[0].manifest, targetMatches[0].manifest)
|
|
490
|
+
: entries[0].manifest;
|
|
443
491
|
if (nameCollisionKeys.has(stableKeyIdentity)) {
|
|
444
492
|
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'job-template name is already in use' });
|
|
445
493
|
continue;
|
|
@@ -521,7 +569,7 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
521
569
|
changedFields,
|
|
522
570
|
fieldChanges: describeJobTemplateChanges(desired, target.manifest, changedFields),
|
|
523
571
|
} : {};
|
|
524
|
-
const baseline = lockEntry?.environments[input.envName]
|
|
572
|
+
const baseline = syncBaselineHash('job-template', lockEntry?.environments[input.envName]);
|
|
525
573
|
if (!baseline) {
|
|
526
574
|
items.push({ status: 'missing-lock', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, reason: `missing ${input.envName} lock baseline`, ...dependencyDetails, ...changeDetails });
|
|
527
575
|
}
|
|
@@ -638,19 +686,21 @@ export async function pullJobTemplatesToWorkspace(input) {
|
|
|
638
686
|
const pathIdentity = portablePathIdentity(entry.manifestPath);
|
|
639
687
|
existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
|
|
640
688
|
}
|
|
641
|
-
const writes = manifests.map((
|
|
642
|
-
const hash = hashPortableJobTemplate(
|
|
643
|
-
const existing = existingByKey.get(
|
|
689
|
+
const writes = manifests.map((incoming) => {
|
|
690
|
+
const hash = hashPortableJobTemplate(incoming);
|
|
691
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
692
|
+
const manifest = existing ? preserveOmittedProperties('job-template', incoming, existing.manifest) : incoming;
|
|
693
|
+
const sourceHash = withoutSyncOmit(() => hashPortableJobTemplate(manifest));
|
|
644
694
|
if (existing && !input.force) {
|
|
645
695
|
const localHash = hashPortableJobTemplate(existing.manifest);
|
|
646
696
|
const baseline = lock.jobTemplates[manifest.stableKey];
|
|
647
|
-
if (localHash !== hash && (!baseline || localHash !== baseline
|
|
648
|
-
&& jobTemplateDefinitionHash(existing.manifest, false) !== baseline.sourceHash)) {
|
|
697
|
+
if (localHash !== hash && (!baseline || localHash !== syncSourceBaselineHash('job-template', baseline)
|
|
698
|
+
&& withoutSyncOmit(() => jobTemplateDefinitionHash(existing.manifest, false)) !== baseline.sourceHash)) {
|
|
649
699
|
throw new Error(`Cannot pull job-template "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
650
700
|
}
|
|
651
701
|
}
|
|
652
702
|
const filePath = jobTemplateManifestPath(workspaceRoot, manifest);
|
|
653
|
-
return { manifest, hash, filePath, previousPath: existing?.manifestPath };
|
|
703
|
+
return { manifest, hash, sourceHash, filePath, previousPath: existing?.manifestPath };
|
|
654
704
|
});
|
|
655
705
|
const sourceStableKeys = new Set(manifests.map((manifest) => manifest.stableKey));
|
|
656
706
|
const pruned = input.pruneOrphans === true
|
|
@@ -700,7 +750,7 @@ export async function pullJobTemplatesToWorkspace(input) {
|
|
|
700
750
|
const entry = {
|
|
701
751
|
stableKey: write.manifest.stableKey,
|
|
702
752
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
703
|
-
sourceHash: write.
|
|
753
|
+
sourceHash: write.sourceHash,
|
|
704
754
|
...(write.manifest.migration
|
|
705
755
|
? { migration: write.manifest.migration }
|
|
706
756
|
: {}),
|
|
@@ -772,7 +822,7 @@ function updateJobTemplateEnvironmentBaseline(input) {
|
|
|
772
822
|
lock.jobTemplates[stableKey] = {
|
|
773
823
|
stableKey,
|
|
774
824
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
775
|
-
sourceHash: hashPortableJobTemplate(input.manifest),
|
|
825
|
+
sourceHash: withoutSyncOmit(() => hashPortableJobTemplate(input.manifest)),
|
|
776
826
|
...(input.manifest.migration ? { migration: input.manifest.migration } : {}),
|
|
777
827
|
environments: {
|
|
778
828
|
...(existing?.environments || {}),
|
|
@@ -799,6 +849,7 @@ export async function pushJobTemplates(input) {
|
|
|
799
849
|
const stableKey = prepared.manifest.stableKey;
|
|
800
850
|
const targetPath = localTargetPath(input.cwd, prepared.manifestPath);
|
|
801
851
|
try {
|
|
852
|
+
const fullDesiredHash = withoutSyncOmit(() => hashPortableJobTemplate(prepared.manifest));
|
|
802
853
|
if (prepared.manifest.component.pinnedDigest)
|
|
803
854
|
await componentRevisionByDigest(input.client, prepared.componentId, prepared.manifest.component.pinnedDigest);
|
|
804
855
|
const created = unwrapData(await input.client.createJobTemplate({ ...buildCreatePayload(prepared.manifest, prepared.componentId), ...await targetPrincipalId(input.client, prepared.manifest, input.stableKeyName) }));
|
|
@@ -818,7 +869,7 @@ export async function pushJobTemplates(input) {
|
|
|
818
869
|
throw new Error(`created job template references a component without ${input.stableKeyName}`);
|
|
819
870
|
let verifiedManifest = await withRecordPrincipal(input.client, verified, manifestFromRecord(verified, verifiedStableKey, verifiedComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
820
871
|
const desiredMemory = isRecord(prepared.manifest.options) ? prepared.manifest.options.memory : undefined;
|
|
821
|
-
if (hashPortableJobTemplate(verifiedManifest) !==
|
|
872
|
+
if (withoutSyncOmit(() => hashPortableJobTemplate(verifiedManifest)) !== fullDesiredHash
|
|
822
873
|
&& (desiredMemory === undefined || desiredMemory === null || desiredMemory === 0)) {
|
|
823
874
|
// Create coerces missing/null/0 memory to 256. The existing update API
|
|
824
875
|
// preserves it, so restore the complete desired options before accepting
|
|
@@ -829,10 +880,10 @@ export async function pushJobTemplates(input) {
|
|
|
829
880
|
if (!createdComponentKey)
|
|
830
881
|
throw new Error(`create response dependency is missing ${input.stableKeyName}`);
|
|
831
882
|
const createdManifest = await withRecordPrincipal(input.client, created, manifestFromRecord(created, stableKey, createdComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
832
|
-
if (hashPortableJobTemplate(createdManifest) !== hashPortableJobTemplate(verifiedManifest))
|
|
883
|
+
if (withoutSyncOmit(() => hashPortableJobTemplate(createdManifest) !== hashPortableJobTemplate(verifiedManifest)))
|
|
833
884
|
throw new Error('created job template changed before restoring desired options');
|
|
834
885
|
const latestLocal = readWorkspaceJobTemplates(input.cwd).find(entry => entry.manifest.stableKey === stableKey);
|
|
835
|
-
if (!latestLocal || hashPortableJobTemplate(latestLocal.manifest) !==
|
|
886
|
+
if (!latestLocal || withoutSyncOmit(() => hashPortableJobTemplate(latestLocal.manifest)) !== fullDesiredHash)
|
|
836
887
|
throw new Error('desired manifest changed before restoring created job template options');
|
|
837
888
|
await input.client.updateJobTemplate(createdId, {
|
|
838
889
|
...buildUpdatePayload(prepared.manifest, prepared.componentId, created.version),
|
|
@@ -847,7 +898,7 @@ export async function pushJobTemplates(input) {
|
|
|
847
898
|
throw new Error(`restored target dependency is missing ${input.stableKeyName}`);
|
|
848
899
|
verifiedManifest = await withRecordPrincipal(input.client, verified, manifestFromRecord(verified, restoredStableKey, restoredComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
849
900
|
}
|
|
850
|
-
if (hashPortableJobTemplate(verifiedManifest) !== prepared.desiredHash) {
|
|
901
|
+
if (hashPortableJobTemplate(verifiedManifest) !== prepared.desiredHash || withoutSyncOmit(() => hashPortableJobTemplate(verifiedManifest)) !== fullDesiredHash) {
|
|
851
902
|
throw new Error('created job template did not match desired portable hash');
|
|
852
903
|
}
|
|
853
904
|
updateJobTemplateEnvironmentBaseline({
|
|
@@ -916,6 +967,7 @@ export async function pushJobTemplates(input) {
|
|
|
916
967
|
if (!targetComponentKey)
|
|
917
968
|
throw new Error(`target dependency is missing ${input.stableKeyName}`);
|
|
918
969
|
const targetManifest = await withRecordPrincipal(input.client, target, manifestFromRecord(target, targetStableKey, targetComponentKey, input.stableKeyName), input.stableKeyName, Boolean(local.manifest.executionPrincipal || local.manifest.executionPolicy), Boolean(local.manifest.executionPrincipal));
|
|
970
|
+
const effectiveManifest = preserveOmittedProperties('job-template', local.manifest, targetManifest);
|
|
919
971
|
const targetHash = hashPortableJobTemplate(targetManifest);
|
|
920
972
|
if (targetHash !== item.currentHash)
|
|
921
973
|
throw new Error('target changed after planning');
|
|
@@ -947,7 +999,15 @@ export async function pushJobTemplates(input) {
|
|
|
947
999
|
throw new Error(`dependency "${local.manifest.component.stableKey}" has no target component id`);
|
|
948
1000
|
if (local.manifest.component.pinnedDigest)
|
|
949
1001
|
await componentRevisionByDigest(input.client, componentId, local.manifest.component.pinnedDigest);
|
|
950
|
-
|
|
1002
|
+
const payload = { ...buildUpdatePayload(effectiveManifest, componentId, target.version), ...await targetPrincipalId(input.client, effectiveManifest, input.stableKeyName, target) };
|
|
1003
|
+
const preservesRuntime = omitPaths('job-template').some(parts => ['options', 'inputs'].includes(parts[0]));
|
|
1004
|
+
const runtimeChanged = diffJobTemplates(effectiveManifest, targetManifest).some(field => ['options', 'inputs'].includes(field));
|
|
1005
|
+
if (preservesRuntime && !runtimeChanged) {
|
|
1006
|
+
delete payload.options;
|
|
1007
|
+
delete payload.inputs;
|
|
1008
|
+
}
|
|
1009
|
+
assertJobTemplateOmitWriteSafe(targetManifest, effectiveManifest, payload);
|
|
1010
|
+
await input.client.updateJobTemplate(targetId, payload);
|
|
951
1011
|
const verified = unwrapData(await input.client.getJobTemplate(targetId));
|
|
952
1012
|
const verifiedStableKey = readConfiguredResourceMetadataStableKey(verified, input.stableKeyName);
|
|
953
1013
|
if (verifiedStableKey !== stableKey)
|
|
@@ -959,6 +1019,7 @@ export async function pushJobTemplates(input) {
|
|
|
959
1019
|
if (hashPortableJobTemplate(verifiedManifest) !== desiredHash) {
|
|
960
1020
|
throw new Error('updated job template did not match desired portable hash');
|
|
961
1021
|
}
|
|
1022
|
+
assertOmittedPropertiesPreserved('job-template', targetManifest, verifiedManifest);
|
|
962
1023
|
updateJobTemplateEnvironmentBaseline({
|
|
963
1024
|
cwd: input.cwd,
|
|
964
1025
|
envName: input.envName,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { describeFieldChanges } from "../diff-details.js";
|
|
3
4
|
import { hashStable, readComponentLock, writeComponentLock, } from "../component-lock.js";
|
|
@@ -43,7 +44,7 @@ export function roleGroupManifestFromRecord(record, stableKeyName) {
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
export function hashPortableRoleGroup(manifest) {
|
|
46
|
-
return
|
|
47
|
+
return hashSyncDefinition('role-group', {
|
|
47
48
|
...manifest,
|
|
48
49
|
category: manifest.category ?? null,
|
|
49
50
|
description: manifest.description ?? '',
|
|
@@ -54,6 +55,7 @@ function roleGroupHint(value) {
|
|
|
54
55
|
return normalizeStableKeyValue(`${category}/${String(value.name || '')}`);
|
|
55
56
|
}
|
|
56
57
|
function diffRoleGroups(desired, target) {
|
|
58
|
+
desired = preserveOmittedProperties('role-group', desired, target);
|
|
57
59
|
const changedFields = ['name', 'category', 'description', 'metadata']
|
|
58
60
|
.filter((field) => {
|
|
59
61
|
const desiredValue = field === 'category' ? desired.category ?? null : field === 'description' ? desired.description ?? '' : desired[field];
|
|
@@ -213,9 +215,11 @@ export async function buildRoleGroupsPlan(input) {
|
|
|
213
215
|
items.push({ status: 'collision', stableKey, name: entries[0].manifest.name, reason: 'duplicate desired stableKey' });
|
|
214
216
|
continue;
|
|
215
217
|
}
|
|
216
|
-
const desired = entries[0].manifest;
|
|
217
|
-
const desiredHash = hashPortableRoleGroup(desired);
|
|
218
218
|
const matches = remoteByKey.get(normalized) || [];
|
|
219
|
+
const desired = matches.length === 1
|
|
220
|
+
? preserveOmittedProperties('role-group', entries[0].manifest, matches[0].manifest)
|
|
221
|
+
: entries[0].manifest;
|
|
222
|
+
const desiredHash = hashPortableRoleGroup(desired);
|
|
219
223
|
if (matches.length > 1) {
|
|
220
224
|
blockers.push(`Duplicate target role-group stableKey "${desired.stableKey}".`);
|
|
221
225
|
consumedRemoteKeys.add(normalized);
|
|
@@ -255,7 +259,7 @@ export async function buildRoleGroupsPlan(input) {
|
|
|
255
259
|
items.push({ status: 'clean', ...common });
|
|
256
260
|
continue;
|
|
257
261
|
}
|
|
258
|
-
const baselineHash = lockByNormalizedKey.get(normalized)?.environments[input.envName]
|
|
262
|
+
const baselineHash = syncBaselineHash('role-group', lockByNormalizedKey.get(normalized)?.environments[input.envName]);
|
|
259
263
|
if (!baselineHash) {
|
|
260
264
|
items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
|
|
261
265
|
}
|
|
@@ -351,15 +355,17 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
351
355
|
}
|
|
352
356
|
const writes = [];
|
|
353
357
|
const outputPaths = new Set();
|
|
354
|
-
for (const
|
|
355
|
-
const hash = hashPortableRoleGroup(
|
|
356
|
-
const normalized = normalizeStableKeyValue(
|
|
358
|
+
for (const incoming of managed) {
|
|
359
|
+
const hash = hashPortableRoleGroup(incoming);
|
|
360
|
+
const normalized = normalizeStableKeyValue(incoming.stableKey);
|
|
357
361
|
const existing = existingByStableKey.get(normalized);
|
|
362
|
+
const manifest = existing ? preserveOmittedProperties('role-group', incoming, existing.manifest) : incoming;
|
|
363
|
+
const sourceHash = withoutSyncOmit(() => hashPortableRoleGroup(manifest));
|
|
358
364
|
if (existing && !input.force) {
|
|
359
365
|
const localHash = hashPortableRoleGroup(existing.manifest);
|
|
360
366
|
const lockEntry = Object.values(lock.roleGroups)
|
|
361
367
|
.find((entry) => normalizeStableKeyValue(entry.stableKey) === normalized);
|
|
362
|
-
if (localHash !== hash && (!lockEntry || localHash !== lockEntry
|
|
368
|
+
if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('role-group', lockEntry))) {
|
|
363
369
|
throw new Error(`Cannot pull role-group "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
364
370
|
}
|
|
365
371
|
}
|
|
@@ -379,6 +385,7 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
379
385
|
...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
|
|
380
386
|
manifest,
|
|
381
387
|
hash,
|
|
388
|
+
sourceHash,
|
|
382
389
|
});
|
|
383
390
|
}
|
|
384
391
|
const sourceStableKeys = new Set(managed.map((manifest) => normalizeStableKeyValue(manifest.stableKey)));
|
|
@@ -415,7 +422,7 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
415
422
|
const entry = {
|
|
416
423
|
stableKey: write.manifest.stableKey,
|
|
417
424
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
418
|
-
sourceHash: write.
|
|
425
|
+
sourceHash: write.sourceHash,
|
|
419
426
|
environments: {
|
|
420
427
|
...(previous?.environments || {}),
|
|
421
428
|
[input.envName]: previousBaseline?.remoteHash === write.hash
|
|
@@ -489,7 +496,7 @@ function updateEnvironmentBaseline(input) {
|
|
|
489
496
|
const nextEntry = {
|
|
490
497
|
stableKey: local.manifest.stableKey,
|
|
491
498
|
path: toPortableRelativePath(projectRoot, local.manifestPath),
|
|
492
|
-
sourceHash: hashPortableRoleGroup(local.manifest),
|
|
499
|
+
sourceHash: withoutSyncOmit(() => hashPortableRoleGroup(local.manifest)),
|
|
493
500
|
environments: {
|
|
494
501
|
...(entry?.environments || {}),
|
|
495
502
|
[input.envName]: existingBaseline?.remoteHash === input.remoteHash
|
|
@@ -586,6 +593,8 @@ export async function pushRoleGroups(input) {
|
|
|
586
593
|
if (!verifiedManifest || hashPortableRoleGroup(verifiedManifest) !== liveDesiredHash) {
|
|
587
594
|
throw new Error('created role-group did not match desired portable hash');
|
|
588
595
|
}
|
|
596
|
+
if (!withoutSyncOmit(() => hashPortableRoleGroup(verifiedManifest) === hashPortableRoleGroup(local.manifest)))
|
|
597
|
+
throw new Error('Created resource did not initialize the complete source definition.');
|
|
589
598
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
590
599
|
results.push({ stableKey, action: 'create', status: 'deployed', targetPath });
|
|
591
600
|
}
|
|
@@ -606,9 +615,10 @@ export async function pushRoleGroups(input) {
|
|
|
606
615
|
if (!targetManifest || hashPortableRoleGroup(targetManifest) !== item.currentHash) {
|
|
607
616
|
throw new Error('target changed after planning');
|
|
608
617
|
}
|
|
618
|
+
const preservedTargetManifest = structuredClone(targetManifest);
|
|
609
619
|
const diff = diffRoleGroups(local.manifest, targetManifest);
|
|
610
620
|
if (diff.changedFields.length > 0) {
|
|
611
|
-
await input.client.updateRoleGroup(targetId, buildBaseUpdatePayload(local.manifest, target));
|
|
621
|
+
await input.client.updateRoleGroup(targetId, buildBaseUpdatePayload(preserveOmittedProperties('role-group', local.manifest, targetManifest), target));
|
|
612
622
|
target = unwrapData(await input.client.getRoleGroup(targetId));
|
|
613
623
|
targetManifest = roleGroupManifestFromRecord(target, input.stableKeyName);
|
|
614
624
|
if (!targetManifest)
|
|
@@ -626,6 +636,7 @@ export async function pushRoleGroups(input) {
|
|
|
626
636
|
if (!verifiedManifest || hashPortableRoleGroup(verifiedManifest) !== liveDesiredHash) {
|
|
627
637
|
throw new Error('updated role-group did not match desired portable hash');
|
|
628
638
|
}
|
|
639
|
+
assertOmittedPropertiesPreserved('role-group', preservedTargetManifest, verifiedManifest);
|
|
629
640
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
630
641
|
results.push({ stableKey, action: 'update', status: 'deployed', targetPath });
|
|
631
642
|
}
|