@sedni/cloud_common 2.1.0 → 3.0.1

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/dist/index.js CHANGED
@@ -1,54 +1,1278 @@
1
1
  import {
2
+ ActivationModes,
3
+ AddedAlarmsJson,
4
+ AlarmIndicatorJson,
5
+ AlarmIndicatorRequest,
6
+ AlarmIndicatorResponse,
2
7
  AlarmPriorities,
8
+ AlarmStates,
3
9
  AlarmTypes,
10
+ AutoSemiAutoStates,
11
+ AutomaticSemiAutoJson,
12
+ AutomaticSemiAutoRequest,
13
+ BackgroundJson,
14
+ BreakerJson,
15
+ BreakerPmsJson,
16
+ BreakerPmsRequest,
17
+ BreakerPmsResponse,
18
+ BreakerRequest,
19
+ BreakerResponse,
20
+ CabinetDesigns,
21
+ CabinetJson,
22
+ CabinetRequest,
23
+ CabinetResponse,
24
+ ChannelBaseTypes,
25
+ ChannelJson,
26
+ ChannelRequest,
27
+ ChannelSpecificTypes,
4
28
  CloudAlarmStates,
29
+ CommandJson,
30
+ CommandRequest,
31
+ CommandResponse,
32
+ CommandsOpClJson,
33
+ CommandsOpClRequest,
34
+ CommandsStartStopJson,
35
+ CommandsStartStopRequest,
36
+ CompressorDesigns,
37
+ CompressorJson,
38
+ CompressorRequest,
39
+ CompressorResponse,
40
+ ControlLockJson,
41
+ ControlLockRequest,
42
+ DamperAutomatedJson,
43
+ DamperAutomatedRequest,
44
+ DamperAutomatedResponse,
45
+ DamperJson,
46
+ DamperRequest,
47
+ DamperResponse,
48
+ DialJson,
49
+ DialRequest,
50
+ DialResponse,
5
51
  DiamarAlarmStates,
52
+ DigitalAlarmStates,
53
+ DigitalJson,
54
+ DigitalRequest,
55
+ DigitalResponse,
56
+ DigitalStates,
57
+ DisplayJson,
58
+ DisplayRequest,
59
+ DisplayResponse,
60
+ DynamicTextJson,
61
+ DynamicTextRequest,
62
+ DynamicTextResponse,
6
63
  EventCategories,
7
64
  EventCriticalities,
65
+ FanDesigns,
66
+ FanDirections,
67
+ FanJson,
68
+ FanRequest,
69
+ FanResponse,
70
+ FanRunStates,
71
+ FanTypes,
72
+ FeedbackOpClJson,
73
+ FeedbackOpClRequest,
74
+ FeedbackRunningStoppedJson,
75
+ FeedbackRunningStoppedRequest,
76
+ GeneratorJson,
77
+ GeneratorPmsJson,
78
+ GeneratorPmsRequest,
79
+ GeneratorPmsResponse,
80
+ GeneratorRequest,
81
+ GeneratorResponse,
82
+ ImageAuxiliaryJson,
83
+ ImageAuxiliaryRequest,
84
+ ImageAuxiliaryResponse,
85
+ InfoLocations,
86
+ LedTypes,
87
+ LevelBarJson,
88
+ LevelBarOrientations,
89
+ LevelBarRequest,
90
+ LevelBarResponse,
91
+ LineAuxiliaryJson,
92
+ LineAuxiliaryRequest,
93
+ LineAuxiliaryResponse,
94
+ LineJson,
95
+ LinkAuxiliaryJson,
96
+ LinkAuxiliaryRequest,
97
+ LinkAuxiliaryResponse,
98
+ LinkDesigns,
99
+ LocalizedTextJson,
100
+ LocationJson,
101
+ LogicExpressionJson,
102
+ LogicExpressionsJson,
103
+ MarkTypes,
104
+ MimicAlarmStates,
105
+ MimicControlStates,
106
+ MimicElementTypes,
107
+ OpClStates,
108
+ OperationModeStates,
109
+ OperationModesJson,
110
+ OperationModesRequest,
111
+ OperationModesResponse,
112
+ OrderOpClJson,
113
+ OrderOpClRequest,
114
+ OrderStartStopJson,
115
+ OrderStartStopRequest,
116
+ PolylineAuxiliaryJson,
117
+ PolylineAuxiliaryRequest,
118
+ PolylineAuxiliaryResponse,
119
+ PrioritiesJson,
120
+ PrioritiesRequest,
121
+ PrioritiesResponse,
122
+ PriorityDataJson,
123
+ PriorityDataRequest,
124
+ PumpAutomatedJson,
125
+ PumpAutomatedRequest,
126
+ PumpAutomatedResponse,
127
+ PumpJson,
128
+ PumpRequest,
129
+ PumpResponse,
130
+ RemoteLocalJson,
131
+ RemoteLocalRequest,
132
+ RemoteLocalStates,
133
+ RepeaterDesigns,
134
+ RepeaterJson,
135
+ RepeaterRequest,
136
+ RepeaterResponse,
137
+ RunningStoppedStates,
138
+ ScaleJson,
139
+ ScalePositions,
140
+ ShaftJson,
141
+ ShaftRequest,
142
+ ShaftResponse,
143
+ SliderJson,
144
+ SliderOrientations,
145
+ SliderRequest,
146
+ SliderResponse,
147
+ SquareAuxiliaryJson,
148
+ SquareAuxiliaryRequest,
149
+ SquareAuxiliaryResponse,
150
+ StationDesigns,
151
+ StationJson,
152
+ StationRequest,
153
+ StationResponse,
154
+ TankJson,
155
+ TankRequest,
156
+ TankResponse,
157
+ TextAnchorPoints,
158
+ TextAttributesJson,
159
+ TextAuxiliaryJson,
160
+ TextAuxiliaryRequest,
161
+ TextAuxiliaryResponse,
162
+ TextChannelJson,
163
+ TextChannelRequest,
164
+ TextChannelResponse,
165
+ TitleAligns,
166
+ TitleJson,
167
+ ToggleJson,
168
+ ToggleRequest,
169
+ ToggleResponse,
170
+ TripResetJson,
171
+ TripResetRequest,
172
+ UnitDesigns,
173
+ UnitJson,
174
+ UnitRequest,
175
+ UnitResponse,
8
176
  UnitTypes,
9
- init_alarm_types,
10
- init_event_types,
11
- init_unit_types
12
- } from "./chunk-AOC7BD5E.js";
177
+ ValueTypes,
178
+ ValveAutomatedJson,
179
+ ValveAutomatedRequest,
180
+ ValveAutomatedResponse,
181
+ ValveDesigns,
182
+ ValveJson,
183
+ ValveRequest,
184
+ ValveResponse,
185
+ ZDepths
186
+ } from "./chunk-K5VO2MYI.js";
13
187
 
14
- // app/index.ts
15
- init_alarm_types();
188
+ // app/models/Channel.ts
189
+ import mongoose from "mongoose";
190
+ import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
191
+ import mongooseAutopopulate from "mongoose-autopopulate";
192
+ import mongoosePaginate from "mongoose-paginate-v2";
193
+ var channelSchema = new mongoose.Schema({
194
+ channel_tag: {
195
+ type: String,
196
+ required: true
197
+ },
198
+ channel_description: {
199
+ type: String,
200
+ required: true
201
+ },
202
+ channel_unit_id: {
203
+ type: mongoose.Schema.Types.ObjectId,
204
+ ref: "Unit",
205
+ required: true,
206
+ autopopulate: true
207
+ },
208
+ channel_parsed: {
209
+ type: Object,
210
+ required: true
211
+ },
212
+ channel_last_bucket_sync: {
213
+ type: Date,
214
+ required: false
215
+ }
216
+ }, {
217
+ timestamps: {
218
+ createdAt: true,
219
+ updatedAt: true
220
+ },
221
+ collection: "channels",
222
+ toJSON: {
223
+ transform: function(_doc, ret) {
224
+ ret.id = ret._id;
225
+ ret.channel_unit = ret.channel_unit_id;
226
+ ret.channel_unit_id = ret.channel_unit_id.unit_id;
227
+ delete ret._id;
228
+ delete ret.__v;
229
+ }
230
+ }
231
+ });
232
+ channelSchema.index({ channel_tag: 1 }, { unique: true });
233
+ channelSchema.index({ channel_description: 1 });
234
+ channelSchema.plugin(mongoosePaginate);
235
+ channelSchema.plugin(mongooseAggregatePaginate);
236
+ channelSchema.plugin(mongooseAutopopulate);
237
+ var Channel_default = channelSchema;
238
+
239
+ // app/models/ChannelDataBucket.ts
240
+ import mongoose2 from "mongoose";
241
+ import mongoosePaginate2 from "mongoose-paginate-v2";
242
+ import mongooseAggregatePaginate2 from "mongoose-aggregate-paginate-v2";
243
+ var dataPointSchema = new mongoose2.Schema({
244
+ channel_id: {
245
+ type: String,
246
+ required: true,
247
+ index: true
248
+ },
249
+ timestamp: {
250
+ type: Number,
251
+ required: true
252
+ },
253
+ value: {
254
+ type: Number,
255
+ required: true
256
+ }
257
+ }, {
258
+ _id: false
259
+ });
260
+ var channeldataBucketSchema = new mongoose2.Schema({
261
+ start_date: {
262
+ type: Date,
263
+ required: true,
264
+ default: Date.now
265
+ },
266
+ end_date: {
267
+ type: Date,
268
+ required: true,
269
+ default: function() {
270
+ return new Date(Date.now() + 1e3 * 60 * 60);
271
+ }
272
+ },
273
+ data: {
274
+ type: [dataPointSchema],
275
+ required: true,
276
+ default: []
277
+ },
278
+ size: {
279
+ type: Number,
280
+ required: true,
281
+ default: 0
282
+ },
283
+ synced: {
284
+ type: Number,
285
+ required: true,
286
+ default: 0
287
+ },
288
+ sum: {
289
+ type: Number,
290
+ required: true,
291
+ default: 0
292
+ }
293
+ }, {
294
+ toJSON: {
295
+ transform: function(doc, ret) {
296
+ ret.id = ret._id;
297
+ delete ret._id;
298
+ delete ret.__v;
299
+ ret.start_date = ret.start_date.getTime();
300
+ ret.end_date = ret.end_date.getTime();
301
+ ret.avg = ret.sum / ret.size;
302
+ }
303
+ },
304
+ versionKey: false
305
+ });
306
+ channeldataBucketSchema.index({ start_date: 1, end_date: 1 }, { background: true });
307
+ channeldataBucketSchema.index({ "start_date": 1, "end_date": 1, "data.channel_id": 1 }, { background: true });
308
+ channeldataBucketSchema.index({ start_date: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 365, background: true });
309
+ channeldataBucketSchema.plugin(mongoosePaginate2);
310
+ channeldataBucketSchema.plugin(mongooseAggregatePaginate2);
311
+ var ChannelDataBucket_default = channeldataBucketSchema;
312
+
313
+ // app/models/ChannelDataPoint.ts
314
+ import mongoose3 from "mongoose";
315
+ import mongoosePaginate3 from "mongoose-paginate-v2";
316
+ import mongooseAggregatePaginate3 from "mongoose-aggregate-paginate-v2";
317
+ var channelDataPointSchema = new mongoose3.Schema({
318
+ c: {
319
+ type: String,
320
+ required: true,
321
+ index: true,
322
+ alias: "channel_id"
323
+ },
324
+ t: {
325
+ type: Date,
326
+ required: true,
327
+ alias: "timestamp"
328
+ },
329
+ v: {
330
+ type: Number,
331
+ required: true,
332
+ alias: "value"
333
+ }
334
+ }, {
335
+ collection: "channel_data_points",
336
+ timestamps: false,
337
+ timeseries: {
338
+ timeField: "t",
339
+ metaField: "c",
340
+ granularity: "seconds"
341
+ },
342
+ toJSON: { getters: true },
343
+ toObject: { getters: true },
344
+ versionKey: false
345
+ });
346
+ channelDataPointSchema.index({ c: 1, t: 1 });
347
+ var oneYear = 60 * 60 * 24 * 365;
348
+ channelDataPointSchema.addTTLIndex = function(expirationTimeInSeconds = oneYear, ttlField = "t", metaField = "c") {
349
+ this.index({
350
+ [ttlField]: 1
351
+ }, {
352
+ expireAfterSeconds: expirationTimeInSeconds,
353
+ partialFilterExpression: {
354
+ [metaField]: {
355
+ $exists: true
356
+ }
357
+ },
358
+ name: "ttl_index_" + ttlField
359
+ });
360
+ };
361
+ channelDataPointSchema.plugin(mongoosePaginate3);
362
+ channelDataPointSchema.plugin(mongooseAggregatePaginate3);
363
+ var ChannelDataPoint_default = channelDataPointSchema;
364
+
365
+ // app/models/Event.ts
366
+ import mongoose4 from "mongoose";
367
+ import mongoosePaginate4 from "mongoose-paginate-v2";
368
+ import mongooseAggregatePaginate4 from "mongoose-aggregate-paginate-v2";
369
+ var eventSchema = new mongoose4.Schema({
370
+ event_message: {
371
+ type: String,
372
+ required: true
373
+ },
374
+ event_source: {
375
+ type: String,
376
+ required: true
377
+ },
378
+ event_user: {
379
+ type: String,
380
+ required: false
381
+ },
382
+ event_category: {
383
+ type: String,
384
+ required: true,
385
+ enum: Object.values(EventCategories)
386
+ },
387
+ event_criticality: {
388
+ type: String,
389
+ required: true,
390
+ enum: Object.values(EventCriticalities)
391
+ },
392
+ event_type: {
393
+ type: String,
394
+ required: true
395
+ },
396
+ event_timestamp: {
397
+ type: Date,
398
+ default: Date.now
399
+ },
400
+ event_data: {
401
+ type: Object
402
+ }
403
+ }, {
404
+ timestamps: {
405
+ createdAt: true,
406
+ updatedAt: false
407
+ },
408
+ versionKey: false,
409
+ toJSON: {
410
+ transform: function(doc, ret) {
411
+ ret.id = ret._id;
412
+ delete ret._id;
413
+ delete ret.createdAt;
414
+ ret.event_timestamp = ret.event_timestamp.getTime();
415
+ }
416
+ }
417
+ });
418
+ eventSchema.index({ event_type: 1 });
419
+ eventSchema.index({ event_category: 1 });
420
+ var oneYear2 = 60 * 60 * 24 * 365;
421
+ eventSchema.addTTLIndex = function(expirationTimeInSeconds = oneYear2, ttlField = "event_timestamp") {
422
+ this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
423
+ };
424
+ eventSchema.plugin(mongoosePaginate4);
425
+ eventSchema.plugin(mongooseAggregatePaginate4);
426
+ var Event_default = eventSchema;
427
+
428
+ // app/models/History.ts
429
+ import mongoose5 from "mongoose";
430
+ import mongoosePaginate5 from "mongoose-paginate-v2";
431
+ import mongooseAggregatePaginate5 from "mongoose-aggregate-paginate-v2";
432
+ var historySchema = new mongoose5.Schema({
433
+ channel_tag: {
434
+ type: String,
435
+ required: true
436
+ },
437
+ alarm_timestamp: {
438
+ type: Date,
439
+ required: true,
440
+ default: Date.now
441
+ },
442
+ alarm_priority: {
443
+ type: String,
444
+ required: true,
445
+ enum: Object.values(AlarmPriorities)
446
+ },
447
+ alarm_original_state: {
448
+ type: String,
449
+ required: true,
450
+ enum: Object.values(DiamarAlarmStates)
451
+ },
452
+ alarm_state: {
453
+ type: String,
454
+ required: true,
455
+ enum: Object.values(CloudAlarmStates)
456
+ },
457
+ alarm_type: {
458
+ type: String,
459
+ required: true,
460
+ enum: Object.values(AlarmTypes)
461
+ },
462
+ alarm_value: {
463
+ type: Number,
464
+ required: false
465
+ },
466
+ alarm_message: {
467
+ type: String,
468
+ required: false
469
+ },
470
+ alarm_data: {
471
+ type: Object,
472
+ required: false
473
+ }
474
+ }, {
475
+ timestamps: {
476
+ createdAt: false,
477
+ updatedAt: false
478
+ },
479
+ versionKey: false,
480
+ collection: "history",
481
+ toJSON: {
482
+ transform: function(doc, ret) {
483
+ ret.id = ret._id;
484
+ delete ret._id;
485
+ delete ret.__v;
486
+ ret.alarm_timestamp = new Date(ret.alarm_timestamp).getTime();
487
+ ret.alarm = {
488
+ alarm_priority: ret.alarm_priority,
489
+ alarm_state: ret.alarm_original_state ?? "Inactive",
490
+ alarm_type: ret.alarm_type,
491
+ alarm_value: ret.alarm_value === null ? "inf" : `${ret.alarm_value}`,
492
+ alarm_timestamp: new Date(ret.alarm_timestamp).getTime()
493
+ };
494
+ }
495
+ }
496
+ });
497
+ historySchema.index({ channel_tag: 1 });
498
+ var oneYear3 = 60 * 60 * 24 * 365;
499
+ historySchema.addTTLIndex = function(expirationTimeInSeconds = oneYear3, ttlField = "alarm_timestamp") {
500
+ this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
501
+ };
502
+ historySchema.plugin(mongoosePaginate5);
503
+ historySchema.plugin(mongooseAggregatePaginate5);
504
+ var History_default = historySchema;
505
+
506
+ // app/models/Unit.ts
507
+ import mongoose6 from "mongoose";
508
+ import mongoosePaginate6 from "mongoose-paginate-v2";
509
+ import mongooseAggregatePaginate6 from "mongoose-aggregate-paginate-v2";
510
+ var unitSchema = new mongoose6.Schema({
511
+ unit_id: {
512
+ type: String,
513
+ required: true
514
+ },
515
+ unit_enabled: {
516
+ type: Boolean,
517
+ required: true
518
+ },
519
+ unit_type: {
520
+ type: String,
521
+ required: true,
522
+ enum: Object.values(UnitTypes)
523
+ },
524
+ unit_internal_description: {
525
+ type: String,
526
+ required: true
527
+ },
528
+ unit_cabinet_id: {
529
+ type: String,
530
+ required: false
531
+ }
532
+ }, {
533
+ timestamps: true,
534
+ collection: "units",
535
+ toJSON: {
536
+ transform: function(doc, ret) {
537
+ ret.id = ret._id;
538
+ delete ret._id;
539
+ delete ret.__v;
540
+ }
541
+ }
542
+ });
543
+ unitSchema.index({ unit_id: 1 }, { unique: true });
544
+ unitSchema.index({ unit_internal_description: 1 });
545
+ unitSchema.plugin(mongoosePaginate6);
546
+ unitSchema.plugin(mongooseAggregatePaginate6);
547
+ var Unit_default = unitSchema;
548
+
549
+ // app/models/docs/Channel.json
550
+ var Channel_default2 = {
551
+ components: {
552
+ schemas: {
553
+ Channel: {
554
+ type: "object",
555
+ properties: {
556
+ id: {
557
+ type: "string",
558
+ format: "ObjectId",
559
+ description: "MongoDB ObjectId",
560
+ example: "507f1f77bcf86cd799439011",
561
+ readOnly: true
562
+ },
563
+ channel_tag: {
564
+ type: "string",
565
+ description: "Channel tag",
566
+ example: "MOTOR_PS_TEMP",
567
+ readOnly: true
568
+ },
569
+ channel_description: {
570
+ type: "string",
571
+ description: "Channel description",
572
+ example: "Motor Power Supply Temperature",
573
+ readOnly: true
574
+ },
575
+ channel_unit_id: {
576
+ type: "string",
577
+ format: "ObjectId",
578
+ description: "Unit of the channel",
579
+ example: "507f1f77bcf86cd799439011",
580
+ readOnly: true
581
+ },
582
+ channel_parsed: {
583
+ type: "object",
584
+ description: "Parsed channel data",
585
+ readOnly: true
586
+ }
587
+ },
588
+ required: [
589
+ "channel_tag",
590
+ "channel_description",
591
+ "channel_unit_id",
592
+ "channel_parsed"
593
+ ]
594
+ }
595
+ },
596
+ examples: {
597
+ Channel: {
598
+ value: {
599
+ id: "507f1f77bcf86cd799439011",
600
+ channel_tag: "MOTOR_PS_TEMP",
601
+ channel_description: "Motor Power Supply Temperature",
602
+ channel_type: "Analogic"
603
+ }
604
+ }
605
+ }
606
+ }
607
+ };
608
+
609
+ // app/models/docs/ChannelDataBucket.json
610
+ var ChannelDataBucket_default2 = {
611
+ components: {
612
+ schemas: {
613
+ ChannelData: {
614
+ type: "object",
615
+ description: "ChannelData object. This is the bucket where the data is stored, in batches of 1 hour.",
616
+ properties: {
617
+ id: {
618
+ type: "string",
619
+ format: "ObjectId",
620
+ description: "MongoDB ObjectId",
621
+ example: "507f1f77bcf86cd799439011",
622
+ readOnly: true
623
+ },
624
+ start_date: {
625
+ type: "string",
626
+ format: "date-time",
627
+ description: "Start date of the data",
628
+ example: "2024-07-03T10:15:30Z",
629
+ readOnly: true
630
+ },
631
+ end_date: {
632
+ type: "string",
633
+ format: "date-time",
634
+ description: "End date of the data",
635
+ example: "2024-07-03T11:15:30Z",
636
+ readOnly: true
637
+ },
638
+ data: {
639
+ type: "array",
640
+ description: "Data array of DataPoint objects",
641
+ items: {
642
+ $ref: "#/components/schemas/DataPoint"
643
+ },
644
+ readOnly: false
645
+ },
646
+ size: {
647
+ type: "integer",
648
+ format: "int64",
649
+ description: "Size of the data array",
650
+ example: 60,
651
+ readOnly: true
652
+ },
653
+ synced: {
654
+ type: "TODO",
655
+ description: "TODO",
656
+ example: "TODO",
657
+ readOnly: true
658
+ },
659
+ sum: {
660
+ type: "number",
661
+ format: "double",
662
+ description: "Sum of the data",
663
+ example: 69.42,
664
+ readOnly: true
665
+ }
666
+ }
667
+ }
668
+ },
669
+ examples: {
670
+ ChannelData: {
671
+ id: "507f1f77bcf86cd799439011",
672
+ start_date: "2024-07-03T10:15:30Z",
673
+ end_date: "2024-07-03T11:15:30Z",
674
+ data: [
675
+ {
676
+ t: 1710251647e3,
677
+ v: 69.42
678
+ }
679
+ ],
680
+ size: 60,
681
+ synced: "TODO",
682
+ sum: 69.42
683
+ }
684
+ }
685
+ }
686
+ };
687
+
688
+ // app/models/docs/ChannelWithData.json
689
+ var ChannelWithData_default = {
690
+ components: {
691
+ schemas: {
692
+ ChannelWithData: {
693
+ allOf: [
694
+ {
695
+ $ref: "#/components/schemas/Channel"
696
+ },
697
+ {
698
+ type: "object",
699
+ properties: {
700
+ channel_latest_value: {
701
+ type: "string",
702
+ description: "Latest value of the channel",
703
+ example: "25.0",
704
+ readOnly: true
705
+ },
706
+ channel_latest_timestamp: {
707
+ type: "string",
708
+ format: "date-time",
709
+ description: "Timestamp of the latest value",
710
+ example: 1700034034,
711
+ readOnly: true
712
+ },
713
+ channel_alarm_state: {
714
+ type: "string",
715
+ description: "Alarm state of the channel",
716
+ example: "NoAlarm",
717
+ readOnly: true
718
+ }
719
+ }
720
+ }
721
+ ],
722
+ required: [
723
+ "channel_tag",
724
+ "channel_description",
725
+ "channel_type",
726
+ "channel_latest_value",
727
+ "channel_latest_timestamp",
728
+ "channel_alarm_state"
729
+ ]
730
+ }
731
+ },
732
+ examples: {
733
+ ChannelWithData: {
734
+ value: {
735
+ id: "507f1f77bcf86cd799439011",
736
+ channel_tag: "MOTOR_PS_TEMP",
737
+ channel_description: "Motor Power Supply Temperature",
738
+ channel_type: "Analogic",
739
+ channel_latest_value: 420.69,
740
+ channel_latest_timestamp: 1700034034,
741
+ channel_alarm_state: "NoAlarm"
742
+ }
743
+ }
744
+ }
745
+ }
746
+ };
747
+
748
+ // app/models/docs/ChannelDataPoint.json
749
+ var ChannelDataPoint_default2 = {
750
+ components: {
751
+ schemas: {
752
+ ChannelDataPoint: {
753
+ type: "object",
754
+ description: "ChannelDataPoint object. This is the object that is sent to and from the API. It includes only the timestamp and the value. No id is included because the data is stored inside a larger bucket in the database.",
755
+ properties: {
756
+ c: {
757
+ type: "string",
758
+ description: "Channel ID associated with the data point",
759
+ example: "U001_001",
760
+ readOnly: true
761
+ },
762
+ t: {
763
+ type: "integer",
764
+ format: "int64",
765
+ description: "Timestamp of the data",
766
+ example: 1710251647e3,
767
+ readOnly: true
768
+ },
769
+ v: {
770
+ type: "number",
771
+ format: "double",
772
+ description: "Value of the data",
773
+ example: 69.42,
774
+ readOnly: true
775
+ }
776
+ }
777
+ }
778
+ },
779
+ examples: {
780
+ ChannelDataPoint: {
781
+ c: "U001_001",
782
+ t: 1710251647e3,
783
+ v: 69.42
784
+ }
785
+ }
786
+ }
787
+ };
788
+
789
+ // app/models/docs/Event.json
790
+ var Event_default2 = {
791
+ components: {
792
+ schemas: {
793
+ Event: {
794
+ type: "object",
795
+ description: "Event object. This is the object that is sent to and from the API. It includes the id as a string, the timestamp as a number and the creation timestamp is not included.",
796
+ properties: {
797
+ id: {
798
+ type: "string",
799
+ format: "ObjectId",
800
+ description: "MongoDB ObjectId",
801
+ example: "507f1f77bcf86cd799439011",
802
+ readOnly: true
803
+ },
804
+ event_message: {
805
+ type: "string",
806
+ format: "text",
807
+ description: "Event message",
808
+ example: "Event message"
809
+ },
810
+ event_source: {
811
+ type: "string",
812
+ format: "text",
813
+ description: "Hostname of the source of the event",
814
+ example: "RMS1"
815
+ },
816
+ event_category: {
817
+ type: "string",
818
+ format: "text",
819
+ description: "Event category",
820
+ example: "Login",
821
+ enum: "%%EVENT_CATEGORY_ENUM%%"
822
+ },
823
+ event_type: {
824
+ type: "string",
825
+ format: "text",
826
+ description: "Event type",
827
+ example: "Login"
828
+ },
829
+ event_timestamp: {
830
+ type: "number",
831
+ format: "timestamp",
832
+ description: "Event timestamp",
833
+ example: 1709899759
834
+ },
835
+ event_data: {
836
+ type: "object",
837
+ description: "Event data. Not validated, just stored"
838
+ }
839
+ },
840
+ required: [
841
+ "event_message",
842
+ "event_source",
843
+ "event_category",
844
+ "event_type",
845
+ "event_timestamp"
846
+ ]
847
+ }
848
+ },
849
+ examples: {
850
+ Event: {
851
+ value: {
852
+ id: "507f1f77bcf86cd799439011",
853
+ event_message: "Profile Root logged in for the next 600 seconds, replacing profile Root.",
854
+ event_source: "RMS1",
855
+ event_category: "Login",
856
+ event_type: "LoiginSuccessful",
857
+ event_timestamp: 1709899759,
858
+ event_data: {
859
+ profile: "Root",
860
+ duration: 600,
861
+ replaced_profile: "Monitor"
862
+ }
863
+ }
864
+ }
865
+ }
866
+ }
867
+ };
868
+
869
+ // app/models/docs/History.json
870
+ var History_default2 = {
871
+ components: {
872
+ schemas: {
873
+ History: {
874
+ type: "object",
875
+ properties: {
876
+ id: {
877
+ type: "string",
878
+ format: "ObjectId",
879
+ description: "MongoDB ObjectId",
880
+ example: "507f1f77bcf86cd799439011",
881
+ readOnly: true
882
+ },
883
+ channel_tag: {
884
+ type: "string",
885
+ format: "text",
886
+ description: "Channel tag",
887
+ example: "Channel tag",
888
+ readOnly: true
889
+ },
890
+ alarm_timestamp: {
891
+ type: "string",
892
+ format: "date-time",
893
+ description: "Alarm timestamp",
894
+ example: "2020-12-31T23:59:59Z",
895
+ readOnly: true
896
+ },
897
+ alarm_priority: {
898
+ type: "string",
899
+ format: "text",
900
+ description: "Alarm priority",
901
+ example: "Alarm",
902
+ enum: "%%ALARM_PRIORITY_ENUM%%",
903
+ readOnly: true
904
+ },
905
+ alarm_original_state: {
906
+ type: "string",
907
+ format: "text",
908
+ description: "Alarm original state",
909
+ example: "Inactive",
910
+ enum: "%%DIAMAR_ALARM_STATE_ENUM%%",
911
+ readOnly: true
912
+ },
913
+ alarm_state: {
914
+ type: "string",
915
+ format: "text",
916
+ description: "Alarm new state",
917
+ example: "Inactive",
918
+ enum: "%%CLOUD_ALARM_STATE_ENUM%%",
919
+ readOnly: true
920
+ },
921
+ alarm_type: {
922
+ type: "string",
923
+ format: "text",
924
+ description: "Alarm type",
925
+ example: "AlarmOpen",
926
+ enum: "%%ALARM_TYPE_ENUM%%",
927
+ readOnly: true
928
+ },
929
+ alarm_value: {
930
+ type: "number",
931
+ format: "double",
932
+ description: "Alarm value",
933
+ example: 0,
934
+ readOnly: true
935
+ },
936
+ alarm_message: {
937
+ type: "string",
938
+ format: "text",
939
+ description: "Alarm message",
940
+ example: "Alarm message",
941
+ readOnly: true
942
+ }
943
+ },
944
+ required: [
945
+ "channel_tag",
946
+ "alarm_timestamp",
947
+ "alarm_priority",
948
+ "alarm_original_state",
949
+ "alarm_state",
950
+ "alarm_type",
951
+ "alarm_value",
952
+ "alarm_message"
953
+ ]
954
+ }
955
+ },
956
+ examples: {
957
+ History: {
958
+ value: {
959
+ id: "507f1f77bcf86cd799439011",
960
+ channel_tag: "Channel tag",
961
+ alarm_timestamp: "2020-12-31T23:59:59Z",
962
+ alarm_priority: "Alarm",
963
+ alarm_original_state: "Inactive",
964
+ alarm_state: "Inactive",
965
+ alarm_type: "AlarmOpen",
966
+ alarm_value: 0,
967
+ alarm_message: "AlarmOpen Value: [OP]"
968
+ }
969
+ }
970
+ }
971
+ }
972
+ };
973
+
974
+ // app/models/docs/Unit.json
975
+ var Unit_default2 = {
976
+ components: {
977
+ schemas: {
978
+ Unit: {
979
+ type: "object",
980
+ properties: {
981
+ id: {
982
+ type: "string",
983
+ format: "ObjectId",
984
+ description: "MongoDB ObjectId",
985
+ example: "507f1f77bcf86cd799439011",
986
+ readOnly: true
987
+ },
988
+ unit_id: {
989
+ type: "string",
990
+ description: "Unit identifier in Diamar",
991
+ example: "127",
992
+ readOnly: true
993
+ },
994
+ unit_internal_description: {
995
+ type: "string",
996
+ description: "Unit description",
997
+ example: "Motor Power Supply",
998
+ readOnly: true
999
+ },
1000
+ unit_enabled: {
1001
+ type: "boolean",
1002
+ description: "Unit enabled",
1003
+ example: true,
1004
+ readOnly: true
1005
+ },
1006
+ unit_type: {
1007
+ type: "string",
1008
+ description: "Unit type",
1009
+ example: "DIM36",
1010
+ readOnly: true
1011
+ },
1012
+ unit_cabinet_id: {
1013
+ type: "string",
1014
+ description: "Cabinet identifier",
1015
+ example: "Cabinet 1",
1016
+ readOnly: true
1017
+ }
1018
+ },
1019
+ required: [
1020
+ "unit_id",
1021
+ "unit_internal_description",
1022
+ "unit_enabled",
1023
+ "unit_type",
1024
+ "unit_cabinet_id"
1025
+ ]
1026
+ }
1027
+ },
1028
+ examples: {
1029
+ Unit: {
1030
+ value: {
1031
+ id: "507f1f77bcf86cd799439011",
1032
+ unit_id: "127",
1033
+ unit_internal_description: "Motor Power Supply",
1034
+ unit_enabled: true,
1035
+ unit_type: "DIM36",
1036
+ unit_cabinet_id: "Cabinet 1"
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+ };
16
1042
 
17
- // app/types/channel.types.ts
18
- var ChannelBaseTypes = {
19
- VIRTUAL_ANALOG: "VirtualAnalog",
20
- VIRTUAL_DIGITAL: "VirtualDigital",
21
- VIRTUAL_STRING: "VirtualString",
22
- WIRED_ANALOG: "WiredAnalog",
23
- WIRED_DIGITAL: "WiredDigital"
24
- };
25
- var ChannelSpecificTypes = {
26
- // Wired types
27
- DIGITAL_INPUT: "DigitalInput",
28
- DIGITAL_OUTPUT: "DigitalOutput",
29
- ANALOG_INPUT: "AnalogInput",
30
- ANALOG_OUTPUT: "AnalogOutput",
31
- // Virtual types
32
- ANALOG_SOFTWARE: "AnalogSoftware",
33
- DIGITAL_SOFTWARE: "DigitalSoftware",
34
- VIRTUAL_STRING: "VirtualString",
35
- COMMAND: "Command",
36
- // Virtual logic types
37
- BROADCAST_COMMAND: "BroadcastCommand",
38
- // To be deleted in the near future
39
- SOFTWARE: "Software",
40
- ANALOG_TIMER: "AnalogTimer",
41
- // Serial types
42
- SERIAL_DIGITAL_INPUT: "SerialDigitalInput",
43
- SERIAL_DIGITAL_OUTPUT: "SerialDigitalOutput",
44
- SERIAL_LINE_COMMAND: "SerialLineCommand",
45
- SERIAL_ANALOG_INPUT: "SerialAnalogInput",
46
- SERIAL_ANALOG_OUTPUT: "SerialAnalogOutput"
1043
+ // app/models/docs/index.ts
1044
+ History_default2.components.schemas.History.properties.alarm_priority.enum = Object.values(AlarmPriorities);
1045
+ History_default2.components.schemas.History.properties.alarm_state.enum = Object.values(CloudAlarmStates);
1046
+ History_default2.components.schemas.History.properties.alarm_original_state.enum = Object.values(DiamarAlarmStates);
1047
+ History_default2.components.schemas.History.properties.alarm_type.enum = Object.values(AlarmTypes);
1048
+ Event_default2.components.schemas.Event.properties.event_category.enum = Object.values(EventCategories);
1049
+ var Docs = {
1050
+ ChannelDocs: Channel_default2,
1051
+ ChannelDataBucketDocs: ChannelDataBucket_default2,
1052
+ ChannelWithDataDocs: ChannelWithData_default,
1053
+ ChannelDataPointDocs: ChannelDataPoint_default2,
1054
+ EventDocs: Event_default2,
1055
+ HistoryDocs: History_default2,
1056
+ UnitDocs: Unit_default2
47
1057
  };
1058
+ var docs_default = Docs;
48
1059
 
49
1060
  // app/index.ts
50
- init_event_types();
51
- init_unit_types();
1061
+ import mongoose7 from "mongoose";
1062
+ import mongooseAggregatePaginate7 from "mongoose-aggregate-paginate-v2";
1063
+ import mongooseAutopopulate2 from "mongoose-autopopulate";
1064
+ import mongoosePaginate7 from "mongoose-paginate-v2";
1065
+ var Schemas = {
1066
+ Channel: Channel_default,
1067
+ ChannelDataBucket: ChannelDataBucket_default,
1068
+ ChannelDataPoint: ChannelDataPoint_default,
1069
+ Event: Event_default,
1070
+ History: History_default,
1071
+ Unit: Unit_default
1072
+ };
1073
+ var Mimics = {
1074
+ // Auxiliary
1075
+ ImageAuxiliaryJson,
1076
+ LineAuxiliaryJson,
1077
+ LinkAuxiliaryJson,
1078
+ PolylineAuxiliaryJson,
1079
+ SquareAuxiliaryJson,
1080
+ TextAuxiliaryJson,
1081
+ // Channel
1082
+ ChannelJson,
1083
+ // Control elements
1084
+ CompressorJson,
1085
+ DamperJson,
1086
+ DamperAutomatedJson,
1087
+ FanJson,
1088
+ PumpJson,
1089
+ PumpAutomatedJson,
1090
+ TankJson,
1091
+ ValveJson,
1092
+ ValveAutomatedJson,
1093
+ // Elements
1094
+ AlarmIndicatorJson,
1095
+ CommandJson,
1096
+ DialJson,
1097
+ DigitalJson,
1098
+ DisplayJson,
1099
+ DynamicTextJson,
1100
+ LevelBarJson,
1101
+ SliderJson,
1102
+ TextChannelJson,
1103
+ ToggleJson,
1104
+ // IAS elements
1105
+ CabinetJson,
1106
+ RepeaterJson,
1107
+ StationJson,
1108
+ UnitJson,
1109
+ // Support
1110
+ AddedAlarmsJson,
1111
+ BackgroundJson,
1112
+ LineJson,
1113
+ LocalizedTextJson,
1114
+ LocationJson,
1115
+ LogicExpressionJson,
1116
+ LogicExpressionsJson,
1117
+ ScaleJson,
1118
+ TextAttributesJson,
1119
+ TitleJson,
1120
+ // Traits
1121
+ AutomaticSemiAutoJson,
1122
+ CommandsOpClJson,
1123
+ CommandsStartStopJson,
1124
+ ControlLockJson,
1125
+ FeedbackOpClJson,
1126
+ FeedbackRunningStoppedJson,
1127
+ OrderOpClJson,
1128
+ OrderStartStopJson,
1129
+ RemoteLocalJson,
1130
+ TripResetJson,
1131
+ // PMS elements
1132
+ BreakerJson,
1133
+ BreakerPmsJson,
1134
+ GeneratorJson,
1135
+ GeneratorPmsJson,
1136
+ OperationModesJson,
1137
+ PriorityDataJson,
1138
+ PrioritiesJson,
1139
+ ShaftJson
1140
+ };
1141
+ var MimicsRequest = {
1142
+ // Auxiliary
1143
+ ImageAuxiliaryRequest,
1144
+ LineAuxiliaryRequest,
1145
+ LinkAuxiliaryRequest,
1146
+ PolylineAuxiliaryRequest,
1147
+ SquareAuxiliaryRequest,
1148
+ TextAuxiliaryRequest,
1149
+ // Channel
1150
+ ChannelRequest,
1151
+ // Control elements
1152
+ CompressorRequest,
1153
+ DamperRequest,
1154
+ DamperAutomatedRequest,
1155
+ FanRequest,
1156
+ PumpRequest,
1157
+ PumpAutomatedRequest,
1158
+ TankRequest,
1159
+ ValveRequest,
1160
+ ValveAutomatedRequest,
1161
+ // Elements
1162
+ AlarmIndicatorRequest,
1163
+ CommandRequest,
1164
+ DialRequest,
1165
+ DigitalRequest,
1166
+ DisplayRequest,
1167
+ DynamicTextRequest,
1168
+ LevelBarRequest,
1169
+ SliderRequest,
1170
+ TextChannelRequest,
1171
+ ToggleRequest,
1172
+ // IAS elements
1173
+ CabinetRequest,
1174
+ RepeaterRequest,
1175
+ StationRequest,
1176
+ UnitRequest,
1177
+ // Traits
1178
+ AutomaticSemiAutoRequest,
1179
+ CommandsOpClRequest,
1180
+ CommandsStartStopRequest,
1181
+ ControlLockRequest,
1182
+ FeedbackOpClRequest,
1183
+ FeedbackRunningStoppedRequest,
1184
+ OrderOpClRequest,
1185
+ OrderStartStopRequest,
1186
+ RemoteLocalRequest,
1187
+ TripResetRequest,
1188
+ // PMS elements
1189
+ BreakerRequest,
1190
+ BreakerPmsRequest,
1191
+ GeneratorRequest,
1192
+ GeneratorPmsRequest,
1193
+ OperationModesRequest,
1194
+ PriorityDataRequest,
1195
+ PrioritiesRequest,
1196
+ ShaftRequest
1197
+ };
1198
+ var MimicsResponse = {
1199
+ // Auxiliary
1200
+ ImageAuxiliaryResponse,
1201
+ LineAuxiliaryResponse,
1202
+ LinkAuxiliaryResponse,
1203
+ PolylineAuxiliaryResponse,
1204
+ SquareAuxiliaryResponse,
1205
+ TextAuxiliaryResponse,
1206
+ // Control elements
1207
+ CompressorResponse,
1208
+ DamperResponse,
1209
+ DamperAutomatedResponse,
1210
+ FanResponse,
1211
+ PumpResponse,
1212
+ PumpAutomatedResponse,
1213
+ TankResponse,
1214
+ ValveResponse,
1215
+ ValveAutomatedResponse,
1216
+ // Elements
1217
+ AlarmIndicatorResponse,
1218
+ CommandResponse,
1219
+ DialResponse,
1220
+ DigitalResponse,
1221
+ DisplayResponse,
1222
+ DynamicTextResponse,
1223
+ LevelBarResponse,
1224
+ SliderResponse,
1225
+ TextChannelResponse,
1226
+ ToggleResponse,
1227
+ // IAS elements
1228
+ CabinetResponse,
1229
+ RepeaterResponse,
1230
+ StationResponse,
1231
+ UnitResponse,
1232
+ // PMS elements
1233
+ BreakerResponse,
1234
+ BreakerPmsResponse,
1235
+ GeneratorResponse,
1236
+ GeneratorPmsResponse,
1237
+ OperationModesResponse,
1238
+ PrioritiesResponse,
1239
+ ShaftResponse
1240
+ };
1241
+ var MimicsTypes = {
1242
+ MimicElementTypes,
1243
+ ZDepths,
1244
+ TitleAligns,
1245
+ DigitalStates,
1246
+ DigitalAlarmStates,
1247
+ AlarmStates,
1248
+ MimicAlarmStates,
1249
+ MimicControlStates,
1250
+ ActivationModes,
1251
+ TextAnchorPoints,
1252
+ ValveDesigns,
1253
+ FanDesigns,
1254
+ FanRunStates,
1255
+ FanDirections,
1256
+ FanTypes,
1257
+ LevelBarOrientations,
1258
+ SliderOrientations,
1259
+ CompressorDesigns,
1260
+ LedTypes,
1261
+ InfoLocations,
1262
+ MarkTypes,
1263
+ ScalePositions,
1264
+ ValueTypes,
1265
+ OperationModeStates,
1266
+ UnitDesigns,
1267
+ StationDesigns,
1268
+ RepeaterDesigns,
1269
+ CabinetDesigns,
1270
+ LinkDesigns,
1271
+ OpClStates,
1272
+ RunningStoppedStates,
1273
+ AutoSemiAutoStates,
1274
+ RemoteLocalStates
1275
+ };
52
1276
  var Types = {
53
1277
  AlarmTypes,
54
1278
  AlarmPriorities,
@@ -58,8 +1282,21 @@ var Types = {
58
1282
  ChannelSpecificTypes,
59
1283
  EventCategories,
60
1284
  EventCriticalities,
61
- UnitTypes
1285
+ UnitTypes,
1286
+ Mimics: MimicsTypes
1287
+ };
1288
+ var index_default = {
1289
+ mongoose: mongoose7,
1290
+ mongoosePaginate: mongoosePaginate7,
1291
+ mongooseAggregatePaginate: mongooseAggregatePaginate7,
1292
+ mongooseAutopopulate: mongooseAutopopulate2
62
1293
  };
63
1294
  export {
64
- Types
1295
+ docs_default as Docs,
1296
+ Mimics,
1297
+ MimicsRequest,
1298
+ MimicsResponse,
1299
+ Schemas,
1300
+ Types,
1301
+ index_default as default
65
1302
  };