@sonoransoftware/sonoran.js 1.0.2 → 1.0.5

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 (43) hide show
  1. package/dist/constants.d.ts +84 -10
  2. package/dist/index.d.ts +1 -2
  3. package/dist/index.js +1 -1
  4. package/dist/libs/rest/src/lib/REST.js +23 -1
  5. package/dist/libs/rest/src/lib/utils/constants.d.ts +30 -2
  6. package/dist/libs/rest/src/lib/utils/constants.js +24 -0
  7. package/dist/managers/CMSManager.d.ts +40 -2
  8. package/dist/managers/CMSManager.js +109 -7
  9. package/dist/managers/CMSServerManager.js +6 -0
  10. package/package.json +2 -2
  11. package/src/builders/cad/DispatchCall.ts +158 -158
  12. package/src/builders/index.ts +2 -2
  13. package/src/constants.ts +85 -10
  14. package/src/errors/LibraryErrors.ts +42 -42
  15. package/src/errors/Messages.ts +6 -6
  16. package/src/errors/index.ts +1 -1
  17. package/src/index.ts +4 -12
  18. package/src/instance/Instance.ts +117 -117
  19. package/src/instance/instance.types.ts +16 -16
  20. package/src/libs/rest/src/index.ts +5 -5
  21. package/src/libs/rest/src/lib/REST.ts +23 -1
  22. package/src/libs/rest/src/lib/RequestManager.ts +255 -255
  23. package/src/libs/rest/src/lib/errors/APIError.ts +14 -14
  24. package/src/libs/rest/src/lib/errors/HTTPError.ts +21 -21
  25. package/src/libs/rest/src/lib/errors/RateLimitError.ts +20 -20
  26. package/src/libs/rest/src/lib/errors/index.ts +3 -3
  27. package/src/libs/rest/src/lib/handlers/IHandler.ts +12 -12
  28. package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +157 -157
  29. package/src/libs/rest/src/lib/utils/constants.ts +55 -2
  30. package/src/libs/rest/src/lib/utils/utils.ts +17 -17
  31. package/src/managers/BaseManager.ts +15 -15
  32. package/src/managers/CADActiveUnitsManager.ts +49 -49
  33. package/src/managers/CADManager.ts +58 -58
  34. package/src/managers/CADServerManager.ts +26 -26
  35. package/src/managers/CMSManager.ts +103 -11
  36. package/src/managers/CMSServerManager.ts +6 -0
  37. package/src/managers/CacheManager.ts +37 -37
  38. package/src/managers/DataManager.ts +63 -63
  39. package/src/structures/Base.ts +27 -27
  40. package/src/structures/CADActiveUnit.ts +84 -84
  41. package/src/structures/CADServer.ts +36 -36
  42. package/src/structures/CMSServer.ts +25 -25
  43. package/src/utils/utils.ts +74 -74
@@ -1,118 +1,118 @@
1
- import EventEmitter from 'events';
2
-
3
- import * as globalTypes from '../constants';
4
- import * as InstanceTypes from './instance.types';
5
- import { CADManager } from '../managers/CADManager';
6
- import { CMSManager } from '../managers/CMSManager';
7
- import { debugLog } from '../utils';
8
-
9
- export class Instance extends EventEmitter {
10
- public cadCommunityId: string | undefined;
11
- public cadApiKey: string | undefined;
12
- public cadApiUrl: string = 'https://api.sonorancad.com';
13
- public cadDefaultServerId: number = 1;
14
- public isCADSuccessful: boolean = false;
15
- public cmsCommunityId: string | undefined;
16
- public cmsApiKey: string | undefined;
17
- public cmsApiUrl: string = 'https://api.sonorancms.com';
18
- public cmsDefaultServerId: number = 1;
19
- public isCMSSuccessful: boolean = false;
20
-
21
- public cad: CADManager | undefined;
22
- public cms: CMSManager | undefined;
23
-
24
- public debug: boolean = false;
25
-
26
- constructor(options: InstanceTypes.InstanceOptions) {
27
- super({ captureRejections: true });
28
- if (options.debug) {
29
- this.debug = options.debug;
30
- }
31
- if (Object.prototype.hasOwnProperty.call(options, 'apiKey') && Object.prototype.hasOwnProperty.call(options, 'communityId')) {
32
- if (Object.prototype.hasOwnProperty.call(options, 'product')) {
33
- switch (options.product) {
34
- case globalTypes.productEnums.CAD: {
35
- this.cadCommunityId = options.communityId;
36
- this.cadApiKey = options.apiKey;
37
- if (options.serverId !== undefined) {
38
- this._debugLog(`Overriding default server id... ${options.serverId}`);
39
- this.cadDefaultServerId = options.serverId;
40
- }
41
- if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
42
- this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
43
- this.cadApiUrl = options.cadApiUrl;
44
- }
45
- this._debugLog('About to initialize instance.');
46
- this.initialize();
47
- break;
48
- }
49
- case globalTypes.productEnums.CMS: {
50
- this.cmsCommunityId = options.communityId;
51
- this.cmsApiKey = options.apiKey;
52
- if (options.serverId !== undefined) {
53
- this._debugLog(`Overriding default server id... ${options.serverId}`);
54
- this.cmsDefaultServerId = options.serverId;
55
- }
56
- if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
57
- this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
58
- this.cmsApiUrl = options.cmsApiUrl;
59
- }
60
- this.initialize();
61
- break;
62
- }
63
- default: {
64
- throw new Error('Invalid product enum given for constructor.');
65
- }
66
- }
67
- } else {
68
- throw new Error('No product enum given when instancing.');
69
- }
70
- } else {
71
- this.cadCommunityId = options.cadCommunityId;
72
- this.cadApiKey = options.cadApiKey;
73
- this.cmsCommunityId = options.cmsCommunityId;
74
- this.cmsApiKey = options.cmsApiKey;
75
-
76
- if (options.cadDefaultServerId !== undefined) {
77
- this._debugLog(`Overriding default CAD server id... ${options.serverId}`);
78
- this.cadDefaultServerId = options.cadDefaultServerId;
79
- }
80
- if (options.cmsDefaultServerId !== undefined) {
81
- this._debugLog(`Overriding default CMS server id... ${options.serverId}`);
82
- this.cmsDefaultServerId = options.cmsDefaultServerId;
83
- }
84
- if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
85
- this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
86
- this.cadApiUrl = options.cadApiUrl;
87
- }
88
- if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
89
- this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
90
- this.cmsApiUrl = options.cmsApiUrl;
91
- }
92
- this.initialize();
93
- }
94
- }
95
-
96
-
97
-
98
- private initialize() {
99
- if (this.cadCommunityId && this.cadApiKey && this.cadApiUrl) {
100
- this._debugLog('About to initialize CAD Manager');
101
- this.cad = new CADManager(this);
102
- } else {
103
- this._debugLog('Not initializing CAD Manager due to a missing community id, api key, or api url.');
104
- }
105
- if (this.cmsCommunityId && this.cmsApiKey && this.cmsApiUrl) {
106
- this._debugLog('About to initialize CMS Manager');
107
- this.cms = new CMSManager(this);
108
- } else {
109
- this._debugLog('Not initializing CMS Manager due to a missing community id, api key, or api url.');
110
- }
111
- }
112
-
113
- public _debugLog(message: string): void {
114
- if (this.debug) {
115
- debugLog(message);
116
- }
117
- }
1
+ import EventEmitter from 'events';
2
+
3
+ import * as globalTypes from '../constants';
4
+ import * as InstanceTypes from './instance.types';
5
+ import { CADManager } from '../managers/CADManager';
6
+ import { CMSManager } from '../managers/CMSManager';
7
+ import { debugLog } from '../utils';
8
+
9
+ export class Instance extends EventEmitter {
10
+ public cadCommunityId: string | undefined;
11
+ public cadApiKey: string | undefined;
12
+ public cadApiUrl: string = 'https://api.sonorancad.com';
13
+ public cadDefaultServerId: number = 1;
14
+ public isCADSuccessful: boolean = false;
15
+ public cmsCommunityId: string | undefined;
16
+ public cmsApiKey: string | undefined;
17
+ public cmsApiUrl: string = 'https://api.sonorancms.com';
18
+ public cmsDefaultServerId: number = 1;
19
+ public isCMSSuccessful: boolean = false;
20
+
21
+ public cad: CADManager | undefined;
22
+ public cms: CMSManager | undefined;
23
+
24
+ public debug: boolean = false;
25
+
26
+ constructor(options: InstanceTypes.InstanceOptions) {
27
+ super({ captureRejections: true });
28
+ if (options.debug) {
29
+ this.debug = options.debug;
30
+ }
31
+ if (Object.prototype.hasOwnProperty.call(options, 'apiKey') && Object.prototype.hasOwnProperty.call(options, 'communityId')) {
32
+ if (Object.prototype.hasOwnProperty.call(options, 'product')) {
33
+ switch (options.product) {
34
+ case globalTypes.productEnums.CAD: {
35
+ this.cadCommunityId = options.communityId;
36
+ this.cadApiKey = options.apiKey;
37
+ if (options.serverId !== undefined) {
38
+ this._debugLog(`Overriding default server id... ${options.serverId}`);
39
+ this.cadDefaultServerId = options.serverId;
40
+ }
41
+ if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
42
+ this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
43
+ this.cadApiUrl = options.cadApiUrl;
44
+ }
45
+ this._debugLog('About to initialize instance.');
46
+ this.initialize();
47
+ break;
48
+ }
49
+ case globalTypes.productEnums.CMS: {
50
+ this.cmsCommunityId = options.communityId;
51
+ this.cmsApiKey = options.apiKey;
52
+ if (options.serverId !== undefined) {
53
+ this._debugLog(`Overriding default server id... ${options.serverId}`);
54
+ this.cmsDefaultServerId = options.serverId;
55
+ }
56
+ if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
57
+ this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
58
+ this.cmsApiUrl = options.cmsApiUrl;
59
+ }
60
+ this.initialize();
61
+ break;
62
+ }
63
+ default: {
64
+ throw new Error('Invalid product enum given for constructor.');
65
+ }
66
+ }
67
+ } else {
68
+ throw new Error('No product enum given when instancing.');
69
+ }
70
+ } else {
71
+ this.cadCommunityId = options.cadCommunityId;
72
+ this.cadApiKey = options.cadApiKey;
73
+ this.cmsCommunityId = options.cmsCommunityId;
74
+ this.cmsApiKey = options.cmsApiKey;
75
+
76
+ if (options.cadDefaultServerId !== undefined) {
77
+ this._debugLog(`Overriding default CAD server id... ${options.serverId}`);
78
+ this.cadDefaultServerId = options.cadDefaultServerId;
79
+ }
80
+ if (options.cmsDefaultServerId !== undefined) {
81
+ this._debugLog(`Overriding default CMS server id... ${options.serverId}`);
82
+ this.cmsDefaultServerId = options.cmsDefaultServerId;
83
+ }
84
+ if (Object.prototype.hasOwnProperty.call(options, 'cadApiUrl') && typeof options.cadApiUrl === 'string') {
85
+ this._debugLog(`Overriding CAD API Url... ${options.cadApiUrl}`);
86
+ this.cadApiUrl = options.cadApiUrl;
87
+ }
88
+ if (Object.prototype.hasOwnProperty.call(options, 'cmsApiUrl') && typeof options.cmsApiUrl === 'string') {
89
+ this._debugLog(`Overriding CMS API URL... ${options.cmsApiUrl}`);
90
+ this.cmsApiUrl = options.cmsApiUrl;
91
+ }
92
+ this.initialize();
93
+ }
94
+ }
95
+
96
+
97
+
98
+ private initialize() {
99
+ if (this.cadCommunityId && this.cadApiKey && this.cadApiUrl) {
100
+ this._debugLog('About to initialize CAD Manager');
101
+ this.cad = new CADManager(this);
102
+ } else {
103
+ this._debugLog('Not initializing CAD Manager due to a missing community id, api key, or api url.');
104
+ }
105
+ if (this.cmsCommunityId && this.cmsApiKey && this.cmsApiUrl) {
106
+ this._debugLog('About to initialize CMS Manager');
107
+ this.cms = new CMSManager(this);
108
+ } else {
109
+ this._debugLog('Not initializing CMS Manager due to a missing community id, api key, or api url.');
110
+ }
111
+ }
112
+
113
+ public _debugLog(message: string): void {
114
+ if (this.debug) {
115
+ debugLog(message);
116
+ }
117
+ }
118
118
  }
@@ -1,17 +1,17 @@
1
- import * as globalTypes from '../constants';
2
-
3
- export type InstanceOptions = {
4
- communityId?: string;
5
- apiKey?: string;
6
- product?: globalTypes.productEnums;
7
- serverId?: number;
8
- cadCommunityId?: string;
9
- cadApiKey?: string;
10
- cadApiUrl?: string;
11
- cadDefaultServerId?: number;
12
- cmsCommunityId?: string;
13
- cmsApiKey?: string;
14
- cmsApiUrl?: string;
15
- cmsDefaultServerId?: number;
16
- debug?: boolean;
1
+ import * as globalTypes from '../constants';
2
+
3
+ export type InstanceOptions = {
4
+ communityId?: string;
5
+ apiKey?: string;
6
+ product?: globalTypes.productEnums;
7
+ serverId?: number;
8
+ cadCommunityId?: string;
9
+ cadApiKey?: string;
10
+ cadApiUrl?: string;
11
+ cadDefaultServerId?: number;
12
+ cmsCommunityId?: string;
13
+ cmsApiKey?: string;
14
+ cmsApiUrl?: string;
15
+ cmsDefaultServerId?: number;
16
+ debug?: boolean;
17
17
  };
@@ -1,6 +1,6 @@
1
- export * from './lib/errors/APIError';
2
- export * from './lib/errors/HTTPError';
3
- export * from './lib/errors/RateLimitError';
4
- export * from './lib/RequestManager';
5
- export * from './lib/REST';
1
+ export * from './lib/errors/APIError';
2
+ export * from './lib/errors/HTTPError';
3
+ export * from './lib/errors/RateLimitError';
4
+ export * from './lib/RequestManager';
5
+ export * from './lib/REST';
6
6
  export * from './lib/utils/constants';
@@ -174,11 +174,25 @@ export class REST extends EventEmitter {
174
174
  serverId: args[2]
175
175
  }
176
176
  }
177
+ case 'FULL_WHITELIST': {
178
+ return {
179
+ serverId: args[0]
180
+ }
181
+ }
177
182
  case 'GET_COM_ACCOUNT': {
178
183
  return {
179
184
  apiId: args[0],
180
185
  username: args[1],
181
- accId: args[2]
186
+ accId: args[2],
187
+ discord: args[3]
188
+ };
189
+ }
190
+ case 'GET_ACCOUNT_RANKS': {
191
+ return {
192
+ apiId: args[0],
193
+ username: args[1],
194
+ accId: args[2],
195
+ discord: args[3]
182
196
  };
183
197
  }
184
198
  case 'CLOCK_IN_OUT': {
@@ -193,6 +207,14 @@ export class REST extends EventEmitter {
193
207
  apiId: args[0]
194
208
  };
195
209
  }
210
+ case 'SET_ACCOUNT_RANKS': {
211
+ return {
212
+ accountId: args[0],
213
+ set: args[1].set,
214
+ add: args[1].add,
215
+ remove: args[1].remove,
216
+ };
217
+ }
196
218
  default: {
197
219
  return args;
198
220
  }