@discordjs/rest 3.0.0-pr-11006.1765450794-e636950b2 → 3.0.0-pr-11005.1765454364-f3f6d34e7
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 +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.js +6 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -13
- package/dist/index.mjs.map +1 -1
- package/dist/strategies/undiciRequest.js +4 -9
- package/dist/strategies/undiciRequest.js.map +1 -1
- package/dist/strategies/undiciRequest.mjs +4 -9
- package/dist/strategies/undiciRequest.mjs.map +1 -1
- package/dist/web.d.mts +25 -4
- package/dist/web.d.ts +25 -4
- package/dist/web.js +2 -3
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +2 -3
- package/dist/web.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.d.mts
CHANGED
|
@@ -4,8 +4,7 @@ export { ImageSize } from 'discord-api-types/v10';
|
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
5
|
import { ReadableStream } from 'node:stream/web';
|
|
6
6
|
import { Collection } from '@discordjs/collection';
|
|
7
|
-
import {
|
|
8
|
-
export { RawFile } from '@discordjs/util';
|
|
7
|
+
import { Awaitable } from '@discordjs/util';
|
|
9
8
|
import * as undici from 'undici';
|
|
10
9
|
import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
|
|
11
10
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
@@ -284,7 +283,29 @@ interface InvalidRequestWarningData {
|
|
|
284
283
|
*/
|
|
285
284
|
remainingTime: number;
|
|
286
285
|
}
|
|
287
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Represents a file to be added to the request
|
|
288
|
+
*/
|
|
289
|
+
interface RawFile {
|
|
290
|
+
/**
|
|
291
|
+
* Content-Type of the file
|
|
292
|
+
*/
|
|
293
|
+
contentType?: string;
|
|
294
|
+
/**
|
|
295
|
+
* The actual data for the file
|
|
296
|
+
*/
|
|
297
|
+
data: Buffer | Uint8Array | boolean | number | string;
|
|
298
|
+
/**
|
|
299
|
+
* An explicit key to use for key of the formdata field for this file.
|
|
300
|
+
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
|
301
|
+
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
|
302
|
+
*/
|
|
303
|
+
key?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The name of the file
|
|
306
|
+
*/
|
|
307
|
+
name: string;
|
|
308
|
+
}
|
|
288
309
|
interface AuthData {
|
|
289
310
|
/**
|
|
290
311
|
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
|
@@ -928,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
928
949
|
*/
|
|
929
950
|
declare const version: string;
|
|
930
951
|
|
|
931
|
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
|
952
|
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ export { ImageSize } from 'discord-api-types/v10';
|
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
5
|
import { ReadableStream } from 'node:stream/web';
|
|
6
6
|
import { Collection } from '@discordjs/collection';
|
|
7
|
-
import {
|
|
8
|
-
export { RawFile } from '@discordjs/util';
|
|
7
|
+
import { Awaitable } from '@discordjs/util';
|
|
9
8
|
import * as undici from 'undici';
|
|
10
9
|
import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
|
|
11
10
|
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
@@ -284,7 +283,29 @@ interface InvalidRequestWarningData {
|
|
|
284
283
|
*/
|
|
285
284
|
remainingTime: number;
|
|
286
285
|
}
|
|
287
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Represents a file to be added to the request
|
|
288
|
+
*/
|
|
289
|
+
interface RawFile {
|
|
290
|
+
/**
|
|
291
|
+
* Content-Type of the file
|
|
292
|
+
*/
|
|
293
|
+
contentType?: string;
|
|
294
|
+
/**
|
|
295
|
+
* The actual data for the file
|
|
296
|
+
*/
|
|
297
|
+
data: Buffer | Uint8Array | boolean | number | string;
|
|
298
|
+
/**
|
|
299
|
+
* An explicit key to use for key of the formdata field for this file.
|
|
300
|
+
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
|
301
|
+
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
|
302
|
+
*/
|
|
303
|
+
key?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The name of the file
|
|
306
|
+
*/
|
|
307
|
+
name: string;
|
|
308
|
+
}
|
|
288
309
|
interface AuthData {
|
|
289
310
|
/**
|
|
290
311
|
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
|
@@ -928,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
928
949
|
*/
|
|
929
950
|
declare const version: string;
|
|
930
951
|
|
|
931
|
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
|
952
|
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
package/dist/index.js
CHANGED
|
@@ -57,20 +57,15 @@ function getDefaultStrategy() {
|
|
|
57
57
|
__name(getDefaultStrategy, "getDefaultStrategy");
|
|
58
58
|
|
|
59
59
|
// src/strategies/undiciRequest.ts
|
|
60
|
-
var import_node_buffer = require("buffer");
|
|
61
60
|
var import_node_http = require("http");
|
|
61
|
+
var import_node_url = require("url");
|
|
62
62
|
var import_node_util = require("util");
|
|
63
63
|
var import_undici = require("undici");
|
|
64
|
-
var localAgent = null;
|
|
65
64
|
async function makeRequest(url, init) {
|
|
66
65
|
const options = {
|
|
67
66
|
...init,
|
|
68
67
|
body: await resolveBody(init.body)
|
|
69
68
|
};
|
|
70
|
-
if (!options.dispatcher) {
|
|
71
|
-
localAgent ??= new import_undici.Agent();
|
|
72
|
-
options.dispatcher = localAgent;
|
|
73
|
-
}
|
|
74
69
|
const res = await (0, import_undici.request)(url, options);
|
|
75
70
|
return {
|
|
76
71
|
body: res.body,
|
|
@@ -102,7 +97,7 @@ async function resolveBody(body) {
|
|
|
102
97
|
return body;
|
|
103
98
|
} else if (import_node_util.types.isArrayBuffer(body)) {
|
|
104
99
|
return new Uint8Array(body);
|
|
105
|
-
} else if (body instanceof URLSearchParams) {
|
|
100
|
+
} else if (body instanceof import_node_url.URLSearchParams) {
|
|
106
101
|
return body.toString();
|
|
107
102
|
} else if (body instanceof DataView) {
|
|
108
103
|
return new Uint8Array(body.buffer);
|
|
@@ -114,13 +109,13 @@ async function resolveBody(body) {
|
|
|
114
109
|
return globalToUndiciFormData(body);
|
|
115
110
|
} else if (body[Symbol.iterator]) {
|
|
116
111
|
const chunks = [...body];
|
|
117
|
-
return
|
|
112
|
+
return Buffer.concat(chunks);
|
|
118
113
|
} else if (body[Symbol.asyncIterator]) {
|
|
119
114
|
const chunks = [];
|
|
120
115
|
for await (const chunk of body) {
|
|
121
116
|
chunks.push(chunk);
|
|
122
117
|
}
|
|
123
|
-
return
|
|
118
|
+
return Buffer.concat(chunks);
|
|
124
119
|
}
|
|
125
120
|
throw new TypeError(`Unable to resolve body.`);
|
|
126
121
|
}
|
|
@@ -144,7 +139,7 @@ var import_v102 = require("discord-api-types/v10");
|
|
|
144
139
|
// src/lib/utils/constants.ts
|
|
145
140
|
var import_util = require("@discordjs/util");
|
|
146
141
|
var import_v10 = require("discord-api-types/v10");
|
|
147
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-
|
|
142
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-11005.1765454364-f3f6d34e7)`;
|
|
148
143
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
149
144
|
var DefaultRestOptions = {
|
|
150
145
|
agent: null,
|
|
@@ -1261,7 +1256,6 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1261
1256
|
handlerTimer;
|
|
1262
1257
|
options;
|
|
1263
1258
|
constructor(options = {}) {
|
|
1264
|
-
console.log("even rest got something new \u203C\uFE0F \u{1F5E3}\uFE0F \u{1F525}");
|
|
1265
1259
|
super();
|
|
1266
1260
|
this.cdn = new CDN(options);
|
|
1267
1261
|
this.options = { ...DefaultRestOptions, ...options };
|
|
@@ -1546,7 +1540,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1546
1540
|
};
|
|
1547
1541
|
|
|
1548
1542
|
// src/shared.ts
|
|
1549
|
-
var version = "3.0.0-pr-
|
|
1543
|
+
var version = "3.0.0-pr-11005.1765454364-f3f6d34e7";
|
|
1550
1544
|
|
|
1551
1545
|
// src/index.ts
|
|
1552
1546
|
setDefaultStrategy((0, import_util2.shouldUseGlobalFetchAndWebSocket)() ? fetch : makeRequest);
|