@sedni/cloud_common 1.0.1 → 1.0.2
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/app/models/Channel.js +8 -2
- package/app/models/ChannelDataBucket.js +6 -4
- package/app/models/Event.js +18 -8
- package/app/models/History.js +15 -20
- package/app/models/Unit.js +2 -0
- package/app/models/docs/Channel.json +56 -1
- package/app/models/docs/ChannelDataBucket.json +99 -1
- package/app/models/docs/ChannelWithData.json +58 -0
- package/app/models/docs/DataPoint.json +32 -0
- package/app/models/docs/Event.json +76 -1
- package/app/models/docs/History.json +101 -1
- package/app/models/docs/Unit.json +65 -1
- package/app/types/alarm.types.js +1 -0
- package/eslint.config.js +1 -1
- package/package.json +4 -3
package/app/models/Channel.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
+
const mongooseAutopopulate = require("mongoose-autopopulate");
|
|
2
3
|
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
3
4
|
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
4
5
|
|
|
@@ -15,8 +16,10 @@ const channelSchema = new mongoose.Schema({
|
|
|
15
16
|
index: true,
|
|
16
17
|
},
|
|
17
18
|
channel_unit_id: {
|
|
18
|
-
type:
|
|
19
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
+
ref: "Unit",
|
|
19
21
|
required: true,
|
|
22
|
+
autopopulate: true,
|
|
20
23
|
},
|
|
21
24
|
channel_parsed : {
|
|
22
25
|
type: Object,
|
|
@@ -24,7 +27,7 @@ const channelSchema = new mongoose.Schema({
|
|
|
24
27
|
},
|
|
25
28
|
channel_last_bucket_sync: {
|
|
26
29
|
type: Date,
|
|
27
|
-
required:
|
|
30
|
+
required: false,
|
|
28
31
|
},
|
|
29
32
|
}, {
|
|
30
33
|
timestamps: {
|
|
@@ -36,6 +39,8 @@ const channelSchema = new mongoose.Schema({
|
|
|
36
39
|
transform: function (doc, ret)
|
|
37
40
|
{
|
|
38
41
|
ret.id = ret._id;
|
|
42
|
+
ret.channel_unit = ret.channel_unit_id;
|
|
43
|
+
ret.channel_unit_id = ret.channel_unit_id.unit_id;
|
|
39
44
|
delete ret._id;
|
|
40
45
|
delete ret.__v;
|
|
41
46
|
},
|
|
@@ -66,5 +71,6 @@ channelSchema.index({ "unit_internal_description" : 1 });
|
|
|
66
71
|
*/
|
|
67
72
|
channelSchema.plugin(mongoosePaginate);
|
|
68
73
|
channelSchema.plugin(mongooseAggregatePaginate);
|
|
74
|
+
channelSchema.plugin(mongooseAutopopulate);
|
|
69
75
|
|
|
70
76
|
module.exports = channelSchema;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const mongooseAutopopulate = require("mongoose-autopopulate");
|
|
3
|
+
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
4
|
+
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
4
5
|
|
|
5
6
|
const channeldataBucketSchema = new mongoose.Schema({
|
|
6
7
|
start_date: {
|
|
@@ -73,8 +74,9 @@ channeldataBucketSchema.index({ start_date: 1, end_date: 1 });
|
|
|
73
74
|
* ///////////// PLUGINS /////////////////
|
|
74
75
|
* ///////////////////////////////////////////////
|
|
75
76
|
*/
|
|
76
|
-
channeldataBucketSchema.plugin(
|
|
77
|
-
channeldataBucketSchema.plugin(
|
|
77
|
+
channeldataBucketSchema.plugin(mongoosePaginate);
|
|
78
|
+
channeldataBucketSchema.plugin(mongooseAggregatePaginate);
|
|
79
|
+
channeldataBucketSchema.plugin(mongooseAutopopulate);
|
|
78
80
|
|
|
79
81
|
|
|
80
82
|
/**
|
package/app/models/Event.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const mongooseAutopopulate = require("mongoose-autopopulate");
|
|
3
|
+
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
4
|
+
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
4
5
|
const { EventCategories } = require("../types/event.types");
|
|
5
6
|
|
|
6
7
|
const eventSchema = new mongoose.Schema({
|
|
@@ -12,6 +13,10 @@ const eventSchema = new mongoose.Schema({
|
|
|
12
13
|
type: String,
|
|
13
14
|
required: true
|
|
14
15
|
},
|
|
16
|
+
event_user: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
15
20
|
event_category: {
|
|
16
21
|
type: String,
|
|
17
22
|
required: true,
|
|
@@ -57,22 +62,27 @@ const eventSchema = new mongoose.Schema({
|
|
|
57
62
|
*/
|
|
58
63
|
|
|
59
64
|
/**
|
|
60
|
-
* Index used primarily for filtering by
|
|
65
|
+
* Index used primarily for filtering by timestamp
|
|
61
66
|
*/
|
|
62
|
-
eventSchema.index({ "
|
|
67
|
+
eventSchema.index({ "event_timestamp" : 1 });
|
|
63
68
|
|
|
64
69
|
/**
|
|
65
|
-
* Index used primarily for filtering by
|
|
70
|
+
* Index used primarily for filtering by event_type
|
|
66
71
|
*/
|
|
67
|
-
eventSchema.index({ "
|
|
72
|
+
eventSchema.index({ "event_type" : 1 });
|
|
68
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Index used primarily for filtering by event_category
|
|
76
|
+
*/
|
|
77
|
+
eventSchema.index({ "event_category" : 1 });
|
|
69
78
|
|
|
70
79
|
/**
|
|
71
80
|
* ///////////////////////////////////////////////
|
|
72
81
|
* ///////////// PLUGINS /////////////////
|
|
73
82
|
* ///////////////////////////////////////////////
|
|
74
83
|
*/
|
|
75
|
-
eventSchema.plugin(
|
|
76
|
-
eventSchema.plugin(
|
|
84
|
+
eventSchema.plugin(mongoosePaginate);
|
|
85
|
+
eventSchema.plugin(mongooseAggregatePaginate);
|
|
86
|
+
eventSchema.plugin(mongooseAutopopulate);
|
|
77
87
|
|
|
78
88
|
module.exports = eventSchema;
|
package/app/models/History.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const mongooseAutopopulate = require("mongoose-autopopulate");
|
|
3
|
+
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
4
|
+
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
4
5
|
const { AlarmTypes, AlarmPriorities, CloudAlarmStates, DiamarAlarmStates } = require("../types/alarm.types");
|
|
5
6
|
|
|
6
7
|
const historySchema = new mongoose.Schema({
|
|
7
|
-
timestamp: {
|
|
8
|
-
type: Date,
|
|
9
|
-
required: true,
|
|
10
|
-
default: Date.now,
|
|
11
|
-
},
|
|
12
8
|
channel_tag: {
|
|
13
9
|
type: String,
|
|
14
10
|
required: true,
|
|
15
11
|
},
|
|
12
|
+
alarm_timestamp: {
|
|
13
|
+
type: Date,
|
|
14
|
+
required: true,
|
|
15
|
+
default: Date.now,
|
|
16
|
+
},
|
|
16
17
|
alarm_priority: {
|
|
17
18
|
type: String,
|
|
18
19
|
required: true,
|
|
19
20
|
enum: Object.values(AlarmPriorities),
|
|
20
21
|
},
|
|
21
|
-
|
|
22
|
+
alarm_original_state: {
|
|
22
23
|
type: String,
|
|
23
24
|
required: true,
|
|
24
25
|
enum: Object.values(DiamarAlarmStates),
|
|
@@ -41,9 +42,6 @@ const historySchema = new mongoose.Schema({
|
|
|
41
42
|
type: String,
|
|
42
43
|
required: false,
|
|
43
44
|
},
|
|
44
|
-
metadata: {
|
|
45
|
-
type: Object,
|
|
46
|
-
}
|
|
47
45
|
}, {
|
|
48
46
|
timestamps: {
|
|
49
47
|
createdAt: false,
|
|
@@ -57,17 +55,14 @@ const historySchema = new mongoose.Schema({
|
|
|
57
55
|
ret.id = ret._id;
|
|
58
56
|
delete ret._id;
|
|
59
57
|
delete ret.__v;
|
|
58
|
+
ret.alarm_timestamp = ret.alarm_timestamp.getTime();
|
|
60
59
|
ret.alarm = {
|
|
61
60
|
priority: ret.alarm_priority,
|
|
62
|
-
state: ret.
|
|
61
|
+
state: ret.alarm_original_state ?? "Inactive",
|
|
63
62
|
type: ret.alarm_type,
|
|
64
63
|
value: ret.alarm_value === null ? "inf" : `${ret.alarm_value}`,
|
|
65
|
-
timestamp: new Date(ret.
|
|
64
|
+
timestamp: new Date(ret.alarm_timestamp).getTime()
|
|
66
65
|
};
|
|
67
|
-
delete ret.alarm_priority;
|
|
68
|
-
delete ret.alarm_state;
|
|
69
|
-
delete ret.alarm_type;
|
|
70
|
-
delete ret.alarm_value;
|
|
71
66
|
},
|
|
72
67
|
},
|
|
73
68
|
});
|
|
@@ -94,8 +89,8 @@ historySchema.index({ "timestamp" : 1 });
|
|
|
94
89
|
* ///////////// PLUGINS /////////////////
|
|
95
90
|
* ///////////////////////////////////////////////
|
|
96
91
|
*/
|
|
97
|
-
historySchema.plugin(
|
|
98
|
-
historySchema.plugin(
|
|
99
|
-
|
|
92
|
+
historySchema.plugin(mongoosePaginate);
|
|
93
|
+
historySchema.plugin(mongooseAggregatePaginate);
|
|
94
|
+
historySchema.plugin(mongooseAutopopulate);
|
|
100
95
|
|
|
101
96
|
module.exports = historySchema;
|
package/app/models/Unit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
|
+
const mongooseAutopopulate = require("mongoose-autopopulate");
|
|
2
3
|
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
3
4
|
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
4
5
|
|
|
@@ -61,5 +62,6 @@ unitSchema.index({ "unit_internal_description" : 1 });
|
|
|
61
62
|
*/
|
|
62
63
|
unitSchema.plugin(mongoosePaginate);
|
|
63
64
|
unitSchema.plugin(mongooseAggregatePaginate);
|
|
65
|
+
unitSchema.plugin(mongooseAutopopulate);
|
|
64
66
|
|
|
65
67
|
module.exports = unitSchema;
|
|
@@ -1,3 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"Channel": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"format": "ObjectId",
|
|
10
|
+
"description": "MongoDB ObjectId",
|
|
11
|
+
"example": "507f1f77bcf86cd799439011",
|
|
12
|
+
"readOnly": true
|
|
13
|
+
},
|
|
14
|
+
"channel_tag": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Channel tag",
|
|
17
|
+
"example": "MOTOR_PS_TEMP",
|
|
18
|
+
"readOnly": true
|
|
19
|
+
},
|
|
20
|
+
"channel_description": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Channel description",
|
|
23
|
+
"example": "Motor Power Supply Temperature",
|
|
24
|
+
"readOnly": true
|
|
25
|
+
},
|
|
26
|
+
"channel_unit_id" : {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"format": "ObjectId",
|
|
29
|
+
"description": "Unit of the channel",
|
|
30
|
+
"example": "507f1f77bcf86cd799439011",
|
|
31
|
+
"readOnly": true
|
|
32
|
+
},
|
|
33
|
+
"channel_parsed": {
|
|
34
|
+
"type" : "object",
|
|
35
|
+
"description": "Parsed channel data",
|
|
36
|
+
"readOnly": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": [
|
|
40
|
+
"channel_tag",
|
|
41
|
+
"channel_description",
|
|
42
|
+
"channel_unit_id",
|
|
43
|
+
"channel_parsed"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"examples": {
|
|
48
|
+
"Channel": {
|
|
49
|
+
"value": {
|
|
50
|
+
"id": "507f1f77bcf86cd799439011",
|
|
51
|
+
"channel_tag": "MOTOR_PS_TEMP",
|
|
52
|
+
"channel_description": "Motor Power Supply Temperature",
|
|
53
|
+
"channel_type": "Analogic"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
3
58
|
}
|
|
@@ -1,3 +1,101 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"ChannelData": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"description": "ChannelData object. This is the bucket where the data is stored, in batches of 1 hour.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"format": "ObjectId",
|
|
11
|
+
"description": "MongoDB ObjectId",
|
|
12
|
+
"example": "507f1f77bcf86cd799439011",
|
|
13
|
+
"readOnly": true
|
|
14
|
+
},
|
|
15
|
+
"start_date": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "date-time",
|
|
18
|
+
"description": "Start date of the data",
|
|
19
|
+
"example": "2024-07-03T10:15:30Z",
|
|
20
|
+
"readOnly": true
|
|
21
|
+
},
|
|
22
|
+
"end_date": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "date-time",
|
|
25
|
+
"description": "End date of the data",
|
|
26
|
+
"example": "2024-07-03T11:15:30Z",
|
|
27
|
+
"readOnly": true
|
|
28
|
+
},
|
|
29
|
+
"data": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"description": "Data array of DataPoint objects",
|
|
32
|
+
"items": {
|
|
33
|
+
"$ref": "#/components/schemas/DataPoint"
|
|
34
|
+
},
|
|
35
|
+
"readOnly": false
|
|
36
|
+
},
|
|
37
|
+
"size" : {
|
|
38
|
+
"type" : "integer",
|
|
39
|
+
"format" : "int64",
|
|
40
|
+
"description" : "Size of the data array",
|
|
41
|
+
"example" : 60,
|
|
42
|
+
"readOnly": true
|
|
43
|
+
},
|
|
44
|
+
"synced" : {
|
|
45
|
+
"type" : "TODO",
|
|
46
|
+
"description" : "TODO",
|
|
47
|
+
"example" : "TODO",
|
|
48
|
+
"readOnly": true
|
|
49
|
+
},
|
|
50
|
+
"sum" : {
|
|
51
|
+
"type" : "number",
|
|
52
|
+
"format" : "double",
|
|
53
|
+
"description" : "Sum of the data",
|
|
54
|
+
"example" : 69.420,
|
|
55
|
+
"readOnly": true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"DataPoint" : {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"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.",
|
|
62
|
+
"properties": {
|
|
63
|
+
"timestamp" : {
|
|
64
|
+
"type" : "integer",
|
|
65
|
+
"format" : "int64",
|
|
66
|
+
"description" : "Timestamp of the data",
|
|
67
|
+
"example" : 1710251647000,
|
|
68
|
+
"readOnly": true
|
|
69
|
+
},
|
|
70
|
+
"value" : {
|
|
71
|
+
"type" : "number",
|
|
72
|
+
"format" : "double",
|
|
73
|
+
"description" : "Value of the data",
|
|
74
|
+
"example" : 69.420,
|
|
75
|
+
"readOnly": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"examples" : {
|
|
81
|
+
"ChannelData": {
|
|
82
|
+
"id" : "507f1f77bcf86cd799439011",
|
|
83
|
+
"start_date" : "2024-07-03T10:15:30Z",
|
|
84
|
+
"end_date" : "2024-07-03T11:15:30Z",
|
|
85
|
+
"data" : [
|
|
86
|
+
{
|
|
87
|
+
"timestamp" : 1710251647000,
|
|
88
|
+
"value" : 69.420
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"size" : 60,
|
|
92
|
+
"synced" : "TODO",
|
|
93
|
+
"sum" : 69.420
|
|
94
|
+
},
|
|
95
|
+
"DataPoint" : {
|
|
96
|
+
"timestamp" : 1710251647000,
|
|
97
|
+
"value" : 69.420
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
3
101
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"ChannelWithData": {
|
|
5
|
+
"allOf": [
|
|
6
|
+
{
|
|
7
|
+
"$ref": "#/components/schemas/Channel"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"channel_latest_value": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "Latest value of the channel",
|
|
15
|
+
"example": "25.0",
|
|
16
|
+
"readOnly": true
|
|
17
|
+
},
|
|
18
|
+
"channel_latest_timestamp": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"format": "date-time",
|
|
21
|
+
"description": "Timestamp of the latest value",
|
|
22
|
+
"example": 1700034034,
|
|
23
|
+
"readOnly": true
|
|
24
|
+
},
|
|
25
|
+
"channel_alarm_state": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Alarm state of the channel",
|
|
28
|
+
"example": "NoAlarm",
|
|
29
|
+
"readOnly": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"required": [
|
|
35
|
+
"channel_tag",
|
|
36
|
+
"channel_description",
|
|
37
|
+
"channel_type",
|
|
38
|
+
"channel_latest_value",
|
|
39
|
+
"channel_latest_timestamp",
|
|
40
|
+
"channel_alarm_state"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"examples": {
|
|
45
|
+
"ChannelWithData": {
|
|
46
|
+
"value": {
|
|
47
|
+
"id": "507f1f77bcf86cd799439011",
|
|
48
|
+
"channel_tag": "MOTOR_PS_TEMP",
|
|
49
|
+
"channel_description": "Motor Power Supply Temperature",
|
|
50
|
+
"channel_type": "Analogic",
|
|
51
|
+
"channel_latest_value": 420.69,
|
|
52
|
+
"channel_latest_timestamp": 1700034034,
|
|
53
|
+
"channel_alarm_state": "NoAlarm"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"DataPoint" : {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"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.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"timestamp" : {
|
|
9
|
+
"type" : "integer",
|
|
10
|
+
"format" : "int64",
|
|
11
|
+
"description" : "Timestamp of the data",
|
|
12
|
+
"example" : 1710251647000,
|
|
13
|
+
"readOnly": true
|
|
14
|
+
},
|
|
15
|
+
"value" : {
|
|
16
|
+
"type" : "number",
|
|
17
|
+
"format" : "double",
|
|
18
|
+
"description" : "Value of the data",
|
|
19
|
+
"example" : 69.420,
|
|
20
|
+
"readOnly": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"examples" : {
|
|
26
|
+
"DataPoint" : {
|
|
27
|
+
"timestamp" : 1710251647000,
|
|
28
|
+
"value" : 69.420
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,3 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"Event": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"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.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"format": "ObjectId",
|
|
11
|
+
"description": "MongoDB ObjectId",
|
|
12
|
+
"example": "507f1f77bcf86cd799439011",
|
|
13
|
+
"readOnly": true
|
|
14
|
+
},
|
|
15
|
+
"event_message": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"format": "text",
|
|
18
|
+
"description": "Event message",
|
|
19
|
+
"example": "Event message"
|
|
20
|
+
},
|
|
21
|
+
"event_source": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"format": "text",
|
|
24
|
+
"description": "Hostname of the source of the event",
|
|
25
|
+
"example": "RMS1"
|
|
26
|
+
},
|
|
27
|
+
"event_category": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "text",
|
|
30
|
+
"description": "Event category",
|
|
31
|
+
"example": "Login",
|
|
32
|
+
"enum": ["Login", "Backup", "Config", "Control"]
|
|
33
|
+
},
|
|
34
|
+
"event_type": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"format": "text",
|
|
37
|
+
"description": "Event type",
|
|
38
|
+
"example": "Login"
|
|
39
|
+
},
|
|
40
|
+
"event_timestamp": {
|
|
41
|
+
"type": "number",
|
|
42
|
+
"format": "timestamp",
|
|
43
|
+
"description": "Event timestamp",
|
|
44
|
+
"example": 1709899759
|
|
45
|
+
},
|
|
46
|
+
"event_data" : {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"description": "Event data. Not validated, just stored"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"required": [
|
|
52
|
+
"event_message",
|
|
53
|
+
"event_source",
|
|
54
|
+
"event_category",
|
|
55
|
+
"event_type",
|
|
56
|
+
"event_timestamp"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"examples" : {
|
|
61
|
+
"Event" : {
|
|
62
|
+
"value" : {
|
|
63
|
+
"id": "507f1f77bcf86cd799439011",
|
|
64
|
+
"event_message": "Profile Root logged in for the next 600 seconds, replacing profile Root.",
|
|
65
|
+
"event_source": "RMS1",
|
|
66
|
+
"event_category": "Login",
|
|
67
|
+
"event_type": "LoiginSuccessful",
|
|
68
|
+
"event_timestamp": 1709899759,
|
|
69
|
+
"event_data" : {
|
|
70
|
+
"profile": "Root",
|
|
71
|
+
"duration": 600,
|
|
72
|
+
"replaced_profile": "Monitor"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
3
78
|
}
|
|
@@ -1,3 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"History": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"format": "ObjectId",
|
|
10
|
+
"description": "MongoDB ObjectId",
|
|
11
|
+
"example": "507f1f77bcf86cd799439011",
|
|
12
|
+
"readOnly": true
|
|
13
|
+
},
|
|
14
|
+
"channel_tag": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"format": "text",
|
|
17
|
+
"description": "Channel tag",
|
|
18
|
+
"example": "Channel tag",
|
|
19
|
+
"readOnly": true
|
|
20
|
+
},
|
|
21
|
+
"alarm_timestamp": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"format": "date-time",
|
|
24
|
+
"description": "Alarm timestamp",
|
|
25
|
+
"example": "2020-12-31T23:59:59Z",
|
|
26
|
+
"readOnly": true
|
|
27
|
+
},
|
|
28
|
+
"alarm_priority": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"format": "text",
|
|
31
|
+
"description": "Alarm priority",
|
|
32
|
+
"example": "Alarm",
|
|
33
|
+
"enum": "%%ALARM_PRIORITY_ENUM%%",
|
|
34
|
+
"readOnly": true
|
|
35
|
+
},
|
|
36
|
+
"alarm_original_state" : {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"format": "text",
|
|
39
|
+
"description": "Alarm original state",
|
|
40
|
+
"example": "Inactive",
|
|
41
|
+
"enum": "%%DIAMAR_ALARM_STATE_ENUM%%",
|
|
42
|
+
"readOnly": true
|
|
43
|
+
},
|
|
44
|
+
"alarm_state" : {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"format": "text",
|
|
47
|
+
"description": "Alarm new state",
|
|
48
|
+
"example": "Inactive",
|
|
49
|
+
"enum": "%%CLOUD_ALARM_STATE_ENUM%%",
|
|
50
|
+
"readOnly": true
|
|
51
|
+
},
|
|
52
|
+
"alarm_type": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"format": "text",
|
|
55
|
+
"description": "Alarm type",
|
|
56
|
+
"example" : "AlarmOpen",
|
|
57
|
+
"enum": "%%ALARM_TYPE_ENUM%%",
|
|
58
|
+
"readOnly": true
|
|
59
|
+
},
|
|
60
|
+
"alarm_value": {
|
|
61
|
+
"type": "number",
|
|
62
|
+
"format": "double",
|
|
63
|
+
"description": "Alarm value",
|
|
64
|
+
"example": 0.0,
|
|
65
|
+
"readOnly": true
|
|
66
|
+
},
|
|
67
|
+
"alarm_message": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"format": "text",
|
|
70
|
+
"description": "Alarm message",
|
|
71
|
+
"example": "Alarm message",
|
|
72
|
+
"readOnly": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"required": [
|
|
76
|
+
"channel_tag",
|
|
77
|
+
"alarm_timestamp",
|
|
78
|
+
"alarm_priority",
|
|
79
|
+
"alarm_original_state",
|
|
80
|
+
"alarm_state",
|
|
81
|
+
"alarm_type",
|
|
82
|
+
"alarm_value",
|
|
83
|
+
"alarm_message"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"examples" : {
|
|
88
|
+
"History": {
|
|
89
|
+
"value": {
|
|
90
|
+
"id": "507f1f77bcf86cd799439011",
|
|
91
|
+
"channel_tag": "Channel tag",
|
|
92
|
+
"alarm_timestamp": "2020-12-31T23:59:59Z",
|
|
93
|
+
"alarm_priority": "Alarm",
|
|
94
|
+
"alarm_original_state": "Inactive",
|
|
95
|
+
"alarm_state": "Inactive",
|
|
96
|
+
"alarm_type": "AlarmOpen",
|
|
97
|
+
"alarm_value": 0.0,
|
|
98
|
+
"alarm_message": "AlarmOpen Value: [OP]"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
3
103
|
}
|
|
@@ -1,3 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"Unit": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"format": "ObjectId",
|
|
10
|
+
"description": "MongoDB ObjectId",
|
|
11
|
+
"example": "507f1f77bcf86cd799439011",
|
|
12
|
+
"readOnly": true
|
|
13
|
+
},
|
|
14
|
+
"unit_id": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "Unit identifier in Diamar",
|
|
17
|
+
"example": "127",
|
|
18
|
+
"readOnly": true
|
|
19
|
+
},
|
|
20
|
+
"unit_internal_description": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Unit description",
|
|
23
|
+
"example": "Motor Power Supply",
|
|
24
|
+
"readOnly": true
|
|
25
|
+
},
|
|
26
|
+
"unit_enabled" : {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Unit enabled",
|
|
29
|
+
"example": true,
|
|
30
|
+
"readOnly": true
|
|
31
|
+
},
|
|
32
|
+
"unit_type" : {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Unit type",
|
|
35
|
+
"example": "DIM36",
|
|
36
|
+
"readOnly": true
|
|
37
|
+
},
|
|
38
|
+
"unit_cabinet_id" : {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Cabinet identifier",
|
|
41
|
+
"example": "Cabinet 1",
|
|
42
|
+
"readOnly": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"required": [
|
|
46
|
+
"unit_id",
|
|
47
|
+
"unit_internal_description",
|
|
48
|
+
"unit_enabled",
|
|
49
|
+
"unit_type",
|
|
50
|
+
"unit_cabinet_id"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"examples": {
|
|
55
|
+
"Unit": {
|
|
56
|
+
"value": {
|
|
57
|
+
"id": "507f1f77bcf86cd799439011",
|
|
58
|
+
"unit_id": "127",
|
|
59
|
+
"unit_internal_description": "Motor Power Supply",
|
|
60
|
+
"unit_enabled": true,
|
|
61
|
+
"unit_type": "DIM36",
|
|
62
|
+
"unit_cabinet_id": "Cabinet 1"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
3
67
|
}
|
package/app/types/alarm.types.js
CHANGED
package/eslint.config.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = [
|
|
|
6
6
|
pluginJs.configs.recommended,
|
|
7
7
|
nodePlugin.configs["flat/recommended-script"],
|
|
8
8
|
{
|
|
9
|
-
files: ["app/**/*.js", "
|
|
9
|
+
files: ["app/**/*.js", "index.js"],
|
|
10
10
|
languageOptions: {
|
|
11
11
|
"ecmaVersion": "latest",
|
|
12
12
|
"sourceType": "commonjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sedni/cloud_common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Common package for all types, resources and tools of Diamar Cloud",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"mongoose": "^8.7.1",
|
|
16
16
|
"mongoose-aggregate-paginate-v2": "^1.1.2",
|
|
17
|
+
"mongoose-autopopulate": "^1.1.0",
|
|
17
18
|
"mongoose-paginate-v2": "^1.8.5"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"chai": "^5.1.1",
|
|
21
21
|
"@eslint/js": "^9.12.0",
|
|
22
|
+
"chai": "^5.1.1",
|
|
22
23
|
"eslint": "^9.12.0",
|
|
23
24
|
"eslint-plugin-n": "^17.11.0",
|
|
24
25
|
"globals": "^15.11.0",
|
|
@@ -26,4 +27,4 @@
|
|
|
26
27
|
"nyc": "^17.0.0",
|
|
27
28
|
"supertest": "^7.0.0"
|
|
28
29
|
}
|
|
29
|
-
}
|
|
30
|
+
}
|