summaryrefslogtreecommitdiff
path: root/ext/fetch/internal.d.ts
blob: af1c3715262a8519488a213458439ca73eea96ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

// deno-lint-ignore-file no-explicit-any no-var

/// <reference no-default-lib="true" />
/// <reference lib="esnext" />

declare namespace globalThis {
  declare namespace __bootstrap {
    declare var fetchUtil: {
      requiredArguments(name: string, length: number, required: number): void;
    };

    declare var domIterable: {
      DomIterableMixin(base: any, dataSymbol: symbol): any;
    };

    declare namespace headers {
      class Headers {
      }
      type HeaderList = [string, string][];
      function headersFromHeaderList(
        list: HeaderList,
        guard:
          | "immutable"
          | "request"
          | "request-no-cors"
          | "response"
          | "none",
      ): Headers;
      function headerListFromHeaders(headers: Headers): HeaderList;
      function fillHeaders(headers: Headers, object: HeadersInit): void;
      function getDecodeSplitHeader(
        list: HeaderList,
        name: string,
      ): string[] | null;
      function guardFromHeaders(
        headers: Headers,
      ): "immutable" | "request" | "request-no-cors" | "response" | "none";
    }

    declare namespace formData {
      declare type FormData = typeof FormData;
      declare function formDataToBlob(
        formData: globalThis.FormData,
      ): Blob;
      declare function parseFormData(
        body: Uint8Array,
        boundary: string | undefined,
      ): FormData;
      declare function formDataFromEntries(entries: FormDataEntry[]): FormData;
    }

    declare namespace fetchBody {
      function mixinBody(
        prototype: any,
        bodySymbol: symbol,
        mimeTypeSymbol: symbol,
      ): void;
      class InnerBody {
        constructor(stream?: ReadableStream<Uint8Array>);
        stream: ReadableStream<Uint8Array>;
        source: null | Uint8Array | Blob | FormData;
        length: null | number;
        unusable(): boolean;
        consume(): Promise<Uint8Array>;
        clone(): InnerBody;
      }
      function extractBody(object: BodyInit): {
        body: InnerBody;
        contentType: string | null;
      };
    }

    declare namespace fetch {
      function toInnerRequest(request: Request): InnerRequest;
      function fromInnerRequest(
        inner: InnerRequest,
        signal: AbortSignal | null,
        guard:
          | "request"
          | "immutable"
          | "request-no-cors"
          | "response"
          | "none",
      ): Request;
      function redirectStatus(status: number): boolean;
      function nullBodyStatus(status: number): boolean;
      function newInnerRequest(
        method: string,
        url: any,
        headerList?: [string, string][],
        body?: globalThis.__bootstrap.fetchBody.InnerBody,
      ): InnerResponse;
      function toInnerResponse(response: Response): InnerResponse;
      function fromInnerResponse(
        inner: InnerResponse,
        guard:
          | "request"
          | "immutable"
          | "request-no-cors"
          | "response"
          | "none",
      ): Response;
      function networkError(error: string): InnerResponse;
    }
  }
}