@highstate/backend 0.7.0 → 0.7.2

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 CHANGED
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { WhoAmIResult, Stack, ConfigMap } from '@pulumi/pulumi/automation';
3
3
  import { Logger } from 'pino';
4
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-NNJYvGqi.js';
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-Cm2WqcyB.js';
6
6
  import { BetterLock } from 'better-lock/dist/better_lock';
7
7
  import { Stream, Writable } from 'node:stream';
8
8
 
@@ -51,14 +51,23 @@ interface SecretBackend {
51
51
  set(projectId: string, instanceId: string, values: Record<string, unknown>): Promise<void>;
52
52
  }
53
53
 
54
+ type RunOptions = {
55
+ projectId: string;
56
+ pulumiProjectName: string;
57
+ pulumiStackName: string;
58
+ envVars?: Record<string, string>;
59
+ };
60
+ type RunLocalOptions = RunOptions & {
61
+ projectPath: string;
62
+ stackConfig?: ConfigMap;
63
+ };
54
64
  declare class LocalPulumiHost {
55
65
  private readonly logger;
56
66
  private lock;
57
67
  private constructor();
58
68
  getCurrentUser(): Promise<WhoAmIResult | null>;
59
- runInline<T>(projectId: string, pulumiProjectName: string, pulumiStackName: string, program: () => Promise<void> | Promise<Record<string, unknown>>, fn: (stack: Stack) => Promise<T>, envVars?: Record<string, string>): Promise<T>;
60
- runEmpty<T>(projectId: string, pulumiProjectName: string, pulumiStackName: string, fn: (stack: Stack) => Promise<T>, envVars?: Record<string, string>): Promise<T>;
61
- runLocal<T>(projectId: string, pulumiProjectName: string, pulumiStackName: string, programPathResolver: () => Promise<string> | string, fn: (stack: Stack) => Promise<T>, stackConfig?: ConfigMap, envVars?: Record<string, string>): Promise<T>;
69
+ runEmpty<T>(options: RunOptions, fn: (stack: Stack) => Promise<T>): Promise<T>;
70
+ runLocal<T>(options: RunLocalOptions, fn: (stack: Stack) => Promise<T>): Promise<T>;
62
71
  private sharedPassword;
63
72
  private passwords;
64
73
  hasPassword(projectId: string): boolean;
@@ -275,6 +284,7 @@ declare class ProjectLock {
275
284
  private readonly lock;
276
285
  private readonly projectId;
277
286
  constructor(lock: BetterLock, projectId: string);
287
+ canImmediatelyAcquireLock(instanceId: string): boolean;
278
288
  lockInstance<T>(instanceId: string, fn: () => Promise<T>): Promise<T>;
279
289
  lockInstances<T>(instanceIds: string[], fn: () => Promise<T>): Promise<T>;
280
290
  }
@@ -477,6 +487,24 @@ type InstanceUpdateOptions = RunnerBaseOptions & {
477
487
  * The values of the secrets.
478
488
  */
479
489
  secrets: Record<string, string>;
490
+ /**
491
+ * Whether to refresh the state before updating.
492
+ */
493
+ refresh?: boolean;
494
+ };
495
+ type InstanceDestroyOptions = RunnerBaseOptions & {
496
+ /**
497
+ * The source of the unit.
498
+ */
499
+ source: UnitSource;
500
+ /**
501
+ * Whether to refresh the state before updating.
502
+ */
503
+ refresh?: boolean;
504
+ /**
505
+ * Whether to delete the unreachable resources (e.g. k8s resources in unreachable clusters).
506
+ */
507
+ deleteUnreachable?: boolean;
480
508
  };
481
509
  type InstanceWatchOptions = RunnerBaseOptions & {
482
510
  /**
@@ -517,6 +545,14 @@ interface RunnerBackend {
517
545
  * If the instance is running another operation, it should throw an error.
518
546
  */
519
547
  update(options: InstanceUpdateOptions): Promise<void>;
548
+ /**
549
+ * Previews the instance update without actually applying the changes.
550
+ *
551
+ * The operation must only be aborted by the signal, not even when the connection is closed.
552
+ * If the instance is already updating, it should exit immediately.
553
+ * If the instance is running another operation, it should throw an error.
554
+ */
555
+ preview(options: InstanceUpdateOptions): Promise<void>;
520
556
  /**
521
557
  * Destroys the instance.
522
558
  *
@@ -524,7 +560,7 @@ interface RunnerBackend {
524
560
  * If the instance is not created, it should exit immediately.
525
561
  * If the instance is running another operation, it should throw an error.
526
562
  */
527
- destroy(options: RunnerBaseOptions): Promise<void>;
563
+ destroy(options: InstanceDestroyOptions): Promise<void>;
528
564
  /**
529
565
  * Refreshes the instance.
530
566
  *
@@ -589,7 +625,7 @@ declare class OperationManager {
589
625
  *
590
626
  * @param request The operation request to launch.
591
627
  */
592
- launch(request: ProjectOperationRequest): Promise<void>;
628
+ launch(request: ProjectOperationRequest): Promise<ProjectOperation>;
593
629
  /**
594
630
  * Cancels the current operation.
595
631
  * Does nothing if no operation is running.