import type { ConfigError } from "effect/Config"; import * as Context from "effect/Context"; import type { Digest } from "effect/crypto/Digest"; import type { SecureRandom } from "effect/crypto/SecureRandom"; import * as Effect from "effect/Effect"; import { FileSystem } from "effect/FileSystem"; import type { HttpClient } from "effect/http/HttpClient"; import * as Layer from "effect/Layer"; import { Path } from "effect/Path"; import type { ChildProcessSpawner } from "effect/process/ChildProcessSpawner"; import type * as Scope from "effect/Scope"; import type { ActionLike } from "./Action.ts"; import type { AlchemyContext } from "./AlchemyContext.ts"; import type { ArtifactStore } from "./Artifacts.ts"; import type { CredentialsStore } from "./Auth/Credentials.ts"; import type { ProfileStore } from "./Auth/Profile.ts"; import { type AuthProviders } from "./Auth/Registry.ts"; import type { Input, InputProps } from "./Input.ts"; import type { Interaction } from "./Interaction.ts"; import * as Output from "./Output.ts"; import type { Provider, ProviderCollectionLike } from "./Provider.ts"; import type { ResourceBinding, ResourceLike } from "./Resource.ts"; import type { SecretsEntry, SecretsOption } from "./Secrets/Provider.ts"; import { Stage } from "./Stage.ts"; import type { State } from "./State/State.ts"; import type { PlatformServices } from "./Util/PlatformServices.ts"; export type StackServices = Stack | Stage | Scope.Scope | FileSystem | Digest | SecureRandom | Path | AlchemyContext | HttpClient | ChildProcessSpawner | AuthProviders | ProfileStore | ArtifactStore | CredentialsStore | Interaction; export type ProviderServices = ProviderCollectionLike | Provider | EnvironmentLike | CredentialsLike | DockerLike; export interface EnvironmentLike { readonly kind: "Environment"; } export interface CredentialsLike { readonly kind: "Credentials"; } export interface DockerLike { readonly key: "@alchemy/Docker"; } export type StackEffect = Effect.Effect; export type Stack = Context.ServiceClass.Shape<"Stack", Omit>; /** * Where a stack's configuration comes from: a ConfigProvider layer, or a * list of them applied in order, later ones overriding earlier ones. * * The process environment implicitly closes every list, so the shell * overrides every provider. List `Secrets.ProcessEnv()` yourself to rank it * elsewhere, or `Secrets.ProcessEnv({ disabled: true })` to leave it out. * Omitting `secrets` preserves the existing ConfigProvider and CLI dotenv behavior. * * ```ts * secrets: [ * Doppler.Secrets({ project: "app", config: "dev" }), * Secrets.DotEnv(), * Secrets.ProcessEnv(), * ] * ``` */ export type SecretProviders = SecretsEntry | ReadonlyArray; /** * The `secrets` option: providers, or a callback that picks them from the * stage, so one stack can read `.env` locally and a secrets manager * elsewhere: * * ```ts * secrets: ({ stage }) => * stage === "dev" * ? Secrets.DotEnv() * : Doppler.Secrets({ project: "app", config: stage }), * ``` */ export type StackSecrets = SecretsOption; export interface StackProps { providers: Layer.Layer, never, StackServices>; state: Layer.Layer; /** Opt in to secret providers. When omitted, existing configuration is preserved. */ secrets?: StackSecrets; } /** * Runtime fields the Stack factory attaches to a configured stack effect. * Class-reference forms expose only `stackName` until `.make(...)`. */ export type ConfiguredStackMeta = { readonly stackName: string; } & StackProps; /** * What `Alchemy.Stack(...)` returns, and what an `alchemy.run.ts` * default-exports: the stack program, not yet run, with its providers, * state store, and secrets attached. */ export type ConfiguredStack = Effect.Effect, ConfigError> & ConfiguredStackMeta; export declare const Stack: Context.ServiceClass> & { make(stack: { Shape: A; }, effect: Effect.Effect : Input>, ConfigError, Req>): Effect.Effect, ConfigError>; (): { (stackName: string, options: StackProps>, eff: Effect.Effect): Effect.Effect & { new (_: never): A extends object ? A : {}; readonly stackName: string; stage: { [stage: string]: Effect.Effect; }; }; }; (): { (stackName: string): Effect.Effect & { new (_: never): Output.ToOutput; readonly stackName: string; make: (options: StackProps>, effect: Effect.Effect) => ConfiguredStack>; stage: { readonly [S in Stages]: Effect.Effect; }; }; }; (stackName: string, options: StackProps>, eff: Effect.Effect): ConfiguredStack>; }; export interface StackSpec { name: string; stage: string; resources: { [logicalId: string]: ResourceLike; }; bindings: { [logicalId: string]: ResourceBinding[]; }; /** Tasks registered on the stack, keyed by FQN. */ actions: { [logicalId: string]: ActionLike; }; output: Output; } export interface CompiledStack extends StackSpec { services: Context.Context; } export declare const StackName: Effect.Effect; export interface MakeStackProps { name: string; /** Required; {@link make} dies with setup guidance when it is missing. */ providers?: Layer.Layer; /** Required; {@link make} dies with setup guidance when it is missing. */ state?: Layer.Layer; /** Opt in to secret providers. When omitted, existing configuration is preserved. */ secrets?: StackSecrets; /** @internal */ stack?: StackSpec; } declare const StateScope_base: Context.ServiceClass; /** * The scope a stack's state store is built into when it must close sooner * than the rest of the stack. A store holds its stack's lease until its scope * closes, so `evalStack` (`EvalStack.ts`) gives it one per call even when the caller * keeps providers alive in a longer scope. */ export declare class StateScope extends StateScope_base { } /** * Build a stack's providers, state store, secrets config and `Stack` spec, * without running its program. Destroy needs nothing more: it plans from state * alone, and every row records the provider mode that deletes it. */ export declare const build: (options: MakeStackProps) => Effect.Effect, ConfigError, AlchemyContext | ArtifactStore | ChildProcessSpawner | CredentialsStore | Digest | FileSystem | HttpClient | Interaction | Path | ProfileStore | Scope.Scope | SecureRandom | Stage>; /** Build a stack's services with {@link build}, then run its program under them. */ export declare const make: (options: MakeStackProps) => (effect: Effect.Effect) => Effect.Effect, Err | ConfigError, AlchemyContext | ArtifactStore | ChildProcessSpawner | CredentialsStore | Digest | FileSystem | HttpClient | Interaction | Path | ProfileStore | Scope.Scope | SecureRandom | Stage | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude | Exclude>; /** What `Alchemy.Stack(...)` attaches to the stack it returns: everything but its program. */ export interface StackDefinition { readonly stackName: string; readonly providers?: Layer.Layer; readonly state?: Layer.Layer; readonly secrets?: StackSecrets; } export declare const CurrentStack: Effect.Effect, "output"> | undefined, never, never>; export {}; //# sourceMappingURL=Stack.d.ts.map