@matter/protocol 0.12.4-alpha.0-20250210-ad8edf096 → 0.12.4-alpha.0-20250212-b2729c9eb
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 +36 -0
- package/dist/cjs/action/Interactable.d.ts.map +1 -0
- package/dist/cjs/action/Interactable.js +22 -0
- package/dist/cjs/action/Interactable.js.map +6 -0
- package/dist/cjs/action/Val.d.ts +94 -0
- package/dist/cjs/action/Val.d.ts.map +1 -0
- package/dist/cjs/action/Val.js +33 -0
- package/dist/cjs/action/Val.js.map +6 -0
- package/dist/cjs/action/errors.d.ts +69 -0
- package/dist/cjs/action/errors.d.ts.map +1 -0
- package/dist/cjs/action/errors.js +108 -0
- package/dist/cjs/action/errors.js.map +6 -0
- package/dist/cjs/action/index.d.ts +13 -0
- package/dist/cjs/action/index.d.ts.map +1 -0
- package/dist/cjs/action/index.js +30 -0
- package/dist/cjs/action/index.js.map +6 -0
- package/dist/cjs/action/protocols.d.ts +118 -0
- package/dist/cjs/action/protocols.d.ts.map +1 -0
- package/dist/cjs/action/protocols.js +22 -0
- package/dist/cjs/action/protocols.js.map +6 -0
- package/dist/cjs/action/request/Invoke.d.ts +35 -0
- package/dist/cjs/action/request/Invoke.d.ts.map +1 -0
- package/dist/cjs/action/request/Invoke.js +80 -0
- package/dist/cjs/action/request/Invoke.js.map +6 -0
- package/dist/cjs/action/request/MalformedRequestError.d.ts +14 -0
- package/dist/cjs/action/request/MalformedRequestError.d.ts.map +1 -0
- package/dist/cjs/action/request/MalformedRequestError.js +32 -0
- package/dist/cjs/action/request/MalformedRequestError.js.map +6 -0
- package/dist/cjs/action/request/Read.d.ts +141 -0
- package/dist/cjs/action/request/Read.d.ts.map +1 -0
- package/dist/cjs/action/request/Read.js +173 -0
- package/dist/cjs/action/request/Read.js.map +6 -0
- package/dist/cjs/action/request/Specifier.d.ts +82 -0
- package/dist/cjs/action/request/Specifier.d.ts.map +1 -0
- package/dist/cjs/action/request/Specifier.js +88 -0
- package/dist/cjs/action/request/Specifier.js.map +6 -0
- package/dist/cjs/action/request/Subscribe.d.ts +26 -0
- package/dist/cjs/action/request/Subscribe.d.ts.map +1 -0
- package/dist/cjs/action/request/Subscribe.js +50 -0
- package/dist/cjs/action/request/Subscribe.js.map +6 -0
- package/dist/cjs/action/request/Write.d.ts +10 -0
- package/dist/cjs/action/request/Write.d.ts.map +1 -0
- package/dist/cjs/action/request/Write.js +22 -0
- package/dist/cjs/action/request/Write.js.map +6 -0
- package/dist/cjs/action/request/index.d.ts +11 -0
- package/dist/cjs/action/request/index.d.ts.map +1 -0
- package/dist/cjs/action/request/index.js +28 -0
- package/dist/cjs/action/request/index.js.map +6 -0
- package/dist/cjs/action/response/InvokeResult.d.ts +15 -0
- package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -0
- package/dist/cjs/action/response/InvokeResult.js +22 -0
- package/dist/cjs/action/response/InvokeResult.js.map +6 -0
- package/dist/cjs/action/response/ReadResult.d.ts +63 -0
- package/dist/cjs/action/response/ReadResult.d.ts.map +1 -0
- package/dist/cjs/action/response/ReadResult.js +22 -0
- package/dist/cjs/action/response/ReadResult.js.map +6 -0
- package/dist/cjs/action/response/SubscribeResult.d.ts +13 -0
- package/dist/cjs/action/response/SubscribeResult.d.ts.map +1 -0
- package/dist/cjs/action/response/SubscribeResult.js +22 -0
- package/dist/cjs/action/response/SubscribeResult.js.map +6 -0
- package/dist/cjs/action/response/WriteResult.d.ts +12 -0
- package/dist/cjs/action/response/WriteResult.d.ts.map +1 -0
- package/dist/cjs/action/response/WriteResult.js +22 -0
- package/dist/cjs/action/response/WriteResult.js.map +6 -0
- package/dist/cjs/action/response/index.d.ts +10 -0
- package/dist/cjs/action/response/index.d.ts.map +1 -0
- package/dist/cjs/action/response/index.js +27 -0
- package/dist/cjs/action/response/index.js.map +6 -0
- package/dist/cjs/action/server/AccessControl.d.ts +152 -0
- package/dist/cjs/action/server/AccessControl.d.ts.map +1 -0
- package/dist/cjs/action/server/AccessControl.js +287 -0
- package/dist/cjs/action/server/AccessControl.js.map +6 -0
- package/dist/cjs/action/server/AttributeResponse.d.ts +36 -0
- package/dist/cjs/action/server/AttributeResponse.d.ts.map +1 -0
- package/dist/cjs/action/server/AttributeResponse.js +352 -0
- package/dist/cjs/action/server/AttributeResponse.js.map +6 -0
- package/dist/cjs/action/server/ServerInteraction.d.ts +35 -0
- package/dist/cjs/action/server/ServerInteraction.d.ts.map +1 -0
- package/dist/cjs/action/server/ServerInteraction.js +52 -0
- package/dist/cjs/action/server/ServerInteraction.js.map +6 -0
- package/dist/cjs/action/server/index.d.ts +9 -0
- package/dist/cjs/action/server/index.d.ts.map +1 -0
- package/dist/cjs/action/server/index.js +26 -0
- package/dist/cjs/action/server/index.js.map +6 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interaction/AccessControlManager.d.ts +1 -1
- package/dist/cjs/interaction/AccessControlManager.d.ts.map +1 -1
- package/dist/cjs/interaction/AccessControlManager.js +2 -2
- package/dist/cjs/interaction/AccessControlManager.js.map +1 -1
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts +1 -3
- package/dist/cjs/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionMessenger.d.ts +5 -5
- package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionServer.d.ts +1 -1
- package/dist/cjs/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/cjs/interaction/InteractionServer.js +2 -2
- package/dist/cjs/interaction/InteractionServer.js.map +1 -1
- package/dist/cjs/interaction/ServerSubscription.d.ts +2 -2
- package/dist/cjs/interaction/ServerSubscription.d.ts.map +1 -1
- package/dist/cjs/interaction/ServerSubscription.js +0 -1
- package/dist/cjs/interaction/ServerSubscription.js.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts +2 -2
- package/dist/esm/action/Interactable.d.ts +36 -0
- package/dist/esm/action/Interactable.d.ts.map +1 -0
- package/dist/esm/action/Interactable.js +6 -0
- package/dist/esm/action/Interactable.js.map +6 -0
- package/dist/esm/action/Val.d.ts +94 -0
- package/dist/esm/action/Val.d.ts.map +1 -0
- package/dist/esm/action/Val.js +13 -0
- package/dist/esm/action/Val.js.map +6 -0
- package/dist/esm/action/errors.d.ts +69 -0
- package/dist/esm/action/errors.d.ts.map +1 -0
- package/dist/esm/action/errors.js +88 -0
- package/dist/esm/action/errors.js.map +6 -0
- package/dist/esm/action/index.d.ts +13 -0
- package/dist/esm/action/index.d.ts.map +1 -0
- package/dist/esm/action/index.js +13 -0
- package/dist/esm/action/index.js.map +6 -0
- package/dist/esm/action/protocols.d.ts +118 -0
- package/dist/esm/action/protocols.d.ts.map +1 -0
- package/dist/esm/action/protocols.js +6 -0
- package/dist/esm/action/protocols.js.map +6 -0
- package/dist/esm/action/request/Invoke.d.ts +35 -0
- package/dist/esm/action/request/Invoke.d.ts.map +1 -0
- package/dist/esm/action/request/Invoke.js +60 -0
- package/dist/esm/action/request/Invoke.js.map +6 -0
- package/dist/esm/action/request/MalformedRequestError.d.ts +14 -0
- package/dist/esm/action/request/MalformedRequestError.d.ts.map +1 -0
- package/dist/esm/action/request/MalformedRequestError.js +12 -0
- package/dist/esm/action/request/MalformedRequestError.js.map +6 -0
- package/dist/esm/action/request/Read.d.ts +141 -0
- package/dist/esm/action/request/Read.d.ts.map +1 -0
- package/dist/esm/action/request/Read.js +153 -0
- package/dist/esm/action/request/Read.js.map +6 -0
- package/dist/esm/action/request/Specifier.d.ts +82 -0
- package/dist/esm/action/request/Specifier.d.ts.map +1 -0
- package/dist/esm/action/request/Specifier.js +68 -0
- package/dist/esm/action/request/Specifier.js.map +6 -0
- package/dist/esm/action/request/Subscribe.d.ts +26 -0
- package/dist/esm/action/request/Subscribe.d.ts.map +1 -0
- package/dist/esm/action/request/Subscribe.js +30 -0
- package/dist/esm/action/request/Subscribe.js.map +6 -0
- package/dist/esm/action/request/Write.d.ts +10 -0
- package/dist/esm/action/request/Write.d.ts.map +1 -0
- package/dist/esm/action/request/Write.js +6 -0
- package/dist/esm/action/request/Write.js.map +6 -0
- package/dist/esm/action/request/index.d.ts +11 -0
- package/dist/esm/action/request/index.d.ts.map +1 -0
- package/dist/esm/action/request/index.js +11 -0
- package/dist/esm/action/request/index.js.map +6 -0
- package/dist/esm/action/response/InvokeResult.d.ts +15 -0
- package/dist/esm/action/response/InvokeResult.d.ts.map +1 -0
- package/dist/esm/action/response/InvokeResult.js +6 -0
- package/dist/esm/action/response/InvokeResult.js.map +6 -0
- package/dist/esm/action/response/ReadResult.d.ts +63 -0
- package/dist/esm/action/response/ReadResult.d.ts.map +1 -0
- package/dist/esm/action/response/ReadResult.js +6 -0
- package/dist/esm/action/response/ReadResult.js.map +6 -0
- package/dist/esm/action/response/SubscribeResult.d.ts +13 -0
- package/dist/esm/action/response/SubscribeResult.d.ts.map +1 -0
- package/dist/esm/action/response/SubscribeResult.js +6 -0
- package/dist/esm/action/response/SubscribeResult.js.map +6 -0
- package/dist/esm/action/response/WriteResult.d.ts +12 -0
- package/dist/esm/action/response/WriteResult.d.ts.map +1 -0
- package/dist/esm/action/response/WriteResult.js +6 -0
- package/dist/esm/action/response/WriteResult.js.map +6 -0
- package/dist/esm/action/response/index.d.ts +10 -0
- package/dist/esm/action/response/index.d.ts.map +1 -0
- package/dist/esm/action/response/index.js +10 -0
- package/dist/esm/action/response/index.js.map +6 -0
- package/dist/esm/action/server/AccessControl.d.ts +152 -0
- package/dist/esm/action/server/AccessControl.d.ts.map +1 -0
- package/dist/esm/action/server/AccessControl.js +267 -0
- package/dist/esm/action/server/AccessControl.js.map +6 -0
- package/dist/esm/action/server/AttributeResponse.d.ts +36 -0
- package/dist/esm/action/server/AttributeResponse.d.ts.map +1 -0
- package/dist/esm/action/server/AttributeResponse.js +339 -0
- package/dist/esm/action/server/AttributeResponse.js.map +6 -0
- package/dist/esm/action/server/ServerInteraction.d.ts +35 -0
- package/dist/esm/action/server/ServerInteraction.d.ts.map +1 -0
- package/dist/esm/action/server/ServerInteraction.js +32 -0
- package/dist/esm/action/server/ServerInteraction.js.map +6 -0
- package/dist/esm/action/server/index.d.ts +9 -0
- package/dist/esm/action/server/index.d.ts.map +1 -0
- package/dist/esm/action/server/index.js +9 -0
- package/dist/esm/action/server/index.js.map +6 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interaction/AccessControlManager.d.ts +1 -1
- package/dist/esm/interaction/AccessControlManager.d.ts.map +1 -1
- package/dist/esm/interaction/AccessControlManager.js +2 -2
- package/dist/esm/interaction/AccessControlManager.js.map +1 -1
- package/dist/esm/interaction/AttributeDataEncoder.d.ts +1 -3
- package/dist/esm/interaction/AttributeDataEncoder.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionMessenger.d.ts +5 -5
- package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionServer.d.ts +1 -1
- package/dist/esm/interaction/InteractionServer.d.ts.map +1 -1
- package/dist/esm/interaction/InteractionServer.js +2 -2
- package/dist/esm/interaction/InteractionServer.js.map +1 -1
- package/dist/esm/interaction/ServerSubscription.d.ts +2 -2
- package/dist/esm/interaction/ServerSubscription.d.ts.map +1 -1
- package/dist/esm/interaction/ServerSubscription.js +0 -1
- package/dist/esm/interaction/ServerSubscription.js.map +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts +2 -2
- package/package.json +6 -6
- package/src/action/Interactable.ts +40 -0
- package/src/action/Val.ts +111 -0
- package/src/action/errors.ts +119 -0
- package/src/action/index.ts +13 -0
- package/src/action/protocols.ts +134 -0
- package/src/action/request/Invoke.ts +93 -0
- package/src/action/request/MalformedRequestError.ts +14 -0
- package/src/action/request/Read.ts +356 -0
- package/src/action/request/Specifier.ts +146 -0
- package/src/action/request/Subscribe.ts +54 -0
- package/src/action/request/Write.ts +13 -0
- package/src/action/request/index.ts +11 -0
- package/src/action/response/InvokeResult.ts +17 -0
- package/src/action/response/ReadResult.ts +89 -0
- package/src/action/response/SubscribeResult.ts +14 -0
- package/src/action/response/WriteResult.ts +13 -0
- package/src/action/response/index.ts +10 -0
- package/src/action/server/AccessControl.ts +494 -0
- package/src/action/server/AttributeResponse.ts +413 -0
- package/src/action/server/ServerInteraction.ts +64 -0
- package/src/action/server/index.ts +9 -0
- package/src/index.ts +1 -0
- package/src/interaction/AccessControlManager.ts +3 -3
- package/src/interaction/InteractionServer.ts +2 -3
- package/src/interaction/ServerSubscription.ts +0 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ClusterType, CommandData, InvokeRequest, TlvSchema, TypeFromSchema } from "#types";
|
|
7
|
+
import { Specifier } from "./Specifier.js";
|
|
8
|
+
export interface Invoke extends InvokeRequest {
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Request invocation of one or more commands.
|
|
13
|
+
*/
|
|
14
|
+
export declare function Invoke(definition: Invoke.Definition): Invoke;
|
|
15
|
+
export declare namespace Invoke {
|
|
16
|
+
interface Definition {
|
|
17
|
+
commands: CommandData[];
|
|
18
|
+
suppressResponse?: boolean;
|
|
19
|
+
timed?: boolean;
|
|
20
|
+
interactionModelRevision?: number;
|
|
21
|
+
}
|
|
22
|
+
function Command<const C extends ClusterType>(request: Invoke.CommandRequest<C>): CommandData;
|
|
23
|
+
type CommandRequest<C extends Specifier.Cluster = Specifier.Cluster, CMD extends Specifier.Command<Specifier.ClusterFor<C>> = Specifier.Command<Specifier.ClusterFor<C>>> = {
|
|
24
|
+
endpoint?: Specifier.Endpoint;
|
|
25
|
+
cluster: C;
|
|
26
|
+
command: CMD;
|
|
27
|
+
} & Fields<Specifier.CommandFor<Specifier.ClusterFor<C>, CMD>["requestSchema"]>;
|
|
28
|
+
function commandOf<const R extends CommandRequest>(request: R): ClusterType.Command;
|
|
29
|
+
type Fields<S extends TlvSchema<any>> = S extends TlvSchema<void> ? {} : S extends TlvSchema<null> ? {
|
|
30
|
+
fields?: TypeFromSchema<S>;
|
|
31
|
+
} : {
|
|
32
|
+
fields: TypeFromSchema<S>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invoke.d.ts","sourceRoot":"","sources":["../../../../src/action/request/Invoke.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,MAAO,SAAQ,aAAa;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAkB5D;AAED,yBAAiB,MAAM,CAAC;IACpB,UAAiB,UAAU;QACvB,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACrC;IAED,SAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAcnG;IAED,KAAY,cAAc,CACtB,CAAC,SAAS,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,EAC/C,GAAG,SAAS,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IACnG;QACA,QAAQ,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC;QAC9B,OAAO,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,GAAG,CAAC;KAChB,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IAEhF,SAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,OAAO,CAazF;IAED,KAAY,MAAM,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,IACvC,CAAC,SAAS,SAAS,CAAC,IAAI,CAAC,GACnB,EAAE,GACF,CAAC,SAAS,SAAS,CAAC,IAAI,CAAC,GACvB;QAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE,GAC9B;QAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC;CAC7C"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FALLBACK_INTERACTIONMODEL_REVISION } from "#session/Session.js";
|
|
7
|
+
import { MalformedRequestError } from "./MalformedRequestError.js";
|
|
8
|
+
import { Specifier } from "./Specifier.js";
|
|
9
|
+
function Invoke(definition) {
|
|
10
|
+
const {
|
|
11
|
+
commands,
|
|
12
|
+
interactionModelRevision = FALLBACK_INTERACTIONMODEL_REVISION,
|
|
13
|
+
suppressResponse = false,
|
|
14
|
+
timed: timedRequest = false
|
|
15
|
+
} = definition;
|
|
16
|
+
if (!commands?.length) {
|
|
17
|
+
throw new MalformedRequestError(`Invocation requires at least one command`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
invokeRequests: commands,
|
|
21
|
+
interactionModelRevision,
|
|
22
|
+
suppressResponse,
|
|
23
|
+
timedRequest
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
((Invoke2) => {
|
|
27
|
+
function Command(request) {
|
|
28
|
+
const result = {
|
|
29
|
+
commandPath: {
|
|
30
|
+
clusterId: Specifier.clusterFor(request.cluster).id,
|
|
31
|
+
commandId: Invoke2.commandOf(request).requestId
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const endpointId = Specifier.endpointIdOf(request);
|
|
35
|
+
if (endpointId !== void 0) {
|
|
36
|
+
result.commandPath.endpointId = endpointId;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
Invoke2.Command = Command;
|
|
41
|
+
function commandOf(request) {
|
|
42
|
+
if (typeof request.command === "string") {
|
|
43
|
+
const cluster = Specifier.clusterFor(request.cluster);
|
|
44
|
+
if (cluster === void 0) {
|
|
45
|
+
throw new MalformedRequestError(`Cannot designate command "${request.command}" without cluster`);
|
|
46
|
+
}
|
|
47
|
+
const command = cluster.commands[request.command];
|
|
48
|
+
if (command === void 0) {
|
|
49
|
+
throw new MalformedRequestError(`Cluster ${cluster.name} does not define command ${request.command}`);
|
|
50
|
+
}
|
|
51
|
+
return command;
|
|
52
|
+
}
|
|
53
|
+
return request.command;
|
|
54
|
+
}
|
|
55
|
+
Invoke2.commandOf = commandOf;
|
|
56
|
+
})(Invoke || (Invoke = {}));
|
|
57
|
+
export {
|
|
58
|
+
Invoke
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Invoke.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
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AA,GAjCH;",
|
|
5
|
+
"names": ["Invoke"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ImplementationError } from "#general";
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when an action request does not adhere to the Matter specification.
|
|
9
|
+
*
|
|
10
|
+
* This is a client-side error that throws while formulating a request.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MalformedRequestError extends ImplementationError {
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=MalformedRequestError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MalformedRequestError.d.ts","sourceRoot":"","sources":["../../../../src/action/request/MalformedRequestError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB;CAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ImplementationError } from "#general";
|
|
7
|
+
class MalformedRequestError extends ImplementationError {
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
MalformedRequestError
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=MalformedRequestError.js.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AttributePath, ClusterType, DataVersionFilter, EventFilter, EventPath, GlobalAttributes, ReadRequest } from "#types";
|
|
7
|
+
import { Specifier } from "./Specifier.js";
|
|
8
|
+
/**
|
|
9
|
+
* A read request formulated using Matter protocol semantics.
|
|
10
|
+
*/
|
|
11
|
+
export interface Read extends ReadRequest {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Formulate a read request using Matter numeric IDs.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Read(options: Read.Options): Read;
|
|
17
|
+
/**
|
|
18
|
+
* Formulate a read request with extended options and name-based IDs.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Read(options: Read.Options, ...selectors: Read.Selector[]): Read;
|
|
21
|
+
/**
|
|
22
|
+
* Formulate a read request with name-based IDs.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Read(...selectors: Read.Selector[]): Read;
|
|
25
|
+
export declare namespace Read {
|
|
26
|
+
interface Options {
|
|
27
|
+
attributes?: AttributePath[];
|
|
28
|
+
versionFilters?: DataVersionFilter[];
|
|
29
|
+
events?: EventPath[];
|
|
30
|
+
eventFilters?: EventFilter[];
|
|
31
|
+
fabricFilter?: boolean;
|
|
32
|
+
interactionModelRevision?: number;
|
|
33
|
+
}
|
|
34
|
+
interface Attributes extends Read {
|
|
35
|
+
attributeRequests: Exclude<Read["attributeRequests"], undefined>;
|
|
36
|
+
}
|
|
37
|
+
function isAttribute(request: Read): request is Attributes;
|
|
38
|
+
interface Events extends Read {
|
|
39
|
+
eventRequests: Exclude<Read["eventRequests"], undefined>;
|
|
40
|
+
}
|
|
41
|
+
function isEvent(request: Read): request is Events;
|
|
42
|
+
/**
|
|
43
|
+
* Selects attributes or events to read.
|
|
44
|
+
*/
|
|
45
|
+
type Selector<C extends Specifier.Cluster = Specifier.Cluster> = ({
|
|
46
|
+
kind: "attribute";
|
|
47
|
+
} & AttributeSelector<C>) | ({
|
|
48
|
+
kind: "event";
|
|
49
|
+
} & EventSelector<C>);
|
|
50
|
+
/**
|
|
51
|
+
* Selects attributes to read. Limits fields to legal permutations per the Matter specification.
|
|
52
|
+
*/
|
|
53
|
+
type AttributeSelector<C extends Specifier.Cluster = Specifier.Cluster> = AttributeSelector.Concrete<C> | AttributeSelector.FullWildcard | AttributeSelector.Global | AttributeSelector.WildcardEndpoint<C> | AttributeSelector.WildcardAttribute | AttributeSelector.Endpoint;
|
|
54
|
+
/**
|
|
55
|
+
* Selects events to read. Limits fields to legal permutations per the Matter specification.
|
|
56
|
+
*/
|
|
57
|
+
type EventSelector<C extends Specifier.Cluster = Specifier.Cluster> = EventSelector.Concrete<C> | EventSelector.FullWildcard | EventSelector.WildcardEndpoint<C> | EventSelector.WildcardEvent | EventSelector.Endpoint;
|
|
58
|
+
function Attribute<const C extends ClusterType>(selector?: AttributeSelector<C>): {
|
|
59
|
+
kind: "attribute";
|
|
60
|
+
} & AttributeSelector<C>;
|
|
61
|
+
function Event<const T extends EventSelector>(selector: T): {
|
|
62
|
+
kind: "event";
|
|
63
|
+
} & T;
|
|
64
|
+
interface WildcardFlags {
|
|
65
|
+
skipRoot?: boolean;
|
|
66
|
+
skipCustom?: boolean;
|
|
67
|
+
skipDiagnostics?: boolean;
|
|
68
|
+
skipGlobals?: boolean;
|
|
69
|
+
skipAttributeList?: boolean;
|
|
70
|
+
skipCommandList?: boolean;
|
|
71
|
+
skipFixed?: boolean;
|
|
72
|
+
skipChangesOmitted?: boolean;
|
|
73
|
+
}
|
|
74
|
+
type GlobalAttributeSpecifier = ClusterType.Attribute | keyof GlobalAttributes<any>;
|
|
75
|
+
namespace AttributeSelector {
|
|
76
|
+
interface Concrete<C extends Specifier.Cluster> {
|
|
77
|
+
endpoint: Specifier.Endpoint;
|
|
78
|
+
cluster: C;
|
|
79
|
+
attributes: Specifier.Attribute<Specifier.ClusterFor<C>> | Specifier.Attribute<Specifier.ClusterFor<C>>[];
|
|
80
|
+
}
|
|
81
|
+
interface Wildcard {
|
|
82
|
+
flags?: WildcardFlags;
|
|
83
|
+
}
|
|
84
|
+
interface FullWildcard extends Wildcard {
|
|
85
|
+
endpoint?: undefined;
|
|
86
|
+
cluster?: undefined;
|
|
87
|
+
attributes?: undefined;
|
|
88
|
+
}
|
|
89
|
+
interface Global extends Wildcard {
|
|
90
|
+
endpoint?: Specifier.Endpoint;
|
|
91
|
+
cluster?: undefined;
|
|
92
|
+
attributes: GlobalAttributeSpecifier | GlobalAttributeSpecifier[];
|
|
93
|
+
}
|
|
94
|
+
interface WildcardEndpoint<C extends Specifier.Cluster> extends Wildcard {
|
|
95
|
+
endpoint?: undefined;
|
|
96
|
+
cluster: C;
|
|
97
|
+
attributes: Specifier.Attribute<Specifier.ClusterFor<C>> | Specifier.Attribute<Specifier.ClusterFor<C>>[];
|
|
98
|
+
}
|
|
99
|
+
interface WildcardAttribute extends Wildcard {
|
|
100
|
+
endpoint?: Specifier.Endpoint;
|
|
101
|
+
cluster: Specifier.Cluster;
|
|
102
|
+
attributes?: undefined;
|
|
103
|
+
}
|
|
104
|
+
interface Endpoint extends Wildcard {
|
|
105
|
+
endpoint: Specifier.Endpoint;
|
|
106
|
+
cluster?: undefined;
|
|
107
|
+
attributes?: undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
namespace EventSelector {
|
|
111
|
+
interface Concrete<C extends Specifier.Cluster> {
|
|
112
|
+
endpoint: Specifier.Endpoint;
|
|
113
|
+
cluster: Specifier.Cluster;
|
|
114
|
+
events: Specifier.Event<Specifier.ClusterFor<C>> | Specifier.Event<Specifier.ClusterFor<C>>[];
|
|
115
|
+
}
|
|
116
|
+
interface Wildcard {
|
|
117
|
+
flags?: WildcardFlags;
|
|
118
|
+
}
|
|
119
|
+
interface FullWildcard extends Wildcard {
|
|
120
|
+
endpoint?: undefined;
|
|
121
|
+
cluster?: undefined;
|
|
122
|
+
events?: undefined;
|
|
123
|
+
}
|
|
124
|
+
interface WildcardEndpoint<C extends Specifier.Cluster> extends Wildcard {
|
|
125
|
+
endpoint?: undefined;
|
|
126
|
+
cluster: Specifier.Cluster;
|
|
127
|
+
events: Specifier.Event<Specifier.ClusterFor<C>> | Specifier.Event<Specifier.ClusterFor<C>>[];
|
|
128
|
+
}
|
|
129
|
+
interface WildcardEvent extends Wildcard {
|
|
130
|
+
endpoint: Specifier.Endpoint;
|
|
131
|
+
cluster: Specifier.Cluster;
|
|
132
|
+
events?: undefined;
|
|
133
|
+
}
|
|
134
|
+
interface Endpoint extends Wildcard {
|
|
135
|
+
endpoint: Specifier.Endpoint;
|
|
136
|
+
cluster?: undefined;
|
|
137
|
+
events?: undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=Read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Read.d.ts","sourceRoot":"","sources":["../../../../src/action/request/Read.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,WAAW,EACd,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;CAAG;AAE5C;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AAElD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;AAEjF;;GAEG;AACH,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;AA6J1D,yBAAiB,IAAI,CAAC;IAClB,UAAiB,OAAO;QACpB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;QAC7B,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACrC,MAAM,CAAC,EAAE,SA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import { camelize } from "@matter/general";
|
|
8
|
+
import { MalformedRequestError } from "./MalformedRequestError.js";
|
|
9
|
+
import { Specifier } from "./Specifier.js";
|
|
10
|
+
function Read(optionsOrSelector, ...selectors) {
|
|
11
|
+
let options;
|
|
12
|
+
if ("kind" in optionsOrSelector) {
|
|
13
|
+
selectors = [optionsOrSelector, ...selectors];
|
|
14
|
+
options = {};
|
|
15
|
+
} else {
|
|
16
|
+
options = optionsOrSelector;
|
|
17
|
+
}
|
|
18
|
+
let { attributes: attributeRequests, versionFilters, events: eventRequests, eventFilters } = options;
|
|
19
|
+
const result = {
|
|
20
|
+
isFabricFiltered: options.fabricFilter ?? true,
|
|
21
|
+
interactionModelRevision: options.interactionModelRevision ?? FALLBACK_INTERACTIONMODEL_REVISION
|
|
22
|
+
};
|
|
23
|
+
for (const selector of selectors) {
|
|
24
|
+
reifySelector(selector);
|
|
25
|
+
}
|
|
26
|
+
if (!attributeRequests?.length && !eventRequests?.length) {
|
|
27
|
+
throw new MalformedRequestError(`Read action designates no attributes or events`);
|
|
28
|
+
}
|
|
29
|
+
if (attributeRequests) {
|
|
30
|
+
result.attributeRequests = attributeRequests;
|
|
31
|
+
}
|
|
32
|
+
if (versionFilters) {
|
|
33
|
+
result.dataVersionFilters = versionFilters;
|
|
34
|
+
}
|
|
35
|
+
if (eventRequests) {
|
|
36
|
+
result.eventRequests = eventRequests;
|
|
37
|
+
}
|
|
38
|
+
if (eventFilters !== void 0) {
|
|
39
|
+
result.eventFilters = eventFilters;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
function reifySelector(selector) {
|
|
43
|
+
switch (selector.kind) {
|
|
44
|
+
case "attribute":
|
|
45
|
+
reifyAttributeSelector(selector);
|
|
46
|
+
break;
|
|
47
|
+
case "event":
|
|
48
|
+
reifyEventSelector(selector);
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
throw new MalformedRequestError(`Invalid selector kind "${selector.kind}"`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function reifyAttributeSelector(selector) {
|
|
55
|
+
const cluster = Specifier.clusterOf(selector);
|
|
56
|
+
const { endpoint } = selector;
|
|
57
|
+
if (typeof endpoint === "object" && endpoint?.versions && typeof cluster === "object" && cluster !== null) {
|
|
58
|
+
const version = endpoint.versions?.[camelize(cluster.name)];
|
|
59
|
+
if (version !== void 0) {
|
|
60
|
+
const filter = {
|
|
61
|
+
path: { endpointId: endpoint.number, clusterId: cluster.id },
|
|
62
|
+
dataVersion: version
|
|
63
|
+
};
|
|
64
|
+
if (versionFilters === void 0) {
|
|
65
|
+
versionFilters = [filter];
|
|
66
|
+
} else if (versionFilters.find(
|
|
67
|
+
({ path: { endpointId, clusterId } }) => endpointId === endpoint.number && clusterId === cluster.id
|
|
68
|
+
) === void 0) {
|
|
69
|
+
versionFilters.push(filter);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (attributeRequests === void 0) {
|
|
74
|
+
attributeRequests = [];
|
|
75
|
+
}
|
|
76
|
+
const prototype = {};
|
|
77
|
+
if (endpoint !== void 0) {
|
|
78
|
+
prototype.endpointId = Specifier.endpointIdOf(selector);
|
|
79
|
+
}
|
|
80
|
+
if (cluster !== void 0) {
|
|
81
|
+
prototype.clusterId = cluster.id;
|
|
82
|
+
}
|
|
83
|
+
let { attributes } = selector;
|
|
84
|
+
if (attributes === void 0) {
|
|
85
|
+
attributeRequests.push(prototype);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!Array.isArray(attributes)) {
|
|
89
|
+
attributes = [attributes];
|
|
90
|
+
}
|
|
91
|
+
for (const specifier of attributes) {
|
|
92
|
+
attributeRequests.push({ ...prototype, attributeId: Specifier.attributeFor(cluster, specifier).id });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function reifyEventSelector(selector) {
|
|
96
|
+
const cluster = Specifier.clusterOf(selector);
|
|
97
|
+
const { endpoint } = selector;
|
|
98
|
+
if (typeof endpoint === "object" && endpoint.minEvent !== void 0) {
|
|
99
|
+
if (eventFilters === void 0) {
|
|
100
|
+
eventFilters = [{ eventMin: endpoint.minEvent }];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (eventRequests === void 0) {
|
|
104
|
+
eventRequests = [];
|
|
105
|
+
}
|
|
106
|
+
const prototype = {};
|
|
107
|
+
if (endpoint !== void 0) {
|
|
108
|
+
prototype.endpointId = Specifier.endpointIdOf(selector);
|
|
109
|
+
}
|
|
110
|
+
if (cluster !== void 0) {
|
|
111
|
+
prototype.clusterId = cluster.id;
|
|
112
|
+
}
|
|
113
|
+
let { events } = selector;
|
|
114
|
+
if (events === void 0) {
|
|
115
|
+
eventRequests.push(prototype);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!Array.isArray(events)) {
|
|
119
|
+
events = [events];
|
|
120
|
+
}
|
|
121
|
+
for (const specifier of events) {
|
|
122
|
+
eventRequests.push({ ...prototype, eventId: Specifier.eventFor(cluster, specifier).id });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
((Read2) => {
|
|
127
|
+
function isAttribute(request) {
|
|
128
|
+
return !!request.attributeRequests?.length;
|
|
129
|
+
}
|
|
130
|
+
Read2.isAttribute = isAttribute;
|
|
131
|
+
function isEvent(request) {
|
|
132
|
+
return !!request.eventRequests?.length;
|
|
133
|
+
}
|
|
134
|
+
Read2.isEvent = isEvent;
|
|
135
|
+
function Attribute(selector) {
|
|
136
|
+
return {
|
|
137
|
+
kind: "attribute",
|
|
138
|
+
...selector
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
Read2.Attribute = Attribute;
|
|
142
|
+
function Event(selector) {
|
|
143
|
+
return {
|
|
144
|
+
kind: "event",
|
|
145
|
+
...selector
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
Read2.Event = Event;
|
|
149
|
+
})(Read || (Read = {}));
|
|
150
|
+
export {
|
|
151
|
+
Read
|
|
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+1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ClusterType, EndpointNumber, GlobalAttributeNames } from "#types";
|
|
7
|
+
/**
|
|
8
|
+
* A "specifier" addresses a specific element of the Matter data model in the context of a request.
|
|
9
|
+
*/
|
|
10
|
+
export declare namespace Specifier {
|
|
11
|
+
/**
|
|
12
|
+
* Clusters we designate with an object to convey structural and type information. The second form of this union
|
|
13
|
+
* allows for specification with a host object (such as a ClusterBehavior instance or class).
|
|
14
|
+
*/
|
|
15
|
+
type Cluster = ClusterType | {
|
|
16
|
+
cluster: ClusterType;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* You may address endpoints with a bare ID but the object form allows an "endpoint object" as input and optionally
|
|
20
|
+
* conveys additional metadata.
|
|
21
|
+
*/
|
|
22
|
+
type Endpoint = EndpointNumber | {
|
|
23
|
+
number: EndpointNumber;
|
|
24
|
+
versions?: Record<string, number>;
|
|
25
|
+
minEvent?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* An attribute specifier may be the name of a cluster attribute or the name of a cluster or global attribute.
|
|
29
|
+
*/
|
|
30
|
+
type Attribute<C extends ClusterType = ClusterType> = ClusterType.Attribute | (string & keyof C["attributes"]) | GlobalAttributeNames<any>;
|
|
31
|
+
/**
|
|
32
|
+
* A command specifier may be the name of a cluster attribute or the name of a cluster command.
|
|
33
|
+
*/
|
|
34
|
+
type Command<C extends ClusterType = ClusterType> = ClusterType.Command | (string & keyof C["commands"]);
|
|
35
|
+
/**
|
|
36
|
+
* An event specifier may be the name of a cluser event or an event object.
|
|
37
|
+
*/
|
|
38
|
+
type Event<C extends ClusterType = ClusterType> = ClusterType.Event | (string & keyof C["events"]);
|
|
39
|
+
/**
|
|
40
|
+
* Extract a cluster type from a cluster specifier type.
|
|
41
|
+
*/
|
|
42
|
+
type ClusterFor<T extends Cluster> = T extends ClusterType ? T : T extends {
|
|
43
|
+
cluster: ClusterType;
|
|
44
|
+
} ? T["cluster"] : never;
|
|
45
|
+
/**
|
|
46
|
+
* Extract a cluster type from a cluster specifier.
|
|
47
|
+
*/
|
|
48
|
+
function clusterFor<const T extends Cluster>(specifier: T): ClusterFor<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Extract an attribute object from a cluster and attribute specifier.
|
|
51
|
+
*/
|
|
52
|
+
function attributeFor(cluster: ClusterType | undefined, specifier: Specifier.Attribute): ClusterType.Attribute;
|
|
53
|
+
/**
|
|
54
|
+
* Extract a command type from a cluster type and command specifier.
|
|
55
|
+
*/
|
|
56
|
+
type CommandFor<C extends ClusterType, CMD extends Specifier.Command<C>> = CMD extends string ? C["commands"][CMD] : CMD extends ClusterType.Command ? CMD : never;
|
|
57
|
+
/**
|
|
58
|
+
* Extract an event object from a cluster and event specifier.
|
|
59
|
+
*/
|
|
60
|
+
function eventFor(cluster: ClusterType | undefined, specifier: Specifier.Event): ClusterType.Event;
|
|
61
|
+
/**
|
|
62
|
+
* Extract the cluster type from a cluster request type.
|
|
63
|
+
*/
|
|
64
|
+
type ClusterOf<T extends {
|
|
65
|
+
cluster?: Cluster;
|
|
66
|
+
}> = T extends {
|
|
67
|
+
cluster: Specifier.Cluster;
|
|
68
|
+
} ? Specifier.ClusterFor<T["cluster"]> : undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Extract the cluster type from an element request.
|
|
71
|
+
*/
|
|
72
|
+
function clusterOf<const T extends {
|
|
73
|
+
cluster?: Cluster;
|
|
74
|
+
}>(request: T): ClusterOf<T>;
|
|
75
|
+
/**
|
|
76
|
+
* Determine endpoint number for an object with an endpoint specifier.
|
|
77
|
+
*/
|
|
78
|
+
function endpointIdOf<const T extends {
|
|
79
|
+
endpoint?: Endpoint;
|
|
80
|
+
}>(request: T): EndpointNumber | undefined;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=Spec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-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GlobalAttributes } from "#types";
|
|
7
|
+
import { MalformedRequestError } from "./MalformedRequestError.js";
|
|
8
|
+
const GlobalAttrMap = GlobalAttributes({});
|
|
9
|
+
var Specifier;
|
|
10
|
+
((Specifier2) => {
|
|
11
|
+
function clusterFor(specifier) {
|
|
12
|
+
if ("cluster" in specifier) {
|
|
13
|
+
return specifier["cluster"];
|
|
14
|
+
}
|
|
15
|
+
return specifier;
|
|
16
|
+
}
|
|
17
|
+
Specifier2.clusterFor = clusterFor;
|
|
18
|
+
function attributeFor(cluster, specifier) {
|
|
19
|
+
if (typeof specifier === "object") {
|
|
20
|
+
return specifier;
|
|
21
|
+
}
|
|
22
|
+
if (cluster === void 0) {
|
|
23
|
+
const attr2 = GlobalAttrMap[specifier];
|
|
24
|
+
if (attr2 === void 0) {
|
|
25
|
+
throw new MalformedRequestError(`Cannot designate event "${specifier}" without a cluster`);
|
|
26
|
+
}
|
|
27
|
+
return attr2;
|
|
28
|
+
}
|
|
29
|
+
const attr = cluster.attributes?.[specifier];
|
|
30
|
+
if (attr === void 0) {
|
|
31
|
+
throw new MalformedRequestError(`Cluster ${cluster.name} does not define attribute ${specifier}`);
|
|
32
|
+
}
|
|
33
|
+
return attr;
|
|
34
|
+
}
|
|
35
|
+
Specifier2.attributeFor = attributeFor;
|
|
36
|
+
function eventFor(cluster, specifier) {
|
|
37
|
+
if (typeof specifier === "object") {
|
|
38
|
+
return specifier;
|
|
39
|
+
}
|
|
40
|
+
if (cluster === void 0) {
|
|
41
|
+
throw new MalformedRequestError(`Cannot designate event "${specifier}" without a cluster`);
|
|
42
|
+
}
|
|
43
|
+
const event = cluster.events?.[specifier];
|
|
44
|
+
if (event === void 0) {
|
|
45
|
+
throw new MalformedRequestError(`Cluster ${cluster.name} does not define event ${specifier}`);
|
|
46
|
+
}
|
|
47
|
+
return event;
|
|
48
|
+
}
|
|
49
|
+
Specifier2.eventFor = eventFor;
|
|
50
|
+
function clusterOf(request) {
|
|
51
|
+
if (request.cluster) {
|
|
52
|
+
return Specifier2.clusterFor(request.cluster);
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
Specifier2.clusterOf = clusterOf;
|
|
57
|
+
function endpointIdOf(request) {
|
|
58
|
+
if (typeof request.endpoint === "number") {
|
|
59
|
+
return request.endpoint;
|
|
60
|
+
}
|
|
61
|
+
return request.endpoint?.number;
|
|
62
|
+
}
|
|
63
|
+
Specifier2.endpointIdOf = endpointIdOf;
|
|
64
|
+
})(Specifier || (Specifier = {}));
|
|
65
|
+
export {
|
|
66
|
+
Specifier
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=Specifier.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/action/request/Specifier.ts"],
|
|
4
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAA4D,wBAAwB;AACpF,SAAS,6BAA6B;AAEtC,MAAM,gBAAgB,iBAAiB,CAAC,CAAC;AAKlC,IAAU;AAAA,CAAV,CAAUA,eAAV;AA6CI,WAAS,WAAoC,WAAc;AAC9D,QAAI,aAAa,WAAW;AACxB,aAAO,UAAU,SAAS;AAAA,IAC9B;AACA,WAAO;AAAA,EACX;AALO,EAAAA,WAAS;AAUT,WAAS,aAAa,SAAkC,WAAgC;AAC3F,QAAI,OAAO,cAAc,UAAU;AAC/B,aAAO;AAAA,IACX;AAEA,QAAI,YAAY,QAAW;AACvB,YAAMC,QAAO,cAAc,SAAS;AACpC,UAAIA,UAAS,QAAW;AACpB,cAAM,IAAI,sBAAsB,2BAA2B,SAAS,qBAAqB;AAAA,MAC7F;AACA,aAAOA;AAAA,IACX;AAEA,UAAM,OAAO,QAAQ,aAAa,SAAS;AAC3C,QAAI,SAAS,QAAW;AACpB,YAAM,IAAI,sBAAsB,WAAW,QAAQ,IAAI,8BAA8B,SAAS,EAAE;AAAA,IACpG;AAEA,WAAO;AAAA,EACX;AAnBO,EAAAD,WAAS;AAiCT,WAAS,SAAS,SAAkC,WAA4B;AACnF,QAAI,OAAO,cAAc,UAAU;AAC/B,aAAO;AAAA,IACX;AAEA,QAAI,YAAY,QAAW;AACvB,YAAM,IAAI,sBAAsB,2BAA2B,SAAS,qBAAqB;AAAA,IAC7F;AAEA,UAAM,QAAQ,QAAQ,SAAS,SAAS;AACxC,QAAI,UAAU,QAAW;AACrB,YAAM,IAAI,sBAAsB,WAAW,QAAQ,IAAI,0BAA0B,SAAS,EAAE;AAAA,IAChG;AAEA,WAAO;AAAA,EACX;AAfO,EAAAA,WAAS;AA2BT,WAAS,UAAiD,SAA0B;AACvF,QAAI,QAAQ,SAAS;AACjB,aAAOA,WAAU,WAAW,QAAQ,OAAO;AAAA,IAC/C;AACA,WAAO;AAAA,EACX;AALO,EAAAA,WAAS;AAUT,WAAS,aAAsD,SAAwC;AAC1G,QAAI,OAAO,QAAQ,aAAa,UAAU;AACtC,aAAO,QAAQ;AAAA,IACnB;AACA,WAAO,QAAQ,UAAU;AAAA,EAC7B;AALO,EAAAA,WAAS;AAAA,GA7HH;",
|
|
5
|
+
"names": ["Specifier", "attr"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Read } from "./Read.js";
|
|
7
|
+
/**
|
|
8
|
+
* Defines a subscription.
|
|
9
|
+
*
|
|
10
|
+
* The subscription interval fields are optional as matter.js will set them to appropriate defaults based on physical
|
|
11
|
+
* attributes of the target device. If you are unsure of appropriate values do not set them.
|
|
12
|
+
*/
|
|
13
|
+
export interface Subscribe extends Read {
|
|
14
|
+
keepSubscriptions: boolean;
|
|
15
|
+
minIntervalFloorSeconds?: number;
|
|
16
|
+
maxIntervalCeilingSeconds?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function Subscribe(options: Subscribe.Options): Subscribe;
|
|
19
|
+
export declare namespace Subscribe {
|
|
20
|
+
interface Options extends Read.Options {
|
|
21
|
+
keepSubscriptions?: boolean;
|
|
22
|
+
minIntervalFloorSeconds?: number;
|
|
23
|
+
maxIntervalCeilingSeconds?: number;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Subscribe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscribe.d.ts","sourceRoot":"","sources":["../../../../src/action/request/Subscribe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI;IACnC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAqB/D;AAED,yBAAiB,SAAS,CAAC;IACvB,UAAiB,OAAQ,SAAQ,IAAI,CAAC,OAAO;QACzC,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;KACtC;CACJ"}
|