@sedni/cloud_common 3.0.3 → 3.0.5
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/.idea/cloud_common.iml +8 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/shelf/Changes/shelved.patch +30 -0
- package/.idea/shelf/Changes.xml +4 -0
- package/.idea/shelf/Changes1/shelved.patch +229 -0
- package/.idea/shelf/Changes1.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_16_2_26,_10_07_[Changes]/shelved.patch +229 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_16_2_26,_10_20_[Changes]/shelved.patch +23 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_16_2_26__10_07__Changes_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_16_2_26__10_20__Changes_.xml +4 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +245 -0
- package/dist/browser-index.cjs +32 -5
- package/dist/browser-index.d.cts +38 -17
- package/dist/browser-index.d.ts +38 -17
- package/dist/browser-index.js +7 -1
- package/dist/chunk-72OOHARB.js +1442 -0
- package/dist/{chunk-VQWCQ4E2.js → chunk-XZJXANPO.js} +539 -2
- package/dist/index.cjs +44 -15
- package/dist/index.d.cts +45 -24
- package/dist/index.d.ts +45 -24
- package/dist/index.js +13 -7
- package/dist/models/Channel.d.ts +53 -0
- package/dist/models/Channel.js +65 -0
- package/dist/models/ChannelDataBucket.d.ts +81 -0
- package/dist/models/ChannelDataBucket.js +93 -0
- package/dist/models/ChannelDataPoint.d.ts +21 -0
- package/dist/models/ChannelDataPoint.js +75 -0
- package/dist/models/Event.d.ts +28 -0
- package/dist/models/Event.js +84 -0
- package/dist/models/History.d.ts +30 -0
- package/dist/models/History.js +96 -0
- package/dist/models/Unit.d.ts +50 -0
- package/dist/models/Unit.js +58 -0
- package/dist/models/docs/Channel.json +58 -0
- package/dist/models/docs/ChannelDataBucket.json +77 -0
- package/dist/models/docs/ChannelDataPoint.json +39 -0
- package/dist/models/docs/ChannelWithData.json +58 -0
- package/dist/models/docs/Event.json +78 -0
- package/dist/models/docs/History.json +103 -0
- package/dist/models/docs/Unit.json +67 -0
- package/dist/models/docs/index.d.ts +448 -0
- package/dist/models/docs/index.js +27 -0
- package/dist/models/mimics/AuxiliaryElements.d.ts +39 -0
- package/dist/models/mimics/AuxiliaryElements.js +33 -0
- package/dist/models/mimics/ChannelMimic.d.ts +9 -0
- package/dist/models/mimics/ChannelMimic.js +8 -0
- package/dist/models/mimics/ControlElements.d.ts +123 -0
- package/dist/models/mimics/ControlElements.js +114 -0
- package/dist/models/mimics/Elements.d.ts +109 -0
- package/dist/models/mimics/Elements.js +99 -0
- package/dist/models/mimics/IasElements.d.ts +25 -0
- package/dist/models/mimics/IasElements.js +21 -0
- package/dist/models/mimics/MimicSupport.d.ts +77 -0
- package/dist/models/mimics/MimicSupport.js +59 -0
- package/dist/models/mimics/MimicTraits.d.ts +58 -0
- package/dist/models/mimics/MimicTraits.js +48 -0
- package/dist/models/mimics/PmsElements.d.ts +74 -0
- package/dist/models/mimics/PmsElements.js +66 -0
- package/dist/network/requests/mimics/AuxiliaryElements.d.ts +29 -0
- package/dist/network/requests/mimics/AuxiliaryElements.js +23 -0
- package/dist/network/requests/mimics/ChannelMimic.d.ts +9 -0
- package/dist/network/requests/mimics/ChannelMimic.js +8 -0
- package/dist/network/requests/mimics/ControlElements.d.ts +68 -0
- package/dist/network/requests/mimics/ControlElements.js +59 -0
- package/dist/network/requests/mimics/Elements.d.ts +46 -0
- package/dist/network/requests/mimics/Elements.js +36 -0
- package/dist/network/requests/mimics/IasElements.d.ts +16 -0
- package/dist/network/requests/mimics/IasElements.js +12 -0
- package/dist/network/requests/mimics/MimicSupport.d.ts +77 -0
- package/dist/network/requests/mimics/MimicSupport.js +59 -0
- package/dist/network/requests/mimics/MimicTraits.d.ts +55 -0
- package/dist/network/requests/mimics/MimicTraits.js +45 -0
- package/dist/network/requests/mimics/PmsElements.d.ts +58 -0
- package/dist/network/requests/mimics/PmsElements.js +50 -0
- package/dist/network/responses/mimics/AuxiliaryElements.d.ts +23 -0
- package/dist/network/responses/mimics/AuxiliaryElements.js +17 -0
- package/dist/network/responses/mimics/ControlElements.d.ts +63 -0
- package/dist/network/responses/mimics/ControlElements.js +54 -0
- package/dist/network/responses/mimics/Elements.d.ts +58 -0
- package/dist/network/responses/mimics/Elements.js +48 -0
- package/dist/network/responses/mimics/IasElements.d.ts +17 -0
- package/dist/network/responses/mimics/IasElements.js +13 -0
- package/dist/network/responses/mimics/PmsElements.d.ts +44 -0
- package/dist/network/responses/mimics/PmsElements.js +37 -0
- package/dist/types/alarm.types.d.ts +42 -0
- package/dist/types/alarm.types.js +38 -0
- package/dist/types/channel.types.d.ts +27 -0
- package/dist/types/channel.types.js +30 -0
- package/dist/types/event.types.d.ts +19 -0
- package/dist/types/event.types.js +17 -0
- package/dist/types/mimics.types.d.ts +254 -0
- package/dist/types/mimics.types.js +325 -0
- package/dist/types/unit.types.d.ts +11 -0
- package/dist/types/unit.types.js +10 -0
- package/dist/user.types-CBlsVzYC.d.cts +1270 -0
- package/dist/user.types-CBlsVzYC.d.ts +1270 -0
- package/dist/{unit.types-4ZD9ivHi.d.cts → user.types-DaVBScqh.d.cts} +493 -17
- package/dist/{unit.types-4ZD9ivHi.d.ts → user.types-DaVBScqh.d.ts} +493 -17
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import mongoosePaginate from "mongoose-paginate-v2";
|
|
3
|
+
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
|
|
4
|
+
/**
|
|
5
|
+
* Cambiar por timestamp, value y channel_id.
|
|
6
|
+
* Luego en los indices, agregar un indice compuesto por channel_id y timestamp.
|
|
7
|
+
*/
|
|
8
|
+
const channelDataPointSchema = new mongoose.Schema({
|
|
9
|
+
c: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
index: true,
|
|
13
|
+
alias: "channel_id"
|
|
14
|
+
},
|
|
15
|
+
t: {
|
|
16
|
+
type: Date,
|
|
17
|
+
required: true,
|
|
18
|
+
alias: "timestamp"
|
|
19
|
+
},
|
|
20
|
+
v: {
|
|
21
|
+
type: Number,
|
|
22
|
+
required: true,
|
|
23
|
+
alias: "value"
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
collection: "channel_data_points",
|
|
27
|
+
timestamps: false,
|
|
28
|
+
timeseries: {
|
|
29
|
+
timeField: "t",
|
|
30
|
+
metaField: "c",
|
|
31
|
+
granularity: "seconds"
|
|
32
|
+
},
|
|
33
|
+
toJSON: { getters: true },
|
|
34
|
+
toObject: { getters: true },
|
|
35
|
+
versionKey: false
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* ///////////////////////////////////////////////
|
|
39
|
+
* ///////////// INDEXES /////////////////
|
|
40
|
+
* ///////////////////////////////////////////////
|
|
41
|
+
*/
|
|
42
|
+
channelDataPointSchema.index({ c: 1, t: 1 });
|
|
43
|
+
/**
|
|
44
|
+
* Index used to delete old buckets automatically.
|
|
45
|
+
* This function will need to be called to create the TTL index.
|
|
46
|
+
* The index will expire documents after the specified time in seconds.
|
|
47
|
+
* The default is set to one year, but it can be changed by passing the expirationTimeInSeconds parameter.
|
|
48
|
+
*/
|
|
49
|
+
const oneYear = 60 * 60 * 24 * 365; // One year in seconds
|
|
50
|
+
channelDataPointSchema.addTTLIndex = function (expirationTimeInSeconds = oneYear, ttlField = "t", metaField = "c") {
|
|
51
|
+
this.index({
|
|
52
|
+
[ttlField]: 1
|
|
53
|
+
}, {
|
|
54
|
+
expireAfterSeconds: expirationTimeInSeconds,
|
|
55
|
+
partialFilterExpression: {
|
|
56
|
+
[metaField]: {
|
|
57
|
+
$exists: true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
name: "ttl_index_" + ttlField
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* ///////////////////////////////////////////////
|
|
65
|
+
* //////////// FUNCTIONS ////////////////
|
|
66
|
+
* ///////////////////////////////////////////////
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* ///////////////////////////////////////////////
|
|
70
|
+
* ///////////// PLUGINS /////////////////
|
|
71
|
+
* ///////////////////////////////////////////////
|
|
72
|
+
*/
|
|
73
|
+
channelDataPointSchema.plugin(mongoosePaginate);
|
|
74
|
+
channelDataPointSchema.plugin(mongooseAggregatePaginate);
|
|
75
|
+
export default channelDataPointSchema;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { EventCategories, EventCriticalities } from "../types/event.types.js";
|
|
3
|
+
export type EventDocument = mongoose.Document & {
|
|
4
|
+
event_message: string;
|
|
5
|
+
event_source: string;
|
|
6
|
+
event_user?: string;
|
|
7
|
+
event_category: typeof EventCategories;
|
|
8
|
+
event_criticality: typeof EventCriticalities;
|
|
9
|
+
event_type: string;
|
|
10
|
+
event_timestamp: Date;
|
|
11
|
+
event_data?: Object;
|
|
12
|
+
};
|
|
13
|
+
export type EventModel = mongoose.PaginateModel<EventDocument> & mongoose.AggregatePaginateModel<EventDocument>;
|
|
14
|
+
export type EventJSON = {
|
|
15
|
+
id: string;
|
|
16
|
+
event_message: string;
|
|
17
|
+
event_source: string;
|
|
18
|
+
event_user?: string;
|
|
19
|
+
event_category: typeof EventCategories;
|
|
20
|
+
event_criticality: typeof EventCriticalities;
|
|
21
|
+
event_type: string;
|
|
22
|
+
event_timestamp: number;
|
|
23
|
+
event_data?: Object;
|
|
24
|
+
};
|
|
25
|
+
declare const eventSchema: mongoose.Schema<EventDocument> & {
|
|
26
|
+
addTTLIndex?: (expirationTimeInSeconds?: number, ttlField?: string) => void;
|
|
27
|
+
};
|
|
28
|
+
export default eventSchema;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import mongoosePaginate from "mongoose-paginate-v2";
|
|
3
|
+
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
|
|
4
|
+
import { EventCategories, EventCriticalities } from "../types/event.types.js";
|
|
5
|
+
const eventSchema = new mongoose.Schema({
|
|
6
|
+
event_message: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
event_source: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
event_user: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: false
|
|
17
|
+
},
|
|
18
|
+
event_category: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
enum: Object.values(EventCategories)
|
|
22
|
+
},
|
|
23
|
+
event_criticality: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
enum: Object.values(EventCriticalities)
|
|
27
|
+
},
|
|
28
|
+
event_type: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
event_timestamp: {
|
|
33
|
+
type: Date,
|
|
34
|
+
default: Date.now
|
|
35
|
+
},
|
|
36
|
+
event_data: {
|
|
37
|
+
type: Object
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
timestamps: {
|
|
41
|
+
createdAt: true,
|
|
42
|
+
updatedAt: false
|
|
43
|
+
},
|
|
44
|
+
versionKey: false,
|
|
45
|
+
toJSON: {
|
|
46
|
+
transform: function (doc, ret) {
|
|
47
|
+
ret.id = ret._id;
|
|
48
|
+
delete ret._id;
|
|
49
|
+
delete ret.createdAt;
|
|
50
|
+
ret.event_timestamp = ret.event_timestamp.getTime();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* ///////////////////////////////////////////////
|
|
56
|
+
* ///////////// INDEXES /////////////////
|
|
57
|
+
* ///////////////////////////////////////////////
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Index used primarily for filtering by event_type
|
|
61
|
+
*/
|
|
62
|
+
eventSchema.index({ event_type: 1 });
|
|
63
|
+
/**
|
|
64
|
+
* Index used primarily for filtering by event_category
|
|
65
|
+
*/
|
|
66
|
+
eventSchema.index({ event_category: 1 });
|
|
67
|
+
/**
|
|
68
|
+
* Index used to delete old events automatically.
|
|
69
|
+
* This function will need to be called to create the TTL index.
|
|
70
|
+
* The index will expire documents after the specified time in seconds.
|
|
71
|
+
* The default is set to one year, but it can be changed by passing the expirationTimeInSeconds parameter.
|
|
72
|
+
*/
|
|
73
|
+
const oneYear = 60 * 60 * 24 * 365; // One year in seconds
|
|
74
|
+
eventSchema.addTTLIndex = function (expirationTimeInSeconds = oneYear, ttlField = "event_timestamp") {
|
|
75
|
+
this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* ///////////////////////////////////////////////
|
|
79
|
+
* ///////////// PLUGINS /////////////////
|
|
80
|
+
* ///////////////////////////////////////////////
|
|
81
|
+
*/
|
|
82
|
+
eventSchema.plugin(mongoosePaginate);
|
|
83
|
+
eventSchema.plugin(mongooseAggregatePaginate);
|
|
84
|
+
export default eventSchema;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { AlarmPriorities, AlarmTypes, CloudAlarmStates, DiamarAlarmStates } from "../types/alarm.types.js";
|
|
3
|
+
export type HistoryDocument = mongoose.Document & {
|
|
4
|
+
channel_tag: string;
|
|
5
|
+
alarm_timestamp: Date;
|
|
6
|
+
alarm_priority: typeof AlarmPriorities;
|
|
7
|
+
alarm_original_state: typeof DiamarAlarmStates;
|
|
8
|
+
alarm_state: typeof CloudAlarmStates;
|
|
9
|
+
alarm_type: typeof AlarmTypes;
|
|
10
|
+
alarm_value?: number;
|
|
11
|
+
alarm_message?: string;
|
|
12
|
+
alarm_data?: Object;
|
|
13
|
+
};
|
|
14
|
+
export type HistoryModel = mongoose.PaginateModel<HistoryDocument> & mongoose.AggregatePaginateModel<HistoryDocument>;
|
|
15
|
+
export type HistoryJSON = {
|
|
16
|
+
id: string;
|
|
17
|
+
channel_tag: string;
|
|
18
|
+
alarm_timestamp: number;
|
|
19
|
+
alarm_priority: typeof AlarmPriorities;
|
|
20
|
+
alarm_original_state: typeof DiamarAlarmStates;
|
|
21
|
+
alarm_state: typeof CloudAlarmStates;
|
|
22
|
+
alarm_type: typeof AlarmTypes;
|
|
23
|
+
alarm_value?: number;
|
|
24
|
+
alarm_message?: string;
|
|
25
|
+
alarm_data?: Object;
|
|
26
|
+
};
|
|
27
|
+
declare const historySchema: mongoose.Schema<HistoryDocument> & {
|
|
28
|
+
addTTLIndex?: (expirationTimeInSeconds?: number, ttlField?: string) => void;
|
|
29
|
+
};
|
|
30
|
+
export default historySchema;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import mongoosePaginate from "mongoose-paginate-v2";
|
|
3
|
+
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
|
|
4
|
+
import { AlarmPriorities, AlarmTypes, CloudAlarmStates, DiamarAlarmStates } from "../types/alarm.types.js";
|
|
5
|
+
const historySchema = new mongoose.Schema({
|
|
6
|
+
channel_tag: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
alarm_timestamp: {
|
|
11
|
+
type: Date,
|
|
12
|
+
required: true,
|
|
13
|
+
default: Date.now
|
|
14
|
+
},
|
|
15
|
+
alarm_priority: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
enum: Object.values(AlarmPriorities)
|
|
19
|
+
},
|
|
20
|
+
alarm_original_state: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true,
|
|
23
|
+
enum: Object.values(DiamarAlarmStates)
|
|
24
|
+
},
|
|
25
|
+
alarm_state: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
enum: Object.values(CloudAlarmStates)
|
|
29
|
+
},
|
|
30
|
+
alarm_type: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
enum: Object.values(AlarmTypes)
|
|
34
|
+
},
|
|
35
|
+
alarm_value: {
|
|
36
|
+
type: Number,
|
|
37
|
+
required: false
|
|
38
|
+
},
|
|
39
|
+
alarm_message: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
43
|
+
alarm_data: {
|
|
44
|
+
type: Object,
|
|
45
|
+
required: false
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
timestamps: {
|
|
49
|
+
createdAt: false,
|
|
50
|
+
updatedAt: false
|
|
51
|
+
},
|
|
52
|
+
versionKey: false,
|
|
53
|
+
collection: "history",
|
|
54
|
+
toJSON: {
|
|
55
|
+
transform: function (doc, ret) {
|
|
56
|
+
ret.id = ret._id;
|
|
57
|
+
delete ret._id;
|
|
58
|
+
delete ret.__v;
|
|
59
|
+
ret.alarm_timestamp = new Date(ret.alarm_timestamp).getTime();
|
|
60
|
+
ret.alarm = {
|
|
61
|
+
alarm_priority: ret.alarm_priority,
|
|
62
|
+
alarm_state: ret.alarm_original_state ?? "Inactive",
|
|
63
|
+
alarm_type: ret.alarm_type,
|
|
64
|
+
alarm_value: ret.alarm_value === null ? "inf" : `${ret.alarm_value}`,
|
|
65
|
+
alarm_timestamp: new Date(ret.alarm_timestamp).getTime()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* ///////////////////////////////////////////////
|
|
72
|
+
* ///////////// INDEXES /////////////////
|
|
73
|
+
* ///////////////////////////////////////////////
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* Index used primarily for filtering by channel_tag
|
|
77
|
+
*/
|
|
78
|
+
historySchema.index({ channel_tag: 1 });
|
|
79
|
+
/**
|
|
80
|
+
* Index used to delete old alarms automatically.
|
|
81
|
+
* This function will need to be called to create the TTL index.
|
|
82
|
+
* The index will expire documents after the specified time in seconds.
|
|
83
|
+
* The default is set to one year, but it can be changed by passing the expirationTimeInSeconds parameter.
|
|
84
|
+
*/
|
|
85
|
+
const oneYear = 60 * 60 * 24 * 365; // One year in seconds
|
|
86
|
+
historySchema.addTTLIndex = function (expirationTimeInSeconds = oneYear, ttlField = "alarm_timestamp") {
|
|
87
|
+
this.index({ [ttlField]: 1 }, { expireAfterSeconds: expirationTimeInSeconds });
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* ///////////////////////////////////////////////
|
|
91
|
+
* ///////////// PLUGINS /////////////////
|
|
92
|
+
* ///////////////////////////////////////////////
|
|
93
|
+
*/
|
|
94
|
+
historySchema.plugin(mongoosePaginate);
|
|
95
|
+
historySchema.plugin(mongooseAggregatePaginate);
|
|
96
|
+
export default historySchema;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import { UnitTypes } from "../types/unit.types.js";
|
|
3
|
+
export type UnitDocument = mongoose.Document & {
|
|
4
|
+
unit_id: string;
|
|
5
|
+
unit_enabled: boolean;
|
|
6
|
+
unit_type: typeof UnitTypes;
|
|
7
|
+
unit_internal_description: string;
|
|
8
|
+
unit_cabinet_id?: string;
|
|
9
|
+
};
|
|
10
|
+
export type UnitModel = mongoose.PaginateModel<UnitDocument> & mongoose.AggregatePaginateModel<UnitDocument>;
|
|
11
|
+
export type UnitJSON = {
|
|
12
|
+
id: string;
|
|
13
|
+
unit_id: string;
|
|
14
|
+
unit_enabled: boolean;
|
|
15
|
+
unit_type: typeof UnitTypes;
|
|
16
|
+
unit_internal_description: string;
|
|
17
|
+
unit_cabinet_id?: string;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
};
|
|
21
|
+
declare const unitSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
22
|
+
timestamps: true;
|
|
23
|
+
collection: string;
|
|
24
|
+
toJSON: {
|
|
25
|
+
transform: (doc: UnitDocument, ret: any) => void;
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
unit_id: string;
|
|
29
|
+
unit_enabled: boolean;
|
|
30
|
+
unit_type: "Aim18" | "Dim36" | "Diom24" | "Klim" | "Lum" | "Pmm" | "Slim" | "Tim28";
|
|
31
|
+
unit_internal_description: string;
|
|
32
|
+
unit_cabinet_id?: string | null | undefined;
|
|
33
|
+
} & mongoose.DefaultTimestampProps, UnitDocument, {
|
|
34
|
+
[path: string]: mongoose.SchemaDefinitionProperty<undefined, any, any>;
|
|
35
|
+
} | {
|
|
36
|
+
[x: string]: mongoose.SchemaDefinitionProperty<any, any, UnitDocument> | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
unit_id: string;
|
|
39
|
+
unit_enabled: boolean;
|
|
40
|
+
unit_type: "Aim18" | "Dim36" | "Diom24" | "Klim" | "Lum" | "Pmm" | "Slim" | "Tim28";
|
|
41
|
+
unit_internal_description: string;
|
|
42
|
+
unit_cabinet_id?: string | null | undefined;
|
|
43
|
+
createdAt: NativeDate;
|
|
44
|
+
updatedAt: NativeDate;
|
|
45
|
+
} & {
|
|
46
|
+
_id: mongoose.Types.ObjectId;
|
|
47
|
+
} & {
|
|
48
|
+
__v: number;
|
|
49
|
+
}>;
|
|
50
|
+
export default unitSchema;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
import mongoosePaginate from "mongoose-paginate-v2";
|
|
3
|
+
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
|
|
4
|
+
import { UnitTypes } from "../types/unit.types.js";
|
|
5
|
+
const unitSchema = new mongoose.Schema({
|
|
6
|
+
unit_id: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
unit_enabled: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
unit_type: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
enum: Object.values(UnitTypes)
|
|
18
|
+
},
|
|
19
|
+
unit_internal_description: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
unit_cabinet_id: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: false
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
timestamps: true,
|
|
29
|
+
collection: "units",
|
|
30
|
+
toJSON: {
|
|
31
|
+
transform: function (doc, ret) {
|
|
32
|
+
ret.id = ret._id;
|
|
33
|
+
delete ret._id;
|
|
34
|
+
delete ret.__v;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* ///////////////////////////////////////////////
|
|
40
|
+
* ///////////// INDEXES /////////////////
|
|
41
|
+
* ///////////////////////////////////////////////
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Index used primarily for filtering by unit_id and ensuring uniqueness
|
|
45
|
+
*/
|
|
46
|
+
unitSchema.index({ unit_id: 1 }, { unique: true });
|
|
47
|
+
/**
|
|
48
|
+
* Index used primarily for filtering by unit_internal_description
|
|
49
|
+
*/
|
|
50
|
+
unitSchema.index({ unit_internal_description: 1 });
|
|
51
|
+
/**
|
|
52
|
+
* ///////////////////////////////////////////////
|
|
53
|
+
* ///////////// PLUGINS /////////////////
|
|
54
|
+
* ///////////////////////////////////////////////
|
|
55
|
+
*/
|
|
56
|
+
unitSchema.plugin(mongoosePaginate);
|
|
57
|
+
unitSchema.plugin(mongooseAggregatePaginate);
|
|
58
|
+
export default unitSchema;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
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
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
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
|
+
},
|
|
60
|
+
"examples": {
|
|
61
|
+
"ChannelData": {
|
|
62
|
+
"id": "507f1f77bcf86cd799439011",
|
|
63
|
+
"start_date": "2024-07-03T10:15:30Z",
|
|
64
|
+
"end_date": "2024-07-03T11:15:30Z",
|
|
65
|
+
"data": [
|
|
66
|
+
{
|
|
67
|
+
"t": 1710251647000,
|
|
68
|
+
"v": 69.420
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"size": 60,
|
|
72
|
+
"synced": "TODO",
|
|
73
|
+
"sum": 69.420
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": {
|
|
3
|
+
"schemas": {
|
|
4
|
+
"ChannelDataPoint": {
|
|
5
|
+
"type": "object",
|
|
6
|
+
"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.",
|
|
7
|
+
"properties": {
|
|
8
|
+
"c": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Channel ID associated with the data point",
|
|
11
|
+
"example": "U001_001",
|
|
12
|
+
"readOnly": true
|
|
13
|
+
},
|
|
14
|
+
"t": {
|
|
15
|
+
"type": "integer",
|
|
16
|
+
"format": "int64",
|
|
17
|
+
"description": "Timestamp of the data",
|
|
18
|
+
"example": 1710251647000,
|
|
19
|
+
"readOnly": true
|
|
20
|
+
},
|
|
21
|
+
"v": {
|
|
22
|
+
"type": "number",
|
|
23
|
+
"format": "double",
|
|
24
|
+
"description": "Value of the data",
|
|
25
|
+
"example": 69.420,
|
|
26
|
+
"readOnly": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"examples": {
|
|
32
|
+
"ChannelDataPoint": {
|
|
33
|
+
"c": "U001_001",
|
|
34
|
+
"t": 1710251647000,
|
|
35
|
+
"v": 69.420
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -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
|
+
}
|