@cloudflare/workers-types 4.20250911.0 → 4.20250912.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2021-11-03/index.d.ts +120 -91
- package/2021-11-03/index.ts +226 -86
- package/2022-01-31/index.d.ts +120 -91
- package/2022-01-31/index.ts +226 -86
- package/2022-03-21/index.d.ts +120 -91
- package/2022-03-21/index.ts +226 -86
- package/2022-08-04/index.d.ts +120 -91
- package/2022-08-04/index.ts +226 -86
- package/2022-10-31/index.d.ts +120 -91
- package/2022-10-31/index.ts +226 -86
- package/2022-11-30/index.d.ts +120 -91
- package/2022-11-30/index.ts +226 -86
- package/2023-03-01/index.d.ts +120 -91
- package/2023-03-01/index.ts +226 -86
- package/2023-07-01/index.d.ts +120 -91
- package/2023-07-01/index.ts +226 -86
- package/experimental/index.d.ts +146 -29
- package/experimental/index.ts +252 -24
- package/index.d.ts +120 -91
- package/index.ts +226 -86
- package/latest/index.d.ts +129 -17
- package/latest/index.ts +235 -12
- package/oldest/index.d.ts +120 -91
- package/oldest/index.ts +226 -86
- package/package.json +1 -1
package/2022-10-31/index.d.ts
CHANGED
|
@@ -383,10 +383,10 @@ declare const Cloudflare: Cloudflare;
|
|
|
383
383
|
declare const origin: string;
|
|
384
384
|
declare const navigator: Navigator;
|
|
385
385
|
interface TestController {}
|
|
386
|
-
interface ExecutionContext {
|
|
386
|
+
interface ExecutionContext<Props = unknown> {
|
|
387
387
|
waitUntil(promise: Promise<any>): void;
|
|
388
388
|
passThroughOnException(): void;
|
|
389
|
-
props:
|
|
389
|
+
readonly props: Props;
|
|
390
390
|
}
|
|
391
391
|
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
|
|
392
392
|
request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
|
|
@@ -535,9 +535,12 @@ type DurableObjectLocationHint =
|
|
|
535
535
|
interface DurableObjectNamespaceGetDurableObjectOptions {
|
|
536
536
|
locationHint?: DurableObjectLocationHint;
|
|
537
537
|
}
|
|
538
|
-
interface
|
|
538
|
+
interface DurableObjectClass<
|
|
539
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
540
|
+
> {}
|
|
541
|
+
interface DurableObjectState<Props = unknown> {
|
|
539
542
|
waitUntil(promise: Promise<any>): void;
|
|
540
|
-
props:
|
|
543
|
+
readonly props: Props;
|
|
541
544
|
readonly id: DurableObjectId;
|
|
542
545
|
readonly storage: DurableObjectStorage;
|
|
543
546
|
container?: Container;
|
|
@@ -3073,6 +3076,30 @@ interface MessagePort extends EventTarget {
|
|
|
3073
3076
|
interface MessagePortPostMessageOptions {
|
|
3074
3077
|
transfer?: any[];
|
|
3075
3078
|
}
|
|
3079
|
+
type LoopbackForExport<
|
|
3080
|
+
T extends
|
|
3081
|
+
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
3082
|
+
| ExportedHandler<any, any, any>
|
|
3083
|
+
| undefined = undefined,
|
|
3084
|
+
> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
|
|
3085
|
+
? LoopbackServiceStub<InstanceType<T>>
|
|
3086
|
+
: T extends new (...args: any[]) => Rpc.DurableObjectBranded
|
|
3087
|
+
? LoopbackDurableObjectClass<InstanceType<T>>
|
|
3088
|
+
: T extends ExportedHandler<any, any, any>
|
|
3089
|
+
? LoopbackServiceStub<undefined>
|
|
3090
|
+
: undefined;
|
|
3091
|
+
type LoopbackServiceStub<
|
|
3092
|
+
T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
|
|
3093
|
+
> = Fetcher<T> &
|
|
3094
|
+
(T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
|
|
3095
|
+
? (opts: { props?: Props }) => Fetcher<T>
|
|
3096
|
+
: (opts: { props?: any }) => Fetcher<T>);
|
|
3097
|
+
type LoopbackDurableObjectClass<
|
|
3098
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
3099
|
+
> = DurableObjectClass<T> &
|
|
3100
|
+
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3101
|
+
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3102
|
+
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3076
3103
|
interface SyncKvStorage {
|
|
3077
3104
|
get<T = unknown>(key: string): T | undefined;
|
|
3078
3105
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3087,98 +3114,51 @@ interface SyncKvListOptions {
|
|
|
3087
3114
|
reverse?: boolean;
|
|
3088
3115
|
limit?: number;
|
|
3089
3116
|
}
|
|
3117
|
+
interface WorkerStub {
|
|
3118
|
+
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
|
|
3119
|
+
name?: string,
|
|
3120
|
+
options?: WorkerStubEntrypointOptions,
|
|
3121
|
+
): Fetcher<T>;
|
|
3122
|
+
}
|
|
3123
|
+
interface WorkerStubEntrypointOptions {
|
|
3124
|
+
props?: any;
|
|
3125
|
+
}
|
|
3126
|
+
interface WorkerLoader {
|
|
3127
|
+
get(
|
|
3128
|
+
name: string,
|
|
3129
|
+
getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
|
|
3130
|
+
): WorkerStub;
|
|
3131
|
+
}
|
|
3132
|
+
interface WorkerLoaderModule {
|
|
3133
|
+
js?: string;
|
|
3134
|
+
cjs?: string;
|
|
3135
|
+
text?: string;
|
|
3136
|
+
data?: ArrayBuffer;
|
|
3137
|
+
json?: any;
|
|
3138
|
+
py?: string;
|
|
3139
|
+
}
|
|
3140
|
+
interface WorkerLoaderWorkerCode {
|
|
3141
|
+
compatibilityDate: string;
|
|
3142
|
+
compatibilityFlags?: string[];
|
|
3143
|
+
allowExperimental?: boolean;
|
|
3144
|
+
mainModule: string;
|
|
3145
|
+
modules: Record<string, WorkerLoaderModule | string>;
|
|
3146
|
+
env?: any;
|
|
3147
|
+
globalOutbound?: Fetcher | null;
|
|
3148
|
+
tails?: Fetcher[];
|
|
3149
|
+
streamingTails?: Fetcher[];
|
|
3150
|
+
}
|
|
3090
3151
|
/**
|
|
3091
3152
|
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
|
|
3092
3153
|
* as well as timing of subrequests and other operations.
|
|
3093
3154
|
*
|
|
3094
3155
|
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
|
|
3095
3156
|
*/
|
|
3096
|
-
declare abstract class Performance
|
|
3157
|
+
declare abstract class Performance {
|
|
3097
3158
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
|
|
3098
3159
|
get timeOrigin(): number;
|
|
3099
3160
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
|
|
3100
3161
|
now(): number;
|
|
3101
|
-
get eventCounts(): EventCounts;
|
|
3102
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks) */
|
|
3103
|
-
clearMarks(name?: string): void;
|
|
3104
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures) */
|
|
3105
|
-
clearMeasures(name?: string): void;
|
|
3106
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings) */
|
|
3107
|
-
clearResourceTimings(): void;
|
|
3108
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
|
|
3109
|
-
getEntries(): PerformanceEntry[];
|
|
3110
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
|
|
3111
|
-
getEntriesByName(name: string, type: string): PerformanceEntry[];
|
|
3112
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
|
|
3113
|
-
getEntriesByType(type: string): PerformanceEntry[];
|
|
3114
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
|
|
3115
|
-
mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
|
|
3116
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure) */
|
|
3117
|
-
measure(
|
|
3118
|
-
measureName: string,
|
|
3119
|
-
measureOptionsOrStartMark: PerformanceMeasureOptions | string,
|
|
3120
|
-
maybeEndMark?: string,
|
|
3121
|
-
): PerformanceMeasure;
|
|
3122
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
|
|
3123
|
-
setResourceTimingBufferSize(size: number): void;
|
|
3124
|
-
}
|
|
3125
|
-
/**
|
|
3126
|
-
* PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.
|
|
3127
|
-
*
|
|
3128
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
|
|
3129
|
-
*/
|
|
3130
|
-
interface PerformanceMark extends PerformanceEntry {
|
|
3131
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
|
|
3132
|
-
get detail(): any;
|
|
3133
|
-
}
|
|
3134
|
-
/**
|
|
3135
|
-
* PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.
|
|
3136
|
-
*
|
|
3137
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
|
|
3138
|
-
*/
|
|
3139
|
-
interface PerformanceMeasure extends PerformanceEntry {
|
|
3140
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
|
|
3141
|
-
get detail(): any;
|
|
3142
|
-
}
|
|
3143
|
-
interface PerformanceMarkOptions {
|
|
3144
|
-
detail?: any;
|
|
3145
|
-
startTime?: number;
|
|
3146
|
-
}
|
|
3147
|
-
interface PerformanceMeasureOptions {
|
|
3148
|
-
detail?: any;
|
|
3149
|
-
start?: number;
|
|
3150
|
-
duration?: number;
|
|
3151
|
-
end?: number;
|
|
3152
|
-
}
|
|
3153
|
-
/**
|
|
3154
|
-
* Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
|
|
3155
|
-
*
|
|
3156
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
|
|
3157
|
-
*/
|
|
3158
|
-
declare abstract class PerformanceEntry {
|
|
3159
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name) */
|
|
3160
|
-
get name(): string;
|
|
3161
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType) */
|
|
3162
|
-
get entryType(): string;
|
|
3163
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime) */
|
|
3164
|
-
get startTime(): number;
|
|
3165
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration) */
|
|
3166
|
-
get duration(): number;
|
|
3167
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON) */
|
|
3168
|
-
toJSON(): any;
|
|
3169
|
-
}
|
|
3170
|
-
interface EventCounts {
|
|
3171
|
-
get size(): number;
|
|
3172
|
-
get(eventType: string): number | undefined;
|
|
3173
|
-
has(eventType: string): boolean;
|
|
3174
|
-
entries(): IterableIterator<string[]>;
|
|
3175
|
-
keys(): IterableIterator<string>;
|
|
3176
|
-
values(): IterableIterator<number>;
|
|
3177
|
-
forEach(
|
|
3178
|
-
param1: (param0: number, param1: string, param2: EventCounts) => void,
|
|
3179
|
-
param2?: any,
|
|
3180
|
-
): void;
|
|
3181
|
-
[Symbol.iterator](): IterableIterator<string[]>;
|
|
3182
3162
|
}
|
|
3183
3163
|
type AiImageClassificationInput = {
|
|
3184
3164
|
image: number[];
|
|
@@ -8090,7 +8070,53 @@ declare namespace Rpc {
|
|
|
8090
8070
|
};
|
|
8091
8071
|
}
|
|
8092
8072
|
declare namespace Cloudflare {
|
|
8073
|
+
// Type of `env`.
|
|
8074
|
+
//
|
|
8075
|
+
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
|
|
8076
|
+
// will merge all declarations.
|
|
8077
|
+
//
|
|
8078
|
+
// You can use `wrangler types` to generate the `Env` type automatically.
|
|
8093
8079
|
interface Env {}
|
|
8080
|
+
// Project-specific parameters used to inform types.
|
|
8081
|
+
//
|
|
8082
|
+
// This interface is, again, intended to be declared in project-specific files, and then that
|
|
8083
|
+
// declaration will be merged with this one.
|
|
8084
|
+
//
|
|
8085
|
+
// A project should have a declaration like this:
|
|
8086
|
+
//
|
|
8087
|
+
// interface GlobalProps {
|
|
8088
|
+
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
|
|
8089
|
+
// // of `ctx.exports`.
|
|
8090
|
+
// mainModule: typeof import("my-main-module");
|
|
8091
|
+
//
|
|
8092
|
+
// // Declares which of the main module's exports are configured with durable storage, and
|
|
8093
|
+
// // thus should behave as Durable Object namsepace bindings.
|
|
8094
|
+
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
|
|
8095
|
+
// }
|
|
8096
|
+
//
|
|
8097
|
+
// You can use `wrangler types` to generate `GlobalProps` automatically.
|
|
8098
|
+
interface GlobalProps {}
|
|
8099
|
+
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
|
|
8100
|
+
// present.
|
|
8101
|
+
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
|
|
8102
|
+
? GlobalProps[K]
|
|
8103
|
+
: Default;
|
|
8104
|
+
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
|
|
8105
|
+
// `mainModule` property.
|
|
8106
|
+
type MainModule = GlobalProp<"mainModule", {}>;
|
|
8107
|
+
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
|
|
8108
|
+
type Exports = {
|
|
8109
|
+
[K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
|
|
8110
|
+
// If the export is listed in `durableNamespaces`, then it is also a
|
|
8111
|
+
// DurableObjectNamespace.
|
|
8112
|
+
(K extends GlobalProp<"durableNamespaces", never>
|
|
8113
|
+
? MainModule[K] extends new (...args: any[]) => infer DoInstance
|
|
8114
|
+
? DoInstance extends Rpc.DurableObjectBranded
|
|
8115
|
+
? DurableObjectNamespace<DoInstance>
|
|
8116
|
+
: DurableObjectNamespace<undefined>
|
|
8117
|
+
: DurableObjectNamespace<undefined>
|
|
8118
|
+
: {});
|
|
8119
|
+
};
|
|
8094
8120
|
}
|
|
8095
8121
|
declare module "cloudflare:node" {
|
|
8096
8122
|
export interface DefaultHandler {
|
|
@@ -8108,7 +8134,7 @@ declare module "cloudflare:node" {
|
|
|
8108
8134
|
handlers?: Omit<DefaultHandler, "fetch">,
|
|
8109
8135
|
): DefaultHandler;
|
|
8110
8136
|
}
|
|
8111
|
-
declare
|
|
8137
|
+
declare namespace CloudflareWorkersModule {
|
|
8112
8138
|
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
|
|
8113
8139
|
export const RpcStub: {
|
|
8114
8140
|
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
|
|
@@ -8117,11 +8143,11 @@ declare module "cloudflare:workers" {
|
|
|
8117
8143
|
[Rpc.__RPC_TARGET_BRAND]: never;
|
|
8118
8144
|
}
|
|
8119
8145
|
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
|
|
8120
|
-
export abstract class WorkerEntrypoint<Env =
|
|
8146
|
+
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
|
|
8121
8147
|
implements Rpc.WorkerEntrypointBranded
|
|
8122
8148
|
{
|
|
8123
8149
|
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
|
|
8124
|
-
protected ctx: ExecutionContext
|
|
8150
|
+
protected ctx: ExecutionContext<Props>;
|
|
8125
8151
|
protected env: Env;
|
|
8126
8152
|
constructor(ctx: ExecutionContext, env: Env);
|
|
8127
8153
|
fetch?(request: Request): Response | Promise<Response>;
|
|
@@ -8131,11 +8157,11 @@ declare module "cloudflare:workers" {
|
|
|
8131
8157
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
8132
8158
|
test?(controller: TestController): void | Promise<void>;
|
|
8133
8159
|
}
|
|
8134
|
-
export abstract class DurableObject<Env =
|
|
8160
|
+
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
|
|
8135
8161
|
implements Rpc.DurableObjectBranded
|
|
8136
8162
|
{
|
|
8137
8163
|
[Rpc.__DURABLE_OBJECT_BRAND]: never;
|
|
8138
|
-
protected ctx: DurableObjectState
|
|
8164
|
+
protected ctx: DurableObjectState<Props>;
|
|
8139
8165
|
protected env: Env;
|
|
8140
8166
|
constructor(ctx: DurableObjectState, env: Env);
|
|
8141
8167
|
fetch?(request: Request): Response | Promise<Response>;
|
|
@@ -8222,6 +8248,9 @@ declare module "cloudflare:workers" {
|
|
|
8222
8248
|
export function waitUntil(promise: Promise<unknown>): void;
|
|
8223
8249
|
export const env: Cloudflare.Env;
|
|
8224
8250
|
}
|
|
8251
|
+
declare module "cloudflare:workers" {
|
|
8252
|
+
export = CloudflareWorkersModule;
|
|
8253
|
+
}
|
|
8225
8254
|
interface SecretsStoreSecret {
|
|
8226
8255
|
/**
|
|
8227
8256
|
* Get a secret from the Secrets Store, returning a string of the secret value
|
package/2022-10-31/index.ts
CHANGED
|
@@ -385,10 +385,10 @@ export declare const Cloudflare: Cloudflare;
|
|
|
385
385
|
export declare const origin: string;
|
|
386
386
|
export declare const navigator: Navigator;
|
|
387
387
|
export interface TestController {}
|
|
388
|
-
export interface ExecutionContext {
|
|
388
|
+
export interface ExecutionContext<Props = unknown> {
|
|
389
389
|
waitUntil(promise: Promise<any>): void;
|
|
390
390
|
passThroughOnException(): void;
|
|
391
|
-
props:
|
|
391
|
+
readonly props: Props;
|
|
392
392
|
}
|
|
393
393
|
export type ExportedHandlerFetchHandler<
|
|
394
394
|
Env = unknown,
|
|
@@ -540,9 +540,12 @@ export type DurableObjectLocationHint =
|
|
|
540
540
|
export interface DurableObjectNamespaceGetDurableObjectOptions {
|
|
541
541
|
locationHint?: DurableObjectLocationHint;
|
|
542
542
|
}
|
|
543
|
-
export interface
|
|
543
|
+
export interface DurableObjectClass<
|
|
544
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
545
|
+
> {}
|
|
546
|
+
export interface DurableObjectState<Props = unknown> {
|
|
544
547
|
waitUntil(promise: Promise<any>): void;
|
|
545
|
-
props:
|
|
548
|
+
readonly props: Props;
|
|
546
549
|
readonly id: DurableObjectId;
|
|
547
550
|
readonly storage: DurableObjectStorage;
|
|
548
551
|
container?: Container;
|
|
@@ -3084,6 +3087,30 @@ export interface MessagePort extends EventTarget {
|
|
|
3084
3087
|
export interface MessagePortPostMessageOptions {
|
|
3085
3088
|
transfer?: any[];
|
|
3086
3089
|
}
|
|
3090
|
+
export type LoopbackForExport<
|
|
3091
|
+
T extends
|
|
3092
|
+
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
3093
|
+
| ExportedHandler<any, any, any>
|
|
3094
|
+
| undefined = undefined,
|
|
3095
|
+
> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
|
|
3096
|
+
? LoopbackServiceStub<InstanceType<T>>
|
|
3097
|
+
: T extends new (...args: any[]) => Rpc.DurableObjectBranded
|
|
3098
|
+
? LoopbackDurableObjectClass<InstanceType<T>>
|
|
3099
|
+
: T extends ExportedHandler<any, any, any>
|
|
3100
|
+
? LoopbackServiceStub<undefined>
|
|
3101
|
+
: undefined;
|
|
3102
|
+
export type LoopbackServiceStub<
|
|
3103
|
+
T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
|
|
3104
|
+
> = Fetcher<T> &
|
|
3105
|
+
(T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
|
|
3106
|
+
? (opts: { props?: Props }) => Fetcher<T>
|
|
3107
|
+
: (opts: { props?: any }) => Fetcher<T>);
|
|
3108
|
+
export type LoopbackDurableObjectClass<
|
|
3109
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
3110
|
+
> = DurableObjectClass<T> &
|
|
3111
|
+
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3112
|
+
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3113
|
+
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3087
3114
|
export interface SyncKvStorage {
|
|
3088
3115
|
get<T = unknown>(key: string): T | undefined;
|
|
3089
3116
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3098,98 +3125,51 @@ export interface SyncKvListOptions {
|
|
|
3098
3125
|
reverse?: boolean;
|
|
3099
3126
|
limit?: number;
|
|
3100
3127
|
}
|
|
3128
|
+
export interface WorkerStub {
|
|
3129
|
+
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
|
|
3130
|
+
name?: string,
|
|
3131
|
+
options?: WorkerStubEntrypointOptions,
|
|
3132
|
+
): Fetcher<T>;
|
|
3133
|
+
}
|
|
3134
|
+
export interface WorkerStubEntrypointOptions {
|
|
3135
|
+
props?: any;
|
|
3136
|
+
}
|
|
3137
|
+
export interface WorkerLoader {
|
|
3138
|
+
get(
|
|
3139
|
+
name: string,
|
|
3140
|
+
getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
|
|
3141
|
+
): WorkerStub;
|
|
3142
|
+
}
|
|
3143
|
+
export interface WorkerLoaderModule {
|
|
3144
|
+
js?: string;
|
|
3145
|
+
cjs?: string;
|
|
3146
|
+
text?: string;
|
|
3147
|
+
data?: ArrayBuffer;
|
|
3148
|
+
json?: any;
|
|
3149
|
+
py?: string;
|
|
3150
|
+
}
|
|
3151
|
+
export interface WorkerLoaderWorkerCode {
|
|
3152
|
+
compatibilityDate: string;
|
|
3153
|
+
compatibilityFlags?: string[];
|
|
3154
|
+
allowExperimental?: boolean;
|
|
3155
|
+
mainModule: string;
|
|
3156
|
+
modules: Record<string, WorkerLoaderModule | string>;
|
|
3157
|
+
env?: any;
|
|
3158
|
+
globalOutbound?: Fetcher | null;
|
|
3159
|
+
tails?: Fetcher[];
|
|
3160
|
+
streamingTails?: Fetcher[];
|
|
3161
|
+
}
|
|
3101
3162
|
/**
|
|
3102
3163
|
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
|
|
3103
3164
|
* as well as timing of subrequests and other operations.
|
|
3104
3165
|
*
|
|
3105
3166
|
* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
|
|
3106
3167
|
*/
|
|
3107
|
-
export declare abstract class Performance
|
|
3168
|
+
export declare abstract class Performance {
|
|
3108
3169
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
|
|
3109
3170
|
get timeOrigin(): number;
|
|
3110
3171
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
|
|
3111
3172
|
now(): number;
|
|
3112
|
-
get eventCounts(): EventCounts;
|
|
3113
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks) */
|
|
3114
|
-
clearMarks(name?: string): void;
|
|
3115
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures) */
|
|
3116
|
-
clearMeasures(name?: string): void;
|
|
3117
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings) */
|
|
3118
|
-
clearResourceTimings(): void;
|
|
3119
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
|
|
3120
|
-
getEntries(): PerformanceEntry[];
|
|
3121
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
|
|
3122
|
-
getEntriesByName(name: string, type: string): PerformanceEntry[];
|
|
3123
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
|
|
3124
|
-
getEntriesByType(type: string): PerformanceEntry[];
|
|
3125
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
|
|
3126
|
-
mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
|
|
3127
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure) */
|
|
3128
|
-
measure(
|
|
3129
|
-
measureName: string,
|
|
3130
|
-
measureOptionsOrStartMark: PerformanceMeasureOptions | string,
|
|
3131
|
-
maybeEndMark?: string,
|
|
3132
|
-
): PerformanceMeasure;
|
|
3133
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
|
|
3134
|
-
setResourceTimingBufferSize(size: number): void;
|
|
3135
|
-
}
|
|
3136
|
-
/**
|
|
3137
|
-
* PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.
|
|
3138
|
-
*
|
|
3139
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
|
|
3140
|
-
*/
|
|
3141
|
-
export interface PerformanceMark extends PerformanceEntry {
|
|
3142
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
|
|
3143
|
-
get detail(): any;
|
|
3144
|
-
}
|
|
3145
|
-
/**
|
|
3146
|
-
* PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.
|
|
3147
|
-
*
|
|
3148
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
|
|
3149
|
-
*/
|
|
3150
|
-
export interface PerformanceMeasure extends PerformanceEntry {
|
|
3151
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
|
|
3152
|
-
get detail(): any;
|
|
3153
|
-
}
|
|
3154
|
-
export interface PerformanceMarkOptions {
|
|
3155
|
-
detail?: any;
|
|
3156
|
-
startTime?: number;
|
|
3157
|
-
}
|
|
3158
|
-
export interface PerformanceMeasureOptions {
|
|
3159
|
-
detail?: any;
|
|
3160
|
-
start?: number;
|
|
3161
|
-
duration?: number;
|
|
3162
|
-
end?: number;
|
|
3163
|
-
}
|
|
3164
|
-
/**
|
|
3165
|
-
* Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
|
|
3166
|
-
*
|
|
3167
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
|
|
3168
|
-
*/
|
|
3169
|
-
export declare abstract class PerformanceEntry {
|
|
3170
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name) */
|
|
3171
|
-
get name(): string;
|
|
3172
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType) */
|
|
3173
|
-
get entryType(): string;
|
|
3174
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime) */
|
|
3175
|
-
get startTime(): number;
|
|
3176
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration) */
|
|
3177
|
-
get duration(): number;
|
|
3178
|
-
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON) */
|
|
3179
|
-
toJSON(): any;
|
|
3180
|
-
}
|
|
3181
|
-
export interface EventCounts {
|
|
3182
|
-
get size(): number;
|
|
3183
|
-
get(eventType: string): number | undefined;
|
|
3184
|
-
has(eventType: string): boolean;
|
|
3185
|
-
entries(): IterableIterator<string[]>;
|
|
3186
|
-
keys(): IterableIterator<string>;
|
|
3187
|
-
values(): IterableIterator<number>;
|
|
3188
|
-
forEach(
|
|
3189
|
-
param1: (param0: number, param1: string, param2: EventCounts) => void,
|
|
3190
|
-
param2?: any,
|
|
3191
|
-
): void;
|
|
3192
|
-
[Symbol.iterator](): IterableIterator<string[]>;
|
|
3193
3173
|
}
|
|
3194
3174
|
export type AiImageClassificationInput = {
|
|
3195
3175
|
image: number[];
|
|
@@ -8072,7 +8052,167 @@ export declare namespace Rpc {
|
|
|
8072
8052
|
};
|
|
8073
8053
|
}
|
|
8074
8054
|
export declare namespace Cloudflare {
|
|
8055
|
+
// Type of `env`.
|
|
8056
|
+
//
|
|
8057
|
+
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
|
|
8058
|
+
// will merge all declarations.
|
|
8059
|
+
//
|
|
8060
|
+
// You can use `wrangler types` to generate the `Env` type automatically.
|
|
8075
8061
|
interface Env {}
|
|
8062
|
+
// Project-specific parameters used to inform types.
|
|
8063
|
+
//
|
|
8064
|
+
// This interface is, again, intended to be declared in project-specific files, and then that
|
|
8065
|
+
// declaration will be merged with this one.
|
|
8066
|
+
//
|
|
8067
|
+
// A project should have a declaration like this:
|
|
8068
|
+
//
|
|
8069
|
+
// interface GlobalProps {
|
|
8070
|
+
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
|
|
8071
|
+
// // of `ctx.exports`.
|
|
8072
|
+
// mainModule: typeof import("my-main-module");
|
|
8073
|
+
//
|
|
8074
|
+
// // Declares which of the main module's exports are configured with durable storage, and
|
|
8075
|
+
// // thus should behave as Durable Object namsepace bindings.
|
|
8076
|
+
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
|
|
8077
|
+
// }
|
|
8078
|
+
//
|
|
8079
|
+
// You can use `wrangler types` to generate `GlobalProps` automatically.
|
|
8080
|
+
interface GlobalProps {}
|
|
8081
|
+
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
|
|
8082
|
+
// present.
|
|
8083
|
+
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
|
|
8084
|
+
? GlobalProps[K]
|
|
8085
|
+
: Default;
|
|
8086
|
+
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
|
|
8087
|
+
// `mainModule` property.
|
|
8088
|
+
type MainModule = GlobalProp<"mainModule", {}>;
|
|
8089
|
+
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
|
|
8090
|
+
type Exports = {
|
|
8091
|
+
[K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
|
|
8092
|
+
// If the export is listed in `durableNamespaces`, then it is also a
|
|
8093
|
+
// DurableObjectNamespace.
|
|
8094
|
+
(K extends GlobalProp<"durableNamespaces", never>
|
|
8095
|
+
? MainModule[K] extends new (...args: any[]) => infer DoInstance
|
|
8096
|
+
? DoInstance extends Rpc.DurableObjectBranded
|
|
8097
|
+
? DurableObjectNamespace<DoInstance>
|
|
8098
|
+
: DurableObjectNamespace<undefined>
|
|
8099
|
+
: DurableObjectNamespace<undefined>
|
|
8100
|
+
: {});
|
|
8101
|
+
};
|
|
8102
|
+
}
|
|
8103
|
+
export declare namespace CloudflareWorkersModule {
|
|
8104
|
+
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
|
|
8105
|
+
export const RpcStub: {
|
|
8106
|
+
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
|
|
8107
|
+
};
|
|
8108
|
+
export abstract class RpcTarget implements Rpc.RpcTargetBranded {
|
|
8109
|
+
[Rpc.__RPC_TARGET_BRAND]: never;
|
|
8110
|
+
}
|
|
8111
|
+
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
|
|
8112
|
+
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
|
|
8113
|
+
implements Rpc.WorkerEntrypointBranded
|
|
8114
|
+
{
|
|
8115
|
+
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
|
|
8116
|
+
protected ctx: ExecutionContext<Props>;
|
|
8117
|
+
protected env: Env;
|
|
8118
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
8119
|
+
fetch?(request: Request): Response | Promise<Response>;
|
|
8120
|
+
tail?(events: TraceItem[]): void | Promise<void>;
|
|
8121
|
+
trace?(traces: TraceItem[]): void | Promise<void>;
|
|
8122
|
+
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
8123
|
+
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
8124
|
+
test?(controller: TestController): void | Promise<void>;
|
|
8125
|
+
}
|
|
8126
|
+
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
|
|
8127
|
+
implements Rpc.DurableObjectBranded
|
|
8128
|
+
{
|
|
8129
|
+
[Rpc.__DURABLE_OBJECT_BRAND]: never;
|
|
8130
|
+
protected ctx: DurableObjectState<Props>;
|
|
8131
|
+
protected env: Env;
|
|
8132
|
+
constructor(ctx: DurableObjectState, env: Env);
|
|
8133
|
+
fetch?(request: Request): Response | Promise<Response>;
|
|
8134
|
+
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
8135
|
+
webSocketMessage?(
|
|
8136
|
+
ws: WebSocket,
|
|
8137
|
+
message: string | ArrayBuffer,
|
|
8138
|
+
): void | Promise<void>;
|
|
8139
|
+
webSocketClose?(
|
|
8140
|
+
ws: WebSocket,
|
|
8141
|
+
code: number,
|
|
8142
|
+
reason: string,
|
|
8143
|
+
wasClean: boolean,
|
|
8144
|
+
): void | Promise<void>;
|
|
8145
|
+
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
|
|
8146
|
+
}
|
|
8147
|
+
export type WorkflowDurationLabel =
|
|
8148
|
+
| "second"
|
|
8149
|
+
| "minute"
|
|
8150
|
+
| "hour"
|
|
8151
|
+
| "day"
|
|
8152
|
+
| "week"
|
|
8153
|
+
| "month"
|
|
8154
|
+
| "year";
|
|
8155
|
+
export type WorkflowSleepDuration =
|
|
8156
|
+
| `${number} ${WorkflowDurationLabel}${"s" | ""}`
|
|
8157
|
+
| number;
|
|
8158
|
+
export type WorkflowDelayDuration = WorkflowSleepDuration;
|
|
8159
|
+
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
|
|
8160
|
+
export type WorkflowRetentionDuration = WorkflowSleepDuration;
|
|
8161
|
+
export type WorkflowBackoff = "constant" | "linear" | "exponential";
|
|
8162
|
+
export type WorkflowStepConfig = {
|
|
8163
|
+
retries?: {
|
|
8164
|
+
limit: number;
|
|
8165
|
+
delay: WorkflowDelayDuration | number;
|
|
8166
|
+
backoff?: WorkflowBackoff;
|
|
8167
|
+
};
|
|
8168
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
8169
|
+
};
|
|
8170
|
+
export type WorkflowEvent<T> = {
|
|
8171
|
+
payload: Readonly<T>;
|
|
8172
|
+
timestamp: Date;
|
|
8173
|
+
instanceId: string;
|
|
8174
|
+
};
|
|
8175
|
+
export type WorkflowStepEvent<T> = {
|
|
8176
|
+
payload: Readonly<T>;
|
|
8177
|
+
timestamp: Date;
|
|
8178
|
+
type: string;
|
|
8179
|
+
};
|
|
8180
|
+
export abstract class WorkflowStep {
|
|
8181
|
+
do<T extends Rpc.Serializable<T>>(
|
|
8182
|
+
name: string,
|
|
8183
|
+
callback: () => Promise<T>,
|
|
8184
|
+
): Promise<T>;
|
|
8185
|
+
do<T extends Rpc.Serializable<T>>(
|
|
8186
|
+
name: string,
|
|
8187
|
+
config: WorkflowStepConfig,
|
|
8188
|
+
callback: () => Promise<T>,
|
|
8189
|
+
): Promise<T>;
|
|
8190
|
+
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
|
|
8191
|
+
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
|
|
8192
|
+
waitForEvent<T extends Rpc.Serializable<T>>(
|
|
8193
|
+
name: string,
|
|
8194
|
+
options: {
|
|
8195
|
+
type: string;
|
|
8196
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
8197
|
+
},
|
|
8198
|
+
): Promise<WorkflowStepEvent<T>>;
|
|
8199
|
+
}
|
|
8200
|
+
export abstract class WorkflowEntrypoint<
|
|
8201
|
+
Env = unknown,
|
|
8202
|
+
T extends Rpc.Serializable<T> | unknown = unknown,
|
|
8203
|
+
> implements Rpc.WorkflowEntrypointBranded
|
|
8204
|
+
{
|
|
8205
|
+
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
8206
|
+
protected ctx: ExecutionContext;
|
|
8207
|
+
protected env: Env;
|
|
8208
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
8209
|
+
run(
|
|
8210
|
+
event: Readonly<WorkflowEvent<T>>,
|
|
8211
|
+
step: WorkflowStep,
|
|
8212
|
+
): Promise<unknown>;
|
|
8213
|
+
}
|
|
8214
|
+
export function waitUntil(promise: Promise<unknown>): void;
|
|
8215
|
+
export const env: Cloudflare.Env;
|
|
8076
8216
|
}
|
|
8077
8217
|
export interface SecretsStoreSecret {
|
|
8078
8218
|
/**
|