@sonoransoftware/sonoran.js 1.0.3 → 1.0.6
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/constants.d.ts +56 -0
- package/dist/libs/rest/src/lib/REST.js +18 -1
- package/dist/libs/rest/src/lib/utils/constants.d.ts +23 -3
- package/dist/libs/rest/src/lib/utils/constants.js +12 -0
- package/dist/managers/CMSManager.d.ts +19 -0
- package/dist/managers/CMSManager.js +61 -6
- package/dist/managers/CMSServerManager.js +6 -0
- package/package.json +2 -2
- package/src/builders/cad/DispatchCall.ts +158 -158
- package/src/builders/index.ts +2 -2
- package/src/constants.ts +58 -0
- package/src/errors/LibraryErrors.ts +42 -42
- package/src/errors/Messages.ts +6 -6
- package/src/errors/index.ts +1 -1
- package/src/index.ts +3 -3
- package/src/instance/Instance.ts +117 -117
- package/src/instance/instance.types.ts +16 -16
- package/src/libs/rest/src/index.ts +5 -5
- package/src/libs/rest/src/lib/REST.ts +19 -2
- package/src/libs/rest/src/lib/RequestManager.ts +255 -255
- package/src/libs/rest/src/lib/errors/APIError.ts +14 -14
- package/src/libs/rest/src/lib/errors/HTTPError.ts +21 -21
- package/src/libs/rest/src/lib/errors/RateLimitError.ts +20 -20
- package/src/libs/rest/src/lib/errors/index.ts +3 -3
- package/src/libs/rest/src/lib/handlers/IHandler.ts +12 -12
- package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +157 -157
- package/src/libs/rest/src/lib/utils/constants.ts +35 -2
- package/src/libs/rest/src/lib/utils/utils.ts +17 -17
- package/src/managers/BaseManager.ts +15 -15
- package/src/managers/CADActiveUnitsManager.ts +49 -49
- package/src/managers/CADManager.ts +58 -58
- package/src/managers/CADServerManager.ts +26 -26
- package/src/managers/CMSManager.ts +60 -11
- package/src/managers/CMSServerManager.ts +6 -0
- package/src/managers/CacheManager.ts +37 -37
- package/src/managers/DataManager.ts +63 -63
- package/src/structures/Base.ts +27 -27
- package/src/structures/CADActiveUnit.ts +84 -84
- package/src/structures/CADServer.ts +36 -36
- package/src/structures/CMSServer.ts +25 -25
- package/src/utils/utils.ts +74 -74
package/src/builders/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './cad';
|
|
2
|
-
// export * from './cms';
|
|
1
|
+
export * from './cad';
|
|
2
|
+
// export * from './cms';
|
|
3
3
|
// export * from './global';
|
package/src/constants.ts
CHANGED
|
@@ -132,6 +132,56 @@ export interface CMSCheckComApiIdPromiseResult {
|
|
|
132
132
|
username?: string;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
export interface CMSGetDepartmentsPromiseResult {
|
|
136
|
+
success: boolean;
|
|
137
|
+
reason?: string;
|
|
138
|
+
data?: CMSDepartment[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface CMSSetAccountRanksPromiseResult {
|
|
142
|
+
success: boolean;
|
|
143
|
+
reason?: string;
|
|
144
|
+
data?: {
|
|
145
|
+
accId: string;
|
|
146
|
+
sysStatus: boolean;
|
|
147
|
+
comStatus: boolean;
|
|
148
|
+
joinDate: string;
|
|
149
|
+
lastLogin: string;
|
|
150
|
+
owner: boolean;
|
|
151
|
+
banned: boolean;
|
|
152
|
+
activeApiIds: string[];
|
|
153
|
+
primaryIdentifier: string;
|
|
154
|
+
secondaryIdentifiers: {
|
|
155
|
+
identifiers: { id: string; label: string; }[];
|
|
156
|
+
}
|
|
157
|
+
primaryRank: string;
|
|
158
|
+
secondaryRanks: string[];
|
|
159
|
+
primaryDepartment: string;
|
|
160
|
+
secondaryDepartments: string[];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface CMSSetAccountRanksChangesObject {
|
|
165
|
+
set?: {
|
|
166
|
+
primary?: string | null;
|
|
167
|
+
secondary?: string[];
|
|
168
|
+
}
|
|
169
|
+
add: string[];
|
|
170
|
+
remove: string[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface CMSDepartment {
|
|
174
|
+
uuid: string;
|
|
175
|
+
label: string;
|
|
176
|
+
labelTwo: string;
|
|
177
|
+
ranks: {
|
|
178
|
+
id: string;
|
|
179
|
+
label: string;
|
|
180
|
+
primaryOnly: boolean;
|
|
181
|
+
secondaryOnly: boolean;
|
|
182
|
+
}[];
|
|
183
|
+
}
|
|
184
|
+
|
|
135
185
|
export interface CADGetAccountPromiseResult {
|
|
136
186
|
success: boolean;
|
|
137
187
|
reason?: string;
|
|
@@ -188,4 +238,12 @@ export interface CADGetAccountPromiseResult {
|
|
|
188
238
|
},
|
|
189
239
|
apiIds: string[];
|
|
190
240
|
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface clockInOutRequest {
|
|
244
|
+
id: number;
|
|
245
|
+
notes: any[];
|
|
246
|
+
endTime: string;
|
|
247
|
+
completed: boolean;
|
|
248
|
+
startTime: string;
|
|
191
249
|
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const messages = new Map();
|
|
2
|
-
|
|
3
|
-
export class GenericError extends Error {
|
|
4
|
-
private readonly errCode: string;
|
|
5
|
-
constructor(key: string, ...args: Array<any>) {
|
|
6
|
-
super(GenericError.message(key, args));
|
|
7
|
-
this.errCode = key;
|
|
8
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, GenericError);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
get name(): string {
|
|
12
|
-
return `${super.name} [${this.errCode}]`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get code(): string {
|
|
16
|
-
return this.errCode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Format the message for an error.
|
|
21
|
-
* @param {string} key Error key
|
|
22
|
-
* @param {Array<any>} args Arguments to pass for util format or as function args
|
|
23
|
-
* @returns {string} Formatted string
|
|
24
|
-
*/
|
|
25
|
-
private static message(key: string, args: Array<any>): string {
|
|
26
|
-
if (typeof key !== 'string') throw new Error('Error message key must be a string');
|
|
27
|
-
const msg = messages.get(key);
|
|
28
|
-
if (!msg) throw new Error(`An invalid error message key was used: ${key}.`);
|
|
29
|
-
if (typeof msg === 'function') return msg(...args);
|
|
30
|
-
if (!args?.length) return msg;
|
|
31
|
-
args.unshift(msg);
|
|
32
|
-
return String(...args);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Register an error code and message.
|
|
38
|
-
* @param {string} sym Unique name for the error
|
|
39
|
-
* @param {*} val Value of the error
|
|
40
|
-
*/
|
|
41
|
-
export function register(sym: symbol, val: any): void {
|
|
42
|
-
messages.set(sym, typeof val === 'function' ? val : String(val));
|
|
1
|
+
const messages = new Map();
|
|
2
|
+
|
|
3
|
+
export class GenericError extends Error {
|
|
4
|
+
private readonly errCode: string;
|
|
5
|
+
constructor(key: string, ...args: Array<any>) {
|
|
6
|
+
super(GenericError.message(key, args));
|
|
7
|
+
this.errCode = key;
|
|
8
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, GenericError);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get name(): string {
|
|
12
|
+
return `${super.name} [${this.errCode}]`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get code(): string {
|
|
16
|
+
return this.errCode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Format the message for an error.
|
|
21
|
+
* @param {string} key Error key
|
|
22
|
+
* @param {Array<any>} args Arguments to pass for util format or as function args
|
|
23
|
+
* @returns {string} Formatted string
|
|
24
|
+
*/
|
|
25
|
+
private static message(key: string, args: Array<any>): string {
|
|
26
|
+
if (typeof key !== 'string') throw new Error('Error message key must be a string');
|
|
27
|
+
const msg = messages.get(key);
|
|
28
|
+
if (!msg) throw new Error(`An invalid error message key was used: ${key}.`);
|
|
29
|
+
if (typeof msg === 'function') return msg(...args);
|
|
30
|
+
if (!args?.length) return msg;
|
|
31
|
+
args.unshift(msg);
|
|
32
|
+
return String(...args);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Register an error code and message.
|
|
38
|
+
* @param {string} sym Unique name for the error
|
|
39
|
+
* @param {*} val Value of the error
|
|
40
|
+
*/
|
|
41
|
+
export function register(sym: symbol, val: any): void {
|
|
42
|
+
messages.set(sym, typeof val === 'function' ? val : String(val));
|
|
43
43
|
}
|
package/src/errors/Messages.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { register } from './LibraryErrors';
|
|
2
|
-
|
|
3
|
-
const Messages: Record<string | number | symbol, any> = {
|
|
4
|
-
NOT_IMPLEMENTED: (what: string, name: string) => `Method ${what} not implemented on ${name}.`
|
|
5
|
-
};
|
|
6
|
-
|
|
1
|
+
import { register } from './LibraryErrors';
|
|
2
|
+
|
|
3
|
+
const Messages: Record<string | number | symbol, any> = {
|
|
4
|
+
NOT_IMPLEMENTED: (what: string, name: string) => `Method ${what} not implemented on ${name}.`
|
|
5
|
+
};
|
|
6
|
+
|
|
7
7
|
for (const [name, message] of Object.entries(Messages)) register(Symbol(name), message);
|
package/src/errors/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './LibraryErrors';
|
|
1
|
+
export * from './LibraryErrors';
|
|
2
2
|
export * from './Messages';
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './instance/Instance';
|
|
2
|
-
export * from './builders';
|
|
3
|
-
export * from './libs/rest/src';
|
|
1
|
+
export * from './instance/Instance';
|
|
2
|
+
export * from './builders';
|
|
3
|
+
export * from './libs/rest/src';
|
|
4
4
|
export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum } from './constants';
|
package/src/instance/Instance.ts
CHANGED
|
@@ -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';
|
|
@@ -183,7 +183,16 @@ export class REST extends EventEmitter {
|
|
|
183
183
|
return {
|
|
184
184
|
apiId: args[0],
|
|
185
185
|
username: args[1],
|
|
186
|
-
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]
|
|
187
196
|
};
|
|
188
197
|
}
|
|
189
198
|
case 'CLOCK_IN_OUT': {
|
|
@@ -198,9 +207,17 @@ export class REST extends EventEmitter {
|
|
|
198
207
|
apiId: args[0]
|
|
199
208
|
};
|
|
200
209
|
}
|
|
210
|
+
case 'SET_ACCOUNT_RANKS': {
|
|
211
|
+
return {
|
|
212
|
+
accountId: args[0],
|
|
213
|
+
set: args[1],
|
|
214
|
+
add: args[2],
|
|
215
|
+
remove: args[3],
|
|
216
|
+
};
|
|
217
|
+
}
|
|
201
218
|
default: {
|
|
202
219
|
return args;
|
|
203
220
|
}
|
|
204
221
|
}
|
|
205
222
|
}
|
|
206
|
-
}
|
|
223
|
+
}
|