@cloudflare/workers-types 3.4.0 → 3.6.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.
Files changed (2) hide show
  1. package/index.d.ts +268 -19
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -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>;
@@ -399,27 +419,43 @@ interface DurableObjectStorage {
399
419
  transaction<T>(
400
420
  closure: (txn: DurableObjectTransaction) => Promise<T>
401
421
  ): Promise<T>;
422
+ getAlarm(
423
+ options?: DurableObjectStorageOperationsGetAlarmOptions
424
+ ): Promise<Date | null>;
425
+ setAlarm(
426
+ arg2: Date,
427
+ options?: DurableObjectStorageOperationsSetAlarmOptions
428
+ ): Promise<void>;
429
+ }
430
+
431
+ interface DurableObjectStorageOperationsGetAlarmOptions {
432
+ allowConcurrency?: boolean;
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
 
454
+ interface DurableObjectStorageOperationsSetAlarmOptions {
455
+ allowConcurrency?: boolean;
456
+ allowUnconfirmed?: boolean;
457
+ }
458
+
423
459
  interface DurableObjectStub extends Fetcher {
424
460
  readonly id: DurableObjectId;
425
461
  readonly name?: string;
@@ -446,6 +482,13 @@ interface DurableObjectTransaction {
446
482
  delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
447
483
  delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
448
484
  rollback(): void;
485
+ getAlarm(
486
+ options?: DurableObjectStorageOperationsGetAlarmOptions
487
+ ): Promise<Date | null>;
488
+ setAlarm(
489
+ arg2: Date,
490
+ options?: DurableObjectStorageOperationsSetAlarmOptions
491
+ ): Promise<void>;
449
492
  }
450
493
 
451
494
  interface Element {
@@ -475,6 +518,14 @@ interface EndTag {
475
518
  remove(): EndTag;
476
519
  }
477
520
 
521
+ interface ErrorEvent extends Event {
522
+ readonly filename: string;
523
+ readonly message: string;
524
+ readonly lineno: number;
525
+ readonly colno: number;
526
+ readonly error: any;
527
+ }
528
+
478
529
  declare class Event {
479
530
  constructor(type: string, init?: EventInit);
480
531
  readonly type: string;
@@ -593,7 +644,7 @@ interface FileOptions {
593
644
  }
594
645
 
595
646
  declare class FixedLengthStream extends TransformStream {
596
- constructor(expectedLength: number);
647
+ constructor(expectedLength: number | bigint);
597
648
  }
598
649
 
599
650
  declare class FormData {
@@ -673,6 +724,10 @@ declare type HeadersInit =
673
724
  */
674
725
  declare type HeadersInitializer = HeadersInit;
675
726
 
727
+ declare class IdentityTransformStream extends TransformStream {
728
+ constructor();
729
+ }
730
+
676
731
  /**
677
732
  * In addition to the properties on the standard Request object,
678
733
  * the cf object contains extra information about the request provided
@@ -917,6 +972,10 @@ interface MessageEventInit {
917
972
  */
918
973
  declare type MessageEventInitializer = MessageEventInit;
919
974
 
975
+ declare abstract class Navigator {
976
+ readonly userAgent: string;
977
+ }
978
+
920
979
  /**
921
980
  * Transitionary name.
922
981
  * @deprecated Use StreamPipeOptions
@@ -932,6 +991,141 @@ declare abstract class PromiseRejectionEvent extends Event {
932
991
  readonly reason: any;
933
992
  }
934
993
 
994
+ interface QueuingStrategyInit {
995
+ highWaterMark: number;
996
+ }
997
+
998
+ /**
999
+ * An instance of the R2 bucket binding.
1000
+ */
1001
+ interface R2Bucket {
1002
+ head(key: string, options?: R2HeadOptions): Promise<R2Object | null>;
1003
+ get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1004
+ put(
1005
+ key: string,
1006
+ value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null,
1007
+ options?: R2PutOptions
1008
+ ): Promise<R2Object>;
1009
+ delete(key: string): Promise<void>;
1010
+ list(options?: R2ListOptions): Promise<R2Objects>;
1011
+ }
1012
+
1013
+ /**
1014
+ * Perform the operation conditionally based on meeting the defined criteria.
1015
+ */
1016
+ interface R2Conditional {
1017
+ etagMatches?: string;
1018
+ etagDoesNotMatch?: string;
1019
+ uploadedBefore?: Date;
1020
+ uploadedAfter?: Date;
1021
+ }
1022
+
1023
+ interface R2Error {
1024
+ readonly stack: string;
1025
+ }
1026
+
1027
+ /**
1028
+ * Options for retrieving the object metadata nad payload.
1029
+ */
1030
+ interface R2GetOptions {
1031
+ onlyIf?: R2Conditional | Headers;
1032
+ range?: R2Range;
1033
+ }
1034
+
1035
+ /**
1036
+ * Metadata that's automatically rendered into R2 HTTP API endpoints.
1037
+ * ```
1038
+ * * contentType -> content-type
1039
+ * * contentLanguage -> content-language
1040
+ * etc...
1041
+ * ```
1042
+ * This data is echoed back on GET responses based on what was originally
1043
+ * assigned to the object (and can typically also be overriden when issuing
1044
+ * the GET request).
1045
+ */
1046
+ interface R2HTTPMetadata {
1047
+ contentType?: string;
1048
+ contentLanguage?: string;
1049
+ contentDisposition?: string;
1050
+ contentEncoding?: string;
1051
+ cacheControl?: string;
1052
+ cacheExpiry?: Date;
1053
+ }
1054
+
1055
+ /**
1056
+ * Options for retrieving the object metadata.
1057
+ */
1058
+ interface R2HeadOptions {
1059
+ onlyIf?: R2Conditional | Headers;
1060
+ }
1061
+
1062
+ interface R2ListOptions {
1063
+ limit?: number;
1064
+ prefix?: string;
1065
+ cursor?: string;
1066
+ delimiter?: string;
1067
+ /**
1068
+ * If you populate this array, then items returned will include this metadata.
1069
+ * A tradeoff is that fewer results may be returned depending on how big this
1070
+ * data is. For now the caps are TBD but expect the total memory usage for a list
1071
+ * operation may need to be <1MB or even <128kb depending on how many list operations
1072
+ * you are sending into one bucket. Make sure to look at `truncated` for the result
1073
+ * rather than having logic like
1074
+ * ```
1075
+ * while (listed.length < limit) {
1076
+ * listed = myBucket.list({ limit, include: ['customMetadata'] })
1077
+ * }
1078
+ * ```
1079
+ */
1080
+ include: ("httpMetadata" | "customMetadata")[];
1081
+ }
1082
+
1083
+ /**
1084
+ * The metadata for the object.
1085
+ */
1086
+ declare abstract class R2Object {
1087
+ readonly key: string;
1088
+ readonly version: string;
1089
+ readonly size: number;
1090
+ readonly etag: string;
1091
+ readonly httpEtag: string;
1092
+ readonly uploaded: Date;
1093
+ readonly httpMetadata: R2HTTPMetadata;
1094
+ readonly customMetadata: Record<string, string>;
1095
+ writeHttpMetadata(headers: Headers): void;
1096
+ }
1097
+
1098
+ /**
1099
+ * The metadata for the object and the body of the payload.
1100
+ */
1101
+ interface R2ObjectBody extends R2Object {
1102
+ readonly body: ReadableStream;
1103
+ readonly bodyUsed: boolean;
1104
+ arrayBuffer(): Promise<ArrayBuffer>;
1105
+ text(): Promise<string>;
1106
+ json<T>(): Promise<T>;
1107
+ blob(): Promise<Blob>;
1108
+ }
1109
+
1110
+ interface R2Objects {
1111
+ objects: R2Object[];
1112
+ truncated: boolean;
1113
+ cursor?: string;
1114
+ delimitedPrefixes: string[];
1115
+ }
1116
+
1117
+ interface R2PutOptions {
1118
+ httpMetadata?: R2HTTPMetadata | Headers;
1119
+ customMetadata?: Record<string, string>;
1120
+ md5?: ArrayBuffer | string;
1121
+ sha1?: ArrayBuffer | string;
1122
+ }
1123
+
1124
+ interface R2Range {
1125
+ offset: number;
1126
+ length: number;
1127
+ }
1128
+
935
1129
  interface ReadResult {
936
1130
  value?: any;
937
1131
  done: boolean;
@@ -957,12 +1151,10 @@ declare class ReadableStream {
957
1151
  ): ReadableStream;
958
1152
  pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
959
1153
  tee(): [ReadableStream, ReadableStream];
960
- values(
961
- options?: ReadableStreamValuesOptions
962
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1154
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<any>;
963
1155
  [Symbol.asyncIterator](
964
1156
  options?: ReadableStreamValuesOptions
965
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1157
+ ): AsyncIterableIterator<any>;
966
1158
  }
967
1159
 
968
1160
  declare class ReadableStreamBYOBReader {
@@ -1325,6 +1517,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1325
1517
  crypto: Crypto;
1326
1518
  caches: CacheStorage;
1327
1519
  scheduler: Scheduler;
1520
+ navigator: Navigator;
1328
1521
  readonly console: Console;
1329
1522
  origin: void;
1330
1523
  }
@@ -1344,27 +1537,27 @@ declare abstract class SubtleCrypto {
1344
1537
  encrypt(
1345
1538
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1346
1539
  key: CryptoKey,
1347
- plainText: ArrayBuffer
1540
+ plainText: ArrayBuffer | ArrayBufferView
1348
1541
  ): Promise<ArrayBuffer>;
1349
1542
  decrypt(
1350
1543
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1351
1544
  key: CryptoKey,
1352
- cipherText: ArrayBuffer
1545
+ cipherText: ArrayBuffer | ArrayBufferView
1353
1546
  ): Promise<ArrayBuffer>;
1354
1547
  sign(
1355
1548
  algorithm: string | SubtleCryptoSignAlgorithm,
1356
1549
  key: CryptoKey,
1357
- data: ArrayBuffer
1550
+ data: ArrayBuffer | ArrayBufferView
1358
1551
  ): Promise<ArrayBuffer>;
1359
1552
  verify(
1360
1553
  algorithm: string | SubtleCryptoSignAlgorithm,
1361
1554
  key: CryptoKey,
1362
- signature: ArrayBuffer,
1363
- data: ArrayBuffer
1555
+ signature: ArrayBuffer | ArrayBufferView,
1556
+ data: ArrayBuffer | ArrayBufferView
1364
1557
  ): Promise<boolean>;
1365
1558
  digest(
1366
1559
  algorithm: string | SubtleCryptoHashAlgorithm,
1367
- data: ArrayBuffer
1560
+ data: ArrayBuffer | ArrayBufferView
1368
1561
  ): Promise<ArrayBuffer>;
1369
1562
  generateKey(
1370
1563
  algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
@@ -1399,7 +1592,7 @@ declare abstract class SubtleCrypto {
1399
1592
  ): Promise<ArrayBuffer>;
1400
1593
  unwrapKey(
1401
1594
  format: string,
1402
- wrappedKey: ArrayBuffer,
1595
+ wrappedKey: ArrayBuffer | ArrayBufferView,
1403
1596
  unwrappingKey: CryptoKey,
1404
1597
  unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1405
1598
  unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
@@ -1482,7 +1675,10 @@ declare class TextDecoder {
1482
1675
  label?: "utf-8" | "utf8" | "unicode-1-1-utf-8",
1483
1676
  options?: TextDecoderConstructorOptions
1484
1677
  );
1485
- decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
1678
+ decode(
1679
+ input?: ArrayBuffer | ArrayBufferView,
1680
+ options?: TextDecoderDecodeOptions
1681
+ ): string;
1486
1682
  readonly encoding: string;
1487
1683
  readonly fatal: boolean;
1488
1684
  readonly ignoreBOM: boolean;
@@ -1533,6 +1729,52 @@ declare class URL {
1533
1729
  toJSON(): string;
1534
1730
  }
1535
1731
 
1732
+ declare class URLPattern {
1733
+ constructor(input?: string | URLPatternURLPatternInit, baseURL?: string);
1734
+ readonly protocol: string;
1735
+ readonly username: string;
1736
+ readonly password: string;
1737
+ readonly hostname: string;
1738
+ readonly port: string;
1739
+ readonly pathname: string;
1740
+ readonly search: string;
1741
+ readonly hash: string;
1742
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
1743
+ exec(
1744
+ input?: string | URLPatternURLPatternInit,
1745
+ baseURL?: string
1746
+ ): URLPatternURLPatternResult | null;
1747
+ }
1748
+
1749
+ interface URLPatternURLPatternComponentResult {
1750
+ input: string;
1751
+ groups: Record<string, string>;
1752
+ }
1753
+
1754
+ interface URLPatternURLPatternInit {
1755
+ protocol?: string;
1756
+ username?: string;
1757
+ password?: string;
1758
+ hostname?: string;
1759
+ port?: string;
1760
+ pathname?: string;
1761
+ search?: string;
1762
+ hash?: string;
1763
+ baseURL?: string;
1764
+ }
1765
+
1766
+ interface URLPatternURLPatternResult {
1767
+ inputs: (string | URLPatternURLPatternInit)[];
1768
+ protocol: URLPatternURLPatternComponentResult;
1769
+ username: URLPatternURLPatternComponentResult;
1770
+ password: URLPatternURLPatternComponentResult;
1771
+ hostname: URLPatternURLPatternComponentResult;
1772
+ port: URLPatternURLPatternComponentResult;
1773
+ pathname: URLPatternURLPatternComponentResult;
1774
+ search: URLPatternURLPatternComponentResult;
1775
+ hash: URLPatternURLPatternComponentResult;
1776
+ }
1777
+
1536
1778
  declare class URLSearchParams {
1537
1779
  constructor(init?: URLSearchParamsInit);
1538
1780
  append(name: string, value: string): void;
@@ -1572,21 +1814,26 @@ declare type URLSearchParamsInit =
1572
1814
  */
1573
1815
  declare type URLSearchParamsInitializer = URLSearchParamsInit;
1574
1816
 
1575
- declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
1817
+ declare class WebSocket extends EventTarget<WebSocketEventMap> {
1818
+ constructor(url: string, protocols?: string[] | string);
1576
1819
  accept(): void;
1577
- send(message: ArrayBuffer | string): void;
1820
+ send(message: ArrayBuffer | ArrayBufferView | string): void;
1578
1821
  close(code?: number, reason?: string): void;
1579
1822
  static readonly READY_STATE_CONNECTING: number;
1580
1823
  static readonly READY_STATE_OPEN: number;
1581
1824
  static readonly READY_STATE_CLOSING: number;
1582
1825
  static readonly READY_STATE_CLOSED: number;
1583
1826
  readonly readyState: number;
1827
+ readonly url: string | null;
1828
+ readonly protocol: string | null;
1829
+ readonly extensions: string | null;
1584
1830
  }
1585
1831
 
1586
1832
  declare type WebSocketEventMap = {
1587
1833
  close: CloseEvent;
1588
1834
  message: MessageEvent;
1589
- error: Event;
1835
+ open: Event;
1836
+ error: ErrorEvent;
1590
1837
  };
1591
1838
 
1592
1839
  declare const WebSocketPair: { new (): { 0: WebSocket; 1: WebSocket } };
@@ -1660,6 +1907,8 @@ declare function fetch(
1660
1907
  requestInitr?: RequestInit | Request
1661
1908
  ): Promise<Response>;
1662
1909
 
1910
+ declare const navigator: Navigator;
1911
+
1663
1912
  declare const origin: void;
1664
1913
 
1665
1914
  declare function queueMicrotask(task: Function): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/workers-types",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",