@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.
- package/README.md +314 -239
- package/dist/src/cli.js +126 -9
- package/dist/src/client.d.ts +373 -6
- package/dist/src/client.js +1005 -53
- package/dist/src/commands/auth.js +4 -2
- package/dist/src/commands/component.d.ts +67 -0
- package/dist/src/commands/component.js +555 -164
- package/dist/src/commands/database-tables.d.ts +2 -0
- package/dist/src/commands/database-tables.js +169 -0
- package/dist/src/commands/database-views.d.ts +2 -0
- package/dist/src/commands/database-views.js +126 -0
- package/dist/src/commands/endpoints.js +124 -0
- package/dist/src/commands/env.js +44 -24
- package/dist/src/commands/events.d.ts +2 -0
- package/dist/src/commands/events.js +144 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +160 -0
- package/dist/src/commands/index.d.ts +9 -0
- package/dist/src/commands/index.js +9 -0
- package/dist/src/commands/job-templates.d.ts +2 -0
- package/dist/src/commands/job-templates.js +107 -0
- package/dist/src/commands/metadata.js +75 -10
- package/dist/src/commands/migrate.d.ts +6 -0
- package/dist/src/commands/migrate.js +658 -0
- package/dist/src/commands/project.js +10 -3
- package/dist/src/commands/role-groups.d.ts +2 -0
- package/dist/src/commands/role-groups.js +141 -0
- package/dist/src/commands/schedules.d.ts +2 -0
- package/dist/src/commands/schedules.js +140 -0
- package/dist/src/commands/terminal-browser.d.ts +16 -0
- package/dist/src/commands/terminal-browser.js +92 -0
- package/dist/src/commands/terminal-image.d.ts +7 -0
- package/dist/src/commands/terminal-image.js +40 -0
- package/dist/src/commands/terminal-patch-worker.d.ts +1 -0
- package/dist/src/commands/terminal-patch-worker.js +24 -0
- package/dist/src/commands/terminal-patch.d.ts +2 -0
- package/dist/src/commands/terminal-patch.js +156 -0
- package/dist/src/commands/terminal-sandbox.d.ts +8 -0
- package/dist/src/commands/terminal-sandbox.js +87 -0
- package/dist/src/commands/terminal-service.d.ts +38 -0
- package/dist/src/commands/terminal-service.js +210 -0
- package/dist/src/commands/terminal.d.ts +49 -0
- package/dist/src/commands/terminal.js +826 -0
- package/dist/src/component-lock.d.ts +111 -3
- package/dist/src/component-lock.js +363 -15
- package/dist/src/config.d.ts +10 -2
- package/dist/src/config.js +49 -14
- package/dist/src/database-table-artifacts.d.ts +7 -0
- package/dist/src/database-table-artifacts.js +8 -0
- package/dist/src/diff-details.d.ts +8 -0
- package/dist/src/diff-details.js +152 -0
- package/dist/src/env-sync.d.ts +0 -3
- package/dist/src/env-sync.js +11 -25
- package/dist/src/http-trace.d.ts +94 -0
- package/dist/src/http-trace.js +226 -0
- package/dist/src/metadata-backfill.d.ts +18 -7
- package/dist/src/metadata-backfill.js +1002 -27
- package/dist/src/migration.d.ts +141 -0
- package/dist/src/migration.js +1632 -0
- package/dist/src/project.d.ts +2 -0
- package/dist/src/project.js +4 -17
- package/dist/src/prompt.js +10 -18
- package/dist/src/resource-inventory.d.ts +28 -0
- package/dist/src/resource-inventory.js +85 -0
- package/dist/src/resource-metadata.d.ts +1 -0
- package/dist/src/resource-metadata.js +3 -0
- package/dist/src/resource-syncs/database-table-sync.d.ts +127 -0
- package/dist/src/resource-syncs/database-table-sync.js +2374 -0
- package/dist/src/resource-syncs/database-view-sync.d.ts +146 -0
- package/dist/src/resource-syncs/database-view-sync.js +1405 -0
- package/dist/src/resource-syncs/endpoint-sync.d.ts +123 -0
- package/dist/src/resource-syncs/endpoint-sync.js +1563 -0
- package/dist/src/resource-syncs/event-sync.d.ts +126 -0
- package/dist/src/resource-syncs/event-sync.js +1046 -0
- package/dist/src/resource-syncs/group-sync.d.ts +93 -0
- package/dist/src/resource-syncs/group-sync.js +928 -0
- package/dist/src/resource-syncs/job-template-sync.d.ts +106 -0
- package/dist/src/resource-syncs/job-template-sync.js +843 -0
- package/dist/src/resource-syncs/role-group-sync.d.ts +90 -0
- package/dist/src/resource-syncs/role-group-sync.js +635 -0
- package/dist/src/resource-syncs/schedule-sync.d.ts +140 -0
- package/dist/src/resource-syncs/schedule-sync.js +1396 -0
- package/dist/src/resource-syncs/util.d.ts +22 -0
- package/dist/src/resource-syncs/util.js +118 -0
- package/dist/src/resource-target.d.ts +11 -0
- package/dist/src/resource-target.js +48 -0
- package/dist/src/runtime-view.d.ts +1 -0
- package/dist/src/runtime-view.js +6 -1
- package/dist/src/sync-output.d.ts +66 -0
- package/dist/src/sync-output.js +268 -0
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +28 -2
- package/dist/src/types.d.ts +227 -0
- package/dist/src/ui.d.ts +3 -0
- package/dist/src/ui.js +76 -18
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.js +81 -0
- package/dist/src/workspace-component.d.ts +2 -0
- package/dist/src/workspace-component.js +34 -0
- package/dist/src/workspace-diff.d.ts +25 -0
- package/dist/src/workspace-diff.js +75 -0
- package/dist/src/workspace-resource.d.ts +2 -0
- package/dist/src/workspace-resource.js +52 -0
- package/package.json +12 -4
|
@@ -14,12 +14,110 @@ export type ComponentLockEntry = {
|
|
|
14
14
|
remoteHash: string;
|
|
15
15
|
sourceHash: string;
|
|
16
16
|
pulledAt: string;
|
|
17
|
+
defaultRemoved?: boolean;
|
|
18
|
+
environments?: Record<string, ComponentEnvironmentBaseline>;
|
|
19
|
+
};
|
|
20
|
+
export type ComponentEnvironmentBaseline = {
|
|
21
|
+
remoteComponentId: string;
|
|
22
|
+
remoteVersion: number | null;
|
|
23
|
+
remoteHash: string;
|
|
24
|
+
syncedAt: string;
|
|
25
|
+
};
|
|
26
|
+
export type ComponentLockEntryInput = Omit<ComponentLockEntry, 'identityMode' | 'remoteComponentId' | 'defaultRemoved'> & Partial<Pick<ComponentLockEntry, 'identityMode' | 'remoteComponentId'>>;
|
|
27
|
+
export type EnvironmentBaseline = {
|
|
28
|
+
remoteHash: string;
|
|
29
|
+
syncedAt: string;
|
|
30
|
+
};
|
|
31
|
+
export type RoleGroupLockEntry = {
|
|
32
|
+
stableKey: string;
|
|
33
|
+
path: string;
|
|
34
|
+
sourceHash: string;
|
|
35
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
36
|
+
};
|
|
37
|
+
export type GroupLockEntry = {
|
|
38
|
+
stableKey: string;
|
|
39
|
+
path: string;
|
|
40
|
+
sourceHash: string;
|
|
41
|
+
owner?: GroupOwnerPolicy;
|
|
42
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
43
|
+
};
|
|
44
|
+
export type GroupOwnerPolicy = {
|
|
45
|
+
type: 'group';
|
|
46
|
+
stableKey: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'manual-user';
|
|
49
|
+
} | {
|
|
50
|
+
type: 'unresolved';
|
|
51
|
+
reason: string;
|
|
52
|
+
};
|
|
53
|
+
export type JobTemplateLockEntry = {
|
|
54
|
+
stableKey: string;
|
|
55
|
+
path: string;
|
|
56
|
+
sourceHash: string;
|
|
57
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
58
|
+
migration?: {
|
|
59
|
+
componentBinding?: 'pinned-unsupported';
|
|
60
|
+
executionPrincipal?: 'excluded';
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type ScheduleLockEntry = {
|
|
64
|
+
stableKey: string;
|
|
65
|
+
path: string;
|
|
66
|
+
sourceHash: string;
|
|
67
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
68
|
+
};
|
|
69
|
+
export type EventLockEntry = {
|
|
70
|
+
stableKey: string;
|
|
71
|
+
path: string;
|
|
72
|
+
sourceHash: string;
|
|
73
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
74
|
+
};
|
|
75
|
+
export type EndpointLockEntry = {
|
|
76
|
+
stableKey: string;
|
|
77
|
+
path: string;
|
|
78
|
+
sourceHash: string;
|
|
79
|
+
environments: Record<string, EnvironmentBaseline>;
|
|
80
|
+
};
|
|
81
|
+
export type DatabaseSchemaLockEntry = {
|
|
82
|
+
stableKey: string;
|
|
83
|
+
path: string;
|
|
84
|
+
sourceHash: string;
|
|
85
|
+
sourceRestricted?: boolean;
|
|
86
|
+
parentStableKey?: string;
|
|
87
|
+
environments: Record<string, {
|
|
88
|
+
remoteHash: string;
|
|
89
|
+
tombstone?: {
|
|
90
|
+
deletedAt: string;
|
|
91
|
+
parentStableKey: string;
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
export type DatabaseViewLockEntry = {
|
|
96
|
+
stableKey: string;
|
|
97
|
+
path: string;
|
|
98
|
+
sourceHash: string;
|
|
99
|
+
environments: Record<string, EnvironmentBaseline & {
|
|
100
|
+
dependencyHash?: string;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
export type RevoLockDiagnostics = {
|
|
104
|
+
httpTrace?: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
};
|
|
17
107
|
};
|
|
18
|
-
export type ComponentLockEntryInput = Omit<ComponentLockEntry, 'identityMode' | 'remoteComponentId'> & Partial<Pick<ComponentLockEntry, 'identityMode' | 'remoteComponentId'>>;
|
|
19
108
|
export type RevoLockFile = {
|
|
20
109
|
schemaVersion: 2;
|
|
110
|
+
diagnostics?: RevoLockDiagnostics;
|
|
21
111
|
componentIdentity: ComponentIdentityConfig;
|
|
22
112
|
components: Record<string, ComponentLockEntry>;
|
|
113
|
+
groups: Record<string, GroupLockEntry>;
|
|
114
|
+
roleGroups: Record<string, RoleGroupLockEntry>;
|
|
115
|
+
jobTemplates: Record<string, JobTemplateLockEntry>;
|
|
116
|
+
schedules: Record<string, ScheduleLockEntry>;
|
|
117
|
+
events: Record<string, EventLockEntry>;
|
|
118
|
+
endpoints: Record<string, EndpointLockEntry>;
|
|
119
|
+
databaseSchemas: Record<string, DatabaseSchemaLockEntry>;
|
|
120
|
+
databaseViews: Record<string, DatabaseViewLockEntry>;
|
|
23
121
|
};
|
|
24
122
|
export declare function hashStable(value: unknown): string;
|
|
25
123
|
export declare function sanitizeComponentSource<T extends ComponentRecord>(component: T): T;
|
|
@@ -56,10 +154,20 @@ export declare function normalizePortableComponentSource(component: ComponentRec
|
|
|
56
154
|
}[];
|
|
57
155
|
};
|
|
58
156
|
export declare function hashPortableComponentSource(component: ComponentRecord): string;
|
|
157
|
+
export declare const PORTABLE_COMPONENT_CONFIG_FIELDS: readonly ["name", "category", "desc", "active", "type", "async"];
|
|
158
|
+
export type PortableComponentConfigField = (typeof PORTABLE_COMPONENT_CONFIG_FIELDS)[number];
|
|
159
|
+
export declare function diffPortableComponentSource(source: ComponentRecord, target: ComponentRecord): {
|
|
160
|
+
configurationFields: ("desc" | "name" | "category" | "type" | "active" | "async")[];
|
|
161
|
+
elementsChanged: boolean;
|
|
162
|
+
changedFields: string[];
|
|
163
|
+
};
|
|
164
|
+
export declare function buildPortableComponentUpdatePayload(source: ComponentRecord, target: ComponentRecord, changedFields: ReadonlyArray<string>): Record<string, unknown>;
|
|
59
165
|
export declare function getLockPath(projectRoot: string): string;
|
|
60
166
|
export declare function readComponentLock(projectRoot: string): RevoLockFile;
|
|
61
167
|
export declare function writeComponentLock(projectRoot: string, lock: RevoLockFile): void;
|
|
62
168
|
export declare function componentLockKey(identity: ComponentIdentityConfig, component: ComponentRecord): string | null;
|
|
63
169
|
export declare function componentLockMatchesIdentity(lock: RevoLockFile, identity: ComponentIdentityConfig): boolean;
|
|
64
|
-
export declare function getComponentLockEntry(lock: RevoLockFile, identity: ComponentIdentityConfig, component: ComponentRecord): ComponentLockEntry | null;
|
|
65
|
-
export declare function
|
|
170
|
+
export declare function getComponentLockEntry(lock: RevoLockFile, identity: ComponentIdentityConfig, component: ComponentRecord, environmentName?: string): ComponentLockEntry | null;
|
|
171
|
+
export declare function getComponentLockEntries(lock: RevoLockFile, identity: ComponentIdentityConfig, environmentName?: string): Record<string, ComponentLockEntry>;
|
|
172
|
+
export declare function upsertComponentLockEntry(projectRoot: string, entry: ComponentLockEntryInput, identity?: ComponentIdentityConfig, environmentName?: string): void;
|
|
173
|
+
export declare function removeComponentLockBaseline(projectRoot: string, identity: ComponentIdentityConfig, key: string, remoteComponentId: string, environmentName?: string): void;
|
|
@@ -22,6 +22,28 @@ const VOLATILE_COMPONENT_FIELDS = new Set([
|
|
|
22
22
|
'hash',
|
|
23
23
|
'remoteHash',
|
|
24
24
|
]);
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
function normalizeDiagnostics(value) {
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
if (!isRecord(value)) {
|
|
33
|
+
throw new Error('revo.lock.json field `diagnostics` must be an object.');
|
|
34
|
+
}
|
|
35
|
+
if (value.httpTrace === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
if (!isRecord(value.httpTrace) || typeof value.httpTrace.enabled !== 'boolean') {
|
|
39
|
+
throw new Error('revo.lock.json field `diagnostics.httpTrace.enabled` must be a boolean.');
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
httpTrace: {
|
|
43
|
+
enabled: value.httpTrace.enabled,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
25
47
|
function normalizeValue(value, fallback = null) {
|
|
26
48
|
return value ?? fallback;
|
|
27
49
|
}
|
|
@@ -86,6 +108,41 @@ export function normalizePortableComponentSource(component) {
|
|
|
86
108
|
export function hashPortableComponentSource(component) {
|
|
87
109
|
return hashStable(normalizePortableComponentSource(component));
|
|
88
110
|
}
|
|
111
|
+
export const PORTABLE_COMPONENT_CONFIG_FIELDS = [
|
|
112
|
+
'name',
|
|
113
|
+
'category',
|
|
114
|
+
'desc',
|
|
115
|
+
'active',
|
|
116
|
+
'type',
|
|
117
|
+
'async',
|
|
118
|
+
];
|
|
119
|
+
export function diffPortableComponentSource(source, target) {
|
|
120
|
+
const sourcePortable = normalizePortableComponentSource(source);
|
|
121
|
+
const targetPortable = normalizePortableComponentSource(target);
|
|
122
|
+
const configurationFields = PORTABLE_COMPONENT_CONFIG_FIELDS.filter((field) => sourcePortable[field] !== targetPortable[field]);
|
|
123
|
+
const elementsChanged = hashStable(sourcePortable.elements) !== hashStable(targetPortable.elements);
|
|
124
|
+
return {
|
|
125
|
+
configurationFields,
|
|
126
|
+
elementsChanged,
|
|
127
|
+
changedFields: [
|
|
128
|
+
...configurationFields,
|
|
129
|
+
...(elementsChanged ? ['elements'] : []),
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export function buildPortableComponentUpdatePayload(source, target, changedFields) {
|
|
134
|
+
if (!Number.isInteger(target.version)) {
|
|
135
|
+
throw new Error('target component version is required to update component configuration');
|
|
136
|
+
}
|
|
137
|
+
const sourcePortable = normalizePortableComponentSource(source);
|
|
138
|
+
const payload = { version: target.version };
|
|
139
|
+
for (const field of PORTABLE_COMPONENT_CONFIG_FIELDS) {
|
|
140
|
+
if (changedFields.includes(field)) {
|
|
141
|
+
payload[field] = sourcePortable[field];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return payload;
|
|
145
|
+
}
|
|
89
146
|
export function getLockPath(projectRoot) {
|
|
90
147
|
return path.join(projectRoot, REVO_LOCK_FILE);
|
|
91
148
|
}
|
|
@@ -96,10 +153,19 @@ export function readComponentLock(projectRoot) {
|
|
|
96
153
|
schemaVersion: 2,
|
|
97
154
|
componentIdentity: COMPONENT_IDENTITY_BY_ID,
|
|
98
155
|
components: {},
|
|
156
|
+
groups: {},
|
|
157
|
+
roleGroups: {},
|
|
158
|
+
jobTemplates: {},
|
|
159
|
+
schedules: {},
|
|
160
|
+
events: {},
|
|
161
|
+
endpoints: {},
|
|
162
|
+
databaseSchemas: {},
|
|
163
|
+
databaseViews: {},
|
|
99
164
|
};
|
|
100
165
|
}
|
|
101
166
|
const raw = readJsonFile(lockPath);
|
|
102
167
|
const componentIdentity = normalizeComponentIdentityConfig(raw.componentIdentity, COMPONENT_IDENTITY_BY_ID);
|
|
168
|
+
const diagnostics = normalizeDiagnostics(raw.diagnostics);
|
|
103
169
|
const components = Object.fromEntries(Object.entries(raw.components && typeof raw.components === 'object' ? raw.components : {})
|
|
104
170
|
.map(([key, entry]) => {
|
|
105
171
|
const remoteComponentId = String(entry.remoteComponentId || entry.componentId || key);
|
|
@@ -115,20 +181,210 @@ export function readComponentLock(projectRoot) {
|
|
|
115
181
|
: {}),
|
|
116
182
|
componentId: String(entry.componentId || remoteComponentId),
|
|
117
183
|
remoteComponentId,
|
|
184
|
+
...(entry.environments && typeof entry.environments === 'object'
|
|
185
|
+
? {
|
|
186
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
187
|
+
.filter(([, baseline]) => (typeof baseline.remoteComponentId === 'string'
|
|
188
|
+
&& typeof baseline.remoteHash === 'string'
|
|
189
|
+
&& typeof baseline.syncedAt === 'string'))
|
|
190
|
+
.map(([envName, baseline]) => [envName, {
|
|
191
|
+
remoteComponentId: String(baseline.remoteComponentId),
|
|
192
|
+
remoteVersion: typeof baseline.remoteVersion === 'number' ? baseline.remoteVersion : null,
|
|
193
|
+
remoteHash: String(baseline.remoteHash),
|
|
194
|
+
syncedAt: String(baseline.syncedAt),
|
|
195
|
+
}])),
|
|
196
|
+
}
|
|
197
|
+
: {}),
|
|
118
198
|
}];
|
|
119
199
|
}));
|
|
120
200
|
return {
|
|
121
201
|
schemaVersion: 2,
|
|
202
|
+
...(diagnostics ? { diagnostics } : {}),
|
|
122
203
|
componentIdentity,
|
|
123
204
|
components,
|
|
205
|
+
groups: Object.fromEntries(Object.entries(raw.groups && typeof raw.groups === 'object' ? raw.groups : {})
|
|
206
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
207
|
+
&& typeof entry.path === 'string'
|
|
208
|
+
&& typeof entry.sourceHash === 'string'
|
|
209
|
+
&& entry.environments
|
|
210
|
+
&& typeof entry.environments === 'object'))
|
|
211
|
+
.map(([key, entry]) => [key, {
|
|
212
|
+
stableKey: String(entry.stableKey),
|
|
213
|
+
path: String(entry.path),
|
|
214
|
+
sourceHash: String(entry.sourceHash),
|
|
215
|
+
...((isRecord(entry.owner) && entry.owner.type === 'group' && typeof entry.owner.stableKey === 'string')
|
|
216
|
+
? { owner: { type: 'group', stableKey: entry.owner.stableKey } }
|
|
217
|
+
: (isRecord(entry.owner) && entry.owner.type === 'manual-user')
|
|
218
|
+
? { owner: { type: 'manual-user' } }
|
|
219
|
+
: (isRecord(entry.owner) && entry.owner.type === 'unresolved' && typeof entry.owner.reason === 'string')
|
|
220
|
+
? { owner: { type: 'unresolved', reason: entry.owner.reason } }
|
|
221
|
+
: {}),
|
|
222
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
223
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
224
|
+
.map(([envName, baseline]) => [envName, {
|
|
225
|
+
remoteHash: String(baseline.remoteHash),
|
|
226
|
+
syncedAt: String(baseline.syncedAt),
|
|
227
|
+
}])),
|
|
228
|
+
}])),
|
|
229
|
+
roleGroups: Object.fromEntries(Object.entries(raw.roleGroups && typeof raw.roleGroups === 'object' ? raw.roleGroups : {})
|
|
230
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
231
|
+
&& typeof entry.path === 'string'
|
|
232
|
+
&& typeof entry.sourceHash === 'string'
|
|
233
|
+
&& entry.environments
|
|
234
|
+
&& typeof entry.environments === 'object'))
|
|
235
|
+
.map(([key, entry]) => [key, {
|
|
236
|
+
stableKey: String(entry.stableKey),
|
|
237
|
+
path: String(entry.path),
|
|
238
|
+
sourceHash: String(entry.sourceHash),
|
|
239
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
240
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
241
|
+
.map(([envName, baseline]) => [envName, {
|
|
242
|
+
remoteHash: String(baseline.remoteHash),
|
|
243
|
+
syncedAt: String(baseline.syncedAt),
|
|
244
|
+
}])),
|
|
245
|
+
}])),
|
|
246
|
+
jobTemplates: Object.fromEntries(Object.entries(raw.jobTemplates && typeof raw.jobTemplates === 'object' ? raw.jobTemplates : {})
|
|
247
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
248
|
+
&& typeof entry.path === 'string'
|
|
249
|
+
&& typeof entry.sourceHash === 'string'
|
|
250
|
+
&& entry.environments
|
|
251
|
+
&& typeof entry.environments === 'object'))
|
|
252
|
+
.map(([key, entry]) => [key, {
|
|
253
|
+
stableKey: String(entry.stableKey),
|
|
254
|
+
path: String(entry.path),
|
|
255
|
+
sourceHash: String(entry.sourceHash),
|
|
256
|
+
...((isRecord(entry.migration) && (entry.migration.componentBinding === 'pinned-unsupported'
|
|
257
|
+
|| entry.migration.executionPrincipal === 'excluded')) ? {
|
|
258
|
+
migration: {
|
|
259
|
+
...(entry.migration.componentBinding === 'pinned-unsupported' ? { componentBinding: 'pinned-unsupported' } : {}),
|
|
260
|
+
...(entry.migration.executionPrincipal === 'excluded' ? { executionPrincipal: 'excluded' } : {}),
|
|
261
|
+
},
|
|
262
|
+
} : {}),
|
|
263
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
264
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
265
|
+
.map(([envName, baseline]) => [envName, {
|
|
266
|
+
remoteHash: String(baseline.remoteHash),
|
|
267
|
+
syncedAt: String(baseline.syncedAt),
|
|
268
|
+
}])),
|
|
269
|
+
}])),
|
|
270
|
+
schedules: Object.fromEntries(Object.entries(raw.schedules && typeof raw.schedules === 'object' ? raw.schedules : {})
|
|
271
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
272
|
+
&& typeof entry.path === 'string'
|
|
273
|
+
&& typeof entry.sourceHash === 'string'
|
|
274
|
+
&& entry.environments
|
|
275
|
+
&& typeof entry.environments === 'object'))
|
|
276
|
+
.map(([key, entry]) => [key, {
|
|
277
|
+
stableKey: String(entry.stableKey),
|
|
278
|
+
path: String(entry.path),
|
|
279
|
+
sourceHash: String(entry.sourceHash),
|
|
280
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
281
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
282
|
+
.map(([envName, baseline]) => [envName, {
|
|
283
|
+
remoteHash: String(baseline.remoteHash),
|
|
284
|
+
syncedAt: String(baseline.syncedAt),
|
|
285
|
+
}])),
|
|
286
|
+
}])),
|
|
287
|
+
events: Object.fromEntries(Object.entries(raw.events && typeof raw.events === 'object' ? raw.events : {})
|
|
288
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
289
|
+
&& typeof entry.path === 'string'
|
|
290
|
+
&& typeof entry.sourceHash === 'string'
|
|
291
|
+
&& entry.environments
|
|
292
|
+
&& typeof entry.environments === 'object'))
|
|
293
|
+
.map(([key, entry]) => [key, {
|
|
294
|
+
stableKey: String(entry.stableKey),
|
|
295
|
+
path: String(entry.path),
|
|
296
|
+
sourceHash: String(entry.sourceHash),
|
|
297
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
298
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
299
|
+
.map(([envName, baseline]) => [envName, {
|
|
300
|
+
remoteHash: String(baseline.remoteHash),
|
|
301
|
+
syncedAt: String(baseline.syncedAt),
|
|
302
|
+
}])),
|
|
303
|
+
}])),
|
|
304
|
+
endpoints: Object.fromEntries(Object.entries(raw.endpoints && typeof raw.endpoints === 'object' ? raw.endpoints : {})
|
|
305
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
306
|
+
&& typeof entry.path === 'string'
|
|
307
|
+
&& typeof entry.sourceHash === 'string'
|
|
308
|
+
&& entry.environments
|
|
309
|
+
&& typeof entry.environments === 'object'))
|
|
310
|
+
.map(([key, entry]) => [key, {
|
|
311
|
+
stableKey: String(entry.stableKey),
|
|
312
|
+
path: String(entry.path),
|
|
313
|
+
sourceHash: String(entry.sourceHash),
|
|
314
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
315
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
316
|
+
.map(([envName, baseline]) => [envName, {
|
|
317
|
+
remoteHash: String(baseline.remoteHash),
|
|
318
|
+
syncedAt: String(baseline.syncedAt),
|
|
319
|
+
}])),
|
|
320
|
+
}])),
|
|
321
|
+
databaseSchemas: Object.fromEntries(Object.entries(raw.databaseSchemas && typeof raw.databaseSchemas === 'object' ? raw.databaseSchemas : {})
|
|
322
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
323
|
+
&& typeof entry.path === 'string'
|
|
324
|
+
&& typeof entry.sourceHash === 'string'
|
|
325
|
+
&& entry.environments
|
|
326
|
+
&& typeof entry.environments === 'object'))
|
|
327
|
+
.map(([key, entry]) => [key, {
|
|
328
|
+
stableKey: String(entry.stableKey),
|
|
329
|
+
path: String(entry.path),
|
|
330
|
+
sourceHash: String(entry.sourceHash),
|
|
331
|
+
...(typeof entry.sourceRestricted === 'boolean' ? { sourceRestricted: entry.sourceRestricted } : {}),
|
|
332
|
+
...(typeof entry.parentStableKey === 'string' ? { parentStableKey: entry.parentStableKey } : {}),
|
|
333
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
334
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string')
|
|
335
|
+
.map(([envName, baseline]) => [envName, {
|
|
336
|
+
remoteHash: String(baseline.remoteHash),
|
|
337
|
+
...(typeof baseline.tombstone?.deletedAt === 'string' && typeof baseline.tombstone.parentStableKey === 'string'
|
|
338
|
+
? { tombstone: {
|
|
339
|
+
deletedAt: baseline.tombstone.deletedAt,
|
|
340
|
+
parentStableKey: baseline.tombstone.parentStableKey,
|
|
341
|
+
} }
|
|
342
|
+
: {}),
|
|
343
|
+
}])),
|
|
344
|
+
}])),
|
|
345
|
+
databaseViews: Object.fromEntries(Object.entries(raw.databaseViews && typeof raw.databaseViews === 'object' ? raw.databaseViews : {})
|
|
346
|
+
.filter(([, entry]) => (typeof entry.stableKey === 'string'
|
|
347
|
+
&& typeof entry.path === 'string'
|
|
348
|
+
&& typeof entry.sourceHash === 'string'
|
|
349
|
+
&& entry.environments
|
|
350
|
+
&& typeof entry.environments === 'object'))
|
|
351
|
+
.map(([key, entry]) => [key, {
|
|
352
|
+
stableKey: String(entry.stableKey),
|
|
353
|
+
path: String(entry.path),
|
|
354
|
+
sourceHash: String(entry.sourceHash),
|
|
355
|
+
environments: Object.fromEntries(Object.entries(entry.environments)
|
|
356
|
+
.filter(([, baseline]) => typeof baseline.remoteHash === 'string' && typeof baseline.syncedAt === 'string')
|
|
357
|
+
.map(([envName, baseline]) => [envName, {
|
|
358
|
+
remoteHash: String(baseline.remoteHash),
|
|
359
|
+
syncedAt: String(baseline.syncedAt),
|
|
360
|
+
...(typeof baseline.dependencyHash === 'string' ? { dependencyHash: baseline.dependencyHash } : {}),
|
|
361
|
+
}])),
|
|
362
|
+
}])),
|
|
124
363
|
};
|
|
125
364
|
}
|
|
126
365
|
export function writeComponentLock(projectRoot, lock) {
|
|
127
366
|
const sortedComponents = Object.fromEntries(Object.entries(lock.components).sort(([left], [right]) => left.localeCompare(right)));
|
|
367
|
+
const sortedRoleGroups = Object.fromEntries(Object.entries(lock.roleGroups).sort(([left], [right]) => left.localeCompare(right)));
|
|
368
|
+
const sortedGroups = Object.fromEntries(Object.entries(lock.groups || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
369
|
+
const sortedJobTemplates = Object.fromEntries(Object.entries(lock.jobTemplates || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
370
|
+
const sortedSchedules = Object.fromEntries(Object.entries(lock.schedules || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
371
|
+
const sortedEvents = Object.fromEntries(Object.entries(lock.events || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
372
|
+
const sortedEndpoints = Object.fromEntries(Object.entries(lock.endpoints || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
373
|
+
const sortedDatabaseSchemas = Object.fromEntries(Object.entries(lock.databaseSchemas || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
374
|
+
const sortedDatabaseViews = Object.fromEntries(Object.entries(lock.databaseViews || {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
128
375
|
writeJsonFile(getLockPath(projectRoot), {
|
|
129
376
|
schemaVersion: 2,
|
|
377
|
+
...(lock.diagnostics ? { diagnostics: normalizeDiagnostics(lock.diagnostics) } : {}),
|
|
130
378
|
componentIdentity: normalizeComponentIdentityConfig(lock.componentIdentity),
|
|
131
379
|
components: sortedComponents,
|
|
380
|
+
...(Object.keys(sortedGroups).length > 0 ? { groups: sortedGroups } : {}),
|
|
381
|
+
roleGroups: sortedRoleGroups,
|
|
382
|
+
jobTemplates: sortedJobTemplates,
|
|
383
|
+
...(Object.keys(sortedSchedules).length > 0 ? { schedules: sortedSchedules } : {}),
|
|
384
|
+
...(Object.keys(sortedEvents).length > 0 ? { events: sortedEvents } : {}),
|
|
385
|
+
...(Object.keys(sortedEndpoints).length > 0 ? { endpoints: sortedEndpoints } : {}),
|
|
386
|
+
...(Object.keys(sortedDatabaseSchemas).length > 0 ? { databaseSchemas: sortedDatabaseSchemas } : {}),
|
|
387
|
+
...(Object.keys(sortedDatabaseViews).length > 0 ? { databaseViews: sortedDatabaseViews } : {}),
|
|
132
388
|
});
|
|
133
389
|
}
|
|
134
390
|
export function componentLockKey(identity, component) {
|
|
@@ -137,14 +393,52 @@ export function componentLockKey(identity, component) {
|
|
|
137
393
|
export function componentLockMatchesIdentity(lock, identity) {
|
|
138
394
|
return sameComponentIdentityConfig(lock.componentIdentity, identity);
|
|
139
395
|
}
|
|
140
|
-
export function getComponentLockEntry(lock, identity, component) {
|
|
396
|
+
export function getComponentLockEntry(lock, identity, component, environmentName) {
|
|
141
397
|
if (!componentLockMatchesIdentity(lock, identity)) {
|
|
142
398
|
return null;
|
|
143
399
|
}
|
|
144
400
|
const key = componentLockKey(identity, component);
|
|
145
|
-
|
|
401
|
+
const entry = key ? lock.components[key] || null : null;
|
|
402
|
+
if (entry?.defaultRemoved && !environmentName) {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
if (!entry || !environmentName) {
|
|
406
|
+
return entry;
|
|
407
|
+
}
|
|
408
|
+
const baseline = entry.environments?.[environmentName];
|
|
409
|
+
if (!baseline) {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
...entry,
|
|
414
|
+
remoteComponentId: baseline.remoteComponentId,
|
|
415
|
+
remoteVersion: baseline.remoteVersion,
|
|
416
|
+
remoteHash: baseline.remoteHash,
|
|
417
|
+
pulledAt: baseline.syncedAt,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
export function getComponentLockEntries(lock, identity, environmentName) {
|
|
421
|
+
if (!componentLockMatchesIdentity(lock, identity)) {
|
|
422
|
+
return {};
|
|
423
|
+
}
|
|
424
|
+
if (!environmentName) {
|
|
425
|
+
return Object.fromEntries(Object.entries(lock.components).filter(([, entry]) => !entry.defaultRemoved));
|
|
426
|
+
}
|
|
427
|
+
return Object.fromEntries(Object.entries(lock.components).flatMap(([key, entry]) => {
|
|
428
|
+
const baseline = entry.environments?.[environmentName];
|
|
429
|
+
if (!baseline) {
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
432
|
+
return [[key, {
|
|
433
|
+
...entry,
|
|
434
|
+
remoteComponentId: baseline.remoteComponentId,
|
|
435
|
+
remoteVersion: baseline.remoteVersion,
|
|
436
|
+
remoteHash: baseline.remoteHash,
|
|
437
|
+
pulledAt: baseline.syncedAt,
|
|
438
|
+
}]];
|
|
439
|
+
}));
|
|
146
440
|
}
|
|
147
|
-
export function upsertComponentLockEntry(projectRoot, entry, identity = COMPONENT_IDENTITY_BY_ID) {
|
|
441
|
+
export function upsertComponentLockEntry(projectRoot, entry, identity = COMPONENT_IDENTITY_BY_ID, environmentName) {
|
|
148
442
|
const normalizedIdentity = normalizeComponentIdentityConfig(identity);
|
|
149
443
|
const lock = readComponentLock(projectRoot);
|
|
150
444
|
if (!componentLockMatchesIdentity(lock, normalizedIdentity)) {
|
|
@@ -170,21 +464,75 @@ export function upsertComponentLockEntry(projectRoot, entry, identity = COMPONEN
|
|
|
170
464
|
: {}),
|
|
171
465
|
};
|
|
172
466
|
const existing = lock.components[key];
|
|
467
|
+
const storedEntry = environmentName
|
|
468
|
+
? {
|
|
469
|
+
...normalizedEntry,
|
|
470
|
+
...(existing?.defaultRemoved ? { defaultRemoved: true } : {}),
|
|
471
|
+
remoteComponentId: existing?.remoteComponentId || normalizedEntry.remoteComponentId,
|
|
472
|
+
remoteVersion: existing?.remoteVersion ?? normalizedEntry.remoteVersion,
|
|
473
|
+
remoteHash: existing?.remoteHash || normalizedEntry.remoteHash,
|
|
474
|
+
environments: {
|
|
475
|
+
...existing?.environments,
|
|
476
|
+
[environmentName]: {
|
|
477
|
+
remoteComponentId: normalizedEntry.remoteComponentId,
|
|
478
|
+
remoteVersion: normalizedEntry.remoteVersion,
|
|
479
|
+
remoteHash: normalizedEntry.remoteHash,
|
|
480
|
+
syncedAt: normalizedEntry.pulledAt,
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
}
|
|
484
|
+
: {
|
|
485
|
+
...normalizedEntry,
|
|
486
|
+
...(existing?.environments ? { environments: existing.environments } : {}),
|
|
487
|
+
};
|
|
173
488
|
if (existing
|
|
174
|
-
&& existing.identityMode ===
|
|
175
|
-
&& existing.metadataProperty ===
|
|
176
|
-
&& existing.stableKey ===
|
|
177
|
-
&& existing.componentId ===
|
|
178
|
-
&& existing.remoteComponentId ===
|
|
179
|
-
&& existing.componentName ===
|
|
180
|
-
&& existing.category ===
|
|
181
|
-
&& existing.path ===
|
|
182
|
-
&& existing.remoteVersion ===
|
|
183
|
-
&& existing.remoteHash ===
|
|
184
|
-
&& existing.sourceHash ===
|
|
489
|
+
&& existing.identityMode === storedEntry.identityMode
|
|
490
|
+
&& existing.metadataProperty === storedEntry.metadataProperty
|
|
491
|
+
&& existing.stableKey === storedEntry.stableKey
|
|
492
|
+
&& existing.componentId === storedEntry.componentId
|
|
493
|
+
&& existing.remoteComponentId === storedEntry.remoteComponentId
|
|
494
|
+
&& existing.componentName === storedEntry.componentName
|
|
495
|
+
&& existing.category === storedEntry.category
|
|
496
|
+
&& existing.path === storedEntry.path
|
|
497
|
+
&& existing.remoteVersion === storedEntry.remoteVersion
|
|
498
|
+
&& existing.remoteHash === storedEntry.remoteHash
|
|
499
|
+
&& existing.sourceHash === storedEntry.sourceHash
|
|
500
|
+
&& existing.defaultRemoved === storedEntry.defaultRemoved
|
|
501
|
+
&& JSON.stringify(existing.environments || {}) === JSON.stringify(storedEntry.environments || {})) {
|
|
185
502
|
return;
|
|
186
503
|
}
|
|
187
504
|
lock.componentIdentity = normalizedIdentity;
|
|
188
|
-
lock.components[key] =
|
|
505
|
+
lock.components[key] = storedEntry;
|
|
506
|
+
writeComponentLock(projectRoot, lock);
|
|
507
|
+
}
|
|
508
|
+
export function removeComponentLockBaseline(projectRoot, identity, key, remoteComponentId, environmentName) {
|
|
509
|
+
const lock = readComponentLock(projectRoot);
|
|
510
|
+
if (!componentLockMatchesIdentity(lock, identity)) {
|
|
511
|
+
throw new Error('Component lock identity changed before prune.');
|
|
512
|
+
}
|
|
513
|
+
const entry = lock.components[key];
|
|
514
|
+
const baselineId = environmentName
|
|
515
|
+
? entry?.environments?.[environmentName]?.remoteComponentId
|
|
516
|
+
: entry?.defaultRemoved ? undefined : entry?.remoteComponentId;
|
|
517
|
+
if (!entry || baselineId !== remoteComponentId) {
|
|
518
|
+
throw new Error(`Component lock baseline for "${key}" changed before prune.`);
|
|
519
|
+
}
|
|
520
|
+
if (environmentName) {
|
|
521
|
+
const environments = { ...entry.environments };
|
|
522
|
+
delete environments[environmentName];
|
|
523
|
+
const defaultRemoved = entry.defaultRemoved || entry.remoteComponentId === remoteComponentId;
|
|
524
|
+
if (Object.keys(environments).length === 0 && defaultRemoved) {
|
|
525
|
+
delete lock.components[key];
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
lock.components[key] = { ...entry, ...(defaultRemoved ? { defaultRemoved: true } : {}), environments };
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else if (Object.keys(entry.environments || {}).length > 0) {
|
|
532
|
+
lock.components[key] = { ...entry, defaultRemoved: true };
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
delete lock.components[key];
|
|
536
|
+
}
|
|
189
537
|
writeComponentLock(projectRoot, lock);
|
|
190
538
|
}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type RuntimeConfig = {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
instance: string;
|
|
6
6
|
token: string;
|
|
7
|
+
production?: true;
|
|
7
8
|
};
|
|
8
9
|
export type RuntimeConfigOptions = {
|
|
9
10
|
baseUrl?: string;
|
|
@@ -15,10 +16,12 @@ export type StoredEnvironmentProfile = {
|
|
|
15
16
|
baseUrl: string;
|
|
16
17
|
token: string;
|
|
17
18
|
instance?: string;
|
|
19
|
+
production?: true;
|
|
18
20
|
};
|
|
19
21
|
type StoredConfig = Omit<RuntimeConfig, 'instance'> & {
|
|
20
22
|
instance?: string;
|
|
21
23
|
environments?: Record<string, StoredEnvironmentProfile>;
|
|
24
|
+
activeEnvironment?: string;
|
|
22
25
|
};
|
|
23
26
|
export type AuthValidationState = {
|
|
24
27
|
key: string;
|
|
@@ -54,14 +57,19 @@ export declare function loadStoredConfig(options?: {
|
|
|
54
57
|
}): StoredConfig;
|
|
55
58
|
export declare function listEnvironmentProfiles(): Record<string, StoredEnvironmentProfile>;
|
|
56
59
|
export declare function getEnvironmentProfile(name: string): StoredEnvironmentProfile | null;
|
|
57
|
-
export declare
|
|
60
|
+
export declare const DEFAULT_ENV_NAME = "default";
|
|
61
|
+
export declare function getActiveEnvironmentName(): string;
|
|
62
|
+
export declare function setActiveEnvironmentName(name: string): void;
|
|
63
|
+
export declare function saveEnvironmentProfile(name: string, profile: StoredEnvironmentProfile, options?: {
|
|
64
|
+
activate?: boolean;
|
|
65
|
+
}): void;
|
|
58
66
|
export declare function removeEnvironmentProfile(name: string): boolean;
|
|
59
67
|
export declare function buildAuthValidationKey(runtime: RuntimeConfigOptions): string;
|
|
60
68
|
export declare function readAuthValidationState(key?: string): AuthValidationState;
|
|
61
69
|
export declare function saveAuthValidationState(state: AuthValidationState): void;
|
|
62
70
|
export declare function clearAuthValidationState(key?: string): void;
|
|
63
|
-
export declare const DEFAULT_ENV_NAME = "default";
|
|
64
71
|
export declare function resolveRuntimeConfig(options?: RuntimeConfigOptions): {
|
|
72
|
+
production?: true | undefined;
|
|
65
73
|
baseUrl: string;
|
|
66
74
|
instance: string;
|
|
67
75
|
token: string;
|