@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2021 bluefox<dogafox@gmail.com>,
3
+ Copyright (c) 2014-2022 bluefox<dogafox@gmail.com>,
4
4
  Copyright (c) 2014 hobbyquaker
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
package/README.md CHANGED
@@ -3,4 +3,4 @@ The Library contains the common utils of ioBroker which use the DB directly and
3
3
 
4
4
  ## License
5
5
  MIT
6
- Copyright 2018-2021 bluefox <dogafox@gmail.com>
6
+ Copyright 2018-2022 bluefox <dogafox@gmail.com>
package/build/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * as tools from './lib/common/tools';
2
2
  export { getStatesConstructor } from './lib/common/states';
3
3
  export { getObjectsConstructor } from './lib/common/objects';
4
+ //# sourceMappingURL=index.d.ts.map
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
@@ -1 +1,2 @@
1
1
  export declare function getObjectsConstructor(): any;
2
+ //# sourceMappingURL=objects.d.ts.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
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
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 (_a) {
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"}
@@ -1 +1,2 @@
1
1
  export declare function getStatesConstructor(): any;
2
+ //# sourceMappingURL=states.d.ts.map
@@ -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
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
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 (_a) {
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"}
@@ -26,3 +26,4 @@ export declare function isLocalStatesDbServer(dbType: string, host: string, chec
26
26
  * @returns true if a server class is available
27
27
  */
28
28
  export declare function objectsDbHasServer(dbType: string): boolean;
29
+ //# sourceMappingURL=tools.d.ts.map
@@ -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
- // we currently have no typings so ignore
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 (_a) {
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 (_a) {
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.0-alpha.9-20211115-5dac659e",
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.0-alpha.9-20211115-5dac659e",
13
- "@iobroker/db-objects-jsonl": "4.0.0-alpha.9-20211115-5dac659e",
14
- "@iobroker/db-objects-redis": "4.0.0-alpha.9-20211115-5dac659e",
15
- "@iobroker/db-states-file": "4.0.0-alpha.9-20211115-5dac659e",
16
- "@iobroker/db-states-jsonl": "4.0.0-alpha.9-20211115-5dac659e",
17
- "@iobroker/db-states-redis": "4.0.0-alpha.9-20211115-5dac659e",
18
- "@iobroker/js-controller-common": "4.0.0-alpha.9-20211115-5dac659e",
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": "fe67b6f4f17e34f417ec8b4a11a57a107124c475"
48
+ "gitHead": "79a76a082db91399d0e432ef02bf2981a6739107"
49
49
  }