import type { StackEvent } from '@aws-sdk/client-cloudformation'; import type { ResourceError } from './resource-errors'; import { ResourceErrors } from './resource-errors'; import type { ICloudFormationClient } from '../aws-auth/private'; export interface StackEventPollerProps { /** * The stack to poll */ readonly stackArn: string; /** * IDs of parent stacks of this resource, in case of resources in nested stacks */ readonly parentStackLogicalIds?: string[]; /** * A configurable algorithm to indicate when we should stop consuming the event stream. * * The initialPollRange object will be called on the first occurrence of * polling. It will be shown all events in a chunk in turn, newest-to-oldest, * and should decide the oldest event we're still interested in. We will not * go back further consuming the event stream. * * On subsequent polls, we will use the events we've already seen to decide when to stop * polling. */ readonly initialPollRange: IPollRange; } export interface IPollRange { /** * Whether polling should stop on seeing this event */ shouldStop(event: ResourceEvent): 'stop-include' | 'stop-exclude' | 'continue'; } export declare abstract class PollRange { /** * Only include events since than a given time */ static sinceTimestamp(startTime: number): IPollRange; /** * Stop when we see the root stack entering this status * * Should be something like `CREATE_IN_PROGRESS`, `UPDATE_IN_PROGRESS`, * `DELETE_IN_PROGRESS, `ROLLBACK_IN_PROGRESS`. */ static sinceStackStatus(statuses: string[]): IPollRange; /** * Stop when we see events that belong to a different operation * * Records the first OperationId, and stops as soon as we see events that don't have it anymore. */ static mostRecentOperation(): IPollRange; /** * A poll range decider that always returns 'continue', consuming the entire CFN event stream. */ static consumeAll(): IPollRange; } export interface ResourceEvent { /** * The Stack Event as received from CloudFormation */ readonly event: StackEvent; /** * IDs of parent stacks of the resource, in case of resources in nested stacks */ readonly parentStackLogicalIds: string[]; /** * Whether this event regards the root stack * * @default false */ readonly isRootStackEvent?: boolean; } /** * Poll for stack events, potentially multiple times as new events come in over time * * Includes events from nested stacks. * * Polling may happen in multiple bursts, and every burst consumes events from newest-to-oldest * from the stack events API, so events are consumed in the following order: * * ``` * CONSUMING * * stack events (new) z y x w v u t s r q p o n m l k j i h g f e d c b a (old) * bursts [ poll() #1 ] * [ poll() #2 ] ^ * [ poll() #3 ] initialPollRange * decides to stop here * ``` * * Events are sorted old-to-new before being returned, so the events returned by each * poll are: * * ``` * poll() #1 => [e f g h i j k l] * poll() #2 => [m n o p q r s] * poll() #3 => [t u v w x y z] * ``` * */ export declare class StackEventPoller { private readonly cfn; private readonly props; /** * All events we've seen so far */ readonly events: ResourceEvent[]; complete: boolean; /** * A record of the errors we've seen */ readonly errors: ResourceErrors; private readonly eventIds; private readonly nestedStackPollers; constructor(cfn: ICloudFormationClient, props: StackEventPollerProps); /** * From all accumulated events, return only the errors */ get resourceErrors(): ReadonlyArray; /** * Poll for new stack events * * Will read all events that are available up until the oldest events * indicated by the constructor filters, or until it encounters events that it * has already read before. * * Recurses into nested stacks, and returns events old-to-new. Multiple * invocations to `poll` will return *newer* events (also in old-to-new order). */ poll(): Promise; private doPoll; /** * On the CREATE_IN_PROGRESS, UPDATE_IN_PROGRESS, DELETE_IN_PROGRESS event of a nested stack, poll the nested stack updates */ private trackNestedStack; } //# sourceMappingURL=stack-event-poller.d.ts.map