@highstate/backend 0.2.0 → 0.2.1
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.d.ts +508 -0
- package/dist/index.mjs +832 -0
- package/dist/library/workers/evaluator.mjs +43 -0
- package/dist/library/workers/loader.mjs +11 -0
- package/dist/shared-B55c8XjT.mjs +36 -0
- package/package.json +3 -3
package/dist/index.d.ts
ADDED
@@ -0,0 +1,508 @@
|
|
1
|
+
import { Stack } from '@pulumi/pulumi/automation';
|
2
|
+
import { z } from 'zod';
|
3
|
+
import { ComponentModel, Entity, UnitRegistration, UnitSource } from '@highstate/contract';
|
4
|
+
|
5
|
+
declare class LocalPulumiProjectHost {
|
6
|
+
private lock;
|
7
|
+
private password;
|
8
|
+
hasPassword(): boolean;
|
9
|
+
setPassword(password: string): void;
|
10
|
+
runInline<T>(projectName: string, stackName: string, program: () => Promise<void> | Promise<Record<string, unknown>>, fn: (stack: Stack) => Promise<T>): Promise<T>;
|
11
|
+
runLocal<T>(projectName: string, stackName: string, programPathResolver: () => Promise<string> | string, fn: (stack: Stack) => Promise<T>): Promise<T>;
|
12
|
+
}
|
13
|
+
|
14
|
+
declare const instanceStatusSchema: z.ZodEnum<["not_created", "updating", "destroying", "refreshing", "created", "error"]>;
|
15
|
+
declare const instanceStateSchema: z.ZodObject<{
|
16
|
+
key: z.ZodString;
|
17
|
+
parentKey: z.ZodOptional<z.ZodString>;
|
18
|
+
status: z.ZodEnum<["not_created", "updating", "destroying", "refreshing", "created", "error"]>;
|
19
|
+
resources: z.ZodNumber;
|
20
|
+
totalResources: z.ZodNumber;
|
21
|
+
error: z.ZodOptional<z.ZodString>;
|
22
|
+
message: z.ZodOptional<z.ZodString>;
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
24
|
+
key: string;
|
25
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
26
|
+
resources: number;
|
27
|
+
totalResources: number;
|
28
|
+
error?: string | undefined;
|
29
|
+
parentKey?: string | undefined;
|
30
|
+
message?: string | undefined;
|
31
|
+
}, {
|
32
|
+
key: string;
|
33
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
34
|
+
resources: number;
|
35
|
+
totalResources: number;
|
36
|
+
error?: string | undefined;
|
37
|
+
parentKey?: string | undefined;
|
38
|
+
message?: string | undefined;
|
39
|
+
}>;
|
40
|
+
declare const operationType: z.ZodEnum<["update", "destroy", "recreate", "refresh"]>;
|
41
|
+
declare const projectOperation: z.ZodObject<{
|
42
|
+
type: z.ZodEnum<["update", "destroy", "recreate", "refresh"]>;
|
43
|
+
instanceIds: z.ZodArray<z.ZodString, "many">;
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
45
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
46
|
+
instanceIds: string[];
|
47
|
+
}, {
|
48
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
49
|
+
instanceIds: string[];
|
50
|
+
}>;
|
51
|
+
declare const projectStateSchema: z.ZodObject<{
|
52
|
+
currentOperation: z.ZodOptional<z.ZodObject<{
|
53
|
+
type: z.ZodEnum<["update", "destroy", "recreate", "refresh"]>;
|
54
|
+
instanceIds: z.ZodArray<z.ZodString, "many">;
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
56
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
57
|
+
instanceIds: string[];
|
58
|
+
}, {
|
59
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
60
|
+
instanceIds: string[];
|
61
|
+
}>>;
|
62
|
+
instances: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodObject<{
|
63
|
+
key: z.ZodString;
|
64
|
+
parentKey: z.ZodOptional<z.ZodString>;
|
65
|
+
status: z.ZodEnum<["not_created", "updating", "destroying", "refreshing", "created", "error"]>;
|
66
|
+
resources: z.ZodNumber;
|
67
|
+
totalResources: z.ZodNumber;
|
68
|
+
error: z.ZodOptional<z.ZodString>;
|
69
|
+
message: z.ZodOptional<z.ZodString>;
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
71
|
+
key: string;
|
72
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
73
|
+
resources: number;
|
74
|
+
totalResources: number;
|
75
|
+
error?: string | undefined;
|
76
|
+
parentKey?: string | undefined;
|
77
|
+
message?: string | undefined;
|
78
|
+
}, {
|
79
|
+
key: string;
|
80
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
81
|
+
resources: number;
|
82
|
+
totalResources: number;
|
83
|
+
error?: string | undefined;
|
84
|
+
parentKey?: string | undefined;
|
85
|
+
message?: string | undefined;
|
86
|
+
}>>>;
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
88
|
+
instances: Record<string, {
|
89
|
+
key: string;
|
90
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
91
|
+
resources: number;
|
92
|
+
totalResources: number;
|
93
|
+
error?: string | undefined;
|
94
|
+
parentKey?: string | undefined;
|
95
|
+
message?: string | undefined;
|
96
|
+
} | undefined>;
|
97
|
+
currentOperation?: {
|
98
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
99
|
+
instanceIds: string[];
|
100
|
+
} | undefined;
|
101
|
+
}, {
|
102
|
+
instances: Record<string, {
|
103
|
+
key: string;
|
104
|
+
status: "not_created" | "updating" | "destroying" | "refreshing" | "created" | "error";
|
105
|
+
resources: number;
|
106
|
+
totalResources: number;
|
107
|
+
error?: string | undefined;
|
108
|
+
parentKey?: string | undefined;
|
109
|
+
message?: string | undefined;
|
110
|
+
} | undefined>;
|
111
|
+
currentOperation?: {
|
112
|
+
type: "update" | "destroy" | "recreate" | "refresh";
|
113
|
+
instanceIds: string[];
|
114
|
+
} | undefined;
|
115
|
+
}>;
|
116
|
+
declare const positionSchema: z.ZodObject<{
|
117
|
+
x: z.ZodNumber;
|
118
|
+
y: z.ZodNumber;
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
120
|
+
x: number;
|
121
|
+
y: number;
|
122
|
+
}, {
|
123
|
+
x: number;
|
124
|
+
y: number;
|
125
|
+
}>;
|
126
|
+
declare const outputRefSchema: z.ZodObject<{
|
127
|
+
instanceId: z.ZodString;
|
128
|
+
output: z.ZodString;
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
130
|
+
instanceId: string;
|
131
|
+
output: string;
|
132
|
+
}, {
|
133
|
+
instanceId: string;
|
134
|
+
output: string;
|
135
|
+
}>;
|
136
|
+
declare const instanceModelSchema: z.ZodObject<{
|
137
|
+
id: z.ZodString;
|
138
|
+
type: z.ZodString;
|
139
|
+
name: z.ZodString;
|
140
|
+
position: z.ZodObject<{
|
141
|
+
x: z.ZodNumber;
|
142
|
+
y: z.ZodNumber;
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
144
|
+
x: number;
|
145
|
+
y: number;
|
146
|
+
}, {
|
147
|
+
x: number;
|
148
|
+
y: number;
|
149
|
+
}>;
|
150
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
151
|
+
inputs: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
152
|
+
instanceId: z.ZodString;
|
153
|
+
output: z.ZodString;
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
155
|
+
instanceId: string;
|
156
|
+
output: string;
|
157
|
+
}, {
|
158
|
+
instanceId: string;
|
159
|
+
output: string;
|
160
|
+
}>, z.ZodArray<z.ZodObject<{
|
161
|
+
instanceId: z.ZodString;
|
162
|
+
output: z.ZodString;
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
164
|
+
instanceId: string;
|
165
|
+
output: string;
|
166
|
+
}, {
|
167
|
+
instanceId: string;
|
168
|
+
output: string;
|
169
|
+
}>, "many">]>>;
|
170
|
+
}, "strip", z.ZodTypeAny, {
|
171
|
+
name: string;
|
172
|
+
type: string;
|
173
|
+
id: string;
|
174
|
+
position: {
|
175
|
+
x: number;
|
176
|
+
y: number;
|
177
|
+
};
|
178
|
+
args: Record<string, any>;
|
179
|
+
inputs: Record<string, {
|
180
|
+
instanceId: string;
|
181
|
+
output: string;
|
182
|
+
} | {
|
183
|
+
instanceId: string;
|
184
|
+
output: string;
|
185
|
+
}[]>;
|
186
|
+
}, {
|
187
|
+
name: string;
|
188
|
+
type: string;
|
189
|
+
id: string;
|
190
|
+
position: {
|
191
|
+
x: number;
|
192
|
+
y: number;
|
193
|
+
};
|
194
|
+
args: Record<string, any>;
|
195
|
+
inputs: Record<string, {
|
196
|
+
instanceId: string;
|
197
|
+
output: string;
|
198
|
+
} | {
|
199
|
+
instanceId: string;
|
200
|
+
output: string;
|
201
|
+
}[]>;
|
202
|
+
}>;
|
203
|
+
type OperationType = z.infer<typeof operationType>;
|
204
|
+
type ProjectOperation = z.infer<typeof projectOperation>;
|
205
|
+
type InstanceStatus = z.infer<typeof instanceStatusSchema>;
|
206
|
+
type InstanceState = z.infer<typeof instanceStateSchema>;
|
207
|
+
type ProjectState = z.infer<typeof projectStateSchema>;
|
208
|
+
type Position = z.infer<typeof positionSchema>;
|
209
|
+
type OutputRef = z.infer<typeof outputRefSchema>;
|
210
|
+
type InstanceModel = z.infer<typeof instanceModelSchema>;
|
211
|
+
|
212
|
+
declare const stringArrayType: z.ZodEffects<z.ZodString, string[], string>;
|
213
|
+
|
214
|
+
declare function resolveMainLocalProject(projectPath: string | undefined, projectName: string | undefined): Promise<[projecPath: string, projectName: string]>;
|
215
|
+
|
216
|
+
declare class SecretAccessDeniedError extends Error {
|
217
|
+
constructor(projectId: string, key: string);
|
218
|
+
}
|
219
|
+
interface SecretBackend {
|
220
|
+
/**
|
221
|
+
* Get the secrets of the component.
|
222
|
+
*
|
223
|
+
* @param projectId The ID of the project.
|
224
|
+
* @param instanceKey The key of the component instance.
|
225
|
+
*
|
226
|
+
* @returns A record of secret key-value pairs or `null` if the secrets are not found.
|
227
|
+
* @throws {SecretAccessDeniedError} If access to the secrets is denied.
|
228
|
+
*/
|
229
|
+
get(projectId: string, instanceKey: string): Promise<Record<string, string>>;
|
230
|
+
/**
|
231
|
+
* Set the secrets of the component.
|
232
|
+
*
|
233
|
+
* @param projectId The ID of the project.
|
234
|
+
* @param instanceKey The key of the component instance.
|
235
|
+
* @param values The record of secret key-value pairs.
|
236
|
+
*
|
237
|
+
* @throws {SecretAccessDeniedError} If access to the secrets is denied.
|
238
|
+
*/
|
239
|
+
set(projectId: string, instanceKey: string, values: Record<string, string>): Promise<void>;
|
240
|
+
}
|
241
|
+
|
242
|
+
declare const secretBackendConfig: z.ZodObject<{
|
243
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH: z.ZodOptional<z.ZodString>;
|
244
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME: z.ZodOptional<z.ZodString>;
|
245
|
+
HIGHSTATE_BACKEND_SECRET_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
246
|
+
}, "strip", z.ZodTypeAny, {
|
247
|
+
HIGHSTATE_BACKEND_SECRET_TYPE: "local";
|
248
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH?: string | undefined;
|
249
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME?: string | undefined;
|
250
|
+
}, {
|
251
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH?: string | undefined;
|
252
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME?: string | undefined;
|
253
|
+
HIGHSTATE_BACKEND_SECRET_TYPE?: "local" | undefined;
|
254
|
+
}>;
|
255
|
+
declare function createSecretBackend(config: z.infer<typeof secretBackendConfig>, pulumiProjectHost: LocalPulumiProjectHost): Promise<SecretBackend>;
|
256
|
+
|
257
|
+
type LibraryModel = Readonly<{
|
258
|
+
components: Readonly<Record<string, ComponentModel>>;
|
259
|
+
entities: Readonly<Record<string, Entity>>;
|
260
|
+
}>;
|
261
|
+
type EvaluationInput = {
|
262
|
+
instanceId: string;
|
263
|
+
output: string;
|
264
|
+
};
|
265
|
+
type EvaluationInstance = {
|
266
|
+
type: string;
|
267
|
+
name: string;
|
268
|
+
args: Record<string, unknown>;
|
269
|
+
inputs: Record<string, EvaluationInput | EvaluationInput[]>;
|
270
|
+
};
|
271
|
+
interface LibraryBackend {
|
272
|
+
/**
|
273
|
+
* Loads the library.
|
274
|
+
*/
|
275
|
+
loadLibrary(): Promise<LibraryModel>;
|
276
|
+
/**
|
277
|
+
* Watches the library for changes.
|
278
|
+
* Returns an async iterable that emits the library whenever it changes.
|
279
|
+
*/
|
280
|
+
watchLibrary?(signal?: AbortSignal): AsyncIterable<LibraryModel>;
|
281
|
+
/**
|
282
|
+
* Evaluates the instances and returns the stack registrations.
|
283
|
+
*
|
284
|
+
* @param allInstances The all instances defined in the project.
|
285
|
+
* @param instanceIds The instance IDs to evaluate. If not provided, all instances are evaluated.
|
286
|
+
*/
|
287
|
+
evaluateInstances(allInstances: Record<string, EvaluationInstance>, instanceIds?: string[]): Promise<Record<string, UnitRegistration>>;
|
288
|
+
}
|
289
|
+
|
290
|
+
declare const libraryBackendConfig: z.ZodObject<{
|
291
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES: z.ZodDefault<z.ZodEffects<z.ZodString, string[], string>>;
|
292
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
293
|
+
}, "strip", z.ZodTypeAny, {
|
294
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES: string[];
|
295
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE: "local";
|
296
|
+
}, {
|
297
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES?: string | undefined;
|
298
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE?: "local" | undefined;
|
299
|
+
}>;
|
300
|
+
declare function createLibraryBackend(config: z.infer<typeof libraryBackendConfig>): Promise<LibraryBackend>;
|
301
|
+
|
302
|
+
declare const configSchema: z.ZodObject<{
|
303
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH: z.ZodOptional<z.ZodString>;
|
304
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME: z.ZodOptional<z.ZodString>;
|
305
|
+
HIGHSTATE_BACKEND_STATE_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
306
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH: z.ZodOptional<z.ZodString>;
|
307
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME: z.ZodOptional<z.ZodString>;
|
308
|
+
HIGHSTATE_BACKEND_SECRET_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
309
|
+
HIGHSTATE_BACKEND_PROJECT_BLUEPRINTS_DIR: z.ZodDefault<z.ZodString>;
|
310
|
+
HIGHSTATE_BACKEND_PROJECT_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
311
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES: z.ZodDefault<z.ZodEffects<z.ZodString, string[], string>>;
|
312
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
313
|
+
}, "strip", z.ZodTypeAny, {
|
314
|
+
HIGHSTATE_BACKEND_SECRET_TYPE: "local";
|
315
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES: string[];
|
316
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE: "local";
|
317
|
+
HIGHSTATE_BACKEND_PROJECT_BLUEPRINTS_DIR: string;
|
318
|
+
HIGHSTATE_BACKEND_PROJECT_TYPE: "local";
|
319
|
+
HIGHSTATE_BACKEND_STATE_TYPE: "local";
|
320
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH?: string | undefined;
|
321
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME?: string | undefined;
|
322
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH?: string | undefined;
|
323
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME?: string | undefined;
|
324
|
+
}, {
|
325
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_PATH?: string | undefined;
|
326
|
+
HIGHSTATE_BACKEND_SECRET_PROJECT_NAME?: string | undefined;
|
327
|
+
HIGHSTATE_BACKEND_SECRET_TYPE?: "local" | undefined;
|
328
|
+
HIGHSTATE_BACKEND_LIBRARY_LOCAL_MODULES?: string | undefined;
|
329
|
+
HIGHSTATE_BACKEND_LIBRARY_TYPE?: "local" | undefined;
|
330
|
+
HIGHSTATE_BACKEND_PROJECT_BLUEPRINTS_DIR?: string | undefined;
|
331
|
+
HIGHSTATE_BACKEND_PROJECT_TYPE?: "local" | undefined;
|
332
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH?: string | undefined;
|
333
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME?: string | undefined;
|
334
|
+
HIGHSTATE_BACKEND_STATE_TYPE?: "local" | undefined;
|
335
|
+
}>;
|
336
|
+
type Config = z.infer<typeof configSchema>;
|
337
|
+
declare function loadConfig(env?: NodeJS.ProcessEnv, useDotenv?: boolean): Promise<Config>;
|
338
|
+
|
339
|
+
interface ProjectBackend {
|
340
|
+
getInstances(projectId: string): Promise<Record<string, InstanceModel>>;
|
341
|
+
updateInstance(projectId: string, instance: InstanceModel): Promise<void>;
|
342
|
+
deleteInstance(projectId: string, instanceId: string): Promise<void>;
|
343
|
+
}
|
344
|
+
|
345
|
+
type UnitBaseOptions = {
|
346
|
+
/**
|
347
|
+
* The name of the project to run.
|
348
|
+
*/
|
349
|
+
projectName: string;
|
350
|
+
/**
|
351
|
+
* The name of the stack to run.
|
352
|
+
*/
|
353
|
+
stackName: string;
|
354
|
+
/**
|
355
|
+
* The signal to abort the operation.
|
356
|
+
*/
|
357
|
+
signal?: AbortSignal;
|
358
|
+
};
|
359
|
+
type UnitRunOptions = UnitBaseOptions & {
|
360
|
+
/**
|
361
|
+
* The source of the unit.
|
362
|
+
*/
|
363
|
+
source: UnitSource;
|
364
|
+
};
|
365
|
+
type UnitUpdateOptions = UnitRunOptions & {
|
366
|
+
/**
|
367
|
+
* The configuration of the stack.
|
368
|
+
*/
|
369
|
+
config: Record<string, string>;
|
370
|
+
};
|
371
|
+
type UnitWatchOptions = UnitBaseOptions & {
|
372
|
+
/**
|
373
|
+
* The final statuses to watch.
|
374
|
+
* If the unit reaches one of these statuses, it should return the current state and exit.
|
375
|
+
*/
|
376
|
+
finalStatuses: InstanceStatus[];
|
377
|
+
};
|
378
|
+
interface RunnerBackend {
|
379
|
+
/**
|
380
|
+
* Watches the unit state.
|
381
|
+
*/
|
382
|
+
watch(options: UnitWatchOptions): AsyncIterable<InstanceState>;
|
383
|
+
/**
|
384
|
+
* Updates the unit.
|
385
|
+
*
|
386
|
+
* The operation must only be aborted by the signal, not even when the connection is closed.
|
387
|
+
* If the unit is already updating, it should exit immediately.
|
388
|
+
* If the unit is running another operation, it should throw an error.
|
389
|
+
*/
|
390
|
+
update(options: UnitUpdateOptions): Promise<void>;
|
391
|
+
/**
|
392
|
+
* Destroys the unit.
|
393
|
+
*
|
394
|
+
* The operation must only be aborted by the signal, not even when the connection is closed.
|
395
|
+
* If the unit is not created, it should exit immediately.
|
396
|
+
* If the unit is running another operation, it should throw an error.
|
397
|
+
*/
|
398
|
+
destroy(options: UnitRunOptions): Promise<void>;
|
399
|
+
/**
|
400
|
+
* Refreshes the unit.
|
401
|
+
*
|
402
|
+
* The operation must only be aborted by the signal, not even when the connection is closed.
|
403
|
+
* If the unit is not created, it should exit immediately.
|
404
|
+
* If the unit is running another operation, it should throw an error.
|
405
|
+
* If the unit is not running, it should exit immediately.
|
406
|
+
*/
|
407
|
+
refresh(options: UnitRunOptions): Promise<void>;
|
408
|
+
}
|
409
|
+
|
410
|
+
interface StateBackend {
|
411
|
+
/**
|
412
|
+
* Gets all the component states for a project.
|
413
|
+
*
|
414
|
+
* @param projectId The ID of the project.
|
415
|
+
*/
|
416
|
+
get(projectId: string): Promise<ProjectState>;
|
417
|
+
/**
|
418
|
+
* Watch the component states for a project.
|
419
|
+
* Returns an async iterable that emits the component states.
|
420
|
+
*
|
421
|
+
* @param projectId The ID of the project.
|
422
|
+
*/
|
423
|
+
watch?(projectId: string): AsyncIterable<InstanceState>;
|
424
|
+
/**
|
425
|
+
* Updates the component states for a project.
|
426
|
+
* Use `null` to delete a component state.
|
427
|
+
*
|
428
|
+
* @param projectId The ID of the project.
|
429
|
+
* @param state The new project state.
|
430
|
+
*/
|
431
|
+
set(projectId: string, state: ProjectState): Promise<void>;
|
432
|
+
}
|
433
|
+
|
434
|
+
declare const stateBackendConfig: z.ZodObject<{
|
435
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH: z.ZodOptional<z.ZodString>;
|
436
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME: z.ZodOptional<z.ZodString>;
|
437
|
+
HIGHSTATE_BACKEND_STATE_TYPE: z.ZodDefault<z.ZodEnum<["local"]>>;
|
438
|
+
}, "strip", z.ZodTypeAny, {
|
439
|
+
HIGHSTATE_BACKEND_STATE_TYPE: "local";
|
440
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH?: string | undefined;
|
441
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME?: string | undefined;
|
442
|
+
}, {
|
443
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_PATH?: string | undefined;
|
444
|
+
HIGHSTATE_BACKEND_STATE_PROJECT_NAME?: string | undefined;
|
445
|
+
HIGHSTATE_BACKEND_STATE_TYPE?: "local" | undefined;
|
446
|
+
}>;
|
447
|
+
declare function createStateBackend(config: z.infer<typeof stateBackendConfig>, pulumiProjectHost: LocalPulumiProjectHost): Promise<StateBackend>;
|
448
|
+
|
449
|
+
declare class ProjectOperator {
|
450
|
+
private readonly projectId;
|
451
|
+
readonly state: ProjectState;
|
452
|
+
private readonly runnerBackend;
|
453
|
+
private readonly stateBackend;
|
454
|
+
private readonly libraryBackend;
|
455
|
+
private readonly projectBackend;
|
456
|
+
private readonly secretBackend;
|
457
|
+
constructor(projectId: string, state: ProjectState, runnerBackend: RunnerBackend, stateBackend: StateBackend, libraryBackend: LibraryBackend, projectBackend: ProjectBackend, secretBackend: SecretBackend);
|
458
|
+
private readonly unitPromises;
|
459
|
+
private readonly eventEmitter;
|
460
|
+
private debouncedUpdateState;
|
461
|
+
private abortController;
|
462
|
+
watchInstanceStates(signal?: AbortSignal): AsyncIterable<InstanceState>;
|
463
|
+
watchCurrentOperation(signal?: AbortSignal): AsyncIterable<ProjectOperation | undefined>;
|
464
|
+
/**
|
465
|
+
* Launches the project operation.
|
466
|
+
* Throws an error if the operation is already running.
|
467
|
+
*
|
468
|
+
* @param operation The operation to launch.
|
469
|
+
*/
|
470
|
+
launch(operation: ProjectOperation): void;
|
471
|
+
/**
|
472
|
+
* Cancels the current operation.
|
473
|
+
* Does nothing if no operation is running.
|
474
|
+
*/
|
475
|
+
cancel(): void;
|
476
|
+
private operate;
|
477
|
+
private upUnit;
|
478
|
+
private getUnitConfig;
|
479
|
+
private watchStateStream;
|
480
|
+
private updateCurrentOperation;
|
481
|
+
private updateInstanceState;
|
482
|
+
private getOrCreateUnitPromise;
|
483
|
+
static create(projectId: string, runnerBackend: RunnerBackend, stateBackend: StateBackend, libraryBackend: LibraryBackend, projectBackend: ProjectBackend, secretBackend: SecretBackend): Promise<ProjectOperator>;
|
484
|
+
}
|
485
|
+
|
486
|
+
declare class OperatorManager {
|
487
|
+
private readonly runnerBackend;
|
488
|
+
private readonly stateBackend;
|
489
|
+
private readonly libraryBackend;
|
490
|
+
private readonly projectBackend;
|
491
|
+
private readonly secretBackend;
|
492
|
+
private readonly operators;
|
493
|
+
private readonly lock;
|
494
|
+
constructor(runnerBackend: RunnerBackend, stateBackend: StateBackend, libraryBackend: LibraryBackend, projectBackend: ProjectBackend, secretBackend: SecretBackend);
|
495
|
+
get(projectId: string): Promise<ProjectOperator>;
|
496
|
+
}
|
497
|
+
|
498
|
+
type Services = {
|
499
|
+
readonly libraryBackend: LibraryBackend;
|
500
|
+
readonly secretBackend: SecretBackend;
|
501
|
+
readonly runnerBackend: RunnerBackend;
|
502
|
+
readonly projectBackend: ProjectBackend;
|
503
|
+
readonly stateBackend: StateBackend;
|
504
|
+
readonly operatorManager: OperatorManager;
|
505
|
+
};
|
506
|
+
declare function createServices(config?: Config): Promise<Services>;
|
507
|
+
|
508
|
+
export { type Config, type EvaluationInput, type EvaluationInstance, type InstanceModel, type InstanceState, type InstanceStatus, type LibraryBackend, type LibraryModel, LocalPulumiProjectHost, type OperationType, OperatorManager, type OutputRef, type Position, type ProjectOperation, ProjectOperator, type ProjectState, SecretAccessDeniedError, type SecretBackend, type Services, type StateBackend, createLibraryBackend, createSecretBackend, createServices, createStateBackend, instanceModelSchema, instanceStateSchema, instanceStatusSchema, libraryBackendConfig, loadConfig, operationType, outputRefSchema, positionSchema, projectOperation, projectStateSchema, resolveMainLocalProject, secretBackendConfig, stateBackendConfig, stringArrayType };
|