@discordeno/rest 19.0.0-next.fd8642b → 19.0.0-next.fda3003
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/cjs/index.cjs +25 -0
- package/dist/cjs/invalidBucket.cjs +87 -0
- package/dist/cjs/manager.cjs +1446 -0
- package/dist/cjs/queue.cjs +166 -0
- package/dist/cjs/routes.cjs +581 -0
- package/dist/cjs/types.cjs +6 -0
- package/dist/cjs/typings/routes.cjs +6 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/invalidBucket.js +83 -0
- package/dist/esm/manager.js +1404 -0
- package/dist/esm/queue.js +156 -0
- package/dist/esm/routes.js +571 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/typings/routes.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{invalidBucket.d.ts → types/invalidBucket.d.ts} +11 -7
- package/dist/types/invalidBucket.d.ts.map +1 -0
- package/dist/types/manager.d.ts +12 -0
- package/dist/types/manager.d.ts.map +1 -0
- package/dist/{queue.d.ts → types/queue.d.ts} +19 -1
- package/dist/types/queue.d.ts.map +1 -0
- package/dist/types/routes.d.ts +3 -0
- package/dist/types/routes.d.ts.map +1 -0
- package/dist/types/types.d.ts +2816 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/typings/routes.d.ts +277 -0
- package/dist/types/typings/routes.d.ts.map +1 -0
- package/package.json +30 -24
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/invalidBucket.d.ts.map +0 -1
- package/dist/invalidBucket.js +0 -2
- package/dist/manager.d.ts +0 -3574
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -2
- package/dist/queue.d.ts.map +0 -1
- package/dist/queue.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { logger } from '@discordeno/utils';
|
|
2
2
|
/**
|
|
3
3
|
* A invalid request bucket is used in a similar manner as a leaky bucket but a invalid request bucket can be refilled as needed.
|
|
4
4
|
* It's purpose is to make sure the bot does not hit the limit to getting a 1 hr ban.
|
|
@@ -14,34 +14,38 @@ export interface InvalidRequestBucketOptions {
|
|
|
14
14
|
max?: number;
|
|
15
15
|
/** The time that discord allows to make the max number of invalid requests. Defaults to 10 minutes */
|
|
16
16
|
interval?: number;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** When the timeout for the bucket has started at. */
|
|
18
|
+
resetAt?: number;
|
|
19
19
|
/** how safe to be from max. Defaults to 1 */
|
|
20
20
|
safety?: number;
|
|
21
21
|
/** The request statuses that count as an invalid request. */
|
|
22
22
|
errorStatuses?: number[];
|
|
23
23
|
/** The amount of requests that were requested from this bucket. */
|
|
24
24
|
requested?: number;
|
|
25
|
+
/** The logger that will be used for the bucket */
|
|
26
|
+
logger?: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
25
27
|
}
|
|
26
28
|
export interface InvalidRequestBucket {
|
|
27
29
|
/** current invalid amount */
|
|
28
|
-
|
|
30
|
+
invalidRequests: number;
|
|
29
31
|
/** max invalid requests allowed until ban. Defaults to 10,000 */
|
|
30
32
|
max: number;
|
|
31
33
|
/** The time that discord allows to make the max number of invalid requests. Defaults to 10 minutes */
|
|
32
34
|
interval: number;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
+
/** When the timeout for this bucket has started at. */
|
|
36
|
+
resetAt: number | undefined;
|
|
35
37
|
/** how safe to be from max. Defaults to 1 */
|
|
36
38
|
safety: number;
|
|
37
39
|
/** The request statuses that count as an invalid request. */
|
|
38
40
|
errorStatuses: number[];
|
|
39
41
|
/** The amount of requests that were requested from this bucket. */
|
|
40
|
-
|
|
42
|
+
activeRequests: number;
|
|
41
43
|
/** The requests that are currently pending. */
|
|
42
44
|
waiting: Array<(value: void | PromiseLike<void>) => void>;
|
|
43
45
|
/** Whether or not the waiting queue is already processing. */
|
|
44
46
|
processing: boolean;
|
|
47
|
+
/** The logger that will be used for the bucket */
|
|
48
|
+
logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
|
45
49
|
/** Gives the number of requests that are currently allowed. */
|
|
46
50
|
requestsAllowed: () => number;
|
|
47
51
|
/** Checks if a request is allowed at this time. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidBucket.d.ts","sourceRoot":"","sources":["../../src/invalidBucket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,oBAAoB,CA4FrG;AAED,MAAM,WAAW,2BAA2B;IAC1C,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAA;CAC5E;AAED,MAAM,WAAW,oBAAoB;IACnC,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAA;IACX,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;IACzD,8DAA8D;IAC9D,UAAU,EAAE,OAAO,CAAA;IACnB,kDAAkD;IAClD,MAAM,EAAE,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAA;IAE1E,+DAA+D;IAC/D,eAAe,EAAE,MAAM,MAAM,CAAA;IAC7B,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,OAAO,CAAA;IAC/B,yCAAyC;IACzC,yBAAyB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,uDAAuD;IACvD,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,iIAAiI;IACjI,sBAAsB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,CAAA;CACrE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CreateRestManagerOptions, RestManager } from './types.js';
|
|
2
|
+
export declare const DISCORD_API_VERSION = 10;
|
|
3
|
+
export declare const DISCORD_API_URL = "https://discord.com/api";
|
|
4
|
+
export declare const AUDIT_LOG_REASON_HEADER = "x-audit-log-reason";
|
|
5
|
+
export declare const RATE_LIMIT_REMAINING_HEADER = "x-ratelimit-remaining";
|
|
6
|
+
export declare const RATE_LIMIT_RESET_AFTER_HEADER = "x-ratelimit-reset-after";
|
|
7
|
+
export declare const RATE_LIMIT_GLOBAL_HEADER = "x-ratelimit-global";
|
|
8
|
+
export declare const RATE_LIMIT_BUCKET_HEADER = "x-ratelimit-bucket";
|
|
9
|
+
export declare const RATE_LIMIT_LIMIT_HEADER = "x-ratelimit-limit";
|
|
10
|
+
export declare const RATE_LIMIT_SCOPE_HEADER = "x-ratelimit-scope";
|
|
11
|
+
export declare function createRestManager(options: CreateRestManagerOptions): RestManager;
|
|
12
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/manager.ts"],"names":[],"mappings":"AA6DA,OAAO,KAAK,EAA4B,wBAAwB,EAAsB,WAAW,EAAsB,MAAM,YAAY,CAAA;AAKzI,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,eAAO,MAAM,eAAe,4BAA4B,CAAA;AAExD,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAC3D,eAAO,MAAM,2BAA2B,0BAA0B,CAAA;AAClE,eAAO,MAAM,6BAA6B,4BAA4B,CAAA;AACtE,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,wBAAwB,uBAAuB,CAAA;AAC5D,eAAO,MAAM,uBAAuB,sBAAsB,CAAA;AAC1D,eAAO,MAAM,uBAAuB,sBAAsB,CAAA;AAE1D,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CAg/ChF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RestManager, SendRequestOptions } from './
|
|
2
|
+
import type { RestManager, SendRequestOptions } from './types.js';
|
|
3
3
|
export declare class Queue {
|
|
4
4
|
/** The rest manager */
|
|
5
5
|
rest: RestManager;
|
|
@@ -25,6 +25,17 @@ export declare class Queue {
|
|
|
25
25
|
url: string;
|
|
26
26
|
/** When requests started being made to determine when the interval will reset it. */
|
|
27
27
|
frozenAt: number;
|
|
28
|
+
/** The time in milliseconds to wait before deleting this queue if it is empty. Defaults to 60000(one minute). */
|
|
29
|
+
deleteQueueDelay: number;
|
|
30
|
+
/** The timeout for the deletion of this queue */
|
|
31
|
+
deleteQueueTimeout?: NodeJS.Timeout;
|
|
32
|
+
/**
|
|
33
|
+
* The authorization being used for the requests in this queue
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This is also used to get the key this queue is stored as in the queue mapping of the rest manager
|
|
37
|
+
*/
|
|
38
|
+
requestAuthorization: string;
|
|
28
39
|
constructor(rest: RestManager, options: QueueOptions);
|
|
29
40
|
/** Check if there is any remaining requests that are allowed. */
|
|
30
41
|
isRequestAllowed(): boolean;
|
|
@@ -39,10 +50,13 @@ export declare class Queue {
|
|
|
39
50
|
interval?: number;
|
|
40
51
|
remaining?: number;
|
|
41
52
|
}): void;
|
|
53
|
+
/** Checks if a request is available and adds it to the queue. Also triggers queue processing if not already processing. */
|
|
42
54
|
makeRequest(options: SendRequestOptions): Promise<void>;
|
|
43
55
|
/** Cleans up the queue by checking if there is nothing left and removing it. */
|
|
44
56
|
cleanup(): void;
|
|
57
|
+
/** Simply checks if the queue is able to be cleared or it has requests pending. */
|
|
45
58
|
isQueueClearable(): boolean;
|
|
59
|
+
getQueueType(): string;
|
|
46
60
|
}
|
|
47
61
|
export interface QueueOptions {
|
|
48
62
|
/** How many requests are remaining. Defaults to 1 */
|
|
@@ -55,5 +69,9 @@ export interface QueueOptions {
|
|
|
55
69
|
timeoutId?: NodeJS.Timeout;
|
|
56
70
|
/** The url this queue will be handling. */
|
|
57
71
|
url: string;
|
|
72
|
+
/** The time in milliseconds to wait before deleting this queue if it is empty. Defaults to 60000(one minute). */
|
|
73
|
+
deleteQueueDelay?: number;
|
|
74
|
+
/** The base key that identifies this queue in the rest manager */
|
|
75
|
+
requestAuthorization: string;
|
|
58
76
|
}
|
|
59
77
|
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":";AACA,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