@revoengine/cli 1.0.17 → 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 +14 -4
- package/dist/src/commands/migrate.js +47 -173
- package/dist/src/migration-actions.d.ts +44 -0
- package/dist/src/migration-actions.js +211 -0
- package/dist/src/migration.d.ts +11 -10
- package/dist/src/migration.js +94 -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/workspace-prune.d.ts +2 -0
- package/dist/src/workspace-prune.js +59 -6
- 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,4 @@
|
|
|
1
|
+
import { type MigrationResourcePlan } from './migration-actions.ts';
|
|
1
2
|
import { type WorkspacePrunePlan } from './workspace-prune.ts';
|
|
2
3
|
import { type ServiceAccountsPlan, type ServiceAccountPullResult, type ServiceAccountPushResult } from './resource-syncs/service-account-sync.ts';
|
|
3
4
|
import { RevoClient } from './client.ts';
|
|
@@ -58,16 +59,16 @@ export type MigrationPlan = {
|
|
|
58
59
|
resource: 'group' | 'service-account';
|
|
59
60
|
stableKey: string;
|
|
60
61
|
}>;
|
|
61
|
-
databaseSchemas?: DatabaseSchemasPlan
|
|
62
|
-
databaseViews?: DatabaseViewsPlan
|
|
63
|
-
components?: ComponentPlan
|
|
64
|
-
jobTemplates?: JobTemplatesPlan
|
|
65
|
-
endpoints?: EndpointPlan
|
|
66
|
-
schedules?: SchedulesPlan
|
|
67
|
-
events?: EventsPlan
|
|
68
|
-
groups?: GroupsPlan
|
|
69
|
-
roleGroups?: RoleGroupsPlan
|
|
70
|
-
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>;
|
|
71
72
|
warnings: string[];
|
|
72
73
|
blockers: string[];
|
|
73
74
|
};
|