@highstate/backend 0.4.3 → 0.4.5
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 +93 -47
- package/dist/index.mjs +907 -393
- package/dist/library/worker/main.mjs +3 -8
- package/dist/shared/index.d.ts +80 -16
- package/dist/shared/index.mjs +52 -2
- package/dist/terminal-C1HuyJ6e.mjs +512 -0
- package/dist/terminal-_gg6j6_K.d.ts +1417 -0
- package/package.json +6 -5
- package/dist/input-hash-C8HEDMjz.mjs +0 -292
- package/dist/operation-8k4Tv4dw.d.ts +0 -841
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
import { WhoAmIResult, Stack, ConfigMap } from '@pulumi/pulumi/automation';
|
3
3
|
import { Logger } from 'pino';
|
4
|
-
import { ComponentModel, Entity,
|
5
|
-
import {
|
4
|
+
import { ComponentModel, Entity, InstanceModel, CompositeInstance, UnitSource } from '@highstate/contract';
|
5
|
+
import { H as HubModel, I as InstanceModelPatch, a as HubModelPatch, P as ProjectOperation, b as InstanceState, T as TerminalSession, c as InstanceStatus, d as InstanceStatePatch, e as InstancePageBlock, f as InstanceTerminal, g as ProjectOperationRequest } from './terminal-_gg6j6_K.js';
|
6
6
|
import { BetterLock } from 'better-lock/dist/better_lock';
|
7
|
-
import { Stream, Writable
|
7
|
+
import { Stream, Writable } from 'node:stream';
|
8
8
|
|
9
9
|
declare class SecretAccessDeniedError extends Error {
|
10
10
|
constructor(projectId: string, key: string);
|
@@ -64,7 +64,7 @@ declare class LocalPulumiHost {
|
|
64
64
|
hasPassword(projectId: string): boolean;
|
65
65
|
setPassword(projectId: string, password: string): void;
|
66
66
|
private getPassword;
|
67
|
-
|
67
|
+
tryUnlockStack(stack: Stack, error: unknown): Promise<boolean>;
|
68
68
|
static create(logger: Logger): LocalPulumiHost;
|
69
69
|
}
|
70
70
|
|
@@ -103,13 +103,13 @@ interface LibraryBackend {
|
|
103
103
|
* @param allInstances The all instances defined in the project.
|
104
104
|
* @param instanceIds The instance IDs to evaluate.
|
105
105
|
*/
|
106
|
-
evaluateCompositeInstances(allInstances:
|
106
|
+
evaluateCompositeInstances(allInstances: InstanceModel[], instanceIds: string[]): Promise<readonly CompositeInstance[]>;
|
107
107
|
/**
|
108
108
|
* Evaluates the modules and returns the evaluated instances.
|
109
109
|
*
|
110
110
|
* @param modulePaths The module paths to evaluate.
|
111
111
|
*/
|
112
|
-
evaluateModules(modulePaths: string[]): Promise<readonly
|
112
|
+
evaluateModules(modulePaths: string[]): Promise<readonly InstanceModel[]>;
|
113
113
|
}
|
114
114
|
|
115
115
|
declare const libraryBackendConfig: z.ZodObject<{
|
@@ -194,17 +194,21 @@ declare const configSchema: z.ZodObject<{
|
|
194
194
|
type Config = z.infer<typeof configSchema>;
|
195
195
|
declare function loadConfig(env?: NodeJS.ProcessEnv, useDotenv?: boolean): Promise<Config>;
|
196
196
|
|
197
|
+
type ProjectModel = {
|
198
|
+
instances: InstanceModel[];
|
199
|
+
hubs: HubModel[];
|
200
|
+
};
|
197
201
|
interface ProjectBackend {
|
198
202
|
/**
|
199
203
|
* List the names of the available projects.
|
200
204
|
*/
|
201
205
|
getProjectNames(): Promise<string[]>;
|
202
206
|
/**
|
203
|
-
* Get the instances of the project.
|
207
|
+
* Get the instances and hubs of the project.
|
204
208
|
*
|
205
209
|
* @param projectId The ID of the project.
|
206
210
|
*/
|
207
|
-
|
211
|
+
getProject(projectId: string): Promise<ProjectModel>;
|
208
212
|
/**
|
209
213
|
* Create the instance of the project.
|
210
214
|
*
|
@@ -212,14 +216,6 @@ interface ProjectBackend {
|
|
212
216
|
* @param instance The instance to update.
|
213
217
|
*/
|
214
218
|
createInstance(projectId: string, instance: InstanceModel): Promise<InstanceModel>;
|
215
|
-
/**
|
216
|
-
* Change the position of the instance in the project.
|
217
|
-
*
|
218
|
-
* @param projectId The ID of the project.
|
219
|
-
* @param instanceId The ID of the instance to move.
|
220
|
-
* @param position The new position of the instance.
|
221
|
-
*/
|
222
|
-
moveInstance(projectId: string, instanceId: string, position: Position): Promise<InstanceModel>;
|
223
219
|
/**
|
224
220
|
* Rename the instance of the project.
|
225
221
|
* Changes its id and updates all references to the instance.
|
@@ -227,28 +223,42 @@ interface ProjectBackend {
|
|
227
223
|
*/
|
228
224
|
renameInstance(projectId: string, instanceId: string, newName: string): Promise<InstanceModel>;
|
229
225
|
/**
|
230
|
-
*
|
226
|
+
* Patches the instance of the project.
|
231
227
|
*
|
232
228
|
* @param projectId The ID of the project.
|
233
229
|
* @param instanceId The ID of the instance to update.
|
234
|
-
* @param
|
230
|
+
* @param patch The patch to apply to the instance.
|
235
231
|
*/
|
236
|
-
|
232
|
+
updateInstance(projectId: string, instanceId: string, patch: InstanceModelPatch): Promise<InstanceModel>;
|
237
233
|
/**
|
238
|
-
*
|
234
|
+
* Delete the instance of the project.
|
239
235
|
*
|
240
236
|
* @param projectId The ID of the project.
|
241
|
-
* @param instanceId The ID of the instance to
|
242
|
-
* @param inputs The new inputs of the instance.
|
237
|
+
* @param instanceId The ID of the instance to delete.
|
243
238
|
*/
|
244
|
-
|
239
|
+
deleteInstance(projectId: string, instanceId: string): Promise<void>;
|
245
240
|
/**
|
246
|
-
*
|
241
|
+
* Create a hub in the project.
|
247
242
|
*
|
248
243
|
* @param projectId The ID of the project.
|
249
|
-
* @param
|
244
|
+
* @param hub The hub to create.
|
250
245
|
*/
|
251
|
-
|
246
|
+
createHub(projectId: string, hub: HubModel): Promise<HubModel>;
|
247
|
+
/**
|
248
|
+
* Patches the hub of the project.
|
249
|
+
*
|
250
|
+
* @param projectId The ID of the project.
|
251
|
+
* @param hubId The ID of the hub to update.
|
252
|
+
* @param patch The patch to apply to the hub.
|
253
|
+
*/
|
254
|
+
updateHub(projectId: string, hubId: string, patch: HubModelPatch): Promise<HubModel>;
|
255
|
+
/**
|
256
|
+
* Delete the hub of the project.
|
257
|
+
*
|
258
|
+
* @param projectId The ID of the project.
|
259
|
+
* @param hubId The ID of the hub to delete.
|
260
|
+
*/
|
261
|
+
deleteHub(projectId: string, hubId: string): Promise<void>;
|
252
262
|
}
|
253
263
|
|
254
264
|
declare class ProjectLock {
|
@@ -264,6 +274,7 @@ declare class ProjectLockManager {
|
|
264
274
|
}
|
265
275
|
|
266
276
|
type LogEntry = [instanceId: string, line: string];
|
277
|
+
type TerminalHistoryEntry = [sessionId: string, line: string];
|
267
278
|
type EvaluatedCompositeInstance = CompositeInstance & {
|
268
279
|
/**
|
269
280
|
* The hash of the input of the instance at the moment of the evaluation.
|
@@ -297,7 +308,7 @@ interface StateBackend {
|
|
297
308
|
* @param projectId The ID of the project.
|
298
309
|
* @param instanceId The ID of the instance.
|
299
310
|
*/
|
300
|
-
getInstanceState(projectId: string, instanceId: string): Promise<InstanceState |
|
311
|
+
getInstanceState(projectId: string, instanceId: string): Promise<InstanceState | null>;
|
301
312
|
/**
|
302
313
|
* Gets the affected instance states at the moment of the operation completion.
|
303
314
|
* The logs are not included.
|
@@ -370,6 +381,41 @@ interface StateBackend {
|
|
370
381
|
* @param instanceIds The IDs of the instances to clear.
|
371
382
|
*/
|
372
383
|
clearCompositeInstances(projectId: string, instanceIds: string[]): Promise<void>;
|
384
|
+
/**
|
385
|
+
* Gets all the terminal sessions of the instance.
|
386
|
+
*
|
387
|
+
* @param projectId The ID of the project.
|
388
|
+
* @param instanceId The ID of the instance.
|
389
|
+
*/
|
390
|
+
getTerminalSessions(projectId: string, instanceId: string): Promise<TerminalSession[]>;
|
391
|
+
/**
|
392
|
+
* Gets the terminal session.
|
393
|
+
*
|
394
|
+
* @param projectId The ID of the project.
|
395
|
+
* @param instanceId The ID of the instance.
|
396
|
+
* @param sessionId The ID of the session.
|
397
|
+
*/
|
398
|
+
getTerminalSession(projectId: string, instanceId: string, sessionId: string): Promise<TerminalSession | null>;
|
399
|
+
/**
|
400
|
+
* Puts the terminal sessions of the instance to the state.
|
401
|
+
*
|
402
|
+
* @param projectId The ID of the project.
|
403
|
+
* @param instanceId The ID of the instance.
|
404
|
+
* @param session The terminal session to put.
|
405
|
+
*/
|
406
|
+
putTerminalSession(projectId: string, instanceId: string, session: TerminalSession): Promise<void>;
|
407
|
+
/**
|
408
|
+
* Gets the history lines of the terminal session.
|
409
|
+
*
|
410
|
+
* @param sessionId The ID of the session.
|
411
|
+
*/
|
412
|
+
getTerminalSessionHistory(sessionId: string): Promise<string[]>;
|
413
|
+
/**
|
414
|
+
* Appends the history lines to the terminal sessions.
|
415
|
+
*
|
416
|
+
* @param entries The entries to append.
|
417
|
+
*/
|
418
|
+
appendTerminalSessionHistory(entries: TerminalHistoryEntry[]): Promise<void>;
|
373
419
|
}
|
374
420
|
|
375
421
|
declare class ProjectManager {
|
@@ -381,13 +427,12 @@ declare class ProjectManager {
|
|
381
427
|
private constructor();
|
382
428
|
getCompositeInstance(projectId: string, instanceId: string): Promise<CompositeInstance>;
|
383
429
|
createInstance(projectId: string, instance: InstanceModel): Promise<InstanceModel>;
|
384
|
-
|
385
|
-
updateInstanceInputs(projectId: string, instanceId: string, inputs: InstanceInputMap): Promise<InstanceModel>;
|
386
|
-
moveInstance(projectId: string, instanceId: string, position: Position): Promise<InstanceModel>;
|
430
|
+
updateInstance(projectId: string, instanceId: string, patch: InstanceModelPatch): Promise<InstanceModel>;
|
387
431
|
renameInstance(projectId: string, instanceId: string, newName: string): Promise<InstanceModel>;
|
388
432
|
deleteInstance(projectId: string, instanceId: string): Promise<void>;
|
389
433
|
private updateInstanceChildren;
|
390
434
|
private waitForCompositeInstance;
|
435
|
+
private prepareInputHashResolver;
|
391
436
|
static create(projectBackend: ProjectBackend, stateBackend: StateBackend, operationManager: OperationManager, library: LibraryBackend, logger: Logger): ProjectManager;
|
392
437
|
}
|
393
438
|
|
@@ -443,13 +488,17 @@ interface RunnerBackend {
|
|
443
488
|
*/
|
444
489
|
getState(options: RunnerBaseOptions): Promise<InstanceState>;
|
445
490
|
/**
|
446
|
-
* Gets the content of the
|
491
|
+
* Gets the content of the page.
|
447
492
|
*/
|
448
|
-
|
493
|
+
getPageContent(options: RunnerBaseOptions, pageName: string): Promise<InstancePageBlock[] | null>;
|
494
|
+
/**
|
495
|
+
* Gets the content of the file.
|
496
|
+
*/
|
497
|
+
getFileContent(options: RunnerBaseOptions, fileName: string): Promise<string | null>;
|
449
498
|
/**
|
450
499
|
* Gets the terminal factory.
|
451
500
|
*/
|
452
|
-
getTerminalFactory(options: RunnerBaseOptions): Promise<
|
501
|
+
getTerminalFactory(options: RunnerBaseOptions, terminalName: string): Promise<InstanceTerminal | null>;
|
453
502
|
/**
|
454
503
|
* Updates the instance.
|
455
504
|
*
|
@@ -544,7 +593,7 @@ type TerminalRunOptions = {
|
|
544
593
|
/**
|
545
594
|
* The factory to use.
|
546
595
|
*/
|
547
|
-
factory:
|
596
|
+
factory: InstanceTerminal;
|
548
597
|
/**
|
549
598
|
* The input stream.
|
550
599
|
*/
|
@@ -582,24 +631,21 @@ declare const terminalBackendConfig: z.ZodObject<{
|
|
582
631
|
}>;
|
583
632
|
declare function createTerminalBackend(config: z.infer<typeof terminalBackendConfig>, logger: Logger): TerminalBackend;
|
584
633
|
|
585
|
-
type Terminal = {
|
586
|
-
readonly id: string;
|
587
|
-
readonly abortController: AbortController;
|
588
|
-
readonly stdin: PassThrough;
|
589
|
-
readonly stdout: PassThrough;
|
590
|
-
readonly history: string[];
|
591
|
-
attached: boolean;
|
592
|
-
};
|
593
634
|
declare class TerminalManager {
|
594
635
|
private readonly terminalBackend;
|
636
|
+
private readonly stateBackend;
|
637
|
+
private readonly runnerBackend;
|
595
638
|
private readonly logger;
|
596
|
-
private readonly
|
639
|
+
private readonly managedTerminals;
|
597
640
|
private constructor();
|
598
|
-
|
599
|
-
|
600
|
-
|
641
|
+
createSession(projectId: string, instanceId: string, terminalName: string): Promise<TerminalSession>;
|
642
|
+
ensureSessionCreated(projectId: string, instanceId: string, terminalName: string): Promise<TerminalSession>;
|
643
|
+
close(sessionId: string): void;
|
644
|
+
attach(projectId: string, instanceId: string, sessionId: string, stdin: Stream, stdout: Writable, signal: AbortSignal): Promise<void>;
|
645
|
+
private createManagedTerminal;
|
601
646
|
private closeTerminalIfNotAttached;
|
602
|
-
static create(terminalBackend: TerminalBackend, logger: Logger): TerminalManager;
|
647
|
+
static create(terminalBackend: TerminalBackend, stateBackend: StateBackend, runnerBackend: RunnerBackend, logger: Logger): TerminalManager;
|
648
|
+
private persistHistory;
|
603
649
|
}
|
604
650
|
|
605
651
|
interface WorkspaceBackend {
|