@revoengine/cli 1.0.15 → 1.0.16
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 +45 -9
- package/dist/src/cli.js +5 -1
- package/dist/src/client.d.ts +25 -3
- package/dist/src/client.js +67 -2
- package/dist/src/commands/component.js +1 -0
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +12 -2
- 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 +10 -2
- package/dist/src/migration.js +159 -68
- 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 +3 -0
- 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 +4 -1
- package/dist/src/workspace-diff.d.ts +1 -0
- package/dist/src/workspace-diff.js +4 -1
- 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,4 @@
|
|
|
1
|
+
import { type ServiceAccountsPlan, type ServiceAccountPullResult, type ServiceAccountPushResult } from './resource-syncs/service-account-sync.ts';
|
|
1
2
|
import { RevoClient } from './client.ts';
|
|
2
3
|
import { type ComponentPlan, type ComponentSyncResult } from './commands/component.ts';
|
|
3
4
|
import { type DatabaseSchemaMigrationPolicy, type DatabaseSchemaPullResult, type DatabaseSchemaPushResult, type DatabaseSchemasPlan } from './resource-syncs/database-table-sync.ts';
|
|
@@ -8,10 +9,10 @@ import { type GroupPullResult, type GroupPushResult, type GroupsPlan } from './r
|
|
|
8
9
|
import { type JobTemplatePullResult, type JobTemplatePushResult, type JobTemplatesPlan } from './resource-syncs/job-template-sync.ts';
|
|
9
10
|
import { type SchedulePullResult, type SchedulePushResult, type SchedulesPlan } from './resource-syncs/schedule-sync.ts';
|
|
10
11
|
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';
|
|
12
|
+
export type MigrationResource = 'database-table' | 'database-view' | 'component' | 'job-template' | 'endpoint' | 'schedule' | 'event' | 'group' | 'role-group' | 'service-account';
|
|
12
13
|
export type MigrationVerdict = 'ready' | 'ready-with-warnings' | 'blocked';
|
|
13
14
|
export type MigrationOperations = Record<'noop' | 'create' | 'update' | 'adopt' | 'excluded' | 'blocked', number>;
|
|
14
|
-
type MigrationPushResult = DatabaseSchemaPushResult | DatabaseViewPushResult | ComponentSyncResult | JobTemplatePushResult | EndpointPushResult | SchedulePushResult | EventPushResult | GroupPushResult | RoleGroupPushResult;
|
|
15
|
+
type MigrationPushResult = DatabaseSchemaPushResult | DatabaseViewPushResult | ComponentSyncResult | JobTemplatePushResult | EndpointPushResult | SchedulePushResult | EventPushResult | GroupPushResult | RoleGroupPushResult | ServiceAccountPushResult;
|
|
15
16
|
export type MigrationPhasePlan = {
|
|
16
17
|
order: number;
|
|
17
18
|
resource: MigrationResource;
|
|
@@ -48,6 +49,10 @@ export type MigrationPlan = {
|
|
|
48
49
|
operations: MigrationOperations;
|
|
49
50
|
sourcePull: MigrationSourcePullSummary;
|
|
50
51
|
phases: MigrationPhasePlan[];
|
|
52
|
+
identityOrder?: Array<{
|
|
53
|
+
resource: 'group' | 'service-account';
|
|
54
|
+
stableKey: string;
|
|
55
|
+
}>;
|
|
51
56
|
databaseSchemas?: DatabaseSchemasPlan;
|
|
52
57
|
databaseViews?: DatabaseViewsPlan;
|
|
53
58
|
components?: ComponentPlan;
|
|
@@ -57,6 +62,7 @@ export type MigrationPlan = {
|
|
|
57
62
|
events?: EventsPlan;
|
|
58
63
|
groups?: GroupsPlan;
|
|
59
64
|
roleGroups?: RoleGroupsPlan;
|
|
65
|
+
serviceAccounts?: ServiceAccountsPlan;
|
|
60
66
|
warnings: string[];
|
|
61
67
|
blockers: string[];
|
|
62
68
|
};
|
|
@@ -80,6 +86,7 @@ export type MigrationRun = {
|
|
|
80
86
|
events?: EventPullResult;
|
|
81
87
|
groups?: GroupPullResult;
|
|
82
88
|
roleGroups?: RoleGroupPullResult;
|
|
89
|
+
serviceAccounts?: ServiceAccountPullResult;
|
|
83
90
|
};
|
|
84
91
|
plan: MigrationPlan;
|
|
85
92
|
results: MigrationPushResult[];
|
|
@@ -116,6 +123,7 @@ export type ResourcePullResults = {
|
|
|
116
123
|
events?: EventPullResult;
|
|
117
124
|
groups?: GroupPullResult;
|
|
118
125
|
roleGroups?: RoleGroupPullResult;
|
|
126
|
+
serviceAccounts?: ServiceAccountPullResult;
|
|
119
127
|
};
|
|
120
128
|
export type ResourcePullInput = {
|
|
121
129
|
cwd: string;
|
package/dist/src/migration.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import { planIdentityMigration } from "./resource-syncs/identity-migration.js";
|
|
3
|
+
import { SERVICE_ACCOUNTS_DIRECTORY, buildServiceAccountsPlan, pullServiceAccountsToWorkspace, pushServiceAccounts } from "./resource-syncs/service-account-sync.js";
|
|
2
4
|
import os from 'node:os';
|
|
3
5
|
import path from 'node:path';
|
|
4
6
|
import { RevoClient } from "./client.js";
|
|
@@ -19,6 +21,7 @@ const RESOURCE_ORDER = [
|
|
|
19
21
|
'database-table',
|
|
20
22
|
'database-view',
|
|
21
23
|
'component',
|
|
24
|
+
'service-account',
|
|
22
25
|
'job-template',
|
|
23
26
|
'endpoint',
|
|
24
27
|
'schedule',
|
|
@@ -486,6 +489,24 @@ function summarizeGroupPhase(plan) {
|
|
|
486
489
|
blockers,
|
|
487
490
|
};
|
|
488
491
|
}
|
|
492
|
+
function serviceAccountItemAction(item) {
|
|
493
|
+
if (item.status === 'manual-owner') {
|
|
494
|
+
return 'excluded';
|
|
495
|
+
}
|
|
496
|
+
return roleGroupItemAction({ ...item, status: item.status });
|
|
497
|
+
}
|
|
498
|
+
function summarizeServiceAccountPhase(plan) {
|
|
499
|
+
const operations = emptyOperations();
|
|
500
|
+
for (const item of plan.items) {
|
|
501
|
+
operations[serviceAccountItemAction(item)] += 1;
|
|
502
|
+
}
|
|
503
|
+
const warnings = [...plan.exclusions,
|
|
504
|
+
...plan.items.filter((item) => item.status === 'manual-owner').map((item) => `Service account "${item.stableKey}": ${item.reason}.`),
|
|
505
|
+
...plan.items.filter((item) => item.status === 'create').map((item) => `Service account "${item.stableKey}" will be created active with platform access; configure secrets separately on ${plan.env}.`),
|
|
506
|
+
];
|
|
507
|
+
return { order: 4, resource: 'service-account', operations, warnings, blockers: plan.blockers,
|
|
508
|
+
needsChanges: operations.create + operations.update > 0, readyToMigrate: plan.blockers.length === 0, verdict: phaseVerdict(plan.blockers, warnings) };
|
|
509
|
+
}
|
|
489
510
|
function summarizeRoleGroupPhase(plan) {
|
|
490
511
|
const operations = emptyOperations();
|
|
491
512
|
for (const item of plan.items) {
|
|
@@ -573,6 +594,9 @@ function summarizePulls(mode, pulls) {
|
|
|
573
594
|
skipped: pulls.groups.skipped.length,
|
|
574
595
|
};
|
|
575
596
|
}
|
|
597
|
+
if (pulls.serviceAccounts) {
|
|
598
|
+
byResource['service-account'] = { pulled: pulls.serviceAccounts.pulled.length, pruned: pulls.serviceAccounts.pruned.length, skipped: pulls.serviceAccounts.skipped.length };
|
|
599
|
+
}
|
|
576
600
|
if (pulls.roleGroups) {
|
|
577
601
|
byResource['role-group'] = {
|
|
578
602
|
pulled: pulls.roleGroups.pulled.length,
|
|
@@ -628,6 +652,17 @@ function applyWorkspaceDeploymentPolicy(input, phase, plans) {
|
|
|
628
652
|
}
|
|
629
653
|
}
|
|
630
654
|
}
|
|
655
|
+
if (phase.resource === 'service-account' && plans.serviceAccounts) {
|
|
656
|
+
for (const item of plans.serviceAccounts.items) {
|
|
657
|
+
const action = serviceAccountItemAction(item);
|
|
658
|
+
if (action === 'create' || action === 'update') {
|
|
659
|
+
gates.push({
|
|
660
|
+
from: action,
|
|
661
|
+
message: `Service Account "${item.stableKey || item.name}" can change environment access and requires --force for repository deployment.`,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
631
666
|
if (phase.resource === 'role-group' && plans.roleGroups) {
|
|
632
667
|
for (const item of plans.roleGroups.items) {
|
|
633
668
|
const action = roleGroupItemAction(item);
|
|
@@ -673,82 +708,87 @@ function combinePlan(input) {
|
|
|
673
708
|
...(input.databaseSchemas ? [summarizeSchemaPhase(input.databaseSchemas)] : []),
|
|
674
709
|
...(input.databaseViews ? [summarizeViewPhase(input.databaseViews)] : []),
|
|
675
710
|
...(input.components ? [summarizeComponentPhase(input.components)] : []),
|
|
711
|
+
...(input.serviceAccounts ? [summarizeServiceAccountPhase(input.serviceAccounts)] : []),
|
|
676
712
|
...(input.jobTemplates ? [summarizeJobTemplatePhase(input.jobTemplates)] : []),
|
|
677
713
|
...(input.endpoints ? [summarizeEndpointPhase(input.endpoints)] : []),
|
|
678
714
|
...(input.schedules ? [summarizeSchedulePhase(input.schedules)] : []),
|
|
679
715
|
...(input.events ? [summarizeEventPhase(input.events)] : []),
|
|
680
716
|
...(input.groups ? [summarizeGroupPhase(input.groups)] : []),
|
|
681
717
|
...(input.roleGroups ? [summarizeRoleGroupPhase(input.roleGroups)] : []),
|
|
682
|
-
].map((phase) => applyWorkspaceDeploymentPolicy(input.migrationInput, phase, input))
|
|
718
|
+
].map((phase) => ({ ...phase, order: RESOURCE_ORDER.indexOf(phase.resource) + 1 })).map((phase) => applyWorkspaceDeploymentPolicy(input.migrationInput, phase, input))
|
|
683
719
|
.map((phase) => {
|
|
684
|
-
const pullWarnings = phase.resource === '
|
|
685
|
-
? (input.pulls.
|
|
686
|
-
: phase.resource === 'database-
|
|
687
|
-
? (input.pulls.
|
|
688
|
-
: phase.resource === '
|
|
689
|
-
? (input.pulls.
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
.map((item) => `Source Schedule "${item.stableKey}": ${item.reason}.`),
|
|
706
|
-
...(input.pulls.schedules?.pulled || [])
|
|
707
|
-
.filter(({ manifest }) => manifest.activationCandidate === true)
|
|
708
|
-
.map(({ manifest }) => `Source Schedule "${manifest.stableKey}" is an activation candidate; migration syncs its portable definition but does not automatically change target activation state.`),
|
|
709
|
-
]
|
|
710
|
-
: phase.resource === 'event'
|
|
720
|
+
const pullWarnings = phase.resource === 'service-account'
|
|
721
|
+
? (input.pulls.serviceAccounts?.skipped || []).map((item) => `Source Service Account "${item.name}" skipped: ${item.reason}.`)
|
|
722
|
+
: phase.resource === 'database-table'
|
|
723
|
+
? (input.pulls.databaseSchemas?.skipped || []).map((item) => `Source Database Table skipped: ${item.targetPath}: ${item.reason}.`)
|
|
724
|
+
: phase.resource === 'database-view'
|
|
725
|
+
? (input.pulls.databaseViews?.skipped || []).map((item) => `Source Database View "${item.stableKey || item.name}" skipped: ${item.reason}.`)
|
|
726
|
+
: phase.resource === 'component'
|
|
727
|
+
? (input.pulls.components || [])
|
|
728
|
+
.filter((item) => item.status === 'skipped' && item.reason !== 'no changes')
|
|
729
|
+
.map((item) => `Source Component skipped: ${item.targetPath}: ${item.reason || 'unknown reason'}.`)
|
|
730
|
+
: phase.resource === 'job-template'
|
|
731
|
+
? [
|
|
732
|
+
...(input.pulls.jobTemplates?.skipped || [])
|
|
733
|
+
.map((item) => `Source Job Template "${item.name}" skipped: ${item.reason}.`),
|
|
734
|
+
...(input.pulls.jobTemplates?.warnings || [])
|
|
735
|
+
.map((item) => `Source Job Template "${item.stableKey}": ${item.reason}.`),
|
|
736
|
+
]
|
|
737
|
+
: phase.resource === 'endpoint'
|
|
738
|
+
? (input.pulls.endpoints?.skipped || [])
|
|
739
|
+
.map((item) => `Source Endpoint skipped: ${item.targetPath}: ${item.reason}.`)
|
|
740
|
+
: phase.resource === 'schedule'
|
|
711
741
|
? [
|
|
712
|
-
...(input.pulls.
|
|
713
|
-
.map((item) => `Source
|
|
714
|
-
...(input.pulls.
|
|
715
|
-
.filter(({ manifest }) => manifest.
|
|
716
|
-
.map(({ manifest }) => `Source
|
|
742
|
+
...(input.pulls.schedules?.warnings || [])
|
|
743
|
+
.map((item) => `Source Schedule "${item.stableKey}": ${item.reason}.`),
|
|
744
|
+
...(input.pulls.schedules?.pulled || [])
|
|
745
|
+
.filter(({ manifest }) => manifest.activationCandidate === true)
|
|
746
|
+
.map(({ manifest }) => `Source Schedule "${manifest.stableKey}" is an activation candidate; migration syncs its portable definition but does not automatically change target activation state.`),
|
|
717
747
|
]
|
|
718
|
-
: phase.resource === '
|
|
748
|
+
: phase.resource === 'event'
|
|
719
749
|
? [
|
|
720
|
-
...(input.pulls.
|
|
721
|
-
.map((item) => `Source
|
|
722
|
-
...(input.pulls.
|
|
723
|
-
.
|
|
750
|
+
...(input.pulls.events?.warnings || [])
|
|
751
|
+
.map((item) => `Source Event "${item.stableKey}": ${item.reason}.`),
|
|
752
|
+
...(input.pulls.events?.pulled || [])
|
|
753
|
+
.filter(({ manifest }) => manifest.active === true)
|
|
754
|
+
.map(({ manifest }) => `Source Event "${manifest.stableKey}" is active; migration syncs its portable configuration but does not automatically change target activation state.`),
|
|
724
755
|
]
|
|
725
|
-
:
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
756
|
+
: phase.resource === 'group'
|
|
757
|
+
? [
|
|
758
|
+
...(input.pulls.groups?.skipped || [])
|
|
759
|
+
.map((item) => `Source Group "${item.name}" skipped: ${item.reason}.`),
|
|
760
|
+
...(input.pulls.groups?.notices || [])
|
|
761
|
+
.map((item) => `Source Group "${item.stableKey}": ${item.reason}.`),
|
|
762
|
+
]
|
|
763
|
+
: (input.pulls.roleGroups?.skipped || [])
|
|
764
|
+
.map((item) => `Source Role Group "${item.name}" skipped: ${item.reason}.`);
|
|
765
|
+
const pruneWarnings = phase.resource === 'service-account'
|
|
766
|
+
? (input.pulls.serviceAccounts?.pruned || []).map((item) => `Pruned stale source workspace Service Account "${item.stableKey}".`)
|
|
767
|
+
: phase.resource === 'database-table'
|
|
768
|
+
? (input.pulls.databaseSchemas?.pruned || []).map((item) => `Pruned stale source workspace Database Table "${item.stableKey}".`)
|
|
769
|
+
: phase.resource === 'database-view'
|
|
770
|
+
? (input.pulls.databaseViews?.pruned || []).map((item) => `Pruned stale source workspace Database View "${item.stableKey}".`)
|
|
771
|
+
: phase.resource === 'component'
|
|
772
|
+
? (input.pulls.components || [])
|
|
773
|
+
.filter((item) => item.status === 'pruned')
|
|
774
|
+
.map((item) => `Pruned stale source workspace Component at "${item.targetPath}".`)
|
|
775
|
+
: phase.resource === 'job-template'
|
|
776
|
+
? (input.pulls.jobTemplates?.pruned || [])
|
|
777
|
+
.map((item) => `Pruned stale source workspace Job Template "${item.stableKey}".`)
|
|
778
|
+
: phase.resource === 'endpoint'
|
|
779
|
+
? (input.pulls.endpoints?.pruned || [])
|
|
780
|
+
.map((item) => `Pruned stale source workspace Endpoint "${item.stableKey}".`)
|
|
781
|
+
: phase.resource === 'schedule'
|
|
782
|
+
? (input.pulls.schedules?.pruned || [])
|
|
783
|
+
.map((item) => `Pruned stale source workspace Schedule "${item.stableKey}".`)
|
|
784
|
+
: phase.resource === 'event'
|
|
785
|
+
? (input.pulls.events?.pruned || [])
|
|
786
|
+
.map((item) => `Pruned stale source workspace Event "${item.stableKey}".`)
|
|
787
|
+
: phase.resource === 'group'
|
|
788
|
+
? (input.pulls.groups?.pruned || [])
|
|
789
|
+
.map((item) => `Pruned stale source workspace Group "${item.stableKey}".`)
|
|
790
|
+
: (input.pulls.roleGroups?.pruned || [])
|
|
791
|
+
.map((item) => `Pruned stale source workspace Role Group "${item.stableKey}".`);
|
|
752
792
|
const warnings = [...new Set([...phase.warnings, ...pullWarnings, ...pruneWarnings])];
|
|
753
793
|
return { ...phase, warnings, verdict: phaseVerdict(phase.blockers, warnings) };
|
|
754
794
|
});
|
|
@@ -782,6 +822,7 @@ function combinePlan(input) {
|
|
|
782
822
|
...(input.events ? { events: input.events } : {}),
|
|
783
823
|
...(input.groups ? { groups: input.groups } : {}),
|
|
784
824
|
...(input.roleGroups ? { roleGroups: input.roleGroups } : {}),
|
|
825
|
+
...(input.serviceAccounts ? { serviceAccounts: input.serviceAccounts } : {}),
|
|
785
826
|
warnings,
|
|
786
827
|
blockers,
|
|
787
828
|
};
|
|
@@ -816,6 +857,7 @@ function createTemporaryProject(input) {
|
|
|
816
857
|
EVENTS_DIRECTORY,
|
|
817
858
|
GROUPS_DIRECTORY,
|
|
818
859
|
ROLE_GROUPS_DIRECTORY,
|
|
860
|
+
SERVICE_ACCOUNTS_DIRECTORY,
|
|
819
861
|
]) {
|
|
820
862
|
const sourceDirectory = path.join(workspaceRoot, directory);
|
|
821
863
|
if (fs.existsSync(sourceDirectory)) {
|
|
@@ -927,6 +969,10 @@ export async function pullResourcesToWorkspace(input) {
|
|
|
927
969
|
pruneOrphans: input.pruneOrphans === true,
|
|
928
970
|
}));
|
|
929
971
|
}
|
|
972
|
+
if (resources.includes('service-account')) {
|
|
973
|
+
pulls.serviceAccounts = await runMigrationStage('source pull', 'service-account', input.sourceLabel, () => pullServiceAccountsToWorkspace({ client, cwd: input.cwd, envName: input.sourceKey, stableKeyName,
|
|
974
|
+
force: input.force === true, pruneOrphans: input.pruneOrphans === true }));
|
|
975
|
+
}
|
|
930
976
|
if (resources.includes('job-template')) {
|
|
931
977
|
pulls.jobTemplates = await runMigrationStage('source pull', 'job-template', input.sourceLabel, () => pullJobTemplatesToWorkspace({
|
|
932
978
|
client,
|
|
@@ -1130,12 +1176,20 @@ async function planWorkspace(input) {
|
|
|
1130
1176
|
operation: 'plan',
|
|
1131
1177
|
}), undefined, input.detailedDiff === true))
|
|
1132
1178
|
: undefined;
|
|
1179
|
+
const identities = await planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources });
|
|
1180
|
+
const serviceAccounts = resources.includes('service-account')
|
|
1181
|
+
? await runMigrationStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
|
|
1182
|
+
projectedIdentities: identities?.projection })) : undefined;
|
|
1183
|
+
if (serviceAccounts && identities) {
|
|
1184
|
+
serviceAccounts.blockers.push(...identities.blockers);
|
|
1185
|
+
}
|
|
1133
1186
|
const jobTemplates = resources.includes('job-template')
|
|
1134
1187
|
? await runMigrationStage('target plan', 'job-template', environmentLabel, () => buildJobTemplatesPlan({
|
|
1135
1188
|
client,
|
|
1136
1189
|
cwd: input.cwd,
|
|
1137
1190
|
envName: environmentKey,
|
|
1138
1191
|
stableKeyName,
|
|
1192
|
+
projectedServiceAccounts: identities?.projection.serviceAccounts,
|
|
1139
1193
|
...(input.projectDependencies === true && components
|
|
1140
1194
|
? { projectedComponents: projectedComponentDependencies(components) }
|
|
1141
1195
|
: {}),
|
|
@@ -1183,8 +1237,12 @@ async function planWorkspace(input) {
|
|
|
1183
1237
|
cwd: input.cwd,
|
|
1184
1238
|
envName: environmentKey,
|
|
1185
1239
|
stableKeyName,
|
|
1240
|
+
projectedIdentities: identities?.projection,
|
|
1186
1241
|
}))
|
|
1187
1242
|
: undefined;
|
|
1243
|
+
if (groups && identities && !serviceAccounts) {
|
|
1244
|
+
groups.blockers.push(...identities.blockers);
|
|
1245
|
+
}
|
|
1188
1246
|
const roleGroups = resources.includes('role-group')
|
|
1189
1247
|
? await runMigrationStage('target plan', 'role-group', environmentLabel, () => buildRoleGroupsPlan({
|
|
1190
1248
|
client,
|
|
@@ -1193,7 +1251,7 @@ async function planWorkspace(input) {
|
|
|
1193
1251
|
stableKeyName,
|
|
1194
1252
|
}))
|
|
1195
1253
|
: undefined;
|
|
1196
|
-
|
|
1254
|
+
const combined = combinePlan({
|
|
1197
1255
|
migrationInput: input,
|
|
1198
1256
|
sourcePullMode: input.sourcePullMode,
|
|
1199
1257
|
pulls: input.pulls,
|
|
@@ -1206,7 +1264,12 @@ async function planWorkspace(input) {
|
|
|
1206
1264
|
events,
|
|
1207
1265
|
groups,
|
|
1208
1266
|
roleGroups,
|
|
1267
|
+
serviceAccounts,
|
|
1209
1268
|
});
|
|
1269
|
+
if (identities) {
|
|
1270
|
+
combined.identityOrder = identities.ordered.map(({ resource, stableKey }) => ({ resource, stableKey }));
|
|
1271
|
+
}
|
|
1272
|
+
return combined;
|
|
1210
1273
|
}
|
|
1211
1274
|
export async function buildMigrationPlan(input) {
|
|
1212
1275
|
requireProject(input);
|
|
@@ -1322,6 +1385,7 @@ export async function runMigration(input) {
|
|
|
1322
1385
|
events: initialPlan.events,
|
|
1323
1386
|
groups: initialPlan.groups,
|
|
1324
1387
|
roleGroups: initialPlan.roleGroups,
|
|
1388
|
+
serviceAccounts: initialPlan.serviceAccounts,
|
|
1325
1389
|
});
|
|
1326
1390
|
return { ...base, verdict: 'failed', results, phaseResults, verification };
|
|
1327
1391
|
}
|
|
@@ -1404,6 +1468,32 @@ export async function runMigration(input) {
|
|
|
1404
1468
|
return { ...base, verdict: 'failed', results, phaseResults, verification };
|
|
1405
1469
|
}
|
|
1406
1470
|
}
|
|
1471
|
+
const identityRun = await planIdentityMigration({ client: targetClient, cwd: input.cwd, stableKeyName, resources });
|
|
1472
|
+
if (identityRun) {
|
|
1473
|
+
if (identityRun.blockers.length > 0) {
|
|
1474
|
+
return { ...base, verdict: 'failed', results, phaseResults };
|
|
1475
|
+
}
|
|
1476
|
+
for (const node of identityRun.ordered) {
|
|
1477
|
+
const pushed = node.resource === 'service-account'
|
|
1478
|
+
? await pushServiceAccounts({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] })
|
|
1479
|
+
: await pushGroups({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] });
|
|
1480
|
+
const relevant = pushed.results.filter((item) => item.stableKey === node.stableKey);
|
|
1481
|
+
phaseResults[node.resource] = [...(phaseResults[node.resource] || []), ...relevant];
|
|
1482
|
+
results.push(...relevant);
|
|
1483
|
+
if (!resultsAreComplete(relevant)) {
|
|
1484
|
+
return { ...base, verdict: 'failed', results, phaseResults };
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (resources.includes('service-account')) {
|
|
1488
|
+
const pushed = await pushServiceAccounts({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true });
|
|
1489
|
+
const remaining = pushed.results.filter((item) => !(phaseResults['service-account'] || []).some((prior) => 'stableKey' in prior && prior.stableKey === item.stableKey));
|
|
1490
|
+
phaseResults['service-account'] = [...(phaseResults['service-account'] || []), ...remaining];
|
|
1491
|
+
results.push(...remaining);
|
|
1492
|
+
if (!resultsAreComplete(pushed.results)) {
|
|
1493
|
+
return { ...base, verdict: 'failed', results, phaseResults };
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1407
1497
|
if (resources.includes('job-template')) {
|
|
1408
1498
|
const liveJobTemplatePlan = await buildJobTemplatesPlan({
|
|
1409
1499
|
client: targetClient,
|
|
@@ -1567,8 +1657,9 @@ export async function runMigration(input) {
|
|
|
1567
1657
|
stableKeyName,
|
|
1568
1658
|
force: true,
|
|
1569
1659
|
});
|
|
1570
|
-
phaseResults.group
|
|
1571
|
-
|
|
1660
|
+
const groupRemaining = pushed.results.filter((item) => !(phaseResults.group || []).some((prior) => 'stableKey' in prior && prior.stableKey === item.stableKey));
|
|
1661
|
+
phaseResults.group = [...(phaseResults.group || []), ...groupRemaining];
|
|
1662
|
+
results.push(...groupRemaining);
|
|
1572
1663
|
if (!resultsAreComplete(pushed.results)) {
|
|
1573
1664
|
const verification = await planWorkspace({
|
|
1574
1665
|
...input,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { RevoClient } from './client.ts';
|
|
2
2
|
import type { TrackableResourceType } from './tracked-resources.ts';
|
|
3
|
-
import type { ComponentRecord, DatabaseSchemaRecord, DatabaseViewRecord, EndpointRecord, EventRecord, GroupRecord, JobTemplateRecord, RoleGroupRecord, ScheduleRecord } from './types.ts';
|
|
3
|
+
import type { ComponentRecord, DatabaseSchemaRecord, DatabaseViewRecord, EndpointRecord, EventRecord, GroupRecord, JobTemplateRecord, RoleGroupRecord, ScheduleRecord, ServiceAccountRecord } from './types.ts';
|
|
4
4
|
type ResourceRecordMap = {
|
|
5
|
+
'service-account': ServiceAccountRecord;
|
|
5
6
|
component: ComponentRecord;
|
|
6
7
|
'database-table': DatabaseSchemaRecord;
|
|
7
8
|
'database-view': DatabaseViewRecord;
|
|
@@ -13,7 +14,7 @@ type ResourceRecordMap = {
|
|
|
13
14
|
event: EventRecord;
|
|
14
15
|
};
|
|
15
16
|
export type ResourceRecord = ResourceRecordMap[TrackableResourceType];
|
|
16
|
-
export type ResourceInventoryClient = Pick<RevoClient, 'listAllComponents' | 'getComponent' | 'listAllDatabaseSchemas' | 'listAllDatabaseViewsForSync' | 'listAllEndpoints' | 'getEndpoint' | 'listAllRoleGroups' | 'getRoleGroup' | 'listAllGroups' | 'getGroup' | 'listAllJobTemplates' | 'getJobTemplate' | 'listAllSchedules' | 'getSchedule' | 'listAllEvents' | 'getEvent'>;
|
|
17
|
+
export type ResourceInventoryClient = Pick<RevoClient, 'listAllServiceAccounts' | 'getServiceAccount' | 'listAllComponents' | 'getComponent' | 'listAllDatabaseSchemas' | 'listAllDatabaseViewsForSync' | 'listAllEndpoints' | 'getEndpoint' | 'listAllRoleGroups' | 'getRoleGroup' | 'listAllGroups' | 'getGroup' | 'listAllJobTemplates' | 'getJobTemplate' | 'listAllSchedules' | 'getSchedule' | 'listAllEvents' | 'getEvent'>;
|
|
17
18
|
type InventoryOptions = {
|
|
18
19
|
skipPartitions?: boolean;
|
|
19
20
|
};
|
|
@@ -10,7 +10,8 @@ export function unwrapResource(value) {
|
|
|
10
10
|
return value;
|
|
11
11
|
}
|
|
12
12
|
export function resourceIdOf(resource) {
|
|
13
|
-
return String(('
|
|
13
|
+
return String(('userId' in resource && resource.userId)
|
|
14
|
+
|| ('databaseId' in resource && resource.databaseId)
|
|
14
15
|
|| ('databaseViewId' in resource && resource.databaseViewId)
|
|
15
16
|
|| ('jobTemplateId' in resource && resource.jobTemplateId)
|
|
16
17
|
|| ('endpointId' in resource && resource.endpointId)
|
|
@@ -34,6 +35,10 @@ async function* readDetails(summaries, getDetail) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
const readers = {
|
|
38
|
+
async *'service-account'(client) {
|
|
39
|
+
const { serviceAccounts } = await client.listAllServiceAccounts();
|
|
40
|
+
yield* readDetails(serviceAccounts, (id) => client.getServiceAccount(id));
|
|
41
|
+
},
|
|
37
42
|
async *component(client) {
|
|
38
43
|
const { components } = await client.listAllComponents();
|
|
39
44
|
yield* readDetails(components, (id) => client.getComponent(id));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type RevoClient } from '../client.ts';
|
|
2
|
+
import type { GroupOwnerPolicy } from '../component-lock.ts';
|
|
3
|
+
import type { ServiceAccountRecord } from '../types.ts';
|
|
4
|
+
export type ExecutionPrincipal = {
|
|
5
|
+
kind: 'service-account';
|
|
6
|
+
stableKey: string;
|
|
7
|
+
};
|
|
8
|
+
export type IdentityProjection = {
|
|
9
|
+
serviceAccounts?: string[];
|
|
10
|
+
groups?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function accountPrincipal(client: RevoClient, userId: string, stableKeyName: string): Promise<ExecutionPrincipal | undefined>;
|
|
13
|
+
export declare function readPortableOwner(client: RevoClient, record: ServiceAccountRecord, stableKeyName: string): Promise<GroupOwnerPolicy>;
|
|
14
|
+
export declare function serviceAccountMatches(client: RevoClient, stableKey: string, stableKeyName: string): Promise<ServiceAccountRecord[]>;
|
|
15
|
+
export declare function resolvePortableOwner(client: RevoClient, owner: GroupOwnerPolicy, stableKeyName: string): Promise<{
|
|
16
|
+
ownerType: "USER";
|
|
17
|
+
ownerId: string;
|
|
18
|
+
} | {
|
|
19
|
+
ownerType: "GROUP";
|
|
20
|
+
ownerId: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function ownerIsAvailable(client: RevoClient, owner: GroupOwnerPolicy, stableKeyName: string, projection?: IdentityProjection): Promise<boolean>;
|