@@ -128,6 +128,12 @@ declare type BodyInit =
128
128
*/
129
129
declare type BodyInitializer = BodyInit ;
130
130
131
+ declare class ByteLengthQueuingStrategy {
132
+ constructor ( init : QueuingStrategyInit ) ;
133
+ readonly highWaterMark : number ;
134
+ size ( arg1 ?: any ) : number | undefined ;
135
+ }
136
+
131
137
declare abstract class Cache {
132
138
delete (
133
139
request : Request | string ,
@@ -187,6 +193,10 @@ interface Comment {
187
193
remove ( ) : Comment ;
188
194
}
189
195
196
+ declare class CompressionStream extends TransformStream {
197
+ constructor ( format : string ) ;
198
+ }
199
+
190
200
interface Console {
191
201
debug ( ...data : any [ ] ) : void ;
192
202
error ( ...data : any [ ] ) : void ;
@@ -201,6 +211,12 @@ interface ContentOptions {
201
211
html ?: boolean ;
202
212
}
203
213
214
+ declare class CountQueuingStrategy {
215
+ constructor ( init : QueuingStrategyInit ) ;
216
+ readonly highWaterMark : number ;
217
+ size ( arg1 ?: any ) : number | undefined ;
218
+ }
219
+
204
220
declare abstract class Crypto {
205
221
readonly subtle : SubtleCrypto ;
206
222
getRandomValues <
@@ -306,6 +322,10 @@ declare class DOMException extends Error {
306
322
static readonly DATA_CLONE_ERR : number ;
307
323
}
308
324
325
+ declare class DecompressionStream extends TransformStream {
326
+ constructor ( format : string ) ;
327
+ }
328
+
309
329
declare class DigestStream extends WritableStream {
310
330
constructor ( algorithm : string | SubtleCryptoHashAlgorithm ) ;
311
331
readonly digest : Promise < ArrayBuffer > ;
@@ -325,6 +345,10 @@ interface DurableObject {
325
345
fetch ( request : Request ) : Promise < Response > ;
326
346
}
327
347
348
+ interface DurableObjectGetAlarmOptions {
349
+ allowConcurrency ?: boolean ;
350
+ }
351
+
328
352
interface DurableObjectGetOptions {
329
353
allowConcurrency ?: boolean ;
330
354
noCache ?: boolean ;
@@ -365,6 +389,11 @@ interface DurableObjectPutOptions {
365
389
noCache ?: boolean ;
366
390
}
367
391
392
+ interface DurableObjectSetAlarmOptions {
393
+ allowConcurrency ?: boolean ;
394
+ allowUnconfirmed ?: boolean ;
395
+ }
396
+
368
397
interface DurableObjectState {
369
398
waitUntil ( promise : Promise < any > ) : void ;
370
399
readonly id : DurableObjectId | string ;
@@ -399,24 +428,26 @@ interface DurableObjectStorage {
399
428
transaction < T > (
400
429
closure : ( txn : DurableObjectTransaction ) => Promise < T >
401
430
) : Promise < T > ;
431
+ getAlarm ( options ?: DurableObjectGetAlarmOptions ) : Promise < Date | null > ;
432
+ setAlarm ( arg2 : Date , options ?: DurableObjectSetAlarmOptions ) : Promise < void > ;
402
433
}
403
434
404
435
/**
405
436
*
406
- * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
437
+ * @deprecated Don't use. Introduced incidentally in workers-types 3.x. Scheduled for removal.
407
438
*/
408
439
declare type DurableObjectStorageOperationsGetOptions = DurableObjectGetOptions ;
409
440
410
441
/**
411
442
*
412
- * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
443
+ * @deprecated Don't use. Introduced incidentally in workers-types 3.x. Scheduled for removal.
413
444
*/
414
445
declare type DurableObjectStorageOperationsListOptions =
415
446
DurableObjectListOptions ;
416
447
417
448
/**
418
449
*
419
- * @deprecated Don't use. Introduced incidentally in 3.x. Scheduled for removal.
450
+ * @deprecated Don't use. Introduced incidentally in workers-types 3.x. Scheduled for removal.
420
451
*/
421
452
declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions ;
422
453
@@ -446,6 +477,8 @@ interface DurableObjectTransaction {
446
477
delete ( key : string , options ?: DurableObjectPutOptions ) : Promise < boolean > ;
447
478
delete ( keys : string [ ] , options ?: DurableObjectPutOptions ) : Promise < number > ;
448
479
rollback ( ) : void ;
480
+ getAlarm ( options ?: DurableObjectGetAlarmOptions ) : Promise < Date | null > ;
481
+ setAlarm ( arg2 : Date , options ?: DurableObjectSetAlarmOptions ) : Promise < void > ;
449
482
}
450
483
451
484
interface Element {
@@ -601,7 +634,7 @@ interface FileOptions {
601
634
}
602
635
603
636
declare class FixedLengthStream extends TransformStream {
604
- constructor ( expectedLength : number ) ;
637
+ constructor ( expectedLength : number | bigint ) ;
605
638
}
606
639
607
640
declare class FormData {
@@ -681,6 +714,10 @@ declare type HeadersInit =
681
714
*/
682
715
declare type HeadersInitializer = HeadersInit ;
683
716
717
+ declare class IdentityTransformStream extends TransformStream {
718
+ constructor ( ) ;
719
+ }
720
+
684
721
/**
685
722
* In addition to the properties on the standard Request object,
686
723
* the cf object contains extra information about the request provided
@@ -944,6 +981,141 @@ declare abstract class PromiseRejectionEvent extends Event {
944
981
readonly reason : any ;
945
982
}
946
983
984
+ interface QueuingStrategyInit {
985
+ highWaterMark : number ;
986
+ }
987
+
988
+ /**
989
+ * An instance of the R2 bucket binding.
990
+ */
991
+ interface R2Bucket {
992
+ head ( key : string , options ?: R2HeadOptions ) : Promise < R2Object | null > ;
993
+ get ( key : string , options ?: R2GetOptions ) : Promise < R2ObjectBody | null > ;
994
+ put (
995
+ key : string ,
996
+ value : ReadableStream | ArrayBuffer | ArrayBufferView | string | null ,
997
+ options ?: R2PutOptions
998
+ ) : Promise < R2Object > ;
999
+ delete ( key : string ) : Promise < void > ;
1000
+ list ( options ?: R2ListOptions ) : Promise < R2Objects > ;
1001
+ }
1002
+
1003
+ /**
1004
+ * Perform the operation conditionally based on meeting the defined criteria.
1005
+ */
1006
+ interface R2Conditional {
1007
+ etagMatches ?: string ;
1008
+ etagDoesNotMatch ?: string ;
1009
+ uploadedBefore ?: Date ;
1010
+ uploadedAfter ?: Date ;
1011
+ }
1012
+
1013
+ interface R2Error {
1014
+ readonly stack : string ;
1015
+ }
1016
+
1017
+ /**
1018
+ * Options for retrieving the object metadata nad payload.
1019
+ */
1020
+ interface R2GetOptions {
1021
+ onlyIf ?: R2Conditional | Headers ;
1022
+ range ?: R2Range ;
1023
+ }
1024
+
1025
+ /**
1026
+ * Metadata that's automatically rendered into R2 HTTP API endpoints.
1027
+ * ```
1028
+ * * contentType -> content-type
1029
+ * * contentLanguage -> content-language
1030
+ * etc...
1031
+ * ```
1032
+ * This data is echoed back on GET responses based on what was originally
1033
+ * assigned to the object (and can typically also be overriden when issuing
1034
+ * the GET request).
1035
+ */
1036
+ interface R2HTTPMetadata {
1037
+ contentType ?: string ;
1038
+ contentLanguage ?: string ;
1039
+ contentDisposition ?: string ;
1040
+ contentEncoding ?: string ;
1041
+ cacheControl ?: string ;
1042
+ cacheExpiry ?: Date ;
1043
+ }
1044
+
1045
+ /**
1046
+ * Options for retrieving the object metadata.
1047
+ */
1048
+ interface R2HeadOptions {
1049
+ onlyIf ?: R2Conditional | Headers ;
1050
+ }
1051
+
1052
+ interface R2ListOptions {
1053
+ limit ?: number ;
1054
+ prefix ?: string ;
1055
+ cursor ?: string ;
1056
+ delimiter ?: string ;
1057
+ /**
1058
+ * If you populate this array, then items returned will include this metadata.
1059
+ * A tradeoff is that fewer results may be returned depending on how big this
1060
+ * data is. For now the caps are TBD but expect the total memory usage for a list
1061
+ * operation may need to be <1MB or even <128kb depending on how many list operations
1062
+ * you are sending into one bucket. Make sure to look at `truncated` for the result
1063
+ * rather than having logic like
1064
+ * ```
1065
+ * while (listed.length < limit) {
1066
+ * listed = myBucket.list({ limit, include: ['customMetadata'] })
1067
+ * }
1068
+ * ```
1069
+ */
1070
+ include : ( "httpMetadata" | "customMetadata" ) [ ] ;
1071
+ }
1072
+
1073
+ /**
1074
+ * The metadata for the object.
1075
+ */
1076
+ declare abstract class R2Object {
1077
+ readonly key : string ;
1078
+ readonly version : string ;
1079
+ readonly size : number ;
1080
+ readonly etag : string ;
1081
+ readonly httpEtag : string ;
1082
+ readonly uploaded : Date ;
1083
+ readonly httpMetadata : R2HTTPMetadata ;
1084
+ readonly customMetadata : Record < string , string > ;
1085
+ writeHttpMetadata ( headers : Headers ) : void ;
1086
+ }
1087
+
1088
+ /**
1089
+ * The metadata for the object and the body of the payload.
1090
+ */
1091
+ interface R2ObjectBody extends R2Object {
1092
+ readonly body : ReadableStream ;
1093
+ readonly bodyUsed : boolean ;
1094
+ arrayBuffer ( ) : Promise < ArrayBuffer > ;
1095
+ text ( ) : Promise < string > ;
1096
+ json < T > ( ) : Promise < T > ;
1097
+ blob ( ) : Promise < Blob > ;
1098
+ }
1099
+
1100
+ interface R2Objects {
1101
+ objects : R2Object [ ] ;
1102
+ truncated : boolean ;
1103
+ cursor ?: string ;
1104
+ delimitedPrefixes : string [ ] ;
1105
+ }
1106
+
1107
+ interface R2PutOptions {
1108
+ httpMetadata ?: R2HTTPMetadata | Headers ;
1109
+ customMetadata ?: Record < string , string > ;
1110
+ md5 ?: ArrayBuffer | string ;
1111
+ sha1 ?: ArrayBuffer | string ;
1112
+ }
1113
+
1114
+ interface R2Range {
1115
+ offset : number ;
1116
+ length : number ;
1117
+ }
1118
+
947
1119
interface ReadResult {
948
1120
value ?: any ;
949
1121
done : boolean ;
@@ -969,12 +1141,10 @@ declare class ReadableStream {
969
1141
) : ReadableStream ;
970
1142
pipeTo ( destination : WritableStream , options ?: PipeToOptions ) : Promise < void > ;
971
1143
tee ( ) : [ ReadableStream , ReadableStream ] ;
972
- values (
973
- options ?: ReadableStreamValuesOptions
974
- ) : AsyncIterableIterator < ReadableStreamReadResult > ;
1144
+ values ( options ?: ReadableStreamValuesOptions ) : AsyncIterableIterator < any > ;
975
1145
[ Symbol . asyncIterator ] (
976
1146
options ?: ReadableStreamValuesOptions
977
- ) : AsyncIterableIterator < ReadableStreamReadResult > ;
1147
+ ) : AsyncIterableIterator < any > ;
978
1148
}
979
1149
980
1150
declare class ReadableStreamBYOBReader {
@@ -1357,27 +1527,27 @@ declare abstract class SubtleCrypto {
1357
1527
encrypt (
1358
1528
algorithm : string | SubtleCryptoEncryptAlgorithm ,
1359
1529
key : CryptoKey ,
1360
- plainText : ArrayBuffer
1530
+ plainText : ArrayBuffer | ArrayBufferView
1361
1531
) : Promise < ArrayBuffer > ;
1362
1532
decrypt (
1363
1533
algorithm : string | SubtleCryptoEncryptAlgorithm ,
1364
1534
key : CryptoKey ,
1365
- cipherText : ArrayBuffer
1535
+ cipherText : ArrayBuffer | ArrayBufferView
1366
1536
) : Promise < ArrayBuffer > ;
1367
1537
sign (
1368
1538
algorithm : string | SubtleCryptoSignAlgorithm ,
1369
1539
key : CryptoKey ,
1370
- data : ArrayBuffer
1540
+ data : ArrayBuffer | ArrayBufferView
1371
1541
) : Promise < ArrayBuffer > ;
1372
1542
verify (
1373
1543
algorithm : string | SubtleCryptoSignAlgorithm ,
1374
1544
key : CryptoKey ,
1375
- signature : ArrayBuffer ,
1376
- data : ArrayBuffer
1545
+ signature : ArrayBuffer | ArrayBufferView ,
1546
+ data : ArrayBuffer | ArrayBufferView
1377
1547
) : Promise < boolean > ;
1378
1548
digest (
1379
1549
algorithm : string | SubtleCryptoHashAlgorithm ,
1380
- data : ArrayBuffer
1550
+ data : ArrayBuffer | ArrayBufferView
1381
1551
) : Promise < ArrayBuffer > ;
1382
1552
generateKey (
1383
1553
algorithm : string | SubtleCryptoGenerateKeyAlgorithm ,
@@ -1412,7 +1582,7 @@ declare abstract class SubtleCrypto {
1412
1582
) : Promise < ArrayBuffer > ;
1413
1583
unwrapKey (
1414
1584
format : string ,
1415
- wrappedKey : ArrayBuffer ,
1585
+ wrappedKey : ArrayBuffer | ArrayBufferView ,
1416
1586
unwrappingKey : CryptoKey ,
1417
1587
unwrapAlgorithm : string | SubtleCryptoEncryptAlgorithm ,
1418
1588
unwrappedKeyAlgorithm : string | SubtleCryptoImportKeyAlgorithm ,
@@ -1495,7 +1665,10 @@ declare class TextDecoder {
1495
1665
label ?: "utf-8" | "utf8" | "unicode-1-1-utf-8" ,
1496
1666
options ?: TextDecoderConstructorOptions
1497
1667
) ;
1498
- decode ( input ?: ArrayBuffer , options ?: TextDecoderDecodeOptions ) : string ;
1668
+ decode (
1669
+ input ?: ArrayBuffer | ArrayBufferView ,
1670
+ options ?: TextDecoderDecodeOptions
1671
+ ) : string ;
1499
1672
readonly encoding : string ;
1500
1673
readonly fatal : boolean ;
1501
1674
readonly ignoreBOM : boolean ;
@@ -1631,12 +1804,26 @@ declare type URLSearchParamsInit =
1631
1804
*/
1632
1805
declare type URLSearchParamsInitializer = URLSearchParamsInit ;
1633
1806
1634
- declare abstract class WebSocket extends EventTarget < WebSocketEventMap > { }
1807
+ declare class WebSocket extends EventTarget < WebSocketEventMap > {
1808
+ constructor ( url : string , protocols ?: string [ ] | string ) ;
1809
+ accept ( ) : void ;
1810
+ send ( message : ArrayBuffer | ArrayBufferView | string ) : void ;
1811
+ close ( code ?: number , reason ?: string ) : void ;
1812
+ static readonly READY_STATE_CONNECTING : number ;
1813
+ static readonly READY_STATE_OPEN : number ;
1814
+ static readonly READY_STATE_CLOSING : number ;
1815
+ static readonly READY_STATE_CLOSED : number ;
1816
+ readonly readyState : number ;
1817
+ readonly url : string | null ;
1818
+ readonly protocol : string | null ;
1819
+ readonly extensions : string | null ;
1820
+ }
1635
1821
1636
1822
declare type WebSocketEventMap = {
1637
1823
close : CloseEvent ;
1638
1824
message : MessageEvent ;
1639
- error : Event ;
1825
+ open : Event ;
1826
+ error : ErrorEvent ;
1640
1827
} ;
1641
1828
1642
1829
declare const WebSocketPair : { new ( ) : { 0 : WebSocket ; 1 : WebSocket } } ;
0 commit comments