@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,18 +1,18 @@
1
- import { Instance } from '../instance/Instance';
2
- import { Base } from './Base';
3
- export interface CMSServerData {
4
- id: number;
5
- config: CMSServerConfig;
6
- }
7
- export interface CMSServerConfig {
8
- id: number;
9
- name: string;
10
- description: string;
11
- allowedRanks: string[];
12
- blockedRanks: string[];
13
- }
14
- export declare class CMSServer extends Base {
15
- id: number;
16
- config: CMSServerConfig;
17
- constructor(instance: Instance, data: CMSServerData);
18
- }
1
+ import { Instance } from '../instance/Instance';
2
+ import { Base } from './Base';
3
+ export interface CMSServerData {
4
+ id: number;
5
+ config: CMSServerConfig;
6
+ }
7
+ export interface CMSServerConfig {
8
+ id: number;
9
+ name: string;
10
+ description: string;
11
+ allowedRanks: string[];
12
+ blockedRanks: string[];
13
+ }
14
+ export declare class CMSServer extends Base {
15
+ id: number;
16
+ config: CMSServerConfig;
17
+ constructor(instance: Instance, data: CMSServerData);
18
+ }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CMSServer = void 0;
4
- const Base_1 = require("./Base");
5
- class CMSServer extends Base_1.Base {
6
- constructor(instance, data) {
7
- super(instance);
8
- this.id = data.id;
9
- this.config = data.config;
10
- }
11
- }
12
- exports.CMSServer = CMSServer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CMSServer = void 0;
4
+ const Base_1 = require("./Base");
5
+ class CMSServer extends Base_1.Base {
6
+ constructor(instance, data) {
7
+ super(instance);
8
+ this.id = data.id;
9
+ this.config = data.config;
10
+ }
11
+ }
12
+ exports.CMSServer = CMSServer;
@@ -1 +1 @@
1
- export * from './utils';
1
+ export * from './utils';
@@ -1,17 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./utils"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./utils"), exports);
@@ -1,13 +1,13 @@
1
- export declare function mergeDefault(def: any, given: any): any;
2
- /**
3
- * Shallow-copies an object with its class/prototype intact.
4
- * @param {Object} obj Object to clone
5
- * @returns {Object}
6
- * @private
7
- */
8
- export declare function cloneObject(obj: any): any;
9
- export declare function flatten(obj: any, ...props: any[]): any;
10
- export declare function warnLog(message: string): void;
11
- export declare function infoLog(message: string): void;
12
- export declare function errorLog(message: string): void;
13
- export declare function debugLog(message: string): void;
1
+ export declare function mergeDefault(def: any, given: any): any;
2
+ /**
3
+ * Shallow-copies an object with its class/prototype intact.
4
+ * @param {Object} obj Object to clone
5
+ * @returns {Object}
6
+ * @private
7
+ */
8
+ export declare function cloneObject(obj: any): any;
9
+ export declare function flatten(obj: any, ...props: any[]): any;
10
+ export declare function warnLog(message: string): void;
11
+ export declare function infoLog(message: string): void;
12
+ export declare function errorLog(message: string): void;
13
+ export declare function debugLog(message: string): void;
@@ -1,79 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debugLog = exports.errorLog = exports.infoLog = exports.warnLog = exports.flatten = exports.cloneObject = exports.mergeDefault = void 0;
4
- const collection_1 = require("@discordjs/collection");
5
- const isObject = (d) => typeof d === 'object' && d !== null;
6
- function mergeDefault(def, given) {
7
- if (!given)
8
- return def;
9
- for (const key in def) {
10
- if (!Object.prototype.hasOwnProperty.call(given, key) || given[key] === undefined) {
11
- given[key] = def[key];
12
- }
13
- else if (given[key] === Object(given[key])) {
14
- given[key] = mergeDefault(def[key], given[key]);
15
- }
16
- }
17
- return given;
18
- }
19
- exports.mergeDefault = mergeDefault;
20
- /**
21
- * Shallow-copies an object with its class/prototype intact.
22
- * @param {Object} obj Object to clone
23
- * @returns {Object}
24
- * @private
25
- */
26
- function cloneObject(obj) {
27
- return Object.assign(Object.create(obj), obj);
28
- }
29
- exports.cloneObject = cloneObject;
30
- function flatten(obj, ...props) {
31
- if (!isObject(obj))
32
- return obj;
33
- const objProps = Object.keys(obj)
34
- .filter((k) => !k.startsWith('_'))
35
- .map((k) => ({ [k]: true }));
36
- props = objProps.length ? Object.assign([...objProps], ...props) : Object.assign({}, ...props); // eslint-disable-line
37
- const out = {};
38
- for (let [prop, newProp] of Object.entries(props)) {
39
- if (!newProp)
40
- continue;
41
- newProp = newProp === true ? prop : newProp;
42
- const element = obj[prop];
43
- const elemIsObj = isObject(element);
44
- const valueOf = elemIsObj && typeof element.valueOf === 'function' ? element.valueOf() : null;
45
- // If it's a Collection, make the array of keys
46
- if (element instanceof collection_1.Collection)
47
- out[newProp] = Array.from(element.keys());
48
- // If the valueOf is a Collection, use its array of keys
49
- else if (valueOf instanceof collection_1.Collection)
50
- out[newProp] = Array.from(valueOf.keys());
51
- // If it's an array, flatten each element
52
- else if (Array.isArray(element))
53
- out[newProp] = element.map(e => flatten(e));
54
- // If it's an object with a primitive `valueOf`, use that value
55
- else if (typeof valueOf !== 'object')
56
- out[newProp] = valueOf;
57
- // If it's a primitive
58
- else if (!elemIsObj)
59
- out[newProp] = element;
60
- }
61
- return out;
62
- }
63
- exports.flatten = flatten;
64
- function warnLog(message) {
65
- return console.log(`[Sonoran.js - DEBUG] ${message}`);
66
- }
67
- exports.warnLog = warnLog;
68
- function infoLog(message) {
69
- return console.log(`[Sonoran.js - INFO] ${message}`);
70
- }
71
- exports.infoLog = infoLog;
72
- function errorLog(message) {
73
- return console.log(`[Sonoran.js - ERROR] ${message}`);
74
- }
75
- exports.errorLog = errorLog;
76
- function debugLog(message) {
77
- return console.log(`[Sonoran.js - DEBUG] ${message}`);
78
- }
79
- exports.debugLog = debugLog;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debugLog = exports.errorLog = exports.infoLog = exports.warnLog = exports.flatten = exports.cloneObject = exports.mergeDefault = void 0;
4
+ const collection_1 = require("@discordjs/collection");
5
+ const isObject = (d) => typeof d === 'object' && d !== null;
6
+ function mergeDefault(def, given) {
7
+ if (!given)
8
+ return def;
9
+ for (const key in def) {
10
+ if (!Object.prototype.hasOwnProperty.call(given, key) || given[key] === undefined) {
11
+ given[key] = def[key];
12
+ }
13
+ else if (given[key] === Object(given[key])) {
14
+ given[key] = mergeDefault(def[key], given[key]);
15
+ }
16
+ }
17
+ return given;
18
+ }
19
+ exports.mergeDefault = mergeDefault;
20
+ /**
21
+ * Shallow-copies an object with its class/prototype intact.
22
+ * @param {Object} obj Object to clone
23
+ * @returns {Object}
24
+ * @private
25
+ */
26
+ function cloneObject(obj) {
27
+ return Object.assign(Object.create(obj), obj);
28
+ }
29
+ exports.cloneObject = cloneObject;
30
+ function flatten(obj, ...props) {
31
+ if (!isObject(obj))
32
+ return obj;
33
+ const objProps = Object.keys(obj)
34
+ .filter((k) => !k.startsWith('_'))
35
+ .map((k) => ({ [k]: true }));
36
+ props = objProps.length ? Object.assign([...objProps], ...props) : Object.assign({}, ...props); // eslint-disable-line
37
+ const out = {};
38
+ for (let [prop, newProp] of Object.entries(props)) {
39
+ if (!newProp)
40
+ continue;
41
+ newProp = newProp === true ? prop : newProp;
42
+ const element = obj[prop];
43
+ const elemIsObj = isObject(element);
44
+ const valueOf = elemIsObj && typeof element.valueOf === 'function' ? element.valueOf() : null;
45
+ // If it's a Collection, make the array of keys
46
+ if (element instanceof collection_1.Collection)
47
+ out[newProp] = Array.from(element.keys());
48
+ // If the valueOf is a Collection, use its array of keys
49
+ else if (valueOf instanceof collection_1.Collection)
50
+ out[newProp] = Array.from(valueOf.keys());
51
+ // If it's an array, flatten each element
52
+ else if (Array.isArray(element))
53
+ out[newProp] = element.map(e => flatten(e));
54
+ // If it's an object with a primitive `valueOf`, use that value
55
+ else if (typeof valueOf !== 'object')
56
+ out[newProp] = valueOf;
57
+ // If it's a primitive
58
+ else if (!elemIsObj)
59
+ out[newProp] = element;
60
+ }
61
+ return out;
62
+ }
63
+ exports.flatten = flatten;
64
+ function warnLog(message) {
65
+ return console.log(`[Sonoran.js - DEBUG] ${message}`);
66
+ }
67
+ exports.warnLog = warnLog;
68
+ function infoLog(message) {
69
+ return console.log(`[Sonoran.js - INFO] ${message}`);
70
+ }
71
+ exports.infoLog = infoLog;
72
+ function errorLog(message) {
73
+ return console.log(`[Sonoran.js - ERROR] ${message}`);
74
+ }
75
+ exports.errorLog = errorLog;
76
+ function debugLog(message) {
77
+ return console.log(`[Sonoran.js - DEBUG] ${message}`);
78
+ }
79
+ exports.debugLog = debugLog;
@@ -1,59 +1,59 @@
1
- # Sonoran CAD Specific Methods & Usage
2
- The following methods can be accessed from the `cad` property of an instance.
3
-
4
- ## Basic General Usage
5
- ```js
6
- const Sonoran = require('sonoran.js');
7
- const instance = Sonoran.instance({
8
- communityId: 'mycommunity',
9
- apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
10
- product: Sonoran.productEnums.CAD
11
- });
12
-
13
-
14
- const whitelist = await instance.cad.getAccount('459798465498798432');
15
- ```
16
-
17
- ## getAccount(params)
18
- | Parameter | Optional | Type | Note |
19
- |----------|:-------------:|------:|-----:|
20
- | params.username | Yes | String | Must have at least apiId or accId |
21
- | params.apiId | Yes | String | Must have at least apiId or accId |
22
-
23
- Returns *accountResult*;
24
- | Property | Optional | Type | Note |
25
- |----------|:-------------:|------:|-----:|
26
- | accountResult.success | No | Boolean | Wether the whitelist verification was successful |
27
- | accountResult.account | Yes | Object | Object of the account data |
28
- | accountResult.reason | Yes | String | Fail reason if success is falsy |
29
-
30
- ### Example Code
31
- ```js
32
- const Sonoran = require('sonoran.js');
33
- const instance = Sonoran.instance({
34
- communityId: 'mycommunity',
35
- apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
36
- product: Sonoran.productEnums.CMS,
37
- serverId: 2
38
- });
39
-
40
- // This will verify the whitelist of the given API ID or account ID for server id 2 as specified above
41
- const verification = await instance.cad.getAccount('459798465498798432');
42
- // This will verify the whitelist of the given API ID for server id 1 since I specified that
43
- const verification = await instance.cad.getAccount({
44
- apiId: '459798465498798432',
45
- serverId: 1
46
- });
47
- // OR
48
- // This will verify the whitelist of the given account ID for server id 1 since I specified that
49
- const verification = await instance.cad.getAccount({
50
- accId: 'd5663516-ee35-11e9-9714-5600023b2434',
51
- serverId: 1
52
- });
53
-
54
- if (verification.success) {
55
- console.log('Success!', verification.reason);
56
- } else {
57
- console.log('Unsuccessful', verfication.reason); // Log the reason it was unsuccessful.
58
- }
1
+ # Sonoran CAD Specific Methods & Usage
2
+ The following methods can be accessed from the `cad` property of an instance.
3
+
4
+ ## Basic General Usage
5
+ ```js
6
+ const Sonoran = require('sonoran.js');
7
+ const instance = Sonoran.instance({
8
+ communityId: 'mycommunity',
9
+ apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
10
+ product: Sonoran.productEnums.CAD
11
+ });
12
+
13
+
14
+ const whitelist = await instance.cad.getAccount('459798465498798432');
15
+ ```
16
+
17
+ ## getAccount(params)
18
+ | Parameter | Optional | Type | Note |
19
+ |----------|:-------------:|------:|-----:|
20
+ | params.username | Yes | String | Must have at least apiId or accId |
21
+ | params.apiId | Yes | String | Must have at least apiId or accId |
22
+
23
+ Returns *accountResult*;
24
+ | Property | Optional | Type | Note |
25
+ |----------|:-------------:|------:|-----:|
26
+ | accountResult.success | No | Boolean | Wether the whitelist verification was successful |
27
+ | accountResult.account | Yes | Object | Object of the account data |
28
+ | accountResult.reason | Yes | String | Fail reason if success is falsy |
29
+
30
+ ### Example Code
31
+ ```js
32
+ const Sonoran = require('sonoran.js');
33
+ const instance = Sonoran.instance({
34
+ communityId: 'mycommunity',
35
+ apiKey: 'e6ba9d68-ca7a-4e59-a9e2-93e275b4e0bf',
36
+ product: Sonoran.productEnums.CMS,
37
+ serverId: 2
38
+ });
39
+
40
+ // This will verify the whitelist of the given API ID or account ID for server id 2 as specified above
41
+ const verification = await instance.cad.getAccount('459798465498798432');
42
+ // This will verify the whitelist of the given API ID for server id 1 since I specified that
43
+ const verification = await instance.cad.getAccount({
44
+ apiId: '459798465498798432',
45
+ serverId: 1
46
+ });
47
+ // OR
48
+ // This will verify the whitelist of the given account ID for server id 1 since I specified that
49
+ const verification = await instance.cad.getAccount({
50
+ accId: 'd5663516-ee35-11e9-9714-5600023b2434',
51
+ serverId: 1
52
+ });
53
+
54
+ if (verification.success) {
55
+ console.log('Success!', verification.reason);
56
+ } else {
57
+ console.log('Unsuccessful', verfication.reason); // Log the reason it was unsuccessful.
58
+ }
59
59
  ```