@discordjs/rest 3.0.0-dev.1786968995-99af6d8be → 3.0.0-dev.1788538586-ecea9ed57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +32 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -4
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/undiciRequest.d.mts +13 -3
- package/dist/strategies/undiciRequest.d.ts +13 -3
- package/dist/strategies/undiciRequest.js +17 -1
- package/dist/strategies/undiciRequest.js.map +1 -1
- package/dist/strategies/undiciRequest.mjs +16 -1
- package/dist/strategies/undiciRequest.mjs.map +1 -1
- package/dist/web.d.mts +4 -2
- package/dist/web.d.ts +4 -2
- package/dist/web.js +17 -3
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +17 -3
- package/dist/web.mjs.map +1 -1
- package/package.json +17 -17
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import { Response, request, RequestInit } from 'undici';
|
|
1
|
+
import { Response, Headers, request, RequestInit } from 'undici';
|
|
2
|
+
import { IncomingHttpHeaders } from 'undici/types/header.js';
|
|
2
3
|
import { Readable } from 'node:stream';
|
|
3
4
|
import { ReadableStream } from 'node:stream/web';
|
|
4
5
|
|
|
5
|
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | '
|
|
6
|
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
|
6
7
|
body: Readable | ReadableStream | null;
|
|
8
|
+
clone?(): ResponseLike;
|
|
9
|
+
headers: Pick<Headers, typeof Symbol.iterator | 'get' | 'has'>;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
|
10
13
|
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
|
11
14
|
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
|
15
|
+
/**
|
|
16
|
+
* @privateRemarks
|
|
17
|
+
*
|
|
18
|
+
* Under HTTP/2, Node.js attaches the symbol `sensitiveHeaders` to the headers object,
|
|
19
|
+
* which the `Headers` constructor rejects. Hence the manual construction of the `Headers` object here.
|
|
20
|
+
*/
|
|
21
|
+
declare function buildHeaders(headers: IncomingHttpHeaders): Headers;
|
|
12
22
|
|
|
13
|
-
export { type RequestOptions, makeRequest, resolveBody };
|
|
23
|
+
export { type RequestOptions, buildHeaders, makeRequest, resolveBody };
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import { Response, request, RequestInit } from 'undici';
|
|
1
|
+
import { Response, Headers, request, RequestInit } from 'undici';
|
|
2
|
+
import { IncomingHttpHeaders } from 'undici/types/header.js';
|
|
2
3
|
import { Readable } from 'node:stream';
|
|
3
4
|
import { ReadableStream } from 'node:stream/web';
|
|
4
5
|
|
|
5
|
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | '
|
|
6
|
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
|
6
7
|
body: Readable | ReadableStream | null;
|
|
8
|
+
clone?(): ResponseLike;
|
|
9
|
+
headers: Pick<Headers, typeof Symbol.iterator | 'get' | 'has'>;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
|
10
13
|
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
|
11
14
|
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
|
15
|
+
/**
|
|
16
|
+
* @privateRemarks
|
|
17
|
+
*
|
|
18
|
+
* Under HTTP/2, Node.js attaches the symbol `sensitiveHeaders` to the headers object,
|
|
19
|
+
* which the `Headers` constructor rejects. Hence the manual construction of the `Headers` object here.
|
|
20
|
+
*/
|
|
21
|
+
declare function buildHeaders(headers: IncomingHttpHeaders): Headers;
|
|
12
22
|
|
|
13
|
-
export { type RequestOptions, makeRequest, resolveBody };
|
|
23
|
+
export { type RequestOptions, buildHeaders, makeRequest, resolveBody };
|
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/strategies/undiciRequest.ts
|
|
22
22
|
var undiciRequest_exports = {};
|
|
23
23
|
__export(undiciRequest_exports, {
|
|
24
|
+
buildHeaders: () => buildHeaders,
|
|
24
25
|
makeRequest: () => makeRequest,
|
|
25
26
|
resolveBody: () => resolveBody
|
|
26
27
|
});
|
|
@@ -54,7 +55,7 @@ async function makeRequest(url, init) {
|
|
|
54
55
|
get bodyUsed() {
|
|
55
56
|
return res.body.bodyUsed;
|
|
56
57
|
},
|
|
57
|
-
headers:
|
|
58
|
+
headers: buildHeaders(res.headers),
|
|
58
59
|
status: res.statusCode,
|
|
59
60
|
statusText: import_node_http.STATUS_CODES[res.statusCode],
|
|
60
61
|
ok: res.statusCode >= 200 && res.statusCode < 300
|
|
@@ -93,6 +94,20 @@ async function resolveBody(body) {
|
|
|
93
94
|
throw new TypeError(`Unable to resolve body.`);
|
|
94
95
|
}
|
|
95
96
|
__name(resolveBody, "resolveBody");
|
|
97
|
+
function buildHeaders(headers) {
|
|
98
|
+
const result = new import_undici.Headers();
|
|
99
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
for (const entry of value) {
|
|
102
|
+
result.append(name, `${entry}`);
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
result.append(name, `${value}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
__name(buildHeaders, "buildHeaders");
|
|
96
111
|
function globalToUndiciFormData(fd) {
|
|
97
112
|
const clone = new import_undici.FormData();
|
|
98
113
|
for (const [name, value] of fd.entries()) {
|
|
@@ -107,6 +122,7 @@ function globalToUndiciFormData(fd) {
|
|
|
107
122
|
__name(globalToUndiciFormData, "globalToUndiciFormData");
|
|
108
123
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
124
|
0 && (module.exports = {
|
|
125
|
+
buildHeaders,
|
|
110
126
|
makeRequest,
|
|
111
127
|
resolveBody
|
|
112
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type { IncomingHttpHeaders } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nlet localAgent: Agent | null = null;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\n\t// Mismatched dispatchers from the Node.js-bundled undici and package-installed undici breaks file uploads.\n\t// So we ensure that we always pass an Agent to request()\n\t// https://github.com/nodejs/node/issues/59012\n\tif (!options.dispatcher) {\n\t\tlocalAgent ??= new Agent();\n\t\toptions.dispatcher = localAgent;\n\t}\n\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: buildHeaders(res.headers),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\n/**\n * @privateRemarks\n *\n * Under HTTP/2, Node.js attaches the symbol `sensitiveHeaders` to the headers object,\n * which the `Headers` constructor rejects. Hence the manual construction of the `Headers` object here.\n */\nexport function buildHeaders(headers: IncomingHttpHeaders): Headers {\n\tconst result = new Headers();\n\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const entry of value) {\n\t\t\t\tresult.append(name, `${entry}`);\n\t\t\t}\n\t\t} else {\n\t\t\tresult.append(name, `${value}`);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuB;AACvB,uBAA6B;AAC7B,uBAAsB;AACtB,oBAAsF;AAMtF,IAAI,aAA2B;AAE/B,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AAKA,MAAI,CAAC,QAAQ,YAAY;AACxB,mBAAe,IAAI,oBAAM;AACzB,YAAQ,aAAa;AAAA,EACtB;AAEA,QAAM,MAAM,UAAM,uBAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,IAAI,WAAW;AACd,aAAO,IAAI,KAAK;AAAA,IACjB;AAAA,IACA,SAAS,aAAa,IAAI,OAAO;AAAA,IACjC,QAAQ,IAAI;AAAA,IACZ,YAAY,8BAAa,IAAI,UAAU;AAAA,IACvC,IAAI,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA,EAC/C;AAC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AAA,EACD;AAEA,SAAO;AACR;AAdgB;AAgBhB,SAAS,uBAAuB,IAAyC;AACxE,QAAM,QAAQ,IAAI,cAAAA,SAAe;AAEjC,aAAW,CAAC,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG;AACzC,QAAI,OAAO,UAAU,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":["UndiciFormData"]}
|
|
@@ -31,7 +31,7 @@ async function makeRequest(url, init) {
|
|
|
31
31
|
get bodyUsed() {
|
|
32
32
|
return res.body.bodyUsed;
|
|
33
33
|
},
|
|
34
|
-
headers:
|
|
34
|
+
headers: buildHeaders(res.headers),
|
|
35
35
|
status: res.statusCode,
|
|
36
36
|
statusText: STATUS_CODES[res.statusCode],
|
|
37
37
|
ok: res.statusCode >= 200 && res.statusCode < 300
|
|
@@ -70,6 +70,20 @@ async function resolveBody(body) {
|
|
|
70
70
|
throw new TypeError(`Unable to resolve body.`);
|
|
71
71
|
}
|
|
72
72
|
__name(resolveBody, "resolveBody");
|
|
73
|
+
function buildHeaders(headers) {
|
|
74
|
+
const result = new Headers();
|
|
75
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
for (const entry of value) {
|
|
78
|
+
result.append(name, `${entry}`);
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
result.append(name, `${value}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
__name(buildHeaders, "buildHeaders");
|
|
73
87
|
function globalToUndiciFormData(fd) {
|
|
74
88
|
const clone = new UndiciFormData();
|
|
75
89
|
for (const [name, value] of fd.entries()) {
|
|
@@ -83,6 +97,7 @@ function globalToUndiciFormData(fd) {
|
|
|
83
97
|
}
|
|
84
98
|
__name(globalToUndiciFormData, "globalToUndiciFormData");
|
|
85
99
|
export {
|
|
100
|
+
buildHeaders,
|
|
86
101
|
makeRequest,
|
|
87
102
|
resolveBody
|
|
88
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type { IncomingHttpHeaders } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nlet localAgent: Agent | null = null;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\n\t// Mismatched dispatchers from the Node.js-bundled undici and package-installed undici breaks file uploads.\n\t// So we ensure that we always pass an Agent to request()\n\t// https://github.com/nodejs/node/issues/59012\n\tif (!options.dispatcher) {\n\t\tlocalAgent ??= new Agent();\n\t\toptions.dispatcher = localAgent;\n\t}\n\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: buildHeaders(res.headers),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\n/**\n * @privateRemarks\n *\n * Under HTTP/2, Node.js attaches the symbol `sensitiveHeaders` to the headers object,\n * which the `Headers` constructor rejects. Hence the manual construction of the `Headers` object here.\n */\nexport function buildHeaders(headers: IncomingHttpHeaders): Headers {\n\tconst result = new Headers();\n\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (const entry of value) {\n\t\t\t\tresult.append(name, `${entry}`);\n\t\t\t}\n\t\t} else {\n\t\t\tresult.append(name, `${value}`);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;AAAA,SAAS,UAAAA,eAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AACtB,SAA2B,SAAS,SAAS,YAAY,gBAAgB,aAAa;AAMtF,IAAI,aAA2B;AAE/B,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AAKA,MAAI,CAAC,QAAQ,YAAY;AACxB,mBAAe,IAAI,MAAM;AACzB,YAAQ,aAAa;AAAA,EACtB;AAEA,QAAM,MAAM,MAAM,QAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,IAAI,WAAW;AACd,aAAO,IAAI,KAAK;AAAA,IACjB;AAAA,IACA,SAAS,aAAa,IAAI,OAAO;AAAA,IACjC,QAAQ,IAAI;AAAA,IACZ,YAAY,aAAa,IAAI,UAAU;AAAA,IACvC,IAAI,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA,EAC/C;AACD;AApCsB;AAsCtB,eAAsB,YAAY,MAAgF;AAEjH,MAAI,QAAQ,MAAM;AACjB,WAAO;AAAA,EACR,WAAW,OAAO,SAAS,UAAU;AACpC,WAAO;AAAA,EACR,WAAW,MAAM,aAAa,IAAI,GAAG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U,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":["Buffer","Buffer"]}
|
package/dist/web.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as undici from 'undici';
|
|
2
|
-
import { RequestInit, BodyInit, Agent, Response, Dispatcher } from 'undici';
|
|
2
|
+
import { RequestInit, BodyInit, Agent, Response, Headers, Dispatcher } from 'undici';
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
4
|
import { ReadableStream } from 'node:stream/web';
|
|
5
5
|
import { Collection } from '@discordjs/collection';
|
|
@@ -273,8 +273,10 @@ interface APIRequest {
|
|
|
273
273
|
*/
|
|
274
274
|
route: string;
|
|
275
275
|
}
|
|
276
|
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | '
|
|
276
|
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
|
277
277
|
body: Readable | ReadableStream | null;
|
|
278
|
+
clone?(): ResponseLike;
|
|
279
|
+
headers: Pick<Headers, typeof Symbol.iterator | 'get' | 'has'>;
|
|
278
280
|
}
|
|
279
281
|
interface InvalidRequestWarningData {
|
|
280
282
|
/**
|
package/dist/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as undici from 'undici';
|
|
2
|
-
import { RequestInit, BodyInit, Agent, Response, Dispatcher } from 'undici';
|
|
2
|
+
import { RequestInit, BodyInit, Agent, Response, Headers, Dispatcher } from 'undici';
|
|
3
3
|
import { Readable } from 'node:stream';
|
|
4
4
|
import { ReadableStream } from 'node:stream/web';
|
|
5
5
|
import { Collection } from '@discordjs/collection';
|
|
@@ -273,8 +273,10 @@ interface APIRequest {
|
|
|
273
273
|
*/
|
|
274
274
|
route: string;
|
|
275
275
|
}
|
|
276
|
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | '
|
|
276
|
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
|
277
277
|
body: Readable | ReadableStream | null;
|
|
278
|
+
clone?(): ResponseLike;
|
|
279
|
+
headers: Pick<Headers, typeof Symbol.iterator | 'get' | 'has'>;
|
|
278
280
|
}
|
|
279
281
|
interface InvalidRequestWarningData {
|
|
280
282
|
/**
|
package/dist/web.js
CHANGED
|
@@ -61,7 +61,7 @@ var import_v102 = require("discord-api-types/v10");
|
|
|
61
61
|
// src/lib/utils/constants.ts
|
|
62
62
|
var import_util = require("@discordjs/util");
|
|
63
63
|
var import_v10 = require("discord-api-types/v10");
|
|
64
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.
|
|
64
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1788538586-ecea9ed57)`;
|
|
65
65
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
66
66
|
var DefaultRestOptions = {
|
|
67
67
|
agent: null,
|
|
@@ -402,6 +402,11 @@ var DiscordAPIError = class _DiscordAPIError extends Error {
|
|
|
402
402
|
this.url = url;
|
|
403
403
|
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
|
404
404
|
}
|
|
405
|
+
rawError;
|
|
406
|
+
code;
|
|
407
|
+
status;
|
|
408
|
+
method;
|
|
409
|
+
url;
|
|
405
410
|
static {
|
|
406
411
|
__name(this, "DiscordAPIError");
|
|
407
412
|
}
|
|
@@ -458,6 +463,9 @@ var HTTPError = class _HTTPError extends Error {
|
|
|
458
463
|
this.url = url;
|
|
459
464
|
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
|
460
465
|
}
|
|
466
|
+
status;
|
|
467
|
+
method;
|
|
468
|
+
url;
|
|
461
469
|
static {
|
|
462
470
|
__name(this, "HTTPError");
|
|
463
471
|
}
|
|
@@ -709,7 +717,7 @@ async function makeNetworkRequest(manager, routeId, url, options, requestData, r
|
|
|
709
717
|
data: requestData,
|
|
710
718
|
retries
|
|
711
719
|
},
|
|
712
|
-
res
|
|
720
|
+
res.clone?.() ?? { ...res }
|
|
713
721
|
);
|
|
714
722
|
}
|
|
715
723
|
return res;
|
|
@@ -771,6 +779,9 @@ var BurstHandler = class {
|
|
|
771
779
|
this.majorParameter = majorParameter;
|
|
772
780
|
this.id = `${hash}:${majorParameter}`;
|
|
773
781
|
}
|
|
782
|
+
manager;
|
|
783
|
+
hash;
|
|
784
|
+
majorParameter;
|
|
774
785
|
static {
|
|
775
786
|
__name(this, "BurstHandler");
|
|
776
787
|
}
|
|
@@ -882,6 +893,9 @@ var SequentialHandler = class {
|
|
|
882
893
|
this.majorParameter = majorParameter;
|
|
883
894
|
this.id = `${hash}:${majorParameter}`;
|
|
884
895
|
}
|
|
896
|
+
manager;
|
|
897
|
+
hash;
|
|
898
|
+
majorParameter;
|
|
885
899
|
static {
|
|
886
900
|
__name(this, "SequentialHandler");
|
|
887
901
|
}
|
|
@@ -1495,7 +1509,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1495
1509
|
};
|
|
1496
1510
|
|
|
1497
1511
|
// src/shared.ts
|
|
1498
|
-
var version = "3.0.0-dev.
|
|
1512
|
+
var version = "3.0.0-dev.1788538586-ecea9ed57";
|
|
1499
1513
|
|
|
1500
1514
|
// src/web.ts
|
|
1501
1515
|
setDefaultStrategy(fetch);
|