matterbridge 2.1.2-dev.3 → 2.1.2
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/dist/cli.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/cluster/export.d.ts +2 -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 +27 -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 +114 -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 +110 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +231 -23
- package/dist/frontend.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -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 +2 -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 +2 -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 +2 -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 +2 -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 +5 -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 +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +2 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +409 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +743 -37
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +39 -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 +1056 -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 +177 -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 +39 -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 +834 -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 +2262 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +96 -0
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +152 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +111 -3
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +167 -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 +230 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/storage/export.d.ts +2 -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/utils/colorUtils.d.ts +61 -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/export.d.ts +3 -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/utils.d.ts +221 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +251 -7
- package/dist/utils/utils.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
|
@@ -1,23 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the class MatterbridgeAccessoryPlatform.
|
|
3
|
+
*
|
|
4
|
+
* @file matterbridgePlatform.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-03-21
|
|
7
|
+
* @version 1.1.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
|
+
*/
|
|
1
23
|
import { isValidArray, isValidObject, isValidString } from './utils/utils.js';
|
|
24
|
+
// AnsiLogger module
|
|
2
25
|
import { CYAN, db, nf, wr } from './logger/export.js';
|
|
26
|
+
// Storage module
|
|
3
27
|
import { NodeStorageManager } from './storage/export.js';
|
|
28
|
+
// Node.js module
|
|
4
29
|
import path from 'path';
|
|
30
|
+
/**
|
|
31
|
+
* Represents the base Matterbridge platform. It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
5
34
|
export class MatterbridgePlatform {
|
|
6
35
|
matterbridge;
|
|
7
36
|
log;
|
|
8
37
|
config = {};
|
|
9
|
-
name = '';
|
|
10
|
-
type = '';
|
|
11
|
-
version = '1.0.0';
|
|
38
|
+
name = ''; // Will be set by the loadPlugin() method using the package.json value.
|
|
39
|
+
type = ''; // Will be set by the extending classes.
|
|
40
|
+
version = '1.0.0'; // Will be set by the loadPlugin() method using the package.json value.
|
|
12
41
|
storage;
|
|
13
42
|
context;
|
|
14
43
|
selectDevice = new Map();
|
|
15
44
|
selectEntity = new Map();
|
|
16
45
|
registeredEndpoints = new Map();
|
|
46
|
+
/**
|
|
47
|
+
* Creates an instance of the base MatterbridgePlatform. It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
48
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
49
|
+
* @param {AnsiLogger} log - The logger instance.
|
|
50
|
+
* @param {PlatformConfig} config - The platform configuration.
|
|
51
|
+
*/
|
|
17
52
|
constructor(matterbridge, log, config) {
|
|
18
53
|
this.matterbridge = matterbridge;
|
|
19
54
|
this.log = log;
|
|
20
55
|
this.config = config;
|
|
56
|
+
// create the NodeStorageManager for the plugin platform
|
|
21
57
|
if (!isValidString(this.config.name))
|
|
22
58
|
return;
|
|
23
59
|
this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
|
|
@@ -29,36 +65,74 @@ export class MatterbridgePlatform {
|
|
|
29
65
|
forgiveParseErrors: true,
|
|
30
66
|
});
|
|
31
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* This method must be overridden in the extended class.
|
|
70
|
+
* It is called when the platform is started.
|
|
71
|
+
* Use this method to create the MatterbridgeDevice and call this.registerDevice().
|
|
72
|
+
* @param {string} [reason] - The reason for starting.
|
|
73
|
+
* @throws {Error} - Throws an error if the method is not overridden.
|
|
74
|
+
*/
|
|
32
75
|
async onStart(reason) {
|
|
33
76
|
this.log.error('Plugins must override onStart.', reason);
|
|
34
77
|
throw new Error('Plugins must override onStart.');
|
|
35
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* This method can be overridden in the extended class. Call super.onConfigure() to run checkEndpointNumbers().
|
|
81
|
+
* It is called after the platform has been commissioned.
|
|
82
|
+
* Use this method to perform any configuration of your devices.
|
|
83
|
+
*/
|
|
36
84
|
async onConfigure() {
|
|
37
85
|
this.log.debug(`Configuring platform ${this.name}`);
|
|
38
86
|
await this.checkEndpointNumbers();
|
|
39
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* This method can be overridden in the extended class. Call super.onShutdown() to run checkEndpointNumbers().
|
|
90
|
+
* It is called when the platform is shutting down.
|
|
91
|
+
* Use this method to clean up any resources.
|
|
92
|
+
* @param {string} [reason] - The reason for shutting down.
|
|
93
|
+
*/
|
|
40
94
|
async onShutdown(reason) {
|
|
41
95
|
this.log.debug(`Shutting down platform ${this.name}`, reason);
|
|
42
96
|
await this.checkEndpointNumbers();
|
|
43
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
|
|
100
|
+
* @param {LogLevel} logLevel The new logger level.
|
|
101
|
+
*/
|
|
44
102
|
async onChangeLoggerLevel(logLevel) {
|
|
45
103
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
46
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Registers a device with the Matterbridge platform.
|
|
107
|
+
* @param {MatterbridgeEndpoint} device - The device to register.
|
|
108
|
+
*/
|
|
47
109
|
async registerDevice(device) {
|
|
48
110
|
device.plugin = this.name;
|
|
49
111
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
50
112
|
if (device.uniqueId)
|
|
51
113
|
this.registeredEndpoints.set(device.uniqueId, device);
|
|
52
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Unregisters a device registered with the Matterbridge platform.
|
|
117
|
+
* @param {MatterbridgeEndpoint} device - The device to unregister.
|
|
118
|
+
*/
|
|
53
119
|
async unregisterDevice(device) {
|
|
54
120
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
55
121
|
if (device.uniqueId)
|
|
56
122
|
this.registeredEndpoints.delete(device.uniqueId);
|
|
57
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Unregisters all devices registered with the Matterbridge platform.
|
|
126
|
+
*/
|
|
58
127
|
async unregisterAllDevices() {
|
|
59
128
|
await this.matterbridge.removeAllBridgedEndpoints(this.name);
|
|
60
129
|
this.registeredEndpoints.clear();
|
|
61
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Verifies if the Matterbridge version meets the required version.
|
|
133
|
+
* @param {string} requiredVersion - The required version to compare against.
|
|
134
|
+
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
135
|
+
*/
|
|
62
136
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
63
137
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
64
138
|
const stripTag = (v) => {
|
|
@@ -83,9 +157,21 @@ export class MatterbridgePlatform {
|
|
|
83
157
|
return false;
|
|
84
158
|
return true;
|
|
85
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* @deprecated This method is deprecated and will be removed in future versions. Use validateDevice instead.
|
|
162
|
+
*/
|
|
86
163
|
validateDeviceWhiteBlackList(device, log = true) {
|
|
87
164
|
return this.validateDevice(device, log);
|
|
88
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Validates if a device is allowed based on the whitelist and blacklist configurations.
|
|
168
|
+
* The blacklist has priority over the whitelist.
|
|
169
|
+
*
|
|
170
|
+
* @param {string | string[]} device - The device name(s) to validate.
|
|
171
|
+
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
172
|
+
* @returns {boolean} - Returns true if the device is allowed, false otherwise.
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
89
175
|
validateDevice(device, log = true) {
|
|
90
176
|
if (!Array.isArray(device))
|
|
91
177
|
device = [device];
|
|
@@ -115,9 +201,21 @@ export class MatterbridgePlatform {
|
|
|
115
201
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
116
202
|
return false;
|
|
117
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated This method is deprecated and will be removed in future versions. Use validateEntity instead.
|
|
206
|
+
*/
|
|
118
207
|
validateEntityBlackList(device, entity, log = true) {
|
|
119
208
|
return this.validateEntity(device, entity, log);
|
|
120
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
|
|
212
|
+
*
|
|
213
|
+
* @param {string} device - The device to which the entity belongs.
|
|
214
|
+
* @param {string} entity - The entity to validate.
|
|
215
|
+
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
216
|
+
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
121
219
|
validateEntity(device, entity, log = true) {
|
|
122
220
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
123
221
|
if (log)
|
|
@@ -136,6 +234,15 @@ export class MatterbridgePlatform {
|
|
|
136
234
|
}
|
|
137
235
|
return true;
|
|
138
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Checks and updates the endpoint numbers for Matterbridge devices.
|
|
239
|
+
*
|
|
240
|
+
* This method retrieves the list of Matterbridge devices and their child endpoints,
|
|
241
|
+
* compares their current endpoint numbers with the stored ones, and updates the storage
|
|
242
|
+
* if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
|
|
243
|
+
*
|
|
244
|
+
* @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
|
|
245
|
+
*/
|
|
139
246
|
async checkEndpointNumbers() {
|
|
140
247
|
if (!this.storage)
|
|
141
248
|
return -1;
|
|
@@ -175,3 +282,4 @@ export class MatterbridgePlatform {
|
|
|
175
282
|
return endpointMap.size;
|
|
176
283
|
}
|
|
177
284
|
}
|
|
285
|
+
//# sourceMappingURL=matterbridgePlatform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matterbridgePlatform.js","sourceRoot":"","sources":["../src/matterbridgePlatform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9E,oBAAoB;AACpB,OAAO,EAAc,IAAI,EAAE,EAAE,EAAY,EAAE,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE5E,iBAAiB;AACjB,OAAO,EAAe,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKtE,iBAAiB;AACjB,OAAO,IAAI,MAAM,MAAM,CAAC;AAWxB;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACxB,YAAY,CAAe;IAC3B,GAAG,CAAa;IAChB,MAAM,GAAmB,EAAE,CAAC;IAC5B,IAAI,GAAG,EAAE,CAAC,CAAC,uEAAuE;IAClF,IAAI,GAAG,EAAE,CAAC,CAA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AAC,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,IAAI,GAAG,KAAK,CAAC,WAAW,GAAG,EAAE,EAAE,CAAC,CAAC;oBACjO,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS,GAAG,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;gBAC5E,CAAC;gBACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;oBAC5D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4CAA4C,IAAI,GAAG,MAAM,CAAC,QAAQ,GAAG,EAAE,IAAI,IAAI,GAAG,OAAO,GAAG,EAAE,OAAO,IAAI,GAAG,KAAK,CAAC,WAAW,GAAG,EAAE,EAAE,CAAC,CAAC;oBACrJ,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,SAAS,GAAG,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACpD,OAAO,WAAW,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the types for Matterbridge.
|
|
3
|
+
*
|
|
4
|
+
* @file matterbridgeTypes.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-07-12
|
|
7
|
+
* @version 1.0.2
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2023, 2024, 2025 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
|
+
import { NodeStorage } from './storage/export.js';
|
|
24
|
+
import { LogLevel } from './logger/export.js';
|
|
25
|
+
import { MatterbridgePlatform, PlatformConfig, PlatformSchema } from './matterbridgePlatform.js';
|
|
26
|
+
import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
27
|
+
import { FabricIndex, NodeId, VendorId, StorageContext, ServerNode, EndpointNumber, Endpoint as EndpointNode } from '@matter/main';
|
|
28
|
+
import { ExposedFabricInformation } from '@matter/main/protocol';
|
|
29
|
+
import { AggregatorEndpoint } from '@matter/main/endpoints/aggregator';
|
|
30
|
+
export declare const plg = "\u001B[38;5;33m";
|
|
31
|
+
export declare const dev = "\u001B[38;5;79m";
|
|
32
|
+
export declare const typ = "\u001B[38;5;207m";
|
|
33
|
+
export interface RegisteredPlugin extends BaseRegisteredPlugin {
|
|
34
|
+
nodeContext?: NodeStorage;
|
|
35
|
+
storageContext?: StorageContext;
|
|
36
|
+
serverNode?: ServerNode<ServerNode.RootEndpoint>;
|
|
37
|
+
aggregatorNode?: EndpointNode<AggregatorEndpoint>;
|
|
38
|
+
device?: MatterbridgeEndpoint;
|
|
39
|
+
platform?: MatterbridgePlatform;
|
|
40
|
+
reachabilityTimeout?: NodeJS.Timeout;
|
|
41
|
+
}
|
|
42
|
+
export interface BaseRegisteredPlugin {
|
|
43
|
+
name: string;
|
|
44
|
+
version: string;
|
|
45
|
+
description: string;
|
|
46
|
+
author: string;
|
|
47
|
+
path: string;
|
|
48
|
+
type: string;
|
|
49
|
+
latestVersion?: string;
|
|
50
|
+
locked?: boolean;
|
|
51
|
+
error?: boolean;
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
loaded?: boolean;
|
|
54
|
+
started?: boolean;
|
|
55
|
+
configured?: boolean;
|
|
56
|
+
paired?: boolean;
|
|
57
|
+
fabricInformations?: SanitizedExposedFabricInformation[];
|
|
58
|
+
sessionInformations?: SanitizedSessionInformation[];
|
|
59
|
+
registeredDevices?: number;
|
|
60
|
+
addedDevices?: number;
|
|
61
|
+
qrPairingCode?: string;
|
|
62
|
+
manualPairingCode?: string;
|
|
63
|
+
configJson?: PlatformConfig;
|
|
64
|
+
schemaJson?: PlatformSchema;
|
|
65
|
+
}
|
|
66
|
+
export interface SystemInformation {
|
|
67
|
+
interfaceName: string;
|
|
68
|
+
macAddress: string;
|
|
69
|
+
ipv4Address: string;
|
|
70
|
+
ipv6Address: string;
|
|
71
|
+
nodeVersion: string;
|
|
72
|
+
hostname: string;
|
|
73
|
+
user: string;
|
|
74
|
+
osType: string;
|
|
75
|
+
osRelease: string;
|
|
76
|
+
osPlatform: string;
|
|
77
|
+
osArch: string;
|
|
78
|
+
totalMemory: string;
|
|
79
|
+
freeMemory: string;
|
|
80
|
+
systemUptime: string;
|
|
81
|
+
rss: string;
|
|
82
|
+
heap: string;
|
|
83
|
+
}
|
|
84
|
+
export interface MatterbridgeInformation {
|
|
85
|
+
homeDirectory: string;
|
|
86
|
+
rootDirectory: string;
|
|
87
|
+
matterbridgeDirectory: string;
|
|
88
|
+
matterbridgePluginDirectory: string;
|
|
89
|
+
globalModulesDirectory: string;
|
|
90
|
+
matterbridgeVersion: string;
|
|
91
|
+
matterbridgeLatestVersion: string;
|
|
92
|
+
matterbridgeQrPairingCode: string | undefined;
|
|
93
|
+
matterbridgeManualPairingCode: string | undefined;
|
|
94
|
+
matterbridgeFabricInformations: SanitizedExposedFabricInformation[] | undefined;
|
|
95
|
+
matterbridgeSessionInformations: SanitizedSessionInformation[] | undefined;
|
|
96
|
+
matterbridgePaired: boolean | undefined;
|
|
97
|
+
bridgeMode: string;
|
|
98
|
+
restartMode: string;
|
|
99
|
+
readOnly: boolean;
|
|
100
|
+
profile?: string;
|
|
101
|
+
loggerLevel: LogLevel;
|
|
102
|
+
fileLogger: boolean;
|
|
103
|
+
matterLoggerLevel: number;
|
|
104
|
+
matterFileLogger: boolean;
|
|
105
|
+
mattermdnsinterface: string | undefined;
|
|
106
|
+
matteripv4address: string | undefined;
|
|
107
|
+
matteripv6address: string | undefined;
|
|
108
|
+
matterPort: number;
|
|
109
|
+
matterDiscriminator: number | undefined;
|
|
110
|
+
matterPasscode: number | undefined;
|
|
111
|
+
restartRequired: boolean;
|
|
112
|
+
refreshRequired: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface SanitizedExposedFabricInformation {
|
|
115
|
+
fabricIndex: FabricIndex;
|
|
116
|
+
fabricId: string;
|
|
117
|
+
nodeId: string;
|
|
118
|
+
rootNodeId: string;
|
|
119
|
+
rootVendorId: VendorId;
|
|
120
|
+
rootVendorName: string;
|
|
121
|
+
label: string;
|
|
122
|
+
}
|
|
123
|
+
export interface SessionInformation {
|
|
124
|
+
name: string;
|
|
125
|
+
nodeId: NodeId;
|
|
126
|
+
peerNodeId: NodeId;
|
|
127
|
+
fabric?: ExposedFabricInformation;
|
|
128
|
+
isPeerActive: boolean;
|
|
129
|
+
secure: boolean;
|
|
130
|
+
lastInteractionTimestamp?: number;
|
|
131
|
+
lastActiveTimestamp?: number;
|
|
132
|
+
numberOfActiveSubscriptions: number;
|
|
133
|
+
}
|
|
134
|
+
export interface SanitizedSessionInformation {
|
|
135
|
+
name: string;
|
|
136
|
+
nodeId: string;
|
|
137
|
+
peerNodeId: string;
|
|
138
|
+
fabric?: SanitizedExposedFabricInformation;
|
|
139
|
+
isPeerActive: boolean;
|
|
140
|
+
secure: boolean;
|
|
141
|
+
lastInteractionTimestamp?: string;
|
|
142
|
+
lastActiveTimestamp?: string;
|
|
143
|
+
numberOfActiveSubscriptions: number;
|
|
144
|
+
}
|
|
145
|
+
export interface ApiDevices {
|
|
146
|
+
pluginName: string;
|
|
147
|
+
type: string;
|
|
148
|
+
endpoint: EndpointNumber | undefined;
|
|
149
|
+
name: string;
|
|
150
|
+
serial: string;
|
|
151
|
+
productUrl: string;
|
|
152
|
+
configUrl?: string;
|
|
153
|
+
uniqueId: string;
|
|
154
|
+
cluster: string;
|
|
155
|
+
}
|
|
156
|
+
export interface ApiClusters {
|
|
157
|
+
endpoint: string;
|
|
158
|
+
id: string;
|
|
159
|
+
deviceTypes: number[];
|
|
160
|
+
clusterName: string;
|
|
161
|
+
clusterId: string;
|
|
162
|
+
attributeName: string;
|
|
163
|
+
attributeId: string;
|
|
164
|
+
attributeValue: string;
|
|
165
|
+
attributeLocalValue: unknown;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=matterbridgeTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matterbridgeTypes.d.ts","sourceRoot":"","sources":["../src/matterbridgeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AACnI,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGv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AAM,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2BAA2B,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;CAC9B"}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the types for Matterbridge.
|
|
3
|
+
*
|
|
4
|
+
* @file matterbridgeTypes.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-07-12
|
|
7
|
+
* @version 1.0.2
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2023, 2024, 2025 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
|
+
// Default colors
|
|
1
24
|
export const plg = '\u001B[38;5;33m';
|
|
2
25
|
export const dev = '\u001B[38;5;79m';
|
|
3
26
|
export const typ = '\u001B[38;5;207m';
|
|
27
|
+
//# sourceMappingURL=matterbridgeTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matterbridgeTypes.js","sourceRoot":"","sources":["../src/matterbridgeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAeH,iBAAiB;AACjB,MAAM,CAAC,MAAM,GAAG,GAAG,iBAAiB,CAAC;AACrC,MAAM,CAAC,MAAM,GAAG,GAAG,iBAAiB,CAAC;AACrC,MAAM,CAAC,MAAM,GAAG,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the Plugins class.
|
|
3
|
+
*
|
|
4
|
+
* @file plugins.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @date 2024-07-14
|
|
7
|
+
* @version 1.1.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
|
+
import { LogLevel } from './logger/export.js';
|
|
24
|
+
import { Matterbridge } from './matterbridge.js';
|
|
25
|
+
import { RegisteredPlugin } from './matterbridgeTypes.js';
|
|
26
|
+
import { MatterbridgePlatform, PlatformConfig, PlatformSchema } from './matterbridgePlatform.js';
|
|
27
|
+
export declare class PluginManager {
|
|
28
|
+
private _plugins;
|
|
29
|
+
private nodeContext;
|
|
30
|
+
private matterbridge;
|
|
31
|
+
private log;
|
|
32
|
+
constructor(matterbridge: Matterbridge);
|
|
33
|
+
get length(): number;
|
|
34
|
+
get size(): number;
|
|
35
|
+
has(name: string): boolean;
|
|
36
|
+
get(name: string): RegisteredPlugin | undefined;
|
|
37
|
+
set(plugin: RegisteredPlugin): RegisteredPlugin;
|
|
38
|
+
clear(): void;
|
|
39
|
+
array(): RegisteredPlugin[];
|
|
40
|
+
[Symbol.iterator](): MapIterator<RegisteredPlugin>;
|
|
41
|
+
forEach(callback: (plugin: RegisteredPlugin) => Promise<void>): Promise<void>;
|
|
42
|
+
set logLevel(logLevel: LogLevel);
|
|
43
|
+
/**
|
|
44
|
+
* Loads registered plugins from storage.
|
|
45
|
+
*
|
|
46
|
+
* This method retrieves an array of registered plugins from the storage and converts it
|
|
47
|
+
* into a map where the plugin names are the keys and the plugin objects are the values.
|
|
48
|
+
*
|
|
49
|
+
* @returns {Promise<RegisteredPlugin[]>} A promise that resolves to an array of registered plugins.
|
|
50
|
+
*/
|
|
51
|
+
loadFromStorage(): Promise<RegisteredPlugin[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Loads registered plugins from storage.
|
|
54
|
+
*
|
|
55
|
+
* This method retrieves an array of registered plugins from the storage and converts it
|
|
56
|
+
* into a map where the plugin names are the keys and the plugin objects are the values.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Promise<RegisteredPlugin[]>} A promise that resolves to an array of registered plugins.
|
|
59
|
+
*/
|
|
60
|
+
saveToStorage(): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Resolves the name of a plugin by loading and parsing its package.json file.
|
|
63
|
+
* @param pluginPath - The path to the plugin or the path to the plugin's package.json file.
|
|
64
|
+
* @returns The path to the resolved package.json file, or null if the package.json file is not found or does not contain a name.
|
|
65
|
+
*/
|
|
66
|
+
resolve(pluginPath: string): Promise<string | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Loads and parse the plugin package.json and returns it.
|
|
69
|
+
* @param plugin - The plugin to load the package from.
|
|
70
|
+
* @returns A Promise that resolves to the package.json object or undefined if the package.json could not be loaded.
|
|
71
|
+
*/
|
|
72
|
+
parse(plugin: RegisteredPlugin): Promise<Record<string, string | number | object> | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Enables a plugin by its name or path.
|
|
75
|
+
*
|
|
76
|
+
* This method enables a plugin by setting its `enabled` property to `true` and saving the updated
|
|
77
|
+
* plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
|
|
78
|
+
* If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} nameOrPath - The name or path of the plugin to enable.
|
|
81
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
|
|
82
|
+
*/
|
|
83
|
+
enable(nameOrPath: string): Promise<RegisteredPlugin | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Enables a plugin by its name or path.
|
|
86
|
+
*
|
|
87
|
+
* This method enables a plugin by setting its `enabled` property to `true` and saving the updated
|
|
88
|
+
* plugin information to storage. It first checks if the plugin is already registered in the `_plugins` map.
|
|
89
|
+
* If not, it attempts to resolve the plugin's `package.json` file to retrieve its name and enable it.
|
|
90
|
+
*
|
|
91
|
+
* @param {string} nameOrPath - The name or path of the plugin to enable.
|
|
92
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the enabled plugin object, or null if the plugin could not be enabled.
|
|
93
|
+
*/
|
|
94
|
+
disable(nameOrPath: string): Promise<RegisteredPlugin | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Removes a plugin by its name or path.
|
|
97
|
+
*
|
|
98
|
+
* This method removes a plugin from the `_plugins` map and saves the updated plugin information to storage.
|
|
99
|
+
* It first checks if the plugin is already registered in the `_plugins` map. If not, it attempts to resolve
|
|
100
|
+
* the plugin's `package.json` file to retrieve its name and remove it.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} nameOrPath - The name or path of the plugin to remove.
|
|
103
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the removed plugin object, or null if the plugin could not be removed.
|
|
104
|
+
*/
|
|
105
|
+
remove(nameOrPath: string): Promise<RegisteredPlugin | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Adds a plugin by its name or path.
|
|
108
|
+
*
|
|
109
|
+
* This method adds a plugin to the `_plugins` map and saves the updated plugin information to storage.
|
|
110
|
+
* It first resolves the plugin's `package.json` file to retrieve its details. If the plugin is already
|
|
111
|
+
* registered, it logs an info message and returns null. Otherwise, it registers the plugin, enables it,
|
|
112
|
+
* and saves the updated plugin information to storage.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} nameOrPath - The name or path of the plugin to add.
|
|
115
|
+
* @returns {Promise<RegisteredPlugin | null>} A promise that resolves to the added plugin object, or null if the plugin could not be added.
|
|
116
|
+
*/
|
|
117
|
+
add(nameOrPath: string): Promise<RegisteredPlugin | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Installs a plugin by its name.
|
|
120
|
+
*
|
|
121
|
+
* This method first uninstalls any existing version of the plugin, then installs the plugin globally using npm.
|
|
122
|
+
* It logs the installation process and retrieves the installed version of the plugin.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} name - The name of the plugin to install.
|
|
125
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the installed version of the plugin, or undefined if the installation failed.
|
|
126
|
+
*/
|
|
127
|
+
install(name: string): Promise<string | undefined>;
|
|
128
|
+
/**
|
|
129
|
+
* Uninstalls a plugin by its name.
|
|
130
|
+
*
|
|
131
|
+
* This method uninstalls a globally installed plugin using npm. It logs the uninstallation process
|
|
132
|
+
* and returns the name of the uninstalled plugin if successful, or undefined if the uninstallation failed.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} name - The name of the plugin to uninstall.
|
|
135
|
+
* @returns {Promise<string | undefined>} A promise that resolves to the name of the uninstalled plugin, or undefined if the uninstallation failed.
|
|
136
|
+
*/
|
|
137
|
+
uninstall(name: string): Promise<string | undefined>;
|
|
138
|
+
/**
|
|
139
|
+
* Loads a plugin and returns the corresponding MatterbridgePlatform instance.
|
|
140
|
+
* @param plugin - The plugin to load.
|
|
141
|
+
* @param start - Optional flag indicating whether to start the plugin after loading. Default is false.
|
|
142
|
+
* @param message - Optional message to pass to the plugin when starting.
|
|
143
|
+
* @returns A Promise that resolves to the loaded MatterbridgePlatform instance.
|
|
144
|
+
* @throws An error if the plugin is not enabled, already loaded, or fails to load.
|
|
145
|
+
*/
|
|
146
|
+
load(plugin: RegisteredPlugin, start?: boolean, message?: string, configure?: boolean): Promise<MatterbridgePlatform | undefined>;
|
|
147
|
+
/**
|
|
148
|
+
* Starts a plugin.
|
|
149
|
+
*
|
|
150
|
+
* @param {RegisteredPlugin} plugin - The plugin to start.
|
|
151
|
+
* @param {string} [message] - Optional message to pass to the plugin's onStart method.
|
|
152
|
+
* @param {boolean} [configure] - Indicates whether to configure the plugin after starting (default false).
|
|
153
|
+
* @returns {Promise<RegisteredPlugin | undefined>} A promise that resolves when the plugin is started successfully, or rejects with an error if starting the plugin fails.
|
|
154
|
+
*/
|
|
155
|
+
start(plugin: RegisteredPlugin, message?: string, configure?: boolean): Promise<RegisteredPlugin | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* Configures a plugin.
|
|
158
|
+
*
|
|
159
|
+
* @param {RegisteredPlugin} plugin - The plugin to configure.
|
|
160
|
+
* @returns {Promise<void>} A promise that resolves when the plugin is configured successfully, or rejects with an error if configuration fails.
|
|
161
|
+
*/
|
|
162
|
+
configure(plugin: RegisteredPlugin): Promise<RegisteredPlugin | undefined>;
|
|
163
|
+
/**
|
|
164
|
+
* Shuts down a plugin.
|
|
165
|
+
*
|
|
166
|
+
* This method shuts down a plugin by calling its `onShutdown` method and resetting its state.
|
|
167
|
+
* It logs the shutdown process and optionally removes all devices associated with the plugin.
|
|
168
|
+
*
|
|
169
|
+
* @param {RegisteredPlugin} plugin - The plugin to shut down.
|
|
170
|
+
* @param {string} [reason] - The reason for shutting down the plugin.
|
|
171
|
+
* @param {boolean} [removeAllDevices=false] - Whether to remove all devices associated with the plugin.
|
|
172
|
+
* @param {boolean} [force=false] - Whether to force the shutdown even if the plugin is not loaded or started.
|
|
173
|
+
* @returns {Promise<RegisteredPlugin | undefined>} A promise that resolves to the shut down plugin object, or undefined if the shutdown failed.
|
|
174
|
+
*/
|
|
175
|
+
shutdown(plugin: RegisteredPlugin, reason?: string, removeAllDevices?: boolean, force?: boolean): Promise<RegisteredPlugin | undefined>;
|
|
176
|
+
/**
|
|
177
|
+
* Loads the configuration for a plugin.
|
|
178
|
+
* If the configuration file exists, it reads the file and returns the parsed JSON data.
|
|
179
|
+
* If the configuration file does not exist, it creates a new file with default configuration and returns it.
|
|
180
|
+
* If any error occurs during file access or creation, it logs an error and return un empty config.
|
|
181
|
+
*
|
|
182
|
+
* @param plugin - The plugin for which to load the configuration.
|
|
183
|
+
* @returns A promise that resolves to the loaded or created configuration.
|
|
184
|
+
*/
|
|
185
|
+
loadConfig(plugin: RegisteredPlugin): Promise<PlatformConfig>;
|
|
186
|
+
/**
|
|
187
|
+
* Saves the configuration of a plugin to a file.
|
|
188
|
+
*
|
|
189
|
+
* This method saves the configuration of the specified plugin to a JSON file in the matterbridge directory.
|
|
190
|
+
* If the plugin's configuration is not found, it logs an error and rejects the promise. If the configuration
|
|
191
|
+
* is successfully saved, it logs a debug message. If an error occurs during the file write operation, it logs
|
|
192
|
+
* the error and rejects the promise.
|
|
193
|
+
*
|
|
194
|
+
* @param {RegisteredPlugin} plugin - The plugin whose configuration is to be saved.
|
|
195
|
+
* @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or rejects if an error occurs.
|
|
196
|
+
* @throws {Error} If the plugin's configuration is not found.
|
|
197
|
+
*/
|
|
198
|
+
saveConfigFromPlugin(plugin: RegisteredPlugin): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Saves the configuration of a plugin from a JSON object to a file.
|
|
201
|
+
*
|
|
202
|
+
* This method saves the provided configuration of the specified plugin to a JSON file in the matterbridge directory.
|
|
203
|
+
* It first checks if the configuration data is valid by ensuring it contains the correct name and type, and matches
|
|
204
|
+
* the plugin's name. If the configuration data is invalid, it logs an error and returns. If the configuration is
|
|
205
|
+
* successfully saved, it updates the plugin's `configJson` property and logs a debug message. If an error occurs
|
|
206
|
+
* during the file write operation, it logs the error and returns.
|
|
207
|
+
*
|
|
208
|
+
* @param {RegisteredPlugin} plugin - The plugin whose configuration is to be saved.
|
|
209
|
+
* @param {PlatformConfig} config - The configuration data to be saved.
|
|
210
|
+
* @returns {Promise<void>} A promise that resolves when the configuration is successfully saved, or returns if an error occurs.
|
|
211
|
+
*/
|
|
212
|
+
saveConfigFromJson(plugin: RegisteredPlugin, config: PlatformConfig): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Loads the schema for a plugin.
|
|
215
|
+
*
|
|
216
|
+
* This method attempts to load the schema file for the specified plugin. If the schema file is found,
|
|
217
|
+
* it reads and parses the file, updates the schema's title and description, and logs the process.
|
|
218
|
+
* If the schema file is not found, it logs the event and loads a default schema for the plugin.
|
|
219
|
+
*
|
|
220
|
+
* @param {RegisteredPlugin} plugin - The plugin whose schema is to be loaded.
|
|
221
|
+
* @returns {Promise<PlatformSchema>} A promise that resolves to the loaded schema object, or the default schema if the schema file is not found.
|
|
222
|
+
*/
|
|
223
|
+
loadSchema(plugin: RegisteredPlugin): Promise<PlatformSchema>;
|
|
224
|
+
/**
|
|
225
|
+
* Returns the default schema for a plugin.
|
|
226
|
+
*
|
|
227
|
+
* This method generates a default schema object for the specified plugin. The schema includes
|
|
228
|
+
* metadata such as the plugin's title, description, version, and author. It also defines the
|
|
229
|
+
* properties of the schema, including the plugin's name, type, debug flag, and unregisterOnShutdown flag.
|
|
230
|
+
*
|
|
231
|
+
* @param {RegisteredPlugin} plugin - The plugin for which the default schema is to be generated.
|
|
232
|
+
* @returns {PlatformSchema} The default schema object for the plugin.
|
|
233
|
+
*/
|
|
234
|
+
getDefaultSchema(plugin: RegisteredPlugin): PlatformSchema;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=pluginManager.d.ts.map
|