opcua-webapi-ts 1.0.23 → 1.0.25

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.
@@ -364,11 +364,13 @@ class UaWebClient {
364
364
  if (!response.Results || nodesToBrowse.length != response.Results.length)
365
365
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
366
366
  let results = [];
367
- for (let item of response.Results) {
368
- let result = common_1.UaBrowseResult.fromStruct(item);
369
- if (null == result)
370
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
371
- results.push(result);
367
+ if (response.Results) {
368
+ for (let item of response.Results) {
369
+ let result = common_1.UaBrowseResult.fromStruct(item);
370
+ if (null == result)
371
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
372
+ results.push(result);
373
+ }
372
374
  }
373
375
  return results;
374
376
  });
@@ -37,9 +37,11 @@ class UaCallMethodRequest {
37
37
  let inputArguments = [];
38
38
  if (null == objectId || null == methodId)
39
39
  return null;
40
- for (let item of callMethodRequest.InputArguments) {
41
- let variant = _1.UaPayloadMapper.variantFromWebApi(item);
42
- inputArguments.push(variant);
40
+ if (callMethodRequest.InputArguments) {
41
+ for (let item of callMethodRequest.InputArguments) {
42
+ let variant = _1.UaPayloadMapper.variantFromWebApi(item);
43
+ inputArguments.push(variant);
44
+ }
43
45
  }
44
46
  return new UaCallMethodRequest(objectId, methodId, inputArguments);
45
47
  }
@@ -42,8 +42,10 @@ class UaCallMethodResult {
42
42
  static fromStruct(callMethodResult) {
43
43
  let statusCode = _1.UaPayloadMapper.statusCodeFromWebApi(callMethodResult.StatusCode);
44
44
  let outputArguments = [];
45
- for (let item of callMethodResult.OutputArguments) {
46
- outputArguments.push(_1.UaPayloadMapper.variantFromWebApi(item));
45
+ if (callMethodResult.OutputArguments) {
46
+ for (let item of callMethodResult.OutputArguments) {
47
+ outputArguments.push(_1.UaPayloadMapper.variantFromWebApi(item));
48
+ }
47
49
  }
48
50
  let inputArgumentResults = undefined;
49
51
  if (callMethodResult.InputArgumentResults) {
@@ -3,11 +3,11 @@ import { UaExtensionObject, UaNodeId, UaStatusCode } from "../types";
3
3
  export declare class UaHistoryReadResult {
4
4
  static dataTypeId: UaNodeId;
5
5
  private _statusCode;
6
- private _historyData;
6
+ private _historyData?;
7
7
  private _continuationPoint?;
8
- constructor(statusCode: UaStatusCode, historyData: UaExtensionObject, continuationPoint?: string);
8
+ constructor(statusCode: UaStatusCode, historyData?: UaExtensionObject, continuationPoint?: string);
9
9
  get statusCode(): UaStatusCode;
10
- get historyData(): UaExtensionObject;
10
+ get historyData(): UaExtensionObject | undefined;
11
11
  get continuationPoint(): string | undefined;
12
12
  toStruct(): HistoryReadResult;
13
13
  static fromStruct(historyReadResult: HistoryReadResult): UaHistoryReadResult | null;
@@ -29,8 +29,11 @@ class UaHistoryReadResult {
29
29
  }
30
30
  static fromStruct(historyReadResult) {
31
31
  let statusCode = _1.UaPayloadMapper.statusCodeFromWebApi(historyReadResult.StatusCode);
32
- let historyData = _1.UaPayloadMapper.extensionObjectFromWebApi(historyReadResult.HistoryData);
32
+ let historyData = undefined;
33
33
  let continuationPoint = historyReadResult.ContinuationPoint;
34
+ if (historyReadResult.HistoryData) {
35
+ historyData = _1.UaPayloadMapper.extensionObjectFromWebApi(historyReadResult.HistoryData);
36
+ }
34
37
  return new UaHistoryReadResult(statusCode, historyData, continuationPoint);
35
38
  }
36
39
  }
@@ -15,9 +15,9 @@ class UaPayloadMapper {
15
15
  return { Code: statusCode.value };
16
16
  }
17
17
  static localizedTextFromWebApi(text) {
18
- if (!text || !text.Text)
18
+ if (!text)
19
19
  return null;
20
- return new types_2.UaLocalizedText(text.Text, text.Locale);
20
+ return new types_2.UaLocalizedText((text.Text) ? text.Text : "", (text.Locale) ? text.Locale : undefined);
21
21
  }
22
22
  static localizedTextToWebApi(text) {
23
23
  return {
@@ -11,6 +11,7 @@ export declare class UaExpandedNodeId {
11
11
  isLocalNodeId(): boolean;
12
12
  getNodeId(namespaceUris?: Array<string>): UaNodeId | null;
13
13
  toString(): string;
14
+ static from(nodeId: UaNodeId): UaExpandedNodeId;
14
15
  }
15
16
  export declare function parseUaExpandedNodeId(value: string): UaExpandedNodeId;
16
17
  export declare function parseUaExpandedNodeIdOrNull(value: string | null | undefined): UaExpandedNodeId | null;
@@ -44,6 +44,9 @@ class UaExpandedNodeId {
44
44
  // To be implemented
45
45
  return this._nodeId.toString();
46
46
  }
47
+ static from(nodeId) {
48
+ return new UaExpandedNodeId(nodeId);
49
+ }
47
50
  }
48
51
  exports.UaExpandedNodeId = UaExpandedNodeId;
49
52
  function parseUaExpandedNodeId(value) {
@@ -364,11 +364,13 @@ class UaWebClient {
364
364
  if (!response.Results || nodesToBrowse.length != response.Results.length)
365
365
  throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
366
366
  let results = [];
367
- for (let item of response.Results) {
368
- let result = common_1.UaBrowseResult.fromStruct(item);
369
- if (null == result)
370
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
371
- results.push(result);
367
+ if (response.Results) {
368
+ for (let item of response.Results) {
369
+ let result = common_1.UaBrowseResult.fromStruct(item);
370
+ if (null == result)
371
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
372
+ results.push(result);
373
+ }
372
374
  }
373
375
  return results;
374
376
  });
@@ -37,9 +37,11 @@ class UaCallMethodRequest {
37
37
  let inputArguments = [];
38
38
  if (null == objectId || null == methodId)
39
39
  return null;
40
- for (let item of callMethodRequest.InputArguments) {
41
- let variant = _1.UaPayloadMapper.variantFromWebApi(item);
42
- inputArguments.push(variant);
40
+ if (callMethodRequest.InputArguments) {
41
+ for (let item of callMethodRequest.InputArguments) {
42
+ let variant = _1.UaPayloadMapper.variantFromWebApi(item);
43
+ inputArguments.push(variant);
44
+ }
43
45
  }
44
46
  return new UaCallMethodRequest(objectId, methodId, inputArguments);
45
47
  }
@@ -42,8 +42,10 @@ class UaCallMethodResult {
42
42
  static fromStruct(callMethodResult) {
43
43
  let statusCode = _1.UaPayloadMapper.statusCodeFromWebApi(callMethodResult.StatusCode);
44
44
  let outputArguments = [];
45
- for (let item of callMethodResult.OutputArguments) {
46
- outputArguments.push(_1.UaPayloadMapper.variantFromWebApi(item));
45
+ if (callMethodResult.OutputArguments) {
46
+ for (let item of callMethodResult.OutputArguments) {
47
+ outputArguments.push(_1.UaPayloadMapper.variantFromWebApi(item));
48
+ }
47
49
  }
48
50
  let inputArgumentResults = undefined;
49
51
  if (callMethodResult.InputArgumentResults) {
@@ -3,11 +3,11 @@ import { UaExtensionObject, UaNodeId, UaStatusCode } from "../types";
3
3
  export declare class UaHistoryReadResult {
4
4
  static dataTypeId: UaNodeId;
5
5
  private _statusCode;
6
- private _historyData;
6
+ private _historyData?;
7
7
  private _continuationPoint?;
8
- constructor(statusCode: UaStatusCode, historyData: UaExtensionObject, continuationPoint?: string);
8
+ constructor(statusCode: UaStatusCode, historyData?: UaExtensionObject, continuationPoint?: string);
9
9
  get statusCode(): UaStatusCode;
10
- get historyData(): UaExtensionObject;
10
+ get historyData(): UaExtensionObject | undefined;
11
11
  get continuationPoint(): string | undefined;
12
12
  toStruct(): HistoryReadResult;
13
13
  static fromStruct(historyReadResult: HistoryReadResult): UaHistoryReadResult | null;
@@ -29,8 +29,11 @@ class UaHistoryReadResult {
29
29
  }
30
30
  static fromStruct(historyReadResult) {
31
31
  let statusCode = _1.UaPayloadMapper.statusCodeFromWebApi(historyReadResult.StatusCode);
32
- let historyData = _1.UaPayloadMapper.extensionObjectFromWebApi(historyReadResult.HistoryData);
32
+ let historyData = undefined;
33
33
  let continuationPoint = historyReadResult.ContinuationPoint;
34
+ if (historyReadResult.HistoryData) {
35
+ historyData = _1.UaPayloadMapper.extensionObjectFromWebApi(historyReadResult.HistoryData);
36
+ }
34
37
  return new UaHistoryReadResult(statusCode, historyData, continuationPoint);
35
38
  }
36
39
  }
@@ -15,9 +15,9 @@ class UaPayloadMapper {
15
15
  return { Code: statusCode.value };
16
16
  }
17
17
  static localizedTextFromWebApi(text) {
18
- if (!text || !text.Text)
18
+ if (!text)
19
19
  return null;
20
- return new types_2.UaLocalizedText(text.Text, text.Locale);
20
+ return new types_2.UaLocalizedText((text.Text) ? text.Text : "", (text.Locale) ? text.Locale : undefined);
21
21
  }
22
22
  static localizedTextToWebApi(text) {
23
23
  return {
@@ -11,6 +11,7 @@ export declare class UaExpandedNodeId {
11
11
  isLocalNodeId(): boolean;
12
12
  getNodeId(namespaceUris?: Array<string>): UaNodeId | null;
13
13
  toString(): string;
14
+ static from(nodeId: UaNodeId): UaExpandedNodeId;
14
15
  }
15
16
  export declare function parseUaExpandedNodeId(value: string): UaExpandedNodeId;
16
17
  export declare function parseUaExpandedNodeIdOrNull(value: string | null | undefined): UaExpandedNodeId | null;
@@ -44,6 +44,9 @@ class UaExpandedNodeId {
44
44
  // To be implemented
45
45
  return this._nodeId.toString();
46
46
  }
47
+ static from(nodeId) {
48
+ return new UaExpandedNodeId(nodeId);
49
+ }
47
50
  }
48
51
  exports.UaExpandedNodeId = UaExpandedNodeId;
49
52
  function parseUaExpandedNodeId(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opcua-webapi-ts",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Provides OPC UA WebAPI wrapper and client based on opcua-webapi-typescript",
5
5
  "author": "DingYan",
6
6
  "main": "./dist/cjs/index.js",