matterbridge 2.2.0-dev.4 → 2.2.0-dev.5
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/CHANGELOG.md +1 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -2
- package/dist/cli.js.map +1 -0
- package/dist/cluster/export.d.ts.map +1 -0
- package/dist/cluster/export.js +2 -0
- package/dist/cluster/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +23 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +109 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/frontend.d.ts +172 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +265 -22
- package/dist/frontend.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +2 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -1
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +410 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +718 -47
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +33 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +148 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +32 -1
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +112 -11
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +33 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +827 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +690 -6
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +123 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +118 -9
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +159 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +162 -23
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +24 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +236 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +229 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +131 -4
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +45 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +205 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +37 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +42 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +40 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +65 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +86 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +77 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/parameter.d.ts.map +1 -0
- package/dist/utils/parameter.js +41 -0
- package/dist/utils/parameter.js.map +1 -0
- package/dist/utils/wait.d.ts +43 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +48 -5
- package/dist/utils/wait.js.map +1 -0
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.f87f07b6.js → main.f60aae10.js} +8 -8
- package/frontend/build/static/js/main.f60aae10.js.map +1 -0
- package/npm-shrinkwrap.json +44 -44
- package/package.json +2 -2
- package/frontend/build/static/js/main.f87f07b6.js.map +0 -1
- /package/frontend/build/static/js/{main.f87f07b6.js.LICENSE.txt → main.f60aae10.js.LICENSE.txt} +0 -0
|
@@ -1,19 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the copyDirectory function.
|
|
3
|
+
*
|
|
4
|
+
* @file copyDirectory.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
|
|
1
24
|
import { AnsiLogger } from '../logger/export.js';
|
|
25
|
+
/**
|
|
26
|
+
* Copies a directory and all its subdirectories and files to a new location.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} srcDir - The path to the source directory.
|
|
29
|
+
* @param {string} destDir - The path to the destination directory.
|
|
30
|
+
* @returns {Promise<boolean>} - A promise that resolves when the copy operation is complete or fails for error.
|
|
31
|
+
* @throws {Error} - Throws an error if the copy operation fails.
|
|
32
|
+
*/
|
|
2
33
|
export async function copyDirectory(srcDir, destDir) {
|
|
3
|
-
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4
|
|
34
|
+
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
4
35
|
const fs = await import('node:fs').then((mod) => mod.promises);
|
|
5
36
|
const path = await import('node:path');
|
|
6
37
|
log.debug(`copyDirectory: copying directory from ${srcDir} to ${destDir}`);
|
|
7
38
|
try {
|
|
39
|
+
// Create destination directory if it doesn't exist
|
|
8
40
|
await fs.mkdir(destDir, { recursive: true });
|
|
41
|
+
// Read contents of the source directory
|
|
9
42
|
const entries = await fs.readdir(srcDir, { withFileTypes: true });
|
|
10
43
|
for (const entry of entries) {
|
|
11
44
|
const srcPath = path.join(srcDir, entry.name);
|
|
12
45
|
const destPath = path.join(destDir, entry.name);
|
|
13
46
|
if (entry.isDirectory()) {
|
|
47
|
+
// Recursive call if entry is a directory
|
|
14
48
|
await copyDirectory(srcPath, destPath);
|
|
15
49
|
}
|
|
16
50
|
else if (entry.isFile()) {
|
|
51
|
+
// Copy file if entry is a file
|
|
17
52
|
await fs.copyFile(srcPath, destPath);
|
|
18
53
|
}
|
|
19
54
|
}
|
|
@@ -24,3 +59,4 @@ export async function copyDirectory(srcDir, destDir) {
|
|
|
24
59
|
return false;
|
|
25
60
|
}
|
|
26
61
|
}
|
|
62
|
+
//# sourceMappingURL=copyDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyDirectory.js","sourceRoot":"","sources":["../../src/utils/copyDirectory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAA6B,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,OAAe;IACjE,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,qCAA6B,EAAE,QAAQ,4BAAe,EAAE,CAAC,CAAC;IAE7H,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAA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oot":"","sources":["../../src/utils/createZip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E7F"}
|
package/dist/utils/createZip.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
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
|
|
1
24
|
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
|
+
*/
|
|
2
39
|
export async function createZip(outputPath, ...sourcePaths) {
|
|
3
|
-
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4
|
|
40
|
+
const log = new AnsiLogger({ logName: 'Archive', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: "info" /* LogLevel.INFO */ });
|
|
4
41
|
const { default: archiver } = await import('archiver');
|
|
5
42
|
const { glob } = await import('glob');
|
|
6
43
|
const { createWriteStream, statSync } = await import('node:fs');
|
|
@@ -9,7 +46,7 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
9
46
|
return new Promise((resolve, reject) => {
|
|
10
47
|
const output = createWriteStream(outputPath);
|
|
11
48
|
const archive = archiver('zip', {
|
|
12
|
-
zlib: { level: 9 },
|
|
49
|
+
zlib: { level: 9 }, // Set compression level
|
|
13
50
|
});
|
|
14
51
|
output.on('close', () => {
|
|
15
52
|
log.debug(`archive ${outputPath} closed with ${archive.pointer()} total bytes`);
|
|
@@ -36,6 +73,7 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
36
73
|
});
|
|
37
74
|
archive.pipe(output);
|
|
38
75
|
for (const sourcePath of sourcePaths) {
|
|
76
|
+
// Check if the sourcePath is a file or directory
|
|
39
77
|
let stats;
|
|
40
78
|
try {
|
|
41
79
|
stats = statSync(sourcePath);
|
|
@@ -63,7 +101,9 @@ export async function createZip(outputPath, ...sourcePaths) {
|
|
|
63
101
|
archive.directory(sourcePath, path.basename(sourcePath));
|
|
64
102
|
}
|
|
65
103
|
}
|
|
104
|
+
// Finalize the archive (i.e., we are done appending files but streams have to finish yet)
|
|
66
105
|
log.debug(`finalizing archive ${outputPath}...`);
|
|
67
106
|
archive.finalize().catch(reject);
|
|
68
107
|
});
|
|
69
108
|
}
|
|
109
|
+
//# sourceMappingURL=createZip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createZip.js","sourceRoot":"","sources":["../../src/utils/createZip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAA6B,MAAM,qBAAqB,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAkB,EAAE,GAAG,WAAqB;IAC1E,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,qCAA6B,EAAE,QAAQ,4BAAe,EAAE,CAAC,CAAC;IAE7H,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvC,GAAG,CAAC,KAAK,CAAC,oBAAoB,UAAU,SAAS,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,EAAE;YAC9B,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,wBAAwB;SAC7C,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,C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,sBAAsB,UAAU,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepCopy.d.ts","sourceRoot":"","sources":["../../src/utils/deepCopy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAuCvC"}
|
package/dist/utils/deepCopy.js
CHANGED
|
@@ -1,28 +1,67 @@
|
|
|
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
|
+
*/
|
|
1
30
|
export function deepCopy(value) {
|
|
2
31
|
if (typeof value !== 'object' || value === null) {
|
|
32
|
+
// Primitive value (string, number, boolean, bigint, undefined, symbol) or null
|
|
3
33
|
return value;
|
|
4
34
|
}
|
|
5
35
|
else if (Array.isArray(value)) {
|
|
36
|
+
// Array: Recursively copy each element
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
38
|
return value.map((item) => deepCopy(item));
|
|
7
39
|
}
|
|
8
40
|
else if (value instanceof Date) {
|
|
41
|
+
// Date objects
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
43
|
return new Date(value.getTime());
|
|
10
44
|
}
|
|
11
45
|
else if (value instanceof Map) {
|
|
46
|
+
// Maps
|
|
12
47
|
const mapCopy = new Map();
|
|
13
48
|
value.forEach((val, key) => {
|
|
14
49
|
mapCopy.set(key, deepCopy(val));
|
|
15
50
|
});
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
52
|
return mapCopy;
|
|
17
53
|
}
|
|
18
54
|
else if (value instanceof Set) {
|
|
55
|
+
// Sets
|
|
19
56
|
const setCopy = new Set();
|
|
20
57
|
value.forEach((item) => {
|
|
21
58
|
setCopy.add(deepCopy(item));
|
|
22
59
|
});
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
61
|
return setCopy;
|
|
24
62
|
}
|
|
25
63
|
else {
|
|
64
|
+
// Objects: Create a copy with the same prototype as the original
|
|
26
65
|
const proto = Object.getPrototypeOf(value);
|
|
27
66
|
const copy = Object.create(proto);
|
|
28
67
|
for (const key in value) {
|
|
@@ -33,3 +72,4 @@ export function deepCopy(value) {
|
|
|
33
72
|
return copy;
|
|
34
73
|
}
|
|
35
74
|
}
|
|
75
|
+
//# sourceMappingURL=deepCopy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepCopy.js","sourceRoot":"","sources":["../../src/utils/deepCopy.ts"],"names":[],"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MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;gBACrD,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,IAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.d.ts","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,GAAE,MAAM,EAAO,GAAG,OAAO,CA6EnF"}
|
package/dist/utils/deepEqual.js
CHANGED
|
@@ -1,21 +1,80 @@
|
|
|
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
|
+
*/
|
|
1
53
|
export function deepEqual(a, b, excludeProperties = []) {
|
|
54
|
+
// Toggle debugging on or off easily
|
|
2
55
|
const debug = false;
|
|
56
|
+
// Helper function for conditional logging
|
|
3
57
|
const debugLog = (...messages) => {
|
|
4
58
|
if (debug) {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
5
60
|
console.log(...messages);
|
|
6
61
|
}
|
|
7
62
|
};
|
|
63
|
+
// If both are the same instance, return true (handles primitives and same object references)
|
|
8
64
|
if (a === b) {
|
|
9
65
|
return true;
|
|
10
66
|
}
|
|
67
|
+
// If types are different, return false
|
|
11
68
|
if (typeof a !== typeof b) {
|
|
12
69
|
debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
|
|
13
70
|
return false;
|
|
14
71
|
}
|
|
72
|
+
// If one of them is null (and we know they are not equal from the first check), return false
|
|
15
73
|
if (a == null || b == null) {
|
|
16
74
|
debugLog('deepEqual false for == null');
|
|
17
75
|
return false;
|
|
18
76
|
}
|
|
77
|
+
// Handle Arrays
|
|
19
78
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
20
79
|
if (a.length !== b.length) {
|
|
21
80
|
debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
|
|
@@ -31,26 +90,31 @@ export function deepEqual(a, b, excludeProperties = []) {
|
|
|
31
90
|
}
|
|
32
91
|
return true;
|
|
33
92
|
}
|
|
93
|
+
// Handle Objects (and exclude null, functions, and arrays)
|
|
34
94
|
if (typeof a === 'object' && typeof b === 'object') {
|
|
35
95
|
const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
|
|
36
96
|
const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
|
|
97
|
+
// If their property lengths are different, they're different objects
|
|
37
98
|
if (aProps.length !== bProps.length) {
|
|
38
99
|
debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
|
|
39
100
|
debugLog(`- aProps.length(${aProps.length}):`, aProps);
|
|
40
101
|
debugLog(`- bProps.length(${bProps.length}):`, bProps);
|
|
41
102
|
return false;
|
|
42
103
|
}
|
|
104
|
+
// Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
|
|
43
105
|
for (const prop of aProps) {
|
|
44
106
|
if (!Object.prototype.hasOwnProperty.call(b, prop)) {
|
|
45
107
|
debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
|
|
46
108
|
return false;
|
|
47
109
|
}
|
|
48
110
|
if (!deepEqual(a[prop], b[prop], excludeProperties)) {
|
|
49
|
-
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
|
|
111
|
+
debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
|
|
50
112
|
return false;
|
|
51
113
|
}
|
|
52
114
|
}
|
|
53
115
|
return true;
|
|
54
116
|
}
|
|
117
|
+
// If none of the above, the objects are not equal
|
|
55
118
|
return false;
|
|
56
119
|
}
|
|
120
|
+
//# sourceMappingURL=deepEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepEqual.js","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,uDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,SAAS,CAAC,CAAM,EAAE,CAAM,EAAE,oBAA8B,EAAE;IACxE,oCAAoC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC;IAEpB,0CAA0C;IAE1C,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAe,EAAE,EAAE;QACtC,IAAI,KAAK,EAAE,CAAC;YACV,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;IAEF,6FAA6F;IAC7F,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,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KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kDAAkD;IAClD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
package/dist/utils/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isvalid.d.ts","sourceRoot":"","sources":["../../src/utils/isvalid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAKrF;AAED;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAE3D;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAKjG;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAMjG;AAED;;;;;;;GAOG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,OAAO,EAAE,CAKnG;AAED;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,CAErD;AAED;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAE/D"}
|
package/dist/utils/isvalid.js
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
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
|
+
*/
|
|
1
29
|
export function isValidIpv4Address(ipv4Address) {
|
|
2
30
|
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]?)$/;
|
|
3
31
|
return ipv4Regex.test(ipv4Address);
|
|
4
32
|
}
|
|
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
|
|
5
42
|
export function isValidNumber(value, min, max) {
|
|
6
43
|
if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value))
|
|
7
44
|
return false;
|
|
@@ -11,9 +48,25 @@ export function isValidNumber(value, min, max) {
|
|
|
11
48
|
return false;
|
|
12
49
|
return true;
|
|
13
50
|
}
|
|
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
|
|
14
58
|
export function isValidBoolean(value) {
|
|
15
59
|
return value !== undefined && value !== null && typeof value === 'boolean';
|
|
16
60
|
}
|
|
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
|
|
17
70
|
export function isValidString(value, minLength, maxLength) {
|
|
18
71
|
if (value === undefined || value === null || typeof value !== 'string')
|
|
19
72
|
return false;
|
|
@@ -23,6 +76,15 @@ export function isValidString(value, minLength, maxLength) {
|
|
|
23
76
|
return false;
|
|
24
77
|
return true;
|
|
25
78
|
}
|
|
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
|
|
26
88
|
export function isValidObject(value, minLength, maxLength) {
|
|
27
89
|
if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
|
|
28
90
|
return false;
|
|
@@ -33,6 +95,15 @@ export function isValidObject(value, minLength, maxLength) {
|
|
|
33
95
|
return false;
|
|
34
96
|
return true;
|
|
35
97
|
}
|
|
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
|
|
36
107
|
export function isValidArray(value, minLength, maxLength) {
|
|
37
108
|
if (value === undefined || value === null || !Array.isArray(value))
|
|
38
109
|
return false;
|
|
@@ -42,9 +113,24 @@ export function isValidArray(value, minLength, maxLength) {
|
|
|
42
113
|
return false;
|
|
43
114
|
return true;
|
|
44
115
|
}
|
|
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
|
|
45
123
|
export function isValidNull(value) {
|
|
46
124
|
return value === null;
|
|
47
125
|
}
|
|
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
|
|
48
133
|
export function isValidUndefined(value) {
|
|
49
134
|
return value === undefined;
|
|
50
135
|
}
|
|
136
|
+
//# sourceMappingURL=isvalid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isvalid.js","sourceRoot":"","sources":["../../src/utils/isvalid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,MAAM,SAAS,GAAG,kKAAkK,CAAC;IACrL,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,KAA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