@highstate/backend 0.7.2 → 0.7.3
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/dist/{index.mjs → index.js} +1254 -915
- package/dist/library/source-resolution-worker.js +55 -0
- package/dist/library/worker/main.js +207 -0
- package/dist/{terminal-CqIsctlZ.mjs → library-BW5oPM7V.js} +210 -87
- package/dist/shared/index.js +6 -0
- package/dist/utils-ByadNcv4.js +102 -0
- package/package.json +14 -18
- package/src/common/index.ts +3 -0
- package/src/common/local.ts +22 -0
- package/src/common/pulumi.ts +230 -0
- package/src/common/utils.ts +137 -0
- package/src/config.ts +40 -0
- package/src/index.ts +6 -0
- package/src/library/abstractions.ts +83 -0
- package/src/library/factory.ts +20 -0
- package/src/library/index.ts +2 -0
- package/src/library/local.ts +404 -0
- package/src/library/source-resolution-worker.ts +96 -0
- package/src/library/worker/evaluator.ts +119 -0
- package/src/library/worker/loader.ts +93 -0
- package/src/library/worker/main.ts +82 -0
- package/src/library/worker/protocol.ts +38 -0
- package/src/orchestrator/index.ts +1 -0
- package/src/orchestrator/manager.ts +165 -0
- package/src/orchestrator/operation-workset.ts +483 -0
- package/src/orchestrator/operation.ts +647 -0
- package/src/preferences/shared.ts +1 -0
- package/src/project/abstractions.ts +89 -0
- package/src/project/factory.ts +11 -0
- package/src/project/index.ts +4 -0
- package/src/project/local.ts +412 -0
- package/src/project/lock.ts +39 -0
- package/src/project/manager.ts +374 -0
- package/src/runner/abstractions.ts +146 -0
- package/src/runner/factory.ts +22 -0
- package/src/runner/index.ts +2 -0
- package/src/runner/local.ts +698 -0
- package/src/secret/abstractions.ts +59 -0
- package/src/secret/factory.ts +22 -0
- package/src/secret/index.ts +2 -0
- package/src/secret/local.ts +152 -0
- package/src/services.ts +133 -0
- package/src/shared/index.ts +10 -0
- package/src/shared/library.ts +77 -0
- package/src/shared/operation.ts +85 -0
- package/src/shared/project.ts +62 -0
- package/src/shared/resolvers/graph-resolver.ts +111 -0
- package/src/shared/resolvers/input-hash.ts +77 -0
- package/src/shared/resolvers/input.ts +314 -0
- package/src/shared/resolvers/registry.ts +10 -0
- package/src/shared/resolvers/validation.ts +94 -0
- package/src/shared/state.ts +262 -0
- package/src/shared/terminal.ts +13 -0
- package/src/state/abstractions.ts +222 -0
- package/src/state/factory.ts +22 -0
- package/src/state/index.ts +3 -0
- package/src/state/local.ts +605 -0
- package/src/state/manager.ts +33 -0
- package/src/terminal/docker.ts +90 -0
- package/src/terminal/factory.ts +20 -0
- package/src/terminal/index.ts +3 -0
- package/src/terminal/manager.ts +330 -0
- package/src/terminal/run.sh.ts +37 -0
- package/src/terminal/shared.ts +50 -0
- package/src/workspace/abstractions.ts +41 -0
- package/src/workspace/factory.ts +14 -0
- package/src/workspace/index.ts +2 -0
- package/src/workspace/local.ts +54 -0
- package/dist/index.d.ts +0 -760
- package/dist/library/worker/main.mjs +0 -164
- package/dist/runner/source-resolution-worker.mjs +0 -22
- package/dist/shared/index.d.ts +0 -85
- package/dist/shared/index.mjs +0 -54
- package/dist/terminal-Cm2WqcyB.d.ts +0 -1589
@@ -0,0 +1,483 @@
|
|
1
|
+
import type { LibraryBackend } from "../library"
|
2
|
+
import type { ProjectBackend } from "../project"
|
3
|
+
import type { StateBackend, StateManager } from "../state"
|
4
|
+
import type { Logger } from "pino"
|
5
|
+
import { isUnitModel, type ComponentModel, type InstanceModel } from "@highstate/contract"
|
6
|
+
import {
|
7
|
+
applyPartialInstanceState,
|
8
|
+
createInputHashResolver,
|
9
|
+
createInputResolver,
|
10
|
+
createInstanceState,
|
11
|
+
createInstanceStatePatch,
|
12
|
+
type GraphResolver,
|
13
|
+
type InputHashResolverInput,
|
14
|
+
type InputHashResolverOutput,
|
15
|
+
type InputResolverInput,
|
16
|
+
type InputResolverOutput,
|
17
|
+
type InstanceState,
|
18
|
+
type InstanceStateUpdate,
|
19
|
+
type LibraryModel,
|
20
|
+
type ProjectOperation,
|
21
|
+
type ResolvedInstanceInput,
|
22
|
+
} from "../shared"
|
23
|
+
|
24
|
+
export class OperationWorkset {
|
25
|
+
private readonly affectedInstanceIdSet = new Set<string>()
|
26
|
+
private readonly instanceMap = new Map<string, InstanceModel>()
|
27
|
+
private readonly instanceChildrenMap = new Map<string, InstanceModel[]>()
|
28
|
+
|
29
|
+
private readonly initialStateMap = new Map<string, InstanceState>()
|
30
|
+
private readonly stateMap = new Map<string, InstanceState>()
|
31
|
+
private readonly dependentStateMap = new Map<string, InstanceState[]>()
|
32
|
+
private readonly stateChildIdMap = new Map<string, string[]>()
|
33
|
+
|
34
|
+
private readonly unitSourceHashMap = new Map<string, string>()
|
35
|
+
|
36
|
+
private inputResolver!: GraphResolver<InputResolverOutput>
|
37
|
+
private readonly inputResolverInputs = new Map<string, InputResolverInput>()
|
38
|
+
private readonly inputResolverPromiseCache = new Map<string, Promise<InputResolverOutput>>()
|
39
|
+
|
40
|
+
private inputHashResolver!: GraphResolver<InputHashResolverOutput>
|
41
|
+
private readonly inputHashResolverInputs = new Map<string, InputHashResolverInput>()
|
42
|
+
|
43
|
+
private readonly inputHashResolverPromiseCache = new Map<
|
44
|
+
string,
|
45
|
+
Promise<InputHashResolverOutput>
|
46
|
+
>()
|
47
|
+
|
48
|
+
public readonly resolvedInstanceInputs = new Map<
|
49
|
+
string,
|
50
|
+
Record<string, ResolvedInstanceInput[]>
|
51
|
+
>()
|
52
|
+
|
53
|
+
private constructor(
|
54
|
+
public readonly operation: ProjectOperation,
|
55
|
+
public readonly library: LibraryModel,
|
56
|
+
private readonly stateManager: StateManager,
|
57
|
+
private readonly logger: Logger,
|
58
|
+
) {}
|
59
|
+
|
60
|
+
public getInstance(instanceId: string): InstanceModel {
|
61
|
+
const instance = this.instanceMap.get(instanceId)
|
62
|
+
if (!instance) {
|
63
|
+
throw new Error(`Instance with ID ${instanceId} not found in the operation workset`)
|
64
|
+
}
|
65
|
+
|
66
|
+
return instance
|
67
|
+
}
|
68
|
+
|
69
|
+
public isAffected(instanceId: string): boolean {
|
70
|
+
return this.affectedInstanceIdSet.has(instanceId)
|
71
|
+
}
|
72
|
+
|
73
|
+
public updateState(update: InstanceStateUpdate): InstanceState {
|
74
|
+
const finalState = applyPartialInstanceState(this.stateMap, update)
|
75
|
+
this.stateManager.emitStatePatch(this.operation.projectId, createInstanceStatePatch(update))
|
76
|
+
|
77
|
+
if (finalState.parentId) {
|
78
|
+
this.recalculateCompositeState(finalState.parentId)
|
79
|
+
}
|
80
|
+
|
81
|
+
return finalState
|
82
|
+
}
|
83
|
+
|
84
|
+
public setState(state: InstanceState): void {
|
85
|
+
this.stateMap.set(state.id, state)
|
86
|
+
this.initialStateMap.set(state.id, state)
|
87
|
+
|
88
|
+
if (state.parentId) {
|
89
|
+
let children = this.stateChildIdMap.get(state.parentId)
|
90
|
+
if (!children) {
|
91
|
+
children = []
|
92
|
+
this.stateChildIdMap.set(state.parentId, children)
|
93
|
+
}
|
94
|
+
|
95
|
+
children.push(state.id)
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
public restoreInitialStatus(instanceId: string): void {
|
100
|
+
const state = this.stateMap.get(instanceId)
|
101
|
+
const initialState = this.initialStateMap.get(instanceId)
|
102
|
+
|
103
|
+
if (!state || !initialState) {
|
104
|
+
this.logger.warn(
|
105
|
+
`cannot reset status for instance "${instanceId}" because it is not in the state map`,
|
106
|
+
)
|
107
|
+
return
|
108
|
+
}
|
109
|
+
|
110
|
+
this.stateMap.set(instanceId, { ...initialState, status: initialState.status })
|
111
|
+
}
|
112
|
+
|
113
|
+
public emitAffectedInitialStates(): void {
|
114
|
+
for (const state of this.initialStateMap.values()) {
|
115
|
+
if (this.affectedInstanceIdSet.has(state.id)) {
|
116
|
+
this.stateManager.emitStatePatch(this.operation.projectId, state)
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
public getAffectedCompositeChildren(instanceId: string): InstanceModel[] {
|
122
|
+
const children = this.instanceChildrenMap.get(instanceId)
|
123
|
+
if (!children) {
|
124
|
+
return []
|
125
|
+
}
|
126
|
+
|
127
|
+
return children.filter(child => this.affectedInstanceIdSet.has(child.id))
|
128
|
+
}
|
129
|
+
|
130
|
+
public getState(instanceId: string): InstanceState | undefined {
|
131
|
+
return this.stateMap.get(instanceId)
|
132
|
+
}
|
133
|
+
|
134
|
+
public getDependentStates(instanceId: string): InstanceState[] {
|
135
|
+
return this.dependentStateMap.get(instanceId) ?? []
|
136
|
+
}
|
137
|
+
|
138
|
+
private recalculateCompositeState(instanceId: string): void {
|
139
|
+
const state = this.stateMap.get(instanceId) ?? createInstanceState(instanceId)
|
140
|
+
let currentResourceCount = 0
|
141
|
+
let totalResourceCount = 0
|
142
|
+
|
143
|
+
const children = this.stateChildIdMap.get(instanceId) ?? []
|
144
|
+
for (const childId of children) {
|
145
|
+
const child = this.stateMap.get(childId)
|
146
|
+
|
147
|
+
if (child?.currentResourceCount) {
|
148
|
+
currentResourceCount += child.currentResourceCount
|
149
|
+
}
|
150
|
+
|
151
|
+
if (child?.totalResourceCount) {
|
152
|
+
totalResourceCount += child.totalResourceCount
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
const updatedState = {
|
157
|
+
...state,
|
158
|
+
currentResourceCount,
|
159
|
+
totalResourceCount,
|
160
|
+
}
|
161
|
+
|
162
|
+
this.stateMap.set(instanceId, updatedState)
|
163
|
+
this.stateManager.emitStatePatch(this.operation.projectId, updatedState)
|
164
|
+
|
165
|
+
if (state.parentId) {
|
166
|
+
this.recalculateCompositeState(state.parentId)
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
private addInstance(instance: InstanceModel): void {
|
171
|
+
if (this.instanceMap.has(instance.id)) {
|
172
|
+
throw new Error(`Found multiple instances with the same ID: ${instance.id}`)
|
173
|
+
}
|
174
|
+
|
175
|
+
if (!(instance.type in this.library.components)) {
|
176
|
+
this.logger.warn(
|
177
|
+
`ignoring instance "${instance.id}" because its type "${instance.type}" is not in the library`,
|
178
|
+
)
|
179
|
+
return
|
180
|
+
}
|
181
|
+
|
182
|
+
this.instanceMap.set(instance.id, instance)
|
183
|
+
|
184
|
+
if (instance.parentId) {
|
185
|
+
let children = this.instanceChildrenMap.get(instance.parentId)
|
186
|
+
if (!children) {
|
187
|
+
children = []
|
188
|
+
this.instanceChildrenMap.set(instance.parentId, children)
|
189
|
+
}
|
190
|
+
|
191
|
+
children.push(instance)
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
private async extendForUpdate(): Promise<void> {
|
196
|
+
const traverse = async (instanceId: string) => {
|
197
|
+
if (this.affectedInstanceIdSet.has(instanceId)) {
|
198
|
+
return
|
199
|
+
}
|
200
|
+
|
201
|
+
const instance = this.instanceMap.get(instanceId)
|
202
|
+
if (!instance) {
|
203
|
+
return
|
204
|
+
}
|
205
|
+
|
206
|
+
const instanceInputs = this.resolvedInstanceInputs.get(instance.id) ?? {}
|
207
|
+
|
208
|
+
for (const inputs of Object.values(instanceInputs)) {
|
209
|
+
for (const input of inputs) {
|
210
|
+
await traverse(input.input.instanceId)
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
const state = this.stateMap.get(instance.id)
|
215
|
+
const { inputHash: expectedInputHash } = await this.inputHashResolver(instance.id)
|
216
|
+
|
217
|
+
if (this.operation.options.forceUpdateDependencies) {
|
218
|
+
this.affectedInstanceIdSet.add(instanceId)
|
219
|
+
return
|
220
|
+
}
|
221
|
+
|
222
|
+
if (state?.status !== "created" || state.inputHash !== expectedInputHash) {
|
223
|
+
this.affectedInstanceIdSet.add(instanceId)
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
// 1. extend affected instance IDs with their not-created or not-up-to-date dependencies (only for "update" operations)
|
228
|
+
for (const instanceId of this.operation.instanceIds) {
|
229
|
+
if (this.operation.type === "update") {
|
230
|
+
await traverse(instanceId)
|
231
|
+
}
|
232
|
+
|
233
|
+
this.affectedInstanceIdSet.add(instanceId)
|
234
|
+
}
|
235
|
+
|
236
|
+
// 2. extend affected instance IDs with the children of the affected composite instances
|
237
|
+
const compositeInstanceQueue = Array.from(this.affectedInstanceIdSet)
|
238
|
+
while (compositeInstanceQueue.length > 0) {
|
239
|
+
const childId = compositeInstanceQueue.pop()!
|
240
|
+
const children = this.instanceChildrenMap.get(childId) ?? []
|
241
|
+
|
242
|
+
for (const child of children) {
|
243
|
+
compositeInstanceQueue.push(child.id)
|
244
|
+
this.affectedInstanceIdSet.add(child.id)
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
// 3. detect composite instance children and include their parents (recursively)
|
249
|
+
for (const instanceId of this.affectedInstanceIdSet) {
|
250
|
+
let instance = this.instanceMap.get(instanceId)
|
251
|
+
while (instance?.parentId) {
|
252
|
+
this.affectedInstanceIdSet.add(instance.parentId)
|
253
|
+
instance = this.instanceMap.get(instance.parentId)
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
this.operation.affectedInstanceIds = Array.from(this.affectedInstanceIdSet)
|
258
|
+
}
|
259
|
+
|
260
|
+
private extendForDestroy() {
|
261
|
+
const traverse = (instanceKey: string) => {
|
262
|
+
if (this.affectedInstanceIdSet.has(instanceKey)) {
|
263
|
+
return
|
264
|
+
}
|
265
|
+
|
266
|
+
const state = this.stateMap.get(instanceKey)
|
267
|
+
if (!state || state.status === "not_created") {
|
268
|
+
return
|
269
|
+
}
|
270
|
+
|
271
|
+
const dependents = this.dependentStateMap.get(instanceKey) ?? []
|
272
|
+
|
273
|
+
for (const dependent of dependents) {
|
274
|
+
traverse(dependent.id)
|
275
|
+
this.affectedInstanceIdSet.add(instanceKey)
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
// 1. extend affected instance IDs with their created dependents (if not forbidden by the operation options)
|
280
|
+
for (const instanceId of this.operation.instanceIds) {
|
281
|
+
const instance = this.instanceMap.get(instanceId)
|
282
|
+
if (!instance) {
|
283
|
+
throw new Error(`Instance not found: ${instanceId}`)
|
284
|
+
}
|
285
|
+
|
286
|
+
if (this.operation.options.destroyDependentInstances) {
|
287
|
+
traverse(instance.id)
|
288
|
+
}
|
289
|
+
|
290
|
+
this.affectedInstanceIdSet.add(instanceId)
|
291
|
+
}
|
292
|
+
|
293
|
+
// 2. extend affected instance IDs with the children of the affected composite instances
|
294
|
+
const compositeInstanceQueue = Array.from(this.affectedInstanceIdSet)
|
295
|
+
while (compositeInstanceQueue.length > 0) {
|
296
|
+
const childId = compositeInstanceQueue.pop()!
|
297
|
+
const children = this.stateChildIdMap.get(childId) ?? []
|
298
|
+
|
299
|
+
for (const child of children) {
|
300
|
+
compositeInstanceQueue.push(child)
|
301
|
+
this.affectedInstanceIdSet.add(child)
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
// 3. detect composite instance children and include their parents (recursively)
|
306
|
+
for (const instanceId of this.affectedInstanceIdSet) {
|
307
|
+
let state = this.stateMap.get(instanceId)
|
308
|
+
while (state?.parentId) {
|
309
|
+
this.affectedInstanceIdSet.add(state.parentId)
|
310
|
+
state = this.stateMap.get(state.parentId)
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
this.operation.affectedInstanceIds = Array.from(this.affectedInstanceIdSet)
|
315
|
+
}
|
316
|
+
|
317
|
+
private getSourceHashIfApplicable(
|
318
|
+
instance: InstanceModel,
|
319
|
+
component: ComponentModel,
|
320
|
+
): string | undefined {
|
321
|
+
if (isUnitModel(component)) {
|
322
|
+
return this.unitSourceHashMap.get(instance.type)
|
323
|
+
}
|
324
|
+
|
325
|
+
return undefined
|
326
|
+
}
|
327
|
+
|
328
|
+
public async getUpToDateInputHash(instance: InstanceModel): Promise<string> {
|
329
|
+
const component = this.library.components[instance.type]
|
330
|
+
|
331
|
+
this.inputHashResolverInputs.set(instance.id, {
|
332
|
+
instance,
|
333
|
+
component,
|
334
|
+
resolvedInputs: this.resolvedInstanceInputs.get(instance.id)!,
|
335
|
+
state: this.stateMap.get(instance.id),
|
336
|
+
sourceHash: this.getSourceHashIfApplicable(instance, component),
|
337
|
+
})
|
338
|
+
|
339
|
+
this.inputHashResolverPromiseCache.delete(instance.id)
|
340
|
+
|
341
|
+
const { inputHash } = await this.inputHashResolver(instance.id)
|
342
|
+
return inputHash
|
343
|
+
}
|
344
|
+
|
345
|
+
public getLockInstanceIds(): string[] {
|
346
|
+
const instanceIds = new Set<string>(this.operation.affectedInstanceIds)
|
347
|
+
|
348
|
+
// enrich with the parent IDs of the affected instances in order to lock and update parent states
|
349
|
+
for (const instanceId of this.operation.affectedInstanceIds) {
|
350
|
+
const instance = this.getInstance(instanceId)
|
351
|
+
|
352
|
+
if (instance.parentId) {
|
353
|
+
instanceIds.add(instance.parentId)
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
return Array.from(instanceIds)
|
358
|
+
}
|
359
|
+
|
360
|
+
public static async load(
|
361
|
+
operation: ProjectOperation,
|
362
|
+
projectBackend: ProjectBackend,
|
363
|
+
libraryBackend: LibraryBackend,
|
364
|
+
stateBackend: StateBackend,
|
365
|
+
stateManager: StateManager,
|
366
|
+
logger: Logger,
|
367
|
+
signal: AbortSignal,
|
368
|
+
): Promise<OperationWorkset> {
|
369
|
+
const [library, unitSources, project, compositeInstances, states] = await Promise.all([
|
370
|
+
libraryBackend.loadLibrary(signal),
|
371
|
+
libraryBackend.getResolvedUnitSources(),
|
372
|
+
projectBackend.getProject(operation.projectId, signal),
|
373
|
+
stateBackend.getCompositeInstances(operation.projectId, signal),
|
374
|
+
stateBackend.getAllInstanceStates(operation.projectId, signal),
|
375
|
+
])
|
376
|
+
|
377
|
+
const workset = new OperationWorkset(
|
378
|
+
operation,
|
379
|
+
library,
|
380
|
+
stateManager,
|
381
|
+
logger.child({ operationId: operation.id, service: "OperationWorkset" }),
|
382
|
+
)
|
383
|
+
|
384
|
+
for (const unitSource of unitSources) {
|
385
|
+
workset.unitSourceHashMap.set(unitSource.unitType, unitSource.sourceHash)
|
386
|
+
}
|
387
|
+
|
388
|
+
// prepare instances
|
389
|
+
for (const instance of project.instances) {
|
390
|
+
workset.addInstance(instance)
|
391
|
+
}
|
392
|
+
|
393
|
+
for (const instance of compositeInstances) {
|
394
|
+
const worksetInstance = workset.instanceMap.get(instance.instance.id)
|
395
|
+
|
396
|
+
if (worksetInstance) {
|
397
|
+
worksetInstance.outputs = instance.instance.outputs
|
398
|
+
worksetInstance.resolvedOutputs = instance.instance.resolvedOutputs
|
399
|
+
} else {
|
400
|
+
workset.addInstance(instance.instance)
|
401
|
+
}
|
402
|
+
|
403
|
+
for (const child of instance.children) {
|
404
|
+
workset.addInstance(child)
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
for (const state of states) {
|
409
|
+
if (!workset.instanceMap.has(state.id)) {
|
410
|
+
workset.logger.warn(
|
411
|
+
`ignoring instance "${state.id}" from state because it is not in the project or is not a part of a composite instance`,
|
412
|
+
)
|
413
|
+
continue
|
414
|
+
}
|
415
|
+
|
416
|
+
workset.setState(state)
|
417
|
+
}
|
418
|
+
|
419
|
+
// prepare input resolver
|
420
|
+
for (const instance of workset.instanceMap.values()) {
|
421
|
+
workset.inputResolverInputs.set(`instance:${instance.id}`, {
|
422
|
+
kind: "instance",
|
423
|
+
instance,
|
424
|
+
component: library.components[instance.type],
|
425
|
+
})
|
426
|
+
}
|
427
|
+
|
428
|
+
for (const hub of project.hubs) {
|
429
|
+
workset.inputResolverInputs.set(`hub:${hub.id}`, { kind: "hub", hub })
|
430
|
+
}
|
431
|
+
|
432
|
+
workset.inputResolver = createInputResolver(
|
433
|
+
//
|
434
|
+
workset.inputResolverInputs,
|
435
|
+
logger,
|
436
|
+
{ promiseCache: workset.inputResolverPromiseCache },
|
437
|
+
)
|
438
|
+
|
439
|
+
// resolve inputs for all instances and pass outputs to input hash resolver
|
440
|
+
for (const instance of workset.instanceMap.values()) {
|
441
|
+
const output = await workset.inputResolver(`instance:${instance.id}`)
|
442
|
+
if (output.kind !== "instance") {
|
443
|
+
throw new Error("Unexpected output kind")
|
444
|
+
}
|
445
|
+
|
446
|
+
workset.resolvedInstanceInputs.set(instance.id, output.resolvedInputs)
|
447
|
+
|
448
|
+
const component = workset.library.components[instance.type]
|
449
|
+
|
450
|
+
workset.inputHashResolverInputs.set(instance.id, {
|
451
|
+
instance,
|
452
|
+
component,
|
453
|
+
resolvedInputs: output.resolvedInputs,
|
454
|
+
state: workset.stateMap.get(instance.id),
|
455
|
+
sourceHash: workset.getSourceHashIfApplicable(instance, component),
|
456
|
+
})
|
457
|
+
}
|
458
|
+
|
459
|
+
// prepare input hash resolver
|
460
|
+
workset.inputHashResolver = createInputHashResolver(
|
461
|
+
//
|
462
|
+
workset.inputHashResolverInputs,
|
463
|
+
logger,
|
464
|
+
{ promiseCache: workset.inputHashResolverPromiseCache },
|
465
|
+
)
|
466
|
+
|
467
|
+
switch (operation.type) {
|
468
|
+
case "update":
|
469
|
+
case "preview":
|
470
|
+
case "refresh":
|
471
|
+
await workset.extendForUpdate()
|
472
|
+
break
|
473
|
+
case "recreate":
|
474
|
+
workset.extendForDestroy()
|
475
|
+
break
|
476
|
+
case "destroy":
|
477
|
+
workset.extendForDestroy()
|
478
|
+
break
|
479
|
+
}
|
480
|
+
|
481
|
+
return workset
|
482
|
+
}
|
483
|
+
}
|