@revoengine/cli 1.0.11 → 1.0.12

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,3 +1,4 @@
1
+ import { type FieldChange } from '../diff-details.ts';
1
2
  import type { RevoClient } from '../client.ts';
2
3
  export declare const EVENTS_DIRECTORY = "Events";
3
4
  export declare const EVENT_MANIFEST_FILE = "event.json";
@@ -9,6 +10,7 @@ export type EventManifest = {
9
10
  description?: string;
10
11
  metadata: Record<string, unknown>;
11
12
  active: boolean;
13
+ custom: boolean;
12
14
  type: string;
13
15
  filter?: Record<string, unknown> | null;
14
16
  target: {
@@ -22,13 +24,33 @@ export type EventPullResult = {
22
24
  manifest: EventManifest;
23
25
  targetPath: string;
24
26
  }>;
27
+ pruned: Array<{
28
+ stableKey: string;
29
+ targetPath: string;
30
+ }>;
25
31
  warnings: Array<{
26
32
  stableKey: string;
27
33
  reason: string;
28
34
  }>;
29
35
  };
36
+ export type ProjectedEventJobTemplateDependency = {
37
+ stableKey: string;
38
+ desiredHash: string;
39
+ actualHash: string | null;
40
+ state: 'ready' | 'pending-create' | 'pending-update' | 'pending-adopt';
41
+ };
42
+ export type EventDependencyReadiness = 'ready' | 'pending-job-template-create' | 'pending-job-template-update' | 'pending-job-template-adopt' | 'blocked';
43
+ export type EventDependencyEdge = {
44
+ resource: 'job-template';
45
+ stableKey: string;
46
+ expectedHash: string | null;
47
+ projectedHash: string | null;
48
+ actualHash: string | null;
49
+ readiness: EventDependencyReadiness;
50
+ };
30
51
  export type EventPlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'activation-drift' | 'orphan' | 'collision' | 'skipped';
31
52
  export type EventPlanItem = {
53
+ fieldChanges?: FieldChange[];
32
54
  status: EventPlanStatus;
33
55
  stableKey?: string;
34
56
  name: string;
@@ -38,12 +60,15 @@ export type EventPlanItem = {
38
60
  currentHash?: string;
39
61
  baselineHash?: string;
40
62
  jobTemplateStableKey?: string;
63
+ dependency?: EventDependencyEdge;
64
+ blocked?: boolean;
41
65
  };
42
66
  export type EventsPlan = {
43
67
  resourceType: 'event';
44
68
  env: string;
45
69
  counts: Record<EventPlanStatus, number>;
46
70
  blockers: string[];
71
+ warnings: string[];
47
72
  items: EventPlanItem[];
48
73
  exclusions: string[];
49
74
  };
@@ -74,6 +99,7 @@ export declare function buildEventsPlan(input: {
74
99
  cwd: string;
75
100
  envName: string;
76
101
  stableKeyName: string;
102
+ projectedJobTemplates?: ProjectedEventJobTemplateDependency[];
77
103
  }): Promise<EventsPlan>;
78
104
  export declare function pushEvents(input: {
79
105
  client: RevoClient;
@@ -96,4 +122,5 @@ export declare function pullEventsToWorkspace(input: {
96
122
  envName: string;
97
123
  stableKeyName: string;
98
124
  force?: boolean;
125
+ pruneOrphans?: boolean;
99
126
  }): Promise<EventPullResult>;
@@ -1,14 +1,15 @@
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 { NULL_CATEGORY_KEY, 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 EVENTS_DIRECTORY = 'Events';
7
8
  export const EVENT_MANIFEST_FILE = 'event.json';
8
9
  const EVENT_TRANSPORT_FIELDS = new Set([
9
10
  'jobEventId', 'eventId', 'id', 'name', 'category', 'desc', 'description', 'active', 'type',
10
11
  'targetType', 'targetId', 'targetVersion', 'targetConfig', 'filter', 'version', 'metadata',
11
- 'metaData', 'resourceMetadata', 'topic', 'deletedAt', 'deletedBy', 'createdAt', 'createdBy',
12
+ 'metaData', 'resourceMetadata', 'topic', 'custom', 'deletedAt', 'deletedBy', 'createdAt', 'createdBy',
12
13
  'lastUpdateAt', 'lastUpdateBy', 'updatedAt', 'updatedBy', 'history', 'jobEventHistory',
13
14
  ]);
14
15
  function eventIdOf(record) {
@@ -83,7 +84,7 @@ function nonEmptyString(value) {
83
84
  }
84
85
  function validManifest(value, stableKeyName) {
85
86
  if (!isRecord(value) || value.kind !== 'event' || !nonEmptyString(value.stableKey) || !nonEmptyString(value.name)
86
- || !nonEmptyString(value.type) || !isRecord(value.metadata) || !isRecord(value.target)) {
87
+ || !nonEmptyString(value.type) || typeof value.custom !== 'boolean' || !isRecord(value.metadata) || !isRecord(value.target)) {
87
88
  return false;
88
89
  }
89
90
  if (value.category !== undefined && value.category !== null && typeof value.category !== 'string') {
@@ -108,6 +109,9 @@ function validManifest(value, stableKeyName) {
108
109
  }
109
110
  function manifestFromRecord(input) {
110
111
  const { record, stableKey, jobTemplateStableKey, stableKeyName } = input;
112
+ if (typeof record.custom !== 'boolean') {
113
+ throw new Error(`Event "${stableKey}" is missing the custom classifier in the API response.`);
114
+ }
111
115
  const extensions = extensionFields(record);
112
116
  return {
113
117
  kind: 'event',
@@ -117,6 +121,7 @@ function manifestFromRecord(input) {
117
121
  ...(typeof record.desc === 'string' ? { description: record.desc } : typeof record.description === 'string' ? { description: record.description } : {}),
118
122
  metadata: canonicalMetadata(record, stableKeyName, stableKey),
119
123
  active: record.active === true,
124
+ custom: record.custom,
120
125
  type: String(record.type || ''),
121
126
  ...(record.filter === undefined ? {} : { filter: canonicalValue(record.filter) }),
122
127
  target: { type: 'JOB_TEMPLATE', jobTemplateStableKey },
@@ -126,7 +131,7 @@ function manifestFromRecord(input) {
126
131
  export function hashEventContent(manifest) {
127
132
  return hashStable({
128
133
  kind: 'event', stableKey: manifest.stableKey, name: manifest.name, category: manifest.category ?? null,
129
- description: manifest.description ?? '', metadata: canonicalValue(manifest.metadata), type: manifest.type,
134
+ description: manifest.description ?? '', metadata: canonicalValue(manifest.metadata), custom: manifest.custom, type: manifest.type,
130
135
  filter: canonicalValue(manifest.filter ?? null), target: manifest.target, extensions: canonicalValue(manifest.extensions || {}),
131
136
  });
132
137
  }
@@ -137,10 +142,10 @@ export function hashEventManifest(manifest) {
137
142
  return hashStable(canonicalValue(manifest));
138
143
  }
139
144
  async function hydrate(records, idOf, get) {
140
- return Promise.all(records.map(async (record) => {
145
+ return mapWithConcurrency(records, async (record) => {
141
146
  const id = idOf(record);
142
147
  return id ? unwrapData(await get(id)) : record;
143
- }));
148
+ });
144
149
  }
145
150
  async function loadRemoteEventInventory(client, stableKeyName) {
146
151
  const [{ events: eventSummaries }, { jobTemplates: templateSummaries }] = await Promise.all([
@@ -191,6 +196,7 @@ function diffEvents(desired, current) {
191
196
  ['category', desired.category ?? null, current.category ?? null],
192
197
  ['description', desired.description ?? '', current.description ?? ''],
193
198
  ['metadata', desired.metadata, current.metadata],
199
+ ['custom', desired.custom, current.custom],
194
200
  ['type', desired.type, current.type],
195
201
  ['filter', desired.filter ?? null, current.filter ?? null],
196
202
  ['target.jobTemplateStableKey', desired.target.jobTemplateStableKey, current.target.jobTemplateStableKey],
@@ -234,8 +240,18 @@ export async function buildEventsPlan(input) {
234
240
  const templatesById = remote.jobTemplatesById;
235
241
  const templatesByStableKey = remote.jobTemplatesByStableKey;
236
242
  const blockers = [];
243
+ const warnings = [];
237
244
  const exclusions = [];
238
245
  const items = [];
246
+ const projectedJobTemplatesByKey = input.projectedJobTemplates === undefined
247
+ ? undefined
248
+ : new Map();
249
+ for (const dependency of input.projectedJobTemplates || []) {
250
+ projectedJobTemplatesByKey?.set(dependency.stableKey, [
251
+ ...(projectedJobTemplatesByKey.get(dependency.stableKey) || []),
252
+ dependency,
253
+ ]);
254
+ }
239
255
  const localByStableKey = new Map();
240
256
  for (const entry of readWorkspaceEvents(input.cwd)) {
241
257
  const manifest = entry.manifest;
@@ -245,9 +261,11 @@ export async function buildEventsPlan(input) {
245
261
  : [];
246
262
  const reason = unsupportedExtensions.length > 0
247
263
  ? `unsupported extension fields: ${unsupportedExtensions.join(', ')}`
248
- : 'invalid manifest';
264
+ : isRecord(manifest) && manifest.custom === undefined
265
+ ? 'missing custom classifier; re-pull the Event from its source or add custom: true/false explicitly'
266
+ : 'invalid manifest';
249
267
  blockers.push(`Invalid Event manifest ${path.relative(projectRoot, entry.manifestPath)}: ${reason}.`);
250
- items.push({ status: 'conflict', name: isRecord(manifest) && nonEmptyString(manifest.name) ? manifest.name : path.basename(entry.manifestPath), reason });
268
+ items.push({ status: 'conflict', name: isRecord(manifest) && nonEmptyString(manifest.name) ? manifest.name : path.basename(entry.manifestPath), reason, blocked: true });
251
269
  continue;
252
270
  }
253
271
  localByStableKey.set(manifest.stableKey, [...(localByStableKey.get(manifest.stableKey) || []), { manifest }]);
@@ -256,7 +274,7 @@ export async function buildEventsPlan(input) {
256
274
  if (localEvents.length > 1) {
257
275
  blockers.push(`Duplicate local Event stableKey "${stableKey}".`);
258
276
  for (const local of localEvents) {
259
- items.push({ status: 'collision', stableKey, name: local.manifest.name, reason: 'duplicate workspace stableKey' });
277
+ items.push({ status: 'collision', stableKey, name: local.manifest.name, reason: 'duplicate workspace stableKey', blocked: true });
260
278
  }
261
279
  }
262
280
  }
@@ -276,7 +294,7 @@ export async function buildEventsPlan(input) {
276
294
  const label = target.stableKey || String(record.name || eventIdOf(record) || 'unknown event');
277
295
  if (target.dependencyBlocked) {
278
296
  blockers.push(`Cannot plan Event "${label}": ${target.reason}.`);
279
- items.push({ status: 'conflict', ...(target.stableKey ? { stableKey: target.stableKey } : {}), name: String(record.name || label), reason: target.reason });
297
+ items.push({ status: 'conflict', ...(target.stableKey ? { stableKey: target.stableKey } : {}), name: String(record.name || label), reason: target.reason, blocked: true });
280
298
  }
281
299
  else {
282
300
  exclusions.push(`${label}: ${target.reason}`);
@@ -298,6 +316,7 @@ export async function buildEventsPlan(input) {
298
316
  name: target.manifest.name,
299
317
  currentHash: target.hash,
300
318
  reason: 'duplicate target stableKey',
319
+ blocked: true,
301
320
  });
302
321
  }
303
322
  }
@@ -308,19 +327,60 @@ export async function buildEventsPlan(input) {
308
327
  continue;
309
328
  }
310
329
  const desired = localEvents[0].manifest;
311
- const templates = templatesByStableKey.get(desired.target.jobTemplateStableKey) || [];
330
+ const dependencyStableKey = desired.target.jobTemplateStableKey;
331
+ const liveTemplates = templatesByStableKey.get(dependencyStableKey) || [];
332
+ const usesProjection = projectedJobTemplatesByKey !== undefined;
333
+ const projectedTemplates = projectedJobTemplatesByKey?.get(dependencyStableKey) || [];
334
+ const templates = usesProjection ? projectedTemplates : liveTemplates;
312
335
  if (templates.length !== 1) {
313
- const reason = `target Job Template dependency "${desired.target.jobTemplateStableKey}" is ${templates.length === 0 ? 'missing' : 'ambiguous'}`;
336
+ const reason = templates.length === 0
337
+ ? (usesProjection ? 'Job Template is missing from the projected source migration' : 'target Job Template is missing')
338
+ : (usesProjection ? 'Job Template dependency stableKey is ambiguous in the projected source migration' : 'target Job Template dependency stableKey is ambiguous');
314
339
  blockers.push(`Cannot plan Event "${stableKey}": ${reason}.`);
315
- items.push({ status: 'conflict', stableKey, name: desired.name, reason, jobTemplateStableKey: desired.target.jobTemplateStableKey });
340
+ items.push({
341
+ status: 'conflict',
342
+ stableKey,
343
+ name: desired.name,
344
+ reason,
345
+ jobTemplateStableKey: dependencyStableKey,
346
+ dependency: {
347
+ resource: 'job-template',
348
+ stableKey: dependencyStableKey,
349
+ expectedHash: null,
350
+ projectedHash: null,
351
+ actualHash: null,
352
+ readiness: 'blocked',
353
+ },
354
+ blocked: true,
355
+ });
316
356
  continue;
317
357
  }
358
+ const projectedDependency = usesProjection ? projectedTemplates[0] : undefined;
359
+ const dependencyReadiness = projectedDependency?.state === 'pending-create'
360
+ ? 'pending-job-template-create'
361
+ : projectedDependency?.state === 'pending-update'
362
+ ? 'pending-job-template-update'
363
+ : projectedDependency?.state === 'pending-adopt'
364
+ ? 'pending-job-template-adopt'
365
+ : 'ready';
366
+ const dependency = {
367
+ resource: 'job-template',
368
+ stableKey: dependencyStableKey,
369
+ expectedHash: projectedDependency?.desiredHash || null,
370
+ projectedHash: projectedDependency?.desiredHash || null,
371
+ actualHash: projectedDependency?.actualHash || null,
372
+ readiness: dependencyReadiness,
373
+ };
374
+ if (dependencyReadiness !== 'ready') {
375
+ warnings.push(`Event "${stableKey}" dependency "${dependencyStableKey}" is ${dependencyReadiness}; migration will resolve its verified target UUID after the Job Template phase.`);
376
+ }
318
377
  const targets = targetsByStableKey.get(stableKey) || [];
319
378
  const common = {
320
379
  stableKey,
321
380
  name: desired.name,
322
381
  desiredHash: hashPortableEvent(desired),
323
382
  jobTemplateStableKey: desired.target.jobTemplateStableKey,
383
+ dependency,
324
384
  };
325
385
  if (targets.length > 1) {
326
386
  consumedTargets.add(stableKey);
@@ -330,7 +390,7 @@ export async function buildEventsPlan(input) {
330
390
  const targetIssue = targetIssuesByStableKey.get(stableKey);
331
391
  if (targetIssue) {
332
392
  blockers.push(`Cannot plan Event "${stableKey}": ${targetIssue}.`);
333
- items.push({ status: 'conflict', ...common, reason: targetIssue });
393
+ items.push({ status: 'conflict', ...common, reason: targetIssue, blocked: true });
334
394
  }
335
395
  else if (targetEvents.some((record) => !record.deletedAt
336
396
  && !record.deletedBy
@@ -338,7 +398,7 @@ export async function buildEventsPlan(input) {
338
398
  && eventPresentationKey(record) === eventPresentationKey(desired))) {
339
399
  const reason = `target Event matching category/name is missing ${input.stableKeyName}`;
340
400
  blockers.push(`Cannot plan Event "${stableKey}": ${reason}.`);
341
- items.push({ status: 'conflict', ...common, reason });
401
+ items.push({ status: 'conflict', ...common, reason, blocked: true });
342
402
  }
343
403
  else {
344
404
  items.push({ status: 'create', ...common });
@@ -347,27 +407,36 @@ export async function buildEventsPlan(input) {
347
407
  }
348
408
  consumedTargets.add(stableKey);
349
409
  const current = targets[0];
410
+ const fieldChanges = describeFieldChanges(desired, current.manifest, diffEvents(desired, current.manifest));
350
411
  const currentHash = current.hash;
351
412
  const baselineHash = lock.events[stableKey]?.environments[input.envName]?.remoteHash;
352
413
  const currentContentHash = current.contentHash;
353
414
  const desiredContentHash = hashEventContent(desired);
354
415
  if (desiredContentHash === currentContentHash && desired.active !== current.manifest.active) {
355
- items.push({ status: 'activation-drift', ...common, currentHash, baselineHash, reason: `source active=${desired.active}; target active=${current.manifest.active}` });
416
+ items.push({
417
+ status: 'activation-drift',
418
+ ...common,
419
+ changedFields: ['active'],
420
+ fieldChanges: describeFieldChanges(desired, current.manifest, ['active']),
421
+ currentHash,
422
+ baselineHash,
423
+ reason: `source active=${desired.active}; target active=${current.manifest.active}`,
424
+ });
356
425
  }
357
426
  else if (common.desiredHash === currentHash) {
358
427
  items.push({ status: 'clean', ...common, currentHash, ...(baselineHash ? { baselineHash } : {}) });
359
428
  }
360
429
  else if (!baselineHash) {
361
- items.push({ status: 'missing-lock', ...common, currentHash, reason: `missing ${input.envName} lock baseline` });
430
+ items.push({ status: 'missing-lock', ...common, fieldChanges, currentHash, changedFields: diffEvents(desired, current.manifest), reason: `missing ${input.envName} lock baseline` });
362
431
  }
363
432
  else if (currentHash === baselineHash) {
364
- items.push({ status: 'safe-update', ...common, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'local manifest changed; target matches lock baseline' });
433
+ items.push({ status: 'safe-update', ...common, fieldChanges, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'local manifest changed; target matches lock baseline' });
365
434
  }
366
435
  else if (common.desiredHash === baselineHash) {
367
- items.push({ status: 'remote-changed', ...common, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'target changed; local manifest matches lock baseline' });
436
+ items.push({ status: 'remote-changed', ...common, fieldChanges, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'target changed; local manifest matches lock baseline' });
368
437
  }
369
438
  else {
370
- items.push({ status: 'conflict', ...common, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'local manifest and target both changed since lock baseline' });
439
+ items.push({ status: 'conflict', ...common, fieldChanges, currentHash, baselineHash, changedFields: diffEvents(desired, current.manifest), reason: 'local manifest and target both changed since lock baseline' });
371
440
  }
372
441
  }
373
442
  for (const [stableKey, targets] of targetsByStableKey) {
@@ -400,6 +469,7 @@ export async function buildEventsPlan(input) {
400
469
  env: input.envName,
401
470
  counts,
402
471
  blockers: [...new Set(blockers)].sort(),
472
+ warnings: [...new Set(warnings)].sort(),
403
473
  items,
404
474
  exclusions: [...new Set(exclusions)].sort(),
405
475
  };
@@ -413,6 +483,7 @@ function buildEventCreatePayload(manifest, targetId) {
413
483
  active: false,
414
484
  ...(manifest.description === undefined ? {} : { desc: manifest.description }),
415
485
  metadata: canonicalValue(manifest.metadata),
486
+ custom: manifest.custom,
416
487
  type: manifest.type,
417
488
  ...(manifest.filter === undefined ? {} : { filter: canonicalValue(manifest.filter) }),
418
489
  targetType: 'JOB_TEMPLATE',
@@ -427,6 +498,7 @@ function buildEventUpdatePayload(manifest, targetId, version) {
427
498
  category: manifest.category ?? null,
428
499
  desc: manifest.description ?? '',
429
500
  metadata: canonicalValue(manifest.metadata),
501
+ custom: manifest.custom,
430
502
  type: manifest.type,
431
503
  filter: canonicalValue(manifest.filter ?? null),
432
504
  targetType: 'JOB_TEMPLATE',
@@ -861,14 +933,17 @@ export async function pullEventsToWorkspace(input) {
861
933
  const existingByPath = new Map();
862
934
  for (const entry of readWorkspaceEvents(input.cwd)) {
863
935
  const manifest = entry.manifest;
864
- if (!validManifest(manifest, input.stableKeyName)) {
936
+ const legacyWithoutCustom = isRecord(manifest) && manifest.custom === undefined
937
+ && validManifest({ ...manifest, custom: false }, input.stableKeyName);
938
+ if (!validManifest(manifest, input.stableKeyName) && !legacyWithoutCustom) {
865
939
  throw new Error(`Cannot pull over invalid Event manifest ${path.relative(projectRoot, entry.manifestPath)}.`);
866
940
  }
867
- if (existingByKey.has(manifest.stableKey)) {
868
- throw new Error(`Duplicate local Event stableKey "${manifest.stableKey}"; no files were changed.`);
941
+ const existingManifest = manifest;
942
+ if (existingByKey.has(existingManifest.stableKey)) {
943
+ throw new Error(`Duplicate local Event stableKey "${existingManifest.stableKey}"; no files were changed.`);
869
944
  }
870
- const localEntry = { manifestPath: entry.manifestPath, manifest };
871
- existingByKey.set(manifest.stableKey, localEntry);
945
+ const localEntry = { manifestPath: entry.manifestPath, manifest: existingManifest };
946
+ existingByKey.set(existingManifest.stableKey, localEntry);
872
947
  const pathIdentity = portablePathIdentity(entry.manifestPath);
873
948
  existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), localEntry]);
874
949
  }
@@ -891,6 +966,17 @@ export async function pullEventsToWorkspace(input) {
891
966
  previousPath: existing?.manifestPath,
892
967
  };
893
968
  });
969
+ const sourceStableKeys = new Set(manifests.map((manifest) => manifest.stableKey));
970
+ const pruned = input.pruneOrphans === true
971
+ ? [...existingByKey.values()]
972
+ .filter((entry) => !sourceStableKeys.has(entry.manifest.stableKey))
973
+ .map((entry) => ({
974
+ stableKey: entry.manifest.stableKey,
975
+ targetPath: localTargetPath(input.cwd, entry.manifestPath),
976
+ manifestPath: entry.manifestPath,
977
+ }))
978
+ .sort((left, right) => right.manifestPath.length - left.manifestPath.length || left.stableKey.localeCompare(right.stableKey))
979
+ : [];
894
980
  const candidatePathCounts = new Map();
895
981
  for (const write of writes) {
896
982
  const pathIdentity = portablePathIdentity(write.targetPath);
@@ -916,6 +1002,13 @@ export async function pullEventsToWorkspace(input) {
916
1002
  }
917
1003
  const root = path.join(workspaceRoot, EVENTS_DIRECTORY);
918
1004
  let lockChanged = false;
1005
+ for (const item of pruned) {
1006
+ removeRelocatedManifest(item.manifestPath, root);
1007
+ if (lock.events[item.stableKey]) {
1008
+ delete lock.events[item.stableKey];
1009
+ lockChanged = true;
1010
+ }
1011
+ }
919
1012
  for (const write of writes) {
920
1013
  writePulledManifest({
921
1014
  filePath: write.targetPath,
@@ -945,5 +1038,9 @@ export async function pullEventsToWorkspace(input) {
945
1038
  if (lockChanged) {
946
1039
  writeComponentLock(projectRoot, lock);
947
1040
  }
948
- return { pulled: writes.map((write) => ({ manifest: write.manifest, targetPath: localTargetPath(input.cwd, write.targetPath) })), warnings };
1041
+ return {
1042
+ pulled: writes.map((write) => ({ manifest: write.manifest, targetPath: localTargetPath(input.cwd, write.targetPath) })),
1043
+ pruned: pruned.map(({ stableKey, targetPath }) => ({ stableKey, targetPath })),
1044
+ warnings,
1045
+ };
949
1046
  }
@@ -1,3 +1,4 @@
1
+ import { type FieldChange } from '../diff-details.ts';
1
2
  import type { RevoClient } from '../client.ts';
2
3
  import type { GroupRecord } from '../types.ts';
3
4
  export declare const GROUPS_DIRECTORY = "Groups";
@@ -15,6 +16,10 @@ export type GroupPullResult = {
15
16
  manifest: GroupManifest;
16
17
  targetPath: string;
17
18
  }>;
19
+ pruned: Array<{
20
+ stableKey: string;
21
+ targetPath: string;
22
+ }>;
18
23
  skipped: Array<{
19
24
  name: string;
20
25
  targetPath: string;
@@ -27,6 +32,7 @@ export type GroupPullResult = {
27
32
  };
28
33
  export type GroupPlanStatus = 'clean' | 'create' | 'manual-owner' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped' | 'delete';
29
34
  export type GroupPlanItem = {
35
+ fieldChanges?: FieldChange[];
30
36
  status: GroupPlanStatus;
31
37
  stableKey?: string;
32
38
  name: string;
@@ -73,6 +79,7 @@ export declare function pullGroupsToWorkspace(input: {
73
79
  envName: string;
74
80
  stableKeyName: string;
75
81
  force?: boolean;
82
+ pruneOrphans?: boolean;
76
83
  }): Promise<GroupPullResult>;
77
84
  export declare function pushGroups(input: {
78
85
  client: RevoClient;
@@ -1,8 +1,9 @@
1
1
  import path from 'node:path';
2
+ import { describeFieldChanges, formatDiffValue } from "../diff-details.js";
2
3
  import { hashStable, readComponentLock, writeComponentLock, } from "../component-lock.js";
3
4
  import { 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 GROUPS_DIRECTORY = 'Groups';
7
8
  export const GROUP_MANIFEST_FILE = 'group.json';
8
9
  function groupIdOf(record) {
@@ -85,6 +86,13 @@ export function groupManifestPath(workspaceRoot, manifest) {
85
86
  : sanitizeSegment(manifest.category);
86
87
  return path.join(workspaceRoot, GROUPS_DIRECTORY, category, `${sanitizeSegment(manifest.name)}-${stableKeySuffix(manifest.stableKey)}`, GROUP_MANIFEST_FILE);
87
88
  }
89
+ function portablePathIdentity(filePath) {
90
+ return path.resolve(filePath)
91
+ .normalize('NFC')
92
+ .split(path.sep)
93
+ .map((segment) => segment.replace(/[. ]+$/g, '').toLowerCase())
94
+ .join(path.sep);
95
+ }
88
96
  export function readWorkspaceGroups(cwd) {
89
97
  const { workspaceRoot } = requireProjectLayout(cwd, 'Group');
90
98
  return findManifestFiles(path.join(workspaceRoot, GROUPS_DIRECTORY), GROUP_MANIFEST_FILE)
@@ -95,17 +103,10 @@ export function readWorkspaceGroups(cwd) {
95
103
  }
96
104
  async function loadRemoteGroups(client) {
97
105
  const { groups } = await client.listAllGroups();
98
- const records = [];
99
- for (const summary of groups) {
106
+ return mapWithConcurrency(groups, async (summary) => {
100
107
  const id = groupIdOf(summary);
101
- if (id) {
102
- records.push(unwrapData(await client.getGroup(id)));
103
- }
104
- else {
105
- records.push(summary);
106
- }
107
- }
108
- return records;
108
+ return id ? unwrapData(await client.getGroup(id)) : summary;
109
+ });
109
110
  }
110
111
  function validateManifest(manifest, stableKeyName) {
111
112
  const errors = [];
@@ -414,13 +415,31 @@ export async function buildGroupsPlan(input) {
414
415
  ...diffGroups(desired, target.manifest),
415
416
  ...(ownerChanged ? ['owner'] : []),
416
417
  ].sort((left, right) => left.localeCompare(right));
418
+ const targetOwner = ownerChanged
419
+ ? records.find((record) => groupIdOf(record) === target.record.ownerId)
420
+ : undefined;
421
+ const targetOwnerDescription = String(target.record.ownerType || '').toUpperCase() === 'GROUP'
422
+ ? (targetOwner && stableKeyOf(targetOwner, input.stableKeyName)) || 'GROUP (unmanaged)'
423
+ : String(target.record.ownerType || '').toUpperCase() === 'USER'
424
+ ? 'USER (target-local)'
425
+ : '<absent>';
417
426
  const common = {
418
427
  stableKey: desired.stableKey,
419
428
  name: desired.name,
420
429
  desiredHash,
421
430
  currentHash: target.hash,
422
431
  ...(ownerStableKey ? { ownerStableKey } : {}),
423
- ...(changedFields.length > 0 ? { changedFields } : {}),
432
+ ...(changedFields.length > 0 ? {
433
+ changedFields,
434
+ fieldChanges: [
435
+ ...describeFieldChanges(desired, target.manifest, changedFields.filter((field) => field !== 'owner')),
436
+ ...(ownerChanged && ownerStableKey ? [{
437
+ field: 'owner',
438
+ target: formatDiffValue(targetOwnerDescription),
439
+ workspace: formatDiffValue(ownerStableKey),
440
+ }] : []),
441
+ ],
442
+ } : {}),
424
443
  };
425
444
  if (desiredHash === target.hash && !ownerChanged) {
426
445
  items.push({ status: 'clean', ...common });
@@ -547,6 +566,7 @@ export async function pullGroupsToWorkspace(input) {
547
566
  managed.sort((left, right) => left.manifest.stableKey.localeCompare(right.manifest.stableKey));
548
567
  const lock = readComponentLock(projectRoot);
549
568
  const existingByStableKey = new Map();
569
+ const existingByPath = new Map();
550
570
  for (const entry of readWorkspaceGroups(input.cwd)) {
551
571
  const errors = validateManifest(entry.manifest, input.stableKeyName);
552
572
  if (errors.length > 0) {
@@ -556,6 +576,8 @@ export async function pullGroupsToWorkspace(input) {
556
576
  throw new Error(`Duplicate local Group stableKey "${entry.manifest.stableKey}"; no files were changed.`);
557
577
  }
558
578
  existingByStableKey.set(entry.manifest.stableKey, entry);
579
+ const pathIdentity = portablePathIdentity(entry.manifestPath);
580
+ existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
559
581
  }
560
582
  const writes = [];
561
583
  const outputPaths = new Set();
@@ -571,10 +593,16 @@ export async function pullGroupsToWorkspace(input) {
571
593
  }
572
594
  }
573
595
  const filePath = groupManifestPath(workspaceRoot, manifest);
574
- if (outputPaths.has(filePath)) {
596
+ const pathIdentity = portablePathIdentity(filePath);
597
+ if (outputPaths.has(pathIdentity)) {
575
598
  throw new Error(`Multiple Groups resolve to workspace path "${path.relative(projectRoot, filePath)}"; no files were changed.`);
576
599
  }
577
- outputPaths.add(filePath);
600
+ const pathOwner = (existingByPath.get(pathIdentity) || [])
601
+ .find((entry) => entry.manifest.stableKey !== manifest.stableKey);
602
+ if (pathOwner) {
603
+ throw new Error(`Group workspace path "${path.relative(projectRoot, filePath)}" is occupied by different stableKey "${pathOwner.manifest.stableKey}"; no files were changed.`);
604
+ }
605
+ outputPaths.add(pathIdentity);
578
606
  writes.push({
579
607
  filePath,
580
608
  ...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
@@ -583,6 +611,18 @@ export async function pullGroupsToWorkspace(input) {
583
611
  owner,
584
612
  });
585
613
  }
614
+ const sourceStableKeys = new Set(managed.map(({ manifest }) => manifest.stableKey));
615
+ const pruned = input.pruneOrphans === true
616
+ ? [...existingByStableKey.values()]
617
+ .filter((entry) => !sourceStableKeys.has(entry.manifest.stableKey))
618
+ .map((entry) => ({
619
+ stableKey: entry.manifest.stableKey,
620
+ targetPath: localTargetPath(input.cwd, entry.manifestPath),
621
+ manifestPath: entry.manifestPath,
622
+ }))
623
+ .sort((left, right) => right.manifestPath.length - left.manifestPath.length
624
+ || left.stableKey.localeCompare(right.stableKey))
625
+ : [];
586
626
  const groupsRoot = path.join(workspaceRoot, GROUPS_DIRECTORY);
587
627
  let lockChanged = false;
588
628
  for (const write of writes) {
@@ -612,6 +652,11 @@ export async function pullGroupsToWorkspace(input) {
612
652
  }
613
653
  lock.groups[write.manifest.stableKey] = entry;
614
654
  }
655
+ for (const removed of pruned) {
656
+ removeRelocatedManifest(removed.manifestPath, groupsRoot);
657
+ delete lock.groups[removed.stableKey];
658
+ lockChanged = true;
659
+ }
615
660
  if (lockChanged) {
616
661
  writeComponentLock(projectRoot, lock);
617
662
  }
@@ -620,6 +665,7 @@ export async function pullGroupsToWorkspace(input) {
620
665
  manifest: write.manifest,
621
666
  targetPath: localTargetPath(input.cwd, write.filePath),
622
667
  })),
668
+ pruned: pruned.map(({ stableKey, targetPath }) => ({ stableKey, targetPath })),
623
669
  skipped,
624
670
  notices,
625
671
  };
@@ -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 JOB_TEMPLATES_DIRECTORY = "JobTemplates";
3
4
  export declare const JOB_TEMPLATE_MANIFEST_FILE = "job-template.json";
@@ -24,11 +25,26 @@ export type JobTemplatePullResult = {
24
25
  manifest: JobTemplateManifest;
25
26
  targetPath: string;
26
27
  }>;
28
+ pruned: Array<{
29
+ stableKey: string;
30
+ targetPath: string;
31
+ }>;
32
+ skipped: Array<{
33
+ name: string;
34
+ targetPath: string;
35
+ reason: string;
36
+ }>;
27
37
  warnings: Array<{
28
38
  stableKey: string;
29
39
  reason: string;
30
40
  }>;
31
41
  };
42
+ export type ProjectedComponentDependency = {
43
+ stableKey: string;
44
+ desiredHash: string;
45
+ state: 'ready' | 'pending-create' | 'pending-update' | 'pending-adopt';
46
+ };
47
+ export type JobTemplateDependencyReadiness = 'ready' | 'pending-component-create' | 'pending-component-update' | 'pending-component-adopt' | 'blocked';
32
48
  export type JobTemplatePushResult = {
33
49
  stableKey: string;
34
50
  action: 'create' | 'update' | 'noop' | 'orphan' | 'skipped';
@@ -39,6 +55,7 @@ export type JobTemplatePushResult = {
39
55
  };
40
56
  export type JobTemplatePlanStatus = 'clean' | 'create' | 'safe-update' | 'remote-changed' | 'conflict' | 'missing-lock' | 'orphan' | 'collision' | 'skipped';
41
57
  export type JobTemplatePlanItem = {
58
+ fieldChanges?: FieldChange[];
42
59
  status: JobTemplatePlanStatus;
43
60
  stableKey?: string;
44
61
  name: string;
@@ -48,6 +65,8 @@ export type JobTemplatePlanItem = {
48
65
  currentHash?: string;
49
66
  baselineHash?: string;
50
67
  componentStableKey?: string;
68
+ componentDesiredHash?: string;
69
+ dependencyReadiness?: JobTemplateDependencyReadiness;
51
70
  };
52
71
  export type JobTemplatesPlan = {
53
72
  resourceType: 'job-template';
@@ -65,6 +84,7 @@ export declare function buildJobTemplatesPlan(input: {
65
84
  cwd: string;
66
85
  envName: string;
67
86
  stableKeyName: string;
87
+ projectedComponents?: ProjectedComponentDependency[];
68
88
  }): Promise<JobTemplatesPlan>;
69
89
  export declare function pullJobTemplatesToWorkspace(input: {
70
90
  client: RevoClient;
@@ -72,6 +92,7 @@ export declare function pullJobTemplatesToWorkspace(input: {
72
92
  envName: string;
73
93
  stableKeyName: string;
74
94
  force?: boolean;
95
+ pruneOrphans?: boolean;
75
96
  }): Promise<JobTemplatePullResult>;
76
97
  export declare function pushJobTemplates(input: {
77
98
  client: RevoClient;