@revoengine/cli 1.0.10 → 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 (104) hide show
  1. package/README.md +314 -239
  2. package/dist/src/cli.js +126 -9
  3. package/dist/src/client.d.ts +373 -6
  4. package/dist/src/client.js +1005 -53
  5. package/dist/src/commands/auth.js +4 -2
  6. package/dist/src/commands/component.d.ts +67 -0
  7. package/dist/src/commands/component.js +555 -164
  8. package/dist/src/commands/database-tables.d.ts +2 -0
  9. package/dist/src/commands/database-tables.js +169 -0
  10. package/dist/src/commands/database-views.d.ts +2 -0
  11. package/dist/src/commands/database-views.js +126 -0
  12. package/dist/src/commands/endpoints.js +124 -0
  13. package/dist/src/commands/env.js +44 -24
  14. package/dist/src/commands/events.d.ts +2 -0
  15. package/dist/src/commands/events.js +144 -0
  16. package/dist/src/commands/groups.d.ts +2 -0
  17. package/dist/src/commands/groups.js +160 -0
  18. package/dist/src/commands/index.d.ts +9 -0
  19. package/dist/src/commands/index.js +9 -0
  20. package/dist/src/commands/job-templates.d.ts +2 -0
  21. package/dist/src/commands/job-templates.js +107 -0
  22. package/dist/src/commands/metadata.js +75 -10
  23. package/dist/src/commands/migrate.d.ts +6 -0
  24. package/dist/src/commands/migrate.js +658 -0
  25. package/dist/src/commands/project.js +10 -3
  26. package/dist/src/commands/role-groups.d.ts +2 -0
  27. package/dist/src/commands/role-groups.js +141 -0
  28. package/dist/src/commands/schedules.d.ts +2 -0
  29. package/dist/src/commands/schedules.js +140 -0
  30. package/dist/src/commands/terminal-browser.d.ts +16 -0
  31. package/dist/src/commands/terminal-browser.js +92 -0
  32. package/dist/src/commands/terminal-image.d.ts +7 -0
  33. package/dist/src/commands/terminal-image.js +40 -0
  34. package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
  35. package/dist/src/commands/terminal-patch-worker.js +24 -0
  36. package/dist/src/commands/terminal-patch.d.ts +2 -0
  37. package/dist/src/commands/terminal-patch.js +156 -0
  38. package/dist/src/commands/terminal-sandbox.d.ts +8 -0
  39. package/dist/src/commands/terminal-sandbox.js +87 -0
  40. package/dist/src/commands/terminal-service.d.ts +38 -0
  41. package/dist/src/commands/terminal-service.js +210 -0
  42. package/dist/src/commands/terminal.d.ts +49 -0
  43. package/dist/src/commands/terminal.js +826 -0
  44. package/dist/src/component-lock.d.ts +111 -3
  45. package/dist/src/component-lock.js +363 -15
  46. package/dist/src/config.d.ts +10 -2
  47. package/dist/src/config.js +49 -14
  48. package/dist/src/database-table-artifacts.d.ts +7 -0
  49. package/dist/src/database-table-artifacts.js +8 -0
  50. package/dist/src/diff-details.d.ts +8 -0
  51. package/dist/src/diff-details.js +152 -0
  52. package/dist/src/env-sync.d.ts +0 -3
  53. package/dist/src/env-sync.js +11 -25
  54. package/dist/src/http-trace.d.ts +94 -0
  55. package/dist/src/http-trace.js +226 -0
  56. package/dist/src/metadata-backfill.d.ts +18 -7
  57. package/dist/src/metadata-backfill.js +1002 -27
  58. package/dist/src/migration.d.ts +141 -0
  59. package/dist/src/migration.js +1632 -0
  60. package/dist/src/project.d.ts +2 -0
  61. package/dist/src/project.js +4 -17
  62. package/dist/src/prompt.js +10 -18
  63. package/dist/src/resource-inventory.d.ts +28 -0
  64. package/dist/src/resource-inventory.js +85 -0
  65. package/dist/src/resource-metadata.d.ts +1 -0
  66. package/dist/src/resource-metadata.js +3 -0
  67. package/dist/src/resource-syncs/database-table-sync.d.ts +127 -0
  68. package/dist/src/resource-syncs/database-table-sync.js +2374 -0
  69. package/dist/src/resource-syncs/database-view-sync.d.ts +146 -0
  70. package/dist/src/resource-syncs/database-view-sync.js +1405 -0
  71. package/dist/src/resource-syncs/endpoint-sync.d.ts +123 -0
  72. package/dist/src/resource-syncs/endpoint-sync.js +1563 -0
  73. package/dist/src/resource-syncs/event-sync.d.ts +126 -0
  74. package/dist/src/resource-syncs/event-sync.js +1046 -0
  75. package/dist/src/resource-syncs/group-sync.d.ts +93 -0
  76. package/dist/src/resource-syncs/group-sync.js +928 -0
  77. package/dist/src/resource-syncs/job-template-sync.d.ts +106 -0
  78. package/dist/src/resource-syncs/job-template-sync.js +843 -0
  79. package/dist/src/resource-syncs/role-group-sync.d.ts +90 -0
  80. package/dist/src/resource-syncs/role-group-sync.js +635 -0
  81. package/dist/src/resource-syncs/schedule-sync.d.ts +140 -0
  82. package/dist/src/resource-syncs/schedule-sync.js +1396 -0
  83. package/dist/src/resource-syncs/util.d.ts +22 -0
  84. package/dist/src/resource-syncs/util.js +118 -0
  85. package/dist/src/resource-target.d.ts +11 -0
  86. package/dist/src/resource-target.js +48 -0
  87. package/dist/src/runtime-view.d.ts +1 -0
  88. package/dist/src/runtime-view.js +6 -1
  89. package/dist/src/sync-output.d.ts +66 -0
  90. package/dist/src/sync-output.js +268 -0
  91. package/dist/src/tracked-resources.d.ts +1 -1
  92. package/dist/src/tracked-resources.js +28 -2
  93. package/dist/src/types.d.ts +227 -0
  94. package/dist/src/ui.d.ts +3 -0
  95. package/dist/src/ui.js +76 -18
  96. package/dist/src/utils.d.ts +4 -0
  97. package/dist/src/utils.js +81 -0
  98. package/dist/src/workspace-component.d.ts +2 -0
  99. package/dist/src/workspace-component.js +34 -0
  100. package/dist/src/workspace-diff.d.ts +25 -0
  101. package/dist/src/workspace-diff.js +75 -0
  102. package/dist/src/workspace-resource.d.ts +2 -0
  103. package/dist/src/workspace-resource.js +52 -0
  104. package/package.json +12 -4
@@ -0,0 +1,22 @@
1
+ import { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency } from '../utils.ts';
2
+ export { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency };
3
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
4
+ export declare function unwrapData<T>(value: unknown): T;
5
+ export declare function requireProjectLayout(cwd: string, resourceLabel: string): {
6
+ projectRoot: string;
7
+ workspaceRoot: string;
8
+ };
9
+ export declare function stableKeySuffix(stableKey: string): string;
10
+ export declare function findManifestFiles(directory: string, manifestFileName: string): string[];
11
+ export declare function writeManifestIfChanged(filePath: string, manifest: unknown): boolean;
12
+ export declare function writePulledManifest(input: {
13
+ filePath: string;
14
+ manifest: unknown;
15
+ previousPath?: string;
16
+ root: string;
17
+ force?: boolean;
18
+ legacyManifestNames?: readonly string[];
19
+ }): void;
20
+ export declare function removeRelocatedManifest(filePath: string, root: string): void;
21
+ export declare function localTargetPath(cwd: string, manifestPath: string): string;
22
+ export declare function toPortableRelativePath(root: string, filePath: string): string;
@@ -0,0 +1,118 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { hashStable } from "../component-lock.js";
4
+ import { resolveProjectRoot, resolveProjectWorkspace } from "../project.js";
5
+ import { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency, sanitizeSegment, writeJsonFile } from "../utils.js";
6
+ import { replaceWorkspaceResourceDirectory } from "../workspace-resource.js";
7
+ export { DEFAULT_RESOURCE_CONCURRENCY, mapWithConcurrency };
8
+ export function isRecord(value) {
9
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
10
+ }
11
+ export function unwrapData(value) {
12
+ return isRecord(value) && isRecord(value.data) ? value.data : value;
13
+ }
14
+ export function requireProjectLayout(cwd, resourceLabel) {
15
+ const projectRoot = resolveProjectRoot(cwd);
16
+ const workspaceRoot = resolveProjectWorkspace(cwd);
17
+ if (!projectRoot || !workspaceRoot) {
18
+ throw new Error(`${resourceLabel} sync requires a configured Revo project. Run \`revo project init [path]\` first.`);
19
+ }
20
+ return { projectRoot, workspaceRoot };
21
+ }
22
+ export function stableKeySuffix(stableKey) {
23
+ const suffix = stableKey.includes('#') ? stableKey.slice(stableKey.lastIndexOf('#') + 1) : '';
24
+ return sanitizeSegment(suffix || hashStable(stableKey).slice(0, 8));
25
+ }
26
+ export function findManifestFiles(directory, manifestFileName) {
27
+ if (!fs.existsSync(directory))
28
+ return [];
29
+ const files = [];
30
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
31
+ const entryPath = path.join(directory, entry.name);
32
+ if (entry.isDirectory())
33
+ files.push(...findManifestFiles(entryPath, manifestFileName));
34
+ else if (entry.isFile() && entry.name === manifestFileName)
35
+ files.push(entryPath);
36
+ }
37
+ return files.sort((left, right) => left.localeCompare(right));
38
+ }
39
+ export function writeManifestIfChanged(filePath, manifest) {
40
+ const serialized = `${JSON.stringify(manifest, null, 2)}\n`;
41
+ if (fs.existsSync(filePath) && fs.readFileSync(filePath, 'utf8') === serialized)
42
+ return false;
43
+ writeJsonFile(filePath, manifest);
44
+ return true;
45
+ }
46
+ // Nested manifests belong to separate resources (notably DB partitions).
47
+ // Preserve those directories until their own pull or explicit prune handles them.
48
+ function copyNestedResourceDirectories(source, target, manifestNames) {
49
+ if (!fs.existsSync(source)) {
50
+ return;
51
+ }
52
+ for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
53
+ if (!entry.isDirectory()) {
54
+ continue;
55
+ }
56
+ const sourceDirectory = path.join(source, entry.name);
57
+ const targetDirectory = path.join(target, entry.name);
58
+ if (manifestNames.some((manifestName) => fs.existsSync(path.join(sourceDirectory, manifestName)))) {
59
+ fs.cpSync(sourceDirectory, targetDirectory, { recursive: true, dereference: false });
60
+ }
61
+ else {
62
+ copyNestedResourceDirectories(sourceDirectory, targetDirectory, manifestNames);
63
+ }
64
+ }
65
+ }
66
+ export function writePulledManifest(input) {
67
+ const directory = path.dirname(input.filePath);
68
+ const manifestName = path.basename(input.filePath);
69
+ const manifestNames = [manifestName, ...(input.legacyManifestNames || [])];
70
+ if (input.force) {
71
+ const serialized = `${JSON.stringify(input.manifest, null, 2)}\n`;
72
+ replaceWorkspaceResourceDirectory(input.root, directory, (staged) => {
73
+ copyNestedResourceDirectories(directory, staged, manifestNames);
74
+ fs.writeFileSync(path.join(staged, manifestName), serialized);
75
+ });
76
+ }
77
+ else {
78
+ writeManifestIfChanged(input.filePath, input.manifest);
79
+ }
80
+ if (!input.previousPath || input.previousPath === input.filePath || !fs.existsSync(input.previousPath)) {
81
+ return;
82
+ }
83
+ const previousDirectory = path.dirname(input.previousPath);
84
+ const previousStat = fs.statSync(previousDirectory);
85
+ const currentStat = fs.statSync(directory);
86
+ if (previousStat.dev === currentStat.dev && previousStat.ino === currentStat.ino) {
87
+ return;
88
+ }
89
+ if (input.force) {
90
+ replaceWorkspaceResourceDirectory(input.root, previousDirectory, (staged) => {
91
+ copyNestedResourceDirectories(previousDirectory, staged, manifestNames);
92
+ });
93
+ removeEmptyResourceParents(previousDirectory, input.root);
94
+ }
95
+ else {
96
+ removeRelocatedManifest(input.previousPath, input.root);
97
+ }
98
+ }
99
+ function removeEmptyResourceParents(directory, root) {
100
+ const resolvedRoot = path.resolve(root);
101
+ let current = path.resolve(directory);
102
+ while (current.startsWith(`${resolvedRoot}${path.sep}`) && fs.readdirSync(current).length === 0) {
103
+ fs.rmdirSync(current);
104
+ current = path.dirname(current);
105
+ }
106
+ }
107
+ export function removeRelocatedManifest(filePath, root) {
108
+ if (!fs.existsSync(filePath))
109
+ return;
110
+ fs.unlinkSync(filePath);
111
+ removeEmptyResourceParents(path.dirname(filePath), root);
112
+ }
113
+ export function localTargetPath(cwd, manifestPath) {
114
+ return path.relative(cwd, path.dirname(manifestPath)) || '.';
115
+ }
116
+ export function toPortableRelativePath(root, filePath) {
117
+ return path.relative(root, filePath).split(path.sep).join('/');
118
+ }
@@ -0,0 +1,11 @@
1
+ import { RevoClient } from './client.ts';
2
+ import type { CommandContext } from './types.ts';
3
+ export declare function resolveAuthenticatedInstance(client: RevoClient, role: 'source' | 'target'): Promise<string>;
4
+ export declare function resolveResourceTarget(context: CommandContext, options: {
5
+ resource: string;
6
+ allowDefaultProfile?: boolean;
7
+ }): Promise<{
8
+ client: RevoClient;
9
+ envName: string;
10
+ displayName: string;
11
+ }>;
@@ -0,0 +1,48 @@
1
+ import { extractProfileInstanceId, RevoClient } from "./client.js";
2
+ import { DEFAULT_ENV_NAME, resolveRuntimeConfig } from "./config.js";
3
+ import { readFlag } from "./utils.js";
4
+ export async function resolveAuthenticatedInstance(client, role) {
5
+ const configuredInstance = client.instance.trim();
6
+ const session = await client.validateSession({ force: true });
7
+ const authenticatedInstance = extractProfileInstanceId(session.profile).trim();
8
+ if (!authenticatedInstance) {
9
+ throw new Error(`${role === 'source' ? 'Source' : 'Target'} instance could not be resolved from --instance, REVO_INSTANCE, stored configuration, or /api/v1/me.`);
10
+ }
11
+ if (configuredInstance && configuredInstance !== authenticatedInstance) {
12
+ throw new Error(`Configured ${role} instance "${configuredInstance}" does not match authenticated instance "${authenticatedInstance}" returned by /api/v1/me.`);
13
+ }
14
+ client.instance = authenticatedInstance;
15
+ return authenticatedInstance;
16
+ }
17
+ export async function resolveResourceTarget(context, options) {
18
+ const selectedEnvironment = readFlag(context.args, ['env']);
19
+ if (context.args.env !== undefined && !selectedEnvironment) {
20
+ throw new Error('Missing --env <name>.');
21
+ }
22
+ if (selectedEnvironment === DEFAULT_ENV_NAME && context.args.project === DEFAULT_ENV_NAME) {
23
+ const instance = await resolveAuthenticatedInstance(context.client, 'target');
24
+ return {
25
+ client: context.client,
26
+ envName: `instance:${instance}`,
27
+ displayName: context.client.baseUrl,
28
+ };
29
+ }
30
+ if (selectedEnvironment) {
31
+ if (selectedEnvironment === DEFAULT_ENV_NAME && options.allowDefaultProfile !== true) {
32
+ throw new Error(`${options.resource} sync requires a named environment profile; "default" is not supported.`);
33
+ }
34
+ return {
35
+ client: context.componentEnvironment === selectedEnvironment
36
+ ? context.client
37
+ : new RevoClient({ ...resolveRuntimeConfig({ envName: selectedEnvironment }), environmentName: selectedEnvironment }),
38
+ envName: selectedEnvironment,
39
+ displayName: selectedEnvironment,
40
+ };
41
+ }
42
+ const instance = await resolveAuthenticatedInstance(context.client, 'target');
43
+ return {
44
+ client: context.client,
45
+ envName: `instance:${instance}`,
46
+ displayName: context.client.baseUrl,
47
+ };
48
+ }
@@ -10,6 +10,7 @@ export type RuntimeViewModel = {
10
10
  nodeVersion: string;
11
11
  configDir: string;
12
12
  runtime: ReturnType<typeof resolveRuntimeConfig>;
13
+ environmentName: string;
13
14
  auth: AuthViewState;
14
15
  };
15
16
  export declare function buildRuntimeViewModel(context: CommandContext, options?: {
@@ -1,7 +1,8 @@
1
- import { getConfigDir, resolveRuntimeConfig } from "./config.js";
1
+ import { getActiveEnvironmentName, getConfigDir, resolveRuntimeConfig } from "./config.js";
2
2
  import { AuthenticationError } from "./client.js";
3
3
  function resolveArgsRuntime(context) {
4
4
  return resolveRuntimeConfig({
5
+ envName: typeof context.args.env === 'string' ? context.args.env : undefined,
5
6
  baseUrl: typeof context.args.url === 'string'
6
7
  ? context.args.url
7
8
  : typeof context.args.baseUrl === 'string'
@@ -44,6 +45,9 @@ function extractEmail(profile) {
44
45
  }
45
46
  export async function buildRuntimeViewModel(context, options = {}) {
46
47
  const runtime = resolveArgsRuntime(context);
48
+ const environmentName = typeof context.args.env === 'string'
49
+ ? context.args.env
50
+ : getActiveEnvironmentName();
47
51
  const auth = {
48
52
  status: 'not_authenticated',
49
53
  validation: null,
@@ -75,6 +79,7 @@ export async function buildRuntimeViewModel(context, options = {}) {
75
79
  nodeVersion: process.version,
76
80
  configDir: getConfigDir(),
77
81
  runtime,
82
+ environmentName,
78
83
  auth,
79
84
  };
80
85
  }
@@ -0,0 +1,66 @@
1
+ import type { CommandContext } from './types.ts';
2
+ import type { FieldChange } from './diff-details.ts';
3
+ import type { WorkspaceDiff } from './workspace-diff.ts';
4
+ export type WorkspaceSyncStatus = 'pulled' | 'pruned' | 'deployed' | 'skipped' | 'failed' | 'write-unverified';
5
+ export type WorkspaceSyncResult = {
6
+ status: WorkspaceSyncStatus;
7
+ targetPath: string;
8
+ reason?: string;
9
+ };
10
+ export type SyncOutputStatus = 'Pulled' | 'Pruned' | 'Skipped' | 'Deployed' | 'Activated' | 'Deactivated' | 'Failed' | 'Unverified';
11
+ export type SyncPlanDetail = {
12
+ label: string;
13
+ values?: string | ReadonlyArray<string>;
14
+ diffs?: ReadonlyArray<{
15
+ field: string;
16
+ risk?: string;
17
+ before: string;
18
+ after: string;
19
+ }>;
20
+ lines?: ReadonlyArray<string>;
21
+ };
22
+ export declare function planValueChanges(changes: ReadonlyArray<{
23
+ field: string;
24
+ risk?: string;
25
+ before?: unknown;
26
+ after?: unknown;
27
+ }>): SyncPlanDetail[];
28
+ export declare function planListChanges(label: string, removed?: ReadonlyArray<string>, added?: ReadonlyArray<string>): SyncPlanDetail[];
29
+ export type SyncPlanItem = {
30
+ status: string;
31
+ stableKey?: string;
32
+ name?: string;
33
+ target?: string;
34
+ reason?: string;
35
+ changedFields?: ReadonlyArray<string>;
36
+ fieldChanges?: ReadonlyArray<FieldChange>;
37
+ details?: ReadonlyArray<SyncPlanDetail>;
38
+ hints?: ReadonlyArray<SyncPlanDetail>;
39
+ };
40
+ export declare function planDependencyHints(dependency: {
41
+ resource: string;
42
+ stableKey: string;
43
+ readiness: string;
44
+ expectedHash: string | null;
45
+ projectedHash: string | null;
46
+ actualHash: string | null;
47
+ }): SyncPlanDetail[];
48
+ export type SyncPlanOutput = {
49
+ title: string;
50
+ environment: string;
51
+ counts: Readonly<Record<string, number>>;
52
+ items: ReadonlyArray<SyncPlanItem>;
53
+ showHints?: boolean;
54
+ warnings?: ReadonlyArray<string>;
55
+ blockers?: ReadonlyArray<string>;
56
+ };
57
+ export declare function printSyncPlan(println: CommandContext['println'], input: SyncPlanOutput): void;
58
+ export declare function printWorkspaceDiff(println: CommandContext['println'], diff: WorkspaceDiff): void;
59
+ export declare function printSyncStatus(println: CommandContext['println'], input: {
60
+ status: SyncOutputStatus;
61
+ direction: 'pull' | 'push';
62
+ targetPath: string;
63
+ reason?: string;
64
+ }): void;
65
+ export declare function printSyncNotice(println: CommandContext['println'], message: string): void;
66
+ export declare function printSyncSummary(println: CommandContext['println'], label: 'Pulled' | 'Deployed' | 'Activated', results: ReadonlyArray<Pick<WorkspaceSyncResult, 'status'>>, durationMs: number): void;
@@ -0,0 +1,268 @@
1
+ import { formatDiffValue } from "./diff-details.js";
2
+ export function planValueChanges(changes) {
3
+ if (changes.length === 0) {
4
+ return [];
5
+ }
6
+ return [{
7
+ label: 'changes',
8
+ diffs: changes.map((change) => ({
9
+ field: change.field,
10
+ ...(change.risk ? { risk: change.risk } : {}),
11
+ before: formatDiffValue(change.before, change.field),
12
+ after: formatDiffValue(change.after, change.field),
13
+ })),
14
+ }];
15
+ }
16
+ export function planListChanges(label, removed = [], added = []) {
17
+ const lines = [
18
+ ...removed.map((value) => `- ${value}`),
19
+ ...added.map((value) => `+ ${value}`),
20
+ ];
21
+ return lines.length > 0 ? [{ label, lines }] : [];
22
+ }
23
+ export function planDependencyHints(dependency) {
24
+ return [
25
+ { label: 'dependency', values: `${dependency.resource}:${dependency.stableKey} (${dependency.readiness})` },
26
+ { label: 'expected hash', values: dependency.expectedHash || '<not projected>' },
27
+ { label: 'projected hash', values: dependency.projectedHash || '<not projected>' },
28
+ { label: 'actual hash', values: dependency.actualHash || '<missing>' },
29
+ ];
30
+ }
31
+ const ANSI = {
32
+ reset: '\u001b[0m',
33
+ bold: '\u001b[1m',
34
+ dim: '\u001b[2m',
35
+ red: '\u001b[31m',
36
+ green: '\u001b[32m',
37
+ yellow: '\u001b[33m',
38
+ cyan: '\u001b[36m',
39
+ blue: '\u001b[34m',
40
+ magenta: '\u001b[35m',
41
+ white: '\u001b[97m',
42
+ black: '\u001b[30m',
43
+ redBackground: '\u001b[41m',
44
+ greenBackground: '\u001b[42m',
45
+ };
46
+ function supportsColor() {
47
+ return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR);
48
+ }
49
+ function paint(text, code) {
50
+ return supportsColor() ? `${code}${text}${ANSI.reset}` : text;
51
+ }
52
+ function paintStatus(status) {
53
+ if (status === 'Skipped' || status === 'Pruned') {
54
+ return paint(status.padEnd(9), ANSI.bold + ANSI.yellow);
55
+ }
56
+ if (status === 'Failed') {
57
+ return paint(status.padEnd(9), ANSI.bold + ANSI.red);
58
+ }
59
+ if (status === 'Unverified') {
60
+ return paint(status.padEnd(9), ANSI.bold + ANSI.magenta);
61
+ }
62
+ if (status === 'Notice') {
63
+ return paint(status.padEnd(9), ANSI.bold + ANSI.magenta);
64
+ }
65
+ return paint(status.padEnd(9), ANSI.bold + ANSI.green);
66
+ }
67
+ function formatDuration(durationMs) {
68
+ if (durationMs < 1_000) {
69
+ return `${durationMs}ms`;
70
+ }
71
+ const seconds = durationMs / 1_000;
72
+ return seconds < 10 ? `${seconds.toFixed(1)}s` : `${Math.round(seconds)}s`;
73
+ }
74
+ const PLAN_STATUS_MARKS = {
75
+ clean: { symbol: '=', code: ANSI.green },
76
+ create: { symbol: '+', code: ANSI.bold + ANSI.green },
77
+ restore: { symbol: '+', code: ANSI.bold + ANSI.yellow },
78
+ 'restore-blocked': { symbol: '!', code: ANSI.bold + ANSI.red },
79
+ 'manual-create': { symbol: '+', code: ANSI.bold + ANSI.yellow },
80
+ 'manual-owner': { symbol: '-', code: ANSI.bold + ANSI.yellow },
81
+ 'local-changed': { symbol: '~', code: ANSI.bold + ANSI.yellow },
82
+ 'safe-update': { symbol: '~', code: ANSI.bold + ANSI.yellow },
83
+ 'remote-changed': { symbol: '>', code: ANSI.bold + ANSI.magenta },
84
+ conflict: { symbol: '!', code: ANSI.bold + ANSI.red },
85
+ 'validation-failed': { symbol: '!', code: ANSI.bold + ANSI.red },
86
+ 'missing-lock': { symbol: '?', code: ANSI.bold + ANSI.red },
87
+ reconciled: { symbol: '=', code: ANSI.bold + ANSI.cyan },
88
+ 'manual-schema-migration-required': { symbol: '!', code: ANSI.bold + ANSI.red },
89
+ 'access-policy-required': { symbol: '!', code: ANSI.bold + ANSI.yellow },
90
+ 'activation-drift': { symbol: '^', code: ANSI.bold + ANSI.yellow },
91
+ orphan: { symbol: 'o', code: ANSI.dim + ANSI.cyan },
92
+ 'orphan-root': { symbol: 'o', code: ANSI.dim + ANSI.cyan },
93
+ 'orphan-partition': { symbol: 'o', code: ANSI.dim + ANSI.cyan },
94
+ unmanaged: { symbol: '-', code: ANSI.dim + ANSI.yellow },
95
+ collision: { symbol: '!', code: ANSI.bold + ANSI.red },
96
+ skipped: { symbol: '-', code: ANSI.dim + ANSI.yellow },
97
+ delete: { symbol: '-', code: ANSI.bold + ANSI.red },
98
+ 'delete-partition': { symbol: '-', code: ANSI.bold + ANSI.red },
99
+ 'previously-deleted-partition': { symbol: '!', code: ANSI.bold + ANSI.red },
100
+ 'replacement-requires-two-phases': { symbol: '!', code: ANSI.bold + ANSI.yellow },
101
+ };
102
+ function planDetailValue(values) {
103
+ if (values === undefined) {
104
+ return '';
105
+ }
106
+ return typeof values === 'string' ? values : values.join(', ');
107
+ }
108
+ function paintPlanDiffLine(line) {
109
+ if (line.startsWith('-')) {
110
+ return paint(line, ANSI.redBackground + ANSI.white);
111
+ }
112
+ if (line.startsWith('+')) {
113
+ return paint(line, ANSI.greenBackground + ANSI.black);
114
+ }
115
+ if (line.startsWith('@@')) {
116
+ return paint(line, ANSI.cyan);
117
+ }
118
+ return paint(line, ANSI.dim);
119
+ }
120
+ function printPlanSection(println, label, messages) {
121
+ if (messages.length === 0) {
122
+ return;
123
+ }
124
+ println('');
125
+ const code = label === 'Blockers' ? ANSI.bold + ANSI.red : ANSI.bold + ANSI.yellow;
126
+ println(paint(`${label} (${messages.length})`, code));
127
+ for (const message of messages)
128
+ println(` ${paint('!', code)} ${message}`);
129
+ }
130
+ export function printSyncPlan(println, input) {
131
+ println(`${paint(`${input.title} plan`, ANSI.bold)} for ${paint(input.environment, ANSI.bold + ANSI.cyan)}`);
132
+ for (const item of input.items) {
133
+ const mark = PLAN_STATUS_MARKS[item.status] || { symbol: '-', code: ANSI.dim };
134
+ const target = item.target || item.stableKey || item.name || 'unknown';
135
+ println(`${paint(mark.symbol, mark.code)} ${paint(item.status.padEnd(14), mark.code)} ${paint(target, ANSI.cyan)}`);
136
+ const lineDiffFields = new Set((item.details || []).filter((detail) => detail.label === 'rawQuery diff' && detail.lines?.length)
137
+ .map(() => 'rawQuery'));
138
+ const fieldChanges = item.status === 'create'
139
+ ? []
140
+ : (item.fieldChanges || []).filter((change) => !lineDiffFields.has(change.field));
141
+ const describedFields = new Set([
142
+ ...fieldChanges.map((change) => change.field),
143
+ ...(item.details || []).flatMap((detail) => detail.diffs?.map((diff) => diff.field) || []),
144
+ ]);
145
+ const remainingFields = item.changedFields?.filter((field) => !describedFields.has(field) && !lineDiffFields.has(field)) || [];
146
+ const details = [
147
+ ...(remainingFields.length ? [{ label: 'fields', values: remainingFields }] : []),
148
+ ...(fieldChanges.length ? [{
149
+ label: 'changes',
150
+ diffs: fieldChanges.map((change) => ({
151
+ field: change.field,
152
+ before: change.target,
153
+ after: change.workspace,
154
+ })),
155
+ }] : []),
156
+ ...(item.details || []),
157
+ ...(input.showHints === true ? item.hints || [] : []),
158
+ ];
159
+ for (const detail of details) {
160
+ if (detail.label === 'reason') {
161
+ continue;
162
+ }
163
+ if (detail.label === 'hints' && input.showHints !== true) {
164
+ continue;
165
+ }
166
+ if (detail.lines?.length) {
167
+ println(` ${paint(detail.label, ANSI.dim)}`);
168
+ for (const line of detail.lines) {
169
+ println(` ${paintPlanDiffLine(line)}`);
170
+ }
171
+ continue;
172
+ }
173
+ if (detail.diffs?.length) {
174
+ println(` ${paint(detail.label, ANSI.dim)}`);
175
+ for (const diff of detail.diffs) {
176
+ println(` ${paint(`${diff.field}${diff.risk ? ` (${diff.risk})` : ''}`, ANSI.bold)}`);
177
+ println(` ${paintPlanDiffLine(`- ${diff.before}`)}`);
178
+ println(` ${paintPlanDiffLine(`+ ${diff.after}`)}`);
179
+ }
180
+ continue;
181
+ }
182
+ const value = planDetailValue(detail.values);
183
+ if (value) {
184
+ println(` ${paint(detail.label.padEnd(14), ANSI.dim)} ${value}`);
185
+ }
186
+ }
187
+ }
188
+ const summary = Object.entries(input.counts)
189
+ .filter(([, count]) => count > 0)
190
+ .map(([status, count]) => `${count} ${status}`);
191
+ println(`${paint('Summary', ANSI.bold)} ${summary.length > 0 ? summary.join(', ') : 'no resources'}`);
192
+ printPlanSection(println, 'Warnings', input.warnings || []);
193
+ printPlanSection(println, 'Blockers', input.blockers || []);
194
+ }
195
+ const DIFF_KIND_STYLE = {
196
+ create: { symbol: '+', code: ANSI.bold + ANSI.green },
197
+ update: { symbol: '~', code: ANSI.bold + ANSI.yellow },
198
+ 'target-only': { symbol: '-', code: ANSI.dim + ANSI.cyan },
199
+ };
200
+ export function printWorkspaceDiff(println, diff) {
201
+ println(`${paint('Workspace diff', ANSI.bold)} for ${paint(diff.to, ANSI.bold + ANSI.cyan)}`);
202
+ if (diff.changes.length === 0) {
203
+ println(paint('No differences.', ANSI.green));
204
+ return;
205
+ }
206
+ for (const change of diff.changes) {
207
+ const style = DIFF_KIND_STYLE[change.kind];
208
+ println(`${paint(style.symbol, style.code)} ${paint(change.resource, style.code)} ${paint(change.identity, ANSI.cyan)} ${paint(`(${change.kind})`, style.code)}`);
209
+ if (change.resource === 'component' && change.kind === 'create') {
210
+ continue;
211
+ }
212
+ const describedFields = new Set(change.fieldChanges?.map((field) => field.field) || []);
213
+ const remainingFields = (change.fields || []).filter((field) => !describedFields.has(field) && field !== 'elements');
214
+ if (remainingFields.length > 0) {
215
+ println(` ${paint('changed fields:', ANSI.dim)} ${remainingFields.join(', ')}`);
216
+ }
217
+ for (const field of change.fieldChanges || []) {
218
+ println(` ${paint(`${field.field}:`, ANSI.bold)}`);
219
+ println(` ${paintPlanDiffLine(`- ${field.target}`)}`);
220
+ println(` ${paintPlanDiffLine(`+ ${field.workspace}`)}`);
221
+ }
222
+ for (const code of change.codeDiffs || []) {
223
+ const label = code.element === 'rawQuery' ? 'rawQuery diff:' : `element ${code.element}:`;
224
+ println(` ${paint(label, ANSI.bold)}`);
225
+ for (const line of code.lines) {
226
+ println(` ${paintPlanDiffLine(line)}`);
227
+ }
228
+ }
229
+ for (const role of change.rolesToRemove || []) {
230
+ println(` ${paintPlanDiffLine(`- role ${role}`)}`);
231
+ }
232
+ for (const role of change.rolesToAdd || []) {
233
+ println(` ${paintPlanDiffLine(`+ role ${role}`)}`);
234
+ }
235
+ if (change.kind === 'update' && !change.fieldChanges?.length && !change.codeDiffs?.length
236
+ && !change.rolesToAdd?.length && !change.rolesToRemove?.length && remainingFields.length === 0) {
237
+ println(` ${paint('target hash:', ANSI.dim)} ${(change.targetHash || '').slice(0, 12)}`);
238
+ println(` ${paint('workspace hash:', ANSI.dim)} ${(change.workspaceHash || '').slice(0, 12)}`);
239
+ }
240
+ }
241
+ }
242
+ export function printSyncStatus(println, input) {
243
+ const engine = paint('RevoEngine', ANSI.bold + ANSI.blue);
244
+ const arrow = paint(input.direction === 'pull' ? '->' : '<-', ANSI.bold + ANSI.magenta);
245
+ const targetPath = paint(input.targetPath, ANSI.cyan);
246
+ const reason = input.reason ? ` ${paint(`(${input.reason})`, ANSI.dim + ANSI.yellow)}` : '';
247
+ println(`${paintStatus(input.status)} ${engine} ${arrow} ${targetPath}${reason}`);
248
+ }
249
+ export function printSyncNotice(println, message) {
250
+ println(`${paintStatus('Notice')} ${message}`);
251
+ }
252
+ export function printSyncSummary(println, label, results, durationMs) {
253
+ const total = results.length;
254
+ const primaryStatus = label === 'Activated' ? 'deployed' : label.toLowerCase();
255
+ const primary = results.filter((result) => result.status === primaryStatus).length;
256
+ const skipped = results.filter((result) => result.status === 'skipped').length;
257
+ const pruned = results.filter((result) => result.status === 'pruned').length;
258
+ const failed = results.filter((result) => result.status === 'failed').length;
259
+ const unverified = results.filter((result) => result.status === 'write-unverified').length;
260
+ const details = [
261
+ `${label} ${primary}/${total}`,
262
+ ...(pruned > 0 ? [`Pruned ${pruned}/${total}`] : []),
263
+ ...(skipped > 0 ? [`Skipped ${skipped}/${total}`] : []),
264
+ ...(failed > 0 ? [`Failed ${failed}/${total}`] : []),
265
+ ...(unverified > 0 ? [`Unverified ${unverified}/${total}`] : []),
266
+ ];
267
+ println(`${details.join(', ')} in ${formatDuration(durationMs)}`);
268
+ }
@@ -1,5 +1,5 @@
1
1
  export declare const TRACK_ALL_RESOURCES = "all";
2
- export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component"];
2
+ export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component", "endpoint", "group", "role-group", "job-template", "schedule", "event", "database-table", "database-view"];
3
3
  export type TrackableResourceType = typeof TRACKABLE_RESOURCE_TYPES[number];
4
4
  export type TrackedResource = typeof TRACK_ALL_RESOURCES | TrackableResourceType;
5
5
  export declare function normalizeTrackedResources(value: string | string[] | null | undefined): TrackedResource[];
@@ -1,10 +1,36 @@
1
1
  export const TRACK_ALL_RESOURCES = 'all';
2
- export const TRACKABLE_RESOURCE_TYPES = ['component'];
2
+ export const TRACKABLE_RESOURCE_TYPES = ['component', 'endpoint', 'group', 'role-group', 'job-template', 'schedule', 'event', 'database-table', 'database-view'];
3
3
  const RESOURCE_ALIASES = {
4
4
  all: TRACK_ALL_RESOURCES,
5
5
  '*': TRACK_ALL_RESOURCES,
6
6
  component: 'component',
7
7
  components: 'component',
8
+ endpoint: 'endpoint',
9
+ endpoints: 'endpoint',
10
+ group: 'group',
11
+ groups: 'group',
12
+ 'role-group': 'role-group',
13
+ 'role-groups': 'role-group',
14
+ rolegroup: 'role-group',
15
+ rolegroups: 'role-group',
16
+ 'job-template': 'job-template',
17
+ 'job-templates': 'job-template',
18
+ jobtemplate: 'job-template',
19
+ jobtemplates: 'job-template',
20
+ schedule: 'schedule',
21
+ schedules: 'schedule',
22
+ event: 'event',
23
+ events: 'event',
24
+ 'database-table': 'database-table',
25
+ 'database-tables': 'database-table',
26
+ 'database-schema': 'database-table',
27
+ 'database-schemas': 'database-table',
28
+ database: 'database-table',
29
+ databases: 'database-table',
30
+ 'database-view': 'database-view',
31
+ 'database-views': 'database-view',
32
+ databaseview: 'database-view',
33
+ databaseviews: 'database-view',
8
34
  };
9
35
  export function normalizeTrackedResources(value) {
10
36
  const rawValues = Array.isArray(value) ? value : value ? [value] : [TRACK_ALL_RESOURCES];
@@ -17,7 +43,7 @@ export function normalizeTrackedResources(value) {
17
43
  }
18
44
  const resource = RESOURCE_ALIASES[key];
19
45
  if (!resource) {
20
- throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component.`);
46
+ throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component, endpoint, group, role-group, job-template, schedule, event, database-table, database-view.`);
21
47
  }
22
48
  if (!normalized.includes(resource)) {
23
49
  normalized.push(resource);