Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit f498fd9

Browse files
autodecl-bot[bot]vlovich
autodecl-bot[bot]
authored andcommitted
Updated types for 2022-04-13
1 parent bc61b8d commit f498fd9

File tree

3 files changed

+1546
-59
lines changed

3 files changed

+1546
-59
lines changed

.changeset/2022-04-13.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/workers-types": minor
3+
---
4+
5+
Updated auto-generated types @ 2022-04-13

index.d.ts

+205-18
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ declare type BodyInit =
128128
*/
129129
declare type BodyInitializer = BodyInit;
130130

131+
declare class ByteLengthQueuingStrategy {
132+
constructor(init: QueuingStrategyInit);
133+
readonly highWaterMark: number;
134+
size(arg1?: any): number | undefined;
135+
}
136+
131137
declare abstract class Cache {
132138
delete(
133139
request: Request | string,
@@ -187,6 +193,10 @@ interface Comment {
187193
remove(): Comment;
188194
}
189195

196+
declare class CompressionStream extends TransformStream {
197+
constructor(format: string);
198+
}
199+
190200
interface Console {
191201
debug(...data: any[]): void;
192202
error(...data: any[]): void;
@@ -201,6 +211,12 @@ interface ContentOptions {
201211
html?: boolean;
202212
}
203213

214+
declare class CountQueuingStrategy {
215+
constructor(init: QueuingStrategyInit);
216+
readonly highWaterMark: number;
217+
size(arg1?: any): number | undefined;
218+
}
219+
204220
declare abstract class Crypto {
205221
readonly subtle: SubtleCrypto;
206222
getRandomValues<
@@ -306,6 +322,10 @@ declare class DOMException extends Error {
306322
static readonly DATA_CLONE_ERR: number;
307323
}
308324

325+
declare class DecompressionStream extends TransformStream {
326+
constructor(format: string);
327+
}
328+
309329
declare class DigestStream extends WritableStream {
310330
constructor(algorithm: string | SubtleCryptoHashAlgorithm);
311331
readonly digest: Promise<ArrayBuffer>;
@@ -325,6 +345,10 @@ interface DurableObject {
325345
fetch(request: Request): Promise<Response>;
326346
}
327347

348+
interface DurableObjectGetAlarmOptions {
349+
allowConcurrency?: boolean;
350+
}
351+
328352
interface DurableObjectGetOptions {
329353
allowConcurrency?: boolean;
330354
noCache?: boolean;
@@ -365,6 +389,11 @@ interface DurableObjectPutOptions {
365389
noCache?: boolean;
366390
}
367391

392+
interface DurableObjectSetAlarmOptions {
393+
allowConcurrency?: boolean;
394+
allowUnconfirmed?: boolean;
395+
}
396+
368397
interface DurableObjectState {
369398
waitUntil(promise: Promise<any>): void;
370399
readonly id: DurableObjectId | string;
@@ -399,24 +428,26 @@ interface DurableObjectStorage {
399428
transaction<T>(
400429
closure: (txn: DurableObjectTransaction) => Promise<T>
401430
): Promise<T>;
431+
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<Date | null>;
432+
setAlarm(arg2: Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
402433
}
403434

404435
/**
405436
*
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.
407438
*/
408439
declare type DurableObjectStorageOperationsGetOptions = DurableObjectGetOptions;
409440

410441
/**
411442
*
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.
413444
*/
414445
declare type DurableObjectStorageOperationsListOptions =
415446
DurableObjectListOptions;
416447

417448
/**
418449
*
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.
420451
*/
421452
declare type DurableObjectStorageOperationsPutOptions = DurableObjectPutOptions;
422453

@@ -446,6 +477,8 @@ interface DurableObjectTransaction {
446477
delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
447478
delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
448479
rollback(): void;
480+
getAlarm(options?: DurableObjectGetAlarmOptions): Promise<Date | null>;
481+
setAlarm(arg2: Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
449482
}
450483

451484
interface Element {
@@ -601,7 +634,7 @@ interface FileOptions {
601634
}
602635

603636
declare class FixedLengthStream extends TransformStream {
604-
constructor(expectedLength: number);
637+
constructor(expectedLength: number | bigint);
605638
}
606639

607640
declare class FormData {
@@ -681,6 +714,10 @@ declare type HeadersInit =
681714
*/
682715
declare type HeadersInitializer = HeadersInit;
683716

717+
declare class IdentityTransformStream extends TransformStream {
718+
constructor();
719+
}
720+
684721
/**
685722
* In addition to the properties on the standard Request object,
686723
* the cf object contains extra information about the request provided
@@ -944,6 +981,141 @@ declare abstract class PromiseRejectionEvent extends Event {
944981
readonly reason: any;
945982
}
946983

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+
9471119
interface ReadResult {
9481120
value?: any;
9491121
done: boolean;
@@ -969,12 +1141,10 @@ declare class ReadableStream {
9691141
): ReadableStream;
9701142
pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
9711143
tee(): [ReadableStream, ReadableStream];
972-
values(
973-
options?: ReadableStreamValuesOptions
974-
): AsyncIterableIterator<ReadableStreamReadResult>;
1144+
values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<any>;
9751145
[Symbol.asyncIterator](
9761146
options?: ReadableStreamValuesOptions
977-
): AsyncIterableIterator<ReadableStreamReadResult>;
1147+
): AsyncIterableIterator<any>;
9781148
}
9791149

9801150
declare class ReadableStreamBYOBReader {
@@ -1357,27 +1527,27 @@ declare abstract class SubtleCrypto {
13571527
encrypt(
13581528
algorithm: string | SubtleCryptoEncryptAlgorithm,
13591529
key: CryptoKey,
1360-
plainText: ArrayBuffer
1530+
plainText: ArrayBuffer | ArrayBufferView
13611531
): Promise<ArrayBuffer>;
13621532
decrypt(
13631533
algorithm: string | SubtleCryptoEncryptAlgorithm,
13641534
key: CryptoKey,
1365-
cipherText: ArrayBuffer
1535+
cipherText: ArrayBuffer | ArrayBufferView
13661536
): Promise<ArrayBuffer>;
13671537
sign(
13681538
algorithm: string | SubtleCryptoSignAlgorithm,
13691539
key: CryptoKey,
1370-
data: ArrayBuffer
1540+
data: ArrayBuffer | ArrayBufferView
13711541
): Promise<ArrayBuffer>;
13721542
verify(
13731543
algorithm: string | SubtleCryptoSignAlgorithm,
13741544
key: CryptoKey,
1375-
signature: ArrayBuffer,
1376-
data: ArrayBuffer
1545+
signature: ArrayBuffer | ArrayBufferView,
1546+
data: ArrayBuffer | ArrayBufferView
13771547
): Promise<boolean>;
13781548
digest(
13791549
algorithm: string | SubtleCryptoHashAlgorithm,
1380-
data: ArrayBuffer
1550+
data: ArrayBuffer | ArrayBufferView
13811551
): Promise<ArrayBuffer>;
13821552
generateKey(
13831553
algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
@@ -1412,7 +1582,7 @@ declare abstract class SubtleCrypto {
14121582
): Promise<ArrayBuffer>;
14131583
unwrapKey(
14141584
format: string,
1415-
wrappedKey: ArrayBuffer,
1585+
wrappedKey: ArrayBuffer | ArrayBufferView,
14161586
unwrappingKey: CryptoKey,
14171587
unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
14181588
unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
@@ -1495,7 +1665,10 @@ declare class TextDecoder {
14951665
label?: "utf-8" | "utf8" | "unicode-1-1-utf-8",
14961666
options?: TextDecoderConstructorOptions
14971667
);
1498-
decode(input?: ArrayBuffer, options?: TextDecoderDecodeOptions): string;
1668+
decode(
1669+
input?: ArrayBuffer | ArrayBufferView,
1670+
options?: TextDecoderDecodeOptions
1671+
): string;
14991672
readonly encoding: string;
15001673
readonly fatal: boolean;
15011674
readonly ignoreBOM: boolean;
@@ -1631,12 +1804,26 @@ declare type URLSearchParamsInit =
16311804
*/
16321805
declare type URLSearchParamsInitializer = URLSearchParamsInit;
16331806

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+
}
16351821

16361822
declare type WebSocketEventMap = {
16371823
close: CloseEvent;
16381824
message: MessageEvent;
1639-
error: Event;
1825+
open: Event;
1826+
error: ErrorEvent;
16401827
};
16411828

16421829
declare const WebSocketPair: { new (): { 0: WebSocket; 1: WebSocket } };

0 commit comments

Comments
 (0)