@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.
- package/dist/constants.d.ts +84 -10
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/libs/rest/src/lib/REST.js +23 -1
- package/dist/libs/rest/src/lib/utils/constants.d.ts +30 -2
- package/dist/libs/rest/src/lib/utils/constants.js +24 -0
- package/dist/managers/CMSManager.d.ts +40 -2
- package/dist/managers/CMSManager.js +109 -7
- 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 +85 -10
- 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 +4 -12
- 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 +23 -1
- 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 +55 -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 +103 -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/dist/constants.d.ts
CHANGED
|
@@ -61,26 +61,42 @@ export interface CMSVerifyWhitelistPromiseResult {
|
|
|
61
61
|
success: boolean;
|
|
62
62
|
reason?: string;
|
|
63
63
|
}
|
|
64
|
+
export interface CMSGetFullWhitelistPromiseResult {
|
|
65
|
+
success: boolean;
|
|
66
|
+
reason?: string;
|
|
67
|
+
data?: {
|
|
68
|
+
name: string;
|
|
69
|
+
apiIds: string[];
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
72
|
+
export interface CMSGetAccountRanksPromiseResult {
|
|
73
|
+
success: boolean;
|
|
74
|
+
reason?: string;
|
|
75
|
+
data?: string[];
|
|
76
|
+
}
|
|
64
77
|
export interface CMSGetComAccountPromiseResult {
|
|
65
78
|
success: boolean;
|
|
66
79
|
reason?: string;
|
|
67
80
|
data?: {
|
|
68
81
|
accId: string;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
sysStatus: boolean;
|
|
83
|
+
comStatus: boolean;
|
|
84
|
+
joinDate: string;
|
|
85
|
+
lastLogin: string;
|
|
86
|
+
owner: boolean;
|
|
87
|
+
banned: boolean;
|
|
88
|
+
activeApiIds: string[];
|
|
72
89
|
primaryIdentifier: string;
|
|
73
|
-
secondaryIdentifiers:
|
|
90
|
+
secondaryIdentifiers: {
|
|
91
|
+
identifiers: {
|
|
92
|
+
id: string;
|
|
93
|
+
label: string;
|
|
94
|
+
}[];
|
|
95
|
+
};
|
|
74
96
|
primaryRank: string;
|
|
75
97
|
secondaryRanks: string[];
|
|
76
98
|
primaryDepartment: string;
|
|
77
99
|
secondaryDepartments: string[];
|
|
78
|
-
joinDate: string;
|
|
79
|
-
totalRankPower: number;
|
|
80
|
-
comOwner: boolean;
|
|
81
|
-
isBanned: boolean;
|
|
82
|
-
lastLogin: string;
|
|
83
|
-
activeApiIds: string[];
|
|
84
100
|
};
|
|
85
101
|
}
|
|
86
102
|
export declare const uuidRegex: RegExp;
|
|
@@ -99,6 +115,55 @@ export interface CMSCheckComApiIdPromiseResult {
|
|
|
99
115
|
reason?: string;
|
|
100
116
|
username?: string;
|
|
101
117
|
}
|
|
118
|
+
export interface CMSGetDepartmentsPromiseResult {
|
|
119
|
+
success: boolean;
|
|
120
|
+
reason?: string;
|
|
121
|
+
data?: CMSDepartment[];
|
|
122
|
+
}
|
|
123
|
+
export interface CMSSetAccountRanksPromiseResult {
|
|
124
|
+
success: boolean;
|
|
125
|
+
reason?: string;
|
|
126
|
+
data?: {
|
|
127
|
+
accId: string;
|
|
128
|
+
sysStatus: boolean;
|
|
129
|
+
comStatus: boolean;
|
|
130
|
+
joinDate: string;
|
|
131
|
+
lastLogin: string;
|
|
132
|
+
owner: boolean;
|
|
133
|
+
banned: boolean;
|
|
134
|
+
activeApiIds: string[];
|
|
135
|
+
primaryIdentifier: string;
|
|
136
|
+
secondaryIdentifiers: {
|
|
137
|
+
identifiers: {
|
|
138
|
+
id: string;
|
|
139
|
+
label: string;
|
|
140
|
+
}[];
|
|
141
|
+
};
|
|
142
|
+
primaryRank: string;
|
|
143
|
+
secondaryRanks: string[];
|
|
144
|
+
primaryDepartment: string;
|
|
145
|
+
secondaryDepartments: string[];
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export interface CMSSetAccountRanksChangesObject {
|
|
149
|
+
set?: {
|
|
150
|
+
primary?: string | null;
|
|
151
|
+
secondary?: string[];
|
|
152
|
+
};
|
|
153
|
+
add: string[];
|
|
154
|
+
remove: string[];
|
|
155
|
+
}
|
|
156
|
+
export interface CMSDepartment {
|
|
157
|
+
uuid: string;
|
|
158
|
+
label: string;
|
|
159
|
+
labelTwo: string;
|
|
160
|
+
ranks: {
|
|
161
|
+
id: string;
|
|
162
|
+
label: string;
|
|
163
|
+
primaryOnly: boolean;
|
|
164
|
+
secondaryOnly: boolean;
|
|
165
|
+
}[];
|
|
166
|
+
}
|
|
102
167
|
export interface CADGetAccountPromiseResult {
|
|
103
168
|
success: boolean;
|
|
104
169
|
reason?: string;
|
|
@@ -124,6 +189,7 @@ export interface CADGetAccountPromiseResult {
|
|
|
124
189
|
polEditUnit: boolean;
|
|
125
190
|
polEditOtherUnit: boolean;
|
|
126
191
|
selfDispatch: boolean;
|
|
192
|
+
liveMap: boolean;
|
|
127
193
|
medRecAdd: boolean;
|
|
128
194
|
medRecEdit: boolean;
|
|
129
195
|
medRecRemove: boolean;
|
|
@@ -136,6 +202,7 @@ export interface CADGetAccountPromiseResult {
|
|
|
136
202
|
dmvRecEdit: boolean;
|
|
137
203
|
dmvRecRemove: boolean;
|
|
138
204
|
dmvSuper: boolean;
|
|
205
|
+
modifyStreetSigns: boolean;
|
|
139
206
|
lawRecAdd: boolean;
|
|
140
207
|
lawRecEdit: boolean;
|
|
141
208
|
lawRecRemove: boolean;
|
|
@@ -154,3 +221,10 @@ export interface CADGetAccountPromiseResult {
|
|
|
154
221
|
apiIds: string[];
|
|
155
222
|
};
|
|
156
223
|
}
|
|
224
|
+
export interface clockInOutRequest {
|
|
225
|
+
id: number;
|
|
226
|
+
notes: any[];
|
|
227
|
+
endTime: string;
|
|
228
|
+
completed: boolean;
|
|
229
|
+
startTime: string;
|
|
230
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './instance/Instance';
|
|
2
2
|
export * from './builders';
|
|
3
3
|
export * from './libs/rest/src';
|
|
4
|
-
|
|
5
|
-
export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum };
|
|
4
|
+
export { productEnums, CADNewDispatchBuilderOptions, CADSubscriptionVersionEnum, CMSSubscriptionVersionEnum } from './constants';
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.CMSSubscriptionVersionEnum = exports.CADSubscriptionVersionEnum = export
|
|
|
18
18
|
__exportStar(require("./instance/Instance"), exports);
|
|
19
19
|
__exportStar(require("./builders"), exports);
|
|
20
20
|
__exportStar(require("./libs/rest/src"), exports);
|
|
21
|
-
|
|
21
|
+
var constants_1 = require("./constants");
|
|
22
22
|
Object.defineProperty(exports, "productEnums", { enumerable: true, get: function () { return constants_1.productEnums; } });
|
|
23
23
|
Object.defineProperty(exports, "CADSubscriptionVersionEnum", { enumerable: true, get: function () { return constants_1.CADSubscriptionVersionEnum; } });
|
|
24
24
|
Object.defineProperty(exports, "CMSSubscriptionVersionEnum", { enumerable: true, get: function () { return constants_1.CMSSubscriptionVersionEnum; } });
|
|
@@ -69,11 +69,25 @@ class REST extends events_1.EventEmitter {
|
|
|
69
69
|
serverId: args[2]
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
+
case 'FULL_WHITELIST': {
|
|
73
|
+
return {
|
|
74
|
+
serverId: args[0]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
72
77
|
case 'GET_COM_ACCOUNT': {
|
|
73
78
|
return {
|
|
74
79
|
apiId: args[0],
|
|
75
80
|
username: args[1],
|
|
76
|
-
accId: args[2]
|
|
81
|
+
accId: args[2],
|
|
82
|
+
discord: args[3]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
case 'GET_ACCOUNT_RANKS': {
|
|
86
|
+
return {
|
|
87
|
+
apiId: args[0],
|
|
88
|
+
username: args[1],
|
|
89
|
+
accId: args[2],
|
|
90
|
+
discord: args[3]
|
|
77
91
|
};
|
|
78
92
|
}
|
|
79
93
|
case 'CLOCK_IN_OUT': {
|
|
@@ -88,6 +102,14 @@ class REST extends events_1.EventEmitter {
|
|
|
88
102
|
apiId: args[0]
|
|
89
103
|
};
|
|
90
104
|
}
|
|
105
|
+
case 'SET_ACCOUNT_RANKS': {
|
|
106
|
+
return {
|
|
107
|
+
accountId: args[0],
|
|
108
|
+
set: args[1].set,
|
|
109
|
+
add: args[1].add,
|
|
110
|
+
remove: args[1].remove,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
91
113
|
default: {
|
|
92
114
|
return args;
|
|
93
115
|
}
|
|
@@ -32,7 +32,7 @@ export declare const EmergencyCADAPITypes: APITypeData[];
|
|
|
32
32
|
export declare const GeneralCMSAPITypes: APITypeData[];
|
|
33
33
|
export declare const ServersCMSAPITypes: APITypeData[];
|
|
34
34
|
export declare const AllAPITypes: AllAPITypeData[];
|
|
35
|
-
export declare type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT';
|
|
35
|
+
export declare type AllAPITypesType = 'GET_SERVERS' | 'SET_SERVERS' | 'GET_VERSION' | 'SET_PENAL_CODES' | 'SET_API_ID' | 'GET_TEMPLATES' | 'NEW_RECORD' | 'EDIT_RECORD' | 'REMOVE_RECORD' | 'LOOKUP_INT' | 'LOOKUP' | 'GET_ACCOUNT' | 'CHECK_APIID' | 'APPLY_PERMISSION_KEY' | 'SET_ACCOUNT_PERMISSIONS' | 'BAN_USER' | 'VERIFY_SECRET' | 'AUTH_STREETSIGNS' | 'SET_POSTALS' | 'SEND_PHOTO' | 'GET_CHARACTERS' | 'NEW_CHARACTER' | 'EDIT_CHARACTER' | 'REMOVE_CHARACTER' | 'GET_IDENTIFIERS' | 'MODIFY_IDENTIFIER' | 'SET_IDENTIFIER' | 'UNIT_PANIC' | 'UNIT_STATUS' | 'GET_BLIPS' | 'ADD_BLIP' | 'MODIFY_BLIP' | 'REMOVE_BLIP' | '911_CALL' | 'REMOVE_911' | 'GET_CALLS' | 'GET_ACTIVE_UNITS' | 'KICK_UNIT' | 'NEW_DISPATCH' | 'ATTACH_UNIT' | 'DETACH_UNIT' | 'SET_CALL_POSTAL' | 'SET_CALL_PRIMARY' | 'ADD_CALL_NOTE' | 'CLOSE_CALL' | 'UNIT_LOCATION' | 'SET_STREETSIGN_CONFIG' | 'UPDATE_STREETSIGN' | 'GET_COM_ACCOUNT' | 'GET_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS';
|
|
36
36
|
export interface CMSServerAPIStruct {
|
|
37
37
|
id: number;
|
|
38
38
|
name: string;
|
|
@@ -386,7 +386,8 @@ export interface RESTTypedAPIDataStructs {
|
|
|
386
386
|
GET_COM_ACCOUNT: [
|
|
387
387
|
apiId?: string,
|
|
388
388
|
username?: string,
|
|
389
|
-
accId?: string
|
|
389
|
+
accId?: string,
|
|
390
|
+
discord?: string
|
|
390
391
|
];
|
|
391
392
|
GET_SUB_VERSION: [];
|
|
392
393
|
CHECK_COM_APIID: [apiId: string];
|
|
@@ -395,12 +396,31 @@ export interface RESTTypedAPIDataStructs {
|
|
|
395
396
|
accId?: string,
|
|
396
397
|
forceClockIn?: boolean
|
|
397
398
|
];
|
|
399
|
+
GET_DEPARTMENTS: [];
|
|
400
|
+
GET_ACCOUNT_RANKS: [
|
|
401
|
+
apiId?: string,
|
|
402
|
+
username?: string,
|
|
403
|
+
accId?: string,
|
|
404
|
+
discord?: string
|
|
405
|
+
];
|
|
406
|
+
SET_ACCOUNT_RANKS: [
|
|
407
|
+
accountId: string,
|
|
408
|
+
set?: {
|
|
409
|
+
primary?: string | null;
|
|
410
|
+
secondary?: string[];
|
|
411
|
+
},
|
|
412
|
+
add?: string[],
|
|
413
|
+
remove?: string[]
|
|
414
|
+
];
|
|
398
415
|
GET_GAME_SERVERS: [];
|
|
399
416
|
VERIFY_WHITELIST: [
|
|
400
417
|
apiId: string | undefined,
|
|
401
418
|
accId: string | undefined,
|
|
402
419
|
serverId: number
|
|
403
420
|
];
|
|
421
|
+
FULL_WHITELIST: [
|
|
422
|
+
serverId?: number
|
|
423
|
+
];
|
|
404
424
|
}
|
|
405
425
|
export declare type PossibleRequestData = undefined | {
|
|
406
426
|
data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct;
|
|
@@ -490,4 +510,12 @@ export declare type PossibleRequestData = undefined | {
|
|
|
490
510
|
} | {
|
|
491
511
|
apiId: string;
|
|
492
512
|
forceClockIn: boolean;
|
|
513
|
+
} | {
|
|
514
|
+
accountId: string;
|
|
515
|
+
set?: {
|
|
516
|
+
primary: string[];
|
|
517
|
+
secondary: string[];
|
|
518
|
+
};
|
|
519
|
+
add?: string[];
|
|
520
|
+
remove?: string[];
|
|
493
521
|
};
|
|
@@ -316,6 +316,24 @@ exports.GeneralCMSAPITypes = [
|
|
|
316
316
|
method: 'POST',
|
|
317
317
|
minVersion: 3
|
|
318
318
|
},
|
|
319
|
+
{
|
|
320
|
+
type: 'GET_ACCOUNT_RANKS',
|
|
321
|
+
path: 'general/get_account_ranks',
|
|
322
|
+
method: 'POST',
|
|
323
|
+
minVersion: 2,
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
type: 'SET_ACCOUNT_RANKS',
|
|
327
|
+
path: 'general/set_account_ranks',
|
|
328
|
+
method: 'POST',
|
|
329
|
+
minVersion: 2,
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
type: 'GET_DEPARTMENTS',
|
|
333
|
+
path: 'general/get_departments',
|
|
334
|
+
method: 'POST',
|
|
335
|
+
minVersion: 2,
|
|
336
|
+
},
|
|
319
337
|
{
|
|
320
338
|
type: 'GET_SUB_VERSION',
|
|
321
339
|
path: 'general/get_sub_version',
|
|
@@ -347,6 +365,12 @@ exports.ServersCMSAPITypes = [
|
|
|
347
365
|
path: 'servers/verify_whitelist',
|
|
348
366
|
method: 'POST',
|
|
349
367
|
minVersion: 3
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
type: 'FULL_WHITELIST',
|
|
371
|
+
path: 'servers/full_whitelist',
|
|
372
|
+
method: 'POST',
|
|
373
|
+
minVersion: 3
|
|
350
374
|
}
|
|
351
375
|
];
|
|
352
376
|
function formatForAll(array, product) {
|
|
@@ -27,6 +27,12 @@ export declare class CMSManager extends BaseManager {
|
|
|
27
27
|
apiId?: string;
|
|
28
28
|
serverId?: number;
|
|
29
29
|
} | string): Promise<globalTypes.CMSVerifyWhitelistPromiseResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets a full whitelist allowed list for a specific server.
|
|
32
|
+
* @param {number} serverId (Optional) Server ID to get the whole allow list for, if not specified it will grab the default server ID that is set.
|
|
33
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
|
|
34
|
+
*/
|
|
35
|
+
getFullWhitelist(serverId?: number): Promise<globalTypes.CMSGetFullWhitelistPromiseResult>;
|
|
30
36
|
/**
|
|
31
37
|
* Gets a community account by `accId`, `apiId`, or `username`.
|
|
32
38
|
* @param {Object} params The object that contains parameters to get a community account.
|
|
@@ -39,12 +45,27 @@ export declare class CMSManager extends BaseManager {
|
|
|
39
45
|
accId?: string;
|
|
40
46
|
apiId?: string;
|
|
41
47
|
username?: string;
|
|
48
|
+
discord?: string;
|
|
42
49
|
}): Promise<globalTypes.CMSGetComAccountPromiseResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets a community account by `accId`, `apiId`, or `username`.
|
|
52
|
+
* @param {Object} params The object that contains parameters to get a community account.
|
|
53
|
+
* @param {string} [data.accId] (Optional) The account id to find a community account.
|
|
54
|
+
* @param {string} [data.apiId] (Optional) The api id to find a community account.
|
|
55
|
+
* @param {string} [data.username] (Optional) The username to find a community account.
|
|
56
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
|
|
57
|
+
*/
|
|
58
|
+
getAccountRanks(params: {
|
|
59
|
+
accId?: string;
|
|
60
|
+
apiId?: string;
|
|
61
|
+
username?: string;
|
|
62
|
+
discord?: string;
|
|
63
|
+
}): Promise<globalTypes.CMSGetAccountRanksPromiseResult>;
|
|
43
64
|
/**
|
|
44
65
|
* Clocks in or out an account by `accId` or `apiId`.
|
|
45
66
|
* @param {Object} data The object that contains critical data to clock in or out an account.
|
|
46
|
-
* @param {string} [data.accId] The account id to clock in or out.
|
|
47
|
-
* @param {string} [data.apiId] The api id to clock in or out.
|
|
67
|
+
* @param {string} [data.accId] (Optional) The account id to clock in or out.
|
|
68
|
+
* @param {string} [data.apiId] (Optional) The api id to clock in or out.
|
|
48
69
|
* @param {boolean} [data.forceClockIn] If true, it will override any current clock in with a new clock in at the time of the request.
|
|
49
70
|
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
50
71
|
*/
|
|
@@ -59,4 +80,21 @@ export declare class CMSManager extends BaseManager {
|
|
|
59
80
|
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
60
81
|
*/
|
|
61
82
|
checkComApiId(apiId: string): Promise<globalTypes.CMSCheckComApiIdPromiseResult>;
|
|
83
|
+
/**
|
|
84
|
+
* Gets all department information within the community CMS.
|
|
85
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
86
|
+
*/
|
|
87
|
+
getDepartments(): Promise<globalTypes.CMSGetDepartmentsPromiseResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Sets a community account's ranks for the CMS community.
|
|
90
|
+
* @param {string} accountId The object that contains critical data to clock in or out an account.
|
|
91
|
+
* @param {Object} changes The object that contains change data for setting account ranks.
|
|
92
|
+
* @param {Object} [changes.set] (Optional) The object that contains primary and secondary data for setting account ranks.
|
|
93
|
+
* @param {string} [changes.set.primary] (Optional) The primary rank ID wanting to set to the account.
|
|
94
|
+
* @param {string} [changes.set.secondary] (Optional) The secondary rank ID(s) wanting to set to the account.
|
|
95
|
+
* @param {Array} [changes.add] (Optional) The secondary rank IDs wanting to add to the account.
|
|
96
|
+
* @param {Array} [changes.remove] (Optional) The secondary rank IDs wanting to remove to the account.
|
|
97
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
98
|
+
*/
|
|
99
|
+
setAccountRanks(accountId: string, changes: globalTypes.CMSSetAccountRanksChangesObject): Promise<globalTypes.CMSSetAccountRanksPromiseResult>;
|
|
62
100
|
}
|
|
@@ -43,12 +43,16 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
43
43
|
var _a;
|
|
44
44
|
try {
|
|
45
45
|
const versionResp = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_SUB_VERSION'));
|
|
46
|
+
const version = Number.parseInt(versionResp.replace(/(^\d+)(.+$)/i, '$1'));
|
|
46
47
|
const mutableThis = this;
|
|
47
|
-
|
|
48
|
-
if (this.version >= globalTypes.CMSSubscriptionVersionEnum.STANDARD) {
|
|
48
|
+
if (version >= globalTypes.CMSSubscriptionVersionEnum.STANDARD) {
|
|
49
49
|
this.servers = new CMSServerManager_1.CMSServerManager(instance, this);
|
|
50
50
|
}
|
|
51
51
|
mutableThis.ready = true;
|
|
52
|
+
mutableThis.version = version;
|
|
53
|
+
console.log(mutableThis.version);
|
|
54
|
+
console.log(this.version);
|
|
55
|
+
console.log(version);
|
|
52
56
|
instance.isCMSSuccessful = true;
|
|
53
57
|
instance.emit('CMS_SETUP_SUCCESSFUL');
|
|
54
58
|
}
|
|
@@ -88,6 +92,28 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
88
92
|
}
|
|
89
93
|
});
|
|
90
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets a full whitelist allowed list for a specific server.
|
|
97
|
+
* @param {number} serverId (Optional) Server ID to get the whole allow list for, if not specified it will grab the default server ID that is set.
|
|
98
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
|
|
99
|
+
*/
|
|
100
|
+
async getFullWhitelist(serverId) {
|
|
101
|
+
return new Promise(async (resolve, reject) => {
|
|
102
|
+
var _a;
|
|
103
|
+
try {
|
|
104
|
+
const getFullWhitelistRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('FULL_WHITELIST', serverId !== null && serverId !== void 0 ? serverId : this.instance.cmsDefaultServerId));
|
|
105
|
+
resolve({ success: true, data: getFullWhitelistRequest });
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err instanceof src_1.APIError) {
|
|
109
|
+
resolve({ success: false, reason: err.response });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
reject(err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
91
117
|
/**
|
|
92
118
|
* Gets a community account by `accId`, `apiId`, or `username`.
|
|
93
119
|
* @param {Object} params The object that contains parameters to get a community account.
|
|
@@ -100,7 +126,7 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
100
126
|
return new Promise(async (resolve, reject) => {
|
|
101
127
|
var _a;
|
|
102
128
|
try {
|
|
103
|
-
const getAccountRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_COM_ACCOUNT', params.apiId, params.username, params.accId));
|
|
129
|
+
const getAccountRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_COM_ACCOUNT', params.apiId, params.username, params.accId, params.discord));
|
|
104
130
|
resolve({ success: true, data: getAccountRequest });
|
|
105
131
|
}
|
|
106
132
|
catch (err) {
|
|
@@ -113,11 +139,36 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
113
139
|
}
|
|
114
140
|
});
|
|
115
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Gets a community account by `accId`, `apiId`, or `username`.
|
|
144
|
+
* @param {Object} params The object that contains parameters to get a community account.
|
|
145
|
+
* @param {string} [data.accId] (Optional) The account id to find a community account.
|
|
146
|
+
* @param {string} [data.apiId] (Optional) The api id to find a community account.
|
|
147
|
+
* @param {string} [data.username] (Optional) The username to find a community account.
|
|
148
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
|
|
149
|
+
*/
|
|
150
|
+
async getAccountRanks(params) {
|
|
151
|
+
return new Promise(async (resolve, reject) => {
|
|
152
|
+
var _a;
|
|
153
|
+
try {
|
|
154
|
+
const getAccountRanksRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_ACCOUNT_RANKS', params.apiId, params.username, params.accId, params.discord));
|
|
155
|
+
resolve({ success: true, data: getAccountRanksRequest });
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
if (err instanceof src_1.APIError) {
|
|
159
|
+
resolve({ success: false, reason: err.response });
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
reject(err);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
116
167
|
/**
|
|
117
168
|
* Clocks in or out an account by `accId` or `apiId`.
|
|
118
169
|
* @param {Object} data The object that contains critical data to clock in or out an account.
|
|
119
|
-
* @param {string} [data.accId] The account id to clock in or out.
|
|
120
|
-
* @param {string} [data.apiId] The api id to clock in or out.
|
|
170
|
+
* @param {string} [data.accId] (Optional) The account id to clock in or out.
|
|
171
|
+
* @param {string} [data.apiId] (Optional) The api id to clock in or out.
|
|
121
172
|
* @param {boolean} [data.forceClockIn] If true, it will override any current clock in with a new clock in at the time of the request.
|
|
122
173
|
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
123
174
|
*/
|
|
@@ -126,8 +177,10 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
126
177
|
var _a;
|
|
127
178
|
try {
|
|
128
179
|
const clockInOutRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('CLOCK_IN_OUT', data.apiId, data.accId, !!data.forceClockIn));
|
|
129
|
-
const
|
|
130
|
-
|
|
180
|
+
const clockInOutResponse = clockInOutRequest;
|
|
181
|
+
if (!clockInOutResponse)
|
|
182
|
+
resolve({ success: false, reason: clockInOutRequest });
|
|
183
|
+
resolve({ success: true, clockedIn: clockInOutResponse.completed });
|
|
131
184
|
}
|
|
132
185
|
catch (err) {
|
|
133
186
|
if (err instanceof src_1.APIError) {
|
|
@@ -161,5 +214,54 @@ class CMSManager extends BaseManager_1.BaseManager {
|
|
|
161
214
|
}
|
|
162
215
|
});
|
|
163
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Gets all department information within the community CMS.
|
|
219
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
220
|
+
*/
|
|
221
|
+
async getDepartments() {
|
|
222
|
+
return new Promise(async (resolve, reject) => {
|
|
223
|
+
var _a;
|
|
224
|
+
try {
|
|
225
|
+
const getDepartmentsRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_DEPARTMENTS'));
|
|
226
|
+
resolve({ success: true, data: getDepartmentsRequest });
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
if (err instanceof src_1.APIError) {
|
|
230
|
+
resolve({ success: false, reason: err.response });
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
reject(err);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Sets a community account's ranks for the CMS community.
|
|
240
|
+
* @param {string} accountId The object that contains critical data to clock in or out an account.
|
|
241
|
+
* @param {Object} changes The object that contains change data for setting account ranks.
|
|
242
|
+
* @param {Object} [changes.set] (Optional) The object that contains primary and secondary data for setting account ranks.
|
|
243
|
+
* @param {string} [changes.set.primary] (Optional) The primary rank ID wanting to set to the account.
|
|
244
|
+
* @param {string} [changes.set.secondary] (Optional) The secondary rank ID(s) wanting to set to the account.
|
|
245
|
+
* @param {Array} [changes.add] (Optional) The secondary rank IDs wanting to add to the account.
|
|
246
|
+
* @param {Array} [changes.remove] (Optional) The secondary rank IDs wanting to remove to the account.
|
|
247
|
+
* @returns {Promise} Promise object represents if the request was successful with reason for failure if needed.
|
|
248
|
+
*/
|
|
249
|
+
async setAccountRanks(accountId, changes) {
|
|
250
|
+
return new Promise(async (resolve, reject) => {
|
|
251
|
+
var _a;
|
|
252
|
+
try {
|
|
253
|
+
const setAccountRanksRequest = await ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('SET_ACCOUNT_RANKS', accountId, changes.set, changes.add, changes.remove));
|
|
254
|
+
resolve({ success: true, data: setAccountRanksRequest });
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
if (err instanceof src_1.APIError) {
|
|
258
|
+
resolve({ success: false, reason: err.response });
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
reject(err);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
164
266
|
}
|
|
165
267
|
exports.CMSManager = CMSManager;
|
|
@@ -8,6 +8,11 @@ class CMSServerManager extends CacheManager_1.CacheManager {
|
|
|
8
8
|
super(instance, CMSServer_1.CMSServer, []);
|
|
9
9
|
(async () => {
|
|
10
10
|
var _a;
|
|
11
|
+
while (!manager.ready) {
|
|
12
|
+
await new Promise((resolve) => {
|
|
13
|
+
setTimeout(resolve, 100);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
11
16
|
try {
|
|
12
17
|
const serversRes = await ((_a = manager.rest) === null || _a === void 0 ? void 0 : _a.request('GET_GAME_SERVERS'));
|
|
13
18
|
const servers = serversRes.servers;
|
|
@@ -18,6 +23,7 @@ class CMSServerManager extends CacheManager_1.CacheManager {
|
|
|
18
23
|
};
|
|
19
24
|
this._add(serverStruct, true, server.id);
|
|
20
25
|
});
|
|
26
|
+
console.log(`Found ${servers.length} servers`);
|
|
21
27
|
}
|
|
22
28
|
catch (err) {
|
|
23
29
|
throw new Error(String(err));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonoransoftware/sonoran.js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^17.0.21",
|
|
21
|
-
"@types/node-fetch": "^2.6.
|
|
21
|
+
"@types/node-fetch": "^2.6.2",
|
|
22
22
|
"eslint": "^8.10.0",
|
|
23
23
|
"eslint-config-prettier": "^8.5.0",
|
|
24
24
|
"eslint-plugin-import": "^2.25.4",
|