effect-pulumi 0.1.2 → 0.2.0

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
@@ -1,11 +1,9 @@
1
- import * as effect_Cause from 'effect/Cause';
2
- import * as effect_Types from 'effect/Types';
3
- import * as pulumi from '@pulumi/pulumi';
4
- import { Effect } from 'effect';
5
- import { PulumiFn, LocalWorkspaceOptions, ConfigMap, UpOptions, PreviewOptions, Stack, UpResult, PreviewResult, DestroyOptions, DestroyResult, RefreshOptions, RefreshResult, RemoveOptions, OutputMap } from '@pulumi/pulumi/automation/index.js';
6
-
7
- declare const PulumiError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
8
- readonly _tag: "PulumiError";
1
+ import { Effect } from "effect";
2
+ import * as pulumi from "@pulumi/pulumi";
3
+ import { ConfigMap, DestroyOptions, DestroyResult, LocalWorkspaceOptions, OutputMap, PreviewOptions, PreviewResult, PulumiFn, RefreshOptions, RefreshResult, RemoveOptions, Stack, UpOptions, UpResult } from "@pulumi/pulumi/automation/index.js";
4
+ //#region src/errors.d.ts
5
+ declare const PulumiError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
6
+ readonly _tag: "PulumiError";
9
7
  } & Readonly<A>;
10
8
  /**
11
9
  * Any synchronous failure constructing a resource (bad args, provider
@@ -21,18 +19,18 @@ declare const PulumiError_base: new <A extends Record<string, any> = {}>(args: e
21
19
  * );
22
20
  * ```
23
21
  */
24
- declare class PulumiError extends PulumiError_base<{
25
- /** The original thrown value or rejection reason, unwrapped and unmodified.
26
- * Not necessarily an `Error`. */
27
- readonly cause: unknown;
22
+ export declare class PulumiError extends PulumiError_base<{
23
+ /** The original thrown value or rejection reason, unwrapped and unmodified.
24
+ * Not necessarily an `Error`. */
25
+ readonly cause: unknown;
28
26
  }> {
29
- /** Derived so anything reading `.message` - plain logging, test failure
30
- * output, non-Effect error handling - sees the underlying failure instead
31
- * of an empty string. */
32
- get message(): string;
27
+ /** Derived so anything reading `.message` - plain logging, test failure
28
+ * output, non-Effect error handling - sees the underlying failure instead
29
+ * of an empty string. */
30
+ get message(): string;
33
31
  }
34
- declare const AutomationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
35
- readonly _tag: "AutomationError";
32
+ declare const AutomationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
33
+ readonly _tag: "AutomationError";
36
34
  } & Readonly<A>;
37
35
  /**
38
36
  * Failure from an Automation API lifecycle call (up/preview/destroy/select).
@@ -52,19 +50,20 @@ declare const AutomationError_base: new <A extends Record<string, any> = {}>(arg
52
50
  * );
53
51
  * ```
54
52
  */
55
- declare class AutomationError extends AutomationError_base<{
56
- /** Which Automation API call failed. Named for the wrapper that raised it,
57
- * so `deploy`'s failures still report the underlying stage. */
58
- readonly stage: "createOrSelectStack" | "setConfig" | "up" | "preview" | "refresh" | "outputs" | "destroy" | "removeStack";
59
- /** The rejection reason from the Automation API. For a failed update this is
60
- * usually a `CommandError` carrying the CLI's stdout and stderr. */
61
- readonly cause: unknown;
53
+ export declare class AutomationError extends AutomationError_base<{
54
+ /** Which Automation API call failed. Named for the wrapper that raised it,
55
+ * so `deploy`'s failures still report the underlying stage. */
56
+ readonly stage: "createOrSelectStack" | "setConfig" | "up" | "preview" | "refresh" | "outputs" | "destroy" | "removeStack";
57
+ /** The rejection reason from the Automation API. For a failed update this is
58
+ * usually a `CommandError` carrying the CLI's stdout and stderr. */
59
+ readonly cause: unknown;
62
60
  }> {
63
- /** `"<stage> failed: <cause>"` - the stage is included because the cause
64
- * alone rarely says which operation produced it. */
65
- get message(): string;
61
+ /** `"<stage> failed: <cause>"` - the stage is included because the cause
62
+ * alone rarely says which operation produced it. */
63
+ get message(): string;
66
64
  }
67
-
65
+ //#endregion
66
+ //#region src/output-bridge.d.ts
68
67
  /**
69
68
  * Lift a single Output into an Effect.
70
69
  *
@@ -86,7 +85,7 @@ declare class AutomationError extends AutomationError_base<{
86
85
  * During `preview` the value may be the unknown sentinel rather than real data,
87
86
  * so don't branch on it to decide what to create.
88
87
  */
89
- declare const fromOutput: <T>(output: pulumi.Output<T>) => Effect.Effect<T, PulumiError>;
88
+ export declare const fromOutput: <T>(output: pulumi.Output<T>) => Effect.Effect<T, PulumiError>;
90
89
  /**
91
90
  * Lift a record of Outputs into a single Effect of the resolved record - use
92
91
  * this right after constructing a resource to grab several fields at once.
@@ -105,71 +104,18 @@ declare const fromOutput: <T>(output: pulumi.Output<T>) => Effect.Effect<T, Pulu
105
104
  * const { id, arn } = yield* fromOutputs({ id: bucket.id, arn: bucket.arn });
106
105
  * ```
107
106
  */
108
- declare const fromOutputs: <T extends { [K in keyof T]: pulumi.Output<any>; }>(outputs: T) => Effect.Effect<{ [K in keyof T]: pulumi.Unwrap<T[K]>; }, PulumiError>;
109
-
110
- /**
111
- * effectify - auto-wrap a Pulumi provider package (e.g. @pulumi/aws,
112
- * @pulumi/cloudflare) so every resource constructor becomes an
113
- * Effect-returning factory, without the caller ever writing `Effect.sync`.
114
- *
115
- * Usage:
116
- *
117
- * import * as aws from "@pulumi/aws";
118
- * const eaws = effectify(aws);
119
- *
120
- * const program = Effect.gen(function* () {
121
- * const bucket = yield* eaws.s3.Bucket("my-bucket", { forceDestroy: true });
122
- * // ^ Effect<aws.s3.Bucket, PulumiError> - no manual wrapping
123
- * });
124
- *
125
- * How it works:
126
- * - Every Pulumi resource class extends `pulumi.Resource` under the hood
127
- * (via CustomResource / ComponentResource). That's the runtime marker
128
- * used to tell "this export is a resource constructor" apart from "this
129
- * export is a namespace object" (e.g. `aws.s3`) or "this export is an
130
- * invoke function" (e.g. `aws.s3.getBucket`).
131
- * - Namespace objects get recursively proxied (lazily, memoized).
132
- * - CustomResource constructors get wrapped so any field in their args
133
- * object may *additionally* be an Effect - resolved (concurrently, they
134
- * are independent by construction) before construction. This is safe
135
- * because codegen guarantees CustomResource args are always
136
- * Record<string, Input<T>>.
137
- * - Wrapped constructors keep their static members: `Bucket.get(...)`,
138
- * `Bucket.isInstance(...)` and friends forward to the original class, so
139
- * the wrapped package can be the only import a program needs.
140
- * - ComponentResource constructors get wrapped with no arg-lifting - args
141
- * pass through exactly as declared, since component args aren't
142
- * guaranteed to be Input<T>-shaped (hand-authored, may do synchronous
143
- * work on a bare primitive inside the constructor).
144
- * - Invoke functions (`aws.s3.getBucket`) return an Effect instead of a
145
- * Promise. There is no runtime marker for "this function is async", so
146
- * the wrapper calls the function and inspects the result: a thenable
147
- * becomes an Effect, anything else is returned as-is. That means the
148
- * invoke *starts* at the call site (see the caveat on `wrapInvokeLike`);
149
- * `*Output` invoke variants return an Output, which is not thenable, so
150
- * they pass through untouched - matching the type-level mapping, which
151
- * only rewrites Promise-returning signatures.
152
- * - Everything else (enums, plain values, non-resource classes) passes
153
- * through untouched.
154
- *
155
- * Resource registration remains synchronous under the hood - Effect.try
156
- * runs its thunk immediately. This only removes hand-written wrapper
157
- * boilerplate, not Pulumi's execution model.
158
- */
159
-
107
+ export declare const fromOutputs: <T extends { [K in keyof T]: pulumi.Output<any>; }>(outputs: T) => Effect.Effect<{ [K in keyof T]: pulumi.Unwrap<T[K]>; }, PulumiError>;
108
+ //#endregion
109
+ //#region src/effectify.d.ts
160
110
  /** Allow any field of a CustomResource args object to *additionally* be an
161
111
  * Effect. Homomorphic, so optional fields stay optional and plain
162
112
  * `Input<T>`/`Output<T>` values keep working untouched. */
163
- type LiftedArgs<A> = A extends object ? {
164
- [K in keyof A]: A[K] | Effect.Effect<A[K], PulumiError>;
165
- } : A;
113
+ type LiftedArgs<A> = A extends object ? { [K in keyof A]: A[K] | Effect.Effect<A[K], PulumiError>; } : A;
166
114
  /** Apply `LiftedArgs` to the second constructor parameter (the args object),
167
115
  * leaving `name` and `opts` alone. Mapping over the parameter tuple
168
116
  * homomorphically preserves labels and optionality, so constructors whose
169
117
  * args are optional stay callable as `Bucket("name")`. */
170
- type LiftArgsParam<P extends readonly unknown[]> = {
171
- [K in keyof P]: K extends "1" ? LiftedArgs<P[K]> : P[K];
172
- };
118
+ type LiftArgsParam<P extends readonly unknown[]> = { [K in keyof P]: K extends "1" ? LiftedArgs<P[K]> : P[K]; };
173
119
  /** The class's static side, minus `prototype`: `keyof` on a constructor type
174
120
  * yields exactly the statics (own and inherited, e.g. codegen'd `get` and
175
121
  * `isInstance`), which the runtime wrapper forwards to the original class. */
@@ -194,9 +140,7 @@ type StaticMembers<T> = Omit<T, "prototype">;
194
140
  * Statics survive on the wrapped constructors, so `Bucket.get` and
195
141
  * `Bucket.isInstance` remain callable.
196
142
  */
197
- type Effectify<T> = T extends abstract new (...params: infer P) => infer R ? R extends pulumi.ComponentResource ? ((...params: P) => Effect.Effect<R, PulumiError>) & StaticMembers<T> : R extends pulumi.CustomResource ? ((...params: LiftArgsParam<P>) => Effect.Effect<R, PulumiError>) & StaticMembers<T> : T : T extends (...args: infer A) => Promise<infer R> ? (...args: A) => Effect.Effect<R, PulumiError> : T extends (...args: any[]) => any ? T : T extends object ? {
198
- [K in keyof T]: Effectify<T[K]>;
199
- } : T;
143
+ export type Effectify<T> = T extends (abstract new (...params: infer P) => infer R) ? R extends pulumi.ComponentResource ? ((...params: P) => Effect.Effect<R, PulumiError>) & StaticMembers<T> : R extends pulumi.CustomResource ? ((...params: LiftArgsParam<P>) => Effect.Effect<R, PulumiError>) & StaticMembers<T> : T : T extends ((...args: infer A) => Promise<infer R>) ? (...args: A) => Effect.Effect<R, PulumiError> : T extends ((...args: any[]) => any) ? T : T extends object ? { [K in keyof T]: Effectify<T[K]>; } : T;
200
144
  /**
201
145
  * Wrap a provider package (or any namespace) once, turning every resource
202
146
  * constructor into an `Effect`-returning factory and every `Promise`-returning
@@ -236,106 +180,107 @@ type Effectify<T> = T extends abstract new (...params: infer P) => infer R ? R e
236
180
  *
237
181
  * @see {@link Effectify} for the type-level mapping.
238
182
  */
239
- declare function effectify<T extends object>(mod: T): Effectify<T>;
240
-
183
+ export declare function effectify<T extends object>(mod: T): Effectify<T>;
184
+ //#endregion
185
+ //#region src/automation.d.ts
241
186
  /** Arguments for an inline program - the Pulumi program is a function in this
242
187
  * process, with no `Pulumi.yaml` on disk. */
243
- interface InlineStackOptions {
244
- /** Stack to select, created if absent. */
245
- readonly stackName: string;
246
- /** Project name to register the stack under. Chosen freely here, since
247
- * there is no `Pulumi.yaml` to take it from - but it is part of the stack's
248
- * identity in the backend, so changing it later points at a different
249
- * stack. */
250
- readonly projectName: string;
251
- /** The program itself. Runs in this process, so it needs no separate Node
252
- * runtime and can close over values from the caller. */
253
- readonly program: PulumiFn;
254
- readonly workspaceOptions?: LocalWorkspaceOptions;
188
+ export interface InlineStackOptions {
189
+ /** Stack to select, created if absent. */
190
+ readonly stackName: string;
191
+ /** Project name to register the stack under. Chosen freely here, since
192
+ * there is no `Pulumi.yaml` to take it from - but it is part of the stack's
193
+ * identity in the backend, so changing it later points at a different
194
+ * stack. */
195
+ readonly projectName: string;
196
+ /** The program itself. Runs in this process, so it needs no separate Node
197
+ * runtime and can close over values from the caller. */
198
+ readonly program: PulumiFn;
199
+ readonly workspaceOptions?: LocalWorkspaceOptions;
255
200
  }
256
201
  /** Arguments for a local program - an existing Pulumi project on disk. */
257
- interface LocalStackOptions {
258
- /** Stack to select, created if absent. */
259
- readonly stackName: string;
260
- /** Directory holding the project's `Pulumi.yaml`. Its `name:` supplies the
261
- * project name, which is why there is no `projectName` here. */
262
- readonly workDir: string;
263
- readonly workspaceOptions?: LocalWorkspaceOptions;
202
+ export interface LocalStackOptions {
203
+ /** Stack to select, created if absent. */
204
+ readonly stackName: string;
205
+ /** Directory holding the project's `Pulumi.yaml`. Its `name:` supplies the
206
+ * project name, which is why there is no `projectName` here. */
207
+ readonly workDir: string;
208
+ readonly workspaceOptions?: LocalWorkspaceOptions;
264
209
  }
265
210
  /** Either flavour of stack. Discriminated at runtime by the presence of
266
211
  * `workDir`, so the two are not interchangeable: an inline program needs
267
212
  * `projectName`, a local one takes it from `Pulumi.yaml`. */
268
- type StackOptions = InlineStackOptions | LocalStackOptions;
213
+ export type StackOptions = InlineStackOptions | LocalStackOptions;
269
214
  /** Select the stack, creating it if it does not exist, and return the handle
270
215
  * every other operation here takes.
271
216
  *
272
217
  * Creating the workspace is itself work - it may write files and shell out to
273
218
  * the CLI - so hold on to the returned `Stack` rather than re-selecting before
274
219
  * each operation. */
275
- declare const createOrSelectStack: (opts: StackOptions) => Effect.Effect<Stack, AutomationError>;
220
+ export declare const createOrSelectStack: (opts: StackOptions) => Effect.Effect<Stack, AutomationError>;
276
221
  /** Apply the whole config map in one `setAllConfig` call - a single CLI
277
222
  * round-trip, where per-key `setConfig` costs one `pulumi config set`
278
223
  * invocation each. */
279
- declare const setStackConfig: (stack: Stack, config: ConfigMap | undefined) => Effect.Effect<void, AutomationError>;
224
+ export declare const setStackConfig: (stack: Stack, config: ConfigMap | undefined) => Effect.Effect<void, AutomationError>;
280
225
  /** Compute the plan without applying it.
281
226
  *
282
227
  * A preview is a full engine run against the provider, not a cheap check - see
283
228
  * {@link DeployOptions.preview} before pairing one with an `up`. */
284
- declare const previewStack: (stack: Stack, opts?: PreviewOptions) => Effect.Effect<PreviewResult, AutomationError>;
229
+ export declare const previewStack: (stack: Stack, opts?: PreviewOptions) => Effect.Effect<PreviewResult, AutomationError>;
285
230
  /** Apply the program: create, update and delete resources to match it.
286
231
  *
287
232
  * The result carries the stack's outputs and a summary; pass `onOutput` to
288
233
  * watch progress while it runs. */
289
- declare const upStack: (stack: Stack, opts?: UpOptions) => Effect.Effect<UpResult, AutomationError>;
234
+ export declare const upStack: (stack: Stack, opts?: UpOptions) => Effect.Effect<UpResult, AutomationError>;
290
235
  /** Refresh the stack's state from the actual cloud resources, without
291
236
  * changing them - what to run when state may have drifted (manual console
292
237
  * edits, a crashed update) before deciding what to do about it. */
293
- declare const refreshStack: (stack: Stack, opts?: RefreshOptions) => Effect.Effect<RefreshResult, AutomationError>;
238
+ export declare const refreshStack: (stack: Stack, opts?: RefreshOptions) => Effect.Effect<RefreshResult, AutomationError>;
294
239
  /** Read the stack's current outputs without running an update. */
295
- declare const stackOutputs: (stack: Stack) => Effect.Effect<OutputMap, AutomationError>;
240
+ export declare const stackOutputs: (stack: Stack) => Effect.Effect<OutputMap, AutomationError>;
296
241
  /** Destroy the stack's resources. The stack itself remains registered with
297
242
  * the backend - see `removeStack` / `teardownStack` to delete it too. */
298
- declare const destroyStack: (stack: Stack, opts?: DestroyOptions) => Effect.Effect<DestroyResult, AutomationError>;
243
+ export declare const destroyStack: (stack: Stack, opts?: DestroyOptions) => Effect.Effect<DestroyResult, AutomationError>;
299
244
  /** Delete the stack and its configuration and history from the backend.
300
245
  *
301
246
  * This does not destroy resources - run `destroyStack` first, or use
302
247
  * `teardownStack`. Pulumi refuses to remove a stack that still has resources
303
248
  * unless `RemoveOptions.force` is set, and forcing it orphans them: they keep
304
249
  * existing and billing with nothing tracking them. */
305
- declare const removeStack: (stack: Stack, opts?: RemoveOptions) => Effect.Effect<void, AutomationError>;
250
+ export declare const removeStack: (stack: Stack, opts?: RemoveOptions) => Effect.Effect<void, AutomationError>;
306
251
  /** Full teardown: destroy the resources, then delete the stack.
307
252
  *
308
253
  * `destroyStack` alone leaves an empty stack behind, so anything creating
309
254
  * stacks per-run (ephemeral environments, tests naming stacks by timestamp)
310
255
  * accumulates them in the backend. */
311
- declare const teardownStack: (stack: Stack, opts?: {
312
- readonly destroy?: DestroyOptions;
313
- readonly remove?: RemoveOptions;
256
+ export declare const teardownStack: (stack: Stack, opts?: {
257
+ readonly destroy?: DestroyOptions;
258
+ readonly remove?: RemoveOptions;
314
259
  }) => Effect.Effect<DestroyResult, AutomationError>;
315
260
  /** {@link deploy}'s arguments: the stack to target, plus what to do with it. */
316
- type DeployOptions = StackOptions & {
317
- /** Config to apply before the update, in one `setAllConfig` call. Keys are
318
- * fully qualified (`"my-project:myKey"`). */
319
- readonly config?: ConfigMap;
320
- /** Options forwarded to the update - `onOutput` to stream progress,
321
- * `parallel`, `target`, and so on. */
322
- readonly up?: UpOptions;
323
- /** Run `preview` before `up`, returning its result.
324
- *
325
- * Off by default: a preview is a full engine run against the provider, so
326
- * previewing and then immediately upping does the work twice. `up` reports
327
- * the same failures, so this earns its cost only when you want the plan
328
- * itself. */
329
- readonly preview?: PreviewOptions | boolean;
261
+ export type DeployOptions = StackOptions & {
262
+ /** Config to apply before the update, in one `setAllConfig` call. Keys are
263
+ * fully qualified (`"my-project:myKey"`). */
264
+ readonly config?: ConfigMap;
265
+ /** Options forwarded to the update - `onOutput` to stream progress,
266
+ * `parallel`, `target`, and so on. */
267
+ readonly up?: UpOptions;
268
+ /** Run `preview` before `up`, returning its result.
269
+ *
270
+ * Off by default: a preview is a full engine run against the provider, so
271
+ * previewing and then immediately upping does the work twice. `up` reports
272
+ * the same failures, so this earns its cost only when you want the plan
273
+ * itself. */
274
+ readonly preview?: PreviewOptions | boolean;
330
275
  };
331
276
  /** What {@link deploy} hands back. */
332
- interface DeployResult {
333
- /** The selected stack, so teardown needs no second `createOrSelectStack`. */
334
- readonly stack: Stack;
335
- /** The update's result - `outputs` and `summary` live here. */
336
- readonly result: UpResult;
337
- /** Present only when `preview` was requested. */
338
- readonly preview?: PreviewResult;
277
+ export interface DeployResult {
278
+ /** The selected stack, so teardown needs no second `createOrSelectStack`. */
279
+ readonly stack: Stack;
280
+ /** The update's result - `outputs` and `summary` live here. */
281
+ readonly result: UpResult;
282
+ /** Present only when `preview` was requested. */
283
+ readonly preview?: PreviewResult;
339
284
  }
340
285
  /**
341
286
  * Select or create the stack, apply config, optionally preview, then up.
@@ -361,6 +306,6 @@ interface DeployResult {
361
306
  * );
362
307
  * ```
363
308
  */
364
- declare const deploy: (opts: DeployOptions) => Effect.Effect<DeployResult, AutomationError>;
365
-
366
- export { AutomationError, type DeployOptions, type DeployResult, type Effectify, type InlineStackOptions, type LocalStackOptions, PulumiError, type StackOptions, createOrSelectStack, deploy, destroyStack, effectify, fromOutput, fromOutputs, previewStack, refreshStack, removeStack, setStackConfig, stackOutputs, teardownStack, upStack };
309
+ export declare const deploy: (opts: DeployOptions) => Effect.Effect<DeployResult, AutomationError>;
310
+ //#endregion
311
+ //# sourceMappingURL=index.d.ts.map