@iobroker/js-controller-adapter 7.2.3 → 8.0.0-alpha.2-20260923-99da17fcc
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.d.ts +0 -1
- package/build/cjs/index.js +5 -8
- package/build/cjs/index.js.map +2 -2
- package/build/cjs/lib/_Types.d.ts +394 -63
- package/build/cjs/lib/adapter/adapter.d.ts +1896 -177
- package/build/cjs/lib/adapter/adapter.js +788 -1035
- package/build/cjs/lib/adapter/adapter.js.map +2 -2
- package/build/cjs/lib/adapter/asyncAdapter.d.ts +167 -0
- package/build/cjs/lib/adapter/asyncAdapter.js +252 -0
- package/build/cjs/lib/adapter/asyncAdapter.js.map +7 -0
- package/build/cjs/lib/adapter/context.d.ts +34 -0
- package/build/cjs/lib/adapter/context.js +17 -0
- package/build/cjs/lib/adapter/context.js.map +7 -0
- package/build/cjs/lib/adapter/defaultObjs.d.ts +5 -0
- package/build/cjs/lib/adapter/defaultObjs.js +2 -0
- package/build/cjs/lib/adapter/defaultObjs.js.map +2 -2
- package/build/cjs/lib/adapter/log.d.ts +25 -0
- package/build/cjs/lib/adapter/log.js +29 -0
- package/build/cjs/lib/adapter/log.js.map +2 -2
- package/build/cjs/lib/adapter/managers/AdapterContextBase.d.ts +49 -0
- package/build/cjs/lib/adapter/managers/AdapterContextBase.js +98 -0
- package/build/cjs/lib/adapter/managers/AdapterContextBase.js.map +7 -0
- package/build/cjs/lib/adapter/managers/AliasManager.d.ts +103 -0
- package/build/cjs/lib/adapter/managers/AliasManager.js +293 -0
- package/build/cjs/lib/adapter/managers/AliasManager.js.map +7 -0
- package/build/cjs/lib/adapter/managers/CertificateManager.d.ts +50 -0
- package/build/cjs/lib/adapter/managers/CertificateManager.js +174 -0
- package/build/cjs/lib/adapter/managers/CertificateManager.js.map +7 -0
- package/build/cjs/lib/adapter/managers/MessagingManager.d.ts +58 -0
- package/build/cjs/lib/adapter/managers/MessagingManager.js +289 -0
- package/build/cjs/lib/adapter/managers/MessagingManager.js.map +7 -0
- package/build/cjs/lib/adapter/managers/ResourceManager.d.ts +69 -0
- package/build/cjs/lib/adapter/managers/ResourceManager.js +170 -0
- package/build/cjs/lib/adapter/managers/ResourceManager.js.map +7 -0
- package/build/cjs/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
- package/build/cjs/lib/adapter/managers/SubscriptionManager.js +349 -0
- package/build/cjs/lib/adapter/managers/SubscriptionManager.js.map +7 -0
- package/build/cjs/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
- package/build/cjs/lib/adapter/userInterfaceMessagingController.js +9 -2
- package/build/cjs/lib/adapter/userInterfaceMessagingController.js.map +2 -2
- package/build/cjs/lib/adapter/utils.js +15 -1
- package/build/cjs/lib/adapter/utils.js.map +2 -2
- package/build/cjs/lib/adapter/validator.d.ts +10 -5
- package/build/cjs/lib/adapter/validator.js +6 -5
- package/build/cjs/lib/adapter/validator.js.map +2 -2
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +0 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/lib/_Types.d.ts +394 -63
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.d.ts +1896 -177
- package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.js +900 -1215
- package/build/esm/lib/adapter/adapter.js.map +1 -1
- package/build/esm/lib/adapter/asyncAdapter.d.ts +167 -0
- package/build/esm/lib/adapter/asyncAdapter.d.ts.map +1 -0
- package/build/esm/lib/adapter/asyncAdapter.js +225 -0
- package/build/esm/lib/adapter/asyncAdapter.js.map +1 -0
- package/build/esm/lib/adapter/context.d.ts +34 -0
- package/build/esm/lib/adapter/context.d.ts.map +1 -0
- package/build/esm/lib/adapter/context.js +2 -0
- package/build/esm/lib/adapter/context.js.map +1 -0
- package/build/esm/lib/adapter/defaultObjs.d.ts +5 -0
- package/build/esm/lib/adapter/defaultObjs.d.ts.map +1 -1
- package/build/esm/lib/adapter/defaultObjs.js +5 -0
- package/build/esm/lib/adapter/defaultObjs.js.map +1 -1
- package/build/esm/lib/adapter/log.d.ts +25 -0
- package/build/esm/lib/adapter/log.d.ts.map +1 -1
- package/build/esm/lib/adapter/log.js +25 -0
- package/build/esm/lib/adapter/log.js.map +1 -1
- package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts +49 -0
- package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/AdapterContextBase.js +77 -0
- package/build/esm/lib/adapter/managers/AdapterContextBase.js.map +1 -0
- package/build/esm/lib/adapter/managers/AliasManager.d.ts +103 -0
- package/build/esm/lib/adapter/managers/AliasManager.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/AliasManager.js +269 -0
- package/build/esm/lib/adapter/managers/AliasManager.js.map +1 -0
- package/build/esm/lib/adapter/managers/CertificateManager.d.ts +50 -0
- package/build/esm/lib/adapter/managers/CertificateManager.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/CertificateManager.js +142 -0
- package/build/esm/lib/adapter/managers/CertificateManager.js.map +1 -0
- package/build/esm/lib/adapter/managers/MessagingManager.d.ts +58 -0
- package/build/esm/lib/adapter/managers/MessagingManager.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/MessagingManager.js +267 -0
- package/build/esm/lib/adapter/managers/MessagingManager.js.map +1 -0
- package/build/esm/lib/adapter/managers/ResourceManager.d.ts +69 -0
- package/build/esm/lib/adapter/managers/ResourceManager.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/ResourceManager.js +151 -0
- package/build/esm/lib/adapter/managers/ResourceManager.js.map +1 -0
- package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
- package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts.map +1 -0
- package/build/esm/lib/adapter/managers/SubscriptionManager.js +374 -0
- package/build/esm/lib/adapter/managers/SubscriptionManager.js.map +1 -0
- package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
- package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts.map +1 -1
- package/build/esm/lib/adapter/userInterfaceMessagingController.js +8 -2
- package/build/esm/lib/adapter/userInterfaceMessagingController.js.map +1 -1
- package/build/esm/lib/adapter/utils.d.ts.map +1 -1
- package/build/esm/lib/adapter/utils.js +1 -1
- package/build/esm/lib/adapter/utils.js.map +1 -1
- package/build/esm/lib/adapter/validator.d.ts +10 -5
- package/build/esm/lib/adapter/validator.d.ts.map +1 -1
- package/build/esm/lib/adapter/validator.js +8 -5
- package/build/esm/lib/adapter/validator.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +25 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/adapter/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n isObject,\n encrypt,\n decrypt,\n appNameLowerCase,\n getRootDir,\n execAsync,\n} from '@iobroker/js-controller-common-db/tools';\nimport { getSupportedFeatures as getSupportedFeaturesCommon } from '@iobroker/js-controller-common';\nimport path from 'node:path';\nimport fs from 'fs-extra';\n\ninterface EncryptArrayOptions {\n /** The objects whose values should be en/decrypted */\n obj: Record<string, unknown>;\n /** Keys which need to be en/decrypted */\n keys: string[];\n /** Secret to use for en/decryption */\n secret: string;\n}\n\ninterface GetScopedPackageIdentifierOptions {\n /** Name of the node module */\n moduleName: string;\n /** Adapter namespace */\n namespace: string;\n}\n\n/**\n * Check if messagebox is configured for given instance\n * This means, at least one of the properties has a value different from false\n *\n * @param instanceCommon Instance common\n */\nexport function isMessageboxSupported(instanceCommon: ioBroker.InstanceCommon): boolean {\n if (!isObject(instanceCommon.supportedMessages)) {\n return !!instanceCommon.messagebox;\n }\n\n return Object.values(instanceCommon.supportedMessages).find(val => val !== false) !== undefined;\n}\n\n/**\n * Get the supported features for the current running controller\n */\nexport function getSupportedFeatures(): ioBroker.SupportedFeature[] {\n return getSupportedFeaturesCommon();\n}\n\n/**\n * Encrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function encryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const encrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n encrypted[i] = typeof val[i] === 'string' ? encrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, encrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, encrypt(secret, val));\n }\n }\n}\n\n/**\n * Decrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function decryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const decrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n decrypted[i] = typeof val[i] === 'string' ? decrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, decrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, decrypt(secret, val));\n }\n }\n}\n\n/**\n * Transform a npm moduleName to the adapter scoped name, like `axios` to `@iobroker-javascript.0/axios`\n *\n * @param options name of the node module and namespace information\n */\nexport function getAdapterScopedPackageIdentifier(options: GetScopedPackageIdentifierOptions): string {\n const { moduleName, namespace } = options;\n\n let internalModuleName = moduleName;\n if (internalModuleName.startsWith('@')) {\n internalModuleName = internalModuleName.substring(1).replace(/\\//g, '-');\n }\n\n return `@${appNameLowerCase}-${namespace}/${internalModuleName}`;\n}\n\n/**\n * List all packages installed in the given adapter namespace\n *\n * @param namespace namespace to check installed modules for\n */\nexport async function listInstalledNodeModules(namespace: string): Promise<string[]> {\n const packJson = (await fs.readJson(path.join(getRootDir(), 'package.json'))) as {\n dependencies: Record<string, string>;\n };\n const dependencies: string[] = [];\n\n for (const [dependency, versionInfo] of Object.entries(packJson.dependencies)) {\n if (!dependency.startsWith(`@${appNameLowerCase}-${namespace}/`)) {\n continue;\n }\n\n let realDependencyName: string;\n // remove npm: and version after last @\n if (versionInfo.startsWith('npm:')) {\n realDependencyName = versionInfo.substring(4, versionInfo.lastIndexOf('@'));\n } else {\n realDependencyName = await requestModuleNameByUrl(versionInfo);\n }\n\n dependencies.push(realDependencyName);\n }\n\n return dependencies;\n}\n\n/**\n * Request a module name by given url using `npm view`\n *\n * @param url the url to the package which should be installed via npm\n */\nexport async function requestModuleNameByUrl(url: string): Promise<string> {\n const res = await execAsync(`npm view ${url} name`);\n\n if (typeof res.stdout !== 'string') {\n throw new Error(
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n isObject,\n encrypt,\n decrypt,\n appNameLowerCase,\n getRootDir,\n execAsync,\n} from '@iobroker/js-controller-common-db/tools';\nimport { getSupportedFeatures as getSupportedFeaturesCommon } from '@iobroker/js-controller-common';\nimport path from 'node:path';\nimport fs from 'fs-extra';\n\ninterface EncryptArrayOptions {\n /** The objects whose values should be en/decrypted */\n obj: Record<string, unknown>;\n /** Keys which need to be en/decrypted */\n keys: string[];\n /** Secret to use for en/decryption */\n secret: string;\n}\n\ninterface GetScopedPackageIdentifierOptions {\n /** Name of the node module */\n moduleName: string;\n /** Adapter namespace */\n namespace: string;\n}\n\n/**\n * Check if messagebox is configured for given instance\n * This means, at least one of the properties has a value different from false\n *\n * @param instanceCommon Instance common\n */\nexport function isMessageboxSupported(instanceCommon: ioBroker.InstanceCommon): boolean {\n if (!isObject(instanceCommon.supportedMessages)) {\n return !!instanceCommon.messagebox;\n }\n\n return Object.values(instanceCommon.supportedMessages).find(val => val !== false) !== undefined;\n}\n\n/**\n * Get the supported features for the current running controller\n */\nexport function getSupportedFeatures(): ioBroker.SupportedFeature[] {\n return getSupportedFeaturesCommon();\n}\n\n/**\n * Encrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function encryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const encrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n encrypted[i] = typeof val[i] === 'string' ? encrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, encrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, encrypt(secret, val));\n }\n }\n}\n\n/**\n * Decrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function decryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const decrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n decrypted[i] = typeof val[i] === 'string' ? decrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, decrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, decrypt(secret, val));\n }\n }\n}\n\n/**\n * Transform a npm moduleName to the adapter scoped name, like `axios` to `@iobroker-javascript.0/axios`\n *\n * @param options name of the node module and namespace information\n */\nexport function getAdapterScopedPackageIdentifier(options: GetScopedPackageIdentifierOptions): string {\n const { moduleName, namespace } = options;\n\n let internalModuleName = moduleName;\n if (internalModuleName.startsWith('@')) {\n internalModuleName = internalModuleName.substring(1).replace(/\\//g, '-');\n }\n\n return `@${appNameLowerCase}-${namespace}/${internalModuleName}`;\n}\n\n/**\n * List all packages installed in the given adapter namespace\n *\n * @param namespace namespace to check installed modules for\n */\nexport async function listInstalledNodeModules(namespace: string): Promise<string[]> {\n const packJson = (await fs.readJson(path.join(getRootDir(), 'package.json'))) as {\n dependencies: Record<string, string>;\n };\n const dependencies: string[] = [];\n\n for (const [dependency, versionInfo] of Object.entries(packJson.dependencies)) {\n if (!dependency.startsWith(`@${appNameLowerCase}-${namespace}/`)) {\n continue;\n }\n\n let realDependencyName: string;\n // remove npm: and version after last @\n if (versionInfo.startsWith('npm:')) {\n realDependencyName = versionInfo.substring(4, versionInfo.lastIndexOf('@'));\n } else {\n realDependencyName = await requestModuleNameByUrl(versionInfo);\n }\n\n dependencies.push(realDependencyName);\n }\n\n return dependencies;\n}\n\n/**\n * Request a module name by given url using `npm view`\n *\n * @param url the url to the package which should be installed via npm\n */\nexport async function requestModuleNameByUrl(url: string): Promise<string> {\n const res = await execAsync(`npm view ${url} name`);\n\n if (typeof res.stdout !== 'string') {\n throw new Error(`Could not determine module name for url \"${url}\". Unexpected stdout: \"${typeof res.stdout}\"`);\n }\n\n return res.stdout.trim();\n}\n\n/**\n * Get attribute of an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _getObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n return obj[attrParts[index]];\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n const result: any = [];\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n result.push(_getObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1));\n }\n return result;\n }\n\n return _getObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Get attribute of an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @returns could be a value or an array\n */\nexport function getObjectAttribute(obj: Record<string, any>, attr: string): any {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n return obj[attr];\n }\n return _getObjectAttribute(obj, attr.split('.'), 0);\n}\n\n/**\n * Set attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param value - value to set (Could be an array)\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _setObjectAttribute(obj: Record<string, any>, value: any, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n obj[attrParts[index]] = value;\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n if (!Array.isArray(value)) {\n throw new Error('Value is not an array');\n }\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _setObjectAttribute(obj[attrParts[index]][i], value[i], attrParts, index + 1);\n }\n return;\n }\n\n _setObjectAttribute(obj[attrParts[index]], value, attrParts, index + 1);\n}\n\n/**\n * Set attribute in an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @param value - value to set (could be a value or an array)\n */\nexport function setObjectAttribute(obj: Record<string, any>, attr: string, value: any): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n obj[attr] = value;\n return;\n }\n _setObjectAttribute(obj, value, attr.split('.'), 0);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _deleteObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n delete obj[attrParts[index]];\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _deleteObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1);\n }\n return;\n }\n\n _deleteObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n */\nexport function deleteObjectAttribute(obj: Record<string, any>, attr: string): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n delete obj[attr];\n return;\n }\n\n _deleteObjectAttribute(obj, attr.split('.'), 0);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAAA,mBAOO;AACP,kCAAm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AAC;AAC1E;AAnBS;AA4BH,SAAU,mBAAmB,KAA0B,MAAc,OAAU;AAEjF,MAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AACrB,QAAI,IAAI,IAAI;AACZ;EACJ;AACA,sBAAoB,KAAK,OAAO,KAAK,MAAM,GAAG,GAAG,CAAC;AACtD;AAPgB;AAgBhB,SAAS,uBAAuB,KAA0B,WAAqB,OAAa;AACxF,MAAI,UAAU,UAAU,SAAS,GAAG;AAChC,WAAO,IAAI,UAAU,KAAK,CAAC;AAC3B;EACJ;AACA,MAAI,CAAC,IAAI,UAAU,KAAK,CAAC,KAAK,OAAO,IAAI,UAAU,KAAK,CAAC,MAAM,UAAU;AACrE;EACJ;AACA,MAAI,MAAM,QAAQ,IAAI,UAAU,KAAK,CAAC,CAAC,GAAG;AACtC,aAAS,IAAI,GAAG,IAAI,IAAI,UAAU,KAAK,CAAC,EAAE,QAAQ,KAAK;AACnD,6BAAuB,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC,GAAG,WAAW,QAAQ,CAAC;IACzE;AACA;EACJ;AAEA,yBAAuB,IAAI,UAAU,KAAK,CAAC,GAAG,WAAW,QAAQ,CAAC;AACtE;AAhBS;AAwBH,SAAU,sBAAsB,KAA0B,MAAY;AAExE,MAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AACrB,WAAO,IAAI,IAAI;AACf;EACJ;AAEA,yBAAuB,KAAK,KAAK,MAAM,GAAG,GAAG,CAAC;AAClD;AARgB;",
|
|
6
6
|
"names": ["getSupportedFeaturesCommon", "fs", "path"]
|
|
7
7
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import type { Client as ObjectsInRedisClient } from '../../../../db-objects-redis/src/index.js';
|
|
1
2
|
type Callback = (...args: any[]) => void | Promise<void>;
|
|
2
3
|
type OptionalCallback = undefined | Callback;
|
|
3
4
|
type Pattern = string | string[];
|
|
5
|
+
/** Options for validating an object/state id */
|
|
4
6
|
export interface ValidateIdOptions {
|
|
5
7
|
/** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */
|
|
6
8
|
maintenance?: boolean;
|
|
7
9
|
/** User used to check for access rights */
|
|
8
10
|
user?: string;
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Validates arguments passed to the adapter's public methods
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
10
17
|
export declare class Validator {
|
|
11
18
|
private readonly objects;
|
|
12
|
-
private readonly states;
|
|
13
19
|
private readonly namespaceLog;
|
|
14
20
|
private readonly log;
|
|
15
21
|
private readonly namespace;
|
|
@@ -18,13 +24,12 @@ export declare class Validator {
|
|
|
18
24
|
* Validator for internal adapter.js usage
|
|
19
25
|
*
|
|
20
26
|
* @param objects - Objects DB
|
|
21
|
-
* @param states - States DB
|
|
22
27
|
* @param namespaceLog - Log prefix
|
|
23
28
|
* @param logger - Logger instance
|
|
24
29
|
* @param namespace - the namespace of the adapter
|
|
25
30
|
* @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`
|
|
26
31
|
*/
|
|
27
|
-
constructor(objects:
|
|
32
|
+
constructor(objects: ObjectsInRedisClient, namespaceLog: string, logger: ioBroker.Logger, namespace: string, namespaceRegExp: RegExp);
|
|
28
33
|
/**
|
|
29
34
|
* Performs the strict object check, which includes checking object existence, read-only logic, type and min/max
|
|
30
35
|
* additionally it rounds state values whose objects have a `common.step` attribute defined
|
|
@@ -39,9 +44,9 @@ export declare class Validator {
|
|
|
39
44
|
* @param id id to check or object with properties device, channel and state
|
|
40
45
|
* @param isForeignId true&false if the ID is a foreign/full ID or only an "adapter local" id
|
|
41
46
|
* @param options optional
|
|
42
|
-
* @throws Error when id is invalid
|
|
47
|
+
* @throws {Error} when id is invalid
|
|
43
48
|
*/
|
|
44
|
-
validateId(id:
|
|
49
|
+
validateId(id: string, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string;
|
|
45
50
|
/**
|
|
46
51
|
* Look up the error description for an error code
|
|
47
52
|
*
|
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -24,8 +25,10 @@ module.exports = __toCommonJS(validator_exports);
|
|
|
24
25
|
var import_constants = require("../../lib/adapter/constants.js");
|
|
25
26
|
var import_js_controller_common = require("@iobroker/js-controller-common");
|
|
26
27
|
class Validator {
|
|
28
|
+
static {
|
|
29
|
+
__name(this, "Validator");
|
|
30
|
+
}
|
|
27
31
|
objects;
|
|
28
|
-
states;
|
|
29
32
|
namespaceLog;
|
|
30
33
|
log;
|
|
31
34
|
namespace;
|
|
@@ -34,15 +37,13 @@ class Validator {
|
|
|
34
37
|
* Validator for internal adapter.js usage
|
|
35
38
|
*
|
|
36
39
|
* @param objects - Objects DB
|
|
37
|
-
* @param states - States DB
|
|
38
40
|
* @param namespaceLog - Log prefix
|
|
39
41
|
* @param logger - Logger instance
|
|
40
42
|
* @param namespace - the namespace of the adapter
|
|
41
43
|
* @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`
|
|
42
44
|
*/
|
|
43
|
-
constructor(objects,
|
|
45
|
+
constructor(objects, namespaceLog, logger, namespace, namespaceRegExp) {
|
|
44
46
|
this.objects = objects;
|
|
45
|
-
this.states = states;
|
|
46
47
|
this.namespaceLog = namespaceLog;
|
|
47
48
|
this.namespace = namespace;
|
|
48
49
|
this.namespaceRegExp = namespaceRegExp;
|
|
@@ -103,7 +104,7 @@ class Validator {
|
|
|
103
104
|
* @param id id to check or object with properties device, channel and state
|
|
104
105
|
* @param isForeignId true&false if the ID is a foreign/full ID or only an "adapter local" id
|
|
105
106
|
* @param options optional
|
|
106
|
-
* @throws Error when id is invalid
|
|
107
|
+
* @throws {Error} when id is invalid
|
|
107
108
|
*/
|
|
108
109
|
validateId(id, isForeignId, options) {
|
|
109
110
|
if (options && options.maintenance && options.user === import_constants.SYSTEM_ADMIN_USER) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/adapter/validator.ts"],
|
|
4
|
-
"sourcesContent": ["import { MAX_TIMEOUT, SYSTEM_ADMIN_USER } from '@/lib/adapter/constants.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\n\ntype Callback = (...args: any[]) => void | Promise<void>;\ntype OptionalCallback = undefined | Callback;\ntype Pattern = string | string[];\n\nexport interface ValidateIdOptions {\n /** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */\n maintenance?: boolean;\n /** User used to check for access rights */\n user?: string;\n}\n\nexport class Validator {\n private readonly objects: any;\n private readonly states: any;\n private readonly namespaceLog: string;\n private readonly log: any;\n private readonly namespace: string;\n private readonly namespaceRegExp: RegExp;\n\n /**\n * Validator for internal adapter.js usage\n *\n * @param objects - Objects DB\n * @param states - States DB\n * @param namespaceLog - Log prefix\n * @param logger - Logger instance\n * @param namespace - the namespace of the adapter\n * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`\n */\n constructor(\n objects: any,\n states: any,\n namespaceLog: string,\n logger: any,\n namespace: string,\n namespaceRegExp: RegExp,\n ) {\n this.objects = objects;\n this.states = states;\n this.namespaceLog = namespaceLog;\n this.namespace = namespace;\n this.namespaceRegExp = namespaceRegExp;\n this.log = logger;\n }\n\n /**\n * Performs the strict object check, which includes checking object existence, read-only logic, type and min/max\n * additionally it rounds state values whose objects have a `common.step` attribute defined\n *\n * @param id - id of the state\n * @param state - ioBroker setState object\n */\n async performStrictObjectCheck(id: string, state: ioBroker.SettableState): Promise<void> {\n // TODO: in js-c 3.5 (or 2 releases after 3.3) we should let it throw and add tests, maybe we\n // can already let the non existing object case throw with 3.4 because this is already producing a warning\n try {\n if (state.val === undefined) {\n // only ack etc. is also possible to acknowledge the current value,\n // if only undefined provided, it should have thrown before\n return;\n }\n\n const obj = await this.objects.getObjectAsync(id);\n // at first check object existence\n if (!obj) {\n this.log.warn(\n `${this.namespaceLog} State \"${id}\" has no existing object, this might lead to an error in future versions`,\n );\n return;\n }\n\n // for a state object, we require common.type to exist\n if (obj.common?.type) {\n // check if we are allowed to write (read-only can only be written with ack: true)\n if (!state.ack && obj.common.write === false) {\n this.log.warn(\n `${this.namespaceLog} Read-only state \"${id}\" has been written without ack-flag with value \"${state.val}\"`,\n );\n }\n\n if (state.val !== null) {\n // now check if a type is correct, null is always allowed\n if (\n !(\n (obj.common.type === 'mixed' && typeof state.val !== 'object') ||\n (obj.common.type !== 'object' && obj.common.type === typeof state.val) ||\n (obj.common.type === 'array' && typeof state.val === 'string') ||\n (obj.common.type === 'json' && typeof state.val === 'string') ||\n (obj.common.type === 'object' && typeof state.val === 'string')\n )\n ) {\n // types can be 'number', 'string', 'boolean', 'array', 'object', 'mixed', 'json';\n // 'array', 'object', 'json' need to be string\n if (['object', 'json', 'array'].includes(obj.common.type)) {\n this.log.info(\n `${\n this.namespaceLog\n } State value to set for \"${id}\" has to be stringified but received type \"${typeof state.val}\"`,\n );\n } else {\n this.log.info(\n `${this.namespaceLog} State value to set for \"${id}\" has to be ${\n obj.common.type === 'mixed'\n ? `one of type \"string\", \"number\", \"boolean\"`\n : `type \"${obj.common.type}\"`\n } but received type \"${typeof state.val}\" `,\n );\n }\n }\n\n // now round step and check min/max if it's a number\n if (typeof state.val === 'number') {\n if (typeof obj.common.step === 'number' && obj.common.step > 0) {\n // round to next step\n const inv = 1 / obj.common.step;\n state.val = Math.round(state.val * inv) / inv;\n }\n\n if (obj.common.max !== undefined && state.val > obj.common.max) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" greater than max \"${obj.common.max}\"`,\n );\n }\n\n if (obj.common.min !== undefined && state.val < obj.common.min) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" less than min \"${obj.common.min}\"`,\n );\n }\n }\n }\n } else {\n this.log.warn(\n `${this.namespaceLog} Object of state \"${id}\" is missing the required property \"common.type\"`,\n );\n }\n } catch (e) {\n this.log.warn(`${this.namespaceLog} Could not perform strict object check of state ${id}: ${e.message}`);\n }\n }\n\n /**\n * Checks if a passed ID is valid. Throws an error if id is invalid\n *\n * @param id id to check or object with properties device, channel and state\n * @param isForeignId true&false if the ID is a foreign/full ID or only an \"adapter local\" id\n * @param options optional\n * @throws Error when id is invalid\n */\n validateId(id: any, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string {\n // there is a special maintenance mode to clear the DB from invalid IDs\n if (options && options.maintenance && options.user === SYSTEM_ADMIN_USER) {\n return;\n }\n\n if (!id && id !== 0) {\n throw new Error('The id is empty! Please provide a valid id.');\n }\n\n const type = typeof id;\n\n if (!isForeignId && type === 'number') {\n this.log.warn(\n `${this.namespaceLog} The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"number\".`,\n );\n this.log.warn(\n `${this.namespaceLog} This will be refused in future versions. Please report this to the developer.`,\n );\n } else if (type !== 'string' && !tools.isObject(id)) {\n throw new Error(`The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"${type}\".`);\n }\n\n if (tools.isObject(id)) {\n // id can be an object, at least one of the following properties has to exist\n const reqProperties = ['device', 'channel', 'state'];\n let found = false;\n for (const reqProperty of reqProperties) {\n if (id[reqProperty] !== undefined) {\n if (typeof id[reqProperty] !== 'string') {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" has an invalid type! Expected \"string\", received \"${typeof id[reqProperty]}\".`,\n );\n }\n\n if (id[reqProperty].includes('.')) {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" contains the invalid character \".\"!`,\n );\n }\n found = true;\n }\n }\n if (!found) {\n throw new Error(\n `The id \"${JSON.stringify(\n id,\n )}\" is an invalid object! Expected at least one of the properties \"device\", \"channel\" or \"state\" to exist.`,\n );\n }\n } else {\n if (type !== 'string') {\n throw new Error(\n `The id \"${JSON.stringify(id)}\" has an invalid type! Expected \"string\", received \"${type}\".`,\n );\n }\n if (id.endsWith('.')) {\n throw new Error(`The id \"${id}\" is invalid. Ids are not allowed to end in \".\"`);\n }\n }\n }\n\n /**\n * Look up the error description for an error code\n *\n * @param code error code\n * @returns error description\n */\n static getErrorText(code: number): string {\n code = code || 0;\n return (EXIT_CODES[code] || code).toString();\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertString(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not a pattern\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertPattern(value: unknown, name: string): asserts value is Pattern {\n if (typeof value !== 'string' && !Array.isArray(value)) {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", \"${typeof value}\" has been passed`,\n );\n } else if (Array.isArray(value)) {\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", but the array contains a value of type \"${typeof value}\"`,\n );\n }\n }\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBoolean(value: unknown, name: string): asserts value is boolean {\n if (typeof value !== 'boolean') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"boolean\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertNumber(value: unknown, name: string): asserts value is number {\n if (typeof value !== 'number') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"number\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertObject<T extends Record<string, any> = Record<string, any>>(\n value: unknown,\n name: string,\n ): asserts value is T {\n if (!tools.isObject(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a real object but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBuffer(value: unknown, name: string): asserts value is Buffer {\n if (!Buffer.isBuffer(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a Buffer but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertOptionalCallback(value: unknown, name: string): asserts value is OptionalCallback {\n if (value && typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"null\", \"undefined\" or \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertCallback(value: unknown, name: string): asserts value is Callback {\n if (typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Adds the namespace to the ID if it is missing, if an object is passed it will be converted to an id string\n *\n * @param id id which will be fixed\n * @param isPattern if the id is a pattern\n */\n fixId(id: string | ioBroker.IdObject, isPattern = false): string {\n if (!id) {\n id = '';\n }\n\n let result = '';\n if (typeof id === 'string') {\n result = id;\n\n // if not the instance name itself and also not starts with namespace and \".\"\n if (id !== this.namespace && !this.namespaceRegExp.test(id)) {\n if (!isPattern) {\n result = this.namespace + (id ? `.${id}` : '');\n } else {\n result = `${this.namespace}.${id ? id : ''}`;\n }\n }\n } else if (tools.isObject(id)) {\n // If ID is an object\n // Add namespace + device + channel\n result = `${this.namespace}.${id.device ? `${id.device}.` : ''}${id.channel ? `${id.channel}.` : ''}${\n id.state ? id.state : ''\n }`;\n }\n return result;\n }\n\n /**\n * Validates the object-type argument that is passed to setState\n *\n * @param obj object to validate\n */\n validateSetStateObjectArgument(obj: Record<string, any>): void {\n // Check that we have at least one existing non-undefined property at all, else invalid\n if (!Object.values(obj).some(prop => prop !== undefined)) {\n throw new Error(`The state contains no properties! At least one property is expected!`);\n }\n\n /*\n The following object parameters and types are allowed:\n val: any, (optional)\n ack: boolean, (optional)\n ts: number, (optional)\n q: number, (optional)\n from: string, (optional)\n c: string, (optional)\n expire: number (optional)\n lc: number (optional)\n user: string (optional)\n\n Everything else is forbidden\n */\n const optionalProperties: Record<string, string> = {\n val: 'any',\n ack: 'boolean',\n ts: 'number',\n q: 'number',\n from: 'string',\n c: 'string',\n expire: 'number',\n lc: 'number',\n user: 'string',\n };\n\n // Are there any forbidden properties?\n const forbiddenProperties = Object.keys(obj).filter(k => !optionalProperties[k]);\n if (forbiddenProperties.length) {\n throw new Error(`The state contains the forbidden properties ${forbiddenProperties.join(', ')}!`);\n }\n // Do all properties have the correct type?\n for (const [key, type] of Object.entries(optionalProperties)) {\n // any permits all types\n if (type === 'any') {\n continue;\n }\n // don't flag optional properties when they don't exist or are undefined\n if (!(key in obj) || obj[key] === undefined) {\n continue;\n }\n if (type !== typeof obj[key]) {\n throw new Error(\n `The state property \"${key}\" has the wrong type \"${typeof obj[key]}\" (should be \"${type}\")!`,\n );\n }\n }\n }\n\n /**\n * Validates that the timeout is not exceeding a 32-bit signed integer\n *\n * @param ms milliseconds to validate\n */\n static assertTimeout(ms: number): void {\n if (ms > MAX_TIMEOUT) {\n throw new Error(`Timeout (${ms}) is larger than a 32-bit signed integer (${MAX_TIMEOUT})`);\n }\n\n if (ms < 0) {\n throw new Error(`Timeout (${ms}) is smaller than 0`);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { MAX_TIMEOUT, SYSTEM_ADMIN_USER } from '@/lib/adapter/constants.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsInRedisClient } from '../../../../db-objects-redis/src/index.js';\n\ntype Callback = (...args: any[]) => void | Promise<void>;\ntype OptionalCallback = undefined | Callback;\ntype Pattern = string | string[];\n\n/** Options for validating an object/state id */\nexport interface ValidateIdOptions {\n /** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */\n maintenance?: boolean;\n /** User used to check for access rights */\n user?: string;\n}\n\n/**\n * Validates arguments passed to the adapter's public methods\n *\n * @internal\n */\nexport class Validator {\n private readonly objects: ObjectsInRedisClient;\n private readonly namespaceLog: string;\n private readonly log: ioBroker.Logger;\n private readonly namespace: string;\n private readonly namespaceRegExp: RegExp;\n\n /**\n * Validator for internal adapter.js usage\n *\n * @param objects - Objects DB\n * @param namespaceLog - Log prefix\n * @param logger - Logger instance\n * @param namespace - the namespace of the adapter\n * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`\n */\n constructor(\n objects: ObjectsInRedisClient,\n namespaceLog: string,\n logger: ioBroker.Logger,\n namespace: string,\n namespaceRegExp: RegExp,\n ) {\n this.objects = objects;\n this.namespaceLog = namespaceLog;\n this.namespace = namespace;\n this.namespaceRegExp = namespaceRegExp;\n this.log = logger;\n }\n\n /**\n * Performs the strict object check, which includes checking object existence, read-only logic, type and min/max\n * additionally it rounds state values whose objects have a `common.step` attribute defined\n *\n * @param id - id of the state\n * @param state - ioBroker setState object\n */\n async performStrictObjectCheck(id: string, state: ioBroker.SettableState): Promise<void> {\n // TODO: in js-c 3.5 (or 2 releases after 3.3) we should let it throw and add tests, maybe we\n // can already let the non existing object case throw with 3.4 because this is already producing a warning\n try {\n if (state.val === undefined) {\n // only ack etc. is also possible to acknowledge the current value,\n // if only undefined provided, it should have thrown before\n return;\n }\n\n const obj = await this.objects.getObjectAsync(id);\n // at first check object existence\n if (!obj) {\n this.log.warn(\n `${this.namespaceLog} State \"${id}\" has no existing object, this might lead to an error in future versions`,\n );\n return;\n }\n\n // for a state object, we require common.type to exist\n if (obj.common?.type) {\n // check if we are allowed to write (read-only can only be written with ack: true)\n if (!state.ack && obj.common.write === false) {\n this.log.warn(\n `${this.namespaceLog} Read-only state \"${id}\" has been written without ack-flag with value \"${state.val}\"`,\n );\n }\n\n if (state.val !== null) {\n // now check if a type is correct, null is always allowed\n if (!(\n (obj.common.type === 'mixed' && typeof state.val !== 'object') ||\n (obj.common.type !== 'object' && obj.common.type === typeof state.val) ||\n (obj.common.type === 'array' && typeof state.val === 'string') ||\n (obj.common.type === 'json' && typeof state.val === 'string') ||\n (obj.common.type === 'object' && typeof state.val === 'string')\n )) {\n // types can be 'number', 'string', 'boolean', 'array', 'object', 'mixed', 'json';\n // 'array', 'object', 'json' need to be string\n if (['object', 'json', 'array'].includes(obj.common.type)) {\n this.log.info(\n `${\n this.namespaceLog\n } State value to set for \"${id}\" has to be stringified but received type \"${typeof state.val}\"`,\n );\n } else {\n this.log.info(\n `${this.namespaceLog} State value to set for \"${id}\" has to be ${\n obj.common.type === 'mixed'\n ? `one of type \"string\", \"number\", \"boolean\"`\n : `type \"${obj.common.type}\"`\n } but received type \"${typeof state.val}\" `,\n );\n }\n }\n\n // now round step and check min/max if it's a number\n if (typeof state.val === 'number') {\n if (typeof obj.common.step === 'number' && obj.common.step > 0) {\n // round to next step\n const inv = 1 / obj.common.step;\n state.val = Math.round(state.val * inv) / inv;\n }\n\n if (obj.common.max !== undefined && state.val > obj.common.max) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" greater than max \"${obj.common.max}\"`,\n );\n }\n\n if (obj.common.min !== undefined && state.val < obj.common.min) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" less than min \"${obj.common.min}\"`,\n );\n }\n }\n }\n } else {\n this.log.warn(\n `${this.namespaceLog} Object of state \"${id}\" is missing the required property \"common.type\"`,\n );\n }\n } catch (e) {\n this.log.warn(`${this.namespaceLog} Could not perform strict object check of state ${id}: ${e.message}`);\n }\n }\n\n /**\n * Checks if a passed ID is valid. Throws an error if id is invalid\n *\n * @param id id to check or object with properties device, channel and state\n * @param isForeignId true&false if the ID is a foreign/full ID or only an \"adapter local\" id\n * @param options optional\n * @throws {Error} when id is invalid\n */\n validateId(id: string, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string {\n // there is a special maintenance mode to clear the DB from invalid IDs\n if (options && options.maintenance && options.user === SYSTEM_ADMIN_USER) {\n return;\n }\n\n // @ts-expect-error could happen\n if (!id && id !== 0) {\n throw new Error('The id is empty! Please provide a valid id.');\n }\n\n const type = typeof id;\n\n if (!isForeignId && type === 'number') {\n this.log.warn(\n `${this.namespaceLog} The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"number\".`,\n );\n this.log.warn(\n `${this.namespaceLog} This will be refused in future versions. Please report this to the developer.`,\n );\n } else if (type !== 'string' && !tools.isObject(id)) {\n throw new Error(`The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"${type}\".`);\n }\n\n if (tools.isObject(id)) {\n // id can be an object, at least one of the following properties has to exist\n const reqProperties = ['device', 'channel', 'state'];\n let found = false;\n for (const reqProperty of reqProperties) {\n if (id[reqProperty] !== undefined) {\n if (typeof id[reqProperty] !== 'string') {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" has an invalid type! Expected \"string\", received \"${typeof id[reqProperty]}\".`,\n );\n }\n\n if (id[reqProperty].includes('.')) {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" contains the invalid character \".\"!`,\n );\n }\n found = true;\n }\n }\n if (!found) {\n throw new Error(\n `The id \"${JSON.stringify(\n id,\n )}\" is an invalid object! Expected at least one of the properties \"device\", \"channel\" or \"state\" to exist.`,\n );\n }\n } else {\n if (type !== 'string') {\n throw new Error(\n `The id \"${JSON.stringify(id)}\" has an invalid type! Expected \"string\", received \"${type}\".`,\n );\n }\n if (id.endsWith('.')) {\n throw new Error(`The id \"${id}\" is invalid. Ids are not allowed to end in \".\"`);\n }\n }\n }\n\n /**\n * Look up the error description for an error code\n *\n * @param code error code\n * @returns error description\n */\n static getErrorText(code: number): string {\n code = code || 0;\n return (EXIT_CODES[code] || code).toString();\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertString(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not a pattern\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertPattern(value: unknown, name: string): asserts value is Pattern {\n if (typeof value !== 'string' && !Array.isArray(value)) {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", \"${typeof value}\" has been passed`,\n );\n } else if (Array.isArray(value)) {\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", but the array contains a value of type \"${typeof value}\"`,\n );\n }\n }\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBoolean(value: unknown, name: string): asserts value is boolean {\n if (typeof value !== 'boolean') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"boolean\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertNumber(value: unknown, name: string): asserts value is number {\n if (typeof value !== 'number') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"number\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertObject<T extends Record<string, any> = Record<string, any>>(\n value: unknown,\n name: string,\n ): asserts value is T {\n if (!tools.isObject(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a real object but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBuffer(value: unknown, name: string): asserts value is Buffer {\n if (!Buffer.isBuffer(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a Buffer but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertOptionalCallback(value: unknown, name: string): asserts value is OptionalCallback {\n if (value && typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"null\", \"undefined\" or \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertCallback(value: unknown, name: string): asserts value is Callback {\n if (typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Adds the namespace to the ID if it is missing, if an object is passed it will be converted to an id string\n *\n * @param id id which will be fixed\n * @param isPattern if the id is a pattern\n */\n fixId(id: string | ioBroker.IdObject, isPattern = false): string {\n if (!id) {\n id = '';\n }\n\n let result = '';\n if (typeof id === 'string') {\n result = id;\n\n // if not the instance name itself and also not starts with namespace and \".\"\n if (id !== this.namespace && !this.namespaceRegExp.test(id)) {\n if (!isPattern) {\n result = this.namespace + (id ? `.${id}` : '');\n } else {\n result = `${this.namespace}.${id ? id : ''}`;\n }\n }\n } else if (tools.isObject(id)) {\n // If ID is an object\n // Add namespace + device + channel\n result = `${this.namespace}.${id.device ? `${id.device}.` : ''}${id.channel ? `${id.channel}.` : ''}${\n id.state ? id.state : ''\n }`;\n }\n return result;\n }\n\n /**\n * Validates the object-type argument that is passed to setState\n *\n * @param obj object to validate\n */\n validateSetStateObjectArgument(obj: Record<string, any>): void {\n // Check that we have at least one existing non-undefined property at all, else invalid\n if (!Object.values(obj).some(prop => prop !== undefined)) {\n throw new Error(`The state contains no properties! At least one property is expected!`);\n }\n\n /*\n The following object parameters and types are allowed:\n val: any, (optional)\n ack: boolean, (optional)\n ts: number, (optional)\n q: number, (optional)\n from: string, (optional)\n c: string, (optional)\n expire: number (optional)\n lc: number (optional)\n user: string (optional)\n\n Everything else is forbidden\n */\n const optionalProperties: Record<string, string> = {\n val: 'any',\n ack: 'boolean',\n ts: 'number',\n q: 'number',\n from: 'string',\n c: 'string',\n expire: 'number',\n lc: 'number',\n user: 'string',\n };\n\n // Are there any forbidden properties?\n const forbiddenProperties = Object.keys(obj).filter(k => !optionalProperties[k]);\n if (forbiddenProperties.length) {\n throw new Error(`The state contains the forbidden properties ${forbiddenProperties.join(', ')}!`);\n }\n // Do all properties have the correct type?\n for (const [key, type] of Object.entries(optionalProperties)) {\n // any permits all types\n if (type === 'any') {\n continue;\n }\n // don't flag optional properties when they don't exist or are undefined\n if (!(key in obj) || obj[key] === undefined) {\n continue;\n }\n if (type !== typeof obj[key]) {\n throw new Error(\n `The state property \"${key}\" has the wrong type \"${typeof obj[key]}\" (should be \"${type}\")!`,\n );\n }\n }\n }\n\n /**\n * Validates that the timeout is not exceeding a 32-bit signed integer\n *\n * @param ms milliseconds to validate\n */\n static assertTimeout(ms: number): void {\n if (ms > MAX_TIMEOUT) {\n throw new Error(`Timeout (${ms}) is larger than a 32-bit signed integer (${MAX_TIMEOUT})`);\n }\n\n if (ms < 0) {\n throw new Error(`Timeout (${ms}) is smaller than 0`);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,uBAA+C;AAC/C,kCAAkC;AAoB5B,MAAO,UAAS;EArBtB,OAqBsB;;;EACD;EACA;EACA;EACA;EACA;;;;;;;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,QAAI,KAAK,8BAAa;AAClB,YAAM,IAAI,MAAM,YAAY,EAAE,6CAA6C,4BAAW,GAAG;IAC7F;AAEA,QAAI,KAAK,GAAG;AACR,YAAM,IAAI,MAAM,YAAY,EAAE,qBAAqB;IACvD;EACJ;;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/esm/index.d.ts
CHANGED
package/build/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,mBAAmB,iBAAiB,CAAC"}
|
package/build/esm/index.js
CHANGED
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|