@cloudflare/workers-types 0.20230404.0 → 0.20230518.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 +82 -3
- package/2021-11-03/index.ts +75 -3
- package/2022-01-31/index.d.ts +82 -3
- package/2022-01-31/index.ts +75 -3
- package/2022-03-21/index.d.ts +82 -3
- package/2022-03-21/index.ts +75 -3
- package/2022-08-04/index.d.ts +82 -3
- package/2022-08-04/index.ts +75 -3
- package/2022-10-31/index.d.ts +84 -5
- package/2022-10-31/index.ts +77 -5
- package/2022-11-30/index.d.ts +84 -5
- package/2022-11-30/index.ts +77 -5
- package/experimental/index.d.ts +67 -5
- package/experimental/index.ts +60 -5
- package/index.d.ts +82 -3
- package/index.ts +75 -3
- package/oldest/index.d.ts +82 -3
- package/oldest/index.ts +75 -3
- package/package.json +1 -1
package/2021-11-03/index.d.ts
CHANGED
|
@@ -184,11 +184,14 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
184
184
|
crypto: Crypto;
|
|
185
185
|
caches: CacheStorage;
|
|
186
186
|
scheduler: Scheduler;
|
|
187
|
+
performance: Performance;
|
|
188
|
+
readonly origin: string;
|
|
187
189
|
Event: typeof Event;
|
|
188
190
|
ExtendableEvent: typeof ExtendableEvent;
|
|
189
191
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
190
192
|
FetchEvent: typeof FetchEvent;
|
|
191
|
-
|
|
193
|
+
TailEvent: typeof TailEvent;
|
|
194
|
+
TraceEvent: typeof TailEvent;
|
|
192
195
|
ScheduledEvent: typeof ScheduledEvent;
|
|
193
196
|
MessageEvent: typeof MessageEvent;
|
|
194
197
|
CloseEvent: typeof CloseEvent;
|
|
@@ -280,6 +283,8 @@ declare const self: ServiceWorkerGlobalScope;
|
|
|
280
283
|
declare const crypto: Crypto;
|
|
281
284
|
declare const caches: CacheStorage;
|
|
282
285
|
declare const scheduler: Scheduler;
|
|
286
|
+
declare const performance: Performance;
|
|
287
|
+
declare const origin: string;
|
|
283
288
|
declare interface TestController {}
|
|
284
289
|
declare interface ExecutionContext {
|
|
285
290
|
waitUntil(promise: Promise<any>): void;
|
|
@@ -293,6 +298,11 @@ declare type ExportedHandlerFetchHandler<
|
|
|
293
298
|
env: Env,
|
|
294
299
|
ctx: ExecutionContext
|
|
295
300
|
) => Response | Promise<Response>;
|
|
301
|
+
declare type ExportedHandlerTailHandler<Env = unknown> = (
|
|
302
|
+
events: TraceItem[],
|
|
303
|
+
env: Env,
|
|
304
|
+
ctx: ExecutionContext
|
|
305
|
+
) => void | Promise<void>;
|
|
296
306
|
declare type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
297
307
|
traces: TraceItem[],
|
|
298
308
|
env: Env,
|
|
@@ -319,6 +329,7 @@ declare interface ExportedHandler<
|
|
|
319
329
|
CfHostMetadata = unknown
|
|
320
330
|
> {
|
|
321
331
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
332
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
322
333
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
323
334
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
324
335
|
test?: ExportedHandlerTestHandler<Env>;
|
|
@@ -331,6 +342,11 @@ declare abstract class PromiseRejectionEvent extends Event {
|
|
|
331
342
|
readonly promise: Promise<any>;
|
|
332
343
|
readonly reason: any;
|
|
333
344
|
}
|
|
345
|
+
/** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
|
|
346
|
+
declare interface Performance {
|
|
347
|
+
readonly timeOrigin: number;
|
|
348
|
+
now(): number;
|
|
349
|
+
}
|
|
334
350
|
declare interface DurableObject {
|
|
335
351
|
fetch(request: Request): Response | Promise<Response>;
|
|
336
352
|
alarm?(): void | Promise<void>;
|
|
@@ -378,6 +394,8 @@ declare interface DurableObjectState {
|
|
|
378
394
|
readonly id: DurableObjectId;
|
|
379
395
|
readonly storage: DurableObjectStorage;
|
|
380
396
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
397
|
+
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
398
|
+
getWebSockets(tag?: string): WebSocket[];
|
|
381
399
|
}
|
|
382
400
|
declare interface DurableObjectTransaction {
|
|
383
401
|
get<T = unknown>(
|
|
@@ -444,6 +462,7 @@ declare interface DurableObjectStorage {
|
|
|
444
462
|
): Promise<void>;
|
|
445
463
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
446
464
|
sync(): Promise<void>;
|
|
465
|
+
transactionSync<T>(closure: () => T): T;
|
|
447
466
|
}
|
|
448
467
|
declare interface DurableObjectListOptions {
|
|
449
468
|
start?: string;
|
|
@@ -564,6 +583,7 @@ declare class AbortController {
|
|
|
564
583
|
declare abstract class AbortSignal extends EventTarget {
|
|
565
584
|
static abort(reason?: any): AbortSignal;
|
|
566
585
|
static timeout(delay: number): AbortSignal;
|
|
586
|
+
static any(signals: AbortSignal[]): AbortSignal;
|
|
567
587
|
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
|
|
568
588
|
readonly aborted: boolean;
|
|
569
589
|
readonly reason: any;
|
|
@@ -1059,6 +1079,7 @@ declare interface RequestInit<Cf = CfProperties> {
|
|
|
1059
1079
|
}
|
|
1060
1080
|
declare abstract class Fetcher {
|
|
1061
1081
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1082
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1062
1083
|
}
|
|
1063
1084
|
declare interface FetcherPutOptions {
|
|
1064
1085
|
expiration?: number;
|
|
@@ -1631,7 +1652,8 @@ declare interface QueuingStrategyInit {
|
|
|
1631
1652
|
*/
|
|
1632
1653
|
highWaterMark: number;
|
|
1633
1654
|
}
|
|
1634
|
-
declare abstract class
|
|
1655
|
+
declare abstract class TailEvent extends ExtendableEvent {
|
|
1656
|
+
readonly events: TraceItem[];
|
|
1635
1657
|
readonly traces: TraceItem[];
|
|
1636
1658
|
}
|
|
1637
1659
|
declare interface TraceItem {
|
|
@@ -1831,6 +1853,8 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1831
1853
|
accept(): void;
|
|
1832
1854
|
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
|
|
1833
1855
|
close(code?: number, reason?: string): void;
|
|
1856
|
+
serializeAttachment(attachment: any): void;
|
|
1857
|
+
deserializeAttachment(): any | null;
|
|
1834
1858
|
static readonly READY_STATE_CONNECTING: number;
|
|
1835
1859
|
static readonly READY_STATE_OPEN: number;
|
|
1836
1860
|
static readonly READY_STATE_CLOSING: number;
|
|
@@ -1850,6 +1874,24 @@ declare const WebSocketPair: {
|
|
|
1850
1874
|
1: WebSocket;
|
|
1851
1875
|
};
|
|
1852
1876
|
};
|
|
1877
|
+
declare interface Socket {
|
|
1878
|
+
get readable(): ReadableStream;
|
|
1879
|
+
get writable(): WritableStream;
|
|
1880
|
+
get closed(): Promise<void>;
|
|
1881
|
+
close(): Promise<void>;
|
|
1882
|
+
startTls(options?: TlsOptions): Socket;
|
|
1883
|
+
}
|
|
1884
|
+
declare interface SocketOptions {
|
|
1885
|
+
secureTransport?: string;
|
|
1886
|
+
allowHalfOpen: boolean;
|
|
1887
|
+
}
|
|
1888
|
+
declare interface SocketAddress {
|
|
1889
|
+
hostname: string;
|
|
1890
|
+
port: number;
|
|
1891
|
+
}
|
|
1892
|
+
declare interface TlsOptions {
|
|
1893
|
+
expectedServerHostname?: string;
|
|
1894
|
+
}
|
|
1853
1895
|
declare interface BasicImageTransformations {
|
|
1854
1896
|
/**
|
|
1855
1897
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2984,12 +3026,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2984
3026
|
// Key Identifier of the JWK
|
|
2985
3027
|
readonly kid: string;
|
|
2986
3028
|
}
|
|
3029
|
+
declare module "cloudflare:sockets" {
|
|
3030
|
+
function _connect(
|
|
3031
|
+
address: string | SocketAddress,
|
|
3032
|
+
options?: SocketOptions
|
|
3033
|
+
): Socket;
|
|
3034
|
+
export { _connect as connect };
|
|
3035
|
+
}
|
|
2987
3036
|
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3037
|
+
declare interface DynamicDispatchLimits {
|
|
3038
|
+
/**
|
|
3039
|
+
* Limit CPU time in milliseconds.
|
|
3040
|
+
*/
|
|
3041
|
+
cpuMs?: number;
|
|
3042
|
+
/**
|
|
3043
|
+
* Limit number of subrequests.
|
|
3044
|
+
*/
|
|
3045
|
+
subRequests?: number;
|
|
3046
|
+
}
|
|
3047
|
+
declare interface DynamicDispatchOptions {
|
|
3048
|
+
/**
|
|
3049
|
+
* Limit resources of invoked Worker script.
|
|
3050
|
+
*/
|
|
3051
|
+
limits?: DynamicDispatchLimits;
|
|
3052
|
+
/**
|
|
3053
|
+
* Arguments for outbound Worker script, if configured.
|
|
3054
|
+
*/
|
|
3055
|
+
outbound?: {
|
|
3056
|
+
[key: string]: any;
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
2988
3059
|
declare interface DispatchNamespace {
|
|
2989
3060
|
/**
|
|
2990
3061
|
* @param name Name of the Worker script.
|
|
3062
|
+
* @param args Arguments to Worker script.
|
|
3063
|
+
* @param options Options for Dynamic Dispatch invocation.
|
|
2991
3064
|
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
2992
3065
|
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2993
3066
|
*/
|
|
2994
|
-
get(
|
|
3067
|
+
get(
|
|
3068
|
+
name: string,
|
|
3069
|
+
args?: {
|
|
3070
|
+
[key: string]: any;
|
|
3071
|
+
},
|
|
3072
|
+
options?: DynamicDispatchOptions
|
|
3073
|
+
): Fetcher;
|
|
2995
3074
|
}
|
package/2021-11-03/index.ts
CHANGED
|
@@ -184,11 +184,14 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
184
184
|
crypto: Crypto;
|
|
185
185
|
caches: CacheStorage;
|
|
186
186
|
scheduler: Scheduler;
|
|
187
|
+
performance: Performance;
|
|
188
|
+
readonly origin: string;
|
|
187
189
|
Event: typeof Event;
|
|
188
190
|
ExtendableEvent: typeof ExtendableEvent;
|
|
189
191
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
190
192
|
FetchEvent: typeof FetchEvent;
|
|
191
|
-
|
|
193
|
+
TailEvent: typeof TailEvent;
|
|
194
|
+
TraceEvent: typeof TailEvent;
|
|
192
195
|
ScheduledEvent: typeof ScheduledEvent;
|
|
193
196
|
MessageEvent: typeof MessageEvent;
|
|
194
197
|
CloseEvent: typeof CloseEvent;
|
|
@@ -282,6 +285,8 @@ export declare const self: ServiceWorkerGlobalScope;
|
|
|
282
285
|
export declare const crypto: Crypto;
|
|
283
286
|
export declare const caches: CacheStorage;
|
|
284
287
|
export declare const scheduler: Scheduler;
|
|
288
|
+
export declare const performance: Performance;
|
|
289
|
+
export declare const origin: string;
|
|
285
290
|
export interface TestController {}
|
|
286
291
|
export interface ExecutionContext {
|
|
287
292
|
waitUntil(promise: Promise<any>): void;
|
|
@@ -295,6 +300,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
295
300
|
env: Env,
|
|
296
301
|
ctx: ExecutionContext
|
|
297
302
|
) => Response | Promise<Response>;
|
|
303
|
+
export type ExportedHandlerTailHandler<Env = unknown> = (
|
|
304
|
+
events: TraceItem[],
|
|
305
|
+
env: Env,
|
|
306
|
+
ctx: ExecutionContext
|
|
307
|
+
) => void | Promise<void>;
|
|
298
308
|
export type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
299
309
|
traces: TraceItem[],
|
|
300
310
|
env: Env,
|
|
@@ -321,6 +331,7 @@ export interface ExportedHandler<
|
|
|
321
331
|
CfHostMetadata = unknown
|
|
322
332
|
> {
|
|
323
333
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
334
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
324
335
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
325
336
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
326
337
|
test?: ExportedHandlerTestHandler<Env>;
|
|
@@ -333,6 +344,11 @@ export declare abstract class PromiseRejectionEvent extends Event {
|
|
|
333
344
|
readonly promise: Promise<any>;
|
|
334
345
|
readonly reason: any;
|
|
335
346
|
}
|
|
347
|
+
/** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
|
|
348
|
+
export interface Performance {
|
|
349
|
+
readonly timeOrigin: number;
|
|
350
|
+
now(): number;
|
|
351
|
+
}
|
|
336
352
|
export interface DurableObject {
|
|
337
353
|
fetch(request: Request): Response | Promise<Response>;
|
|
338
354
|
alarm?(): void | Promise<void>;
|
|
@@ -380,6 +396,8 @@ export interface DurableObjectState {
|
|
|
380
396
|
readonly id: DurableObjectId;
|
|
381
397
|
readonly storage: DurableObjectStorage;
|
|
382
398
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
399
|
+
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
400
|
+
getWebSockets(tag?: string): WebSocket[];
|
|
383
401
|
}
|
|
384
402
|
export interface DurableObjectTransaction {
|
|
385
403
|
get<T = unknown>(
|
|
@@ -446,6 +464,7 @@ export interface DurableObjectStorage {
|
|
|
446
464
|
): Promise<void>;
|
|
447
465
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
448
466
|
sync(): Promise<void>;
|
|
467
|
+
transactionSync<T>(closure: () => T): T;
|
|
449
468
|
}
|
|
450
469
|
export interface DurableObjectListOptions {
|
|
451
470
|
start?: string;
|
|
@@ -566,6 +585,7 @@ export declare class AbortController {
|
|
|
566
585
|
export declare abstract class AbortSignal extends EventTarget {
|
|
567
586
|
static abort(reason?: any): AbortSignal;
|
|
568
587
|
static timeout(delay: number): AbortSignal;
|
|
588
|
+
static any(signals: AbortSignal[]): AbortSignal;
|
|
569
589
|
/** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
|
|
570
590
|
readonly aborted: boolean;
|
|
571
591
|
readonly reason: any;
|
|
@@ -1061,6 +1081,7 @@ export interface RequestInit<Cf = CfProperties> {
|
|
|
1061
1081
|
}
|
|
1062
1082
|
export declare abstract class Fetcher {
|
|
1063
1083
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1084
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1064
1085
|
}
|
|
1065
1086
|
export interface FetcherPutOptions {
|
|
1066
1087
|
expiration?: number;
|
|
@@ -1636,7 +1657,8 @@ export interface QueuingStrategyInit {
|
|
|
1636
1657
|
*/
|
|
1637
1658
|
highWaterMark: number;
|
|
1638
1659
|
}
|
|
1639
|
-
export declare abstract class
|
|
1660
|
+
export declare abstract class TailEvent extends ExtendableEvent {
|
|
1661
|
+
readonly events: TraceItem[];
|
|
1640
1662
|
readonly traces: TraceItem[];
|
|
1641
1663
|
}
|
|
1642
1664
|
export interface TraceItem {
|
|
@@ -1836,6 +1858,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1836
1858
|
accept(): void;
|
|
1837
1859
|
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
|
|
1838
1860
|
close(code?: number, reason?: string): void;
|
|
1861
|
+
serializeAttachment(attachment: any): void;
|
|
1862
|
+
deserializeAttachment(): any | null;
|
|
1839
1863
|
static readonly READY_STATE_CONNECTING: number;
|
|
1840
1864
|
static readonly READY_STATE_OPEN: number;
|
|
1841
1865
|
static readonly READY_STATE_CLOSING: number;
|
|
@@ -1855,6 +1879,24 @@ export declare const WebSocketPair: {
|
|
|
1855
1879
|
1: WebSocket;
|
|
1856
1880
|
};
|
|
1857
1881
|
};
|
|
1882
|
+
export interface Socket {
|
|
1883
|
+
get readable(): ReadableStream;
|
|
1884
|
+
get writable(): WritableStream;
|
|
1885
|
+
get closed(): Promise<void>;
|
|
1886
|
+
close(): Promise<void>;
|
|
1887
|
+
startTls(options?: TlsOptions): Socket;
|
|
1888
|
+
}
|
|
1889
|
+
export interface SocketOptions {
|
|
1890
|
+
secureTransport?: string;
|
|
1891
|
+
allowHalfOpen: boolean;
|
|
1892
|
+
}
|
|
1893
|
+
export interface SocketAddress {
|
|
1894
|
+
hostname: string;
|
|
1895
|
+
port: number;
|
|
1896
|
+
}
|
|
1897
|
+
export interface TlsOptions {
|
|
1898
|
+
expectedServerHostname?: string;
|
|
1899
|
+
}
|
|
1858
1900
|
export interface BasicImageTransformations {
|
|
1859
1901
|
/**
|
|
1860
1902
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2980,11 +3022,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2980
3022
|
readonly kid: string;
|
|
2981
3023
|
}
|
|
2982
3024
|
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3025
|
+
export interface DynamicDispatchLimits {
|
|
3026
|
+
/**
|
|
3027
|
+
* Limit CPU time in milliseconds.
|
|
3028
|
+
*/
|
|
3029
|
+
cpuMs?: number;
|
|
3030
|
+
/**
|
|
3031
|
+
* Limit number of subrequests.
|
|
3032
|
+
*/
|
|
3033
|
+
subRequests?: number;
|
|
3034
|
+
}
|
|
3035
|
+
export interface DynamicDispatchOptions {
|
|
3036
|
+
/**
|
|
3037
|
+
* Limit resources of invoked Worker script.
|
|
3038
|
+
*/
|
|
3039
|
+
limits?: DynamicDispatchLimits;
|
|
3040
|
+
/**
|
|
3041
|
+
* Arguments for outbound Worker script, if configured.
|
|
3042
|
+
*/
|
|
3043
|
+
outbound?: {
|
|
3044
|
+
[key: string]: any;
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
2983
3047
|
export interface DispatchNamespace {
|
|
2984
3048
|
/**
|
|
2985
3049
|
* @param name Name of the Worker script.
|
|
3050
|
+
* @param args Arguments to Worker script.
|
|
3051
|
+
* @param options Options for Dynamic Dispatch invocation.
|
|
2986
3052
|
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
2987
3053
|
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2988
3054
|
*/
|
|
2989
|
-
get(
|
|
3055
|
+
get(
|
|
3056
|
+
name: string,
|
|
3057
|
+
args?: {
|
|
3058
|
+
[key: string]: any;
|
|
3059
|
+
},
|
|
3060
|
+
options?: DynamicDispatchOptions
|
|
3061
|
+
): Fetcher;
|
|
2990
3062
|
}
|
package/2022-01-31/index.d.ts
CHANGED
|
@@ -184,11 +184,14 @@ declare interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
184
184
|
crypto: Crypto;
|
|
185
185
|
caches: CacheStorage;
|
|
186
186
|
scheduler: Scheduler;
|
|
187
|
+
performance: Performance;
|
|
188
|
+
readonly origin: string;
|
|
187
189
|
Event: typeof Event;
|
|
188
190
|
ExtendableEvent: typeof ExtendableEvent;
|
|
189
191
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
190
192
|
FetchEvent: typeof FetchEvent;
|
|
191
|
-
|
|
193
|
+
TailEvent: typeof TailEvent;
|
|
194
|
+
TraceEvent: typeof TailEvent;
|
|
192
195
|
ScheduledEvent: typeof ScheduledEvent;
|
|
193
196
|
MessageEvent: typeof MessageEvent;
|
|
194
197
|
CloseEvent: typeof CloseEvent;
|
|
@@ -280,6 +283,8 @@ declare const self: ServiceWorkerGlobalScope;
|
|
|
280
283
|
declare const crypto: Crypto;
|
|
281
284
|
declare const caches: CacheStorage;
|
|
282
285
|
declare const scheduler: Scheduler;
|
|
286
|
+
declare const performance: Performance;
|
|
287
|
+
declare const origin: string;
|
|
283
288
|
declare interface TestController {}
|
|
284
289
|
declare interface ExecutionContext {
|
|
285
290
|
waitUntil(promise: Promise<any>): void;
|
|
@@ -293,6 +298,11 @@ declare type ExportedHandlerFetchHandler<
|
|
|
293
298
|
env: Env,
|
|
294
299
|
ctx: ExecutionContext
|
|
295
300
|
) => Response | Promise<Response>;
|
|
301
|
+
declare type ExportedHandlerTailHandler<Env = unknown> = (
|
|
302
|
+
events: TraceItem[],
|
|
303
|
+
env: Env,
|
|
304
|
+
ctx: ExecutionContext
|
|
305
|
+
) => void | Promise<void>;
|
|
296
306
|
declare type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
297
307
|
traces: TraceItem[],
|
|
298
308
|
env: Env,
|
|
@@ -319,6 +329,7 @@ declare interface ExportedHandler<
|
|
|
319
329
|
CfHostMetadata = unknown
|
|
320
330
|
> {
|
|
321
331
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
332
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
322
333
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
323
334
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
324
335
|
test?: ExportedHandlerTestHandler<Env>;
|
|
@@ -331,6 +342,11 @@ declare abstract class PromiseRejectionEvent extends Event {
|
|
|
331
342
|
readonly promise: Promise<any>;
|
|
332
343
|
readonly reason: any;
|
|
333
344
|
}
|
|
345
|
+
/** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
|
|
346
|
+
declare interface Performance {
|
|
347
|
+
readonly timeOrigin: number;
|
|
348
|
+
now(): number;
|
|
349
|
+
}
|
|
334
350
|
declare interface DurableObject {
|
|
335
351
|
fetch(request: Request): Response | Promise<Response>;
|
|
336
352
|
alarm?(): void | Promise<void>;
|
|
@@ -378,6 +394,8 @@ declare interface DurableObjectState {
|
|
|
378
394
|
readonly id: DurableObjectId;
|
|
379
395
|
readonly storage: DurableObjectStorage;
|
|
380
396
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
397
|
+
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
398
|
+
getWebSockets(tag?: string): WebSocket[];
|
|
381
399
|
}
|
|
382
400
|
declare interface DurableObjectTransaction {
|
|
383
401
|
get<T = unknown>(
|
|
@@ -444,6 +462,7 @@ declare interface DurableObjectStorage {
|
|
|
444
462
|
): Promise<void>;
|
|
445
463
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
446
464
|
sync(): Promise<void>;
|
|
465
|
+
transactionSync<T>(closure: () => T): T;
|
|
447
466
|
}
|
|
448
467
|
declare interface DurableObjectListOptions {
|
|
449
468
|
start?: string;
|
|
@@ -553,6 +572,7 @@ declare class AbortController {
|
|
|
553
572
|
declare abstract class AbortSignal extends EventTarget {
|
|
554
573
|
static abort(reason?: any): AbortSignal;
|
|
555
574
|
static timeout(delay: number): AbortSignal;
|
|
575
|
+
static any(signals: AbortSignal[]): AbortSignal;
|
|
556
576
|
get aborted(): boolean;
|
|
557
577
|
get reason(): any;
|
|
558
578
|
throwIfAborted(): void;
|
|
@@ -1039,6 +1059,7 @@ declare interface RequestInit<Cf = CfProperties> {
|
|
|
1039
1059
|
}
|
|
1040
1060
|
declare abstract class Fetcher {
|
|
1041
1061
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1062
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1042
1063
|
}
|
|
1043
1064
|
declare interface FetcherPutOptions {
|
|
1044
1065
|
expiration?: number;
|
|
@@ -1611,7 +1632,8 @@ declare interface QueuingStrategyInit {
|
|
|
1611
1632
|
*/
|
|
1612
1633
|
highWaterMark: number;
|
|
1613
1634
|
}
|
|
1614
|
-
declare abstract class
|
|
1635
|
+
declare abstract class TailEvent extends ExtendableEvent {
|
|
1636
|
+
readonly events: TraceItem[];
|
|
1615
1637
|
readonly traces: TraceItem[];
|
|
1616
1638
|
}
|
|
1617
1639
|
declare interface TraceItem {
|
|
@@ -1821,6 +1843,8 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1821
1843
|
accept(): void;
|
|
1822
1844
|
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
|
|
1823
1845
|
close(code?: number, reason?: string): void;
|
|
1846
|
+
serializeAttachment(attachment: any): void;
|
|
1847
|
+
deserializeAttachment(): any | null;
|
|
1824
1848
|
static readonly READY_STATE_CONNECTING: number;
|
|
1825
1849
|
static readonly READY_STATE_OPEN: number;
|
|
1826
1850
|
static readonly READY_STATE_CLOSING: number;
|
|
@@ -1836,6 +1860,24 @@ declare const WebSocketPair: {
|
|
|
1836
1860
|
1: WebSocket;
|
|
1837
1861
|
};
|
|
1838
1862
|
};
|
|
1863
|
+
declare interface Socket {
|
|
1864
|
+
get readable(): ReadableStream;
|
|
1865
|
+
get writable(): WritableStream;
|
|
1866
|
+
get closed(): Promise<void>;
|
|
1867
|
+
close(): Promise<void>;
|
|
1868
|
+
startTls(options?: TlsOptions): Socket;
|
|
1869
|
+
}
|
|
1870
|
+
declare interface SocketOptions {
|
|
1871
|
+
secureTransport?: string;
|
|
1872
|
+
allowHalfOpen: boolean;
|
|
1873
|
+
}
|
|
1874
|
+
declare interface SocketAddress {
|
|
1875
|
+
hostname: string;
|
|
1876
|
+
port: number;
|
|
1877
|
+
}
|
|
1878
|
+
declare interface TlsOptions {
|
|
1879
|
+
expectedServerHostname?: string;
|
|
1880
|
+
}
|
|
1839
1881
|
declare interface BasicImageTransformations {
|
|
1840
1882
|
/**
|
|
1841
1883
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2970,12 +3012,49 @@ declare interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2970
3012
|
// Key Identifier of the JWK
|
|
2971
3013
|
readonly kid: string;
|
|
2972
3014
|
}
|
|
3015
|
+
declare module "cloudflare:sockets" {
|
|
3016
|
+
function _connect(
|
|
3017
|
+
address: string | SocketAddress,
|
|
3018
|
+
options?: SocketOptions
|
|
3019
|
+
): Socket;
|
|
3020
|
+
export { _connect as connect };
|
|
3021
|
+
}
|
|
2973
3022
|
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3023
|
+
declare interface DynamicDispatchLimits {
|
|
3024
|
+
/**
|
|
3025
|
+
* Limit CPU time in milliseconds.
|
|
3026
|
+
*/
|
|
3027
|
+
cpuMs?: number;
|
|
3028
|
+
/**
|
|
3029
|
+
* Limit number of subrequests.
|
|
3030
|
+
*/
|
|
3031
|
+
subRequests?: number;
|
|
3032
|
+
}
|
|
3033
|
+
declare interface DynamicDispatchOptions {
|
|
3034
|
+
/**
|
|
3035
|
+
* Limit resources of invoked Worker script.
|
|
3036
|
+
*/
|
|
3037
|
+
limits?: DynamicDispatchLimits;
|
|
3038
|
+
/**
|
|
3039
|
+
* Arguments for outbound Worker script, if configured.
|
|
3040
|
+
*/
|
|
3041
|
+
outbound?: {
|
|
3042
|
+
[key: string]: any;
|
|
3043
|
+
};
|
|
3044
|
+
}
|
|
2974
3045
|
declare interface DispatchNamespace {
|
|
2975
3046
|
/**
|
|
2976
3047
|
* @param name Name of the Worker script.
|
|
3048
|
+
* @param args Arguments to Worker script.
|
|
3049
|
+
* @param options Options for Dynamic Dispatch invocation.
|
|
2977
3050
|
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
2978
3051
|
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2979
3052
|
*/
|
|
2980
|
-
get(
|
|
3053
|
+
get(
|
|
3054
|
+
name: string,
|
|
3055
|
+
args?: {
|
|
3056
|
+
[key: string]: any;
|
|
3057
|
+
},
|
|
3058
|
+
options?: DynamicDispatchOptions
|
|
3059
|
+
): Fetcher;
|
|
2981
3060
|
}
|
package/2022-01-31/index.ts
CHANGED
|
@@ -184,11 +184,14 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
|
|
|
184
184
|
crypto: Crypto;
|
|
185
185
|
caches: CacheStorage;
|
|
186
186
|
scheduler: Scheduler;
|
|
187
|
+
performance: Performance;
|
|
188
|
+
readonly origin: string;
|
|
187
189
|
Event: typeof Event;
|
|
188
190
|
ExtendableEvent: typeof ExtendableEvent;
|
|
189
191
|
PromiseRejectionEvent: typeof PromiseRejectionEvent;
|
|
190
192
|
FetchEvent: typeof FetchEvent;
|
|
191
|
-
|
|
193
|
+
TailEvent: typeof TailEvent;
|
|
194
|
+
TraceEvent: typeof TailEvent;
|
|
192
195
|
ScheduledEvent: typeof ScheduledEvent;
|
|
193
196
|
MessageEvent: typeof MessageEvent;
|
|
194
197
|
CloseEvent: typeof CloseEvent;
|
|
@@ -282,6 +285,8 @@ export declare const self: ServiceWorkerGlobalScope;
|
|
|
282
285
|
export declare const crypto: Crypto;
|
|
283
286
|
export declare const caches: CacheStorage;
|
|
284
287
|
export declare const scheduler: Scheduler;
|
|
288
|
+
export declare const performance: Performance;
|
|
289
|
+
export declare const origin: string;
|
|
285
290
|
export interface TestController {}
|
|
286
291
|
export interface ExecutionContext {
|
|
287
292
|
waitUntil(promise: Promise<any>): void;
|
|
@@ -295,6 +300,11 @@ export type ExportedHandlerFetchHandler<
|
|
|
295
300
|
env: Env,
|
|
296
301
|
ctx: ExecutionContext
|
|
297
302
|
) => Response | Promise<Response>;
|
|
303
|
+
export type ExportedHandlerTailHandler<Env = unknown> = (
|
|
304
|
+
events: TraceItem[],
|
|
305
|
+
env: Env,
|
|
306
|
+
ctx: ExecutionContext
|
|
307
|
+
) => void | Promise<void>;
|
|
298
308
|
export type ExportedHandlerTraceHandler<Env = unknown> = (
|
|
299
309
|
traces: TraceItem[],
|
|
300
310
|
env: Env,
|
|
@@ -321,6 +331,7 @@ export interface ExportedHandler<
|
|
|
321
331
|
CfHostMetadata = unknown
|
|
322
332
|
> {
|
|
323
333
|
fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
|
|
334
|
+
tail?: ExportedHandlerTailHandler<Env>;
|
|
324
335
|
trace?: ExportedHandlerTraceHandler<Env>;
|
|
325
336
|
scheduled?: ExportedHandlerScheduledHandler<Env>;
|
|
326
337
|
test?: ExportedHandlerTestHandler<Env>;
|
|
@@ -333,6 +344,11 @@ export declare abstract class PromiseRejectionEvent extends Event {
|
|
|
333
344
|
readonly promise: Promise<any>;
|
|
334
345
|
readonly reason: any;
|
|
335
346
|
}
|
|
347
|
+
/** Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API. */
|
|
348
|
+
export interface Performance {
|
|
349
|
+
readonly timeOrigin: number;
|
|
350
|
+
now(): number;
|
|
351
|
+
}
|
|
336
352
|
export interface DurableObject {
|
|
337
353
|
fetch(request: Request): Response | Promise<Response>;
|
|
338
354
|
alarm?(): void | Promise<void>;
|
|
@@ -380,6 +396,8 @@ export interface DurableObjectState {
|
|
|
380
396
|
readonly id: DurableObjectId;
|
|
381
397
|
readonly storage: DurableObjectStorage;
|
|
382
398
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
399
|
+
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
400
|
+
getWebSockets(tag?: string): WebSocket[];
|
|
383
401
|
}
|
|
384
402
|
export interface DurableObjectTransaction {
|
|
385
403
|
get<T = unknown>(
|
|
@@ -446,6 +464,7 @@ export interface DurableObjectStorage {
|
|
|
446
464
|
): Promise<void>;
|
|
447
465
|
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
448
466
|
sync(): Promise<void>;
|
|
467
|
+
transactionSync<T>(closure: () => T): T;
|
|
449
468
|
}
|
|
450
469
|
export interface DurableObjectListOptions {
|
|
451
470
|
start?: string;
|
|
@@ -555,6 +574,7 @@ export declare class AbortController {
|
|
|
555
574
|
export declare abstract class AbortSignal extends EventTarget {
|
|
556
575
|
static abort(reason?: any): AbortSignal;
|
|
557
576
|
static timeout(delay: number): AbortSignal;
|
|
577
|
+
static any(signals: AbortSignal[]): AbortSignal;
|
|
558
578
|
get aborted(): boolean;
|
|
559
579
|
get reason(): any;
|
|
560
580
|
throwIfAborted(): void;
|
|
@@ -1041,6 +1061,7 @@ export interface RequestInit<Cf = CfProperties> {
|
|
|
1041
1061
|
}
|
|
1042
1062
|
export declare abstract class Fetcher {
|
|
1043
1063
|
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
1064
|
+
connect(address: SocketAddress | string, options?: SocketOptions): Socket;
|
|
1044
1065
|
}
|
|
1045
1066
|
export interface FetcherPutOptions {
|
|
1046
1067
|
expiration?: number;
|
|
@@ -1616,7 +1637,8 @@ export interface QueuingStrategyInit {
|
|
|
1616
1637
|
*/
|
|
1617
1638
|
highWaterMark: number;
|
|
1618
1639
|
}
|
|
1619
|
-
export declare abstract class
|
|
1640
|
+
export declare abstract class TailEvent extends ExtendableEvent {
|
|
1641
|
+
readonly events: TraceItem[];
|
|
1620
1642
|
readonly traces: TraceItem[];
|
|
1621
1643
|
}
|
|
1622
1644
|
export interface TraceItem {
|
|
@@ -1826,6 +1848,8 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
|
1826
1848
|
accept(): void;
|
|
1827
1849
|
send(message: (ArrayBuffer | ArrayBufferView) | string): void;
|
|
1828
1850
|
close(code?: number, reason?: string): void;
|
|
1851
|
+
serializeAttachment(attachment: any): void;
|
|
1852
|
+
deserializeAttachment(): any | null;
|
|
1829
1853
|
static readonly READY_STATE_CONNECTING: number;
|
|
1830
1854
|
static readonly READY_STATE_OPEN: number;
|
|
1831
1855
|
static readonly READY_STATE_CLOSING: number;
|
|
@@ -1841,6 +1865,24 @@ export declare const WebSocketPair: {
|
|
|
1841
1865
|
1: WebSocket;
|
|
1842
1866
|
};
|
|
1843
1867
|
};
|
|
1868
|
+
export interface Socket {
|
|
1869
|
+
get readable(): ReadableStream;
|
|
1870
|
+
get writable(): WritableStream;
|
|
1871
|
+
get closed(): Promise<void>;
|
|
1872
|
+
close(): Promise<void>;
|
|
1873
|
+
startTls(options?: TlsOptions): Socket;
|
|
1874
|
+
}
|
|
1875
|
+
export interface SocketOptions {
|
|
1876
|
+
secureTransport?: string;
|
|
1877
|
+
allowHalfOpen: boolean;
|
|
1878
|
+
}
|
|
1879
|
+
export interface SocketAddress {
|
|
1880
|
+
hostname: string;
|
|
1881
|
+
port: number;
|
|
1882
|
+
}
|
|
1883
|
+
export interface TlsOptions {
|
|
1884
|
+
expectedServerHostname?: string;
|
|
1885
|
+
}
|
|
1844
1886
|
export interface BasicImageTransformations {
|
|
1845
1887
|
/**
|
|
1846
1888
|
* Maximum width in image pixels. The value must be an integer.
|
|
@@ -2966,11 +3008,41 @@ export interface JsonWebKeyWithKid extends JsonWebKey {
|
|
|
2966
3008
|
readonly kid: string;
|
|
2967
3009
|
}
|
|
2968
3010
|
// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
|
|
3011
|
+
export interface DynamicDispatchLimits {
|
|
3012
|
+
/**
|
|
3013
|
+
* Limit CPU time in milliseconds.
|
|
3014
|
+
*/
|
|
3015
|
+
cpuMs?: number;
|
|
3016
|
+
/**
|
|
3017
|
+
* Limit number of subrequests.
|
|
3018
|
+
*/
|
|
3019
|
+
subRequests?: number;
|
|
3020
|
+
}
|
|
3021
|
+
export interface DynamicDispatchOptions {
|
|
3022
|
+
/**
|
|
3023
|
+
* Limit resources of invoked Worker script.
|
|
3024
|
+
*/
|
|
3025
|
+
limits?: DynamicDispatchLimits;
|
|
3026
|
+
/**
|
|
3027
|
+
* Arguments for outbound Worker script, if configured.
|
|
3028
|
+
*/
|
|
3029
|
+
outbound?: {
|
|
3030
|
+
[key: string]: any;
|
|
3031
|
+
};
|
|
3032
|
+
}
|
|
2969
3033
|
export interface DispatchNamespace {
|
|
2970
3034
|
/**
|
|
2971
3035
|
* @param name Name of the Worker script.
|
|
3036
|
+
* @param args Arguments to Worker script.
|
|
3037
|
+
* @param options Options for Dynamic Dispatch invocation.
|
|
2972
3038
|
* @returns A Fetcher object that allows you to send requests to the Worker script.
|
|
2973
3039
|
* @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
|
|
2974
3040
|
*/
|
|
2975
|
-
get(
|
|
3041
|
+
get(
|
|
3042
|
+
name: string,
|
|
3043
|
+
args?: {
|
|
3044
|
+
[key: string]: any;
|
|
3045
|
+
},
|
|
3046
|
+
options?: DynamicDispatchOptions
|
|
3047
|
+
): Fetcher;
|
|
2976
3048
|
}
|