import * as Config from "effect/Config"; import * as Effect from "effect/Effect"; import type { Pipeable } from "effect/Pipeable"; import { type Ref } from "./Ref.ts"; import { type Resource, type ResourceLike } from "./Resource.ts"; import { RuntimeContext } from "./RuntimeContext.ts"; import * as State from "./State/State.ts"; import { type Primitive } from "./Util/data.ts"; declare const inspect: unique symbol; export declare const of: (resource: Ref | R) => R extends ResourceLike ? ResourceExpr : RefExpr; export declare const asOutput: (t: T | Output | Effect.Effect) => Output; /** * Lift a plan-time Effect into an {@link Output}. * * The effect runs when the stack resolves the Output during plan/deploy — * with the stack's services (cloud credentials, region, ...) provided — and * never inside a deployed runtime: constructing the Output is inert, so * helpers built on `fromEffect` (e.g. AMI lookups) are safe to call from * composition code that is re-executed inside a Function/Worker/Instance * bundle. * * The effect must not fail (`E = never`) — die with a descriptive error for * unresolvable lookups. */ export declare const fromEffect: (effect: Effect.Effect) => ToOutput; export declare const isOutput: (value: any) => value is Output; export interface Output extends Pipeable { /** @internal phantom */ readonly kind: string; /** @internal phantom */ readonly A: A; /** @internal phantom */ readonly req: Req; /** @internal phantom */ [Symbol.iterator](): Iterator, Accessor, void>; bind(id: string): Effect.Effect, never, RuntimeContext>; asEffect(): Effect.Effect, never, Req>; as(): Output; } export interface Accessor extends Effect.Effect { } export type ToOutput = [ A ] extends [Primitive | Date] ? Output : [Extract] extends [never] ? Output : [Extract] extends [never] ? ObjectExpr<{ [attr in keyof A]: A[attr]; }, Req> : ArrayExpr, Req>; export declare const ExprSymbol: unique symbol; export declare const isExpr: (value: any) => value is Expr; export type Expr = AllExpr[]> | ApplyExpr | EffectExpr | FlatMapExpr | LiteralExpr | NamedExpr | PropExpr | ResourceExpr | RefExpr | StackRefExpr; export declare abstract class BaseExpr implements Output { readonly kind: any; readonly A: A; readonly src: ResourceLike; readonly req: Req; constructor(); as(): Output; [Symbol.iterator](): Iterator, Accessor, void>; asEffect(): any; bind(id: string): any; pipe(...fns: any[]): any; abstract [inspect](): string; toString(): string; } export type ObjectExpr = Output & { [Prop in keyof Exclude]-?: ToOutput[Prop] | Extract, Req>; }; export type ArrayExpr = Output & { [i in Extract]: ToOutput; }; export declare const isResourceExpr: (node: Expr | any) => node is ResourceExpr; export declare class ResourceExpr extends BaseExpr { readonly src: ResourceLike; readonly stables?: Record | undefined; readonly kind = "ResourceExpr"; constructor(src: ResourceLike, stables?: Record | undefined); [inspect](): string; } export declare const isPropExpr: (node: any) => node is PropExpr; export declare class PropExpr extends BaseExpr { readonly expr: Expr; readonly identifier: Id; readonly kind = "PropExpr"; constructor(expr: Expr, identifier: Id); [inspect](): string; } export declare const literal: (value: A) => LiteralExpr; export declare const isLiteralExpr: (node: any) => node is LiteralExpr; export declare class LiteralExpr extends BaseExpr { readonly value: A; readonly kind = "LiteralExpr"; constructor(value: A); [inspect](): string; } export declare const VoidExpr: LiteralExpr; export declare const map: { (fn: (value: A) => B): (output: Output) => ToOutput; (output: Output, fn: (value: A) => B): ToOutput; }; export declare const isApplyExpr: (node: Output) => node is ApplyExpr; export declare class ApplyExpr extends BaseExpr { readonly expr: Expr; readonly f: (value: A) => B; readonly kind = "ApplyExpr"; constructor(expr: Expr, f: (value: A) => B); [inspect](): string; } export declare const mapEffect: (fn: (value: A) => Effect.Effect) => (output: Output) => ToOutput; export declare const flatMap: { (fn: (value: A) => Output): (output: Output) => ToOutput; (output: Output, fn: (value: A) => Output): ToOutput; }; export declare const isFlatMapExpr: (node: any) => node is FlatMapExpr; export declare class FlatMapExpr extends BaseExpr { readonly expr: Expr; readonly f: (value: A) => Output; readonly kind = "FlatMapExpr"; constructor(expr: Expr, f: (value: A) => Output); [inspect](): string; } export declare const isEffectExpr: (node: any) => node is EffectExpr; export declare class EffectExpr extends BaseExpr { readonly expr: Expr; readonly f: (value: A) => Effect.Effect; readonly kind = "EffectExpr"; constructor(expr: Expr, f: (value: A) => Effect.Effect); [inspect](): string; } export declare const isNamedExpr: (node: any) => node is NamedExpr; /** * Wraps another `Expr` and overrides its `toString()` / inspect output. * * `BaseExpr` derives the binding id from `this.toString()`, so * wrapping an expression in `NamedExpr` makes that derived id stable and * caller-controlled (e.g. an env var name like `"API_KEY"`). */ export declare class NamedExpr extends BaseExpr { readonly expr: Expr; readonly bindingName: string; readonly kind = "NamedExpr"; constructor(expr: Expr, bindingName: string); [inspect](): string; } export declare const named: (expr: Output, name: string) => Output; export declare const all: (...outs: Outs) => All; export type All = number extends Outs["length"] ? [Outs[number]] extends [ Output | Expr ] ? Output : never : Tuple; type Tuple = Outs extends [infer H, ...infer Tail extends (Output | Expr)[]] ? H extends Output ? Tuple : never : Output; export declare const isAllExpr: (node: any) => node is AllExpr; export declare class AllExpr extends BaseExpr { readonly outs: Outs; readonly kind = "AllExpr"; constructor(outs: Outs); [inspect](): string; } export declare const isRefExpr: (node: any) => node is RefExpr; export declare class RefExpr extends BaseExpr { readonly stack: string | undefined; readonly stage: string | undefined; readonly resourceId: string; /** * Statically-known properties of the ref's target (currently its * resource `Type`), served as literals by the proxy instead of * `PropExpr`s — mirrors {@link ResourceExpr}'s `stables`. */ readonly stables?: Record | undefined; readonly kind = "RefExpr"; constructor(stack: string | undefined, stage: string | undefined, resourceId: string, /** * Statically-known properties of the ref's target (currently its * resource `Type`), served as literals by the proxy instead of * `PropExpr`s — mirrors {@link ResourceExpr}'s `stables`. */ stables?: Record | undefined); [inspect](): string; } export declare const isStackRefExpr: (node: any) => node is StackRefExpr; /** * A reference to the persisted output of a Stack at `(stack, stage)`. * * Resolved at evaluation time by reading `state.getOutput({ stack, * stage })`. Distinct from {@link RefExpr}, which references a * single resource's attributes within a stack/stage. `stage` may be * `undefined`, in which case it falls back to the current stage. */ export declare class StackRefExpr extends BaseExpr { readonly stack: string; readonly stage: string | undefined; readonly kind = "StackRefExpr"; constructor(stack: string, stage: string | undefined); [inspect](): string; } /** * Build an `Output` referencing the persisted output of another * Stack. The returned Effect resolves to a lazy `Output` whose * value is read from the state store at plan/apply time. * * Returns `Effect>` (not `Output` directly) so that * `yield* Output.stackRef(...)` reads ergonomically inside an Effect * generator and lines up with `Resource.ref` and `Stack.stage.`. */ export declare const stackRef: (stack: string, options?: { stage?: string; }) => Effect.Effect>; export declare const filter: (...outs: Outs) => Filter; export type Filter = number extends Outs["length"] ? Output["value"], Extract["req"]> : FilterTuple; export type FilterTuple = Outs extends [infer H, ...infer Tail extends (Output | Expr)[]] ? H extends Output ? FilterTuple : FilterTuple : Output; export declare const interpolate: (template: TemplateStringsArray, ...args: Args) => All extends Output ? Output : never; declare const MissingSourceError_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & { readonly _tag: "MissingSourceError"; } & Readonly; export declare class MissingSourceError extends MissingSourceError_base<{ message: string; srcId: string; }> { } declare const InvalidReferenceError_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & { readonly _tag: "InvalidReferenceError"; } & Readonly; export declare class InvalidReferenceError extends InvalidReferenceError_base<{ message: string; stack: string; stage: string; resourceId: string; }> { } export declare const evaluate: (expr: Output | A, upstream: { [Id in string]: any; }, ancestors?: ReadonlySet) => Effect.Effect; export declare const hasOutputs: (value: any) => value is Output; export declare const upstreamAny: (value: any, seen?: WeakSet) => { [ID in string]: Resource; }; export declare const upstream: >(expr: E, seen?: WeakSet) => any; export declare const resolveUpstream: (value: A, seen?: WeakSet) => any; export declare const log: (_value: A) => Effect.Effect; export declare const toEnvKey: (id: ID, suffix: Suffix) => `${Replace, "">}_${Replace, "">}`; export declare const toUpper: (str: S) => string extends S ? S : Uppercase; type Replace = string extends S ? S : S extends "" ? Accum : S extends `${infer S}${infer Rest}` ? S extends "-" ? Replace : Replace : Accum; export {}; //# sourceMappingURL=Output.d.ts.map