@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";
|
|
@@ -166,7 +167,7 @@ function manifestFromRecord(input) {
|
|
|
166
167
|
}
|
|
167
168
|
/** Desired target shape. Source-only configuration and activation are excluded. */
|
|
168
169
|
export function hashPortableSchedule(manifest) {
|
|
169
|
-
return
|
|
170
|
+
return hashSyncDefinition('schedule', {
|
|
170
171
|
kind: 'schedule',
|
|
171
172
|
stableKey: manifest.stableKey,
|
|
172
173
|
name: manifest.name,
|
|
@@ -181,7 +182,7 @@ export function hashPortableSchedule(manifest) {
|
|
|
181
182
|
}
|
|
182
183
|
/** Local baseline shape. It deliberately includes editable/source-only pull data. */
|
|
183
184
|
export function hashScheduleManifest(manifest) {
|
|
184
|
-
return
|
|
185
|
+
return hashSyncDefinition('schedule', canonicalValue(manifest));
|
|
185
186
|
}
|
|
186
187
|
function warningKey(record, stableKey) {
|
|
187
188
|
return stableKey || String(record.name || scheduleIdOf(record) || 'unknown schedule');
|
|
@@ -309,6 +310,7 @@ function scheduleHint(value) {
|
|
|
309
310
|
return normalizeStableKeyValue(`${category}/${String(value.name || '')}`);
|
|
310
311
|
}
|
|
311
312
|
function diffSchedules(desired, target) {
|
|
313
|
+
desired = preserveOmittedProperties('schedule', desired, target);
|
|
312
314
|
const desiredInput = readAutomationInput(desired);
|
|
313
315
|
const targetInput = readAutomationInput(target);
|
|
314
316
|
const fields = [
|
|
@@ -521,7 +523,10 @@ export async function buildSchedulesPlan(input) {
|
|
|
521
523
|
consumedTargetKeys.add(stableKey);
|
|
522
524
|
continue;
|
|
523
525
|
}
|
|
524
|
-
const
|
|
526
|
+
const matchingTargets = targetByKey.get(stableKey) || [];
|
|
527
|
+
const desired = matchingTargets.length === 1
|
|
528
|
+
? preserveOmittedProperties('schedule', entries[0].manifest, matchingTargets[0].manifest)
|
|
529
|
+
: entries[0].manifest;
|
|
525
530
|
const desiredHash = hashPortableSchedule(desired);
|
|
526
531
|
const excluded = excludedTargetByKey.get(stableKey) || [];
|
|
527
532
|
if (excluded.length > 0) {
|
|
@@ -740,7 +745,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
740
745
|
...planTargetDetails(desired.target),
|
|
741
746
|
...(changedFields.length > 0 ? { changedFields, fieldChanges } : {}),
|
|
742
747
|
};
|
|
743
|
-
const baselineHash = lock.schedules[desired.stableKey]?.environments[input.envName]
|
|
748
|
+
const baselineHash = syncBaselineHash('schedule', lock.schedules[desired.stableKey]?.environments[input.envName]);
|
|
744
749
|
if (desiredHash === target.hash && activationDiffers) {
|
|
745
750
|
items.push({ status: 'activation-drift', ...common, reason: `desired active=${desiredActive}; target active=${currentActive}`, ...(baselineHash ? { baselineHash } : {}) });
|
|
746
751
|
}
|
|
@@ -914,14 +919,16 @@ export async function pullSchedulesToWorkspace(input) {
|
|
|
914
919
|
const pathIdentity = portablePathIdentity(entry.manifestPath);
|
|
915
920
|
existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
|
|
916
921
|
}
|
|
917
|
-
const writes = manifests.map((
|
|
918
|
-
const
|
|
919
|
-
const remoteHash = hashPortableSchedule(
|
|
920
|
-
const existing = existingByKey.get(
|
|
922
|
+
const writes = manifests.map((incoming) => {
|
|
923
|
+
const incomingHash = hashScheduleManifest(incoming);
|
|
924
|
+
const remoteHash = hashPortableSchedule(incoming);
|
|
925
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
926
|
+
const manifest = existing ? preserveOmittedProperties('schedule', incoming, existing.manifest) : incoming;
|
|
927
|
+
const sourceHash = withoutSyncOmit(() => hashScheduleManifest(manifest));
|
|
921
928
|
if (existing && !input.force) {
|
|
922
929
|
const localHash = hashScheduleManifest(existing.manifest);
|
|
923
930
|
const baseline = lock.schedules[manifest.stableKey];
|
|
924
|
-
if (localHash !==
|
|
931
|
+
if (localHash !== incomingHash && (!baseline || localHash !== syncSourceBaselineHash('schedule', baseline))) {
|
|
925
932
|
throw new Error(`Cannot pull Schedule "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
926
933
|
}
|
|
927
934
|
}
|
|
@@ -1067,7 +1074,7 @@ function updateScheduleEnvironmentBaseline(input) {
|
|
|
1067
1074
|
lock.schedules[stableKey] = {
|
|
1068
1075
|
stableKey,
|
|
1069
1076
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
1070
|
-
sourceHash: hashScheduleManifest(input.manifest),
|
|
1077
|
+
sourceHash: withoutSyncOmit(() => hashScheduleManifest(input.manifest)),
|
|
1071
1078
|
environments: {
|
|
1072
1079
|
...(existing?.environments || {}),
|
|
1073
1080
|
[input.envName]: previousBaseline?.remoteHash === input.remoteHash
|
|
@@ -1156,6 +1163,7 @@ async function resolveLiveScheduleWriteTarget(input) {
|
|
|
1156
1163
|
schedule,
|
|
1157
1164
|
scheduleId,
|
|
1158
1165
|
currentHash: hashPortableSchedule(currentManifest),
|
|
1166
|
+
currentManifest,
|
|
1159
1167
|
};
|
|
1160
1168
|
}
|
|
1161
1169
|
async function verifyScheduleWrite(input) {
|
|
@@ -1189,6 +1197,10 @@ async function verifyScheduleWrite(input) {
|
|
|
1189
1197
|
if (hashPortableSchedule(verifiedManifest) !== input.desiredHash) {
|
|
1190
1198
|
throw new Error('written Schedule did not match desired portable hash');
|
|
1191
1199
|
}
|
|
1200
|
+
if (input.verifyFullSource && !withoutSyncOmit(() => hashPortableSchedule(verifiedManifest) === hashPortableSchedule(input.manifest)))
|
|
1201
|
+
throw new Error('Created Schedule did not initialize the complete source definition.');
|
|
1202
|
+
if (input.preservedTargetManifest)
|
|
1203
|
+
assertOmittedPropertiesPreserved('schedule', input.preservedTargetManifest, verifiedManifest);
|
|
1192
1204
|
return schedule;
|
|
1193
1205
|
}
|
|
1194
1206
|
export async function pushSchedules(input) {
|
|
@@ -1239,7 +1251,7 @@ export async function pushSchedules(input) {
|
|
|
1239
1251
|
if (live.currentHash !== item.currentHash) {
|
|
1240
1252
|
throw new Error('target Schedule changed after planning');
|
|
1241
1253
|
}
|
|
1242
|
-
await input.client.updateSchedule(live.scheduleId, buildScheduleUpdatePayload(local.manifest, live.targetId, live.schedule.version));
|
|
1254
|
+
await input.client.updateSchedule(live.scheduleId, buildScheduleUpdatePayload(preserveOmittedProperties('schedule', local.manifest, live.currentManifest), live.targetId, live.schedule.version));
|
|
1243
1255
|
scheduleId = live.scheduleId;
|
|
1244
1256
|
}
|
|
1245
1257
|
const verified = await verifyScheduleWrite({
|
|
@@ -1249,6 +1261,8 @@ export async function pushSchedules(input) {
|
|
|
1249
1261
|
scheduleId,
|
|
1250
1262
|
targetId: live.targetId,
|
|
1251
1263
|
desiredHash,
|
|
1264
|
+
preservedTargetManifest: action === 'update' ? live.currentManifest : undefined,
|
|
1265
|
+
verifyFullSource: action === 'create',
|
|
1252
1266
|
});
|
|
1253
1267
|
updateScheduleEnvironmentBaseline({
|
|
1254
1268
|
cwd: input.cwd,
|
|
@@ -1457,6 +1471,7 @@ export async function activateVerifiedSchedules(input) {
|
|
|
1457
1471
|
|| hashPortableSchedule(verifiedManifest) !== candidate.portableHash) {
|
|
1458
1472
|
throw new Error('activated Schedule definition does not match the verified candidate');
|
|
1459
1473
|
}
|
|
1474
|
+
assertOmittedPropertiesPreserved('schedule', currentManifest, verifiedManifest);
|
|
1460
1475
|
results.push({
|
|
1461
1476
|
stableKey: candidate.stableKey,
|
|
1462
1477
|
action,
|
|
@@ -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 { readPortableOwner, resolvePortableOwner, ownerIsAvailable } from "./account-principal.js";
|
|
3
4
|
import { isBuiltinSystemAccount } from "./account-principal.js";
|
|
@@ -45,13 +46,14 @@ async function readManagementPrincipal(client, record, stableKeyName) {
|
|
|
45
46
|
: { ownerType: 'USER', ownerId: managers[0].userId }, stableKeyName);
|
|
46
47
|
}
|
|
47
48
|
export function hashPortableServiceAccount(manifest) {
|
|
48
|
-
return
|
|
49
|
+
return hashSyncDefinition('service-account', { kind: manifest.kind, stableKey: manifest.stableKey, name: manifest.name, metadata: manifest.metadata,
|
|
49
50
|
...(['group', 'service-account', 'system'].includes(manifest.owner.type) ? { owner: manifest.owner } : {}) });
|
|
50
51
|
}
|
|
51
52
|
function serviceAccountHint(value) {
|
|
52
53
|
return String(value.name || '').trim().toLowerCase();
|
|
53
54
|
}
|
|
54
55
|
function diffServiceAccounts(desired, target) {
|
|
56
|
+
desired = preserveOmittedProperties('service-account', desired, target);
|
|
55
57
|
return { changedFields: ['name', 'metadata', 'owner'].filter((field) => {
|
|
56
58
|
if (field === 'owner' && !['group', 'service-account', 'system'].includes(desired.owner.type)) {
|
|
57
59
|
return false;
|
|
@@ -190,9 +192,11 @@ export async function buildServiceAccountsPlan(input) {
|
|
|
190
192
|
items.push({ status: 'collision', stableKey, name: entries[0].manifest.name, reason: 'duplicate desired stableKey' });
|
|
191
193
|
continue;
|
|
192
194
|
}
|
|
193
|
-
const desired = entries[0].manifest;
|
|
194
|
-
const desiredHash = hashPortableServiceAccount(desired);
|
|
195
195
|
const matches = remoteByKey.get(normalized) || [];
|
|
196
|
+
const desired = matches.length === 1
|
|
197
|
+
? preserveOmittedProperties('service-account', entries[0].manifest, matches[0].manifest)
|
|
198
|
+
: entries[0].manifest;
|
|
199
|
+
const desiredHash = hashPortableServiceAccount(desired);
|
|
196
200
|
if (matches.length > 1) {
|
|
197
201
|
blockers.push(`Duplicate target service-account stableKey "${desired.stableKey}".`);
|
|
198
202
|
consumedRemoteKeys.add(normalized);
|
|
@@ -247,7 +251,7 @@ export async function buildServiceAccountsPlan(input) {
|
|
|
247
251
|
items.push({ status: 'clean', ...common });
|
|
248
252
|
continue;
|
|
249
253
|
}
|
|
250
|
-
const baselineHash = lockByNormalizedKey.get(normalized)?.environments[input.envName]
|
|
254
|
+
const baselineHash = syncBaselineHash('service-account', lockByNormalizedKey.get(normalized)?.environments[input.envName]);
|
|
251
255
|
if (!baselineHash) {
|
|
252
256
|
items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
|
|
253
257
|
}
|
|
@@ -350,15 +354,17 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
350
354
|
}
|
|
351
355
|
const writes = [];
|
|
352
356
|
const outputPaths = new Set();
|
|
353
|
-
for (const
|
|
354
|
-
const hash = hashPortableServiceAccount(
|
|
355
|
-
const normalized = exactKey(
|
|
357
|
+
for (const incoming of managed) {
|
|
358
|
+
const hash = hashPortableServiceAccount(incoming);
|
|
359
|
+
const normalized = exactKey(incoming.stableKey);
|
|
356
360
|
const existing = existingByStableKey.get(normalized);
|
|
361
|
+
const manifest = existing ? preserveOmittedProperties('service-account', incoming, existing.manifest) : incoming;
|
|
362
|
+
const sourceHash = withoutSyncOmit(() => hashPortableServiceAccount(manifest));
|
|
357
363
|
if (existing && !input.force) {
|
|
358
364
|
const localHash = hashPortableServiceAccount(existing.manifest);
|
|
359
365
|
const lockEntry = Object.values(lock.serviceAccounts)
|
|
360
366
|
.find((entry) => exactKey(entry.stableKey) === normalized);
|
|
361
|
-
if (localHash !== hash && (!lockEntry || localHash !== lockEntry
|
|
367
|
+
if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('service-account', lockEntry))) {
|
|
362
368
|
throw new Error(`Cannot pull service-account "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
363
369
|
}
|
|
364
370
|
}
|
|
@@ -378,6 +384,7 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
378
384
|
...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
|
|
379
385
|
manifest,
|
|
380
386
|
hash,
|
|
387
|
+
sourceHash,
|
|
381
388
|
});
|
|
382
389
|
}
|
|
383
390
|
const sourceStableKeys = new Set(managed.map((manifest) => exactKey(manifest.stableKey)));
|
|
@@ -414,7 +421,7 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
414
421
|
const entry = {
|
|
415
422
|
stableKey: write.manifest.stableKey,
|
|
416
423
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
417
|
-
sourceHash: write.
|
|
424
|
+
sourceHash: write.sourceHash,
|
|
418
425
|
environments: {
|
|
419
426
|
...(previous?.environments || {}),
|
|
420
427
|
[input.envName]: previousBaseline?.remoteHash === write.hash
|
|
@@ -498,7 +505,7 @@ function updateEnvironmentBaseline(input) {
|
|
|
498
505
|
const nextEntry = {
|
|
499
506
|
stableKey: local.manifest.stableKey,
|
|
500
507
|
path: toPortableRelativePath(projectRoot, local.manifestPath),
|
|
501
|
-
sourceHash: hashPortableServiceAccount(local.manifest),
|
|
508
|
+
sourceHash: withoutSyncOmit(() => hashPortableServiceAccount(local.manifest)),
|
|
502
509
|
environments: {
|
|
503
510
|
...(entry?.environments || {}),
|
|
504
511
|
[input.envName]: existingBaseline?.remoteHash === input.remoteHash
|
|
@@ -605,6 +612,8 @@ export async function pushServiceAccounts(input) {
|
|
|
605
612
|
if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
|
|
606
613
|
throw new Error('created service-account did not match desired portable hash');
|
|
607
614
|
}
|
|
615
|
+
if (!withoutSyncOmit(() => hashPortableServiceAccount(verifiedManifest) === hashPortableServiceAccount(local.manifest)))
|
|
616
|
+
throw new Error('Created resource did not initialize the complete source definition.');
|
|
608
617
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
609
618
|
results.push({ stableKey, action: 'create', status: 'deployed', targetPath, reason: 'Created; secrets are target-local and require separate configuration', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'configure-manually' } });
|
|
610
619
|
}
|
|
@@ -630,9 +639,10 @@ export async function pushServiceAccounts(input) {
|
|
|
630
639
|
if (!targetManifest || hashPortableServiceAccount(targetManifest) !== item.currentHash) {
|
|
631
640
|
throw new Error('target changed after planning');
|
|
632
641
|
}
|
|
642
|
+
const preservedTargetManifest = structuredClone(targetManifest);
|
|
633
643
|
const diff = diffServiceAccounts(local.manifest, targetManifest);
|
|
634
644
|
if (diff.changedFields.length > 0) {
|
|
635
|
-
await input.client.updateServiceAccount(targetId, await buildBaseUpdatePayload(input.client, local.manifest, target, input.stableKeyName));
|
|
645
|
+
await input.client.updateServiceAccount(targetId, await buildBaseUpdatePayload(input.client, preserveOmittedProperties('service-account', local.manifest, targetManifest), target, input.stableKeyName));
|
|
636
646
|
target = unwrapData(await input.client.getServiceAccount(targetId));
|
|
637
647
|
targetManifest = await serviceAccountManifestFromRecord(input.client, target, input.stableKeyName);
|
|
638
648
|
if (!targetManifest) {
|
|
@@ -645,6 +655,7 @@ export async function pushServiceAccounts(input) {
|
|
|
645
655
|
if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
|
|
646
656
|
throw new Error('updated service-account did not match desired portable hash');
|
|
647
657
|
}
|
|
658
|
+
assertOmittedPropertiesPreserved('service-account', preservedTargetManifest, verifiedManifest);
|
|
648
659
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
649
660
|
results.push({ stableKey, action: 'update', status: 'deployed', targetPath, reason: 'Target-local secrets preserved', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'preserved-target-local' } });
|
|
650
661
|
}
|
|
@@ -6,6 +6,9 @@ const families = ['databaseSchemas', 'databaseViews', 'components', 'jobTemplate
|
|
|
6
6
|
function reviewState(plan) {
|
|
7
7
|
return {
|
|
8
8
|
target: plan.pruneTargetKey,
|
|
9
|
+
omitTargetRevisionHash: plan.omitTargetRevisionHash,
|
|
10
|
+
omitSourceRevisionHash: plan.omitSourceRevisionHash,
|
|
11
|
+
omitTargetVersions: plan.omitTargetVersions,
|
|
9
12
|
resources: plan.resources,
|
|
10
13
|
policy: plan.policy,
|
|
11
14
|
identityOrder: plan.identityOrder,
|
package/dist/src/runtime-view.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
import { getActiveEnvironmentName, getConfigDir, resolveRuntimeConfig } from "./config.js";
|
|
2
2
|
import { AuthenticationError } from "./client.js";
|
|
3
|
+
import { runtimeConnectionOverrides } from "./argument-contract.js";
|
|
3
4
|
function resolveArgsRuntime(context) {
|
|
4
|
-
return resolveRuntimeConfig(
|
|
5
|
-
envName: typeof context.args.env === 'string' ? context.args.env : undefined,
|
|
6
|
-
baseUrl: typeof context.args.url === 'string'
|
|
7
|
-
? context.args.url
|
|
8
|
-
: typeof context.args.baseUrl === 'string'
|
|
9
|
-
? context.args.baseUrl
|
|
10
|
-
: undefined,
|
|
11
|
-
instance: typeof context.args.instance === 'string'
|
|
12
|
-
? context.args.instance
|
|
13
|
-
: typeof context.args.i === 'string'
|
|
14
|
-
? context.args.i
|
|
15
|
-
: undefined,
|
|
16
|
-
token: typeof context.args.token === 'string'
|
|
17
|
-
? context.args.token
|
|
18
|
-
: typeof context.args.t === 'string'
|
|
19
|
-
? context.args.t
|
|
20
|
-
: undefined,
|
|
21
|
-
});
|
|
5
|
+
return resolveRuntimeConfig(runtimeConnectionOverrides(context.args));
|
|
22
6
|
}
|
|
23
7
|
function extractEmail(profile) {
|
|
24
8
|
if (!profile || typeof profile !== 'object') {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SyncResourceFamily } from './sync-omit.ts';
|
|
2
|
+
import type { CommandContext } from './types.ts';
|
|
3
|
+
export declare function commandWritesWorkspace(context: CommandContext): boolean;
|
|
4
|
+
/** One invocation owns its policy and digest cache, including direct command handlers. */
|
|
5
|
+
export declare function withCommandSyncOmit<T>(context: CommandContext, families: readonly SyncResourceFamily[], operation: (context: CommandContext) => T): T;
|
|
6
|
+
export declare function workspaceSyncOmitFamilies(context: CommandContext): SyncResourceFamily[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readProjectStableKeyName, readProjectTrackedResources } from "./project.js";
|
|
2
|
+
import { shouldTrackResource } from "./tracked-resources.js";
|
|
3
|
+
import { currentSyncOmitPolicy, parseOmitPolicy, SYNC_RESOURCE_FAMILIES, validateSyncOmitFamilies, withSyncOmitPolicy } from "./sync-omit.js";
|
|
4
|
+
import { validateCommandArguments } from "./argument-contract.js";
|
|
5
|
+
import { withWorkspaceWriteLock } from "./workspace-write-lock.js";
|
|
6
|
+
export function commandWritesWorkspace(context) {
|
|
7
|
+
const [command, action] = context.args._;
|
|
8
|
+
const dryRun = [context.args['dry-run'], context.args.dryRun].some(value => value === true || value === 'true');
|
|
9
|
+
if (dryRun && (command === 'migrate' || ['env', 'projects'].includes(command) && action === 'apply'))
|
|
10
|
+
return false;
|
|
11
|
+
return command === 'pull' || command === 'deploy'
|
|
12
|
+
|| command === 'plan' && action === 'update'
|
|
13
|
+
|| command === 'migrate' && action === 'run'
|
|
14
|
+
|| ['env', 'projects'].includes(command) && action === 'apply'
|
|
15
|
+
|| !['env', 'projects', 'migrate'].includes(command) && ['pull', 'pull-all', 'push', 'push-all'].includes(action);
|
|
16
|
+
}
|
|
17
|
+
/** One invocation owns its policy and digest cache, including direct command handlers. */
|
|
18
|
+
export function withCommandSyncOmit(context, families, operation) {
|
|
19
|
+
validateCommandArguments(context.args);
|
|
20
|
+
const execute = (scoped) => commandWritesWorkspace(scoped)
|
|
21
|
+
? withWorkspaceWriteLock(scoped.cwd, () => operation(scoped)) : operation(scoped);
|
|
22
|
+
const inherited = currentSyncOmitPolicy();
|
|
23
|
+
if (context.args.omit === undefined && inherited.rules.length)
|
|
24
|
+
return execute(context);
|
|
25
|
+
const policy = parseOmitPolicy(context.args, { stableKeyName: readProjectStableKeyName(context.cwd) });
|
|
26
|
+
if (policy.rules.length) {
|
|
27
|
+
const command = context.args._[0];
|
|
28
|
+
const action = context.args._[1];
|
|
29
|
+
const allowed = ['plan', 'diff', 'deploy', 'pull'].includes(command)
|
|
30
|
+
|| (command === 'migrate' && ['plan', 'run', 'verify'].includes(action))
|
|
31
|
+
|| (['env', 'projects'].includes(command) && ['diff', 'apply'].includes(action))
|
|
32
|
+
|| (!['migrate', 'env', 'projects'].includes(command) && ['plan', 'push', 'push-all', 'pull', 'pull-all'].includes(action));
|
|
33
|
+
if (!allowed)
|
|
34
|
+
throw new Error('--omit is supported only by sync pull/plan/diff/push/deploy and migration run/verify.');
|
|
35
|
+
validateSyncOmitFamilies(policy, families);
|
|
36
|
+
}
|
|
37
|
+
const scoped = policy.rules.length ? {
|
|
38
|
+
...context,
|
|
39
|
+
print: (value) => context.print(value && typeof value === 'object' && !Array.isArray(value)
|
|
40
|
+
? { ...value, omit: policy } : value),
|
|
41
|
+
} : context;
|
|
42
|
+
if (policy.rules.length && !context.args.json)
|
|
43
|
+
context.println(`Preserving ${context.args._[0] === 'pull' || ['pull', 'pull-all'].includes(context.args._[1]) ? 'local' : 'target'} properties (--omit): ${policy.rules.map(rule => `${rule.resource ? `${rule.resource}:` : ''}${rule.path}`).join(', ')}`);
|
|
44
|
+
return withSyncOmitPolicy(policy, () => execute(scoped));
|
|
45
|
+
}
|
|
46
|
+
export function workspaceSyncOmitFamilies(context) {
|
|
47
|
+
const tracked = readProjectTrackedResources(context.cwd);
|
|
48
|
+
return SYNC_RESOURCE_FAMILIES.filter(family => shouldTrackResource(tracked, family));
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RevoClient } from './client.ts';
|
|
2
|
+
import type { SyncResourceFamily } from './sync-omit.ts';
|
|
3
|
+
export type SyncOmitTargetVersions = Record<string, number | null>;
|
|
4
|
+
/** Inspect resource envelopes only. Runtime inputs and resource configurations are never traversed. */
|
|
5
|
+
export declare function syncTargetVersionRecords(family: SyncResourceFamily, value: unknown, fallbackId?: string): Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
version: number | null;
|
|
8
|
+
}>;
|
|
9
|
+
/** Preserve the reviewed revision even if an update builder reads a newer ignored value. Backend CAS covers the following race. */
|
|
10
|
+
export declare function fenceSyncOmitWrites(client: RevoClient, reviewed: Readonly<SyncOmitTargetVersions>, assertSourceUnchanged?: () => void): RevoClient;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const identityFields = {
|
|
2
|
+
'database-table': 'databaseId', 'database-view': 'databaseViewId', component: 'componentId',
|
|
3
|
+
endpoint: 'endpointId', 'job-template': 'jobTemplateId', schedule: 'scheduleId', event: 'eventId',
|
|
4
|
+
group: 'groupId', 'role-group': 'roleGroupId', 'service-account': 'userId', agent: 'agentId', 'agent-plugin': 'agentPluginId',
|
|
5
|
+
};
|
|
6
|
+
const envelopeFields = ['data', 'items', 'results', 'resource', 'database', 'databaseSchema', 'databaseView', 'component', 'endpoint',
|
|
7
|
+
'jobTemplate', 'schedule', 'event', 'jobEvent', 'group', 'roleGroup', 'account', 'agent', 'agentPlugin', 'databases', 'databaseSchemas', 'databaseViews',
|
|
8
|
+
'components', 'endpoints', 'jobTemplates', 'schedules', 'events', 'jobEvents', 'groups', 'roleGroups', 'accounts', 'serviceAccounts', 'agents', 'agentPlugins'];
|
|
9
|
+
function isObject(value) {
|
|
10
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
/** Inspect resource envelopes only. Runtime inputs and resource configurations are never traversed. */
|
|
13
|
+
export function syncTargetVersionRecords(family, value, fallbackId) {
|
|
14
|
+
const records = [];
|
|
15
|
+
function visit(current, depth, fallback) {
|
|
16
|
+
if (depth > 12)
|
|
17
|
+
throw new Error('Target revision response is nested too deeply; review a fresh deployment plan.');
|
|
18
|
+
if (Array.isArray(current)) {
|
|
19
|
+
for (const item of current)
|
|
20
|
+
visit(item, depth + 1);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!isObject(current))
|
|
24
|
+
return;
|
|
25
|
+
const identity = family === 'event' ? current.jobEventId ?? current.eventId ?? current.id : current[identityFields[family]] ?? current.id;
|
|
26
|
+
const id = typeof identity === 'string' && identity ? identity : fallback;
|
|
27
|
+
const version = Number.isSafeInteger(current.version) && Number(current.version) >= 0 ? Number(current.version) : null;
|
|
28
|
+
if (id && (identity !== undefined || Object.hasOwn(current, 'version'))) {
|
|
29
|
+
records.push({ id, version });
|
|
30
|
+
// A resource row can contain hydrated relationship rows with independent
|
|
31
|
+
// revision counters. Envelope traversal ends at the authoring resource.
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (const key of envelopeFields) {
|
|
35
|
+
if (Object.hasOwn(current, key))
|
|
36
|
+
visit(current[key], depth + 1, fallback);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
visit(value, 0, fallbackId);
|
|
40
|
+
return records;
|
|
41
|
+
}
|
|
42
|
+
const writeFamilies = {
|
|
43
|
+
updateJobTemplate: 'job-template', updateEndpoint: 'endpoint', updateSchedule: 'schedule', updateEvent: 'event',
|
|
44
|
+
updateGroup: 'group', updateRoleGroup: 'role-group', updateServiceAccount: 'service-account',
|
|
45
|
+
updateAgent: 'agent', updateAgentPlugin: 'agent-plugin', updateDatabaseSchema: 'database-table',
|
|
46
|
+
updateDatabaseSchemaMetadata: 'database-table', acceptDatabaseSchema: 'database-table', updateDatabaseView: 'database-view',
|
|
47
|
+
};
|
|
48
|
+
const createFamilies = {
|
|
49
|
+
createJobTemplate: 'job-template', createEndpoint: 'endpoint', createSchedule: 'schedule', createEvent: 'event',
|
|
50
|
+
createGroup: 'group', createRoleGroup: 'role-group', createServiceAccount: 'service-account',
|
|
51
|
+
createAgent: 'agent', createAgentPlugin: 'agent-plugin', createDatabaseSchema: 'database-table', createDatabaseView: 'database-view',
|
|
52
|
+
};
|
|
53
|
+
/** Preserve the reviewed revision even if an update builder reads a newer ignored value. Backend CAS covers the following race. */
|
|
54
|
+
export function fenceSyncOmitWrites(client, reviewed, assertSourceUnchanged) {
|
|
55
|
+
const versions = { ...reviewed };
|
|
56
|
+
const created = new Set();
|
|
57
|
+
const pending = new Set();
|
|
58
|
+
return new Proxy(client, {
|
|
59
|
+
get(target, property) {
|
|
60
|
+
const value = Reflect.get(target, property, target);
|
|
61
|
+
if (typeof value !== 'function')
|
|
62
|
+
return value;
|
|
63
|
+
const creatingFamily = typeof property === 'string' && Object.hasOwn(createFamilies, property) ? createFamilies[property] : undefined;
|
|
64
|
+
if (creatingFamily)
|
|
65
|
+
return async (...args) => {
|
|
66
|
+
assertSourceUnchanged?.();
|
|
67
|
+
const result = await value.apply(target, args);
|
|
68
|
+
for (const record of syncTargetVersionRecords(creatingFamily, result)) {
|
|
69
|
+
const key = `${creatingFamily}:${record.id}`;
|
|
70
|
+
if (Object.hasOwn(reviewed, key))
|
|
71
|
+
throw new Error(`Created ${creatingFamily} reused a reviewed identity; review a fresh deployment plan.`);
|
|
72
|
+
versions[key] = record.version;
|
|
73
|
+
created.add(key);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
const family = typeof property === 'string' && Object.hasOwn(writeFamilies, property) ? writeFamilies[property] : undefined;
|
|
78
|
+
if (!family) {
|
|
79
|
+
if (typeof property === 'string' && /^(create|update|save|restore|activate|disable|delete|add|remove|accept)/.test(property))
|
|
80
|
+
return async (...args) => {
|
|
81
|
+
assertSourceUnchanged?.();
|
|
82
|
+
return value.apply(target, args);
|
|
83
|
+
};
|
|
84
|
+
return value.bind(target);
|
|
85
|
+
}
|
|
86
|
+
return async (...args) => {
|
|
87
|
+
const admission = property === 'acceptDatabaseSchema';
|
|
88
|
+
const id = args[admission ? 1 : 0];
|
|
89
|
+
const body = args[admission ? 0 : 1];
|
|
90
|
+
if (typeof id !== 'string' || !id) {
|
|
91
|
+
if (!admission)
|
|
92
|
+
throw new Error(`Target ${family} identity is missing before a reviewed write.`);
|
|
93
|
+
assertSourceUnchanged?.();
|
|
94
|
+
const result = await value.apply(target, args);
|
|
95
|
+
if (admission)
|
|
96
|
+
for (const record of syncTargetVersionRecords(family, result)) {
|
|
97
|
+
const key = `${family}:${record.id}`;
|
|
98
|
+
if (Object.hasOwn(reviewed, key))
|
|
99
|
+
throw new Error(`Created ${family} reused a reviewed identity; review a fresh deployment plan.`);
|
|
100
|
+
versions[key] = record.version;
|
|
101
|
+
created.add(key);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
const key = `${family}:${id}`;
|
|
106
|
+
if (!Object.hasOwn(versions, key) || !Object.hasOwn(reviewed, key) && !created.has(key))
|
|
107
|
+
throw new Error(`Target ${family} identity was not reviewed or created by this deployment; review a fresh deployment plan.`);
|
|
108
|
+
const expected = versions[key];
|
|
109
|
+
const submitted = isObject(body) ? body.version : undefined;
|
|
110
|
+
if (expected === null || submitted !== expected || pending.has(key)) {
|
|
111
|
+
throw new Error(`Reviewed ${family} revision changed before write; review a fresh deployment plan.`);
|
|
112
|
+
}
|
|
113
|
+
pending.add(key);
|
|
114
|
+
try {
|
|
115
|
+
assertSourceUnchanged?.();
|
|
116
|
+
const result = await value.apply(target, args);
|
|
117
|
+
const revisions = syncTargetVersionRecords(family, result, id).filter(record => record.id === id && record.version !== null);
|
|
118
|
+
const observed = revisions.at(-1)?.version;
|
|
119
|
+
if (observed !== undefined && observed !== null) {
|
|
120
|
+
if (observed < expected)
|
|
121
|
+
throw new Error(`Written ${family} returned an older revision; review a fresh deployment plan.`);
|
|
122
|
+
if (observed > expected + 1)
|
|
123
|
+
throw new Error(`Written ${family} advanced beyond this reviewed write; review a fresh deployment plan.`);
|
|
124
|
+
versions[key] = observed;
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
pending.delete(key);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ParsedArgs } from './types.ts';
|
|
2
|
+
export declare const SYNC_RESOURCE_FAMILIES: readonly ["database-table", "database-view", "component", "service-account", "agent-plugin", "agent", "job-template", "endpoint", "schedule", "event", "group", "role-group"];
|
|
3
|
+
export type SyncResourceFamily = (typeof SYNC_RESOURCE_FAMILIES)[number];
|
|
4
|
+
export type SyncOmitRule = {
|
|
5
|
+
resource?: SyncResourceFamily;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
export type SyncOmitPolicy = {
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
rules: readonly SyncOmitRule[];
|
|
11
|
+
fingerprint: string;
|
|
12
|
+
};
|
|
13
|
+
export type SyncDefinitionDigest = {
|
|
14
|
+
kind: 'value';
|
|
15
|
+
hash: string;
|
|
16
|
+
array?: true;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'object';
|
|
19
|
+
properties: Record<string, SyncDefinitionDigest>;
|
|
20
|
+
};
|
|
21
|
+
export type SyncOmitBaseline = {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
rawHash: string;
|
|
24
|
+
tree: SyncDefinitionDigest;
|
|
25
|
+
paths: string[];
|
|
26
|
+
policyFingerprint: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function normalizeSyncResourceFamily(value: string): SyncResourceFamily;
|
|
29
|
+
/** Flags are invocation-local; resource metadata never changes this policy. */
|
|
30
|
+
export declare function parseOmitPolicy(args: Pick<ParsedArgs, string> | Record<string, unknown>, options?: {
|
|
31
|
+
stableKeyName?: string;
|
|
32
|
+
}): SyncOmitPolicy;
|
|
33
|
+
export declare function emptySyncOmitPolicy(): SyncOmitPolicy;
|
|
34
|
+
/** Unqualified paths must be meaningful for every selected family. Mixed workspaces can qualify individual rules. */
|
|
35
|
+
export declare function validateSyncOmitFamilies(policy: SyncOmitPolicy, resources: readonly (SyncResourceFamily | string)[]): void;
|
|
36
|
+
export declare function currentSyncOmitPolicy(): SyncOmitPolicy;
|
|
37
|
+
export declare function withSyncOmitPolicy<T>(policy: SyncOmitPolicy, operation: () => T): T;
|
|
38
|
+
/** Integrity checks and source manifests always retain the complete definition. */
|
|
39
|
+
export declare function withoutSyncOmit<T>(operation: () => T): T;
|
|
40
|
+
export declare function omitPaths(resource: SyncResourceFamily | string, policy?: SyncOmitPolicy): readonly string[][];
|
|
41
|
+
export declare function projectSyncDefinition<T>(family: SyncResourceFamily | string, shape: T, policy?: SyncOmitPolicy): T;
|
|
42
|
+
/** Updates retain target ownership, including the difference between missing and null. Creates use the complete desired definition. */
|
|
43
|
+
export declare function preserveOmittedProperties<T>(family: SyncResourceFamily | string, desired: T, target: unknown, policy?: SyncOmitPolicy): T;
|
|
44
|
+
/** Verify target-owned values separately from the deliberately masked convergence hash. */
|
|
45
|
+
export declare function assertOmittedPropertiesPreserved(family: SyncResourceFamily | string, expectedTargetManifest: unknown, actualManifest: unknown): void;
|
|
46
|
+
export declare function createSyncDefinitionDigest(shape: unknown): SyncDefinitionDigest;
|
|
47
|
+
export declare function projectSyncDefinitionDigest(resource: SyncResourceFamily | string, tree: SyncDefinitionDigest, policy?: SyncOmitPolicy): SyncDefinitionDigest;
|
|
48
|
+
export declare function hashSyncDefinitionDigest(tree: SyncDefinitionDigest): string;
|
|
49
|
+
export declare function hashSyncDefinition(resource: SyncResourceFamily | string, shape: unknown, legacyHash?: string): string;
|
|
50
|
+
export declare function syncBaselineData(resource: SyncResourceFamily | string, value: string): SyncOmitBaseline | undefined;
|
|
51
|
+
export declare function syncBaselineHash(resource: SyncResourceFamily | string, baseline?: {
|
|
52
|
+
remoteHash?: string;
|
|
53
|
+
omitBaseline?: SyncOmitBaseline;
|
|
54
|
+
}): string | undefined;
|
|
55
|
+
/** Local pull ownership has its own complete proof; target-environment baselines never prove local edit safety. */
|
|
56
|
+
export declare function syncSourceBaselineHash(resource: SyncResourceFamily | string, entry?: {
|
|
57
|
+
sourceHash?: string;
|
|
58
|
+
sourceBaseline?: SyncOmitBaseline;
|
|
59
|
+
}): string | undefined;
|