diff --git a/.changeset/short-pigs-collect.md b/.changeset/short-pigs-collect.md new file mode 100644 index 00000000..597da2e5 --- /dev/null +++ b/.changeset/short-pigs-collect.md @@ -0,0 +1,5 @@ +--- +"@cloudflare/workers-types": patch +--- + +Updated auto-generated types @ 2022-01-15 diff --git a/index.d.ts b/index.d.ts index 131161d3..ab63298a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -463,6 +463,14 @@ interface Element { remove(): Element; removeAndKeepContent(): Element; setInnerContent(content: Content, options?: ContentOptions): Element; + onEndTag(handler: Function): void; +} + +interface EndTag { + name: string; + before(content: Content, options?: ContentOptions): EndTag; + after(content: Content, options?: ContentOptions): EndTag; + remove(): EndTag; } declare class Event { @@ -778,32 +786,29 @@ interface JsonWebKey { * Workers KV is a global, low-latency, key-value data store. It supports exceptionally high read volumes with low-latency, * making it possible to build highly dynamic APIs and websites which respond as quickly as a cached static file would. */ -interface KVNamespace { +interface KVNamespace { get( - key: string, + key: K, options?: Partial> ): Promise; - get(key: string, type: "text"): Promise; + get(key: K, type: "text"): Promise; get( - key: string, + key: K, type: "json" ): Promise; - get(key: string, type: "arrayBuffer"): Promise; - get(key: string, type: "stream"): Promise; - get( - key: string, - options: KVNamespaceGetOptions<"text"> - ): Promise; + get(key: K, type: "arrayBuffer"): Promise; + get(key: K, type: "stream"): Promise; + get(key: K, options: KVNamespaceGetOptions<"text">): Promise; get( key: string, options: KVNamespaceGetOptions<"json"> ): Promise; get( - key: string, + key: K, options: KVNamespaceGetOptions<"arrayBuffer"> ): Promise; get( - key: string, + key: K, options: KVNamespaceGetOptions<"stream"> ): Promise; list( @@ -818,44 +823,44 @@ interface KVNamespace { * await NAMESPACE.put(key, value) */ put( - key: string, + key: K, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions ): Promise; getWithMetadata( - key: string, + key: K, options?: Partial> ): Promise>; getWithMetadata( - key: string, + key: K, type: "text" ): Promise>; getWithMetadata( - key: string, + key: K, type: "json" ): Promise>; getWithMetadata( - key: string, + key: K, type: "arrayBuffer" ): Promise>; getWithMetadata( - key: string, + key: K, type: "stream" ): Promise>; getWithMetadata( - key: string, + key: K, options: KVNamespaceGetOptions<"text"> ): Promise>; getWithMetadata( - key: string, + key: K, options: KVNamespaceGetOptions<"json"> ): Promise>; getWithMetadata( - key: string, + key: K, options: KVNamespaceGetOptions<"arrayBuffer"> ): Promise>; getWithMetadata( - key: string, + key: K, options: KVNamespaceGetOptions<"stream"> ): Promise>; delete(name: string): Promise; @@ -930,7 +935,7 @@ interface ReadResult { done: boolean; } -interface ReadableByteStreamController { +declare abstract class ReadableByteStreamController { readonly byobRequest: ReadableStreamBYOBRequest | null; readonly desiredSize: number | null; close(): void; @@ -950,6 +955,12 @@ declare class ReadableStream { ): ReadableStream; pipeTo(destination: WritableStream, options?: PipeToOptions): Promise; tee(): [ReadableStream, ReadableStream]; + values( + options?: ReadableStreamValuesOptions + ): AsyncIterableIterator; + [Symbol.asyncIterator]( + options?: ReadableStreamValuesOptions + ): AsyncIterableIterator; } declare class ReadableStreamBYOBReader { @@ -966,14 +977,14 @@ declare class ReadableStreamBYOBReader { ): Promise>; } -interface ReadableStreamBYOBRequest { +declare abstract class ReadableStreamBYOBRequest { readonly view: Uint8Array | null; respond(bytesWritten: number): void; respondWithNewView(view: ArrayBufferView): void; readonly atLeast: number | null; } -interface ReadableStreamDefaultController { +declare abstract class ReadableStreamDefaultController { readonly desiredSize: number | null; close(): void; enqueue(chunk?: any): void; @@ -1020,6 +1031,10 @@ interface ReadableStreamTransform { readable: ReadableStream; } +interface ReadableStreamValuesOptions { + preventCancel?: boolean; +} + declare class Request extends Body { constructor(input: Request | string, init?: RequestInit | Request); clone(): Request; @@ -1586,7 +1601,7 @@ declare class WritableStream { getWriter(): WritableStreamDefaultWriter; } -interface WritableStreamDefaultController { +declare abstract class WritableStreamDefaultController { readonly signal: AbortSignal; error(reason?: any): void; } diff --git a/src/workers.json b/src/workers.json index 056c377f..ca030df1 100644 --- a/src/workers.json +++ b/src/workers.json @@ -3030,6 +3030,89 @@ "name": "Element" } } + }, + { + "name": "onEndTag", + "type": { + "params": [ + { + "name": "handler", + "type": { + "name": "Function" + } + } + ], + "returns": { + "name": "void" + } + } + } + ], + "kind": "class" + }, + "EndTag": { + "name": "EndTag", + "members": [ + { + "name": "name", + "type": { + "name": "string" + } + }, + { + "name": "before", + "type": { + "params": [ + { + "name": "content", + "type": { + "name": "Content" + } + }, + { + "name": "options", + "type": { + "name": "ContentOptions", + "optional": true + } + } + ], + "returns": { + "name": "EndTag" + } + } + }, + { + "name": "after", + "type": { + "params": [ + { + "name": "content", + "type": { + "name": "Content" + } + }, + { + "name": "options", + "type": { + "name": "ContentOptions", + "optional": true + } + } + ], + "returns": { + "name": "EndTag" + } + } + }, + { + "name": "remove", + "type": { + "params": [], + "returns": { + "name": "EndTag" + } + } } ], "kind": "class" @@ -5417,7 +5500,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5463,7 +5546,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5498,7 +5581,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5541,7 +5624,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5576,7 +5659,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5611,7 +5694,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5699,7 +5782,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5739,7 +5822,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5814,7 +5897,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5881,7 +5964,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5935,7 +6018,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -5978,7 +6061,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6027,7 +6110,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6070,7 +6153,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6113,7 +6196,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6161,7 +6244,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6215,7 +6298,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6263,7 +6346,7 @@ { "name": "key", "type": { - "name": "string" + "name": "K" } }, { @@ -6326,6 +6409,17 @@ } } ], + "typeparams": [ + { + "name": "K", + "constraint": { + "name": "string" + }, + "default": { + "name": "string" + } + } + ], "comment": { "text": "Workers KV is a global, low-latency, key-value data store. It supports exceptionally high read volumes with low-latency,\nmaking it possible to build highly dynamic APIs and websites which respond as quickly as a cached static file would." }, @@ -6930,6 +7024,50 @@ ] } } + }, + { + "name": "values", + "type": { + "params": [ + { + "name": "options", + "type": { + "name": "ReadableStreamValuesOptions", + "optional": true + } + } + ], + "returns": { + "name": "AsyncIterableIterator", + "args": [ + { + "name": "ReadableStreamReadResult" + } + ] + } + } + }, + { + "name": "[Symbol.asyncIterator]", + "type": { + "params": [ + { + "name": "options", + "type": { + "name": "ReadableStreamValuesOptions", + "optional": true + } + } + ], + "returns": { + "name": "AsyncIterableIterator", + "args": [ + { + "name": "ReadableStreamReadResult" + } + ] + } + } } ], "kind": "class" @@ -7386,6 +7524,19 @@ ], "kind": "struct" }, + "ReadableStreamValuesOptions": { + "name": "ReadableStreamValuesOptions", + "members": [ + { + "name": "preventCancel", + "type": { + "name": "boolean", + "optional": true + } + } + ], + "kind": "struct" + }, "Request": { "name": "Request", "members": [ @@ -8835,6 +8986,58 @@ "static": true, "readonly": true }, + { + "name": "ReadableStreamBYOBRequest", + "type": { + "name": "typeof", + "args": [ + { + "name": "ReadableStreamBYOBRequest" + } + ] + }, + "static": true, + "readonly": true + }, + { + "name": "ReadableStreamDefaultController", + "type": { + "name": "typeof", + "args": [ + { + "name": "ReadableStreamDefaultController" + } + ] + }, + "static": true, + "readonly": true + }, + { + "name": "ReadableByteStreamController", + "type": { + "name": "typeof", + "args": [ + { + "name": "ReadableByteStreamController" + } + ] + }, + "static": true, + "readonly": true + }, + { + "name": "WritableStreamDefaultController", + "type": { + "name": "typeof", + "args": [ + { + "name": "WritableStreamDefaultController" + } + ] + }, + "static": true, + "readonly": true + }, { "name": "Headers", "type": {