matterbridge 2.2.2 → 2.2.4-dev.1

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.
Files changed (152) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cli.js +2 -37
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -94
  6. package/dist/frontend.js +31 -306
  7. package/dist/index.js +1 -28
  8. package/dist/logger/export.js +0 -1
  9. package/dist/matter/behaviors.js +0 -2
  10. package/dist/matter/clusters.js +0 -2
  11. package/dist/matter/devices.js +0 -2
  12. package/dist/matter/endpoints.js +0 -2
  13. package/dist/matter/export.js +0 -2
  14. package/dist/matter/types.js +0 -2
  15. package/dist/matterbridge.js +69 -727
  16. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  17. package/dist/matterbridgeBehaviors.js +1 -32
  18. package/dist/matterbridgeDeviceTypes.js +11 -112
  19. package/dist/matterbridgeDynamicPlatform.js +0 -33
  20. package/dist/matterbridgeEndpoint.js +6 -690
  21. package/dist/matterbridgeEndpointHelpers.js +9 -118
  22. package/dist/matterbridgePlatform.js +7 -185
  23. package/dist/matterbridgeTypes.js +0 -24
  24. package/dist/pluginManager.js +3 -229
  25. package/dist/shelly.js +6 -121
  26. package/dist/storage/export.js +0 -1
  27. package/dist/update.js +0 -45
  28. package/dist/utils/colorUtils.js +2 -205
  29. package/dist/utils/copyDirectory.js +1 -37
  30. package/dist/utils/createZip.js +2 -42
  31. package/dist/utils/deepCopy.js +0 -40
  32. package/dist/utils/deepEqual.js +1 -65
  33. package/dist/utils/export.js +0 -1
  34. package/dist/utils/isvalid.js +0 -86
  35. package/dist/utils/network.js +5 -77
  36. package/dist/utils/parameter.js +0 -41
  37. package/dist/utils/wait.js +5 -48
  38. package/frontend/build/asset-manifest.json +3 -3
  39. package/frontend/build/index.html +1 -1
  40. package/frontend/build/static/js/{main.6bd178dd.js → main.819c0908.js} +4 -4
  41. package/frontend/build/static/js/{main.6bd178dd.js.map → main.819c0908.js.map} +1 -1
  42. package/npm-shrinkwrap.json +2 -2
  43. package/package.json +1 -2
  44. package/dist/cli.d.ts +0 -29
  45. package/dist/cli.d.ts.map +0 -1
  46. package/dist/cli.js.map +0 -1
  47. package/dist/cluster/export.d.ts +0 -2
  48. package/dist/cluster/export.d.ts.map +0 -1
  49. package/dist/cluster/export.js.map +0 -1
  50. package/dist/defaultConfigSchema.d.ts +0 -27
  51. package/dist/defaultConfigSchema.d.ts.map +0 -1
  52. package/dist/defaultConfigSchema.js.map +0 -1
  53. package/dist/deviceManager.d.ts +0 -114
  54. package/dist/deviceManager.d.ts.map +0 -1
  55. package/dist/deviceManager.js.map +0 -1
  56. package/dist/frontend.d.ts +0 -201
  57. package/dist/frontend.d.ts.map +0 -1
  58. package/dist/frontend.js.map +0 -1
  59. package/dist/index.d.ts +0 -35
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/index.js.map +0 -1
  62. package/dist/logger/export.d.ts +0 -2
  63. package/dist/logger/export.d.ts.map +0 -1
  64. package/dist/logger/export.js.map +0 -1
  65. package/dist/matter/behaviors.d.ts +0 -2
  66. package/dist/matter/behaviors.d.ts.map +0 -1
  67. package/dist/matter/behaviors.js.map +0 -1
  68. package/dist/matter/clusters.d.ts +0 -2
  69. package/dist/matter/clusters.d.ts.map +0 -1
  70. package/dist/matter/clusters.js.map +0 -1
  71. package/dist/matter/devices.d.ts +0 -2
  72. package/dist/matter/devices.d.ts.map +0 -1
  73. package/dist/matter/devices.js.map +0 -1
  74. package/dist/matter/endpoints.d.ts +0 -2
  75. package/dist/matter/endpoints.d.ts.map +0 -1
  76. package/dist/matter/endpoints.js.map +0 -1
  77. package/dist/matter/export.d.ts +0 -5
  78. package/dist/matter/export.d.ts.map +0 -1
  79. package/dist/matter/export.js.map +0 -1
  80. package/dist/matter/types.d.ts +0 -3
  81. package/dist/matter/types.d.ts.map +0 -1
  82. package/dist/matter/types.js.map +0 -1
  83. package/dist/matterbridge.d.ts +0 -412
  84. package/dist/matterbridge.d.ts.map +0 -1
  85. package/dist/matterbridge.js.map +0 -1
  86. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  87. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  88. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  89. package/dist/matterbridgeBehaviors.d.ts +0 -1056
  90. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  91. package/dist/matterbridgeBehaviors.js.map +0 -1
  92. package/dist/matterbridgeDeviceTypes.d.ts +0 -177
  93. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  94. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  95. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  96. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  97. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  98. package/dist/matterbridgeEndpoint.d.ts +0 -835
  99. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  100. package/dist/matterbridgeEndpoint.js.map +0 -1
  101. package/dist/matterbridgeEndpointHelpers.d.ts +0 -2275
  102. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  103. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  104. package/dist/matterbridgePlatform.d.ts +0 -251
  105. package/dist/matterbridgePlatform.d.ts.map +0 -1
  106. package/dist/matterbridgePlatform.js.map +0 -1
  107. package/dist/matterbridgeTypes.d.ts +0 -177
  108. package/dist/matterbridgeTypes.d.ts.map +0 -1
  109. package/dist/matterbridgeTypes.js.map +0 -1
  110. package/dist/pluginManager.d.ts +0 -236
  111. package/dist/pluginManager.d.ts.map +0 -1
  112. package/dist/pluginManager.js.map +0 -1
  113. package/dist/shelly.d.ts +0 -77
  114. package/dist/shelly.d.ts.map +0 -1
  115. package/dist/shelly.js.map +0 -1
  116. package/dist/storage/export.d.ts +0 -2
  117. package/dist/storage/export.d.ts.map +0 -1
  118. package/dist/storage/export.js.map +0 -1
  119. package/dist/update.d.ts +0 -32
  120. package/dist/update.d.ts.map +0 -1
  121. package/dist/update.js.map +0 -1
  122. package/dist/utils/colorUtils.d.ts +0 -61
  123. package/dist/utils/colorUtils.d.ts.map +0 -1
  124. package/dist/utils/colorUtils.js.map +0 -1
  125. package/dist/utils/copyDirectory.d.ts +0 -32
  126. package/dist/utils/copyDirectory.d.ts.map +0 -1
  127. package/dist/utils/copyDirectory.js.map +0 -1
  128. package/dist/utils/createZip.d.ts +0 -38
  129. package/dist/utils/createZip.d.ts.map +0 -1
  130. package/dist/utils/createZip.js.map +0 -1
  131. package/dist/utils/deepCopy.d.ts +0 -31
  132. package/dist/utils/deepCopy.d.ts.map +0 -1
  133. package/dist/utils/deepCopy.js.map +0 -1
  134. package/dist/utils/deepEqual.d.ts +0 -53
  135. package/dist/utils/deepEqual.d.ts.map +0 -1
  136. package/dist/utils/deepEqual.js.map +0 -1
  137. package/dist/utils/export.d.ts +0 -10
  138. package/dist/utils/export.d.ts.map +0 -1
  139. package/dist/utils/export.js.map +0 -1
  140. package/dist/utils/isvalid.d.ts +0 -87
  141. package/dist/utils/isvalid.d.ts.map +0 -1
  142. package/dist/utils/isvalid.js.map +0 -1
  143. package/dist/utils/network.d.ts +0 -70
  144. package/dist/utils/network.d.ts.map +0 -1
  145. package/dist/utils/network.js.map +0 -1
  146. package/dist/utils/parameter.d.ts +0 -44
  147. package/dist/utils/parameter.d.ts.map +0 -1
  148. package/dist/utils/parameter.js.map +0 -1
  149. package/dist/utils/wait.d.ts +0 -43
  150. package/dist/utils/wait.d.ts.map +0 -1
  151. package/dist/utils/wait.js.map +0 -1
  152. /package/frontend/build/static/js/{main.6bd178dd.js.LICENSE.txt → main.819c0908.js.LICENSE.txt} +0 -0
@@ -1,43 +1,6 @@
1
- /**
2
- * This file contains the createZip function.
3
- *
4
- * @file createZip.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // AnsiLogger module
24
1
  import { AnsiLogger } from '../logger/export.js';
25
- /**
26
- * Creates a ZIP archive from the specified source pattern or directory and writes it to the specified output path.
27
- *
28
- * @param {string} outputPath - The path where the output ZIP file will be written.
29
- * @param {string[]} sourcePaths - The source pattern or directory to be zipped (use path.join for sourcePath).
30
- * @returns {Promise<number>} - A promise that resolves to the total number of bytes written to the ZIP file.
31
- *
32
- * @remarks
33
- * This function uses the `archiver` library to create a ZIP archive. It sets the compression level to 9 (maximum compression).
34
- * The function ensures that the output file is properly closed after the archiving process is complete.
35
- * It logs the progress and the total number of bytes written to the console.
36
- *
37
- * This function uses the `glob` library to match files based on the source pattern (internally converted in posix).
38
- */
39
2
  export async function createZip(outputPath, ...sourcePaths) {
40
- const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
3
+ const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4, logLevel: "info" });
41
4
  const { default: archiver } = await import('archiver');
42
5
  const { glob } = await import('glob');
43
6
  const { createWriteStream, statSync } = await import('node:fs');
@@ -46,7 +9,7 @@ export async function createZip(outputPath, ...sourcePaths) {
46
9
  return new Promise((resolve, reject) => {
47
10
  const output = createWriteStream(outputPath);
48
11
  const archive = archiver('zip', {
49
- zlib: { level: 9 }, // Set compression level
12
+ zlib: { level: 9 },
50
13
  });
51
14
  output.on('close', () => {
52
15
  log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
@@ -73,7 +36,6 @@ export async function createZip(outputPath, ...sourcePaths) {
73
36
  });
74
37
  archive.pipe(output);
75
38
  for (const sourcePath of sourcePaths) {
76
- // Check if the sourcePath is a file or directory
77
39
  let stats;
78
40
  try {
79
41
  stats = statSync(sourcePath);
@@ -101,9 +63,7 @@ export async function createZip(outputPath, ...sourcePaths) {
101
63
  archive.directory(sourcePath, path.basename(sourcePath));
102
64
  }
103
65
  }
104
- // Finalize the archive (i.e., we are done appending files but streams have to finish yet)
105
66
  log.debug(`finalizing archive ${outputPath}...`);
106
67
  archive.finalize().catch(reject);
107
68
  });
108
69
  }
109
- //# sourceMappingURL=createZip.js.map
@@ -1,67 +1,28 @@
1
- /**
2
- * This file contains the deepCopy function.
3
- *
4
- * @file deepCopy.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- /**
24
- * Creates a deep copy of the given value.
25
- *
26
- * @template T - The type of the value being copied.
27
- * @param {T} value - The value to be copied.
28
- * @returns {T} - The deep copy of the value.
29
- */
30
1
  export function deepCopy(value) {
31
2
  if (typeof value !== 'object' || value === null) {
32
- // Primitive value (string, number, boolean, bigint, undefined, symbol) or null
33
3
  return value;
34
4
  }
35
5
  else if (Array.isArray(value)) {
36
- // Array: Recursively copy each element
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
6
  return value.map((item) => deepCopy(item));
39
7
  }
40
8
  else if (value instanceof Date) {
41
- // Date objects
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
9
  return new Date(value.getTime());
44
10
  }
45
11
  else if (value instanceof Map) {
46
- // Maps
47
12
  const mapCopy = new Map();
48
13
  value.forEach((val, key) => {
49
14
  mapCopy.set(key, deepCopy(val));
50
15
  });
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
16
  return mapCopy;
53
17
  }
54
18
  else if (value instanceof Set) {
55
- // Sets
56
19
  const setCopy = new Set();
57
20
  value.forEach((item) => {
58
21
  setCopy.add(deepCopy(item));
59
22
  });
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
23
  return setCopy;
62
24
  }
63
25
  else {
64
- // Objects: Create a copy with the same prototype as the original
65
26
  const proto = Object.getPrototypeOf(value);
66
27
  const copy = Object.create(proto);
67
28
  for (const key in value) {
@@ -72,4 +33,3 @@ export function deepCopy(value) {
72
33
  return copy;
73
34
  }
74
35
  }
75
- //# sourceMappingURL=deepCopy.js.map
@@ -1,80 +1,21 @@
1
- /**
2
- * This file contains the deepEqual function.
3
- *
4
- * @file deepEqual.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- /* eslint-disable @typescript-eslint/no-explicit-any */
24
- /**
25
- * Performs a deep comparison between two values to determine if they are equivalent.
26
- * This comparison includes primitive types, arrays, and objects, allowing for optional
27
- * exclusion of specific properties from the comparison in objects.
28
- *
29
- * @param {any} a The first value to compare.
30
- * @param {any} b The second value to compare.
31
- * @param {string[]} [excludeProperties=[]] An array of property names to exclude from the comparison in objects.
32
- * @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
33
- *
34
- * Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
35
- * mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
36
- * objects do not contain circular references when enabling debug logging to avoid infinite loops.
37
- *
38
- * Example usage:
39
- * ```
40
- * const obj1 = { a: 1, b: { c: 2 } };
41
- * const obj2 = { a: 1, b: { c: 2 } };
42
- * console.log(deepEqual(obj1, obj2)); // true
43
- *
44
- * const arr1 = [1, 2, [3, 4]];
45
- * const arr2 = [1, 2, [3, 4]];
46
- * console.log(deepEqual(arr1, arr2)); // true
47
- *
48
- * const obj3 = { a: 1, b: { c: 2, d: 3 } };
49
- * const obj4 = { a: 1, b: { c: 2 } };
50
- * console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
51
- * ```
52
- */
53
1
  export function deepEqual(a, b, excludeProperties = []) {
54
- // Toggle debugging on or off easily
55
2
  const debug = false;
56
- // Helper function for conditional logging
57
3
  const debugLog = (...messages) => {
58
4
  if (debug) {
59
- // eslint-disable-next-line no-console
60
5
  console.log(...messages);
61
6
  }
62
7
  };
63
- // If both are the same instance, return true (handles primitives and same object references)
64
8
  if (a === b) {
65
9
  return true;
66
10
  }
67
- // If types are different, return false
68
11
  if (typeof a !== typeof b) {
69
12
  debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
70
13
  return false;
71
14
  }
72
- // If one of them is null (and we know they are not equal from the first check), return false
73
15
  if (a == null || b == null) {
74
16
  debugLog('deepEqual false for == null');
75
17
  return false;
76
18
  }
77
- // Handle Arrays
78
19
  if (Array.isArray(a) && Array.isArray(b)) {
79
20
  if (a.length !== b.length) {
80
21
  debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
@@ -90,31 +31,26 @@ export function deepEqual(a, b, excludeProperties = []) {
90
31
  }
91
32
  return true;
92
33
  }
93
- // Handle Objects (and exclude null, functions, and arrays)
94
34
  if (typeof a === 'object' && typeof b === 'object') {
95
35
  const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
96
36
  const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
97
- // If their property lengths are different, they're different objects
98
37
  if (aProps.length !== bProps.length) {
99
38
  debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
100
39
  debugLog(`- aProps.length(${aProps.length}):`, aProps);
101
40
  debugLog(`- bProps.length(${bProps.length}):`, bProps);
102
41
  return false;
103
42
  }
104
- // Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
105
43
  for (const prop of aProps) {
106
44
  if (!Object.prototype.hasOwnProperty.call(b, prop)) {
107
45
  debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
108
46
  return false;
109
47
  }
110
48
  if (!deepEqual(a[prop], b[prop], excludeProperties)) {
111
- debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
49
+ debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
112
50
  return false;
113
51
  }
114
52
  }
115
53
  return true;
116
54
  }
117
- // If none of the above, the objects are not equal
118
55
  return false;
119
56
  }
120
- //# sourceMappingURL=deepEqual.js.map
@@ -7,4 +7,3 @@ export * from './deepEqual.js';
7
7
  export * from './copyDirectory.js';
8
8
  export * from './createZip.js';
9
9
  export * from './wait.js';
10
- //# sourceMappingURL=export.js.map
@@ -1,44 +1,7 @@
1
- /**
2
- * This file contains the deepEqual function.
3
- *
4
- * @file isvalid.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- /**
24
- * Checks if a given string is a valid IPv4 address.
25
- *
26
- * @param {string} ipv4Address - The string to be checked.
27
- * @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
28
- */
29
1
  export function isValidIpv4Address(ipv4Address) {
30
2
  const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
31
3
  return ipv4Regex.test(ipv4Address);
32
4
  }
33
- /**
34
- * Checks if a value is a valid number within the specified range.
35
- *
36
- * @param {any} value - The value to be checked.
37
- * @param {number} min - The minimum value allowed (optional).
38
- * @param {number} max - The maximum value allowed (optional).
39
- * @returns {boolean} Returns true if the value is a valid number within the specified range, otherwise false.
40
- */
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
5
  export function isValidNumber(value, min, max) {
43
6
  if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value))
44
7
  return false;
@@ -48,25 +11,9 @@ export function isValidNumber(value, min, max) {
48
11
  return false;
49
12
  return true;
50
13
  }
51
- /**
52
- * Checks if a value is a valid boolean.
53
- *
54
- * @param {any} value - The value to be checked.
55
- * @returns {boolean} `true` if the value is a valid boolean, `false` otherwise.
56
- */
57
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
14
  export function isValidBoolean(value) {
59
15
  return value !== undefined && value !== null && typeof value === 'boolean';
60
16
  }
61
- /**
62
- * Checks if a value is a valid string.
63
- *
64
- * @param {any} value - The value to be checked.
65
- * @param {number} minLength - The min string length (optional).
66
- * @param {number} maxLength - The max string length (optional).
67
- * @returns {boolean} A boolean indicating whether the value is a valid string.
68
- */
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
17
  export function isValidString(value, minLength, maxLength) {
71
18
  if (value === undefined || value === null || typeof value !== 'string')
72
19
  return false;
@@ -76,15 +23,6 @@ export function isValidString(value, minLength, maxLength) {
76
23
  return false;
77
24
  return true;
78
25
  }
79
- /**
80
- * Checks if a value is a valid object.
81
- *
82
- * @param {any} value - The value to be checked.
83
- * @param {number} minLength - The min number of keys (optional).
84
- * @param {number} maxLength - The max number of keys (optional).
85
- * @returns {boolean} A boolean indicating whether the value is a valid object.
86
- */
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
26
  export function isValidObject(value, minLength, maxLength) {
89
27
  if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
90
28
  return false;
@@ -95,15 +33,6 @@ export function isValidObject(value, minLength, maxLength) {
95
33
  return false;
96
34
  return true;
97
35
  }
98
- /**
99
- * Checks if a value is a valid array.
100
- *
101
- * @param {any} value - The value to be checked.
102
- * @param {number} minLength - The min number of elements (optional).
103
- * @param {number} maxLength - The max number of elements (optional).
104
- * @returns {boolean} A boolean indicating whether the value is a valid array.
105
- */
106
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
107
36
  export function isValidArray(value, minLength, maxLength) {
108
37
  if (value === undefined || value === null || !Array.isArray(value))
109
38
  return false;
@@ -113,24 +42,9 @@ export function isValidArray(value, minLength, maxLength) {
113
42
  return false;
114
43
  return true;
115
44
  }
116
- /**
117
- * Checks if the given value is null.
118
- *
119
- * @param {any} value - The value to check.
120
- * @returns {boolean} `true` if the value is null, `false` otherwise.
121
- */
122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
45
  export function isValidNull(value) {
124
46
  return value === null;
125
47
  }
126
- /**
127
- * Checks if a value is undefined.
128
- *
129
- * @param {any} value - The value to check.
130
- * @returns {boolean} `true` if the value is undefined, `false` otherwise.
131
- */
132
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
48
  export function isValidUndefined(value) {
134
49
  return value === undefined;
135
50
  }
136
- //# sourceMappingURL=isvalid.js.map
@@ -1,37 +1,8 @@
1
- /**
2
- * This file contains the network function.
3
- *
4
- * @file network.ts
5
- * @author Luca Liguori
6
- * @date 2024-02-17
7
- * @version 1.0.0
8
- *
9
- * Copyright 2024, 2025, 2026 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // Node.js modules
24
1
  import os from 'node:os';
25
- // AnsiLogger module
26
2
  import { AnsiLogger, idn, rs } from '../logger/export.js';
27
- /**
28
- * Retrieves the IPv4 address of the first non-internal network interface.
29
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
30
- */
31
3
  export function getIpv4InterfaceAddress() {
32
4
  let ipv4Address;
33
5
  const networkInterfaces = os.networkInterfaces();
34
- // console.log('Available Network Interfaces:', networkInterfaces);
35
6
  for (const interfaceDetails of Object.values(networkInterfaces)) {
36
7
  if (!interfaceDetails) {
37
8
  break;
@@ -45,17 +16,11 @@ export function getIpv4InterfaceAddress() {
45
16
  break;
46
17
  }
47
18
  }
48
- // console.log('Selected Network Interfaces:', ipv4Address);
49
19
  return ipv4Address;
50
20
  }
51
- /**
52
- * Retrieves the IPv6 address of the first non-internal network interface.
53
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
54
- */
55
21
  export function getIpv6InterfaceAddress() {
56
22
  let ipv6Address;
57
23
  const networkInterfaces = os.networkInterfaces();
58
- // console.log('Available Network Interfaces:', networkInterfaces);
59
24
  for (const interfaceDetails of Object.values(networkInterfaces)) {
60
25
  if (!interfaceDetails) {
61
26
  break;
@@ -69,17 +34,11 @@ export function getIpv6InterfaceAddress() {
69
34
  break;
70
35
  }
71
36
  }
72
- // console.log('Selected Network Interfaces:', ipv6Address);
73
37
  return ipv6Address;
74
38
  }
75
- /**
76
- * Retrieves the mac address of the first non-internal network interface.
77
- * @returns {string | undefined} The IPv4 address of the selected network interface, or undefined if not found.
78
- */
79
39
  export function getMacAddress() {
80
40
  let macAddress;
81
41
  const networkInterfaces = os.networkInterfaces();
82
- // console.log('Available Network Interfaces:', networkInterfaces);
83
42
  for (const interfaceDetails of Object.values(networkInterfaces)) {
84
43
  if (!interfaceDetails) {
85
44
  break;
@@ -95,14 +54,9 @@ export function getMacAddress() {
95
54
  }
96
55
  return macAddress;
97
56
  }
98
- /**
99
- * Logs the available network interfaces and their details.
100
- * @param {boolean} log - Whether to enable logging of network interface details.
101
- * @returns {string | undefined} The IPv6 address of the network interface, if available.
102
- */
103
57
  export function logInterfaces(debug = true) {
104
- const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
105
- log.logLevel = "info" /* LogLevel.INFO */;
58
+ const log = new AnsiLogger({ logName: 'MatterbridgeUtils', logTimestampFormat: 4, logLevel: "info" });
59
+ log.logLevel = "info";
106
60
  log.logName = 'LogInterfaces';
107
61
  let ipv6Address;
108
62
  const networkInterfaces = os.networkInterfaces();
@@ -120,36 +74,16 @@ export function logInterfaces(debug = true) {
120
74
  }
121
75
  return ipv6Address;
122
76
  }
123
- /**
124
- * Resolves the given hostname to an IP address.
125
- *
126
- * @param {string} hostname - The hostname to resolve.
127
- * @param {0 | 4 | 6} [family=4] - The address family to use (0 for any, 4 for IPv4, 6 for IPv6). Default is 4.
128
- * @returns {Promise<string | null>} - A promise that resolves to the IP address or null if not found.
129
- *
130
- * @remarks
131
- * This function uses DNS lookup to resolve the hostname, which can take some time to complete.
132
- */
133
77
  export async function resolveHostname(hostname, family = 4) {
134
78
  const dns = await import('node:dns');
135
79
  try {
136
- const addresses = await dns.promises.lookup(hostname.toLowerCase() /* + '.local'*/, { family });
80
+ const addresses = await dns.promises.lookup(hostname.toLowerCase(), { family });
137
81
  return addresses.address;
138
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
139
82
  }
140
83
  catch (error) {
141
84
  return null;
142
85
  }
143
86
  }
144
- /**
145
- * Retrieves the version of an npm package from the npm registry.
146
- *
147
- * @param {string} packageName - The name of the npm package.
148
- * @param {string} [tag='latest'] - The tag of the package version to retrieve (default is 'latest').
149
- * @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 5000ms).
150
- * @returns {Promise<string>} A promise that resolves to the version string of the package.
151
- * @throws {Error} If the request fails or the tag is not found.
152
- */
153
87
  export async function getNpmPackageVersion(packageName, tag = 'latest', timeout = 5000) {
154
88
  const https = await import('https');
155
89
  return new Promise((resolve, reject) => {
@@ -163,8 +97,8 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
163
97
  let data = '';
164
98
  if (res.statusCode !== 200) {
165
99
  clearTimeout(timeoutId);
166
- res.resume(); // Discard response data to close the socket properly
167
- req.destroy(); // Forcefully close the request
100
+ res.resume();
101
+ req.destroy();
168
102
  reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
169
103
  return;
170
104
  }
@@ -175,7 +109,6 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
175
109
  clearTimeout(timeoutId);
176
110
  try {
177
111
  const jsonData = JSON.parse(data);
178
- // console.log(`Package ${packageName} tag ${tag}`, jsonData);
179
112
  const version = jsonData['dist-tags']?.[tag];
180
113
  if (version) {
181
114
  resolve(version);
@@ -195,10 +128,6 @@ export async function getNpmPackageVersion(packageName, tag = 'latest', timeout
195
128
  });
196
129
  });
197
130
  }
198
- /**
199
- * Retrieves the path to the global Node.js modules directory.
200
- * @returns A promise that resolves to the path of the global Node.js modules directory.
201
- */
202
131
  export async function getGlobalNodeModules() {
203
132
  const { exec } = await import('node:child_process');
204
133
  return new Promise((resolve, reject) => {
@@ -212,4 +141,3 @@ export async function getGlobalNodeModules() {
212
141
  });
213
142
  });
214
143
  }
215
- //# sourceMappingURL=network.js.map
@@ -1,32 +1,4 @@
1
- /**
2
- * This file contains the deepEqual function.
3
- *
4
- * @file parameter.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
1
  import { isValidNumber } from './export.js';
24
- /**
25
- * Retrieves the value of a command-line parameter.
26
- *
27
- * @param {string} name - The name of the parameter to retrieve.
28
- * @returns {string | undefined} The value of the parameter, or undefined if not found.
29
- */
30
2
  export function getParameter(name) {
31
3
  const commandArguments = process.argv.slice(2);
32
4
  let markerIndex = commandArguments.indexOf(`-${name}`);
@@ -36,12 +8,6 @@ export function getParameter(name) {
36
8
  return undefined;
37
9
  return commandArguments[markerIndex + 1];
38
10
  }
39
- /**
40
- * Checks if a command-line parameter is present.
41
- *
42
- * @param {string} name - The name of the parameter to check.
43
- * @returns {boolean} True if the parameter is present, otherwise false.
44
- */
45
11
  export function hasParameter(name) {
46
12
  const commandArguments = process.argv.slice(2);
47
13
  let markerIncluded = commandArguments.includes(`-${name}`);
@@ -49,12 +15,6 @@ export function hasParameter(name) {
49
15
  markerIncluded = commandArguments.includes(`--${name}`);
50
16
  return markerIncluded;
51
17
  }
52
- /**
53
- * Retrieves the value of a command-line parameter as an integer.
54
- *
55
- * @param {string} name - The name of the parameter to retrieve.
56
- * @returns {number | undefined} The integer value of the parameter, or undefined if not found or invalid.
57
- */
58
18
  export function getIntParameter(name) {
59
19
  const value = getParameter(name);
60
20
  if (value === undefined)
@@ -64,4 +24,3 @@ export function getIntParameter(name) {
64
24
  return undefined;
65
25
  return intValue;
66
26
  }
67
- //# sourceMappingURL=parameter.js.map