import { ResourceFQN, ResourceID, ResourceKind, type Resource, type ResourceAttributes, type ResourceProps } from "./resource.ts"; import type { Scope } from "./scope.ts"; import type { State } from "./state.ts"; export type Context = CreateContext | UpdateContext | DeleteContext; export interface CreateContext extends BaseContext { phase: "create"; output?: undefined; props?: undefined; } export interface UpdateContext extends BaseContext { phase: "update"; output: Out; props: Props; } export interface DeleteContext extends BaseContext { phase: "delete"; output: Out; props: Props; } export interface BaseContext { quiet: boolean; stage: string; id: ResourceID; fqn: ResourceFQN; scope: Scope; /** * Indicates whether this resource is being created as a replacement for another resource */ isReplacement: boolean; get(key: string): Promise; set(key: string, value: T): Promise; delete(key: string): Promise; /** * Indicate that this resource is being replaced. * This will cause the resource to be deleted at the end of the stack's CREATE phase. */ replace(force?: boolean): never; /** * Terminate the resource lifecycle handler and destroy the resource. * * This is the final operation performed during a delete operation. * * It is so that the resource lifecycle handler can "return never" instead of * "return undefined" so that `await MyResource()` always returns a value. * * @param retainChildren - Whether to retain the children of the resource. */ destroy(retainChildren?: boolean): never; /** * Register a cleanup function that will be called when the process exits. * * @example * const proc = spawn('my-command', ['arg1', 'arg2']); * this.onCleanup(async () => { * proc.kill(); * await waitForExit(proc); * }); */ onCleanup(fn: () => void | Promise): void; /** * Create the Resource envelope (with Alchemy + User properties) */ create(props: Omit): Out; /** * Create the Resource envelope (with Alchemy + User properties) */ (id: string, props: Omit): Out; (props: Omit): Out; } export declare function context({ scope, phase, kind, id, fqn, seq, state, replace, props, isReplacement, }: { scope: Scope; phase: "create" | "update" | "delete"; kind: ResourceKind; id: ResourceID; fqn: ResourceFQN; seq: number; props: Props; state: State; replace: (force?: boolean) => never; isReplacement?: boolean; }): Context; //# sourceMappingURL=context.d.ts.map