@revoengine/cli 1.0.11 → 1.0.13

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.
Files changed (81) hide show
  1. package/README.md +275 -479
  2. package/dist/src/cli.js +71 -5
  3. package/dist/src/client.d.ts +28 -12
  4. package/dist/src/client.js +234 -66
  5. package/dist/src/commands/component.d.ts +67 -0
  6. package/dist/src/commands/component.js +299 -27
  7. package/dist/src/commands/database-tables.d.ts +2 -0
  8. package/dist/src/commands/{database-schemas.js → database-tables.js} +21 -40
  9. package/dist/src/commands/database-views.js +21 -18
  10. package/dist/src/commands/endpoints.js +26 -16
  11. package/dist/src/commands/events.js +18 -20
  12. package/dist/src/commands/groups.js +13 -22
  13. package/dist/src/commands/index.d.ts +2 -1
  14. package/dist/src/commands/index.js +2 -1
  15. package/dist/src/commands/job-templates.js +21 -15
  16. package/dist/src/commands/metadata.js +58 -15
  17. package/dist/src/commands/migrate.d.ts +6 -0
  18. package/dist/src/commands/migrate.js +658 -0
  19. package/dist/src/commands/project.js +4 -4
  20. package/dist/src/commands/role-groups.js +14 -25
  21. package/dist/src/commands/schedules.js +19 -20
  22. package/dist/src/commands/terminal-browser.d.ts +16 -0
  23. package/dist/src/commands/terminal-browser.js +92 -0
  24. package/dist/src/commands/terminal-image.d.ts +7 -0
  25. package/dist/src/commands/terminal-image.js +40 -0
  26. package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
  27. package/dist/src/commands/terminal-patch-worker.js +24 -0
  28. package/dist/src/commands/terminal-patch.d.ts +2 -0
  29. package/dist/src/commands/terminal-patch.js +156 -0
  30. package/dist/src/commands/terminal-sandbox.d.ts +8 -0
  31. package/dist/src/commands/terminal-sandbox.js +87 -0
  32. package/dist/src/commands/terminal-service.js +2 -2
  33. package/dist/src/commands/terminal.d.ts +31 -4
  34. package/dist/src/commands/terminal.js +360 -45
  35. package/dist/src/component-lock.d.ts +12 -2
  36. package/dist/src/component-lock.js +60 -1
  37. package/dist/src/diff-details.d.ts +8 -0
  38. package/dist/src/diff-details.js +152 -0
  39. package/dist/src/env-sync.js +8 -6
  40. package/dist/src/http-trace.d.ts +94 -0
  41. package/dist/src/http-trace.js +226 -0
  42. package/dist/src/metadata-backfill.d.ts +5 -4
  43. package/dist/src/metadata-backfill.js +82 -158
  44. package/dist/src/migration.d.ts +141 -0
  45. package/dist/src/migration.js +1632 -0
  46. package/dist/src/resource-inventory.d.ts +28 -0
  47. package/dist/src/resource-inventory.js +85 -0
  48. package/dist/src/resource-syncs/{database-schema-sync.d.ts → database-table-sync.d.ts} +13 -3
  49. package/dist/src/resource-syncs/{database-schema-sync.js → database-table-sync.js} +147 -62
  50. package/dist/src/resource-syncs/database-view-sync.d.ts +24 -2
  51. package/dist/src/resource-syncs/database-view-sync.js +156 -68
  52. package/dist/src/resource-syncs/endpoint-sync.d.ts +27 -0
  53. package/dist/src/resource-syncs/endpoint-sync.js +362 -82
  54. package/dist/src/resource-syncs/event-sync.d.ts +27 -0
  55. package/dist/src/resource-syncs/event-sync.js +123 -26
  56. package/dist/src/resource-syncs/group-sync.d.ts +7 -0
  57. package/dist/src/resource-syncs/group-sync.js +60 -14
  58. package/dist/src/resource-syncs/job-template-sync.d.ts +21 -0
  59. package/dist/src/resource-syncs/job-template-sync.js +91 -30
  60. package/dist/src/resource-syncs/role-group-sync.d.ts +7 -0
  61. package/dist/src/resource-syncs/role-group-sync.js +47 -9
  62. package/dist/src/resource-syncs/schedule-sync.d.ts +30 -1
  63. package/dist/src/resource-syncs/schedule-sync.js +114 -20
  64. package/dist/src/resource-syncs/util.d.ts +3 -0
  65. package/dist/src/resource-syncs/util.js +8 -6
  66. package/dist/src/resource-target.d.ts +11 -0
  67. package/dist/src/resource-target.js +48 -0
  68. package/dist/src/sync-output.d.ts +29 -1
  69. package/dist/src/sync-output.js +139 -2
  70. package/dist/src/tracked-resources.d.ts +1 -1
  71. package/dist/src/tracked-resources.js +8 -6
  72. package/dist/src/types.d.ts +3 -0
  73. package/dist/src/ui.js +18 -9
  74. package/dist/src/utils.d.ts +2 -0
  75. package/dist/src/utils.js +17 -0
  76. package/dist/src/workspace-diff.d.ts +25 -0
  77. package/dist/src/workspace-diff.js +75 -0
  78. package/package.json +9 -6
  79. package/dist/src/commands/database-schemas.d.ts +0 -2
  80. /package/dist/src/{database-schema-artifacts.d.ts → database-table-artifacts.d.ts} +0 -0
  81. /package/dist/src/{database-schema-artifacts.js → database-table-artifacts.js} +0 -0
@@ -1,8 +1,9 @@
1
1
  import path from 'node:path';
2
+ import { describeFieldChanges } from "../diff-details.js";
2
3
  import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
3
4
  import { normalizeStableKeyValue, readConfiguredResourceMetadataStableKey, sanitizeUserMetadata } from "../resource-metadata.js";
4
5
  import { readJsonFile, sanitizeSegment } from "../utils.js";
5
- import { findManifestFiles, isRecord, localTargetPath, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
6
+ import { findManifestFiles, isRecord, localTargetPath, mapWithConcurrency, removeRelocatedManifest, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
6
7
  export const JOB_TEMPLATES_DIRECTORY = 'JobTemplates';
7
8
  export const JOB_TEMPLATE_MANIFEST_FILE = 'job-template.json';
8
9
  const DEFAULT_JOB_TEMPLATE_MEMORY_MB = 128;
@@ -79,21 +80,17 @@ function readWorkspaceJobTemplates(cwd) {
79
80
  }
80
81
  async function loadRemoteJobTemplates(client) {
81
82
  const { jobTemplates } = await client.listAllJobTemplates();
82
- const records = [];
83
- for (const summary of jobTemplates) {
83
+ return mapWithConcurrency(jobTemplates, async (summary) => {
84
84
  const id = jobTemplateIdOf(summary);
85
- records.push(id ? unwrapData(await client.getJobTemplate(id)) : summary);
86
- }
87
- return records;
85
+ return id ? unwrapData(await client.getJobTemplate(id)) : summary;
86
+ });
88
87
  }
89
88
  async function loadRemoteComponents(client) {
90
89
  const { components } = await client.listAllComponents();
91
- const records = [];
92
- for (const summary of components) {
90
+ return mapWithConcurrency(components, async (summary) => {
93
91
  const id = componentIdOf(summary);
94
- records.push(id ? unwrapData(await client.getComponent(id)) : summary);
95
- }
96
- return records;
92
+ return id ? unwrapData(await client.getComponent(id)) : summary;
93
+ });
97
94
  }
98
95
  const JOB_TEMPLATE_MANIFEST_FIELDS = new Set([
99
96
  'kind', 'stableKey', 'name', 'category', 'description', 'metadata', 'component',
@@ -243,6 +240,14 @@ function diffJobTemplates(desired, target) {
243
240
  .map(([field]) => field)
244
241
  .sort((left, right) => left.localeCompare(right));
245
242
  }
243
+ function describeJobTemplateChanges(desired, target, changedFields) {
244
+ const normalized = (manifest) => ({
245
+ ...manifest,
246
+ options: canonicalJobTemplateOptions(manifest.options, manifest.inputs),
247
+ inputs: canonicalJobTemplateInputs(manifest.inputs),
248
+ });
249
+ return describeFieldChanges(normalized(desired), normalized(target), changedFields);
250
+ }
246
251
  function emptyPlanCounts() {
247
252
  return {
248
253
  clean: 0,
@@ -269,6 +274,13 @@ export async function buildJobTemplatesPlan(input) {
269
274
  const targetComponentKeysById = new Map();
270
275
  const activeTargetComponentIds = new Set();
271
276
  const targetComponentsByKey = new Map();
277
+ const projectedComponentsByKey = new Map();
278
+ for (const component of input.projectedComponents || []) {
279
+ projectedComponentsByKey.set(component.stableKey, [
280
+ ...(projectedComponentsByKey.get(component.stableKey) || []),
281
+ component,
282
+ ]);
283
+ }
272
284
  for (const component of targetComponents) {
273
285
  const stableKey = readConfiguredResourceMetadataStableKey(component, input.stableKeyName);
274
286
  const id = componentIdOf(component);
@@ -362,43 +374,68 @@ export async function buildJobTemplatesPlan(input) {
362
374
  consumedTargetKeys.add(stableKeyIdentity);
363
375
  continue;
364
376
  }
365
- const dependencyMatches = targetComponentsByKey.get(desired.component.stableKey) || [];
377
+ const liveDependencyMatches = targetComponentsByKey.get(desired.component.stableKey) || [];
378
+ const projectedDependencyMatches = projectedComponentsByKey.get(desired.component.stableKey) || [];
379
+ const dependencyMatches = input.projectedComponents ? projectedDependencyMatches : liveDependencyMatches;
366
380
  if (dependencyMatches.length !== 1) {
367
- const reason = dependencyMatches.length === 0 ? 'target component is missing' : 'target component stableKey is ambiguous';
381
+ const reason = dependencyMatches.length === 0
382
+ ? (input.projectedComponents ? 'component is missing from the projected source migration' : 'target component is missing')
383
+ : input.projectedComponents
384
+ ? 'component stableKey is ambiguous in the projected source migration'
385
+ : 'target component stableKey is ambiguous';
368
386
  blockers.push(`Job template "${desired.stableKey}" dependency "${desired.component.stableKey}": ${reason}.`);
369
- items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason, componentStableKey: desired.component.stableKey });
387
+ items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason, componentStableKey: desired.component.stableKey, dependencyReadiness: 'blocked' });
370
388
  continue;
371
389
  }
390
+ const projectedDependency = input.projectedComponents ? projectedDependencyMatches[0] : undefined;
391
+ const dependencyReadiness = projectedDependency?.state === 'pending-create'
392
+ ? 'pending-component-create'
393
+ : projectedDependency?.state === 'pending-update'
394
+ ? 'pending-component-update'
395
+ : projectedDependency?.state === 'pending-adopt'
396
+ ? 'pending-component-adopt'
397
+ : 'ready';
398
+ if (dependencyReadiness !== 'ready') {
399
+ warnings.push(`Job template "${desired.stableKey}" dependency "${desired.component.stableKey}" is ${dependencyReadiness}; migration will resolve its verified target UUID after the Component phase.`);
400
+ }
401
+ const dependencyDetails = {
402
+ componentStableKey: desired.component.stableKey,
403
+ ...(projectedDependency ? { componentDesiredHash: projectedDependency.desiredHash } : {}),
404
+ dependencyReadiness,
405
+ };
372
406
  const desiredHash = hashPortableJobTemplate(desired);
373
407
  const matches = targetByKey.get(stableKeyIdentity) || [];
374
408
  if (matches.length === 0) {
375
- items.push({ status: 'create', stableKey: desired.stableKey, name: desired.name, desiredHash, componentStableKey: desired.component.stableKey });
409
+ items.push({ status: 'create', stableKey: desired.stableKey, name: desired.name, desiredHash, ...dependencyDetails });
376
410
  continue;
377
411
  }
378
412
  consumedTargetKeys.add(stableKeyIdentity);
379
413
  const target = matches[0];
380
414
  if (target.pinned) {
381
415
  blockers.push(`Target job template "${desired.stableKey}" uses a pinned component version, which is unsupported.`);
382
- items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason: 'target pinned component version is unsupported', componentStableKey: desired.component.stableKey });
416
+ items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, reason: 'target pinned component version is unsupported', ...dependencyDetails });
383
417
  continue;
384
418
  }
385
419
  const changedFields = diffJobTemplates(desired, target.manifest);
386
- const changeDetails = changedFields.length > 0 ? { changedFields } : {};
420
+ const changeDetails = changedFields.length > 0 ? {
421
+ changedFields,
422
+ fieldChanges: describeJobTemplateChanges(desired, target.manifest, changedFields),
423
+ } : {};
387
424
  const baseline = lockEntry?.environments[input.envName]?.remoteHash;
388
425
  if (!baseline) {
389
- items.push({ status: 'missing-lock', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, reason: `missing ${input.envName} lock baseline`, componentStableKey: desired.component.stableKey, ...changeDetails });
426
+ items.push({ status: 'missing-lock', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, reason: `missing ${input.envName} lock baseline`, ...dependencyDetails, ...changeDetails });
390
427
  }
391
428
  else if (desiredHash === target.hash) {
392
- items.push({ status: 'clean', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, componentStableKey: desired.component.stableKey });
429
+ items.push({ status: 'clean', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, ...dependencyDetails });
393
430
  }
394
431
  else if (target.hash === baseline) {
395
- items.push({ status: 'safe-update', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'local manifest changed; target matches lock baseline', componentStableKey: desired.component.stableKey, ...changeDetails });
432
+ items.push({ status: 'safe-update', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'local manifest changed; target matches lock baseline', ...dependencyDetails, ...changeDetails });
396
433
  }
397
434
  else if (desiredHash === baseline) {
398
- items.push({ status: 'remote-changed', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'target changed; local manifest matches lock baseline', componentStableKey: desired.component.stableKey, ...changeDetails });
435
+ items.push({ status: 'remote-changed', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'target changed; local manifest matches lock baseline', ...dependencyDetails, ...changeDetails });
399
436
  }
400
437
  else {
401
- items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'local manifest and target both changed since lock baseline', componentStableKey: desired.component.stableKey, ...changeDetails });
438
+ items.push({ status: 'conflict', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, baselineHash: baseline, reason: 'local manifest and target both changed since lock baseline', ...dependencyDetails, ...changeDetails });
402
439
  }
403
440
  }
404
441
  for (const [stableKeyIdentity, matches] of targetByKey) {
@@ -442,23 +479,30 @@ export async function pullJobTemplatesToWorkspace(input) {
442
479
  const { projectRoot, workspaceRoot } = requireProjectLayout(input.cwd, 'Job-template');
443
480
  const { jobTemplates } = await input.client.listAllJobTemplates();
444
481
  const manifests = [];
482
+ const skipped = [];
445
483
  const warnings = [];
446
- const missing = [];
447
484
  const stableKeys = new Set();
448
- for (const summary of jobTemplates) {
485
+ const records = await mapWithConcurrency(jobTemplates, async (summary) => {
449
486
  const id = jobTemplateIdOf(summary);
450
- const record = id ? unwrapData(await input.client.getJobTemplate(id)) : summary;
487
+ return id ? unwrapData(await input.client.getJobTemplate(id)) : summary;
488
+ });
489
+ for (const record of records) {
490
+ const id = jobTemplateIdOf(record);
451
491
  const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
452
492
  if (!stableKey) {
453
- missing.push(String(record.name || id || 'unknown'));
493
+ const name = String(record.name || id || 'unknown');
494
+ skipped.push({ name, targetPath: name, reason: `missing ${input.stableKeyName}; unmanaged WIP` });
454
495
  continue;
455
496
  }
456
497
  if (stableKeys.has(stableKey))
457
498
  throw new Error(`Duplicate job-template stableKey "${stableKey}" on ${input.envName}; no files were changed.`);
458
499
  stableKeys.add(stableKey);
459
500
  const dependencyStableKey = await componentStableKey({ client: input.client, record, stableKeyName: input.stableKeyName });
460
- if (!dependencyStableKey)
461
- throw new Error(`Job template "${stableKey}" references a component without ${input.stableKeyName}; no files were changed.`);
501
+ if (!dependencyStableKey) {
502
+ const name = String(record.name || id || stableKey);
503
+ skipped.push({ name, targetPath: name, reason: `component missing ${input.stableKeyName}; unmanaged WIP` });
504
+ continue;
505
+ }
462
506
  const migration = {
463
507
  ...(typeof record.componentVersion === 'number' ? { componentBinding: 'pinned-unsupported' } : {}),
464
508
  ...(record.triggerUser ? { executionPrincipal: 'excluded' } : {}),
@@ -470,9 +514,8 @@ export async function pullJobTemplatesToWorkspace(input) {
470
514
  if (record.triggerUser)
471
515
  warnings.push({ stableKey, reason: 'triggerUser execution principal skipped' });
472
516
  }
473
- if (missing.length > 0)
474
- throw new Error(`Active source job template(s) missing ${input.stableKeyName}: ${missing.sort().join(', ')}; no files were changed.`);
475
517
  manifests.sort((left, right) => left.stableKey.localeCompare(right.stableKey));
518
+ skipped.sort((left, right) => left.name.localeCompare(right.name));
476
519
  warnings.sort((left, right) => left.stableKey.localeCompare(right.stableKey));
477
520
  const lock = readComponentLock(projectRoot);
478
521
  const existingByKey = new Map();
@@ -500,6 +543,17 @@ export async function pullJobTemplatesToWorkspace(input) {
500
543
  const filePath = jobTemplateManifestPath(workspaceRoot, manifest);
501
544
  return { manifest, hash, filePath, previousPath: existing?.manifestPath };
502
545
  });
546
+ const sourceStableKeys = new Set(manifests.map((manifest) => manifest.stableKey));
547
+ const pruned = input.pruneOrphans === true
548
+ ? [...existingByKey.values()]
549
+ .filter((entry) => !sourceStableKeys.has(entry.manifest.stableKey))
550
+ .map((entry) => ({
551
+ stableKey: entry.manifest.stableKey,
552
+ targetPath: localTargetPath(input.cwd, entry.manifestPath),
553
+ manifestPath: entry.manifestPath,
554
+ }))
555
+ .sort((left, right) => right.manifestPath.length - left.manifestPath.length || left.stableKey.localeCompare(right.stableKey))
556
+ : [];
503
557
  const candidatePathCounts = new Map();
504
558
  for (const write of writes) {
505
559
  const identity = portablePathIdentity(write.filePath);
@@ -552,10 +606,17 @@ export async function pullJobTemplatesToWorkspace(input) {
552
606
  lockChanged = true;
553
607
  lock.jobTemplates[write.manifest.stableKey] = entry;
554
608
  }
609
+ for (const removed of pruned) {
610
+ removeRelocatedManifest(removed.manifestPath, root);
611
+ delete lock.jobTemplates[removed.stableKey];
612
+ lockChanged = true;
613
+ }
555
614
  if (lockChanged)
556
615
  writeComponentLock(projectRoot, lock);
557
616
  return {
558
617
  pulled: writes.map((write) => ({ manifest: write.manifest, targetPath: localTargetPath(input.cwd, write.filePath) })),
618
+ pruned: pruned.map(({ stableKey, targetPath }) => ({ stableKey, targetPath })),
619
+ skipped,
559
620
  warnings,
560
621
  };
561
622
  }
@@ -1,3 +1,4 @@
1
+ import { type FieldChange } from '../diff-details.ts';
1
2
  import type { RoleGroupRecord } from '../types.ts';
2
3
  import type { RevoClient } from '../client.ts';
3
4
  export declare const ROLE_GROUPS_DIRECTORY = "RoleGroups";
@@ -16,6 +17,10 @@ export type RoleGroupPullResult = {
16
17
  manifest: RoleGroupManifest;
17
18
  targetPath: string;
18
19
  }>;
20
+ pruned: Array<{
21
+ stableKey: string;
22
+ targetPath: string;
23
+ }>;
19
24
  skipped: Array<{
20
25
  name: string;
21
26
  targetPath: string;
@@ -24,6 +29,7 @@ export type RoleGroupPullResult = {
24
29
  };
25
30
  export type RoleGroupPlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped' | 'delete';
26
31
  export type RoleGroupPlanItem = {
32
+ fieldChanges?: FieldChange[];
27
33
  status: RoleGroupPlanStatus;
28
34
  stableKey?: string;
29
35
  name: string;
@@ -70,6 +76,7 @@ export declare function pullRoleGroupsToWorkspace(input: {
70
76
  envName: string;
71
77
  stableKeyName: string;
72
78
  force?: boolean;
79
+ pruneOrphans?: boolean;
73
80
  }): Promise<RoleGroupPullResult>;
74
81
  export declare function pushRoleGroups(input: {
75
82
  client: RevoClient;
@@ -1,8 +1,9 @@
1
1
  import path from 'node:path';
2
+ import { describeFieldChanges } from "../diff-details.js";
2
3
  import { hashStable, readComponentLock, writeComponentLock, } from "../component-lock.js";
3
4
  import { normalizeStableKeyValue, readConfiguredResourceMetadataStableKey, sanitizeUserMetadata, } from "../resource-metadata.js";
4
5
  import { readJsonFile, sanitizeSegment } from "../utils.js";
5
- import { findManifestFiles, isRecord, localTargetPath, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
6
+ import { findManifestFiles, isRecord, localTargetPath, mapWithConcurrency, removeRelocatedManifest, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest, } from "./util.js";
6
7
  export const ROLE_GROUPS_DIRECTORY = 'RoleGroups';
7
8
  export const ROLE_GROUP_MANIFEST_FILE = 'role-group.json';
8
9
  function roleGroupIdOf(record) {
@@ -70,6 +71,13 @@ export function roleGroupManifestPath(workspaceRoot, manifest) {
70
71
  const category = manifest.category == null || manifest.category === '' ? '__no_category__' : sanitizeSegment(manifest.category);
71
72
  return path.join(workspaceRoot, ROLE_GROUPS_DIRECTORY, category, `${sanitizeSegment(manifest.name)}-${stableKeySuffix(manifest.stableKey)}`, ROLE_GROUP_MANIFEST_FILE);
72
73
  }
74
+ function portablePathIdentity(filePath) {
75
+ return path.resolve(filePath)
76
+ .normalize('NFC')
77
+ .split(path.sep)
78
+ .map((segment) => segment.replace(/[. ]+$/g, '').toLowerCase())
79
+ .join(path.sep);
80
+ }
73
81
  export function readWorkspaceRoleGroups(cwd) {
74
82
  const { workspaceRoot } = requireProjectLayout(cwd, 'Role-group');
75
83
  return findManifestFiles(path.join(workspaceRoot, ROLE_GROUPS_DIRECTORY), ROLE_GROUP_MANIFEST_FILE)
@@ -80,12 +88,10 @@ export function readWorkspaceRoleGroups(cwd) {
80
88
  }
81
89
  async function loadRemoteRoleGroups(client) {
82
90
  const { roleGroups } = await client.listAllRoleGroups();
83
- const records = [];
84
- for (const summary of roleGroups) {
91
+ return mapWithConcurrency(roleGroups, async (summary) => {
85
92
  const id = roleGroupIdOf(summary);
86
- records.push(id ? unwrapData(await client.getRoleGroup(id)) : summary);
87
- }
88
- return records;
93
+ return id ? unwrapData(await client.getRoleGroup(id)) : summary;
94
+ });
89
95
  }
90
96
  function validateManifest(manifest, stableKeyName) {
91
97
  const errors = [];
@@ -233,7 +239,7 @@ export async function buildRoleGroupsPlan(input) {
233
239
  name: desired.name,
234
240
  desiredHash,
235
241
  currentHash: target.hash,
236
- ...(diff.changedFields.length > 0 ? { changedFields: diff.changedFields } : {}),
242
+ ...(diff.changedFields.length > 0 ? { changedFields: diff.changedFields, fieldChanges: describeFieldChanges(desired, target.manifest, diff.changedFields) } : {}),
237
243
  ...(diff.rolesToAdd.length > 0 ? { rolesToAdd: diff.rolesToAdd } : {}),
238
244
  ...(diff.rolesToRemove.length > 0 ? { rolesToRemove: diff.rolesToRemove } : {}),
239
245
  };
@@ -321,6 +327,7 @@ export async function pullRoleGroupsToWorkspace(input) {
321
327
  managed.sort((left, right) => left.stableKey.localeCompare(right.stableKey));
322
328
  const lock = readComponentLock(projectRoot);
323
329
  const existingByStableKey = new Map();
330
+ const existingByPath = new Map();
324
331
  for (const entry of readWorkspaceRoleGroups(input.cwd)) {
325
332
  const errors = validateManifest(entry.manifest, input.stableKeyName);
326
333
  if (errors.length > 0) {
@@ -331,6 +338,8 @@ export async function pullRoleGroupsToWorkspace(input) {
331
338
  throw new Error(`Duplicate local role-group stableKey "${entry.manifest.stableKey}"; no files were changed.`);
332
339
  }
333
340
  existingByStableKey.set(normalized, entry);
341
+ const pathIdentity = portablePathIdentity(entry.manifestPath);
342
+ existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
334
343
  }
335
344
  const writes = [];
336
345
  const outputPaths = new Set();
@@ -347,10 +356,16 @@ export async function pullRoleGroupsToWorkspace(input) {
347
356
  }
348
357
  }
349
358
  const filePath = roleGroupManifestPath(workspaceRoot, manifest);
350
- if (outputPaths.has(filePath)) {
359
+ const pathIdentity = portablePathIdentity(filePath);
360
+ if (outputPaths.has(pathIdentity)) {
351
361
  throw new Error(`Multiple role-groups resolve to workspace path "${path.relative(projectRoot, filePath)}"; no files were changed.`);
352
362
  }
353
- outputPaths.add(filePath);
363
+ const pathOwner = (existingByPath.get(pathIdentity) || [])
364
+ .find((entry) => normalizeStableKeyValue(entry.manifest.stableKey) !== normalized);
365
+ if (pathOwner) {
366
+ throw new Error(`Role-group workspace path "${path.relative(projectRoot, filePath)}" is occupied by different stableKey "${pathOwner.manifest.stableKey}"; no files were changed.`);
367
+ }
368
+ outputPaths.add(pathIdentity);
354
369
  writes.push({
355
370
  filePath,
356
371
  ...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
@@ -358,6 +373,18 @@ export async function pullRoleGroupsToWorkspace(input) {
358
373
  hash,
359
374
  });
360
375
  }
376
+ const sourceStableKeys = new Set(managed.map((manifest) => normalizeStableKeyValue(manifest.stableKey)));
377
+ const pruned = input.pruneOrphans === true
378
+ ? [...existingByStableKey.entries()]
379
+ .filter(([normalized]) => !sourceStableKeys.has(normalized))
380
+ .map(([, entry]) => ({
381
+ stableKey: entry.manifest.stableKey,
382
+ targetPath: localTargetPath(input.cwd, entry.manifestPath),
383
+ manifestPath: entry.manifestPath,
384
+ }))
385
+ .sort((left, right) => right.manifestPath.length - left.manifestPath.length
386
+ || left.stableKey.localeCompare(right.stableKey))
387
+ : [];
361
388
  const roleGroupsRoot = path.join(workspaceRoot, ROLE_GROUPS_DIRECTORY);
362
389
  let lockChanged = false;
363
390
  for (const write of writes) {
@@ -392,6 +419,16 @@ export async function pullRoleGroupsToWorkspace(input) {
392
419
  lockChanged = true;
393
420
  lock.roleGroups[write.manifest.stableKey] = entry;
394
421
  }
422
+ for (const removed of pruned) {
423
+ removeRelocatedManifest(removed.manifestPath, roleGroupsRoot);
424
+ const normalized = normalizeStableKeyValue(removed.stableKey);
425
+ const lockKey = Object.keys(lock.roleGroups)
426
+ .find((stableKey) => normalizeStableKeyValue(stableKey) === normalized);
427
+ if (lockKey) {
428
+ delete lock.roleGroups[lockKey];
429
+ }
430
+ lockChanged = true;
431
+ }
395
432
  if (lockChanged)
396
433
  writeComponentLock(projectRoot, lock);
397
434
  return {
@@ -399,6 +436,7 @@ export async function pullRoleGroupsToWorkspace(input) {
399
436
  manifest: write.manifest,
400
437
  targetPath: localTargetPath(input.cwd, write.filePath),
401
438
  })),
439
+ pruned: pruned.map(({ stableKey, targetPath }) => ({ stableKey, targetPath })),
402
440
  skipped,
403
441
  };
404
442
  }
@@ -1,3 +1,4 @@
1
+ import { type FieldChange } from '../diff-details.ts';
1
2
  import type { RevoClient } from '../client.ts';
2
3
  export declare const SCHEDULES_DIRECTORY = "Schedules";
3
4
  export declare const SCHEDULE_MANIFEST_FILE = "schedule.json";
@@ -35,20 +36,46 @@ export type SchedulePullResult = {
35
36
  manifest: ScheduleManifest;
36
37
  targetPath: string;
37
38
  }>;
39
+ pruned: Array<{
40
+ stableKey: string;
41
+ targetPath: string;
42
+ }>;
38
43
  warnings: SchedulePullWarning[];
39
44
  };
45
+ export type ProjectedScheduleDependency = {
46
+ stableKey: string;
47
+ desiredHash: string;
48
+ actualHash: string | null;
49
+ state: 'ready' | 'pending-create' | 'pending-update' | 'pending-adopt';
50
+ };
51
+ export type ProjectedScheduleDatabaseViewDependency = ProjectedScheduleDependency & {
52
+ viewType: string;
53
+ };
54
+ export type ScheduleDependencyReadiness = 'ready' | 'pending-job-template-create' | 'pending-job-template-update' | 'pending-job-template-adopt' | 'pending-database-view-create' | 'pending-database-view-update' | 'pending-database-view-adopt' | 'blocked';
55
+ export type ScheduleDependencyEdge = {
56
+ resource: 'job-template' | 'database-view';
57
+ stableKey: string;
58
+ expectedHash: string | null;
59
+ projectedHash: string | null;
60
+ actualHash: string | null;
61
+ readiness: ScheduleDependencyReadiness;
62
+ };
40
63
  export type SchedulePlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped';
41
64
  export type SchedulePlanItem = {
65
+ fieldChanges?: FieldChange[];
42
66
  status: SchedulePlanStatus;
43
67
  stableKey?: string;
44
68
  name: string;
45
69
  reason?: string;
70
+ forceRequirement?: 'schedule-target-type-transition';
46
71
  changedFields?: string[];
47
72
  desiredHash?: string;
48
73
  currentHash?: string;
49
74
  baselineHash?: string;
50
75
  jobTemplateStableKey?: string;
51
76
  databaseViewStableKey?: string;
77
+ dependency?: ScheduleDependencyEdge;
78
+ blocked?: boolean;
52
79
  };
53
80
  export type SchedulesPlan = {
54
81
  resourceType: 'schedule';
@@ -85,6 +112,8 @@ export declare function buildSchedulesPlan(input: {
85
112
  cwd: string;
86
113
  envName: string;
87
114
  stableKeyName: string;
115
+ projectedJobTemplates?: ProjectedScheduleDependency[];
116
+ projectedDatabaseViews?: ProjectedScheduleDatabaseViewDependency[];
88
117
  }): Promise<SchedulesPlan>;
89
118
  export declare function pullSchedulesToWorkspace(input: {
90
119
  client: RevoClient;
@@ -92,6 +121,7 @@ export declare function pullSchedulesToWorkspace(input: {
92
121
  envName: string;
93
122
  stableKeyName: string;
94
123
  force?: boolean;
124
+ pruneOrphans?: boolean;
95
125
  }): Promise<SchedulePullResult>;
96
126
  export declare function pushSchedules(input: {
97
127
  client: RevoClient;
@@ -99,7 +129,6 @@ export declare function pushSchedules(input: {
99
129
  envName: string;
100
130
  stableKeyName: string;
101
131
  force?: boolean;
102
- allowMaterialized?: boolean;
103
132
  }): Promise<{
104
133
  plan: SchedulesPlan;
105
134
  results: SchedulePushResult[];