opcjs-client 0.1.13 → 0.1.17-alpha
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/index.cjs +396 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -5
- package/dist/index.d.ts +141 -5
- package/dist/index.js +397 -33
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISecureChannel, RequestHeader, NodeId, EndpointDescription, UserIdentityToken, Configuration, UserTokenTypeEnum, Encoder, Decoder } from 'opcjs-base';
|
|
1
|
+
import { ISecureChannel, RequestHeader, NodeId, EndpointDescription, UserIdentityToken, Configuration, UserTokenTypeEnum, ILoggerFactory, Encoder, Decoder } from 'opcjs-base';
|
|
2
2
|
|
|
3
3
|
declare abstract class ServiceBase {
|
|
4
4
|
private authToken;
|
|
@@ -9,6 +9,7 @@ declare abstract class ServiceBase {
|
|
|
9
9
|
|
|
10
10
|
declare class SessionService extends ServiceBase {
|
|
11
11
|
private configuration;
|
|
12
|
+
private logger;
|
|
12
13
|
createSession(): Promise<{
|
|
13
14
|
sessionId: number;
|
|
14
15
|
authToken: NodeId;
|
|
@@ -19,6 +20,15 @@ declare class SessionService extends ServiceBase {
|
|
|
19
20
|
constructor(authToken: NodeId, secureChannel: ISecureChannel, configuration: Configuration);
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
interface IssuerEndpointUrl {
|
|
24
|
+
'ua.resourceId': string;
|
|
25
|
+
'ua.authorityUrl': string;
|
|
26
|
+
'ua.authorityProfileUri': string;
|
|
27
|
+
'ua.tokenEndpoint': string;
|
|
28
|
+
'ua.authorizationEndpoint': string;
|
|
29
|
+
'ua.requestTypes': string[];
|
|
30
|
+
'ua.scopes': string[];
|
|
31
|
+
}
|
|
22
32
|
declare class IssuerConfiguration {
|
|
23
33
|
resourceId: string;
|
|
24
34
|
authorityUrl: string;
|
|
@@ -27,7 +37,7 @@ declare class IssuerConfiguration {
|
|
|
27
37
|
authorizationEndpoint: string;
|
|
28
38
|
requestTypes: string[];
|
|
29
39
|
scopes: string[];
|
|
30
|
-
static newFrom(issuerEndpointUrl:
|
|
40
|
+
static newFrom(issuerEndpointUrl: IssuerEndpointUrl): IssuerConfiguration;
|
|
31
41
|
constructor(resourceId: string, authorityUrl: string, authorityProfileUri: string, tokenEndpoint: string, authorizationEndpoint: string, requestTypes: string[], scopes: string[]);
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -65,21 +75,147 @@ declare class ReadValueResult {
|
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
declare class ConfigurationClient extends Configuration {
|
|
68
|
-
static getSimple(name: string, company: string): ConfigurationClient;
|
|
69
|
-
constructor(applicationName: string, applicationUri: string, productName: string, productUri: string, encoder: Encoder, decoder: Decoder);
|
|
78
|
+
static getSimple(name: string, company: string, loggerFactory?: ILoggerFactory): ConfigurationClient;
|
|
79
|
+
constructor(applicationName: string, applicationUri: string, productName: string, productUri: string, encoder: Encoder, decoder: Decoder, loggerFactory: ILoggerFactory);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare class CallMethodResult {
|
|
83
|
+
values: unknown[];
|
|
84
|
+
status: string;
|
|
85
|
+
constructor(values: unknown[], status: string);
|
|
70
86
|
}
|
|
71
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Enumeration of variant types based on BuiltinType NodeIds.
|
|
90
|
+
*/
|
|
91
|
+
declare enum BuiltInType {
|
|
92
|
+
Null = 0,
|
|
93
|
+
Boolean = 1,
|
|
94
|
+
SByte = 2,
|
|
95
|
+
Byte = 3,
|
|
96
|
+
Int16 = 4,
|
|
97
|
+
UInt16 = 5,
|
|
98
|
+
Int32 = 6,
|
|
99
|
+
UInt32 = 7,
|
|
100
|
+
Int64 = 8,
|
|
101
|
+
UInt64 = 9,
|
|
102
|
+
Float = 10,
|
|
103
|
+
Double = 11,
|
|
104
|
+
String = 12,
|
|
105
|
+
DateTime = 13,
|
|
106
|
+
Guid = 14,
|
|
107
|
+
ByteString = 15,
|
|
108
|
+
XmlElement = 16,
|
|
109
|
+
NodeId = 17,
|
|
110
|
+
ExpandedNodeId = 18,
|
|
111
|
+
StatusCode = 19,
|
|
112
|
+
QualifiedName = 20,
|
|
113
|
+
LocalizedText = 21,
|
|
114
|
+
ExtensionObject = 22,
|
|
115
|
+
DataValue = 23,
|
|
116
|
+
Variant = 24,
|
|
117
|
+
DiagnosticInfo = 25
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* OPC UA Primitive Type Mappings
|
|
122
|
+
*
|
|
123
|
+
* We try to use the JS built in types wherever we can. But sometimes, often in the context
|
|
124
|
+
* where Variant is involved, we need to have a wrapper type that includes the BuiltInType
|
|
125
|
+
* for type checking and encoding purposes. In those cases, we define a wrapper type with a
|
|
126
|
+
* value and a type field. For simple cases like boolean, we can just use the native boolean
|
|
127
|
+
* type directly as UaBoolean.
|
|
128
|
+
* @module primitives
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
type UaBoolean = boolean;
|
|
132
|
+
/**
|
|
133
|
+
* OPC UA Builtin Type Numeric IDs
|
|
134
|
+
*
|
|
135
|
+
* These correspond to the NodeId numeric identifiers defined in OPC UA Part 6, Table 1.
|
|
136
|
+
*/
|
|
137
|
+
type UaSbyte = {
|
|
138
|
+
value: number;
|
|
139
|
+
readonly type: BuiltInType.SByte;
|
|
140
|
+
};
|
|
141
|
+
type UaByte = {
|
|
142
|
+
value: number;
|
|
143
|
+
readonly type: BuiltInType.Byte;
|
|
144
|
+
};
|
|
145
|
+
type UaInt16 = {
|
|
146
|
+
value: number;
|
|
147
|
+
readonly type: BuiltInType.Int16;
|
|
148
|
+
};
|
|
149
|
+
type UaUint16 = {
|
|
150
|
+
value: number;
|
|
151
|
+
readonly type: BuiltInType.UInt16;
|
|
152
|
+
};
|
|
153
|
+
type UaInt32 = {
|
|
154
|
+
value: number;
|
|
155
|
+
readonly type: BuiltInType.Int32;
|
|
156
|
+
};
|
|
157
|
+
type UaUint32 = {
|
|
158
|
+
value: number;
|
|
159
|
+
readonly type: BuiltInType.UInt32;
|
|
160
|
+
};
|
|
161
|
+
type UaInt64 = {
|
|
162
|
+
value: bigint;
|
|
163
|
+
readonly type: BuiltInType.Int64;
|
|
164
|
+
};
|
|
165
|
+
type UaUint64 = {
|
|
166
|
+
value: bigint;
|
|
167
|
+
readonly type: BuiltInType.UInt64;
|
|
168
|
+
};
|
|
169
|
+
type UaFloat = {
|
|
170
|
+
value: number;
|
|
171
|
+
readonly type: BuiltInType.Float;
|
|
172
|
+
};
|
|
173
|
+
type UaDouble = {
|
|
174
|
+
value: number;
|
|
175
|
+
readonly type: BuiltInType.Double;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* OPC UA String primitive type.
|
|
179
|
+
*
|
|
180
|
+
* A String in OPC UA can be null (encoded as length -1 in binary).
|
|
181
|
+
* Using `string | null` instead of `string | undefined` aligns with the
|
|
182
|
+
* OPC UA specification where null is an explicit, valid value distinct
|
|
183
|
+
* from an empty string. Same is true for ByteString which can be null (length -1)
|
|
184
|
+
* or a Uint8Array.
|
|
185
|
+
*/
|
|
186
|
+
type UaString = string | null;
|
|
187
|
+
type UaByteString = Uint8Array | null;
|
|
188
|
+
type UaGuid = {
|
|
189
|
+
value: string;
|
|
190
|
+
readonly type: BuiltInType.Guid;
|
|
191
|
+
};
|
|
192
|
+
type UaDateTime = Date;
|
|
193
|
+
/**
|
|
194
|
+
* Union of all OPC UA primitive types accepted by {@link Variant.newFrom}.
|
|
195
|
+
*/
|
|
196
|
+
type UaPrimitive = UaBoolean | UaSbyte | UaByte | UaInt16 | UaUint16 | UaInt32 | UaUint32 | UaInt64 | UaUint64 | UaFloat | UaDouble | UaString | UaDateTime | UaGuid | UaByteString;
|
|
197
|
+
|
|
72
198
|
declare class Client {
|
|
73
199
|
private configuration;
|
|
74
200
|
private identity;
|
|
75
201
|
private endpointUrl;
|
|
76
|
-
private
|
|
202
|
+
private attributeService?;
|
|
203
|
+
private methodService?;
|
|
77
204
|
private session?;
|
|
78
205
|
private subscriptionHandler?;
|
|
206
|
+
private logger;
|
|
79
207
|
getSession(): Session;
|
|
80
208
|
connect(): Promise<void>;
|
|
81
209
|
disconnect(): Promise<void>;
|
|
82
210
|
read(ids: NodeId[]): Promise<ReadValueResult[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Method for calling a single method on the server.
|
|
213
|
+
* @param objectId - NodeId of the Object that owns the method.
|
|
214
|
+
* @param methodId - NodeId of the Method to invoke.
|
|
215
|
+
* @param inputArguments - Input argument Variants (default: empty).
|
|
216
|
+
* @returns The CallMethodResult for the invoked method.
|
|
217
|
+
*/
|
|
218
|
+
callMethod(objectId: NodeId, methodId: NodeId, inputArguments?: UaPrimitive[]): Promise<CallMethodResult>;
|
|
83
219
|
subscribe(ids: NodeId[], callback: (data: {
|
|
84
220
|
id: NodeId;
|
|
85
221
|
value: unknown;
|