@sonoransoftware/sonoran.js 1.0.0

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/.eslintrc.js +11 -0
  2. package/.prettierrc.js +7 -0
  3. package/docs/CAD-Methods-and-Usage.md +59 -0
  4. package/docs/CMS-Methods-and-Usage.md +212 -0
  5. package/docs/REST-Methods-and-Usage.md +47 -0
  6. package/package.json +42 -0
  7. package/readme.md +54 -0
  8. package/src/builders/cad/DispatchCall.ts +159 -0
  9. package/src/builders/cad/index.ts +1 -0
  10. package/src/builders/index.ts +3 -0
  11. package/src/constants.ts +174 -0
  12. package/src/errors/LibraryErrors.ts +43 -0
  13. package/src/errors/Messages.ts +7 -0
  14. package/src/errors/index.ts +2 -0
  15. package/src/index.ts +12 -0
  16. package/src/instance/Instance.ts +118 -0
  17. package/src/instance/instance.types.ts +17 -0
  18. package/src/libs/rest/src/index.ts +6 -0
  19. package/src/libs/rest/src/lib/REST.ts +201 -0
  20. package/src/libs/rest/src/lib/RequestManager.ts +256 -0
  21. package/src/libs/rest/src/lib/errors/APIError.ts +15 -0
  22. package/src/libs/rest/src/lib/errors/HTTPError.ts +22 -0
  23. package/src/libs/rest/src/lib/errors/RateLimitError.ts +21 -0
  24. package/src/libs/rest/src/lib/errors/index.ts +4 -0
  25. package/src/libs/rest/src/lib/handlers/IHandler.ts +13 -0
  26. package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +157 -0
  27. package/src/libs/rest/src/lib/utils/constants.ts +919 -0
  28. package/src/libs/rest/src/lib/utils/utils.ts +18 -0
  29. package/src/managers/BaseManager.ts +15 -0
  30. package/src/managers/CADActiveUnitsManager.ts +50 -0
  31. package/src/managers/CADManager.ts +58 -0
  32. package/src/managers/CADServerManager.ts +27 -0
  33. package/src/managers/CMSManager.ts +133 -0
  34. package/src/managers/CMSServerManager.ts +27 -0
  35. package/src/managers/CacheManager.ts +38 -0
  36. package/src/managers/DataManager.ts +64 -0
  37. package/src/structures/Base.ts +28 -0
  38. package/src/structures/CADActiveUnit.ts +85 -0
  39. package/src/structures/CADServer.ts +37 -0
  40. package/src/structures/CMSServer.ts +26 -0
  41. package/src/utils/index.ts +1 -0
  42. package/src/utils/utils.ts +75 -0
  43. package/tsconfig.json +71 -0
@@ -0,0 +1,919 @@
1
+ import { productEnums } from '../../../../../constants';
2
+ import type { RESTOptions } from '../REST';
3
+
4
+ export const DefaultUserAgent = 'Sonoran.js NPM Module';
5
+
6
+ export const DefaultCADRestOptions: Required<RESTOptions> = {
7
+ agent: {},
8
+ api: 'https://api.sonorancad.com',
9
+ headers: {},
10
+ rejectOnRateLimit: true
11
+ };
12
+
13
+ export const DefaultCMSRestOptions: Required<RESTOptions> = {
14
+ agent: {},
15
+ api: 'https://api.sonorancms.com',
16
+ headers: {},
17
+ rejectOnRateLimit: true
18
+ };
19
+
20
+ /**
21
+ * The events that the REST manager emits
22
+ */
23
+ export const enum RESTEvents {
24
+ Debug = 'restDebug',
25
+ InvalidRequestWarning = 'invalidRequestWarning',
26
+ RateLimited = 'rateLimited',
27
+ Request = 'request',
28
+ Response = 'response'
29
+ }
30
+
31
+ export interface APITypeData {
32
+ type: string;
33
+ path: string;
34
+ method: 'POST' | 'GET' | 'DELETE' | 'PATCH';
35
+ minVersion: number;
36
+ }
37
+
38
+ export interface AllAPITypeData {
39
+ product: productEnums;
40
+ type: string;
41
+ path: string;
42
+ method: 'POST' | 'GET' | 'DELETE' | 'PATCH';
43
+ minVersion: number;
44
+ }
45
+
46
+ export const GeneralCADAPITypes: APITypeData[] = [
47
+ {
48
+ type: 'GET_SERVERS',
49
+ path: 'general/get_servers',
50
+ method: 'POST',
51
+ minVersion: 2
52
+ },
53
+ {
54
+ type: 'SET_SERVERS',
55
+ path: 'general/set_servers',
56
+ method: 'POST',
57
+ minVersion: 3
58
+ },
59
+ {
60
+ type: 'GET_VERSION',
61
+ path: 'general/get_version',
62
+ method: 'POST',
63
+ minVersion: 0
64
+ },
65
+ {
66
+ type: 'SET_PENAL_CODES',
67
+ path: 'general/set_penal_codes',
68
+ method: 'POST',
69
+ minVersion: 2
70
+ },
71
+ {
72
+ type: 'SET_API_ID',
73
+ path: 'general/set_api_id',
74
+ method: 'POST',
75
+ minVersion: 2
76
+ },
77
+ {
78
+ type: 'GET_TEMPLATES',
79
+ path: 'general/get_templates',
80
+ method: 'POST',
81
+ minVersion: 2
82
+ },
83
+ {
84
+ type: 'NEW_RECORD',
85
+ path: 'general/new_record',
86
+ method: 'POST',
87
+ minVersion: 3
88
+ },
89
+ {
90
+ type: 'EDIT_RECORD',
91
+ path: 'general/edit_record',
92
+ method: 'POST',
93
+ minVersion: 3
94
+ },
95
+ {
96
+ type: 'REMOVE_RECORD',
97
+ path: 'general/remove_record',
98
+ method: 'POST',
99
+ minVersion: 3
100
+ },
101
+ {
102
+ type: 'LOOKUP_INT',
103
+ path: 'general/lookup_int',
104
+ method: 'POST',
105
+ minVersion: 3
106
+ },
107
+ {
108
+ type: 'LOOKUP',
109
+ path: 'general/lookup',
110
+ method: 'POST',
111
+ minVersion: 3
112
+ },
113
+ {
114
+ type: 'GET_ACCOUNT',
115
+ path: 'general/get_account',
116
+ method: 'POST',
117
+ minVersion: 3
118
+ },
119
+ {
120
+ type: 'CHECK_APIID',
121
+ path: 'general/check_apiid',
122
+ method: 'POST',
123
+ minVersion: 2
124
+ },
125
+ {
126
+ type: 'APPLY_PERMISSION_KEY',
127
+ path: 'general/apply_permission_key',
128
+ method: 'POST',
129
+ minVersion: 3
130
+ },
131
+ {
132
+ type: 'SET_ACCOUNT_PERMISSIONS',
133
+ path: 'general/set_account_permissions',
134
+ method: 'POST',
135
+ minVersion: 3
136
+ },
137
+ {
138
+ type: 'BAN_USER',
139
+ path: 'general/ban_user',
140
+ method: 'POST',
141
+ minVersion: 3
142
+ },
143
+ {
144
+ type: 'VERIFY_SECRET',
145
+ path: 'general/verify_secret',
146
+ method: 'POST',
147
+ minVersion: 2
148
+ },
149
+ {
150
+ type: 'AUTH_STREETSIGNS',
151
+ path: 'general/auth_streetsigns',
152
+ method: 'POST',
153
+ minVersion: 4
154
+ },
155
+ {
156
+ type: 'SET_POSTALS',
157
+ path: 'general/set_postals',
158
+ method: 'POST',
159
+ minVersion: 4
160
+ },
161
+ {
162
+ type: 'SEND_PHOTO',
163
+ path: 'general/send_photo',
164
+ method: 'POST',
165
+ minVersion: 4
166
+ }
167
+ ];
168
+
169
+ export const CivilianCADAPITypes: APITypeData[] = [
170
+ {
171
+ type: 'GET_CHARACTERS',
172
+ path: 'civilian/get_characters',
173
+ method: 'POST',
174
+ minVersion: 2
175
+ },
176
+ {
177
+ type: 'NEW_CHARACTER',
178
+ path: 'civilian/new_character',
179
+ method: 'POST',
180
+ minVersion: 2
181
+ },
182
+ {
183
+ type: 'EDIT_CHARACTER',
184
+ path: 'civilian/edit_characters',
185
+ method: 'POST',
186
+ minVersion: 2
187
+ },
188
+ {
189
+ type: 'REMOVE_CHARACTER',
190
+ path: 'civilian/remove_character',
191
+ method: 'POST',
192
+ minVersion: 2
193
+ }
194
+ ];
195
+
196
+ export const EmergencyCADAPITypes: APITypeData[] = [
197
+ {
198
+ type: 'GET_IDENTIFIERS',
199
+ path: 'emergency/get_identifiers',
200
+ method: 'POST',
201
+ minVersion: 3
202
+ },
203
+ {
204
+ type: 'MODIFY_IDENTIFIER',
205
+ path: 'emergency/modify_identifier',
206
+ method: 'POST',
207
+ minVersion: 4
208
+ },
209
+ {
210
+ type: 'SET_IDENTIFIER',
211
+ path: 'emergency/set_identifier',
212
+ method: 'POST',
213
+ minVersion: 3
214
+ },
215
+ {
216
+ type: 'UNIT_PANIC',
217
+ path: 'emergency/unit_panic',
218
+ method: 'POST',
219
+ minVersion: 2
220
+ },
221
+ {
222
+ type: 'UNIT_STATUS',
223
+ path: 'emergency/unit_status',
224
+ method: 'POST',
225
+ minVersion: 2
226
+ },
227
+ {
228
+ type: 'GET_BLIPS',
229
+ path: 'emergency/get_blips',
230
+ method: 'POST',
231
+ minVersion: 4
232
+ },
233
+ {
234
+ type: 'ADD_BLIP',
235
+ path: 'emergency/add_blip',
236
+ method: 'POST',
237
+ minVersion: 4
238
+ },
239
+ {
240
+ type: 'MODIFY_BLIP',
241
+ path: 'emergency/modify_blip',
242
+ method: 'POST',
243
+ minVersion: 4
244
+ },
245
+ {
246
+ type: 'REMOVE_BLIP',
247
+ path: 'emergency/remove_blip',
248
+ method: 'POST',
249
+ minVersion: 4
250
+ },
251
+ {
252
+ type: '911_CALL',
253
+ path: 'emergency/911_call',
254
+ method: 'POST',
255
+ minVersion: 2
256
+ },
257
+ {
258
+ type: 'REMOVE_911',
259
+ path: 'emergency/remove_911',
260
+ method: 'POST',
261
+ minVersion: 2
262
+ },
263
+ {
264
+ type: 'GET_CALLS',
265
+ path: 'emergency/get_calls',
266
+ method: 'POST',
267
+ minVersion: 3
268
+ },
269
+ {
270
+ type: 'GET_ACTIVE_UNITS',
271
+ path: 'emergency/get_active_units',
272
+ method: 'POST',
273
+ minVersion: 3
274
+ },
275
+ {
276
+ type: 'KICK_UNIT',
277
+ path: 'emergency/kick_unit',
278
+ method: 'POST',
279
+ minVersion: 2
280
+ },
281
+ {
282
+ type: 'NEW_DISPATCH',
283
+ path: 'emergency/new_dispatch',
284
+ method: 'POST',
285
+ minVersion: 3
286
+ },
287
+ {
288
+ type: 'ATTACH_UNIT',
289
+ path: 'emergency/attach_unit',
290
+ method: 'POST',
291
+ minVersion: 3
292
+ },
293
+ {
294
+ type: 'DETACH_UNIT',
295
+ path: 'emergency/detach_unit',
296
+ method: 'POST',
297
+ minVersion: 3
298
+ },
299
+ {
300
+ type: 'SET_CALL_POSTAL',
301
+ path: 'emergency/set_call_postal',
302
+ method: 'POST',
303
+ minVersion: 3
304
+ },
305
+ {
306
+ type: 'SET_CALL_PRIMARY',
307
+ path: 'emergency/set_call_primary',
308
+ method: 'POST',
309
+ minVersion: 3
310
+ },
311
+ {
312
+ type: 'ADD_CALL_NOTE',
313
+ path: 'emergency/add_call_note',
314
+ method: 'POST',
315
+ minVersion: 3
316
+ },
317
+ {
318
+ type: 'CLOSE_CALL',
319
+ path: 'emergency/close_call',
320
+ method: 'POST',
321
+ minVersion: 2
322
+ },
323
+ {
324
+ type: 'UNIT_LOCATION',
325
+ path: 'emergency/unit_location',
326
+ method: 'POST',
327
+ minVersion: 2
328
+ },
329
+ {
330
+ type: 'SET_STREETSIGN_CONFIG',
331
+ path: 'emergency/set_streetsign_config',
332
+ method: 'POST',
333
+ minVersion: 4
334
+ },
335
+ {
336
+ type: 'UPDATE_STREETSIGN',
337
+ path: 'emergency/update_streetsign',
338
+ method: 'POST',
339
+ minVersion: 4
340
+ }
341
+ ];
342
+
343
+ export const GeneralCMSAPITypes: APITypeData[] = [
344
+ {
345
+ type: 'GET_COM_ACCOUNT',
346
+ path: 'general/get_com_account',
347
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
348
+ minVersion: 3
349
+ },
350
+ {
351
+ type: 'GET_SUB_VERSION',
352
+ path: 'general/get_sub_version',
353
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
354
+ minVersion: 0
355
+ },
356
+ {
357
+ type: 'CHECK_COM_APIID',
358
+ path: 'general/check_com_apiid',
359
+ method: 'POST',
360
+ minVersion: 2
361
+ },
362
+ {
363
+ type: 'CLOCK_IN_OUT',
364
+ path: 'general/clock_in_out',
365
+ method: 'POST',
366
+ minVersion: 3
367
+ }
368
+ ];
369
+
370
+ export const ServersCMSAPITypes: APITypeData[] = [
371
+ {
372
+ type: 'GET_GAME_SERVERS',
373
+ path: 'servers/get_game_servers',
374
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
375
+ minVersion: 2
376
+ },
377
+ {
378
+ type: 'VERIFY_WHITELIST',
379
+ path: 'servers/verify_whitelist',
380
+ method: 'POST',
381
+ minVersion: 3
382
+ }
383
+ ];
384
+
385
+ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeData[] {
386
+ return array.map((val) => {
387
+ return {
388
+ ...val,
389
+ product
390
+ }
391
+ });
392
+ }
393
+
394
+ export const AllAPITypes: AllAPITypeData[] = [ ...formatForAll(GeneralCADAPITypes, productEnums.CAD), ...formatForAll(CivilianCADAPITypes, productEnums.CAD), ...formatForAll(EmergencyCADAPITypes, productEnums.CAD), ...formatForAll(GeneralCMSAPITypes, productEnums.CMS), ...formatForAll(ServersCMSAPITypes, productEnums.CMS) ];
395
+
396
+ export 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';
397
+
398
+ export interface CMSServerAPIStruct {
399
+ id: number;
400
+ name: string;
401
+ description: string;
402
+ }
403
+
404
+ export interface CADServerAPIStruct {
405
+ id: number;
406
+ name: string;
407
+ description: string;
408
+ signal: string;
409
+ mapUrl: string;
410
+ mapIp: string;
411
+ listenerPort: number;
412
+ differingOutbound: boolean;
413
+ outboundIp: string;
414
+ enableMap: boolean;
415
+ isStatic: boolean;
416
+ mapType: string;
417
+ }
418
+
419
+ export interface CADPenalCodeStruct {
420
+ code: string;
421
+ type: string;
422
+ title: string;
423
+ bondType: string;
424
+ jailTime: string;
425
+ bondAmount: number;
426
+ }
427
+
428
+ export interface CADSetAPIIDStruct {
429
+ username: string;
430
+ sessionId?: string;
431
+ apiIds: string[];
432
+ pushNew: boolean;
433
+ }
434
+
435
+ export enum CADRecordTypeEnums {
436
+ Warrant = 2,
437
+ Bolo = 3,
438
+ License = 4,
439
+ VehicleRegistration = 5,
440
+ Character = 7,
441
+ PoliceRecord = 8,
442
+ PoliceReport = 9,
443
+ MedicalRecord = 10,
444
+ MedicalReport = 11,
445
+ FireRecord = 12,
446
+ FireReport = 13,
447
+ DMVRecord = 14,
448
+ LawRecord = 15,
449
+ LawReport = 16
450
+ }
451
+
452
+ export enum CADRecordSectionCategoryEnums {
453
+ Custom,
454
+ Flags,
455
+ Speed = 5,
456
+ Charges = 6,
457
+ LinkedRecords = 9
458
+ }
459
+
460
+ export interface CADRecordDependencyStruct {
461
+ type: string;
462
+ fid: string;
463
+ acceptableValues: string[];
464
+ }
465
+
466
+ export interface CADRecordSectionFieldStruct {
467
+ type: 'INPUT' | 'TEXTAREA' | 'ADDRESS' | 'SELECT' | 'STATUS' | 'DATE' | 'TIME' | 'IMAGE' | 'CHECKBOXES' | 'LABEL' | 'UNIT_NUMBER' | 'UNIT_NAME' | 'UNIT_RANK' | 'UNIT_AGENCY' | 'UNIT_DEPARTMENT' | 'UNIT_SUBDIVISION' | 'UNIT_AGENCY_LOCATION' | 'UNIT_AGENCY_ZIP' | 'UNIT_LOCATION';
468
+ value: string;
469
+ size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
470
+ data: Record<string | number | symbol, unknown>;
471
+ options: string[];
472
+ isPreviewed: boolean;
473
+ isSupervisor: boolean;
474
+ isRequired: boolean;
475
+ unique: boolean;
476
+ readOnly: boolean;
477
+ mask: string;
478
+ maskReverse: boolean;
479
+ dbMap: boolean;
480
+ isFromSync: boolean;
481
+ uid: string;
482
+ dependency: CADRecordDependencyStruct;
483
+ }
484
+
485
+ export interface CADRecordSectionStruct {
486
+ category: CADRecordSectionCategoryEnums;
487
+ label: string;
488
+ fields: CADRecordSectionFieldStruct[];
489
+ searchCiv: boolean;
490
+ searchVeh: boolean;
491
+ enableDuplicate: boolean;
492
+ dependency: CADRecordDependencyStruct;
493
+ }
494
+
495
+ export interface CADRecordStruct {
496
+ recordTypeId: number;
497
+ id: number;
498
+ syncId: string;
499
+ name: string;
500
+ type: CADRecordTypeEnums;
501
+ sections: CADRecordSectionStruct[];
502
+ }
503
+
504
+ export interface CADNewEditRecordOptionOneStruct {
505
+ user: string;
506
+ useDictionary: boolean;
507
+ recordTypeId: number;
508
+ replaceValues: Record<string, string>;
509
+ }
510
+
511
+ export interface CADNewEditRecordOptionTwoStruct {
512
+ user: string;
513
+ record: CADRecordStruct;
514
+ }
515
+
516
+ export enum CADLookupByIntSearchTypeEnums {
517
+ IDENTIFIER,
518
+ SUPERVISOR_STATUS,
519
+ ACTIVE_STATUS,
520
+ NUMBER
521
+ }
522
+
523
+ export interface CADLookupByIntStruct {
524
+ apiId?: string;
525
+ searchType: CADLookupByIntSearchTypeEnums;
526
+ value: number;
527
+ types: number[],
528
+ limit?: number;
529
+ offset?: number;
530
+ }
531
+
532
+ export interface CADLookupStruct {
533
+ apiId?: string;
534
+ types: number[];
535
+ first: string;
536
+ last: string;
537
+ mi: string;
538
+ plate: string;
539
+ partial: boolean;
540
+ agency?: string;
541
+ department?: string;
542
+ subdivision?: string;
543
+ }
544
+
545
+ export interface CADModifyAccountPermsStruct {
546
+ apiId?: string;
547
+ username?: string;
548
+ active?: boolean;
549
+ add: string[];
550
+ remove: string[];
551
+ }
552
+
553
+ export interface CADKickBanUserStruct {
554
+ apiId: string;
555
+ isBan?: boolean;
556
+ isKick?: boolean;
557
+ }
558
+
559
+ export interface CADSetPostalStruct {
560
+ code: string;
561
+ x: number;
562
+ y: number;
563
+ }
564
+
565
+ export enum CADModifyIdentifierActionEnums {
566
+ ADD,
567
+ EDIT,
568
+ REMOVE
569
+ }
570
+
571
+ export interface CADModifyIdentifierStruct {
572
+ apiId: string;
573
+ action: CADModifyIdentifierActionEnums;
574
+ identifier?: Record<string, string>;
575
+ identId?: number;
576
+ }
577
+
578
+ export interface CADBlipStruct {
579
+ id: number;
580
+ coordinates: {
581
+ x: number;
582
+ y: number;
583
+ };
584
+ icon: string;
585
+ color: string;
586
+ tooltip: string;
587
+ }
588
+
589
+ export interface CADAddBlipStruct {
590
+ serverId: number;
591
+ blip: CADBlipStruct;
592
+ }
593
+
594
+ export interface CADModifyBlipStruct {
595
+ id: number;
596
+ coordinates?: {
597
+ x: number;
598
+ y: number;
599
+ };
600
+ icon?: string;
601
+ color?: string;
602
+ tooltip?: string;
603
+ }
604
+
605
+ export interface CADGetCallsStruct {
606
+ serverId?: number;
607
+ closedLimit?: number;
608
+ closedOffset?: number;
609
+ }
610
+
611
+ export interface CADGetActiveUnitsStruct {
612
+ serverId?: number;
613
+ onlyUnits?: boolean;
614
+ includeOffline?: boolean;
615
+ limit?: number;
616
+ offset?: number;
617
+ }
618
+
619
+ export enum CADDispatchOriginEnums {
620
+ Caller,
621
+ RadioDispatch,
622
+ Observed,
623
+ WalkUp
624
+ }
625
+
626
+ export enum CADDispatchStatusEnums {
627
+ Pending,
628
+ Active,
629
+ Closed
630
+ }
631
+
632
+ export interface CADNewDispatchStruct {
633
+ serverId: number;
634
+ origin: CADDispatchOriginEnums;
635
+ status: CADDispatchStatusEnums;
636
+ priority: 1 | 2 | 3;
637
+ block: string;
638
+ address: string;
639
+ postal: string;
640
+ title: string;
641
+ code: string;
642
+ primary: number;
643
+ trackPrimary: boolean;
644
+ description: string;
645
+ metaData: Record<string, string>;
646
+ units: string[];
647
+ }
648
+
649
+ export interface CADStreetSignStruct {
650
+ id: number;
651
+ label: string;
652
+ text1: string;
653
+ text2: string;
654
+ text3: string;
655
+ }
656
+
657
+ export interface CADUnitLocationStruct {
658
+ apiId: string;
659
+ location: string;
660
+ }
661
+
662
+ export interface RESTTypedAPIDataStructs {
663
+ // CAD - General
664
+ GET_SERVERS: [];
665
+ SET_SERVERS: [
666
+ servers: CADServerAPIStruct[],
667
+ deployMap: boolean
668
+ ];
669
+ GET_VERSION: [];
670
+ SET_PENAL_CODES: [data: CADPenalCodeStruct[]];
671
+ SET_API_ID: [data: CADSetAPIIDStruct];
672
+ GET_TEMPLATES: [recordTypeId?: number];
673
+ NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
674
+ EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
675
+ REMOVE_RECORD: [id: number];
676
+ LOOKUP_INT: [data: CADLookupByIntStruct];
677
+ LOOKUP: [data: CADLookupStruct];
678
+ GET_ACCOUNT: [
679
+ apiId?: string,
680
+ username?: string
681
+ ];
682
+ CHECK_APIID: [apiId: string];
683
+ APPLY_PERMISSION_KEY: [
684
+ apiId: string,
685
+ permissionKey: string
686
+ ];
687
+ SET_ACCOUNT_PERMISSIONS: [data: CADModifyAccountPermsStruct];
688
+ BAN_USER: [data: CADKickBanUserStruct];
689
+ VERIFY_SECRET: [secret: string];
690
+ AUTH_STREETSIGNS: [serverId: number];
691
+ SET_POSTALS: [data: CADSetPostalStruct[]];
692
+ SEND_PHOTO: [
693
+ apiId: string,
694
+ url: string
695
+ ];
696
+ // CAD - Civilian
697
+ GET_CHARACTERS: [apiId: string];
698
+ NEW_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
699
+ EDIT_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
700
+ REMOVE_CHARACTER: [id: number];
701
+ // CAD - Emergency
702
+ GET_IDENTIFIERS: [apiId: string];
703
+ MODIFY_IDENTIFIER: [data: CADModifyIdentifierStruct];
704
+ SET_IDENTIFIER: [
705
+ apiId: string,
706
+ identId: number
707
+ ];
708
+ UNIT_PANIC: [
709
+ apiId: string,
710
+ isPanic: boolean
711
+ ];
712
+ UNIT_STATUS: [
713
+ apiId: string,
714
+ status: number,
715
+ serverId: number
716
+ ];
717
+ GET_BLIPS: [serverId: number];
718
+ ADD_BLIP: [data: CADAddBlipStruct[]];
719
+ MODIFY_BLIP: [data: CADModifyBlipStruct[]];
720
+ REMOVE_BLIP: [id: number];
721
+ REMOVE_911: [callId: number];
722
+ GET_CALLS: [data: CADGetCallsStruct];
723
+ GET_ACTIVE_UNITS: [data: CADGetActiveUnitsStruct];
724
+ KICK_UNIT: [
725
+ apiId: string,
726
+ reason: string,
727
+ serverId: number
728
+ ];
729
+ NEW_DISPATCH: [data: CADNewDispatchStruct];
730
+ ATTACH_UNIT: [
731
+ serverId: number,
732
+ callId: number,
733
+ units: string[]
734
+ ];
735
+ DETACH_UNIT: [
736
+ serverId: number,
737
+ units: string[]
738
+ ];
739
+ SET_CALL_POSTAL: [
740
+ serverId: number,
741
+ callId: number,
742
+ postal: string
743
+ ];
744
+ SET_CALL_PRIMARY: [
745
+ serverId: number,
746
+ callId: number,
747
+ primary: number,
748
+ trackPrimary: boolean
749
+ ];
750
+ ADD_CALL_NOTE: [
751
+ serverId: number,
752
+ callId: number,
753
+ note: string
754
+ ];
755
+ CLOSE_CALL: [
756
+ serverId: number,
757
+ callId: number
758
+ ];
759
+ 'CALL_911': [
760
+ serverId: number,
761
+ isEmergency: boolean,
762
+ caller: string,
763
+ location: string,
764
+ description: string,
765
+ metaData: Record<string, string>
766
+ ];
767
+ SET_STREETSIGN_CONFIG: [
768
+ serverId: number,
769
+ signConfig: CADStreetSignStruct[]
770
+ ];
771
+ UPDATE_STREETSIGN: [
772
+ serverId: number,
773
+ signData: {
774
+ ids: number[],
775
+ text1: string,
776
+ text2: string,
777
+ text3: string
778
+ }
779
+ ];
780
+ UNIT_LOCATION: [data: CADUnitLocationStruct[]];
781
+ // CMS - General
782
+ GET_COM_ACCOUNT: [
783
+ apiId?: string,
784
+ username?: string,
785
+ accId?: string
786
+ ];
787
+ GET_SUB_VERSION: [];
788
+ CHECK_COM_APIID: [apiId: string];
789
+ CLOCK_IN_OUT: [
790
+ apiId?: string,
791
+ accId?: string,
792
+ forceClockIn?: boolean
793
+ ];
794
+ // CMS - Servers
795
+ GET_GAME_SERVERS: [];
796
+ VERIFY_WHITELIST: [
797
+ apiId: string | undefined,
798
+ accId: string | undefined,
799
+ serverId: number
800
+ ];
801
+ }
802
+
803
+ export type PossibleRequestData =
804
+ undefined |
805
+ {
806
+ data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
807
+ } |
808
+ {
809
+ servers: CADServerAPIStruct[];
810
+ deployMap: boolean;
811
+ } |
812
+ {
813
+ id: number;
814
+ } |
815
+ {
816
+ recordTypeId?: number;
817
+ } |
818
+ {
819
+ apiId?: string;
820
+ username?: string;
821
+ } |
822
+ {
823
+ apiId: string
824
+ } |
825
+ {
826
+ apiId: string;
827
+ permissionKey: string;
828
+ } |
829
+ {
830
+ secret: string;
831
+ } |
832
+ {
833
+ serverId: number;
834
+ } |
835
+ {
836
+ serverId?: number;
837
+ } |
838
+ {
839
+ apiId: string;
840
+ url: string;
841
+ } |
842
+ {
843
+ apiId: string;
844
+ identId: number;
845
+ } |
846
+ {
847
+ apiId: string;
848
+ isPanic: boolean;
849
+ } |
850
+ {
851
+ apiId: string;
852
+ status: number;
853
+ serverId: number;
854
+ } |
855
+ {
856
+ callId: number;
857
+ } |
858
+ {
859
+ serverId: number;
860
+ callId: number;
861
+ units: string[];
862
+ } |
863
+ {
864
+ serverId: number;
865
+ units: string[];
866
+ } |
867
+ {
868
+ serverId: number;
869
+ callId: number;
870
+ postal: string;
871
+ } |
872
+ {
873
+ serverId: number;
874
+ callId: number;
875
+ primary: number;
876
+ trackPrimary: boolean;
877
+ } |
878
+ {
879
+ serverId: number;
880
+ callId: number;
881
+ note: string;
882
+ } |
883
+ {
884
+ serverId: number;
885
+ callId: number;
886
+ } |
887
+ {
888
+ serverId: number;
889
+ isEmergency: boolean;
890
+ caller: string;
891
+ location: string;
892
+ description: string;
893
+ metaData: Record<string, string>;
894
+ } |
895
+ {
896
+ serverId: number;
897
+ signConfig: CADStreetSignStruct[];
898
+ } |
899
+ {
900
+ serverId: number;
901
+ signData: {
902
+ ids: number[];
903
+ text1: string;
904
+ text2: string;
905
+ text3: string;
906
+ }
907
+ } |
908
+ {
909
+ apiId?: string;
910
+ username?: string;
911
+ } |
912
+ {
913
+ apiId: string;
914
+ serverId: number;
915
+ } |
916
+ {
917
+ apiId: string;
918
+ forceClockIn: boolean;
919
+ };