@sedni/cloud_common 1.0.0 → 1.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/app/models/ChannelDataBucket.js +1 -1
- package/app/models/Event.js +5 -5
- package/app/models/History.js +2 -2
- package/app/types/alarm.types.js +2 -2
- package/eslint.config.js +38 -0
- package/index.js +23 -13
- package/package.json +6 -4
- package/.eslintrc.js +0 -32
|
@@ -191,7 +191,7 @@ channeldataBucketSchema.statics.lastTimeSynced = async function(options)
|
|
|
191
191
|
channeldataBucketSchema.statics.getNotUploadedData = async function(options)
|
|
192
192
|
{
|
|
193
193
|
// Get the last time the data was synced
|
|
194
|
-
|
|
194
|
+
const last_sync = options?.last_sync ?? await this.lastTimeSynced(options);
|
|
195
195
|
|
|
196
196
|
// Get all the buckets that synced is lt size and end_date is gt last_sync
|
|
197
197
|
const buckets = await this.find({
|
package/app/models/Event.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const mongoose_paginate = require("mongoose-paginate-v2");
|
|
3
3
|
const mongoose_aggregate_paginate = require("mongoose-aggregate-paginate-v2");
|
|
4
|
-
const { EventCategories } = require("
|
|
4
|
+
const { EventCategories } = require("../types/event.types");
|
|
5
5
|
|
|
6
6
|
const eventSchema = new mongoose.Schema({
|
|
7
7
|
event_message: {
|
|
@@ -59,12 +59,12 @@ const eventSchema = new mongoose.Schema({
|
|
|
59
59
|
/**
|
|
60
60
|
* Index used primarily for filtering by channel_tag
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
eventSchema.index({ "channel_tag" : 1 });
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Index used primarily for filtering by timestamp
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
eventSchema.index({ "timestamp" : 1 });
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -72,7 +72,7 @@ historySchema.index({ "timestamp" : 1 });
|
|
|
72
72
|
* ///////////// PLUGINS /////////////////
|
|
73
73
|
* ///////////////////////////////////////////////
|
|
74
74
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
eventSchema.plugin(mongoose_paginate);
|
|
76
|
+
eventSchema.plugin(mongoose_aggregate_paginate);
|
|
77
77
|
|
|
78
78
|
module.exports = eventSchema;
|
package/app/models/History.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const mongoose = require("mongoose");
|
|
2
2
|
const mongoose_paginate = require("mongoose-paginate-v2");
|
|
3
3
|
const mongoose_aggregate_paginate = require("mongoose-aggregate-paginate-v2");
|
|
4
|
-
const { AlarmTypes, AlarmPriorities,
|
|
4
|
+
const { AlarmTypes, AlarmPriorities, CloudAlarmStates, DiamarAlarmStates } = require("../types/alarm.types");
|
|
5
5
|
|
|
6
6
|
const historySchema = new mongoose.Schema({
|
|
7
7
|
timestamp: {
|
|
@@ -26,7 +26,7 @@ const historySchema = new mongoose.Schema({
|
|
|
26
26
|
alarm_state: {
|
|
27
27
|
type: String,
|
|
28
28
|
required: true,
|
|
29
|
-
enum: Object.values(
|
|
29
|
+
enum: Object.values(CloudAlarmStates),
|
|
30
30
|
},
|
|
31
31
|
alarm_type: {
|
|
32
32
|
type: String,
|
package/app/types/alarm.types.js
CHANGED
|
@@ -3,7 +3,7 @@ const AlarmPriorities =
|
|
|
3
3
|
CRITICAL: "Critical",
|
|
4
4
|
ALARM: "Alarm",
|
|
5
5
|
WARNING: "Warning",
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
const DiamarAlarmStates =
|
|
9
9
|
{
|
|
@@ -40,7 +40,7 @@ const AlarmTypes =
|
|
|
40
40
|
ALARM_FAIL: "AlarmFail",
|
|
41
41
|
ALARM_INH: "AlarmInh",
|
|
42
42
|
ALARM_UNK: "AlarmUnk",
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
|
|
45
45
|
module.exports =
|
|
46
46
|
{
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const globals = require("globals");
|
|
2
|
+
const pluginJs = require("@eslint/js");
|
|
3
|
+
const nodePlugin = require("eslint-plugin-n");
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
pluginJs.configs.recommended,
|
|
7
|
+
nodePlugin.configs["flat/recommended-script"],
|
|
8
|
+
{
|
|
9
|
+
files: ["app/**/*.js", "app/**/*.json", "index.js"],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
"ecmaVersion": "latest",
|
|
12
|
+
"sourceType": "commonjs",
|
|
13
|
+
"globals": globals.node,
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"prefer-const": ["error"],
|
|
17
|
+
"no-var": ["error"],
|
|
18
|
+
"semi": ["error", "always"],
|
|
19
|
+
"indent": ["error", 4],
|
|
20
|
+
"quotes": ["error", "double"],
|
|
21
|
+
"no-unused-vars": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
"varsIgnorePattern": "should|expect|supertest|assert",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
"curly": ["error", "all"],
|
|
28
|
+
"brace-style": ["error", "allman"],
|
|
29
|
+
"n/no-missing-require" : "off",
|
|
30
|
+
"n/no-unpublished-require": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
"allowModules": ["swagger-ui-express"],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
];
|
package/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SCHEMAS
|
|
3
3
|
*/
|
|
4
|
-
const Channel = require("app/models/
|
|
5
|
-
const ChannelDataBucket = require("app/models/
|
|
6
|
-
const Event = require("app/models/
|
|
7
|
-
const History = require("app/models/
|
|
8
|
-
const Unit = require("app/models/
|
|
4
|
+
const Channel = require("./app/models/Channel");
|
|
5
|
+
const ChannelDataBucket = require("./app/models/ChannelDataBucket.js");
|
|
6
|
+
const Event = require("./app/models/Event.js");
|
|
7
|
+
const History = require("./app/models/History.js");
|
|
8
|
+
const Unit = require("./app/models/Unit.js");
|
|
9
9
|
|
|
10
10
|
const Schemas = {
|
|
11
11
|
Channel,
|
|
@@ -18,11 +18,11 @@ const Schemas = {
|
|
|
18
18
|
/**
|
|
19
19
|
* DOCS
|
|
20
20
|
*/
|
|
21
|
-
const ChannelDocs = require("app/models/docs/
|
|
22
|
-
const ChannelDataBucketDocs = require("app/models/docs/
|
|
23
|
-
const EventDocs = require("app/models/docs/
|
|
24
|
-
const HistoryDocs = require("app/models/docs/
|
|
25
|
-
const UnitDocs = require("app/models/docs/
|
|
21
|
+
const ChannelDocs = require("./app/models/docs/Channel.json");
|
|
22
|
+
const ChannelDataBucketDocs = require("./app/models/docs/ChannelDataBucket.json");
|
|
23
|
+
const EventDocs = require("./app/models/docs/Event.json");
|
|
24
|
+
const HistoryDocs = require("./app/models/docs/History.json");
|
|
25
|
+
const UnitDocs = require("./app/models/docs/Unit.json");
|
|
26
26
|
|
|
27
27
|
const Docs = {
|
|
28
28
|
ChannelDocs,
|
|
@@ -35,19 +35,29 @@ const Docs = {
|
|
|
35
35
|
/**
|
|
36
36
|
* TYPES
|
|
37
37
|
*/
|
|
38
|
-
const { AlarmTypes, AlarmPriorities,
|
|
39
|
-
const { EventCategories } = require("app/types/event.types");
|
|
38
|
+
const { AlarmTypes, AlarmPriorities, CloudAlarmStates, DiamarAlarmStates } = require("./app/types/alarm.types");
|
|
39
|
+
const { EventCategories } = require("./app/types/event.types");
|
|
40
40
|
|
|
41
41
|
const Types = {
|
|
42
42
|
AlarmTypes,
|
|
43
43
|
AlarmPriorities,
|
|
44
|
-
|
|
44
|
+
CloudAlarmStates,
|
|
45
45
|
DiamarAlarmStates,
|
|
46
46
|
EventCategories,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* EXTERNAL
|
|
51
|
+
*/
|
|
52
|
+
const mongoose = require("mongoose");
|
|
53
|
+
const mongoosePaginate = require("mongoose-paginate-v2");
|
|
54
|
+
const mongooseAggregatePaginate = require("mongoose-aggregate-paginate-v2");
|
|
55
|
+
|
|
49
56
|
module.exports = {
|
|
50
57
|
Schemas,
|
|
51
58
|
Docs,
|
|
52
59
|
Types,
|
|
60
|
+
mongoose,
|
|
61
|
+
mongoosePaginate,
|
|
62
|
+
mongooseAggregatePaginate,
|
|
53
63
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sedni/cloud_common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Common package for all types, resources and tools of Diamar Cloud",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"chai": "^5.1.1",
|
|
21
|
-
"eslint": "^
|
|
22
|
-
"eslint
|
|
21
|
+
"@eslint/js": "^9.12.0",
|
|
22
|
+
"eslint": "^9.12.0",
|
|
23
|
+
"eslint-plugin-n": "^17.11.0",
|
|
24
|
+
"globals": "^15.11.0",
|
|
23
25
|
"mocha": "^10.7.3",
|
|
24
26
|
"nyc": "^17.0.0",
|
|
25
27
|
"supertest": "^7.0.0"
|
|
26
28
|
}
|
|
27
|
-
}
|
|
29
|
+
}
|
package/.eslintrc.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
node: true,
|
|
4
|
-
commonjs: true,
|
|
5
|
-
es2021: true,
|
|
6
|
-
mocha: true,
|
|
7
|
-
},
|
|
8
|
-
extends: [ "eslint:recommended", "plugin:node/recommended" ],
|
|
9
|
-
parserOptions: {
|
|
10
|
-
ecmaVersion: "latest",
|
|
11
|
-
},
|
|
12
|
-
rules: {
|
|
13
|
-
indent: [ "error", 4, { SwitchCase: 1 } ],
|
|
14
|
-
quotes: [ "error", "double" ],
|
|
15
|
-
semi: [ "error", "always" ],
|
|
16
|
-
"no-unused-vars": [
|
|
17
|
-
"error",
|
|
18
|
-
{
|
|
19
|
-
varsIgnorePattern: "should|expect|supertest|assert",
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
curly: [ "error", "all" ],
|
|
23
|
-
"brace-style": [ "error", "allman" ],
|
|
24
|
-
"node/no-unpublished-require": [
|
|
25
|
-
"error",
|
|
26
|
-
{
|
|
27
|
-
allowModules: [ "swagger-ui-express" ],
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
"node/no-missing-require": "off",
|
|
31
|
-
},
|
|
32
|
-
};
|