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

Commit

Permalink
Updated types for 2022-01-15 (#181)
Browse files Browse the repository at this point in the history
* Updated types for 2022-01-15

* run prettier on all files

* add a changeset

Co-authored-by: autodecl-bot[bot] <91285878+autodecl-bot[bot]@users.noreply.github.com>
Co-authored-by: Sunil Pai <spai@cloudflare.com>
  • Loading branch information
autodecl-bot[bot] and threepointone authored Jan 18, 2022
1 parent 771ce75 commit 0dc3fe4
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-pigs-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-types": patch
---

Updated auto-generated types @ 2022-01-15
67 changes: 41 additions & 26 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<K extends string = string> {
get(
key: string,
key: K,
options?: Partial<KVNamespaceGetOptions<undefined>>
): Promise<string | null>;
get(key: string, type: "text"): Promise<string | null>;
get(key: K, type: "text"): Promise<string | null>;
get<ExpectedValue = unknown>(
key: string,
key: K,
type: "json"
): Promise<ExpectedValue | null>;
get(key: string, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
get(key: string, type: "stream"): Promise<ReadableStream | null>;
get(
key: string,
options: KVNamespaceGetOptions<"text">
): Promise<string | null>;
get(key: K, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
get(key: K, type: "stream"): Promise<ReadableStream | null>;
get(key: K, options: KVNamespaceGetOptions<"text">): Promise<string | null>;
get<ExpectedValue = unknown>(
key: string,
options: KVNamespaceGetOptions<"json">
): Promise<ExpectedValue | null>;
get(
key: string,
key: K,
options: KVNamespaceGetOptions<"arrayBuffer">
): Promise<ArrayBuffer | null>;
get(
key: string,
key: K,
options: KVNamespaceGetOptions<"stream">
): Promise<ReadableStream | null>;
list<Metadata = unknown>(
Expand All @@ -818,44 +823,44 @@ interface KVNamespace {
* await NAMESPACE.put(key, value)
*/
put(
key: string,
key: K,
value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
options?: KVNamespacePutOptions
): Promise<void>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
options?: Partial<KVNamespaceGetOptions<undefined>>
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
type: "text"
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: string,
key: K,
type: "json"
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
type: "arrayBuffer"
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
type: "stream"
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
options: KVNamespaceGetOptions<"text">
): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
key: string,
key: K,
options: KVNamespaceGetOptions<"json">
): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
options: KVNamespaceGetOptions<"arrayBuffer">
): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
getWithMetadata<Metadata = unknown>(
key: string,
key: K,
options: KVNamespaceGetOptions<"stream">
): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
delete(name: string): Promise<void>;
Expand Down Expand Up @@ -930,7 +935,7 @@ interface ReadResult {
done: boolean;
}

interface ReadableByteStreamController {
declare abstract class ReadableByteStreamController {
readonly byobRequest: ReadableStreamBYOBRequest | null;
readonly desiredSize: number | null;
close(): void;
Expand All @@ -950,6 +955,12 @@ declare class ReadableStream {
): ReadableStream;
pipeTo(destination: WritableStream, options?: PipeToOptions): Promise<void>;
tee(): [ReadableStream, ReadableStream];
values(
options?: ReadableStreamValuesOptions
): AsyncIterableIterator<ReadableStreamReadResult>;
[Symbol.asyncIterator](
options?: ReadableStreamValuesOptions
): AsyncIterableIterator<ReadableStreamReadResult>;
}

declare class ReadableStreamBYOBReader {
Expand All @@ -966,14 +977,14 @@ declare class ReadableStreamBYOBReader {
): Promise<ReadableStreamReadResult<Uint8Array>>;
}

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1586,7 +1601,7 @@ declare class WritableStream {
getWriter(): WritableStreamDefaultWriter;
}

interface WritableStreamDefaultController {
declare abstract class WritableStreamDefaultController {
readonly signal: AbortSignal;
error(reason?: any): void;
}
Expand Down
Loading

0 comments on commit 0dc3fe4

Please sign in to comment.