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/README.md +3 -1
- package/dist/index.cjs +460 -199
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -148
- package/dist/index.d.ts +93 -148
- package/dist/index.js +436 -177
- package/dist/index.js.map +1 -1
- package/package.json +12 -13
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/output-bridge.ts","../src/effectify.ts","../src/automation.ts"],"names":["Data","Effect","pulumi","pulumi2","LocalWorkspace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,aAAA,GAAgB,CAAC,KAAA,KACrB,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK,CAAA;AAgBhD,IAAM,WAAA,GAAN,cAA0BA,WAAA,CAAK,WAAA,CAAY,aAAa,CAAA,CAI5D;AAAA;AAAA;AAAA;AAAA,EAID,IAAI,OAAA,GAAkB;AACpB,IAAA,OAAO,aAAA,CAAc,KAAK,KAAK,CAAA;AAAA,EACjC;AACF;AAoBO,IAAM,eAAA,GAAN,cAA8BA,WAAA,CAAK,WAAA,CAAY,iBAAiB,CAAA,CAepE;AAAA;AAAA;AAAA,EAGD,IAAI,OAAA,GAAkB;AACpB,IAAA,OAAO,GAAG,IAAA,CAAK,KAAK,YAAY,aAAA,CAAc,IAAA,CAAK,KAAK,CAAC,CAAA,CAAA;AAAA,EAC3D;AACF;ACxCO,IAAM,UAAA,GAAa,CACxB,MAAA,KAEAC,aAAA,CAAO,UAAA,CAAW;AAAA,EAChB,GAAA,EAAK,MAAO,MAAA,CAA0C,OAAA,CAAQ,IAAI,CAAA;AAAA,EAClE,OAAO,CAAC,KAAA,KAAU,IAAI,WAAA,CAAY,EAAE,OAAO;AAC7C,CAAC;AAoBI,IAAM,cAAc,CACzB,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AAA,GACvD,GACA,MAAA;AAEJ,EAAA,MAAM,MAAA,GAAS,OAAO,OAAA,CAAQ,KAAA,EAAO,KAAK,EAAE,CAAA;AAC5C,EAAA,OAAO,EAAE,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAQ;AAClC,CAAC","file":"index.cjs","sourcesContent":["import { Data } from \"effect\";\n\nconst describeCause = (cause: unknown): string =>\n cause instanceof Error ? cause.message : String(cause);\n\n/**\n * Any synchronous failure constructing a resource (bad args, provider\n * validation, etc.), or a failure resolving an Output's promise.\n *\n * Tagged `\"PulumiError\"`, so it can be matched by tag rather than by\n * `instanceof`:\n *\n * @example\n * ```ts\n * program.pipe(\n * Effect.catchTag(\"PulumiError\", (e) => Effect.logError(e.message))\n * );\n * ```\n */\nexport class PulumiError extends Data.TaggedError(\"PulumiError\")<{\n /** The original thrown value or rejection reason, unwrapped and unmodified.\n * Not necessarily an `Error`. */\n readonly cause: unknown;\n}> {\n /** Derived so anything reading `.message` - plain logging, test failure\n * output, non-Effect error handling - sees the underlying failure instead\n * of an empty string. */\n get message(): string {\n return describeCause(this.cause);\n }\n}\n\n/**\n * Failure from an Automation API lifecycle call (up/preview/destroy/select).\n *\n * `stage` says which call failed, which matters most in the composite\n * operations: a failed `deploy` could have died selecting the stack, applying\n * config, or running the update, and the three want different responses.\n *\n * @example\n * ```ts\n * deploy(opts).pipe(\n * Effect.catchTag(\"AutomationError\", (e) =>\n * e.stage === \"createOrSelectStack\"\n * ? Effect.fail(new BackendUnreachable())\n * : Effect.logError(e.message)\n * )\n * );\n * ```\n */\nexport class AutomationError extends Data.TaggedError(\"AutomationError\")<{\n /** Which Automation API call failed. Named for the wrapper that raised it,\n * so `deploy`'s failures still report the underlying stage. */\n readonly stage:\n | \"createOrSelectStack\"\n | \"setConfig\"\n | \"up\"\n | \"preview\"\n | \"refresh\"\n | \"outputs\"\n | \"destroy\"\n | \"removeStack\";\n /** The rejection reason from the Automation API. For a failed update this is\n * usually a `CommandError` carrying the CLI's stdout and stderr. */\n readonly cause: unknown;\n}> {\n /** `\"<stage> failed: <cause>\"` - the stage is included because the cause\n * alone rarely says which operation produced it. */\n get message(): string {\n return `${this.stage} failed: ${describeCause(this.cause)}`;\n }\n}\n","import * as pulumi from \"@pulumi/pulumi\";\nimport { Effect } from \"effect\";\nimport { PulumiError } from \"./errors.js\";\n\n/** `Output.promise()` is how the Pulumi runtime itself gets a settled value out\n * of an Output, but it is not part of the public `Output<T>` surface. */\ninterface PromisableOutput<T> {\n promise(withUnknowns?: boolean): Promise<T>;\n}\n\n/**\n * Lift a single Output into an Effect.\n *\n * `withUnknowns: true` matters during `pulumi preview`, where a not-yet-created\n * resource's outputs have no value: it resolves to Pulumi's unknown sentinel\n * instead of throwing, so a program that reads outputs still previews cleanly.\n *\n * @param output - The Output to resolve.\n * @returns An Effect yielding the settled value, failing with\n * {@link PulumiError} if the underlying promise rejects.\n *\n * @example\n * ```ts\n * const bucket = yield* eaws.s3.Bucket(\"assets\", {});\n * const id = yield* fromOutput(bucket.id); // string\n * ```\n *\n * @remarks Reading an Output only makes sense inside a running Pulumi program.\n * During `preview` the value may be the unknown sentinel rather than real data,\n * so don't branch on it to decide what to create.\n */\nexport const fromOutput = <T>(\n output: pulumi.Output<T>\n): Effect.Effect<T, PulumiError> =>\n Effect.tryPromise({\n try: () => (output as unknown as PromisableOutput<T>).promise(true),\n catch: (cause) => new PulumiError({ cause }),\n });\n\n/**\n * Lift a record of Outputs into a single Effect of the resolved record - use\n * this right after constructing a resource to grab several fields at once.\n *\n * Resolves them together via `pulumi.all`, so it costs one await rather than\n * one per field.\n *\n * @param outputs - A record whose values are all Outputs. Interfaces work as\n * well as object literals; the constraint is self-referential rather than\n * `Record<string, Output<any>>` precisely so interface-typed bags are accepted.\n * @returns An Effect yielding the same record with each value unwrapped.\n *\n * @example\n * ```ts\n * const bucket = yield* eaws.s3.Bucket(\"assets\", {});\n * const { id, arn } = yield* fromOutputs({ id: bucket.id, arn: bucket.arn });\n * ```\n */\nexport const fromOutputs = <T extends { [K in keyof T]: pulumi.Output<any> }>(\n outputs: T\n): Effect.Effect<{ [K in keyof T]: pulumi.Unwrap<T[K]> }, PulumiError> =>\n fromOutput(pulumi.all(outputs) as pulumi.Output<any>);\n","/**\n * effectify - auto-wrap a Pulumi provider package (e.g. @pulumi/aws,\n * @pulumi/cloudflare) so every resource constructor becomes an\n * Effect-returning factory, without the caller ever writing `Effect.sync`.\n *\n * Usage:\n *\n * import * as aws from \"@pulumi/aws\";\n * const eaws = effectify(aws);\n *\n * const program = Effect.gen(function* () {\n * const bucket = yield* eaws.s3.Bucket(\"my-bucket\", { forceDestroy: true });\n * // ^ Effect<aws.s3.Bucket, PulumiError> - no manual wrapping\n * });\n *\n * How it works:\n * - Every Pulumi resource class extends `pulumi.Resource` under the hood\n * (via CustomResource / ComponentResource). That's the runtime marker\n * used to tell \"this export is a resource constructor\" apart from \"this\n * export is a namespace object\" (e.g. `aws.s3`) or \"this export is an\n * invoke function\" (e.g. `aws.s3.getBucket`).\n * - Namespace objects get recursively proxied (lazily, memoized).\n * - CustomResource constructors get wrapped so any field in their args\n * object may *additionally* be an Effect - resolved (concurrently, they\n * are independent by construction) before construction. This is safe\n * because codegen guarantees CustomResource args are always\n * Record<string, Input<T>>.\n * - Wrapped constructors keep their static members: `Bucket.get(...)`,\n * `Bucket.isInstance(...)` and friends forward to the original class, so\n * the wrapped package can be the only import a program needs.\n * - ComponentResource constructors get wrapped with no arg-lifting - args\n * pass through exactly as declared, since component args aren't\n * guaranteed to be Input<T>-shaped (hand-authored, may do synchronous\n * work on a bare primitive inside the constructor).\n * - Invoke functions (`aws.s3.getBucket`) return an Effect instead of a\n * Promise. There is no runtime marker for \"this function is async\", so\n * the wrapper calls the function and inspects the result: a thenable\n * becomes an Effect, anything else is returned as-is. That means the\n * invoke *starts* at the call site (see the caveat on `wrapInvokeLike`);\n * `*Output` invoke variants return an Output, which is not thenable, so\n * they pass through untouched - matching the type-level mapping, which\n * only rewrites Promise-returning signatures.\n * - Everything else (enums, plain values, non-resource classes) passes\n * through untouched.\n *\n * Resource registration remains synchronous under the hood - Effect.try\n * runs its thunk immediately. This only removes hand-written wrapper\n * boilerplate, not Pulumi's execution model.\n */\n\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { Effect } from \"effect\";\nimport { PulumiError } from \"./errors.js\";\n\n// ---------------------------------------------------------------------------\n// Runtime type guards\n// ---------------------------------------------------------------------------\n\nconst isResourceConstructor = (\n value: unknown\n): value is new (...args: any[]) => pulumi.Resource =>\n typeof value === \"function\" &&\n (value === (pulumi.Resource as unknown) ||\n value.prototype instanceof pulumi.Resource);\n\nconst isComponentResourceConstructor = (\n Ctor: Function\n): Ctor is new (...args: any[]) => pulumi.ComponentResource =>\n Ctor === (pulumi.ComponentResource as unknown) ||\n Ctor.prototype instanceof pulumi.ComponentResource;\n\n/** An object whose string-keyed properties we only ever *read*. Distinct from\n * `Record<string, unknown>`, which additionally claims the properties are\n * writable and that the object declares an index signature - neither is true\n * of a codegen'd `BucketArgs`, and neither is something this module relies on. */\ntype UnknownProps = { readonly [key: string]: unknown };\n\n/** Is this a namespace to recurse into? The narrowed type is only ever handed\n * to `effectifyInner`, which takes `object` - so claim exactly that and no\n * more. */\nconst isNamespace = (value: unknown): value is object =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** Is this an args object whose entries we can scan for Effects? Same runtime\n * check as `isNamespace`, but a different question, so it gets the narrowing\n * that question needs: `object` would make `Object.entries` infer `any` values\n * and silently drop the `isEffect` filter's type safety. */\nconst isArgsObject = (value: unknown): value is UnknownProps =>\n isNamespace(value);\n\n/** Note: `pulumi.Output` is deliberately not thenable, so `*Output` invoke\n * variants fail this check and pass through unwrapped - keeping the runtime\n * behaviour aligned with the type mapping, which only rewrites\n * Promise-returning signatures. */\nconst isPromiseLike = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { then?: unknown }).then === \"function\";\n\n// ---------------------------------------------------------------------------\n// Type-level mapping\n// ---------------------------------------------------------------------------\n\n/** Allow any field of a CustomResource args object to *additionally* be an\n * Effect. Homomorphic, so optional fields stay optional and plain\n * `Input<T>`/`Output<T>` values keep working untouched. */\ntype LiftedArgs<A> = A extends object\n ? { [K in keyof A]: A[K] | Effect.Effect<A[K], PulumiError> }\n : A;\n\n/** Apply `LiftedArgs` to the second constructor parameter (the args object),\n * leaving `name` and `opts` alone. Mapping over the parameter tuple\n * homomorphically preserves labels and optionality, so constructors whose\n * args are optional stay callable as `Bucket(\"name\")`. */\ntype LiftArgsParam<P extends readonly unknown[]> = {\n [K in keyof P]: K extends \"1\" ? LiftedArgs<P[K]> : P[K];\n};\n\n/** The class's static side, minus `prototype`: `keyof` on a constructor type\n * yields exactly the statics (own and inherited, e.g. codegen'd `get` and\n * `isInstance`), which the runtime wrapper forwards to the original class. */\ntype StaticMembers<T> = Omit<T, \"prototype\">;\n\n/**\n * The type of {@link effectify}'s result: `T` with every resource constructor\n * and every `Promise`-returning invoke rewritten, and everything else left\n * alone.\n *\n * The cases, in the order they are tried:\n *\n * | Input | Becomes |\n * | --------------------------- | ---------------------------------------------- |\n * | `ComponentResource` class | factory returning `Effect`, args **not** lifted |\n * | `CustomResource` class | factory returning `Effect`, args lifted |\n * | other class | unchanged |\n * | `(...) => Promise<R>` | `(...) => Effect<R, PulumiError>` |\n * | other function | unchanged (includes `*Output` invokes) |\n * | object | mapped recursively |\n * | anything else | unchanged |\n *\n * Statics survive on the wrapped constructors, so `Bucket.get` and\n * `Bucket.isInstance` remain callable.\n */\nexport type Effectify<T> = T extends abstract new (\n ...params: infer P\n) => infer R\n ? R extends pulumi.ComponentResource\n ? ((...params: P) => Effect.Effect<R, PulumiError>) & StaticMembers<T>\n : R extends pulumi.CustomResource\n ? ((...params: LiftArgsParam<P>) => Effect.Effect<R, PulumiError>) &\n StaticMembers<T>\n : T\n : T extends (...args: infer A) => Promise<infer R>\n ? (...args: A) => Effect.Effect<R, PulumiError>\n : T extends (...args: any[]) => any\n ? T\n : T extends object\n ? { [K in keyof T]: Effectify<T[K]> }\n : T;\n\n// ---------------------------------------------------------------------------\n// Runtime implementation\n// ---------------------------------------------------------------------------\n\nconst proxyCache = new WeakMap<object, unknown>();\n\nconst isEffect = (value: unknown): value is Effect.Effect<unknown, unknown> =>\n Effect.isEffect(value);\n\nfunction resolveLiftedArgs(args: unknown): Effect.Effect<unknown, PulumiError> {\n if (!isArgsObject(args)) {\n return Effect.succeed(args);\n }\n\n const effectEntries = Object.entries(args).filter(([, v]) => isEffect(v));\n\n if (effectEntries.length === 0) {\n return Effect.succeed(args);\n }\n\n // The arg Effects are independent of one another, so resolve them\n // concurrently - it matters when several of them await slow Outputs.\n return Effect.map(\n Effect.all(\n effectEntries.map(([key, effectValue]) =>\n Effect.map(\n effectValue as Effect.Effect<unknown, PulumiError>,\n (resolved) => [key, resolved] as const\n )\n ),\n { concurrency: \"unbounded\" }\n ),\n (resolved) => ({ ...args, ...Object.fromEntries(resolved) })\n );\n}\n\nfunction wrapCustomResourceCtor(\n Ctor: new (...args: any[]) => pulumi.CustomResource\n) {\n return (name: string, args?: unknown, opts?: unknown) =>\n Effect.gen(function* () {\n const resolvedArgs = yield* resolveLiftedArgs(args);\n return yield* Effect.try({\n try: () => new Ctor(name, resolvedArgs, opts),\n catch: (cause) => new PulumiError({ cause }),\n });\n });\n}\n\nfunction wrapComponentResourceCtor(\n Ctor: new (...args: any[]) => pulumi.ComponentResource\n) {\n return (name: string, args?: unknown, opts?: unknown) =>\n Effect.try({\n try: () => new Ctor(name, args, opts),\n catch: (cause) => new PulumiError({ cause }),\n });\n}\n\n/** Forward static members (codegen'd `get`, `isInstance`, …) from the class\n * onto the factory. The factory's own and inherited properties (`name`,\n * `length`, `call`, …) win; anything else falls through to the class, so new\n * statics keep working without being enumerated here. A bonus of forwarding\n * `prototype` is that `x instanceof wrapped` still works. */\nconst withStatics = <F extends object>(factory: F, Ctor: Function): F =>\n new Proxy(factory, {\n get: (target, prop, receiver) =>\n Reflect.has(target, prop)\n ? Reflect.get(target, prop, receiver)\n : Reflect.get(Ctor, prop),\n has: (target, prop) => Reflect.has(target, prop) || Reflect.has(Ctor, prop),\n });\n\nfunction wrapResourceCtor(Ctor: new (...args: any[]) => pulumi.Resource) {\n const factory = isComponentResourceConstructor(Ctor)\n ? wrapComponentResourceCtor(Ctor)\n : wrapCustomResourceCtor(\n Ctor as new (...args: any[]) => pulumi.CustomResource\n );\n return withStatics(factory, Ctor);\n}\n\n/** Turn a Promise-returning invoke into an Effect-returning one, leaving\n * synchronous functions' behaviour untouched.\n *\n * A Proxy over the original function (rather than a new function) so `name`,\n * `length`, own properties and prototype all survive; only the call itself is\n * intercepted.\n *\n * Caveat, stated openly: whether a function is async is only knowable by\n * calling it, so the invoke *starts* when the factory is called - the Effect\n * resolves an already-in-flight Promise rather than deferring the call. Two\n * consequences:\n * - `Effect.retry` re-awaits the same call instead of re-invoking. To\n * re-invoke per attempt, wrap the call site: `Effect.suspend(() =>\n * eaws.getAmi(args))`.\n * - A discarded Effect must not surface as an unhandled rejection, so the\n * rejection is pre-observed on a side branch before the Effect awaits it.\n */\nfunction wrapInvokeLike(fn: Function): Function {\n return new Proxy(fn, {\n apply(target, thisArg, args) {\n const result = Reflect.apply(target, thisArg, args);\n if (!isPromiseLike(result)) {\n return result;\n }\n result.then(undefined, () => {});\n return Effect.tryPromise({\n try: () => result as Promise<unknown>,\n catch: (cause) => new PulumiError({ cause }),\n });\n },\n });\n}\n\n/** Wrapped constructors are cached so repeated reads of the same property\n * hand back the same function - identity checks like\n * `eaws.s3.Bucket === eaws.s3.Bucket` hold, and the `get` and\n * `getOwnPropertyDescriptor` traps agree on a property's value. */\nconst wrapperCache = new WeakMap<object, unknown>();\n\nfunction effectifyValue(value: unknown): unknown {\n if (isResourceConstructor(value)) {\n const cached = wrapperCache.get(value);\n if (cached) return cached;\n const wrapped = wrapResourceCtor(value);\n wrapperCache.set(value, wrapped);\n return wrapped;\n }\n\n if (typeof value === \"function\") {\n const cached = wrapperCache.get(value);\n if (cached) return cached;\n const wrapped = wrapInvokeLike(value);\n wrapperCache.set(value, wrapped);\n return wrapped;\n }\n\n if (isNamespace(value)) {\n return effectifyInner(value);\n }\n\n return value; // plain value, enum member, type-only export\n}\n\nfunction effectifyInner<T extends object>(mod: T): Effectify<T> {\n const cached = proxyCache.get(mod);\n if (cached) return cached as Effectify<T>;\n\n // The proxy target is a fresh plain object rather than `mod` itself: ES\n // module namespace objects (and @pulumi/aws's lazily-defined namespace\n // getters) expose non-configurable own properties, and a `get` trap that\n // returns a wrapper instead of the real value would violate the proxy\n // invariants for those. Forwarding to `mod` from a closure sidesteps that\n // entirely while keeping the lazy-loading behaviour intact.\n const proxy = new Proxy(Object.create(null) as T, {\n get(_target, prop) {\n return effectifyValue(Reflect.get(mod, prop));\n },\n has(_target, prop) {\n return Reflect.has(mod, prop);\n },\n ownKeys() {\n return Reflect.ownKeys(mod);\n },\n getOwnPropertyDescriptor(_target, prop) {\n const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);\n if (!descriptor) return undefined;\n // Must be reported as configurable - the target does not actually have\n // the property, so claiming otherwise breaks the proxy invariants.\n return {\n value: effectifyValue(Reflect.get(mod, prop)),\n enumerable: descriptor.enumerable,\n configurable: true,\n writable: true,\n };\n },\n set() {\n return false; // the wrapper is read-only\n },\n }) as Effectify<T>;\n\n proxyCache.set(mod, proxy);\n return proxy;\n}\n\n/**\n * Wrap a provider package (or any namespace) once, turning every resource\n * constructor into an `Effect`-returning factory and every `Promise`-returning\n * invoke into an `Effect`-returning function.\n *\n * Call this once per package at module scope and export the result - the\n * wrapper is cached, so repeated calls and repeated property reads hand back\n * the same objects, but there is no reason to re-wrap.\n *\n * @param mod - The provider package, or any namespace within one. Not mutated;\n * the result is a read-only proxy that forwards to it.\n * @returns A same-shaped view of `mod`, typed by {@link Effectify}.\n *\n * @example Constructing a resource\n * ```ts\n * import * as aws from \"@pulumi/aws\";\n * const eaws = effectify(aws);\n *\n * const program = Effect.gen(function* () {\n * const bucket = yield* eaws.s3.Bucket(\"assets\", { forceDestroy: true });\n * return bucket.id;\n * });\n * ```\n *\n * @example Passing an Effect as an argument\n * A `CustomResource`'s args may hold Effects, which are resolved concurrently\n * before the resource is constructed:\n * ```ts\n * yield* eaws.s3.BucketObject(\"readme\", {\n * bucket: bucketIdEffect,\n * content: \"hello\",\n * });\n * ```\n *\n * @throws Nothing. Failures surface in the returned Effect's error channel as\n * {@link PulumiError} - including synchronous throws from the constructor.\n *\n * @see {@link Effectify} for the type-level mapping.\n */\nexport function effectify<T extends object>(mod: T): Effectify<T> {\n return effectifyInner(mod);\n}\n","import type {\n ConfigMap,\n DestroyOptions,\n DestroyResult,\n LocalWorkspaceOptions,\n OutputMap,\n PreviewOptions,\n PreviewResult,\n PulumiFn,\n RefreshOptions,\n RefreshResult,\n RemoveOptions,\n Stack,\n UpOptions,\n UpResult,\n} from \"@pulumi/pulumi/automation/index.js\";\nimport { LocalWorkspace } from \"@pulumi/pulumi/automation/index.js\";\nimport { Effect } from \"effect\";\nimport { AutomationError } from \"./errors.js\";\n\n// ---------------------------------------------------------------------------\n// Primitives\n//\n// Each wraps one Automation API call, tagging failures with the stage they\n// came from. They are exported individually so callers can assemble their own\n// lifecycle - `deploy` below is only the common path.\n//\n// Every operation takes the matching Pulumi options type. That includes\n// `onOutput`: pass it to stream the CLI's progress as it happens. Without it\n// nothing is printed during what may be a multi-minute operation (the text is\n// still captured on the result's `stdout`, and on the error when one is\n// thrown, but only once the operation has finished).\n// ---------------------------------------------------------------------------\n\n/** Arguments for an inline program - the Pulumi program is a function in this\n * process, with no `Pulumi.yaml` on disk. */\nexport interface InlineStackOptions {\n /** Stack to select, created if absent. */\n readonly stackName: string;\n /** Project name to register the stack under. Chosen freely here, since\n * there is no `Pulumi.yaml` to take it from - but it is part of the stack's\n * identity in the backend, so changing it later points at a different\n * stack. */\n readonly projectName: string;\n /** The program itself. Runs in this process, so it needs no separate Node\n * runtime and can close over values from the caller. */\n readonly program: PulumiFn;\n readonly workspaceOptions?: LocalWorkspaceOptions;\n}\n\n/** Arguments for a local program - an existing Pulumi project on disk. */\nexport interface LocalStackOptions {\n /** Stack to select, created if absent. */\n readonly stackName: string;\n /** Directory holding the project's `Pulumi.yaml`. Its `name:` supplies the\n * project name, which is why there is no `projectName` here. */\n readonly workDir: string;\n readonly workspaceOptions?: LocalWorkspaceOptions;\n}\n\n/** Either flavour of stack. Discriminated at runtime by the presence of\n * `workDir`, so the two are not interchangeable: an inline program needs\n * `projectName`, a local one takes it from `Pulumi.yaml`. */\nexport type StackOptions = InlineStackOptions | LocalStackOptions;\n\nconst isLocal = (opts: StackOptions): opts is LocalStackOptions =>\n \"workDir\" in opts;\n\n/** Select the stack, creating it if it does not exist, and return the handle\n * every other operation here takes.\n *\n * Creating the workspace is itself work - it may write files and shell out to\n * the CLI - so hold on to the returned `Stack` rather than re-selecting before\n * each operation. */\nexport const createOrSelectStack = (\n opts: StackOptions\n): Effect.Effect<Stack, AutomationError> =>\n Effect.tryPromise({\n try: () =>\n isLocal(opts)\n ? LocalWorkspace.createOrSelectStack(\n { stackName: opts.stackName, workDir: opts.workDir },\n opts.workspaceOptions\n )\n : LocalWorkspace.createOrSelectStack(\n {\n stackName: opts.stackName,\n projectName: opts.projectName,\n program: opts.program,\n },\n opts.workspaceOptions\n ),\n catch: (cause) =>\n new AutomationError({ stage: \"createOrSelectStack\", cause }),\n });\n\n/** Apply the whole config map in one `setAllConfig` call - a single CLI\n * round-trip, where per-key `setConfig` costs one `pulumi config set`\n * invocation each. */\nexport const setStackConfig = (\n stack: Stack,\n config: ConfigMap | undefined\n): Effect.Effect<void, AutomationError> =>\n !config || Object.keys(config).length === 0\n ? Effect.void\n : Effect.tryPromise({\n try: () => stack.setAllConfig(config),\n catch: (cause) => new AutomationError({ stage: \"setConfig\", cause }),\n });\n\n/** Compute the plan without applying it.\n *\n * A preview is a full engine run against the provider, not a cheap check - see\n * {@link DeployOptions.preview} before pairing one with an `up`. */\nexport const previewStack = (\n stack: Stack,\n opts?: PreviewOptions\n): Effect.Effect<PreviewResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.preview(opts),\n catch: (cause) => new AutomationError({ stage: \"preview\", cause }),\n });\n\n/** Apply the program: create, update and delete resources to match it.\n *\n * The result carries the stack's outputs and a summary; pass `onOutput` to\n * watch progress while it runs. */\nexport const upStack = (\n stack: Stack,\n opts?: UpOptions\n): Effect.Effect<UpResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.up(opts),\n catch: (cause) => new AutomationError({ stage: \"up\", cause }),\n });\n\n/** Refresh the stack's state from the actual cloud resources, without\n * changing them - what to run when state may have drifted (manual console\n * edits, a crashed update) before deciding what to do about it. */\nexport const refreshStack = (\n stack: Stack,\n opts?: RefreshOptions\n): Effect.Effect<RefreshResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.refresh(opts),\n catch: (cause) => new AutomationError({ stage: \"refresh\", cause }),\n });\n\n/** Read the stack's current outputs without running an update. */\nexport const stackOutputs = (\n stack: Stack\n): Effect.Effect<OutputMap, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.outputs(),\n catch: (cause) => new AutomationError({ stage: \"outputs\", cause }),\n });\n\n/** Destroy the stack's resources. The stack itself remains registered with\n * the backend - see `removeStack` / `teardownStack` to delete it too. */\nexport const destroyStack = (\n stack: Stack,\n opts?: DestroyOptions\n): Effect.Effect<DestroyResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.destroy(opts),\n catch: (cause) => new AutomationError({ stage: \"destroy\", cause }),\n });\n\n/** Delete the stack and its configuration and history from the backend.\n *\n * This does not destroy resources - run `destroyStack` first, or use\n * `teardownStack`. Pulumi refuses to remove a stack that still has resources\n * unless `RemoveOptions.force` is set, and forcing it orphans them: they keep\n * existing and billing with nothing tracking them. */\nexport const removeStack = (\n stack: Stack,\n opts?: RemoveOptions\n): Effect.Effect<void, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.workspace.removeStack(stack.name, opts),\n catch: (cause) => new AutomationError({ stage: \"removeStack\", cause }),\n });\n\n/** Full teardown: destroy the resources, then delete the stack.\n *\n * `destroyStack` alone leaves an empty stack behind, so anything creating\n * stacks per-run (ephemeral environments, tests naming stacks by timestamp)\n * accumulates them in the backend. */\nexport const teardownStack = (\n stack: Stack,\n opts?: { readonly destroy?: DestroyOptions; readonly remove?: RemoveOptions }\n): Effect.Effect<DestroyResult, AutomationError> =>\n Effect.gen(function* () {\n const result = yield* destroyStack(stack, opts?.destroy);\n yield* removeStack(stack, opts?.remove);\n return result;\n });\n\n// ---------------------------------------------------------------------------\n// Convenience lifecycle\n// ---------------------------------------------------------------------------\n\n/** {@link deploy}'s arguments: the stack to target, plus what to do with it. */\nexport type DeployOptions = StackOptions & {\n /** Config to apply before the update, in one `setAllConfig` call. Keys are\n * fully qualified (`\"my-project:myKey\"`). */\n readonly config?: ConfigMap;\n /** Options forwarded to the update - `onOutput` to stream progress,\n * `parallel`, `target`, and so on. */\n readonly up?: UpOptions;\n /** Run `preview` before `up`, returning its result.\n *\n * Off by default: a preview is a full engine run against the provider, so\n * previewing and then immediately upping does the work twice. `up` reports\n * the same failures, so this earns its cost only when you want the plan\n * itself. */\n readonly preview?: PreviewOptions | boolean;\n};\n\n/** What {@link deploy} hands back. */\nexport interface DeployResult {\n /** The selected stack, so teardown needs no second `createOrSelectStack`. */\n readonly stack: Stack;\n /** The update's result - `outputs` and `summary` live here. */\n readonly result: UpResult;\n /** Present only when `preview` was requested. */\n readonly preview?: PreviewResult;\n}\n\n/**\n * Select or create the stack, apply config, optionally preview, then up.\n *\n * The common path, assembled from the primitives above. Anything more\n * involved - refreshing first, inspecting the plan before deciding, retrying a\n * stage - should compose those directly rather than grow options here.\n *\n * @param opts - Which stack, and what to do with it.\n * @returns The stack handle alongside the results, so callers can tear down\n * afterwards without re-selecting.\n *\n * @example Deploy, use the outputs, then always tear down\n * ```ts\n * Effect.scoped(\n * Effect.gen(function* () {\n * const { result } = yield* Effect.acquireRelease(\n * deploy({ stackName, projectName, program, up: { onOutput } }),\n * ({ stack }) => teardownStack(stack).pipe(Effect.ignore)\n * );\n * return result.outputs.bucketId?.value;\n * })\n * );\n * ```\n */\nexport const deploy = (\n opts: DeployOptions\n): Effect.Effect<DeployResult, AutomationError> =>\n Effect.gen(function* () {\n const stack = yield* createOrSelectStack(opts);\n yield* setStackConfig(stack, opts.config);\n\n const preview = opts.preview\n ? yield* previewStack(\n stack,\n typeof opts.preview === \"boolean\" ? undefined : opts.preview\n )\n : undefined;\n\n const result = yield* upStack(stack, opts.up);\n return { stack, result, preview };\n });\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Data","Effect","pulumi","pulumi","Effect","Effect","LocalWorkspace"],"sources":["../src/errors.ts","../src/output-bridge.ts","../src/effectify.ts","../src/automation.ts"],"sourcesContent":["import { Data } from \"effect\";\n\nconst describeCause = (cause: unknown): string =>\n cause instanceof Error ? cause.message : String(cause);\n\n/**\n * Any synchronous failure constructing a resource (bad args, provider\n * validation, etc.), or a failure resolving an Output's promise.\n *\n * Tagged `\"PulumiError\"`, so it can be matched by tag rather than by\n * `instanceof`:\n *\n * @example\n * ```ts\n * program.pipe(\n * Effect.catchTag(\"PulumiError\", (e) => Effect.logError(e.message))\n * );\n * ```\n */\nexport class PulumiError extends Data.TaggedError(\"PulumiError\")<{\n /** The original thrown value or rejection reason, unwrapped and unmodified.\n * Not necessarily an `Error`. */\n readonly cause: unknown;\n}> {\n /** Derived so anything reading `.message` - plain logging, test failure\n * output, non-Effect error handling - sees the underlying failure instead\n * of an empty string. */\n get message(): string {\n return describeCause(this.cause);\n }\n}\n\n/**\n * Failure from an Automation API lifecycle call (up/preview/destroy/select).\n *\n * `stage` says which call failed, which matters most in the composite\n * operations: a failed `deploy` could have died selecting the stack, applying\n * config, or running the update, and the three want different responses.\n *\n * @example\n * ```ts\n * deploy(opts).pipe(\n * Effect.catchTag(\"AutomationError\", (e) =>\n * e.stage === \"createOrSelectStack\"\n * ? Effect.fail(new BackendUnreachable())\n * : Effect.logError(e.message)\n * )\n * );\n * ```\n */\nexport class AutomationError extends Data.TaggedError(\"AutomationError\")<{\n /** Which Automation API call failed. Named for the wrapper that raised it,\n * so `deploy`'s failures still report the underlying stage. */\n readonly stage:\n | \"createOrSelectStack\"\n | \"setConfig\"\n | \"up\"\n | \"preview\"\n | \"refresh\"\n | \"outputs\"\n | \"destroy\"\n | \"removeStack\";\n /** The rejection reason from the Automation API. For a failed update this is\n * usually a `CommandError` carrying the CLI's stdout and stderr. */\n readonly cause: unknown;\n}> {\n /** `\"<stage> failed: <cause>\"` - the stage is included because the cause\n * alone rarely says which operation produced it. */\n get message(): string {\n return `${this.stage} failed: ${describeCause(this.cause)}`;\n }\n}\n","import * as pulumi from \"@pulumi/pulumi\";\nimport { Effect } from \"effect\";\nimport { PulumiError } from \"./errors.js\";\n\n/** `Output.promise()` is how the Pulumi runtime itself gets a settled value out\n * of an Output, but it is not part of the public `Output<T>` surface. */\ninterface PromisableOutput<T> {\n promise(withUnknowns?: boolean): Promise<T>;\n}\n\n/**\n * Lift a single Output into an Effect.\n *\n * `withUnknowns: true` matters during `pulumi preview`, where a not-yet-created\n * resource's outputs have no value: it resolves to Pulumi's unknown sentinel\n * instead of throwing, so a program that reads outputs still previews cleanly.\n *\n * @param output - The Output to resolve.\n * @returns An Effect yielding the settled value, failing with\n * {@link PulumiError} if the underlying promise rejects.\n *\n * @example\n * ```ts\n * const bucket = yield* eaws.s3.Bucket(\"assets\", {});\n * const id = yield* fromOutput(bucket.id); // string\n * ```\n *\n * @remarks Reading an Output only makes sense inside a running Pulumi program.\n * During `preview` the value may be the unknown sentinel rather than real data,\n * so don't branch on it to decide what to create.\n */\nexport const fromOutput = <T>(\n output: pulumi.Output<T>\n): Effect.Effect<T, PulumiError> =>\n Effect.tryPromise({\n try: () => (output as unknown as PromisableOutput<T>).promise(true),\n catch: (cause) => new PulumiError({ cause }),\n });\n\n/**\n * Lift a record of Outputs into a single Effect of the resolved record - use\n * this right after constructing a resource to grab several fields at once.\n *\n * Resolves them together via `pulumi.all`, so it costs one await rather than\n * one per field.\n *\n * @param outputs - A record whose values are all Outputs. Interfaces work as\n * well as object literals; the constraint is self-referential rather than\n * `Record<string, Output<any>>` precisely so interface-typed bags are accepted.\n * @returns An Effect yielding the same record with each value unwrapped.\n *\n * @example\n * ```ts\n * const bucket = yield* eaws.s3.Bucket(\"assets\", {});\n * const { id, arn } = yield* fromOutputs({ id: bucket.id, arn: bucket.arn });\n * ```\n */\nexport const fromOutputs = <T extends { [K in keyof T]: pulumi.Output<any> }>(\n outputs: T\n): Effect.Effect<{ [K in keyof T]: pulumi.Unwrap<T[K]> }, PulumiError> =>\n fromOutput(pulumi.all(outputs) as pulumi.Output<any>);\n","/**\n * effectify - auto-wrap a Pulumi provider package (e.g. @pulumi/aws,\n * @pulumi/cloudflare) so every resource constructor becomes an\n * Effect-returning factory, without the caller ever writing `Effect.sync`.\n *\n * Usage:\n *\n * import * as aws from \"@pulumi/aws\";\n * const eaws = effectify(aws);\n *\n * const program = Effect.gen(function* () {\n * const bucket = yield* eaws.s3.Bucket(\"my-bucket\", { forceDestroy: true });\n * // ^ Effect<aws.s3.Bucket, PulumiError> - no manual wrapping\n * });\n *\n * How it works:\n * - Every Pulumi resource class extends `pulumi.Resource` under the hood\n * (via CustomResource / ComponentResource). That's the runtime marker\n * used to tell \"this export is a resource constructor\" apart from \"this\n * export is a namespace object\" (e.g. `aws.s3`) or \"this export is an\n * invoke function\" (e.g. `aws.s3.getBucket`).\n * - Namespace objects get recursively proxied (lazily, memoized).\n * - CustomResource constructors get wrapped so any field in their args\n * object may *additionally* be an Effect - resolved (concurrently, they\n * are independent by construction) before construction. This is safe\n * because codegen guarantees CustomResource args are always\n * Record<string, Input<T>>.\n * - Wrapped constructors keep their static members: `Bucket.get(...)`,\n * `Bucket.isInstance(...)` and friends forward to the original class, so\n * the wrapped package can be the only import a program needs.\n * - ComponentResource constructors get wrapped with no arg-lifting - args\n * pass through exactly as declared, since component args aren't\n * guaranteed to be Input<T>-shaped (hand-authored, may do synchronous\n * work on a bare primitive inside the constructor).\n * - Invoke functions (`aws.s3.getBucket`) return an Effect instead of a\n * Promise. There is no runtime marker for \"this function is async\", so\n * the wrapper calls the function and inspects the result: a thenable\n * becomes an Effect, anything else is returned as-is. That means the\n * invoke *starts* at the call site (see the caveat on `wrapInvokeLike`);\n * `*Output` invoke variants return an Output, which is not thenable, so\n * they pass through untouched - matching the type-level mapping, which\n * only rewrites Promise-returning signatures.\n * - Everything else (enums, plain values, non-resource classes) passes\n * through untouched.\n *\n * Resource registration remains synchronous under the hood - Effect.try\n * runs its thunk immediately. This only removes hand-written wrapper\n * boilerplate, not Pulumi's execution model.\n */\n\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { Effect } from \"effect\";\nimport { PulumiError } from \"./errors.js\";\n\n// ---------------------------------------------------------------------------\n// Runtime type guards\n// ---------------------------------------------------------------------------\n\nconst isResourceConstructor = (\n value: unknown\n): value is new (...args: any[]) => pulumi.Resource =>\n typeof value === \"function\" &&\n (value === (pulumi.Resource as unknown) ||\n value.prototype instanceof pulumi.Resource);\n\nconst isComponentResourceConstructor = (\n Ctor: Function\n): Ctor is new (...args: any[]) => pulumi.ComponentResource =>\n Ctor === (pulumi.ComponentResource as unknown) ||\n Ctor.prototype instanceof pulumi.ComponentResource;\n\n/** An object whose string-keyed properties we only ever *read*. Distinct from\n * `Record<string, unknown>`, which additionally claims the properties are\n * writable and that the object declares an index signature - neither is true\n * of a codegen'd `BucketArgs`, and neither is something this module relies on. */\ntype UnknownProps = { readonly [key: string]: unknown };\n\n/** Is this a namespace to recurse into? The narrowed type is only ever handed\n * to `effectifyInner`, which takes `object` - so claim exactly that and no\n * more. */\nconst isNamespace = (value: unknown): value is object =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/** Is this an args object whose entries we can scan for Effects? Same runtime\n * check as `isNamespace`, but a different question, so it gets the narrowing\n * that question needs: `object` would make `Object.entries` infer `any` values\n * and silently drop the `isEffect` filter's type safety. */\nconst isArgsObject = (value: unknown): value is UnknownProps =>\n isNamespace(value);\n\n/** Note: `pulumi.Output` is deliberately not thenable, so `*Output` invoke\n * variants fail this check and pass through unwrapped - keeping the runtime\n * behaviour aligned with the type mapping, which only rewrites\n * Promise-returning signatures. */\nconst isPromiseLike = (value: unknown): value is PromiseLike<unknown> =>\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { then?: unknown }).then === \"function\";\n\n// ---------------------------------------------------------------------------\n// Type-level mapping\n// ---------------------------------------------------------------------------\n\n/** Allow any field of a CustomResource args object to *additionally* be an\n * Effect. Homomorphic, so optional fields stay optional and plain\n * `Input<T>`/`Output<T>` values keep working untouched. */\ntype LiftedArgs<A> = A extends object\n ? { [K in keyof A]: A[K] | Effect.Effect<A[K], PulumiError> }\n : A;\n\n/** Apply `LiftedArgs` to the second constructor parameter (the args object),\n * leaving `name` and `opts` alone. Mapping over the parameter tuple\n * homomorphically preserves labels and optionality, so constructors whose\n * args are optional stay callable as `Bucket(\"name\")`. */\ntype LiftArgsParam<P extends readonly unknown[]> = {\n [K in keyof P]: K extends \"1\" ? LiftedArgs<P[K]> : P[K];\n};\n\n/** The class's static side, minus `prototype`: `keyof` on a constructor type\n * yields exactly the statics (own and inherited, e.g. codegen'd `get` and\n * `isInstance`), which the runtime wrapper forwards to the original class. */\ntype StaticMembers<T> = Omit<T, \"prototype\">;\n\n/**\n * The type of {@link effectify}'s result: `T` with every resource constructor\n * and every `Promise`-returning invoke rewritten, and everything else left\n * alone.\n *\n * The cases, in the order they are tried:\n *\n * | Input | Becomes |\n * | --------------------------- | ---------------------------------------------- |\n * | `ComponentResource` class | factory returning `Effect`, args **not** lifted |\n * | `CustomResource` class | factory returning `Effect`, args lifted |\n * | other class | unchanged |\n * | `(...) => Promise<R>` | `(...) => Effect<R, PulumiError>` |\n * | other function | unchanged (includes `*Output` invokes) |\n * | object | mapped recursively |\n * | anything else | unchanged |\n *\n * Statics survive on the wrapped constructors, so `Bucket.get` and\n * `Bucket.isInstance` remain callable.\n */\nexport type Effectify<T> = T extends abstract new (\n ...params: infer P\n) => infer R\n ? R extends pulumi.ComponentResource\n ? ((...params: P) => Effect.Effect<R, PulumiError>) & StaticMembers<T>\n : R extends pulumi.CustomResource\n ? ((...params: LiftArgsParam<P>) => Effect.Effect<R, PulumiError>) &\n StaticMembers<T>\n : T\n : T extends (...args: infer A) => Promise<infer R>\n ? (...args: A) => Effect.Effect<R, PulumiError>\n : T extends (...args: any[]) => any\n ? T\n : T extends object\n ? { [K in keyof T]: Effectify<T[K]> }\n : T;\n\n// ---------------------------------------------------------------------------\n// Runtime implementation\n// ---------------------------------------------------------------------------\n\nconst proxyCache = new WeakMap<object, unknown>();\n\nconst isEffect = (value: unknown): value is Effect.Effect<unknown, unknown> =>\n Effect.isEffect(value);\n\nfunction resolveLiftedArgs(args: unknown): Effect.Effect<unknown, PulumiError> {\n if (!isArgsObject(args)) {\n return Effect.succeed(args);\n }\n\n const effectEntries = Object.entries(args).filter(([, v]) => isEffect(v));\n\n if (effectEntries.length === 0) {\n return Effect.succeed(args);\n }\n\n // The arg Effects are independent of one another, so resolve them\n // concurrently - it matters when several of them await slow Outputs.\n return Effect.map(\n Effect.all(\n effectEntries.map(([key, effectValue]) =>\n Effect.map(\n effectValue as Effect.Effect<unknown, PulumiError>,\n (resolved) => [key, resolved] as const\n )\n ),\n { concurrency: \"unbounded\" }\n ),\n (resolved) => ({ ...args, ...Object.fromEntries(resolved) })\n );\n}\n\nfunction wrapCustomResourceCtor(\n Ctor: new (...args: any[]) => pulumi.CustomResource\n) {\n return (name: string, args?: unknown, opts?: unknown) =>\n Effect.gen(function* () {\n const resolvedArgs = yield* resolveLiftedArgs(args);\n return yield* Effect.try({\n try: () => new Ctor(name, resolvedArgs, opts),\n catch: (cause) => new PulumiError({ cause }),\n });\n });\n}\n\nfunction wrapComponentResourceCtor(\n Ctor: new (...args: any[]) => pulumi.ComponentResource\n) {\n return (name: string, args?: unknown, opts?: unknown) =>\n Effect.try({\n try: () => new Ctor(name, args, opts),\n catch: (cause) => new PulumiError({ cause }),\n });\n}\n\n/** Forward static members (codegen'd `get`, `isInstance`, …) from the class\n * onto the factory. The factory's own and inherited properties (`name`,\n * `length`, `call`, …) win; anything else falls through to the class, so new\n * statics keep working without being enumerated here. A bonus of forwarding\n * `prototype` is that `x instanceof wrapped` still works. */\nconst withStatics = <F extends object>(factory: F, Ctor: Function): F =>\n new Proxy(factory, {\n get: (target, prop, receiver) =>\n Reflect.has(target, prop)\n ? Reflect.get(target, prop, receiver)\n : Reflect.get(Ctor, prop),\n has: (target, prop) => Reflect.has(target, prop) || Reflect.has(Ctor, prop),\n });\n\nfunction wrapResourceCtor(Ctor: new (...args: any[]) => pulumi.Resource) {\n const factory = isComponentResourceConstructor(Ctor)\n ? wrapComponentResourceCtor(Ctor)\n : wrapCustomResourceCtor(\n Ctor as new (...args: any[]) => pulumi.CustomResource\n );\n return withStatics(factory, Ctor);\n}\n\n/** Turn a Promise-returning invoke into an Effect-returning one, leaving\n * synchronous functions' behaviour untouched.\n *\n * A Proxy over the original function (rather than a new function) so `name`,\n * `length`, own properties and prototype all survive; only the call itself is\n * intercepted.\n *\n * Caveat, stated openly: whether a function is async is only knowable by\n * calling it, so the invoke *starts* when the factory is called - the Effect\n * resolves an already-in-flight Promise rather than deferring the call. Two\n * consequences:\n * - `Effect.retry` re-awaits the same call instead of re-invoking. To\n * re-invoke per attempt, wrap the call site: `Effect.suspend(() =>\n * eaws.getAmi(args))`.\n * - A discarded Effect must not surface as an unhandled rejection, so the\n * rejection is pre-observed on a side branch before the Effect awaits it.\n */\nfunction wrapInvokeLike(fn: Function): Function {\n return new Proxy(fn, {\n apply(target, thisArg, args) {\n const result = Reflect.apply(target, thisArg, args);\n if (!isPromiseLike(result)) {\n return result;\n }\n result.then(undefined, () => {});\n return Effect.tryPromise({\n try: () => result as Promise<unknown>,\n catch: (cause) => new PulumiError({ cause }),\n });\n },\n });\n}\n\n/** Wrapped constructors are cached so repeated reads of the same property\n * hand back the same function - identity checks like\n * `eaws.s3.Bucket === eaws.s3.Bucket` hold, and the `get` and\n * `getOwnPropertyDescriptor` traps agree on a property's value. */\nconst wrapperCache = new WeakMap<object, unknown>();\n\nfunction effectifyValue(value: unknown): unknown {\n if (isResourceConstructor(value)) {\n const cached = wrapperCache.get(value);\n if (cached) return cached;\n const wrapped = wrapResourceCtor(value);\n wrapperCache.set(value, wrapped);\n return wrapped;\n }\n\n if (typeof value === \"function\") {\n const cached = wrapperCache.get(value);\n if (cached) return cached;\n const wrapped = wrapInvokeLike(value);\n wrapperCache.set(value, wrapped);\n return wrapped;\n }\n\n if (isNamespace(value)) {\n return effectifyInner(value);\n }\n\n return value; // plain value, enum member, type-only export\n}\n\nfunction effectifyInner<T extends object>(mod: T): Effectify<T> {\n const cached = proxyCache.get(mod);\n if (cached) return cached as Effectify<T>;\n\n // The proxy target is a fresh plain object rather than `mod` itself: ES\n // module namespace objects (and @pulumi/aws's lazily-defined namespace\n // getters) expose non-configurable own properties, and a `get` trap that\n // returns a wrapper instead of the real value would violate the proxy\n // invariants for those. Forwarding to `mod` from a closure sidesteps that\n // entirely while keeping the lazy-loading behaviour intact.\n const proxy = new Proxy(Object.create(null) as T, {\n get(_target, prop) {\n return effectifyValue(Reflect.get(mod, prop));\n },\n has(_target, prop) {\n return Reflect.has(mod, prop);\n },\n ownKeys() {\n return Reflect.ownKeys(mod);\n },\n getOwnPropertyDescriptor(_target, prop) {\n const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);\n if (!descriptor) return undefined;\n // Must be reported as configurable - the target does not actually have\n // the property, so claiming otherwise breaks the proxy invariants.\n return {\n value: effectifyValue(Reflect.get(mod, prop)),\n enumerable: descriptor.enumerable,\n configurable: true,\n writable: true,\n };\n },\n set() {\n return false; // the wrapper is read-only\n },\n }) as Effectify<T>;\n\n proxyCache.set(mod, proxy);\n return proxy;\n}\n\n/**\n * Wrap a provider package (or any namespace) once, turning every resource\n * constructor into an `Effect`-returning factory and every `Promise`-returning\n * invoke into an `Effect`-returning function.\n *\n * Call this once per package at module scope and export the result - the\n * wrapper is cached, so repeated calls and repeated property reads hand back\n * the same objects, but there is no reason to re-wrap.\n *\n * @param mod - The provider package, or any namespace within one. Not mutated;\n * the result is a read-only proxy that forwards to it.\n * @returns A same-shaped view of `mod`, typed by {@link Effectify}.\n *\n * @example Constructing a resource\n * ```ts\n * import * as aws from \"@pulumi/aws\";\n * const eaws = effectify(aws);\n *\n * const program = Effect.gen(function* () {\n * const bucket = yield* eaws.s3.Bucket(\"assets\", { forceDestroy: true });\n * return bucket.id;\n * });\n * ```\n *\n * @example Passing an Effect as an argument\n * A `CustomResource`'s args may hold Effects, which are resolved concurrently\n * before the resource is constructed:\n * ```ts\n * yield* eaws.s3.BucketObject(\"readme\", {\n * bucket: bucketIdEffect,\n * content: \"hello\",\n * });\n * ```\n *\n * @throws Nothing. Failures surface in the returned Effect's error channel as\n * {@link PulumiError} - including synchronous throws from the constructor.\n *\n * @see {@link Effectify} for the type-level mapping.\n */\nexport function effectify<T extends object>(mod: T): Effectify<T> {\n return effectifyInner(mod);\n}\n","import type {\n ConfigMap,\n DestroyOptions,\n DestroyResult,\n LocalWorkspaceOptions,\n OutputMap,\n PreviewOptions,\n PreviewResult,\n PulumiFn,\n RefreshOptions,\n RefreshResult,\n RemoveOptions,\n Stack,\n UpOptions,\n UpResult,\n} from \"@pulumi/pulumi/automation/index.js\";\nimport { LocalWorkspace } from \"@pulumi/pulumi/automation/index.js\";\nimport { Effect } from \"effect\";\nimport { AutomationError } from \"./errors.js\";\n\n// ---------------------------------------------------------------------------\n// Primitives\n//\n// Each wraps one Automation API call, tagging failures with the stage they\n// came from. They are exported individually so callers can assemble their own\n// lifecycle - `deploy` below is only the common path.\n//\n// Every operation takes the matching Pulumi options type. That includes\n// `onOutput`: pass it to stream the CLI's progress as it happens. Without it\n// nothing is printed during what may be a multi-minute operation (the text is\n// still captured on the result's `stdout`, and on the error when one is\n// thrown, but only once the operation has finished).\n// ---------------------------------------------------------------------------\n\n/** Arguments for an inline program - the Pulumi program is a function in this\n * process, with no `Pulumi.yaml` on disk. */\nexport interface InlineStackOptions {\n /** Stack to select, created if absent. */\n readonly stackName: string;\n /** Project name to register the stack under. Chosen freely here, since\n * there is no `Pulumi.yaml` to take it from - but it is part of the stack's\n * identity in the backend, so changing it later points at a different\n * stack. */\n readonly projectName: string;\n /** The program itself. Runs in this process, so it needs no separate Node\n * runtime and can close over values from the caller. */\n readonly program: PulumiFn;\n readonly workspaceOptions?: LocalWorkspaceOptions;\n}\n\n/** Arguments for a local program - an existing Pulumi project on disk. */\nexport interface LocalStackOptions {\n /** Stack to select, created if absent. */\n readonly stackName: string;\n /** Directory holding the project's `Pulumi.yaml`. Its `name:` supplies the\n * project name, which is why there is no `projectName` here. */\n readonly workDir: string;\n readonly workspaceOptions?: LocalWorkspaceOptions;\n}\n\n/** Either flavour of stack. Discriminated at runtime by the presence of\n * `workDir`, so the two are not interchangeable: an inline program needs\n * `projectName`, a local one takes it from `Pulumi.yaml`. */\nexport type StackOptions = InlineStackOptions | LocalStackOptions;\n\nconst isLocal = (opts: StackOptions): opts is LocalStackOptions =>\n \"workDir\" in opts;\n\n/** Select the stack, creating it if it does not exist, and return the handle\n * every other operation here takes.\n *\n * Creating the workspace is itself work - it may write files and shell out to\n * the CLI - so hold on to the returned `Stack` rather than re-selecting before\n * each operation. */\nexport const createOrSelectStack = (\n opts: StackOptions\n): Effect.Effect<Stack, AutomationError> =>\n Effect.tryPromise({\n try: () =>\n isLocal(opts)\n ? LocalWorkspace.createOrSelectStack(\n { stackName: opts.stackName, workDir: opts.workDir },\n opts.workspaceOptions\n )\n : LocalWorkspace.createOrSelectStack(\n {\n stackName: opts.stackName,\n projectName: opts.projectName,\n program: opts.program,\n },\n opts.workspaceOptions\n ),\n catch: (cause) =>\n new AutomationError({ stage: \"createOrSelectStack\", cause }),\n });\n\n/** Apply the whole config map in one `setAllConfig` call - a single CLI\n * round-trip, where per-key `setConfig` costs one `pulumi config set`\n * invocation each. */\nexport const setStackConfig = (\n stack: Stack,\n config: ConfigMap | undefined\n): Effect.Effect<void, AutomationError> =>\n !config || Object.keys(config).length === 0\n ? Effect.void\n : Effect.tryPromise({\n try: () => stack.setAllConfig(config),\n catch: (cause) => new AutomationError({ stage: \"setConfig\", cause }),\n });\n\n/** Compute the plan without applying it.\n *\n * A preview is a full engine run against the provider, not a cheap check - see\n * {@link DeployOptions.preview} before pairing one with an `up`. */\nexport const previewStack = (\n stack: Stack,\n opts?: PreviewOptions\n): Effect.Effect<PreviewResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.preview(opts),\n catch: (cause) => new AutomationError({ stage: \"preview\", cause }),\n });\n\n/** Apply the program: create, update and delete resources to match it.\n *\n * The result carries the stack's outputs and a summary; pass `onOutput` to\n * watch progress while it runs. */\nexport const upStack = (\n stack: Stack,\n opts?: UpOptions\n): Effect.Effect<UpResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.up(opts),\n catch: (cause) => new AutomationError({ stage: \"up\", cause }),\n });\n\n/** Refresh the stack's state from the actual cloud resources, without\n * changing them - what to run when state may have drifted (manual console\n * edits, a crashed update) before deciding what to do about it. */\nexport const refreshStack = (\n stack: Stack,\n opts?: RefreshOptions\n): Effect.Effect<RefreshResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.refresh(opts),\n catch: (cause) => new AutomationError({ stage: \"refresh\", cause }),\n });\n\n/** Read the stack's current outputs without running an update. */\nexport const stackOutputs = (\n stack: Stack\n): Effect.Effect<OutputMap, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.outputs(),\n catch: (cause) => new AutomationError({ stage: \"outputs\", cause }),\n });\n\n/** Destroy the stack's resources. The stack itself remains registered with\n * the backend - see `removeStack` / `teardownStack` to delete it too. */\nexport const destroyStack = (\n stack: Stack,\n opts?: DestroyOptions\n): Effect.Effect<DestroyResult, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.destroy(opts),\n catch: (cause) => new AutomationError({ stage: \"destroy\", cause }),\n });\n\n/** Delete the stack and its configuration and history from the backend.\n *\n * This does not destroy resources - run `destroyStack` first, or use\n * `teardownStack`. Pulumi refuses to remove a stack that still has resources\n * unless `RemoveOptions.force` is set, and forcing it orphans them: they keep\n * existing and billing with nothing tracking them. */\nexport const removeStack = (\n stack: Stack,\n opts?: RemoveOptions\n): Effect.Effect<void, AutomationError> =>\n Effect.tryPromise({\n try: () => stack.workspace.removeStack(stack.name, opts),\n catch: (cause) => new AutomationError({ stage: \"removeStack\", cause }),\n });\n\n/** Full teardown: destroy the resources, then delete the stack.\n *\n * `destroyStack` alone leaves an empty stack behind, so anything creating\n * stacks per-run (ephemeral environments, tests naming stacks by timestamp)\n * accumulates them in the backend. */\nexport const teardownStack = (\n stack: Stack,\n opts?: { readonly destroy?: DestroyOptions; readonly remove?: RemoveOptions }\n): Effect.Effect<DestroyResult, AutomationError> =>\n Effect.gen(function* () {\n const result = yield* destroyStack(stack, opts?.destroy);\n yield* removeStack(stack, opts?.remove);\n return result;\n });\n\n// ---------------------------------------------------------------------------\n// Convenience lifecycle\n// ---------------------------------------------------------------------------\n\n/** {@link deploy}'s arguments: the stack to target, plus what to do with it. */\nexport type DeployOptions = StackOptions & {\n /** Config to apply before the update, in one `setAllConfig` call. Keys are\n * fully qualified (`\"my-project:myKey\"`). */\n readonly config?: ConfigMap;\n /** Options forwarded to the update - `onOutput` to stream progress,\n * `parallel`, `target`, and so on. */\n readonly up?: UpOptions;\n /** Run `preview` before `up`, returning its result.\n *\n * Off by default: a preview is a full engine run against the provider, so\n * previewing and then immediately upping does the work twice. `up` reports\n * the same failures, so this earns its cost only when you want the plan\n * itself. */\n readonly preview?: PreviewOptions | boolean;\n};\n\n/** What {@link deploy} hands back. */\nexport interface DeployResult {\n /** The selected stack, so teardown needs no second `createOrSelectStack`. */\n readonly stack: Stack;\n /** The update's result - `outputs` and `summary` live here. */\n readonly result: UpResult;\n /** Present only when `preview` was requested. */\n readonly preview?: PreviewResult;\n}\n\n/**\n * Select or create the stack, apply config, optionally preview, then up.\n *\n * The common path, assembled from the primitives above. Anything more\n * involved - refreshing first, inspecting the plan before deciding, retrying a\n * stage - should compose those directly rather than grow options here.\n *\n * @param opts - Which stack, and what to do with it.\n * @returns The stack handle alongside the results, so callers can tear down\n * afterwards without re-selecting.\n *\n * @example Deploy, use the outputs, then always tear down\n * ```ts\n * Effect.scoped(\n * Effect.gen(function* () {\n * const { result } = yield* Effect.acquireRelease(\n * deploy({ stackName, projectName, program, up: { onOutput } }),\n * ({ stack }) => teardownStack(stack).pipe(Effect.ignore)\n * );\n * return result.outputs.bucketId?.value;\n * })\n * );\n * ```\n */\nexport const deploy = (\n opts: DeployOptions\n): Effect.Effect<DeployResult, AutomationError> =>\n Effect.gen(function* () {\n const stack = yield* createOrSelectStack(opts);\n yield* setStackConfig(stack, opts.config);\n\n const preview = opts.preview\n ? yield* previewStack(\n stack,\n typeof opts.preview === \"boolean\" ? undefined : opts.preview\n )\n : undefined;\n\n const result = yield* upStack(stack, opts.up);\n return { stack, result, preview };\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,iBAAiB,UACrB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;;;;;;;;;;;;;;;AAgBvD,IAAa,cAAb,cAAiCA,OAAAA,KAAK,YAAY,aAAa,CAAC,CAI7D;;;;CAID,IAAI,UAAkB;EACpB,OAAO,cAAc,KAAK,KAAK;CACjC;AACF;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,kBAAb,cAAqCA,OAAAA,KAAK,YAAY,iBAAiB,CAAC,CAerE;;;CAGD,IAAI,UAAkB;EACpB,OAAO,GAAG,KAAK,MAAM,WAAW,cAAc,KAAK,KAAK;CAC1D;AACF;;;;;;;;;;;;;;;;;;;;;;;;ACxCA,MAAa,cACX,WAEAC,OAAAA,OAAO,WAAW;CAChB,WAAY,OAA0C,QAAQ,IAAI;CAClE,QA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AAW,MAAM,QAAQ,IAAI;CAC7B,QAAQ,UAAU,IAAI,gBAAgB;EAAE,OAAO;EAAW;CAAM,CAAC;AACnE,CAAC;;;;;;;AAQH,MAAa,eACX,OACA,SAEAA,OAAAA,OAAO,WAAW;CAChB,WAAW,MAAM,UAAU,YAAY,MAAM,MAAM,IAAI;CACvD,QAAQ,UAAU,IAAI,gBAAgB;EAAE,OAAO;EAAe;CAAM,CAAC;AACvE,CAAC;;;;;;AAOH,MAAa,iBACX,OACA,SAEAA,OAAAA,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,aAAa,OAAO,MAAM,OAAO;CACvD,OAAO,YAAY,OAAO,MAAM,MAAM;CACtC,OAAO;AACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyDH,MAAa,UACX,SAEAA,OAAAA,OAAO,IAAI,aAAa;CACtB,MAAM,QAAQ,OAAO,oBAAoB,IAAI;CAC7C,OAAO,eAAe,OAAO,KAAK,MAAM;CAExC,MAAM,UAAU,KAAK,UACjB,OAAO,aACL,OACA,OAAO,KAAK,YAAY,YAAY,KAAA,IAAY,KAAK,OACvD,IACA,KAAA;CAGJ,OAAO;EAAE;EAAO,QAAA,OADM,QAAQ,OAAO,KAAK,EAAE;EACpB;CAAQ;AAClC,CAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
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 * as pulumi from "@pulumi/pulumi";
|
|
2
|
+
import { Effect } from "effect";
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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:
|
|
35
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
313
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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
|
-
|
|
309
|
+
export declare const deploy: (opts: DeployOptions) => Effect.Effect<DeployResult, AutomationError>;
|
|
310
|
+
//#endregion
|
|
311
|
+
//# sourceMappingURL=index.d.cts.map
|