@cloudflare/workers-types 3.3.1 → 3.5.1

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 +275 -23
  2. package/package.json +3 -3
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<
@@ -211,6 +227,8 @@ declare abstract class Crypto {
211
227
  | Uint16Array
212
228
  | Int32Array
213
229
  | Uint32Array
230
+ | BigInt64Array
231
+ | BigUint64Array
214
232
  >(buffer: T): T;
215
233
  randomUUID(): string;
216
234
  }
@@ -304,6 +322,10 @@ declare class DOMException extends Error {
304
322
  static readonly DATA_CLONE_ERR: number;
305
323
  }
306
324
 
325
+ declare class DecompressionStream extends TransformStream {
326
+ constructor(format: string);
327
+ }
328
+
307
329
  declare class DigestStream extends WritableStream {
308
330
  constructor(algorithm: string | SubtleCryptoHashAlgorithm);
309
331
  readonly digest: Promise<ArrayBuffer>;
@@ -323,6 +345,10 @@ interface DurableObject {
323
345
  fetch(request: Request): Promise<Response>;
324
346
  }
325
347
 
348
+ interface DurableObjectGetAlarmOptions {
349
+ allowConcurrency?: boolean;
350
+ }
351
+
326
352
  interface DurableObjectGetOptions {
327
353
  allowConcurrency?: boolean;
328
354
  noCache?: boolean;
@@ -363,6 +389,11 @@ interface DurableObjectPutOptions {
363
389
  noCache?: boolean;
364
390
  }
365
391
 
392
+ interface DurableObjectSetAlarmOptions {
393
+ allowConcurrency?: boolean;
394
+ allowUnconfirmed?: boolean;
395
+ }
396
+
366
397
  interface DurableObjectState {
367
398
  waitUntil(promise: Promise<any>): void;
368
399
  readonly id: DurableObjectId | string;
@@ -397,24 +428,26 @@ interface DurableObjectStorage {
397
428
  transaction<T>(
398
429
  closure: (txn: DurableObjectTransaction) => Promise<T>
399
430
  ): Promise<T>;
431
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<Date | null>;
432
+ setAlarm(arg2: Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
400
433
  }
401
434
 
402
435
  /**
403
436
  *
404
- * @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.
405
438
  */
406
439
  declare type DurableObjectStorageOperationsGetOptions = DurableObjectGetOptions;
407
440
 
408
441
  /**
409
442
  *
410
- * @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.
411
444
  */
412
445
  declare type DurableObjectStorageOperationsListOptions =
413
446
  DurableObjectListOptions;
414
447
 
415
448
  /**
416
449
  *
417
- * @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.
418
451
  */
419
452
  declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
420
453
 
@@ -444,6 +477,8 @@ interface DurableObjectTransaction {
444
477
  delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
445
478
  delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
446
479
  rollback(): void;
480
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<Date | null>;
481
+ setAlarm(arg2: Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
447
482
  }
448
483
 
449
484
  interface Element {
@@ -463,7 +498,7 @@ interface Element {
463
498
  remove(): Element;
464
499
  removeAndKeepContent(): Element;
465
500
  setInnerContent(content: Content, options?: ContentOptions): Element;
466
- onEndTag(handler: Function): void;
501
+ onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
467
502
  }
468
503
 
469
504
  interface EndTag {
@@ -473,6 +508,14 @@ interface EndTag {
473
508
  remove(): EndTag;
474
509
  }
475
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
+
476
519
  declare class Event {
477
520
  constructor(type: string, init?: EventInit);
478
521
  readonly type: string;
@@ -591,7 +634,7 @@ interface FileOptions {
591
634
  }
592
635
 
593
636
  declare class FixedLengthStream extends TransformStream {
594
- constructor(expectedLength: number);
637
+ constructor(expectedLength: number | bigint);
595
638
  }
596
639
 
597
640
  declare class FormData {
@@ -604,7 +647,7 @@ declare class FormData {
604
647
  has(name: string): boolean;
605
648
  set(name: string, value: string): void;
606
649
  set(name: string, value: Blob, filename?: string): void;
607
- entries(): IterableIterator<[key: string, value: File | string][]>;
650
+ entries(): IterableIterator<[key: string, value: File | string]>;
608
651
  keys(): IterableIterator<string>;
609
652
  values(): IterableIterator<File | string>;
610
653
  forEach<This = unknown>(
@@ -616,7 +659,7 @@ declare class FormData {
616
659
  ) => void,
617
660
  thisArg?: This
618
661
  ): void;
619
- [Symbol.iterator](): IterableIterator<[key: string, value: File | string][]>;
662
+ [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
620
663
  }
621
664
 
622
665
  declare class HTMLRewriter {
@@ -671,6 +714,10 @@ declare type HeadersInit =
671
714
  */
672
715
  declare type HeadersInitializer = HeadersInit;
673
716
 
717
+ declare class IdentityTransformStream extends TransformStream {
718
+ constructor();
719
+ }
720
+
674
721
  /**
675
722
  * In addition to the properties on the standard Request object,
676
723
  * the cf object contains extra information about the request provided
@@ -820,7 +867,7 @@ interface KVNamespace<K extends string = string> {
820
867
  * @param value value to store. The type is inferred. The maximum size of a value is 25MB.
821
868
  * @returns Returns a `Promise` that you should `await` on in order to verify a successful update.
822
869
  * @example
823
- * await NAMESPACE.put(key, value)
870
+ * await NAMESPACE.put(key, value);
824
871
  */
825
872
  put(
826
873
  key: K,
@@ -915,6 +962,10 @@ interface MessageEventInit {
915
962
  */
916
963
  declare type MessageEventInitializer = MessageEventInit;
917
964
 
965
+ declare abstract class Navigator {
966
+ readonly userAgent: string;
967
+ }
968
+
918
969
  /**
919
970
  * Transitionary name.
920
971
  * @deprecated Use StreamPipeOptions
@@ -930,6 +981,147 @@ declare abstract class PromiseRejectionEvent extends Event {
930
981
  readonly reason: any;
931
982
  }
932
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:
997
+ | ReadableStream
998
+ | ArrayBuffer
999
+ | ArrayBufferView
1000
+ | string
1001
+ | null
1002
+ | Blob,
1003
+ options?: R2PutOptions
1004
+ ): Promise<R2Object>;
1005
+ delete(key: string): Promise<void>;
1006
+ list(options?: R2ListOptions): Promise<R2Objects>;
1007
+ }
1008
+
1009
+ /**
1010
+ * Perform the operation conditionally based on meeting the defined criteria.
1011
+ */
1012
+ interface R2Conditional {
1013
+ etagMatches?: string;
1014
+ etagDoesNotMatch?: string;
1015
+ uploadedBefore?: Date;
1016
+ uploadedAfter?: Date;
1017
+ }
1018
+
1019
+ interface R2Error {
1020
+ readonly stack: string;
1021
+ }
1022
+
1023
+ /**
1024
+ * Options for retrieving the object metadata nad payload.
1025
+ */
1026
+ interface R2GetOptions {
1027
+ onlyIf?: R2Conditional | Headers;
1028
+ range?: R2Range;
1029
+ }
1030
+
1031
+ /**
1032
+ * Metadata that's automatically rendered into R2 HTTP API endpoints.
1033
+ * ```
1034
+ * * contentType -> content-type
1035
+ * * contentLanguage -> content-language
1036
+ * etc...
1037
+ * ```
1038
+ * This data is echoed back on GET responses based on what was originally
1039
+ * assigned to the object (and can typically also be overriden when issuing
1040
+ * the GET request).
1041
+ */
1042
+ interface R2HTTPMetadata {
1043
+ contentType?: string;
1044
+ contentLanguage?: string;
1045
+ contentDisposition?: string;
1046
+ contentEncoding?: string;
1047
+ cacheControl?: string;
1048
+ cacheExpiry?: Date;
1049
+ }
1050
+
1051
+ /**
1052
+ * Options for retrieving the object metadata.
1053
+ */
1054
+ interface R2HeadOptions {
1055
+ onlyIf?: R2Conditional | Headers;
1056
+ }
1057
+
1058
+ interface R2ListOptions {
1059
+ limit?: number;
1060
+ prefix?: string;
1061
+ cursor?: string;
1062
+ delimiter?: string;
1063
+ /**
1064
+ * If you populate this array, then items returned will include this metadata.
1065
+ * A tradeoff is that fewer results may be returned depending on how big this
1066
+ * data is. For now the caps are TBD but expect the total memory usage for a list
1067
+ * operation may need to be <1MB or even <128kb depending on how many list operations
1068
+ * you are sending into one bucket. Make sure to look at `truncated` for the result
1069
+ * rather than having logic like
1070
+ * ```
1071
+ * while (listed.length < limit) {
1072
+ * listed = myBucket.list({ limit, include: ['customMetadata'] })
1073
+ * }
1074
+ * ```
1075
+ */
1076
+ include?: ("httpMetadata" | "customMetadata")[];
1077
+ }
1078
+
1079
+ /**
1080
+ * The metadata for the object.
1081
+ */
1082
+ declare abstract class R2Object {
1083
+ readonly key: string;
1084
+ readonly version: string;
1085
+ readonly size: number;
1086
+ readonly etag: string;
1087
+ readonly httpEtag: string;
1088
+ readonly uploaded: Date;
1089
+ readonly httpMetadata: R2HTTPMetadata;
1090
+ readonly customMetadata: Record<string, string>;
1091
+ writeHttpMetadata(headers: Headers): void;
1092
+ }
1093
+
1094
+ /**
1095
+ * The metadata for the object and the body of the payload.
1096
+ */
1097
+ interface R2ObjectBody extends R2Object {
1098
+ readonly body: ReadableStream;
1099
+ readonly bodyUsed: boolean;
1100
+ arrayBuffer(): Promise<ArrayBuffer>;
1101
+ text(): Promise<string>;
1102
+ json<T>(): Promise<T>;
1103
+ blob(): Promise<Blob>;
1104
+ }
1105
+
1106
+ interface R2Objects {
1107
+ objects: R2Object[];
1108
+ truncated: boolean;
1109
+ cursor?: string;
1110
+ delimitedPrefixes: string[];
1111
+ }
1112
+
1113
+ interface R2PutOptions {
1114
+ httpMetadata?: R2HTTPMetadata | Headers;
1115
+ customMetadata?: Record<string, string>;
1116
+ md5?: ArrayBuffer | string;
1117
+ sha1?: ArrayBuffer | string;
1118
+ }
1119
+
1120
+ interface R2Range {
1121
+ offset: number;
1122
+ length: number;
1123
+ }
1124
+
933
1125
  interface ReadResult {
934
1126
  value?: any;
935
1127
  done: boolean;
@@ -955,12 +1147,10 @@ declare class ReadableStream {
955
1147
  ): ReadableStream;
956
1148
  pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
957
1149
  tee(): [ReadableStream, ReadableStream];
958
- values(
959
- options?: ReadableStreamValuesOptions
960
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1150
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<any>;
961
1151
  [Symbol.asyncIterator](
962
1152
  options?: ReadableStreamValuesOptions
963
- ): AsyncIterableIterator<ReadableStreamReadResult>;
1153
+ ): AsyncIterableIterator<any>;
964
1154
  }
965
1155
 
966
1156
  declare class ReadableStreamBYOBReader {
@@ -1323,6 +1513,7 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
1323
1513
  crypto: Crypto;
1324
1514
  caches: CacheStorage;
1325
1515
  scheduler: Scheduler;
1516
+ navigator: Navigator;
1326
1517
  readonly console: Console;
1327
1518
  origin: void;
1328
1519
  }
@@ -1342,27 +1533,27 @@ declare abstract class SubtleCrypto {
1342
1533
  encrypt(
1343
1534
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1344
1535
  key: CryptoKey,
1345
- plainText: ArrayBuffer
1536
+ plainText: ArrayBuffer | ArrayBufferView
1346
1537
  ): Promise<ArrayBuffer>;
1347
1538
  decrypt(
1348
1539
  algorithm: string | SubtleCryptoEncryptAlgorithm,
1349
1540
  key: CryptoKey,
1350
- cipherText: ArrayBuffer
1541
+ cipherText: ArrayBuffer | ArrayBufferView
1351
1542
  ): Promise<ArrayBuffer>;
1352
1543
  sign(
1353
1544
  algorithm: string | SubtleCryptoSignAlgorithm,
1354
1545
  key: CryptoKey,
1355
- data: ArrayBuffer
1546
+ data: ArrayBuffer | ArrayBufferView
1356
1547
  ): Promise<ArrayBuffer>;
1357
1548
  verify(
1358
1549
  algorithm: string | SubtleCryptoSignAlgorithm,
1359
1550
  key: CryptoKey,
1360
- signature: ArrayBuffer,
1361
- data: ArrayBuffer
1551
+ signature: ArrayBuffer | ArrayBufferView,
1552
+ data: ArrayBuffer | ArrayBufferView
1362
1553
  ): Promise<boolean>;
1363
1554
  digest(
1364
1555
  algorithm: string | SubtleCryptoHashAlgorithm,
1365
- data: ArrayBuffer
1556
+ data: ArrayBuffer | ArrayBufferView
1366
1557
  ): Promise<ArrayBuffer>;
1367
1558
  generateKey(
1368
1559
  algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
@@ -1397,7 +1588,7 @@ declare abstract class SubtleCrypto {
1397
1588
  ): Promise<ArrayBuffer>;
1398
1589
  unwrapKey(
1399
1590
  format: string,
1400
- wrappedKey: ArrayBuffer,
1591
+ wrappedKey: ArrayBuffer | ArrayBufferView,
1401
1592
  unwrappingKey: CryptoKey,
1402
1593
  unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1403
1594
  unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
@@ -1480,7 +1671,10 @@ declare class TextDecoder {
1480
1671
  label?: "utf-8" | "utf8" | "unicode-1-1-utf-8",
1481
1672
  options?: TextDecoderConstructorOptions
1482
1673
  );
1483
- decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
1674
+ decode(
1675
+ input?: ArrayBuffer | ArrayBufferView,
1676
+ options?: TextDecoderDecodeOptions
1677
+ ): string;
1484
1678
  readonly encoding: string;
1485
1679
  readonly fatal: boolean;
1486
1680
  readonly ignoreBOM: boolean;
@@ -1531,6 +1725,52 @@ declare class URL {
1531
1725
  toJSON(): string;
1532
1726
  }
1533
1727
 
1728
+ declare class URLPattern {
1729
+ constructor(input?: string | URLPatternURLPatternInit, baseURL?: string);
1730
+ readonly protocol: string;
1731
+ readonly username: string;
1732
+ readonly password: string;
1733
+ readonly hostname: string;
1734
+ readonly port: string;
1735
+ readonly pathname: string;
1736
+ readonly search: string;
1737
+ readonly hash: string;
1738
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
1739
+ exec(
1740
+ input?: string | URLPatternURLPatternInit,
1741
+ baseURL?: string
1742
+ ): URLPatternURLPatternResult | null;
1743
+ }
1744
+
1745
+ interface URLPatternURLPatternComponentResult {
1746
+ input: string;
1747
+ groups: Record<string, string>;
1748
+ }
1749
+
1750
+ interface URLPatternURLPatternInit {
1751
+ protocol?: string;
1752
+ username?: string;
1753
+ password?: string;
1754
+ hostname?: string;
1755
+ port?: string;
1756
+ pathname?: string;
1757
+ search?: string;
1758
+ hash?: string;
1759
+ baseURL?: string;
1760
+ }
1761
+
1762
+ interface URLPatternURLPatternResult {
1763
+ inputs: (string | URLPatternURLPatternInit)[];
1764
+ protocol: URLPatternURLPatternComponentResult;
1765
+ username: URLPatternURLPatternComponentResult;
1766
+ password: URLPatternURLPatternComponentResult;
1767
+ hostname: URLPatternURLPatternComponentResult;
1768
+ port: URLPatternURLPatternComponentResult;
1769
+ pathname: URLPatternURLPatternComponentResult;
1770
+ search: URLPatternURLPatternComponentResult;
1771
+ hash: URLPatternURLPatternComponentResult;
1772
+ }
1773
+
1534
1774
  declare class URLSearchParams {
1535
1775
  constructor(init?: URLSearchParamsInit);
1536
1776
  append(name: string, value: string): void;
@@ -1570,16 +1810,26 @@ declare type URLSearchParamsInit =
1570
1810
  */
1571
1811
  declare type URLSearchParamsInitializer = URLSearchParamsInit;
1572
1812
 
1573
- declare abstract class WebSocket extends EventTarget<WebSocketEventMap> {
1813
+ declare class WebSocket extends EventTarget<WebSocketEventMap> {
1814
+ constructor(url: string, protocols?: string[] | string);
1574
1815
  accept(): void;
1575
- send(message: ArrayBuffer | string): void;
1816
+ send(message: ArrayBuffer | ArrayBufferView | string): void;
1576
1817
  close(code?: number, reason?: string): void;
1818
+ static readonly READY_STATE_CONNECTING: number;
1819
+ static readonly READY_STATE_OPEN: number;
1820
+ static readonly READY_STATE_CLOSING: number;
1821
+ static readonly READY_STATE_CLOSED: number;
1822
+ readonly readyState: number;
1823
+ readonly url: string | null;
1824
+ readonly protocol: string | null;
1825
+ readonly extensions: string | null;
1577
1826
  }
1578
1827
 
1579
1828
  declare type WebSocketEventMap = {
1580
1829
  close: CloseEvent;
1581
1830
  message: MessageEvent;
1582
- error: Event;
1831
+ open: Event;
1832
+ error: ErrorEvent;
1583
1833
  };
1584
1834
 
1585
1835
  declare const WebSocketPair: { new (): { 0: WebSocket; 1: WebSocket } };
@@ -1653,6 +1903,8 @@ declare function fetch(
1653
1903
  requestInitr?: RequestInit | Request
1654
1904
  ): Promise<Response>;
1655
1905
 
1906
+ declare const navigator: Navigator;
1907
+
1656
1908
  declare const origin: void;
1657
1909
 
1658
1910
  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.3.1",
3
+ "version": "3.5.1",
4
4
  "description": "TypeScript typings for Cloudflare Workers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,11 +22,11 @@
22
22
  "devDependencies": {
23
23
  "@changesets/changelog-github": "^0.4.2",
24
24
  "@changesets/cli": "^2.18.1",
25
- "@types/marked": "^3.0.0",
25
+ "@types/marked": "^4.0.1",
26
26
  "@types/node": "^16.6.1",
27
27
  "esbuild": "^0.12.22",
28
28
  "esbuild-register": "^3.0.0",
29
- "marked": "^3.0.2",
29
+ "marked": "^4.0.10",
30
30
  "prettier": "^2.5.1",
31
31
  "typescript": "^4.3.5"
32
32
  }