@revoengine/cli 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/dist/src/client.d.ts +23 -7
- package/dist/src/client.js +14 -0
- package/dist/src/commands/component.js +17 -0
- package/dist/src/commands/env.js +8 -5
- package/dist/src/commands/migrate.js +5 -1
- package/dist/src/commands/schedules.js +11 -9
- package/dist/src/commands/terminal.d.ts +2 -0
- package/dist/src/commands/terminal.js +106 -31
- package/dist/src/component-contract.d.ts +8 -0
- package/dist/src/component-contract.js +68 -0
- package/dist/src/component-lock.d.ts +4 -2
- package/dist/src/component-lock.js +4 -2
- package/dist/src/database-indexes.d.ts +14 -0
- package/dist/src/database-indexes.js +124 -0
- package/dist/src/env-sync.d.ts +2 -0
- package/dist/src/env-sync.js +18 -2
- package/dist/src/migration-actions.js +1 -1
- package/dist/src/migration.js +3 -3
- package/dist/src/resource-syncs/agent-sync.js +28 -2
- package/dist/src/resource-syncs/database-table-sync.d.ts +3 -0
- package/dist/src/resource-syncs/database-table-sync.js +10 -6
- package/dist/src/resource-syncs/database-view-sync.d.ts +2 -4
- package/dist/src/resource-syncs/database-view-sync.js +16 -38
- package/dist/src/resource-syncs/endpoint-sync.js +69 -30
- package/dist/src/resource-syncs/job-template-sync.d.ts +1 -0
- package/dist/src/resource-syncs/job-template-sync.js +31 -10
- package/dist/src/resource-syncs/schedule-sync.d.ts +7 -3
- package/dist/src/resource-syncs/schedule-sync.js +85 -16
- package/dist/src/types.d.ts +2 -0
- package/dist/src/ui.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { componentContentDigest, componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
|
|
1
2
|
import { executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validPortableExecutionPolicy } from "./account-principal.js";
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { describeFieldChanges } from "../diff-details.js";
|
|
4
|
-
import { hashPortableComponentSource, hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
5
|
+
import { hashPortableComponentSource, normalizePortableComponentSource, hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
5
6
|
import { withHttpTraceContext } from "../http-trace.js";
|
|
6
7
|
import { readConfiguredResourceMetadataStableKey, sanitizeUserMetadata } from "../resource-metadata.js";
|
|
7
8
|
import { HTTP_REQUEST_CONCURRENCY } from "../request-queue.js";
|
|
@@ -68,6 +69,7 @@ function portableOptions(record) {
|
|
|
68
69
|
const options = { ...record.options };
|
|
69
70
|
delete options.componentSchemaId;
|
|
70
71
|
delete options.componentSchemaVersion;
|
|
72
|
+
delete options.componentSchemaDigest;
|
|
71
73
|
delete options.componentSchemaElement;
|
|
72
74
|
return Object.keys(options).length > 0 ? canonicalValue(options) : undefined;
|
|
73
75
|
}
|
|
@@ -75,10 +77,7 @@ function canonicalPortableOptions(options) {
|
|
|
75
77
|
if (options === undefined) {
|
|
76
78
|
return undefined;
|
|
77
79
|
}
|
|
78
|
-
return canonicalValue(
|
|
79
|
-
...options,
|
|
80
|
-
...(options.memory === null ? { memory: ENDPOINT_DEFAULT_MEMORY_MB } : {}),
|
|
81
|
-
});
|
|
80
|
+
return canonicalValue(options);
|
|
82
81
|
}
|
|
83
82
|
function endpointLabel(record, fallback = 'remote-id') {
|
|
84
83
|
const category = typeof record.category === 'string' && record.category.trim()
|
|
@@ -113,7 +112,7 @@ const ENDPOINT_MANIFEST_FIELDS = new Set([
|
|
|
113
112
|
'route', 'options', 'execution', 'executionPolicy', 'schema',
|
|
114
113
|
]);
|
|
115
114
|
const INSTANCE_LOCAL_SCHEMA_OPTION_FIELDS = new Set([
|
|
116
|
-
'componentSchemaId', 'componentSchemaVersion', 'componentSchemaElement',
|
|
115
|
+
'componentSchemaId', 'componentSchemaVersion', 'componentSchemaDigest', 'componentSchemaElement',
|
|
117
116
|
]);
|
|
118
117
|
function hasOnlyKeys(value, allowed) {
|
|
119
118
|
return Object.keys(value).every((key) => allowed.has(key));
|
|
@@ -131,7 +130,7 @@ function hasValidBinding(value) {
|
|
|
131
130
|
if (value.binding === 'latest') {
|
|
132
131
|
return value.pinnedDigest === undefined;
|
|
133
132
|
}
|
|
134
|
-
return
|
|
133
|
+
return isComponentDigest(value.pinnedDigest);
|
|
135
134
|
}
|
|
136
135
|
function hasValidSchemaBinding(value) {
|
|
137
136
|
if (!isRecord(value) || !hasOnlyKeys(value, new Set(['stableKey', 'binding', 'pinnedDigest', 'element']))) {
|
|
@@ -197,12 +196,28 @@ export function hashPortableEndpoint(manifest) {
|
|
|
197
196
|
...(manifest.schema === undefined ? {} : { schema: canonicalValue(manifest.schema) }),
|
|
198
197
|
});
|
|
199
198
|
}
|
|
200
|
-
function readWorkspaceEndpoints(cwd) {
|
|
199
|
+
function readWorkspaceEndpoints(cwd, stableKeyName = 'stableKey') {
|
|
201
200
|
const { workspaceRoot } = requireProjectLayout(cwd, 'Endpoint');
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
manifest
|
|
205
|
-
|
|
201
|
+
let components;
|
|
202
|
+
return findManifestFiles(path.join(workspaceRoot, ENDPOINTS_DIRECTORY), ENDPOINT_MANIFEST_FILE).map(manifestPath => {
|
|
203
|
+
const manifest = readJsonFile(manifestPath);
|
|
204
|
+
if (isRecord(manifest))
|
|
205
|
+
for (const field of ['execution', 'schema']) {
|
|
206
|
+
const binding = manifest[field];
|
|
207
|
+
if (!isRecord(binding) || typeof binding.pinnedDigest !== 'string' || !/^[a-f0-9]{64}$/i.test(binding.pinnedDigest))
|
|
208
|
+
continue;
|
|
209
|
+
components ??= readWorkspaceComponents(cwd, stableKeyName);
|
|
210
|
+
const matches = components.get(String(binding.stableKey)) || [];
|
|
211
|
+
if (matches.length !== 1)
|
|
212
|
+
continue;
|
|
213
|
+
// Before 1.0.22 this value was a configuration fingerprint. Upgrade only
|
|
214
|
+
// when the exact local source proves which content it identifies.
|
|
215
|
+
const { metadata, ...legacy } = normalizePortableComponentSource(matches[0]);
|
|
216
|
+
if (hashStable(legacy) === binding.pinnedDigest)
|
|
217
|
+
binding.pinnedDigest = componentContentDigest(matches[0]);
|
|
218
|
+
}
|
|
219
|
+
return { manifestPath, manifest };
|
|
220
|
+
});
|
|
206
221
|
}
|
|
207
222
|
function readWorkspaceComponents(cwd, stableKeyName) {
|
|
208
223
|
const { workspaceRoot } = requireProjectLayout(cwd, 'Endpoint');
|
|
@@ -255,6 +270,10 @@ async function componentBinding(input) {
|
|
|
255
270
|
throw new Error(`Endpoint "${input.endpointStableKey}" ${input.relation} component is unmanaged: missing ${input.stableKeyName}.`);
|
|
256
271
|
}
|
|
257
272
|
const componentVersion = input.componentVersion;
|
|
273
|
+
if (input.componentDigest) {
|
|
274
|
+
const snapshot = await componentRevisionByDigest(input.client, input.componentId, String(input.componentDigest));
|
|
275
|
+
return { stableKey, binding: 'pinned', pinnedDigest: componentContentDigest(snapshot) };
|
|
276
|
+
}
|
|
258
277
|
if (typeof componentVersion !== 'number') {
|
|
259
278
|
return { stableKey, binding: 'latest' };
|
|
260
279
|
}
|
|
@@ -263,7 +282,7 @@ async function componentBinding(input) {
|
|
|
263
282
|
operation: 'get-snapshot',
|
|
264
283
|
entityId: input.componentId,
|
|
265
284
|
}, () => input.client.getComponentSnapshotVersion(input.componentId, componentVersion)));
|
|
266
|
-
return { stableKey, binding: 'pinned', pinnedDigest:
|
|
285
|
+
return { stableKey, binding: 'pinned', pinnedDigest: componentContentDigest(snapshot) };
|
|
267
286
|
}
|
|
268
287
|
async function manifestFromRecord(input) {
|
|
269
288
|
const { record } = input;
|
|
@@ -286,6 +305,7 @@ async function manifestFromRecord(input) {
|
|
|
286
305
|
componentsById: input.componentsById,
|
|
287
306
|
componentId: executionComponentId,
|
|
288
307
|
componentVersion: record.componentVersion,
|
|
308
|
+
componentDigest: record.componentDigest,
|
|
289
309
|
stableKeyName: input.stableKeyName,
|
|
290
310
|
endpointStableKey: input.stableKey,
|
|
291
311
|
relation: 'execution',
|
|
@@ -304,6 +324,7 @@ async function manifestFromRecord(input) {
|
|
|
304
324
|
componentsById: input.componentsById,
|
|
305
325
|
componentId: schemaComponentId,
|
|
306
326
|
componentVersion: record.options?.componentSchemaVersion,
|
|
327
|
+
componentDigest: record.options?.componentSchemaDigest,
|
|
307
328
|
stableKeyName: input.stableKeyName,
|
|
308
329
|
endpointStableKey: input.stableKey,
|
|
309
330
|
relation: 'schema',
|
|
@@ -374,7 +395,7 @@ export async function pullEndpointsToWorkspace(input) {
|
|
|
374
395
|
const lock = readComponentLock(projectRoot);
|
|
375
396
|
const existingByKey = new Map();
|
|
376
397
|
const existingByPath = new Map();
|
|
377
|
-
for (const entry of readWorkspaceEndpoints(input.cwd)) {
|
|
398
|
+
for (const entry of readWorkspaceEndpoints(input.cwd, input.stableKeyName)) {
|
|
378
399
|
if (!validateManifest(entry.manifest, input.stableKeyName)) {
|
|
379
400
|
throw new Error(`Cannot pull over invalid endpoint manifest ${path.relative(projectRoot, entry.manifestPath)}.`);
|
|
380
401
|
}
|
|
@@ -550,11 +571,11 @@ function componentDependencyDiagnostics(input) {
|
|
|
550
571
|
}
|
|
551
572
|
const workspace = workspaceMatches[0];
|
|
552
573
|
const target = targetMatches.length === 1 ? targetMatches[0] : undefined;
|
|
553
|
-
const workspaceDigest = hashPortableComponentSource(workspace);
|
|
554
|
-
const targetDigest = target ? hashPortableComponentSource(target) : null;
|
|
574
|
+
const workspaceDigest = binding.binding === 'pinned' ? componentContentDigest(workspace) : hashPortableComponentSource(workspace);
|
|
575
|
+
const targetDigest = target ? (binding.binding === 'pinned' ? componentContentDigest(target) : hashPortableComponentSource(target)) : null;
|
|
555
576
|
const projected = usesProjection ? projectedMatches[0] : undefined;
|
|
556
577
|
const expectedHash = binding.binding === 'pinned' ? binding.pinnedDigest || '' : workspaceDigest;
|
|
557
|
-
const projectedHash = projected?.desiredHash ?? targetDigest;
|
|
578
|
+
const projectedHash = binding.binding === 'pinned' && projected ? workspaceDigest : projected?.desiredHash ?? targetDigest;
|
|
558
579
|
const readiness = projected?.state === 'pending-create'
|
|
559
580
|
? 'pending-component-create'
|
|
560
581
|
: projected?.state === 'pending-update'
|
|
@@ -648,6 +669,7 @@ function endpointRevisionHash(record) {
|
|
|
648
669
|
method: record.method ?? null,
|
|
649
670
|
componentId: record.componentId ?? null,
|
|
650
671
|
componentVersion: record.componentVersion ?? null,
|
|
672
|
+
componentDigest: record.componentDigest ?? null,
|
|
651
673
|
options: canonicalValue(record.options ?? null),
|
|
652
674
|
version: record.version ?? null,
|
|
653
675
|
deletedAt: record.deletedAt ?? null,
|
|
@@ -659,7 +681,7 @@ async function activeDeletedEndpointRestoreBlockers(input) {
|
|
|
659
681
|
return [];
|
|
660
682
|
}
|
|
661
683
|
const blockers = [];
|
|
662
|
-
const loadBinding = async (componentId, version, relation) => {
|
|
684
|
+
const loadBinding = async (componentId, version, relation, digest) => {
|
|
663
685
|
const current = input.componentsById.get(componentId);
|
|
664
686
|
if (!current) {
|
|
665
687
|
blockers.push(`old ${relation} Component "${componentId}" is missing`);
|
|
@@ -670,9 +692,11 @@ async function activeDeletedEndpointRestoreBlockers(input) {
|
|
|
670
692
|
return undefined;
|
|
671
693
|
}
|
|
672
694
|
try {
|
|
673
|
-
const component =
|
|
674
|
-
?
|
|
675
|
-
:
|
|
695
|
+
const component = digest
|
|
696
|
+
? await componentRevisionByDigest(input.client, componentId, String(digest))
|
|
697
|
+
: typeof version === 'number'
|
|
698
|
+
? unwrapData(await input.client.getComponentSnapshotVersion(componentId, version))
|
|
699
|
+
: current;
|
|
676
700
|
if (!component) {
|
|
677
701
|
blockers.push(`old ${relation} Component "${componentId}" is missing`);
|
|
678
702
|
}
|
|
@@ -684,7 +708,7 @@ async function activeDeletedEndpointRestoreBlockers(input) {
|
|
|
684
708
|
}
|
|
685
709
|
};
|
|
686
710
|
if (typeof input.record.componentId === 'string' && input.record.componentId) {
|
|
687
|
-
const execution = await loadBinding(input.record.componentId, input.record.componentVersion, 'execution');
|
|
711
|
+
const execution = await loadBinding(input.record.componentId, input.record.componentVersion, 'execution', input.record.componentDigest);
|
|
688
712
|
if (execution && !new Set(['CODE_JS', 'CODE_TS']).has(componentType(execution))) {
|
|
689
713
|
blockers.push(`old execution Component "${input.record.componentId}" is not executable`);
|
|
690
714
|
}
|
|
@@ -692,7 +716,7 @@ async function activeDeletedEndpointRestoreBlockers(input) {
|
|
|
692
716
|
const options = isRecord(input.record.options) ? input.record.options : {};
|
|
693
717
|
const schemaId = typeof options.componentSchemaId === 'string' ? options.componentSchemaId : '';
|
|
694
718
|
if (schemaId) {
|
|
695
|
-
const schema = await loadBinding(schemaId, options.componentSchemaVersion, 'schema');
|
|
719
|
+
const schema = await loadBinding(schemaId, options.componentSchemaVersion, 'schema', options.componentSchemaDigest);
|
|
696
720
|
if (schema && componentType(schema) !== 'JSON_VALIDATOR') {
|
|
697
721
|
blockers.push(`old schema Component "${schemaId}" is not JSON_VALIDATOR`);
|
|
698
722
|
}
|
|
@@ -715,7 +739,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
715
739
|
const warnings = [];
|
|
716
740
|
const exclusions = [];
|
|
717
741
|
const localByStableKey = new Map();
|
|
718
|
-
for (const entry of readWorkspaceEndpoints(input.cwd)) {
|
|
742
|
+
for (const entry of readWorkspaceEndpoints(input.cwd, input.stableKeyName)) {
|
|
719
743
|
if (!validateManifest(entry.manifest, input.stableKeyName)) {
|
|
720
744
|
const relativePath = path.relative(projectRoot, entry.manifestPath);
|
|
721
745
|
blockers.push(`Invalid Endpoint manifest "${relativePath}".`);
|
|
@@ -786,13 +810,14 @@ export async function buildEndpointsPlan(input) {
|
|
|
786
810
|
for (const record of targetEndpoints) {
|
|
787
811
|
const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
|
|
788
812
|
const routeKey = endpointRecordRouteKey(record);
|
|
789
|
-
|
|
813
|
+
// Soft-deleted records do not own live routes. Keep them in the identity
|
|
814
|
+
// inventory for exact-key restores, matching the API's live-only uniqueness.
|
|
815
|
+
if (routeKey && !record.deletedAt && !record.deletedBy) {
|
|
790
816
|
targetRouteOwners.set(routeKey, [
|
|
791
817
|
...(targetRouteOwners.get(routeKey) || []),
|
|
792
818
|
{
|
|
793
819
|
...(stableKey ? { stableKey } : {}),
|
|
794
820
|
name: endpointLabel(record, 'unknown'),
|
|
795
|
-
deleted: Boolean(record.deletedAt || record.deletedBy),
|
|
796
821
|
},
|
|
797
822
|
]);
|
|
798
823
|
}
|
|
@@ -874,8 +899,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
874
899
|
}
|
|
875
900
|
for (const stableKey of stableKeys) {
|
|
876
901
|
const collisions = (targetRouteOwners.get(routeKey) || []).filter((owner) => owner.stableKey !== stableKey);
|
|
877
|
-
const movingOwners = collisions.filter((owner) => (
|
|
878
|
-
&& owner.stableKey
|
|
902
|
+
const movingOwners = collisions.filter((owner) => (owner.stableKey
|
|
879
903
|
&& desiredRoutesByStableKey.has(owner.stableKey)
|
|
880
904
|
&& desiredRoutesByStableKey.get(owner.stableKey) !== routeKey));
|
|
881
905
|
for (const owner of movingOwners) {
|
|
@@ -968,6 +992,13 @@ export async function buildEndpointsPlan(input) {
|
|
|
968
992
|
record: deletedTargets[0],
|
|
969
993
|
componentsById,
|
|
970
994
|
});
|
|
995
|
+
// Restore happens before configuration update, so the old physical route
|
|
996
|
+
// must also be available even when the desired manifest changes its path.
|
|
997
|
+
const oldRoute = endpointRecordRouteKey(deletedTargets[0]);
|
|
998
|
+
const oldRouteOwners = oldRoute ? targetRouteOwners.get(oldRoute) || [] : [];
|
|
999
|
+
if (oldRouteOwners.length > 0) {
|
|
1000
|
+
restoreSafety.push(`old route ${oldRoute} is owned by ${oldRouteOwners.map(owner => owner.stableKey || owner.name).sort().join(', ')}`);
|
|
1001
|
+
}
|
|
971
1002
|
if (restoreSafety.length > 0) {
|
|
972
1003
|
blockers.push(...restoreSafety.map((reason) => `Cannot restore Endpoint "${stableKey}": ${reason}.`));
|
|
973
1004
|
}
|
|
@@ -1095,7 +1126,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
1095
1126
|
}
|
|
1096
1127
|
function readValidWorkspaceEndpoints(cwd, stableKeyName) {
|
|
1097
1128
|
const result = new Map();
|
|
1098
|
-
for (const entry of readWorkspaceEndpoints(cwd)) {
|
|
1129
|
+
for (const entry of readWorkspaceEndpoints(cwd, stableKeyName)) {
|
|
1099
1130
|
if (validateManifest(entry.manifest, stableKeyName)) {
|
|
1100
1131
|
result.set(entry.manifest.stableKey, { manifest: entry.manifest, manifestPath: entry.manifestPath });
|
|
1101
1132
|
}
|
|
@@ -1113,6 +1144,7 @@ function endpointWriteOptions(manifest, schemaComponent) {
|
|
|
1113
1144
|
options.componentSchemaVersion = manifest.schema.binding === 'pinned'
|
|
1114
1145
|
? schemaComponent.version
|
|
1115
1146
|
: null;
|
|
1147
|
+
options.componentSchemaDigest = manifest.schema.binding === 'pinned' ? componentContentDigest(schemaComponent) : null;
|
|
1116
1148
|
options.componentSchemaElement = manifest.schema.element ?? null;
|
|
1117
1149
|
}
|
|
1118
1150
|
return Object.keys(options).length > 0 ? options : undefined;
|
|
@@ -1162,9 +1194,10 @@ async function resolveEndpointWritePayload(input) {
|
|
|
1162
1194
|
...(execution
|
|
1163
1195
|
? {
|
|
1164
1196
|
componentId,
|
|
1197
|
+
componentDigest: input.manifest.execution?.binding === 'pinned' ? componentContentDigest(execution) : null,
|
|
1165
1198
|
componentVersion: input.manifest.execution?.binding === 'pinned' ? execution.version : null,
|
|
1166
1199
|
}
|
|
1167
|
-
: { componentId: null, componentVersion: null }),
|
|
1200
|
+
: { componentId: null, componentDigest: null, componentVersion: null }),
|
|
1168
1201
|
timeout: input.manifest.timeout ?? ENDPOINT_DEFAULT_TIMEOUT_SECONDS,
|
|
1169
1202
|
path: input.manifest.route.path,
|
|
1170
1203
|
method: input.manifest.route.method,
|
|
@@ -1433,6 +1466,7 @@ export async function pushEndpoints(input) {
|
|
|
1433
1466
|
if (!prepared.manifest.execution) {
|
|
1434
1467
|
delete createPayload.componentId;
|
|
1435
1468
|
delete createPayload.componentVersion;
|
|
1469
|
+
delete createPayload.componentDigest;
|
|
1436
1470
|
}
|
|
1437
1471
|
const created = unwrapData(await input.client.createEndpoint(createPayload));
|
|
1438
1472
|
const createdId = endpointIdOf(created);
|
|
@@ -1488,6 +1522,11 @@ export async function pushEndpoints(input) {
|
|
|
1488
1522
|
if (restoreBlockers.length > 0) {
|
|
1489
1523
|
throw new Error(`restore safety changed after planning: ${restoreBlockers.join('; ')}`);
|
|
1490
1524
|
}
|
|
1525
|
+
const oldRoute = endpointRecordRouteKey(target);
|
|
1526
|
+
if (oldRoute && liveEndpoints.some(record => !record.deletedAt && !record.deletedBy
|
|
1527
|
+
&& endpointRecordRouteKey(record) === oldRoute)) {
|
|
1528
|
+
throw new Error(`restore safety changed after planning: old route ${oldRoute} is now owned by a live endpoint`);
|
|
1529
|
+
}
|
|
1491
1530
|
await input.client.restoreEndpoint(targetId);
|
|
1492
1531
|
const restored = unwrapData(await input.client.getEndpoint(targetId));
|
|
1493
1532
|
const restoredStableKey = readConfiguredResourceMetadataStableKey(restored, input.stableKeyName);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { accountPrincipal, resolveExecutionPrincipal, executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validExecutionPrincipal, validPortableExecutionPolicy } from "./account-principal.js";
|
|
3
4
|
import { describeFieldChanges } from "../diff-details.js";
|
|
@@ -7,7 +8,7 @@ import { readJsonFile, sanitizeSegment } from "../utils.js";
|
|
|
7
8
|
import { findManifestFiles, isRecord, localTargetPath, mapWithConcurrency, removeRelocatedManifest, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
|
|
8
9
|
export const JOB_TEMPLATES_DIRECTORY = 'JobTemplates';
|
|
9
10
|
export const JOB_TEMPLATE_MANIFEST_FILE = 'job-template.json';
|
|
10
|
-
const DEFAULT_JOB_TEMPLATE_MEMORY_MB =
|
|
11
|
+
const DEFAULT_JOB_TEMPLATE_MEMORY_MB = 256;
|
|
11
12
|
function canonicalValue(value) {
|
|
12
13
|
if (Array.isArray(value))
|
|
13
14
|
return value.map((item) => canonicalValue(item));
|
|
@@ -37,7 +38,7 @@ function canonicalJobTemplateOptions(value, inputs) {
|
|
|
37
38
|
const inputIsEmpty = isRecord(normalized.input) && Object.keys(normalized.input).length === 0;
|
|
38
39
|
const inputDuplicatesLegacyInputs = inputs !== undefined
|
|
39
40
|
&& JSON.stringify(normalized.input) === JSON.stringify(canonicalInputs);
|
|
40
|
-
if (inputIsEmpty || inputDuplicatesLegacyInputs)
|
|
41
|
+
if ((inputIsEmpty && (canonicalInputs === undefined || (isRecord(canonicalInputs) && Object.keys(canonicalInputs).length === 0))) || inputDuplicatesLegacyInputs)
|
|
41
42
|
delete normalized.input;
|
|
42
43
|
return Object.keys(normalized).length === 0 ? undefined : normalized;
|
|
43
44
|
}
|
|
@@ -116,8 +117,9 @@ function isOptionalFiniteNumber(value) {
|
|
|
116
117
|
}
|
|
117
118
|
function hasValidJobTemplateComponent(value) {
|
|
118
119
|
return isRecord(value)
|
|
119
|
-
&& hasOnlyKeys(value, new Set(['stableKey']))
|
|
120
|
-
&& isNonEmptyString(value.stableKey)
|
|
120
|
+
&& hasOnlyKeys(value, new Set(['stableKey', 'pinnedDigest']))
|
|
121
|
+
&& isNonEmptyString(value.stableKey)
|
|
122
|
+
&& (value.pinnedDigest === undefined || isComponentDigest(value.pinnedDigest));
|
|
121
123
|
}
|
|
122
124
|
function hasValidJobTemplateMigration(value) {
|
|
123
125
|
return value === undefined || (isRecord(value)
|
|
@@ -182,7 +184,7 @@ function manifestFromRecord(record, stableKey, componentKey, stableKeyName) {
|
|
|
182
184
|
...(record.category === undefined ? {} : { category: record.category }),
|
|
183
185
|
...(typeof record.desc === 'string' ? { description: record.desc } : typeof record.description === 'string' ? { description: record.description } : {}),
|
|
184
186
|
metadata: canonicalMetadata(record, stableKeyName, stableKey),
|
|
185
|
-
component: { stableKey: componentKey },
|
|
187
|
+
component: { stableKey: componentKey, ...(record.componentDigest ? { pinnedDigest: String(record.componentDigest) } : {}) },
|
|
186
188
|
...(typeof record.timeout === 'number' ? { timeout: record.timeout } : {}),
|
|
187
189
|
...(record.options === undefined ? {} : { options: canonicalValue(record.options) }),
|
|
188
190
|
...(record.inputs === undefined ? {} : { inputs: canonicalValue(record.inputs) }),
|
|
@@ -218,6 +220,7 @@ function buildCreatePayload(manifest, componentId) {
|
|
|
218
220
|
...(manifest.description === undefined ? {} : { desc: manifest.description }),
|
|
219
221
|
metadata: canonicalValue(manifest.metadata),
|
|
220
222
|
componentId,
|
|
223
|
+
...(manifest.component.pinnedDigest ? { componentDigest: manifest.component.pinnedDigest } : {}),
|
|
221
224
|
...(manifest.timeout === undefined ? {} : { timeout: manifest.timeout }),
|
|
222
225
|
...(manifest.options === undefined ? {} : { options: canonicalValue(manifest.options) }),
|
|
223
226
|
...(manifest.inputs === undefined ? {} : { inputs: canonicalValue(manifest.inputs) }),
|
|
@@ -230,6 +233,8 @@ function buildUpdatePayload(manifest, componentId, version) {
|
|
|
230
233
|
desc: manifest.description ?? '',
|
|
231
234
|
metadata: canonicalValue(manifest.metadata),
|
|
232
235
|
componentId,
|
|
236
|
+
componentDigest: manifest.component.pinnedDigest ?? null,
|
|
237
|
+
componentVersion: null,
|
|
233
238
|
...(manifest.timeout === undefined ? {} : { timeout: manifest.timeout }),
|
|
234
239
|
...(manifest.options === undefined ? {} : { options: canonicalValue(manifest.options) }),
|
|
235
240
|
...(manifest.inputs === undefined ? {} : { inputs: canonicalValue(manifest.inputs) }),
|
|
@@ -245,7 +250,7 @@ export function hashPortableJobTemplate(manifest) {
|
|
|
245
250
|
category: manifest.category ?? null,
|
|
246
251
|
description: manifest.description ?? '',
|
|
247
252
|
metadata: canonicalValue(manifest.metadata),
|
|
248
|
-
component: {
|
|
253
|
+
component: { ...manifest.component },
|
|
249
254
|
...(manifest.executionPrincipal ? { executionPrincipal: manifest.executionPrincipal } : {}),
|
|
250
255
|
...(manifest.executionPolicy ? { executionPolicy: manifest.executionPolicy } : {}),
|
|
251
256
|
...(manifest.timeout === undefined ? {} : { timeout: manifest.timeout }),
|
|
@@ -260,6 +265,7 @@ function diffJobTemplates(desired, target) {
|
|
|
260
265
|
['description', desired.description ?? '', target.description ?? ''],
|
|
261
266
|
['metadata', canonicalValue(desired.metadata), canonicalValue(target.metadata)],
|
|
262
267
|
['component.stableKey', desired.component.stableKey, target.component.stableKey],
|
|
268
|
+
['component.pinnedDigest', desired.component.pinnedDigest, target.component.pinnedDigest],
|
|
263
269
|
...(desired.executionPrincipal ? [['executionPrincipal', desired.executionPrincipal, target.executionPrincipal]] : []),
|
|
264
270
|
...(desired.executionPolicy ? [['executionPolicy', desired.executionPolicy, target.executionPolicy]] : []),
|
|
265
271
|
['timeout', desired.timeout, target.timeout],
|
|
@@ -372,7 +378,7 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
372
378
|
continue;
|
|
373
379
|
}
|
|
374
380
|
targetRecordsByKey.set(stableKey, [...(targetRecordsByKey.get(stableKey) || []), { record, stableKey }]);
|
|
375
|
-
if (typeof record.componentVersion === 'number') {
|
|
381
|
+
if ((typeof record.componentVersion === 'number' && !record.componentDigest)) {
|
|
376
382
|
blockers.push(`Target job template "${stableKey}" uses a pinned component version, which is unsupported.`);
|
|
377
383
|
}
|
|
378
384
|
}
|
|
@@ -411,7 +417,7 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
411
417
|
record,
|
|
412
418
|
manifest,
|
|
413
419
|
hash: hashPortableJobTemplate(manifest),
|
|
414
|
-
pinned: typeof record.componentVersion === 'number',
|
|
420
|
+
pinned: (typeof record.componentVersion === 'number' && !record.componentDigest),
|
|
415
421
|
}]);
|
|
416
422
|
}
|
|
417
423
|
const consumedTargetKeys = new Set();
|
|
@@ -475,6 +481,17 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
475
481
|
items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason: 'execution principal is unavailable or ambiguous' });
|
|
476
482
|
continue;
|
|
477
483
|
}
|
|
484
|
+
if (desired.component.pinnedDigest && dependencyReadiness === 'ready') {
|
|
485
|
+
try {
|
|
486
|
+
await componentRevisionByDigest(input.client, componentIdOf(liveDependencyMatches[0] || {}), desired.component.pinnedDigest);
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
490
|
+
blockers.push(`Job template "${desired.stableKey}": ${reason}`);
|
|
491
|
+
items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason, ...dependencyDetails });
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
478
495
|
const desiredHash = hashPortableJobTemplate(desired);
|
|
479
496
|
const matches = targetByKey.get(stableKeyIdentity) || [];
|
|
480
497
|
if (matches.length === 0) {
|
|
@@ -551,7 +568,7 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
551
568
|
blockers: [...new Set(blockers)].sort((left, right) => left.localeCompare(right)),
|
|
552
569
|
warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),
|
|
553
570
|
items,
|
|
554
|
-
exclusions: ['UUID, version, componentVersion and triggerUser are never persisted', 'target-only orphans are informational and never deleted'],
|
|
571
|
+
exclusions: ['UUID, version, componentVersion/componentDigest and triggerUser are never persisted', 'target-only orphans are informational and never deleted'],
|
|
555
572
|
};
|
|
556
573
|
}
|
|
557
574
|
export async function pullJobTemplatesToWorkspace(input) {
|
|
@@ -583,7 +600,7 @@ export async function pullJobTemplatesToWorkspace(input) {
|
|
|
583
600
|
continue;
|
|
584
601
|
}
|
|
585
602
|
const migration = {
|
|
586
|
-
...(typeof record.componentVersion === 'number' ? { componentBinding: 'pinned-unsupported' } : {}),
|
|
603
|
+
...((typeof record.componentVersion === 'number' && !record.componentDigest) ? { componentBinding: 'pinned-unsupported' } : {}),
|
|
587
604
|
...(record.triggerUser && (!record.executionPolicy || record.executionPolicy.mode === 'INHERIT') && !await accountPrincipal(input.client, record.triggerUser, input.stableKeyName) ? { executionPrincipal: 'excluded' } : {}),
|
|
588
605
|
};
|
|
589
606
|
manifests.push({
|
|
@@ -770,6 +787,8 @@ export async function pushJobTemplates(input) {
|
|
|
770
787
|
const stableKey = prepared.manifest.stableKey;
|
|
771
788
|
const targetPath = localTargetPath(input.cwd, prepared.manifestPath);
|
|
772
789
|
try {
|
|
790
|
+
if (prepared.manifest.component.pinnedDigest)
|
|
791
|
+
await componentRevisionByDigest(input.client, prepared.componentId, prepared.manifest.component.pinnedDigest);
|
|
773
792
|
const created = unwrapData(await input.client.createJobTemplate({ ...buildCreatePayload(prepared.manifest, prepared.componentId), ...await targetPrincipalId(input.client, prepared.manifest, input.stableKeyName) }));
|
|
774
793
|
const createdId = jobTemplateIdOf(created);
|
|
775
794
|
if (!createdId)
|
|
@@ -882,6 +901,8 @@ export async function pushJobTemplates(input) {
|
|
|
882
901
|
const componentId = componentIdOf(componentMatches[0]);
|
|
883
902
|
if (!componentId)
|
|
884
903
|
throw new Error(`dependency "${local.manifest.component.stableKey}" has no target component id`);
|
|
904
|
+
if (local.manifest.component.pinnedDigest)
|
|
905
|
+
await componentRevisionByDigest(input.client, componentId, local.manifest.component.pinnedDigest);
|
|
885
906
|
await input.client.updateJobTemplate(targetId, { ...buildUpdatePayload(local.manifest, componentId, target.version), ...await targetPrincipalId(input.client, local.manifest, input.stableKeyName, target) });
|
|
886
907
|
const verified = unwrapData(await input.client.getJobTemplate(targetId));
|
|
887
908
|
const verifiedStableKey = readConfiguredResourceMetadataStableKey(verified, input.stableKeyName);
|
|
@@ -24,7 +24,7 @@ export type ScheduleManifest = {
|
|
|
24
24
|
target: ScheduleTarget;
|
|
25
25
|
/** Retained for operator context only. It is never used in a target write. */
|
|
26
26
|
sourceTargetConfig?: Record<string, unknown> | null;
|
|
27
|
-
/**
|
|
27
|
+
/** Desired active state, applied by the explicit activation phase. */
|
|
28
28
|
activationCandidate: boolean;
|
|
29
29
|
};
|
|
30
30
|
export type SchedulePullWarning = {
|
|
@@ -60,7 +60,7 @@ export type ScheduleDependencyEdge = {
|
|
|
60
60
|
actualHash: string | null;
|
|
61
61
|
readiness: ScheduleDependencyReadiness;
|
|
62
62
|
};
|
|
63
|
-
export type SchedulePlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped';
|
|
63
|
+
export type SchedulePlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'activation-drift' | 'orphan' | 'collision' | 'skipped';
|
|
64
64
|
export type SchedulePlanItem = {
|
|
65
65
|
fieldChanges?: FieldChange[];
|
|
66
66
|
status: SchedulePlanStatus;
|
|
@@ -76,6 +76,8 @@ export type SchedulePlanItem = {
|
|
|
76
76
|
databaseViewStableKey?: string;
|
|
77
77
|
dependency?: ScheduleDependencyEdge;
|
|
78
78
|
blocked?: boolean;
|
|
79
|
+
desiredActive?: boolean;
|
|
80
|
+
currentActive?: boolean;
|
|
79
81
|
};
|
|
80
82
|
export type SchedulesPlan = {
|
|
81
83
|
resourceType: 'schedule';
|
|
@@ -88,7 +90,7 @@ export type SchedulesPlan = {
|
|
|
88
90
|
};
|
|
89
91
|
export type SchedulePushResult = {
|
|
90
92
|
stableKey: string;
|
|
91
|
-
action: 'create' | 'update' | 'noop' | 'orphan' | 'skipped' | 'activate';
|
|
93
|
+
action: 'create' | 'update' | 'noop' | 'orphan' | 'skipped' | 'activate' | 'disable';
|
|
92
94
|
status: 'deployed' | 'skipped' | 'failed';
|
|
93
95
|
targetPath: string;
|
|
94
96
|
reason?: string;
|
|
@@ -101,6 +103,8 @@ export type VerifiedScheduleActivation = {
|
|
|
101
103
|
stableKeyName: string;
|
|
102
104
|
targetId: string;
|
|
103
105
|
target: ScheduleTarget;
|
|
106
|
+
desiredActive: boolean;
|
|
107
|
+
portableHash: string;
|
|
104
108
|
};
|
|
105
109
|
export declare function scheduleManifestPath(workspaceRoot: string, manifest: ScheduleManifest): string;
|
|
106
110
|
/** Desired target shape. Source-only configuration and activation are excluded. */
|