import type { Bucket } from "../bucket.js"; import type { ConditionPredicate } from "../condition.js"; import type { Entity, EntityIndex, EntityTransactItem } from "../entity/entity.js"; import type { EventEnvelope } from "../event.js"; import type { Execution, ExecutionHandle } from "../execution.js"; import type { FifoContentBasedDeduplication, FifoQueue, Queue } from "../queue.js"; import type { DurationSchedule, Schedule } from "../schedule.js"; import type { SearchIndex } from "../search/search-index.js"; import { Socket } from "../socket/socket.js"; import type { Task } from "../task.js"; import type { Workflow, WorkflowExecutionOptions } from "../workflow.js"; import type { SignalTarget } from "./signal.js"; export type Call = AwaitTimerCall | BucketCall | ChildWorkflowCall | ConditionCall | EmitEventsCall | EntityCall | ExpectSignalCall | GetExecutionCall | InvokeTransactionCall | SignalHandlerCall | SearchCall | SendSignalCall | SocketCall | StartWorkflowCall | TaskCall | TaskRequestCall | QueueCall; export declare enum CallKind { AwaitTimerCall = 1, BucketCall = 10, ChildWorkflowCall = 7, ConditionCall = 2, EmitEventsCall = 4, EntityCall = 8, ExpectSignalCall = 3, GetExecutionCall = 14, InvokeTransactionCall = 9, QueueCall = 15, SearchCall = 11, SendSignalCall = 6, SignalHandlerCall = 5, SocketCall = 16, StartWorkflowCall = 13, TaskCall = 0, TaskRequestCall = 12 } export declare const CallSymbol: unique symbol; export type CallOutput = E extends CallBase ? Output : never; export interface CallBase { __output: Output; [CallSymbol]: Kind; } export declare function createCall(kind: E[typeof CallSymbol], e: Omit): E; export declare function isCall(a: any): a is Call; export declare function isCallOfKind(kind: E[typeof CallSymbol], a: any): a is E; export declare function isAwaitTimerCall(a: any): a is AwaitTimerCall; export interface AwaitTimerCall extends CallBase { schedule: Schedule; } export declare function isConditionCall(a: any): a is ConditionCall; export interface ConditionCall extends CallBase { predicate: ConditionPredicate; timeout?: Promise; } export declare function isEmitEventsCall(a: any): a is EmitEventsCall; export interface EmitEventsCall extends CallBase { events: EventEnvelope[]; id?: string; } export declare function isEntityCall(a: any): a is EntityCall; export type EntityCallOutput = Op extends EntityMethod ? ReturnType : Op extends "transact" ? void : Op extends "queryIndex" ? ReturnType : ReturnType; export type EntityCall = CallBase> & { operation: EntityOperation & { operation: Op; }; }; export declare function isEntityOperationOfType(operation: OpType, call: EntityOperation): call is EntityOperation; export type EntityMethod = Exclude<{ [k in keyof Entity]: [Entity[k]] extends [Function] ? k : never; }[keyof Entity], "partition" | "sort" | "stream" | "batchStream" | "index" | undefined>; export type EntityOperation = Op extends EntityMethod ? { operation: Op; entityName: string; params: Parameters; } : Op extends "transact" ? EntityTransactOperation : Op extends "queryIndex" ? EntityQueryIndexOperation : EntityScanIndexOperation; export interface EntityQueryIndexOperation { operation: "queryIndex"; entityName: string; indexName: string; params: Parameters; } export interface EntityScanIndexOperation { operation: "scanIndex"; entityName: string; indexName: string; params: Parameters; } export interface EntityTransactEventOperationItem extends Omit { entity: string; } export interface EntityTransactOperation { operation: "transact"; items: EntityTransactEventOperationItem[]; } export interface BucketDefinition { name: string; } export type BucketMethod = Exclude<{ [k in keyof Bucket]: Bucket[k] extends Function ? k : never; }[keyof Bucket], "on">; export declare function isBucketCall(a: any): a is BucketCall; export type BucketCall = CallBase> & { operation: BucketOperation; }; export type BucketOperation = { operation: Op; bucketName: string; params: Parameters; }; export declare function isBucketCallOperation(op: Op, operation: BucketCall): operation is BucketCall; export declare function isQueueCall(a: any): a is QueueCall; export type QueueMethod = Exclude<{ [k in keyof Queue]: Queue[k] extends Function ? k : never; }[keyof Queue], "handler" | undefined>; export interface QueueCall extends CallBase> { operation: QueueOperation; } interface QueueOperationBase { queueName: string; operation: Op; } export type StandardQueueSendMessagePayload = { delay?: DurationSchedule; message: any; }; export interface FifoQueueSendMessagePayload extends StandardQueueSendMessagePayload { messageGroupId: string; messageDeduplicationId: string | FifoContentBasedDeduplication; } export type QueueSendMessageOperation = QueueOperationBase<"sendMessage"> & (({ fifo: true; } & FifoQueueSendMessagePayload) | ({ fifo: false; } & StandardQueueSendMessagePayload)); export type QueueSendMessageBatchOperation = QueueOperationBase<"sendMessageBatch"> & ({ fifo: true; entries: ({ id: string; } & FifoQueueSendMessagePayload)[]; } | { fifo: false; entries: ({ id: string; } & StandardQueueSendMessagePayload)[]; }); export type QueueOperation = Op extends "sendMessage" ? QueueSendMessageOperation : Op extends "sendMessageBatch" ? QueueSendMessageBatchOperation : QueueOperationBase & { params: Parameters; }; export declare function isQueueOperationOfType(op: Op, operation: QueueOperation): operation is QueueOperation; export declare function isExpectSignalCall(a: any): a is ExpectSignalCall; export interface ExpectSignalCall extends CallBase { signalId: string; timeout?: Promise; } export declare function isSendSignalCall(a: any): a is SendSignalCall; export interface SendSignalCall extends CallBase { signalId: string; payload?: any; target: SignalTarget; id?: string; } export declare function isSignalHandlerCall(a: any): a is SignalHandlerCall; export interface SignalHandlerCall extends CallBase { operation: { operation: "register"; signalId: string; handler: (input: T) => void; } | { operation: "dispose"; seq: number; }; } export declare function isSearchCall(a: any): a is SearchCall; export type SearchCallRequest = Parameters any>>[0]; export type SearchOperation = Exclude<{ [op in keyof SearchIndex]: [SearchIndex[op]] extends [Function] ? op : never; }[keyof SearchIndex], undefined>; export type SearchCall = CallBase> & { operation: Op; request: SearchCallRequest; indexName: string; }; export declare function isTaskRequestCall(a: any): a is TaskRequestCall; export declare function isTaskRequestCallOperation(a: any, Op: O): a is TaskRequestCall; export type TaskMethods = Exclude<{ [op in keyof Task]: [Task[op]] extends [Function] ? op : never; }[keyof Task], "handler" | undefined | "definition">; export interface TaskRequestCall extends CallBase> { operation: Op; params: Parameters; } export declare function isTaskCall(a: any): a is TaskCall; export interface TaskCall extends CallBase { name: string; input: any; heartbeat?: DurationSchedule; /** * Timeout can be any Eventual (promise). When the promise resolves, the task is considered to be timed out. */ timeout?: Promise; } export declare function isChildWorkflowCall(a: Call): a is ChildWorkflowCall; /** * A {@link Call} representing an awaited call to a {@link Workflow}. */ export interface ChildWorkflowCall extends CallBase { name: string; input?: any; opts?: WorkflowExecutionOptions; /** * An Eventual/Promise that determines when a child workflow should timeout. * * This timeout is separate from the timeout passed to the workflow (opts.timeout), which can only be a relative duration. * * TODO: support cancellation of child workflow. */ timeout?: Promise; } export declare function isStartWorkflowCall(a: Call): a is StartWorkflowCall; /** * An starts a {@link Workflow}, but does not wait for it. */ export interface StartWorkflowCall extends CallBase> { name: string; input?: any; opts?: WorkflowExecutionOptions; } export declare function isGetExecutionCall(a: Call): a is GetExecutionCall; /** * An starts a {@link Workflow}, but does not wait for it. */ export interface GetExecutionCall extends CallBase { executionId: string; } export declare function isInvokeTransactionCall(a: any): a is InvokeTransactionCall; export interface InvokeTransactionCall extends CallBase { input: Input; transactionName: string; } export type SocketMethod = Exclude<{ [op in keyof Socket]: [Socket[op]] extends [Function] ? op : never; }[keyof Socket], undefined>; export type SocketOperation = { operation: Op; socketName: string; params: Parameters; }; export declare function isSocketCall(a: any): a is SocketCall; export interface SocketCall extends CallBase { operation: SocketOperation; } export declare function isSocketCallOperation(op: Op, operation: SocketCall): operation is SocketCall; export {}; //# sourceMappingURL=calls.d.ts.map