tabletcommand-backend-models 5.27.0 → 5.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/build/index.js +1 -0
  2. package/build/index.js.map +1 -1
  3. package/build/models/battalion.js +1 -1
  4. package/build/models/battalion.js.map +1 -1
  5. package/build/models/cad-incident-flat.js +14 -0
  6. package/build/models/cad-incident-flat.js.map +1 -0
  7. package/build/models/cad-incident.js +5 -459
  8. package/build/models/cad-incident.js.map +1 -1
  9. package/build/models/monitor.js +6 -1
  10. package/build/models/monitor.js.map +1 -1
  11. package/build/models/schema/cad-incident.js +463 -0
  12. package/build/models/schema/cad-incident.js.map +1 -0
  13. package/build/models/template.js +1 -1
  14. package/build/models/template.js.map +1 -1
  15. package/definitions/index.d.ts +2 -0
  16. package/definitions/index.d.ts.map +1 -1
  17. package/definitions/models/cad-incident-flat.d.ts +314 -0
  18. package/definitions/models/cad-incident-flat.d.ts.map +1 -0
  19. package/definitions/models/cad-incident.d.ts +2 -502
  20. package/definitions/models/cad-incident.d.ts.map +1 -1
  21. package/definitions/models/monitor.d.ts +1 -0
  22. package/definitions/models/monitor.d.ts.map +1 -1
  23. package/definitions/models/schema/cad-incident.d.ts +503 -0
  24. package/definitions/models/schema/cad-incident.d.ts.map +1 -0
  25. package/package.json +11 -11
  26. package/src/index.ts +2 -0
  27. package/src/models/battalion.ts +1 -1
  28. package/src/models/cad-incident-flat.ts +20 -0
  29. package/src/models/cad-incident.ts +3 -495
  30. package/src/models/monitor.ts +7 -1
  31. package/src/models/schema/cad-incident.ts +500 -0
  32. package/src/models/template.ts +1 -1
  33. package/test/0index.js +1 -0
  34. package/test/mock.js +2 -1
@@ -1,509 +1,17 @@
1
1
  import {
2
2
  createModel,
3
- createSchema,
4
- currentDate,
5
- DocumentTypeFromSchema,
6
- FieldsOfDocument,
7
3
  ItemTypeFromTypeSchemaFunction,
8
- ModelFromSchema,
9
4
  ModelTypeFromTypeSchemaFunction,
10
- MongooseDocument,
11
5
  MongooseModule,
12
6
  ReplaceModelReturnType,
13
7
  } from "../helpers";
14
8
 
15
- import * as uuid from "uuid";
16
- import * as mongooseLeanVirtuals from "mongoose-lean-virtuals";
17
- import { IncidentEventSchema } from "./incident-event";
18
-
19
- export function CADIncidentSchema(mongoose: MongooseModule) {
20
- const { Schema, Types } = mongoose;
21
- const IncidentEvent = IncidentEventSchema(mongoose);
22
-
23
- const toJSONOpts = {
24
- versionKey: false,
25
- transform(doc: DocumentTypeFromSchema<typeof modelSchema>, ret: FieldsOfDocument<DocumentTypeFromSchema<typeof modelSchema>>) {
26
- strictSchema(doc.schema, ret);
27
- },
28
- };
29
-
30
- const CADComment = createSchema(Schema, {
31
- Comment: {
32
- type: String,
33
- },
34
- CommentSource: {
35
- type: String,
36
- },
37
- CommentDateTime: {
38
- type: String,
39
- },
40
- CommentConfidential: {
41
- type: Boolean,
42
- default: false
43
- }
44
- }, {
45
- _id: false,
46
- id: false,
47
- });
48
- CADComment.set("toJSON", toJSONOpts);
49
-
50
- const CADPerson = createSchema(Schema, {
51
- PersonnelID: {
52
- type: String,
53
- },
54
- PersonnelName: {
55
- type: String,
56
- },
57
- PersonnelRank: {
58
- type: String,
59
- },
60
- PersonnelWorkCode: {
61
- type: String,
62
- },
63
- PersonnelNote: {
64
- type: String,
65
- },
66
- }, {
67
- _id: false,
68
- id: false,
69
- });
70
- CADPerson.set("toJSON", toJSONOpts);
71
-
72
- const CADUnit = createSchema(Schema, {
73
- UnitID: {
74
- type: String,
75
- required: true,
76
- },
77
- UnitDispatchNumber: {
78
- type: String,
79
- required: true,
80
- },
81
- AlarmAtDispatch: {
82
- type: String,
83
- },
84
- TimeDispatched: {
85
- type: String,
86
- },
87
- TimeEnroute: {
88
- type: String,
89
- },
90
- TimeArrived: {
91
- type: String,
92
- },
93
- TimeStaged: {
94
- type: String,
95
- },
96
- TimeCleared: {
97
- type: String,
98
- },
99
- TimeAtHospital: {
100
- type: String,
101
- },
102
- TimePatient: {
103
- type: String,
104
- },
105
- TimeTransport: {
106
- type: String,
107
- },
108
- TimeTransporting: {
109
- type: String,
110
- },
111
-
112
- PersonnelCount: {
113
- type: Number,
114
- },
115
- Personnel: [CADPerson],
116
- }, {
117
- _id: false,
118
- id: false,
119
- });
120
- CADUnit.set("toJSON", toJSONOpts);
121
-
122
- const APNNotificationType = createSchema(Schema, {
123
- name: {
124
- type: String,
125
- },
126
- value: {
127
- type: String,
128
- },
129
- }, {
130
- _id: false,
131
- id: false,
132
- });
133
- APNNotificationType.set("toJSON", toJSONOpts);
134
-
135
- const CADPriorIncident = createSchema(Schema, {
136
- Address: {
137
- type: String,
138
- },
139
- Comment: {
140
- type: [CADComment],
141
- },
142
- IncidentDateTime: {
143
- type: String,
144
- },
145
- IncidentNumber: {
146
- type: String,
147
- },
148
- Jurisdiction: {
149
- type: String,
150
- },
151
- Problem: {
152
- type: String,
153
- },
154
- Suite: {
155
- type: String,
156
- },
157
- }, {
158
- _id: false,
159
- id: false,
160
- });
161
- CADPriorIncident.set("toJSON", toJSONOpts);
162
-
163
- const ReportNumber = createSchema(Schema, {
164
- name: {
165
- type: String,
166
- default: "",
167
- },
168
- number: {
169
- type: String,
170
- default: "",
171
- },
172
- }, {
173
- _id: false,
174
- id: false,
175
- });
176
- ReportNumber.set("toJSON", toJSONOpts);
177
-
178
- const modelSchema = createSchema(Schema, {
179
- _id: {
180
- type: Types.ObjectId,
181
- auto: true,
182
- },
183
- uuid: {
184
- type: String,
185
- default: uuid.v4,
186
- },
187
- departmentId: {
188
- type: String,
189
- default: "",
190
- required: true,
191
- index: true,
192
- },
193
- AgencyID: {
194
- type: String,
195
- default: "",
196
- },
197
- IncidentNumber: {
198
- type: String,
199
- required: true,
200
- },
201
- TransactionID: {
202
- type: String,
203
- default: "",
204
- },
205
-
206
- // Incident Specific
207
- AgencyIncidentCallTypeDescription: {
208
- type: String,
209
- },
210
- AgencyIncidentCallType: {
211
- type: String,
212
- },
213
- AgencyIncidentCallSubTypeDescription: {
214
- type: String,
215
- },
216
- AgencyIncidentCallSubType: {
217
- type: String,
218
- },
219
- AgencyIncidentPriorityDescription: {
220
- type: String,
221
- },
222
- PulsePointIncidentCallType: {
223
- type: String,
224
- },
225
- PulsePointDeterminantCode: {
226
- type: String,
227
- },
228
- AlarmLevel: {
229
- type: String,
230
- },
231
- CommandName: {
232
- type: String,
233
- },
234
- FireMap: {
235
- type: String,
236
- },
237
- TBMap: {
238
- type: String,
239
- },
240
- MapPages: {
241
- type: String,
242
- },
243
- TacticalChannel: {
244
- type: String,
245
- },
246
- TacticalAltChannel: {
247
- type: String,
248
- },
249
- CommandChannel: {
250
- type: String,
251
- },
252
-
253
- // Dates
254
- EntryDateTime: {
255
- type: String,
256
- },
257
- ClosedDateTime: {
258
- type: String,
259
- },
260
- CallReceivedDateTime: {
261
- type: String,
262
- },
263
- DispatchDateTime: {
264
- type: String,
265
- },
266
- IncidentLastUpdate: {
267
- type: String,
268
- },
269
- EnrouteDateTime: {
270
- type: String,
271
- },
272
- OnSceneDateTime: {
273
- type: String,
274
- },
275
-
276
- modified_date: {
277
- type: String,
278
- },
279
- modified_unix_date: {
280
- type: Number,
281
- },
282
- modified: {
283
- type: Date,
284
- default: currentDate,
285
- },
286
- start_unix_date: {
287
- type: Number,
288
- },
289
- closed_unix_date: {
290
- type: Number,
291
- },
292
- queued_at: {
293
- type: Number,
294
- },
295
- scheduled_at: {
296
- type: Number,
297
- },
298
- ignored: {
299
- type: Boolean,
300
- default: false,
301
- },
302
- expiration_date: {
303
- type: Date,
304
- default: null,
305
- },
306
-
307
- // Address fields
308
- StreetName: {
309
- type: String,
310
- },
311
- StreetSuffix: {
312
- type: String,
313
- },
314
- Predirectional: {
315
- type: String,
316
- },
317
- Postdirectional: {
318
- type: String,
319
- },
320
- CityOrLocality: {
321
- type: String,
322
- },
323
- StateOrProvince: {
324
- type: String,
325
- },
326
- // Legacy
327
- StateOfProvince: {
328
- type: String,
329
- },
330
- CommonPlaceName: {
331
- type: String,
332
- },
333
- CrossStreet1: {
334
- type: String,
335
- },
336
- CrossStreet2: {
337
- type: String,
338
- },
339
- StreetNumber: {
340
- type: String,
341
- },
342
- Building: {
343
- type: String,
344
- },
345
- Floor: {
346
- type: String,
347
- },
348
- Suite: {
349
- type: String,
350
- },
351
- City: {
352
- type: String,
353
- },
354
- County: {
355
- type: String,
356
- },
357
- PostalCode: {
358
- type: String,
359
- },
360
- CrossStreetName: {
361
- type: String,
362
- },
363
- LocationComment: {
364
- type: String,
365
- },
366
- // TC Address
367
- full_address: {
368
- type: String,
369
- },
370
- address: {
371
- type: String,
372
- },
373
- cross_streets: {
374
- type: String,
375
- },
376
-
377
- // Prior History
378
- PriorIncidentChanged: {
379
- type: Boolean,
380
- },
381
- PriorIncident: {
382
- type: [CADPriorIncident],
383
- default: [],
384
- },
385
-
386
- // Caller
387
- CallerNumber: {
388
- type: String,
389
- default: "",
390
- },
391
-
392
- ReportNumber: {
393
- type: [ReportNumber],
394
- default: [],
395
- },
396
-
397
- tag: {
398
- type: String,
399
- default: "",
400
- },
401
-
402
- // Coordinate
403
- Latitude: {
404
- type: String,
405
- },
406
- Longitude: {
407
- type: String,
408
- },
409
-
410
- Comment: {
411
- type: [CADComment],
412
- default: [],
413
- },
414
-
415
- units: {
416
- type: [CADUnit],
417
- default: [],
418
- },
419
-
420
- events: {
421
- type: [IncidentEvent], // setting types as object, because it does not work with importing IncidentEvent
422
- default: [],
423
- },
424
-
425
- // Tablet Command Internal fields
426
- preference_location: {
427
- type: String,
428
- },
429
-
430
- // Training
431
- simulation: {
432
- type: Boolean,
433
- default: false,
434
- },
435
- notify: {
436
- type: Boolean,
437
- default: true,
438
- },
439
- rts: {
440
- type: Boolean,
441
- default: true,
442
- },
443
-
444
- // Leaked
445
- CADSimulator: {
446
- type: String,
447
- },
448
-
449
- notificationType: {
450
- type: [APNNotificationType],
451
- default: [],
452
- },
453
- notifiedUnits: {
454
- type: [String],
455
- default: [],
456
- },
457
- }, {
458
- collection: "massive_incident_cad",
459
- strict: false, // Because we accept all kind of data in
460
- });
461
- modelSchema.set("autoIndex", false);
462
-
463
- modelSchema.set("toJSON", {
464
- virtuals: true,
465
- versionKey: false,
466
- transform(doc: ModelFromSchema<typeof modelSchema>, ret: DocumentTypeFromSchema<typeof modelSchema>) {
467
- // Remove fields that should not be here
468
- delete (ret as unknown as { apikey: unknown }).apikey;
469
-
470
- strictSchema(doc.schema as typeof modelSchema, ret);
471
-
472
- ret.id = ret._id;
473
- },
474
- });
475
-
476
- modelSchema.virtual("id").get(function(this: MongooseDocument) {
477
- // tslint:disable-next-line: no-unsafe-any
478
- return this._id.toString();
479
- });
480
-
481
- const ignoreFields: ReadonlyArray<string> = ["station", "callerNumber"];
482
-
483
- function strictSchema(schema: typeof modelSchema, ret: Record<string, unknown>) {
484
- Object.keys(ret).forEach(function(element) {
485
- // Don't complain about the virtuals
486
- if (element === "id") {
487
- return;
488
- }
489
-
490
- if (ignoreFields.indexOf(element) !== -1) {
491
- delete ret[element];
492
- return;
493
- }
494
- const pathSchema = schema as unknown as { paths: Record<string, string> };
495
- if (pathSchema.paths[element] === undefined) {
496
- // console.log("backend-models.cad-incident: undefined schema.paths[element]:", element, pathSchema.paths[element]);
497
- delete ret[element];
498
- }
499
- });
500
- }
501
- modelSchema.plugin(mongooseLeanVirtuals);
502
- return modelSchema;
503
- }
9
+ import { CADIncidentSchema } from "./schema/cad-incident";
504
10
 
505
11
  export async function CADIncidentModule(mongoose: MongooseModule) {
506
12
  const modelSchema = CADIncidentSchema(mongoose);
13
+ modelSchema.set("collection", "massive_incident_cad");
14
+ modelSchema.set("strict", false); // Because we accept all kind of data in
507
15
  return createModel(mongoose, "CADIncident", modelSchema);
508
16
  }
509
17
 
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  createModel,
3
3
  createSchema,
4
+ currentDate,
4
5
  ItemTypeFromTypeSchemaFunction,
5
6
  ModelTypeFromTypeSchemaFunction,
6
7
  MongooseDocument,
@@ -42,9 +43,14 @@ export async function MonitorModule(mongoose: MongooseModule) {
42
43
  type: Number,
43
44
  default: retrieveCurrentUnixTime,
44
45
  },
46
+ sentAt: {
47
+ type: Date,
48
+ default: currentDate,
49
+ },
45
50
  ticketId: {
46
51
  type: String,
47
- }
52
+ default: "",
53
+ },
48
54
  }, {
49
55
  collection: "massive_monitor",
50
56
  });