@revoengine/cli 1.0.16 → 1.0.18
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 +35 -3
- package/dist/src/cli.js +1 -1
- package/dist/src/client.d.ts +5 -1
- package/dist/src/client.js +27 -2
- package/dist/src/commands/component.js +1 -4
- package/dist/src/commands/migrate.js +110 -183
- package/dist/src/migration-actions.d.ts +44 -0
- package/dist/src/migration-actions.js +211 -0
- package/dist/src/migration.d.ts +21 -13
- package/dist/src/migration.js +128 -217
- package/dist/src/resource-syncs/endpoint-sync.d.ts +2 -0
- package/dist/src/resource-syncs/endpoint-sync.js +7 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +1 -0
- package/dist/src/resource-syncs/job-template-sync.js +31 -0
- package/dist/src/sync-output.js +7 -5
- package/dist/src/ui.js +2 -2
- package/dist/src/workspace-prune.d.ts +42 -0
- package/dist/src/workspace-prune.js +416 -0
- package/package.json +2 -2
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
export const BLOCKING_SCHEMA_STATUSES = new Set([
|
|
2
|
+
'collision',
|
|
3
|
+
'manual-schema-migration-required',
|
|
4
|
+
'access-policy-required',
|
|
5
|
+
'previously-deleted-partition',
|
|
6
|
+
'replacement-requires-two-phases',
|
|
7
|
+
]);
|
|
8
|
+
export function schemaItemAction(item) {
|
|
9
|
+
if (BLOCKING_SCHEMA_STATUSES.has(item.status)) {
|
|
10
|
+
return 'blocked';
|
|
11
|
+
}
|
|
12
|
+
if (item.status === 'create') {
|
|
13
|
+
return 'create';
|
|
14
|
+
}
|
|
15
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
16
|
+
return 'update';
|
|
17
|
+
}
|
|
18
|
+
if (item.status === 'missing-lock') {
|
|
19
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
20
|
+
}
|
|
21
|
+
if (item.status === 'reconciled') {
|
|
22
|
+
return 'adopt';
|
|
23
|
+
}
|
|
24
|
+
if (item.status === 'orphan-root'
|
|
25
|
+
|| item.status === 'orphan-partition'
|
|
26
|
+
|| item.status === 'delete-partition'
|
|
27
|
+
|| item.status === 'unmanaged') {
|
|
28
|
+
return 'excluded';
|
|
29
|
+
}
|
|
30
|
+
return 'noop';
|
|
31
|
+
}
|
|
32
|
+
export function viewItemIsBlocked(item) {
|
|
33
|
+
return item.status === 'collision'
|
|
34
|
+
|| item.status === 'validation-failed'
|
|
35
|
+
|| (item.status === 'conflict' && Boolean(item.reason));
|
|
36
|
+
}
|
|
37
|
+
export function viewItemAction(item) {
|
|
38
|
+
if (viewItemIsBlocked(item)) {
|
|
39
|
+
return 'blocked';
|
|
40
|
+
}
|
|
41
|
+
if (item.status === 'create') {
|
|
42
|
+
return 'create';
|
|
43
|
+
}
|
|
44
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
45
|
+
return 'update';
|
|
46
|
+
}
|
|
47
|
+
if (item.status === 'missing-lock') {
|
|
48
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
49
|
+
}
|
|
50
|
+
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
51
|
+
return 'excluded';
|
|
52
|
+
}
|
|
53
|
+
return 'noop';
|
|
54
|
+
}
|
|
55
|
+
export function componentItemAction(item) {
|
|
56
|
+
if (item.blocked === true || item.status === 'blocked') {
|
|
57
|
+
return 'blocked';
|
|
58
|
+
}
|
|
59
|
+
if (item.status === 'clean'
|
|
60
|
+
&& item.lockHash === null
|
|
61
|
+
&& item.localHash !== null
|
|
62
|
+
&& item.localHash === item.remoteHash) {
|
|
63
|
+
return 'adopt';
|
|
64
|
+
}
|
|
65
|
+
if (item.status === 'create') {
|
|
66
|
+
return 'create';
|
|
67
|
+
}
|
|
68
|
+
if (item.status === 'local-changed'
|
|
69
|
+
|| item.status === 'remote-changed'
|
|
70
|
+
|| item.status === 'conflict'
|
|
71
|
+
|| item.status === 'missing-lock') {
|
|
72
|
+
return 'update';
|
|
73
|
+
}
|
|
74
|
+
if (item.status === 'safe-update') {
|
|
75
|
+
return 'excluded';
|
|
76
|
+
}
|
|
77
|
+
return 'noop';
|
|
78
|
+
}
|
|
79
|
+
export function jobTemplateItemAction(item) {
|
|
80
|
+
if (item.status === 'collision' || (item.status === 'conflict' && !item.desiredHash)) {
|
|
81
|
+
return 'blocked';
|
|
82
|
+
}
|
|
83
|
+
if (item.status === 'create') {
|
|
84
|
+
return 'create';
|
|
85
|
+
}
|
|
86
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
87
|
+
return 'update';
|
|
88
|
+
}
|
|
89
|
+
if (item.status === 'missing-lock') {
|
|
90
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
91
|
+
}
|
|
92
|
+
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
93
|
+
return 'excluded';
|
|
94
|
+
}
|
|
95
|
+
return 'noop';
|
|
96
|
+
}
|
|
97
|
+
export function endpointItemAction(item) {
|
|
98
|
+
if (item.dependencyBlockers?.length || item.status === 'restore-blocked' || item.status === 'collision') {
|
|
99
|
+
return 'blocked';
|
|
100
|
+
}
|
|
101
|
+
if (item.status === 'create') {
|
|
102
|
+
return 'create';
|
|
103
|
+
}
|
|
104
|
+
if (item.status === 'restore' || item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
105
|
+
return 'update';
|
|
106
|
+
}
|
|
107
|
+
if (item.status === 'missing-lock') {
|
|
108
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
109
|
+
}
|
|
110
|
+
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
111
|
+
return 'excluded';
|
|
112
|
+
}
|
|
113
|
+
return 'noop';
|
|
114
|
+
}
|
|
115
|
+
export function scheduleItemAction(item) {
|
|
116
|
+
if (item.blocked === true || item.status === 'collision') {
|
|
117
|
+
return 'blocked';
|
|
118
|
+
}
|
|
119
|
+
if (item.status === 'create') {
|
|
120
|
+
return 'create';
|
|
121
|
+
}
|
|
122
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
123
|
+
return 'update';
|
|
124
|
+
}
|
|
125
|
+
if (item.status === 'missing-lock') {
|
|
126
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
127
|
+
}
|
|
128
|
+
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
129
|
+
return 'excluded';
|
|
130
|
+
}
|
|
131
|
+
return 'noop';
|
|
132
|
+
}
|
|
133
|
+
export function eventItemAction(item) {
|
|
134
|
+
if (item.blocked === true || item.status === 'collision') {
|
|
135
|
+
return 'blocked';
|
|
136
|
+
}
|
|
137
|
+
if (item.status === 'create') {
|
|
138
|
+
return 'create';
|
|
139
|
+
}
|
|
140
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
141
|
+
return 'update';
|
|
142
|
+
}
|
|
143
|
+
if (item.status === 'missing-lock') {
|
|
144
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
145
|
+
}
|
|
146
|
+
if (item.status === 'orphan' || item.status === 'skipped' || item.status === 'activation-drift') {
|
|
147
|
+
return 'excluded';
|
|
148
|
+
}
|
|
149
|
+
return 'noop';
|
|
150
|
+
}
|
|
151
|
+
export function groupItemAction(item) {
|
|
152
|
+
if (item.status === 'collision'
|
|
153
|
+
|| ((item.status === 'conflict' || item.status === 'missing-lock') && !item.currentHash)) {
|
|
154
|
+
return 'blocked';
|
|
155
|
+
}
|
|
156
|
+
if (item.status === 'create') {
|
|
157
|
+
return 'create';
|
|
158
|
+
}
|
|
159
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
160
|
+
return 'update';
|
|
161
|
+
}
|
|
162
|
+
if (item.status === 'missing-lock') {
|
|
163
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
164
|
+
}
|
|
165
|
+
if (item.status === 'manual-owner' || item.status === 'orphan' || item.status === 'skipped') {
|
|
166
|
+
return 'excluded';
|
|
167
|
+
}
|
|
168
|
+
return 'noop';
|
|
169
|
+
}
|
|
170
|
+
export function roleGroupItemAction(item) {
|
|
171
|
+
if (item.status === 'collision' || (item.status === 'conflict' && !item.currentHash)) {
|
|
172
|
+
return 'blocked';
|
|
173
|
+
}
|
|
174
|
+
if (item.status === 'create') {
|
|
175
|
+
return 'create';
|
|
176
|
+
}
|
|
177
|
+
if (item.status === 'safe-update' || item.status === 'remote-changed' || item.status === 'conflict') {
|
|
178
|
+
return 'update';
|
|
179
|
+
}
|
|
180
|
+
if (item.status === 'missing-lock') {
|
|
181
|
+
return item.desiredHash === item.currentHash ? 'adopt' : 'update';
|
|
182
|
+
}
|
|
183
|
+
if (item.status === 'orphan' || item.status === 'skipped') {
|
|
184
|
+
return 'excluded';
|
|
185
|
+
}
|
|
186
|
+
return 'noop';
|
|
187
|
+
}
|
|
188
|
+
export function serviceAccountItemAction(item) {
|
|
189
|
+
if (item.status === 'manual-owner') {
|
|
190
|
+
return 'excluded';
|
|
191
|
+
}
|
|
192
|
+
return roleGroupItemAction({ ...item, status: item.status });
|
|
193
|
+
}
|
|
194
|
+
export function projectRepositoryItems(items, classify, baselineHash) {
|
|
195
|
+
return items.map((item) => {
|
|
196
|
+
const action = classify(item);
|
|
197
|
+
const desired = item.desiredHash ?? item.localHash;
|
|
198
|
+
const current = item.currentHash ?? item.remoteHash;
|
|
199
|
+
const converged = (action === 'noop' || action === 'adopt') && Boolean(desired) && desired === current;
|
|
200
|
+
const baseline = baselineHash(item);
|
|
201
|
+
return {
|
|
202
|
+
...item,
|
|
203
|
+
// Domain classification takes precedence: equal hashes cannot hide owner updates or validation failures.
|
|
204
|
+
operation: converged && action === 'adopt' ? 'noop' : action,
|
|
205
|
+
baselineAction: !converged ? 'none' : !baseline ? 'adopt' : baseline !== current ? 'refresh' : 'none',
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
export function migrationItemOperation(item, legacyAction) {
|
|
210
|
+
return item.operation ?? legacyAction;
|
|
211
|
+
}
|
package/dist/src/migration.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type MigrationResourcePlan } from './migration-actions.ts';
|
|
2
|
+
import { type WorkspacePrunePlan } from './workspace-prune.ts';
|
|
1
3
|
import { type ServiceAccountsPlan, type ServiceAccountPullResult, type ServiceAccountPushResult } from './resource-syncs/service-account-sync.ts';
|
|
2
4
|
import { RevoClient } from './client.ts';
|
|
3
5
|
import { type ComponentPlan, type ComponentSyncResult } from './commands/component.ts';
|
|
@@ -11,7 +13,9 @@ import { type SchedulePullResult, type SchedulePushResult, type SchedulesPlan }
|
|
|
11
13
|
import { type RoleGroupPullResult, type RoleGroupPushResult, type RoleGroupsPlan } from './resource-syncs/role-group-sync.ts';
|
|
12
14
|
export type MigrationResource = 'database-table' | 'database-view' | 'component' | 'job-template' | 'endpoint' | 'schedule' | 'event' | 'group' | 'role-group' | 'service-account';
|
|
13
15
|
export type MigrationVerdict = 'ready' | 'ready-with-warnings' | 'blocked';
|
|
14
|
-
export type MigrationOperations = Record<'noop' | 'create' | 'update' | 'adopt' | 'excluded' | 'blocked', number
|
|
16
|
+
export type MigrationOperations = Record<'noop' | 'create' | 'update' | 'adopt' | 'excluded' | 'blocked', number> & {
|
|
17
|
+
delete?: number;
|
|
18
|
+
};
|
|
15
19
|
type MigrationPushResult = DatabaseSchemaPushResult | DatabaseViewPushResult | ComponentSyncResult | JobTemplatePushResult | EndpointPushResult | SchedulePushResult | EventPushResult | GroupPushResult | RoleGroupPushResult | ServiceAccountPushResult;
|
|
16
20
|
export type MigrationPhasePlan = {
|
|
17
21
|
order: number;
|
|
@@ -40,8 +44,10 @@ export type MigrationPlan = {
|
|
|
40
44
|
from: string;
|
|
41
45
|
to: string;
|
|
42
46
|
resources: MigrationResource[];
|
|
47
|
+
prune?: WorkspacePrunePlan;
|
|
48
|
+
pruneTargetKey?: string;
|
|
43
49
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
44
|
-
mode: 'upsert';
|
|
50
|
+
mode: 'upsert' | 'reconcile';
|
|
45
51
|
};
|
|
46
52
|
needsChanges: boolean;
|
|
47
53
|
readyToMigrate: boolean;
|
|
@@ -53,16 +59,16 @@ export type MigrationPlan = {
|
|
|
53
59
|
resource: 'group' | 'service-account';
|
|
54
60
|
stableKey: string;
|
|
55
61
|
}>;
|
|
56
|
-
databaseSchemas?: DatabaseSchemasPlan
|
|
57
|
-
databaseViews?: DatabaseViewsPlan
|
|
58
|
-
components?: ComponentPlan
|
|
59
|
-
jobTemplates?: JobTemplatesPlan
|
|
60
|
-
endpoints?: EndpointPlan
|
|
61
|
-
schedules?: SchedulesPlan
|
|
62
|
-
events?: EventsPlan
|
|
63
|
-
groups?: GroupsPlan
|
|
64
|
-
roleGroups?: RoleGroupsPlan
|
|
65
|
-
serviceAccounts?: ServiceAccountsPlan
|
|
62
|
+
databaseSchemas?: MigrationResourcePlan<DatabaseSchemasPlan>;
|
|
63
|
+
databaseViews?: MigrationResourcePlan<DatabaseViewsPlan>;
|
|
64
|
+
components?: MigrationResourcePlan<ComponentPlan>;
|
|
65
|
+
jobTemplates?: MigrationResourcePlan<JobTemplatesPlan>;
|
|
66
|
+
endpoints?: MigrationResourcePlan<EndpointPlan>;
|
|
67
|
+
schedules?: MigrationResourcePlan<SchedulesPlan>;
|
|
68
|
+
events?: MigrationResourcePlan<EventsPlan>;
|
|
69
|
+
groups?: MigrationResourcePlan<GroupsPlan>;
|
|
70
|
+
roleGroups?: MigrationResourcePlan<RoleGroupsPlan>;
|
|
71
|
+
serviceAccounts?: MigrationResourcePlan<ServiceAccountsPlan>;
|
|
66
72
|
warnings: string[];
|
|
67
73
|
blockers: string[];
|
|
68
74
|
};
|
|
@@ -73,7 +79,7 @@ export type MigrationRun = {
|
|
|
73
79
|
to: string;
|
|
74
80
|
resources: MigrationResource[];
|
|
75
81
|
policy: DatabaseSchemaMigrationPolicy & {
|
|
76
|
-
mode: 'upsert';
|
|
82
|
+
mode: 'upsert' | 'reconcile';
|
|
77
83
|
};
|
|
78
84
|
verdict: 'succeeded' | 'blocked' | 'failed';
|
|
79
85
|
sourcePull: {
|
|
@@ -101,6 +107,8 @@ type MigrationInputBase = {
|
|
|
101
107
|
withStats?: boolean;
|
|
102
108
|
allowDestructive?: boolean;
|
|
103
109
|
detailedDiff?: boolean;
|
|
110
|
+
prune?: boolean;
|
|
111
|
+
reviewedPrune?: WorkspacePrunePlan;
|
|
104
112
|
};
|
|
105
113
|
export type MigrationInput = MigrationInputBase & ({
|
|
106
114
|
sourceMode: 'workspace';
|