@matter/protocol 0.13.1-alpha.0-20250520-d699cd56d → 0.14.0-alpha.0-20250524-51a7e1721
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/cjs/action/Interactable.d.ts +1 -1
- package/dist/cjs/action/Interactable.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts +1 -1
- package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/cjs/action/client/ClientInteraction.js +50 -8
- package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +49 -15
- package/dist/cjs/action/protocols.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.d.ts +10 -1
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
- package/dist/cjs/action/request/Invoke.js +17 -5
- package/dist/cjs/action/request/Invoke.js.map +1 -1
- package/dist/cjs/action/request/Read.d.ts.map +1 -1
- package/dist/cjs/action/request/Read.js +1 -1
- package/dist/cjs/action/request/Read.js.map +1 -1
- package/dist/cjs/action/request/Write.d.ts +2 -0
- package/dist/cjs/action/request/Write.d.ts.map +1 -1
- package/dist/cjs/action/request/Write.js.map +1 -1
- package/dist/cjs/action/response/InvokeResult.d.ts +22 -6
- package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +1 -2
- package/dist/cjs/action/server/AttributeReadResponse.js.map +2 -2
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +1 -14
- package/dist/cjs/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts +25 -0
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts.map +1 -0
- package/dist/cjs/action/server/CommandInvokeResponse.js +331 -0
- package/dist/cjs/action/server/CommandInvokeResponse.js.map +6 -0
- package/dist/cjs/action/server/EventReadResponse.js +1 -1
- package/dist/cjs/action/server/ServerInteraction.d.ts +1 -3
- package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/cjs/action/server/ServerInteraction.js +4 -2
- package/dist/cjs/action/server/ServerInteraction.js.map +1 -1
- package/dist/cjs/action/server/index.d.ts +1 -0
- package/dist/cjs/action/server/index.d.ts.map +1 -1
- package/dist/cjs/action/server/index.js +1 -0
- package/dist/cjs/action/server/index.js.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.d.ts +2 -0
- package/dist/cjs/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/cjs/cluster/client/AttributeClient.js +10 -0
- package/dist/cjs/cluster/client/AttributeClient.js.map +1 -1
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts +0 -4
- package/dist/cjs/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/cjs/cluster/index.d.ts +0 -1
- package/dist/cjs/cluster/index.d.ts.map +1 -1
- package/dist/cjs/cluster/index.js +0 -1
- package/dist/cjs/cluster/index.js.map +1 -1
- package/dist/cjs/events/OccurrenceManager.d.ts +10 -2
- package/dist/cjs/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/cjs/events/OccurrenceManager.js +57 -11
- package/dist/cjs/events/OccurrenceManager.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +2 -11
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +1 -38
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/cjs/interaction/InteractionClient.d.ts +13 -0
- package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionClient.js +14 -0
- package/dist/cjs/interaction/InteractionClient.js.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +8 -8
- package/dist/cjs/interaction/index.d.ts +0 -1
- package/dist/cjs/interaction/index.d.ts.map +1 -1
- package/dist/cjs/interaction/index.js +0 -1
- package/dist/cjs/interaction/index.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts +23 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js +124 -11
- package/dist/cjs/mdns/MdnsScanner.js.map +2 -2
- package/dist/esm/action/Interactable.d.ts +1 -1
- package/dist/esm/action/Interactable.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts +1 -1
- package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
- package/dist/esm/action/client/ClientInteraction.js +50 -8
- package/dist/esm/action/client/ClientInteraction.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +49 -15
- package/dist/esm/action/protocols.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.d.ts +10 -1
- package/dist/esm/action/request/Invoke.d.ts.map +1 -1
- package/dist/esm/action/request/Invoke.js +17 -5
- package/dist/esm/action/request/Invoke.js.map +1 -1
- package/dist/esm/action/request/Read.d.ts.map +1 -1
- package/dist/esm/action/request/Read.js +1 -1
- package/dist/esm/action/request/Read.js.map +1 -1
- package/dist/esm/action/request/Write.d.ts +2 -0
- package/dist/esm/action/request/Write.d.ts.map +1 -1
- package/dist/esm/action/request/Write.js.map +1 -1
- package/dist/esm/action/response/InvokeResult.d.ts +22 -6
- package/dist/esm/action/response/InvokeResult.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts.map +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +2 -15
- package/dist/esm/action/server/AttributeWriteResponse.js.map +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.d.ts +25 -0
- package/dist/esm/action/server/CommandInvokeResponse.d.ts.map +1 -0
- package/dist/esm/action/server/CommandInvokeResponse.js +317 -0
- package/dist/esm/action/server/CommandInvokeResponse.js.map +6 -0
- package/dist/esm/action/server/EventReadResponse.js +1 -1
- package/dist/esm/action/server/ServerInteraction.d.ts +1 -3
- package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -1
- package/dist/esm/action/server/ServerInteraction.js +4 -2
- package/dist/esm/action/server/ServerInteraction.js.map +1 -1
- package/dist/esm/action/server/index.d.ts +1 -0
- package/dist/esm/action/server/index.d.ts.map +1 -1
- package/dist/esm/action/server/index.js +1 -0
- package/dist/esm/action/server/index.js.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.d.ts +2 -0
- package/dist/esm/cluster/client/AttributeClient.d.ts.map +1 -1
- package/dist/esm/cluster/client/AttributeClient.js +10 -0
- package/dist/esm/cluster/client/AttributeClient.js.map +1 -1
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts +0 -4
- package/dist/esm/cluster/client/ClusterClientTypes.d.ts.map +1 -1
- package/dist/esm/cluster/index.d.ts +0 -1
- package/dist/esm/cluster/index.d.ts.map +1 -1
- package/dist/esm/cluster/index.js +0 -1
- package/dist/esm/cluster/index.js.map +1 -1
- package/dist/esm/events/OccurrenceManager.d.ts +10 -2
- package/dist/esm/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/esm/events/OccurrenceManager.js +62 -12
- package/dist/esm/events/OccurrenceManager.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +2 -11
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +1 -38
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.d.ts +1 -1
- package/dist/esm/interaction/InteractionClient.d.ts +13 -0
- package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionClient.js +14 -0
- package/dist/esm/interaction/InteractionClient.js.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +8 -8
- package/dist/esm/interaction/index.d.ts +0 -1
- package/dist/esm/interaction/index.d.ts.map +1 -1
- package/dist/esm/interaction/index.js +0 -1
- package/dist/esm/interaction/index.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts +23 -1
- package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js +127 -11
- package/dist/esm/mdns/MdnsScanner.js.map +2 -2
- package/package.json +6 -6
- package/src/action/Interactable.ts +1 -1
- package/src/action/client/ClientInteraction.ts +53 -16
- package/src/action/protocols.ts +70 -16
- package/src/action/request/Invoke.ts +32 -5
- package/src/action/request/Read.ts +1 -1
- package/src/action/request/Write.ts +4 -1
- package/src/action/response/InvokeResult.ts +26 -6
- package/src/action/response/ReadResult.ts +1 -1
- package/src/action/server/AttributeReadResponse.ts +1 -1
- package/src/action/server/AttributeWriteResponse.ts +2 -20
- package/src/action/server/CommandInvokeResponse.ts +427 -0
- package/src/action/server/EventReadResponse.ts +1 -1
- package/src/action/server/ServerInteraction.ts +6 -5
- package/src/action/server/index.ts +1 -0
- package/src/cluster/client/AttributeClient.ts +12 -0
- package/src/cluster/client/ClusterClientTypes.ts +0 -6
- package/src/cluster/index.ts +0 -1
- package/src/events/OccurrenceManager.ts +91 -11
- package/src/fabric/Fabric.ts +1 -49
- package/src/index.ts +0 -1
- package/src/interaction/InteractionClient.ts +24 -0
- package/src/interaction/index.ts +0 -1
- package/src/mdns/MdnsScanner.ts +187 -12
- package/dist/cjs/cluster/server/AttributeServer.d.ts +0 -307
- package/dist/cjs/cluster/server/AttributeServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/AttributeServer.js +0 -736
- package/dist/cjs/cluster/server/AttributeServer.js.map +0 -6
- package/dist/cjs/cluster/server/ClusterDatasource.d.ts +0 -16
- package/dist/cjs/cluster/server/ClusterDatasource.d.ts.map +0 -1
- package/dist/cjs/cluster/server/ClusterDatasource.js +0 -22
- package/dist/cjs/cluster/server/ClusterDatasource.js.map +0 -6
- package/dist/cjs/cluster/server/ClusterServer.d.ts +0 -40
- package/dist/cjs/cluster/server/ClusterServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/ClusterServer.js +0 -22
- package/dist/cjs/cluster/server/ClusterServer.js.map +0 -6
- package/dist/cjs/cluster/server/CommandServer.d.ts +0 -34
- package/dist/cjs/cluster/server/CommandServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/CommandServer.js +0 -76
- package/dist/cjs/cluster/server/CommandServer.js.map +0 -6
- package/dist/cjs/cluster/server/EventServer.d.ts +0 -42
- package/dist/cjs/cluster/server/EventServer.d.ts.map +0 -1
- package/dist/cjs/cluster/server/EventServer.js +0 -152
- package/dist/cjs/cluster/server/EventServer.js.map +0 -6
- package/dist/cjs/cluster/server/index.d.ts +0 -11
- package/dist/cjs/cluster/server/index.d.ts.map +0 -1
- package/dist/cjs/cluster/server/index.js +0 -28
- package/dist/cjs/cluster/server/index.js.map +0 -6
- package/dist/cjs/endpoint/EndpointInterface.d.ts +0 -37
- package/dist/cjs/endpoint/EndpointInterface.d.ts.map +0 -1
- package/dist/cjs/endpoint/EndpointInterface.js +0 -22
- package/dist/cjs/endpoint/EndpointInterface.js.map +0 -6
- package/dist/cjs/endpoint/EndpointStructureLogger.d.ts +0 -31
- package/dist/cjs/endpoint/EndpointStructureLogger.d.ts.map +0 -1
- package/dist/cjs/endpoint/EndpointStructureLogger.js +0 -230
- package/dist/cjs/endpoint/EndpointStructureLogger.js.map +0 -6
- package/dist/cjs/endpoint/index.d.ts +0 -8
- package/dist/cjs/endpoint/index.d.ts.map +0 -1
- package/dist/cjs/endpoint/index.js +0 -25
- package/dist/cjs/endpoint/index.js.map +0 -6
- package/dist/cjs/interaction/InteractionEndpointStructure.d.ts +0 -95
- package/dist/cjs/interaction/InteractionEndpointStructure.d.ts.map +0 -1
- package/dist/cjs/interaction/InteractionEndpointStructure.js +0 -359
- package/dist/cjs/interaction/InteractionEndpointStructure.js.map +0 -6
- package/dist/esm/cluster/server/AttributeServer.d.ts +0 -307
- package/dist/esm/cluster/server/AttributeServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/AttributeServer.js +0 -729
- package/dist/esm/cluster/server/AttributeServer.js.map +0 -6
- package/dist/esm/cluster/server/ClusterDatasource.d.ts +0 -16
- package/dist/esm/cluster/server/ClusterDatasource.d.ts.map +0 -1
- package/dist/esm/cluster/server/ClusterDatasource.js +0 -6
- package/dist/esm/cluster/server/ClusterDatasource.js.map +0 -6
- package/dist/esm/cluster/server/ClusterServer.d.ts +0 -40
- package/dist/esm/cluster/server/ClusterServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/ClusterServer.js +0 -6
- package/dist/esm/cluster/server/ClusterServer.js.map +0 -6
- package/dist/esm/cluster/server/CommandServer.d.ts +0 -34
- package/dist/esm/cluster/server/CommandServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/CommandServer.js +0 -56
- package/dist/esm/cluster/server/CommandServer.js.map +0 -6
- package/dist/esm/cluster/server/EventServer.d.ts +0 -42
- package/dist/esm/cluster/server/EventServer.d.ts.map +0 -1
- package/dist/esm/cluster/server/EventServer.js +0 -141
- package/dist/esm/cluster/server/EventServer.js.map +0 -6
- package/dist/esm/cluster/server/index.d.ts +0 -11
- package/dist/esm/cluster/server/index.d.ts.map +0 -1
- package/dist/esm/cluster/server/index.js +0 -11
- package/dist/esm/cluster/server/index.js.map +0 -6
- package/dist/esm/endpoint/EndpointInterface.d.ts +0 -37
- package/dist/esm/endpoint/EndpointInterface.d.ts.map +0 -1
- package/dist/esm/endpoint/EndpointInterface.js +0 -6
- package/dist/esm/endpoint/EndpointInterface.js.map +0 -6
- package/dist/esm/endpoint/EndpointStructureLogger.d.ts +0 -31
- package/dist/esm/endpoint/EndpointStructureLogger.d.ts.map +0 -1
- package/dist/esm/endpoint/EndpointStructureLogger.js +0 -210
- package/dist/esm/endpoint/EndpointStructureLogger.js.map +0 -6
- package/dist/esm/endpoint/index.d.ts +0 -8
- package/dist/esm/endpoint/index.d.ts.map +0 -1
- package/dist/esm/endpoint/index.js +0 -8
- package/dist/esm/endpoint/index.js.map +0 -6
- package/dist/esm/interaction/InteractionEndpointStructure.d.ts +0 -95
- package/dist/esm/interaction/InteractionEndpointStructure.d.ts.map +0 -1
- package/dist/esm/interaction/InteractionEndpointStructure.js +0 -355
- package/dist/esm/interaction/InteractionEndpointStructure.js.map +0 -6
- package/src/cluster/server/AttributeServer.ts +0 -997
- package/src/cluster/server/ClusterDatasource.ts +0 -17
- package/src/cluster/server/ClusterServer.ts +0 -46
- package/src/cluster/server/CommandServer.ts +0 -89
- package/src/cluster/server/EventServer.ts +0 -202
- package/src/cluster/server/index.ts +0 -11
- package/src/endpoint/EndpointInterface.ts +0 -41
- package/src/endpoint/EndpointStructureLogger.ts +0 -270
- package/src/endpoint/index.ts +0 -8
- package/src/interaction/InteractionEndpointStructure.ts +0 -510
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { OccurrenceManager } from "#events/OccurrenceManager.js";
|
|
8
|
-
import { Fabric } from "#fabric/Fabric.js";
|
|
9
|
-
import { SupportedStorageTypes } from "#general";
|
|
10
|
-
|
|
11
|
-
export interface ClusterDatasource {
|
|
12
|
-
readonly version: number;
|
|
13
|
-
readonly eventHandler?: OccurrenceManager;
|
|
14
|
-
readonly fabrics: Fabric[];
|
|
15
|
-
increaseVersion(): number;
|
|
16
|
-
changed(key: string, value: SupportedStorageTypes): void;
|
|
17
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { ClusterId } from "#types";
|
|
8
|
-
import { AnyAttributeServer } from "./AttributeServer.js";
|
|
9
|
-
import { ClusterDatasource } from "./ClusterDatasource.js";
|
|
10
|
-
import { CommandServer } from "./CommandServer.js";
|
|
11
|
-
import { AnyEventServer } from "./EventServer.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A collection of servers for a cluster's attributes, commands and events.
|
|
15
|
-
*/
|
|
16
|
-
export interface ClusterServer {
|
|
17
|
-
/**
|
|
18
|
-
* Cluster ID
|
|
19
|
-
*/
|
|
20
|
-
id: ClusterId;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Cluster name
|
|
24
|
-
*/
|
|
25
|
-
readonly name: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Cluster datasource
|
|
29
|
-
*/
|
|
30
|
-
datasource?: ClusterDatasource;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Cluster attributes as named object that can be used to programmatically work with available attributes
|
|
34
|
-
*/
|
|
35
|
-
readonly attributes: Record<string, AnyAttributeServer>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Cluster commands as array
|
|
39
|
-
*/
|
|
40
|
-
readonly commands: Record<string, CommandServer>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Cluster events as named object
|
|
44
|
-
*/
|
|
45
|
-
readonly events: Record<string, AnyEventServer>;
|
|
46
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { Diagnostic, Logger } from "#general";
|
|
8
|
-
import { AccessLevel, FabricIndex } from "#model";
|
|
9
|
-
import { CommandId, StatusCode, TlvSchema, TlvStream } from "#types";
|
|
10
|
-
import { Message } from "../../codec/MessageCodec.js";
|
|
11
|
-
import { EndpointInterface } from "../../endpoint/EndpointInterface.js";
|
|
12
|
-
import { SecureSession } from "../../session/SecureSession.js";
|
|
13
|
-
import { Session } from "../../session/Session.js";
|
|
14
|
-
|
|
15
|
-
const logger = Logger.get("CommandServer");
|
|
16
|
-
|
|
17
|
-
export class CommandServer<RequestT = any, ResponseT = any> {
|
|
18
|
-
readonly #invokeAcl: AccessLevel;
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
readonly invokeId: CommandId,
|
|
22
|
-
readonly responseId: CommandId,
|
|
23
|
-
readonly name: string,
|
|
24
|
-
readonly requestSchema: TlvSchema<RequestT>,
|
|
25
|
-
readonly responseSchema: TlvSchema<ResponseT>,
|
|
26
|
-
readonly requiresTimedInteraction: boolean,
|
|
27
|
-
invokeAcl: AccessLevel,
|
|
28
|
-
protected readonly handler: (
|
|
29
|
-
request: RequestT,
|
|
30
|
-
session: Session,
|
|
31
|
-
message: Message,
|
|
32
|
-
endpoint: EndpointInterface,
|
|
33
|
-
) => Promise<ResponseT> | ResponseT,
|
|
34
|
-
) {
|
|
35
|
-
this.#invokeAcl = invokeAcl;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async invoke(
|
|
39
|
-
session: Session,
|
|
40
|
-
args: TlvStream,
|
|
41
|
-
message: Message,
|
|
42
|
-
endpoint: EndpointInterface,
|
|
43
|
-
): Promise<{
|
|
44
|
-
/** Primary StatusCode of the invoke request as defined by Interaction proptocol. */
|
|
45
|
-
code: StatusCode;
|
|
46
|
-
|
|
47
|
-
/** Cluster specific StatusCode of the invoke request if required */
|
|
48
|
-
clusterCode?: number;
|
|
49
|
-
|
|
50
|
-
/** ID of the response */
|
|
51
|
-
responseId: CommandId;
|
|
52
|
-
|
|
53
|
-
/** Response data */
|
|
54
|
-
response: TlvStream;
|
|
55
|
-
}> {
|
|
56
|
-
let request = this.requestSchema.decodeTlv(args);
|
|
57
|
-
|
|
58
|
-
// Inject fabric index into structures in general if undefined, if set it will be used
|
|
59
|
-
if (session.isSecure) {
|
|
60
|
-
const fabric = (session as SecureSession).fabric;
|
|
61
|
-
if (fabric) {
|
|
62
|
-
request = this.requestSchema.injectField(
|
|
63
|
-
request,
|
|
64
|
-
<number>FabricIndex.id,
|
|
65
|
-
session.associatedFabric.fabricIndex,
|
|
66
|
-
() => true, // Noone should send any index and if we simply SHALL ignore it
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.requestSchema.validate(request);
|
|
72
|
-
this.debug(`Invoke ${this.name} with data ${Diagnostic.json(request)}`);
|
|
73
|
-
const response = await this.handler(request, session, message, endpoint);
|
|
74
|
-
this.debug(`Invoke ${this.name} response : ${Diagnostic.json(response)}`);
|
|
75
|
-
return {
|
|
76
|
-
code: StatusCode.Success,
|
|
77
|
-
responseId: this.responseId,
|
|
78
|
-
response: this.responseSchema.encodeTlv(response),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
debug(message: string) {
|
|
83
|
-
logger.debug(message);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
get invokeAcl() {
|
|
87
|
-
return this.#invokeAcl ?? AccessLevel.Operate; // or View?? Re "Read/Invoke" in Access table
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { NumberedOccurrence, Occurrence } from "#events/Occurrence.js";
|
|
8
|
-
import { OccurrenceManager } from "#events/OccurrenceManager.js";
|
|
9
|
-
import {
|
|
10
|
-
ImplementationError,
|
|
11
|
-
InternalError,
|
|
12
|
-
isObject,
|
|
13
|
-
MatterAggregateError,
|
|
14
|
-
MaybePromise,
|
|
15
|
-
Storage,
|
|
16
|
-
StorageOperationResult,
|
|
17
|
-
Time,
|
|
18
|
-
} from "#general";
|
|
19
|
-
import { AccessLevel, ClusterModel, EventModel, MatterModel } from "#model";
|
|
20
|
-
import {
|
|
21
|
-
Attributes,
|
|
22
|
-
BitSchema,
|
|
23
|
-
Cluster,
|
|
24
|
-
ClusterId,
|
|
25
|
-
Commands,
|
|
26
|
-
Event,
|
|
27
|
-
EventId,
|
|
28
|
-
EventPriority,
|
|
29
|
-
Events,
|
|
30
|
-
FabricIndex,
|
|
31
|
-
TlvEventFilter,
|
|
32
|
-
TlvSchema,
|
|
33
|
-
TypeFromPartialBitSchema,
|
|
34
|
-
TypeFromSchema,
|
|
35
|
-
} from "#types";
|
|
36
|
-
import { Message } from "../../codec/MessageCodec.js";
|
|
37
|
-
import { EndpointInterface } from "../../endpoint/EndpointInterface.js";
|
|
38
|
-
import { SecureSession } from "../../session/SecureSession.js";
|
|
39
|
-
import { Session } from "../../session/Session.js";
|
|
40
|
-
|
|
41
|
-
export type AnyEventServer<T = any, S extends Storage = any> = EventServer<T, S> | FabricSensitiveEventServer<T, S>;
|
|
42
|
-
|
|
43
|
-
export function createEventServer<
|
|
44
|
-
T,
|
|
45
|
-
F extends BitSchema,
|
|
46
|
-
SF extends TypeFromPartialBitSchema<F>,
|
|
47
|
-
A extends Attributes,
|
|
48
|
-
C extends Commands,
|
|
49
|
-
E extends Events,
|
|
50
|
-
S extends Storage,
|
|
51
|
-
>(
|
|
52
|
-
clusterDef: Cluster<F, SF, A, C, E>,
|
|
53
|
-
eventDef: Event<T, F>,
|
|
54
|
-
eventName: string,
|
|
55
|
-
schema: TlvSchema<T>,
|
|
56
|
-
priority: EventPriority,
|
|
57
|
-
readAcl: AccessLevel | undefined,
|
|
58
|
-
): EventServer<T, S> {
|
|
59
|
-
let fabricSensitive = false;
|
|
60
|
-
const clusterFromModel = MatterModel.standard.get(ClusterModel, clusterDef.id);
|
|
61
|
-
if (clusterFromModel !== undefined) {
|
|
62
|
-
const eventModel = clusterFromModel.get(EventModel, eventDef.id);
|
|
63
|
-
if (eventModel !== undefined) {
|
|
64
|
-
fabricSensitive = eventModel.fabricSensitive;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (fabricSensitive) {
|
|
68
|
-
return new FabricSensitiveEventServer(eventDef.id, clusterDef.id, eventName, schema, priority, readAcl);
|
|
69
|
-
}
|
|
70
|
-
return new EventServer(eventDef.id, clusterDef.id, eventName, schema, priority, readAcl);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class EventServer<T = any, S extends Storage = any> {
|
|
74
|
-
private eventList = new Array<Occurrence>();
|
|
75
|
-
private readonly listeners = new Array<(event: NumberedOccurrence) => void>();
|
|
76
|
-
protected endpoint?: EndpointInterface;
|
|
77
|
-
protected eventHandler?: OccurrenceManager;
|
|
78
|
-
#readAcl: AccessLevel | undefined;
|
|
79
|
-
hasFabricSensitiveData = false;
|
|
80
|
-
|
|
81
|
-
constructor(
|
|
82
|
-
readonly id: EventId,
|
|
83
|
-
readonly clusterId: ClusterId,
|
|
84
|
-
readonly name: string,
|
|
85
|
-
readonly schema: TlvSchema<T>,
|
|
86
|
-
readonly priority: EventPriority,
|
|
87
|
-
readAcl: AccessLevel | undefined,
|
|
88
|
-
) {
|
|
89
|
-
this.#readAcl = readAcl;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
get readAcl() {
|
|
93
|
-
return this.#readAcl ?? AccessLevel.View; // ???
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
assignToEndpoint(endpoint: EndpointInterface) {
|
|
97
|
-
this.endpoint = endpoint;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// TODO Try to get rid of that late binding and simply things again
|
|
101
|
-
// potentially with refactoring out MatterDevice and MatterController
|
|
102
|
-
bindToEventHandler(eventHandler: OccurrenceManager) {
|
|
103
|
-
this.eventHandler = eventHandler;
|
|
104
|
-
// Send all stored events to the new listener
|
|
105
|
-
const promises = new Array<PromiseLike<void>>();
|
|
106
|
-
for (const event of this.eventList) {
|
|
107
|
-
const finalEvent = this.eventHandler.add(event);
|
|
108
|
-
if (finalEvent !== undefined && MaybePromise.is(finalEvent)) {
|
|
109
|
-
promises.push(finalEvent.then(e => this.listeners.forEach(listener => listener(e))));
|
|
110
|
-
} else {
|
|
111
|
-
this.listeners.forEach(listener => listener(finalEvent));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
this.eventList = [];
|
|
115
|
-
if (promises.length > 0) {
|
|
116
|
-
return MatterAggregateError.allSettled(promises, "Error binding events to the event handlers").then(
|
|
117
|
-
() => {},
|
|
118
|
-
) as StorageOperationResult<S>;
|
|
119
|
-
}
|
|
120
|
-
return undefined as StorageOperationResult<S>;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
triggerEvent(data: T) {
|
|
124
|
-
if (this.endpoint === undefined || this.endpoint.number === undefined) {
|
|
125
|
-
throw new InternalError("Endpoint not assigned");
|
|
126
|
-
}
|
|
127
|
-
const occurrence: Occurrence = {
|
|
128
|
-
eventId: this.id,
|
|
129
|
-
clusterId: this.clusterId,
|
|
130
|
-
endpointId: this.endpoint.number,
|
|
131
|
-
epochTimestamp: Time.nowMs(),
|
|
132
|
-
priority: this.priority,
|
|
133
|
-
payload: data,
|
|
134
|
-
};
|
|
135
|
-
if (this.eventHandler === undefined) {
|
|
136
|
-
// As long as we have no occurrence manager, we store the events
|
|
137
|
-
this.eventList.push(occurrence);
|
|
138
|
-
} else {
|
|
139
|
-
const finalEvent = this.eventHandler.add(occurrence);
|
|
140
|
-
return MaybePromise.then(finalEvent, e => {
|
|
141
|
-
this.listeners.forEach(listener => listener(e));
|
|
142
|
-
}) as StorageOperationResult<S>;
|
|
143
|
-
}
|
|
144
|
-
return undefined as StorageOperationResult<S>;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
addListener(listener: (event: NumberedOccurrence) => void) {
|
|
148
|
-
this.listeners.push(listener);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
removeListener(listener: (event: NumberedOccurrence) => void) {
|
|
152
|
-
const entryIndex = this.listeners.indexOf(listener);
|
|
153
|
-
if (entryIndex !== -1) {
|
|
154
|
-
this.listeners.splice(entryIndex, 1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
get(
|
|
159
|
-
session: Session,
|
|
160
|
-
isFabricFiltered: boolean,
|
|
161
|
-
_message?: Message,
|
|
162
|
-
filters?: TypeFromSchema<typeof TlvEventFilter>[],
|
|
163
|
-
) {
|
|
164
|
-
if (this.eventHandler === undefined) {
|
|
165
|
-
throw new InternalError("EventServer not bound to OccurrenceManager");
|
|
166
|
-
}
|
|
167
|
-
if (this.endpoint === undefined) {
|
|
168
|
-
throw new InternalError("EventServer not bound to Endpoint");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return this.eventHandler.query(
|
|
172
|
-
{ endpointId: this.endpoint.number, clusterId: this.clusterId, eventId: this.id },
|
|
173
|
-
filters,
|
|
174
|
-
// When request is fabric filtered or the event is Fabric sensitive then filter the events for the fabrics
|
|
175
|
-
isFabricFiltered ? ((session as SecureSession).fabric?.fabricIndex ?? FabricIndex.NO_FABRIC) : undefined,
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export class FabricSensitiveEventServer<T, S extends Storage> extends EventServer<T, S> {
|
|
181
|
-
override hasFabricSensitiveData = true;
|
|
182
|
-
|
|
183
|
-
override get(
|
|
184
|
-
session: Session,
|
|
185
|
-
_isFabricFiltered: boolean,
|
|
186
|
-
message?: Message,
|
|
187
|
-
filters?: TypeFromSchema<typeof TlvEventFilter>[],
|
|
188
|
-
) {
|
|
189
|
-
// because the event is fabric sensitive it is always filtered out when another fabric tries to access it
|
|
190
|
-
return super.get(session, true, message, filters);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
override triggerEvent(data: T) {
|
|
194
|
-
if (!isObject(data) || data === null) {
|
|
195
|
-
throw new ImplementationError("FabricSensitive events need to have an object as data.");
|
|
196
|
-
}
|
|
197
|
-
if (!("fabricIndex" in data)) {
|
|
198
|
-
throw new InternalError("FabricSensitive events requires fabricIndex in data.");
|
|
199
|
-
}
|
|
200
|
-
return super.triggerEvent(data);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export * from "./AttributeServer.js";
|
|
8
|
-
export * from "./ClusterDatasource.js";
|
|
9
|
-
export * from "./ClusterServer.js";
|
|
10
|
-
export * from "./CommandServer.js";
|
|
11
|
-
export * from "./EventServer.js";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { ClusterId, ClusterType, DeviceTypeId, EndpointNumber } from "#types";
|
|
8
|
-
import { ClusterClientObj } from "../cluster/index.js";
|
|
9
|
-
import { ClusterServer } from "../cluster/server/ClusterServer.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The primary interface for Matter.js endpoint implementations.
|
|
13
|
-
*
|
|
14
|
-
* TODO - this is a transitional interface that allows us to have multiple implementations of the legacy endpoint API
|
|
15
|
-
*/
|
|
16
|
-
export interface EndpointInterface {
|
|
17
|
-
name: string;
|
|
18
|
-
number: EndpointNumber | undefined;
|
|
19
|
-
deviceType: DeviceTypeId;
|
|
20
|
-
getNumber(): EndpointNumber;
|
|
21
|
-
removeFromStructure(): void;
|
|
22
|
-
updatePartsList(): EndpointNumber[];
|
|
23
|
-
getChildEndpoints(): EndpointInterface[];
|
|
24
|
-
determineUniqueID(): string | undefined;
|
|
25
|
-
verifyRequiredClusters(): void;
|
|
26
|
-
close(): void;
|
|
27
|
-
setStructureChangedCallback(callback: () => void): void;
|
|
28
|
-
|
|
29
|
-
addClusterServer(server: ClusterServer): void;
|
|
30
|
-
hasClusterServer(cluster: ClusterType): boolean;
|
|
31
|
-
getClusterServer<T extends ClusterType>(cluster: T): ClusterServer | undefined;
|
|
32
|
-
getClusterServerById(clusterId: ClusterId): ClusterServer | undefined;
|
|
33
|
-
getAllClusterServers(): ClusterServer[];
|
|
34
|
-
|
|
35
|
-
addClusterClient(client: ClusterClientObj): void;
|
|
36
|
-
getClusterClient<const T extends ClusterType>(cluster: T): ClusterClientObj<T> | undefined;
|
|
37
|
-
getAllClusterClients(): ClusterClientObj[];
|
|
38
|
-
|
|
39
|
-
addChildEndpoint(endpoint: EndpointInterface): void;
|
|
40
|
-
getChildEndpoint(id: EndpointNumber): EndpointInterface | undefined;
|
|
41
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { Diagnostic, Logger } from "#general";
|
|
8
|
-
import { GlobalAttributes } from "#types";
|
|
9
|
-
import { SupportedAttributeClient, UnknownSupportedAttributeClient } from "../cluster/client/AttributeClient.js";
|
|
10
|
-
import { ClusterClientObj } from "../cluster/client/ClusterClientTypes.js";
|
|
11
|
-
import { AnyAttributeServer, FabricScopeError } from "../cluster/server/AttributeServer.js";
|
|
12
|
-
import { ClusterServer } from "../cluster/server/ClusterServer.js";
|
|
13
|
-
import { EndpointInterface } from "../endpoint/EndpointInterface.js";
|
|
14
|
-
|
|
15
|
-
const logger = Logger.get("EndpointStructureLogger");
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Options for logging endpoint structure. The default is that anything is logged beside "Non Supported" attributes and
|
|
19
|
-
* events on ClusterClients. The Filter methods can be used to filter out specific endpoints or clusters if wanted.
|
|
20
|
-
*/
|
|
21
|
-
export type EndpointLoggingOptions = {
|
|
22
|
-
logClusterServers?: boolean;
|
|
23
|
-
logClusterClients?: boolean;
|
|
24
|
-
logChildEndpoints?: boolean;
|
|
25
|
-
logClusterGlobalAttributes?: boolean;
|
|
26
|
-
logClusterAttributes?: boolean;
|
|
27
|
-
logNotSupportedClusterAttributes?: boolean;
|
|
28
|
-
logClusterCommands?: boolean;
|
|
29
|
-
logClusterEvents?: boolean;
|
|
30
|
-
logNotSupportedClusterEvents?: boolean;
|
|
31
|
-
logNotSupportedClusterCommands?: boolean;
|
|
32
|
-
logAttributePrimitiveValues?: boolean;
|
|
33
|
-
logAttributeObjectValues?: boolean;
|
|
34
|
-
|
|
35
|
-
clusterServerFilter?: (endpoint: EndpointInterface, cluster: ClusterServer) => boolean;
|
|
36
|
-
clusterClientFilter?: (endpoint: EndpointInterface, cluster: ClusterClientObj) => boolean;
|
|
37
|
-
endpointFilter?: (endpoint: EndpointInterface) => boolean;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function getAttributeServerValue(attribute: AnyAttributeServer<any>, options: EndpointLoggingOptions = {}) {
|
|
41
|
-
let value = "";
|
|
42
|
-
try {
|
|
43
|
-
const attributeValue = attribute.getLocal();
|
|
44
|
-
const attributeValueType = typeof attributeValue;
|
|
45
|
-
if (
|
|
46
|
-
(attributeValueType !== "object" || attributeValue === null) &&
|
|
47
|
-
options.logAttributePrimitiveValues !== false
|
|
48
|
-
) {
|
|
49
|
-
value = attributeValue === null ? "null" : attributeValue.toString();
|
|
50
|
-
} else if (
|
|
51
|
-
attributeValueType === "object" &&
|
|
52
|
-
attributeValue !== null &&
|
|
53
|
-
options.logAttributeObjectValues !== false
|
|
54
|
-
) {
|
|
55
|
-
value = Diagnostic.json(attributeValue);
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
if (error instanceof FabricScopeError) {
|
|
59
|
-
value = "Fabric-Scoped";
|
|
60
|
-
} else {
|
|
61
|
-
value = `Error: ${(error as any).message}`;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function logClusterServer(
|
|
68
|
-
endpoint: EndpointInterface,
|
|
69
|
-
clusterServer: ClusterServer,
|
|
70
|
-
options: EndpointLoggingOptions = {},
|
|
71
|
-
) {
|
|
72
|
-
if (options.clusterServerFilter !== undefined && !options.clusterServerFilter(endpoint, clusterServer)) return;
|
|
73
|
-
|
|
74
|
-
const featureMap = clusterServer.attributes.featureMap?.getLocal() ?? {};
|
|
75
|
-
const globalAttributes = GlobalAttributes<any>(featureMap);
|
|
76
|
-
const supportedFeatures = new Array<string>();
|
|
77
|
-
for (const featureName in featureMap) {
|
|
78
|
-
if (featureMap[featureName] === true) supportedFeatures.push(featureName);
|
|
79
|
-
}
|
|
80
|
-
logger.info(
|
|
81
|
-
`Cluster-Server "${clusterServer.name}" (${Diagnostic.hex(clusterServer.id)}) ${
|
|
82
|
-
supportedFeatures.length ? `(Features: ${supportedFeatures.join(", ")})` : ""
|
|
83
|
-
}`,
|
|
84
|
-
);
|
|
85
|
-
if (options.logClusterGlobalAttributes !== false) {
|
|
86
|
-
Logger.nest(() => {
|
|
87
|
-
logger.info("Global-Attributes:");
|
|
88
|
-
Logger.nest(() => {
|
|
89
|
-
for (const attributeName in globalAttributes) {
|
|
90
|
-
const attribute = clusterServer.attributes[attributeName];
|
|
91
|
-
if (attribute === undefined) continue;
|
|
92
|
-
|
|
93
|
-
const value = getAttributeServerValue(attribute, options);
|
|
94
|
-
logger.info(
|
|
95
|
-
`"${attribute.name}" (${Diagnostic.hex(attribute.id)})${value !== "" ? `: value = ${value}` : ""}`,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (options.logClusterAttributes !== false) {
|
|
102
|
-
Logger.nest(() => {
|
|
103
|
-
logger.info("Attributes:");
|
|
104
|
-
Logger.nest(() => {
|
|
105
|
-
for (const attributeName in clusterServer.attributes) {
|
|
106
|
-
if (attributeName in globalAttributes) continue;
|
|
107
|
-
const attribute = clusterServer.attributes[attributeName];
|
|
108
|
-
if (attribute === undefined) continue;
|
|
109
|
-
|
|
110
|
-
const value = getAttributeServerValue(attribute, options);
|
|
111
|
-
logger.info(
|
|
112
|
-
`"${attribute.name}" (${Diagnostic.hex(attribute.id)})${value !== "" ? `: value = ${value}` : ""}`,
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
if (options.logClusterCommands !== false) {
|
|
119
|
-
Logger.nest(() => {
|
|
120
|
-
logger.info("Commands:");
|
|
121
|
-
Logger.nest(() => {
|
|
122
|
-
const commands = clusterServer.commands;
|
|
123
|
-
for (const commandName in commands) {
|
|
124
|
-
const command = commands[commandName];
|
|
125
|
-
if (command === undefined) continue;
|
|
126
|
-
logger.info(
|
|
127
|
-
`"${command.name}" (${Diagnostic.hex(command.invokeId)}/${Diagnostic.hex(command.responseId)})`,
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (options.logClusterEvents !== false) {
|
|
134
|
-
Logger.nest(() => {
|
|
135
|
-
logger.info("Events:");
|
|
136
|
-
Logger.nest(() => {
|
|
137
|
-
const events = clusterServer.events;
|
|
138
|
-
for (const eventName in events) {
|
|
139
|
-
const event = events[eventName];
|
|
140
|
-
if (event === undefined) continue;
|
|
141
|
-
logger.info(`"${event.name}" (${Diagnostic.hex(event.id)})`);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function logClusterClient(
|
|
149
|
-
endpoint: EndpointInterface,
|
|
150
|
-
clusterClient: ClusterClientObj,
|
|
151
|
-
options: EndpointLoggingOptions = {},
|
|
152
|
-
) {
|
|
153
|
-
if (options.clusterClientFilter !== undefined && !options.clusterClientFilter(endpoint, clusterClient)) return;
|
|
154
|
-
|
|
155
|
-
const { supportedFeatures: features } = clusterClient;
|
|
156
|
-
const globalAttributes = GlobalAttributes<any>(features);
|
|
157
|
-
const supportedFeatures = new Array<string>();
|
|
158
|
-
for (const featureName in features) {
|
|
159
|
-
if (features[featureName] === true) supportedFeatures.push(featureName);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
logger.info(
|
|
163
|
-
`Cluster-Client "${clusterClient.name}" (${Diagnostic.hex(clusterClient.id)}) ${
|
|
164
|
-
supportedFeatures.length ? `(Features: ${supportedFeatures.join(", ")})` : ""
|
|
165
|
-
}`,
|
|
166
|
-
);
|
|
167
|
-
if (options.logClusterGlobalAttributes !== false) {
|
|
168
|
-
Logger.nest(() => {
|
|
169
|
-
logger.info("Global-Attributes:");
|
|
170
|
-
Logger.nest(() => {
|
|
171
|
-
for (const attributeName in globalAttributes) {
|
|
172
|
-
const attribute = clusterClient.attributes[attributeName];
|
|
173
|
-
if (attribute === undefined) continue;
|
|
174
|
-
|
|
175
|
-
logger.info(`"${attribute.name}" (${Diagnostic.hex(attribute.id)})`);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
if (options.logClusterAttributes !== false) {
|
|
181
|
-
Logger.nest(() => {
|
|
182
|
-
logger.info("Attributes:");
|
|
183
|
-
Logger.nest(() => {
|
|
184
|
-
for (const attributeName in clusterClient.attributes) {
|
|
185
|
-
if (attributeName in globalAttributes) continue;
|
|
186
|
-
const attribute = clusterClient.attributes[attributeName];
|
|
187
|
-
if (attribute === undefined) continue;
|
|
188
|
-
const supported = attribute instanceof SupportedAttributeClient;
|
|
189
|
-
if (!supported && options.logNotSupportedClusterAttributes === false) continue;
|
|
190
|
-
const unknown = attribute instanceof UnknownSupportedAttributeClient;
|
|
191
|
-
|
|
192
|
-
let info = "";
|
|
193
|
-
if (!supported) info += " (Not Supported)";
|
|
194
|
-
if (unknown) info += " (Unknown)";
|
|
195
|
-
|
|
196
|
-
logger.info(`"${attribute.name}" (${Diagnostic.hex(attribute.id)})${info}`);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
if (options.logClusterCommands !== false) {
|
|
202
|
-
Logger.nest(() => {
|
|
203
|
-
logger.info("Commands:");
|
|
204
|
-
Logger.nest(() => {
|
|
205
|
-
for (const commandName in clusterClient.commands) {
|
|
206
|
-
if (commandName.match(/^\d+$/)) continue;
|
|
207
|
-
const supported = clusterClient.isCommandSupportedByName(commandName);
|
|
208
|
-
if (!supported && options.logNotSupportedClusterCommands === false) continue;
|
|
209
|
-
logger.info(`"${commandName}"${supported ? "" : " (Not Supported)"}`);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
if (options.logClusterEvents !== false) {
|
|
215
|
-
Logger.nest(() => {
|
|
216
|
-
logger.info("Events:");
|
|
217
|
-
Logger.nest(() => {
|
|
218
|
-
for (const eventName in clusterClient.events) {
|
|
219
|
-
const event = clusterClient.events[eventName];
|
|
220
|
-
if (event === undefined) continue;
|
|
221
|
-
|
|
222
|
-
logger.info(`"${event.name}" (${Diagnostic.hex(event.id)})`);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function logEndpoint(
|
|
230
|
-
endpoint: EndpointInterface,
|
|
231
|
-
options: EndpointLoggingOptions = {
|
|
232
|
-
logNotSupportedClusterAttributes: false,
|
|
233
|
-
logNotSupportedClusterEvents: false,
|
|
234
|
-
logNotSupportedClusterCommands: false,
|
|
235
|
-
},
|
|
236
|
-
) {
|
|
237
|
-
if (options.endpointFilter !== undefined && !options.endpointFilter(endpoint)) return;
|
|
238
|
-
|
|
239
|
-
logger.info(`Endpoint ${endpoint.number} (${endpoint.name}):`);
|
|
240
|
-
if (options.logClusterServers !== false) {
|
|
241
|
-
Logger.nest(() => {
|
|
242
|
-
logger.info("Cluster-Servers:");
|
|
243
|
-
Logger.nest(() => {
|
|
244
|
-
for (const clusterServer of endpoint.getAllClusterServers()) {
|
|
245
|
-
logClusterServer(endpoint, clusterServer, options);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
if (options.logClusterClients !== false) {
|
|
251
|
-
Logger.nest(() => {
|
|
252
|
-
logger.info("Cluster-Clients:");
|
|
253
|
-
Logger.nest(() => {
|
|
254
|
-
for (const clusterClient of endpoint.getAllClusterClients()) {
|
|
255
|
-
logClusterClient(endpoint, clusterClient, options);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
if (options.logChildEndpoints !== false) {
|
|
261
|
-
Logger.nest(() => {
|
|
262
|
-
logger.info("Child-Endpoints:");
|
|
263
|
-
Logger.nest(() => {
|
|
264
|
-
for (const childEndpoint of endpoint.getChildEndpoints()) {
|
|
265
|
-
logEndpoint(childEndpoint, options);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|