@revoengine/cli 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -12
- package/dist/src/cli.js +6 -2
- package/dist/src/client.d.ts +29 -3
- package/dist/src/client.js +92 -2
- package/dist/src/commands/component.js +2 -4
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +83 -20
- package/dist/src/commands/service-accounts.d.ts +2 -0
- package/dist/src/commands/service-accounts.js +149 -0
- package/dist/src/commands/terminal-browser.d.ts +29 -2
- package/dist/src/commands/terminal-browser.js +144 -35
- package/dist/src/commands/terminal-file.d.ts +21 -0
- package/dist/src/commands/terminal-file.js +160 -0
- package/dist/src/commands/terminal-operational-log.js +2 -2
- package/dist/src/commands/terminal-policy.d.ts +5 -2
- package/dist/src/commands/terminal-policy.js +10 -4
- package/dist/src/commands/terminal-reconnect-grace.js +1 -1
- package/dist/src/commands/terminal-sandbox.js +7 -0
- package/dist/src/commands/terminal-secure-browser.d.ts +1 -0
- package/dist/src/commands/terminal-secure-browser.js +2 -1
- package/dist/src/commands/terminal-service.js +4 -4
- package/dist/src/commands/terminal.d.ts +12 -0
- package/dist/src/commands/terminal.js +134 -45
- package/dist/src/component-lock.d.ts +4 -0
- package/dist/src/component-lock.js +21 -2
- package/dist/src/metadata-backfill.js +50 -1
- package/dist/src/migration.d.ts +20 -5
- package/dist/src/migration.js +200 -75
- package/dist/src/resource-inventory.d.ts +3 -2
- package/dist/src/resource-inventory.js +6 -1
- package/dist/src/resource-syncs/account-principal.d.ts +22 -0
- package/dist/src/resource-syncs/account-principal.js +86 -0
- package/dist/src/resource-syncs/group-sync.d.ts +10 -0
- package/dist/src/resource-syncs/group-sync.js +92 -20
- package/dist/src/resource-syncs/identity-migration.d.ts +19 -0
- package/dist/src/resource-syncs/identity-migration.js +108 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +4 -0
- package/dist/src/resource-syncs/job-template-sync.js +55 -12
- package/dist/src/resource-syncs/service-account-sync.d.ts +98 -0
- package/dist/src/resource-syncs/service-account-sync.js +620 -0
- package/dist/src/sync-output.js +10 -5
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +5 -1
- package/dist/src/types.d.ts +12 -0
- package/dist/src/ui.js +6 -3
- package/dist/src/workspace-diff.d.ts +1 -0
- package/dist/src/workspace-diff.js +4 -1
- package/dist/src/workspace-prune.d.ts +40 -0
- package/dist/src/workspace-prune.js +363 -0
- package/package.json +2 -2
|
@@ -155,6 +155,7 @@ export function readComponentLock(projectRoot) {
|
|
|
155
155
|
components: {},
|
|
156
156
|
groups: {},
|
|
157
157
|
roleGroups: {},
|
|
158
|
+
serviceAccounts: {},
|
|
158
159
|
jobTemplates: {},
|
|
159
160
|
schedules: {},
|
|
160
161
|
events: {},
|
|
@@ -212,8 +213,8 @@ export function readComponentLock(projectRoot) {
|
|
|
212
213
|
stableKey: String(entry.stableKey),
|
|
213
214
|
path: String(entry.path),
|
|
214
215
|
sourceHash: String(entry.sourceHash),
|
|
215
|
-
...((isRecord(entry.owner) && entry.owner.type === 'group' && typeof entry.owner.stableKey === 'string')
|
|
216
|
-
? { owner: { type:
|
|
216
|
+
...((isRecord(entry.owner) && (entry.owner.type === 'group' || entry.owner.type === 'service-account') && typeof entry.owner.stableKey === 'string')
|
|
217
|
+
? { owner: { type: entry.owner.type, stableKey: entry.owner.stableKey } }
|
|
217
218
|
: (isRecord(entry.owner) && entry.owner.type === 'manual-user')
|
|
218
219
|
? { owner: { type: 'manual-user' } }
|
|
219
220
|
: (isRecord(entry.owner) && entry.owner.type === 'unresolved' && typeof entry.owner.reason === 'string')
|
|
@@ -226,6 +227,23 @@ export function readComponentLock(projectRoot) {
|
|
|
226
227
|
syncedAt: String(baseline.syncedAt),
|
|
227
228
|
}])),
|
|
228
229
|
}])),
|
|
230
|
+
serviceAccounts: Object.fromEntries(Object.entries(raw.serviceAccounts && typeof raw.serviceAccounts === 'object' ? raw.serviceAccounts : {})
|
|
231
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
232
|
+
&& typeof entry.path === 'string'
|
|
233
|
+
&& typeof entry.sourceHash === 'string'
|
|
234
|
+
&& entry.environments
|
|
235
|
+
&& typeof entry.environments === 'object'))
|
|
236
|
+
.map(([key, entry]) => [key, {
|
|
237
|
+
stableKey: String(entry.stableKey),
|
|
238
|
+
path: String(entry.path),
|
|
239
|
+
sourceHash: String(entry.sourceHash),
|
|
240
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
241
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
242
|
+
.map(([envName, baseline]) => [envName, {
|
|
243
|
+
remoteHash: String(baseline.remoteHash),
|
|
244
|
+
syncedAt: String(baseline.syncedAt),
|
|
245
|
+
}])),
|
|
246
|
+
}])),
|
|
229
247
|
roleGroups: Object.fromEntries(Object.entries(raw.roleGroups && typeof raw.roleGroups === 'object' ? raw.roleGroups : {})
|
|
230
248
|
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
231
249
|
&& typeof entry.path === 'string'
|
|
@@ -379,6 +397,7 @@ export function writeComponentLock(projectRoot, lock) {
|
|
|
379
397
|
components: sortedComponents,
|
|
380
398
|
...(Object.keys(sortedGroups).length > 0 ? { groups: sortedGroups } : {}),
|
|
381
399
|
roleGroups: sortedRoleGroups,
|
|
400
|
+
...(Object.keys(lock.serviceAccounts || {}).length ? { serviceAccounts: lock.serviceAccounts } : {}),
|
|
382
401
|
jobTemplates: sortedJobTemplates,
|
|
383
402
|
...(Object.keys(sortedSchedules).length > 0 ? { schedules: sortedSchedules } : {}),
|
|
384
403
|
...(Object.keys(sortedEvents).length > 0 ? { events: sortedEvents } : {}),
|
|
@@ -485,6 +485,32 @@ export async function buildMetadataBackfillPlan(input) {
|
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
+
if (shouldTrackResource(trackedResources, 'service-account') && typeof client.listAllServiceAccounts === 'function') {
|
|
489
|
+
for await (const { listedId, resource: account } of readResourceInventory(client, 'service-account')) {
|
|
490
|
+
if (!listedId) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const resourceId = resourceIdOf(account) || listedId;
|
|
494
|
+
const existingStableKey = readConfiguredResourceMetadataStableKey(account, stableKeyName);
|
|
495
|
+
const stableKey = existingStableKey && !force
|
|
496
|
+
? undefined
|
|
497
|
+
: buildNamedResourceGeneratedStableKey(account);
|
|
498
|
+
const plannedStableKey = stableKey || existingStableKey || undefined;
|
|
499
|
+
items.push({
|
|
500
|
+
resourceType: 'service-account',
|
|
501
|
+
resourceId,
|
|
502
|
+
name: String(account.name || ''),
|
|
503
|
+
category: null,
|
|
504
|
+
action: rawConfiguredStableKey(account, stableKeyName).present && !existingStableKey ? 'blocked' : existingStableKey && !force ? 'skip' : 'update',
|
|
505
|
+
metadataField: 'metadata',
|
|
506
|
+
stableKeyName,
|
|
507
|
+
...(plannedStableKey ? { stableKey: plannedStableKey } : {}),
|
|
508
|
+
reason: existingStableKey
|
|
509
|
+
? (force ? 'stable key will be regenerated' : 'stable key already exists')
|
|
510
|
+
: 'stable key missing',
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
488
514
|
if (shouldTrackResource(trackedResources, 'role-group') && typeof client.listAllRoleGroups === 'function') {
|
|
489
515
|
for await (const { listedId, resource: roleGroup } of readResourceInventory(client, 'role-group')) {
|
|
490
516
|
if (!listedId) {
|
|
@@ -714,7 +740,7 @@ export async function applyMetadataBackfillPlan(input) {
|
|
|
714
740
|
const resourceTypes = new Set(plan.items.map((item) => item.resourceType));
|
|
715
741
|
const readOrder = [
|
|
716
742
|
'component', 'database-table', 'database-view', 'endpoint',
|
|
717
|
-
'role-group', 'group', 'job-template', 'schedule', 'event',
|
|
743
|
+
'role-group', 'service-account', 'group', 'job-template', 'schedule', 'event',
|
|
718
744
|
];
|
|
719
745
|
for (const resourceType of readOrder) {
|
|
720
746
|
if (!resourceTypes.has(resourceType)) {
|
|
@@ -954,6 +980,29 @@ export async function applyMetadataBackfillPlan(input) {
|
|
|
954
980
|
results.push({ resourceType: item.resourceType, resourceId: item.resourceId, stableKey, action: 'update' });
|
|
955
981
|
continue;
|
|
956
982
|
}
|
|
983
|
+
if (item.resourceType === 'service-account') {
|
|
984
|
+
const account = await client.getServiceAccount(item.resourceId);
|
|
985
|
+
const current = readConfiguredResourceMetadataStableKey(account, plan.stableKeyName);
|
|
986
|
+
if (current && !plan.force) {
|
|
987
|
+
results.push({ resourceType: item.resourceType, resourceId: item.resourceId, stableKey: current, action: 'skip' });
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
if (!current && rawConfiguredStableKey(account, plan.stableKeyName).present) {
|
|
991
|
+
throw new Error('Invalid service-account stableKey; refusing to overwrite it.');
|
|
992
|
+
}
|
|
993
|
+
const stableKey = item.stableKey || buildNamedResourceGeneratedStableKey(account);
|
|
994
|
+
if (!Number.isInteger(account.version)) {
|
|
995
|
+
throw new Error('Service-account version is required.');
|
|
996
|
+
}
|
|
997
|
+
await client.updateServiceAccount(item.resourceId, { version: account.version,
|
|
998
|
+
metadata: { ...sanitizeUserMetadata(account.metadata), [plan.stableKeyName]: stableKey } });
|
|
999
|
+
const verified = await client.getServiceAccount(item.resourceId);
|
|
1000
|
+
if (readConfiguredResourceMetadataStableKey(verified, plan.stableKeyName) !== stableKey) {
|
|
1001
|
+
throw new Error('Updated service account did not retain the planned stableKey.');
|
|
1002
|
+
}
|
|
1003
|
+
results.push({ resourceType: item.resourceType, resourceId: item.resourceId, stableKey, action: 'update' });
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
957
1006
|
if (item.resourceType === 'role-group') {
|
|
958
1007
|
const roleGroup = currentResources.get(`role-group:${item.resourceId}`);
|
|
959
1008
|
if (!roleGroup)
|
package/dist/src/migration.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type WorkspacePrunePlan } from './workspace-prune.ts';
|
|
2
|
+
import { type ServiceAccountsPlan, type ServiceAccountPullResult, type ServiceAccountPushResult } from './resource-syncs/service-account-sync.ts';
|
|
1
3
|
import { RevoClient } from './client.ts';
|
|
2
4
|
import { type ComponentPlan, type ComponentSyncResult } from './commands/component.ts';
|
|
3
5
|
import { type DatabaseSchemaMigrationPolicy, type DatabaseSchemaPullResult, type DatabaseSchemaPushResult, type DatabaseSchemasPlan } from './resource-syncs/database-table-sync.ts';
|
|
@@ -8,10 +10,12 @@ import { type GroupPullResult, type GroupPushResult, type GroupsPlan } from './r
|
|
|
8
10
|
import { type JobTemplatePullResult, type JobTemplatePushResult, type JobTemplatesPlan } from './resource-syncs/job-template-sync.ts';
|
|
9
11
|
import { type SchedulePullResult, type SchedulePushResult, type SchedulesPlan } from './resource-syncs/schedule-sync.ts';
|
|
10
12
|
import { type RoleGroupPullResult, type RoleGroupPushResult, type RoleGroupsPlan } from './resource-syncs/role-group-sync.ts';
|
|
11
|
-
export type MigrationResource = 'database-table' | 'database-view' | 'component' | 'job-template' | 'endpoint' | 'schedule' | 'event' | 'group' | 'role-group';
|
|
13
|
+
export type MigrationResource = 'database-table' | 'database-view' | 'component' | 'job-template' | 'endpoint' | 'schedule' | 'event' | 'group' | 'role-group' | 'service-account';
|
|
12
14
|
export type MigrationVerdict = 'ready' | 'ready-with-warnings' | 'blocked';
|
|
13
|
-
export type MigrationOperations = Record<'noop' | 'create' | 'update' | 'adopt' | 'excluded' | 'blocked', number
|
|
14
|
-
|
|
15
|
+
export type MigrationOperations = Record<'noop' | 'create' | 'update' | 'adopt' | 'excluded' | 'blocked', number> & {
|
|
16
|
+
delete?: number;
|
|
17
|
+
};
|
|
18
|
+
type MigrationPushResult = DatabaseSchemaPushResult | DatabaseViewPushResult | ComponentSyncResult | JobTemplatePushResult | EndpointPushResult | SchedulePushResult | EventPushResult | GroupPushResult | RoleGroupPushResult | ServiceAccountPushResult;
|
|
15
19
|
export type MigrationPhasePlan = {
|
|
16
20
|
order: number;
|
|
17
21
|
resource: MigrationResource;
|
|
@@ -39,8 +43,10 @@ export type MigrationPlan = {
|
|
|
39
43
|
from: string;
|
|
40
44
|
to: string;
|
|
41
45
|
resources: MigrationResource[];
|
|
46
|
+
prune?: WorkspacePrunePlan;
|
|
47
|
+
pruneTargetKey?: string;
|
|
42
48
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
43
|
-
mode: 'upsert';
|
|
49
|
+
mode: 'upsert' | 'reconcile';
|
|
44
50
|
};
|
|
45
51
|
needsChanges: boolean;
|
|
46
52
|
readyToMigrate: boolean;
|
|
@@ -48,6 +54,10 @@ export type MigrationPlan = {
|
|
|
48
54
|
operations: MigrationOperations;
|
|
49
55
|
sourcePull: MigrationSourcePullSummary;
|
|
50
56
|
phases: MigrationPhasePlan[];
|
|
57
|
+
identityOrder?: Array<{
|
|
58
|
+
resource: 'group' | 'service-account';
|
|
59
|
+
stableKey: string;
|
|
60
|
+
}>;
|
|
51
61
|
databaseSchemas?: DatabaseSchemasPlan;
|
|
52
62
|
databaseViews?: DatabaseViewsPlan;
|
|
53
63
|
components?: ComponentPlan;
|
|
@@ -57,6 +67,7 @@ export type MigrationPlan = {
|
|
|
57
67
|
events?: EventsPlan;
|
|
58
68
|
groups?: GroupsPlan;
|
|
59
69
|
roleGroups?: RoleGroupsPlan;
|
|
70
|
+
serviceAccounts?: ServiceAccountsPlan;
|
|
60
71
|
warnings: string[];
|
|
61
72
|
blockers: string[];
|
|
62
73
|
};
|
|
@@ -67,7 +78,7 @@ export type MigrationRun = {
|
|
|
67
78
|
to: string;
|
|
68
79
|
resources: MigrationResource[];
|
|
69
80
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
70
|
-
mode: 'upsert';
|
|
81
|
+
mode: 'upsert' | 'reconcile';
|
|
71
82
|
};
|
|
72
83
|
verdict: 'succeeded' | 'blocked' | 'failed';
|
|
73
84
|
sourcePull: {
|
|
@@ -80,6 +91,7 @@ export type MigrationRun = {
|
|
|
80
91
|
events?: EventPullResult;
|
|
81
92
|
groups?: GroupPullResult;
|
|
82
93
|
roleGroups?: RoleGroupPullResult;
|
|
94
|
+
serviceAccounts?: ServiceAccountPullResult;
|
|
83
95
|
};
|
|
84
96
|
plan: MigrationPlan;
|
|
85
97
|
results: MigrationPushResult[];
|
|
@@ -94,6 +106,8 @@ type MigrationInputBase = {
|
|
|
94
106
|
withStats?: boolean;
|
|
95
107
|
allowDestructive?: boolean;
|
|
96
108
|
detailedDiff?: boolean;
|
|
109
|
+
prune?: boolean;
|
|
110
|
+
reviewedPrune?: WorkspacePrunePlan;
|
|
97
111
|
};
|
|
98
112
|
export type MigrationInput = MigrationInputBase & ({
|
|
99
113
|
sourceMode: 'workspace';
|
|
@@ -116,6 +130,7 @@ export type ResourcePullResults = {
|
|
|
116
130
|
events?: EventPullResult;
|
|
117
131
|
groups?: GroupPullResult;
|
|
118
132
|
roleGroups?: RoleGroupPullResult;
|
|
133
|
+
serviceAccounts?: ServiceAccountPullResult;
|
|
119
134
|
};
|
|
120
135
|
export type ResourcePullInput = {
|
|
121
136
|
cwd: string;
|