@discordjs/rest 3.0.0-move-client-init.1761650119-a4c0a246f → 3.0.0-pr-11006.1765450794-e636950b2

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 CHANGED
@@ -4,7 +4,8 @@ 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 { Awaitable } from '@discordjs/util';
7
+ import { RawFile, Awaitable } from '@discordjs/util';
8
+ export { RawFile } from '@discordjs/util';
8
9
  import * as undici from 'undici';
9
10
  import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
10
11
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
@@ -283,29 +284,7 @@ interface InvalidRequestWarningData {
283
284
  */
284
285
  remainingTime: number;
285
286
  }
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
- }
287
+
309
288
  interface AuthData {
310
289
  /**
311
290
  * The authorization prefix to use for this request, useful if you use this with bearer tokens
@@ -949,4 +928,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
949
928
  */
950
929
  declare const version: string;
951
930
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@ 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 { Awaitable } from '@discordjs/util';
7
+ import { RawFile, Awaitable } from '@discordjs/util';
8
+ export { RawFile } from '@discordjs/util';
8
9
  import * as undici from 'undici';
9
10
  import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
10
11
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
@@ -283,29 +284,7 @@ interface InvalidRequestWarningData {
283
284
  */
284
285
  remainingTime: number;
285
286
  }
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
- }
287
+
309
288
  interface AuthData {
310
289
  /**
311
290
  * The authorization prefix to use for this request, useful if you use this with bearer tokens
@@ -949,4 +928,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
949
928
  */
950
929
  declare const version: string;
951
930
 
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 };
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 };
package/dist/index.js CHANGED
@@ -57,15 +57,20 @@ function getDefaultStrategy() {
57
57
  __name(getDefaultStrategy, "getDefaultStrategy");
58
58
 
59
59
  // src/strategies/undiciRequest.ts
60
+ var import_node_buffer = require("buffer");
60
61
  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;
64
65
  async function makeRequest(url, init) {
65
66
  const options = {
66
67
  ...init,
67
68
  body: await resolveBody(init.body)
68
69
  };
70
+ if (!options.dispatcher) {
71
+ localAgent ??= new import_undici.Agent();
72
+ options.dispatcher = localAgent;
73
+ }
69
74
  const res = await (0, import_undici.request)(url, options);
70
75
  return {
71
76
  body: res.body,
@@ -97,7 +102,7 @@ async function resolveBody(body) {
97
102
  return body;
98
103
  } else if (import_node_util.types.isArrayBuffer(body)) {
99
104
  return new Uint8Array(body);
100
- } else if (body instanceof import_node_url.URLSearchParams) {
105
+ } else if (body instanceof URLSearchParams) {
101
106
  return body.toString();
102
107
  } else if (body instanceof DataView) {
103
108
  return new Uint8Array(body.buffer);
@@ -109,13 +114,13 @@ async function resolveBody(body) {
109
114
  return globalToUndiciFormData(body);
110
115
  } else if (body[Symbol.iterator]) {
111
116
  const chunks = [...body];
112
- return Buffer.concat(chunks);
117
+ return import_node_buffer.Buffer.concat(chunks);
113
118
  } else if (body[Symbol.asyncIterator]) {
114
119
  const chunks = [];
115
120
  for await (const chunk of body) {
116
121
  chunks.push(chunk);
117
122
  }
118
- return Buffer.concat(chunks);
123
+ return import_node_buffer.Buffer.concat(chunks);
119
124
  }
120
125
  throw new TypeError(`Unable to resolve body.`);
121
126
  }
@@ -139,7 +144,7 @@ var import_v102 = require("discord-api-types/v10");
139
144
  // src/lib/utils/constants.ts
140
145
  var import_util = require("@discordjs/util");
141
146
  var import_v10 = require("discord-api-types/v10");
142
- var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-move-client-init.1761650119-a4c0a246f)`;
147
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-11006.1765450794-e636950b2)`;
143
148
  var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
144
149
  var DefaultRestOptions = {
145
150
  agent: null,
@@ -1256,6 +1261,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1256
1261
  handlerTimer;
1257
1262
  options;
1258
1263
  constructor(options = {}) {
1264
+ console.log("even rest got something new \u203C\uFE0F \u{1F5E3}\uFE0F \u{1F525}");
1259
1265
  super();
1260
1266
  this.cdn = new CDN(options);
1261
1267
  this.options = { ...DefaultRestOptions, ...options };
@@ -1540,7 +1546,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1540
1546
  };
1541
1547
 
1542
1548
  // src/shared.ts
1543
- var version = "3.0.0-move-client-init.1761650119-a4c0a246f";
1549
+ var version = "3.0.0-pr-11006.1765450794-e636950b2";
1544
1550
 
1545
1551
  // src/index.ts
1546
1552
  setDefaultStrategy((0, import_util2.shouldUseGlobalFetchAndWebSocket)() ? fetch : makeRequest);