@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/deno.jsonc +46 -0
- package/dist/browser-index.cjs +1481 -0
- package/dist/browser-index.d.cts +470 -0
- package/dist/browser-index.d.ts +470 -0
- package/dist/browser-index.js +409 -0
- package/dist/chunk-55XBONH2.js +1415 -0
- package/dist/chunk-K5VO2MYI.js +1415 -0
- package/dist/chunk-VQWCQ4E2.js +908 -0
- package/dist/index.cjs +2278 -31
- package/dist/index.d.cts +1631 -100
- package/dist/index.d.ts +1631 -100
- package/dist/index.js +1277 -40
- package/dist/unit.types-4ZD9ivHi.d.cts +797 -0
- package/dist/unit.types-4ZD9ivHi.d.ts +797 -0
- package/dist/unit.types-BZWIS1vq.d.cts +1246 -0
- package/dist/unit.types-BZWIS1vq.d.ts +1246 -0
- package/dist/unit.types-CFWDGNUR.d.cts +1246 -0
- package/dist/unit.types-CFWDGNUR.d.ts +1246 -0
- package/package.json +24 -19
- package/tsconfig.json +2 -1
- package/dist/chunk-AOC7BD5E.js +0 -153
- package/dist/chunk-NCUZ3O3P.js +0 -152
- package/dist/node-entry.cjs +0 -1191
- package/dist/node-entry.d.cts +0 -53
- package/dist/node-entry.d.ts +0 -53
- package/dist/node-entry.js +0 -1078
package/dist/node-entry.cjs
DELETED
|
@@ -1,1191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __esm = (fn, res) => function __init() {
|
|
7
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
-
};
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
|
-
var __export = (target, all) => {
|
|
13
|
-
for (var name in all)
|
|
14
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
|
|
26
|
-
// app/models/Channel.cjs
|
|
27
|
-
var require_Channel = __commonJS({
|
|
28
|
-
"app/models/Channel.cjs"(exports2, module2) {
|
|
29
|
-
"use strict";
|
|
30
|
-
var mongoose2 = require("mongoose");
|
|
31
|
-
var mongooseAutopopulate2 = require("mongoose-autopopulate");
|
|
32
|
-
var mongoosePaginate2 = require("mongoose-paginate-v2");
|
|
33
|
-
var mongooseAggregatePaginate2 = require("mongoose-aggregate-paginate-v2");
|
|
34
|
-
var channelSchema = new mongoose2.Schema({
|
|
35
|
-
channel_tag: {
|
|
36
|
-
type: String,
|
|
37
|
-
required: true
|
|
38
|
-
},
|
|
39
|
-
channel_description: {
|
|
40
|
-
type: String,
|
|
41
|
-
required: true
|
|
42
|
-
},
|
|
43
|
-
channel_unit_id: {
|
|
44
|
-
type: mongoose2.Schema.Types.ObjectId,
|
|
45
|
-
ref: "Unit",
|
|
46
|
-
required: true,
|
|
47
|
-
autopopulate: true
|
|
48
|
-
},
|
|
49
|
-
channel_parsed: {
|
|
50
|
-
type: Object,
|
|
51
|
-
required: true
|
|
52
|
-
},
|
|
53
|
-
channel_last_bucket_sync: {
|
|
54
|
-
type: Date,
|
|
55
|
-
required: false
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
timestamps: {
|
|
59
|
-
createdAt: true,
|
|
60
|
-
updatedAt: true
|
|
61
|
-
},
|
|
62
|
-
collection: "channels",
|
|
63
|
-
toJSON: {
|
|
64
|
-
transform: function(doc, ret) {
|
|
65
|
-
ret.id = ret._id;
|
|
66
|
-
ret.channel_unit = ret.channel_unit_id;
|
|
67
|
-
ret.channel_unit_id = ret.channel_unit_id.unit_id;
|
|
68
|
-
delete ret._id;
|
|
69
|
-
delete ret.__v;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
channelSchema.index({ "channel_tag": 1 }, { unique: true });
|
|
74
|
-
channelSchema.index({ "channel_description": 1 });
|
|
75
|
-
channelSchema.plugin(mongoosePaginate2);
|
|
76
|
-
channelSchema.plugin(mongooseAggregatePaginate2);
|
|
77
|
-
channelSchema.plugin(mongooseAutopopulate2);
|
|
78
|
-
module2.exports = channelSchema;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// app/models/ChannelDataBucket.cjs
|
|
83
|
-
var require_ChannelDataBucket = __commonJS({
|
|
84
|
-
"app/models/ChannelDataBucket.cjs"(exports2, module2) {
|
|
85
|
-
"use strict";
|
|
86
|
-
var mongoose2 = require("mongoose");
|
|
87
|
-
var mongooseAutopopulate2 = require("mongoose-autopopulate");
|
|
88
|
-
var mongoosePaginate2 = require("mongoose-paginate-v2");
|
|
89
|
-
var mongooseAggregatePaginate2 = require("mongoose-aggregate-paginate-v2");
|
|
90
|
-
var dataPointSchema = new mongoose2.Schema({
|
|
91
|
-
timestamp: {
|
|
92
|
-
type: Number,
|
|
93
|
-
required: true
|
|
94
|
-
},
|
|
95
|
-
value: {
|
|
96
|
-
type: Number,
|
|
97
|
-
required: true
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
_id: false
|
|
101
|
-
});
|
|
102
|
-
var channeldataBucketSchema = new mongoose2.Schema({
|
|
103
|
-
start_date: {
|
|
104
|
-
type: Date,
|
|
105
|
-
required: true,
|
|
106
|
-
default: Date.now
|
|
107
|
-
},
|
|
108
|
-
end_date: {
|
|
109
|
-
type: Date,
|
|
110
|
-
required: true,
|
|
111
|
-
default: function() {
|
|
112
|
-
return new Date(Date.now() + 1e3 * 60 * 60);
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
data: {
|
|
116
|
-
type: [dataPointSchema],
|
|
117
|
-
required: true,
|
|
118
|
-
default: []
|
|
119
|
-
},
|
|
120
|
-
size: {
|
|
121
|
-
type: Number,
|
|
122
|
-
required: true,
|
|
123
|
-
default: 0
|
|
124
|
-
},
|
|
125
|
-
synced: {
|
|
126
|
-
type: Number,
|
|
127
|
-
required: true,
|
|
128
|
-
default: 0
|
|
129
|
-
},
|
|
130
|
-
sum: {
|
|
131
|
-
type: Number,
|
|
132
|
-
required: true,
|
|
133
|
-
default: 0
|
|
134
|
-
}
|
|
135
|
-
}, {
|
|
136
|
-
toJSON: {
|
|
137
|
-
transform: function(doc, ret) {
|
|
138
|
-
ret.id = ret._id;
|
|
139
|
-
delete ret._id;
|
|
140
|
-
delete ret.__v;
|
|
141
|
-
ret.start_date = ret.start_date.getTime();
|
|
142
|
-
ret.end_date = ret.end_date.getTime();
|
|
143
|
-
ret.avg = ret.sum / ret.size;
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
versionKey: false
|
|
147
|
-
});
|
|
148
|
-
channeldataBucketSchema.index({ start_date: 1, end_date: 1 }, { background: true });
|
|
149
|
-
channeldataBucketSchema.index({ start_date: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 365, background: true });
|
|
150
|
-
channeldataBucketSchema.plugin(mongoosePaginate2);
|
|
151
|
-
channeldataBucketSchema.plugin(mongooseAggregatePaginate2);
|
|
152
|
-
channeldataBucketSchema.plugin(mongooseAutopopulate2);
|
|
153
|
-
channeldataBucketSchema.methods.insertDataPoint = async function(timestamp, value) {
|
|
154
|
-
this.data.push({ timestamp, value });
|
|
155
|
-
this.size++;
|
|
156
|
-
this.sum += value;
|
|
157
|
-
await this.save();
|
|
158
|
-
};
|
|
159
|
-
channeldataBucketSchema.methods.removeDataPointsOutsideDateRange = function(start_date, end_date) {
|
|
160
|
-
start_date = start_date instanceof Date ? start_date.getTime() : start_date;
|
|
161
|
-
end_date = end_date instanceof Date ? end_date.getTime() : end_date;
|
|
162
|
-
this.data = this.data.filter((data_point) => data_point.timestamp >= start_date && data_point.timestamp < end_date);
|
|
163
|
-
this.size = this.data.length;
|
|
164
|
-
this.sum = this.data.reduce((sum, data_point) => sum + data_point.value, 0);
|
|
165
|
-
};
|
|
166
|
-
channeldataBucketSchema.methods.isBucketClosed = function(timestamp = Date.now()) {
|
|
167
|
-
return timestamp >= this.end_date.getTime();
|
|
168
|
-
};
|
|
169
|
-
channeldataBucketSchema.statics.insertDataPoint = async function(timestamp, value) {
|
|
170
|
-
const date = new Date(timestamp);
|
|
171
|
-
date.setMinutes(0);
|
|
172
|
-
date.setSeconds(0);
|
|
173
|
-
date.setMilliseconds(0);
|
|
174
|
-
const bucket = await this.findOneAndUpdate(
|
|
175
|
-
{
|
|
176
|
-
start_date: date
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
$push: {
|
|
180
|
-
data: {
|
|
181
|
-
timestamp,
|
|
182
|
-
value
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
$inc: {
|
|
186
|
-
size: 1,
|
|
187
|
-
sum: value
|
|
188
|
-
},
|
|
189
|
-
$set: {
|
|
190
|
-
end_date: new Date(date.getTime() + 1e3 * 60 * 60)
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
upsert: true,
|
|
195
|
-
new: true
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
return bucket;
|
|
199
|
-
};
|
|
200
|
-
channeldataBucketSchema.statics.lastTimeSynced = async function(options) {
|
|
201
|
-
let last_sync = 0;
|
|
202
|
-
if (options?.channel_tag && options?.db) {
|
|
203
|
-
const channel = await options.db.collection("channels").findOne({
|
|
204
|
-
channel_tag: options.channel_tag
|
|
205
|
-
});
|
|
206
|
-
last_sync = channel.channel_last_bucket_sync.getTime();
|
|
207
|
-
}
|
|
208
|
-
return last_sync;
|
|
209
|
-
};
|
|
210
|
-
channeldataBucketSchema.statics.getNotUploadedData = async function(options) {
|
|
211
|
-
const last_sync = options?.last_sync ?? await this.lastTimeSynced(options);
|
|
212
|
-
const buckets = await this.find({
|
|
213
|
-
end_date: {
|
|
214
|
-
$gt: new Date(last_sync)
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
return buckets;
|
|
218
|
-
};
|
|
219
|
-
channeldataBucketSchema.statics.getData = async function(start_date, end_date, plain = false) {
|
|
220
|
-
const date = new Date(start_date);
|
|
221
|
-
date.setMinutes(0);
|
|
222
|
-
date.setSeconds(0);
|
|
223
|
-
date.setMilliseconds(0);
|
|
224
|
-
const data = await this.find({
|
|
225
|
-
start_date: {
|
|
226
|
-
$gte: date,
|
|
227
|
-
$lt: new Date(end_date)
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
if (!data || data.length === 0) {
|
|
231
|
-
return [];
|
|
232
|
-
}
|
|
233
|
-
data[0].removeDataPointsOutsideDateRange(start_date, end_date);
|
|
234
|
-
if (data.length > 1) {
|
|
235
|
-
data[1].removeDataPointsOutsideDateRange(start_date, end_date);
|
|
236
|
-
}
|
|
237
|
-
return plain ? data.flatMap((bucket) => {
|
|
238
|
-
return bucket.data.map((data_point) => {
|
|
239
|
-
return {
|
|
240
|
-
timestamp: data_point.timestamp,
|
|
241
|
-
value: data_point.value
|
|
242
|
-
};
|
|
243
|
-
});
|
|
244
|
-
}) : data;
|
|
245
|
-
};
|
|
246
|
-
channeldataBucketSchema.statics.upsertBucket = async function(bucket) {
|
|
247
|
-
const date = new Date(bucket.start_date);
|
|
248
|
-
date.setMinutes(0);
|
|
249
|
-
date.setSeconds(0);
|
|
250
|
-
date.setMilliseconds(0);
|
|
251
|
-
const result = await this.updateOne(
|
|
252
|
-
{
|
|
253
|
-
start_date: date
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
$set: {
|
|
257
|
-
data: bucket.data,
|
|
258
|
-
size: bucket.size,
|
|
259
|
-
sum: bucket.sum,
|
|
260
|
-
end_date: new Date(date.getTime() + 1e3 * 60 * 60)
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
upsert: true
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
return result;
|
|
268
|
-
};
|
|
269
|
-
module2.exports = channeldataBucketSchema;
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// app/types/event.types.ts
|
|
274
|
-
var event_types_exports = {};
|
|
275
|
-
__export(event_types_exports, {
|
|
276
|
-
EventCategories: () => EventCategories,
|
|
277
|
-
EventCriticalities: () => EventCriticalities
|
|
278
|
-
});
|
|
279
|
-
var EventCategories, EventCriticalities;
|
|
280
|
-
var init_event_types = __esm({
|
|
281
|
-
"app/types/event.types.ts"() {
|
|
282
|
-
"use strict";
|
|
283
|
-
EventCategories = {
|
|
284
|
-
ACCESS_CONTROL: "AccessControl",
|
|
285
|
-
REQUEST_ERROR: "RequestErrors",
|
|
286
|
-
OS: "OperatingSystemEvents",
|
|
287
|
-
CONTROL: "ControlSystemEvents",
|
|
288
|
-
BACKUP: "BackupAndRestoreEvents",
|
|
289
|
-
CONFIG_CHANGE: "ConfigurationChanges",
|
|
290
|
-
LOGS: "AuditLogEvents",
|
|
291
|
-
POTENTIAL_ATTACK: "PotentialAttackActivity"
|
|
292
|
-
};
|
|
293
|
-
EventCriticalities = {
|
|
294
|
-
VERBOSE: "Verbose",
|
|
295
|
-
INFO: "Info",
|
|
296
|
-
WARNING: "Warning",
|
|
297
|
-
ERROR: "Error",
|
|
298
|
-
CRITICAL: "Critical"
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// app/models/Event.cjs
|
|
304
|
-
var require_Event = __commonJS({
|
|
305
|
-
"app/models/Event.cjs"(exports2, module2) {
|
|
306
|
-
"use strict";
|
|
307
|
-
var mongoose2 = require("mongoose");
|
|
308
|
-
var mongooseAutopopulate2 = require("mongoose-autopopulate");
|
|
309
|
-
var mongoosePaginate2 = require("mongoose-paginate-v2");
|
|
310
|
-
var mongooseAggregatePaginate2 = require("mongoose-aggregate-paginate-v2");
|
|
311
|
-
var { EventCategories: EventCategories3, EventCriticalities: EventCriticalities2 } = (init_event_types(), __toCommonJS(event_types_exports));
|
|
312
|
-
var eventSchema = new mongoose2.Schema({
|
|
313
|
-
event_message: {
|
|
314
|
-
type: String,
|
|
315
|
-
required: true
|
|
316
|
-
},
|
|
317
|
-
event_source: {
|
|
318
|
-
type: String,
|
|
319
|
-
required: true
|
|
320
|
-
},
|
|
321
|
-
event_user: {
|
|
322
|
-
type: String,
|
|
323
|
-
required: false
|
|
324
|
-
},
|
|
325
|
-
event_category: {
|
|
326
|
-
type: String,
|
|
327
|
-
required: true,
|
|
328
|
-
enum: Object.values(EventCategories3)
|
|
329
|
-
},
|
|
330
|
-
event_criticality: {
|
|
331
|
-
type: String,
|
|
332
|
-
required: true,
|
|
333
|
-
enum: Object.values(EventCriticalities2)
|
|
334
|
-
},
|
|
335
|
-
event_type: {
|
|
336
|
-
type: String,
|
|
337
|
-
required: true
|
|
338
|
-
},
|
|
339
|
-
event_timestamp: {
|
|
340
|
-
type: Date,
|
|
341
|
-
default: Date.now
|
|
342
|
-
},
|
|
343
|
-
event_data: {
|
|
344
|
-
type: Object
|
|
345
|
-
}
|
|
346
|
-
}, {
|
|
347
|
-
timestamps: {
|
|
348
|
-
createdAt: true,
|
|
349
|
-
updatedAt: false
|
|
350
|
-
},
|
|
351
|
-
versionKey: false,
|
|
352
|
-
toJSON: {
|
|
353
|
-
transform: function(doc, ret) {
|
|
354
|
-
ret.id = ret._id;
|
|
355
|
-
delete ret._id;
|
|
356
|
-
delete ret.createdAt;
|
|
357
|
-
ret.event_timestamp = ret.event_timestamp.getTime();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
eventSchema.index({ "event_type": 1 });
|
|
362
|
-
eventSchema.index({ "event_category": 1 });
|
|
363
|
-
var oneYear = 60 * 60 * 24 * 365;
|
|
364
|
-
eventSchema.addTTLIndex = function(ttlField, expirationTimeInSeconds = oneYear) {
|
|
365
|
-
this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
|
|
366
|
-
};
|
|
367
|
-
eventSchema.plugin(mongoosePaginate2);
|
|
368
|
-
eventSchema.plugin(mongooseAggregatePaginate2);
|
|
369
|
-
eventSchema.plugin(mongooseAutopopulate2);
|
|
370
|
-
module2.exports = eventSchema;
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
// app/types/alarm.types.ts
|
|
375
|
-
var alarm_types_exports = {};
|
|
376
|
-
__export(alarm_types_exports, {
|
|
377
|
-
AlarmPriorities: () => AlarmPriorities,
|
|
378
|
-
AlarmTypes: () => AlarmTypes,
|
|
379
|
-
CloudAlarmStates: () => CloudAlarmStates,
|
|
380
|
-
DiamarAlarmStates: () => DiamarAlarmStates
|
|
381
|
-
});
|
|
382
|
-
var AlarmPriorities, DiamarAlarmStates, CloudAlarmStates, AlarmTypes;
|
|
383
|
-
var init_alarm_types = __esm({
|
|
384
|
-
"app/types/alarm.types.ts"() {
|
|
385
|
-
"use strict";
|
|
386
|
-
AlarmPriorities = {
|
|
387
|
-
CRITICAL: "Critical",
|
|
388
|
-
ALARM: "Alarm",
|
|
389
|
-
WARNING: "Warning"
|
|
390
|
-
};
|
|
391
|
-
DiamarAlarmStates = {
|
|
392
|
-
INACTIVE: "Inactive",
|
|
393
|
-
ACKNOWLEDGED: "Acknowledged",
|
|
394
|
-
ACTIVE: "Active",
|
|
395
|
-
UNACKNOWLEDGED: "Unacknowledged",
|
|
396
|
-
UNDEFINED: "Undefined"
|
|
397
|
-
};
|
|
398
|
-
CloudAlarmStates = {
|
|
399
|
-
INACTIVE: "Inactive",
|
|
400
|
-
ALARM: "Active",
|
|
401
|
-
ALARM_ACK: "Acknowledged",
|
|
402
|
-
WARNING: "WarningActive",
|
|
403
|
-
WARNING_ACK: "WarningAcknowledged",
|
|
404
|
-
RETURN_NO_ACK: "Unacknowledged",
|
|
405
|
-
INHIBITED: "Inhibited",
|
|
406
|
-
OFFSCAN: "Offscan",
|
|
407
|
-
UNDEFINED: "Undefined"
|
|
408
|
-
};
|
|
409
|
-
AlarmTypes = {
|
|
410
|
-
NORMAL: "Normal",
|
|
411
|
-
ALARM_OPEN: "AlarmOpen",
|
|
412
|
-
ALARM_CLOSE: "AlarmClose",
|
|
413
|
-
ALARM_IFH: "AlarmIfh",
|
|
414
|
-
ALARM_HH: "AlarmHh",
|
|
415
|
-
ALARM_H: "AlarmH",
|
|
416
|
-
ALARM_L: "AlarmL",
|
|
417
|
-
ALARM_LL: "AlarmLl",
|
|
418
|
-
ALARM_IFL: "AlarmIfl",
|
|
419
|
-
ALARM_OFFSCAN: "AlarmOffScan",
|
|
420
|
-
ALARM_FAIL: "AlarmFail",
|
|
421
|
-
ALARM_INH: "AlarmInh",
|
|
422
|
-
ALARM_UNK: "AlarmUnk"
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
// app/models/History.cjs
|
|
428
|
-
var require_History = __commonJS({
|
|
429
|
-
"app/models/History.cjs"(exports2, module2) {
|
|
430
|
-
"use strict";
|
|
431
|
-
var mongoose2 = require("mongoose");
|
|
432
|
-
var mongooseAutopopulate2 = require("mongoose-autopopulate");
|
|
433
|
-
var mongoosePaginate2 = require("mongoose-paginate-v2");
|
|
434
|
-
var mongooseAggregatePaginate2 = require("mongoose-aggregate-paginate-v2");
|
|
435
|
-
var { AlarmTypes: AlarmTypes3, AlarmPriorities: AlarmPriorities3, CloudAlarmStates: CloudAlarmStates3, DiamarAlarmStates: DiamarAlarmStates3 } = (init_alarm_types(), __toCommonJS(alarm_types_exports));
|
|
436
|
-
var historySchema = new mongoose2.Schema({
|
|
437
|
-
channel_tag: {
|
|
438
|
-
type: String,
|
|
439
|
-
required: true
|
|
440
|
-
},
|
|
441
|
-
alarm_timestamp: {
|
|
442
|
-
type: Date,
|
|
443
|
-
required: true,
|
|
444
|
-
default: Date.now
|
|
445
|
-
},
|
|
446
|
-
alarm_priority: {
|
|
447
|
-
type: String,
|
|
448
|
-
required: true,
|
|
449
|
-
enum: Object.values(AlarmPriorities3)
|
|
450
|
-
},
|
|
451
|
-
alarm_original_state: {
|
|
452
|
-
type: String,
|
|
453
|
-
required: true,
|
|
454
|
-
enum: Object.values(DiamarAlarmStates3)
|
|
455
|
-
},
|
|
456
|
-
alarm_state: {
|
|
457
|
-
type: String,
|
|
458
|
-
required: true,
|
|
459
|
-
enum: Object.values(CloudAlarmStates3)
|
|
460
|
-
},
|
|
461
|
-
alarm_type: {
|
|
462
|
-
type: String,
|
|
463
|
-
required: true,
|
|
464
|
-
enum: Object.values(AlarmTypes3)
|
|
465
|
-
},
|
|
466
|
-
alarm_value: {
|
|
467
|
-
type: Number,
|
|
468
|
-
required: false
|
|
469
|
-
},
|
|
470
|
-
alarm_message: {
|
|
471
|
-
type: String,
|
|
472
|
-
required: false
|
|
473
|
-
},
|
|
474
|
-
alarm_data: {
|
|
475
|
-
type: Object,
|
|
476
|
-
required: false
|
|
477
|
-
}
|
|
478
|
-
}, {
|
|
479
|
-
timestamps: {
|
|
480
|
-
createdAt: false,
|
|
481
|
-
updatedAt: false
|
|
482
|
-
},
|
|
483
|
-
versionKey: false,
|
|
484
|
-
collection: "history",
|
|
485
|
-
toJSON: {
|
|
486
|
-
transform: function(doc, ret) {
|
|
487
|
-
ret.id = ret._id;
|
|
488
|
-
delete ret._id;
|
|
489
|
-
delete ret.__v;
|
|
490
|
-
ret.alarm_timestamp = new Date(ret.alarm_timestamp).getTime();
|
|
491
|
-
ret.alarm = {
|
|
492
|
-
alarm_priority: ret.alarm_priority,
|
|
493
|
-
alarm_state: ret.alarm_original_state ?? "Inactive",
|
|
494
|
-
alarm_type: ret.alarm_type,
|
|
495
|
-
alarm_value: ret.alarm_value === null ? "inf" : `${ret.alarm_value}`,
|
|
496
|
-
alarm_timestamp: new Date(ret.alarm_timestamp).getTime()
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
historySchema.index({ "channel_tag": 1 });
|
|
502
|
-
var oneYear = 60 * 60 * 24 * 365;
|
|
503
|
-
historySchema.addTTLIndex = function(ttlField, expirationTimeInSeconds = oneYear) {
|
|
504
|
-
this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
|
|
505
|
-
};
|
|
506
|
-
historySchema.plugin(mongoosePaginate2);
|
|
507
|
-
historySchema.plugin(mongooseAggregatePaginate2);
|
|
508
|
-
historySchema.plugin(mongooseAutopopulate2);
|
|
509
|
-
module2.exports = historySchema;
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// app/types/unit.types.ts
|
|
514
|
-
var unit_types_exports = {};
|
|
515
|
-
__export(unit_types_exports, {
|
|
516
|
-
UnitTypes: () => UnitTypes
|
|
517
|
-
});
|
|
518
|
-
var UnitTypes;
|
|
519
|
-
var init_unit_types = __esm({
|
|
520
|
-
"app/types/unit.types.ts"() {
|
|
521
|
-
"use strict";
|
|
522
|
-
UnitTypes = {
|
|
523
|
-
AIM18: "Aim18",
|
|
524
|
-
DIM36: "Dim36",
|
|
525
|
-
DIOM24: "Diom24",
|
|
526
|
-
KLIM: "Klim",
|
|
527
|
-
LUM: "Lum",
|
|
528
|
-
PMM: "Pmm",
|
|
529
|
-
SLIM: "Slim",
|
|
530
|
-
TIM28: "Tim28"
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
|
|
535
|
-
// app/models/Unit.cjs
|
|
536
|
-
var require_Unit = __commonJS({
|
|
537
|
-
"app/models/Unit.cjs"(exports2, module2) {
|
|
538
|
-
"use strict";
|
|
539
|
-
var mongoose2 = require("mongoose");
|
|
540
|
-
var mongooseAutopopulate2 = require("mongoose-autopopulate");
|
|
541
|
-
var mongoosePaginate2 = require("mongoose-paginate-v2");
|
|
542
|
-
var mongooseAggregatePaginate2 = require("mongoose-aggregate-paginate-v2");
|
|
543
|
-
var { UnitTypes: UnitTypes2 } = (init_unit_types(), __toCommonJS(unit_types_exports));
|
|
544
|
-
var unitSchema = new mongoose2.Schema({
|
|
545
|
-
unit_id: {
|
|
546
|
-
type: String,
|
|
547
|
-
required: true
|
|
548
|
-
},
|
|
549
|
-
unit_enabled: {
|
|
550
|
-
type: Boolean,
|
|
551
|
-
required: true
|
|
552
|
-
},
|
|
553
|
-
unit_type: {
|
|
554
|
-
type: String,
|
|
555
|
-
required: true,
|
|
556
|
-
enum: Object.values(UnitTypes2)
|
|
557
|
-
},
|
|
558
|
-
unit_internal_description: {
|
|
559
|
-
type: String,
|
|
560
|
-
required: true
|
|
561
|
-
},
|
|
562
|
-
unit_cabinet_id: {
|
|
563
|
-
type: String,
|
|
564
|
-
required: false
|
|
565
|
-
}
|
|
566
|
-
}, {
|
|
567
|
-
timestamps: true,
|
|
568
|
-
collection: "units",
|
|
569
|
-
toJSON: {
|
|
570
|
-
transform: function(doc, ret) {
|
|
571
|
-
ret.id = ret._id;
|
|
572
|
-
delete ret._id;
|
|
573
|
-
delete ret.__v;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
unitSchema.index({ "unit_id": 1 }, { unique: true });
|
|
578
|
-
unitSchema.index({ "unit_internal_description": 1 });
|
|
579
|
-
unitSchema.plugin(mongoosePaginate2);
|
|
580
|
-
unitSchema.plugin(mongooseAggregatePaginate2);
|
|
581
|
-
unitSchema.plugin(mongooseAutopopulate2);
|
|
582
|
-
module2.exports = unitSchema;
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
// app/models/docs/Channel.json
|
|
587
|
-
var require_Channel2 = __commonJS({
|
|
588
|
-
"app/models/docs/Channel.json"(exports2, module2) {
|
|
589
|
-
module2.exports = {
|
|
590
|
-
components: {
|
|
591
|
-
schemas: {
|
|
592
|
-
Channel: {
|
|
593
|
-
type: "object",
|
|
594
|
-
properties: {
|
|
595
|
-
id: {
|
|
596
|
-
type: "string",
|
|
597
|
-
format: "ObjectId",
|
|
598
|
-
description: "MongoDB ObjectId",
|
|
599
|
-
example: "507f1f77bcf86cd799439011",
|
|
600
|
-
readOnly: true
|
|
601
|
-
},
|
|
602
|
-
channel_tag: {
|
|
603
|
-
type: "string",
|
|
604
|
-
description: "Channel tag",
|
|
605
|
-
example: "MOTOR_PS_TEMP",
|
|
606
|
-
readOnly: true
|
|
607
|
-
},
|
|
608
|
-
channel_description: {
|
|
609
|
-
type: "string",
|
|
610
|
-
description: "Channel description",
|
|
611
|
-
example: "Motor Power Supply Temperature",
|
|
612
|
-
readOnly: true
|
|
613
|
-
},
|
|
614
|
-
channel_unit_id: {
|
|
615
|
-
type: "string",
|
|
616
|
-
format: "ObjectId",
|
|
617
|
-
description: "Unit of the channel",
|
|
618
|
-
example: "507f1f77bcf86cd799439011",
|
|
619
|
-
readOnly: true
|
|
620
|
-
},
|
|
621
|
-
channel_parsed: {
|
|
622
|
-
type: "object",
|
|
623
|
-
description: "Parsed channel data",
|
|
624
|
-
readOnly: true
|
|
625
|
-
}
|
|
626
|
-
},
|
|
627
|
-
required: [
|
|
628
|
-
"channel_tag",
|
|
629
|
-
"channel_description",
|
|
630
|
-
"channel_unit_id",
|
|
631
|
-
"channel_parsed"
|
|
632
|
-
]
|
|
633
|
-
}
|
|
634
|
-
},
|
|
635
|
-
examples: {
|
|
636
|
-
Channel: {
|
|
637
|
-
value: {
|
|
638
|
-
id: "507f1f77bcf86cd799439011",
|
|
639
|
-
channel_tag: "MOTOR_PS_TEMP",
|
|
640
|
-
channel_description: "Motor Power Supply Temperature",
|
|
641
|
-
channel_type: "Analogic"
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
// app/models/docs/ChannelDataBucket.json
|
|
651
|
-
var require_ChannelDataBucket2 = __commonJS({
|
|
652
|
-
"app/models/docs/ChannelDataBucket.json"(exports2, module2) {
|
|
653
|
-
module2.exports = {
|
|
654
|
-
components: {
|
|
655
|
-
schemas: {
|
|
656
|
-
ChannelData: {
|
|
657
|
-
type: "object",
|
|
658
|
-
description: "ChannelData object. This is the bucket where the data is stored, in batches of 1 hour.",
|
|
659
|
-
properties: {
|
|
660
|
-
id: {
|
|
661
|
-
type: "string",
|
|
662
|
-
format: "ObjectId",
|
|
663
|
-
description: "MongoDB ObjectId",
|
|
664
|
-
example: "507f1f77bcf86cd799439011",
|
|
665
|
-
readOnly: true
|
|
666
|
-
},
|
|
667
|
-
start_date: {
|
|
668
|
-
type: "string",
|
|
669
|
-
format: "date-time",
|
|
670
|
-
description: "Start date of the data",
|
|
671
|
-
example: "2024-07-03T10:15:30Z",
|
|
672
|
-
readOnly: true
|
|
673
|
-
},
|
|
674
|
-
end_date: {
|
|
675
|
-
type: "string",
|
|
676
|
-
format: "date-time",
|
|
677
|
-
description: "End date of the data",
|
|
678
|
-
example: "2024-07-03T11:15:30Z",
|
|
679
|
-
readOnly: true
|
|
680
|
-
},
|
|
681
|
-
data: {
|
|
682
|
-
type: "array",
|
|
683
|
-
description: "Data array of DataPoint objects",
|
|
684
|
-
items: {
|
|
685
|
-
$ref: "#/components/schemas/DataPoint"
|
|
686
|
-
},
|
|
687
|
-
readOnly: false
|
|
688
|
-
},
|
|
689
|
-
size: {
|
|
690
|
-
type: "integer",
|
|
691
|
-
format: "int64",
|
|
692
|
-
description: "Size of the data array",
|
|
693
|
-
example: 60,
|
|
694
|
-
readOnly: true
|
|
695
|
-
},
|
|
696
|
-
synced: {
|
|
697
|
-
type: "TODO",
|
|
698
|
-
description: "TODO",
|
|
699
|
-
example: "TODO",
|
|
700
|
-
readOnly: true
|
|
701
|
-
},
|
|
702
|
-
sum: {
|
|
703
|
-
type: "number",
|
|
704
|
-
format: "double",
|
|
705
|
-
description: "Sum of the data",
|
|
706
|
-
example: 69.42,
|
|
707
|
-
readOnly: true
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
DataPoint: {
|
|
712
|
-
type: "object",
|
|
713
|
-
description: "DataPoint 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.",
|
|
714
|
-
properties: {
|
|
715
|
-
timestamp: {
|
|
716
|
-
type: "integer",
|
|
717
|
-
format: "int64",
|
|
718
|
-
description: "Timestamp of the data",
|
|
719
|
-
example: 1710251647e3,
|
|
720
|
-
readOnly: true
|
|
721
|
-
},
|
|
722
|
-
value: {
|
|
723
|
-
type: "number",
|
|
724
|
-
format: "double",
|
|
725
|
-
description: "Value of the data",
|
|
726
|
-
example: 69.42,
|
|
727
|
-
readOnly: true
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
},
|
|
732
|
-
examples: {
|
|
733
|
-
ChannelData: {
|
|
734
|
-
id: "507f1f77bcf86cd799439011",
|
|
735
|
-
start_date: "2024-07-03T10:15:30Z",
|
|
736
|
-
end_date: "2024-07-03T11:15:30Z",
|
|
737
|
-
data: [
|
|
738
|
-
{
|
|
739
|
-
timestamp: 1710251647e3,
|
|
740
|
-
value: 69.42
|
|
741
|
-
}
|
|
742
|
-
],
|
|
743
|
-
size: 60,
|
|
744
|
-
synced: "TODO",
|
|
745
|
-
sum: 69.42
|
|
746
|
-
},
|
|
747
|
-
DataPoint: {
|
|
748
|
-
timestamp: 1710251647e3,
|
|
749
|
-
value: 69.42
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
// app/models/docs/ChannelWithData.json
|
|
758
|
-
var require_ChannelWithData = __commonJS({
|
|
759
|
-
"app/models/docs/ChannelWithData.json"(exports2, module2) {
|
|
760
|
-
module2.exports = {
|
|
761
|
-
components: {
|
|
762
|
-
schemas: {
|
|
763
|
-
ChannelWithData: {
|
|
764
|
-
allOf: [
|
|
765
|
-
{
|
|
766
|
-
$ref: "#/components/schemas/Channel"
|
|
767
|
-
},
|
|
768
|
-
{
|
|
769
|
-
type: "object",
|
|
770
|
-
properties: {
|
|
771
|
-
channel_latest_value: {
|
|
772
|
-
type: "string",
|
|
773
|
-
description: "Latest value of the channel",
|
|
774
|
-
example: "25.0",
|
|
775
|
-
readOnly: true
|
|
776
|
-
},
|
|
777
|
-
channel_latest_timestamp: {
|
|
778
|
-
type: "string",
|
|
779
|
-
format: "date-time",
|
|
780
|
-
description: "Timestamp of the latest value",
|
|
781
|
-
example: 1700034034,
|
|
782
|
-
readOnly: true
|
|
783
|
-
},
|
|
784
|
-
channel_alarm_state: {
|
|
785
|
-
type: "string",
|
|
786
|
-
description: "Alarm state of the channel",
|
|
787
|
-
example: "NoAlarm",
|
|
788
|
-
readOnly: true
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
],
|
|
793
|
-
required: [
|
|
794
|
-
"channel_tag",
|
|
795
|
-
"channel_description",
|
|
796
|
-
"channel_type",
|
|
797
|
-
"channel_latest_value",
|
|
798
|
-
"channel_latest_timestamp",
|
|
799
|
-
"channel_alarm_state"
|
|
800
|
-
]
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
examples: {
|
|
804
|
-
ChannelWithData: {
|
|
805
|
-
value: {
|
|
806
|
-
id: "507f1f77bcf86cd799439011",
|
|
807
|
-
channel_tag: "MOTOR_PS_TEMP",
|
|
808
|
-
channel_description: "Motor Power Supply Temperature",
|
|
809
|
-
channel_type: "Analogic",
|
|
810
|
-
channel_latest_value: 420.69,
|
|
811
|
-
channel_latest_timestamp: 1700034034,
|
|
812
|
-
channel_alarm_state: "NoAlarm"
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
// app/models/docs/DataPoint.json
|
|
822
|
-
var require_DataPoint = __commonJS({
|
|
823
|
-
"app/models/docs/DataPoint.json"(exports2, module2) {
|
|
824
|
-
module2.exports = {
|
|
825
|
-
components: {
|
|
826
|
-
schemas: {
|
|
827
|
-
DataPoint: {
|
|
828
|
-
type: "object",
|
|
829
|
-
description: "DataPoint 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.",
|
|
830
|
-
properties: {
|
|
831
|
-
timestamp: {
|
|
832
|
-
type: "integer",
|
|
833
|
-
format: "int64",
|
|
834
|
-
description: "Timestamp of the data",
|
|
835
|
-
example: 1710251647e3,
|
|
836
|
-
readOnly: true
|
|
837
|
-
},
|
|
838
|
-
value: {
|
|
839
|
-
type: "number",
|
|
840
|
-
format: "double",
|
|
841
|
-
description: "Value of the data",
|
|
842
|
-
example: 69.42,
|
|
843
|
-
readOnly: true
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
},
|
|
848
|
-
examples: {
|
|
849
|
-
DataPoint: {
|
|
850
|
-
timestamp: 1710251647e3,
|
|
851
|
-
value: 69.42
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
// app/models/docs/Event.json
|
|
860
|
-
var require_Event2 = __commonJS({
|
|
861
|
-
"app/models/docs/Event.json"(exports2, module2) {
|
|
862
|
-
module2.exports = {
|
|
863
|
-
components: {
|
|
864
|
-
schemas: {
|
|
865
|
-
Event: {
|
|
866
|
-
type: "object",
|
|
867
|
-
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.",
|
|
868
|
-
properties: {
|
|
869
|
-
id: {
|
|
870
|
-
type: "string",
|
|
871
|
-
format: "ObjectId",
|
|
872
|
-
description: "MongoDB ObjectId",
|
|
873
|
-
example: "507f1f77bcf86cd799439011",
|
|
874
|
-
readOnly: true
|
|
875
|
-
},
|
|
876
|
-
event_message: {
|
|
877
|
-
type: "string",
|
|
878
|
-
format: "text",
|
|
879
|
-
description: "Event message",
|
|
880
|
-
example: "Event message"
|
|
881
|
-
},
|
|
882
|
-
event_source: {
|
|
883
|
-
type: "string",
|
|
884
|
-
format: "text",
|
|
885
|
-
description: "Hostname of the source of the event",
|
|
886
|
-
example: "RMS1"
|
|
887
|
-
},
|
|
888
|
-
event_category: {
|
|
889
|
-
type: "string",
|
|
890
|
-
format: "text",
|
|
891
|
-
description: "Event category",
|
|
892
|
-
example: "Login",
|
|
893
|
-
enum: "%%EVENT_CATEGORY_ENUM%%"
|
|
894
|
-
},
|
|
895
|
-
event_type: {
|
|
896
|
-
type: "string",
|
|
897
|
-
format: "text",
|
|
898
|
-
description: "Event type",
|
|
899
|
-
example: "Login"
|
|
900
|
-
},
|
|
901
|
-
event_timestamp: {
|
|
902
|
-
type: "number",
|
|
903
|
-
format: "timestamp",
|
|
904
|
-
description: "Event timestamp",
|
|
905
|
-
example: 1709899759
|
|
906
|
-
},
|
|
907
|
-
event_data: {
|
|
908
|
-
type: "object",
|
|
909
|
-
description: "Event data. Not validated, just stored"
|
|
910
|
-
}
|
|
911
|
-
},
|
|
912
|
-
required: [
|
|
913
|
-
"event_message",
|
|
914
|
-
"event_source",
|
|
915
|
-
"event_category",
|
|
916
|
-
"event_type",
|
|
917
|
-
"event_timestamp"
|
|
918
|
-
]
|
|
919
|
-
}
|
|
920
|
-
},
|
|
921
|
-
examples: {
|
|
922
|
-
Event: {
|
|
923
|
-
value: {
|
|
924
|
-
id: "507f1f77bcf86cd799439011",
|
|
925
|
-
event_message: "Profile Root logged in for the next 600 seconds, replacing profile Root.",
|
|
926
|
-
event_source: "RMS1",
|
|
927
|
-
event_category: "Login",
|
|
928
|
-
event_type: "LoiginSuccessful",
|
|
929
|
-
event_timestamp: 1709899759,
|
|
930
|
-
event_data: {
|
|
931
|
-
profile: "Root",
|
|
932
|
-
duration: 600,
|
|
933
|
-
replaced_profile: "Monitor"
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// app/models/docs/History.json
|
|
944
|
-
var require_History2 = __commonJS({
|
|
945
|
-
"app/models/docs/History.json"(exports2, module2) {
|
|
946
|
-
module2.exports = {
|
|
947
|
-
components: {
|
|
948
|
-
schemas: {
|
|
949
|
-
History: {
|
|
950
|
-
type: "object",
|
|
951
|
-
properties: {
|
|
952
|
-
id: {
|
|
953
|
-
type: "string",
|
|
954
|
-
format: "ObjectId",
|
|
955
|
-
description: "MongoDB ObjectId",
|
|
956
|
-
example: "507f1f77bcf86cd799439011",
|
|
957
|
-
readOnly: true
|
|
958
|
-
},
|
|
959
|
-
channel_tag: {
|
|
960
|
-
type: "string",
|
|
961
|
-
format: "text",
|
|
962
|
-
description: "Channel tag",
|
|
963
|
-
example: "Channel tag",
|
|
964
|
-
readOnly: true
|
|
965
|
-
},
|
|
966
|
-
alarm_timestamp: {
|
|
967
|
-
type: "string",
|
|
968
|
-
format: "date-time",
|
|
969
|
-
description: "Alarm timestamp",
|
|
970
|
-
example: "2020-12-31T23:59:59Z",
|
|
971
|
-
readOnly: true
|
|
972
|
-
},
|
|
973
|
-
alarm_priority: {
|
|
974
|
-
type: "string",
|
|
975
|
-
format: "text",
|
|
976
|
-
description: "Alarm priority",
|
|
977
|
-
example: "Alarm",
|
|
978
|
-
enum: "%%ALARM_PRIORITY_ENUM%%",
|
|
979
|
-
readOnly: true
|
|
980
|
-
},
|
|
981
|
-
alarm_original_state: {
|
|
982
|
-
type: "string",
|
|
983
|
-
format: "text",
|
|
984
|
-
description: "Alarm original state",
|
|
985
|
-
example: "Inactive",
|
|
986
|
-
enum: "%%DIAMAR_ALARM_STATE_ENUM%%",
|
|
987
|
-
readOnly: true
|
|
988
|
-
},
|
|
989
|
-
alarm_state: {
|
|
990
|
-
type: "string",
|
|
991
|
-
format: "text",
|
|
992
|
-
description: "Alarm new state",
|
|
993
|
-
example: "Inactive",
|
|
994
|
-
enum: "%%CLOUD_ALARM_STATE_ENUM%%",
|
|
995
|
-
readOnly: true
|
|
996
|
-
},
|
|
997
|
-
alarm_type: {
|
|
998
|
-
type: "string",
|
|
999
|
-
format: "text",
|
|
1000
|
-
description: "Alarm type",
|
|
1001
|
-
example: "AlarmOpen",
|
|
1002
|
-
enum: "%%ALARM_TYPE_ENUM%%",
|
|
1003
|
-
readOnly: true
|
|
1004
|
-
},
|
|
1005
|
-
alarm_value: {
|
|
1006
|
-
type: "number",
|
|
1007
|
-
format: "double",
|
|
1008
|
-
description: "Alarm value",
|
|
1009
|
-
example: 0,
|
|
1010
|
-
readOnly: true
|
|
1011
|
-
},
|
|
1012
|
-
alarm_message: {
|
|
1013
|
-
type: "string",
|
|
1014
|
-
format: "text",
|
|
1015
|
-
description: "Alarm message",
|
|
1016
|
-
example: "Alarm message",
|
|
1017
|
-
readOnly: true
|
|
1018
|
-
}
|
|
1019
|
-
},
|
|
1020
|
-
required: [
|
|
1021
|
-
"channel_tag",
|
|
1022
|
-
"alarm_timestamp",
|
|
1023
|
-
"alarm_priority",
|
|
1024
|
-
"alarm_original_state",
|
|
1025
|
-
"alarm_state",
|
|
1026
|
-
"alarm_type",
|
|
1027
|
-
"alarm_value",
|
|
1028
|
-
"alarm_message"
|
|
1029
|
-
]
|
|
1030
|
-
}
|
|
1031
|
-
},
|
|
1032
|
-
examples: {
|
|
1033
|
-
History: {
|
|
1034
|
-
value: {
|
|
1035
|
-
id: "507f1f77bcf86cd799439011",
|
|
1036
|
-
channel_tag: "Channel tag",
|
|
1037
|
-
alarm_timestamp: "2020-12-31T23:59:59Z",
|
|
1038
|
-
alarm_priority: "Alarm",
|
|
1039
|
-
alarm_original_state: "Inactive",
|
|
1040
|
-
alarm_state: "Inactive",
|
|
1041
|
-
alarm_type: "AlarmOpen",
|
|
1042
|
-
alarm_value: 0,
|
|
1043
|
-
alarm_message: "AlarmOpen Value: [OP]"
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
});
|
|
1051
|
-
|
|
1052
|
-
// app/models/docs/Unit.json
|
|
1053
|
-
var require_Unit2 = __commonJS({
|
|
1054
|
-
"app/models/docs/Unit.json"(exports2, module2) {
|
|
1055
|
-
module2.exports = {
|
|
1056
|
-
components: {
|
|
1057
|
-
schemas: {
|
|
1058
|
-
Unit: {
|
|
1059
|
-
type: "object",
|
|
1060
|
-
properties: {
|
|
1061
|
-
id: {
|
|
1062
|
-
type: "string",
|
|
1063
|
-
format: "ObjectId",
|
|
1064
|
-
description: "MongoDB ObjectId",
|
|
1065
|
-
example: "507f1f77bcf86cd799439011",
|
|
1066
|
-
readOnly: true
|
|
1067
|
-
},
|
|
1068
|
-
unit_id: {
|
|
1069
|
-
type: "string",
|
|
1070
|
-
description: "Unit identifier in Diamar",
|
|
1071
|
-
example: "127",
|
|
1072
|
-
readOnly: true
|
|
1073
|
-
},
|
|
1074
|
-
unit_internal_description: {
|
|
1075
|
-
type: "string",
|
|
1076
|
-
description: "Unit description",
|
|
1077
|
-
example: "Motor Power Supply",
|
|
1078
|
-
readOnly: true
|
|
1079
|
-
},
|
|
1080
|
-
unit_enabled: {
|
|
1081
|
-
type: "boolean",
|
|
1082
|
-
description: "Unit enabled",
|
|
1083
|
-
example: true,
|
|
1084
|
-
readOnly: true
|
|
1085
|
-
},
|
|
1086
|
-
unit_type: {
|
|
1087
|
-
type: "string",
|
|
1088
|
-
description: "Unit type",
|
|
1089
|
-
example: "DIM36",
|
|
1090
|
-
readOnly: true
|
|
1091
|
-
},
|
|
1092
|
-
unit_cabinet_id: {
|
|
1093
|
-
type: "string",
|
|
1094
|
-
description: "Cabinet identifier",
|
|
1095
|
-
example: "Cabinet 1",
|
|
1096
|
-
readOnly: true
|
|
1097
|
-
}
|
|
1098
|
-
},
|
|
1099
|
-
required: [
|
|
1100
|
-
"unit_id",
|
|
1101
|
-
"unit_internal_description",
|
|
1102
|
-
"unit_enabled",
|
|
1103
|
-
"unit_type",
|
|
1104
|
-
"unit_cabinet_id"
|
|
1105
|
-
]
|
|
1106
|
-
}
|
|
1107
|
-
},
|
|
1108
|
-
examples: {
|
|
1109
|
-
Unit: {
|
|
1110
|
-
value: {
|
|
1111
|
-
id: "507f1f77bcf86cd799439011",
|
|
1112
|
-
unit_id: "127",
|
|
1113
|
-
unit_internal_description: "Motor Power Supply",
|
|
1114
|
-
unit_enabled: true,
|
|
1115
|
-
unit_type: "DIM36",
|
|
1116
|
-
unit_cabinet_id: "Cabinet 1"
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
});
|
|
1124
|
-
|
|
1125
|
-
// app/models/docs/index.cjs
|
|
1126
|
-
var require_docs = __commonJS({
|
|
1127
|
-
"app/models/docs/index.cjs"(exports2, module2) {
|
|
1128
|
-
"use strict";
|
|
1129
|
-
var { AlarmTypes: AlarmTypes3, AlarmPriorities: AlarmPriorities3, CloudAlarmStates: CloudAlarmStates3, DiamarAlarmStates: DiamarAlarmStates3 } = (init_alarm_types(), __toCommonJS(alarm_types_exports));
|
|
1130
|
-
var { EventCategories: EventCategories3 } = (init_event_types(), __toCommonJS(event_types_exports));
|
|
1131
|
-
var ChannelDocs = require_Channel2();
|
|
1132
|
-
var ChannelDataBucketDocs = require_ChannelDataBucket2();
|
|
1133
|
-
var ChannelWithDataDocs = require_ChannelWithData();
|
|
1134
|
-
var DataPointDocs = require_DataPoint();
|
|
1135
|
-
var EventDocs = require_Event2();
|
|
1136
|
-
var HistoryDocs = require_History2();
|
|
1137
|
-
var UnitDocs = require_Unit2();
|
|
1138
|
-
HistoryDocs.components.schemas.History.properties.alarm_priority.enum = Object.values(AlarmPriorities3);
|
|
1139
|
-
HistoryDocs.components.schemas.History.properties.alarm_state.enum = Object.values(CloudAlarmStates3);
|
|
1140
|
-
HistoryDocs.components.schemas.History.properties.alarm_original_state.enum = Object.values(DiamarAlarmStates3);
|
|
1141
|
-
HistoryDocs.components.schemas.History.properties.alarm_type.enum = Object.values(AlarmTypes3);
|
|
1142
|
-
EventDocs.components.schemas.Event.properties.event_category.enum = Object.values(EventCategories3);
|
|
1143
|
-
var Docs2 = {
|
|
1144
|
-
ChannelDocs,
|
|
1145
|
-
ChannelDataBucketDocs,
|
|
1146
|
-
ChannelWithDataDocs,
|
|
1147
|
-
DataPointDocs,
|
|
1148
|
-
EventDocs,
|
|
1149
|
-
HistoryDocs,
|
|
1150
|
-
UnitDocs
|
|
1151
|
-
};
|
|
1152
|
-
module2.exports = Docs2;
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
// app/node-entry.cjs
|
|
1157
|
-
var Channel = require_Channel();
|
|
1158
|
-
var ChannelDataBucket = require_ChannelDataBucket();
|
|
1159
|
-
var Event = require_Event();
|
|
1160
|
-
var History = require_History();
|
|
1161
|
-
var Unit = require_Unit();
|
|
1162
|
-
var Schemas = {
|
|
1163
|
-
Channel,
|
|
1164
|
-
ChannelDataBucket,
|
|
1165
|
-
Event,
|
|
1166
|
-
History,
|
|
1167
|
-
Unit
|
|
1168
|
-
};
|
|
1169
|
-
var Docs = require_docs();
|
|
1170
|
-
var { AlarmTypes: AlarmTypes2, AlarmPriorities: AlarmPriorities2, CloudAlarmStates: CloudAlarmStates2, DiamarAlarmStates: DiamarAlarmStates2 } = (init_alarm_types(), __toCommonJS(alarm_types_exports));
|
|
1171
|
-
var { EventCategories: EventCategories2 } = (init_event_types(), __toCommonJS(event_types_exports));
|
|
1172
|
-
var Types = {
|
|
1173
|
-
AlarmTypes: AlarmTypes2,
|
|
1174
|
-
AlarmPriorities: AlarmPriorities2,
|
|
1175
|
-
CloudAlarmStates: CloudAlarmStates2,
|
|
1176
|
-
DiamarAlarmStates: DiamarAlarmStates2,
|
|
1177
|
-
EventCategories: EventCategories2
|
|
1178
|
-
};
|
|
1179
|
-
var mongoose = require("mongoose");
|
|
1180
|
-
var mongooseAutopopulate = require("mongoose-autopopulate");
|
|
1181
|
-
var mongoosePaginate = require("mongoose-paginate-v2");
|
|
1182
|
-
var mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
1183
|
-
module.exports = {
|
|
1184
|
-
Schemas,
|
|
1185
|
-
Docs,
|
|
1186
|
-
Types,
|
|
1187
|
-
mongoose,
|
|
1188
|
-
mongoosePaginate,
|
|
1189
|
-
mongooseAggregatePaginate,
|
|
1190
|
-
mongooseAutopopulate
|
|
1191
|
-
};
|