Skip to content

Commit

Permalink
fix: close cloudflare#3620
Browse files Browse the repository at this point in the history
  • Loading branch information
rxliuli committed Feb 27, 2025
1 parent 6713212 commit 893d3fb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions types/defines/rpc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ declare namespace Rpc {
: T extends Set<infer V> ? Set<Stubify<V>>
: T extends Array<infer V> ? Array<Stubify<V>>
: T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>>
: T extends Rpc.Serializable<T> ? T
// When using "unknown" instead of "any", interfaces are not stubified.
: T extends { [key: string | number]: any } ? { [K in keyof T]: Stubify<T[K]> }
: T;
Expand All @@ -100,6 +101,7 @@ declare namespace Rpc {
: T extends Set<infer V> ? Set<Unstubify<V>>
: T extends Array<infer V> ? Array<Unstubify<V>>
: T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>>
: T extends Rpc.Serializable<T> ? T
: T extends { [key: string | number]: unknown } ? { [K in keyof T]: Unstubify<T[K]> }
: T;
type UnstubifyAll<A extends any[]> = { [I in keyof A]: Unstubify<A[I]> };
Expand Down Expand Up @@ -239,8 +241,15 @@ declare module "cloudflare:workers" {
};

export abstract class WorkflowStep {
do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
do<T extends Rpc.Serializable<T>>(
name: string,
callback: () => Promise<T>
): Promise<T>;
do<T extends Rpc.Serializable<T>>(
name: string,
config: WorkflowStepConfig,
callback: () => Promise<T>
): Promise<T>;
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
}
Expand All @@ -257,6 +266,9 @@ declare module "cloudflare:workers" {

constructor(ctx: ExecutionContext, env: Env);

run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
run(
event: Readonly<WorkflowEvent<T>>,
step: WorkflowStep
): Promise<unknown>;
}
}

0 comments on commit 893d3fb

Please sign in to comment.