@sonoransoftware/sonoran.js 1.0.0 → 1.0.1

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 (73) hide show
  1. package/.github/workflows/npm-publish.yml +34 -0
  2. package/dist/builders/cad/DispatchCall.d.ts +92 -0
  3. package/dist/builders/cad/DispatchCall.js +144 -0
  4. package/dist/builders/cad/index.d.ts +1 -0
  5. package/dist/builders/cad/index.js +17 -0
  6. package/dist/builders/index.d.ts +1 -0
  7. package/dist/builders/index.js +19 -0
  8. package/dist/constants.d.ts +156 -0
  9. package/dist/constants.js +27 -0
  10. package/dist/errors/LibraryErrors.d.ts +19 -0
  11. package/dist/errors/LibraryErrors.js +47 -0
  12. package/dist/errors/Messages.d.ts +1 -0
  13. package/dist/errors/Messages.js +8 -0
  14. package/dist/errors/index.d.ts +2 -0
  15. package/dist/errors/index.js +18 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +24 -0
  18. package/dist/instance/Instance.d.ts +23 -0
  19. package/dist/instance/Instance.js +134 -0
  20. package/dist/instance/instance.types.d.ts +16 -0
  21. package/dist/instance/instance.types.js +2 -0
  22. package/dist/libs/rest/src/index.d.ts +6 -0
  23. package/dist/libs/rest/src/index.js +22 -0
  24. package/dist/libs/rest/src/lib/REST.d.ts +99 -0
  25. package/dist/libs/rest/src/lib/REST.js +97 -0
  26. package/dist/libs/rest/src/lib/RequestManager.d.ts +58 -0
  27. package/dist/libs/rest/src/lib/RequestManager.js +201 -0
  28. package/dist/libs/rest/src/lib/errors/APIError.d.ts +9 -0
  29. package/dist/libs/rest/src/lib/errors/APIError.js +17 -0
  30. package/dist/libs/rest/src/lib/errors/HTTPError.d.ts +17 -0
  31. package/dist/libs/rest/src/lib/errors/HTTPError.js +23 -0
  32. package/dist/libs/rest/src/lib/errors/RateLimitError.d.ts +13 -0
  33. package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -0
  34. package/dist/libs/rest/src/lib/errors/index.d.ts +4 -0
  35. package/dist/libs/rest/src/lib/errors/index.js +20 -0
  36. package/dist/libs/rest/src/lib/handlers/IHandler.d.ts +7 -0
  37. package/dist/libs/rest/src/lib/handlers/IHandler.js +2 -0
  38. package/dist/libs/rest/src/lib/handlers/SequentialHandler.d.ts +45 -0
  39. package/dist/libs/rest/src/lib/handlers/SequentialHandler.js +155 -0
  40. package/dist/libs/rest/src/lib/utils/Utils.d.ts +1 -0
  41. package/dist/libs/rest/src/lib/utils/Utils.js +22 -0
  42. package/dist/libs/rest/src/lib/utils/constants.d.ts +493 -0
  43. package/dist/libs/rest/src/lib/utils/constants.js +408 -0
  44. package/dist/managers/BaseManager.d.ts +14 -0
  45. package/dist/managers/BaseManager.js +18 -0
  46. package/dist/managers/CADActiveUnitsManager.d.ts +15 -0
  47. package/dist/managers/CADActiveUnitsManager.js +49 -0
  48. package/dist/managers/CADManager.d.ts +27 -0
  49. package/dist/managers/CADManager.js +93 -0
  50. package/dist/managers/CADServerManager.d.ts +8 -0
  51. package/dist/managers/CADServerManager.js +37 -0
  52. package/dist/managers/CMSManager.d.ts +62 -0
  53. package/dist/managers/CMSManager.js +181 -0
  54. package/dist/managers/CMSServerManager.d.ts +8 -0
  55. package/dist/managers/CMSServerManager.js +37 -0
  56. package/dist/managers/CacheManager.d.ts +10 -0
  57. package/dist/managers/CacheManager.js +39 -0
  58. package/dist/managers/DataManager.d.ts +31 -0
  59. package/dist/managers/DataManager.js +61 -0
  60. package/dist/structures/Base.d.ts +9 -0
  61. package/dist/structures/Base.js +24 -0
  62. package/dist/structures/CADActiveUnit.d.ts +47 -0
  63. package/dist/structures/CADActiveUnit.js +66 -0
  64. package/dist/structures/CADServer.d.ts +26 -0
  65. package/dist/structures/CADServer.js +15 -0
  66. package/dist/structures/CMSServer.d.ts +18 -0
  67. package/dist/structures/CMSServer.js +12 -0
  68. package/dist/utils/index.d.ts +1 -0
  69. package/dist/utils/index.js +17 -0
  70. package/dist/utils/utils.d.ts +13 -0
  71. package/dist/utils/utils.js +82 -0
  72. package/package.json +8 -4
  73. package/tsconfig.json +3 -3
@@ -0,0 +1,408 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CADDispatchStatusEnums = exports.CADDispatchOriginEnums = exports.CADModifyIdentifierActionEnums = exports.CADLookupByIntSearchTypeEnums = exports.CADRecordSectionCategoryEnums = exports.CADRecordTypeEnums = exports.AllAPITypes = exports.ServersCMSAPITypes = exports.GeneralCMSAPITypes = exports.EmergencyCADAPITypes = exports.CivilianCADAPITypes = exports.GeneralCADAPITypes = exports.DefaultCMSRestOptions = exports.DefaultCADRestOptions = exports.DefaultUserAgent = void 0;
4
+ const constants_1 = require("../../../../../constants");
5
+ exports.DefaultUserAgent = 'Sonoran.js NPM Module';
6
+ exports.DefaultCADRestOptions = {
7
+ agent: {},
8
+ api: 'https://api.sonorancad.com',
9
+ headers: {},
10
+ rejectOnRateLimit: true
11
+ };
12
+ exports.DefaultCMSRestOptions = {
13
+ agent: {},
14
+ api: 'https://api.sonorancms.com',
15
+ headers: {},
16
+ rejectOnRateLimit: true
17
+ };
18
+ exports.GeneralCADAPITypes = [
19
+ {
20
+ type: 'GET_SERVERS',
21
+ path: 'general/get_servers',
22
+ method: 'POST',
23
+ minVersion: 2
24
+ },
25
+ {
26
+ type: 'SET_SERVERS',
27
+ path: 'general/set_servers',
28
+ method: 'POST',
29
+ minVersion: 3
30
+ },
31
+ {
32
+ type: 'GET_VERSION',
33
+ path: 'general/get_version',
34
+ method: 'POST',
35
+ minVersion: 0
36
+ },
37
+ {
38
+ type: 'SET_PENAL_CODES',
39
+ path: 'general/set_penal_codes',
40
+ method: 'POST',
41
+ minVersion: 2
42
+ },
43
+ {
44
+ type: 'SET_API_ID',
45
+ path: 'general/set_api_id',
46
+ method: 'POST',
47
+ minVersion: 2
48
+ },
49
+ {
50
+ type: 'GET_TEMPLATES',
51
+ path: 'general/get_templates',
52
+ method: 'POST',
53
+ minVersion: 2
54
+ },
55
+ {
56
+ type: 'NEW_RECORD',
57
+ path: 'general/new_record',
58
+ method: 'POST',
59
+ minVersion: 3
60
+ },
61
+ {
62
+ type: 'EDIT_RECORD',
63
+ path: 'general/edit_record',
64
+ method: 'POST',
65
+ minVersion: 3
66
+ },
67
+ {
68
+ type: 'REMOVE_RECORD',
69
+ path: 'general/remove_record',
70
+ method: 'POST',
71
+ minVersion: 3
72
+ },
73
+ {
74
+ type: 'LOOKUP_INT',
75
+ path: 'general/lookup_int',
76
+ method: 'POST',
77
+ minVersion: 3
78
+ },
79
+ {
80
+ type: 'LOOKUP',
81
+ path: 'general/lookup',
82
+ method: 'POST',
83
+ minVersion: 3
84
+ },
85
+ {
86
+ type: 'GET_ACCOUNT',
87
+ path: 'general/get_account',
88
+ method: 'POST',
89
+ minVersion: 3
90
+ },
91
+ {
92
+ type: 'CHECK_APIID',
93
+ path: 'general/check_apiid',
94
+ method: 'POST',
95
+ minVersion: 2
96
+ },
97
+ {
98
+ type: 'APPLY_PERMISSION_KEY',
99
+ path: 'general/apply_permission_key',
100
+ method: 'POST',
101
+ minVersion: 3
102
+ },
103
+ {
104
+ type: 'SET_ACCOUNT_PERMISSIONS',
105
+ path: 'general/set_account_permissions',
106
+ method: 'POST',
107
+ minVersion: 3
108
+ },
109
+ {
110
+ type: 'BAN_USER',
111
+ path: 'general/ban_user',
112
+ method: 'POST',
113
+ minVersion: 3
114
+ },
115
+ {
116
+ type: 'VERIFY_SECRET',
117
+ path: 'general/verify_secret',
118
+ method: 'POST',
119
+ minVersion: 2
120
+ },
121
+ {
122
+ type: 'AUTH_STREETSIGNS',
123
+ path: 'general/auth_streetsigns',
124
+ method: 'POST',
125
+ minVersion: 4
126
+ },
127
+ {
128
+ type: 'SET_POSTALS',
129
+ path: 'general/set_postals',
130
+ method: 'POST',
131
+ minVersion: 4
132
+ },
133
+ {
134
+ type: 'SEND_PHOTO',
135
+ path: 'general/send_photo',
136
+ method: 'POST',
137
+ minVersion: 4
138
+ }
139
+ ];
140
+ exports.CivilianCADAPITypes = [
141
+ {
142
+ type: 'GET_CHARACTERS',
143
+ path: 'civilian/get_characters',
144
+ method: 'POST',
145
+ minVersion: 2
146
+ },
147
+ {
148
+ type: 'NEW_CHARACTER',
149
+ path: 'civilian/new_character',
150
+ method: 'POST',
151
+ minVersion: 2
152
+ },
153
+ {
154
+ type: 'EDIT_CHARACTER',
155
+ path: 'civilian/edit_characters',
156
+ method: 'POST',
157
+ minVersion: 2
158
+ },
159
+ {
160
+ type: 'REMOVE_CHARACTER',
161
+ path: 'civilian/remove_character',
162
+ method: 'POST',
163
+ minVersion: 2
164
+ }
165
+ ];
166
+ exports.EmergencyCADAPITypes = [
167
+ {
168
+ type: 'GET_IDENTIFIERS',
169
+ path: 'emergency/get_identifiers',
170
+ method: 'POST',
171
+ minVersion: 3
172
+ },
173
+ {
174
+ type: 'MODIFY_IDENTIFIER',
175
+ path: 'emergency/modify_identifier',
176
+ method: 'POST',
177
+ minVersion: 4
178
+ },
179
+ {
180
+ type: 'SET_IDENTIFIER',
181
+ path: 'emergency/set_identifier',
182
+ method: 'POST',
183
+ minVersion: 3
184
+ },
185
+ {
186
+ type: 'UNIT_PANIC',
187
+ path: 'emergency/unit_panic',
188
+ method: 'POST',
189
+ minVersion: 2
190
+ },
191
+ {
192
+ type: 'UNIT_STATUS',
193
+ path: 'emergency/unit_status',
194
+ method: 'POST',
195
+ minVersion: 2
196
+ },
197
+ {
198
+ type: 'GET_BLIPS',
199
+ path: 'emergency/get_blips',
200
+ method: 'POST',
201
+ minVersion: 4
202
+ },
203
+ {
204
+ type: 'ADD_BLIP',
205
+ path: 'emergency/add_blip',
206
+ method: 'POST',
207
+ minVersion: 4
208
+ },
209
+ {
210
+ type: 'MODIFY_BLIP',
211
+ path: 'emergency/modify_blip',
212
+ method: 'POST',
213
+ minVersion: 4
214
+ },
215
+ {
216
+ type: 'REMOVE_BLIP',
217
+ path: 'emergency/remove_blip',
218
+ method: 'POST',
219
+ minVersion: 4
220
+ },
221
+ {
222
+ type: '911_CALL',
223
+ path: 'emergency/911_call',
224
+ method: 'POST',
225
+ minVersion: 2
226
+ },
227
+ {
228
+ type: 'REMOVE_911',
229
+ path: 'emergency/remove_911',
230
+ method: 'POST',
231
+ minVersion: 2
232
+ },
233
+ {
234
+ type: 'GET_CALLS',
235
+ path: 'emergency/get_calls',
236
+ method: 'POST',
237
+ minVersion: 3
238
+ },
239
+ {
240
+ type: 'GET_ACTIVE_UNITS',
241
+ path: 'emergency/get_active_units',
242
+ method: 'POST',
243
+ minVersion: 3
244
+ },
245
+ {
246
+ type: 'KICK_UNIT',
247
+ path: 'emergency/kick_unit',
248
+ method: 'POST',
249
+ minVersion: 2
250
+ },
251
+ {
252
+ type: 'NEW_DISPATCH',
253
+ path: 'emergency/new_dispatch',
254
+ method: 'POST',
255
+ minVersion: 3
256
+ },
257
+ {
258
+ type: 'ATTACH_UNIT',
259
+ path: 'emergency/attach_unit',
260
+ method: 'POST',
261
+ minVersion: 3
262
+ },
263
+ {
264
+ type: 'DETACH_UNIT',
265
+ path: 'emergency/detach_unit',
266
+ method: 'POST',
267
+ minVersion: 3
268
+ },
269
+ {
270
+ type: 'SET_CALL_POSTAL',
271
+ path: 'emergency/set_call_postal',
272
+ method: 'POST',
273
+ minVersion: 3
274
+ },
275
+ {
276
+ type: 'SET_CALL_PRIMARY',
277
+ path: 'emergency/set_call_primary',
278
+ method: 'POST',
279
+ minVersion: 3
280
+ },
281
+ {
282
+ type: 'ADD_CALL_NOTE',
283
+ path: 'emergency/add_call_note',
284
+ method: 'POST',
285
+ minVersion: 3
286
+ },
287
+ {
288
+ type: 'CLOSE_CALL',
289
+ path: 'emergency/close_call',
290
+ method: 'POST',
291
+ minVersion: 2
292
+ },
293
+ {
294
+ type: 'UNIT_LOCATION',
295
+ path: 'emergency/unit_location',
296
+ method: 'POST',
297
+ minVersion: 2
298
+ },
299
+ {
300
+ type: 'SET_STREETSIGN_CONFIG',
301
+ path: 'emergency/set_streetsign_config',
302
+ method: 'POST',
303
+ minVersion: 4
304
+ },
305
+ {
306
+ type: 'UPDATE_STREETSIGN',
307
+ path: 'emergency/update_streetsign',
308
+ method: 'POST',
309
+ minVersion: 4
310
+ }
311
+ ];
312
+ exports.GeneralCMSAPITypes = [
313
+ {
314
+ type: 'GET_COM_ACCOUNT',
315
+ path: 'general/get_com_account',
316
+ method: 'POST',
317
+ minVersion: 3
318
+ },
319
+ {
320
+ type: 'GET_SUB_VERSION',
321
+ path: 'general/get_sub_version',
322
+ method: 'POST',
323
+ minVersion: 0
324
+ },
325
+ {
326
+ type: 'CHECK_COM_APIID',
327
+ path: 'general/check_com_apiid',
328
+ method: 'POST',
329
+ minVersion: 2
330
+ },
331
+ {
332
+ type: 'CLOCK_IN_OUT',
333
+ path: 'general/clock_in_out',
334
+ method: 'POST',
335
+ minVersion: 3
336
+ }
337
+ ];
338
+ exports.ServersCMSAPITypes = [
339
+ {
340
+ type: 'GET_GAME_SERVERS',
341
+ path: 'servers/get_game_servers',
342
+ method: 'POST',
343
+ minVersion: 2
344
+ },
345
+ {
346
+ type: 'VERIFY_WHITELIST',
347
+ path: 'servers/verify_whitelist',
348
+ method: 'POST',
349
+ minVersion: 3
350
+ }
351
+ ];
352
+ function formatForAll(array, product) {
353
+ return array.map((val) => {
354
+ return Object.assign(Object.assign({}, val), { product });
355
+ });
356
+ }
357
+ exports.AllAPITypes = [...formatForAll(exports.GeneralCADAPITypes, constants_1.productEnums.CAD), ...formatForAll(exports.CivilianCADAPITypes, constants_1.productEnums.CAD), ...formatForAll(exports.EmergencyCADAPITypes, constants_1.productEnums.CAD), ...formatForAll(exports.GeneralCMSAPITypes, constants_1.productEnums.CMS), ...formatForAll(exports.ServersCMSAPITypes, constants_1.productEnums.CMS)];
358
+ var CADRecordTypeEnums;
359
+ (function (CADRecordTypeEnums) {
360
+ CADRecordTypeEnums[CADRecordTypeEnums["Warrant"] = 2] = "Warrant";
361
+ CADRecordTypeEnums[CADRecordTypeEnums["Bolo"] = 3] = "Bolo";
362
+ CADRecordTypeEnums[CADRecordTypeEnums["License"] = 4] = "License";
363
+ CADRecordTypeEnums[CADRecordTypeEnums["VehicleRegistration"] = 5] = "VehicleRegistration";
364
+ CADRecordTypeEnums[CADRecordTypeEnums["Character"] = 7] = "Character";
365
+ CADRecordTypeEnums[CADRecordTypeEnums["PoliceRecord"] = 8] = "PoliceRecord";
366
+ CADRecordTypeEnums[CADRecordTypeEnums["PoliceReport"] = 9] = "PoliceReport";
367
+ CADRecordTypeEnums[CADRecordTypeEnums["MedicalRecord"] = 10] = "MedicalRecord";
368
+ CADRecordTypeEnums[CADRecordTypeEnums["MedicalReport"] = 11] = "MedicalReport";
369
+ CADRecordTypeEnums[CADRecordTypeEnums["FireRecord"] = 12] = "FireRecord";
370
+ CADRecordTypeEnums[CADRecordTypeEnums["FireReport"] = 13] = "FireReport";
371
+ CADRecordTypeEnums[CADRecordTypeEnums["DMVRecord"] = 14] = "DMVRecord";
372
+ CADRecordTypeEnums[CADRecordTypeEnums["LawRecord"] = 15] = "LawRecord";
373
+ CADRecordTypeEnums[CADRecordTypeEnums["LawReport"] = 16] = "LawReport";
374
+ })(CADRecordTypeEnums = exports.CADRecordTypeEnums || (exports.CADRecordTypeEnums = {}));
375
+ var CADRecordSectionCategoryEnums;
376
+ (function (CADRecordSectionCategoryEnums) {
377
+ CADRecordSectionCategoryEnums[CADRecordSectionCategoryEnums["Custom"] = 0] = "Custom";
378
+ CADRecordSectionCategoryEnums[CADRecordSectionCategoryEnums["Flags"] = 1] = "Flags";
379
+ CADRecordSectionCategoryEnums[CADRecordSectionCategoryEnums["Speed"] = 5] = "Speed";
380
+ CADRecordSectionCategoryEnums[CADRecordSectionCategoryEnums["Charges"] = 6] = "Charges";
381
+ CADRecordSectionCategoryEnums[CADRecordSectionCategoryEnums["LinkedRecords"] = 9] = "LinkedRecords";
382
+ })(CADRecordSectionCategoryEnums = exports.CADRecordSectionCategoryEnums || (exports.CADRecordSectionCategoryEnums = {}));
383
+ var CADLookupByIntSearchTypeEnums;
384
+ (function (CADLookupByIntSearchTypeEnums) {
385
+ CADLookupByIntSearchTypeEnums[CADLookupByIntSearchTypeEnums["IDENTIFIER"] = 0] = "IDENTIFIER";
386
+ CADLookupByIntSearchTypeEnums[CADLookupByIntSearchTypeEnums["SUPERVISOR_STATUS"] = 1] = "SUPERVISOR_STATUS";
387
+ CADLookupByIntSearchTypeEnums[CADLookupByIntSearchTypeEnums["ACTIVE_STATUS"] = 2] = "ACTIVE_STATUS";
388
+ CADLookupByIntSearchTypeEnums[CADLookupByIntSearchTypeEnums["NUMBER"] = 3] = "NUMBER";
389
+ })(CADLookupByIntSearchTypeEnums = exports.CADLookupByIntSearchTypeEnums || (exports.CADLookupByIntSearchTypeEnums = {}));
390
+ var CADModifyIdentifierActionEnums;
391
+ (function (CADModifyIdentifierActionEnums) {
392
+ CADModifyIdentifierActionEnums[CADModifyIdentifierActionEnums["ADD"] = 0] = "ADD";
393
+ CADModifyIdentifierActionEnums[CADModifyIdentifierActionEnums["EDIT"] = 1] = "EDIT";
394
+ CADModifyIdentifierActionEnums[CADModifyIdentifierActionEnums["REMOVE"] = 2] = "REMOVE";
395
+ })(CADModifyIdentifierActionEnums = exports.CADModifyIdentifierActionEnums || (exports.CADModifyIdentifierActionEnums = {}));
396
+ var CADDispatchOriginEnums;
397
+ (function (CADDispatchOriginEnums) {
398
+ CADDispatchOriginEnums[CADDispatchOriginEnums["Caller"] = 0] = "Caller";
399
+ CADDispatchOriginEnums[CADDispatchOriginEnums["RadioDispatch"] = 1] = "RadioDispatch";
400
+ CADDispatchOriginEnums[CADDispatchOriginEnums["Observed"] = 2] = "Observed";
401
+ CADDispatchOriginEnums[CADDispatchOriginEnums["WalkUp"] = 3] = "WalkUp";
402
+ })(CADDispatchOriginEnums = exports.CADDispatchOriginEnums || (exports.CADDispatchOriginEnums = {}));
403
+ var CADDispatchStatusEnums;
404
+ (function (CADDispatchStatusEnums) {
405
+ CADDispatchStatusEnums[CADDispatchStatusEnums["Pending"] = 0] = "Pending";
406
+ CADDispatchStatusEnums[CADDispatchStatusEnums["Active"] = 1] = "Active";
407
+ CADDispatchStatusEnums[CADDispatchStatusEnums["Closed"] = 2] = "Closed";
408
+ })(CADDispatchStatusEnums = exports.CADDispatchStatusEnums || (exports.CADDispatchStatusEnums = {}));
@@ -0,0 +1,14 @@
1
+ import Instance from '../instance/Instance';
2
+ /**
3
+ * Manages the API methods of a data model or a specific product methods.
4
+ * @abstract
5
+ */
6
+ export declare abstract class BaseManager {
7
+ readonly instance: Instance;
8
+ /**
9
+ *
10
+ * @param {Instance} instance The instance that instantiated this Manager
11
+ * @readonly
12
+ */
13
+ constructor(instance: Instance);
14
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseManager = void 0;
4
+ /**
5
+ * Manages the API methods of a data model or a specific product methods.
6
+ * @abstract
7
+ */
8
+ class BaseManager {
9
+ /**
10
+ *
11
+ * @param {Instance} instance The instance that instantiated this Manager
12
+ * @readonly
13
+ */
14
+ constructor(instance) {
15
+ this.instance = instance;
16
+ }
17
+ }
18
+ exports.BaseManager = BaseManager;
@@ -0,0 +1,15 @@
1
+ import Instance from '../instance/Instance';
2
+ import { CADActiveUnit, CADActiveUnitResolvable, CADActiveUnitStruct } from '../structures/CADActiveUnit';
3
+ import { CacheManager } from './CacheManager';
4
+ export declare class CADActiveUnitsManager extends CacheManager<number, CADActiveUnit, CADActiveUnitResolvable> {
5
+ serverId: number;
6
+ instance: Instance;
7
+ constructor(instance: Instance, iterable: Iterable<CADActiveUnitStruct>, serverId: number);
8
+ _add(data: any, cache?: boolean): any;
9
+ fetch(): void;
10
+ _fetchSingle({ unit, includeOffline, force }: {
11
+ unit: CADActiveUnitResolvable;
12
+ includeOffline: boolean;
13
+ force: boolean;
14
+ }): Promise<any>;
15
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ // Work in progress still...
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.CADActiveUnitsManager = void 0;
14
+ const CADActiveUnit_1 = require("../structures/CADActiveUnit");
15
+ const CacheManager_1 = require("./CacheManager");
16
+ class CADActiveUnitsManager extends CacheManager_1.CacheManager {
17
+ constructor(instance, iterable, serverId) {
18
+ super(instance, CADActiveUnit_1.CADActiveUnit, iterable);
19
+ this.instance = instance;
20
+ this.serverId = serverId;
21
+ }
22
+ _add(data, cache = true) {
23
+ return super._add(data, cache, data.id);
24
+ }
25
+ fetch( /*options: CADActiveUnitResolvable | CADActiveUnitFetchOptions**/) {
26
+ // if (!options) return this._fetchMany();
27
+ this._fetchSingle({
28
+ unit: -1,
29
+ includeOffline: false,
30
+ force: false
31
+ });
32
+ }
33
+ _fetchSingle({ unit, includeOffline = false, force = false }) {
34
+ var _a, _b;
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ if (!force) {
37
+ const existing = this.cache.get(unit);
38
+ if (existing)
39
+ return existing;
40
+ }
41
+ const data = yield ((_b = (_a = this.instance.cad) === null || _a === void 0 ? void 0 : _a.rest) === null || _b === void 0 ? void 0 : _b.request('GET_ACTIVE_UNITS', {
42
+ serverId: this.serverId,
43
+ includeOffline
44
+ }));
45
+ console.log(data);
46
+ });
47
+ }
48
+ }
49
+ exports.CADActiveUnitsManager = CADActiveUnitsManager;
@@ -0,0 +1,27 @@
1
+ import Instance from '../instance/Instance';
2
+ import { CADSubscriptionVersionEnum } from '../constants';
3
+ import { REST } from '../libs/rest/src';
4
+ import { BaseManager } from './BaseManager';
5
+ import * as globalTypes from '../constants';
6
+ import { CADServerManager } from './CADServerManager';
7
+ /**
8
+ * Manages all Sonoran CAD data and methods to interact with the public API.
9
+ */
10
+ export declare class CADManager extends BaseManager {
11
+ readonly version: CADSubscriptionVersionEnum;
12
+ rest: REST | undefined;
13
+ servers: CADServerManager | undefined;
14
+ constructor(instance: Instance);
15
+ protected buildManager(instance: Instance): Promise<void>;
16
+ /**
17
+ * Gets a community account by `accId` or `apiId`.
18
+ * @param {Object} params The object that contains parameters to get a community account.
19
+ * @param {string} [data.accId] The account id to find a community account.
20
+ * @param {string} [data.apiId] The api id to find a community account.
21
+ * @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
22
+ */
23
+ getAccount(params: {
24
+ apiId?: string;
25
+ username?: string;
26
+ }): Promise<globalTypes.CADGetAccountPromiseResult>;
27
+ }
@@ -0,0 +1,93 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.CADManager = void 0;
36
+ const src_1 = require("../libs/rest/src");
37
+ const BaseManager_1 = require("./BaseManager");
38
+ const globalTypes = __importStar(require("../constants"));
39
+ const CADServerManager_1 = require("./CADServerManager");
40
+ /**
41
+ * Manages all Sonoran CAD data and methods to interact with the public API.
42
+ */
43
+ class CADManager extends BaseManager_1.BaseManager {
44
+ constructor(instance) {
45
+ super(instance);
46
+ this.version = 0;
47
+ this.rest = new src_1.REST(instance, this, globalTypes.productEnums.CAD, src_1.DefaultCADRestOptions);
48
+ this.buildManager(instance);
49
+ }
50
+ buildManager(instance) {
51
+ var _a;
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ try {
54
+ const versionResp = yield ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_VERSION'));
55
+ const mutableThis = this;
56
+ mutableThis.version = Number.parseInt(versionResp.replace(/(^\d+)(.+$)/i, '$1'));
57
+ if (this.version >= globalTypes.CADSubscriptionVersionEnum.STANDARD) {
58
+ this.servers = new CADServerManager_1.CADServerManager(instance, this);
59
+ }
60
+ }
61
+ catch (err) {
62
+ console.log(err);
63
+ }
64
+ });
65
+ }
66
+ /**
67
+ * Gets a community account by `accId` or `apiId`.
68
+ * @param {Object} params The object that contains parameters to get a community account.
69
+ * @param {string} [data.accId] The account id to find a community account.
70
+ * @param {string} [data.apiId] The api id to find a community account.
71
+ * @returns {Promise} Promise object represents if the request was successful with reason for failure if needed and the account data object if found.
72
+ */
73
+ getAccount(params) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
76
+ var _a;
77
+ try {
78
+ const getAccountRequest = yield ((_a = this.rest) === null || _a === void 0 ? void 0 : _a.request('GET_ACCOUNT', params.apiId, params.username));
79
+ resolve({ success: true, data: getAccountRequest });
80
+ }
81
+ catch (err) {
82
+ if (err instanceof src_1.APIError) {
83
+ resolve({ success: false, reason: err.response });
84
+ }
85
+ else {
86
+ reject(err);
87
+ }
88
+ }
89
+ }));
90
+ });
91
+ }
92
+ }
93
+ exports.CADManager = CADManager;
@@ -0,0 +1,8 @@
1
+ import Instance from '../instance/Instance';
2
+ import { CADServerAPIStruct } from '../libs/rest/src';
3
+ import { CADServer } from '../structures/CADServer';
4
+ import { CacheManager } from './CacheManager';
5
+ import { CADManager } from './CADManager';
6
+ export declare class CADServerManager extends CacheManager<number, CADServer, CADServerAPIStruct> {
7
+ constructor(instance: Instance, manager: CADManager);
8
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CADServerManager = void 0;
13
+ const CADServer_1 = require("../structures/CADServer");
14
+ const CacheManager_1 = require("./CacheManager");
15
+ class CADServerManager extends CacheManager_1.CacheManager {
16
+ constructor(instance, manager) {
17
+ super(instance, CADServer_1.CADServer, []);
18
+ (() => __awaiter(this, void 0, void 0, function* () {
19
+ var _a;
20
+ try {
21
+ const serversRes = yield ((_a = manager.rest) === null || _a === void 0 ? void 0 : _a.request('GET_SERVERS'));
22
+ const servers = JSON.parse(serversRes).servers;
23
+ servers.forEach((server) => {
24
+ const serverStruct = {
25
+ id: server.id,
26
+ config: server
27
+ };
28
+ this._add(serverStruct, true, server.id);
29
+ });
30
+ }
31
+ catch (err) {
32
+ throw new Error(String(err));
33
+ }
34
+ }))();
35
+ }
36
+ }
37
+ exports.CADServerManager = CADServerManager;