Skip to content

Commit 40fb5f0

Browse files
refactor: clean-up/remove interfaces that are not needed/used
1 parent 52b067c commit 40fb5f0

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

packages/binding-opcua/src/opcua-protocol-client.ts

+6-16
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { makeBrowsePath } from "node-opcua-service-translate-browse-path";
4545
import { StatusCodes } from "node-opcua-status-code";
4646

4747
import { schemaDataValue } from "./codec";
48-
import { FormElementProperty } from "wot-thing-description-types";
4948
import { opcuaJsonEncodeVariant } from "node-opcua-json";
5049
import { Argument, BrowseDescription, BrowseResult } from "node-opcua-types";
5150
import { isGoodish2, ReferenceTypeIds } from "node-opcua";
@@ -64,20 +63,11 @@ export type NodeIdLike2 = NodeIdLike & {
6463
};
6564

6665
export interface FormPartialNodeDescription {
67-
"opcua:nodeId"?: NodeIdLike | NodeByBrowsePath;
66+
"opcua:nodeId"?: NodeIdLike | NodeByBrowsePath; // TODO remove in future, kept for backwards compatibility only
6867
}
6968

7069
export interface OPCUAForm extends Form, FormPartialNodeDescription {}
7170

72-
export interface OPCUAFormElement extends FormElementProperty, FormPartialNodeDescription {}
73-
74-
export interface OPCUAFormInvoke extends OPCUAForm {
75-
"opcua:method"?: NodeIdLike | NodeByBrowsePath;
76-
}
77-
export interface OPCUAFormSubscribe extends OPCUAForm {
78-
"opcua:samplingInterval"?: number;
79-
}
80-
8171
interface OPCUAConnection {
8272
session: ClientSession;
8373
client: OPCUAClient;
@@ -301,14 +291,14 @@ export class OPCUAProtocolClient implements ProtocolClient {
301291
});
302292
}
303293

304-
private async _resolveMethodNodeId(form: OPCUAFormInvoke): Promise<NodeId> {
294+
private async _resolveMethodNodeId(form: OPCUAForm): Promise<NodeId> {
305295
// const objectNode = this._resolveNodeId(form);
306296
const fNodeId = form["opcua:method"];
307297
if (fNodeId == null) {
308298
debug(`resolveNodeId: form = ${form}`);
309299
throw new Error("form must expose a 'opcua:method'");
310300
}
311-
return this._resolveNodeId2(form, fNodeId);
301+
return this._resolveNodeId2(form, fNodeId as NodeIdLike | NodeByBrowsePath);
312302
}
313303

314304
public async readResource(form: OPCUAForm): Promise<Content> {
@@ -343,7 +333,7 @@ export class OPCUAProtocolClient implements ProtocolClient {
343333
}
344334
}
345335

346-
public async invokeResource(form: OPCUAFormInvoke, content: Content): Promise<Content> {
336+
public async invokeResource(form: OPCUAForm, content: Content): Promise<Content> {
347337
return await this._withSession(form, async (session) => {
348338
const objectId = await this._resolveNodeId(form);
349339
const methodId = await this._resolveMethodNodeId(form);
@@ -590,7 +580,7 @@ export class OPCUAProtocolClient implements ProtocolClient {
590580

591581
private async _resolveInputArguments(
592582
session: IBasicSession,
593-
form: OPCUAFormInvoke,
583+
form: OPCUAForm,
594584
content: Content | undefined | null,
595585
argumentDefinition: ArgumentDefinition
596586
): Promise<VariantOptions[]> {
@@ -638,7 +628,7 @@ export class OPCUAProtocolClient implements ProtocolClient {
638628

639629
private async _resolveOutputArguments(
640630
session: IBasicSession,
641-
form: OPCUAFormInvoke,
631+
form: OPCUAForm,
642632
argumentDefinition: ArgumentDefinition,
643633
outputVariants: Variant[]
644634
): Promise<Content> {

packages/binding-opcua/test/client-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { ContentSerdes, createLoggers } from "@node-wot/core";
1919

2020
import { VariableIds, OPCUAServer } from "node-opcua";
2121

22-
import { OPCUAProtocolClient, OPCUAForm, OPCUAFormInvoke } from "../src/opcua-protocol-client";
22+
import { OPCUAProtocolClient, OPCUAForm } from "../src/opcua-protocol-client";
2323
import { OpcuaJSONCodec, schemaDataValue } from "../src/codec";
2424
import { startServer } from "./fixture/basic-opcua-server";
2525

@@ -164,7 +164,7 @@ describe("OPCUA Client", function () {
164164
required: ["TargetTemperature"],
165165
};
166166

167-
const form: OPCUAFormInvoke = {
167+
const form: OPCUAForm = {
168168
href: endpoint,
169169
"opcua:nodeId": { root: "i=84", path: "/Objects/1:MySensor" },
170170
"opcua:method": { root: "i=84", path: "/Objects/1:MySensor/2:MethodSet/1:SetTemperatureSetPoint" },

0 commit comments

Comments
 (0)