@discordjs/rest 3.0.0-dev.1784246195-c73e2a76d → 3.0.0-dev.1784551164-2de90a767
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/README.md +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -5
- package/dist/index.mjs.map +1 -1
- package/dist/web.d.mts +17 -4
- package/dist/web.d.ts +17 -4
- package/dist/web.js +24 -5
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +24 -5
- package/dist/web.mjs.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -7,8 +7,8 @@ import { RawFile, Awaitable } from '@discordjs/util';
|
|
|
7
7
|
export { RawFile } from '@discordjs/util';
|
|
8
8
|
import { ImageSize, Snowflake } from 'discord-api-types/v10';
|
|
9
9
|
export { ImageSize } from 'discord-api-types/v10';
|
|
10
|
-
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
11
10
|
import * as url from 'url';
|
|
11
|
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
12
12
|
|
|
13
13
|
interface IHandler {
|
|
14
14
|
/**
|
|
@@ -901,14 +901,27 @@ declare class REST extends AsyncEventEmitter<RestEvents> {
|
|
|
901
901
|
private static generateRouteData;
|
|
902
902
|
}
|
|
903
903
|
|
|
904
|
+
/**
|
|
905
|
+
* Options for serializing URL search parameters.
|
|
906
|
+
*/
|
|
907
|
+
interface MakeURLSearchParamsOptions {
|
|
908
|
+
/**
|
|
909
|
+
* How array values should be serialized.
|
|
910
|
+
*
|
|
911
|
+
* @defaultValue `'repeat'`
|
|
912
|
+
* @see {@link https://docs.discord.com/developers/reference#array-query-strings}
|
|
913
|
+
*/
|
|
914
|
+
arrayFormat?: 'comma' | 'repeat';
|
|
915
|
+
}
|
|
904
916
|
/**
|
|
905
917
|
* Creates and populates an URLSearchParams instance from an object, stripping
|
|
906
918
|
* out null and undefined values, while also coercing non-strings to strings.
|
|
907
919
|
*
|
|
908
|
-
* @param
|
|
920
|
+
* @param parameters - The parameters to use
|
|
921
|
+
* @param options - The options for serializing URL search parameters
|
|
909
922
|
* @returns A populated URLSearchParams instance
|
|
910
923
|
*/
|
|
911
|
-
declare function makeURLSearchParams<
|
|
924
|
+
declare function makeURLSearchParams<ParametersType extends object>(parameters?: Readonly<ParametersType>, options?: MakeURLSearchParamsOptions): url.URLSearchParams;
|
|
912
925
|
/**
|
|
913
926
|
* Converts the response to usable data
|
|
914
927
|
*
|
|
@@ -928,4 +941,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
928
941
|
*/
|
|
929
942
|
declare const version: string;
|
|
930
943
|
|
|
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 };
|
|
944
|
+
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 MakeURLSearchParamsOptions, 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
|
@@ -7,8 +7,8 @@ import { RawFile, Awaitable } from '@discordjs/util';
|
|
|
7
7
|
export { RawFile } from '@discordjs/util';
|
|
8
8
|
import { ImageSize, Snowflake } from 'discord-api-types/v10';
|
|
9
9
|
export { ImageSize } from 'discord-api-types/v10';
|
|
10
|
-
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
11
10
|
import * as url from 'url';
|
|
11
|
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
|
12
12
|
|
|
13
13
|
interface IHandler {
|
|
14
14
|
/**
|
|
@@ -901,14 +901,27 @@ declare class REST extends AsyncEventEmitter<RestEvents> {
|
|
|
901
901
|
private static generateRouteData;
|
|
902
902
|
}
|
|
903
903
|
|
|
904
|
+
/**
|
|
905
|
+
* Options for serializing URL search parameters.
|
|
906
|
+
*/
|
|
907
|
+
interface MakeURLSearchParamsOptions {
|
|
908
|
+
/**
|
|
909
|
+
* How array values should be serialized.
|
|
910
|
+
*
|
|
911
|
+
* @defaultValue `'repeat'`
|
|
912
|
+
* @see {@link https://docs.discord.com/developers/reference#array-query-strings}
|
|
913
|
+
*/
|
|
914
|
+
arrayFormat?: 'comma' | 'repeat';
|
|
915
|
+
}
|
|
904
916
|
/**
|
|
905
917
|
* Creates and populates an URLSearchParams instance from an object, stripping
|
|
906
918
|
* out null and undefined values, while also coercing non-strings to strings.
|
|
907
919
|
*
|
|
908
|
-
* @param
|
|
920
|
+
* @param parameters - The parameters to use
|
|
921
|
+
* @param options - The options for serializing URL search parameters
|
|
909
922
|
* @returns A populated URLSearchParams instance
|
|
910
923
|
*/
|
|
911
|
-
declare function makeURLSearchParams<
|
|
924
|
+
declare function makeURLSearchParams<ParametersType extends object>(parameters?: Readonly<ParametersType>, options?: MakeURLSearchParamsOptions): url.URLSearchParams;
|
|
912
925
|
/**
|
|
913
926
|
* Converts the response to usable data
|
|
914
927
|
*
|
|
@@ -928,4 +941,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
|
928
941
|
*/
|
|
929
942
|
declare const version: string;
|
|
930
943
|
|
|
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 };
|
|
944
|
+
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 MakeURLSearchParamsOptions, 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
|
@@ -144,7 +144,7 @@ var import_v102 = require("discord-api-types/v10");
|
|
|
144
144
|
// src/lib/utils/constants.ts
|
|
145
145
|
var import_util = require("@discordjs/util");
|
|
146
146
|
var import_v10 = require("discord-api-types/v10");
|
|
147
|
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.
|
|
147
|
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-dev.1784551164-2de90a767)`;
|
|
148
148
|
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
|
149
149
|
var DefaultRestOptions = {
|
|
150
150
|
agent: null,
|
|
@@ -624,10 +624,29 @@ function serializeSearchParam(value) {
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
__name(serializeSearchParam, "serializeSearchParam");
|
|
627
|
-
function makeURLSearchParams(options) {
|
|
627
|
+
function makeURLSearchParams(parameters, options = {}) {
|
|
628
628
|
const params = new URLSearchParams();
|
|
629
|
-
if (!
|
|
630
|
-
|
|
629
|
+
if (!parameters) return params;
|
|
630
|
+
const { arrayFormat = "repeat" } = options;
|
|
631
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
632
|
+
if (Array.isArray(value)) {
|
|
633
|
+
const commaSeparatedElements = arrayFormat === "comma" ? [] : null;
|
|
634
|
+
for (const element of value) {
|
|
635
|
+
const serialized2 = serializeSearchParam(element);
|
|
636
|
+
if (serialized2 === null) {
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
if (commaSeparatedElements) {
|
|
640
|
+
commaSeparatedElements.push(serialized2);
|
|
641
|
+
} else {
|
|
642
|
+
params.append(key, serialized2);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (commaSeparatedElements?.length) {
|
|
646
|
+
params.append(key, commaSeparatedElements.join(","));
|
|
647
|
+
}
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
631
650
|
const serialized = serializeSearchParam(value);
|
|
632
651
|
if (serialized !== null) params.append(key, serialized);
|
|
633
652
|
}
|
|
@@ -1545,7 +1564,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
1545
1564
|
};
|
|
1546
1565
|
|
|
1547
1566
|
// src/shared.ts
|
|
1548
|
-
var version = "3.0.0-dev.
|
|
1567
|
+
var version = "3.0.0-dev.1784551164-2de90a767";
|
|
1549
1568
|
|
|
1550
1569
|
// src/index.ts
|
|
1551
1570
|
setDefaultStrategy((0, import_util2.shouldUseGlobalFetchAndWebSocket)() ? fetch : makeRequest);
|