@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,7 +1,8 @@
|
|
|
1
|
+
import { hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, assertOmittedPropertiesPreserved, omitPaths } from "../sync-omit.js";
|
|
1
2
|
import { databaseIndexPayload } from "../database-indexes.js";
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
|
-
import { ApiError } from "../client.js";
|
|
5
|
+
import { ApiError, DatabaseSchemaOperationWaitError, isDatabaseSchemaOperation } from "../client.js";
|
|
5
6
|
import { hashStable, readComponentLock, writeComponentLock, } from "../component-lock.js";
|
|
6
7
|
import { excludeDatabaseBackupArtifacts, isDatabaseBackupArtifact } from "../database-table-artifacts.js";
|
|
7
8
|
import { readConfiguredResourceMetadataStableKey, sanitizeUserMetadata } from "../resource-metadata.js";
|
|
@@ -175,7 +176,7 @@ function portableDatabaseSchemaManifest(manifest) {
|
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
178
|
export function hashPortableDatabaseSchema(manifest) {
|
|
178
|
-
return
|
|
179
|
+
return hashSyncDefinition('database-table', portableDatabaseSchemaManifest(manifest));
|
|
179
180
|
}
|
|
180
181
|
function rootManifestPath(workspaceRoot, manifest) {
|
|
181
182
|
const category = typeof manifest.category === 'string' && manifest.category.trim()
|
|
@@ -798,7 +799,7 @@ export async function buildDatabaseSchemasPlan(input) {
|
|
|
798
799
|
if (entries.length !== 1) {
|
|
799
800
|
continue;
|
|
800
801
|
}
|
|
801
|
-
const name = physicalNameHint(entries[0].manifest);
|
|
802
|
+
const name = physicalNameHint(preserveOmittedProperties('database-table', entries[0].manifest, targetByKey.get(stableKey)?.[0]?.manifest));
|
|
802
803
|
localKeysByPhysicalName.set(name, [...(localKeysByPhysicalName.get(name) || []), stableKey]);
|
|
803
804
|
}
|
|
804
805
|
const duplicateLocalNames = new Set();
|
|
@@ -846,7 +847,7 @@ export async function buildDatabaseSchemasPlan(input) {
|
|
|
846
847
|
visitParent(stableKey, []);
|
|
847
848
|
}
|
|
848
849
|
for (const [stableKey, entries] of localByKey) {
|
|
849
|
-
const desired = portableDatabaseSchemaManifest(entries[0].manifest);
|
|
850
|
+
const desired = preserveOmittedProperties('database-table', portableDatabaseSchemaManifest(entries[0].manifest), targetByKey.get(stableKey)?.[0]?.manifest);
|
|
850
851
|
if (entries.length > 1) {
|
|
851
852
|
blockers.push(`Duplicate desired Database Table stableKey "${stableKey}".`);
|
|
852
853
|
items.push({
|
|
@@ -1001,7 +1002,7 @@ export async function buildDatabaseSchemasPlan(input) {
|
|
|
1001
1002
|
});
|
|
1002
1003
|
}
|
|
1003
1004
|
const changedFields = [...new Set(changes.map((change) => change.field))];
|
|
1004
|
-
const baselineHash = lock.databaseSchemas[stableKey]?.environments[input.envName]
|
|
1005
|
+
const baselineHash = syncBaselineHash('database-table', lock.databaseSchemas[stableKey]?.environments[input.envName]);
|
|
1005
1006
|
const currentStats = statsById.get(current.databaseId);
|
|
1006
1007
|
const sizeHint = changes.length > 0 ? sizeRiskHint(currentStats) : undefined;
|
|
1007
1008
|
const common = {
|
|
@@ -1355,7 +1356,8 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1355
1356
|
if (input.strict && catalog.skipped.length > 0) {
|
|
1356
1357
|
throw new Error(`Database Table strict pull requires Stable Keys on all active resources; ${catalog.skipped.length} unmanaged resource(s) found.`);
|
|
1357
1358
|
}
|
|
1358
|
-
const
|
|
1359
|
+
const sourceManifestsById = new Map(catalog.entries.map((entry) => [entry.id, manifestFromEntry(entry, input.stableKeyName)]));
|
|
1360
|
+
const manifestsById = new Map(sourceManifestsById);
|
|
1359
1361
|
const pathsById = new Map();
|
|
1360
1362
|
const resolvePath = (entry) => {
|
|
1361
1363
|
const existing = pathsById.get(entry.id);
|
|
@@ -1370,15 +1372,6 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1370
1372
|
return filePath;
|
|
1371
1373
|
};
|
|
1372
1374
|
const existingByKey = new Map();
|
|
1373
|
-
const catalogPathOwners = new Map();
|
|
1374
|
-
for (const entry of catalog.entries) {
|
|
1375
|
-
const identity = pathIdentity(resolvePath(entry));
|
|
1376
|
-
const owner = catalogPathOwners.get(identity);
|
|
1377
|
-
if (owner && owner !== entry.stableKey) {
|
|
1378
|
-
throw new Error(`Database Table workspace path collision for "${entry.stableKey}" and "${owner}"; no files were changed.`);
|
|
1379
|
-
}
|
|
1380
|
-
catalogPathOwners.set(identity, entry.stableKey);
|
|
1381
|
-
}
|
|
1382
1375
|
for (const local of loadWorkspaceManifests(workspaceRoot)) {
|
|
1383
1376
|
if (!isRecord(local.manifest) || typeof local.manifest.stableKey !== 'string') {
|
|
1384
1377
|
throw new Error(`Invalid database-table manifest ${path.relative(projectRoot, local.manifestPath)}; no files were changed.`);
|
|
@@ -1388,6 +1381,18 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1388
1381
|
}
|
|
1389
1382
|
existingByKey.set(local.manifest.stableKey, local);
|
|
1390
1383
|
}
|
|
1384
|
+
for (const entry of catalog.entries) {
|
|
1385
|
+
manifestsById.set(entry.id, preserveOmittedProperties('database-table', sourceManifestsById.get(entry.id), existingByKey.get(entry.stableKey)?.manifest));
|
|
1386
|
+
}
|
|
1387
|
+
const catalogPathOwners = new Map();
|
|
1388
|
+
for (const entry of catalog.entries) {
|
|
1389
|
+
const identity = pathIdentity(resolvePath(entry));
|
|
1390
|
+
const owner = catalogPathOwners.get(identity);
|
|
1391
|
+
if (owner && owner !== entry.stableKey) {
|
|
1392
|
+
throw new Error(`Database Table workspace path collision for "${entry.stableKey}" and "${owner}"; no files were changed.`);
|
|
1393
|
+
}
|
|
1394
|
+
catalogPathOwners.set(identity, entry.stableKey);
|
|
1395
|
+
}
|
|
1391
1396
|
const lock = readComponentLock(projectRoot);
|
|
1392
1397
|
const skipped = [...catalog.skipped];
|
|
1393
1398
|
const writes = [];
|
|
@@ -1404,12 +1409,12 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1404
1409
|
: [];
|
|
1405
1410
|
for (const entry of catalog.entries) {
|
|
1406
1411
|
const manifest = manifestsById.get(entry.id);
|
|
1407
|
-
const hash = hashPortableDatabaseSchema(
|
|
1412
|
+
const hash = hashPortableDatabaseSchema(sourceManifestsById.get(entry.id));
|
|
1408
1413
|
const existing = existingByKey.get(entry.stableKey);
|
|
1409
1414
|
if (existing && !input.force) {
|
|
1410
1415
|
const localHash = hashPortableDatabaseSchema(existing.manifest);
|
|
1411
1416
|
const baseline = lock.databaseSchemas[entry.stableKey];
|
|
1412
|
-
if (localHash !== hash &&
|
|
1417
|
+
if (localHash !== hash && localHash !== syncSourceBaselineHash('database-table', baseline)) {
|
|
1413
1418
|
skipped.push({
|
|
1414
1419
|
targetPath: localTargetPath(input.cwd, existing.manifestPath),
|
|
1415
1420
|
reason: 'local manifest changed since the lock baseline; use --force to overwrite',
|
|
@@ -1420,6 +1425,7 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1420
1425
|
writes.push({
|
|
1421
1426
|
manifest,
|
|
1422
1427
|
hash,
|
|
1428
|
+
sourceHash: withoutSyncOmit(() => hashPortableDatabaseSchema(manifest)),
|
|
1423
1429
|
filePath: resolvePath(entry),
|
|
1424
1430
|
...(entry.parentId || typeof entry.record.restricted !== 'boolean'
|
|
1425
1431
|
? {}
|
|
@@ -1455,7 +1461,7 @@ export async function pullDatabaseSchemasToWorkspace(input) {
|
|
|
1455
1461
|
const entry = {
|
|
1456
1462
|
stableKey: write.manifest.stableKey,
|
|
1457
1463
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
1458
|
-
sourceHash: write.
|
|
1464
|
+
sourceHash: write.sourceHash,
|
|
1459
1465
|
...(typeof write.sourceRestricted === 'boolean' ? { sourceRestricted: write.sourceRestricted } : {}),
|
|
1460
1466
|
...(write.manifest.parentStableKey ? { parentStableKey: write.manifest.parentStableKey } : {}),
|
|
1461
1467
|
environments: {
|
|
@@ -1635,12 +1641,12 @@ function verifyCreatedDatabaseSchema(input) {
|
|
|
1635
1641
|
if (verified.length !== 1) {
|
|
1636
1642
|
throw new Error('created target could not be resolved into the live partition graph');
|
|
1637
1643
|
}
|
|
1638
|
-
const remoteHash = verified[0].
|
|
1639
|
-
const desiredHash = hashPortableDatabaseSchema(input.desired);
|
|
1644
|
+
const remoteHash = withoutSyncOmit(() => hashPortableDatabaseSchema(verified[0].manifest));
|
|
1645
|
+
const desiredHash = withoutSyncOmit(() => hashPortableDatabaseSchema(input.desired));
|
|
1640
1646
|
if (remoteHash !== desiredHash) {
|
|
1641
1647
|
throw new Error(`created target did not match desired portable hash (desired: ${desiredHash}; actual: ${remoteHash})`);
|
|
1642
1648
|
}
|
|
1643
|
-
return
|
|
1649
|
+
return verified[0].hash;
|
|
1644
1650
|
}
|
|
1645
1651
|
function updateDatabaseSchemaEnvironmentBaseline(input) {
|
|
1646
1652
|
const { projectRoot } = requireProjectLayout(input.cwd, 'Database Table');
|
|
@@ -1649,7 +1655,7 @@ function updateDatabaseSchemaEnvironmentBaseline(input) {
|
|
|
1649
1655
|
const entry = {
|
|
1650
1656
|
stableKey: input.manifest.stableKey,
|
|
1651
1657
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
1652
|
-
sourceHash: hashPortableDatabaseSchema(input.manifest),
|
|
1658
|
+
sourceHash: withoutSyncOmit(() => hashPortableDatabaseSchema(input.manifest)),
|
|
1653
1659
|
...(input.manifest.kind === 'database-schema' && typeof existing?.sourceRestricted === 'boolean'
|
|
1654
1660
|
? { sourceRestricted: existing.sourceRestricted }
|
|
1655
1661
|
: {}),
|
|
@@ -1798,6 +1804,10 @@ function verifyDatabaseSchemaWrite(input) {
|
|
|
1798
1804
|
stableKey: input.desired.stableKey,
|
|
1799
1805
|
stableKeyName: input.stableKeyName,
|
|
1800
1806
|
});
|
|
1807
|
+
if (omitPaths('database-table').length) {
|
|
1808
|
+
const previous = resolveDatabaseSchemaManifestFromRecords({ records: input.recordsBeforeWrite, databaseId, stableKey: input.desired.stableKey, stableKeyName: input.stableKeyName });
|
|
1809
|
+
assertOmittedPropertiesPreserved('database-table', previous.manifest, verified.manifest);
|
|
1810
|
+
}
|
|
1801
1811
|
const desiredHash = hashPortableDatabaseSchema(input.desired);
|
|
1802
1812
|
if (verified.hash !== desiredHash) {
|
|
1803
1813
|
throw new Error(`written target did not match desired portable hash (desired: ${desiredHash}; actual: ${verified.hash})`);
|
|
@@ -1933,6 +1943,9 @@ function recordDeletedPartitionTombstone(input) {
|
|
|
1933
1943
|
writeComponentLock(projectRoot, lock);
|
|
1934
1944
|
}
|
|
1935
1945
|
export async function pushDatabaseSchemas(input) {
|
|
1946
|
+
if (input.async && (!input.stableKey || input.prunePartitions || input.pruneOrphans)) {
|
|
1947
|
+
throw new Error('--async requires one Database Table Stable Key and cannot prune dependent resources.');
|
|
1948
|
+
}
|
|
1936
1949
|
const plan = await buildDatabaseSchemasPlan(input);
|
|
1937
1950
|
const localByKey = readWorkspaceDatabaseSchemasForPush(input.cwd, input.stableKeyName);
|
|
1938
1951
|
if (input.stableKey && !localByKey.has(input.stableKey) && input.pruneOrphans !== true) {
|
|
@@ -2013,11 +2026,22 @@ export async function pushDatabaseSchemas(input) {
|
|
|
2013
2026
|
stableKeyName: input.stableKeyName,
|
|
2014
2027
|
});
|
|
2015
2028
|
lastMutation.at = Date.now();
|
|
2016
|
-
const
|
|
2017
|
-
manifest: desired,
|
|
2018
|
-
parentName: preflight.parentName,
|
|
2029
|
+
const payload = createPayloadForDatabaseSchema({
|
|
2030
|
+
manifest: desired, parentName: preflight.parentName,
|
|
2019
2031
|
restricted: sourceLock.databaseSchemas[stableKey]?.sourceRestricted === true,
|
|
2020
|
-
})
|
|
2032
|
+
});
|
|
2033
|
+
if (input.async) {
|
|
2034
|
+
const operation = await input.client.acceptDatabaseSchema(payload, undefined, input.idempotencyKey);
|
|
2035
|
+
if (!isDatabaseSchemaOperation(operation))
|
|
2036
|
+
throw new Error('Backend did not return a durable schema receipt.');
|
|
2037
|
+
const accepted = { stableKey, action: 'create', status: 'accepted',
|
|
2038
|
+
targetPath: localTargetPath(input.cwd, local.manifestPath), operation,
|
|
2039
|
+
reason: `Schema operation ${operation.jobId}: ${operation.status}; baseline awaits verified completion` };
|
|
2040
|
+
results.push(accepted);
|
|
2041
|
+
resultsByKey.set(stableKey, accepted);
|
|
2042
|
+
continue;
|
|
2043
|
+
}
|
|
2044
|
+
const created = unwrapData(await input.client.createDatabaseSchema(payload, { idempotencyKey: input.idempotencyKey }));
|
|
2021
2045
|
writeAccepted = true;
|
|
2022
2046
|
const createdId = databaseIdOf(created);
|
|
2023
2047
|
if (!createdId) {
|
|
@@ -2048,6 +2072,8 @@ export async function pushDatabaseSchemas(input) {
|
|
|
2048
2072
|
resultsByKey.set(stableKey, deployed);
|
|
2049
2073
|
}
|
|
2050
2074
|
catch (error) {
|
|
2075
|
+
if (error instanceof DatabaseSchemaOperationWaitError)
|
|
2076
|
+
writeAccepted = true;
|
|
2051
2077
|
const message = error instanceof Error ? error.message : String(error);
|
|
2052
2078
|
const unavailableParent = error instanceof PartitionParentUnavailableError;
|
|
2053
2079
|
const result = {
|
|
@@ -2116,12 +2142,18 @@ export async function pushDatabaseSchemas(input) {
|
|
|
2116
2142
|
}
|
|
2117
2143
|
await waitForDatabaseSchemaMutation(lastMutation.at);
|
|
2118
2144
|
lastMutation.at = Date.now();
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2145
|
+
const effectiveDesired = preserveOmittedProperties('database-table', desired, live.manifest);
|
|
2146
|
+
const payload = buildDatabaseSchemaUpdatePayload({ desired: effectiveDesired, target: live.record,
|
|
2147
|
+
stableKeyName: input.stableKeyName, sourceWins: input.migrationPolicy?.sourceWins });
|
|
2148
|
+
if (input.async) {
|
|
2149
|
+
const operation = await input.client.acceptDatabaseSchema(payload, live.databaseId, input.idempotencyKey);
|
|
2150
|
+
if (!isDatabaseSchemaOperation(operation))
|
|
2151
|
+
throw new Error('Backend did not return a durable schema receipt.');
|
|
2152
|
+
results.push({ stableKey, action, status: 'accepted', targetPath, operation,
|
|
2153
|
+
reason: `Schema operation ${operation.jobId}: ${operation.status}; baseline awaits verified completion` });
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
await input.client.updateDatabaseSchema(live.databaseId, payload, { idempotencyKey: input.idempotencyKey });
|
|
2125
2157
|
writeAccepted = true;
|
|
2126
2158
|
if (live.record.audit === true) {
|
|
2127
2159
|
lastAuditedWrite.at = Date.now();
|
|
@@ -2174,6 +2206,8 @@ export async function pushDatabaseSchemas(input) {
|
|
|
2174
2206
|
});
|
|
2175
2207
|
}
|
|
2176
2208
|
catch (error) {
|
|
2209
|
+
if (error instanceof DatabaseSchemaOperationWaitError)
|
|
2210
|
+
writeAccepted = true;
|
|
2177
2211
|
const message = error instanceof Error ? error.message : String(error);
|
|
2178
2212
|
results.push({
|
|
2179
2213
|
stableKey,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths, assertOmittedPropertiesPreserved } from "../sync-omit.js";
|
|
1
2
|
import { normalizeDatabaseIndexes, databaseIndexPayload, databaseIndexReferences } from "../database-indexes.js";
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { describeFieldChanges, unifiedLineDiff } from "../diff-details.js";
|
|
@@ -130,7 +131,7 @@ function validManifest(value, stableKeyName) {
|
|
|
130
131
|
return stableKeyOf(value, stableKeyName) === value.stableKey;
|
|
131
132
|
}
|
|
132
133
|
export function hashPortableDatabaseView(manifest) {
|
|
133
|
-
return
|
|
134
|
+
return hashSyncDefinition('database-view', canonicalValue({
|
|
134
135
|
...manifest,
|
|
135
136
|
...(manifest.type === 'MATERIALIZED_VIEW' ? { indexes: normalizeDatabaseIndexes(manifest.indexes) } : {}),
|
|
136
137
|
sources: [...manifest.sources].sort((left, right) => (left.databaseStableKey.localeCompare(right.databaseStableKey)
|
|
@@ -575,7 +576,7 @@ export async function buildDatabaseViewsPlan(input) {
|
|
|
575
576
|
continue;
|
|
576
577
|
}
|
|
577
578
|
const entry = entries[0];
|
|
578
|
-
|
|
579
|
+
let desired = entry.manifest;
|
|
579
580
|
const desiredHash = hashPortableDatabaseView(desired);
|
|
580
581
|
const comparableRecords = targetByKey.get(stableKey) || [];
|
|
581
582
|
const comparableTarget = comparableRecords.length === 1
|
|
@@ -601,6 +602,8 @@ export async function buildDatabaseViewsPlan(input) {
|
|
|
601
602
|
items.push({ status: 'conflict', stableKey, name: desired.name, reason: sourceReadiness, desiredHash, ...rawQueryDetail });
|
|
602
603
|
continue;
|
|
603
604
|
}
|
|
605
|
+
if (comparableTarget && typeof comparableTarget !== 'string')
|
|
606
|
+
desired = preserveOmittedProperties('database-view', desired, comparableTarget);
|
|
604
607
|
const currentDetails = comparableTarget && typeof comparableTarget !== 'string'
|
|
605
608
|
? {
|
|
606
609
|
currentHash: hashPortableDatabaseView(comparableTarget),
|
|
@@ -611,7 +614,7 @@ export async function buildDatabaseViewsPlan(input) {
|
|
|
611
614
|
const baseline = lock.databaseViews[stableKey]?.environments[input.envName];
|
|
612
615
|
const dependencyHash = databaseViewDependencyHash(desired, input.dependencyDatabases || targetDatabases, input.stableKeyName);
|
|
613
616
|
const unchanged = currentDetails.currentHash === desiredHash
|
|
614
|
-
&& baseline
|
|
617
|
+
&& syncBaselineHash('database-view', baseline) === desiredHash
|
|
615
618
|
&& dependencyHash !== undefined && baseline.dependencyHash === dependencyHash;
|
|
616
619
|
if (input.migrationPolicy?.deferPreview === true) {
|
|
617
620
|
warnings.push(`Database View "${stableKey}" TARGET preview is deferred until Database Table migration completes.`);
|
|
@@ -683,7 +686,7 @@ export async function buildDatabaseViewsPlan(input) {
|
|
|
683
686
|
}
|
|
684
687
|
}
|
|
685
688
|
const currentHash = hashPortableDatabaseView(current);
|
|
686
|
-
const baselineHash = lock.databaseViews[stableKey]?.environments[input.envName]
|
|
689
|
+
const baselineHash = syncBaselineHash('database-view', lock.databaseViews[stableKey]?.environments[input.envName]);
|
|
687
690
|
if (desiredHash === currentHash) {
|
|
688
691
|
items.push({
|
|
689
692
|
status: baselineHash ? 'clean' : 'missing-lock',
|
|
@@ -712,7 +715,7 @@ export async function buildDatabaseViewsPlan(input) {
|
|
|
712
715
|
});
|
|
713
716
|
continue;
|
|
714
717
|
}
|
|
715
|
-
const localChanged = hashDatabaseViewManifest(desired) !== lock.databaseViews[stableKey]
|
|
718
|
+
const localChanged = hashDatabaseViewManifest(desired) !== syncSourceBaselineHash('database-view', lock.databaseViews[stableKey]);
|
|
716
719
|
const targetChanged = currentHash !== baselineHash;
|
|
717
720
|
const status = localChanged && targetChanged ? 'conflict' : targetChanged ? 'remote-changed' : 'safe-update';
|
|
718
721
|
items.push({
|
|
@@ -840,12 +843,12 @@ function verifyCreatedDatabaseView(input) {
|
|
|
840
843
|
if (typeof actual === 'string') {
|
|
841
844
|
throw new Error(actual);
|
|
842
845
|
}
|
|
843
|
-
const desiredHash = hashPortableDatabaseView(input.desired);
|
|
844
|
-
const remoteHash = hashPortableDatabaseView(actual);
|
|
846
|
+
const desiredHash = withoutSyncOmit(() => hashPortableDatabaseView(input.desired));
|
|
847
|
+
const remoteHash = withoutSyncOmit(() => hashPortableDatabaseView(actual));
|
|
845
848
|
if (remoteHash !== desiredHash) {
|
|
846
849
|
throw new Error(`created target did not match desired portable hash (desired: ${desiredHash}; actual: ${remoteHash})`);
|
|
847
850
|
}
|
|
848
|
-
return
|
|
851
|
+
return hashPortableDatabaseView(actual);
|
|
849
852
|
}
|
|
850
853
|
function targetPrincipalIds(entries, property) {
|
|
851
854
|
const ids = [];
|
|
@@ -870,31 +873,32 @@ function updateDatabaseViewPayload(input) {
|
|
|
870
873
|
throw new Error('TARGET version is unavailable for optimistic update');
|
|
871
874
|
}
|
|
872
875
|
const version = input.target.version;
|
|
876
|
+
const manifest = preserveOmittedProperties('database-view', input.manifest, { ...input.manifest, name: input.target.name, category: input.target.category, description: input.target.desc, metadata: input.target.metadata });
|
|
873
877
|
const base = {
|
|
874
|
-
name:
|
|
875
|
-
category:
|
|
876
|
-
desc:
|
|
877
|
-
metadata: sanitizeUserMetadata(
|
|
878
|
-
type:
|
|
878
|
+
name: manifest.name,
|
|
879
|
+
category: manifest.category ?? null,
|
|
880
|
+
desc: manifest.description ?? null,
|
|
881
|
+
metadata: sanitizeUserMetadata(manifest.metadata),
|
|
882
|
+
type: manifest.type,
|
|
879
883
|
restricted: input.target.restricted,
|
|
880
884
|
users: targetPrincipalIds(input.target.users, 'userId'),
|
|
881
885
|
groups: targetPrincipalIds(input.target.groups, 'groupId'),
|
|
882
886
|
version,
|
|
883
|
-
...(
|
|
884
|
-
? { uniqueKey:
|
|
887
|
+
...(manifest.type === 'MATERIALIZED_VIEW'
|
|
888
|
+
? { uniqueKey: manifest.uniqueKey, indexes: databaseViewWriteIndexes(manifest.indexes) }
|
|
885
889
|
: {}),
|
|
886
890
|
};
|
|
887
|
-
if (
|
|
891
|
+
if (manifest.definitionMode === 'RAW_SQL') {
|
|
888
892
|
return {
|
|
889
893
|
...base,
|
|
890
894
|
definitionMode: 'RAW_SQL',
|
|
891
|
-
rawQuery:
|
|
895
|
+
rawQuery: manifest.rawQuery,
|
|
892
896
|
};
|
|
893
897
|
}
|
|
894
898
|
return {
|
|
895
899
|
...base,
|
|
896
900
|
definitionMode: 'STRUCTURED',
|
|
897
|
-
request: canonicalValue(
|
|
901
|
+
request: canonicalValue(manifest.request),
|
|
898
902
|
};
|
|
899
903
|
}
|
|
900
904
|
function verifyUpdatedDatabaseView(input) {
|
|
@@ -920,6 +924,12 @@ function verifyUpdatedDatabaseView(input) {
|
|
|
920
924
|
if (typeof actual === 'string') {
|
|
921
925
|
throw new Error(actual);
|
|
922
926
|
}
|
|
927
|
+
if (input.previous && omitPaths('database-view').length) {
|
|
928
|
+
const previous = manifestFromRecord({ record: input.previous, stableKey: input.desired.stableKey, stableKeyName: input.stableKeyName, inventory: sourceInventory(input.databases, input.stableKeyName) });
|
|
929
|
+
if (typeof previous === 'string')
|
|
930
|
+
throw new Error(previous);
|
|
931
|
+
assertOmittedPropertiesPreserved('database-view', previous, actual);
|
|
932
|
+
}
|
|
923
933
|
const remoteHash = hashPortableDatabaseView(actual);
|
|
924
934
|
const desiredHash = hashPortableDatabaseView(input.desired);
|
|
925
935
|
if (remoteHash !== desiredHash) {
|
|
@@ -948,7 +958,7 @@ async function recheckDatabaseViewUpdate(input) {
|
|
|
948
958
|
&& input.migrationPolicy?.allowDestructive !== true) {
|
|
949
959
|
throw new Error('TARGET Database View changed type or definitionMode after planning');
|
|
950
960
|
}
|
|
951
|
-
if (target.name !== input.manifest.name && input.migrationPolicy?.sourceWins !== true) {
|
|
961
|
+
if (target.name !== input.manifest.name && !omitPaths('database-view').some(path => path.length === 1 && path[0] === 'name') && input.migrationPolicy?.sourceWins !== true) {
|
|
952
962
|
throw new Error('TARGET name differs; renames require an explicit migration');
|
|
953
963
|
}
|
|
954
964
|
const sourceReadiness = validateTargetSources(input.manifest, databaseResult.databases, input.stableKeyName);
|
|
@@ -978,7 +988,7 @@ function updateDatabaseViewEnvironmentBaseline(input) {
|
|
|
978
988
|
const entry = {
|
|
979
989
|
stableKey: input.manifest.stableKey,
|
|
980
990
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
981
|
-
sourceHash: hashDatabaseViewManifest(input.manifest),
|
|
991
|
+
sourceHash: withoutSyncOmit(() => hashDatabaseViewManifest(input.manifest)),
|
|
982
992
|
environments: {
|
|
983
993
|
...(existing?.environments || {}),
|
|
984
994
|
[input.envName]: {
|
|
@@ -1131,6 +1141,7 @@ export async function pushDatabaseViews(input) {
|
|
|
1131
1141
|
databases: live.databases,
|
|
1132
1142
|
desired,
|
|
1133
1143
|
stableKeyName: input.stableKeyName,
|
|
1144
|
+
previous: live.target,
|
|
1134
1145
|
expectedRestricted: payload.restricted,
|
|
1135
1146
|
expectedUsers: payload.users,
|
|
1136
1147
|
expectedGroups: payload.groups,
|
|
@@ -1190,6 +1201,7 @@ export async function pushDatabaseViews(input) {
|
|
|
1190
1201
|
databases: live.databases,
|
|
1191
1202
|
desired: local.manifest,
|
|
1192
1203
|
stableKeyName: input.stableKeyName,
|
|
1204
|
+
previous: live.target,
|
|
1193
1205
|
expectedRestricted: accessPolicy.restricted,
|
|
1194
1206
|
expectedUsers: accessPolicy.users,
|
|
1195
1207
|
expectedGroups: accessPolicy.groups,
|
|
@@ -1283,20 +1295,21 @@ export async function pullDatabaseViewsToWorkspace(input) {
|
|
|
1283
1295
|
existingByKey.set(entry.manifest.stableKey, entry);
|
|
1284
1296
|
existingByPath.set(path.resolve(entry.manifestPath), entry);
|
|
1285
1297
|
}
|
|
1286
|
-
const writes = manifests.map((
|
|
1287
|
-
const existing = existingByKey.get(
|
|
1288
|
-
const
|
|
1298
|
+
const writes = manifests.map((sourceManifest) => {
|
|
1299
|
+
const existing = existingByKey.get(sourceManifest.stableKey);
|
|
1300
|
+
const remoteHash = hashPortableDatabaseView(sourceManifest);
|
|
1289
1301
|
if (existing && !input.force) {
|
|
1290
1302
|
const localHash = hashDatabaseViewManifest(existing.manifest);
|
|
1291
|
-
const baseline = lock.databaseViews[
|
|
1292
|
-
if (localHash !==
|
|
1293
|
-
throw new Error(`Cannot pull Database View "${
|
|
1303
|
+
const baseline = lock.databaseViews[sourceManifest.stableKey];
|
|
1304
|
+
if (localHash !== remoteHash && localHash !== syncSourceBaselineHash('database-view', baseline)) {
|
|
1305
|
+
throw new Error(`Cannot pull Database View "${sourceManifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
1294
1306
|
}
|
|
1295
1307
|
}
|
|
1308
|
+
const manifest = preserveOmittedProperties('database-view', sourceManifest, existing?.manifest);
|
|
1296
1309
|
return {
|
|
1297
1310
|
manifest,
|
|
1298
|
-
sourceHash,
|
|
1299
|
-
remoteHash
|
|
1311
|
+
sourceHash: withoutSyncOmit(() => hashDatabaseViewManifest(manifest)),
|
|
1312
|
+
remoteHash,
|
|
1300
1313
|
filePath: databaseViewManifestPath(workspaceRoot, manifest),
|
|
1301
1314
|
previousPath: existing?.manifestPath,
|
|
1302
1315
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { requestContractDefaults } from "../request-contract.js";
|
|
2
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths } from "../sync-omit.js";
|
|
1
3
|
import { loadComponentSources } from "../component-manifests.js";
|
|
2
4
|
import { componentContentDigest, componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
|
|
3
5
|
import { executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validPortableExecutionPolicy } from "./account-principal.js";
|
|
@@ -184,7 +186,7 @@ export function hashPortableEndpoint(manifest) {
|
|
|
184
186
|
}
|
|
185
187
|
function endpointDefinitionHash(manifest, normalizeDefaults) {
|
|
186
188
|
const options = normalizeDefaults ? canonicalPortableOptions(manifest.options) : canonicalValue(manifest.options);
|
|
187
|
-
return
|
|
189
|
+
return hashSyncDefinition('endpoint', {
|
|
188
190
|
kind: manifest.kind,
|
|
189
191
|
stableKey: manifest.stableKey,
|
|
190
192
|
name: manifest.name,
|
|
@@ -398,20 +400,23 @@ export async function pullEndpointsToWorkspace(input) {
|
|
|
398
400
|
const identity = portablePathIdentity(entry.manifestPath);
|
|
399
401
|
existingByPath.set(identity, [...(existingByPath.get(identity) || []), entry]);
|
|
400
402
|
}
|
|
401
|
-
const writes = manifests.map((
|
|
402
|
-
const hash = hashPortableEndpoint(
|
|
403
|
-
const existing = existingByKey.get(
|
|
403
|
+
const writes = manifests.map((incoming) => {
|
|
404
|
+
const hash = hashPortableEndpoint(incoming);
|
|
405
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
406
|
+
const manifest = existing ? preserveOmittedProperties('endpoint', incoming, existing.manifest) : incoming;
|
|
407
|
+
const sourceHash = withoutSyncOmit(() => hashPortableEndpoint(manifest));
|
|
404
408
|
if (existing && !input.force) {
|
|
405
409
|
const localHash = hashPortableEndpoint(existing.manifest);
|
|
406
410
|
const baseline = lock.endpoints[manifest.stableKey];
|
|
407
|
-
if (localHash !== hash && (!baseline || localHash !== baseline
|
|
408
|
-
&& endpointDefinitionHash(existing.manifest, false) !== baseline.sourceHash)) {
|
|
411
|
+
if (localHash !== hash && (!baseline || localHash !== syncSourceBaselineHash('endpoint', baseline)
|
|
412
|
+
&& withoutSyncOmit(() => endpointDefinitionHash(existing.manifest, false)) !== baseline.sourceHash)) {
|
|
409
413
|
throw new Error(`Cannot pull endpoint "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
410
414
|
}
|
|
411
415
|
}
|
|
412
416
|
return {
|
|
413
417
|
manifest,
|
|
414
418
|
hash,
|
|
419
|
+
sourceHash,
|
|
415
420
|
filePath: endpointManifestPath(workspaceRoot, manifest),
|
|
416
421
|
...(existing ? { previousPath: existing.manifestPath } : {}),
|
|
417
422
|
};
|
|
@@ -465,7 +470,7 @@ export async function pullEndpointsToWorkspace(input) {
|
|
|
465
470
|
const entry = {
|
|
466
471
|
stableKey: write.manifest.stableKey,
|
|
467
472
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
468
|
-
sourceHash: write.
|
|
473
|
+
sourceHash: write.sourceHash,
|
|
469
474
|
environments: {
|
|
470
475
|
...(previous?.environments || {}),
|
|
471
476
|
[input.envName]: previousBaseline?.remoteHash === write.hash
|
|
@@ -513,6 +518,7 @@ function endpointRecordRouteKey(record) {
|
|
|
513
518
|
}
|
|
514
519
|
}
|
|
515
520
|
function diffEndpoints(desired, current) {
|
|
521
|
+
desired = preserveOmittedProperties('endpoint', desired, current);
|
|
516
522
|
const fields = [
|
|
517
523
|
['name', desired.name, current.name],
|
|
518
524
|
['category', desired.category ?? null, current.category ?? null],
|
|
@@ -873,6 +879,12 @@ export async function buildEndpointsPlan(input) {
|
|
|
873
879
|
});
|
|
874
880
|
}
|
|
875
881
|
}
|
|
882
|
+
for (const [stableKey, entries] of localByStableKey) {
|
|
883
|
+
const targets = liveTargetsByStableKey.get(stableKey) || [];
|
|
884
|
+
if (entries.length === 1 && targets.length === 1) {
|
|
885
|
+
entries[0] = { ...entries[0], manifest: preserveOmittedProperties('endpoint', entries[0].manifest, targets[0].manifest) };
|
|
886
|
+
}
|
|
887
|
+
}
|
|
876
888
|
const desiredRouteOwners = new Map();
|
|
877
889
|
const desiredRoutesByStableKey = new Map();
|
|
878
890
|
for (const [stableKey, entries] of localByStableKey) {
|
|
@@ -1047,7 +1059,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
1047
1059
|
}
|
|
1048
1060
|
consumedTargets.add(stableKey);
|
|
1049
1061
|
const current = targets[0];
|
|
1050
|
-
const baselineHash = lock.endpoints[stableKey]?.environments[input.envName]
|
|
1062
|
+
const baselineHash = syncBaselineHash('endpoint', lock.endpoints[stableKey]?.environments[input.envName]);
|
|
1051
1063
|
const common = {
|
|
1052
1064
|
...dependencyBlockers,
|
|
1053
1065
|
stableKey,
|
|
@@ -1200,6 +1212,24 @@ async function resolveEndpointWritePayload(input) {
|
|
|
1200
1212
|
};
|
|
1201
1213
|
return common;
|
|
1202
1214
|
}
|
|
1215
|
+
function assertEndpointOmitWriteSafe(target, desired, options) {
|
|
1216
|
+
if (!omitPaths('endpoint').some(parts => parts[0] === 'options'))
|
|
1217
|
+
return;
|
|
1218
|
+
let normalized = options;
|
|
1219
|
+
if (options) {
|
|
1220
|
+
normalized = { ...requestContractDefaults.endpoint.optionDefaults, ...structuredClone(options), input: options.input ?? {} };
|
|
1221
|
+
if (!normalized.memory)
|
|
1222
|
+
normalized.memory = requestContractDefaults.endpoint.optionDefaults.memory;
|
|
1223
|
+
if (typeof normalized.popResult === 'string')
|
|
1224
|
+
normalized.popResult = `${normalized.popResult.charAt(0).toUpperCase()}${normalized.popResult.slice(1)}`;
|
|
1225
|
+
}
|
|
1226
|
+
try {
|
|
1227
|
+
assertOmittedPropertiesPreserved('endpoint', target, { ...desired, options: normalized });
|
|
1228
|
+
}
|
|
1229
|
+
catch {
|
|
1230
|
+
throw new Error('Endpoint options cannot be updated without normalizing an omitted property; align target defaults or omit the complete options envelope.');
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1203
1233
|
async function updateEndpointConfigurationAndActivation(input) {
|
|
1204
1234
|
const latest = unwrapData(await input.client.getEndpoint(input.endpointId));
|
|
1205
1235
|
const latestStableKey = readConfiguredResourceMetadataStableKey(latest, input.stableKeyName);
|
|
@@ -1212,20 +1242,51 @@ async function updateEndpointConfigurationAndActivation(input) {
|
|
|
1212
1242
|
if (typeof latest.version !== 'number') {
|
|
1213
1243
|
throw new Error(`${input.targetLabel} did not include a current version`);
|
|
1214
1244
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1245
|
+
let effectiveManifest = input.manifest;
|
|
1246
|
+
let preservedTargetManifest;
|
|
1247
|
+
let preservationComponents;
|
|
1248
|
+
if (omitPaths('endpoint').length > 0) {
|
|
1249
|
+
const targetComponents = await loadRemoteComponents(input.client, input.cwd);
|
|
1250
|
+
preservationComponents = new Map(targetComponents.map(component => [componentIdOf(component), component]));
|
|
1251
|
+
const currentManifest = await manifestFromRecord({
|
|
1252
|
+
includeExecutionPolicy: input.manifest.executionPolicy !== undefined,
|
|
1253
|
+
client: input.client,
|
|
1254
|
+
record: latest,
|
|
1255
|
+
stableKey: input.stableKey,
|
|
1256
|
+
stableKeyName: input.stableKeyName,
|
|
1257
|
+
componentsById: preservationComponents,
|
|
1258
|
+
});
|
|
1259
|
+
preservedTargetManifest = currentManifest;
|
|
1260
|
+
effectiveManifest = preserveOmittedProperties('endpoint', input.manifest, currentManifest);
|
|
1261
|
+
}
|
|
1262
|
+
const payload = await resolveEndpointWritePayload({ ...input, manifest: effectiveManifest });
|
|
1263
|
+
const runtimePaths = omitPaths('endpoint').filter(parts => parts[0] === 'options');
|
|
1264
|
+
const wholeOptions = runtimePaths.some(parts => parts.length === 1);
|
|
1265
|
+
const schemaChanged = preservedTargetManifest && hashStable(effectiveManifest.schema ?? null) !== hashStable(preservedTargetManifest.schema ?? null);
|
|
1266
|
+
if (wholeOptions && schemaChanged)
|
|
1267
|
+
throw new Error('Endpoint schema binding cannot change while the complete options envelope is omitted; reconcile the binding or narrow --omit before deployment.');
|
|
1268
|
+
const runtimeChanged = !preservedTargetManifest || hashStable(canonicalPortableOptions(effectiveManifest.options)) !== hashStable(canonicalPortableOptions(preservedTargetManifest.options)) || schemaChanged;
|
|
1269
|
+
const { options, ...configuration } = payload;
|
|
1270
|
+
const writeOptions = runtimePaths.length > 0 && !runtimeChanged ? {} : { options: options ?? null };
|
|
1271
|
+
if (Object.hasOwn(writeOptions, 'options') && preservedTargetManifest)
|
|
1272
|
+
assertEndpointOmitWriteSafe(preservedTargetManifest, effectiveManifest, options ?? null);
|
|
1273
|
+
await input.client.updateEndpoint(input.endpointId, { ...configuration, ...writeOptions, version: latest.version });
|
|
1274
|
+
let configured = unwrapData(await input.client.getEndpoint(input.endpointId));
|
|
1275
|
+
if (Boolean(configured.active) !== effectiveManifest.active) {
|
|
1276
|
+
if (effectiveManifest.active) {
|
|
1224
1277
|
await input.client.activateEndpoint(input.endpointId);
|
|
1225
1278
|
}
|
|
1226
1279
|
else {
|
|
1227
1280
|
await input.client.disableEndpoint(input.endpointId);
|
|
1228
1281
|
}
|
|
1282
|
+
if (preservedTargetManifest)
|
|
1283
|
+
configured = unwrapData(await input.client.getEndpoint(input.endpointId));
|
|
1284
|
+
}
|
|
1285
|
+
if (preservedTargetManifest) {
|
|
1286
|
+
const verifiedManifest = await manifestFromRecord({ client: input.client, record: configured,
|
|
1287
|
+
stableKey: input.stableKey, stableKeyName: input.stableKeyName,
|
|
1288
|
+
includeExecutionPolicy: input.manifest.executionPolicy !== undefined, componentsById: preservationComponents });
|
|
1289
|
+
assertOmittedPropertiesPreserved('endpoint', preservedTargetManifest, verifiedManifest);
|
|
1229
1290
|
}
|
|
1230
1291
|
}
|
|
1231
1292
|
async function verifyEndpointWrite(input) {
|
|
@@ -1244,6 +1305,8 @@ async function verifyEndpointWrite(input) {
|
|
|
1244
1305
|
stableKeyName: input.stableKeyName,
|
|
1245
1306
|
componentsById,
|
|
1246
1307
|
});
|
|
1308
|
+
if (input.verifyFullSource && !withoutSyncOmit(() => hashPortableEndpoint(verifiedManifest) === hashPortableEndpoint(input.desiredManifest)))
|
|
1309
|
+
throw new Error('Created Endpoint did not initialize the complete source definition.');
|
|
1247
1310
|
const remoteHash = hashPortableEndpoint(verifiedManifest);
|
|
1248
1311
|
if (remoteHash !== input.desiredHash) {
|
|
1249
1312
|
const changedFields = diffEndpoints(input.desiredManifest, verifiedManifest);
|
|
@@ -1264,7 +1327,7 @@ function updateEndpointEnvironmentBaseline(input) {
|
|
|
1264
1327
|
lock.endpoints[stableKey] = {
|
|
1265
1328
|
stableKey,
|
|
1266
1329
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
1267
|
-
sourceHash: hashPortableEndpoint(input.manifest),
|
|
1330
|
+
sourceHash: withoutSyncOmit(() => hashPortableEndpoint(input.manifest)),
|
|
1268
1331
|
environments: {
|
|
1269
1332
|
...(existing?.environments || {}),
|
|
1270
1333
|
[input.envName]: previousBaseline?.remoteHash === input.remoteHash
|
|
@@ -1297,6 +1360,7 @@ async function executeEndpointPushItem(input) {
|
|
|
1297
1360
|
endpointId,
|
|
1298
1361
|
stableKey,
|
|
1299
1362
|
desiredManifest: local.manifest,
|
|
1363
|
+
verifyFullSource: input.action === 'create',
|
|
1300
1364
|
desiredHash,
|
|
1301
1365
|
stableKeyName: input.stableKeyName,
|
|
1302
1366
|
});
|
|
@@ -1523,6 +1587,14 @@ export async function pushEndpoints(input) {
|
|
|
1523
1587
|
&& endpointRecordRouteKey(record) === oldRoute)) {
|
|
1524
1588
|
throw new Error(`restore safety changed after planning: old route ${oldRoute} is now owned by a live endpoint`);
|
|
1525
1589
|
}
|
|
1590
|
+
if (omitPaths('endpoint').some(parts => parts.length === 1 && parts[0] === 'options')) {
|
|
1591
|
+
const priorManifest = await manifestFromRecord({ client: input.client, record: target, stableKey: prepared.stableKey,
|
|
1592
|
+
stableKeyName: input.stableKeyName, includeExecutionPolicy: prepared.manifest.executionPolicy !== undefined,
|
|
1593
|
+
componentsById: new Map(targetComponents.map(component => [componentIdOf(component), component])) });
|
|
1594
|
+
if (hashStable(prepared.manifest.schema ?? null) !== hashStable(priorManifest.schema ?? null)) {
|
|
1595
|
+
throw new Error('Endpoint schema binding cannot change while the complete options envelope is omitted; reconcile the binding or narrow --omit before deployment.');
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1526
1598
|
await input.client.restoreEndpoint(targetId);
|
|
1527
1599
|
const restored = unwrapData(await input.client.getEndpoint(targetId));
|
|
1528
1600
|
const restoredStableKey = readConfiguredResourceMetadataStableKey(restored, input.stableKeyName);
|