@sonoransoftware/sonoran.js 1.0.18 → 1.0.20

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 (89) hide show
  1. package/.eslintrc.js +10 -10
  2. package/.github/workflows/npm-publish.yml +34 -34
  3. package/.prettierrc.js +6 -6
  4. package/dist/builders/cad/DispatchCall.d.ts +92 -92
  5. package/dist/builders/cad/DispatchCall.js +144 -144
  6. package/dist/builders/cad/index.d.ts +1 -1
  7. package/dist/builders/cad/index.js +17 -17
  8. package/dist/builders/index.d.ts +1 -1
  9. package/dist/builders/index.js +19 -19
  10. package/dist/constants.d.ts +230 -230
  11. package/dist/constants.js +27 -27
  12. package/dist/errors/LibraryErrors.d.ts +19 -19
  13. package/dist/errors/LibraryErrors.js +47 -47
  14. package/dist/errors/Messages.d.ts +1 -1
  15. package/dist/errors/Messages.js +8 -8
  16. package/dist/errors/index.d.ts +2 -2
  17. package/dist/errors/index.js +18 -18
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +24 -24
  20. package/dist/instance/Instance.d.ts +24 -24
  21. package/dist/instance/Instance.js +139 -139
  22. package/dist/instance/instance.types.d.ts +17 -17
  23. package/dist/instance/instance.types.js +2 -2
  24. package/dist/libs/rest/src/index.d.ts +6 -6
  25. package/dist/libs/rest/src/index.js +22 -22
  26. package/dist/libs/rest/src/lib/REST.d.ts +101 -101
  27. package/dist/libs/rest/src/lib/REST.js +136 -129
  28. package/dist/libs/rest/src/lib/RequestManager.d.ts +59 -59
  29. package/dist/libs/rest/src/lib/RequestManager.js +191 -191
  30. package/dist/libs/rest/src/lib/errors/APIError.d.ts +9 -9
  31. package/dist/libs/rest/src/lib/errors/APIError.js +17 -17
  32. package/dist/libs/rest/src/lib/errors/HTTPError.d.ts +17 -17
  33. package/dist/libs/rest/src/lib/errors/HTTPError.js +23 -23
  34. package/dist/libs/rest/src/lib/errors/RateLimitError.d.ts +13 -13
  35. package/dist/libs/rest/src/lib/errors/RateLimitError.js +19 -19
  36. package/dist/libs/rest/src/lib/errors/index.d.ts +4 -4
  37. package/dist/libs/rest/src/lib/errors/index.js +20 -20
  38. package/dist/libs/rest/src/lib/handlers/IHandler.d.ts +7 -7
  39. package/dist/libs/rest/src/lib/handlers/IHandler.js +2 -2
  40. package/dist/libs/rest/src/lib/handlers/SequentialHandler.d.ts +45 -45
  41. package/dist/libs/rest/src/lib/handlers/SequentialHandler.js +143 -143
  42. package/dist/libs/rest/src/lib/utils/constants.d.ts +533 -527
  43. package/dist/libs/rest/src/lib/utils/constants.js +463 -443
  44. package/dist/libs/rest/src/lib/utils/utils.d.ts +1 -1
  45. package/dist/libs/rest/src/lib/utils/utils.js +22 -22
  46. package/dist/managers/BaseManager.d.ts +14 -14
  47. package/dist/managers/BaseManager.js +18 -18
  48. package/dist/managers/CADActiveUnitsManager.d.ts +15 -15
  49. package/dist/managers/CADActiveUnitsManager.js +38 -38
  50. package/dist/managers/CADManager.d.ts +29 -29
  51. package/dist/managers/CADManager.js +86 -86
  52. package/dist/managers/CADServerManager.d.ts +8 -8
  53. package/dist/managers/CADServerManager.js +28 -28
  54. package/dist/managers/CMSManager.d.ts +101 -101
  55. package/dist/managers/CMSManager.js +266 -266
  56. package/dist/managers/CMSServerManager.d.ts +8 -8
  57. package/dist/managers/CMSServerManager.js +34 -34
  58. package/dist/managers/CacheManager.d.ts +10 -10
  59. package/dist/managers/CacheManager.js +36 -36
  60. package/dist/managers/DataManager.d.ts +31 -31
  61. package/dist/managers/DataManager.js +58 -58
  62. package/dist/structures/Base.d.ts +9 -9
  63. package/dist/structures/Base.js +24 -24
  64. package/dist/structures/CADActiveUnit.d.ts +47 -47
  65. package/dist/structures/CADActiveUnit.js +66 -66
  66. package/dist/structures/CADServer.d.ts +26 -26
  67. package/dist/structures/CADServer.js +15 -15
  68. package/dist/structures/CMSServer.d.ts +18 -18
  69. package/dist/structures/CMSServer.js +12 -12
  70. package/dist/utils/index.d.ts +1 -1
  71. package/dist/utils/index.js +17 -17
  72. package/dist/utils/utils.d.ts +13 -13
  73. package/dist/utils/utils.js +79 -79
  74. package/docs/CAD-Methods-and-Usage.md +58 -58
  75. package/docs/CMS-Methods-and-Usage.md +211 -211
  76. package/docs/REST-Methods-and-Usage.md +46 -46
  77. package/package.json +48 -48
  78. package/readme.md +53 -53
  79. package/src/constants.ts +248 -248
  80. package/src/instance/Instance.ts +121 -121
  81. package/src/instance/instance.types.ts +17 -17
  82. package/src/libs/rest/src/lib/REST.ts +241 -235
  83. package/src/libs/rest/src/lib/RequestManager.ts +260 -260
  84. package/src/libs/rest/src/lib/handlers/SequentialHandler.ts +160 -160
  85. package/src/libs/rest/src/lib/utils/constants.ts +1012 -985
  86. package/src/managers/CADManager.ts +63 -63
  87. package/src/managers/CMSManager.ts +226 -226
  88. package/src/managers/CMSServerManager.ts +32 -32
  89. package/tsconfig.json +71 -71
@@ -1,986 +1,1013 @@
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_ACCOUNT_RANKS',
352
- path: 'general/get_account_ranks',
353
- method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
354
- minVersion: 2,
355
- },
356
- {
357
- type: 'SET_ACCOUNT_RANKS',
358
- path: 'general/set_account_ranks',
359
- method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
360
- minVersion: 2,
361
- },
362
- {
363
- type: 'GET_DEPARTMENTS',
364
- path: 'general/get_departments',
365
- method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
366
- minVersion: 2,
367
- },
368
- {
369
- type: 'GET_SUB_VERSION',
370
- path: 'general/get_sub_version',
371
- method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
372
- minVersion: 0
373
- },
374
- {
375
- type: 'CHECK_COM_APIID',
376
- path: 'general/check_com_apiid',
377
- method: 'POST',
378
- minVersion: 2
379
- },
380
- {
381
- type: 'CLOCK_IN_OUT',
382
- path: 'general/clock_in_out',
383
- method: 'POST',
384
- minVersion: 3
385
- }
386
- ];
387
-
388
- export const ServersCMSAPITypes: APITypeData[] = [
389
- {
390
- type: 'GET_GAME_SERVERS',
391
- path: 'servers/get_game_servers',
392
- method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
393
- minVersion: 2
394
- },
395
- {
396
- type: 'VERIFY_WHITELIST',
397
- path: 'servers/verify_whitelist',
398
- method: 'POST',
399
- minVersion: 3
400
- },
401
- {
402
- type: 'FULL_WHITELIST',
403
- path: 'servers/full_whitelist',
404
- method: 'POST',
405
- minVersion: 3
406
- }
407
- ];
408
-
409
- export const EventsCMSAPITypes: APITypeData[] = [
410
- {
411
- type: 'RSVP',
412
- path: 'events/rsvp',
413
- method: 'POST',
414
- minVersion: 3
415
- }
416
- ];
417
-
418
- function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeData[] {
419
- return array.map((val) => {
420
- return {
421
- ...val,
422
- product
423
- }
424
- });
425
- }
426
-
427
- export const AllAPITypes: AllAPITypeData[] = [ ...formatForAll(GeneralCADAPITypes, productEnums.CAD), ...formatForAll(CivilianCADAPITypes, productEnums.CAD), ...formatForAll(EmergencyCADAPITypes, productEnums.CAD), ...formatForAll(GeneralCMSAPITypes, productEnums.CMS), ...formatForAll(ServersCMSAPITypes, productEnums.CMS), ...formatForAll(EventsCMSAPITypes, productEnums.CMS) ];
428
-
429
- 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_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP';
430
-
431
- export interface CMSServerAPIStruct {
432
- id: number;
433
- name: string;
434
- description: string;
435
- }
436
-
437
- export interface CADServerAPIStruct {
438
- id: number;
439
- name: string;
440
- description: string;
441
- signal: string;
442
- mapUrl: string;
443
- mapIp: string;
444
- listenerPort: number;
445
- differingOutbound: boolean;
446
- outboundIp: string;
447
- enableMap: boolean;
448
- isStatic: boolean;
449
- mapType: string;
450
- }
451
-
452
- export interface CADPenalCodeStruct {
453
- code: string;
454
- type: string;
455
- title: string;
456
- bondType: string;
457
- jailTime: string;
458
- bondAmount: number;
459
- }
460
-
461
- export interface CADSetAPIIDStruct {
462
- username: string;
463
- sessionId?: string;
464
- apiIds: string[];
465
- pushNew: boolean;
466
- }
467
-
468
- export enum CADRecordTypeEnums {
469
- Warrant = 2,
470
- Bolo = 3,
471
- License = 4,
472
- VehicleRegistration = 5,
473
- Character = 7,
474
- PoliceRecord = 8,
475
- PoliceReport = 9,
476
- MedicalRecord = 10,
477
- MedicalReport = 11,
478
- FireRecord = 12,
479
- FireReport = 13,
480
- DMVRecord = 14,
481
- LawRecord = 15,
482
- LawReport = 16
483
- }
484
-
485
- export enum CADRecordSectionCategoryEnums {
486
- Custom,
487
- Flags,
488
- Speed = 5,
489
- Charges = 6,
490
- LinkedRecords = 9
491
- }
492
-
493
- export interface CADRecordDependencyStruct {
494
- type: string;
495
- fid: string;
496
- acceptableValues: string[];
497
- }
498
-
499
- export interface CADRecordSectionFieldStruct {
500
- 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';
501
- value: string;
502
- size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
503
- data: Record<string | number | symbol, unknown>;
504
- options: string[];
505
- isPreviewed: boolean;
506
- isSupervisor: boolean;
507
- isRequired: boolean;
508
- unique: boolean;
509
- readOnly: boolean;
510
- mask: string;
511
- maskReverse: boolean;
512
- dbMap: boolean;
513
- isFromSync: boolean;
514
- uid: string;
515
- dependency: CADRecordDependencyStruct;
516
- }
517
-
518
- export interface CADRecordSectionStruct {
519
- category: CADRecordSectionCategoryEnums;
520
- label: string;
521
- fields: CADRecordSectionFieldStruct[];
522
- searchCiv: boolean;
523
- searchVeh: boolean;
524
- enableDuplicate: boolean;
525
- dependency: CADRecordDependencyStruct;
526
- }
527
-
528
- export interface CADRecordStruct {
529
- recordTypeId: number;
530
- id: number;
531
- syncId: string;
532
- name: string;
533
- type: CADRecordTypeEnums;
534
- sections: CADRecordSectionStruct[];
535
- }
536
-
537
- export interface CADNewEditRecordOptionOneStruct {
538
- user: string;
539
- useDictionary: boolean;
540
- recordTypeId: number;
541
- replaceValues: Record<string, string>;
542
- }
543
-
544
- export interface CADNewEditRecordOptionTwoStruct {
545
- user: string;
546
- record: CADRecordStruct;
547
- }
548
-
549
- export enum CADLookupByIntSearchTypeEnums {
550
- IDENTIFIER,
551
- SUPERVISOR_STATUS,
552
- ACTIVE_STATUS,
553
- NUMBER
554
- }
555
-
556
- export interface CADLookupByIntStruct {
557
- apiId?: string;
558
- searchType: CADLookupByIntSearchTypeEnums;
559
- value: number;
560
- types: number[],
561
- limit?: number;
562
- offset?: number;
563
- }
564
-
565
- export interface CADLookupStruct {
566
- apiId?: string;
567
- types: number[];
568
- first: string;
569
- last: string;
570
- mi: string;
571
- plate: string;
572
- partial: boolean;
573
- agency?: string;
574
- department?: string;
575
- subdivision?: string;
576
- }
577
-
578
- export interface CADModifyAccountPermsStruct {
579
- apiId?: string;
580
- username?: string;
581
- active?: boolean;
582
- add: string[];
583
- remove: string[];
584
- }
585
-
586
- export interface CADKickBanUserStruct {
587
- apiId: string;
588
- isBan?: boolean;
589
- isKick?: boolean;
590
- }
591
-
592
- export interface CADSetPostalStruct {
593
- code: string;
594
- x: number;
595
- y: number;
596
- }
597
-
598
- export enum CADModifyIdentifierActionEnums {
599
- ADD,
600
- EDIT,
601
- REMOVE
602
- }
603
-
604
- export interface CADModifyIdentifierStruct {
605
- apiId: string;
606
- action: CADModifyIdentifierActionEnums;
607
- identifier?: Record<string, string>;
608
- identId?: number;
609
- }
610
-
611
- export interface CADBlipStruct {
612
- id: number;
613
- coordinates: {
614
- x: number;
615
- y: number;
616
- };
617
- icon: string;
618
- color: string;
619
- tooltip: string;
620
- }
621
-
622
- export interface CADAddBlipStruct {
623
- serverId: number;
624
- blip: CADBlipStruct;
625
- }
626
-
627
- export interface CADModifyBlipStruct {
628
- id: number;
629
- coordinates?: {
630
- x: number;
631
- y: number;
632
- };
633
- icon?: string;
634
- color?: string;
635
- tooltip?: string;
636
- }
637
-
638
- export interface CADGetCallsStruct {
639
- serverId?: number;
640
- closedLimit?: number;
641
- closedOffset?: number;
642
- }
643
-
644
- export interface CADGetActiveUnitsStruct {
645
- serverId?: number;
646
- onlyUnits?: boolean;
647
- includeOffline?: boolean;
648
- limit?: number;
649
- offset?: number;
650
- }
651
-
652
- export enum CADDispatchOriginEnums {
653
- Caller,
654
- RadioDispatch,
655
- Observed,
656
- WalkUp
657
- }
658
-
659
- export enum CADDispatchStatusEnums {
660
- Pending,
661
- Active,
662
- Closed
663
- }
664
-
665
- export interface CADNewDispatchStruct {
666
- serverId: number;
667
- origin: CADDispatchOriginEnums;
668
- status: CADDispatchStatusEnums;
669
- priority: 1 | 2 | 3;
670
- block: string;
671
- address: string;
672
- postal: string;
673
- title: string;
674
- code: string;
675
- primary: number;
676
- trackPrimary: boolean;
677
- description: string;
678
- metaData: Record<string, string>;
679
- units: string[];
680
- }
681
-
682
- export interface CADStreetSignStruct {
683
- id: number;
684
- label: string;
685
- text1: string;
686
- text2: string;
687
- text3: string;
688
- }
689
-
690
- export interface CADUnitLocationStruct {
691
- apiId: string;
692
- location: string;
693
- }
694
-
695
- export interface RESTTypedAPIDataStructs {
696
- // CAD - General
697
- GET_SERVERS: [];
698
- SET_SERVERS: [
699
- servers: CADServerAPIStruct[],
700
- deployMap: boolean
701
- ];
702
- GET_VERSION: [];
703
- SET_PENAL_CODES: [data: CADPenalCodeStruct[]];
704
- SET_API_ID: [data: CADSetAPIIDStruct];
705
- GET_TEMPLATES: [recordTypeId?: number];
706
- NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
707
- EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
708
- REMOVE_RECORD: [id: number];
709
- LOOKUP_INT: [data: CADLookupByIntStruct];
710
- LOOKUP: [data: CADLookupStruct];
711
- GET_ACCOUNT: [
712
- apiId?: string,
713
- username?: string
714
- ];
715
- CHECK_APIID: [apiId: string];
716
- APPLY_PERMISSION_KEY: [
717
- apiId: string,
718
- permissionKey: string
719
- ];
720
- SET_ACCOUNT_PERMISSIONS: [data: CADModifyAccountPermsStruct];
721
- BAN_USER: [data: CADKickBanUserStruct];
722
- VERIFY_SECRET: [secret: string];
723
- AUTH_STREETSIGNS: [serverId: number];
724
- SET_POSTALS: [data: CADSetPostalStruct[]];
725
- SEND_PHOTO: [
726
- apiId: string,
727
- url: string
728
- ];
729
- // CAD - Civilian
730
- GET_CHARACTERS: [apiId: string];
731
- NEW_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
732
- EDIT_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
733
- REMOVE_CHARACTER: [id: number];
734
- // CAD - Emergency
735
- GET_IDENTIFIERS: [apiId: string];
736
- MODIFY_IDENTIFIER: [data: CADModifyIdentifierStruct];
737
- SET_IDENTIFIER: [
738
- apiId: string,
739
- identId: number
740
- ];
741
- UNIT_PANIC: [
742
- apiId: string,
743
- isPanic: boolean
744
- ];
745
- UNIT_STATUS: [
746
- apiId: string,
747
- status: number,
748
- serverId: number
749
- ];
750
- GET_BLIPS: [serverId: number];
751
- ADD_BLIP: [data: CADAddBlipStruct[]];
752
- MODIFY_BLIP: [data: CADModifyBlipStruct[]];
753
- REMOVE_BLIP: [id: number];
754
- REMOVE_911: [callId: number];
755
- GET_CALLS: [data: CADGetCallsStruct];
756
- GET_ACTIVE_UNITS: [data: CADGetActiveUnitsStruct];
757
- KICK_UNIT: [
758
- apiId: string,
759
- reason: string,
760
- serverId: number
761
- ];
762
- NEW_DISPATCH: [data: CADNewDispatchStruct];
763
- ATTACH_UNIT: [
764
- serverId: number,
765
- callId: number,
766
- units: string[]
767
- ];
768
- DETACH_UNIT: [
769
- serverId: number,
770
- units: string[]
771
- ];
772
- SET_CALL_POSTAL: [
773
- serverId: number,
774
- callId: number,
775
- postal: string
776
- ];
777
- SET_CALL_PRIMARY: [
778
- serverId: number,
779
- callId: number,
780
- primary: number,
781
- trackPrimary: boolean
782
- ];
783
- ADD_CALL_NOTE: [
784
- serverId: number,
785
- callId: number,
786
- note: string
787
- ];
788
- CLOSE_CALL: [
789
- serverId: number,
790
- callId: number
791
- ];
792
- 'CALL_911': [
793
- serverId: number,
794
- isEmergency: boolean,
795
- caller: string,
796
- location: string,
797
- description: string,
798
- metaData: Record<string, string>
799
- ];
800
- SET_STREETSIGN_CONFIG: [
801
- serverId: number,
802
- signConfig: CADStreetSignStruct[]
803
- ];
804
- UPDATE_STREETSIGN: [
805
- serverId: number,
806
- signData: {
807
- ids: number[],
808
- text1: string,
809
- text2: string,
810
- text3: string
811
- }
812
- ];
813
- UNIT_LOCATION: [data: CADUnitLocationStruct[]];
814
- // CMS - General
815
- GET_COM_ACCOUNT: [
816
- apiId?: string,
817
- username?: string,
818
- accId?: string,
819
- discord?: string,
820
- ];
821
- GET_SUB_VERSION: [];
822
- CHECK_COM_APIID: [apiId: string];
823
- CLOCK_IN_OUT: [
824
- apiId?: string,
825
- accId?: string,
826
- forceClockIn?: boolean
827
- ];
828
- GET_DEPARTMENTS: [];
829
- GET_ACCOUNT_RANKS: [
830
- apiId?: string,
831
- username?: string,
832
- accId?: string,
833
- discord?: string,
834
- ],
835
- SET_ACCOUNT_RANKS: [
836
- accountId: string,
837
- set?: {
838
- primary?: string | null,
839
- secondary?: string[]
840
- },
841
- add?: string[],
842
- remove?: string[],
843
- ],
844
- // CMS - Servers
845
- GET_GAME_SERVERS: [];
846
- VERIFY_WHITELIST: [
847
- apiId: string | undefined,
848
- accId: string | undefined,
849
- serverId: number
850
- ];
851
- FULL_WHITELIST: [
852
- serverId?: number,
853
- ]
854
- RSVP : [
855
- eventId: string,
856
- apiId: string | undefined,
857
- accId: string | undefined,
858
- ]
859
- }
860
-
861
- export type PossibleRequestData =
862
- undefined |
863
- {
864
- data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
865
- } |
866
- {
867
- servers: CADServerAPIStruct[];
868
- deployMap: boolean;
869
- } |
870
- {
871
- id: number;
872
- } |
873
- {
874
- recordTypeId?: number;
875
- } |
876
- {
877
- apiId?: string;
878
- username?: string;
879
- } |
880
- {
881
- apiId: string
882
- } |
883
- {
884
- apiId: string;
885
- permissionKey: string;
886
- } |
887
- {
888
- secret: string;
889
- } |
890
- {
891
- serverId: number;
892
- } |
893
- {
894
- serverId?: number;
895
- } |
896
- {
897
- apiId: string;
898
- url: string;
899
- } |
900
- {
901
- apiId: string;
902
- identId: number;
903
- } |
904
- {
905
- apiId: string;
906
- isPanic: boolean;
907
- } |
908
- {
909
- apiId: string;
910
- status: number;
911
- serverId: number;
912
- } |
913
- {
914
- callId: number;
915
- } |
916
- {
917
- serverId: number;
918
- callId: number;
919
- units: string[];
920
- } |
921
- {
922
- serverId: number;
923
- units: string[];
924
- } |
925
- {
926
- serverId: number;
927
- callId: number;
928
- postal: string;
929
- } |
930
- {
931
- serverId: number;
932
- callId: number;
933
- primary: number;
934
- trackPrimary: boolean;
935
- } |
936
- {
937
- serverId: number;
938
- callId: number;
939
- note: string;
940
- } |
941
- {
942
- serverId: number;
943
- callId: number;
944
- } |
945
- {
946
- serverId: number;
947
- isEmergency: boolean;
948
- caller: string;
949
- location: string;
950
- description: string;
951
- metaData: Record<string, string>;
952
- } |
953
- {
954
- serverId: number;
955
- signConfig: CADStreetSignStruct[];
956
- } |
957
- {
958
- serverId: number;
959
- signData: {
960
- ids: number[];
961
- text1: string;
962
- text2: string;
963
- text3: string;
964
- }
965
- } |
966
- {
967
- apiId?: string;
968
- username?: string;
969
- } |
970
- {
971
- apiId: string;
972
- serverId: number;
973
- } |
974
- {
975
- apiId: string;
976
- forceClockIn: boolean;
977
- } |
978
- {
979
- accountId: string,
980
- set?: {
981
- primary: string[],
982
- secondary: string[]
983
- },
984
- add?: string[],
985
- remove?: string[],
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_ACCOUNT_RANKS',
352
+ path: 'general/get_account_ranks',
353
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
354
+ minVersion: 2,
355
+ },
356
+ {
357
+ type: 'SET_ACCOUNT_RANKS',
358
+ path: 'general/set_account_ranks',
359
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
360
+ minVersion: 2,
361
+ },
362
+ {
363
+ type: 'GET_DEPARTMENTS',
364
+ path: 'general/get_departments',
365
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
366
+ minVersion: 2,
367
+ },
368
+ {
369
+ type: 'GET_SUB_VERSION',
370
+ path: 'general/get_sub_version',
371
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
372
+ minVersion: 0
373
+ },
374
+ {
375
+ type: 'CHECK_COM_APIID',
376
+ path: 'general/check_com_apiid',
377
+ method: 'POST',
378
+ minVersion: 2
379
+ },
380
+ {
381
+ type: 'CLOCK_IN_OUT',
382
+ path: 'general/clock_in_out',
383
+ method: 'POST',
384
+ minVersion: 3
385
+ },
386
+ {
387
+ type: 'KICK_ACCOUNT',
388
+ path: 'general/kick_account',
389
+ method: 'POST',
390
+ minVersion: 3
391
+ },
392
+ {
393
+ type: 'BAN_ACCOUNT',
394
+ path: 'general/ban_account',
395
+ method: 'POST',
396
+ minVersion: 3
397
+ }
398
+ ];
399
+
400
+ export const ServersCMSAPITypes: APITypeData[] = [
401
+ {
402
+ type: 'GET_GAME_SERVERS',
403
+ path: 'servers/get_game_servers',
404
+ method: 'POST', // Would've been 'GET' but fetch doesn't allow body with GET requests.
405
+ minVersion: 2
406
+ },
407
+ {
408
+ type: 'VERIFY_WHITELIST',
409
+ path: 'servers/verify_whitelist',
410
+ method: 'POST',
411
+ minVersion: 3
412
+ },
413
+ {
414
+ type: 'FULL_WHITELIST',
415
+ path: 'servers/full_whitelist',
416
+ method: 'POST',
417
+ minVersion: 3
418
+ }
419
+ ];
420
+
421
+ export const EventsCMSAPITypes: APITypeData[] = [
422
+ {
423
+ type: 'RSVP',
424
+ path: 'events/rsvp',
425
+ method: 'POST',
426
+ minVersion: 3
427
+ }
428
+ ];
429
+
430
+ export const FormsCMSAPITypes: APITypeData[] = [
431
+ {
432
+ type: 'CHANGE_FORM_STAGE',
433
+ path: '/forms/change/stage',
434
+ method: 'POST',
435
+ minVersion: 0
436
+ }
437
+ ];
438
+
439
+ function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeData[] {
440
+ return array.map((val) => {
441
+ return {
442
+ ...val,
443
+ product
444
+ }
445
+ });
446
+ }
447
+
448
+ export const AllAPITypes: AllAPITypeData[] = [ ...formatForAll(GeneralCADAPITypes, productEnums.CAD), ...formatForAll(CivilianCADAPITypes, productEnums.CAD), ...formatForAll(EmergencyCADAPITypes, productEnums.CAD), ...formatForAll(GeneralCMSAPITypes, productEnums.CMS), ...formatForAll(ServersCMSAPITypes, productEnums.CMS), ...formatForAll(EventsCMSAPITypes, productEnums.CMS) ];
449
+
450
+ 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_DEPARTMENTS' | 'GET_SUB_VERSION' | 'CHECK_COM_APIID' | 'VERIFY_WHITELIST' | 'CLOCK_IN_OUT' | 'FULL_WHITELIST' | 'GET_ACCOUNT_RANKS' | 'SET_ACCOUNT_RANKS' | 'RSVP' | 'CHANGE_FORM_STAGE';
451
+
452
+ export interface CMSServerAPIStruct {
453
+ id: number;
454
+ name: string;
455
+ description: string;
456
+ }
457
+
458
+ export interface CADServerAPIStruct {
459
+ id: number;
460
+ name: string;
461
+ description: string;
462
+ signal: string;
463
+ mapUrl: string;
464
+ mapIp: string;
465
+ listenerPort: number;
466
+ differingOutbound: boolean;
467
+ outboundIp: string;
468
+ enableMap: boolean;
469
+ isStatic: boolean;
470
+ mapType: string;
471
+ }
472
+
473
+ export interface CADPenalCodeStruct {
474
+ code: string;
475
+ type: string;
476
+ title: string;
477
+ bondType: string;
478
+ jailTime: string;
479
+ bondAmount: number;
480
+ }
481
+
482
+ export interface CADSetAPIIDStruct {
483
+ username: string;
484
+ sessionId?: string;
485
+ apiIds: string[];
486
+ pushNew: boolean;
487
+ }
488
+
489
+ export enum CADRecordTypeEnums {
490
+ Warrant = 2,
491
+ Bolo = 3,
492
+ License = 4,
493
+ VehicleRegistration = 5,
494
+ Character = 7,
495
+ PoliceRecord = 8,
496
+ PoliceReport = 9,
497
+ MedicalRecord = 10,
498
+ MedicalReport = 11,
499
+ FireRecord = 12,
500
+ FireReport = 13,
501
+ DMVRecord = 14,
502
+ LawRecord = 15,
503
+ LawReport = 16
504
+ }
505
+
506
+ export enum CADRecordSectionCategoryEnums {
507
+ Custom,
508
+ Flags,
509
+ Speed = 5,
510
+ Charges = 6,
511
+ LinkedRecords = 9
512
+ }
513
+
514
+ export interface CADRecordDependencyStruct {
515
+ type: string;
516
+ fid: string;
517
+ acceptableValues: string[];
518
+ }
519
+
520
+ export interface CADRecordSectionFieldStruct {
521
+ 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';
522
+ value: string;
523
+ size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
524
+ data: Record<string | number | symbol, unknown>;
525
+ options: string[];
526
+ isPreviewed: boolean;
527
+ isSupervisor: boolean;
528
+ isRequired: boolean;
529
+ unique: boolean;
530
+ readOnly: boolean;
531
+ mask: string;
532
+ maskReverse: boolean;
533
+ dbMap: boolean;
534
+ isFromSync: boolean;
535
+ uid: string;
536
+ dependency: CADRecordDependencyStruct;
537
+ }
538
+
539
+ export interface CADRecordSectionStruct {
540
+ category: CADRecordSectionCategoryEnums;
541
+ label: string;
542
+ fields: CADRecordSectionFieldStruct[];
543
+ searchCiv: boolean;
544
+ searchVeh: boolean;
545
+ enableDuplicate: boolean;
546
+ dependency: CADRecordDependencyStruct;
547
+ }
548
+
549
+ export interface CADRecordStruct {
550
+ recordTypeId: number;
551
+ id: number;
552
+ syncId: string;
553
+ name: string;
554
+ type: CADRecordTypeEnums;
555
+ sections: CADRecordSectionStruct[];
556
+ }
557
+
558
+ export interface CADNewEditRecordOptionOneStruct {
559
+ user: string;
560
+ useDictionary: boolean;
561
+ recordTypeId: number;
562
+ replaceValues: Record<string, string>;
563
+ }
564
+
565
+ export interface CADNewEditRecordOptionTwoStruct {
566
+ user: string;
567
+ record: CADRecordStruct;
568
+ }
569
+
570
+ export enum CADLookupByIntSearchTypeEnums {
571
+ IDENTIFIER,
572
+ SUPERVISOR_STATUS,
573
+ ACTIVE_STATUS,
574
+ NUMBER
575
+ }
576
+
577
+ export interface CADLookupByIntStruct {
578
+ apiId?: string;
579
+ searchType: CADLookupByIntSearchTypeEnums;
580
+ value: number;
581
+ types: number[],
582
+ limit?: number;
583
+ offset?: number;
584
+ }
585
+
586
+ export interface CADLookupStruct {
587
+ apiId?: string;
588
+ types: number[];
589
+ first: string;
590
+ last: string;
591
+ mi: string;
592
+ plate: string;
593
+ partial: boolean;
594
+ agency?: string;
595
+ department?: string;
596
+ subdivision?: string;
597
+ }
598
+
599
+ export interface CADModifyAccountPermsStruct {
600
+ apiId?: string;
601
+ username?: string;
602
+ active?: boolean;
603
+ add: string[];
604
+ remove: string[];
605
+ }
606
+
607
+ export interface CADKickBanUserStruct {
608
+ apiId: string;
609
+ isBan?: boolean;
610
+ isKick?: boolean;
611
+ }
612
+
613
+ export interface CADSetPostalStruct {
614
+ code: string;
615
+ x: number;
616
+ y: number;
617
+ }
618
+
619
+ export enum CADModifyIdentifierActionEnums {
620
+ ADD,
621
+ EDIT,
622
+ REMOVE
623
+ }
624
+
625
+ export interface CADModifyIdentifierStruct {
626
+ apiId: string;
627
+ action: CADModifyIdentifierActionEnums;
628
+ identifier?: Record<string, string>;
629
+ identId?: number;
630
+ }
631
+
632
+ export interface CADBlipStruct {
633
+ id: number;
634
+ coordinates: {
635
+ x: number;
636
+ y: number;
637
+ };
638
+ icon: string;
639
+ color: string;
640
+ tooltip: string;
641
+ }
642
+
643
+ export interface CADAddBlipStruct {
644
+ serverId: number;
645
+ blip: CADBlipStruct;
646
+ }
647
+
648
+ export interface CADModifyBlipStruct {
649
+ id: number;
650
+ coordinates?: {
651
+ x: number;
652
+ y: number;
653
+ };
654
+ icon?: string;
655
+ color?: string;
656
+ tooltip?: string;
657
+ }
658
+
659
+ export interface CADGetCallsStruct {
660
+ serverId?: number;
661
+ closedLimit?: number;
662
+ closedOffset?: number;
663
+ }
664
+
665
+ export interface CADGetActiveUnitsStruct {
666
+ serverId?: number;
667
+ onlyUnits?: boolean;
668
+ includeOffline?: boolean;
669
+ limit?: number;
670
+ offset?: number;
671
+ }
672
+
673
+ export enum CADDispatchOriginEnums {
674
+ Caller,
675
+ RadioDispatch,
676
+ Observed,
677
+ WalkUp
678
+ }
679
+
680
+ export enum CADDispatchStatusEnums {
681
+ Pending,
682
+ Active,
683
+ Closed
684
+ }
685
+
686
+ export interface CADNewDispatchStruct {
687
+ serverId: number;
688
+ origin: CADDispatchOriginEnums;
689
+ status: CADDispatchStatusEnums;
690
+ priority: 1 | 2 | 3;
691
+ block: string;
692
+ address: string;
693
+ postal: string;
694
+ title: string;
695
+ code: string;
696
+ primary: number;
697
+ trackPrimary: boolean;
698
+ description: string;
699
+ metaData: Record<string, string>;
700
+ units: string[];
701
+ }
702
+
703
+ export interface CADStreetSignStruct {
704
+ id: number;
705
+ label: string;
706
+ text1: string;
707
+ text2: string;
708
+ text3: string;
709
+ }
710
+
711
+ export interface CADUnitLocationStruct {
712
+ apiId: string;
713
+ location: string;
714
+ }
715
+
716
+ export interface RESTTypedAPIDataStructs {
717
+ // CAD - General
718
+ GET_SERVERS: [];
719
+ SET_SERVERS: [
720
+ servers: CADServerAPIStruct[],
721
+ deployMap: boolean
722
+ ];
723
+ GET_VERSION: [];
724
+ SET_PENAL_CODES: [data: CADPenalCodeStruct[]];
725
+ SET_API_ID: [data: CADSetAPIIDStruct];
726
+ GET_TEMPLATES: [recordTypeId?: number];
727
+ NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
728
+ EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
729
+ REMOVE_RECORD: [id: number];
730
+ LOOKUP_INT: [data: CADLookupByIntStruct];
731
+ LOOKUP: [data: CADLookupStruct];
732
+ GET_ACCOUNT: [
733
+ apiId?: string,
734
+ username?: string
735
+ ];
736
+ CHECK_APIID: [apiId: string];
737
+ APPLY_PERMISSION_KEY: [
738
+ apiId: string,
739
+ permissionKey: string
740
+ ];
741
+ SET_ACCOUNT_PERMISSIONS: [data: CADModifyAccountPermsStruct];
742
+ BAN_USER: [data: CADKickBanUserStruct];
743
+ VERIFY_SECRET: [secret: string];
744
+ AUTH_STREETSIGNS: [serverId: number];
745
+ SET_POSTALS: [data: CADSetPostalStruct[]];
746
+ SEND_PHOTO: [
747
+ apiId: string,
748
+ url: string
749
+ ];
750
+ // CAD - Civilian
751
+ GET_CHARACTERS: [apiId: string];
752
+ NEW_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
753
+ EDIT_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
754
+ REMOVE_CHARACTER: [id: number];
755
+ // CAD - Emergency
756
+ GET_IDENTIFIERS: [apiId: string];
757
+ MODIFY_IDENTIFIER: [data: CADModifyIdentifierStruct];
758
+ SET_IDENTIFIER: [
759
+ apiId: string,
760
+ identId: number
761
+ ];
762
+ UNIT_PANIC: [
763
+ apiId: string,
764
+ isPanic: boolean
765
+ ];
766
+ UNIT_STATUS: [
767
+ apiId: string,
768
+ status: number,
769
+ serverId: number
770
+ ];
771
+ GET_BLIPS: [serverId: number];
772
+ ADD_BLIP: [data: CADAddBlipStruct[]];
773
+ MODIFY_BLIP: [data: CADModifyBlipStruct[]];
774
+ REMOVE_BLIP: [id: number];
775
+ REMOVE_911: [callId: number];
776
+ GET_CALLS: [data: CADGetCallsStruct];
777
+ GET_ACTIVE_UNITS: [data: CADGetActiveUnitsStruct];
778
+ KICK_UNIT: [
779
+ apiId: string,
780
+ reason: string,
781
+ serverId: number
782
+ ];
783
+ NEW_DISPATCH: [data: CADNewDispatchStruct];
784
+ ATTACH_UNIT: [
785
+ serverId: number,
786
+ callId: number,
787
+ units: string[]
788
+ ];
789
+ DETACH_UNIT: [
790
+ serverId: number,
791
+ units: string[]
792
+ ];
793
+ SET_CALL_POSTAL: [
794
+ serverId: number,
795
+ callId: number,
796
+ postal: string
797
+ ];
798
+ SET_CALL_PRIMARY: [
799
+ serverId: number,
800
+ callId: number,
801
+ primary: number,
802
+ trackPrimary: boolean
803
+ ];
804
+ ADD_CALL_NOTE: [
805
+ serverId: number,
806
+ callId: number,
807
+ note: string
808
+ ];
809
+ CLOSE_CALL: [
810
+ serverId: number,
811
+ callId: number
812
+ ];
813
+ 'CALL_911': [
814
+ serverId: number,
815
+ isEmergency: boolean,
816
+ caller: string,
817
+ location: string,
818
+ description: string,
819
+ metaData: Record<string, string>
820
+ ];
821
+ SET_STREETSIGN_CONFIG: [
822
+ serverId: number,
823
+ signConfig: CADStreetSignStruct[]
824
+ ];
825
+ UPDATE_STREETSIGN: [
826
+ serverId: number,
827
+ signData: {
828
+ ids: number[],
829
+ text1: string,
830
+ text2: string,
831
+ text3: string
832
+ }
833
+ ];
834
+ UNIT_LOCATION: [data: CADUnitLocationStruct[]];
835
+ // CMS - General
836
+ GET_COM_ACCOUNT: [
837
+ apiId?: string,
838
+ username?: string,
839
+ accId?: string,
840
+ discord?: string,
841
+ ];
842
+ GET_SUB_VERSION: [];
843
+ CHECK_COM_APIID: [apiId: string];
844
+ CLOCK_IN_OUT: [
845
+ apiId?: string,
846
+ accId?: string,
847
+ forceClockIn?: boolean
848
+ ];
849
+ GET_DEPARTMENTS: [];
850
+ GET_ACCOUNT_RANKS: [
851
+ apiId?: string,
852
+ username?: string,
853
+ accId?: string,
854
+ discord?: string,
855
+ ],
856
+ SET_ACCOUNT_RANKS: [
857
+ accountId: string,
858
+ set?: {
859
+ primary?: string | null,
860
+ secondary?: string[]
861
+ },
862
+ add?: string[],
863
+ remove?: string[],
864
+ ],
865
+ // CMS - Servers
866
+ GET_GAME_SERVERS: [];
867
+ VERIFY_WHITELIST: [
868
+ apiId: string | undefined,
869
+ accId: string | undefined,
870
+ serverId: number
871
+ ];
872
+ FULL_WHITELIST: [
873
+ serverId?: number,
874
+ ]
875
+ RSVP : [
876
+ eventId: string,
877
+ apiId: string | undefined,
878
+ accId: string | undefined,
879
+ ]
880
+ // CMS - Forms
881
+ CHANGE_FORM_STAGE: [
882
+ accId: string,
883
+ formId: number,
884
+ newStageId: string
885
+ ]
886
+ }
887
+
888
+ export type PossibleRequestData =
889
+ undefined |
890
+ {
891
+ data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
892
+ } |
893
+ {
894
+ servers: CADServerAPIStruct[];
895
+ deployMap: boolean;
896
+ } |
897
+ {
898
+ id: number;
899
+ } |
900
+ {
901
+ recordTypeId?: number;
902
+ } |
903
+ {
904
+ apiId?: string;
905
+ username?: string;
906
+ } |
907
+ {
908
+ apiId: string
909
+ } |
910
+ {
911
+ apiId: string;
912
+ permissionKey: string;
913
+ } |
914
+ {
915
+ secret: string;
916
+ } |
917
+ {
918
+ serverId: number;
919
+ } |
920
+ {
921
+ serverId?: number;
922
+ } |
923
+ {
924
+ apiId: string;
925
+ url: string;
926
+ } |
927
+ {
928
+ apiId: string;
929
+ identId: number;
930
+ } |
931
+ {
932
+ apiId: string;
933
+ isPanic: boolean;
934
+ } |
935
+ {
936
+ apiId: string;
937
+ status: number;
938
+ serverId: number;
939
+ } |
940
+ {
941
+ callId: number;
942
+ } |
943
+ {
944
+ serverId: number;
945
+ callId: number;
946
+ units: string[];
947
+ } |
948
+ {
949
+ serverId: number;
950
+ units: string[];
951
+ } |
952
+ {
953
+ serverId: number;
954
+ callId: number;
955
+ postal: string;
956
+ } |
957
+ {
958
+ serverId: number;
959
+ callId: number;
960
+ primary: number;
961
+ trackPrimary: boolean;
962
+ } |
963
+ {
964
+ serverId: number;
965
+ callId: number;
966
+ note: string;
967
+ } |
968
+ {
969
+ serverId: number;
970
+ callId: number;
971
+ } |
972
+ {
973
+ serverId: number;
974
+ isEmergency: boolean;
975
+ caller: string;
976
+ location: string;
977
+ description: string;
978
+ metaData: Record<string, string>;
979
+ } |
980
+ {
981
+ serverId: number;
982
+ signConfig: CADStreetSignStruct[];
983
+ } |
984
+ {
985
+ serverId: number;
986
+ signData: {
987
+ ids: number[];
988
+ text1: string;
989
+ text2: string;
990
+ text3: string;
991
+ }
992
+ } |
993
+ {
994
+ apiId?: string;
995
+ username?: string;
996
+ } |
997
+ {
998
+ apiId: string;
999
+ serverId: number;
1000
+ } |
1001
+ {
1002
+ apiId: string;
1003
+ forceClockIn: boolean;
1004
+ } |
1005
+ {
1006
+ accountId: string,
1007
+ set?: {
1008
+ primary: string[],
1009
+ secondary: string[]
1010
+ },
1011
+ add?: string[],
1012
+ remove?: string[],
986
1013
  };