@riddix/hamh 2.1.0-alpha.486 → 2.1.0-alpha.487
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/backend/cli.js
CHANGED
|
@@ -2229,12 +2229,12 @@ var init_Diagnostic = __esm({
|
|
|
2229
2229
|
const diagnostic = Array();
|
|
2230
2230
|
format(details);
|
|
2231
2231
|
return Diagnostic2("error", diagnostic);
|
|
2232
|
-
function format({ id, message: message2, path:
|
|
2232
|
+
function format({ id, message: message2, path: path14, cause }) {
|
|
2233
2233
|
if (id) {
|
|
2234
2234
|
diagnostic.push(Diagnostic2.squash("[", Diagnostic2.strong(id), "]"));
|
|
2235
2235
|
}
|
|
2236
|
-
if (
|
|
2237
|
-
diagnostic.push(Diagnostic2.squash(
|
|
2236
|
+
if (path14) {
|
|
2237
|
+
diagnostic.push(Diagnostic2.squash(path14, ":"));
|
|
2238
2238
|
}
|
|
2239
2239
|
const hasCause = cause !== void 0;
|
|
2240
2240
|
if (hasCause) {
|
|
@@ -2324,12 +2324,12 @@ var init_Diagnostic = __esm({
|
|
|
2324
2324
|
let message2;
|
|
2325
2325
|
let rawStack;
|
|
2326
2326
|
let id;
|
|
2327
|
-
let
|
|
2327
|
+
let path14;
|
|
2328
2328
|
if (error2 !== void 0 && error2 !== null) {
|
|
2329
2329
|
if (typeof error2 === "string" || typeof error2 === "number") {
|
|
2330
2330
|
return { message: `${error2}` };
|
|
2331
2331
|
}
|
|
2332
|
-
({ message: message2, stack: rawStack, id, path:
|
|
2332
|
+
({ message: message2, stack: rawStack, id, path: path14 } = error2);
|
|
2333
2333
|
if (message2 === void 0) {
|
|
2334
2334
|
message2 = error2.toString();
|
|
2335
2335
|
}
|
|
@@ -2348,7 +2348,7 @@ var init_Diagnostic = __esm({
|
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
2350
2350
|
if (!rawStack) {
|
|
2351
|
-
return { message: message2, id, path:
|
|
2351
|
+
return { message: message2, id, path: path14 };
|
|
2352
2352
|
}
|
|
2353
2353
|
rawStack = rawStack.toString();
|
|
2354
2354
|
rawStack = rawStack.replace(/^.*?\n\nError: /gs, "Error: ");
|
|
@@ -2403,7 +2403,7 @@ var init_Diagnostic = __esm({
|
|
|
2403
2403
|
if (truncatedToParent) {
|
|
2404
2404
|
stack.push(Diagnostic2.weak("(see parent frames)"));
|
|
2405
2405
|
}
|
|
2406
|
-
return { message: message2, id, path:
|
|
2406
|
+
return { message: message2, id, path: path14, stack, stackLines };
|
|
2407
2407
|
}
|
|
2408
2408
|
Diagnostic2.messageAndStackFor = messageAndStackFor;
|
|
2409
2409
|
})(Diagnostic || (Diagnostic = {}));
|
|
@@ -8818,16 +8818,16 @@ var init_RuntimeService = __esm({
|
|
|
8818
8818
|
});
|
|
8819
8819
|
|
|
8820
8820
|
// ../../node_modules/.pnpm/@matter+general@0.16.10/node_modules/@matter/general/dist/esm/environment/VariableService.js
|
|
8821
|
-
function addVariable(into,
|
|
8822
|
-
if (!
|
|
8821
|
+
function addVariable(into, path14, value) {
|
|
8822
|
+
if (!path14.length) {
|
|
8823
8823
|
return;
|
|
8824
8824
|
}
|
|
8825
|
-
const firstPathEntry =
|
|
8825
|
+
const firstPathEntry = path14[0];
|
|
8826
8826
|
if (firstPathEntry === "__proto__" || firstPathEntry === "constructor" || firstPathEntry === "prototype") {
|
|
8827
8827
|
throw new ImplementationError(`Invalid variable path name: ${firstPathEntry}`);
|
|
8828
8828
|
}
|
|
8829
8829
|
let current = into[firstPathEntry];
|
|
8830
|
-
if (
|
|
8830
|
+
if (path14.length === 1) {
|
|
8831
8831
|
if (current === void 0) {
|
|
8832
8832
|
into[firstPathEntry] = value;
|
|
8833
8833
|
}
|
|
@@ -8836,7 +8836,7 @@ function addVariable(into, path13, value) {
|
|
|
8836
8836
|
if (typeof current !== "object") {
|
|
8837
8837
|
current = into[firstPathEntry] = {};
|
|
8838
8838
|
}
|
|
8839
|
-
addVariable(current,
|
|
8839
|
+
addVariable(current, path14.slice(1), value);
|
|
8840
8840
|
}
|
|
8841
8841
|
function parseUnixStyle(values4) {
|
|
8842
8842
|
const variables = {};
|
|
@@ -9031,16 +9031,16 @@ var init_VariableService = __esm({
|
|
|
9031
9031
|
return value;
|
|
9032
9032
|
}
|
|
9033
9033
|
addConfigStyle(vars) {
|
|
9034
|
-
const
|
|
9034
|
+
const path14 = Array();
|
|
9035
9035
|
const add = (vars2) => {
|
|
9036
9036
|
for (const name in vars2) {
|
|
9037
9037
|
const val = vars2[name];
|
|
9038
9038
|
if (isObject(val)) {
|
|
9039
|
-
|
|
9039
|
+
path14.push(name);
|
|
9040
9040
|
add(val);
|
|
9041
|
-
|
|
9041
|
+
path14.pop();
|
|
9042
9042
|
} else {
|
|
9043
|
-
this.set([...
|
|
9043
|
+
this.set([...path14, name].join("."), val);
|
|
9044
9044
|
}
|
|
9045
9045
|
}
|
|
9046
9046
|
};
|
|
@@ -11045,8 +11045,8 @@ var init_AppAddress = __esm({
|
|
|
11045
11045
|
host = `${host}:${definition.transport.port}`;
|
|
11046
11046
|
}
|
|
11047
11047
|
}
|
|
11048
|
-
const
|
|
11049
|
-
definition = `${protocol}://${host}${
|
|
11048
|
+
const path14 = definition.path ?? "/";
|
|
11049
|
+
definition = `${protocol}://${host}${path14}`;
|
|
11050
11050
|
}
|
|
11051
11051
|
try {
|
|
11052
11052
|
super(definition);
|
|
@@ -16441,8 +16441,8 @@ var init_errors2 = __esm({
|
|
|
16441
16441
|
"../../node_modules/.pnpm/@matter+model@0.16.10/node_modules/@matter/model/dist/esm/common/errors.js"() {
|
|
16442
16442
|
init_esm();
|
|
16443
16443
|
SchemaImplementationError = class extends MatterError {
|
|
16444
|
-
constructor(
|
|
16445
|
-
super(`Definition of ${
|
|
16444
|
+
constructor(path14, message) {
|
|
16445
|
+
super(`Definition of ${path14.path ?? path14}: ${message}`);
|
|
16446
16446
|
}
|
|
16447
16447
|
};
|
|
16448
16448
|
}
|
|
@@ -38183,10 +38183,10 @@ var init_ModelTraversal = __esm({
|
|
|
38183
38183
|
if (type === void 0) {
|
|
38184
38184
|
return;
|
|
38185
38185
|
}
|
|
38186
|
-
const
|
|
38187
|
-
if (
|
|
38186
|
+
const path14 = type.split(".");
|
|
38187
|
+
if (path14.length === 1) {
|
|
38188
38188
|
for (const tag3 of model.allowedBaseTags) {
|
|
38189
|
-
const found = this.findType(this.findParent(model),
|
|
38189
|
+
const found = this.findType(this.findParent(model), path14[0], tag3);
|
|
38190
38190
|
if (found) {
|
|
38191
38191
|
return found;
|
|
38192
38192
|
}
|
|
@@ -38194,7 +38194,7 @@ var init_ModelTraversal = __esm({
|
|
|
38194
38194
|
return;
|
|
38195
38195
|
}
|
|
38196
38196
|
for (const tag3 of model.allowedBaseTags) {
|
|
38197
|
-
const found = this.findQualifiedType(this.findParent(model),
|
|
38197
|
+
const found = this.findQualifiedType(this.findParent(model), path14, tag3);
|
|
38198
38198
|
if (found) {
|
|
38199
38199
|
return found;
|
|
38200
38200
|
}
|
|
@@ -38489,21 +38489,21 @@ var init_ModelTraversal = __esm({
|
|
|
38489
38489
|
* This is quite complicated and would be painfully slow except in practice we don't use many qualified types and
|
|
38490
38490
|
* those we do use resolve with few failing branches in the search once the root qualifier of the name matches.
|
|
38491
38491
|
*/
|
|
38492
|
-
findQualifiedType(scope,
|
|
38492
|
+
findQualifiedType(scope, path14, tag3) {
|
|
38493
38493
|
if (!scope) {
|
|
38494
38494
|
return;
|
|
38495
38495
|
}
|
|
38496
38496
|
function resolve6(scope2, position = 0) {
|
|
38497
|
-
if (position ===
|
|
38498
|
-
return scope2.children.select(
|
|
38497
|
+
if (position === path14.length - 1) {
|
|
38498
|
+
return scope2.children.select(path14[position], tag3);
|
|
38499
38499
|
}
|
|
38500
|
-
for (const subscope of scope2.children.selectAll(
|
|
38500
|
+
for (const subscope of scope2.children.selectAll(path14[position])) {
|
|
38501
38501
|
const result = resolve6(subscope, position + 1);
|
|
38502
38502
|
if (result) {
|
|
38503
38503
|
return result;
|
|
38504
38504
|
}
|
|
38505
38505
|
}
|
|
38506
|
-
if (position === 0 && scope2.tag === ElementTag.Matter &&
|
|
38506
|
+
if (position === 0 && scope2.tag === ElementTag.Matter && path14[0] === "Matter") {
|
|
38507
38507
|
const result = resolve6(scope2, position + 1);
|
|
38508
38508
|
if (result) {
|
|
38509
38509
|
return result;
|
|
@@ -91490,9 +91490,9 @@ function encodeAttributePayload(attributePayload, options) {
|
|
|
91490
91490
|
if (attributeData === void 0) {
|
|
91491
91491
|
return TlvAttributeReport.encodeTlv({ attributeStatus });
|
|
91492
91492
|
}
|
|
91493
|
-
const { path:
|
|
91493
|
+
const { path: path14, schema: schema6, payload, dataVersion } = attributeData;
|
|
91494
91494
|
return TlvAttributeReport.encodeTlv({
|
|
91495
|
-
attributeData: { path:
|
|
91495
|
+
attributeData: { path: path14, data: schema6.encodeTlv(payload, options), dataVersion }
|
|
91496
91496
|
});
|
|
91497
91497
|
}
|
|
91498
91498
|
function encodeEventPayload(eventPayload, options) {
|
|
@@ -91501,7 +91501,7 @@ function encodeEventPayload(eventPayload, options) {
|
|
|
91501
91501
|
return TlvEventReport.encodeTlv({ eventStatus });
|
|
91502
91502
|
}
|
|
91503
91503
|
const {
|
|
91504
|
-
path:
|
|
91504
|
+
path: path14,
|
|
91505
91505
|
schema: schema6,
|
|
91506
91506
|
payload,
|
|
91507
91507
|
eventNumber,
|
|
@@ -91513,7 +91513,7 @@ function encodeEventPayload(eventPayload, options) {
|
|
|
91513
91513
|
} = eventData;
|
|
91514
91514
|
return TlvEventReport.encodeTlv({
|
|
91515
91515
|
eventData: {
|
|
91516
|
-
path:
|
|
91516
|
+
path: path14,
|
|
91517
91517
|
data: schema6.encodeTlv(payload, options),
|
|
91518
91518
|
priority: priority3,
|
|
91519
91519
|
systemTimestamp,
|
|
@@ -91543,7 +91543,7 @@ function chunkAttributePayload(attributePayload) {
|
|
|
91543
91543
|
`Cannot chunk an AttributePayload with just a attributeStatus: ${Diagnostic.json(attributePayload)}`
|
|
91544
91544
|
);
|
|
91545
91545
|
}
|
|
91546
|
-
const { schema: schema6, path:
|
|
91546
|
+
const { schema: schema6, path: path14, dataVersion, payload } = attributeData;
|
|
91547
91547
|
if (!(schema6 instanceof ArraySchema) || !Array.isArray(payload)) {
|
|
91548
91548
|
throw new MatterFlowError(
|
|
91549
91549
|
`Cannot chunk an AttributePayload with attributeData that is not an array: ${Diagnostic.json(
|
|
@@ -91554,14 +91554,14 @@ function chunkAttributePayload(attributePayload) {
|
|
|
91554
91554
|
const chunks = new Array();
|
|
91555
91555
|
chunks.push({
|
|
91556
91556
|
hasFabricSensitiveData,
|
|
91557
|
-
attributeData: { schema: schema6, path: { ...
|
|
91557
|
+
attributeData: { schema: schema6, path: { ...path14, listIndex: void 0 }, payload: [], dataVersion }
|
|
91558
91558
|
});
|
|
91559
91559
|
payload.forEach((element2) => {
|
|
91560
91560
|
chunks.push({
|
|
91561
91561
|
hasFabricSensitiveData,
|
|
91562
91562
|
attributeData: {
|
|
91563
91563
|
schema: schema6.elementSchema,
|
|
91564
|
-
path: { ...
|
|
91564
|
+
path: { ...path14, listIndex: null },
|
|
91565
91565
|
payload: element2,
|
|
91566
91566
|
dataVersion
|
|
91567
91567
|
}
|
|
@@ -92074,13 +92074,13 @@ var init_InteractionMessenger = __esm({
|
|
|
92074
92074
|
static convertServerInteractionReport(report) {
|
|
92075
92075
|
switch (report.kind) {
|
|
92076
92076
|
case "attr-value": {
|
|
92077
|
-
const { path:
|
|
92077
|
+
const { path: path14, value: payload, version: dataVersion, tlv: schema6 } = report;
|
|
92078
92078
|
if (schema6 === void 0) {
|
|
92079
|
-
throw new InternalError(`Attribute ${
|
|
92079
|
+
throw new InternalError(`Attribute ${path14.clusterId}/${path14.attributeId} not found`);
|
|
92080
92080
|
}
|
|
92081
92081
|
const data = {
|
|
92082
92082
|
attributeData: {
|
|
92083
|
-
path:
|
|
92083
|
+
path: path14,
|
|
92084
92084
|
payload,
|
|
92085
92085
|
schema: schema6,
|
|
92086
92086
|
dataVersion
|
|
@@ -92091,10 +92091,10 @@ var init_InteractionMessenger = __esm({
|
|
|
92091
92091
|
return data;
|
|
92092
92092
|
}
|
|
92093
92093
|
case "attr-status": {
|
|
92094
|
-
const { path:
|
|
92094
|
+
const { path: path14, status: status3, clusterStatus } = report;
|
|
92095
92095
|
const statusReport = {
|
|
92096
92096
|
attributeStatus: {
|
|
92097
|
-
path:
|
|
92097
|
+
path: path14,
|
|
92098
92098
|
status: { status: status3 }
|
|
92099
92099
|
},
|
|
92100
92100
|
hasFabricSensitiveData: false
|
|
@@ -92106,7 +92106,7 @@ var init_InteractionMessenger = __esm({
|
|
|
92106
92106
|
}
|
|
92107
92107
|
case "event-value": {
|
|
92108
92108
|
const {
|
|
92109
|
-
path:
|
|
92109
|
+
path: path14,
|
|
92110
92110
|
value: payload,
|
|
92111
92111
|
number: eventNumber,
|
|
92112
92112
|
priority: priority3,
|
|
@@ -92115,7 +92115,7 @@ var init_InteractionMessenger = __esm({
|
|
|
92115
92115
|
} = report;
|
|
92116
92116
|
const data = {
|
|
92117
92117
|
eventData: {
|
|
92118
|
-
path:
|
|
92118
|
+
path: path14,
|
|
92119
92119
|
eventNumber,
|
|
92120
92120
|
priority: priority3,
|
|
92121
92121
|
epochTimestamp,
|
|
@@ -92128,10 +92128,10 @@ var init_InteractionMessenger = __esm({
|
|
|
92128
92128
|
return data;
|
|
92129
92129
|
}
|
|
92130
92130
|
case "event-status": {
|
|
92131
|
-
const { path:
|
|
92131
|
+
const { path: path14, status: status3, clusterStatus } = report;
|
|
92132
92132
|
const statusReport = {
|
|
92133
92133
|
eventStatus: {
|
|
92134
|
-
path:
|
|
92134
|
+
path: path14,
|
|
92135
92135
|
status: { status: status3 }
|
|
92136
92136
|
},
|
|
92137
92137
|
hasFabricSensitiveData: false
|
|
@@ -101110,8 +101110,8 @@ function normalizeAndDecodeReadAttributeReport(data, leftoverAttributeReports) {
|
|
|
101110
101110
|
if (attributeData === void 0) {
|
|
101111
101111
|
break;
|
|
101112
101112
|
}
|
|
101113
|
-
const { path:
|
|
101114
|
-
if (
|
|
101113
|
+
const { path: path14, data: tlvData } = attributeData;
|
|
101114
|
+
if (path14.listIndex !== void 0) {
|
|
101115
101115
|
chunkedArrayDataFound = true;
|
|
101116
101116
|
continue;
|
|
101117
101117
|
} else if (chunkedArrayDataFound || // We found chunked elements before so this must be array initial value now
|
|
@@ -101136,25 +101136,25 @@ function expandPathsInAttributeData(data, acceptWildcardPaths = false) {
|
|
|
101136
101136
|
let lastPath;
|
|
101137
101137
|
data.forEach((value) => {
|
|
101138
101138
|
if (value === void 0) return;
|
|
101139
|
-
const { path:
|
|
101140
|
-
if (
|
|
101139
|
+
const { path: path14 } = value;
|
|
101140
|
+
if (path14.enableTagCompression) {
|
|
101141
101141
|
if (lastPath === void 0) throw new UnexpectedDataError("Tag compression enabled, but no previous path");
|
|
101142
|
-
if (
|
|
101143
|
-
if (
|
|
101144
|
-
if (
|
|
101145
|
-
if (
|
|
101142
|
+
if (path14.nodeId === void 0 && lastPath.nodeId !== void 0) path14.nodeId = lastPath.nodeId;
|
|
101143
|
+
if (path14.endpointId === void 0) path14.endpointId = lastPath.endpointId;
|
|
101144
|
+
if (path14.clusterId === void 0) path14.clusterId = lastPath.clusterId;
|
|
101145
|
+
if (path14.attributeId === void 0) path14.attributeId = lastPath.attributeId;
|
|
101146
101146
|
if (value.dataVersion === void 0 && lastPath.dataVersion !== void 0)
|
|
101147
101147
|
value.dataVersion = lastPath.dataVersion;
|
|
101148
|
-
} else if (
|
|
101148
|
+
} else if (path14.endpointId !== void 0 && path14.clusterId !== void 0 && path14.attributeId !== void 0) {
|
|
101149
101149
|
lastPath = {
|
|
101150
|
-
nodeId:
|
|
101151
|
-
endpointId:
|
|
101152
|
-
clusterId:
|
|
101153
|
-
attributeId:
|
|
101150
|
+
nodeId: path14.nodeId,
|
|
101151
|
+
endpointId: path14.endpointId,
|
|
101152
|
+
clusterId: path14.clusterId,
|
|
101153
|
+
attributeId: path14.attributeId,
|
|
101154
101154
|
dataVersion: value.dataVersion
|
|
101155
101155
|
};
|
|
101156
101156
|
} else if (!acceptWildcardPaths) {
|
|
101157
|
-
throw new UnexpectedDataError("Tag compression disabled, but path is incomplete: " + Diagnostic.json(
|
|
101157
|
+
throw new UnexpectedDataError("Tag compression disabled, but path is incomplete: " + Diagnostic.json(path14));
|
|
101158
101158
|
}
|
|
101159
101159
|
});
|
|
101160
101160
|
return data;
|
|
@@ -103077,77 +103077,77 @@ var init_errors5 = __esm({
|
|
|
103077
103077
|
init_esm3();
|
|
103078
103078
|
init_esm2();
|
|
103079
103079
|
SchemaViolationError = class extends StatusResponseError {
|
|
103080
|
-
constructor(prefix,
|
|
103081
|
-
const text = `${prefix} ${
|
|
103080
|
+
constructor(prefix, path14, message, code) {
|
|
103081
|
+
const text = `${prefix} ${path14.path ?? path14}: ${message} (${code})`;
|
|
103082
103082
|
super(text, code);
|
|
103083
103083
|
this.message = text;
|
|
103084
103084
|
}
|
|
103085
103085
|
};
|
|
103086
103086
|
ReadError = class extends SchemaViolationError {
|
|
103087
|
-
constructor(
|
|
103088
|
-
super("Reading",
|
|
103087
|
+
constructor(path14, message, code) {
|
|
103088
|
+
super("Reading", path14, message, code ?? Status2.UnsupportedRead);
|
|
103089
103089
|
}
|
|
103090
103090
|
};
|
|
103091
103091
|
WriteError = class extends SchemaViolationError {
|
|
103092
|
-
constructor(
|
|
103093
|
-
super("Writing",
|
|
103092
|
+
constructor(path14, message, code) {
|
|
103093
|
+
super("Writing", path14, message, code ?? Status2.UnsupportedWrite);
|
|
103094
103094
|
}
|
|
103095
103095
|
};
|
|
103096
103096
|
InvokeError = class extends SchemaViolationError {
|
|
103097
|
-
constructor(
|
|
103098
|
-
super("Invoking",
|
|
103097
|
+
constructor(path14, message, code) {
|
|
103098
|
+
super("Invoking", path14, message, code ?? Status2.UnsupportedAccess);
|
|
103099
103099
|
}
|
|
103100
103100
|
};
|
|
103101
103101
|
ValidateError = class extends SchemaViolationError {
|
|
103102
|
-
constructor(
|
|
103103
|
-
super("Validating",
|
|
103102
|
+
constructor(path14, message, code) {
|
|
103103
|
+
super("Validating", path14, message, code ?? Status2.InvalidDataType);
|
|
103104
103104
|
}
|
|
103105
103105
|
};
|
|
103106
103106
|
DatatypeError = class extends ValidateError {
|
|
103107
|
-
constructor(
|
|
103107
|
+
constructor(path14, type, value, code) {
|
|
103108
103108
|
let str = `${value}`;
|
|
103109
103109
|
if (str.length > 60) {
|
|
103110
103110
|
str = `${str.substring(60)}\u2026`;
|
|
103111
103111
|
}
|
|
103112
|
-
super(
|
|
103112
|
+
super(path14, `Value "${str}" is not ${type}`, code);
|
|
103113
103113
|
}
|
|
103114
103114
|
};
|
|
103115
103115
|
ConstraintError = class extends ValidateError {
|
|
103116
|
-
constructor(schema6,
|
|
103117
|
-
super(
|
|
103116
|
+
constructor(schema6, path14, message) {
|
|
103117
|
+
super(path14, `Constraint "${schema6.constraint}": ${message}`, Status2.ConstraintError);
|
|
103118
103118
|
}
|
|
103119
103119
|
};
|
|
103120
103120
|
IntegerRangeError = class extends ValidateError {
|
|
103121
|
-
constructor(
|
|
103122
|
-
super(
|
|
103121
|
+
constructor(path14, message) {
|
|
103122
|
+
super(path14, message, Status2.ConstraintError);
|
|
103123
103123
|
}
|
|
103124
103124
|
};
|
|
103125
103125
|
UnknownEnumValueError = class extends ValidateError {
|
|
103126
|
-
constructor(
|
|
103127
|
-
super(
|
|
103126
|
+
constructor(path14, message) {
|
|
103127
|
+
super(path14, message, Status2.ConstraintError);
|
|
103128
103128
|
}
|
|
103129
103129
|
};
|
|
103130
103130
|
ConformanceError = class extends ValidateError {
|
|
103131
|
-
constructor(schema6,
|
|
103131
|
+
constructor(schema6, path14, message, choice) {
|
|
103132
103132
|
let prefix;
|
|
103133
103133
|
if (choice) {
|
|
103134
103134
|
prefix = `Conformance choice "${choice}"`;
|
|
103135
103135
|
} else {
|
|
103136
103136
|
prefix = `Conformance "${schema6.conformance}"`;
|
|
103137
103137
|
}
|
|
103138
|
-
super(
|
|
103138
|
+
super(path14, `${prefix}: ${message}`, Status2.ConstraintError);
|
|
103139
103139
|
}
|
|
103140
103140
|
};
|
|
103141
103141
|
EnumValueConformanceError = class extends ConformanceError {
|
|
103142
103142
|
};
|
|
103143
103143
|
ExpiredReferenceError = class extends SchemaViolationError {
|
|
103144
|
-
constructor(
|
|
103145
|
-
super("Referencing",
|
|
103144
|
+
constructor(path14) {
|
|
103145
|
+
super("Referencing", path14, "This value is no longer available because its context has exited", Status2.Failure);
|
|
103146
103146
|
}
|
|
103147
103147
|
};
|
|
103148
103148
|
PhantomReferenceError = class extends SchemaViolationError {
|
|
103149
|
-
constructor(
|
|
103150
|
-
super("Referencing",
|
|
103149
|
+
constructor(path14) {
|
|
103150
|
+
super("Referencing", path14, "Container was removed", Status2.Failure);
|
|
103151
103151
|
}
|
|
103152
103152
|
};
|
|
103153
103153
|
}
|
|
@@ -103183,8 +103183,8 @@ function Read(optionsOrSelector, ...selectors) {
|
|
|
103183
103183
|
isFabricFiltered: fabricFilter,
|
|
103184
103184
|
interactionModelRevision,
|
|
103185
103185
|
[Diagnostic.value]: () => Diagnostic.dict({
|
|
103186
|
-
attributes: attributeRequests?.length ? selectors.filter(({ kind }) => kind === "attribute").map((
|
|
103187
|
-
events: eventRequests?.length ? selectors.filter(({ kind }) => kind === "event").map((
|
|
103186
|
+
attributes: attributeRequests?.length ? selectors.filter(({ kind }) => kind === "attribute").map((path14) => resolvePathForSpecifier(path14)).join(", ") : void 0,
|
|
103187
|
+
events: eventRequests?.length ? selectors.filter(({ kind }) => kind === "event").map((path14) => resolvePathForSpecifier(path14)).join(", ") : void 0,
|
|
103188
103188
|
dataVersionFilters: versionFilters?.length ? versionFilters.map(
|
|
103189
103189
|
({ path: { endpointId, clusterId: clusterId3 }, dataVersion }) => `${endpointId}/${clusterId3}=${dataVersion}`
|
|
103190
103190
|
).join(", ") : void 0,
|
|
@@ -103357,8 +103357,8 @@ var init_Subscribe = __esm({
|
|
|
103357
103357
|
});
|
|
103358
103358
|
|
|
103359
103359
|
// ../../node_modules/.pnpm/@matter+protocol@0.16.10/node_modules/@matter/protocol/dist/esm/action/request/Write.js
|
|
103360
|
-
function isAclOrExtensionPath(
|
|
103361
|
-
const { clusterId: clusterId3, attributeId } =
|
|
103360
|
+
function isAclOrExtensionPath(path14) {
|
|
103361
|
+
const { clusterId: clusterId3, attributeId } = path14;
|
|
103362
103362
|
return clusterId3 === AclClusterId && (attributeId === AclAttributeId || attributeId === AclExtensionAttributeId);
|
|
103363
103363
|
}
|
|
103364
103364
|
function Write(optionsOrData, ...data) {
|
|
@@ -103512,29 +103512,29 @@ var init_SubscribeResult = __esm({
|
|
|
103512
103512
|
});
|
|
103513
103513
|
|
|
103514
103514
|
// ../../node_modules/.pnpm/@matter+protocol@0.16.10/node_modules/@matter/protocol/dist/esm/common/ExpandedPath.js
|
|
103515
|
-
function ExpandedPath({ path:
|
|
103515
|
+
function ExpandedPath({ path: path14, matter: matter2, base, kind }) {
|
|
103516
103516
|
if (matter2 === void 0) {
|
|
103517
103517
|
matter2 = Matter;
|
|
103518
103518
|
}
|
|
103519
103519
|
if (base && "path" in base) {
|
|
103520
103520
|
base = base.path;
|
|
103521
103521
|
}
|
|
103522
|
-
const endpointIdent =
|
|
103522
|
+
const endpointIdent = path14.endpointId ?? "*";
|
|
103523
103523
|
base = base ? base.at(endpointIdent, "endpoint") : DataModelPath(endpointIdent, "endpoint");
|
|
103524
103524
|
let cluster2;
|
|
103525
|
-
base = base.at(identityOf(matter2, ClusterModel,
|
|
103526
|
-
if ("attributeId" in
|
|
103527
|
-
base = base.at("state").at(identityOf(cluster2, AttributeModel,
|
|
103528
|
-
if (
|
|
103529
|
-
return base.at(
|
|
103525
|
+
base = base.at(identityOf(matter2, ClusterModel, path14.clusterId), "cluster");
|
|
103526
|
+
if ("attributeId" in path14) {
|
|
103527
|
+
base = base.at("state").at(identityOf(cluster2, AttributeModel, path14.attributeId));
|
|
103528
|
+
if (path14.listIndex) {
|
|
103529
|
+
return base.at(path14.listIndex, "entry");
|
|
103530
103530
|
}
|
|
103531
103531
|
return base;
|
|
103532
103532
|
}
|
|
103533
|
-
if ("commandId" in
|
|
103534
|
-
return base.at(identityOf(cluster2, CommandModel,
|
|
103533
|
+
if ("commandId" in path14) {
|
|
103534
|
+
return base.at(identityOf(cluster2, CommandModel, path14.commandId));
|
|
103535
103535
|
}
|
|
103536
|
-
if ("eventId" in
|
|
103537
|
-
return base.at("events").at(identityOf(cluster2, EventModel,
|
|
103536
|
+
if ("eventId" in path14) {
|
|
103537
|
+
return base.at("events").at(identityOf(cluster2, EventModel, path14.eventId));
|
|
103538
103538
|
}
|
|
103539
103539
|
return base.at("*", kind ?? "element");
|
|
103540
103540
|
function identityOf(parent, type, id) {
|
|
@@ -103621,13 +103621,13 @@ var init_PathError = __esm({
|
|
|
103621
103621
|
PathError = class extends StatusResponseError {
|
|
103622
103622
|
#id;
|
|
103623
103623
|
#path;
|
|
103624
|
-
constructor({ path:
|
|
103624
|
+
constructor({ path: path14, status: { id, status: status3, clusterStatus }, message }) {
|
|
103625
103625
|
if (message === void 0) {
|
|
103626
103626
|
message = capitalize(decamelize(camelize(id), " "));
|
|
103627
103627
|
}
|
|
103628
103628
|
super(message, status3, clusterStatus);
|
|
103629
103629
|
this.#id = id;
|
|
103630
|
-
this.#path =
|
|
103630
|
+
this.#path = path14;
|
|
103631
103631
|
}
|
|
103632
103632
|
get id() {
|
|
103633
103633
|
return this.#id;
|
|
@@ -103651,9 +103651,9 @@ var init_WriteResult = __esm({
|
|
|
103651
103651
|
((WriteResult2) => {
|
|
103652
103652
|
function assertSuccess(result) {
|
|
103653
103653
|
const errors = result.filter((attr) => attr.status !== Status2.Success).map((attr) => {
|
|
103654
|
-
const
|
|
103654
|
+
const path14 = ExpandedPath({ ...attr, kind: "attribute" });
|
|
103655
103655
|
const status3 = new ExpandedStatus(attr);
|
|
103656
|
-
return new PathError({ path:
|
|
103656
|
+
return new PathError({ path: path14, status: status3 });
|
|
103657
103657
|
});
|
|
103658
103658
|
if (!errors.length) {
|
|
103659
103659
|
return;
|
|
@@ -104105,11 +104105,11 @@ var init_AttributeReadResponse = __esm({
|
|
|
104105
104105
|
(this.#versions[endpointId] ?? (this.#versions[endpointId] = {}))[clusterId3] = dataVersion;
|
|
104106
104106
|
}
|
|
104107
104107
|
}
|
|
104108
|
-
for (const
|
|
104109
|
-
if (
|
|
104110
|
-
this.addWildcard(
|
|
104108
|
+
for (const path14 of attributeRequests) {
|
|
104109
|
+
if (path14.endpointId === void 0 || path14.clusterId === void 0 || path14.attributeId === void 0) {
|
|
104110
|
+
this.addWildcard(path14);
|
|
104111
104111
|
} else {
|
|
104112
|
-
this.addConcrete(
|
|
104112
|
+
this.addConcrete(path14);
|
|
104113
104113
|
}
|
|
104114
104114
|
}
|
|
104115
104115
|
if (this.#dataProducers) {
|
|
@@ -104150,8 +104150,8 @@ var init_AttributeReadResponse = __esm({
|
|
|
104150
104150
|
/**
|
|
104151
104151
|
* Validate a wildcard path and update internal state.
|
|
104152
104152
|
*/
|
|
104153
|
-
addWildcard(
|
|
104154
|
-
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId, wildcardPathFlags } =
|
|
104153
|
+
addWildcard(path14) {
|
|
104154
|
+
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId, wildcardPathFlags } = path14;
|
|
104155
104155
|
if (clusterId3 === void 0 && attributeId !== void 0 && !GlobalAttrIds.has(attributeId)) {
|
|
104156
104156
|
throw new StatusResponseError(
|
|
104157
104157
|
`Illegal read of wildcard cluster with non-global attribute #${attributeId}`,
|
|
@@ -104166,7 +104166,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104166
104166
|
this.#addProducer(function* () {
|
|
104167
104167
|
this.#wildcardPathFlags = wpf;
|
|
104168
104168
|
for (const endpoint2 of this.node) {
|
|
104169
|
-
yield* this.readEndpointForWildcard(endpoint2,
|
|
104169
|
+
yield* this.readEndpointForWildcard(endpoint2, path14);
|
|
104170
104170
|
}
|
|
104171
104171
|
});
|
|
104172
104172
|
return;
|
|
@@ -104175,17 +104175,17 @@ var init_AttributeReadResponse = __esm({
|
|
|
104175
104175
|
if (endpoint) {
|
|
104176
104176
|
this.#addProducer(function() {
|
|
104177
104177
|
this.#wildcardPathFlags = wpf;
|
|
104178
|
-
return this.readEndpointForWildcard(endpoint,
|
|
104178
|
+
return this.readEndpointForWildcard(endpoint, path14);
|
|
104179
104179
|
});
|
|
104180
104180
|
}
|
|
104181
104181
|
}
|
|
104182
104182
|
/**
|
|
104183
104183
|
* Validate a concrete path and update internal state.
|
|
104184
104184
|
*/
|
|
104185
|
-
addConcrete(
|
|
104186
|
-
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId } =
|
|
104185
|
+
addConcrete(path14) {
|
|
104186
|
+
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId } = path14;
|
|
104187
104187
|
if (nodeId3 !== void 0 && this.nodeId !== nodeId3) {
|
|
104188
|
-
this.addStatus(
|
|
104188
|
+
this.addStatus(path14, Status2.UnsupportedNode);
|
|
104189
104189
|
return;
|
|
104190
104190
|
}
|
|
104191
104191
|
const endpoint = this.node[endpointId];
|
|
@@ -104193,7 +104193,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104193
104193
|
const attribute2 = cluster2?.type.attributes[attributeId];
|
|
104194
104194
|
let limits;
|
|
104195
104195
|
if (attribute2 === void 0) {
|
|
104196
|
-
const modelAttr = this.node.matter.member(
|
|
104196
|
+
const modelAttr = this.node.matter.member(path14.clusterId, [ElementTag.Cluster])?.member(path14.attributeId, [ElementTag.Attribute]);
|
|
104197
104197
|
if (modelAttr) {
|
|
104198
104198
|
limits = AccessControl4(modelAttr).limits;
|
|
104199
104199
|
} else {
|
|
@@ -104216,32 +104216,32 @@ var init_AttributeReadResponse = __esm({
|
|
|
104216
104216
|
case AccessControl4.Authority.Granted:
|
|
104217
104217
|
break;
|
|
104218
104218
|
case AccessControl4.Authority.Unauthorized:
|
|
104219
|
-
this.addStatus(
|
|
104219
|
+
this.addStatus(path14, Status2.UnsupportedAccess);
|
|
104220
104220
|
return;
|
|
104221
104221
|
case AccessControl4.Authority.Restricted:
|
|
104222
|
-
this.addStatus(
|
|
104222
|
+
this.addStatus(path14, Status2.AccessRestricted);
|
|
104223
104223
|
return;
|
|
104224
104224
|
default:
|
|
104225
104225
|
throw new InternalError(`Unsupported authorization state ${permission}`);
|
|
104226
104226
|
}
|
|
104227
104227
|
}
|
|
104228
104228
|
if (endpoint === void 0) {
|
|
104229
|
-
this.addStatus(
|
|
104229
|
+
this.addStatus(path14, Status2.UnsupportedEndpoint);
|
|
104230
104230
|
return;
|
|
104231
104231
|
}
|
|
104232
104232
|
if (cluster2 === void 0) {
|
|
104233
|
-
this.addStatus(
|
|
104233
|
+
this.addStatus(path14, Status2.UnsupportedCluster);
|
|
104234
104234
|
return;
|
|
104235
104235
|
}
|
|
104236
104236
|
if (attribute2 === void 0 || !cluster2.type.attributes[attribute2.id]) {
|
|
104237
|
-
this.addStatus(
|
|
104237
|
+
this.addStatus(path14, Status2.UnsupportedAttribute);
|
|
104238
104238
|
return;
|
|
104239
104239
|
}
|
|
104240
104240
|
if (!limits.readable) {
|
|
104241
|
-
this.addStatus(
|
|
104241
|
+
this.addStatus(path14, Status2.UnsupportedRead);
|
|
104242
104242
|
return;
|
|
104243
104243
|
}
|
|
104244
|
-
const skipVersion = this.#versions?.[
|
|
104244
|
+
const skipVersion = this.#versions?.[path14.endpointId]?.[path14.clusterId];
|
|
104245
104245
|
if (skipVersion !== void 0 && skipVersion === cluster2.version) {
|
|
104246
104246
|
this.#filteredCount++;
|
|
104247
104247
|
return;
|
|
@@ -104264,9 +104264,9 @@ var init_AttributeReadResponse = __esm({
|
|
|
104264
104264
|
const value = this.#currentState[attributeId];
|
|
104265
104265
|
const version = cluster2.version;
|
|
104266
104266
|
logger55.debug(
|
|
104267
|
-
() => `Reading attribute ${this.node.inspectPath(
|
|
104267
|
+
() => `Reading attribute ${this.node.inspectPath(path14)}=${serialize(value)} (version=${version})`
|
|
104268
104268
|
);
|
|
104269
|
-
this.#addValue(
|
|
104269
|
+
this.#addValue(path14, value, version, this.#currentCluster.type.attributes[attributeId].tlv);
|
|
104270
104270
|
});
|
|
104271
104271
|
}
|
|
104272
104272
|
/**
|
|
@@ -104279,7 +104279,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104279
104279
|
*
|
|
104280
104280
|
* TODO - skip endpoints for which subject is unauthorized as optimization
|
|
104281
104281
|
*/
|
|
104282
|
-
*readEndpointForWildcard(endpoint,
|
|
104282
|
+
*readEndpointForWildcard(endpoint, path14) {
|
|
104283
104283
|
if (endpoint.wildcardPathFlags & this.#wildcardPathFlags) {
|
|
104284
104284
|
return;
|
|
104285
104285
|
}
|
|
@@ -104291,15 +104291,15 @@ var init_AttributeReadResponse = __esm({
|
|
|
104291
104291
|
this.#currentEndpoint = endpoint;
|
|
104292
104292
|
this.#currentCluster = void 0;
|
|
104293
104293
|
}
|
|
104294
|
-
const { clusterId: clusterId3 } =
|
|
104294
|
+
const { clusterId: clusterId3 } = path14;
|
|
104295
104295
|
if (clusterId3 === void 0) {
|
|
104296
104296
|
for (const cluster2 of endpoint) {
|
|
104297
|
-
this.readClusterForWildcard(cluster2,
|
|
104297
|
+
this.readClusterForWildcard(cluster2, path14);
|
|
104298
104298
|
}
|
|
104299
104299
|
} else {
|
|
104300
104300
|
const cluster2 = endpoint[clusterId3];
|
|
104301
104301
|
if (cluster2 !== void 0) {
|
|
104302
|
-
this.readClusterForWildcard(cluster2,
|
|
104302
|
+
this.readClusterForWildcard(cluster2, path14);
|
|
104303
104303
|
}
|
|
104304
104304
|
}
|
|
104305
104305
|
}
|
|
@@ -104310,7 +104310,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104310
104310
|
*
|
|
104311
104311
|
* TODO - skip clusters for which subject is unauthorized
|
|
104312
104312
|
*/
|
|
104313
|
-
readClusterForWildcard(cluster2,
|
|
104313
|
+
readClusterForWildcard(cluster2, path14) {
|
|
104314
104314
|
if (cluster2.type.wildcardPathFlags & this.#wildcardPathFlags) {
|
|
104315
104315
|
return;
|
|
104316
104316
|
}
|
|
@@ -104318,7 +104318,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104318
104318
|
this.#currentCluster = cluster2;
|
|
104319
104319
|
this.#currentState = void 0;
|
|
104320
104320
|
}
|
|
104321
|
-
const { attributeId } =
|
|
104321
|
+
const { attributeId } = path14;
|
|
104322
104322
|
const skipVersion = this.#versions?.[this.#guardedCurrentEndpoint.id]?.[cluster2.type.id];
|
|
104323
104323
|
const filteredByVersion = skipVersion !== void 0 && skipVersion === cluster2.version;
|
|
104324
104324
|
if (attributeId === void 0) {
|
|
@@ -104331,7 +104331,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104331
104331
|
return;
|
|
104332
104332
|
}
|
|
104333
104333
|
for (const attribute2 of cluster2.type.attributes) {
|
|
104334
|
-
this.readAttributeForWildcard(attribute2,
|
|
104334
|
+
this.readAttributeForWildcard(attribute2, path14);
|
|
104335
104335
|
}
|
|
104336
104336
|
} else {
|
|
104337
104337
|
if (filteredByVersion) {
|
|
@@ -104340,7 +104340,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104340
104340
|
}
|
|
104341
104341
|
const attribute2 = cluster2.type.attributes[attributeId];
|
|
104342
104342
|
if (attribute2 !== void 0) {
|
|
104343
|
-
this.readAttributeForWildcard(attribute2,
|
|
104343
|
+
this.readAttributeForWildcard(attribute2, path14);
|
|
104344
104344
|
}
|
|
104345
104345
|
}
|
|
104346
104346
|
}
|
|
@@ -104349,7 +104349,7 @@ var init_AttributeReadResponse = __esm({
|
|
|
104349
104349
|
*
|
|
104350
104350
|
* Depends on state initialized by {@link #readClusterForWildcard}.
|
|
104351
104351
|
*/
|
|
104352
|
-
readAttributeForWildcard(attribute2,
|
|
104352
|
+
readAttributeForWildcard(attribute2, path14) {
|
|
104353
104353
|
if (!this.#guardedCurrentCluster.type.attributes[attribute2.id]) {
|
|
104354
104354
|
return;
|
|
104355
104355
|
}
|
|
@@ -104364,12 +104364,12 @@ var init_AttributeReadResponse = __esm({
|
|
|
104364
104364
|
}
|
|
104365
104365
|
const value = this.#currentState[attribute2.id];
|
|
104366
104366
|
if (value === void 0) {
|
|
104367
|
-
logger55.warn(`Attribute ${this.node.inspectPath(
|
|
104367
|
+
logger55.warn(`Attribute ${this.node.inspectPath(path14)} defined and enabled but has no value.`);
|
|
104368
104368
|
return;
|
|
104369
104369
|
}
|
|
104370
104370
|
this.#addValue(
|
|
104371
104371
|
{
|
|
104372
|
-
...
|
|
104372
|
+
...path14,
|
|
104373
104373
|
endpointId: this.#guardedCurrentEndpoint.id,
|
|
104374
104374
|
clusterId: this.#guardedCurrentCluster.type.id,
|
|
104375
104375
|
attributeId: attribute2.id
|
|
@@ -104399,13 +104399,13 @@ var init_AttributeReadResponse = __esm({
|
|
|
104399
104399
|
/**
|
|
104400
104400
|
* Add a status value.
|
|
104401
104401
|
*/
|
|
104402
|
-
addStatus(
|
|
104402
|
+
addStatus(path14, status3) {
|
|
104403
104403
|
logger55.debug(
|
|
104404
|
-
() => `Error reading attribute ${this.node.inspectPath(
|
|
104404
|
+
() => `Error reading attribute ${this.node.inspectPath(path14)}: Status=${StatusCode[status3]}(${status3})`
|
|
104405
104405
|
);
|
|
104406
104406
|
const report = {
|
|
104407
104407
|
kind: "attr-status",
|
|
104408
|
-
path:
|
|
104408
|
+
path: path14,
|
|
104409
104409
|
status: status3
|
|
104410
104410
|
};
|
|
104411
104411
|
this.#addReportData(report);
|
|
@@ -104414,10 +104414,10 @@ var init_AttributeReadResponse = __esm({
|
|
|
104414
104414
|
/**
|
|
104415
104415
|
* Add an attribute value.
|
|
104416
104416
|
*/
|
|
104417
|
-
#addValue(
|
|
104417
|
+
#addValue(path14, value, version, tlv) {
|
|
104418
104418
|
const report = {
|
|
104419
104419
|
kind: "attr-value",
|
|
104420
|
-
path:
|
|
104420
|
+
path: path14,
|
|
104421
104421
|
value,
|
|
104422
104422
|
version,
|
|
104423
104423
|
tlv
|
|
@@ -104460,32 +104460,32 @@ var init_AttributeSubscriptionResponse = __esm({
|
|
|
104460
104460
|
}
|
|
104461
104461
|
return this.#currentClusterDirty;
|
|
104462
104462
|
}
|
|
104463
|
-
addConcrete(
|
|
104464
|
-
const { endpointId, clusterId: clusterId3, attributeId } =
|
|
104463
|
+
addConcrete(path14) {
|
|
104464
|
+
const { endpointId, clusterId: clusterId3, attributeId } = path14;
|
|
104465
104465
|
if (this.#dirty[endpointId]?.[clusterId3]?.has(attributeId) === void 0) {
|
|
104466
104466
|
return;
|
|
104467
104467
|
}
|
|
104468
|
-
super.addConcrete(
|
|
104468
|
+
super.addConcrete(path14);
|
|
104469
104469
|
}
|
|
104470
|
-
*readEndpointForWildcard(endpoint,
|
|
104470
|
+
*readEndpointForWildcard(endpoint, path14) {
|
|
104471
104471
|
this.#currentEndpointDirty = this.#dirty[endpoint.id];
|
|
104472
104472
|
if (this.#currentEndpointDirty === void 0) {
|
|
104473
104473
|
return;
|
|
104474
104474
|
}
|
|
104475
|
-
yield* super.readEndpointForWildcard(endpoint,
|
|
104475
|
+
yield* super.readEndpointForWildcard(endpoint, path14);
|
|
104476
104476
|
}
|
|
104477
|
-
readClusterForWildcard(cluster2,
|
|
104477
|
+
readClusterForWildcard(cluster2, path14) {
|
|
104478
104478
|
this.#currentClusterDirty = this.currentEndpointDirty[cluster2.type.id];
|
|
104479
104479
|
if (this.#currentClusterDirty === void 0) {
|
|
104480
104480
|
return;
|
|
104481
104481
|
}
|
|
104482
|
-
super.readClusterForWildcard(cluster2,
|
|
104482
|
+
super.readClusterForWildcard(cluster2, path14);
|
|
104483
104483
|
}
|
|
104484
|
-
readAttributeForWildcard(attribute2,
|
|
104484
|
+
readAttributeForWildcard(attribute2, path14) {
|
|
104485
104485
|
if (!this.currentClusterDirty.has(attribute2.id)) {
|
|
104486
104486
|
return;
|
|
104487
104487
|
}
|
|
104488
|
-
super.readAttributeForWildcard(attribute2,
|
|
104488
|
+
super.readAttributeForWildcard(attribute2, path14);
|
|
104489
104489
|
}
|
|
104490
104490
|
addStatus() {
|
|
104491
104491
|
}
|
|
@@ -104568,9 +104568,9 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104568
104568
|
try {
|
|
104569
104569
|
const _writing = __using19(_stack, this.join("writing"));
|
|
104570
104570
|
const writeResponses = new Array();
|
|
104571
|
-
for (const { path:
|
|
104572
|
-
if (
|
|
104573
|
-
const responses = await this.#processWildcard(
|
|
104571
|
+
for (const { path: path14, data, dataVersion } of writeRequests) {
|
|
104572
|
+
if (path14.endpointId === void 0 || path14.clusterId === void 0 || path14.attributeId === void 0) {
|
|
104573
|
+
const responses = await this.#processWildcard(path14, data);
|
|
104574
104574
|
if (responses !== void 0) {
|
|
104575
104575
|
writeResponses.push(...responses);
|
|
104576
104576
|
}
|
|
@@ -104579,7 +104579,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104579
104579
|
throw new StatusResponseError("Group writes can not be concrete paths", StatusCode.InvalidAction);
|
|
104580
104580
|
}
|
|
104581
104581
|
writeResponses.push(
|
|
104582
|
-
await this.#writeConcrete(
|
|
104582
|
+
await this.#writeConcrete(path14, data, dataVersion)
|
|
104583
104583
|
);
|
|
104584
104584
|
}
|
|
104585
104585
|
}
|
|
@@ -104617,8 +104617,8 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104617
104617
|
/**
|
|
104618
104618
|
* Validate a wildcard path and update internal state.
|
|
104619
104619
|
*/
|
|
104620
|
-
async #processWildcard(
|
|
104621
|
-
const { nodeId: nodeId3, endpointId } =
|
|
104620
|
+
async #processWildcard(path14, value) {
|
|
104621
|
+
const { nodeId: nodeId3, endpointId } = path14;
|
|
104622
104622
|
if (nodeId3 !== void 0 && nodeId3 !== this.nodeId) {
|
|
104623
104623
|
return;
|
|
104624
104624
|
}
|
|
@@ -104638,7 +104638,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104638
104638
|
if (groupEndpoints !== void 0 && !groupEndpoints.includes(endpoint2.id)) {
|
|
104639
104639
|
continue;
|
|
104640
104640
|
}
|
|
104641
|
-
const response = await this.#writeEndpointForWildcard(endpoint2,
|
|
104641
|
+
const response = await this.#writeEndpointForWildcard(endpoint2, path14, value);
|
|
104642
104642
|
if (response !== void 0) {
|
|
104643
104643
|
responses.push(response);
|
|
104644
104644
|
}
|
|
@@ -104653,7 +104653,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104653
104653
|
}
|
|
104654
104654
|
const endpoint = this.node[endpointId];
|
|
104655
104655
|
if (endpoint) {
|
|
104656
|
-
const response = await this.#writeEndpointForWildcard(endpoint,
|
|
104656
|
+
const response = await this.#writeEndpointForWildcard(endpoint, path14, value);
|
|
104657
104657
|
if (response !== void 0) {
|
|
104658
104658
|
return [response];
|
|
104659
104659
|
}
|
|
@@ -104662,17 +104662,17 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104662
104662
|
/**
|
|
104663
104663
|
* Write to a concrete path and update internal state.
|
|
104664
104664
|
*/
|
|
104665
|
-
async #writeConcrete(
|
|
104666
|
-
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId } =
|
|
104665
|
+
async #writeConcrete(path14, value, version) {
|
|
104666
|
+
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, attributeId } = path14;
|
|
104667
104667
|
if (nodeId3 !== void 0 && this.nodeId !== nodeId3) {
|
|
104668
|
-
return this.#asStatus(
|
|
104668
|
+
return this.#asStatus(path14, Status2.UnsupportedNode);
|
|
104669
104669
|
}
|
|
104670
104670
|
const endpoint = this.node[endpointId];
|
|
104671
104671
|
const cluster2 = endpoint?.[clusterId3];
|
|
104672
104672
|
const attribute2 = cluster2?.type.attributes[attributeId];
|
|
104673
104673
|
let limits;
|
|
104674
104674
|
if (attribute2 === void 0) {
|
|
104675
|
-
const modelAttr = this.node.matter.member(
|
|
104675
|
+
const modelAttr = this.node.matter.member(path14.clusterId, [ElementTag.Cluster])?.member(path14.attributeId, [ElementTag.Attribute]);
|
|
104676
104676
|
if (modelAttr) {
|
|
104677
104677
|
limits = AccessControl4(modelAttr).limits;
|
|
104678
104678
|
} else {
|
|
@@ -104695,39 +104695,39 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104695
104695
|
case AccessControl4.Authority.Granted:
|
|
104696
104696
|
break;
|
|
104697
104697
|
case AccessControl4.Authority.Unauthorized:
|
|
104698
|
-
return this.#asStatus(
|
|
104698
|
+
return this.#asStatus(path14, Status2.UnsupportedAccess);
|
|
104699
104699
|
case AccessControl4.Authority.Restricted:
|
|
104700
|
-
return this.#asStatus(
|
|
104700
|
+
return this.#asStatus(path14, Status2.AccessRestricted);
|
|
104701
104701
|
default:
|
|
104702
104702
|
throw new InternalError(`Unsupported authorization state ${permission}`);
|
|
104703
104703
|
}
|
|
104704
104704
|
}
|
|
104705
104705
|
if (endpoint === void 0) {
|
|
104706
|
-
return this.#asStatus(
|
|
104706
|
+
return this.#asStatus(path14, Status2.UnsupportedEndpoint);
|
|
104707
104707
|
}
|
|
104708
104708
|
if (cluster2 === void 0) {
|
|
104709
|
-
return this.#asStatus(
|
|
104709
|
+
return this.#asStatus(path14, Status2.UnsupportedCluster);
|
|
104710
104710
|
}
|
|
104711
104711
|
if (attribute2 === void 0 || !cluster2.type.attributes[attribute2.id]) {
|
|
104712
|
-
return this.#asStatus(
|
|
104712
|
+
return this.#asStatus(path14, Status2.UnsupportedAttribute);
|
|
104713
104713
|
}
|
|
104714
104714
|
if (!limits.writable) {
|
|
104715
104715
|
this.#errorCount++;
|
|
104716
|
-
return this.#asStatus(
|
|
104716
|
+
return this.#asStatus(path14, Status2.UnsupportedWrite);
|
|
104717
104717
|
}
|
|
104718
104718
|
if (hasRemoteActor(this.session)) {
|
|
104719
104719
|
if (limits.timed && !this.session.timed) {
|
|
104720
104720
|
this.#errorCount++;
|
|
104721
|
-
return this.#asStatus(
|
|
104721
|
+
return this.#asStatus(path14, Status2.NeedsTimedInteraction);
|
|
104722
104722
|
}
|
|
104723
104723
|
if (limits.fabricScoped && !this.session.fabric) {
|
|
104724
104724
|
this.#errorCount++;
|
|
104725
|
-
return this.#asStatus(
|
|
104725
|
+
return this.#asStatus(path14, Status2.UnsupportedAccess);
|
|
104726
104726
|
}
|
|
104727
104727
|
}
|
|
104728
104728
|
if (version !== void 0 && version !== cluster2.version) {
|
|
104729
104729
|
this.#errorCount++;
|
|
104730
|
-
return this.#asStatus(
|
|
104730
|
+
return this.#asStatus(path14, Status2.DataVersionMismatch);
|
|
104731
104731
|
}
|
|
104732
104732
|
if (this.#currentEndpoint !== endpoint) {
|
|
104733
104733
|
this.#currentEndpoint = endpoint;
|
|
@@ -104735,7 +104735,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104735
104735
|
} else if (this.#currentCluster !== cluster2) {
|
|
104736
104736
|
this.#currentCluster = cluster2;
|
|
104737
104737
|
}
|
|
104738
|
-
return await this.writeValue(attribute2,
|
|
104738
|
+
return await this.writeValue(attribute2, path14, value);
|
|
104739
104739
|
}
|
|
104740
104740
|
/**
|
|
104741
104741
|
* Starts new chunk or adds to current chunk all values from {@link endpoint} selected by {@link path}.
|
|
@@ -104745,8 +104745,8 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104745
104745
|
*
|
|
104746
104746
|
* TODO - skip endpoints for which subject is unauthorized as optimization
|
|
104747
104747
|
*/
|
|
104748
|
-
#writeEndpointForWildcard(endpoint,
|
|
104749
|
-
const { clusterId: clusterId3, attributeId } =
|
|
104748
|
+
#writeEndpointForWildcard(endpoint, path14, value) {
|
|
104749
|
+
const { clusterId: clusterId3, attributeId } = path14;
|
|
104750
104750
|
if (clusterId3 === void 0 || attributeId === void 0) {
|
|
104751
104751
|
throw new StatusResponseError(
|
|
104752
104752
|
"Wildcard path write must specify a clusterId and attributeId",
|
|
@@ -104759,7 +104759,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104759
104759
|
}
|
|
104760
104760
|
const cluster2 = endpoint[clusterId3];
|
|
104761
104761
|
if (cluster2 !== void 0) {
|
|
104762
|
-
return this.#writeClusterForWildcard(cluster2,
|
|
104762
|
+
return this.#writeClusterForWildcard(cluster2, path14, value);
|
|
104763
104763
|
}
|
|
104764
104764
|
}
|
|
104765
104765
|
/**
|
|
@@ -104769,17 +104769,17 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104769
104769
|
*
|
|
104770
104770
|
* TODO - skip clusters for which subject is unauthorized
|
|
104771
104771
|
*/
|
|
104772
|
-
#writeClusterForWildcard(cluster2,
|
|
104772
|
+
#writeClusterForWildcard(cluster2, path14, value) {
|
|
104773
104773
|
if (this.#currentCluster !== cluster2) {
|
|
104774
104774
|
this.#currentCluster = cluster2;
|
|
104775
104775
|
}
|
|
104776
|
-
const { attributeId } =
|
|
104776
|
+
const { attributeId } = path14;
|
|
104777
104777
|
if (attributeId === void 0) {
|
|
104778
104778
|
throw new StatusResponseError("Wildcard path write must specify an attributeId", StatusCode.InvalidAction);
|
|
104779
104779
|
} else {
|
|
104780
104780
|
const attribute2 = cluster2.type.attributes[attributeId];
|
|
104781
104781
|
if (attribute2 !== void 0) {
|
|
104782
|
-
return this.#writeAttributeForWildcard(attribute2,
|
|
104782
|
+
return this.#writeAttributeForWildcard(attribute2, path14, value);
|
|
104783
104783
|
}
|
|
104784
104784
|
}
|
|
104785
104785
|
}
|
|
@@ -104788,7 +104788,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104788
104788
|
*
|
|
104789
104789
|
* Depends on state initialized by {@link #writeClusterForWildcard}.
|
|
104790
104790
|
*/
|
|
104791
|
-
#writeAttributeForWildcard(attribute2,
|
|
104791
|
+
#writeAttributeForWildcard(attribute2, path14, value) {
|
|
104792
104792
|
if (!this.#guardedCurrentCluster.type.attributes[attribute2.id]) {
|
|
104793
104793
|
return;
|
|
104794
104794
|
}
|
|
@@ -104806,7 +104806,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104806
104806
|
return this.writeValue(
|
|
104807
104807
|
attribute2,
|
|
104808
104808
|
{
|
|
104809
|
-
...
|
|
104809
|
+
...path14,
|
|
104810
104810
|
endpointId: this.#guardedCurrentEndpoint.id,
|
|
104811
104811
|
clusterId: this.#guardedCurrentCluster.type.id,
|
|
104812
104812
|
attributeId: attribute2.id
|
|
@@ -104817,15 +104817,15 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104817
104817
|
/**
|
|
104818
104818
|
* Add a status value.
|
|
104819
104819
|
*/
|
|
104820
|
-
#asStatus(
|
|
104820
|
+
#asStatus(path14, status3, clusterStatus) {
|
|
104821
104821
|
if (status3 !== Status2.Success) {
|
|
104822
104822
|
logger56.debug(
|
|
104823
|
-
() => `Error writing attribute ${this.node.inspectPath(
|
|
104823
|
+
() => `Error writing attribute ${this.node.inspectPath(path14)}: Status=${StatusCode[status3]}(${toHex(status3)}), ClusterStatus=${clusterStatus !== void 0 ? toHex(clusterStatus) : void 0}`
|
|
104824
104824
|
);
|
|
104825
104825
|
}
|
|
104826
104826
|
const report = {
|
|
104827
104827
|
kind: "attr-status",
|
|
104828
|
-
path:
|
|
104828
|
+
path: path14,
|
|
104829
104829
|
status: status3,
|
|
104830
104830
|
clusterStatus
|
|
104831
104831
|
};
|
|
@@ -104834,8 +104834,8 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104834
104834
|
}
|
|
104835
104835
|
return report;
|
|
104836
104836
|
}
|
|
104837
|
-
async writeValue(attribute2,
|
|
104838
|
-
const { attributeId, listIndex } =
|
|
104837
|
+
async writeValue(attribute2, path14, value) {
|
|
104838
|
+
const { attributeId, listIndex } = path14;
|
|
104839
104839
|
if (listIndex !== void 0 && listIndex !== null) {
|
|
104840
104840
|
throw new StatusResponseError(
|
|
104841
104841
|
`Unsupported Write path provided: listIndex === ${listIndex}`,
|
|
@@ -104846,7 +104846,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104846
104846
|
const { tlv } = attribute2;
|
|
104847
104847
|
if (listIndex === void 0) {
|
|
104848
104848
|
const decoded = this.#decodeWithSchema(tlv, value);
|
|
104849
|
-
logger56.debug(() => `Writing attribute ${this.node.inspectPath(
|
|
104849
|
+
logger56.debug(() => `Writing attribute ${this.node.inspectPath(path14)}=${Diagnostic.json(decoded)}`);
|
|
104850
104850
|
const writeState = await this.#guardedCurrentCluster.openForWrite(this.session);
|
|
104851
104851
|
writeState[attributeId] = decoded;
|
|
104852
104852
|
await this.session.transaction?.commit();
|
|
@@ -104860,7 +104860,7 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104860
104860
|
const writeState = await this.#guardedCurrentCluster.openForWrite(this.session);
|
|
104861
104861
|
const decoded = this.#decodeWithSchema(tlv.elementSchema, value);
|
|
104862
104862
|
logger56.debug(
|
|
104863
|
-
() => `Writing attribute chunk ${this.node.inspectPath(
|
|
104863
|
+
() => `Writing attribute chunk ${this.node.inspectPath(path14)} adding ${serialize(decoded)}`
|
|
104864
104864
|
);
|
|
104865
104865
|
writeState[attributeId].push(decoded);
|
|
104866
104866
|
await this.session.transaction?.commit();
|
|
@@ -104869,12 +104869,12 @@ var init_AttributeWriteResponse = __esm({
|
|
|
104869
104869
|
await this.session.transaction?.rollback();
|
|
104870
104870
|
if (StatusResponseError.is(error)) {
|
|
104871
104871
|
this.#errorCount++;
|
|
104872
|
-
return this.#asStatus(
|
|
104872
|
+
return this.#asStatus(path14, error.code, error.clusterCode);
|
|
104873
104873
|
}
|
|
104874
104874
|
throw error;
|
|
104875
104875
|
}
|
|
104876
104876
|
this.#successCount++;
|
|
104877
|
-
return this.#asStatus(
|
|
104877
|
+
return this.#asStatus(path14, Status2.Success);
|
|
104878
104878
|
}
|
|
104879
104879
|
#decodeWithSchema(tlv, value) {
|
|
104880
104880
|
return tlv.injectField(
|
|
@@ -104972,15 +104972,15 @@ var init_CommandInvokeResponse = __esm({
|
|
|
104972
104972
|
const _invoking = __using20(_stack, this.join("invoking"));
|
|
104973
104973
|
const multipleInvokes = invokeRequests.length > 1;
|
|
104974
104974
|
for (const command of invokeRequests) {
|
|
104975
|
-
const { commandPath:
|
|
104976
|
-
if (
|
|
104975
|
+
const { commandPath: path14, commandFields, commandRef } = command;
|
|
104976
|
+
if (path14.endpointId === void 0 || path14.clusterId === void 0 || path14.commandId === void 0) {
|
|
104977
104977
|
if (multipleInvokes) {
|
|
104978
104978
|
throw new StatusResponseError(
|
|
104979
104979
|
"Wildcard path must not be used with multiple invokes",
|
|
104980
104980
|
StatusCode.InvalidAction
|
|
104981
104981
|
);
|
|
104982
104982
|
}
|
|
104983
|
-
this.#processWildcard(
|
|
104983
|
+
this.#processWildcard(path14, commandRef, commandFields);
|
|
104984
104984
|
} else {
|
|
104985
104985
|
if (Subject.isGroup(this.session.subject)) {
|
|
104986
104986
|
throw new StatusResponseError("Group commands connot be concrete paths", StatusCode.InvalidAction);
|
|
@@ -104991,7 +104991,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
104991
104991
|
StatusCode.InvalidAction
|
|
104992
104992
|
);
|
|
104993
104993
|
}
|
|
104994
|
-
this.#processConcrete(
|
|
104994
|
+
this.#processConcrete(path14, commandRef, commandFields);
|
|
104995
104995
|
}
|
|
104996
104996
|
}
|
|
104997
104997
|
if (this.#invokers) {
|
|
@@ -105022,8 +105022,8 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105022
105022
|
/**
|
|
105023
105023
|
* Process a wildcard path and invoke commands on all endpoints that match the path.
|
|
105024
105024
|
*/
|
|
105025
|
-
#processWildcard(
|
|
105026
|
-
const { clusterId: clusterId3, endpointId, commandId: commandId3 } =
|
|
105025
|
+
#processWildcard(path14, commandRef, commandFields) {
|
|
105026
|
+
const { clusterId: clusterId3, endpointId, commandId: commandId3 } = path14;
|
|
105027
105027
|
const isGroupPath = Subject.isGroup(this.session.subject);
|
|
105028
105028
|
if (isGroupPath && endpointId !== void 0) {
|
|
105029
105029
|
throw new StatusResponseError(
|
|
@@ -105051,19 +105051,19 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105051
105051
|
if (groupEndpoints !== void 0 && !groupEndpoints.includes(endpoint.id)) {
|
|
105052
105052
|
continue;
|
|
105053
105053
|
}
|
|
105054
|
-
yield* this.#processEndpointForWildcard(endpoint,
|
|
105054
|
+
yield* this.#processEndpointForWildcard(endpoint, path14, commandRef, commandFields);
|
|
105055
105055
|
}
|
|
105056
105056
|
});
|
|
105057
105057
|
}
|
|
105058
105058
|
/**
|
|
105059
105059
|
* Invoke a command specified by a concrete path
|
|
105060
105060
|
*/
|
|
105061
|
-
#processConcrete(
|
|
105062
|
-
const { endpointId, clusterId: clusterId3, commandId: commandId3 } =
|
|
105061
|
+
#processConcrete(path14, commandRef, commandFields) {
|
|
105062
|
+
const { endpointId, clusterId: clusterId3, commandId: commandId3 } = path14;
|
|
105063
105063
|
const pathKey = `${endpointId}-${clusterId3}-${commandId3}`;
|
|
105064
105064
|
if (this.#registeredPaths.has(pathKey)) {
|
|
105065
105065
|
throw new StatusResponseError(
|
|
105066
|
-
`Duplicate concrete command path ${this.node.inspectPath(
|
|
105066
|
+
`Duplicate concrete command path ${this.node.inspectPath(path14)} on batch invoke`,
|
|
105067
105067
|
StatusCode.InvalidAction
|
|
105068
105068
|
);
|
|
105069
105069
|
}
|
|
@@ -105082,7 +105082,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105082
105082
|
const command = cluster2?.type.commands[commandId3];
|
|
105083
105083
|
let limits;
|
|
105084
105084
|
if (command === void 0) {
|
|
105085
|
-
const modelAttr = this.node.matter.member(
|
|
105085
|
+
const modelAttr = this.node.matter.member(path14.clusterId, [ElementTag.Cluster])?.member(path14.commandId, [ElementTag.Command]);
|
|
105086
105086
|
if (modelAttr) {
|
|
105087
105087
|
limits = AccessControl4(modelAttr).limits;
|
|
105088
105088
|
} else {
|
|
@@ -105105,34 +105105,34 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105105
105105
|
case AccessControl4.Authority.Granted:
|
|
105106
105106
|
break;
|
|
105107
105107
|
case AccessControl4.Authority.Unauthorized:
|
|
105108
|
-
return this.#addStatus(
|
|
105108
|
+
return this.#addStatus(path14, commandRef, Status2.UnsupportedAccess);
|
|
105109
105109
|
case AccessControl4.Authority.Restricted:
|
|
105110
|
-
return this.#addStatus(
|
|
105110
|
+
return this.#addStatus(path14, commandRef, Status2.AccessRestricted);
|
|
105111
105111
|
default:
|
|
105112
105112
|
throw new InternalError(`Unsupported authorization state ${permission}`);
|
|
105113
105113
|
}
|
|
105114
105114
|
}
|
|
105115
105115
|
if (endpoint === void 0) {
|
|
105116
|
-
return this.#addStatus(
|
|
105116
|
+
return this.#addStatus(path14, commandRef, Status2.UnsupportedEndpoint);
|
|
105117
105117
|
}
|
|
105118
105118
|
if (cluster2 === void 0) {
|
|
105119
|
-
return this.#addStatus(
|
|
105119
|
+
return this.#addStatus(path14, commandRef, Status2.UnsupportedCluster);
|
|
105120
105120
|
}
|
|
105121
105121
|
if (command === void 0 || !cluster2.type.commands[command.id]) {
|
|
105122
|
-
return this.#addStatus(
|
|
105122
|
+
return this.#addStatus(path14, commandRef, Status2.UnsupportedCommand);
|
|
105123
105123
|
}
|
|
105124
105124
|
if (hasRemoteActor(this.session)) {
|
|
105125
105125
|
if (limits.largeMessage && !this.session.largeMessage) {
|
|
105126
105126
|
this.#errorCount++;
|
|
105127
|
-
return this.#addStatus(
|
|
105127
|
+
return this.#addStatus(path14, commandRef, Status2.InvalidTransportType);
|
|
105128
105128
|
}
|
|
105129
105129
|
if (limits.fabricScoped && !this.session.fabric) {
|
|
105130
105130
|
this.#errorCount++;
|
|
105131
|
-
return this.#addStatus(
|
|
105131
|
+
return this.#addStatus(path14, commandRef, Status2.UnsupportedAccess);
|
|
105132
105132
|
}
|
|
105133
105133
|
if (limits.timed && !this.session.timed) {
|
|
105134
105134
|
this.#errorCount++;
|
|
105135
|
-
return this.#addStatus(
|
|
105135
|
+
return this.#addStatus(path14, commandRef, Status2.NeedsTimedInteraction);
|
|
105136
105136
|
}
|
|
105137
105137
|
}
|
|
105138
105138
|
this.#addInvoker(async function* invokeConcretePath() {
|
|
@@ -105143,7 +105143,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105143
105143
|
}
|
|
105144
105144
|
this.#currentEndpoint = endpoint;
|
|
105145
105145
|
}
|
|
105146
|
-
await this.#invokeCommand(command,
|
|
105146
|
+
await this.#invokeCommand(command, path14, commandRef, commandFields, cluster2.commands[command.id]);
|
|
105147
105147
|
});
|
|
105148
105148
|
}
|
|
105149
105149
|
/**
|
|
@@ -105154,8 +105154,8 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105154
105154
|
**
|
|
105155
105155
|
* TODO - skip endpoints for which subject is unauthorized as optimization
|
|
105156
105156
|
*/
|
|
105157
|
-
async *#processEndpointForWildcard(endpoint,
|
|
105158
|
-
const { clusterId: clusterId3 } =
|
|
105157
|
+
async *#processEndpointForWildcard(endpoint, path14, commandRef, commandFields) {
|
|
105158
|
+
const { clusterId: clusterId3 } = path14;
|
|
105159
105159
|
if (this.#currentEndpoint !== endpoint) {
|
|
105160
105160
|
if (this.#chunk) {
|
|
105161
105161
|
yield this.#chunk;
|
|
@@ -105165,7 +105165,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105165
105165
|
}
|
|
105166
105166
|
const cluster2 = endpoint[clusterId3];
|
|
105167
105167
|
if (cluster2 !== void 0) {
|
|
105168
|
-
const { commandId: commandId3 } =
|
|
105168
|
+
const { commandId: commandId3 } = path14;
|
|
105169
105169
|
const command = cluster2.type.commands[commandId3];
|
|
105170
105170
|
if (command !== void 0) {
|
|
105171
105171
|
if (hasRemoteActor(this.session)) {
|
|
@@ -105186,7 +105186,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105186
105186
|
await this.#invokeCommand(
|
|
105187
105187
|
command,
|
|
105188
105188
|
{
|
|
105189
|
-
...
|
|
105189
|
+
...path14,
|
|
105190
105190
|
endpointId: endpoint.id
|
|
105191
105191
|
},
|
|
105192
105192
|
commandRef,
|
|
@@ -105216,15 +105216,15 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105216
105216
|
/**
|
|
105217
105217
|
* Add a status value.
|
|
105218
105218
|
*/
|
|
105219
|
-
#addStatus(
|
|
105219
|
+
#addStatus(path14, commandRef, status3, clusterStatus) {
|
|
105220
105220
|
if (status3 !== StatusCode.Success) {
|
|
105221
105221
|
logger57.info(
|
|
105222
|
-
() => `Invoke error ${this.node.inspectPath(
|
|
105222
|
+
() => `Invoke error ${this.node.inspectPath(path14)}: Status=${StatusCode[status3]}(${status3}), ClusterStatus=${clusterStatus}`
|
|
105223
105223
|
);
|
|
105224
105224
|
}
|
|
105225
105225
|
const response = {
|
|
105226
105226
|
kind: "cmd-status",
|
|
105227
|
-
path:
|
|
105227
|
+
path: path14,
|
|
105228
105228
|
status: status3,
|
|
105229
105229
|
clusterStatus,
|
|
105230
105230
|
commandRef
|
|
@@ -105234,7 +105234,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105234
105234
|
}
|
|
105235
105235
|
this.#addResponse(response);
|
|
105236
105236
|
}
|
|
105237
|
-
async #invokeCommand(command,
|
|
105237
|
+
async #invokeCommand(command, path14, commandRef, commandFields, invoker) {
|
|
105238
105238
|
try {
|
|
105239
105239
|
const { requestTlv, responseTlv } = command;
|
|
105240
105240
|
const request = this.#decodeWithSchema(requestTlv, commandFields);
|
|
@@ -105244,12 +105244,12 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105244
105244
|
this.#successCount++;
|
|
105245
105245
|
const encodedResponse = responseTlv.encodeTlv(response);
|
|
105246
105246
|
if (encodedResponse.length === 0) {
|
|
105247
|
-
this.#addStatus(
|
|
105247
|
+
this.#addStatus(path14, commandRef, StatusCode.Success);
|
|
105248
105248
|
} else {
|
|
105249
105249
|
this.#addResponse({
|
|
105250
105250
|
kind: "cmd-response",
|
|
105251
105251
|
path: {
|
|
105252
|
-
...
|
|
105252
|
+
...path14,
|
|
105253
105253
|
commandId: command.responseId
|
|
105254
105254
|
},
|
|
105255
105255
|
data: encodedResponse,
|
|
@@ -105272,7 +105272,7 @@ var init_CommandInvokeResponse = __esm({
|
|
|
105272
105272
|
} else {
|
|
105273
105273
|
logger57.info(errorLogText);
|
|
105274
105274
|
}
|
|
105275
|
-
this.#addStatus(
|
|
105275
|
+
this.#addStatus(path14, commandRef, errorCode, error.clusterCode);
|
|
105276
105276
|
return;
|
|
105277
105277
|
}
|
|
105278
105278
|
throw error;
|
|
@@ -105338,11 +105338,11 @@ var init_EventReadResponse = __esm({
|
|
|
105338
105338
|
if (isFabricFiltered) {
|
|
105339
105339
|
this.#filteredForFabricIndex = this.session.fabric ?? FabricIndex3.NO_FABRIC;
|
|
105340
105340
|
}
|
|
105341
|
-
for (const
|
|
105342
|
-
if (
|
|
105343
|
-
this.#addWildcard(
|
|
105341
|
+
for (const path14 of eventRequests) {
|
|
105342
|
+
if (path14.endpointId === void 0 || path14.clusterId === void 0 || path14.eventId === void 0) {
|
|
105343
|
+
this.#addWildcard(path14);
|
|
105344
105344
|
} else {
|
|
105345
|
-
const status3 = this.#addConcrete(
|
|
105345
|
+
const status3 = this.#addConcrete(path14);
|
|
105346
105346
|
if (status3 !== void 0) {
|
|
105347
105347
|
yield [status3];
|
|
105348
105348
|
this.#statusCount++;
|
|
@@ -105378,8 +105378,8 @@ var init_EventReadResponse = __esm({
|
|
|
105378
105378
|
/**
|
|
105379
105379
|
* Validate a wildcard path and update the internal state.
|
|
105380
105380
|
*/
|
|
105381
|
-
#addWildcard(
|
|
105382
|
-
const { nodeId: nodeId3, clusterId: clusterId3, endpointId, eventId: eventId3 } =
|
|
105381
|
+
#addWildcard(path14) {
|
|
105382
|
+
const { nodeId: nodeId3, clusterId: clusterId3, endpointId, eventId: eventId3 } = path14;
|
|
105383
105383
|
if (clusterId3 === void 0 && eventId3 !== void 0) {
|
|
105384
105384
|
throw new StatusResponseError("Illegal read request with wildcard cluster ID", StatusCode.InvalidAction);
|
|
105385
105385
|
}
|
|
@@ -105388,29 +105388,29 @@ var init_EventReadResponse = __esm({
|
|
|
105388
105388
|
}
|
|
105389
105389
|
if (endpointId === void 0) {
|
|
105390
105390
|
for (const endpoint2 of this.node) {
|
|
105391
|
-
this.#addEndpointForWildcard(endpoint2,
|
|
105391
|
+
this.#addEndpointForWildcard(endpoint2, path14);
|
|
105392
105392
|
}
|
|
105393
105393
|
return;
|
|
105394
105394
|
}
|
|
105395
105395
|
const endpoint = this.node[endpointId];
|
|
105396
105396
|
if (endpoint) {
|
|
105397
|
-
return this.#addEndpointForWildcard(endpoint,
|
|
105397
|
+
return this.#addEndpointForWildcard(endpoint, path14);
|
|
105398
105398
|
}
|
|
105399
105399
|
}
|
|
105400
105400
|
/**
|
|
105401
105401
|
* Validate a concrete path and update the internal state.
|
|
105402
105402
|
*/
|
|
105403
|
-
#addConcrete(
|
|
105404
|
-
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, eventId: eventId3 } =
|
|
105403
|
+
#addConcrete(path14) {
|
|
105404
|
+
const { nodeId: nodeId3, endpointId, clusterId: clusterId3, eventId: eventId3 } = path14;
|
|
105405
105405
|
if (nodeId3 !== void 0 && this.nodeId !== nodeId3) {
|
|
105406
|
-
return this.#asStatus(
|
|
105406
|
+
return this.#asStatus(path14, Status2.UnsupportedNode);
|
|
105407
105407
|
}
|
|
105408
105408
|
const endpoint = this.node[endpointId];
|
|
105409
105409
|
const cluster2 = endpoint?.[clusterId3];
|
|
105410
105410
|
const event3 = cluster2?.type.events[eventId3];
|
|
105411
105411
|
let limits;
|
|
105412
105412
|
if (event3 === void 0) {
|
|
105413
|
-
const modelEvent = this.node.matter.member(
|
|
105413
|
+
const modelEvent = this.node.matter.member(path14.clusterId, [ElementTag.Cluster])?.member(path14.eventId, [ElementTag.Event]);
|
|
105414
105414
|
if (modelEvent) {
|
|
105415
105415
|
limits = AccessControl4(modelEvent).limits;
|
|
105416
105416
|
} else {
|
|
@@ -105433,21 +105433,21 @@ var init_EventReadResponse = __esm({
|
|
|
105433
105433
|
case AccessControl4.Authority.Granted:
|
|
105434
105434
|
break;
|
|
105435
105435
|
case AccessControl4.Authority.Unauthorized:
|
|
105436
|
-
return this.#asStatus(
|
|
105436
|
+
return this.#asStatus(path14, Status2.UnsupportedAccess);
|
|
105437
105437
|
case AccessControl4.Authority.Restricted:
|
|
105438
|
-
return this.#asStatus(
|
|
105438
|
+
return this.#asStatus(path14, Status2.AccessRestricted);
|
|
105439
105439
|
default:
|
|
105440
105440
|
throw new InternalError(`Unsupported authorization state ${permission}`);
|
|
105441
105441
|
}
|
|
105442
105442
|
}
|
|
105443
105443
|
if (endpoint === void 0) {
|
|
105444
|
-
return this.#asStatus(
|
|
105444
|
+
return this.#asStatus(path14, Status2.UnsupportedEndpoint);
|
|
105445
105445
|
}
|
|
105446
105446
|
if (cluster2 === void 0) {
|
|
105447
|
-
return this.#asStatus(
|
|
105447
|
+
return this.#asStatus(path14, Status2.UnsupportedCluster);
|
|
105448
105448
|
}
|
|
105449
105449
|
if (event3 === void 0 || !cluster2.type.events[event3.id]) {
|
|
105450
|
-
return this.#asStatus(
|
|
105450
|
+
return this.#asStatus(path14, Status2.UnsupportedEvent);
|
|
105451
105451
|
}
|
|
105452
105452
|
if (this.#currentEndpoint !== endpoint) {
|
|
105453
105453
|
this.#currentEndpoint = endpoint;
|
|
@@ -105455,7 +105455,7 @@ var init_EventReadResponse = __esm({
|
|
|
105455
105455
|
} else if (this.#currentCluster !== cluster2) {
|
|
105456
105456
|
this.#currentCluster = cluster2;
|
|
105457
105457
|
}
|
|
105458
|
-
this.#registerEventPath(
|
|
105458
|
+
this.#registerEventPath(path14);
|
|
105459
105459
|
}
|
|
105460
105460
|
/**
|
|
105461
105461
|
* Starts new chunk or adds to current chunk all values from {@link endpoint} selected by {@link path}.
|
|
@@ -105465,20 +105465,20 @@ var init_EventReadResponse = __esm({
|
|
|
105465
105465
|
*
|
|
105466
105466
|
* TODO - skip endpoints for which subject is unauthorized
|
|
105467
105467
|
*/
|
|
105468
|
-
#addEndpointForWildcard(endpoint,
|
|
105468
|
+
#addEndpointForWildcard(endpoint, path14) {
|
|
105469
105469
|
if (this.#currentEndpoint !== endpoint) {
|
|
105470
105470
|
this.#currentEndpoint = endpoint;
|
|
105471
105471
|
this.#currentCluster = void 0;
|
|
105472
105472
|
}
|
|
105473
|
-
const { clusterId: clusterId3 } =
|
|
105473
|
+
const { clusterId: clusterId3 } = path14;
|
|
105474
105474
|
if (clusterId3 === void 0) {
|
|
105475
105475
|
for (const cluster2 of endpoint) {
|
|
105476
|
-
this.#addClusterForWildcard(cluster2, { ...
|
|
105476
|
+
this.#addClusterForWildcard(cluster2, { ...path14, endpointId: endpoint.id });
|
|
105477
105477
|
}
|
|
105478
105478
|
} else {
|
|
105479
105479
|
const cluster2 = endpoint[clusterId3];
|
|
105480
105480
|
if (cluster2 !== void 0) {
|
|
105481
|
-
this.#addClusterForWildcard(cluster2, { ...
|
|
105481
|
+
this.#addClusterForWildcard(cluster2, { ...path14, endpointId: endpoint.id });
|
|
105482
105482
|
}
|
|
105483
105483
|
}
|
|
105484
105484
|
}
|
|
@@ -105489,15 +105489,15 @@ var init_EventReadResponse = __esm({
|
|
|
105489
105489
|
*
|
|
105490
105490
|
* TODO - skip endpoints for which subject is unauthorized as optimization
|
|
105491
105491
|
*/
|
|
105492
|
-
#addClusterForWildcard(cluster2,
|
|
105492
|
+
#addClusterForWildcard(cluster2, path14) {
|
|
105493
105493
|
if (this.#currentCluster !== cluster2) {
|
|
105494
105494
|
this.#currentCluster = cluster2;
|
|
105495
105495
|
}
|
|
105496
|
-
const { eventId: eventId3 } =
|
|
105496
|
+
const { eventId: eventId3 } = path14;
|
|
105497
105497
|
if (eventId3 === void 0) {
|
|
105498
105498
|
for (const event3 of cluster2.type.events) {
|
|
105499
105499
|
this.#addEventForWildcard(event3, {
|
|
105500
|
-
...
|
|
105500
|
+
...path14,
|
|
105501
105501
|
clusterId: cluster2.type.id
|
|
105502
105502
|
});
|
|
105503
105503
|
}
|
|
@@ -105505,7 +105505,7 @@ var init_EventReadResponse = __esm({
|
|
|
105505
105505
|
const event3 = cluster2.type.events[eventId3];
|
|
105506
105506
|
if (event3 !== void 0) {
|
|
105507
105507
|
this.#addEventForWildcard(event3, {
|
|
105508
|
-
...
|
|
105508
|
+
...path14,
|
|
105509
105509
|
clusterId: cluster2.type.id
|
|
105510
105510
|
});
|
|
105511
105511
|
}
|
|
@@ -105516,24 +105516,24 @@ var init_EventReadResponse = __esm({
|
|
|
105516
105516
|
*
|
|
105517
105517
|
* Depends on state initialized by {@link #addClusterForWildcard}.
|
|
105518
105518
|
*/
|
|
105519
|
-
#addEventForWildcard(event3,
|
|
105519
|
+
#addEventForWildcard(event3, path14) {
|
|
105520
105520
|
if (!this.#guardedCurrentCluster.type.events[event3.id]) {
|
|
105521
105521
|
return;
|
|
105522
105522
|
}
|
|
105523
105523
|
if (hasRemoteActor(this.session) && this.session.authorityAt(event3.limits.readLevel, this.#guardedCurrentCluster.location) !== AccessControl4.Authority.Granted) {
|
|
105524
105524
|
return;
|
|
105525
105525
|
}
|
|
105526
|
-
this.#registerEventPath({ ...
|
|
105526
|
+
this.#registerEventPath({ ...path14, eventId: event3.id });
|
|
105527
105527
|
}
|
|
105528
|
-
#createEventKey(
|
|
105529
|
-
const { endpointId, clusterId: clusterId3, eventId: eventId3 } =
|
|
105528
|
+
#createEventKey(path14) {
|
|
105529
|
+
const { endpointId, clusterId: clusterId3, eventId: eventId3 } = path14;
|
|
105530
105530
|
return `${endpointId}:${clusterId3}:${eventId3}`;
|
|
105531
105531
|
}
|
|
105532
|
-
#registerEventPath(
|
|
105533
|
-
const { eventId: eventId3 } =
|
|
105532
|
+
#registerEventPath(path14) {
|
|
105533
|
+
const { eventId: eventId3 } = path14;
|
|
105534
105534
|
this.#allowedEventPaths.set(
|
|
105535
105535
|
this.#createEventKey({
|
|
105536
|
-
...
|
|
105536
|
+
...path14,
|
|
105537
105537
|
endpointId: this.#guardedCurrentEndpoint.id,
|
|
105538
105538
|
clusterId: this.#guardedCurrentCluster.type.id,
|
|
105539
105539
|
eventId: eventId3
|
|
@@ -105563,11 +105563,11 @@ var init_EventReadResponse = __esm({
|
|
|
105563
105563
|
/**
|
|
105564
105564
|
* Add a status value.
|
|
105565
105565
|
*/
|
|
105566
|
-
#asStatus(
|
|
105567
|
-
logger58.debug(`Error reading event ${this.node.inspectPath(
|
|
105566
|
+
#asStatus(path14, status3) {
|
|
105567
|
+
logger58.debug(`Error reading event ${this.node.inspectPath(path14)}: Status=${StatusCode[status3]}(${status3})`);
|
|
105568
105568
|
const report = {
|
|
105569
105569
|
kind: "event-status",
|
|
105570
|
-
path:
|
|
105570
|
+
path: path14,
|
|
105571
105571
|
status: status3
|
|
105572
105572
|
};
|
|
105573
105573
|
return report;
|
|
@@ -109223,8 +109223,8 @@ var init_DclClient = __esm({
|
|
|
109223
109223
|
};
|
|
109224
109224
|
MatterDclResponseError = class extends MatterDclError {
|
|
109225
109225
|
response;
|
|
109226
|
-
constructor(
|
|
109227
|
-
super(`Error fetching ${
|
|
109226
|
+
constructor(path14, error, options) {
|
|
109227
|
+
super(`Error fetching ${path14} from DCL: ${error.code} - ${error.message}`, options);
|
|
109228
109228
|
this.response = error;
|
|
109229
109229
|
}
|
|
109230
109230
|
};
|
|
@@ -109234,11 +109234,11 @@ var init_DclClient = __esm({
|
|
|
109234
109234
|
this.#baseUrl = this.production ? DCL_PRODUCTION_URL : DCL_TEST_URL;
|
|
109235
109235
|
}
|
|
109236
109236
|
#baseUrl;
|
|
109237
|
-
async #fetchPaginatedJson(
|
|
109237
|
+
async #fetchPaginatedJson(path14, paginatedField, options) {
|
|
109238
109238
|
const allItems = [];
|
|
109239
109239
|
let nextKey;
|
|
109240
109240
|
do {
|
|
109241
|
-
const currentPath = nextKey !== void 0 ? `${
|
|
109241
|
+
const currentPath = nextKey !== void 0 ? `${path14}${path14.includes("?") ? "&" : "?"}pagination.key=${encodeURIComponent(nextKey)}` : path14;
|
|
109242
109242
|
const response = await this.#fetchJson(currentPath, options);
|
|
109243
109243
|
const items = response[paginatedField];
|
|
109244
109244
|
if (items && Array.isArray(items)) {
|
|
@@ -109248,8 +109248,8 @@ var init_DclClient = __esm({
|
|
|
109248
109248
|
} while (nextKey);
|
|
109249
109249
|
return allItems;
|
|
109250
109250
|
}
|
|
109251
|
-
async #fetchJson(
|
|
109252
|
-
const url2 = new URL(
|
|
109251
|
+
async #fetchJson(path14, options) {
|
|
109252
|
+
const url2 = new URL(path14, this.#baseUrl).toString();
|
|
109253
109253
|
logger70.debug(`Fetching for DCL:`, url2);
|
|
109254
109254
|
try {
|
|
109255
109255
|
const timeoutMs = options?.timeout ?? DEFAULT_DCL_TIMEOUT;
|
|
@@ -109261,13 +109261,13 @@ var init_DclClient = __esm({
|
|
|
109261
109261
|
signal: AbortSignal.timeout(timeoutMs)
|
|
109262
109262
|
});
|
|
109263
109263
|
if (!response.ok) {
|
|
109264
|
-
throw new MatterDclResponseError(
|
|
109264
|
+
throw new MatterDclResponseError(path14, await response.json());
|
|
109265
109265
|
}
|
|
109266
109266
|
return await response.json();
|
|
109267
109267
|
} catch (error) {
|
|
109268
109268
|
MatterDclResponseError.reject(error);
|
|
109269
109269
|
throw new MatterDclResponseError(
|
|
109270
|
-
|
|
109270
|
+
path14,
|
|
109271
109271
|
{
|
|
109272
109272
|
code: 500,
|
|
109273
109273
|
message: error.message ?? error,
|
|
@@ -109287,8 +109287,8 @@ var init_DclClient = __esm({
|
|
|
109287
109287
|
return certList.approvedRootCertificates.certs;
|
|
109288
109288
|
}
|
|
109289
109289
|
async fetchRootCertificateBySubject(subject, options) {
|
|
109290
|
-
const
|
|
109291
|
-
const response = await this.#fetchJson(
|
|
109290
|
+
const path14 = `/dcl/pki/certificates/${encodeURIComponent(subject.subject)}/${encodeURIComponent(subject.subjectKeyId)}`;
|
|
109291
|
+
const response = await this.#fetchJson(path14, options);
|
|
109292
109292
|
if (!response || !response.approvedCertificates || response.approvedCertificates.subject !== subject.subject || response.approvedCertificates.subjectKeyId !== subject.subjectKeyId || response.approvedCertificates.schemaVersion !== 0) {
|
|
109293
109293
|
throw new MatterDclError(
|
|
109294
109294
|
`Root certificate not found for subject: ${subject.subject}, subjectKeyId: ${subject.subjectKeyId}`
|
|
@@ -109297,24 +109297,24 @@ var init_DclClient = __esm({
|
|
|
109297
109297
|
return response.approvedCertificates.certs;
|
|
109298
109298
|
}
|
|
109299
109299
|
async fetchModelByVidPid(vid, pid, options) {
|
|
109300
|
-
const
|
|
109301
|
-
const response = await this.#fetchJson(
|
|
109300
|
+
const path14 = `/dcl/model/models/${encodeURIComponent(vid)}/${encodeURIComponent(pid)}`;
|
|
109301
|
+
const response = await this.#fetchJson(path14, options);
|
|
109302
109302
|
if (!response || !response.model || response.model.vid !== vid || response.model.pid !== pid || response.model.schemaVersion !== 0) {
|
|
109303
109303
|
throw new MatterDclError(`Model not found for VID: ${vid}, PID: ${pid}`);
|
|
109304
109304
|
}
|
|
109305
109305
|
return response.model;
|
|
109306
109306
|
}
|
|
109307
109307
|
async fetchModelVersionsByVidPid(vid, pid, options) {
|
|
109308
|
-
const
|
|
109309
|
-
const response = await this.#fetchJson(
|
|
109308
|
+
const path14 = `/dcl/model/versions/${encodeURIComponent(vid)}/${encodeURIComponent(pid)}`;
|
|
109309
|
+
const response = await this.#fetchJson(path14, options);
|
|
109310
109310
|
if (!response || !response.modelVersions || response.modelVersions.vid !== vid || response.modelVersions.pid !== pid || response.modelVersions.schemaVersion !== 0) {
|
|
109311
109311
|
throw new MatterDclError(`Model versions not found for VID: ${vid}, PID: ${pid}`);
|
|
109312
109312
|
}
|
|
109313
109313
|
return response.modelVersions.softwareVersions;
|
|
109314
109314
|
}
|
|
109315
109315
|
async fetchModelVersionByVidPidSoftwareVersion(vid, pid, softwareVersion, options) {
|
|
109316
|
-
const
|
|
109317
|
-
const response = await this.#fetchJson(
|
|
109316
|
+
const path14 = `/dcl/model/versions/${encodeURIComponent(vid)}/${encodeURIComponent(pid)}/${encodeURIComponent(softwareVersion)}`;
|
|
109317
|
+
const response = await this.#fetchJson(path14, options);
|
|
109318
109318
|
if (!response || !response.modelVersion || response.modelVersion.vid !== vid || response.modelVersion.pid !== pid || response.modelVersion.softwareVersion !== softwareVersion || response.modelVersion.schemaVersion !== 0) {
|
|
109319
109319
|
throw new MatterDclError(
|
|
109320
109320
|
`Model version not found for VID: ${vid}, PID: ${pid}, Software Version: ${softwareVersion}`
|
|
@@ -116101,51 +116101,51 @@ var init_ValueCaster = __esm({
|
|
|
116101
116101
|
});
|
|
116102
116102
|
|
|
116103
116103
|
// ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/behavior/state/validation/assertions.js
|
|
116104
|
-
function assertNumber(value,
|
|
116104
|
+
function assertNumber(value, path14) {
|
|
116105
116105
|
if (Number.isFinite(value)) {
|
|
116106
116106
|
return;
|
|
116107
116107
|
}
|
|
116108
|
-
throw new DatatypeError(
|
|
116108
|
+
throw new DatatypeError(path14, "a number", value);
|
|
116109
116109
|
}
|
|
116110
|
-
function assertBoolean(value,
|
|
116110
|
+
function assertBoolean(value, path14) {
|
|
116111
116111
|
if (typeof value === "boolean" || value === 0 || value === 1) {
|
|
116112
116112
|
return;
|
|
116113
116113
|
}
|
|
116114
|
-
throw new DatatypeError(
|
|
116114
|
+
throw new DatatypeError(path14, "a boolean", value);
|
|
116115
116115
|
}
|
|
116116
|
-
function assertObject(value,
|
|
116116
|
+
function assertObject(value, path14) {
|
|
116117
116117
|
if (isObject(value)) {
|
|
116118
116118
|
return;
|
|
116119
116119
|
}
|
|
116120
|
-
throw new DatatypeError(
|
|
116120
|
+
throw new DatatypeError(path14, "an object", value);
|
|
116121
116121
|
}
|
|
116122
|
-
function assertNumeric(value,
|
|
116122
|
+
function assertNumeric(value, path14) {
|
|
116123
116123
|
if (typeof value === "number" || typeof value === "bigint") {
|
|
116124
116124
|
return;
|
|
116125
116125
|
}
|
|
116126
|
-
throw new DatatypeError(
|
|
116126
|
+
throw new DatatypeError(path14, "a number or bigint", value);
|
|
116127
116127
|
}
|
|
116128
|
-
function assertString(value,
|
|
116128
|
+
function assertString(value, path14) {
|
|
116129
116129
|
if (typeof value === "string") {
|
|
116130
116130
|
return;
|
|
116131
116131
|
}
|
|
116132
|
-
throw new DatatypeError(
|
|
116132
|
+
throw new DatatypeError(path14, "a string", value);
|
|
116133
116133
|
}
|
|
116134
|
-
function assertBytes(value,
|
|
116134
|
+
function assertBytes(value, path14) {
|
|
116135
116135
|
if (Bytes.isBytes(value)) {
|
|
116136
116136
|
return;
|
|
116137
116137
|
}
|
|
116138
|
-
throw new DatatypeError(
|
|
116138
|
+
throw new DatatypeError(path14, "a byte array", value);
|
|
116139
116139
|
}
|
|
116140
|
-
function assertSequence(value,
|
|
116140
|
+
function assertSequence(value, path14) {
|
|
116141
116141
|
if (typeof value === "string" || Bytes.isBytes(value)) {
|
|
116142
116142
|
return;
|
|
116143
116143
|
}
|
|
116144
|
-
throw new DatatypeError(
|
|
116144
|
+
throw new DatatypeError(path14, "a string or byte array", value);
|
|
116145
116145
|
}
|
|
116146
|
-
function assertArray(value,
|
|
116146
|
+
function assertArray(value, path14) {
|
|
116147
116147
|
if (!Array.isArray(value)) {
|
|
116148
|
-
throw new DatatypeError(
|
|
116148
|
+
throw new DatatypeError(path14, "an array", value);
|
|
116149
116149
|
}
|
|
116150
116150
|
}
|
|
116151
116151
|
function createIntAssertion(name, lowerBoundInclusive, upperBoundExclusive) {
|
|
@@ -116155,13 +116155,13 @@ function createIntAssertion(name, lowerBoundInclusive, upperBoundExclusive) {
|
|
|
116155
116155
|
return createVarIntAssertion(name, Number(lowerBoundInclusive), Number(upperBoundExclusive));
|
|
116156
116156
|
}
|
|
116157
116157
|
function createVarIntAssertion(name, min, max) {
|
|
116158
|
-
return function assertInt2(value,
|
|
116159
|
-
assertNumeric(value,
|
|
116158
|
+
return function assertInt2(value, path14) {
|
|
116159
|
+
assertNumeric(value, path14);
|
|
116160
116160
|
if (value < min) {
|
|
116161
|
-
throw new IntegerRangeError(
|
|
116161
|
+
throw new IntegerRangeError(path14, `Value ${value} is below the ${name} minimum of ${min}`);
|
|
116162
116162
|
}
|
|
116163
116163
|
if (value > max) {
|
|
116164
|
-
throw new IntegerRangeError(
|
|
116164
|
+
throw new IntegerRangeError(path14, `Value ${value} is above the ${name} maximum of ${max}`);
|
|
116165
116165
|
}
|
|
116166
116166
|
};
|
|
116167
116167
|
}
|
|
@@ -117266,18 +117266,18 @@ function StructPatcher(schema6, supervisor) {
|
|
|
117266
117266
|
memberArrays[key] = true;
|
|
117267
117267
|
}
|
|
117268
117268
|
}
|
|
117269
|
-
return (changes, target,
|
|
117269
|
+
return (changes, target, path14) => {
|
|
117270
117270
|
if (typeof changes !== "object" || changes === null || Array.isArray(changes)) {
|
|
117271
|
-
throw new WriteError(
|
|
117271
|
+
throw new WriteError(path14, `patch definition ${changes} is not an object`);
|
|
117272
117272
|
}
|
|
117273
117273
|
if (typeof target !== "object" || target === null || Array.isArray(target)) {
|
|
117274
|
-
throw new WriteError(
|
|
117274
|
+
throw new WriteError(path14, `cannot patch ${target} because it is not an object`);
|
|
117275
117275
|
}
|
|
117276
117276
|
for (let key in changes) {
|
|
117277
117277
|
let newValue = changes[key];
|
|
117278
117278
|
if (!(key in memberPatchers)) {
|
|
117279
117279
|
if (!(key in memberAltKeys)) {
|
|
117280
|
-
throw new WriteError(
|
|
117280
|
+
throw new WriteError(path14, `${key} is not a property of ${schema6.name}`);
|
|
117281
117281
|
}
|
|
117282
117282
|
key = memberAltKeys[key];
|
|
117283
117283
|
}
|
|
@@ -117288,17 +117288,17 @@ function StructPatcher(schema6, supervisor) {
|
|
|
117288
117288
|
}
|
|
117289
117289
|
if (memberArrays[key]) {
|
|
117290
117290
|
if (target[key] === void 0 || target[key] === null) {
|
|
117291
|
-
newValue = subpatch(newValue, [],
|
|
117291
|
+
newValue = subpatch(newValue, [], path14.at(key));
|
|
117292
117292
|
target[key] = newValue;
|
|
117293
117293
|
continue;
|
|
117294
117294
|
}
|
|
117295
117295
|
}
|
|
117296
117296
|
if (target[key] === void 0 || target[key] === null) {
|
|
117297
|
-
newValue = subpatch(newValue, { ...memberDefaults[key] },
|
|
117297
|
+
newValue = subpatch(newValue, { ...memberDefaults[key] }, path14.at(key));
|
|
117298
117298
|
target[key] = newValue;
|
|
117299
117299
|
continue;
|
|
117300
117300
|
}
|
|
117301
|
-
subpatch(newValue, target[key],
|
|
117301
|
+
subpatch(newValue, target[key], path14.at(key));
|
|
117302
117302
|
}
|
|
117303
117303
|
return target;
|
|
117304
117304
|
};
|
|
@@ -117317,28 +117317,28 @@ function ListPatcher(schema6, supervisor) {
|
|
|
117317
117317
|
if (entryMetatype === Metatype.object) {
|
|
117318
117318
|
entryDefaults = getDefaults(supervisor, entry);
|
|
117319
117319
|
}
|
|
117320
|
-
return (changes, target,
|
|
117320
|
+
return (changes, target, path14) => {
|
|
117321
117321
|
if (typeof changes !== "object" || changes === null) {
|
|
117322
|
-
throw new WriteError(
|
|
117322
|
+
throw new WriteError(path14, `patch definition ${changes} is not an object`);
|
|
117323
117323
|
}
|
|
117324
117324
|
if (!Array.isArray(target)) {
|
|
117325
|
-
throw new WriteError(
|
|
117325
|
+
throw new WriteError(path14, `patch definition ${changes} is not an object`);
|
|
117326
117326
|
}
|
|
117327
117327
|
for (const indexStr in changes) {
|
|
117328
117328
|
const index = Number.parseInt(indexStr);
|
|
117329
117329
|
if (index < 0 || !Number.isFinite(index)) {
|
|
117330
|
-
throw new WriteError(
|
|
117330
|
+
throw new WriteError(path14, `key ${index} is not a valid array index`);
|
|
117331
117331
|
}
|
|
117332
117332
|
let newValue = changes[indexStr];
|
|
117333
117333
|
if (patchEntry) {
|
|
117334
117334
|
const oldValue = index < target.length ? target[index] : void 0;
|
|
117335
117335
|
if (newValue === void 0 || newValue === null || oldValue === void 0 || oldValue === null) {
|
|
117336
117336
|
if (entryDefaults && isObject(newValue)) {
|
|
117337
|
-
newValue = patchEntry(newValue, { ...entryDefaults },
|
|
117337
|
+
newValue = patchEntry(newValue, { ...entryDefaults }, path14.at(index));
|
|
117338
117338
|
}
|
|
117339
117339
|
target[index] = newValue;
|
|
117340
117340
|
} else {
|
|
117341
|
-
patchEntry(newValue, target[index],
|
|
117341
|
+
patchEntry(newValue, target[index], path14.at(index));
|
|
117342
117342
|
}
|
|
117343
117343
|
} else {
|
|
117344
117344
|
target[index] = newValue;
|
|
@@ -117351,8 +117351,8 @@ function ListPatcher(schema6, supervisor) {
|
|
|
117351
117351
|
};
|
|
117352
117352
|
}
|
|
117353
117353
|
function PrimitivePatcher() {
|
|
117354
|
-
return (_changes, _target,
|
|
117355
|
-
throw new ImplementationError(`Cannot generate patch ${
|
|
117354
|
+
return (_changes, _target, path14) => {
|
|
117355
|
+
throw new ImplementationError(`Cannot generate patch ${path14} because it does not define not a collection`);
|
|
117356
117356
|
};
|
|
117357
117357
|
}
|
|
117358
117358
|
var defaultsCache;
|
|
@@ -121501,12 +121501,12 @@ function invokeCommand(backing, command, request, session) {
|
|
|
121501
121501
|
} else {
|
|
121502
121502
|
requestDiagnostic = Diagnostic.weak("(no payload)");
|
|
121503
121503
|
}
|
|
121504
|
-
const { path:
|
|
121504
|
+
const { path: path14, endpoint } = backing;
|
|
121505
121505
|
const context = session;
|
|
121506
121506
|
logger93.info(
|
|
121507
121507
|
"Invoke",
|
|
121508
121508
|
Mark.INBOUND,
|
|
121509
|
-
Diagnostic.strong(`${
|
|
121509
|
+
Diagnostic.strong(`${path14.toString()}.${command.name}`),
|
|
121510
121510
|
session.transaction.via,
|
|
121511
121511
|
requestDiagnostic
|
|
121512
121512
|
);
|
|
@@ -121544,7 +121544,7 @@ function invokeCommand(backing, command, request, session) {
|
|
|
121544
121544
|
logger93.info(
|
|
121545
121545
|
"Invoke",
|
|
121546
121546
|
Mark.OUTBOUND,
|
|
121547
|
-
Diagnostic.strong(`${
|
|
121547
|
+
Diagnostic.strong(`${path14.toString()}.${command.name}`),
|
|
121548
121548
|
session.transaction.via,
|
|
121549
121549
|
Diagnostic.dict(result2)
|
|
121550
121550
|
);
|
|
@@ -121556,7 +121556,7 @@ function invokeCommand(backing, command, request, session) {
|
|
|
121556
121556
|
logger93.info(
|
|
121557
121557
|
"Invoke",
|
|
121558
121558
|
Mark.OUTBOUND,
|
|
121559
|
-
Diagnostic.strong(`${
|
|
121559
|
+
Diagnostic.strong(`${path14.toString()}.${command.name}`),
|
|
121560
121560
|
session.transaction.via,
|
|
121561
121561
|
Diagnostic.dict(result)
|
|
121562
121562
|
);
|
|
@@ -121569,12 +121569,12 @@ function invokeCommand(backing, command, request, session) {
|
|
|
121569
121569
|
}
|
|
121570
121570
|
return result;
|
|
121571
121571
|
}
|
|
121572
|
-
function resolvePathForNode(node,
|
|
121573
|
-
const { endpointId, clusterId: clusterId3 } =
|
|
121574
|
-
const isUrgentString = "isUrgent" in
|
|
121575
|
-
const listIndexString = "listIndex" in
|
|
121572
|
+
function resolvePathForNode(node, path14) {
|
|
121573
|
+
const { endpointId, clusterId: clusterId3 } = path14;
|
|
121574
|
+
const isUrgentString = "isUrgent" in path14 && path14.isUrgent ? "!" : "";
|
|
121575
|
+
const listIndexString = "listIndex" in path14 && path14.listIndex === null ? "[ADD]" : "";
|
|
121576
121576
|
const postString = `${listIndexString}${isUrgentString}`;
|
|
121577
|
-
const elementId = "attributeId" in
|
|
121577
|
+
const elementId = "attributeId" in path14 ? path14.attributeId : "eventId" in path14 ? path14.eventId : "commandId" in path14 ? path14.commandId : void 0;
|
|
121578
121578
|
if (endpointId === void 0) {
|
|
121579
121579
|
return `*.${toWildcardOrHexPath("", clusterId3)}.${toWildcardOrHexPath("", elementId)}${postString}`;
|
|
121580
121580
|
}
|
|
@@ -121592,13 +121592,13 @@ function resolvePathForNode(node, path13) {
|
|
|
121592
121592
|
}
|
|
121593
121593
|
const clusterName = toWildcardOrHexPath(cluster2.type.name, clusterId3);
|
|
121594
121594
|
if (elementId !== void 0) {
|
|
121595
|
-
if ("eventId" in
|
|
121595
|
+
if ("eventId" in path14) {
|
|
121596
121596
|
const event3 = cluster2.type.events[elementId];
|
|
121597
121597
|
return `${endpointName}.${clusterName}.${toWildcardOrHexPath(event3?.name ?? "?", elementId)}${postString}`;
|
|
121598
|
-
} else if ("attributeId" in
|
|
121598
|
+
} else if ("attributeId" in path14) {
|
|
121599
121599
|
const attribute2 = cluster2.type.attributes[elementId];
|
|
121600
121600
|
return `${endpointName}.${clusterName}.${toWildcardOrHexPath(attribute2?.name ?? "?", elementId)}${postString}`;
|
|
121601
|
-
} else if ("commandId" in
|
|
121601
|
+
} else if ("commandId" in path14) {
|
|
121602
121602
|
const command = cluster2.type.commands[elementId];
|
|
121603
121603
|
return `${endpointName}.${clusterName}.${toWildcardOrHexPath(command?.name ?? "?", elementId)}${postString}`;
|
|
121604
121604
|
} else {
|
|
@@ -121699,8 +121699,8 @@ var init_ProtocolService = __esm({
|
|
|
121699
121699
|
inspect() {
|
|
121700
121700
|
return this.toString();
|
|
121701
121701
|
},
|
|
121702
|
-
inspectPath(
|
|
121703
|
-
return resolvePathForNode(this,
|
|
121702
|
+
inspectPath(path14) {
|
|
121703
|
+
return resolvePathForNode(this, path14);
|
|
121704
121704
|
}
|
|
121705
121705
|
};
|
|
121706
121706
|
}
|
|
@@ -124169,11 +124169,11 @@ var init_ServerSubscription = __esm({
|
|
|
124169
124169
|
});
|
|
124170
124170
|
|
|
124171
124171
|
// ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/node/server/InteractionServer.js
|
|
124172
|
-
function validateReadAttributesPath(
|
|
124172
|
+
function validateReadAttributesPath(path14, isGroupSession = false) {
|
|
124173
124173
|
if (isGroupSession) {
|
|
124174
124174
|
throw new StatusResponseError("Illegal read request with group session", StatusCode.InvalidAction);
|
|
124175
124175
|
}
|
|
124176
|
-
const { clusterId: clusterId3, attributeId } =
|
|
124176
|
+
const { clusterId: clusterId3, attributeId } = path14;
|
|
124177
124177
|
if (clusterId3 === void 0 && attributeId !== void 0) {
|
|
124178
124178
|
if (!GLOBAL_IDS2.has(attributeId)) {
|
|
124179
124179
|
throw new StatusResponseError(
|
|
@@ -124183,8 +124183,8 @@ function validateReadAttributesPath(path13, isGroupSession = false) {
|
|
|
124183
124183
|
}
|
|
124184
124184
|
}
|
|
124185
124185
|
}
|
|
124186
|
-
function validateReadEventPath(
|
|
124187
|
-
const { clusterId: clusterId3, eventId: eventId3 } =
|
|
124186
|
+
function validateReadEventPath(path14, isGroupSession = false) {
|
|
124187
|
+
const { clusterId: clusterId3, eventId: eventId3 } = path14;
|
|
124188
124188
|
if (clusterId3 === void 0 && eventId3 !== void 0) {
|
|
124189
124189
|
throw new StatusResponseError("Illegal read request with wildcard cluster ID", StatusCode.InvalidAction);
|
|
124190
124190
|
}
|
|
@@ -124366,8 +124366,8 @@ var init_InteractionServer = __esm({
|
|
|
124366
124366
|
exchange.via,
|
|
124367
124367
|
Diagnostic.asFlags({ fabricFiltered: isFabricFiltered }),
|
|
124368
124368
|
Diagnostic.dict({
|
|
124369
|
-
attributes: `${attributeRequests?.map((
|
|
124370
|
-
events: `${eventRequests?.map((
|
|
124369
|
+
attributes: `${attributeRequests?.map((path14) => this.#node.protocol.inspectPath(path14)).join(", ") ?? "none"}${dataVersionFilters?.length ? ` with ${dataVersionFilters?.length} filters` : ""}`,
|
|
124370
|
+
events: `${eventRequests?.map((path14) => this.#node.protocol.inspectPath(path14)).join(", ") ?? "none"}${eventFilters?.length ? `, ${eventFilters?.length} filters` : ""}`
|
|
124371
124371
|
})
|
|
124372
124372
|
]);
|
|
124373
124373
|
if (interactionModelRevision > Specification.INTERACTION_MODEL_REVISION) {
|
|
@@ -124476,22 +124476,22 @@ var init_InteractionServer = __esm({
|
|
|
124476
124476
|
currentBatch = [];
|
|
124477
124477
|
};
|
|
124478
124478
|
for (const request of writeRequests) {
|
|
124479
|
-
const { path:
|
|
124480
|
-
const listIndex =
|
|
124479
|
+
const { path: path14 } = request;
|
|
124480
|
+
const listIndex = path14.listIndex;
|
|
124481
124481
|
if (listIndex === null) {
|
|
124482
|
-
if (previousProcessedAttributePath?.endpointId !==
|
|
124482
|
+
if (previousProcessedAttributePath?.endpointId !== path14.endpointId || previousProcessedAttributePath?.clusterId !== path14.clusterId || previousProcessedAttributePath?.attributeId !== path14.attributeId) {
|
|
124483
124483
|
await processBatch();
|
|
124484
124484
|
allResponses.push({
|
|
124485
124485
|
kind: "attr-status",
|
|
124486
|
-
path:
|
|
124486
|
+
path: path14,
|
|
124487
124487
|
status: Status2.Busy
|
|
124488
124488
|
});
|
|
124489
124489
|
continue;
|
|
124490
124490
|
}
|
|
124491
124491
|
}
|
|
124492
124492
|
currentBatch.push(request);
|
|
124493
|
-
if (
|
|
124494
|
-
previousProcessedAttributePath =
|
|
124493
|
+
if (path14.endpointId !== void 0 && path14.clusterId !== void 0 && path14.attributeId !== void 0) {
|
|
124494
|
+
previousProcessedAttributePath = path14;
|
|
124495
124495
|
}
|
|
124496
124496
|
}
|
|
124497
124497
|
await processBatch();
|
|
@@ -124499,8 +124499,8 @@ var init_InteractionServer = __esm({
|
|
|
124499
124499
|
break;
|
|
124500
124500
|
}
|
|
124501
124501
|
const chunkResponse = {
|
|
124502
|
-
writeResponses: allResponses.map(({ path:
|
|
124503
|
-
path:
|
|
124502
|
+
writeResponses: allResponses.map(({ path: path14, status: status3, clusterStatus }) => ({
|
|
124503
|
+
path: path14,
|
|
124504
124504
|
status: { status: status3, clusterStatus }
|
|
124505
124505
|
})),
|
|
124506
124506
|
interactionModelRevision: Specification.INTERACTION_MODEL_REVISION
|
|
@@ -124590,16 +124590,16 @@ var init_InteractionServer = __esm({
|
|
|
124590
124590
|
Mark.INBOUND,
|
|
124591
124591
|
exchange.via,
|
|
124592
124592
|
Diagnostic.dict({
|
|
124593
|
-
attributes: attributeRequests?.length ? attributeRequests?.map((
|
|
124593
|
+
attributes: attributeRequests?.length ? attributeRequests?.map((path14) => this.#node.protocol.inspectPath(path14)).join(", ") : void 0,
|
|
124594
124594
|
dataVersionFilters: dataVersionFilters?.length ? dataVersionFilters.map(
|
|
124595
124595
|
({ path: { nodeId: nodeId3, endpointId, clusterId: clusterId3 }, dataVersion }) => `${clusterPathToId({ nodeId: nodeId3, endpointId, clusterId: clusterId3 })}=${dataVersion}`
|
|
124596
124596
|
).join(", ") : void 0,
|
|
124597
|
-
events: eventRequests?.length ? eventRequests.map((
|
|
124597
|
+
events: eventRequests?.length ? eventRequests.map((path14) => this.#node.protocol.inspectPath(path14)).join(", ") : void 0,
|
|
124598
124598
|
eventFilters: eventFilters?.length ? eventFilters.map((filter) => `${filter.nodeId}/${filter.eventMin}`).join(", ") : void 0
|
|
124599
124599
|
})
|
|
124600
124600
|
]);
|
|
124601
|
-
attributeRequests?.forEach((
|
|
124602
|
-
eventRequests?.forEach((
|
|
124601
|
+
attributeRequests?.forEach((path14) => validateReadAttributesPath(path14));
|
|
124602
|
+
eventRequests?.forEach((path14) => validateReadEventPath(path14));
|
|
124603
124603
|
if (minIntervalFloorSeconds < 0) {
|
|
124604
124604
|
throw new StatusResponseError(
|
|
124605
124605
|
"minIntervalFloorSeconds should be greater or equal to 0",
|
|
@@ -124881,9 +124881,9 @@ var init_InteractionServer = __esm({
|
|
|
124881
124881
|
break;
|
|
124882
124882
|
}
|
|
124883
124883
|
case "cmd-status": {
|
|
124884
|
-
const { path:
|
|
124884
|
+
const { path: path14, commandRef, status: status3, clusterStatus } = data;
|
|
124885
124885
|
await sendChunkIfNeeded({
|
|
124886
|
-
status: { commandPath:
|
|
124886
|
+
status: { commandPath: path14, status: { status: status3, clusterStatus }, commandRef }
|
|
124887
124887
|
});
|
|
124888
124888
|
break;
|
|
124889
124889
|
}
|
|
@@ -134966,14 +134966,14 @@ var init_ApiPath = __esm({
|
|
|
134966
134966
|
*
|
|
134967
134967
|
* So generally normal UNIX/URL semantics.
|
|
134968
134968
|
*/
|
|
134969
|
-
constructor(
|
|
134970
|
-
if (
|
|
134971
|
-
|
|
134969
|
+
constructor(path14) {
|
|
134970
|
+
if (path14 instanceof URL) {
|
|
134971
|
+
path14 = path14.pathname;
|
|
134972
134972
|
}
|
|
134973
|
-
if (!Array.isArray(
|
|
134974
|
-
|
|
134973
|
+
if (!Array.isArray(path14)) {
|
|
134974
|
+
path14 = path14.split("/").map(decodeURIComponent);
|
|
134975
134975
|
}
|
|
134976
|
-
for (const segment of
|
|
134976
|
+
for (const segment of path14) {
|
|
134977
134977
|
if (segment === "" || segment === ".") {
|
|
134978
134978
|
continue;
|
|
134979
134979
|
}
|
|
@@ -134993,20 +134993,20 @@ var init_ApiPath = __esm({
|
|
|
134993
134993
|
slice(start, end) {
|
|
134994
134994
|
return new _ApiPath(this.#segments.slice(start, end));
|
|
134995
134995
|
}
|
|
134996
|
-
at(
|
|
134996
|
+
at(path14) {
|
|
134997
134997
|
if (this.isEmpty) {
|
|
134998
|
-
return new _ApiPath(
|
|
134998
|
+
return new _ApiPath(path14);
|
|
134999
134999
|
}
|
|
135000
|
-
if (
|
|
135001
|
-
|
|
135000
|
+
if (path14 instanceof URL) {
|
|
135001
|
+
path14 = path14.pathname;
|
|
135002
135002
|
}
|
|
135003
|
-
if (Array.isArray(
|
|
135004
|
-
|
|
135003
|
+
if (Array.isArray(path14)) {
|
|
135004
|
+
path14 = path14.map(encodeURIComponent).join("/");
|
|
135005
135005
|
}
|
|
135006
|
-
if (
|
|
135007
|
-
return new _ApiPath(
|
|
135006
|
+
if (path14.startsWith("/")) {
|
|
135007
|
+
return new _ApiPath(path14);
|
|
135008
135008
|
}
|
|
135009
|
-
return new _ApiPath(`${this.toString()}/${
|
|
135009
|
+
return new _ApiPath(`${this.toString()}/${path14}`);
|
|
135010
135010
|
}
|
|
135011
135011
|
toString() {
|
|
135012
135012
|
return `${this.#segments.map(encodeURIComponent).join("/")}`;
|
|
@@ -135091,12 +135091,12 @@ var init_Envelope = __esm({
|
|
|
135091
135091
|
/**
|
|
135092
135092
|
* Validate against the schema. Casts to appropriate types if necessary.
|
|
135093
135093
|
*/
|
|
135094
|
-
validate(
|
|
135095
|
-
if (!
|
|
135096
|
-
|
|
135094
|
+
validate(path14) {
|
|
135095
|
+
if (!path14) {
|
|
135096
|
+
path14 = DataModelPath(this.#supervisor.schema.path);
|
|
135097
135097
|
}
|
|
135098
135098
|
this.#js = this.#supervisor.cast(this.#js);
|
|
135099
|
-
this.#supervisor.validate?.(this.js, LocalActorContext.ReadOnly, { path:
|
|
135099
|
+
this.#supervisor.validate?.(this.js, LocalActorContext.ReadOnly, { path: path14 });
|
|
135100
135100
|
}
|
|
135101
135101
|
/**
|
|
135102
135102
|
* Convert a {@link js} value to {@link JSON}.
|
|
@@ -135336,11 +135336,11 @@ var init_PropertyResource = __esm({
|
|
|
135336
135336
|
}
|
|
135337
135337
|
return "field";
|
|
135338
135338
|
}
|
|
135339
|
-
constructor(parent, id, supervisor,
|
|
135339
|
+
constructor(parent, id, supervisor, path14) {
|
|
135340
135340
|
super(parent);
|
|
135341
135341
|
this.id = id;
|
|
135342
135342
|
this.supervisor = supervisor;
|
|
135343
|
-
this.dataModelPath =
|
|
135343
|
+
this.dataModelPath = path14;
|
|
135344
135344
|
}
|
|
135345
135345
|
get schema() {
|
|
135346
135346
|
return this.supervisor.schema;
|
|
@@ -135976,7 +135976,7 @@ var init_Api = __esm({
|
|
|
135976
135976
|
init_ServerNodeResource();
|
|
135977
135977
|
loggers = /* @__PURE__ */ new Map();
|
|
135978
135978
|
((Api2) => {
|
|
135979
|
-
async function resourceFor(agent,
|
|
135979
|
+
async function resourceFor(agent, path14) {
|
|
135980
135980
|
let item;
|
|
135981
135981
|
if ("peers" in agent.endpoint) {
|
|
135982
135982
|
item = new ServerNodeResource(agent, void 0);
|
|
@@ -135986,7 +135986,7 @@ var init_Api = __esm({
|
|
|
135986
135986
|
item = new EndpointResource(agent, void 0);
|
|
135987
135987
|
}
|
|
135988
135988
|
const breadcrumb = [item];
|
|
135989
|
-
for (const segment of
|
|
135989
|
+
for (const segment of path14) {
|
|
135990
135990
|
const parent = breadcrumb[breadcrumb.length - 1];
|
|
135991
135991
|
const item2 = await parent.childFor(segment);
|
|
135992
135992
|
if (!item2) {
|
|
@@ -136401,12 +136401,12 @@ var init_HttpInterface = __esm({
|
|
|
136401
136401
|
let response;
|
|
136402
136402
|
try {
|
|
136403
136403
|
const address = new AppAddress(request.url);
|
|
136404
|
-
const
|
|
136405
|
-
if (!
|
|
136404
|
+
const path14 = this.root.subpathFor(new ApiPath(address));
|
|
136405
|
+
if (!path14) {
|
|
136406
136406
|
return;
|
|
136407
136407
|
}
|
|
136408
136408
|
response = await this.node.act("http", async (agent) => {
|
|
136409
|
-
const resource = await Api.resourceFor(agent,
|
|
136409
|
+
const resource = await Api.resourceFor(agent, path14);
|
|
136410
136410
|
if (resource === void 0) {
|
|
136411
136411
|
throw new StatusResponse.NotFoundError(`Path "${address.pathname}" not found`);
|
|
136412
136412
|
}
|
|
@@ -138200,8 +138200,8 @@ var init_WebSocketInterface = __esm({
|
|
|
138200
138200
|
var _stack = [];
|
|
138201
138201
|
try {
|
|
138202
138202
|
const address = new AppAddress(request.url);
|
|
138203
|
-
const
|
|
138204
|
-
if (
|
|
138203
|
+
const path14 = new ApiPath(address).toString();
|
|
138204
|
+
if (path14 !== this.root.toString()) {
|
|
138205
138205
|
return;
|
|
138206
138206
|
}
|
|
138207
138207
|
const ws2 = await Abort.race(this.abort, await upgrade());
|
|
@@ -138880,8 +138880,8 @@ var init_endpoint = __esm({
|
|
|
138880
138880
|
});
|
|
138881
138881
|
|
|
138882
138882
|
// ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/loader/load.mjs
|
|
138883
|
-
function load(
|
|
138884
|
-
return import(
|
|
138883
|
+
function load(path14) {
|
|
138884
|
+
return import(path14);
|
|
138885
138885
|
}
|
|
138886
138886
|
var init_load = __esm({
|
|
138887
138887
|
"../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/loader/load.mjs"() {
|
|
@@ -138889,8 +138889,8 @@ var init_load = __esm({
|
|
|
138889
138889
|
});
|
|
138890
138890
|
|
|
138891
138891
|
// ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/loader/loader.js
|
|
138892
|
-
function doLoad(description, exportName,
|
|
138893
|
-
const cachedResult = cache5[
|
|
138892
|
+
function doLoad(description, exportName, path14) {
|
|
138893
|
+
const cachedResult = cache5[path14];
|
|
138894
138894
|
if (cachedResult) {
|
|
138895
138895
|
return cachedResult;
|
|
138896
138896
|
}
|
|
@@ -138901,7 +138901,7 @@ function doLoad(description, exportName, path13) {
|
|
|
138901
138901
|
failure();
|
|
138902
138902
|
}
|
|
138903
138903
|
try {
|
|
138904
|
-
const module = load(
|
|
138904
|
+
const module = load(path14);
|
|
138905
138905
|
if (MaybePromise.is(module)) {
|
|
138906
138906
|
return module.then(extractExport, failure);
|
|
138907
138907
|
}
|
|
@@ -143435,11 +143435,11 @@ var init_NodeJsHttpEndpoint = __esm({
|
|
|
143435
143435
|
}
|
|
143436
143436
|
break;
|
|
143437
143437
|
case "unix":
|
|
143438
|
-
const
|
|
143438
|
+
const path14 = decodeURIComponent(address.hostname);
|
|
143439
143439
|
if (options.basePathForUnixSockets) {
|
|
143440
|
-
opts.path = resolve(options.basePathForUnixSockets, normalize(
|
|
143440
|
+
opts.path = resolve(options.basePathForUnixSockets, normalize(path14));
|
|
143441
143441
|
} else {
|
|
143442
|
-
opts.path = normalize(
|
|
143442
|
+
opts.path = normalize(path14);
|
|
143443
143443
|
}
|
|
143444
143444
|
if (existsSync(opts.path)) {
|
|
143445
143445
|
if (statSync(opts.path).isSocket()) {
|
|
@@ -143643,9 +143643,9 @@ var init_StorageBackendDisk = __esm({
|
|
|
143643
143643
|
isInitialized = false;
|
|
143644
143644
|
#writeFileBlocker = /* @__PURE__ */ new Map();
|
|
143645
143645
|
#index = {};
|
|
143646
|
-
constructor(
|
|
143646
|
+
constructor(path14, clear = false) {
|
|
143647
143647
|
super();
|
|
143648
|
-
this.#path =
|
|
143648
|
+
this.#path = path14;
|
|
143649
143649
|
this.#clear = clear;
|
|
143650
143650
|
}
|
|
143651
143651
|
get initialized() {
|
|
@@ -143908,9 +143908,9 @@ var init_StorageBackendJsonFile = __esm({
|
|
|
143908
143908
|
"../../node_modules/.pnpm/@matter+nodejs@0.16.10/node_modules/@matter/nodejs/dist/esm/storage/fs/StorageBackendJsonFile.js"() {
|
|
143909
143909
|
init_esm();
|
|
143910
143910
|
StorageBackendJsonFile = class _StorageBackendJsonFile extends StorageBackendMemory {
|
|
143911
|
-
constructor(
|
|
143911
|
+
constructor(path14) {
|
|
143912
143912
|
super();
|
|
143913
|
-
this.path =
|
|
143913
|
+
this.path = path14;
|
|
143914
143914
|
}
|
|
143915
143915
|
/** We store changes after a value was set to the storage, but not more often than this setting (in ms). */
|
|
143916
143916
|
static commitDelay = Seconds.one;
|
|
@@ -143922,8 +143922,8 @@ var init_StorageBackendJsonFile = __esm({
|
|
|
143922
143922
|
);
|
|
143923
143923
|
closed = false;
|
|
143924
143924
|
resolveCommitted;
|
|
143925
|
-
static async create(
|
|
143926
|
-
const storage2 = new this(
|
|
143925
|
+
static async create(path14) {
|
|
143926
|
+
const storage2 = new this(path14);
|
|
143927
143927
|
storage2.initialize();
|
|
143928
143928
|
return storage2;
|
|
143929
143929
|
}
|
|
@@ -144128,8 +144128,8 @@ var init_SqliteStorage = __esm({
|
|
|
144128
144128
|
*/
|
|
144129
144129
|
constructor(args) {
|
|
144130
144130
|
super();
|
|
144131
|
-
const { databaseCreator, path:
|
|
144132
|
-
this.dbPath =
|
|
144131
|
+
const { databaseCreator, path: path14, tableName, clear } = args;
|
|
144132
|
+
this.dbPath = path14 === null ? _SqliteStorage.memoryPath : path14;
|
|
144133
144133
|
this.databaseCreator = databaseCreator;
|
|
144134
144134
|
this.database = databaseCreator(this.dbPath);
|
|
144135
144135
|
this.tableName = tableName ?? _SqliteStorage.defaultTableName;
|
|
@@ -144513,10 +144513,10 @@ var init_NodeJsSqlite = __esm({
|
|
|
144513
144513
|
"../../node_modules/.pnpm/@matter+nodejs@0.16.10/node_modules/@matter/nodejs/dist/esm/storage/sqlite/platform/NodeJsSqlite.js"() {
|
|
144514
144514
|
init_SqliteStorage();
|
|
144515
144515
|
NodeJsSqlite = class extends SqliteStorage {
|
|
144516
|
-
constructor(
|
|
144516
|
+
constructor(path14, clear = false) {
|
|
144517
144517
|
super({
|
|
144518
144518
|
databaseCreator: (path22) => new DatabaseSync(path22),
|
|
144519
|
-
path:
|
|
144519
|
+
path: path14,
|
|
144520
144520
|
clear
|
|
144521
144521
|
});
|
|
144522
144522
|
}
|
|
@@ -144561,13 +144561,13 @@ var init_BunSqlite = __esm({
|
|
|
144561
144561
|
init_bun_sqlite();
|
|
144562
144562
|
init_bun();
|
|
144563
144563
|
BunSqlite = class extends SqliteStorage {
|
|
144564
|
-
constructor(
|
|
144564
|
+
constructor(path14, clear = false) {
|
|
144565
144565
|
super({
|
|
144566
144566
|
databaseCreator: (path22) => new Database(path22, {
|
|
144567
144567
|
strict: true,
|
|
144568
144568
|
create: true
|
|
144569
144569
|
}),
|
|
144570
|
-
path:
|
|
144570
|
+
path: path14,
|
|
144571
144571
|
clear
|
|
144572
144572
|
});
|
|
144573
144573
|
}
|
|
@@ -144584,16 +144584,16 @@ var init_BunSqlite = __esm({
|
|
|
144584
144584
|
});
|
|
144585
144585
|
|
|
144586
144586
|
// ../../node_modules/.pnpm/@matter+nodejs@0.16.10/node_modules/@matter/nodejs/dist/esm/storage/sqlite/platform/PlatformSqlite.js
|
|
144587
|
-
async function PlatformSqlite(
|
|
144587
|
+
async function PlatformSqlite(path14, clear = false) {
|
|
144588
144588
|
const isBun = isBunjs();
|
|
144589
144589
|
if (!isBun) {
|
|
144590
144590
|
const module2 = await Promise.resolve().then(() => (init_NodeJsSqlite(), NodeJsSqlite_exports));
|
|
144591
144591
|
const NodeJsSqlite2 = findDefaultExport(module2, "NodeJsSqlite");
|
|
144592
|
-
return new NodeJsSqlite2(
|
|
144592
|
+
return new NodeJsSqlite2(path14, clear);
|
|
144593
144593
|
}
|
|
144594
144594
|
const module = await Promise.resolve().then(() => (init_BunSqlite(), BunSqlite_exports));
|
|
144595
144595
|
const BunSqlite2 = findDefaultExport(module, "BunSqlite");
|
|
144596
|
-
return new BunSqlite2(
|
|
144596
|
+
return new BunSqlite2(path14, clear);
|
|
144597
144597
|
}
|
|
144598
144598
|
function findDefaultExport(moduleLike, name) {
|
|
144599
144599
|
return moduleLike[name] || moduleLike.default?.[name] || moduleLike.default;
|
|
@@ -144638,11 +144638,11 @@ var init_StorageFactory = __esm({
|
|
|
144638
144638
|
if (!await exists(rootDir)) {
|
|
144639
144639
|
await mkdir2(rootDir, { recursive: true });
|
|
144640
144640
|
}
|
|
144641
|
-
const
|
|
144642
|
-
if (clear || await exists(
|
|
144643
|
-
return await createRawInit(type,
|
|
144641
|
+
const path14 = getRealPath(type, rootDir, namespace3);
|
|
144642
|
+
if (clear || await exists(path14)) {
|
|
144643
|
+
return await createRawInit(type, path14, clear);
|
|
144644
144644
|
}
|
|
144645
|
-
const storage2 = await createRawInit(type,
|
|
144645
|
+
const storage2 = await createRawInit(type, path14, false);
|
|
144646
144646
|
const migrationRootDir = resolve2(rootDir, ".migrations", getResultDirName(namespace3));
|
|
144647
144647
|
for (const otherType of StorageTypes) {
|
|
144648
144648
|
if (type === otherType) {
|
|
@@ -144669,7 +144669,7 @@ var init_StorageFactory = __esm({
|
|
|
144669
144669
|
fromType: otherType,
|
|
144670
144670
|
fromPath: otherPath,
|
|
144671
144671
|
toType: type,
|
|
144672
|
-
toPath:
|
|
144672
|
+
toPath: path14,
|
|
144673
144673
|
result: migrationResult
|
|
144674
144674
|
}),
|
|
144675
144675
|
4
|
|
@@ -144692,14 +144692,14 @@ Error: ${errorMessage}`
|
|
|
144692
144692
|
const { driver, namespace: namespace3 } = args;
|
|
144693
144693
|
const rootDir = resolve2(args.rootDir);
|
|
144694
144694
|
const type = getStorageType(driver);
|
|
144695
|
-
const
|
|
144696
|
-
if (!await exists(
|
|
144695
|
+
const path14 = getRealPath(type, rootDir, namespace3);
|
|
144696
|
+
if (!await exists(path14)) {
|
|
144697
144697
|
return;
|
|
144698
144698
|
}
|
|
144699
|
-
await rm3(
|
|
144699
|
+
await rm3(path14, { recursive: true, force: true });
|
|
144700
144700
|
}
|
|
144701
144701
|
StorageFactory2.remove = remove;
|
|
144702
|
-
async function createRaw(type,
|
|
144702
|
+
async function createRaw(type, path14, clear) {
|
|
144703
144703
|
const normalizedType = type.toLowerCase();
|
|
144704
144704
|
if (normalizedType === "sqlite") {
|
|
144705
144705
|
if (!supportsSqlite()) {
|
|
@@ -144710,21 +144710,21 @@ Error: ${errorMessage}`
|
|
|
144710
144710
|
`.replace(/\n\s+/g, "\n")
|
|
144711
144711
|
);
|
|
144712
144712
|
}
|
|
144713
|
-
return await PlatformSqlite(
|
|
144713
|
+
return await PlatformSqlite(path14, clear);
|
|
144714
144714
|
}
|
|
144715
144715
|
if (normalizedType === "file") {
|
|
144716
|
-
return new StorageBackendDisk(
|
|
144716
|
+
return new StorageBackendDisk(path14, clear);
|
|
144717
144717
|
}
|
|
144718
144718
|
throw new Error(`'${type}' storage type is not implemented.`);
|
|
144719
144719
|
}
|
|
144720
|
-
async function createRawInit(type,
|
|
144721
|
-
const storage2 = await createRaw(type,
|
|
144720
|
+
async function createRawInit(type, path14, clear) {
|
|
144721
|
+
const storage2 = await createRaw(type, path14, clear);
|
|
144722
144722
|
await storage2.initialize();
|
|
144723
144723
|
return storage2;
|
|
144724
144724
|
}
|
|
144725
|
-
async function hasStorage(type,
|
|
144725
|
+
async function hasStorage(type, path14) {
|
|
144726
144726
|
try {
|
|
144727
|
-
const pathStat = await lstat(
|
|
144727
|
+
const pathStat = await lstat(path14);
|
|
144728
144728
|
switch (type) {
|
|
144729
144729
|
case "file":
|
|
144730
144730
|
return pathStat.isDirectory();
|
|
@@ -144791,9 +144791,9 @@ Error: ${errorMessage}`
|
|
|
144791
144791
|
}
|
|
144792
144792
|
return result;
|
|
144793
144793
|
}
|
|
144794
|
-
async function exists(
|
|
144794
|
+
async function exists(path14) {
|
|
144795
144795
|
try {
|
|
144796
|
-
await lstat(resolve2(
|
|
144796
|
+
await lstat(resolve2(path14));
|
|
144797
144797
|
return true;
|
|
144798
144798
|
} catch (err) {
|
|
144799
144799
|
return false;
|
|
@@ -147438,7 +147438,7 @@ BigInt.prototype.toJSON = function() {
|
|
|
147438
147438
|
};
|
|
147439
147439
|
|
|
147440
147440
|
// src/cli.ts
|
|
147441
|
-
import * as
|
|
147441
|
+
import * as path13 from "node:path";
|
|
147442
147442
|
import * as url from "node:url";
|
|
147443
147443
|
import yargs from "yargs";
|
|
147444
147444
|
import { hideBin } from "yargs/helpers";
|
|
@@ -147615,7 +147615,7 @@ import express from "express";
|
|
|
147615
147615
|
import multer from "multer";
|
|
147616
147616
|
import unzipper from "unzipper";
|
|
147617
147617
|
var upload = multer({ storage: multer.memoryStorage() });
|
|
147618
|
-
function backupApi(bridgeStorage, mappingStorage, storageLocation, _bridgeService) {
|
|
147618
|
+
function backupApi(bridgeStorage, mappingStorage, storageLocation, backupService, settingsStorage, _bridgeService) {
|
|
147619
147619
|
const router = express.Router();
|
|
147620
147620
|
router.get("/download", async (req, res) => {
|
|
147621
147621
|
try {
|
|
@@ -147828,6 +147828,169 @@ WARNING: ${includeIdentity ? "This backup contains sensitive Matter identity dat
|
|
|
147828
147828
|
process.exit(0);
|
|
147829
147829
|
}, 500);
|
|
147830
147830
|
});
|
|
147831
|
+
router.get("/snapshots", async (_, res) => {
|
|
147832
|
+
try {
|
|
147833
|
+
const backups = backupService.listBackups();
|
|
147834
|
+
res.json(backups);
|
|
147835
|
+
} catch (error) {
|
|
147836
|
+
const message = error instanceof Error ? error.message : "Failed to list backups";
|
|
147837
|
+
res.status(500).json({ error: message });
|
|
147838
|
+
}
|
|
147839
|
+
});
|
|
147840
|
+
router.post("/snapshots/create", async (_, res) => {
|
|
147841
|
+
try {
|
|
147842
|
+
const metadata = await backupService.createBackup(false);
|
|
147843
|
+
res.json(metadata);
|
|
147844
|
+
} catch (error) {
|
|
147845
|
+
const message = error instanceof Error ? error.message : "Failed to create backup";
|
|
147846
|
+
res.status(500).json({ error: message });
|
|
147847
|
+
}
|
|
147848
|
+
});
|
|
147849
|
+
router.get("/snapshots/:filename/download", async (req, res) => {
|
|
147850
|
+
try {
|
|
147851
|
+
const filepath = backupService.getBackupPath(req.params.filename);
|
|
147852
|
+
if (!filepath) {
|
|
147853
|
+
res.status(404).json({ error: "Backup not found" });
|
|
147854
|
+
return;
|
|
147855
|
+
}
|
|
147856
|
+
res.setHeader("Content-Type", "application/zip");
|
|
147857
|
+
res.setHeader(
|
|
147858
|
+
"Content-Disposition",
|
|
147859
|
+
`attachment; filename="${req.params.filename}"`
|
|
147860
|
+
);
|
|
147861
|
+
const stream = fs.createReadStream(filepath);
|
|
147862
|
+
stream.pipe(res);
|
|
147863
|
+
} catch (error) {
|
|
147864
|
+
const message = error instanceof Error ? error.message : "Failed to download backup";
|
|
147865
|
+
res.status(500).json({ error: message });
|
|
147866
|
+
}
|
|
147867
|
+
});
|
|
147868
|
+
router.post("/snapshots/:filename/restore", async (req, res) => {
|
|
147869
|
+
try {
|
|
147870
|
+
const filepath = backupService.getBackupPath(req.params.filename);
|
|
147871
|
+
if (!filepath) {
|
|
147872
|
+
res.status(404).json({ error: "Backup not found" });
|
|
147873
|
+
return;
|
|
147874
|
+
}
|
|
147875
|
+
const buffer = fs.readFileSync(filepath);
|
|
147876
|
+
const options = req.body || {};
|
|
147877
|
+
const { backupData, zipDirectory } = await extractBackupData(buffer);
|
|
147878
|
+
const existingIds = new Set(bridgeStorage.bridges.map((b) => b.id));
|
|
147879
|
+
const bridgesToRestore = options.bridgeIds ? backupData.bridges.filter((b) => options.bridgeIds.includes(b.id)) : backupData.bridges;
|
|
147880
|
+
let bridgesRestored = 0;
|
|
147881
|
+
let bridgesSkipped = 0;
|
|
147882
|
+
let mappingsRestored = 0;
|
|
147883
|
+
let identitiesRestored = 0;
|
|
147884
|
+
let iconsRestored = 0;
|
|
147885
|
+
const errors = [];
|
|
147886
|
+
for (const bridge of bridgesToRestore) {
|
|
147887
|
+
try {
|
|
147888
|
+
const exists = existingIds.has(bridge.id);
|
|
147889
|
+
if (exists && !options.overwriteExisting) {
|
|
147890
|
+
bridgesSkipped++;
|
|
147891
|
+
continue;
|
|
147892
|
+
}
|
|
147893
|
+
await bridgeStorage.add(bridge);
|
|
147894
|
+
bridgesRestored++;
|
|
147895
|
+
if (options.includeMappings !== false) {
|
|
147896
|
+
const mappings = backupData.entityMappings[bridge.id];
|
|
147897
|
+
if (mappings) {
|
|
147898
|
+
for (const mapping of mappings) {
|
|
147899
|
+
const config10 = mapping;
|
|
147900
|
+
await mappingStorage.setMapping({
|
|
147901
|
+
bridgeId: bridge.id,
|
|
147902
|
+
entityId: config10.entityId,
|
|
147903
|
+
matterDeviceType: config10.matterDeviceType,
|
|
147904
|
+
customName: config10.customName,
|
|
147905
|
+
disabled: config10.disabled,
|
|
147906
|
+
filterLifeEntity: config10.filterLifeEntity,
|
|
147907
|
+
cleaningModeEntity: config10.cleaningModeEntity,
|
|
147908
|
+
humidityEntity: config10.humidityEntity,
|
|
147909
|
+
pressureEntity: config10.pressureEntity,
|
|
147910
|
+
batteryEntity: config10.batteryEntity,
|
|
147911
|
+
roomEntities: config10.roomEntities,
|
|
147912
|
+
disableLockPin: config10.disableLockPin,
|
|
147913
|
+
powerEntity: config10.powerEntity,
|
|
147914
|
+
energyEntity: config10.energyEntity,
|
|
147915
|
+
suctionLevelEntity: config10.suctionLevelEntity,
|
|
147916
|
+
mopIntensityEntity: config10.mopIntensityEntity
|
|
147917
|
+
});
|
|
147918
|
+
mappingsRestored++;
|
|
147919
|
+
}
|
|
147920
|
+
}
|
|
147921
|
+
}
|
|
147922
|
+
if (options.restoreIdentity !== false && backupData.includesIdentity) {
|
|
147923
|
+
const identityRestored = await restoreIdentityFiles(
|
|
147924
|
+
zipDirectory,
|
|
147925
|
+
bridge.id,
|
|
147926
|
+
storageLocation
|
|
147927
|
+
);
|
|
147928
|
+
if (identityRestored) {
|
|
147929
|
+
identitiesRestored++;
|
|
147930
|
+
}
|
|
147931
|
+
}
|
|
147932
|
+
if (backupData.includesIcons) {
|
|
147933
|
+
const iconRestored = await restoreBridgeIcon(
|
|
147934
|
+
zipDirectory,
|
|
147935
|
+
bridge.id,
|
|
147936
|
+
storageLocation
|
|
147937
|
+
);
|
|
147938
|
+
if (iconRestored) {
|
|
147939
|
+
iconsRestored++;
|
|
147940
|
+
}
|
|
147941
|
+
}
|
|
147942
|
+
} catch (e) {
|
|
147943
|
+
errors.push({
|
|
147944
|
+
bridgeId: bridge.id,
|
|
147945
|
+
error: e instanceof Error ? e.message : "Unknown error"
|
|
147946
|
+
});
|
|
147947
|
+
}
|
|
147948
|
+
}
|
|
147949
|
+
res.json({
|
|
147950
|
+
bridgesRestored,
|
|
147951
|
+
bridgesSkipped,
|
|
147952
|
+
mappingsRestored,
|
|
147953
|
+
identitiesRestored,
|
|
147954
|
+
iconsRestored,
|
|
147955
|
+
errors,
|
|
147956
|
+
restartRequired: bridgesRestored > 0 || identitiesRestored > 0
|
|
147957
|
+
});
|
|
147958
|
+
} catch (error) {
|
|
147959
|
+
const message = error instanceof Error ? error.message : "Failed to restore from snapshot";
|
|
147960
|
+
res.status(400).json({ error: message });
|
|
147961
|
+
}
|
|
147962
|
+
});
|
|
147963
|
+
router.delete("/snapshots/:filename", async (req, res) => {
|
|
147964
|
+
try {
|
|
147965
|
+
const deleted = backupService.deleteBackup(req.params.filename);
|
|
147966
|
+
if (!deleted) {
|
|
147967
|
+
res.status(404).json({ error: "Backup not found" });
|
|
147968
|
+
return;
|
|
147969
|
+
}
|
|
147970
|
+
res.json({ success: true });
|
|
147971
|
+
} catch (error) {
|
|
147972
|
+
const message = error instanceof Error ? error.message : "Failed to delete backup";
|
|
147973
|
+
res.status(500).json({ error: message });
|
|
147974
|
+
}
|
|
147975
|
+
});
|
|
147976
|
+
router.get("/settings", async (_, res) => {
|
|
147977
|
+
try {
|
|
147978
|
+
res.json(settingsStorage.backupSettings);
|
|
147979
|
+
} catch (error) {
|
|
147980
|
+
const message = error instanceof Error ? error.message : "Failed to get settings";
|
|
147981
|
+
res.status(500).json({ error: message });
|
|
147982
|
+
}
|
|
147983
|
+
});
|
|
147984
|
+
router.put("/settings", async (req, res) => {
|
|
147985
|
+
try {
|
|
147986
|
+
const body = req.body;
|
|
147987
|
+
await settingsStorage.setBackupSettings(body);
|
|
147988
|
+
res.json(settingsStorage.backupSettings);
|
|
147989
|
+
} catch (error) {
|
|
147990
|
+
const message = error instanceof Error ? error.message : "Failed to update settings";
|
|
147991
|
+
res.status(500).json({ error: message });
|
|
147992
|
+
}
|
|
147993
|
+
});
|
|
147831
147994
|
return router;
|
|
147832
147995
|
}
|
|
147833
147996
|
async function extractBackupData(buffer) {
|
|
@@ -150562,8 +150725,8 @@ function detectEnvironment2() {
|
|
|
150562
150725
|
return "Docker";
|
|
150563
150726
|
}
|
|
150564
150727
|
try {
|
|
150565
|
-
const
|
|
150566
|
-
if (
|
|
150728
|
+
const fs13 = __require("node:fs");
|
|
150729
|
+
if (fs13.existsSync("/.dockerenv")) {
|
|
150567
150730
|
return "Docker";
|
|
150568
150731
|
}
|
|
150569
150732
|
} catch {
|
|
@@ -150710,9 +150873,9 @@ function getDataPath() {
|
|
|
150710
150873
|
}
|
|
150711
150874
|
return process.cwd();
|
|
150712
150875
|
}
|
|
150713
|
-
async function getWindowsStorageInfo(
|
|
150876
|
+
async function getWindowsStorageInfo(path14) {
|
|
150714
150877
|
try {
|
|
150715
|
-
const drive = `${
|
|
150878
|
+
const drive = `${path14.split(":")[0]}:`;
|
|
150716
150879
|
const { stdout } = await execAsync(
|
|
150717
150880
|
`powershell -Command "Get-PSDrive -Name '${drive.replace(":", "")}' | Select-Object Used,Free | ConvertTo-Json"`
|
|
150718
150881
|
);
|
|
@@ -150723,7 +150886,7 @@ async function getWindowsStorageInfo(path13) {
|
|
|
150723
150886
|
return { total, used, free };
|
|
150724
150887
|
} catch {
|
|
150725
150888
|
try {
|
|
150726
|
-
const drive = `${
|
|
150889
|
+
const drive = `${path14.split(":")[0]}:`;
|
|
150727
150890
|
const { stdout } = await execAsync(
|
|
150728
150891
|
`wmic logicaldisk where "DeviceID='${drive}'" get Size,FreeSpace /format:csv`
|
|
150729
150892
|
);
|
|
@@ -150740,9 +150903,9 @@ async function getWindowsStorageInfo(path13) {
|
|
|
150740
150903
|
return { total: 0, used: 0, free: 0 };
|
|
150741
150904
|
}
|
|
150742
150905
|
}
|
|
150743
|
-
async function getUnixStorageInfo(
|
|
150906
|
+
async function getUnixStorageInfo(path14) {
|
|
150744
150907
|
try {
|
|
150745
|
-
const { stdout } = await execAsync(`df -Pk "${
|
|
150908
|
+
const { stdout } = await execAsync(`df -Pk "${path14}" 2>/dev/null`);
|
|
150746
150909
|
const lines = stdout.trim().split("\n");
|
|
150747
150910
|
if (lines.length >= 2) {
|
|
150748
150911
|
const parts = lines[1].split(/\s+/);
|
|
@@ -150917,7 +151080,7 @@ var WebSocketApi = class {
|
|
|
150917
151080
|
|
|
150918
151081
|
// src/api/web-api.ts
|
|
150919
151082
|
var WebApi = class extends Service {
|
|
150920
|
-
constructor(logger203, bridgeService, haClient, haRegistry, bridgeStorage, mappingStorage, lockCredentialStorage, settingsStorage, props) {
|
|
151083
|
+
constructor(logger203, bridgeService, haClient, haRegistry, bridgeStorage, mappingStorage, lockCredentialStorage, settingsStorage, backupService, props) {
|
|
150921
151084
|
super("WebApi");
|
|
150922
151085
|
this.bridgeService = bridgeService;
|
|
150923
151086
|
this.haClient = haClient;
|
|
@@ -150926,6 +151089,7 @@ var WebApi = class extends Service {
|
|
|
150926
151089
|
this.mappingStorage = mappingStorage;
|
|
150927
151090
|
this.lockCredentialStorage = lockCredentialStorage;
|
|
150928
151091
|
this.settingsStorage = settingsStorage;
|
|
151092
|
+
this.backupService = backupService;
|
|
150929
151093
|
this.props = props;
|
|
150930
151094
|
this.logger = logger203;
|
|
150931
151095
|
this.log = logger203.get(this);
|
|
@@ -150965,7 +151129,9 @@ var WebApi = class extends Service {
|
|
|
150965
151129
|
backupApi(
|
|
150966
151130
|
this.bridgeStorage,
|
|
150967
151131
|
this.mappingStorage,
|
|
150968
|
-
this.props.storageLocation
|
|
151132
|
+
this.props.storageLocation,
|
|
151133
|
+
this.backupService,
|
|
151134
|
+
this.settingsStorage
|
|
150969
151135
|
)
|
|
150970
151136
|
).use("/home-assistant", homeAssistantApi(this.haRegistry, this.haClient)).use("/logs", logsApi(this.logger)).use("/system", systemApi(this.props.version)).use(
|
|
150971
151137
|
"/diagnostic",
|
|
@@ -151279,8 +151445,8 @@ init_dist();
|
|
|
151279
151445
|
init_esm6();
|
|
151280
151446
|
import { pickBy } from "lodash-es";
|
|
151281
151447
|
var LegacyCustomStorage = class extends StorageBackendJsonFile {
|
|
151282
|
-
constructor(log,
|
|
151283
|
-
super(
|
|
151448
|
+
constructor(log, path14) {
|
|
151449
|
+
super(path14);
|
|
151284
151450
|
this.log = log;
|
|
151285
151451
|
const parser = this;
|
|
151286
151452
|
const serialize2 = parser.toJson.bind(parser);
|
|
@@ -151294,7 +151460,7 @@ var LegacyCustomStorage = class extends StorageBackendJsonFile {
|
|
|
151294
151460
|
return this.removeClusters(object, Object.values(ClusterId2));
|
|
151295
151461
|
} catch (e) {
|
|
151296
151462
|
this.log.error(
|
|
151297
|
-
`Failed to parse json file '${
|
|
151463
|
+
`Failed to parse json file '${path14}' with content:
|
|
151298
151464
|
|
|
151299
151465
|
${json}
|
|
151300
151466
|
|
|
@@ -151308,7 +151474,7 @@ ${json}
|
|
|
151308
151474
|
this.removeClusters(object, [ClusterId2.homeAssistantEntity])
|
|
151309
151475
|
);
|
|
151310
151476
|
if (json.trim().length === 0) {
|
|
151311
|
-
throw new Error(`Tried to write empty storage to ${
|
|
151477
|
+
throw new Error(`Tried to write empty storage to ${path14}`);
|
|
151312
151478
|
}
|
|
151313
151479
|
return json;
|
|
151314
151480
|
};
|
|
@@ -151326,10 +151492,10 @@ ${json}
|
|
|
151326
151492
|
|
|
151327
151493
|
// src/core/app/storage/custom-storage.ts
|
|
151328
151494
|
var CustomStorage = class extends StorageBackendDisk {
|
|
151329
|
-
constructor(log,
|
|
151330
|
-
super(
|
|
151495
|
+
constructor(log, path14) {
|
|
151496
|
+
super(path14);
|
|
151331
151497
|
this.log = log;
|
|
151332
|
-
this.path =
|
|
151498
|
+
this.path = path14;
|
|
151333
151499
|
}
|
|
151334
151500
|
async initialize() {
|
|
151335
151501
|
await super.initialize();
|
|
@@ -151346,11 +151512,11 @@ var CustomStorage = class extends StorageBackendDisk {
|
|
|
151346
151512
|
return await super.keys(contexts);
|
|
151347
151513
|
}
|
|
151348
151514
|
async migrateLegacyStorage() {
|
|
151349
|
-
const
|
|
151515
|
+
const path14 = this.path;
|
|
151350
151516
|
this.log.warn(
|
|
151351
|
-
`Migrating legacy storage (JSON file) to new storage (directory): ${
|
|
151517
|
+
`Migrating legacy storage (JSON file) to new storage (directory): ${path14}`
|
|
151352
151518
|
);
|
|
151353
|
-
const legacyStorage = new LegacyCustomStorage(this.log, `${
|
|
151519
|
+
const legacyStorage = new LegacyCustomStorage(this.log, `${path14}.json`);
|
|
151354
151520
|
legacyStorage.initialize();
|
|
151355
151521
|
forEach(legacyStorage.data, (values4, context) => {
|
|
151356
151522
|
forEach(values4, (value, key) => {
|
|
@@ -151358,7 +151524,7 @@ var CustomStorage = class extends StorageBackendDisk {
|
|
|
151358
151524
|
});
|
|
151359
151525
|
});
|
|
151360
151526
|
await legacyStorage.close();
|
|
151361
|
-
fs7.renameSync(`${
|
|
151527
|
+
fs7.renameSync(`${path14}.json`, `${path14}/backup.alpha-69.json`);
|
|
151362
151528
|
}
|
|
151363
151529
|
};
|
|
151364
151530
|
|
|
@@ -151494,6 +151660,201 @@ function notEmpty(val) {
|
|
|
151494
151660
|
// src/core/ioc/app-environment.ts
|
|
151495
151661
|
init_esm7();
|
|
151496
151662
|
|
|
151663
|
+
// src/services/backup/backup-service.ts
|
|
151664
|
+
init_esm();
|
|
151665
|
+
import fs9 from "node:fs";
|
|
151666
|
+
import path10 from "node:path";
|
|
151667
|
+
import archiver2 from "archiver";
|
|
151668
|
+
var BackupService = class {
|
|
151669
|
+
constructor(bridgeStorage, mappingStorage, settingsStorage, props) {
|
|
151670
|
+
this.bridgeStorage = bridgeStorage;
|
|
151671
|
+
this.mappingStorage = mappingStorage;
|
|
151672
|
+
this.settingsStorage = settingsStorage;
|
|
151673
|
+
this.props = props;
|
|
151674
|
+
this.backupDir = path10.join(props.storageLocation, "backups");
|
|
151675
|
+
fs9.mkdirSync(this.backupDir, { recursive: true });
|
|
151676
|
+
}
|
|
151677
|
+
log = Logger.get("BackupService");
|
|
151678
|
+
backupDir;
|
|
151679
|
+
async createBackup(auto) {
|
|
151680
|
+
const now = /* @__PURE__ */ new Date();
|
|
151681
|
+
const version = this.props.appVersion;
|
|
151682
|
+
const dateStr = now.toISOString().replace(/T/, "_").replace(/:/g, "-").replace(/\.\d+Z$/, "");
|
|
151683
|
+
const prefix = auto ? "auto" : "manual";
|
|
151684
|
+
const filename = `hamh-${prefix}-${version}-${dateStr}.zip`;
|
|
151685
|
+
const filepath = path10.join(this.backupDir, filename);
|
|
151686
|
+
const bridges = this.bridgeStorage.bridges;
|
|
151687
|
+
const entityMappings = {};
|
|
151688
|
+
for (const bridge of bridges) {
|
|
151689
|
+
const mappings = this.mappingStorage.getMappingsForBridge(bridge.id);
|
|
151690
|
+
if (mappings.length > 0) {
|
|
151691
|
+
entityMappings[bridge.id] = mappings;
|
|
151692
|
+
}
|
|
151693
|
+
}
|
|
151694
|
+
let includesIcons = false;
|
|
151695
|
+
const iconsDir = path10.join(this.props.storageLocation, "bridge-icons");
|
|
151696
|
+
if (fs9.existsSync(iconsDir)) {
|
|
151697
|
+
const iconFiles = fs9.readdirSync(iconsDir);
|
|
151698
|
+
includesIcons = iconFiles.some((f) => {
|
|
151699
|
+
const bridgeId = f.split(".")[0];
|
|
151700
|
+
return bridges.some((b) => b.id === bridgeId);
|
|
151701
|
+
});
|
|
151702
|
+
}
|
|
151703
|
+
const backupData = {
|
|
151704
|
+
version: 2,
|
|
151705
|
+
createdAt: now.toISOString(),
|
|
151706
|
+
bridges,
|
|
151707
|
+
entityMappings,
|
|
151708
|
+
includesIdentity: true,
|
|
151709
|
+
includesIcons,
|
|
151710
|
+
appVersion: version,
|
|
151711
|
+
auto
|
|
151712
|
+
};
|
|
151713
|
+
await new Promise((resolve6, reject) => {
|
|
151714
|
+
const output = fs9.createWriteStream(filepath);
|
|
151715
|
+
const archive = archiver2("zip", { zlib: { level: 9 } });
|
|
151716
|
+
output.on("close", () => resolve6());
|
|
151717
|
+
archive.on("error", (err) => reject(err));
|
|
151718
|
+
archive.pipe(output);
|
|
151719
|
+
archive.append(JSON.stringify(backupData, null, 2), {
|
|
151720
|
+
name: "backup.json"
|
|
151721
|
+
});
|
|
151722
|
+
archive.append(
|
|
151723
|
+
[
|
|
151724
|
+
"Home Assistant Matter Hub Backup",
|
|
151725
|
+
`Created: ${backupData.createdAt}`,
|
|
151726
|
+
`Version: ${version}`,
|
|
151727
|
+
`Type: ${auto ? "Automatic" : "Manual"}`,
|
|
151728
|
+
`Bridges: ${bridges.length}`,
|
|
151729
|
+
`Includes Identity: true`,
|
|
151730
|
+
`Includes Icons: ${includesIcons}`,
|
|
151731
|
+
"",
|
|
151732
|
+
"WARNING: This backup contains sensitive Matter identity data (keypairs, fabric credentials). Keep it secure!",
|
|
151733
|
+
""
|
|
151734
|
+
].join("\n"),
|
|
151735
|
+
{ name: "README.txt" }
|
|
151736
|
+
);
|
|
151737
|
+
for (const bridge of bridges) {
|
|
151738
|
+
const bridgeStoragePath = path10.join(
|
|
151739
|
+
this.props.storageLocation,
|
|
151740
|
+
bridge.id
|
|
151741
|
+
);
|
|
151742
|
+
if (fs9.existsSync(bridgeStoragePath)) {
|
|
151743
|
+
archive.directory(bridgeStoragePath, `identity/${bridge.id}`);
|
|
151744
|
+
}
|
|
151745
|
+
}
|
|
151746
|
+
if (includesIcons) {
|
|
151747
|
+
const iconFiles = fs9.readdirSync(iconsDir);
|
|
151748
|
+
for (const iconFile of iconFiles) {
|
|
151749
|
+
const bridgeId = iconFile.split(".")[0];
|
|
151750
|
+
if (bridges.some((b) => b.id === bridgeId)) {
|
|
151751
|
+
archive.file(path10.join(iconsDir, iconFile), {
|
|
151752
|
+
name: `bridge-icons/${iconFile}`
|
|
151753
|
+
});
|
|
151754
|
+
}
|
|
151755
|
+
}
|
|
151756
|
+
}
|
|
151757
|
+
archive.finalize();
|
|
151758
|
+
});
|
|
151759
|
+
const stat = fs9.statSync(filepath);
|
|
151760
|
+
const metadata = {
|
|
151761
|
+
filename,
|
|
151762
|
+
version,
|
|
151763
|
+
createdAt: now.toISOString(),
|
|
151764
|
+
sizeBytes: stat.size,
|
|
151765
|
+
auto
|
|
151766
|
+
};
|
|
151767
|
+
this.log.info(
|
|
151768
|
+
`Backup created: ${filename} (${Math.round(stat.size / 1024)} KB)`
|
|
151769
|
+
);
|
|
151770
|
+
await this.enforceRetention();
|
|
151771
|
+
return metadata;
|
|
151772
|
+
}
|
|
151773
|
+
async createAutoBackup() {
|
|
151774
|
+
const settings = this.settingsStorage.backupSettings;
|
|
151775
|
+
if (!settings.autoBackup) {
|
|
151776
|
+
this.log.debug("Auto-backup disabled, skipping");
|
|
151777
|
+
return null;
|
|
151778
|
+
}
|
|
151779
|
+
try {
|
|
151780
|
+
return await this.createBackup(true);
|
|
151781
|
+
} catch (e) {
|
|
151782
|
+
this.log.error("Auto-backup failed:", e);
|
|
151783
|
+
return null;
|
|
151784
|
+
}
|
|
151785
|
+
}
|
|
151786
|
+
listBackups() {
|
|
151787
|
+
if (!fs9.existsSync(this.backupDir)) {
|
|
151788
|
+
return [];
|
|
151789
|
+
}
|
|
151790
|
+
const files = fs9.readdirSync(this.backupDir).filter((f) => f.startsWith("hamh-") && f.endsWith(".zip"));
|
|
151791
|
+
return files.map((filename) => {
|
|
151792
|
+
try {
|
|
151793
|
+
const stat = fs9.statSync(path10.join(this.backupDir, filename));
|
|
151794
|
+
const parsed = this.parseFilename(filename);
|
|
151795
|
+
return {
|
|
151796
|
+
filename,
|
|
151797
|
+
version: parsed.version,
|
|
151798
|
+
createdAt: stat.mtime.toISOString(),
|
|
151799
|
+
sizeBytes: stat.size,
|
|
151800
|
+
auto: parsed.auto
|
|
151801
|
+
};
|
|
151802
|
+
} catch {
|
|
151803
|
+
return null;
|
|
151804
|
+
}
|
|
151805
|
+
}).filter((m) => m !== null).sort(
|
|
151806
|
+
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
151807
|
+
);
|
|
151808
|
+
}
|
|
151809
|
+
getBackupPath(filename) {
|
|
151810
|
+
if (filename.includes("..") || filename.includes("/")) {
|
|
151811
|
+
return null;
|
|
151812
|
+
}
|
|
151813
|
+
const filepath = path10.join(this.backupDir, filename);
|
|
151814
|
+
if (!fs9.existsSync(filepath)) {
|
|
151815
|
+
return null;
|
|
151816
|
+
}
|
|
151817
|
+
return filepath;
|
|
151818
|
+
}
|
|
151819
|
+
deleteBackup(filename) {
|
|
151820
|
+
const filepath = this.getBackupPath(filename);
|
|
151821
|
+
if (!filepath) return false;
|
|
151822
|
+
try {
|
|
151823
|
+
fs9.unlinkSync(filepath);
|
|
151824
|
+
this.log.info(`Backup deleted: ${filename}`);
|
|
151825
|
+
return true;
|
|
151826
|
+
} catch (e) {
|
|
151827
|
+
this.log.error(`Failed to delete backup ${filename}:`, e);
|
|
151828
|
+
return false;
|
|
151829
|
+
}
|
|
151830
|
+
}
|
|
151831
|
+
async enforceRetention() {
|
|
151832
|
+
const settings = this.settingsStorage.backupSettings;
|
|
151833
|
+
const maxCount = settings.backupRetentionCount;
|
|
151834
|
+
if (maxCount <= 0) return;
|
|
151835
|
+
const backups = this.listBackups();
|
|
151836
|
+
if (backups.length <= maxCount) return;
|
|
151837
|
+
const toDelete = backups.slice(maxCount);
|
|
151838
|
+
for (const backup of toDelete) {
|
|
151839
|
+
this.deleteBackup(backup.filename);
|
|
151840
|
+
}
|
|
151841
|
+
if (toDelete.length > 0) {
|
|
151842
|
+
this.log.info(
|
|
151843
|
+
`Retention: deleted ${toDelete.length} old backup(s), keeping ${maxCount}`
|
|
151844
|
+
);
|
|
151845
|
+
}
|
|
151846
|
+
}
|
|
151847
|
+
parseFilename(filename) {
|
|
151848
|
+
const auto = filename.startsWith("hamh-auto-");
|
|
151849
|
+
const withoutPrefix = filename.replace(/^hamh-(auto|manual)-/, "").replace(/\.zip$/, "");
|
|
151850
|
+
const dateMatch = withoutPrefix.match(
|
|
151851
|
+
/^(.+)-(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})$/
|
|
151852
|
+
);
|
|
151853
|
+
const version = dateMatch ? dateMatch[1] : withoutPrefix;
|
|
151854
|
+
return { version, auto };
|
|
151855
|
+
}
|
|
151856
|
+
};
|
|
151857
|
+
|
|
151497
151858
|
// src/services/bridges/bridge-factory.ts
|
|
151498
151859
|
init_service();
|
|
151499
151860
|
var BridgeFactory = class extends Service {
|
|
@@ -152009,6 +152370,10 @@ function mockDeviceId(entityId) {
|
|
|
152009
152370
|
|
|
152010
152371
|
// src/services/storage/app-settings-storage.ts
|
|
152011
152372
|
init_service();
|
|
152373
|
+
var DEFAULT_BACKUP_SETTINGS = {
|
|
152374
|
+
autoBackup: true,
|
|
152375
|
+
backupRetentionCount: 5
|
|
152376
|
+
};
|
|
152012
152377
|
var AppSettingsStorage = class extends Service {
|
|
152013
152378
|
constructor(appStorage) {
|
|
152014
152379
|
super("AppSettingsStorage");
|
|
@@ -152031,6 +152396,13 @@ var AppSettingsStorage = class extends Service {
|
|
|
152031
152396
|
this.settings.auth = auth;
|
|
152032
152397
|
await this.persist();
|
|
152033
152398
|
}
|
|
152399
|
+
get backupSettings() {
|
|
152400
|
+
return { ...DEFAULT_BACKUP_SETTINGS, ...this.settings.backup };
|
|
152401
|
+
}
|
|
152402
|
+
async setBackupSettings(settings) {
|
|
152403
|
+
this.settings.backup = { ...this.settings.backup, ...settings };
|
|
152404
|
+
await this.persist();
|
|
152405
|
+
}
|
|
152034
152406
|
async persist() {
|
|
152035
152407
|
await this.storage.set(
|
|
152036
152408
|
"data",
|
|
@@ -164315,8 +164687,8 @@ var ServerModeServerNode = class extends ServerNode {
|
|
|
164315
164687
|
|
|
164316
164688
|
// src/plugins/plugin-manager.ts
|
|
164317
164689
|
init_esm();
|
|
164318
|
-
import * as
|
|
164319
|
-
import * as
|
|
164690
|
+
import * as fs11 from "node:fs";
|
|
164691
|
+
import * as path12 from "node:path";
|
|
164320
164692
|
|
|
164321
164693
|
// src/plugins/plugin-device-factory.ts
|
|
164322
164694
|
init_esm();
|
|
@@ -165582,8 +165954,8 @@ function getSupportedPluginDeviceTypes() {
|
|
|
165582
165954
|
|
|
165583
165955
|
// src/plugins/plugin-storage.ts
|
|
165584
165956
|
init_esm();
|
|
165585
|
-
import * as
|
|
165586
|
-
import * as
|
|
165957
|
+
import * as fs10 from "node:fs";
|
|
165958
|
+
import * as path11 from "node:path";
|
|
165587
165959
|
var logger160 = Logger.get("PluginStorage");
|
|
165588
165960
|
var FilePluginStorage = class {
|
|
165589
165961
|
data = {};
|
|
@@ -165591,7 +165963,7 @@ var FilePluginStorage = class {
|
|
|
165591
165963
|
filePath;
|
|
165592
165964
|
constructor(storageDir, pluginName) {
|
|
165593
165965
|
const safePluginName = pluginName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
165594
|
-
this.filePath =
|
|
165966
|
+
this.filePath = path11.join(storageDir, `plugin-${safePluginName}.json`);
|
|
165595
165967
|
this.load();
|
|
165596
165968
|
}
|
|
165597
165969
|
async get(key, defaultValue) {
|
|
@@ -165613,8 +165985,8 @@ var FilePluginStorage = class {
|
|
|
165613
165985
|
}
|
|
165614
165986
|
load() {
|
|
165615
165987
|
try {
|
|
165616
|
-
if (
|
|
165617
|
-
const raw =
|
|
165988
|
+
if (fs10.existsSync(this.filePath)) {
|
|
165989
|
+
const raw = fs10.readFileSync(this.filePath, "utf-8");
|
|
165618
165990
|
this.data = JSON.parse(raw);
|
|
165619
165991
|
}
|
|
165620
165992
|
} catch (e) {
|
|
@@ -165625,11 +165997,11 @@ var FilePluginStorage = class {
|
|
|
165625
165997
|
save() {
|
|
165626
165998
|
if (!this.dirty) return;
|
|
165627
165999
|
try {
|
|
165628
|
-
const dir =
|
|
165629
|
-
if (!
|
|
165630
|
-
|
|
166000
|
+
const dir = path11.dirname(this.filePath);
|
|
166001
|
+
if (!fs10.existsSync(dir)) {
|
|
166002
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
165631
166003
|
}
|
|
165632
|
-
|
|
166004
|
+
fs10.writeFileSync(this.filePath, JSON.stringify(this.data, null, 2));
|
|
165633
166005
|
this.dirty = false;
|
|
165634
166006
|
} catch (e) {
|
|
165635
166007
|
logger160.warn(`Failed to save plugin storage to ${this.filePath}:`, e);
|
|
@@ -165806,13 +166178,13 @@ var PluginManager = class {
|
|
|
165806
166178
|
*/
|
|
165807
166179
|
async loadExternal(packagePath, config10) {
|
|
165808
166180
|
try {
|
|
165809
|
-
const pkgJsonPath =
|
|
165810
|
-
if (!
|
|
166181
|
+
const pkgJsonPath = path12.join(packagePath, "package.json");
|
|
166182
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
165811
166183
|
throw new Error(`Plugin at ${packagePath} has no package.json`);
|
|
165812
166184
|
}
|
|
165813
166185
|
let manifest;
|
|
165814
166186
|
try {
|
|
165815
|
-
manifest = JSON.parse(
|
|
166187
|
+
manifest = JSON.parse(fs11.readFileSync(pkgJsonPath, "utf-8"));
|
|
165816
166188
|
} catch {
|
|
165817
166189
|
throw new Error(`Plugin at ${packagePath} has invalid package.json`);
|
|
165818
166190
|
}
|
|
@@ -179764,6 +180136,18 @@ var AppEnvironment = class _AppEnvironment extends EnvironmentBase {
|
|
|
179764
180136
|
this.options.bridgeService
|
|
179765
180137
|
)
|
|
179766
180138
|
);
|
|
180139
|
+
this.set(
|
|
180140
|
+
BackupService,
|
|
180141
|
+
new BackupService(
|
|
180142
|
+
await this.load(BridgeStorage),
|
|
180143
|
+
await this.load(EntityMappingStorage),
|
|
180144
|
+
await this.load(AppSettingsStorage),
|
|
180145
|
+
{
|
|
180146
|
+
storageLocation: this.options.webApi.storageLocation,
|
|
180147
|
+
appVersion: this.options.webApi.version
|
|
180148
|
+
}
|
|
180149
|
+
)
|
|
180150
|
+
);
|
|
179767
180151
|
this.set(
|
|
179768
180152
|
WebApi,
|
|
179769
180153
|
new WebApi(
|
|
@@ -179775,6 +180159,7 @@ var AppEnvironment = class _AppEnvironment extends EnvironmentBase {
|
|
|
179775
180159
|
await this.load(EntityMappingStorage),
|
|
179776
180160
|
await this.load(LockCredentialStorage),
|
|
179777
180161
|
await this.load(AppSettingsStorage),
|
|
180162
|
+
await this.load(BackupService),
|
|
179778
180163
|
this.options.webApi
|
|
179779
180164
|
)
|
|
179780
180165
|
);
|
|
@@ -179891,7 +180276,12 @@ async function startHandler(startOptions, webUiDist) {
|
|
|
179891
180276
|
const bridgeService$ = appEnvironment.load(BridgeService);
|
|
179892
180277
|
const webApi$ = appEnvironment.load(WebApi);
|
|
179893
180278
|
const registry$ = appEnvironment.load(HomeAssistantRegistry);
|
|
179894
|
-
const
|
|
180279
|
+
const backupService$ = appEnvironment.load(BackupService);
|
|
180280
|
+
const [bridgeService, webApi, backupService] = await Promise.all([
|
|
180281
|
+
bridgeService$,
|
|
180282
|
+
webApi$,
|
|
180283
|
+
backupService$
|
|
180284
|
+
]);
|
|
179895
180285
|
bridgeService.onBridgeChanged = (bridgeId) => {
|
|
179896
180286
|
webApi.websocket.broadcastBridgeUpdate(bridgeId);
|
|
179897
180287
|
};
|
|
@@ -179900,6 +180290,14 @@ async function startHandler(startOptions, webUiDist) {
|
|
|
179900
180290
|
if (shuttingDown) return;
|
|
179901
180291
|
shuttingDown = true;
|
|
179902
180292
|
console.log(`Received ${signal}, shutting down gracefully...`);
|
|
180293
|
+
try {
|
|
180294
|
+
await Promise.race([
|
|
180295
|
+
backupService.createAutoBackup(),
|
|
180296
|
+
new Promise((resolve6) => setTimeout(resolve6, 5e3))
|
|
180297
|
+
]);
|
|
180298
|
+
} catch (e) {
|
|
180299
|
+
console.warn("Auto-backup during shutdown failed:", e);
|
|
180300
|
+
}
|
|
179903
180301
|
try {
|
|
179904
180302
|
await Promise.race([
|
|
179905
180303
|
bridgeService.dispose(),
|
|
@@ -179919,7 +180317,7 @@ async function startHandler(startOptions, webUiDist) {
|
|
|
179919
180317
|
}
|
|
179920
180318
|
|
|
179921
180319
|
// src/commands/start/start-options-builder.ts
|
|
179922
|
-
import
|
|
180320
|
+
import fs12 from "node:fs";
|
|
179923
180321
|
function startOptionsBuilder(yargs2) {
|
|
179924
180322
|
return yargs2.env("HAMH").version(false).config(
|
|
179925
180323
|
"config",
|
|
@@ -179928,10 +180326,10 @@ function startOptionsBuilder(yargs2) {
|
|
|
179928
180326
|
if (configPath.trim() === "") {
|
|
179929
180327
|
return {};
|
|
179930
180328
|
}
|
|
179931
|
-
if (!
|
|
180329
|
+
if (!fs12.existsSync(configPath)) {
|
|
179932
180330
|
throw new Error(`Config file '${configPath}' does not exist!`);
|
|
179933
180331
|
}
|
|
179934
|
-
return JSON.parse(
|
|
180332
|
+
return JSON.parse(fs12.readFileSync(configPath, "utf-8"));
|
|
179935
180333
|
}
|
|
179936
180334
|
).option("log-level", {
|
|
179937
180335
|
type: "string",
|
|
@@ -179993,7 +180391,7 @@ function startCommand(webDist) {
|
|
|
179993
180391
|
// src/cli.ts
|
|
179994
180392
|
var dirname4 = import.meta.dirname ?? url.fileURLToPath(new URL(".", import.meta.url));
|
|
179995
180393
|
async function cli(argv) {
|
|
179996
|
-
const webDist = process.env.NODE_ENV === "development" ? void 0 :
|
|
180394
|
+
const webDist = process.env.NODE_ENV === "development" ? void 0 : path13.join(dirname4, "../frontend");
|
|
179997
180395
|
const cli2 = yargs(hideBin(argv));
|
|
179998
180396
|
cli2.scriptName("home-assistant-matter-hub").version().strict().recommendCommands().detectLocale(false).help().command(startCommand(webDist)).demandCommand().wrap(Math.min(140, cli2.terminalWidth())).parse();
|
|
179999
180397
|
}
|