diff --git a/.changeset/2022-08-30.md b/.changeset/2022-08-30.md new file mode 100644 index 00000000..a14db2ad --- /dev/null +++ b/.changeset/2022-08-30.md @@ -0,0 +1,5 @@ +--- +"@cloudflare/workers-types": minor +--- + +Updated auto-generated types @ 2022-08-30 diff --git a/index.d.ts b/index.d.ts index 1ba428d3..7dea8d33 100644 --- a/index.d.ts +++ b/index.d.ts @@ -293,6 +293,29 @@ interface CryptoKeyVoprfKeyAlgorithm { namedCurve: string; } +interface D1Database { + prepare(query: string): D1PreparedStatement; + dump(): Promise; + batch(statements: D1PreparedStatement[]): Promise[]>; + exec(query: string): Promise>; +} + +interface D1PreparedStatement { + bind(...values: any[]): D1PreparedStatement; + first(colName?: string): Promise; + run(): Promise>; + all(): Promise>; + raw(): Promise; +} + +declare type D1Result = { + results?: T[]; + lastRowId: number | null; + changes: number; + duration: number; + error?: string; +}; + declare class DOMException extends Error { constructor(message?: string, name?: string); readonly code: number; @@ -399,7 +422,7 @@ interface DurableObjectSetAlarmOptions { interface DurableObjectState { waitUntil(promise: Promise): void; - readonly id: DurableObjectId | string; + id: DurableObjectId; readonly storage: DurableObjectStorage; blockConcurrencyWhile(callback: () => Promise): Promise; } @@ -464,7 +487,10 @@ interface DurableObjectStub extends Fetcher { } interface DurableObjectTransaction { - get(key: string, options?: DurableObjectGetOptions): Promise; + get( + key: string, + options?: DurableObjectGetOptions + ): Promise; get( keys: string[], options?: DurableObjectGetOptions @@ -597,6 +623,10 @@ interface EventTargetEventListenerOptions { capture?: boolean; } +interface EventTargetHandlerObject { + handleEvent(arg1: Event): any | undefined; +} + interface ExecutionContext { waitUntil(promise: Promise): void; passThroughOnException(): void; @@ -664,7 +694,7 @@ declare class FormData { set(name: string, value: Blob, filename?: string): void; entries(): IterableIterator<[key: string, value: File | string]>; keys(): IterableIterator; - values(): IterableIterator; + values(): IterableIterator; forEach( callback: ( this: This, @@ -768,6 +798,7 @@ interface IncomingRequestCfProperties { */ country: string; httpProtocol: string; + isEUCountry?: string; latitude?: string; longitude?: string; /** @@ -805,9 +836,13 @@ interface IncomingRequestCfPropertiesBotManagement { interface IncomingRequestCfPropertiesTLSClientAuth { certIssuerDNLegacy: string; certIssuerDN: string; + certIssuerDNRFC2253: string; + certIssuerSKI: string; + certIssuerSerial: string; certPresented: "0" | "1"; certSubjectDNLegacy: string; certSubjectDN: string; + certSubjectDNRFC2253: string; /** * In format "Dec 22 19:39:00 2018 GMT" */ @@ -822,6 +857,8 @@ interface IncomingRequestCfPropertiesTLSClientAuth { * "SUCCESS", "FAILED:reason", "NONE" */ certVerified: string; + certRevoked: string; + certSKI: string; } interface JsonWebKey { @@ -1042,6 +1079,7 @@ interface R2Conditional { etagDoesNotMatch?: string; uploadedBefore?: Date; uploadedAfter?: Date; + secondsGranularity?: boolean; } /** @@ -1049,7 +1087,7 @@ interface R2Conditional { */ interface R2GetOptions { onlyIf?: R2Conditional | Headers; - range?: R2Range; + range?: R2Range | Headers; } /** @@ -1077,6 +1115,7 @@ interface R2ListOptions { prefix?: string; cursor?: string; delimiter?: string; + startAfter?: string; /** * If you populate this array, then items returned will include this metadata. * A tradeoff is that fewer results may be returned depending on how big this @@ -1103,8 +1142,8 @@ declare abstract class R2Object { readonly etag: string; readonly httpEtag: string; readonly uploaded: Date; - readonly httpMetadata: R2HTTPMetadata; - readonly customMetadata: Record; + readonly httpMetadata?: R2HTTPMetadata; + readonly customMetadata?: Record; readonly range?: R2Range; writeHttpMetadata(headers: Headers): void; } @@ -1624,6 +1663,10 @@ declare abstract class SubtleCrypto { extractable: boolean, keyUsages: string[] ): Promise; + timingSafeEqual( + a: ArrayBuffer | ArrayBufferView, + b: ArrayBuffer | ArrayBufferView + ): boolean; } interface SubtleCryptoDeriveKeyAlgorithm { @@ -1718,6 +1761,14 @@ interface TextDecoderDecodeOptions { stream: boolean; } +declare class TextDecoderStream extends TransformStream { + constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit); +} + +interface TextDecoderStreamTextDecoderStreamInit { + fatal?: boolean; +} + declare class TextEncoder { constructor(); encode(input?: string): Uint8Array; @@ -1730,6 +1781,10 @@ interface TextEncoderEncodeIntoResult { written: number; } +declare class TextEncoderStream extends TransformStream { + constructor(); +} + declare class TransformStream { constructor( maybeTransformer?: Transformer, diff --git a/src/workers.json b/src/workers.json index 82986210..4abf16c9 100644 --- a/src/workers.json +++ b/src/workers.json @@ -1505,6 +1505,325 @@ ], "kind": "struct" }, + "D1Database": { + "name": "D1Database", + "members": [ + { + "name": "prepare", + "type": { + "params": [ + { + "name": "query", + "type": { + "name": "string" + } + } + ], + "returns": { + "name": "D1PreparedStatement" + } + } + }, + { + "name": "dump", + "type": { + "params": [], + "returns": { + "name": "Promise", + "args": [ + { + "name": "ArrayBuffer" + } + ] + } + } + }, + { + "name": "batch", + "type": { + "params": [ + { + "name": "statements", + "type": { + "name": "[]", + "args": [ + { + "name": "D1PreparedStatement" + } + ] + } + } + ], + "returns": { + "name": "Promise", + "args": [ + { + "name": "[]", + "args": [ + { + "name": "D1Result", + "args": [ + { + "name": "T" + } + ] + } + ] + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + }, + { + "name": "exec", + "type": { + "params": [ + { + "name": "query", + "type": { + "name": "string" + } + } + ], + "returns": { + "name": "Promise", + "args": [ + { + "name": "D1Result", + "args": [ + { + "name": "T" + } + ] + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + } + ], + "kind": "class" + }, + "D1PreparedStatement": { + "name": "D1PreparedStatement", + "members": [ + { + "name": "bind", + "type": { + "params": [ + { + "name": "values", + "type": { + "name": "[]", + "args": [ + { + "name": "any" + } + ], + "variadic": true + } + } + ], + "returns": { + "name": "D1PreparedStatement" + } + } + }, + { + "name": "first", + "type": { + "params": [ + { + "name": "colName", + "type": { + "name": "string", + "optional": true + } + } + ], + "returns": { + "name": "Promise", + "args": [ + { + "name": "T" + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + }, + { + "name": "run", + "type": { + "params": [], + "returns": { + "name": "Promise", + "args": [ + { + "name": "D1Result", + "args": [ + { + "name": "T" + } + ] + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + }, + { + "name": "all", + "type": { + "params": [], + "returns": { + "name": "Promise", + "args": [ + { + "name": "D1Result", + "args": [ + { + "name": "[]", + "args": [ + { + "name": "T" + } + ] + } + ] + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + }, + { + "name": "raw", + "type": { + "params": [], + "returns": { + "name": "Promise", + "args": [ + { + "name": "[]", + "args": [ + { + "name": "T" + } + ] + } + ] + } + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ] + } + ], + "kind": "class" + }, + "D1Result": { + "name": "D1Result", + "type": { + "members": [ + { + "name": "results", + "type": { + "name": "[]", + "args": [ + { + "name": "T" + } + ], + "optional": true + } + }, + { + "name": "lastRowId", + "type": { + "name": "|", + "args": [ + { + "name": "number" + }, + { + "name": "null" + } + ] + } + }, + { + "name": "changes", + "type": { + "name": "number" + } + }, + { + "name": "duration", + "type": { + "name": "number" + } + }, + { + "name": "error", + "type": { + "name": "string", + "optional": true + } + } + ] + }, + "typeparams": [ + { + "name": "T", + "default": { + "name": "unknown" + } + } + ], + "kind": "typedef" + }, "DOMException": { "name": "DOMException", "members": [ @@ -2242,17 +2561,8 @@ { "name": "id", "type": { - "name": "|", - "args": [ - { - "name": "DurableObjectId" - }, - { - "name": "string" - } - ] - }, - "readonly": true + "name": "DurableObjectId" + } }, { "name": "storage", @@ -2803,7 +3113,15 @@ "name": "Promise", "args": [ { - "name": "T" + "name": "|", + "args": [ + { + "name": "T" + }, + { + "name": "undefined" + } + ] } ] } @@ -4100,6 +4418,29 @@ ], "kind": "struct" }, + "EventTargetHandlerObject": { + "name": "EventTargetHandlerObject", + "members": [ + { + "name": "handleEvent", + "type": { + "params": [ + { + "name": "arg1", + "type": { + "name": "Event" + } + } + ], + "returns": { + "name": "any", + "optional": true + } + } + } + ], + "kind": "struct" + }, "ExecutionContext": { "name": "ExecutionContext", "members": [ @@ -4794,10 +5135,10 @@ "name": "|", "args": [ { - "name": "File" + "name": "string" }, { - "name": "string" + "name": "File" } ] } @@ -5642,6 +5983,13 @@ "name": "string" } }, + { + "name": "isEUCountry", + "type": { + "name": "string", + "optional": true + } + }, { "name": "latitude", "type": { @@ -5775,6 +6123,24 @@ "name": "string" } }, + { + "name": "certIssuerDNRFC2253", + "type": { + "name": "string" + } + }, + { + "name": "certIssuerSKI", + "type": { + "name": "string" + } + }, + { + "name": "certIssuerSerial", + "type": { + "name": "string" + } + }, { "name": "certPresented", "type": { @@ -5801,6 +6167,12 @@ "name": "string" } }, + { + "name": "certSubjectDNRFC2253", + "type": { + "name": "string" + } + }, { "name": "certNotBefore", "type": { @@ -5839,6 +6211,18 @@ "comment": { "text": "\"SUCCESS\", \"FAILED:reason\", \"NONE\"" } + }, + { + "name": "certRevoked", + "type": { + "name": "string" + } + }, + { + "name": "certSKI", + "type": { + "name": "string" + } } ], "kind": "struct" @@ -7576,6 +7960,13 @@ "name": "Date", "optional": true } + }, + { + "name": "secondsGranularity", + "type": { + "name": "boolean", + "optional": true + } } ], "comment": { @@ -7605,7 +7996,15 @@ { "name": "range", "type": { - "name": "R2Range", + "name": "|", + "args": [ + { + "name": "R2Range" + }, + { + "name": "Headers" + } + ], "optional": true } } @@ -7699,6 +8098,13 @@ "optional": true } }, + { + "name": "startAfter", + "type": { + "name": "string", + "optional": true + } + }, { "name": "include", "type": { @@ -7777,7 +8183,8 @@ { "name": "httpMetadata", "type": { - "name": "R2HTTPMetadata" + "name": "R2HTTPMetadata", + "optional": true }, "readonly": true }, @@ -7792,7 +8199,8 @@ { "name": "string" } - ] + ], + "optional": true }, "readonly": true }, @@ -10422,6 +10830,32 @@ "static": true, "readonly": true }, + { + "name": "TextEncoderStream", + "type": { + "name": "typeof", + "args": [ + { + "name": "TextEncoderStream" + } + ] + }, + "static": true, + "readonly": true + }, + { + "name": "TextDecoderStream", + "type": { + "name": "typeof", + "args": [ + { + "name": "TextDecoderStream" + } + ] + }, + "static": true, + "readonly": true + }, { "name": "Headers", "type": { @@ -11430,6 +11864,28 @@ ] } } + }, + { + "name": "timingSafeEqual", + "type": { + "params": [ + { + "name": "a", + "type": { + "name": "ArrayBuffer|ArrayBufferView" + } + }, + { + "name": "b", + "type": { + "name": "ArrayBuffer|ArrayBufferView" + } + } + ], + "returns": { + "name": "boolean" + } + } } ], "kind": "class" @@ -11939,6 +12395,51 @@ ], "kind": "struct" }, + "TextDecoderStream": { + "name": "TextDecoderStream", + "members": [ + { + "name": "constructor", + "type": { + "params": [ + { + "name": "label", + "type": { + "name": "string", + "optional": true + } + }, + { + "name": "options", + "type": { + "name": "TextDecoderStreamTextDecoderStreamInit", + "optional": true + } + } + ] + } + } + ], + "extends": [ + { + "name": "TransformStream" + } + ], + "kind": "class" + }, + "TextDecoderStreamTextDecoderStreamInit": { + "name": "TextDecoderStreamTextDecoderStreamInit", + "members": [ + { + "name": "fatal", + "type": { + "name": "boolean", + "optional": true + } + } + ], + "kind": "struct" + }, "TextEncoder": { "name": "TextEncoder", "members": [ @@ -12015,6 +12516,23 @@ ], "kind": "struct" }, + "TextEncoderStream": { + "name": "TextEncoderStream", + "members": [ + { + "name": "constructor", + "type": { + "params": [] + } + } + ], + "extends": [ + { + "name": "TransformStream" + } + ], + "kind": "class" + }, "TransformStream": { "name": "TransformStream", "members": [