Skip to content

Commit

Permalink
remove incorrect import
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthachatterjee committed Aug 8, 2024
1 parent 868afab commit 2c207a8
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions types/defines/rpc.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
// to referenced by `Fetcher`. This is included in the "importable" version of the types which

import { Serializable } from "child_process";

// strips all `module` blocks.
declare namespace Rpc {
// Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
Expand Down Expand Up @@ -158,7 +155,8 @@ declare module "cloudflare:workers" {
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC

export abstract class WorkerEntrypoint<Env = unknown>
implements Rpc.WorkerEntrypointBranded {
implements Rpc.WorkerEntrypointBranded
{
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;

protected ctx: ExecutionContext;
Expand All @@ -174,7 +172,8 @@ declare module "cloudflare:workers" {
}

export abstract class DurableObject<Env = unknown>
implements Rpc.DurableObjectBranded {
implements Rpc.DurableObjectBranded
{
[Rpc.__DURABLE_OBJECT_BRAND]: never;

protected ctx: DurableObjectState;
Expand All @@ -196,27 +195,38 @@ declare module "cloudflare:workers" {
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
}

export type DurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
export type SleepDuration = `${number} ${DurationLabel}${'s' | ''}` | number;

export type DurationLabel =
| "second"
| "minute"
| "hour"
| "day"
| "week"
| "month"
| "year";
export type SleepDuration = `${number} ${DurationLabel}${"s" | ""}` | number;

type WorkflowStep = {
do: <T extends Serializable>(name: string, callback: () => T) => T | Promise<T>;
sleep:(name: string, duration: SleepDuration) => void | Promise<void>;
}

do: <T extends Serializable>(
name: string,
callback: () => T
) => T | Promise<T>;
sleep: (name: string, duration: SleepDuration) => void | Promise<void>;
};

export abstract class Workflow<Env = unknown, T extends Serializable | unknown = unknown>
implements Rpc.WorkflowBranded {
export abstract class Workflow<
Env = unknown,
T extends Serializable | unknown = unknown,
> implements Rpc.WorkflowBranded
{
[Rpc.__WORKFLOW_BRAND]: never;

protected ctx: ExecutionContext;
protected env: Env;

run(
events: Array<{
payload: T,
timestamp: Date
payload: T;
timestamp: Date;
}>,
step: WorkflowStep
): unknown | Promise<unknown>;
Expand Down

0 comments on commit 2c207a8

Please sign in to comment.