import type { NonEmptyReadonlyArray } from "../../Array.ts";
import type * as Brand from "../../Brand.ts";
import * as Cause from "../../Cause.ts";
import * as Effect from "../../Effect.ts";
import * as Exit from "../../Exit.ts";
import * as Schema from "../../Schema.ts";
import * as Workflow from "./Workflow.ts";
import type { WorkflowEngine, WorkflowInstance } from "./WorkflowEngine.ts";
declare const TypeId = "~effect/workflow/DurableDeferred";
/**
 * @since 4.0.0
 * @category Models
 */
export interface DurableDeferred<Success extends Schema.Top, Error extends Schema.Top = Schema.Never> {
    readonly [TypeId]: typeof TypeId;
    readonly name: string;
    readonly successSchema: Success;
    readonly errorSchema: Error;
    readonly exitSchema: Schema.Exit<Schema.Top, Schema.Top, Schema.Top>;
    readonly withActivityAttempt: Effect.Effect<DurableDeferred<Success, Error>>;
}
/**
 * @since 4.0.0
 * @category Models
 */
export interface Any {
    readonly [TypeId]: typeof TypeId;
    readonly name: string;
}
/**
 * @since 4.0.0
 * @category Models
 */
export interface AnyWithProps {
    readonly [TypeId]: typeof TypeId;
    readonly name: string;
    readonly successSchema: Schema.Top;
    readonly errorSchema: Schema.Top;
    readonly exitSchema: Schema.Exit<any, any, any>;
}
/**
 * @since 4.0.0
 * @category Constructors
 */
export declare const make: <Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never>(name: string, options?: {
    readonly success?: Success | undefined;
    readonly error?: Error | undefined;
}) => DurableDeferred<Success, Error>;
declare const await_: <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>) => Effect.Effect<Success["Type"], Error["Type"], WorkflowEngine | WorkflowInstance | Success["DecodingServices"] | Error["DecodingServices"]>;
export { 
/**
 * @since 4.0.0
 * @category Combinators
 */
await_ as await };
/**
 * @since 4.0.0
 * @category Combinators
 */
export declare const into: {
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>): <R>(effect: Effect.Effect<Success["Type"], Error["Type"], R>) => Effect.Effect<Success["Type"], Error["Type"], R | WorkflowEngine | WorkflowInstance | Success["DecodingServices"] | Error["DecodingServices"]>;
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top, R>(effect: Effect.Effect<Success["Type"], Error["Type"], R>, self: DurableDeferred<Success, Error>): Effect.Effect<Success["Type"], Error["Type"], R | WorkflowEngine | WorkflowInstance | Success["DecodingServices"] | Error["DecodingServices"]>;
};
/**
 * @since 4.0.0
 * @category Racing
 */
export declare const raceAll: <const Effects extends NonEmptyReadonlyArray<Effect.Effect<any, any, any>>, Success extends Schema.Schema<Effect.Success<Effects[number]>>, Error extends Schema.Schema<Effect.Error<Effects[number]>>>(options: {
    name: string;
    success: Success;
    error: Error;
    effects: Effects;
}) => Effect.Effect<Effect.Success<Effects[number]>, Effect.Error<Effects[number]>, Effect.Services<Effects[number]> | Success["DecodingServices"] | Success["EncodingServices"] | Error["DecodingServices"] | Error["EncodingServices"] | WorkflowEngine | WorkflowInstance>;
/**
 * @since 4.0.0
 */
export declare const TokenTypeId = "~effect/workflow/DurableDeferred/Token";
/**
 * @since 4.0.0
 */
export type TokenTypeId = typeof TokenTypeId;
/**
 * @since 4.0.0
 * @category Token
 */
export type Token = Brand.Branded<string, TokenTypeId>;
/**
 * @since 4.0.0
 * @category Token
 */
export declare const Token: Schema.brand<Schema.String, TokenTypeId>;
declare const TokenParsed_base: Schema.Class<TokenParsed, Schema.Struct<{
    readonly workflowName: Schema.String;
    readonly executionId: Schema.String;
    readonly deferredName: Schema.String;
}>, {}>;
/**
 * @since 4.0.0
 * @category Token
 */
export declare class TokenParsed extends TokenParsed_base {
    /**
     * @since 4.0.0
     */
    get asToken(): Token;
    /**
     * @since 4.0.0
     */
    static readonly FromString: Schema.decodeTo<typeof TokenParsed, Schema.decodeTo<Schema.fromJsonString<Schema.Tuple<readonly [Schema.String, Schema.String, Schema.String]>>, Schema.String, never, never>, never, never>;
    /**
     * @since 4.0.0
     */
    static readonly fromString: (input: string, options?: import("../../SchemaAST.ts").ParseOptions) => TokenParsed;
    /**
     * @since 4.0.0
     */
    static readonly encode: (input: TokenParsed, options?: import("../../SchemaAST.ts").ParseOptions) => string;
}
/**
 * @since 4.0.0
 * @category Token
 */
export declare const token: <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>) => Effect.Effect<Token, never, WorkflowInstance>;
/**
 * @since 4.0.0
 * @category Token
 */
export declare const tokenFromExecutionId: {
    /**
     * @since 4.0.0
     * @category Token
     */
    (options: {
        readonly workflow: Workflow.Any;
        readonly executionId: string;
    }): <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>) => Token;
    /**
     * @since 4.0.0
     * @category Token
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>, options: {
        readonly workflow: Workflow.Any;
        readonly executionId: string;
    }): Token;
};
/**
 * @since 4.0.0
 * @category Token
 */
export declare const tokenFromPayload: {
    /**
     * @since 4.0.0
     * @category Token
     */
    <W extends Workflow.Any>(options: {
        readonly workflow: W;
        readonly payload: Workflow.PayloadSchema<W>["~type.make.in"];
    }): <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>) => Effect.Effect<Token>;
    /**
     * @since 4.0.0
     * @category Token
     */
    <Success extends Schema.Top, Error extends Schema.Top, W extends Workflow.Any>(self: DurableDeferred<Success, Error>, options: {
        readonly workflow: W;
        readonly payload: Workflow.PayloadSchema<W>["~type.make.in"];
    }): Effect.Effect<Token>;
};
/**
 * @since 4.0.0
 * @category Combinators
 */
export declare const done: {
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(options: {
        readonly token: Token;
        readonly exit: Exit.Exit<Success["Type"], Error["Type"]>;
    }): (self: DurableDeferred<Success, Error>) => Effect.Effect<void, never, WorkflowEngine | Success["EncodingServices"] | Error["EncodingServices"]>;
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>, options: {
        readonly token: Token;
        readonly exit: Exit.Exit<Success["Type"], Error["Type"]>;
    }): Effect.Effect<void, never, WorkflowEngine | Success["EncodingServices"] | Error["EncodingServices"]>;
};
/**
 * @since 4.0.0
 * @category Combinators
 */
export declare const succeed: {
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(options: {
        readonly token: Token;
        readonly value: Success["Type"];
    }): (self: DurableDeferred<Success, Error>) => Effect.Effect<void, never, WorkflowEngine | Success["EncodingServices"]>;
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>, options: {
        readonly token: Token;
        readonly value: Success["Type"];
    }): Effect.Effect<void, never, WorkflowEngine | Success["EncodingServices"]>;
};
/**
 * @since 4.0.0
 * @category Combinators
 */
export declare const fail: {
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(options: {
        readonly token: Token;
        readonly error: Error["Type"];
    }): (self: DurableDeferred<Success, Error>) => Effect.Effect<void, never, WorkflowEngine | Error["EncodingServices"]>;
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>, options: {
        readonly token: Token;
        readonly error: Error["Type"];
    }): Effect.Effect<void, never, WorkflowEngine | Error["EncodingServices"]>;
};
/**
 * @since 4.0.0
 * @category Combinators
 */
export declare const failCause: {
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(options: {
        readonly token: Token;
        readonly cause: Cause.Cause<Error["Type"]>;
    }): (self: DurableDeferred<Success, Error>) => Effect.Effect<void, never, WorkflowEngine | Error["EncodingServices"]>;
    /**
     * @since 4.0.0
     * @category Combinators
     */
    <Success extends Schema.Top, Error extends Schema.Top>(self: DurableDeferred<Success, Error>, options: {
        readonly token: Token;
        readonly cause: Cause.Cause<Error["Type"]>;
    }): Effect.Effect<void, never, WorkflowEngine | Error["EncodingServices"]>;
};
//# sourceMappingURL=DurableDeferred.d.ts.map