@sonoransoftware/sonoran.js 1.0.18 → 1.0.20

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.
Files changed (89) hide show
  1. package/.eslintrc.js +10 -10
  2. package/.github/workflows/npm-publish.yml +34 -34
  3. package/.prettierrc.js +6 -6
  4. package/dist/builders/cad/DispatchCall.d.ts +92 -92
  5. package/dist/builders/cad/DispatchCall.js +144 -144
  6. package/dist/builders/cad/index.d.ts +1 -1
  7. package/dist/builders/cad/index.js +17 -17
  8. package/dist/builders/index.d.ts +1 -1
  9. package/dist/builders/index.js +19 -19
  10. package/dist/constants.d.ts +230 -230
  11. package/dist/constants.js +27 -27
  12. package/dist/errors/LibraryErrors.d.ts +19 -19
  13. package/dist/errors/LibraryErrors.js +47 -47
  14. package/dist/errors/Messages.d.ts +1 -1
  15. package/dist/errors/Messages.js +8 -8
  16. package/dist/errors/index.d.ts +2 -2
  17. package/dist/errors/index.js +18 -18
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +24 -24
  20. package/dist/instance/Instance.d.ts +24 -24
  21. package/dist/instance/Instance.js +139 -139
  22. package/dist/instance/instance.types.d.ts +17 -17
  23. package/dist/instance/instance.types.js +2 -2
  24. package/dist/libs/rest/src/index.d.ts +6 -6
  25. package/dist/libs/rest/src/index.js +22 -22
  26. package/dist/libs/rest/src/lib/REST.d.ts +101 -101
  27. package/dist/libs/rest/src/lib/REST.js +136 -129
  28. package/dist/libs/rest/src/lib/RequestManager.d.ts +59 -59
  29. package/dist/libs/rest/src/lib/RequestManager.js +191 -191
  30. package/dist/libs/rest/src/lib/errors/APIError.d.ts +9 -9
  31. package/dist/libs/rest/src/lib/errors/APIError.js +17 -17
  32. package/dist/libs/rest/src/lib/errors/HTTPError.d.ts +17 -17
  33. package/dist/libs/rest/src/lib/errors/HTTPError.js +23 -23
  34. package/dist/libs/rest/src/lib/errors/RateLimitError.d.ts +13 -13
  35. package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -19
  36. package/dist/libs/rest/src/lib/errors/index.d.ts +4 -4
  37. package/dist/libs/rest/src/lib/errors/index.js +20 -20
  38. package/dist/libs/rest/src/lib/handlers/IHandler.d.ts +7 -7
  39. package/dist/libs/rest/src/lib/handlers/IHandler.js +2 -2
  40. package/dist/libs/rest/src/lib/handlers/SequentialHandler.d.ts +45 -45
  41. package/dist/libs/rest/src/lib/handlers/SequentialHandler.js +143 -143
  42. package/dist/libs/rest/src/lib/utils/constants.d.ts +533 -527
  43. package/dist/libs/rest/src/lib/utils/constants.js +463 -443
  44. package/dist/libs/rest/src/lib/utils/utils.d.ts +1 -1
  45. package/dist/libs/rest/src/lib/utils/utils.js +22 -22
  46. package/dist/managers/BaseManager.d.ts +14 -14
  47. package/dist/managers/BaseManager.js +18 -18
  48. package/dist/managers/CADActiveUnitsManager.d.ts +15 -15
  49. package/dist/managers/CADActiveUnitsManager.js +38 -38
  50. package/dist/managers/CADManager.d.ts +29 -29
  51. package/dist/managers/CADManager.js +86 -86
  52. package/dist/managers/CADServerManager.d.ts +8 -8
  53. package/dist/managers/CADServerManager.js +28 -28
  54. package/dist/managers/CMSManager.d.ts +101 -101
  55. package/dist/managers/CMSManager.js +266 -266
  56. package/dist/managers/CMSServerManager.d.ts +8 -8
  57. package/dist/managers/CMSServerManager.js +34 -34
  58. package/dist/managers/CacheManager.d.ts +10 -10
  59. package/dist/managers/CacheManager.js +36 -36
  60. package/dist/managers/DataManager.d.ts +31 -31
  61. package/dist/managers/DataManager.js +58 -58
  62. package/dist/structures/Base.d.ts +9 -9
  63. package/dist/structures/Base.js +24 -24
  64. package/dist/structures/CADActiveUnit.d.ts +47 -47
  65. package/dist/structures/CADActiveUnit.js +66 -66
  66. package/dist/structures/CADServer.d.ts +26 -26
  67. package/dist/structures/CADServer.js +15 -15
  68. package/dist/structures/CMSServer.d.ts +18 -18
  69. package/dist/structures/CMSServer.js +12 -12
  70. package/dist/utils/index.d.ts +1 -1
  71. package/dist/utils/index.js +17 -17
  72. package/dist/utils/utils.d.ts +13 -13
  73. package/dist/utils/utils.js +79 -79
  74. package/docs/CAD-Methods-and-Usage.md +58 -58
  75. package/docs/CMS-Methods-and-Usage.md +211 -211
  76. package/docs/REST-Methods-and-Usage.md +46 -46
  77. package/package.json +48 -48
  78. package/readme.md +53 -53
  79. package/src/constants.ts +248 -248
  80. package/src/instance/Instance.ts +121 -121
  81. package/src/instance/instance.types.ts +17 -17
  82. package/src/libs/rest/src/lib/REST.ts +241 -235
  83. package/src/libs/rest/src/lib/RequestManager.ts +260 -260
  84. package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +160 -160
  85. package/src/libs/rest/src/lib/utils/constants.ts +1012 -985
  86. package/src/managers/CADManager.ts +63 -63
  87. package/src/managers/CMSManager.ts +226 -226
  88. package/src/managers/CMSServerManager.ts +32 -32
  89. package/tsconfig.json +71 -71
@@ -1,101 +1,101 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { EventEmitter } from 'events';
5
- import { RequestData, RequestManager } from './RequestManager';
6
- import { AllAPITypesType, RESTTypedAPIDataStructs } from './utils/constants';
7
- import { productEnums } from '../../../../constants';
8
- import type { AgentOptions } from 'node:https';
9
- import type { RequestInit, Response } from 'node-fetch';
10
- import { Instance } from '../../../../instance/Instance';
11
- import { CADManager } from '../../../../managers/CADManager';
12
- import { CMSManager } from '../../../../managers/CMSManager';
13
- /**
14
- * Options to be passed when creating the REST instance
15
- */
16
- export interface RESTOptions {
17
- /**
18
- * HTTPS Agent options
19
- * @default {}
20
- */
21
- agent: Omit<AgentOptions, 'keepAlive'>;
22
- /**
23
- * The base api path, without version
24
- */
25
- api: string;
26
- /**
27
- * Additional headers to send for all API requests
28
- * @default {}
29
- */
30
- headers: Record<string, string>;
31
- /**
32
- * Wether the request should be queued if there's a current ratelimit or to reject.
33
- * @default true
34
- */
35
- rejectOnRateLimit: boolean;
36
- }
37
- /**
38
- * Data emitted on `RESTEvents.RateLimited`
39
- */
40
- export interface RateLimitData {
41
- product: productEnums;
42
- type: string;
43
- timeTill: NodeJS.Timer;
44
- }
45
- export interface APIRequest {
46
- /**
47
- * The HTTP method used in this request
48
- */
49
- type: AllAPITypesType;
50
- /**
51
- * Additional HTTP options for this request
52
- */
53
- options: RequestInit;
54
- /**
55
- * The data that was used to form the body of this request
56
- */
57
- data: RequestData;
58
- }
59
- export interface InvalidRequestWarningData {
60
- /**
61
- * Number of invalid requests that have been made in the window
62
- */
63
- count: number;
64
- /**
65
- * API request type which the request is for
66
- */
67
- type: string;
68
- /**
69
- * Product which the invalid request is for
70
- */
71
- product: productEnums;
72
- }
73
- export interface RestEvents {
74
- invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
75
- restDebug: [info: string];
76
- rateLimited: [rateLimitInfo: RateLimitData];
77
- request: [request: APIRequest];
78
- response: [request: APIRequest, response: Response];
79
- newListener: [name: string, listener: (...args: any) => void];
80
- removeListener: [name: string, listener: (...args: any) => void];
81
- }
82
- export interface REST {
83
- on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
84
- once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
85
- emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
86
- off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
87
- removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
88
- }
89
- export type RestManagerTypes = CADManager | CMSManager;
90
- export declare class REST extends EventEmitter {
91
- readonly requestManager: RequestManager;
92
- readonly instance: Instance;
93
- readonly manager: RestManagerTypes;
94
- constructor(_instance: Instance, _manager: RestManagerTypes, _product: productEnums, options: RESTOptions);
95
- /**
96
- * Runs a request from the api
97
- * @param type API Type Enum
98
- */
99
- request<K extends keyof RESTTypedAPIDataStructs>(type: K, ...args: RESTTypedAPIDataStructs[K]): Promise<unknown>;
100
- private formatDataArguments;
101
- }
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { EventEmitter } from 'events';
5
+ import { RequestData, RequestManager } from './RequestManager';
6
+ import { AllAPITypesType, RESTTypedAPIDataStructs } from './utils/constants';
7
+ import { productEnums } from '../../../../constants';
8
+ import type { AgentOptions } from 'node:https';
9
+ import type { RequestInit, Response } from 'node-fetch';
10
+ import { Instance } from '../../../../instance/Instance';
11
+ import { CADManager } from '../../../../managers/CADManager';
12
+ import { CMSManager } from '../../../../managers/CMSManager';
13
+ /**
14
+ * Options to be passed when creating the REST instance
15
+ */
16
+ export interface RESTOptions {
17
+ /**
18
+ * HTTPS Agent options
19
+ * @default {}
20
+ */
21
+ agent: Omit<AgentOptions, 'keepAlive'>;
22
+ /**
23
+ * The base api path, without version
24
+ */
25
+ api: string;
26
+ /**
27
+ * Additional headers to send for all API requests
28
+ * @default {}
29
+ */
30
+ headers: Record<string, string>;
31
+ /**
32
+ * Wether the request should be queued if there's a current ratelimit or to reject.
33
+ * @default true
34
+ */
35
+ rejectOnRateLimit: boolean;
36
+ }
37
+ /**
38
+ * Data emitted on `RESTEvents.RateLimited`
39
+ */
40
+ export interface RateLimitData {
41
+ product: productEnums;
42
+ type: string;
43
+ timeTill: NodeJS.Timer;
44
+ }
45
+ export interface APIRequest {
46
+ /**
47
+ * The HTTP method used in this request
48
+ */
49
+ type: AllAPITypesType;
50
+ /**
51
+ * Additional HTTP options for this request
52
+ */
53
+ options: RequestInit;
54
+ /**
55
+ * The data that was used to form the body of this request
56
+ */
57
+ data: RequestData;
58
+ }
59
+ export interface InvalidRequestWarningData {
60
+ /**
61
+ * Number of invalid requests that have been made in the window
62
+ */
63
+ count: number;
64
+ /**
65
+ * API request type which the request is for
66
+ */
67
+ type: string;
68
+ /**
69
+ * Product which the invalid request is for
70
+ */
71
+ product: productEnums;
72
+ }
73
+ export interface RestEvents {
74
+ invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
75
+ restDebug: [info: string];
76
+ rateLimited: [rateLimitInfo: RateLimitData];
77
+ request: [request: APIRequest];
78
+ response: [request: APIRequest, response: Response];
79
+ newListener: [name: string, listener: (...args: any) => void];
80
+ removeListener: [name: string, listener: (...args: any) => void];
81
+ }
82
+ export interface REST {
83
+ on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
84
+ once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
85
+ emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
86
+ off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
87
+ removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
88
+ }
89
+ export type RestManagerTypes = CADManager | CMSManager;
90
+ export declare class REST extends EventEmitter {
91
+ readonly requestManager: RequestManager;
92
+ readonly instance: Instance;
93
+ readonly manager: RestManagerTypes;
94
+ constructor(_instance: Instance, _manager: RestManagerTypes, _product: productEnums, options: RESTOptions);
95
+ /**
96
+ * Runs a request from the api
97
+ * @param type API Type Enum
98
+ */
99
+ request<K extends keyof RESTTypedAPIDataStructs>(type: K, ...args: RESTTypedAPIDataStructs[K]): Promise<unknown>;
100
+ private formatDataArguments;
101
+ }
@@ -1,129 +1,136 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REST = void 0;
4
- const events_1 = require("events");
5
- const RequestManager_1 = require("./RequestManager");
6
- const constants_1 = require("./utils/constants");
7
- const constants_2 = require("../../../../constants");
8
- class REST extends events_1.EventEmitter {
9
- constructor(_instance, _manager, _product, options) {
10
- super();
11
- this.instance = _instance;
12
- this.manager = _manager;
13
- this.requestManager = new RequestManager_1.RequestManager(_instance, _product, options)
14
- .on("restDebug" /* RESTEvents.Debug */, this.emit.bind(this, "restDebug" /* RESTEvents.Debug */))
15
- .on("rateLimited" /* RESTEvents.RateLimited */, this.emit.bind(this, "rateLimited" /* RESTEvents.RateLimited */))
16
- .on("invalidRequestWarning" /* RESTEvents.InvalidRequestWarning */, this.emit.bind(this, "invalidRequestWarning" /* RESTEvents.InvalidRequestWarning */));
17
- this.on('newListener', (name, listener) => {
18
- if (name === "request" /* RESTEvents.Request */ || name === "response" /* RESTEvents.Response */)
19
- this.requestManager.on(name, listener);
20
- });
21
- this.on('removeListener', (name, listener) => {
22
- if (name === "request" /* RESTEvents.Request */ || name === "response" /* RESTEvents.Response */)
23
- this.requestManager.off(name, listener);
24
- });
25
- }
26
- /**
27
- * Runs a request from the api
28
- * @param type API Type Enum
29
- */
30
- request(type, ...args) {
31
- const apiType = constants_1.AllAPITypes.find((aT) => aT.type === type);
32
- if (!apiType)
33
- throw new Error('Invalid API Type given for request.');
34
- let communityId;
35
- let apiKey;
36
- switch (apiType.product) {
37
- case constants_2.productEnums.CAD: {
38
- communityId = this.instance.cadCommunityId;
39
- apiKey = this.instance.cadApiKey;
40
- break;
41
- }
42
- case constants_2.productEnums.CMS: {
43
- communityId = this.instance.cmsCommunityId;
44
- apiKey = this.instance.cmsApiKey;
45
- break;
46
- }
47
- }
48
- if (!communityId || !apiKey)
49
- throw new Error(`Community ID or API Key could not be found for request. P${apiType.product}`);
50
- // if (apiType.minVersion > this.manager.version) throw new Error(`[${type}] Subscription version too low for this API type request. Current Version: ${convertSubNumToName(this.manager.version)} Needed Version: ${convertSubNumToName(apiType.minVersion)}`); // Verifies API Subscription Level Requirement which is deprecated currently
51
- const formattedData = this.formatDataArguments(apiType.type, args);
52
- const options = {
53
- id: communityId,
54
- key: apiKey,
55
- type,
56
- data: formattedData,
57
- product: apiType.product
58
- };
59
- return this.requestManager.queueRequest(options);
60
- }
61
- formatDataArguments(type, args) {
62
- switch (type) {
63
- case 'VERIFY_WHITELIST': {
64
- return {
65
- apiId: args[0],
66
- accId: constants_2.uuidRegex.test(args[1]) ? args[1] : undefined,
67
- serverId: args[2]
68
- };
69
- }
70
- case 'FULL_WHITELIST': {
71
- return {
72
- serverId: args[0]
73
- };
74
- }
75
- case 'RSVP': {
76
- return {
77
- eventId: args[0],
78
- apiId: args[1],
79
- accId: args[2],
80
- };
81
- }
82
- case 'GET_COM_ACCOUNT': {
83
- return {
84
- apiId: args[0],
85
- username: args[1],
86
- accId: args[2],
87
- discord: args[3]
88
- };
89
- }
90
- case 'GET_ACCOUNT_RANKS': {
91
- return {
92
- apiId: args[0],
93
- username: args[1],
94
- accId: args[2],
95
- discord: args[3]
96
- };
97
- }
98
- case 'CLOCK_IN_OUT': {
99
- return {
100
- apiId: args[0],
101
- accId: args[1],
102
- forceClockIn: args[2]
103
- };
104
- }
105
- case 'CHECK_COM_APIID': {
106
- return {
107
- apiId: args[0]
108
- };
109
- }
110
- case 'SET_ACCOUNT_RANKS': {
111
- return {
112
- accountId: args[0],
113
- set: args[1],
114
- add: args[2],
115
- remove: args[3],
116
- };
117
- }
118
- case 'VERIFY_SECRET': {
119
- return {
120
- secret: args[0],
121
- };
122
- }
123
- default: {
124
- return args;
125
- }
126
- }
127
- }
128
- }
129
- exports.REST = REST;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REST = void 0;
4
+ const events_1 = require("events");
5
+ const RequestManager_1 = require("./RequestManager");
6
+ const constants_1 = require("./utils/constants");
7
+ const constants_2 = require("../../../../constants");
8
+ class REST extends events_1.EventEmitter {
9
+ constructor(_instance, _manager, _product, options) {
10
+ super();
11
+ this.instance = _instance;
12
+ this.manager = _manager;
13
+ this.requestManager = new RequestManager_1.RequestManager(_instance, _product, options)
14
+ .on("restDebug" /* RESTEvents.Debug */, this.emit.bind(this, "restDebug" /* RESTEvents.Debug */))
15
+ .on("rateLimited" /* RESTEvents.RateLimited */, this.emit.bind(this, "rateLimited" /* RESTEvents.RateLimited */))
16
+ .on("invalidRequestWarning" /* RESTEvents.InvalidRequestWarning */, this.emit.bind(this, "invalidRequestWarning" /* RESTEvents.InvalidRequestWarning */));
17
+ this.on('newListener', (name, listener) => {
18
+ if (name === "request" /* RESTEvents.Request */ || name === "response" /* RESTEvents.Response */)
19
+ this.requestManager.on(name, listener);
20
+ });
21
+ this.on('removeListener', (name, listener) => {
22
+ if (name === "request" /* RESTEvents.Request */ || name === "response" /* RESTEvents.Response */)
23
+ this.requestManager.off(name, listener);
24
+ });
25
+ }
26
+ /**
27
+ * Runs a request from the api
28
+ * @param type API Type Enum
29
+ */
30
+ request(type, ...args) {
31
+ const apiType = constants_1.AllAPITypes.find((aT) => aT.type === type);
32
+ if (!apiType)
33
+ throw new Error('Invalid API Type given for request.');
34
+ let communityId;
35
+ let apiKey;
36
+ switch (apiType.product) {
37
+ case constants_2.productEnums.CAD: {
38
+ communityId = this.instance.cadCommunityId;
39
+ apiKey = this.instance.cadApiKey;
40
+ break;
41
+ }
42
+ case constants_2.productEnums.CMS: {
43
+ communityId = this.instance.cmsCommunityId;
44
+ apiKey = this.instance.cmsApiKey;
45
+ break;
46
+ }
47
+ }
48
+ if (!communityId || !apiKey)
49
+ throw new Error(`Community ID or API Key could not be found for request. P${apiType.product}`);
50
+ // if (apiType.minVersion > this.manager.version) throw new Error(`[${type}] Subscription version too low for this API type request. Current Version: ${convertSubNumToName(this.manager.version)} Needed Version: ${convertSubNumToName(apiType.minVersion)}`); // Verifies API Subscription Level Requirement which is deprecated currently
51
+ const formattedData = this.formatDataArguments(apiType.type, args);
52
+ const options = {
53
+ id: communityId,
54
+ key: apiKey,
55
+ type,
56
+ data: formattedData,
57
+ product: apiType.product
58
+ };
59
+ return this.requestManager.queueRequest(options);
60
+ }
61
+ formatDataArguments(type, args) {
62
+ switch (type) {
63
+ case 'VERIFY_WHITELIST': {
64
+ return {
65
+ apiId: args[0],
66
+ accId: constants_2.uuidRegex.test(args[1]) ? args[1] : undefined,
67
+ serverId: args[2]
68
+ };
69
+ }
70
+ case 'FULL_WHITELIST': {
71
+ return {
72
+ serverId: args[0]
73
+ };
74
+ }
75
+ case 'RSVP': {
76
+ return {
77
+ eventId: args[0],
78
+ apiId: args[1],
79
+ accId: args[2],
80
+ };
81
+ }
82
+ case 'GET_COM_ACCOUNT': {
83
+ return {
84
+ apiId: args[0],
85
+ username: args[1],
86
+ accId: args[2],
87
+ discord: args[3]
88
+ };
89
+ }
90
+ case 'GET_ACCOUNT_RANKS': {
91
+ return {
92
+ apiId: args[0],
93
+ username: args[1],
94
+ accId: args[2],
95
+ discord: args[3]
96
+ };
97
+ }
98
+ case 'CLOCK_IN_OUT': {
99
+ return {
100
+ apiId: args[0],
101
+ accId: args[1],
102
+ forceClockIn: args[2]
103
+ };
104
+ }
105
+ case 'CHECK_COM_APIID': {
106
+ return {
107
+ apiId: args[0]
108
+ };
109
+ }
110
+ case 'SET_ACCOUNT_RANKS': {
111
+ return {
112
+ accountId: args[0],
113
+ set: args[1],
114
+ add: args[2],
115
+ remove: args[3],
116
+ };
117
+ }
118
+ case 'VERIFY_SECRET': {
119
+ return {
120
+ secret: args[0],
121
+ };
122
+ }
123
+ case 'CHANGE_FORM_STAGE': {
124
+ return {
125
+ accId: args[0],
126
+ formId: args[1],
127
+ newStageId: args[2],
128
+ };
129
+ }
130
+ default: {
131
+ return args;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ exports.REST = REST;
@@ -1,59 +1,59 @@
1
- /// <reference types="node" />
2
- import { Collection } from '@discordjs/collection';
3
- import { EventEmitter } from 'events';
4
- import type { Instance } from '../../../../instance/Instance';
5
- import { RESTOptions, RateLimitData, RestEvents } from './REST';
6
- import { productEnums } from '../../../../constants';
7
- import { IHandler } from './handlers/IHandler';
8
- export type RouteLike = `/${string}`;
9
- export declare const enum RequestMethod {
10
- Delete = "delete",
11
- Get = "get",
12
- Patch = "patch",
13
- Post = "post",
14
- Put = "put"
15
- }
16
- export type ReqDataType = Array<unknown> | unknown;
17
- export interface RequestData {
18
- id: string;
19
- key: string;
20
- type: string;
21
- data: any;
22
- }
23
- export interface InternalRequestData extends RequestData {
24
- product: productEnums;
25
- }
26
- export interface RequestHeaders {
27
- 'User-Agent': string;
28
- }
29
- export interface APIData {
30
- requestTypeId: string;
31
- typePath: string;
32
- fullUrl: string;
33
- method: string;
34
- fetchOptions: RequestInit;
35
- data: RequestData;
36
- product: productEnums;
37
- type: string;
38
- }
39
- export interface RequestManager {
40
- on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
41
- once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
42
- emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
43
- off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
44
- removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
45
- }
46
- export declare class RequestManager extends EventEmitter {
47
- readonly ratelimitedTypes: Collection<string, RateLimitData>;
48
- readonly handlers: Collection<string, IHandler>;
49
- readonly product: productEnums;
50
- readonly options: RESTOptions;
51
- private instance;
52
- constructor(_instance: Instance, _product: productEnums, options: RESTOptions);
53
- queueRequest(request: InternalRequestData): Promise<unknown>;
54
- onRateLimit(id: string, rateLimitData: RateLimitData): void;
55
- removeRateLimit(id: string): void;
56
- private createHandler;
57
- private static resolveRequestData;
58
- debug(log: string): void;
59
- }
1
+ /// <reference types="node" />
2
+ import { Collection } from '@discordjs/collection';
3
+ import { EventEmitter } from 'events';
4
+ import type { Instance } from '../../../../instance/Instance';
5
+ import { RESTOptions, RateLimitData, RestEvents } from './REST';
6
+ import { productEnums } from '../../../../constants';
7
+ import { IHandler } from './handlers/IHandler';
8
+ export type RouteLike = `/${string}`;
9
+ export declare const enum RequestMethod {
10
+ Delete = "delete",
11
+ Get = "get",
12
+ Patch = "patch",
13
+ Post = "post",
14
+ Put = "put"
15
+ }
16
+ export type ReqDataType = Array<unknown> | unknown;
17
+ export interface RequestData {
18
+ id: string;
19
+ key: string;
20
+ type: string;
21
+ data: any;
22
+ }
23
+ export interface InternalRequestData extends RequestData {
24
+ product: productEnums;
25
+ }
26
+ export interface RequestHeaders {
27
+ 'User-Agent': string;
28
+ }
29
+ export interface APIData {
30
+ requestTypeId: string;
31
+ typePath: string;
32
+ fullUrl: string;
33
+ method: string;
34
+ fetchOptions: RequestInit;
35
+ data: RequestData;
36
+ product: productEnums;
37
+ type: string;
38
+ }
39
+ export interface RequestManager {
40
+ on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
41
+ once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
42
+ emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
43
+ off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
44
+ removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
45
+ }
46
+ export declare class RequestManager extends EventEmitter {
47
+ readonly ratelimitedTypes: Collection<string, RateLimitData>;
48
+ readonly handlers: Collection<string, IHandler>;
49
+ readonly product: productEnums;
50
+ readonly options: RESTOptions;
51
+ private instance;
52
+ constructor(_instance: Instance, _product: productEnums, options: RESTOptions);
53
+ queueRequest(request: InternalRequestData): Promise<unknown>;
54
+ onRateLimit(id: string, rateLimitData: RateLimitData): void;
55
+ removeRateLimit(id: string): void;
56
+ private createHandler;
57
+ private static resolveRequestData;
58
+ debug(log: string): void;
59
+ }