@iobroker/js-controller-common-db 4.0.0-alpha.9-20211115-5dac659e → 4.0.3
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/LICENSE +1 -1
- package/README.md +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +21 -1
- package/build/lib/common/objects.d.ts +1 -0
- package/build/lib/common/objects.d.ts.map +1 -0
- package/build/lib/common/objects.js +23 -4
- package/build/lib/common/objects.js.map +1 -0
- package/build/lib/common/states.d.ts +1 -0
- package/build/lib/common/states.d.ts.map +1 -0
- package/build/lib/common/states.js +23 -4
- package/build/lib/common/states.js.map +1 -0
- package/build/lib/common/tools.d.ts +1 -0
- package/build/lib/common/tools.d.ts.map +1 -0
- package/build/lib/common/tools.js +6 -7
- package/build/lib/common/tools.js.map +1 -0
- package/package.json +9 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.getObjectsConstructor = exports.getStatesConstructor = exports.tools = void 0;
|
|
4
|
-
exports.tools = require("./lib/common/tools");
|
|
23
|
+
exports.tools = __importStar(require("./lib/common/tools"));
|
|
5
24
|
var states_1 = require("./lib/common/states");
|
|
6
25
|
Object.defineProperty(exports, "getStatesConstructor", { enumerable: true, get: function () { return states_1.getStatesConstructor; } });
|
|
7
26
|
var objects_1 = require("./lib/common/objects");
|
|
8
27
|
Object.defineProperty(exports, "getObjectsConstructor", { enumerable: true, get: function () { return objects_1.getObjectsConstructor; } });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/lib/common/objects.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,IAAI,GAAG,CAa3C"}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.getObjectsConstructor = void 0;
|
|
4
|
-
const fs = require("fs-extra");
|
|
5
|
-
//
|
|
6
|
-
// @ts-ignore
|
|
23
|
+
const fs = __importStar(require("fs-extra"));
|
|
24
|
+
// @ts-expect-error no typings yet
|
|
7
25
|
const js_controller_common_1 = require("@iobroker/js-controller-common");
|
|
8
26
|
function getObjectsConstructor() {
|
|
9
27
|
const config = fs.readJSONSync(js_controller_common_1.tools.getConfigFileName());
|
|
@@ -14,9 +32,10 @@ function getObjectsConstructor() {
|
|
|
14
32
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
33
|
return require(`@iobroker/db-objects-${config.objects.type}`).Client;
|
|
16
34
|
}
|
|
17
|
-
catch
|
|
35
|
+
catch {
|
|
18
36
|
console.error(`Installation broken or unknown objects type: ${config.objects.type} configured.`);
|
|
19
37
|
process.exit(101);
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
exports.getObjectsConstructor = getObjectsConstructor;
|
|
41
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../../../src/lib/common/objects.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;AAEb,6CAA+B;AAC/B,kCAAkC;AAClC,yEAAuD;AAEvD,SAAgB,qBAAqB;IACjC,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,4BAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACjB,MAAM,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KACrC;IAED,IAAI;QACA,8DAA8D;QAC9D,OAAO,OAAO,CAAC,wBAAwB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;KACxE;IAAC,MAAM;QACJ,OAAO,CAAC,KAAK,CAAC,gDAAgD,MAAM,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,CAAC;QACjG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACrB;AACL,CAAC;AAbD,sDAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../../../src/lib/common/states.ts"],"names":[],"mappings":"AAMA,wBAAgB,oBAAoB,IAAI,GAAG,CAa1C"}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.getStatesConstructor = void 0;
|
|
4
|
-
const fs = require("fs-extra");
|
|
5
|
-
//
|
|
6
|
-
// @ts-ignore
|
|
23
|
+
const fs = __importStar(require("fs-extra"));
|
|
24
|
+
// @ts-expect-error no typings yet
|
|
7
25
|
const js_controller_common_1 = require("@iobroker/js-controller-common");
|
|
8
26
|
function getStatesConstructor() {
|
|
9
27
|
const config = fs.readJSONSync(js_controller_common_1.tools.getConfigFileName());
|
|
@@ -14,9 +32,10 @@ function getStatesConstructor() {
|
|
|
14
32
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
33
|
return require(`@iobroker/db-states-${config.states.type}`).Client;
|
|
16
34
|
}
|
|
17
|
-
catch
|
|
35
|
+
catch {
|
|
18
36
|
console.error(`Installation broken or unknown states type: ${config.states.type} configured.`);
|
|
19
37
|
process.exit(101);
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
exports.getStatesConstructor = getStatesConstructor;
|
|
41
|
+
//# sourceMappingURL=states.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states.js","sourceRoot":"","sources":["../../../src/lib/common/states.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;AAEb,6CAA+B;AAC/B,kCAAkC;AAClC,yEAAuD;AAEvD,SAAgB,oBAAoB;IAChC,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,4BAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAChB,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KACpC;IAED,IAAI;QACA,8DAA8D;QAC9D,OAAO,OAAO,CAAC,uBAAuB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;KACtE;IAAC,MAAM;QACJ,OAAO,CAAC,KAAK,CAAC,+CAA+C,MAAM,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,CAAC;QAC/F,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACrB;AACL,CAAC;AAbD,oDAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/lib/common/tools.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAU/G;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,UAAQ,GAAG,OAAO,CAUrG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAO1D"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.objectsDbHasServer = exports.isLocalStatesDbServer = exports.isLocalObjectsDbServer = exports.statesDbHasServer = void 0;
|
|
4
|
-
//
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore
|
|
4
|
+
// @ts-expect-error no typings yet
|
|
7
5
|
const js_controller_common_1 = require("@iobroker/js-controller-common");
|
|
8
6
|
/**
|
|
9
7
|
* Allows to find out if a given states dbType offers a server or not
|
|
@@ -15,7 +13,7 @@ function statesDbHasServer(dbType) {
|
|
|
15
13
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
14
|
return !!require(`@iobroker/db-states-${dbType}`).Server;
|
|
17
15
|
}
|
|
18
|
-
catch
|
|
16
|
+
catch {
|
|
19
17
|
throw new Error(`Installation error or unknown states database type: ${dbType}`);
|
|
20
18
|
}
|
|
21
19
|
}
|
|
@@ -28,12 +26,12 @@ exports.statesDbHasServer = statesDbHasServer;
|
|
|
28
26
|
* @returns true if a server listens on this host (locally or globally/by IP)
|
|
29
27
|
*/
|
|
30
28
|
function isLocalObjectsDbServer(dbType, host, checkIfLocalOnly = false) {
|
|
31
|
-
const ownIps = js_controller_common_1.tools.findIPs();
|
|
32
29
|
if (!objectsDbHasServer(dbType)) {
|
|
33
30
|
return false; // if no server it can not be a local server
|
|
34
31
|
}
|
|
35
32
|
let result = host === 'localhost' || host === '127.0.0.1'; // reachable locally only
|
|
36
33
|
if (!checkIfLocalOnly) {
|
|
34
|
+
const ownIps = js_controller_common_1.tools.findIPs();
|
|
37
35
|
result = result || host === '0.0.0.0' || ownIps.includes(host);
|
|
38
36
|
}
|
|
39
37
|
return result;
|
|
@@ -47,12 +45,12 @@ exports.isLocalObjectsDbServer = isLocalObjectsDbServer;
|
|
|
47
45
|
* @returns true if a server listens on this host (locally or globally/by IP)
|
|
48
46
|
*/
|
|
49
47
|
function isLocalStatesDbServer(dbType, host, checkIfLocalOnly = false) {
|
|
50
|
-
const ownIps = js_controller_common_1.tools.findIPs();
|
|
51
48
|
if (!statesDbHasServer(dbType)) {
|
|
52
49
|
return false; // if no server it can not be a local server
|
|
53
50
|
}
|
|
54
51
|
let result = host === 'localhost' || host === '127.0.0.1'; // reachable locally only
|
|
55
52
|
if (!checkIfLocalOnly) {
|
|
53
|
+
const ownIps = js_controller_common_1.tools.findIPs();
|
|
56
54
|
result = result || host === '0.0.0.0' || ownIps.includes(host);
|
|
57
55
|
}
|
|
58
56
|
return result;
|
|
@@ -68,8 +66,9 @@ function objectsDbHasServer(dbType) {
|
|
|
68
66
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
69
67
|
return !!require(`@iobroker/db-objects-${dbType}`).Server;
|
|
70
68
|
}
|
|
71
|
-
catch
|
|
69
|
+
catch {
|
|
72
70
|
throw new Error(`Installation error or unknown objects database type: ${dbType}`);
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
exports.objectsDbHasServer = objectsDbHasServer;
|
|
74
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/lib/common/tools.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,kCAAkC;AAClC,yEAAuD;AAEvD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC5C,IAAI;QACA,8DAA8D;QAC9D,OAAO,CAAC,CAAC,OAAO,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;KAC5D;IAAC,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,uDAAuD,MAAM,EAAE,CAAC,CAAC;KACpF;AACL,CAAC;AAPD,8CAOC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,MAAc,EAAE,IAAY,EAAE,mBAA4B,KAAK;IAClG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;QAC7B,OAAO,KAAK,CAAC,CAAC,4CAA4C;KAC7D;IACD,IAAI,MAAM,GAAG,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC,CAAC,yBAAyB;IACpF,IAAI,CAAC,gBAAgB,EAAE;QACnB,MAAM,MAAM,GAAG,4BAAK,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,GAAG,MAAM,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;KAClE;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAVD,wDAUC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY,EAAE,gBAAgB,GAAG,KAAK;IACxF,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,KAAK,CAAC,CAAC,4CAA4C;KAC7D;IACD,IAAI,MAAM,GAAG,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC,CAAC,yBAAyB;IACpF,IAAI,CAAC,gBAAgB,EAAE;QACnB,MAAM,MAAM,GAAG,4BAAK,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,GAAG,MAAM,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;KAClE;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAVD,sDAUC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC7C,IAAI;QACA,8DAA8D;QAC9D,OAAO,CAAC,CAAC,OAAO,CAAC,wBAAwB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;KAC7D;IAAC,MAAM;QACJ,MAAM,IAAI,KAAK,CAAC,wDAAwD,MAAM,EAAE,CAAC,CAAC;KACrF;AACL,CAAC;AAPD,gDAOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/js-controller-common-db",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=12.0.0"
|
|
6
6
|
},
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"winston-syslog": "^2.4.4"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@iobroker/db-objects-file": "4.0.
|
|
13
|
-
"@iobroker/db-objects-jsonl": "4.0.
|
|
14
|
-
"@iobroker/db-objects-redis": "4.0.
|
|
15
|
-
"@iobroker/db-states-file": "4.0.
|
|
16
|
-
"@iobroker/db-states-jsonl": "4.0.
|
|
17
|
-
"@iobroker/db-states-redis": "4.0.
|
|
18
|
-
"@iobroker/js-controller-common": "4.0.
|
|
12
|
+
"@iobroker/db-objects-file": "4.0.3",
|
|
13
|
+
"@iobroker/db-objects-jsonl": "4.0.3",
|
|
14
|
+
"@iobroker/db-objects-redis": "4.0.3",
|
|
15
|
+
"@iobroker/db-states-file": "4.0.3",
|
|
16
|
+
"@iobroker/db-states-jsonl": "4.0.3",
|
|
17
|
+
"@iobroker/db-states-redis": "4.0.3",
|
|
18
|
+
"@iobroker/js-controller-common": "4.0.3",
|
|
19
19
|
"fs-extra": "^10.0.0"
|
|
20
20
|
},
|
|
21
21
|
"keywords": [
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"build/index.js",
|
|
46
46
|
"build/index.d.ts"
|
|
47
47
|
],
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "79a76a082db91399d0e432ef02bf2981a6739107"
|
|
49
49
|
}
|