@iobroker/js-controller-common-db 7.1.0 → 7.1.1-alpha.29-20260402-93ef165ef

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.
@@ -31,7 +31,7 @@ function applyAliasTransformer(options) {
31
31
  }
32
32
  function applyAliasConvenienceConversion(options) {
33
33
  const { targetCommon, state } = options;
34
- if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null) {
34
+ if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null && state.val !== void 0) {
35
35
  if (targetCommon.type === "boolean") {
36
36
  const lowerVal = typeof state.val === "string" ? state.val.toLowerCase() : state.val;
37
37
  if (lowerVal === "off" || lowerVal === "aus" || state.val === "0") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/common/aliasProcessing.ts"],
4
- "sourcesContent": ["interface ApplyAliasTransformerOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** Properties from this StateCommon will be provided first to the conversion function */\n firstCommon: Partial<ioBroker.StateCommon>;\n /** Properties from this StateCommon will be provided second to the conversion function */\n secondCommon: Partial<ioBroker.StateCommon>;\n /** The actual transformer function as a string */\n transformer: string;\n /** If this is a read function, determines the naming of the passed variables */\n isRead: boolean;\n}\n\ninterface ApplyAliasConvenienceConversionOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** The common attribute of the alias target */\n targetCommon?: Partial<ioBroker.StateCommon>;\n}\n\ninterface ApplyAliasAutoScalingOptions extends ApplyAliasConvenienceConversionOptions {\n /** The common attribute of the alias source */\n sourceCommon?: Partial<ioBroker.StateCommon>;\n}\n\n/**\n * Applies a user-given transformer function and provides the type, min and max of the\n * passed StateCommon variables as well as the state's value\n *\n * @param options state, common information and transformer function\n */\nexport function applyAliasTransformer(options: ApplyAliasTransformerOptions): ioBroker.StateValue {\n const { state, firstCommon, secondCommon, transformer, isRead } = options;\n\n const prefix = isRead ? 's' : 't';\n\n const func = new Function(\n 'val',\n 'type',\n 'min',\n 'max',\n `${prefix}Type`,\n `${prefix}Min`,\n `${prefix}Max`,\n `return ${transformer}`,\n );\n\n return func(\n state.val,\n firstCommon.type,\n firstCommon.min,\n firstCommon.max,\n secondCommon.type,\n secondCommon.min,\n secondCommon.max,\n );\n}\n\n/**\n * Applies some convenience conversions of aliases, e.g. transforming string 'off' to a boolean false, if target is a boolean\n *\n * @param options state and target common information\n */\nexport function applyAliasConvenienceConversion(options: ApplyAliasConvenienceConversionOptions): ioBroker.StateValue {\n const { targetCommon, state } = options;\n\n if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null) {\n if (targetCommon.type === 'boolean') {\n const lowerVal = typeof state.val === 'string' ? state.val.toLowerCase() : state.val;\n if (lowerVal === 'off' || lowerVal === 'aus' || state.val === '0') {\n return false;\n }\n // this also handles strings like \"EIN\" or such that will be true\n return !!state.val;\n } else if (targetCommon.type === 'number' && typeof state.val === 'string') {\n return parseFloat(state.val);\n } else if (targetCommon.type === 'string') {\n return state.val.toString();\n }\n }\n\n return state.val;\n}\n\n/**\n * Applies autoscaling between alias source and target if one has % unit and the other not\n *\n * @param options state, source and target common information\n */\nexport function applyAliasAutoScaling(options: ApplyAliasAutoScalingOptions): ioBroker.StateValue {\n const { state, sourceCommon, targetCommon } = options;\n\n // auto-scaling, only if val not null and unit for target (x)or source is %\n if (\n ((targetCommon?.alias && !targetCommon.alias.read) || (sourceCommon?.alias && !sourceCommon.alias.write)) &&\n state.val !== null\n ) {\n if (\n targetCommon &&\n targetCommon.type === 'number' &&\n targetCommon.unit === '%' &&\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit !== '%' &&\n sourceCommon.min !== undefined &&\n sourceCommon.max !== undefined\n ) {\n // scale target between 0 and 100 % based on sources min/max\n return (((state.val as number) - sourceCommon.min) / (sourceCommon.max - sourceCommon.min)) * 100;\n } else if (\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit === '%' &&\n targetCommon &&\n targetCommon.unit !== '%' &&\n targetCommon.type === 'number' &&\n targetCommon.min !== undefined &&\n targetCommon.max !== undefined\n ) {\n // scale target based on its min/max by its source (assuming source is meant to be 0 - 100 %)\n return ((targetCommon.max - targetCommon.min) * (state.val as number)) / 100 + targetCommon.min;\n }\n }\n\n return state.val;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAyBA;;;;;;;AAMM,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,aAAa,cAAc,aAAa,OAAM,IAAK;AAElE,QAAM,SAAS,SAAS,MAAM;AAE9B,QAAM,OAAO,IAAI,SACb,OACA,QACA,OACA,OACA,GAAG,MAAM,QACT,GAAG,MAAM,OACT,GAAG,MAAM,OACT,UAAU,WAAW,EAAE;AAG3B,SAAO,KACH,MAAM,KACN,YAAY,MACZ,YAAY,KACZ,YAAY,KACZ,aAAa,MACb,aAAa,KACb,aAAa,GAAG;AAExB;AAOM,SAAU,gCAAgC,SAA+C;AAC3F,QAAM,EAAE,cAAc,MAAK,IAAK;AAEhC,MAAI,gBAAgB,OAAO,MAAM,QAAQ,aAAa,QAAQ,MAAM,QAAQ,MAAM;AAC9E,QAAI,aAAa,SAAS,WAAW;AACjC,YAAM,WAAW,OAAO,MAAM,QAAQ,WAAW,MAAM,IAAI,YAAW,IAAK,MAAM;AACjF,UAAI,aAAa,SAAS,aAAa,SAAS,MAAM,QAAQ,KAAK;AAC/D,eAAO;MACX;AAEA,aAAO,CAAC,CAAC,MAAM;IACnB,WAAW,aAAa,SAAS,YAAY,OAAO,MAAM,QAAQ,UAAU;AACxE,aAAO,WAAW,MAAM,GAAG;IAC/B,WAAW,aAAa,SAAS,UAAU;AACvC,aAAO,MAAM,IAAI,SAAQ;IAC7B;EACJ;AAEA,SAAO,MAAM;AACjB;AAOM,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,cAAc,aAAY,IAAK;AAG9C,OACM,cAAc,SAAS,CAAC,aAAa,MAAM,QAAU,cAAc,SAAS,CAAC,aAAa,MAAM,UAClG,MAAM,QAAQ,MAChB;AACE,QACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAU,MAAM,MAAiB,aAAa,QAAQ,aAAa,MAAM,aAAa,OAAQ;IAClG,WACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,OACtB,aAAa,SAAS,YACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAS,aAAa,MAAM,aAAa,OAAQ,MAAM,MAAkB,MAAM,aAAa;IAChG;EACJ;AAEA,SAAO,MAAM;AACjB;",
4
+ "sourcesContent": ["interface ApplyAliasTransformerOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** Properties from this StateCommon will be provided first to the conversion function */\n firstCommon: Partial<ioBroker.StateCommon>;\n /** Properties from this StateCommon will be provided second to the conversion function */\n secondCommon: Partial<ioBroker.StateCommon>;\n /** The actual transformer function as a string */\n transformer: string;\n /** If this is a read function, determines the naming of the passed variables */\n isRead: boolean;\n}\n\ninterface ApplyAliasConvenienceConversionOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** The common attribute of the alias target */\n targetCommon?: Partial<ioBroker.StateCommon>;\n}\n\ninterface ApplyAliasAutoScalingOptions extends ApplyAliasConvenienceConversionOptions {\n /** The common attribute of the alias source */\n sourceCommon?: Partial<ioBroker.StateCommon>;\n}\n\n/**\n * Applies a user-given transformer function and provides the type, min and max of the\n * passed StateCommon variables as well as the state's value\n *\n * @param options state, common information and transformer function\n */\nexport function applyAliasTransformer(options: ApplyAliasTransformerOptions): ioBroker.StateValue {\n const { state, firstCommon, secondCommon, transformer, isRead } = options;\n\n const prefix = isRead ? 's' : 't';\n\n const func = new Function(\n 'val',\n 'type',\n 'min',\n 'max',\n `${prefix}Type`,\n `${prefix}Min`,\n `${prefix}Max`,\n `return ${transformer}`,\n );\n\n return func(\n state.val,\n firstCommon.type,\n firstCommon.min,\n firstCommon.max,\n secondCommon.type,\n secondCommon.min,\n secondCommon.max,\n );\n}\n\n/**\n * Applies some convenience conversions of aliases, e.g. transforming string 'off' to a boolean false, if target is a boolean\n *\n * @param options state and target common information\n */\nexport function applyAliasConvenienceConversion(options: ApplyAliasConvenienceConversionOptions): ioBroker.StateValue {\n const { targetCommon, state } = options;\n\n if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null && state.val !== undefined) {\n if (targetCommon.type === 'boolean') {\n const lowerVal = typeof state.val === 'string' ? state.val.toLowerCase() : state.val;\n if (lowerVal === 'off' || lowerVal === 'aus' || state.val === '0') {\n return false;\n }\n // this also handles strings like \"EIN\" or such that will be true\n return !!state.val;\n } else if (targetCommon.type === 'number' && typeof state.val === 'string') {\n return parseFloat(state.val);\n } else if (targetCommon.type === 'string') {\n return state.val.toString();\n }\n }\n\n return state.val;\n}\n\n/**\n * Applies autoscaling between alias source and target if one has % unit and the other not\n *\n * @param options state, source and target common information\n */\nexport function applyAliasAutoScaling(options: ApplyAliasAutoScalingOptions): ioBroker.StateValue {\n const { state, sourceCommon, targetCommon } = options;\n\n // auto-scaling, only if val not null and unit for target (x)or source is %\n if (\n ((targetCommon?.alias && !targetCommon.alias.read) || (sourceCommon?.alias && !sourceCommon.alias.write)) &&\n state.val !== null\n ) {\n if (\n targetCommon &&\n targetCommon.type === 'number' &&\n targetCommon.unit === '%' &&\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit !== '%' &&\n sourceCommon.min !== undefined &&\n sourceCommon.max !== undefined\n ) {\n // scale target between 0 and 100 % based on sources min/max\n return (((state.val as number) - sourceCommon.min) / (sourceCommon.max - sourceCommon.min)) * 100;\n } else if (\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit === '%' &&\n targetCommon &&\n targetCommon.unit !== '%' &&\n targetCommon.type === 'number' &&\n targetCommon.min !== undefined &&\n targetCommon.max !== undefined\n ) {\n // scale target based on its min/max by its source (assuming source is meant to be 0 - 100 %)\n return ((targetCommon.max - targetCommon.min) * (state.val as number)) / 100 + targetCommon.min;\n }\n }\n\n return state.val;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAyBA;;;;;;;AAMM,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,aAAa,cAAc,aAAa,OAAM,IAAK;AAElE,QAAM,SAAS,SAAS,MAAM;AAE9B,QAAM,OAAO,IAAI,SACb,OACA,QACA,OACA,OACA,GAAG,MAAM,QACT,GAAG,MAAM,OACT,GAAG,MAAM,OACT,UAAU,WAAW,EAAE;AAG3B,SAAO,KACH,MAAM,KACN,YAAY,MACZ,YAAY,KACZ,YAAY,KACZ,aAAa,MACb,aAAa,KACb,aAAa,GAAG;AAExB;AAOM,SAAU,gCAAgC,SAA+C;AAC3F,QAAM,EAAE,cAAc,MAAK,IAAK;AAEhC,MAAI,gBAAgB,OAAO,MAAM,QAAQ,aAAa,QAAQ,MAAM,QAAQ,QAAQ,MAAM,QAAQ,QAAW;AACzG,QAAI,aAAa,SAAS,WAAW;AACjC,YAAM,WAAW,OAAO,MAAM,QAAQ,WAAW,MAAM,IAAI,YAAW,IAAK,MAAM;AACjF,UAAI,aAAa,SAAS,aAAa,SAAS,MAAM,QAAQ,KAAK;AAC/D,eAAO;MACX;AAEA,aAAO,CAAC,CAAC,MAAM;IACnB,WAAW,aAAa,SAAS,YAAY,OAAO,MAAM,QAAQ,UAAU;AACxE,aAAO,WAAW,MAAM,GAAG;IAC/B,WAAW,aAAa,SAAS,UAAU;AACvC,aAAO,MAAM,IAAI,SAAQ;IAC7B;EACJ;AAEA,SAAO,MAAM;AACjB;AAOM,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,cAAc,aAAY,IAAK;AAG9C,OACM,cAAc,SAAS,CAAC,aAAa,MAAM,QAAU,cAAc,SAAS,CAAC,aAAa,MAAM,UAClG,MAAM,QAAQ,MAChB;AACE,QACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAU,MAAM,MAAiB,aAAa,QAAQ,aAAa,MAAM,aAAa,OAAQ;IAClG,WACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,OACtB,aAAa,SAAS,YACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAS,aAAa,MAAM,aAAa,OAAQ,MAAM,MAAkB,MAAM,aAAa;IAChG;EACJ;AAEA,SAAO,MAAM;AACjB;",
6
6
  "names": []
7
7
  }
@@ -393,6 +393,11 @@ function isDocker() {
393
393
  return true;
394
394
  } catch {
395
395
  }
396
+ try {
397
+ import_fs_extra.default.statSync("/run/.containerenv");
398
+ return true;
399
+ } catch {
400
+ }
396
401
  try {
397
402
  return import_fs_extra.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
398
403
  } catch {