@iobroker/js-controller-common-db 7.0.2 → 7.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/build/cjs/index.js +4 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/lib/common/aliasProcessing.d.ts +0 -1
- package/build/cjs/lib/common/aliasProcessing.js.map +1 -1
- package/build/cjs/lib/common/exitCodes.js.map +1 -1
- package/build/cjs/lib/common/interview.d.ts +0 -1
- package/build/cjs/lib/common/interview.js +4 -0
- package/build/cjs/lib/common/interview.js.map +1 -1
- package/build/cjs/lib/common/logger.js +26 -7
- package/build/cjs/lib/common/logger.js.map +3 -3
- package/build/cjs/lib/common/maybeCallback.js.map +1 -1
- package/build/cjs/lib/common/password.js +8 -1
- package/build/cjs/lib/common/password.js.map +1 -1
- package/build/cjs/lib/common/session.js +20 -0
- package/build/cjs/lib/common/session.js.map +1 -1
- package/build/cjs/lib/common/tools.d.ts +0 -4
- package/build/cjs/lib/common/tools.js +37 -18
- package/build/cjs/lib/common/tools.js.map +3 -3
- package/build/esm/lib/common/aliasProcessing.d.ts +0 -1
- package/build/esm/lib/common/aliasProcessing.d.ts.map +1 -1
- package/build/esm/lib/common/interview.d.ts +0 -1
- package/build/esm/lib/common/interview.d.ts.map +1 -1
- package/build/esm/lib/common/tools.d.ts +0 -4
- package/build/esm/lib/common/tools.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -19,6 +19,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
};
|
|
20
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
26
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
27
|
mod
|
|
24
28
|
));
|
|
@@ -113,6 +117,7 @@ __export(tools_exports, {
|
|
|
113
117
|
validateGeneralObjectProperties: () => validateGeneralObjectProperties
|
|
114
118
|
});
|
|
115
119
|
module.exports = __toCommonJS(tools_exports);
|
|
120
|
+
var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
116
121
|
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
117
122
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
118
123
|
var import_semver = __toESM(require("semver"), 1);
|
|
@@ -139,9 +144,8 @@ var import_aliasProcessing = require("../../lib/common/aliasProcessing.js");
|
|
|
139
144
|
var url = __toESM(require("node:url"), 1);
|
|
140
145
|
var import_node_module = require("node:module");
|
|
141
146
|
__reExport(tools_exports, require("../../lib/common/maybeCallback.js"), module.exports);
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const require2 = (0, import_node_module.createRequire)(import_meta.url || `file://${__filename}`);
|
|
147
|
+
const thisDir = url.fileURLToPath(new URL(".", __import_meta_url || `file://${__filename}`));
|
|
148
|
+
const require2 = (0, import_node_module.createRequire)(__import_meta_url || `file://${__filename}`);
|
|
145
149
|
var ERRORS;
|
|
146
150
|
(function(ERRORS2) {
|
|
147
151
|
ERRORS2["ERROR_NOT_FOUND"] = "Not exists";
|
|
@@ -457,7 +461,7 @@ async function updateUuid(newUuid, _objects) {
|
|
|
457
461
|
name: "uuid",
|
|
458
462
|
type: "uuid"
|
|
459
463
|
},
|
|
460
|
-
ts: new Date().getTime(),
|
|
464
|
+
ts: (/* @__PURE__ */ new Date()).getTime(),
|
|
461
465
|
from: `system.host.${getHostName()}.tools`,
|
|
462
466
|
native: {
|
|
463
467
|
uuid: _uuid
|
|
@@ -488,7 +492,7 @@ async function createUuid(objects) {
|
|
|
488
492
|
dontDelete: true,
|
|
489
493
|
enabled: true
|
|
490
494
|
},
|
|
491
|
-
ts: new Date().getTime(),
|
|
495
|
+
ts: (/* @__PURE__ */ new Date()).getTime(),
|
|
492
496
|
from: `system.host.${getHostName()}.tools`,
|
|
493
497
|
native: {}
|
|
494
498
|
});
|
|
@@ -726,6 +730,7 @@ function scanDirectory(dirName, list, regExp) {
|
|
|
726
730
|
icon: ioPackage.common.extIcon || localIcon,
|
|
727
731
|
localIcon,
|
|
728
732
|
title: ioPackage.common.title,
|
|
733
|
+
// deprecated 2021.04.18 BF
|
|
729
734
|
titleLang: ioPackage.common.titleLang,
|
|
730
735
|
desc: ioPackage.common.desc,
|
|
731
736
|
platform: ioPackage.common.platform,
|
|
@@ -764,6 +769,7 @@ function getInstalledInfo(hostRunningVersion) {
|
|
|
764
769
|
version: ioPackage.common.version,
|
|
765
770
|
icon: ioPackage.common.extIcon || ioPackage.common.icon,
|
|
766
771
|
title: ioPackage.common.title,
|
|
772
|
+
// deprecated 2021.04.18 BF
|
|
767
773
|
titleLang: ioPackage.common.titleLang,
|
|
768
774
|
desc: ioPackage.common.desc,
|
|
769
775
|
platform: ioPackage.common.platform,
|
|
@@ -1023,7 +1029,7 @@ function getRepositoryFile(urlOrPath, additionalInfo, callback) {
|
|
|
1023
1029
|
}
|
|
1024
1030
|
_getRepositoryFile(sources, _path, (err) => {
|
|
1025
1031
|
if (err) {
|
|
1026
|
-
console.error(`[${new Date().toString()}] ${err.message}`);
|
|
1032
|
+
console.error(`[${(/* @__PURE__ */ new Date()).toString()}] ${err.message}`);
|
|
1027
1033
|
}
|
|
1028
1034
|
if (typeof callback === "function") {
|
|
1029
1035
|
callback(err, sources);
|
|
@@ -1046,7 +1052,7 @@ function getRepositoryFile(urlOrPath, additionalInfo, callback) {
|
|
|
1046
1052
|
}
|
|
1047
1053
|
}
|
|
1048
1054
|
setImmediate(() => _getRepositoryFile(sources3, _path, (err2) => {
|
|
1049
|
-
err2 && console.error(`[${new Date().toString()}] ${err2.message}`);
|
|
1055
|
+
err2 && console.error(`[${(/* @__PURE__ */ new Date()).toString()}] ${err2.message}`);
|
|
1050
1056
|
typeof callback === "function" && callback(err2, sources3, actualSourcesHash);
|
|
1051
1057
|
}));
|
|
1052
1058
|
} else {
|
|
@@ -1194,10 +1200,16 @@ function getSystemNpmVersion(callback) {
|
|
|
1194
1200
|
const getSystemNpmVersionAsync = promisify(getSystemNpmVersion);
|
|
1195
1201
|
async function detectPackageManagerWithFallback(cwd) {
|
|
1196
1202
|
try {
|
|
1197
|
-
return await (0, import_pak.detectPackageManager)(typeof cwd === "string" ?
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1203
|
+
return await (0, import_pak.detectPackageManager)(typeof cwd === "string" ? (
|
|
1204
|
+
// If a cwd was provided, use it
|
|
1205
|
+
{ cwd }
|
|
1206
|
+
) : (
|
|
1207
|
+
// Otherwise, try to find the ioBroker root dir
|
|
1208
|
+
{
|
|
1209
|
+
cwd: isDevServerInstallation() && require2.main?.path || thisDir,
|
|
1210
|
+
setCwdToPackageRoot: true
|
|
1211
|
+
}
|
|
1212
|
+
));
|
|
1201
1213
|
} catch {
|
|
1202
1214
|
}
|
|
1203
1215
|
const ioBrokerRootDir = getRootDir();
|
|
@@ -1345,7 +1357,7 @@ function generateDefaultCertificates() {
|
|
|
1345
1357
|
const cert = pki.createCertificate();
|
|
1346
1358
|
cert.publicKey = keys.publicKey;
|
|
1347
1359
|
cert.serialNumber = `0${makeid(17)}`;
|
|
1348
|
-
cert.validity.notBefore = new Date();
|
|
1360
|
+
cert.validity.notBefore = /* @__PURE__ */ new Date();
|
|
1349
1361
|
cert.validity.notAfter = new Date(Date.now() + MAX_CERT_VALIDITY);
|
|
1350
1362
|
const subAttrs = [
|
|
1351
1363
|
{ name: "commonName", value: getHostName() },
|
|
@@ -1441,7 +1453,7 @@ async function getHostInfo(objects) {
|
|
|
1441
1453
|
}
|
|
1442
1454
|
}
|
|
1443
1455
|
const cpus = import_node_os.default.cpus();
|
|
1444
|
-
const dateObj = new Date();
|
|
1456
|
+
const dateObj = /* @__PURE__ */ new Date();
|
|
1445
1457
|
const data = {
|
|
1446
1458
|
Platform: isDocker() ? "docker" : import_node_os.default.platform(),
|
|
1447
1459
|
os: process.platform,
|
|
@@ -1574,6 +1586,7 @@ function promisify(fn, context, returnArgNames) {
|
|
|
1574
1586
|
switch (arguments.length) {
|
|
1575
1587
|
case 1:
|
|
1576
1588
|
return resolve();
|
|
1589
|
+
// Promise<void>
|
|
1577
1590
|
case 2:
|
|
1578
1591
|
return resolve(result);
|
|
1579
1592
|
default: {
|
|
@@ -1608,6 +1621,7 @@ function promisifyNoError(fn, context, returnArgNames) {
|
|
|
1608
1621
|
switch (arguments.length) {
|
|
1609
1622
|
case 0:
|
|
1610
1623
|
return resolve();
|
|
1624
|
+
// Promise<void>
|
|
1611
1625
|
case 1:
|
|
1612
1626
|
return resolve(result);
|
|
1613
1627
|
default: {
|
|
@@ -1949,7 +1963,8 @@ function validateGeneralObjectProperties(obj, extend2) {
|
|
|
1949
1963
|
if (obj.type === "state" && obj.common.custom !== void 0 && obj.common.custom !== null && !isObject(obj.common.custom)) {
|
|
1950
1964
|
throw new Error(`obj.common.custom has an invalid type! Expected "object", received "${typeof obj.common.custom}"`);
|
|
1951
1965
|
}
|
|
1952
|
-
if (obj.common.states !== null &&
|
|
1966
|
+
if (obj.common.states !== null && // we allow null for deletion TODO: implement https://github.com/ioBroker/ioBroker.js-controller/issues/1735
|
|
1967
|
+
obj.common.states !== void 0 && !isObject(obj.common.states) && !Array.isArray(obj.common.states)) {
|
|
1953
1968
|
throw new Error(`obj.common.states has an invalid type! Expected "object", received "${typeof obj.common.states}"`);
|
|
1954
1969
|
}
|
|
1955
1970
|
}
|
|
@@ -2009,7 +2024,9 @@ async function getInstances(adapter, objects, withObjects) {
|
|
|
2009
2024
|
}
|
|
2010
2025
|
function execAsync(command, execOptions) {
|
|
2011
2026
|
const defaultOptions = {
|
|
2027
|
+
// we do not want to show the node.js window on Windows
|
|
2012
2028
|
windowsHide: true,
|
|
2029
|
+
// And we want to capture stdout/stderr
|
|
2013
2030
|
encoding: "utf8"
|
|
2014
2031
|
};
|
|
2015
2032
|
return (0, import_promisify_child_process.exec)(command, { ...defaultOptions, ...execOptions });
|
|
@@ -2076,6 +2093,7 @@ function getDefaultNodeArgs(mainFile) {
|
|
|
2076
2093
|
}
|
|
2077
2094
|
function getDefaultRequireResolvePaths(callerModule) {
|
|
2078
2095
|
const ret = [
|
|
2096
|
+
// This is the default for require.resolve
|
|
2079
2097
|
...callerModule.paths
|
|
2080
2098
|
];
|
|
2081
2099
|
if (process.execArgv.includes("--preserve-symlinks") && require2.main) {
|
|
@@ -2425,14 +2443,14 @@ async function updateLicenses(objects, login, password2) {
|
|
|
2425
2443
|
}
|
|
2426
2444
|
}
|
|
2427
2445
|
});
|
|
2428
|
-
systemLicenses.native.readTime = new Date().toISOString();
|
|
2446
|
+
systemLicenses.native.readTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
2429
2447
|
await objects.setObjectAsync("system.licenses", systemLicenses);
|
|
2430
2448
|
return licenses;
|
|
2431
2449
|
} catch (err) {
|
|
2432
2450
|
if (err.message.includes("Authentication required") || err.message.includes("Cannot decode password:")) {
|
|
2433
2451
|
if (systemLicenses && systemLicenses.native && systemLicenses.native.licenses && systemLicenses.native.licenses.length) {
|
|
2434
2452
|
systemLicenses.native.licenses = [];
|
|
2435
|
-
systemLicenses.native.readTime = new Date().toISOString();
|
|
2453
|
+
systemLicenses.native.readTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
2436
2454
|
await objects.setObjectAsync("system.licenses", systemLicenses);
|
|
2437
2455
|
}
|
|
2438
2456
|
}
|
|
@@ -2441,7 +2459,7 @@ async function updateLicenses(objects, login, password2) {
|
|
|
2441
2459
|
} else {
|
|
2442
2460
|
if (systemLicenses && systemLicenses.native && systemLicenses.native.licenses && systemLicenses.native.licenses.length) {
|
|
2443
2461
|
systemLicenses.native.licenses = [];
|
|
2444
|
-
systemLicenses.native.readTime = new Date().toISOString();
|
|
2462
|
+
systemLicenses.native.readTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
2445
2463
|
await objects.setObjectAsync("system.licenses", systemLicenses);
|
|
2446
2464
|
}
|
|
2447
2465
|
throw new Error("No password or login");
|
|
@@ -2694,6 +2712,7 @@ async function getControllerPid() {
|
|
|
2694
2712
|
upToDate,
|
|
2695
2713
|
updateLicenses,
|
|
2696
2714
|
validateDataDir,
|
|
2697
|
-
validateGeneralObjectProperties
|
|
2715
|
+
validateGeneralObjectProperties,
|
|
2716
|
+
...require("../../lib/common/maybeCallback.js")
|
|
2698
2717
|
});
|
|
2699
2718
|
//# sourceMappingURL=tools.js.map
|