@revoengine/cli 1.0.25 → 1.0.27
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 +32 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +44 -0
- package/dist/src/commands/component.js +7 -3
- package/dist/src/commands/migrate.js +25 -1
- package/dist/src/component-lock.d.ts +5 -0
- package/dist/src/component-lock.js +2 -0
- package/dist/src/component-manifests.d.ts +14 -0
- package/dist/src/component-manifests.js +73 -0
- package/dist/src/http-trace.js +2 -2
- package/dist/src/migration.d.ts +4 -0
- package/dist/src/migration.js +90 -59
- package/dist/src/planning-snapshot.d.ts +2 -0
- package/dist/src/planning-snapshot.js +29 -0
- package/dist/src/resource-syncs/endpoint-sync.js +10 -20
- package/dist/src/resource-syncs/event-sync.js +5 -0
- package/dist/src/resource-syncs/identity-migration.js +6 -4
- package/dist/src/resource-syncs/job-template-sync.js +6 -9
- package/dist/src/ui.js +3 -2
- package/dist/src/workspace-digests.d.ts +6 -0
- package/dist/src/workspace-digests.js +54 -0
- package/dist/src/workspace-prune.js +17 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -313,6 +313,13 @@ The JSON extension retains schema version 2, raw family `status`/`counts`, and `
|
|
|
313
313
|
|
|
314
314
|
Repository deployment uses desired-source-wins upsert: it can adopt a missing baseline or overwrite target content drift with the repository state. Its Database Table policy permits supported table renames, column additions and changes, and copying foreign-reference declarations as metadata. Copying those declarations does not create physical SQL foreign-key constraints.
|
|
315
315
|
|
|
316
|
+
Use `--activate` on both repository `plan` and `deploy` to align tracked Event and Schedule `active` values with the manifests. The saved plan includes this activation policy; changing the flag between planning and deployment is rejected before writes. Automation is activated or disabled only after all definition writes and pruning succeed, using verified candidates and readback. Without this flag, target activation is preserved; new automations are created inactive and a remaining activation difference fails deployment verification. Named migrations and dedicated resource commands keep their existing activation behavior.
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
revo plan --prune --activate --out reviewed-plan.json
|
|
320
|
+
revo deploy --prune --activate --yes --reviewed-plan reviewed-plan.json
|
|
321
|
+
```
|
|
322
|
+
|
|
316
323
|
`deploy --force` additionally approves supported high-impact operations reported by `plan`, including column removal, managed partition deletion, Materialized View Schedule writes, Schedule target-type changes, and Group or Role Group writes. Review them with `revo plan --force` before deployment. Force does not bypass invalid identity, missing dependencies, unsupported DDL, ambiguity, or failed verification. Full repository reconciliation explicitly selects these supported operations with `--prune`; it does not require `--force`.
|
|
317
324
|
|
|
318
325
|
To reconcile all tracked families, review the complete plan and approve its deletion list:
|
|
@@ -641,3 +648,28 @@ Schedule and Event activation differences remain pending changes even if their c
|
|
|
641
648
|
`CUSTOM_NODEJS` deployment verifies runtime availability and the active desired revision after source readback. Automatic deployment waits up to two minutes for readiness; failed attempts, manual activation requirements and unavailable/pending revisions fail verification without adopting a deployment baseline. Re-run after the runtime is ready. Named `env diff/apply` also reports unavailable unchanged custom runtimes and returns an error on unverified writes. Definition synchronization does not invoke provider/plugin tests; component dependencies and their pinned revisions are checked with read-only API calls, including unchanged definitions.
|
|
642
649
|
|
|
643
650
|
Execution options are compared without hiding runtime differences: missing Job Template memory means 256 MB; explicit 128 MB remains distinct. An empty `options.input` overrides legacy `inputs`. Endpoint `memory: null` remains distinct from 32 MB. If the backend substitutes a different value, readback verification fails rather than recording false convergence.
|
|
651
|
+
|
|
652
|
+
## Deployment digests and local lock updates
|
|
653
|
+
|
|
654
|
+
`revo plan update [--json]` computes the tracked workspace's portable `sourceDigest`
|
|
655
|
+
index by Stable Key in `.revoengine/revo.lock.json` without authentication or remote
|
|
656
|
+
reads. Component entries also contain the canonical backend `contentDigest`.
|
|
657
|
+
Offline plan update and deployment refresh this index from actual source files;
|
|
658
|
+
the stored index is not trusted in place of recomputation. Existing target baselines
|
|
659
|
+
remain available for three-way diagnostics and ordinary resource push protection.
|
|
660
|
+
A repository `plan/deploy --prune` reconciles reviewed Git source with the current
|
|
661
|
+
target without requiring a pull merely to update historical versions or hashes.
|
|
662
|
+
|
|
663
|
+
The CLI uses `GET /api/v1/component/sync-manifests` where supported. A matching
|
|
664
|
+
aggregate digest alone is insufficient: it verifies every child digest before
|
|
665
|
+
reusing local code, and compares the live configuration and descriptions separately.
|
|
666
|
+
Changed, missing or invalid digests fall back to full source reads. Unsupported
|
|
667
|
+
older APIs (404/405 or the legacy component-ID route validation response) keep the existing inventory path; authentication, permission
|
|
668
|
+
and transport failures are never treated as compatibility fallback.
|
|
669
|
+
|
|
670
|
+
Within one planning pass, duplicate inventory/detail reads share an isolated
|
|
671
|
+
snapshot. A subsequent pass starts fresh; mutations and readback never use that
|
|
672
|
+
cache. Pruning still checks retained and out-of-scope consumers. Human output reports
|
|
673
|
+
phase start/end/duration and a heartbeat for slow phases; JSON output remains clean.
|
|
674
|
+
Stable Keys match identity across instances. Current versions and mutation-review
|
|
675
|
+
tokens remain necessary to reject changes made after plan approval.
|
package/dist/src/cli.js
CHANGED
|
@@ -198,7 +198,7 @@ async function runMain(args, argv) {
|
|
|
198
198
|
const command = args._[0];
|
|
199
199
|
const noPositionals = args._.length === 0;
|
|
200
200
|
if (command === 'version' || ((args.version !== undefined || args.V !== undefined) && noPositionals)) {
|
|
201
|
-
print(args.json ? { version: packageVersion, capabilities: { workspacePrune: true, reviewedPrunePlan: true, reviewedDeploymentPlan: true, componentMutationReview: true } } : packageVersion);
|
|
201
|
+
print(args.json ? { version: packageVersion, capabilities: { workspacePrune: true, reviewedPrunePlan: true, reviewedDeploymentPlan: true, componentMutationReview: true, reviewedAutomationActivation: true } } : packageVersion);
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (command === 'info' || ((args.i === true || args.info === true) && noPositionals)) {
|
package/dist/src/client.d.ts
CHANGED
|
@@ -368,6 +368,7 @@ export declare class RevoClient {
|
|
|
368
368
|
private readonly maxRetries;
|
|
369
369
|
private retryDelayMs;
|
|
370
370
|
private requestQueue;
|
|
371
|
+
private componentSyncManifestsSupported?;
|
|
371
372
|
constructor(options?: ClientOptions);
|
|
372
373
|
get authHeader(): string;
|
|
373
374
|
get authValidationKey(): string;
|
|
@@ -443,6 +444,10 @@ export declare class RevoClient {
|
|
|
443
444
|
components: Record<string, unknown>[];
|
|
444
445
|
discoveredTotal: number | null;
|
|
445
446
|
}>;
|
|
447
|
+
listAllComponentSyncManifests(): Promise<{
|
|
448
|
+
components: Record<string, unknown>[];
|
|
449
|
+
discoveredTotal: number | null;
|
|
450
|
+
}>;
|
|
446
451
|
getComponent(componentId: string, options?: Pick<RequestOptions, 'timeoutMs'>): Promise<unknown>;
|
|
447
452
|
createComponent(body: unknown): Promise<unknown>;
|
|
448
453
|
reviewComponent(componentId: string, body: unknown): Promise<unknown>;
|
package/dist/src/client.js
CHANGED
|
@@ -411,6 +411,7 @@ export class RevoClient {
|
|
|
411
411
|
maxRetries;
|
|
412
412
|
retryDelayMs;
|
|
413
413
|
requestQueue;
|
|
414
|
+
componentSyncManifestsSupported;
|
|
414
415
|
constructor(options = {}) {
|
|
415
416
|
const config = resolveRuntimeConfig(options);
|
|
416
417
|
this.baseUrl = config.baseUrl;
|
|
@@ -1167,6 +1168,49 @@ export class RevoClient {
|
|
|
1167
1168
|
}
|
|
1168
1169
|
return { components, discoveredTotal };
|
|
1169
1170
|
}
|
|
1171
|
+
async listAllComponentSyncManifests() {
|
|
1172
|
+
if (this.componentSyncManifestsSupported === false)
|
|
1173
|
+
return this.listAllComponents();
|
|
1174
|
+
const components = [];
|
|
1175
|
+
const seen = new Set();
|
|
1176
|
+
let afterComponentId = null;
|
|
1177
|
+
do {
|
|
1178
|
+
let page;
|
|
1179
|
+
try {
|
|
1180
|
+
page = await this.requestData('GET', '/api/v1/component/sync-manifests', {
|
|
1181
|
+
query: { take: 200, ...(afterComponentId ? { afterComponentId } : {}) },
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
catch (error) {
|
|
1185
|
+
// Compatibility with already deployed APIs only. Permission/network errors
|
|
1186
|
+
// must not silently turn a failed read into a legacy inventory.
|
|
1187
|
+
const legacyIdRoute = error instanceof ApiError && error.status === 400
|
|
1188
|
+
&& error.data !== null && typeof error.data === 'object' && 'message' in error.data
|
|
1189
|
+
&& error.data.message === 'Provided "componentId" is not valid UUID.';
|
|
1190
|
+
if (components.length === 0 && error instanceof ApiError && ([404, 405].includes(error.status) || legacyIdRoute)) {
|
|
1191
|
+
this.componentSyncManifestsSupported = false;
|
|
1192
|
+
return this.listAllComponents();
|
|
1193
|
+
}
|
|
1194
|
+
throw error;
|
|
1195
|
+
}
|
|
1196
|
+
if (!Array.isArray(page?.data) || !(page.nextComponentId === null || typeof page.nextComponentId === 'string')) {
|
|
1197
|
+
throw new Error('Invalid component sync manifest page.');
|
|
1198
|
+
}
|
|
1199
|
+
for (const component of page.data) {
|
|
1200
|
+
const id = String(component.componentId || '');
|
|
1201
|
+
if (!id || seen.has(id))
|
|
1202
|
+
throw new Error('Repeated or missing component sync ID.');
|
|
1203
|
+
seen.add(id);
|
|
1204
|
+
components.push(component);
|
|
1205
|
+
}
|
|
1206
|
+
const next = page.nextComponentId;
|
|
1207
|
+
if (next !== null && (!page.data.length || next !== page.data.at(-1)?.componentId || next === afterComponentId)) {
|
|
1208
|
+
throw new Error('Invalid component sync pagination cursor.');
|
|
1209
|
+
}
|
|
1210
|
+
afterComponentId = next;
|
|
1211
|
+
} while (afterComponentId);
|
|
1212
|
+
return { components, discoveredTotal: components.length };
|
|
1213
|
+
}
|
|
1170
1214
|
async getComponent(componentId, options = {}) {
|
|
1171
1215
|
return this.requestData('GET', `/api/v1/component/${componentId}`, options);
|
|
1172
1216
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hydrateComponentManifest, listComponentManifests } from "../component-manifests.js";
|
|
1
2
|
import { verifyComponentRuntime } from "../component-contract.js";
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -556,10 +557,13 @@ function componentPruneBlocker(localCatalog, remote) {
|
|
|
556
557
|
async function buildRemoteComponentCatalog(context, identity, summaries) {
|
|
557
558
|
const catalog = createComponentCatalog(identity);
|
|
558
559
|
const source = summaries || (await fetchAllComponentSummaries(context)).components;
|
|
560
|
+
const local = buildLocalComponentCatalog(context.cwd, identity);
|
|
559
561
|
const filtered = source.filter((summary) => Boolean(String(summary.componentId || summary.id || '')));
|
|
560
562
|
const components = await mapWithConcurrency(filtered, async (summary) => {
|
|
561
563
|
const componentId = String(summary.componentId || summary.id || '');
|
|
562
|
-
|
|
564
|
+
const key = readComponentIdentityValue(summary, identity);
|
|
565
|
+
const hydrated = hydrateComponentManifest(summary, key ? local.byIdentity.get(key)?.component : undefined);
|
|
566
|
+
return hydrated || unwrapComponent(await context.client.getComponent(componentId, { timeoutMs: 30_000 }));
|
|
563
567
|
});
|
|
564
568
|
for (const component of components) {
|
|
565
569
|
addCatalogEntry(catalog, {
|
|
@@ -1022,7 +1026,7 @@ async function pullSingleComponent(context, target, mode = { force: false, stale
|
|
|
1022
1026
|
}
|
|
1023
1027
|
async function fetchAllComponentSummaries(context) {
|
|
1024
1028
|
try {
|
|
1025
|
-
return await context.client
|
|
1029
|
+
return await listComponentManifests(context.client);
|
|
1026
1030
|
}
|
|
1027
1031
|
catch (error) {
|
|
1028
1032
|
rethrowComponentAccessError(error, 'list');
|
|
@@ -1233,7 +1237,7 @@ async function pushSingleComponent(context, manifestPath, remoteCatalog) {
|
|
|
1233
1237
|
if (typeTransitionBlocker) {
|
|
1234
1238
|
throw new Error(`Cannot push ${targetPath}: ${typeTransitionBlocker}`);
|
|
1235
1239
|
}
|
|
1236
|
-
if (!readBoolFlag(context.args, ['force', 'f'])) {
|
|
1240
|
+
if (!context.componentReview && !readBoolFlag(context.args, ['force', 'f'])) {
|
|
1237
1241
|
const lockEntry = getComponentLockEntry(readComponentLock(getProjectRoot(context.cwd)), identity, component, context.componentEnvironment);
|
|
1238
1242
|
if (!lockEntry) {
|
|
1239
1243
|
const remoteHash = componentSourceHash(remote, identity);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { updateWorkspaceDigests } from "../workspace-digests.js";
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { normalizeStableKeyValue } from "../resource-metadata.js";
|
|
@@ -125,6 +126,8 @@ function printMigrationPlan(context, plan) {
|
|
|
125
126
|
context.println(`Changes required: ${plan.needsChanges ? 'yes' : 'no'}; verdict: ${plan.verdict}.`);
|
|
126
127
|
context.println(`Summary: create ${plan.operations.create}, update ${plan.operations.update}${plan.prune ? `, delete ${plan.operations.delete || 0}` : ''}, adopt ${plan.operations.adopt}, unchanged ${plan.operations.noop}, excluded ${plan.operations.excluded}, blocked ${plan.operations.blocked}.`);
|
|
127
128
|
context.println(`Diagnostics: ${plan.warnings.length} warning(s), ${plan.blockers.length} blocker(s).`);
|
|
129
|
+
if (plan.policy.activateAutomations)
|
|
130
|
+
context.println('Automation activation: align tracked Events and Schedules with repository active values after verified writes and pruning.');
|
|
128
131
|
if (plan.sourcePull.mode === 'repository') {
|
|
129
132
|
context.println('Source snapshot: repository workspace (no remote source pull).');
|
|
130
133
|
}
|
|
@@ -391,6 +394,7 @@ async function readWorkspaceDeploymentInput(context) {
|
|
|
391
394
|
resources,
|
|
392
395
|
withStats: readBoolFlag(context.args, ['with-stats']),
|
|
393
396
|
allowDestructive: readBoolFlag(context.args, ['force', 'f']) || readBoolFlag(context.args, ['prune']),
|
|
397
|
+
activateAutomations: readBoolFlag(context.args, ['activate']),
|
|
394
398
|
prune: readBoolFlag(context.args, ['prune']),
|
|
395
399
|
sourceMode: 'workspace',
|
|
396
400
|
targetClient: context.client,
|
|
@@ -402,6 +406,7 @@ async function handleMigrationRead(context, input, command) {
|
|
|
402
406
|
const plan = await buildMigrationPlan({
|
|
403
407
|
...input,
|
|
404
408
|
detailedDiff: true,
|
|
409
|
+
onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println,
|
|
405
410
|
...(command === 'diff' ? { allowDestructive: true } : {}),
|
|
406
411
|
});
|
|
407
412
|
if (command === 'diff') {
|
|
@@ -449,6 +454,19 @@ export async function handleDiffCommand(context) {
|
|
|
449
454
|
await handleMigrationRead(context, await readWorkspaceDeploymentInput(context), 'diff');
|
|
450
455
|
}
|
|
451
456
|
export async function handlePlanCommand(context) {
|
|
457
|
+
if (context.args._[1] === 'update') {
|
|
458
|
+
if (Object.keys(context.args).some(key => !['_', 'json', 'project', 'update-notifier'].includes(key))) {
|
|
459
|
+
throw new Error('Offline plan update accepts --json and --project only; target/deployment flags require revo plan.');
|
|
460
|
+
}
|
|
461
|
+
const result = updateWorkspaceDigests(context.cwd);
|
|
462
|
+
if (readBoolFlag(context.args, ['json']))
|
|
463
|
+
context.print(result);
|
|
464
|
+
else
|
|
465
|
+
context.println(`Local digest index: ${result.resourcesIndexed} resources; ${result.changed ? 'updated' : 'unchanged'}. No remote reads or writes.`);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (context.args._[1])
|
|
469
|
+
throw new Error('Unknown plan command; use revo plan or revo plan update.');
|
|
452
470
|
if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base'])) {
|
|
453
471
|
throw new Error('Repository plan evaluates all tracked resources and dependencies; --changed and --base are supported only by component plan.');
|
|
454
472
|
}
|
|
@@ -550,13 +568,18 @@ function printRunResult(context, result, showPlan = true) {
|
|
|
550
568
|
reason: ('error' in item ? item.error : undefined) || item.reason,
|
|
551
569
|
});
|
|
552
570
|
}
|
|
571
|
+
if (result.verdict !== 'succeeded' && result.verification) {
|
|
572
|
+
context.println('Post-deployment verification:');
|
|
573
|
+
printMigrationPlan(context, result.verification);
|
|
574
|
+
}
|
|
553
575
|
context.println(`Final verdict: ${result.verdict}.`);
|
|
554
576
|
}
|
|
555
577
|
export async function handleDeployCommand(context) {
|
|
556
578
|
if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base']) || readValues(context.args, ['resources', 'resource']).length > 0) {
|
|
557
579
|
throw new Error('Repository deployment evaluates all tracked resources; select resources in .revoengine/revo.json.');
|
|
558
580
|
}
|
|
559
|
-
const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true
|
|
581
|
+
const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true,
|
|
582
|
+
onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println };
|
|
560
583
|
const preview = await buildMigrationPlan(input);
|
|
561
584
|
const reviewedFile = readFlag(context.args, ['reviewed-plan']);
|
|
562
585
|
if (reviewedFile) {
|
|
@@ -581,6 +604,7 @@ export async function handleDeployCommand(context) {
|
|
|
581
604
|
if (!preview.readyToMigrate)
|
|
582
605
|
throw new Error(`Deployment plan is blocked by ${preview.blockers.length} issue(s).`);
|
|
583
606
|
await confirmDeploy(context);
|
|
607
|
+
updateWorkspaceDigests(context.cwd);
|
|
584
608
|
const startedAt = Date.now();
|
|
585
609
|
const result = await runMigration({ ...input, reviewedPrune: preview.prune, reviewedPlan: preview });
|
|
586
610
|
if (readBoolFlag(context.args, ['json'])) {
|
|
@@ -111,7 +111,12 @@ export type RevoLockDiagnostics = {
|
|
|
111
111
|
enabled: boolean;
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
|
+
export type WorkspaceDigest = {
|
|
115
|
+
sourceDigest: string;
|
|
116
|
+
contentDigest?: string;
|
|
117
|
+
};
|
|
114
118
|
export type RevoLockFile = {
|
|
119
|
+
workspaceDigests?: Record<string, Record<string, WorkspaceDigest>>;
|
|
115
120
|
schemaVersion: 2;
|
|
116
121
|
diagnostics?: RevoLockDiagnostics;
|
|
117
122
|
componentIdentity: ComponentIdentityConfig;
|
|
@@ -204,6 +204,7 @@ export function readComponentLock(projectRoot) {
|
|
|
204
204
|
}));
|
|
205
205
|
return {
|
|
206
206
|
schemaVersion: 2,
|
|
207
|
+
...(raw.workspaceDigests ? { workspaceDigests: raw.workspaceDigests } : {}),
|
|
207
208
|
...(diagnostics ? { diagnostics } : {}),
|
|
208
209
|
componentIdentity,
|
|
209
210
|
components,
|
|
@@ -432,6 +433,7 @@ export function writeComponentLock(projectRoot, lock) {
|
|
|
432
433
|
const sortedDatabaseViews = Object.fromEntries(Object.entries(lock.databaseViews || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
433
434
|
writeJsonFile(getLockPath(projectRoot), {
|
|
434
435
|
schemaVersion: 2,
|
|
436
|
+
...(lock.workspaceDigests ? { workspaceDigests: lock.workspaceDigests } : {}),
|
|
435
437
|
...(lock.diagnostics ? { diagnostics: normalizeDiagnostics(lock.diagnostics) } : {}),
|
|
436
438
|
componentIdentity: normalizeComponentIdentityConfig(lock.componentIdentity),
|
|
437
439
|
components: sortedComponents,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RevoClient } from './client.ts';
|
|
2
|
+
import type { ComponentRecord } from './types.ts';
|
|
3
|
+
export declare function listComponentManifests(client: RevoClient): Promise<{
|
|
4
|
+
components: Record<string, unknown>[];
|
|
5
|
+
discoveredTotal: number | null;
|
|
6
|
+
}>;
|
|
7
|
+
/** Reuse local source only when each backend-stamped child digest proves equality.
|
|
8
|
+
* Descriptions, ids and properties always come from the live manifest.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hydrateComponentManifest(summary: ComponentRecord, local?: ComponentRecord): (ComponentRecord & {
|
|
11
|
+
elements: NonNullable<ComponentRecord['elements']>;
|
|
12
|
+
}) | null;
|
|
13
|
+
export declare function localComponentSources(cwd: string): Map<string, ComponentRecord>;
|
|
14
|
+
export declare function loadComponentSources(client: RevoClient, cwd: string): Promise<ComponentRecord[]>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { findManifestFiles, requireProjectLayout, unwrapData } from "./resource-syncs/util.js";
|
|
4
|
+
import { readConfiguredResourceMetadataStableKey } from "./resource-metadata.js";
|
|
5
|
+
import { readProjectStableKeyName } from "./project.js";
|
|
6
|
+
import { hydrateWorkspaceComponentElementDetails } from "./workspace-component.js";
|
|
7
|
+
import { mapWithConcurrency } from "./utils.js";
|
|
8
|
+
import { withHttpTraceContext } from "./http-trace.js";
|
|
9
|
+
import { HTTP_REQUEST_CONCURRENCY } from "./request-queue.js";
|
|
10
|
+
import { componentContentDigest, isComponentDigest } from "./component-contract.js";
|
|
11
|
+
import { createHash } from 'node:crypto';
|
|
12
|
+
export async function listComponentManifests(client) {
|
|
13
|
+
return typeof client.listAllComponentSyncManifests === 'function'
|
|
14
|
+
? client.listAllComponentSyncManifests() : client.listAllComponents();
|
|
15
|
+
}
|
|
16
|
+
/** Reuse local source only when each backend-stamped child digest proves equality.
|
|
17
|
+
* Descriptions, ids and properties always come from the live manifest.
|
|
18
|
+
*/
|
|
19
|
+
export function hydrateComponentManifest(summary, local) {
|
|
20
|
+
if (!local || !Array.isArray(summary.elements) || !isComponentDigest(summary.metadata?.__digest))
|
|
21
|
+
return null;
|
|
22
|
+
if (summary.elements.length !== (local.elements || []).length)
|
|
23
|
+
return null;
|
|
24
|
+
const byKey = new Map((local.elements || []).map(element => [element.key, element]));
|
|
25
|
+
if (byKey.size !== (local.elements || []).length
|
|
26
|
+
|| new Set(summary.elements.map(element => element.key)).size !== summary.elements.length)
|
|
27
|
+
return null;
|
|
28
|
+
const elements = summary.elements.map(element => {
|
|
29
|
+
const source = byKey.get(element.key);
|
|
30
|
+
const details = source?.details ?? '';
|
|
31
|
+
const digest = `v1:sha256:${createHash('sha256').update(details).digest('hex')}`;
|
|
32
|
+
if (!source || !isComponentDigest(element.metadata?.__digest)
|
|
33
|
+
|| element.metadata.__digest !== digest)
|
|
34
|
+
return null;
|
|
35
|
+
return { ...element, details };
|
|
36
|
+
});
|
|
37
|
+
if (elements.some(element => element === null))
|
|
38
|
+
return null;
|
|
39
|
+
const hydrated = { ...summary, elements: elements };
|
|
40
|
+
return componentContentDigest(hydrated) === summary.metadata.__digest ? hydrated : null;
|
|
41
|
+
}
|
|
42
|
+
export function localComponentSources(cwd) {
|
|
43
|
+
const { workspaceRoot } = requireProjectLayout(cwd, 'Component manifests');
|
|
44
|
+
const property = readProjectStableKeyName(cwd);
|
|
45
|
+
const result = new Map();
|
|
46
|
+
for (const filename of findManifestFiles(path.join(workspaceRoot, 'Components'), 'component.json')) {
|
|
47
|
+
const manifest = JSON.parse(fs.readFileSync(filename, 'utf8'));
|
|
48
|
+
const type = String(manifest.type || '').toLowerCase();
|
|
49
|
+
const extension = type.includes('ts') || type === 'typescript' ? 'ts'
|
|
50
|
+
: type.includes('json') ? 'json' : type.includes('js') || type === 'javascript' ? 'js' : 'txt';
|
|
51
|
+
const component = hydrateWorkspaceComponentElementDetails(filename, manifest, extension);
|
|
52
|
+
const key = readConfiguredResourceMetadataStableKey(component, property);
|
|
53
|
+
if (!key)
|
|
54
|
+
continue;
|
|
55
|
+
if (result.has(key))
|
|
56
|
+
throw new Error(`Duplicate local Component Stable Key "${key}".`);
|
|
57
|
+
result.set(key, component);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
export async function loadComponentSources(client, cwd) {
|
|
62
|
+
const local = localComponentSources(cwd);
|
|
63
|
+
const property = readProjectStableKeyName(cwd);
|
|
64
|
+
const { components } = await withHttpTraceContext({ dependency: 'component', operation: 'list' }, () => listComponentManifests(client));
|
|
65
|
+
return mapWithConcurrency(components, async (summary) => {
|
|
66
|
+
const key = readConfiguredResourceMetadataStableKey(summary, property);
|
|
67
|
+
const hydrated = hydrateComponentManifest(summary, key ? local.get(key) : undefined);
|
|
68
|
+
const id = String(summary.componentId || summary.id || '');
|
|
69
|
+
return hydrated || (id ? unwrapData(await withHttpTraceContext({
|
|
70
|
+
dependency: 'component', operation: 'get', entityId: id,
|
|
71
|
+
}, () => client.getComponent(id, { timeoutMs: 30_000 }))) : summary);
|
|
72
|
+
}, HTTP_REQUEST_CONCURRENCY);
|
|
73
|
+
}
|
package/dist/src/http-trace.js
CHANGED
|
@@ -6,8 +6,8 @@ import { writeJsonFile } from "./utils.js";
|
|
|
6
6
|
const HTTP_TRACE_DIRECTORY = path.join(REVO_PROJECT_DIR, 'logs', 'http-trace');
|
|
7
7
|
const SAFE_PATH_SEGMENTS = new Set([
|
|
8
8
|
'api', 'v1', 'activity', 'automation', 'event', 'schedule', 'template',
|
|
9
|
-
'component', 'databases', 'stats', 'views', 'preview', 'endpoints',
|
|
10
|
-
'groups', 'me', 'role-groups', 'roles', 'search',
|
|
9
|
+
'component', 'sync-manifests', 'databases', 'stats', 'views', 'preview', 'endpoints',
|
|
10
|
+
'accounts', 'agents', 'registry', 'plugins', 'groups', 'me', 'role-groups', 'roles', 'search',
|
|
11
11
|
]);
|
|
12
12
|
const SAFE_ERROR_NAMES = new Set(['Error', 'TypeError', 'SyntaxError', 'AbortError', 'TimeoutError']);
|
|
13
13
|
const SAFE_HTTP_METHODS = new Set(['GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
package/dist/src/migration.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export type MigrationPlan = {
|
|
|
50
50
|
pruneTargetKey?: string;
|
|
51
51
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
52
52
|
mode: 'upsert' | 'reconcile';
|
|
53
|
+
activateAutomations?: boolean;
|
|
53
54
|
};
|
|
54
55
|
needsChanges: boolean;
|
|
55
56
|
readyToMigrate: boolean;
|
|
@@ -84,6 +85,7 @@ export type MigrationRun = {
|
|
|
84
85
|
resources: MigrationResource[];
|
|
85
86
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
86
87
|
mode: 'upsert' | 'reconcile';
|
|
88
|
+
activateAutomations?: boolean;
|
|
87
89
|
};
|
|
88
90
|
verdict: 'succeeded' | 'blocked' | 'failed';
|
|
89
91
|
sourcePull: {
|
|
@@ -106,12 +108,14 @@ export type MigrationRun = {
|
|
|
106
108
|
verification?: MigrationPlan;
|
|
107
109
|
};
|
|
108
110
|
type MigrationInputBase = {
|
|
111
|
+
onProgress?: (message: string) => void;
|
|
109
112
|
cwd: string;
|
|
110
113
|
from: string;
|
|
111
114
|
to: string;
|
|
112
115
|
resources?: MigrationResource[];
|
|
113
116
|
withStats?: boolean;
|
|
114
117
|
allowDestructive?: boolean;
|
|
118
|
+
activateAutomations?: boolean;
|
|
115
119
|
detailedDiff?: boolean;
|
|
116
120
|
prune?: boolean;
|
|
117
121
|
reviewedPrune?: WorkspacePrunePlan;
|