@sonoransoftware/sonoran.js 1.0.19 → 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 -455
  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 -234
  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 -997
  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,998 +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
- 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
- function formatForAll(array: APITypeData[], product: productEnums): AllAPITypeData[] {
431
- return array.map((val) => {
432
- return {
433
- ...val,
434
- product
435
- }
436
- });
437
- }
438
-
439
- 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) ];
440
-
441
- 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';
442
-
443
- export interface CMSServerAPIStruct {
444
- id: number;
445
- name: string;
446
- description: string;
447
- }
448
-
449
- export interface CADServerAPIStruct {
450
- id: number;
451
- name: string;
452
- description: string;
453
- signal: string;
454
- mapUrl: string;
455
- mapIp: string;
456
- listenerPort: number;
457
- differingOutbound: boolean;
458
- outboundIp: string;
459
- enableMap: boolean;
460
- isStatic: boolean;
461
- mapType: string;
462
- }
463
-
464
- export interface CADPenalCodeStruct {
465
- code: string;
466
- type: string;
467
- title: string;
468
- bondType: string;
469
- jailTime: string;
470
- bondAmount: number;
471
- }
472
-
473
- export interface CADSetAPIIDStruct {
474
- username: string;
475
- sessionId?: string;
476
- apiIds: string[];
477
- pushNew: boolean;
478
- }
479
-
480
- export enum CADRecordTypeEnums {
481
- Warrant = 2,
482
- Bolo = 3,
483
- License = 4,
484
- VehicleRegistration = 5,
485
- Character = 7,
486
- PoliceRecord = 8,
487
- PoliceReport = 9,
488
- MedicalRecord = 10,
489
- MedicalReport = 11,
490
- FireRecord = 12,
491
- FireReport = 13,
492
- DMVRecord = 14,
493
- LawRecord = 15,
494
- LawReport = 16
495
- }
496
-
497
- export enum CADRecordSectionCategoryEnums {
498
- Custom,
499
- Flags,
500
- Speed = 5,
501
- Charges = 6,
502
- LinkedRecords = 9
503
- }
504
-
505
- export interface CADRecordDependencyStruct {
506
- type: string;
507
- fid: string;
508
- acceptableValues: string[];
509
- }
510
-
511
- export interface CADRecordSectionFieldStruct {
512
- 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';
513
- value: string;
514
- size: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
515
- data: Record<string | number | symbol, unknown>;
516
- options: string[];
517
- isPreviewed: boolean;
518
- isSupervisor: boolean;
519
- isRequired: boolean;
520
- unique: boolean;
521
- readOnly: boolean;
522
- mask: string;
523
- maskReverse: boolean;
524
- dbMap: boolean;
525
- isFromSync: boolean;
526
- uid: string;
527
- dependency: CADRecordDependencyStruct;
528
- }
529
-
530
- export interface CADRecordSectionStruct {
531
- category: CADRecordSectionCategoryEnums;
532
- label: string;
533
- fields: CADRecordSectionFieldStruct[];
534
- searchCiv: boolean;
535
- searchVeh: boolean;
536
- enableDuplicate: boolean;
537
- dependency: CADRecordDependencyStruct;
538
- }
539
-
540
- export interface CADRecordStruct {
541
- recordTypeId: number;
542
- id: number;
543
- syncId: string;
544
- name: string;
545
- type: CADRecordTypeEnums;
546
- sections: CADRecordSectionStruct[];
547
- }
548
-
549
- export interface CADNewEditRecordOptionOneStruct {
550
- user: string;
551
- useDictionary: boolean;
552
- recordTypeId: number;
553
- replaceValues: Record<string, string>;
554
- }
555
-
556
- export interface CADNewEditRecordOptionTwoStruct {
557
- user: string;
558
- record: CADRecordStruct;
559
- }
560
-
561
- export enum CADLookupByIntSearchTypeEnums {
562
- IDENTIFIER,
563
- SUPERVISOR_STATUS,
564
- ACTIVE_STATUS,
565
- NUMBER
566
- }
567
-
568
- export interface CADLookupByIntStruct {
569
- apiId?: string;
570
- searchType: CADLookupByIntSearchTypeEnums;
571
- value: number;
572
- types: number[],
573
- limit?: number;
574
- offset?: number;
575
- }
576
-
577
- export interface CADLookupStruct {
578
- apiId?: string;
579
- types: number[];
580
- first: string;
581
- last: string;
582
- mi: string;
583
- plate: string;
584
- partial: boolean;
585
- agency?: string;
586
- department?: string;
587
- subdivision?: string;
588
- }
589
-
590
- export interface CADModifyAccountPermsStruct {
591
- apiId?: string;
592
- username?: string;
593
- active?: boolean;
594
- add: string[];
595
- remove: string[];
596
- }
597
-
598
- export interface CADKickBanUserStruct {
599
- apiId: string;
600
- isBan?: boolean;
601
- isKick?: boolean;
602
- }
603
-
604
- export interface CADSetPostalStruct {
605
- code: string;
606
- x: number;
607
- y: number;
608
- }
609
-
610
- export enum CADModifyIdentifierActionEnums {
611
- ADD,
612
- EDIT,
613
- REMOVE
614
- }
615
-
616
- export interface CADModifyIdentifierStruct {
617
- apiId: string;
618
- action: CADModifyIdentifierActionEnums;
619
- identifier?: Record<string, string>;
620
- identId?: number;
621
- }
622
-
623
- export interface CADBlipStruct {
624
- id: number;
625
- coordinates: {
626
- x: number;
627
- y: number;
628
- };
629
- icon: string;
630
- color: string;
631
- tooltip: string;
632
- }
633
-
634
- export interface CADAddBlipStruct {
635
- serverId: number;
636
- blip: CADBlipStruct;
637
- }
638
-
639
- export interface CADModifyBlipStruct {
640
- id: number;
641
- coordinates?: {
642
- x: number;
643
- y: number;
644
- };
645
- icon?: string;
646
- color?: string;
647
- tooltip?: string;
648
- }
649
-
650
- export interface CADGetCallsStruct {
651
- serverId?: number;
652
- closedLimit?: number;
653
- closedOffset?: number;
654
- }
655
-
656
- export interface CADGetActiveUnitsStruct {
657
- serverId?: number;
658
- onlyUnits?: boolean;
659
- includeOffline?: boolean;
660
- limit?: number;
661
- offset?: number;
662
- }
663
-
664
- export enum CADDispatchOriginEnums {
665
- Caller,
666
- RadioDispatch,
667
- Observed,
668
- WalkUp
669
- }
670
-
671
- export enum CADDispatchStatusEnums {
672
- Pending,
673
- Active,
674
- Closed
675
- }
676
-
677
- export interface CADNewDispatchStruct {
678
- serverId: number;
679
- origin: CADDispatchOriginEnums;
680
- status: CADDispatchStatusEnums;
681
- priority: 1 | 2 | 3;
682
- block: string;
683
- address: string;
684
- postal: string;
685
- title: string;
686
- code: string;
687
- primary: number;
688
- trackPrimary: boolean;
689
- description: string;
690
- metaData: Record<string, string>;
691
- units: string[];
692
- }
693
-
694
- export interface CADStreetSignStruct {
695
- id: number;
696
- label: string;
697
- text1: string;
698
- text2: string;
699
- text3: string;
700
- }
701
-
702
- export interface CADUnitLocationStruct {
703
- apiId: string;
704
- location: string;
705
- }
706
-
707
- export interface RESTTypedAPIDataStructs {
708
- // CAD - General
709
- GET_SERVERS: [];
710
- SET_SERVERS: [
711
- servers: CADServerAPIStruct[],
712
- deployMap: boolean
713
- ];
714
- GET_VERSION: [];
715
- SET_PENAL_CODES: [data: CADPenalCodeStruct[]];
716
- SET_API_ID: [data: CADSetAPIIDStruct];
717
- GET_TEMPLATES: [recordTypeId?: number];
718
- NEW_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
719
- EDIT_RECORD: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
720
- REMOVE_RECORD: [id: number];
721
- LOOKUP_INT: [data: CADLookupByIntStruct];
722
- LOOKUP: [data: CADLookupStruct];
723
- GET_ACCOUNT: [
724
- apiId?: string,
725
- username?: string
726
- ];
727
- CHECK_APIID: [apiId: string];
728
- APPLY_PERMISSION_KEY: [
729
- apiId: string,
730
- permissionKey: string
731
- ];
732
- SET_ACCOUNT_PERMISSIONS: [data: CADModifyAccountPermsStruct];
733
- BAN_USER: [data: CADKickBanUserStruct];
734
- VERIFY_SECRET: [secret: string];
735
- AUTH_STREETSIGNS: [serverId: number];
736
- SET_POSTALS: [data: CADSetPostalStruct[]];
737
- SEND_PHOTO: [
738
- apiId: string,
739
- url: string
740
- ];
741
- // CAD - Civilian
742
- GET_CHARACTERS: [apiId: string];
743
- NEW_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
744
- EDIT_CHARACTER: [data: CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct];
745
- REMOVE_CHARACTER: [id: number];
746
- // CAD - Emergency
747
- GET_IDENTIFIERS: [apiId: string];
748
- MODIFY_IDENTIFIER: [data: CADModifyIdentifierStruct];
749
- SET_IDENTIFIER: [
750
- apiId: string,
751
- identId: number
752
- ];
753
- UNIT_PANIC: [
754
- apiId: string,
755
- isPanic: boolean
756
- ];
757
- UNIT_STATUS: [
758
- apiId: string,
759
- status: number,
760
- serverId: number
761
- ];
762
- GET_BLIPS: [serverId: number];
763
- ADD_BLIP: [data: CADAddBlipStruct[]];
764
- MODIFY_BLIP: [data: CADModifyBlipStruct[]];
765
- REMOVE_BLIP: [id: number];
766
- REMOVE_911: [callId: number];
767
- GET_CALLS: [data: CADGetCallsStruct];
768
- GET_ACTIVE_UNITS: [data: CADGetActiveUnitsStruct];
769
- KICK_UNIT: [
770
- apiId: string,
771
- reason: string,
772
- serverId: number
773
- ];
774
- NEW_DISPATCH: [data: CADNewDispatchStruct];
775
- ATTACH_UNIT: [
776
- serverId: number,
777
- callId: number,
778
- units: string[]
779
- ];
780
- DETACH_UNIT: [
781
- serverId: number,
782
- units: string[]
783
- ];
784
- SET_CALL_POSTAL: [
785
- serverId: number,
786
- callId: number,
787
- postal: string
788
- ];
789
- SET_CALL_PRIMARY: [
790
- serverId: number,
791
- callId: number,
792
- primary: number,
793
- trackPrimary: boolean
794
- ];
795
- ADD_CALL_NOTE: [
796
- serverId: number,
797
- callId: number,
798
- note: string
799
- ];
800
- CLOSE_CALL: [
801
- serverId: number,
802
- callId: number
803
- ];
804
- 'CALL_911': [
805
- serverId: number,
806
- isEmergency: boolean,
807
- caller: string,
808
- location: string,
809
- description: string,
810
- metaData: Record<string, string>
811
- ];
812
- SET_STREETSIGN_CONFIG: [
813
- serverId: number,
814
- signConfig: CADStreetSignStruct[]
815
- ];
816
- UPDATE_STREETSIGN: [
817
- serverId: number,
818
- signData: {
819
- ids: number[],
820
- text1: string,
821
- text2: string,
822
- text3: string
823
- }
824
- ];
825
- UNIT_LOCATION: [data: CADUnitLocationStruct[]];
826
- // CMS - General
827
- GET_COM_ACCOUNT: [
828
- apiId?: string,
829
- username?: string,
830
- accId?: string,
831
- discord?: string,
832
- ];
833
- GET_SUB_VERSION: [];
834
- CHECK_COM_APIID: [apiId: string];
835
- CLOCK_IN_OUT: [
836
- apiId?: string,
837
- accId?: string,
838
- forceClockIn?: boolean
839
- ];
840
- GET_DEPARTMENTS: [];
841
- GET_ACCOUNT_RANKS: [
842
- apiId?: string,
843
- username?: string,
844
- accId?: string,
845
- discord?: string,
846
- ],
847
- SET_ACCOUNT_RANKS: [
848
- accountId: string,
849
- set?: {
850
- primary?: string | null,
851
- secondary?: string[]
852
- },
853
- add?: string[],
854
- remove?: string[],
855
- ],
856
- // CMS - Servers
857
- GET_GAME_SERVERS: [];
858
- VERIFY_WHITELIST: [
859
- apiId: string | undefined,
860
- accId: string | undefined,
861
- serverId: number
862
- ];
863
- FULL_WHITELIST: [
864
- serverId?: number,
865
- ]
866
- RSVP : [
867
- eventId: string,
868
- apiId: string | undefined,
869
- accId: string | undefined,
870
- ]
871
- }
872
-
873
- export type PossibleRequestData =
874
- undefined |
875
- {
876
- data: CADPenalCodeStruct[] | CADSetAPIIDStruct | CADNewEditRecordOptionOneStruct | CADNewEditRecordOptionTwoStruct | CADLookupByIntStruct | CADLookupStruct | CADModifyAccountPermsStruct | CADKickBanUserStruct | CADSetPostalStruct[] | CADModifyIdentifierStruct | CADAddBlipStruct[] | CADModifyBlipStruct[] | CADGetCallsStruct | CADGetActiveUnitsStruct | CADNewDispatchStruct
877
- } |
878
- {
879
- servers: CADServerAPIStruct[];
880
- deployMap: boolean;
881
- } |
882
- {
883
- id: number;
884
- } |
885
- {
886
- recordTypeId?: number;
887
- } |
888
- {
889
- apiId?: string;
890
- username?: string;
891
- } |
892
- {
893
- apiId: string
894
- } |
895
- {
896
- apiId: string;
897
- permissionKey: string;
898
- } |
899
- {
900
- secret: string;
901
- } |
902
- {
903
- serverId: number;
904
- } |
905
- {
906
- serverId?: number;
907
- } |
908
- {
909
- apiId: string;
910
- url: string;
911
- } |
912
- {
913
- apiId: string;
914
- identId: number;
915
- } |
916
- {
917
- apiId: string;
918
- isPanic: boolean;
919
- } |
920
- {
921
- apiId: string;
922
- status: number;
923
- serverId: number;
924
- } |
925
- {
926
- callId: number;
927
- } |
928
- {
929
- serverId: number;
930
- callId: number;
931
- units: string[];
932
- } |
933
- {
934
- serverId: number;
935
- units: string[];
936
- } |
937
- {
938
- serverId: number;
939
- callId: number;
940
- postal: string;
941
- } |
942
- {
943
- serverId: number;
944
- callId: number;
945
- primary: number;
946
- trackPrimary: boolean;
947
- } |
948
- {
949
- serverId: number;
950
- callId: number;
951
- note: string;
952
- } |
953
- {
954
- serverId: number;
955
- callId: number;
956
- } |
957
- {
958
- serverId: number;
959
- isEmergency: boolean;
960
- caller: string;
961
- location: string;
962
- description: string;
963
- metaData: Record<string, string>;
964
- } |
965
- {
966
- serverId: number;
967
- signConfig: CADStreetSignStruct[];
968
- } |
969
- {
970
- serverId: number;
971
- signData: {
972
- ids: number[];
973
- text1: string;
974
- text2: string;
975
- text3: string;
976
- }
977
- } |
978
- {
979
- apiId?: string;
980
- username?: string;
981
- } |
982
- {
983
- apiId: string;
984
- serverId: number;
985
- } |
986
- {
987
- apiId: string;
988
- forceClockIn: boolean;
989
- } |
990
- {
991
- accountId: string,
992
- set?: {
993
- primary: string[],
994
- secondary: string[]
995
- },
996
- add?: string[],
997
- 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[],
998
1013
  };