@revoengine/cli 1.0.20 → 1.0.22
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 +48 -10
- package/dist/src/cli.js +5 -1
- package/dist/src/client.d.ts +37 -8
- package/dist/src/client.js +58 -0
- package/dist/src/commands/agents.d.ts +2 -0
- package/dist/src/commands/agents.js +56 -0
- package/dist/src/commands/component.js +19 -0
- package/dist/src/commands/env.js +8 -5
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +19 -3
- package/dist/src/commands/schedules.js +11 -9
- package/dist/src/component-contract.d.ts +8 -0
- package/dist/src/component-contract.js +68 -0
- package/dist/src/component-lock.d.ts +6 -2
- package/dist/src/component-lock.js +42 -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/metadata-backfill.js +39 -1
- package/dist/src/migration-actions.js +1 -1
- package/dist/src/migration.d.ts +9 -2
- package/dist/src/migration.js +61 -2
- package/dist/src/resource-inventory.d.ts +4 -2
- package/dist/src/resource-inventory.js +11 -1
- package/dist/src/resource-syncs/agent-sync.d.ts +98 -0
- package/dist/src/resource-syncs/agent-sync.js +612 -0
- 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 +53 -26
- 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/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +4 -2
- package/dist/src/types.d.ts +14 -0
- package/dist/src/ui.js +6 -2
- package/dist/src/workspace-diff.js +2 -0
- package/dist/src/workspace-prune.js +38 -2
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { databaseIndexPayload } from "../database-indexes.js";
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { ApiError } from "../client.js";
|
|
@@ -134,6 +135,7 @@ function manifestFromEntry(entry, stableKeyName) {
|
|
|
134
135
|
...common,
|
|
135
136
|
...(typeof record.type === 'string' ? { type: record.type } : {}),
|
|
136
137
|
definition,
|
|
138
|
+
options: { indexes: databaseIndexPayload(isRecord(record.options) ? record.options.indexes : undefined) },
|
|
137
139
|
...(partition ? { partition } : {}),
|
|
138
140
|
...(hasForeignReferences(definition) ? { migration: { foreignReferences: 'manual' } } : {}),
|
|
139
141
|
};
|
|
@@ -163,6 +165,7 @@ function portableDatabaseSchemaManifest(manifest) {
|
|
|
163
165
|
kind: manifest.kind,
|
|
164
166
|
...common,
|
|
165
167
|
...(manifest.type === undefined ? {} : { type: manifest.type }),
|
|
168
|
+
options: { indexes: databaseIndexPayload(manifest.options?.indexes) },
|
|
166
169
|
...(manifest.definition === undefined
|
|
167
170
|
? {}
|
|
168
171
|
: { definition: portableDefinitions(manifest.definition) }),
|
|
@@ -604,19 +607,18 @@ function diffDatabaseSchemas(desired, current, stableKeyName) {
|
|
|
604
607
|
hint: 'Changing the physical table kind can rebuild storage and dependencies; use a replacement table with a new Stable Key and an explicit data migration.',
|
|
605
608
|
});
|
|
606
609
|
}
|
|
607
|
-
for (const field of ['category', 'description', 'metadata']) {
|
|
610
|
+
for (const field of ['category', 'description', 'metadata', 'options']) {
|
|
608
611
|
if (valuesEqual(desired[field], current[field])) {
|
|
609
612
|
continue;
|
|
610
613
|
}
|
|
611
|
-
const cannotClearCategory = field === 'category' && (desired.category === undefined || desired.category === null);
|
|
612
614
|
changes.push({
|
|
613
615
|
kind: 'field-changed',
|
|
614
616
|
field,
|
|
615
|
-
risk:
|
|
617
|
+
risk: field === 'options' ? 'operational' : 'safe',
|
|
616
618
|
before: current[field],
|
|
617
619
|
after: desired[field],
|
|
618
|
-
hint:
|
|
619
|
-
? '
|
|
620
|
+
hint: field === 'options'
|
|
621
|
+
? 'Index changes may scan data and hold schema locks; review target size and deployment timing before applying.'
|
|
620
622
|
: safeFieldHint(field),
|
|
621
623
|
});
|
|
622
624
|
}
|
|
@@ -1538,6 +1540,7 @@ function createPayloadForDatabaseSchema(input) {
|
|
|
1538
1540
|
return {
|
|
1539
1541
|
...common,
|
|
1540
1542
|
definition: portableDefinitions(input.manifest.definition),
|
|
1543
|
+
options: { indexes: databaseIndexPayload(input.manifest.options?.indexes) },
|
|
1541
1544
|
...(input.manifest.partition === undefined
|
|
1542
1545
|
? {}
|
|
1543
1546
|
: { partition: canonicalValue(input.manifest.partition, true) }),
|
|
@@ -1725,7 +1728,7 @@ function buildDatabaseSchemaUpdatePayload(input) {
|
|
|
1725
1728
|
...(input.sourceWins === true && input.desired.name !== input.target.name
|
|
1726
1729
|
? { name: input.desired.name }
|
|
1727
1730
|
: {}),
|
|
1728
|
-
|
|
1731
|
+
category: input.desired.category ?? null,
|
|
1729
1732
|
...(input.desired.description === undefined
|
|
1730
1733
|
? (typeof input.target.desc === 'string' && input.target.desc ? { desc: '' } : {})
|
|
1731
1734
|
: { desc: input.desired.description }),
|
|
@@ -1756,6 +1759,7 @@ function buildDatabaseSchemaUpdatePayload(input) {
|
|
|
1756
1759
|
desiredStableKeyOwners.set(stableKey, [...(desiredStableKeyOwners.get(stableKey) || []), definition]);
|
|
1757
1760
|
}
|
|
1758
1761
|
}
|
|
1762
|
+
payload.options = { indexes: databaseIndexPayload(input.desired.options?.indexes) };
|
|
1759
1763
|
payload.definition = (input.desired.definition || []).map((definition) => {
|
|
1760
1764
|
const value = portableDefinition(definition);
|
|
1761
1765
|
const stableKey = columnStableKey(value, stableKeyName);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DatabaseIndex } from '../database-indexes.ts';
|
|
1
2
|
import { type FieldChange } from '../diff-details.ts';
|
|
2
3
|
import type { RevoClient } from '../client.ts';
|
|
3
4
|
import type { DatabaseSchemaRecord } from '../types.ts';
|
|
@@ -23,10 +24,7 @@ export type DatabaseViewOutputField = {
|
|
|
23
24
|
type: string;
|
|
24
25
|
isArray: boolean;
|
|
25
26
|
};
|
|
26
|
-
export type DatabaseViewIndex =
|
|
27
|
-
columns: string[];
|
|
28
|
-
unique?: boolean;
|
|
29
|
-
};
|
|
27
|
+
export type DatabaseViewIndex = DatabaseIndex;
|
|
30
28
|
type DatabaseViewManifestBase = {
|
|
31
29
|
kind: 'database-view';
|
|
32
30
|
stableKey: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeDatabaseIndexes, databaseIndexPayload, databaseIndexReferences } from "../database-indexes.js";
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { describeFieldChanges, unifiedLineDiff } from "../diff-details.js";
|
|
3
4
|
import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
@@ -119,13 +120,10 @@ function validManifest(value, stableKeyName) {
|
|
|
119
120
|
|| !value.uniqueKey.every(isNonEmptyString)) {
|
|
120
121
|
return false;
|
|
121
122
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
&& index.columns.every(isNonEmptyString)
|
|
127
|
-
&& (index.unique === undefined || typeof index.unique === 'boolean')
|
|
128
|
-
&& Object.keys(index).every((key) => key === 'columns' || key === 'unique'))))) {
|
|
123
|
+
try {
|
|
124
|
+
normalizeDatabaseIndexes(value.indexes);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
129
127
|
return false;
|
|
130
128
|
}
|
|
131
129
|
}
|
|
@@ -134,6 +132,7 @@ function validManifest(value, stableKeyName) {
|
|
|
134
132
|
export function hashPortableDatabaseView(manifest) {
|
|
135
133
|
return hashStable(canonicalValue({
|
|
136
134
|
...manifest,
|
|
135
|
+
...(manifest.type === 'MATERIALIZED_VIEW' ? { indexes: normalizeDatabaseIndexes(manifest.indexes) } : {}),
|
|
137
136
|
sources: [...manifest.sources].sort((left, right) => (left.databaseStableKey.localeCompare(right.databaseStableKey)
|
|
138
137
|
|| left.name.localeCompare(right.name))),
|
|
139
138
|
}));
|
|
@@ -235,33 +234,15 @@ function materializedConfiguration(record, output) {
|
|
|
235
234
|
if (record.uniqueKey.some((column) => !outputNames.has(column))) {
|
|
236
235
|
return `Database View "${String(record.name || viewIdOf(record) || 'unknown')}" uniqueKey references an unknown output column`;
|
|
237
236
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
for (const column of index.columns) {
|
|
248
|
-
const name = isNonEmptyString(column)
|
|
249
|
-
? column
|
|
250
|
-
: isRecord(column) && isNonEmptyString(column.name)
|
|
251
|
-
? column.name
|
|
252
|
-
: undefined;
|
|
253
|
-
if (!name) {
|
|
254
|
-
return `Database View "${String(record.name || viewIdOf(record) || 'unknown')}" has an invalid materialized index`;
|
|
255
|
-
}
|
|
256
|
-
columns.push(name);
|
|
257
|
-
}
|
|
258
|
-
if (columns.some((column) => !outputNames.has(column))) {
|
|
259
|
-
return `Database View "${String(record.name || viewIdOf(record) || 'unknown')}" index references an unknown output column`;
|
|
260
|
-
}
|
|
261
|
-
if (index.unique !== undefined && typeof index.unique !== 'boolean') {
|
|
262
|
-
return `Database View "${String(record.name || viewIdOf(record) || 'unknown')}" has an invalid materialized index unique flag`;
|
|
263
|
-
}
|
|
264
|
-
indexes.push({ columns, ...(index.unique === true ? { unique: true } : {}) });
|
|
237
|
+
let indexes;
|
|
238
|
+
try {
|
|
239
|
+
indexes = normalizeDatabaseIndexes(record.indexes);
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
return `Database View "${String(record.name || viewIdOf(record))}" has an invalid materialized index: ${String(error)}`;
|
|
243
|
+
}
|
|
244
|
+
if (indexes.some(index => databaseIndexReferences(index).some(column => !outputNames.has(column)))) {
|
|
245
|
+
return `Database View "${String(record.name || viewIdOf(record))}" index references an unknown output column`;
|
|
265
246
|
}
|
|
266
247
|
return {
|
|
267
248
|
uniqueKey: [...record.uniqueKey],
|
|
@@ -809,10 +790,7 @@ function createDatabaseViewPayload(manifest) {
|
|
|
809
790
|
};
|
|
810
791
|
}
|
|
811
792
|
function databaseViewWriteIndexes(indexes) {
|
|
812
|
-
return indexes
|
|
813
|
-
columns: index.columns.map((name) => ({ name })),
|
|
814
|
-
...(index.unique === true ? { unique: true } : {}),
|
|
815
|
-
}));
|
|
793
|
+
return databaseIndexPayload(indexes);
|
|
816
794
|
}
|
|
817
795
|
function assertTargetPreviewMatchesManifest(manifest, preview) {
|
|
818
796
|
const output = previewOutput(preview);
|
|
@@ -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}".`);
|
|
@@ -1095,7 +1119,7 @@ export async function buildEndpointsPlan(input) {
|
|
|
1095
1119
|
}
|
|
1096
1120
|
function readValidWorkspaceEndpoints(cwd, stableKeyName) {
|
|
1097
1121
|
const result = new Map();
|
|
1098
|
-
for (const entry of readWorkspaceEndpoints(cwd)) {
|
|
1122
|
+
for (const entry of readWorkspaceEndpoints(cwd, stableKeyName)) {
|
|
1099
1123
|
if (validateManifest(entry.manifest, stableKeyName)) {
|
|
1100
1124
|
result.set(entry.manifest.stableKey, { manifest: entry.manifest, manifestPath: entry.manifestPath });
|
|
1101
1125
|
}
|
|
@@ -1113,6 +1137,7 @@ function endpointWriteOptions(manifest, schemaComponent) {
|
|
|
1113
1137
|
options.componentSchemaVersion = manifest.schema.binding === 'pinned'
|
|
1114
1138
|
? schemaComponent.version
|
|
1115
1139
|
: null;
|
|
1140
|
+
options.componentSchemaDigest = manifest.schema.binding === 'pinned' ? componentContentDigest(schemaComponent) : null;
|
|
1116
1141
|
options.componentSchemaElement = manifest.schema.element ?? null;
|
|
1117
1142
|
}
|
|
1118
1143
|
return Object.keys(options).length > 0 ? options : undefined;
|
|
@@ -1162,9 +1187,10 @@ async function resolveEndpointWritePayload(input) {
|
|
|
1162
1187
|
...(execution
|
|
1163
1188
|
? {
|
|
1164
1189
|
componentId,
|
|
1190
|
+
componentDigest: input.manifest.execution?.binding === 'pinned' ? componentContentDigest(execution) : null,
|
|
1165
1191
|
componentVersion: input.manifest.execution?.binding === 'pinned' ? execution.version : null,
|
|
1166
1192
|
}
|
|
1167
|
-
: { componentId: null, componentVersion: null }),
|
|
1193
|
+
: { componentId: null, componentDigest: null, componentVersion: null }),
|
|
1168
1194
|
timeout: input.manifest.timeout ?? ENDPOINT_DEFAULT_TIMEOUT_SECONDS,
|
|
1169
1195
|
path: input.manifest.route.path,
|
|
1170
1196
|
method: input.manifest.route.method,
|
|
@@ -1433,6 +1459,7 @@ export async function pushEndpoints(input) {
|
|
|
1433
1459
|
if (!prepared.manifest.execution) {
|
|
1434
1460
|
delete createPayload.componentId;
|
|
1435
1461
|
delete createPayload.componentVersion;
|
|
1462
|
+
delete createPayload.componentDigest;
|
|
1436
1463
|
}
|
|
1437
1464
|
const created = unwrapData(await input.client.createEndpoint(createPayload));
|
|
1438
1465
|
const createdId = endpointIdOf(created);
|
|
@@ -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. */
|