@cloudflare/workers-types 3.7.0 → 3.9.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/index.d.ts +86 -32
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ declare type BodyInitializer = BodyInit;
|
|
|
131
131
|
declare class ByteLengthQueuingStrategy {
|
|
132
132
|
constructor(init: QueuingStrategyInit);
|
|
133
133
|
readonly highWaterMark: number;
|
|
134
|
-
size(
|
|
134
|
+
size(chunk?: any): number;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
declare abstract class Cache {
|
|
@@ -194,7 +194,7 @@ interface Comment {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
declare class CompressionStream extends TransformStream {
|
|
197
|
-
constructor(format:
|
|
197
|
+
constructor(format: "gzip" | "deflate");
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
interface Console {
|
|
@@ -214,7 +214,7 @@ interface ContentOptions {
|
|
|
214
214
|
declare class CountQueuingStrategy {
|
|
215
215
|
constructor(init: QueuingStrategyInit);
|
|
216
216
|
readonly highWaterMark: number;
|
|
217
|
-
size(
|
|
217
|
+
size(chunk?: any): number;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
declare abstract class Crypto {
|
|
@@ -323,7 +323,7 @@ declare class DOMException extends Error {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
declare class DecompressionStream extends TransformStream {
|
|
326
|
-
constructor(format:
|
|
326
|
+
constructor(format: "gzip" | "deflate");
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
declare class DigestStream extends WritableStream {
|
|
@@ -345,6 +345,10 @@ interface DurableObject {
|
|
|
345
345
|
fetch(request: Request): Promise<Response>;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
interface DurableObjectGetAlarmOptions {
|
|
349
|
+
allowConcurrency?: boolean;
|
|
350
|
+
}
|
|
351
|
+
|
|
348
352
|
interface DurableObjectGetOptions {
|
|
349
353
|
allowConcurrency?: boolean;
|
|
350
354
|
noCache?: boolean;
|
|
@@ -385,6 +389,11 @@ interface DurableObjectPutOptions {
|
|
|
385
389
|
noCache?: boolean;
|
|
386
390
|
}
|
|
387
391
|
|
|
392
|
+
interface DurableObjectSetAlarmOptions {
|
|
393
|
+
allowConcurrency?: boolean;
|
|
394
|
+
allowUnconfirmed?: boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
388
397
|
interface DurableObjectState {
|
|
389
398
|
waitUntil(promise: Promise<any>): void;
|
|
390
399
|
readonly id: DurableObjectId | string;
|
|
@@ -419,17 +428,12 @@ interface DurableObjectStorage {
|
|
|
419
428
|
transaction<T>(
|
|
420
429
|
closure: (txn: DurableObjectTransaction) => Promise<T>
|
|
421
430
|
): Promise<T>;
|
|
422
|
-
getAlarm(
|
|
423
|
-
options?: DurableObjectStorageOperationsGetAlarmOptions
|
|
424
|
-
): Promise<Date | null>;
|
|
431
|
+
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
|
|
425
432
|
setAlarm(
|
|
426
|
-
|
|
427
|
-
options?:
|
|
433
|
+
scheduledTime: number | Date,
|
|
434
|
+
options?: DurableObjectSetAlarmOptions
|
|
428
435
|
): Promise<void>;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
interface DurableObjectStorageOperationsGetAlarmOptions {
|
|
432
|
-
allowConcurrency?: boolean;
|
|
436
|
+
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
433
437
|
}
|
|
434
438
|
|
|
435
439
|
/**
|
|
@@ -451,11 +455,6 @@ declare type DurableObjectStorageOperationsListOptions =
|
|
|
451
455
|
*/
|
|
452
456
|
declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
|
|
453
457
|
|
|
454
|
-
interface DurableObjectStorageOperationsSetAlarmOptions {
|
|
455
|
-
allowConcurrency?: boolean;
|
|
456
|
-
allowUnconfirmed?: boolean;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
458
|
interface DurableObjectStub extends Fetcher {
|
|
460
459
|
readonly id: DurableObjectId;
|
|
461
460
|
readonly name?: string;
|
|
@@ -482,13 +481,12 @@ interface DurableObjectTransaction {
|
|
|
482
481
|
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
|
|
483
482
|
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
|
|
484
483
|
rollback(): void;
|
|
485
|
-
getAlarm(
|
|
486
|
-
options?: DurableObjectStorageOperationsGetAlarmOptions
|
|
487
|
-
): Promise<Date | null>;
|
|
484
|
+
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
|
|
488
485
|
setAlarm(
|
|
489
|
-
|
|
490
|
-
options?:
|
|
486
|
+
scheduledTime: number | Date,
|
|
487
|
+
options?: DurableObjectSetAlarmOptions
|
|
491
488
|
): Promise<void>;
|
|
489
|
+
deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
|
|
492
490
|
}
|
|
493
491
|
|
|
494
492
|
interface Element {
|
|
@@ -618,11 +616,15 @@ declare type ExportedHandlerScheduledHandler<Env = unknown> = (
|
|
|
618
616
|
ctx: ExecutionContext
|
|
619
617
|
) => void | Promise<void>;
|
|
620
618
|
|
|
619
|
+
declare class ExtendableEvent extends Event {
|
|
620
|
+
constructor(type: string, init?: EventInit);
|
|
621
|
+
waitUntil(promise: Promise<any>): void;
|
|
622
|
+
}
|
|
623
|
+
|
|
621
624
|
declare abstract class FetchEvent extends Event {
|
|
622
625
|
readonly request: Request;
|
|
623
626
|
respondWith(promise: Response | Promise<Response>): void;
|
|
624
627
|
passThroughOnException(): void;
|
|
625
|
-
waitUntil(promise: Promise<any>): void;
|
|
626
628
|
}
|
|
627
629
|
|
|
628
630
|
declare abstract class Fetcher {
|
|
@@ -1003,7 +1005,13 @@ interface R2Bucket {
|
|
|
1003
1005
|
get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
|
|
1004
1006
|
put(
|
|
1005
1007
|
key: string,
|
|
1006
|
-
value:
|
|
1008
|
+
value:
|
|
1009
|
+
| ReadableStream
|
|
1010
|
+
| ArrayBuffer
|
|
1011
|
+
| ArrayBufferView
|
|
1012
|
+
| string
|
|
1013
|
+
| null
|
|
1014
|
+
| Blob,
|
|
1007
1015
|
options?: R2PutOptions
|
|
1008
1016
|
): Promise<R2Object>;
|
|
1009
1017
|
delete(key: string): Promise<void>;
|
|
@@ -1077,7 +1085,7 @@ interface R2ListOptions {
|
|
|
1077
1085
|
* }
|
|
1078
1086
|
* ```
|
|
1079
1087
|
*/
|
|
1080
|
-
include
|
|
1088
|
+
include?: ("httpMetadata" | "customMetadata")[];
|
|
1081
1089
|
}
|
|
1082
1090
|
|
|
1083
1091
|
/**
|
|
@@ -1135,12 +1143,15 @@ declare abstract class ReadableByteStreamController {
|
|
|
1135
1143
|
readonly byobRequest: ReadableStreamBYOBRequest | null;
|
|
1136
1144
|
readonly desiredSize: number | null;
|
|
1137
1145
|
close(): void;
|
|
1138
|
-
enqueue(chunk: ArrayBufferView): void;
|
|
1146
|
+
enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
|
|
1139
1147
|
error(reason: any): void;
|
|
1140
1148
|
}
|
|
1141
1149
|
|
|
1142
1150
|
declare class ReadableStream {
|
|
1143
|
-
constructor(
|
|
1151
|
+
constructor(
|
|
1152
|
+
underlyingSource?: UnderlyingSource,
|
|
1153
|
+
queuingStrategy?: StreamQueuingStrategy
|
|
1154
|
+
);
|
|
1144
1155
|
readonly locked: boolean;
|
|
1145
1156
|
cancel(reason?: any): Promise<void>;
|
|
1146
1157
|
getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
|
|
@@ -1174,7 +1185,7 @@ declare class ReadableStreamBYOBReader {
|
|
|
1174
1185
|
declare abstract class ReadableStreamBYOBRequest {
|
|
1175
1186
|
readonly view: Uint8Array | null;
|
|
1176
1187
|
respond(bytesWritten: number): void;
|
|
1177
|
-
respondWithNewView(view: ArrayBufferView): void;
|
|
1188
|
+
respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
|
|
1178
1189
|
readonly atLeast: number | null;
|
|
1179
1190
|
}
|
|
1180
1191
|
|
|
@@ -1474,11 +1485,10 @@ interface ScheduledController {
|
|
|
1474
1485
|
noRetry(): void;
|
|
1475
1486
|
}
|
|
1476
1487
|
|
|
1477
|
-
declare abstract class ScheduledEvent extends
|
|
1488
|
+
declare abstract class ScheduledEvent extends ExtendableEvent {
|
|
1478
1489
|
readonly scheduledTime: number;
|
|
1479
1490
|
readonly cron: string;
|
|
1480
1491
|
noRetry(): void;
|
|
1481
|
-
waitUntil(promise: Promise<any>): void;
|
|
1482
1492
|
}
|
|
1483
1493
|
|
|
1484
1494
|
interface Scheduler {
|
|
@@ -1814,6 +1824,26 @@ declare type URLSearchParamsInit =
|
|
|
1814
1824
|
*/
|
|
1815
1825
|
declare type URLSearchParamsInitializer = URLSearchParamsInit;
|
|
1816
1826
|
|
|
1827
|
+
interface UnderlyingSink {
|
|
1828
|
+
type?: string;
|
|
1829
|
+
start?(controller: WritableStreamDefaultController): any;
|
|
1830
|
+
write?(chunk: any, controller: WritableStreamDefaultController): any;
|
|
1831
|
+
abort?(reason: any): any;
|
|
1832
|
+
close?(): any;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
interface UnderlyingSource {
|
|
1836
|
+
type?: string;
|
|
1837
|
+
autoAllocateChunkSize?: number;
|
|
1838
|
+
start?(
|
|
1839
|
+
controller: ReadableStreamDefaultController | ReadableByteStreamController
|
|
1840
|
+
): any;
|
|
1841
|
+
pull?(
|
|
1842
|
+
controller: ReadableStreamDefaultController | ReadableByteStreamController
|
|
1843
|
+
): any;
|
|
1844
|
+
cancel?(reason?: any): any;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1817
1847
|
declare class WebSocket extends EventTarget<WebSocketEventMap> {
|
|
1818
1848
|
constructor(url: string, protocols?: string[] | string);
|
|
1819
1849
|
accept(): void;
|
|
@@ -1848,7 +1878,10 @@ declare type WorkerGlobalScopeEventMap = {
|
|
|
1848
1878
|
};
|
|
1849
1879
|
|
|
1850
1880
|
declare class WritableStream {
|
|
1851
|
-
constructor(
|
|
1881
|
+
constructor(
|
|
1882
|
+
underlyingSink?: UnderlyingSink,
|
|
1883
|
+
queuingStrategy?: StreamQueuingStrategy
|
|
1884
|
+
);
|
|
1852
1885
|
readonly locked: boolean;
|
|
1853
1886
|
abort(reason: any): Promise<void>;
|
|
1854
1887
|
close(): Promise<void>;
|
|
@@ -1947,6 +1980,7 @@ type Params<P extends string = any> = Record<P, string | string[]>;
|
|
|
1947
1980
|
|
|
1948
1981
|
type EventContext<Env, P extends string, Data> = {
|
|
1949
1982
|
request: Request;
|
|
1983
|
+
functionPath: string;
|
|
1950
1984
|
waitUntil: (promise: Promise<any>) => void;
|
|
1951
1985
|
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
|
|
1952
1986
|
env: Env & { ASSETS: { fetch: typeof fetch } };
|
|
@@ -1959,3 +1993,23 @@ declare type PagesFunction<
|
|
|
1959
1993
|
Params extends string = any,
|
|
1960
1994
|
Data extends Record<string, unknown> = Record<string, unknown>
|
|
1961
1995
|
> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
|
|
1996
|
+
|
|
1997
|
+
type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
|
|
1998
|
+
request: Request;
|
|
1999
|
+
functionPath: string;
|
|
2000
|
+
waitUntil: (promise: Promise<any>) => void;
|
|
2001
|
+
next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
|
|
2002
|
+
env: Env & { ASSETS: { fetch: typeof fetch } };
|
|
2003
|
+
params: Params<P>;
|
|
2004
|
+
data: Data;
|
|
2005
|
+
pluginArgs: PluginArgs;
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
declare type PagesPluginFunction<
|
|
2009
|
+
Env = unknown,
|
|
2010
|
+
Params extends string = any,
|
|
2011
|
+
Data extends Record<string, unknown> = Record<string, unknown>,
|
|
2012
|
+
PluginArgs = unknown
|
|
2013
|
+
> = (
|
|
2014
|
+
context: EventPluginContext<Env, Params, Data, PluginArgs>
|
|
2015
|
+
) => Response | Promise<Response>;
|