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