@cloudflare/workers-types 3.4.0 → 3.5.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 +258 -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>;
@@ -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 {
@@ -475,6 +508,14 @@ interface EndTag {
475
508
  remove(): EndTag;
476
509
  }
477
510
 
511
+ interface ErrorEvent extends Event {
512
+ readonly filename: string;
513
+ readonly message: string;
514
+ readonly lineno: number;
515
+ readonly colno: number;
516
+ readonly error: any;
517
+ }
518
+
478
519
  declare class Event {
479
520
  constructor(type: string, init?: EventInit);
480
521
  readonly type: string;
@@ -593,7 +634,7 @@ interface FileOptions {
593
634
  }
594
635
 
595
636
  declare class FixedLengthStream extends TransformStream {
596
- constructor(expectedLength: number);
637
+ constructor(expectedLength: number | bigint);
597
638
  }
598
639
 
599
640
  declare class FormData {
@@ -673,6 +714,10 @@ declare type HeadersInit =
673
714
  */
674
715
  declare type HeadersInitializer = HeadersInit;
675
716
 
717
+ declare class IdentityTransformStream extends TransformStream {
718
+ constructor();
719
+ }
720
+
676
721
  /**
677
722
  * In addition to the properties on the standard Request object,
678
723
  * the cf object contains extra information about the request provided
@@ -917,6 +962,10 @@ interface MessageEventInit {
917
962
  */
918
963
  declare type MessageEventInitializer = MessageEventInit;
919
964
 
965
+ declare abstract class Navigator {
966
+ readonly userAgent: string;
967
+ }
968
+
920
969
  /**
921
970
  * Transitionary name.
922
971
  * @deprecated Use StreamPipeOptions
@@ -932,6 +981,141 @@ declare abstract class PromiseRejectionEvent extends Event {
932
981
  readonly reason: any;
933
982
  }
934
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
+
935
1119
  interface ReadResult {
936
1120
  value?: any;
937
1121
  done: boolean;
@@ -957,12 +1141,10 @@ declare class ReadableStream {
957
1141
  ): ReadableStream;
958
1142
  pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
959
1143
  tee(): [ReadableStream, ReadableStream];
960
- values(
961
- options?: ReadableStreamValuesOptions
962
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1144
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<any>;
963
1145
  [Symbol.asyncIterator](
964
1146
  options?: ReadableStreamValuesOptions
965
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1147
+ ): AsyncIterableIterator<any>;
966
1148
  }
967
1149
 
968
1150
  declare class ReadableStreamBYOBReader {
@@ -1325,6 +1507,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1325
1507
  crypto: Crypto;
1326
1508
  caches: CacheStorage;
1327
1509
  scheduler: Scheduler;
1510
+ navigator: Navigator;
1328
1511
  readonly console: Console;
1329
1512
  origin: void;
1330
1513
  }
@@ -1344,27 +1527,27 @@ declare abstract class SubtleCrypto {
1344
1527
  encrypt(
1345
1528
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1346
1529
  key: CryptoKey,
1347
- plainText: ArrayBuffer
1530
+ plainText: ArrayBuffer | ArrayBufferView
1348
1531
  ): Promise<ArrayBuffer>;
1349
1532
  decrypt(
1350
1533
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1351
1534
  key: CryptoKey,
1352
- cipherText: ArrayBuffer
1535
+ cipherText: ArrayBuffer | ArrayBufferView
1353
1536
  ): Promise<ArrayBuffer>;
1354
1537
  sign(
1355
1538
  algorithm: string | SubtleCryptoSignAlgorithm,
1356
1539
  key: CryptoKey,
1357
- data: ArrayBuffer
1540
+ data: ArrayBuffer | ArrayBufferView
1358
1541
  ): Promise<ArrayBuffer>;
1359
1542
  verify(
1360
1543
  algorithm: string | SubtleCryptoSignAlgorithm,
1361
1544
  key: CryptoKey,
1362
- signature: ArrayBuffer,
1363
- data: ArrayBuffer
1545
+ signature: ArrayBuffer | ArrayBufferView,
1546
+ data: ArrayBuffer | ArrayBufferView
1364
1547
  ): Promise<boolean>;
1365
1548
  digest(
1366
1549
  algorithm: string | SubtleCryptoHashAlgorithm,
1367
- data: ArrayBuffer
1550
+ data: ArrayBuffer | ArrayBufferView
1368
1551
  ): Promise<ArrayBuffer>;
1369
1552
  generateKey(
1370
1553
  algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
@@ -1399,7 +1582,7 @@ declare abstract class SubtleCrypto {
1399
1582
  ): Promise<ArrayBuffer>;
1400
1583
  unwrapKey(
1401
1584
  format: string,
1402
- wrappedKey: ArrayBuffer,
1585
+ wrappedKey: ArrayBuffer | ArrayBufferView,
1403
1586
  unwrappingKey: CryptoKey,
1404
1587
  unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1405
1588
  unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
@@ -1482,7 +1665,10 @@ declare class TextDecoder {
1482
1665
  label?: "utf-8" | "utf8" | "unicode-1-1-utf-8",
1483
1666
  options?: TextDecoderConstructorOptions
1484
1667
  );
1485
- decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
1668
+ decode(
1669
+ input?: ArrayBuffer | ArrayBufferView,
1670
+ options?: TextDecoderDecodeOptions
1671
+ ): string;
1486
1672
  readonly encoding: string;
1487
1673
  readonly fatal: boolean;
1488
1674
  readonly ignoreBOM: boolean;
@@ -1533,6 +1719,52 @@ declare class URL {
1533
1719
  toJSON(): string;
1534
1720
  }
1535
1721
 
1722
+ declare class URLPattern {
1723
+ constructor(input?: string | URLPatternURLPatternInit, baseURL?: string);
1724
+ readonly protocol: string;
1725
+ readonly username: string;
1726
+ readonly password: string;
1727
+ readonly hostname: string;
1728
+ readonly port: string;
1729
+ readonly pathname: string;
1730
+ readonly search: string;
1731
+ readonly hash: string;
1732
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
1733
+ exec(
1734
+ input?: string | URLPatternURLPatternInit,
1735
+ baseURL?: string
1736
+ ): URLPatternURLPatternResult | null;
1737
+ }
1738
+
1739
+ interface URLPatternURLPatternComponentResult {
1740
+ input: string;
1741
+ groups: Record<string, string>;
1742
+ }
1743
+
1744
+ interface URLPatternURLPatternInit {
1745
+ protocol?: string;
1746
+ username?: string;
1747
+ password?: string;
1748
+ hostname?: string;
1749
+ port?: string;
1750
+ pathname?: string;
1751
+ search?: string;
1752
+ hash?: string;
1753
+ baseURL?: string;
1754
+ }
1755
+
1756
+ interface URLPatternURLPatternResult {
1757
+ inputs: (string | URLPatternURLPatternInit)[];
1758
+ protocol: URLPatternURLPatternComponentResult;
1759
+ username: URLPatternURLPatternComponentResult;
1760
+ password: URLPatternURLPatternComponentResult;
1761
+ hostname: URLPatternURLPatternComponentResult;
1762
+ port: URLPatternURLPatternComponentResult;
1763
+ pathname: URLPatternURLPatternComponentResult;
1764
+ search: URLPatternURLPatternComponentResult;
1765
+ hash: URLPatternURLPatternComponentResult;
1766
+ }
1767
+
1536
1768
  declare class URLSearchParams {
1537
1769
  constructor(init?: URLSearchParamsInit);
1538
1770
  append(name: string, value: string): void;
@@ -1572,21 +1804,26 @@ declare type URLSearchParamsInit =
1572
1804
  */
1573
1805
  declare type URLSearchParamsInitializer = URLSearchParamsInit;
1574
1806
 
1575
- declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
1807
+ declare class WebSocket extends EventTarget<WebSocketEventMap> {
1808
+ constructor(url: string, protocols?: string[] | string);
1576
1809
  accept(): void;
1577
- send(message: ArrayBuffer | string): void;
1810
+ send(message: ArrayBuffer | ArrayBufferView | string): void;
1578
1811
  close(code?: number, reason?: string): void;
1579
1812
  static readonly READY_STATE_CONNECTING: number;
1580
1813
  static readonly READY_STATE_OPEN: number;
1581
1814
  static readonly READY_STATE_CLOSING: number;
1582
1815
  static readonly READY_STATE_CLOSED: number;
1583
1816
  readonly readyState: number;
1817
+ readonly url: string | null;
1818
+ readonly protocol: string | null;
1819
+ readonly extensions: string | null;
1584
1820
  }
1585
1821
 
1586
1822
  declare type WebSocketEventMap = {
1587
1823
  close: CloseEvent;
1588
1824
  message: MessageEvent;
1589
- error: Event;
1825
+ open: Event;
1826
+ error: ErrorEvent;
1590
1827
  };
1591
1828
 
1592
1829
  declare const WebSocketPair: { new (): { 0: WebSocket; 1: WebSocket } };
@@ -1660,6 +1897,8 @@ declare function fetch(
1660
1897
  requestInitr?: RequestInit | Request
1661
1898
  ): Promise<Response>;
1662
1899
 
1900
+ declare const navigator: Navigator;
1901
+
1663
1902
  declare const origin: void;
1664
1903
 
1665
1904
  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.5.0",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",