@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/experimental/index.d.ts
CHANGED
|
@@ -401,11 +401,11 @@ declare const Cloudflare: Cloudflare;
|
|
|
401
401
|
declare const origin: string;
|
|
402
402
|
declare const navigator: Navigator;
|
|
403
403
|
interface TestController {}
|
|
404
|
-
interface ExecutionContext {
|
|
404
|
+
interface ExecutionContext<Props = unknown> {
|
|
405
405
|
waitUntil(promise: Promise<any>): void;
|
|
406
406
|
passThroughOnException(): void;
|
|
407
|
-
exports:
|
|
408
|
-
props:
|
|
407
|
+
readonly exports: Cloudflare.Exports;
|
|
408
|
+
readonly props: Props;
|
|
409
409
|
abort(reason?: any): void;
|
|
410
410
|
}
|
|
411
411
|
type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
|
|
@@ -566,11 +566,13 @@ type DurableObjectLocationHint =
|
|
|
566
566
|
interface DurableObjectNamespaceGetDurableObjectOptions {
|
|
567
567
|
locationHint?: DurableObjectLocationHint;
|
|
568
568
|
}
|
|
569
|
-
|
|
570
|
-
|
|
569
|
+
interface DurableObjectClass<
|
|
570
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
571
|
+
> {}
|
|
572
|
+
interface DurableObjectState<Props = unknown> {
|
|
571
573
|
waitUntil(promise: Promise<any>): void;
|
|
572
|
-
exports:
|
|
573
|
-
props:
|
|
574
|
+
readonly exports: Cloudflare.Exports;
|
|
575
|
+
readonly props: Props;
|
|
574
576
|
readonly id: DurableObjectId;
|
|
575
577
|
readonly storage: DurableObjectStorage;
|
|
576
578
|
container?: Container;
|
|
@@ -694,21 +696,20 @@ declare class WebSocketRequestResponsePair {
|
|
|
694
696
|
get response(): string;
|
|
695
697
|
}
|
|
696
698
|
interface DurableObjectFacets {
|
|
697
|
-
get(
|
|
699
|
+
get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
|
|
698
700
|
name: string,
|
|
699
701
|
getStartupOptions: () =>
|
|
700
|
-
|
|
|
701
|
-
| Promise<
|
|
702
|
-
): Fetcher
|
|
702
|
+
| FacetStartupOptions<T>
|
|
703
|
+
| Promise<FacetStartupOptions<T>>,
|
|
704
|
+
): Fetcher<T>;
|
|
703
705
|
abort(name: string, reason: any): void;
|
|
704
706
|
delete(name: string): void;
|
|
705
707
|
}
|
|
706
|
-
interface
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
| LoopbackDurableObjectNamespace
|
|
710
|
-
| LoopbackColoLocalActorNamespace;
|
|
708
|
+
interface FacetStartupOptions<
|
|
709
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
710
|
+
> {
|
|
711
711
|
id?: DurableObjectId | string;
|
|
712
|
+
class: DurableObjectClass<T>;
|
|
712
713
|
}
|
|
713
714
|
interface AnalyticsEngineDataset {
|
|
714
715
|
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
|
|
@@ -3342,6 +3343,30 @@ declare class MessageChannel {
|
|
|
3342
3343
|
interface MessagePortPostMessageOptions {
|
|
3343
3344
|
transfer?: any[];
|
|
3344
3345
|
}
|
|
3346
|
+
type LoopbackForExport<
|
|
3347
|
+
T extends
|
|
3348
|
+
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
3349
|
+
| ExportedHandler<any, any, any>
|
|
3350
|
+
| undefined = undefined,
|
|
3351
|
+
> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
|
|
3352
|
+
? LoopbackServiceStub<InstanceType<T>>
|
|
3353
|
+
: T extends new (...args: any[]) => Rpc.DurableObjectBranded
|
|
3354
|
+
? LoopbackDurableObjectClass<InstanceType<T>>
|
|
3355
|
+
: T extends ExportedHandler<any, any, any>
|
|
3356
|
+
? LoopbackServiceStub<undefined>
|
|
3357
|
+
: undefined;
|
|
3358
|
+
type LoopbackServiceStub<
|
|
3359
|
+
T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
|
|
3360
|
+
> = Fetcher<T> &
|
|
3361
|
+
(T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
|
|
3362
|
+
? (opts: { props?: Props }) => Fetcher<T>
|
|
3363
|
+
: (opts: { props?: any }) => Fetcher<T>);
|
|
3364
|
+
type LoopbackDurableObjectClass<
|
|
3365
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
3366
|
+
> = DurableObjectClass<T> &
|
|
3367
|
+
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3368
|
+
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3369
|
+
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3345
3370
|
interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
|
|
3346
3371
|
interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
|
|
3347
3372
|
interface SyncKvStorage {
|
|
@@ -3358,6 +3383,44 @@ interface SyncKvListOptions {
|
|
|
3358
3383
|
reverse?: boolean;
|
|
3359
3384
|
limit?: number;
|
|
3360
3385
|
}
|
|
3386
|
+
interface WorkerStub {
|
|
3387
|
+
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
|
|
3388
|
+
name?: string,
|
|
3389
|
+
options?: WorkerStubEntrypointOptions,
|
|
3390
|
+
): Fetcher<T>;
|
|
3391
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3392
|
+
name?: string,
|
|
3393
|
+
options?: WorkerStubEntrypointOptions,
|
|
3394
|
+
): DurableObjectClass<T>;
|
|
3395
|
+
}
|
|
3396
|
+
interface WorkerStubEntrypointOptions {
|
|
3397
|
+
props?: any;
|
|
3398
|
+
}
|
|
3399
|
+
interface WorkerLoader {
|
|
3400
|
+
get(
|
|
3401
|
+
name: string,
|
|
3402
|
+
getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
|
|
3403
|
+
): WorkerStub;
|
|
3404
|
+
}
|
|
3405
|
+
interface WorkerLoaderModule {
|
|
3406
|
+
js?: string;
|
|
3407
|
+
cjs?: string;
|
|
3408
|
+
text?: string;
|
|
3409
|
+
data?: ArrayBuffer;
|
|
3410
|
+
json?: any;
|
|
3411
|
+
py?: string;
|
|
3412
|
+
}
|
|
3413
|
+
interface WorkerLoaderWorkerCode {
|
|
3414
|
+
compatibilityDate: string;
|
|
3415
|
+
compatibilityFlags?: string[];
|
|
3416
|
+
allowExperimental?: boolean;
|
|
3417
|
+
mainModule: string;
|
|
3418
|
+
modules: Record<string, WorkerLoaderModule | string>;
|
|
3419
|
+
env?: any;
|
|
3420
|
+
globalOutbound?: Fetcher | null;
|
|
3421
|
+
tails?: Fetcher[];
|
|
3422
|
+
streamingTails?: Fetcher[];
|
|
3423
|
+
}
|
|
3361
3424
|
/**
|
|
3362
3425
|
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
|
|
3363
3426
|
* as well as timing of subrequests and other operations.
|
|
@@ -3379,7 +3442,7 @@ declare abstract class Performance extends EventTarget {
|
|
|
3379
3442
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
|
|
3380
3443
|
getEntries(): PerformanceEntry[];
|
|
3381
3444
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
|
|
3382
|
-
getEntriesByName(name: string, type
|
|
3445
|
+
getEntriesByName(name: string, type?: string): PerformanceEntry[];
|
|
3383
3446
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
|
|
3384
3447
|
getEntriesByType(type: string): PerformanceEntry[];
|
|
3385
3448
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
|
|
@@ -3392,15 +3455,20 @@ declare abstract class Performance extends EventTarget {
|
|
|
3392
3455
|
): PerformanceMeasure;
|
|
3393
3456
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
|
|
3394
3457
|
setResourceTimingBufferSize(size: number): void;
|
|
3458
|
+
eventLoopUtilization(): void;
|
|
3459
|
+
markResourceTiming(): void;
|
|
3460
|
+
timerify(fn: () => void): () => void;
|
|
3395
3461
|
}
|
|
3396
3462
|
/**
|
|
3397
3463
|
* 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.
|
|
3398
3464
|
*
|
|
3399
3465
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
|
|
3400
3466
|
*/
|
|
3401
|
-
declare
|
|
3467
|
+
declare class PerformanceMark extends PerformanceEntry {
|
|
3468
|
+
constructor(name: string, maybeOptions?: PerformanceMarkOptions);
|
|
3402
3469
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
|
|
3403
|
-
get detail(): any;
|
|
3470
|
+
get detail(): any | undefined;
|
|
3471
|
+
toJSON(): any;
|
|
3404
3472
|
}
|
|
3405
3473
|
/**
|
|
3406
3474
|
* 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.
|
|
@@ -3409,7 +3477,8 @@ declare abstract class PerformanceMark extends PerformanceEntry {
|
|
|
3409
3477
|
*/
|
|
3410
3478
|
declare abstract class PerformanceMeasure extends PerformanceEntry {
|
|
3411
3479
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
|
|
3412
|
-
get detail(): any;
|
|
3480
|
+
get detail(): any | undefined;
|
|
3481
|
+
toJSON(): any;
|
|
3413
3482
|
}
|
|
3414
3483
|
interface PerformanceMarkOptions {
|
|
3415
3484
|
detail?: any;
|
|
@@ -3502,11 +3571,10 @@ declare class PerformanceObserver {
|
|
|
3502
3571
|
readonly supportedEntryTypes: string[];
|
|
3503
3572
|
}
|
|
3504
3573
|
interface PerformanceObserverObserveOptions {
|
|
3505
|
-
buffered
|
|
3506
|
-
durationThreshold
|
|
3507
|
-
entryTypes
|
|
3574
|
+
buffered?: boolean;
|
|
3575
|
+
durationThreshold?: number;
|
|
3576
|
+
entryTypes?: string[];
|
|
3508
3577
|
type?: string;
|
|
3509
|
-
name?: string;
|
|
3510
3578
|
}
|
|
3511
3579
|
interface EventCounts {
|
|
3512
3580
|
get size(): number;
|
|
@@ -8431,7 +8499,53 @@ declare namespace Rpc {
|
|
|
8431
8499
|
};
|
|
8432
8500
|
}
|
|
8433
8501
|
declare namespace Cloudflare {
|
|
8502
|
+
// Type of `env`.
|
|
8503
|
+
//
|
|
8504
|
+
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
|
|
8505
|
+
// will merge all declarations.
|
|
8506
|
+
//
|
|
8507
|
+
// You can use `wrangler types` to generate the `Env` type automatically.
|
|
8434
8508
|
interface Env {}
|
|
8509
|
+
// Project-specific parameters used to inform types.
|
|
8510
|
+
//
|
|
8511
|
+
// This interface is, again, intended to be declared in project-specific files, and then that
|
|
8512
|
+
// declaration will be merged with this one.
|
|
8513
|
+
//
|
|
8514
|
+
// A project should have a declaration like this:
|
|
8515
|
+
//
|
|
8516
|
+
// interface GlobalProps {
|
|
8517
|
+
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
|
|
8518
|
+
// // of `ctx.exports`.
|
|
8519
|
+
// mainModule: typeof import("my-main-module");
|
|
8520
|
+
//
|
|
8521
|
+
// // Declares which of the main module's exports are configured with durable storage, and
|
|
8522
|
+
// // thus should behave as Durable Object namsepace bindings.
|
|
8523
|
+
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
|
|
8524
|
+
// }
|
|
8525
|
+
//
|
|
8526
|
+
// You can use `wrangler types` to generate `GlobalProps` automatically.
|
|
8527
|
+
interface GlobalProps {}
|
|
8528
|
+
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
|
|
8529
|
+
// present.
|
|
8530
|
+
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
|
|
8531
|
+
? GlobalProps[K]
|
|
8532
|
+
: Default;
|
|
8533
|
+
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
|
|
8534
|
+
// `mainModule` property.
|
|
8535
|
+
type MainModule = GlobalProp<"mainModule", {}>;
|
|
8536
|
+
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
|
|
8537
|
+
type Exports = {
|
|
8538
|
+
[K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
|
|
8539
|
+
// If the export is listed in `durableNamespaces`, then it is also a
|
|
8540
|
+
// DurableObjectNamespace.
|
|
8541
|
+
(K extends GlobalProp<"durableNamespaces", never>
|
|
8542
|
+
? MainModule[K] extends new (...args: any[]) => infer DoInstance
|
|
8543
|
+
? DoInstance extends Rpc.DurableObjectBranded
|
|
8544
|
+
? DurableObjectNamespace<DoInstance>
|
|
8545
|
+
: DurableObjectNamespace<undefined>
|
|
8546
|
+
: DurableObjectNamespace<undefined>
|
|
8547
|
+
: {});
|
|
8548
|
+
};
|
|
8435
8549
|
}
|
|
8436
8550
|
declare module "cloudflare:node" {
|
|
8437
8551
|
export interface DefaultHandler {
|
|
@@ -8449,7 +8563,7 @@ declare module "cloudflare:node" {
|
|
|
8449
8563
|
handlers?: Omit<DefaultHandler, "fetch">,
|
|
8450
8564
|
): DefaultHandler;
|
|
8451
8565
|
}
|
|
8452
|
-
declare
|
|
8566
|
+
declare namespace CloudflareWorkersModule {
|
|
8453
8567
|
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
|
|
8454
8568
|
export const RpcStub: {
|
|
8455
8569
|
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
|
|
@@ -8458,11 +8572,11 @@ declare module "cloudflare:workers" {
|
|
|
8458
8572
|
[Rpc.__RPC_TARGET_BRAND]: never;
|
|
8459
8573
|
}
|
|
8460
8574
|
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
|
|
8461
|
-
export abstract class WorkerEntrypoint<Env =
|
|
8575
|
+
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
|
|
8462
8576
|
implements Rpc.WorkerEntrypointBranded
|
|
8463
8577
|
{
|
|
8464
8578
|
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
|
|
8465
|
-
protected ctx: ExecutionContext
|
|
8579
|
+
protected ctx: ExecutionContext<Props>;
|
|
8466
8580
|
protected env: Env;
|
|
8467
8581
|
constructor(ctx: ExecutionContext, env: Env);
|
|
8468
8582
|
fetch?(request: Request): Response | Promise<Response>;
|
|
@@ -8472,11 +8586,11 @@ declare module "cloudflare:workers" {
|
|
|
8472
8586
|
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
8473
8587
|
test?(controller: TestController): void | Promise<void>;
|
|
8474
8588
|
}
|
|
8475
|
-
export abstract class DurableObject<Env =
|
|
8589
|
+
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
|
|
8476
8590
|
implements Rpc.DurableObjectBranded
|
|
8477
8591
|
{
|
|
8478
8592
|
[Rpc.__DURABLE_OBJECT_BRAND]: never;
|
|
8479
|
-
protected ctx: DurableObjectState
|
|
8593
|
+
protected ctx: DurableObjectState<Props>;
|
|
8480
8594
|
protected env: Env;
|
|
8481
8595
|
constructor(ctx: DurableObjectState, env: Env);
|
|
8482
8596
|
fetch?(request: Request): Response | Promise<Response>;
|
|
@@ -8563,6 +8677,9 @@ declare module "cloudflare:workers" {
|
|
|
8563
8677
|
export function waitUntil(promise: Promise<unknown>): void;
|
|
8564
8678
|
export const env: Cloudflare.Env;
|
|
8565
8679
|
}
|
|
8680
|
+
declare module "cloudflare:workers" {
|
|
8681
|
+
export = CloudflareWorkersModule;
|
|
8682
|
+
}
|
|
8566
8683
|
interface SecretsStoreSecret {
|
|
8567
8684
|
/**
|
|
8568
8685
|
* Get a secret from the Secrets Store, returning a string of the secret value
|
package/experimental/index.ts
CHANGED
|
@@ -403,11 +403,11 @@ export declare const Cloudflare: Cloudflare;
|
|
|
403
403
|
export declare const origin: string;
|
|
404
404
|
export declare const navigator: Navigator;
|
|
405
405
|
export interface TestController {}
|
|
406
|
-
export interface ExecutionContext {
|
|
406
|
+
export interface ExecutionContext<Props = unknown> {
|
|
407
407
|
waitUntil(promise: Promise<any>): void;
|
|
408
408
|
passThroughOnException(): void;
|
|
409
|
-
exports:
|
|
410
|
-
props:
|
|
409
|
+
readonly exports: Cloudflare.Exports;
|
|
410
|
+
readonly props: Props;
|
|
411
411
|
abort(reason?: any): void;
|
|
412
412
|
}
|
|
413
413
|
export type ExportedHandlerFetchHandler<
|
|
@@ -571,11 +571,13 @@ export type DurableObjectLocationHint =
|
|
|
571
571
|
export interface DurableObjectNamespaceGetDurableObjectOptions {
|
|
572
572
|
locationHint?: DurableObjectLocationHint;
|
|
573
573
|
}
|
|
574
|
-
export
|
|
575
|
-
|
|
574
|
+
export interface DurableObjectClass<
|
|
575
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
576
|
+
> {}
|
|
577
|
+
export interface DurableObjectState<Props = unknown> {
|
|
576
578
|
waitUntil(promise: Promise<any>): void;
|
|
577
|
-
exports:
|
|
578
|
-
props:
|
|
579
|
+
readonly exports: Cloudflare.Exports;
|
|
580
|
+
readonly props: Props;
|
|
579
581
|
readonly id: DurableObjectId;
|
|
580
582
|
readonly storage: DurableObjectStorage;
|
|
581
583
|
container?: Container;
|
|
@@ -699,21 +701,20 @@ export declare class WebSocketRequestResponsePair {
|
|
|
699
701
|
get response(): string;
|
|
700
702
|
}
|
|
701
703
|
export interface DurableObjectFacets {
|
|
702
|
-
get(
|
|
704
|
+
get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
|
|
703
705
|
name: string,
|
|
704
706
|
getStartupOptions: () =>
|
|
705
|
-
|
|
|
706
|
-
| Promise<
|
|
707
|
-
): Fetcher
|
|
707
|
+
| FacetStartupOptions<T>
|
|
708
|
+
| Promise<FacetStartupOptions<T>>,
|
|
709
|
+
): Fetcher<T>;
|
|
708
710
|
abort(name: string, reason: any): void;
|
|
709
711
|
delete(name: string): void;
|
|
710
712
|
}
|
|
711
|
-
export interface
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
| LoopbackDurableObjectNamespace
|
|
715
|
-
| LoopbackColoLocalActorNamespace;
|
|
713
|
+
export interface FacetStartupOptions<
|
|
714
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
715
|
+
> {
|
|
716
716
|
id?: DurableObjectId | string;
|
|
717
|
+
class: DurableObjectClass<T>;
|
|
717
718
|
}
|
|
718
719
|
export interface AnalyticsEngineDataset {
|
|
719
720
|
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
|
|
@@ -3353,6 +3354,30 @@ export declare class MessageChannel {
|
|
|
3353
3354
|
export interface MessagePortPostMessageOptions {
|
|
3354
3355
|
transfer?: any[];
|
|
3355
3356
|
}
|
|
3357
|
+
export type LoopbackForExport<
|
|
3358
|
+
T extends
|
|
3359
|
+
| (new (...args: any[]) => Rpc.EntrypointBranded)
|
|
3360
|
+
| ExportedHandler<any, any, any>
|
|
3361
|
+
| undefined = undefined,
|
|
3362
|
+
> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
|
|
3363
|
+
? LoopbackServiceStub<InstanceType<T>>
|
|
3364
|
+
: T extends new (...args: any[]) => Rpc.DurableObjectBranded
|
|
3365
|
+
? LoopbackDurableObjectClass<InstanceType<T>>
|
|
3366
|
+
: T extends ExportedHandler<any, any, any>
|
|
3367
|
+
? LoopbackServiceStub<undefined>
|
|
3368
|
+
: undefined;
|
|
3369
|
+
export type LoopbackServiceStub<
|
|
3370
|
+
T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
|
|
3371
|
+
> = Fetcher<T> &
|
|
3372
|
+
(T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
|
|
3373
|
+
? (opts: { props?: Props }) => Fetcher<T>
|
|
3374
|
+
: (opts: { props?: any }) => Fetcher<T>);
|
|
3375
|
+
export type LoopbackDurableObjectClass<
|
|
3376
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
3377
|
+
> = DurableObjectClass<T> &
|
|
3378
|
+
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3379
|
+
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3380
|
+
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3356
3381
|
export interface LoopbackDurableObjectNamespace
|
|
3357
3382
|
extends DurableObjectNamespace {}
|
|
3358
3383
|
export interface LoopbackColoLocalActorNamespace
|
|
@@ -3371,6 +3396,44 @@ export interface SyncKvListOptions {
|
|
|
3371
3396
|
reverse?: boolean;
|
|
3372
3397
|
limit?: number;
|
|
3373
3398
|
}
|
|
3399
|
+
export interface WorkerStub {
|
|
3400
|
+
getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
|
|
3401
|
+
name?: string,
|
|
3402
|
+
options?: WorkerStubEntrypointOptions,
|
|
3403
|
+
): Fetcher<T>;
|
|
3404
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3405
|
+
name?: string,
|
|
3406
|
+
options?: WorkerStubEntrypointOptions,
|
|
3407
|
+
): DurableObjectClass<T>;
|
|
3408
|
+
}
|
|
3409
|
+
export interface WorkerStubEntrypointOptions {
|
|
3410
|
+
props?: any;
|
|
3411
|
+
}
|
|
3412
|
+
export interface WorkerLoader {
|
|
3413
|
+
get(
|
|
3414
|
+
name: string,
|
|
3415
|
+
getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
|
|
3416
|
+
): WorkerStub;
|
|
3417
|
+
}
|
|
3418
|
+
export interface WorkerLoaderModule {
|
|
3419
|
+
js?: string;
|
|
3420
|
+
cjs?: string;
|
|
3421
|
+
text?: string;
|
|
3422
|
+
data?: ArrayBuffer;
|
|
3423
|
+
json?: any;
|
|
3424
|
+
py?: string;
|
|
3425
|
+
}
|
|
3426
|
+
export interface WorkerLoaderWorkerCode {
|
|
3427
|
+
compatibilityDate: string;
|
|
3428
|
+
compatibilityFlags?: string[];
|
|
3429
|
+
allowExperimental?: boolean;
|
|
3430
|
+
mainModule: string;
|
|
3431
|
+
modules: Record<string, WorkerLoaderModule | string>;
|
|
3432
|
+
env?: any;
|
|
3433
|
+
globalOutbound?: Fetcher | null;
|
|
3434
|
+
tails?: Fetcher[];
|
|
3435
|
+
streamingTails?: Fetcher[];
|
|
3436
|
+
}
|
|
3374
3437
|
/**
|
|
3375
3438
|
* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
|
|
3376
3439
|
* as well as timing of subrequests and other operations.
|
|
@@ -3392,7 +3455,7 @@ export declare abstract class Performance extends EventTarget {
|
|
|
3392
3455
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
|
|
3393
3456
|
getEntries(): PerformanceEntry[];
|
|
3394
3457
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
|
|
3395
|
-
getEntriesByName(name: string, type
|
|
3458
|
+
getEntriesByName(name: string, type?: string): PerformanceEntry[];
|
|
3396
3459
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
|
|
3397
3460
|
getEntriesByType(type: string): PerformanceEntry[];
|
|
3398
3461
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
|
|
@@ -3405,15 +3468,20 @@ export declare abstract class Performance extends EventTarget {
|
|
|
3405
3468
|
): PerformanceMeasure;
|
|
3406
3469
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
|
|
3407
3470
|
setResourceTimingBufferSize(size: number): void;
|
|
3471
|
+
eventLoopUtilization(): void;
|
|
3472
|
+
markResourceTiming(): void;
|
|
3473
|
+
timerify(fn: () => void): () => void;
|
|
3408
3474
|
}
|
|
3409
3475
|
/**
|
|
3410
3476
|
* 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.
|
|
3411
3477
|
*
|
|
3412
3478
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
|
|
3413
3479
|
*/
|
|
3414
|
-
export declare
|
|
3480
|
+
export declare class PerformanceMark extends PerformanceEntry {
|
|
3481
|
+
constructor(name: string, maybeOptions?: PerformanceMarkOptions);
|
|
3415
3482
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
|
|
3416
|
-
get detail(): any;
|
|
3483
|
+
get detail(): any | undefined;
|
|
3484
|
+
toJSON(): any;
|
|
3417
3485
|
}
|
|
3418
3486
|
/**
|
|
3419
3487
|
* 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.
|
|
@@ -3422,7 +3490,8 @@ export declare abstract class PerformanceMark extends PerformanceEntry {
|
|
|
3422
3490
|
*/
|
|
3423
3491
|
export declare abstract class PerformanceMeasure extends PerformanceEntry {
|
|
3424
3492
|
/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
|
|
3425
|
-
get detail(): any;
|
|
3493
|
+
get detail(): any | undefined;
|
|
3494
|
+
toJSON(): any;
|
|
3426
3495
|
}
|
|
3427
3496
|
export interface PerformanceMarkOptions {
|
|
3428
3497
|
detail?: any;
|
|
@@ -3515,11 +3584,10 @@ export declare class PerformanceObserver {
|
|
|
3515
3584
|
readonly supportedEntryTypes: string[];
|
|
3516
3585
|
}
|
|
3517
3586
|
export interface PerformanceObserverObserveOptions {
|
|
3518
|
-
buffered
|
|
3519
|
-
durationThreshold
|
|
3520
|
-
entryTypes
|
|
3587
|
+
buffered?: boolean;
|
|
3588
|
+
durationThreshold?: number;
|
|
3589
|
+
entryTypes?: string[];
|
|
3521
3590
|
type?: string;
|
|
3522
|
-
name?: string;
|
|
3523
3591
|
}
|
|
3524
3592
|
export interface EventCounts {
|
|
3525
3593
|
get size(): number;
|
|
@@ -8415,7 +8483,167 @@ export declare namespace Rpc {
|
|
|
8415
8483
|
};
|
|
8416
8484
|
}
|
|
8417
8485
|
export declare namespace Cloudflare {
|
|
8486
|
+
// Type of `env`.
|
|
8487
|
+
//
|
|
8488
|
+
// The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
|
|
8489
|
+
// will merge all declarations.
|
|
8490
|
+
//
|
|
8491
|
+
// You can use `wrangler types` to generate the `Env` type automatically.
|
|
8418
8492
|
interface Env {}
|
|
8493
|
+
// Project-specific parameters used to inform types.
|
|
8494
|
+
//
|
|
8495
|
+
// This interface is, again, intended to be declared in project-specific files, and then that
|
|
8496
|
+
// declaration will be merged with this one.
|
|
8497
|
+
//
|
|
8498
|
+
// A project should have a declaration like this:
|
|
8499
|
+
//
|
|
8500
|
+
// interface GlobalProps {
|
|
8501
|
+
// // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
|
|
8502
|
+
// // of `ctx.exports`.
|
|
8503
|
+
// mainModule: typeof import("my-main-module");
|
|
8504
|
+
//
|
|
8505
|
+
// // Declares which of the main module's exports are configured with durable storage, and
|
|
8506
|
+
// // thus should behave as Durable Object namsepace bindings.
|
|
8507
|
+
// durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
|
|
8508
|
+
// }
|
|
8509
|
+
//
|
|
8510
|
+
// You can use `wrangler types` to generate `GlobalProps` automatically.
|
|
8511
|
+
interface GlobalProps {}
|
|
8512
|
+
// Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
|
|
8513
|
+
// present.
|
|
8514
|
+
type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
|
|
8515
|
+
? GlobalProps[K]
|
|
8516
|
+
: Default;
|
|
8517
|
+
// The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
|
|
8518
|
+
// `mainModule` property.
|
|
8519
|
+
type MainModule = GlobalProp<"mainModule", {}>;
|
|
8520
|
+
// The type of ctx.exports, which contains loopback bindings for all top-level exports.
|
|
8521
|
+
type Exports = {
|
|
8522
|
+
[K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
|
|
8523
|
+
// If the export is listed in `durableNamespaces`, then it is also a
|
|
8524
|
+
// DurableObjectNamespace.
|
|
8525
|
+
(K extends GlobalProp<"durableNamespaces", never>
|
|
8526
|
+
? MainModule[K] extends new (...args: any[]) => infer DoInstance
|
|
8527
|
+
? DoInstance extends Rpc.DurableObjectBranded
|
|
8528
|
+
? DurableObjectNamespace<DoInstance>
|
|
8529
|
+
: DurableObjectNamespace<undefined>
|
|
8530
|
+
: DurableObjectNamespace<undefined>
|
|
8531
|
+
: {});
|
|
8532
|
+
};
|
|
8533
|
+
}
|
|
8534
|
+
export declare namespace CloudflareWorkersModule {
|
|
8535
|
+
export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
|
|
8536
|
+
export const RpcStub: {
|
|
8537
|
+
new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
|
|
8538
|
+
};
|
|
8539
|
+
export abstract class RpcTarget implements Rpc.RpcTargetBranded {
|
|
8540
|
+
[Rpc.__RPC_TARGET_BRAND]: never;
|
|
8541
|
+
}
|
|
8542
|
+
// `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
|
|
8543
|
+
export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
|
|
8544
|
+
implements Rpc.WorkerEntrypointBranded
|
|
8545
|
+
{
|
|
8546
|
+
[Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
|
|
8547
|
+
protected ctx: ExecutionContext<Props>;
|
|
8548
|
+
protected env: Env;
|
|
8549
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
8550
|
+
fetch?(request: Request): Response | Promise<Response>;
|
|
8551
|
+
tail?(events: TraceItem[]): void | Promise<void>;
|
|
8552
|
+
trace?(traces: TraceItem[]): void | Promise<void>;
|
|
8553
|
+
scheduled?(controller: ScheduledController): void | Promise<void>;
|
|
8554
|
+
queue?(batch: MessageBatch<unknown>): void | Promise<void>;
|
|
8555
|
+
test?(controller: TestController): void | Promise<void>;
|
|
8556
|
+
}
|
|
8557
|
+
export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
|
|
8558
|
+
implements Rpc.DurableObjectBranded
|
|
8559
|
+
{
|
|
8560
|
+
[Rpc.__DURABLE_OBJECT_BRAND]: never;
|
|
8561
|
+
protected ctx: DurableObjectState<Props>;
|
|
8562
|
+
protected env: Env;
|
|
8563
|
+
constructor(ctx: DurableObjectState, env: Env);
|
|
8564
|
+
fetch?(request: Request): Response | Promise<Response>;
|
|
8565
|
+
alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
|
|
8566
|
+
webSocketMessage?(
|
|
8567
|
+
ws: WebSocket,
|
|
8568
|
+
message: string | ArrayBuffer,
|
|
8569
|
+
): void | Promise<void>;
|
|
8570
|
+
webSocketClose?(
|
|
8571
|
+
ws: WebSocket,
|
|
8572
|
+
code: number,
|
|
8573
|
+
reason: string,
|
|
8574
|
+
wasClean: boolean,
|
|
8575
|
+
): void | Promise<void>;
|
|
8576
|
+
webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
|
|
8577
|
+
}
|
|
8578
|
+
export type WorkflowDurationLabel =
|
|
8579
|
+
| "second"
|
|
8580
|
+
| "minute"
|
|
8581
|
+
| "hour"
|
|
8582
|
+
| "day"
|
|
8583
|
+
| "week"
|
|
8584
|
+
| "month"
|
|
8585
|
+
| "year";
|
|
8586
|
+
export type WorkflowSleepDuration =
|
|
8587
|
+
| `${number} ${WorkflowDurationLabel}${"s" | ""}`
|
|
8588
|
+
| number;
|
|
8589
|
+
export type WorkflowDelayDuration = WorkflowSleepDuration;
|
|
8590
|
+
export type WorkflowTimeoutDuration = WorkflowSleepDuration;
|
|
8591
|
+
export type WorkflowRetentionDuration = WorkflowSleepDuration;
|
|
8592
|
+
export type WorkflowBackoff = "constant" | "linear" | "exponential";
|
|
8593
|
+
export type WorkflowStepConfig = {
|
|
8594
|
+
retries?: {
|
|
8595
|
+
limit: number;
|
|
8596
|
+
delay: WorkflowDelayDuration | number;
|
|
8597
|
+
backoff?: WorkflowBackoff;
|
|
8598
|
+
};
|
|
8599
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
8600
|
+
};
|
|
8601
|
+
export type WorkflowEvent<T> = {
|
|
8602
|
+
payload: Readonly<T>;
|
|
8603
|
+
timestamp: Date;
|
|
8604
|
+
instanceId: string;
|
|
8605
|
+
};
|
|
8606
|
+
export type WorkflowStepEvent<T> = {
|
|
8607
|
+
payload: Readonly<T>;
|
|
8608
|
+
timestamp: Date;
|
|
8609
|
+
type: string;
|
|
8610
|
+
};
|
|
8611
|
+
export abstract class WorkflowStep {
|
|
8612
|
+
do<T extends Rpc.Serializable<T>>(
|
|
8613
|
+
name: string,
|
|
8614
|
+
callback: () => Promise<T>,
|
|
8615
|
+
): Promise<T>;
|
|
8616
|
+
do<T extends Rpc.Serializable<T>>(
|
|
8617
|
+
name: string,
|
|
8618
|
+
config: WorkflowStepConfig,
|
|
8619
|
+
callback: () => Promise<T>,
|
|
8620
|
+
): Promise<T>;
|
|
8621
|
+
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
|
|
8622
|
+
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
|
|
8623
|
+
waitForEvent<T extends Rpc.Serializable<T>>(
|
|
8624
|
+
name: string,
|
|
8625
|
+
options: {
|
|
8626
|
+
type: string;
|
|
8627
|
+
timeout?: WorkflowTimeoutDuration | number;
|
|
8628
|
+
},
|
|
8629
|
+
): Promise<WorkflowStepEvent<T>>;
|
|
8630
|
+
}
|
|
8631
|
+
export abstract class WorkflowEntrypoint<
|
|
8632
|
+
Env = unknown,
|
|
8633
|
+
T extends Rpc.Serializable<T> | unknown = unknown,
|
|
8634
|
+
> implements Rpc.WorkflowEntrypointBranded
|
|
8635
|
+
{
|
|
8636
|
+
[Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
|
|
8637
|
+
protected ctx: ExecutionContext;
|
|
8638
|
+
protected env: Env;
|
|
8639
|
+
constructor(ctx: ExecutionContext, env: Env);
|
|
8640
|
+
run(
|
|
8641
|
+
event: Readonly<WorkflowEvent<T>>,
|
|
8642
|
+
step: WorkflowStep,
|
|
8643
|
+
): Promise<unknown>;
|
|
8644
|
+
}
|
|
8645
|
+
export function waitUntil(promise: Promise<unknown>): void;
|
|
8646
|
+
export const env: Cloudflare.Env;
|
|
8419
8647
|
}
|
|
8420
8648
|
export interface SecretsStoreSecret {
|
|
8421
8649
|
/**
|