node-opcua-basic-types 2.98.0 → 2.98.1

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.
Files changed (50) hide show
  1. package/dist/array.d.ts +16 -0
  2. package/dist/array.js +45 -0
  3. package/dist/array.js.map +1 -0
  4. package/dist/attributeIds.d.ts +34 -0
  5. package/dist/attributeIds.js +49 -0
  6. package/dist/attributeIds.js.map +1 -0
  7. package/dist/boolean.d.ts +9 -0
  8. package/dist/boolean.js +34 -0
  9. package/dist/boolean.js.map +1 -0
  10. package/dist/byte_string.d.ts +11 -0
  11. package/dist/byte_string.js +37 -0
  12. package/dist/byte_string.js.map +1 -0
  13. package/dist/data_type.d.ts +31 -0
  14. package/dist/data_type.js +36 -0
  15. package/dist/data_type.js.map +1 -0
  16. package/dist/date_time.d.ts +6 -0
  17. package/dist/date_time.js +21 -0
  18. package/dist/date_time.js.map +1 -0
  19. package/dist/floats.d.ts +16 -0
  20. package/dist/floats.js +81 -0
  21. package/dist/floats.js.map +1 -0
  22. package/dist/guid.d.ts +9 -0
  23. package/dist/guid.js +122 -0
  24. package/dist/guid.js.map +1 -0
  25. package/dist/index.d.ts +19 -0
  26. package/dist/index.js +34 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/integers.d.ts +66 -0
  29. package/dist/integers.js +309 -0
  30. package/dist/integers.js.map +1 -0
  31. package/dist/locale_id.d.ts +9 -0
  32. package/dist/locale_id.js +19 -0
  33. package/dist/locale_id.js.map +1 -0
  34. package/dist/node_id.d.ts +9 -0
  35. package/dist/node_id.js +189 -0
  36. package/dist/node_id.js.map +1 -0
  37. package/dist/round_to_float.d.ts +1 -0
  38. package/dist/round_to_float.js +27 -0
  39. package/dist/round_to_float.js.map +1 -0
  40. package/dist/status_code.d.ts +4 -0
  41. package/dist/status_code.js +21 -0
  42. package/dist/status_code.js.map +1 -0
  43. package/dist/string.d.ts +12 -0
  44. package/dist/string.js +31 -0
  45. package/dist/string.js.map +1 -0
  46. package/dist/utils.d.ts +12 -0
  47. package/dist/utils.js +20 -0
  48. package/dist/utils.js.map +1 -0
  49. package/package.json +16 -12
  50. package/nyc.config.js +0 -16
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /***
3
+ * @module node-opcua-basic-types
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./array"), exports);
21
+ __exportStar(require("./attributeIds"), exports);
22
+ __exportStar(require("./boolean"), exports);
23
+ __exportStar(require("./byte_string"), exports);
24
+ __exportStar(require("./data_type"), exports);
25
+ __exportStar(require("./date_time"), exports);
26
+ __exportStar(require("./floats"), exports);
27
+ __exportStar(require("./guid"), exports);
28
+ __exportStar(require("./integers"), exports);
29
+ __exportStar(require("./locale_id"), exports);
30
+ __exportStar(require("./node_id"), exports);
31
+ __exportStar(require("./round_to_float"), exports);
32
+ __exportStar(require("./status_code"), exports);
33
+ __exportStar(require("./string"), exports);
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,iDAA+B;AAC/B,4CAA0B;AAC1B,gDAA8B;AAC9B,8CAA4B;AAC5B,8CAA4B;AAC5B,2CAAyB;AACzB,yCAAuB;AACvB,6CAA2B;AAC3B,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,gDAA8B;AAC9B,2CAAyB"}
@@ -0,0 +1,66 @@
1
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ export declare function isValidUInt16(value: number): boolean;
3
+ export type UInt8 = number;
4
+ export type UInt16 = number;
5
+ export type UInt32 = number;
6
+ export type UInt64 = UInt32[];
7
+ export type Int8 = number;
8
+ export type Int16 = number;
9
+ export type Int32 = number;
10
+ export type Int64 = UInt32[];
11
+ export type Byte = UInt8;
12
+ export type SByte = Int8;
13
+ export declare function randomUInt16(): UInt16;
14
+ export declare function encodeUInt16(value: UInt16, stream: OutputBinaryStream): void;
15
+ export declare function decodeUInt16(stream: BinaryStream, value?: number): UInt16;
16
+ export declare function isValidInt16(value: number): boolean;
17
+ export declare function randomInt16(): Int16;
18
+ export declare function encodeInt16(value: Int16, stream: OutputBinaryStream): void;
19
+ export declare function decodeInt16(stream: BinaryStream, value?: number): Int16;
20
+ export declare function isValidInt32(value: number): boolean;
21
+ export declare function randomInt32(): Int32;
22
+ export declare function encodeInt32(value: Int32, stream: OutputBinaryStream): void;
23
+ export declare function decodeInt32(stream: BinaryStream, value?: number): Int32;
24
+ export declare function isValidUInt32(value: number): boolean;
25
+ export declare function randomUInt32(): UInt32;
26
+ export declare function encodeUInt32(value: UInt32, stream: OutputBinaryStream): void;
27
+ export declare function decodeUInt32(stream: BinaryStream, value?: number): UInt32;
28
+ export declare function isValidInt8(value: number): boolean;
29
+ export declare function randomInt8(): Int8;
30
+ export declare function encodeInt8(value: Int8, stream: OutputBinaryStream): void;
31
+ export declare function decodeInt8(stream: BinaryStream, value?: number): Int8;
32
+ export declare const isValidSByte: typeof isValidInt8;
33
+ export declare const randomSByte: typeof randomInt8;
34
+ export declare const encodeSByte: typeof encodeInt8;
35
+ export declare const decodeSByte: typeof decodeInt8;
36
+ export declare function isValidUInt8(value: number): boolean;
37
+ export declare function randomUInt8(): UInt8;
38
+ export declare function encodeUInt8(value: UInt8, stream: OutputBinaryStream): void;
39
+ export declare function decodeUInt8(stream: BinaryStream, value?: number): UInt8;
40
+ export declare const isValidByte: typeof isValidUInt8;
41
+ export declare const randomByte: typeof randomUInt8;
42
+ export declare const encodeByte: typeof encodeUInt8;
43
+ export declare const decodeByte: typeof decodeUInt8;
44
+ export declare function isValidUInt64(value?: number | number[]): boolean;
45
+ export declare function randomUInt64(): UInt64;
46
+ export declare function encodeUInt64(value: UInt64 | number, stream: OutputBinaryStream): void;
47
+ export declare function decodeUInt64(stream: BinaryStream, value?: UInt64): UInt64;
48
+ export declare function constructInt64(high: UInt32, low: UInt32): Int64;
49
+ export declare function coerceUInt64(value: number | UInt64 | Int32 | string | null): UInt64;
50
+ export declare function randomInt64(): Int64;
51
+ export declare const coerceInt64: typeof coerceUInt64;
52
+ export declare const isValidInt64: typeof isValidUInt64;
53
+ export declare const encodeInt64: typeof encodeUInt64;
54
+ export declare const decodeInt64: typeof decodeUInt64;
55
+ export declare function coerceInt8(value: number | string | null): Int8;
56
+ export declare function coerceUInt8(value: number | string | null): UInt8;
57
+ export declare function coerceByte(value: number | string | null): UInt8;
58
+ export declare function coerceSByte(value: number | string | null): Int8;
59
+ export declare function coerceUInt16(value: number | string | null): UInt16;
60
+ export declare function coerceInt16(value: number | string | null): Int16;
61
+ interface EnumItemLike {
62
+ value: number;
63
+ }
64
+ export declare function coerceUInt32(value: null | string | number | EnumItemLike): UInt32;
65
+ export declare function coerceInt32(value: null | Int64 | UInt64 | number | string): Int32;
66
+ export {};
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceUInt32 = exports.coerceInt16 = exports.coerceUInt16 = exports.coerceSByte = exports.coerceByte = exports.coerceUInt8 = exports.coerceInt8 = exports.decodeInt64 = exports.encodeInt64 = exports.isValidInt64 = exports.coerceInt64 = exports.randomInt64 = exports.coerceUInt64 = exports.constructInt64 = exports.decodeUInt64 = exports.encodeUInt64 = exports.randomUInt64 = exports.isValidUInt64 = exports.decodeByte = exports.encodeByte = exports.randomByte = exports.isValidByte = exports.decodeUInt8 = exports.encodeUInt8 = exports.randomUInt8 = exports.isValidUInt8 = exports.decodeSByte = exports.encodeSByte = exports.randomSByte = exports.isValidSByte = exports.decodeInt8 = exports.encodeInt8 = exports.randomInt8 = exports.isValidInt8 = exports.decodeUInt32 = exports.encodeUInt32 = exports.randomUInt32 = exports.isValidUInt32 = exports.decodeInt32 = exports.encodeInt32 = exports.randomInt32 = exports.isValidInt32 = exports.decodeInt16 = exports.encodeInt16 = exports.randomInt16 = exports.isValidInt16 = exports.decodeUInt16 = exports.encodeUInt16 = exports.randomUInt16 = exports.isValidUInt16 = void 0;
4
+ exports.coerceInt32 = void 0;
5
+ /***
6
+ * @module node-opcua-basic-types
7
+ */
8
+ const node_opcua_assert_1 = require("node-opcua-assert");
9
+ const utils_1 = require("./utils");
10
+ function isValidUInt16(value) {
11
+ if (!isFinite(value)) {
12
+ return false;
13
+ }
14
+ return value >= 0 && value <= 0xffff;
15
+ }
16
+ exports.isValidUInt16 = isValidUInt16;
17
+ // ---------------------------------------
18
+ function randomUInt16() {
19
+ return (0, utils_1.getRandomInt)(0, 0xffff);
20
+ }
21
+ exports.randomUInt16 = randomUInt16;
22
+ function encodeUInt16(value, stream) {
23
+ stream.writeUInt16(value);
24
+ }
25
+ exports.encodeUInt16 = encodeUInt16;
26
+ function decodeUInt16(stream, value) {
27
+ return stream.readUInt16();
28
+ }
29
+ exports.decodeUInt16 = decodeUInt16;
30
+ function isValidInt16(value) {
31
+ if (!isFinite(value)) {
32
+ return false;
33
+ }
34
+ return value >= -0x8000 && value <= 0x7fff;
35
+ }
36
+ exports.isValidInt16 = isValidInt16;
37
+ function randomInt16() {
38
+ return (0, utils_1.getRandomInt)(-0x8000, 0x7fff);
39
+ }
40
+ exports.randomInt16 = randomInt16;
41
+ function encodeInt16(value, stream) {
42
+ (0, node_opcua_assert_1.assert)(isFinite(value));
43
+ stream.writeInt16(value);
44
+ }
45
+ exports.encodeInt16 = encodeInt16;
46
+ function decodeInt16(stream, value) {
47
+ return stream.readInt16();
48
+ }
49
+ exports.decodeInt16 = decodeInt16;
50
+ function isValidInt32(value) {
51
+ if (!isFinite(value)) {
52
+ return false;
53
+ }
54
+ return value >= -0x80000000 && value <= 0x7fffffff;
55
+ }
56
+ exports.isValidInt32 = isValidInt32;
57
+ function randomInt32() {
58
+ return (0, utils_1.getRandomInt)(-0x80000000, 0x7fffffff);
59
+ }
60
+ exports.randomInt32 = randomInt32;
61
+ function encodeInt32(value, stream) {
62
+ (0, node_opcua_assert_1.assert)(isFinite(value));
63
+ stream.writeInteger(value);
64
+ }
65
+ exports.encodeInt32 = encodeInt32;
66
+ function decodeInt32(stream, value) {
67
+ return stream.readInteger();
68
+ }
69
+ exports.decodeInt32 = decodeInt32;
70
+ function isValidUInt32(value) {
71
+ if (!isFinite(value)) {
72
+ return false;
73
+ }
74
+ return value >= 0 && value <= 0xffffffff;
75
+ }
76
+ exports.isValidUInt32 = isValidUInt32;
77
+ function randomUInt32() {
78
+ return (0, utils_1.getRandomInt)(0, 0xffffffff);
79
+ }
80
+ exports.randomUInt32 = randomUInt32;
81
+ function encodeUInt32(value, stream) {
82
+ stream.writeUInt32(value);
83
+ }
84
+ exports.encodeUInt32 = encodeUInt32;
85
+ function decodeUInt32(stream, value) {
86
+ return stream.readUInt32();
87
+ }
88
+ exports.decodeUInt32 = decodeUInt32;
89
+ function isValidInt8(value) {
90
+ if (!isFinite(value)) {
91
+ return false;
92
+ }
93
+ return value >= -0x80 && value <= 0x7f;
94
+ }
95
+ exports.isValidInt8 = isValidInt8;
96
+ function randomInt8() {
97
+ return (0, utils_1.getRandomInt)(-0x7f, 0x7e);
98
+ }
99
+ exports.randomInt8 = randomInt8;
100
+ function encodeInt8(value, stream) {
101
+ (0, node_opcua_assert_1.assert)(isValidInt8(value));
102
+ stream.writeInt8(value);
103
+ }
104
+ exports.encodeInt8 = encodeInt8;
105
+ function decodeInt8(stream, value) {
106
+ return stream.readInt8();
107
+ }
108
+ exports.decodeInt8 = decodeInt8;
109
+ exports.isValidSByte = isValidInt8;
110
+ exports.randomSByte = randomInt8;
111
+ exports.encodeSByte = encodeInt8;
112
+ exports.decodeSByte = decodeInt8;
113
+ function isValidUInt8(value) {
114
+ if (!isFinite(value)) {
115
+ return false;
116
+ }
117
+ return value >= 0x00 && value <= 0xff;
118
+ }
119
+ exports.isValidUInt8 = isValidUInt8;
120
+ function randomUInt8() {
121
+ return (0, utils_1.getRandomInt)(0x00, 0xff);
122
+ }
123
+ exports.randomUInt8 = randomUInt8;
124
+ function encodeUInt8(value, stream) {
125
+ stream.writeUInt8(value);
126
+ }
127
+ exports.encodeUInt8 = encodeUInt8;
128
+ function decodeUInt8(stream, value) {
129
+ return stream.readUInt8();
130
+ }
131
+ exports.decodeUInt8 = decodeUInt8;
132
+ exports.isValidByte = isValidUInt8;
133
+ exports.randomByte = randomUInt8;
134
+ exports.encodeByte = encodeUInt8;
135
+ exports.decodeByte = decodeUInt8;
136
+ function isValidUInt64(value) {
137
+ return value instanceof Array && value.length === 2;
138
+ }
139
+ exports.isValidUInt64 = isValidUInt64;
140
+ function randomUInt64() {
141
+ return [(0, utils_1.getRandomInt)(0, 0xffffffff), (0, utils_1.getRandomInt)(0, 0xffffffff)];
142
+ }
143
+ exports.randomUInt64 = randomUInt64;
144
+ function encodeUInt64(value, stream) {
145
+ if (typeof value === "number") {
146
+ const arr = coerceUInt64(value);
147
+ stream.writeUInt32(arr[1]);
148
+ stream.writeUInt32(arr[0]);
149
+ }
150
+ else {
151
+ stream.writeUInt32(value[1]);
152
+ stream.writeUInt32(value[0]);
153
+ }
154
+ }
155
+ exports.encodeUInt64 = encodeUInt64;
156
+ function decodeUInt64(stream, value) {
157
+ const low = stream.readUInt32();
158
+ const high = stream.readUInt32();
159
+ return constructInt64(high, low);
160
+ }
161
+ exports.decodeUInt64 = decodeUInt64;
162
+ function constructInt64(high, low) {
163
+ if (high === 0 && low < 0) {
164
+ high = 0xffffffff;
165
+ low = 0xffffffff + low + 1;
166
+ }
167
+ (0, node_opcua_assert_1.assert)(low >= 0 && low <= 0xffffffff);
168
+ (0, node_opcua_assert_1.assert)(high >= 0 && high <= 0xffffffff);
169
+ return [high, low];
170
+ }
171
+ exports.constructInt64 = constructInt64;
172
+ function coerceUInt64(value) {
173
+ let high;
174
+ let low;
175
+ let v;
176
+ if (value === null || value === undefined) {
177
+ return [0, 0];
178
+ }
179
+ if (value instanceof Array) {
180
+ (0, node_opcua_assert_1.assert)(typeof value[0] === "number");
181
+ (0, node_opcua_assert_1.assert)(typeof value[1] === "number");
182
+ return value;
183
+ }
184
+ if (typeof value === "string") {
185
+ v = value.split(",");
186
+ if (v.length === 1) {
187
+ // was a single string, good news ! BigInt can be used with nodejs >=12
188
+ let a = BigInt(value);
189
+ if (a < BigInt(0)) {
190
+ const mask = BigInt("0xFFFFFFFFFFFFFFFF");
191
+ a = (mask + a + BigInt(1)) & mask;
192
+ }
193
+ high = Number(a >> BigInt(32));
194
+ low = Number(a & BigInt(0xffffffff));
195
+ }
196
+ else {
197
+ high = parseInt(v[0], 10);
198
+ low = parseInt(v[1], 10);
199
+ }
200
+ return constructInt64(high, low);
201
+ }
202
+ if (value > 0xffffffff) {
203
+ // beware : as per javascript, value is a double here !
204
+ // our conversion will suffer from some inaccuracy
205
+ high = Math.floor(value / 0x100000000);
206
+ low = value - high * 0x100000000;
207
+ return constructInt64(high, low);
208
+ }
209
+ return constructInt64(0, value);
210
+ }
211
+ exports.coerceUInt64 = coerceUInt64;
212
+ function randomInt64() {
213
+ // High, low
214
+ return [(0, utils_1.getRandomInt)(0, 0xffffffff), (0, utils_1.getRandomInt)(0, 0xffffffff)];
215
+ }
216
+ exports.randomInt64 = randomInt64;
217
+ exports.coerceInt64 = coerceUInt64;
218
+ exports.isValidInt64 = isValidUInt64;
219
+ exports.encodeInt64 = encodeUInt64;
220
+ exports.decodeInt64 = decodeUInt64;
221
+ function coerceInt8(value) {
222
+ if (value === null || value === undefined) {
223
+ return 0;
224
+ }
225
+ if (typeof value === "number") {
226
+ return value;
227
+ }
228
+ return parseInt(value, 10);
229
+ }
230
+ exports.coerceInt8 = coerceInt8;
231
+ function coerceUInt8(value) {
232
+ if (value === null || value === undefined) {
233
+ return 0;
234
+ }
235
+ if (typeof value === "number") {
236
+ return value;
237
+ }
238
+ return parseInt(value, 10);
239
+ }
240
+ exports.coerceUInt8 = coerceUInt8;
241
+ function coerceByte(value) {
242
+ if (value === null || value === undefined) {
243
+ return 0;
244
+ }
245
+ if (typeof value === "number") {
246
+ return value;
247
+ }
248
+ return parseInt(value, 10);
249
+ }
250
+ exports.coerceByte = coerceByte;
251
+ function coerceSByte(value) {
252
+ if (value === null || value === undefined) {
253
+ return 0;
254
+ }
255
+ if (typeof value === "number") {
256
+ return value;
257
+ }
258
+ return parseInt(value, 10);
259
+ }
260
+ exports.coerceSByte = coerceSByte;
261
+ function coerceUInt16(value) {
262
+ if (value === null || value === undefined) {
263
+ return 0;
264
+ }
265
+ if (typeof value === "number") {
266
+ return value;
267
+ }
268
+ return parseInt(value, 10);
269
+ }
270
+ exports.coerceUInt16 = coerceUInt16;
271
+ function coerceInt16(value) {
272
+ if (value === null || value === undefined) {
273
+ return 0;
274
+ }
275
+ if (typeof value === "number") {
276
+ return value;
277
+ }
278
+ return parseInt(value, 10);
279
+ }
280
+ exports.coerceInt16 = coerceInt16;
281
+ function coerceUInt32(value) {
282
+ if (value === null || value === undefined) {
283
+ return 0;
284
+ }
285
+ if (value && Object.prototype.hasOwnProperty.call(value, "value")) {
286
+ // xx assert(value.constructor.name === "EnumItem");
287
+ return coerceUInt32(value.value);
288
+ }
289
+ if (typeof value === "number") {
290
+ return value;
291
+ }
292
+ return parseInt(value, 10);
293
+ }
294
+ exports.coerceUInt32 = coerceUInt32;
295
+ function coerceInt32(value) {
296
+ if (value === null || value === undefined) {
297
+ return 0;
298
+ }
299
+ if (value instanceof Array) {
300
+ // Int64 as a [high,low]
301
+ return value[1] + value[0] * 0xffffffff;
302
+ }
303
+ if (typeof value === "number") {
304
+ return value;
305
+ }
306
+ return parseInt(value, 10);
307
+ }
308
+ exports.coerceInt32 = coerceInt32;
309
+ //# sourceMappingURL=integers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integers.js","sourceRoot":"","sources":["../source/integers.ts"],"names":[],"mappings":";;;;AAAA;;GAEG;AACH,yDAA2C;AAE3C,mCAAuC;AAEvC,SAAgB,aAAa,CAAC,KAAa;IACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC;AACzC,CAAC;AALD,sCAKC;AAeD,0CAA0C;AAE1C,SAAgB,YAAY;IACxB,OAAO,IAAA,oBAAY,EAAC,CAAC,EAAE,MAAM,CAAW,CAAC;AAC7C,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,KAAa,EAAE,MAA0B;IAClE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,MAAoB,EAAE,KAAc;IAC7D,OAAO,MAAM,CAAC,UAAU,EAAY,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY,CAAC,KAAa;IACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,KAAK,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;AAC/C,CAAC;AALD,oCAKC;AAED,SAAgB,WAAW;IACvB,OAAO,IAAA,oBAAY,EAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC;AAFD,kCAEC;AAED,SAAgB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,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAZD,kCAYC"}
@@ -0,0 +1,9 @@
1
+ /***
2
+ * @module node-opcua-basic-types
3
+ */
4
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
5
+ import { UAString } from "./string";
6
+ export declare function validateLocaleId(value: unknown): boolean;
7
+ export type LocaleId = UAString;
8
+ export declare function encodeLocaleId(localeId: LocaleId, stream: OutputBinaryStream): void;
9
+ export declare function decodeLocaleId(stream: BinaryStream): LocaleId;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeLocaleId = exports.encodeLocaleId = exports.validateLocaleId = void 0;
4
+ const string_1 = require("./string");
5
+ function validateLocaleId(value) {
6
+ // TODO : check that localeID is well-formed
7
+ // see part 3 $8.4 page 63
8
+ return true;
9
+ }
10
+ exports.validateLocaleId = validateLocaleId;
11
+ function encodeLocaleId(localeId, stream) {
12
+ return (0, string_1.encodeUAString)(localeId, stream);
13
+ }
14
+ exports.encodeLocaleId = encodeLocaleId;
15
+ function decodeLocaleId(stream) {
16
+ return (0, string_1.decodeUAString)(stream);
17
+ }
18
+ exports.decodeLocaleId = decodeLocaleId;
19
+ //# sourceMappingURL=locale_id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale_id.js","sourceRoot":"","sources":["../source/locale_id.ts"],"names":[],"mappings":";;;AAKA,qCAAoE;AAEpE,SAAgB,gBAAgB,CAAC,KAAc;IAC3C,4CAA4C;IAC5C,0BAA0B;IAC1B,OAAO,IAAI,CAAC;AAChB,CAAC;AAJD,4CAIC;AAGD,SAAgB,cAAc,CAAC,QAAkB,EAAE,MAA0B;IACzE,OAAO,IAAA,uBAAc,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc,CAAC,MAAoB;IAC/C,OAAO,IAAA,uBAAc,EAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC"}
@@ -0,0 +1,9 @@
1
+ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
+ import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
3
+ export declare function isValidNodeId(nodeId: NodeId): boolean;
4
+ export declare function randomNodeId(): NodeId;
5
+ export declare function encodeNodeId(nodeId: NodeId, stream: OutputBinaryStream): void;
6
+ export declare function encodeExpandedNodeId(expandedNodeId: ExpandedNodeId, stream: OutputBinaryStream): void;
7
+ export declare function decodeNodeId(stream: BinaryStream, _nodeId?: NodeId): NodeId;
8
+ export declare function decodeExpandedNodeId(stream: BinaryStream, _nodeId?: ExpandedNodeId): ExpandedNodeId;
9
+ export { coerceNodeId, coerceExpandedNodeId } from "node-opcua-nodeid";
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceExpandedNodeId = exports.coerceNodeId = exports.decodeExpandedNodeId = exports.decodeNodeId = exports.encodeExpandedNodeId = exports.encodeNodeId = exports.randomNodeId = exports.isValidNodeId = void 0;
4
+ /***
5
+ * @module node-opcua-basic-types
6
+ */
7
+ const node_opcua_assert_1 = require("node-opcua-assert");
8
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
9
+ const byte_string_1 = require("./byte_string");
10
+ const guid_1 = require("./guid");
11
+ const integers_1 = require("./integers");
12
+ const string_1 = require("./string");
13
+ const utils_1 = require("./utils");
14
+ function isUInt8(value) {
15
+ return value >= 0 && value <= 0xff;
16
+ }
17
+ function isUInt16(value) {
18
+ return value >= 0 && value <= 0xffff;
19
+ }
20
+ function nodeID_encodingByte(nodeId) {
21
+ let encodingByte = 0;
22
+ if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC) {
23
+ if (isUInt8(nodeId.value) &&
24
+ !nodeId.namespace &&
25
+ !nodeId.namespaceUri &&
26
+ !nodeId.serverIndex) {
27
+ encodingByte = encodingByte | 0 /* EnumNodeIdEncoding.TwoBytes */;
28
+ }
29
+ else if (isUInt16(nodeId.value) &&
30
+ isUInt8(nodeId.namespace) &&
31
+ !nodeId.namespaceUri &&
32
+ !nodeId.serverIndex) {
33
+ encodingByte = encodingByte | 1 /* EnumNodeIdEncoding.FourBytes */;
34
+ }
35
+ else {
36
+ encodingByte = encodingByte | 2 /* EnumNodeIdEncoding.Numeric */;
37
+ }
38
+ }
39
+ else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.STRING) {
40
+ encodingByte = encodingByte | 3 /* EnumNodeIdEncoding.String */;
41
+ }
42
+ else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.BYTESTRING) {
43
+ encodingByte = encodingByte | 5 /* EnumNodeIdEncoding.ByteString */;
44
+ }
45
+ else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.GUID) {
46
+ encodingByte = encodingByte | 4 /* EnumNodeIdEncoding.Guid */;
47
+ }
48
+ if (Object.prototype.hasOwnProperty.call(nodeId, "namespaceUri") && nodeId.namespaceUri) {
49
+ encodingByte = encodingByte | 128 /* EnumNodeIdEncoding.NamespaceUriFlag */;
50
+ }
51
+ if (Object.prototype.hasOwnProperty.call(nodeId, "serverIndex") && nodeId.serverIndex) {
52
+ encodingByte = encodingByte | 64 /* EnumNodeIdEncoding.ServerIndexFlag */;
53
+ }
54
+ return encodingByte;
55
+ }
56
+ function isValidNodeId(nodeId) {
57
+ return nodeId instanceof node_opcua_nodeid_1.NodeId;
58
+ }
59
+ exports.isValidNodeId = isValidNodeId;
60
+ function randomNodeId() {
61
+ const value = (0, utils_1.getRandomInt)(0, 0xfffff);
62
+ const namespace = (0, utils_1.getRandomInt)(0, 3);
63
+ return (0, node_opcua_nodeid_1.makeNodeId)(value, namespace);
64
+ }
65
+ exports.randomNodeId = randomNodeId;
66
+ function _encodeNodeId(encodingByte, nodeId, stream) {
67
+ stream.writeUInt8(encodingByte); // encoding byte
68
+ /*jslint bitwise: true */
69
+ encodingByte &= 0x3f;
70
+ switch (encodingByte) {
71
+ case 0 /* EnumNodeIdEncoding.TwoBytes */:
72
+ stream.writeUInt8(nodeId ? nodeId.value : 0);
73
+ break;
74
+ case 1 /* EnumNodeIdEncoding.FourBytes */:
75
+ stream.writeUInt8(nodeId.namespace);
76
+ stream.writeUInt16(nodeId.value);
77
+ break;
78
+ case 2 /* EnumNodeIdEncoding.Numeric */:
79
+ stream.writeUInt16(nodeId.namespace);
80
+ stream.writeUInt32(nodeId.value);
81
+ break;
82
+ case 3 /* EnumNodeIdEncoding.String */:
83
+ stream.writeUInt16(nodeId.namespace);
84
+ (0, string_1.encodeString)(nodeId.value, stream);
85
+ break;
86
+ case 5 /* EnumNodeIdEncoding.ByteString */:
87
+ stream.writeUInt16(nodeId.namespace);
88
+ (0, byte_string_1.encodeByteString)(nodeId.value, stream);
89
+ break;
90
+ default:
91
+ (0, node_opcua_assert_1.assert)(encodingByte === 4 /* EnumNodeIdEncoding.Guid */);
92
+ stream.writeUInt16(nodeId.namespace);
93
+ (0, guid_1.encodeGuid)(nodeId.value, stream);
94
+ break;
95
+ }
96
+ }
97
+ function encodeNodeId(nodeId, stream) {
98
+ let encodingByte = nodeID_encodingByte(nodeId);
99
+ /*jslint bitwise: true */
100
+ encodingByte &= 0x3f;
101
+ _encodeNodeId(encodingByte, nodeId, stream);
102
+ }
103
+ exports.encodeNodeId = encodeNodeId;
104
+ function encodeExpandedNodeId(expandedNodeId, stream) {
105
+ (0, node_opcua_assert_1.assert)(expandedNodeId, "encodeExpandedNodeId: must provide a valid expandedNodeId");
106
+ const encodingByte = nodeID_encodingByte(expandedNodeId);
107
+ _encodeNodeId(encodingByte, expandedNodeId, stream);
108
+ if (encodingByte & 128 /* EnumNodeIdEncoding.NamespaceUriFlag */) {
109
+ (0, string_1.encodeString)(expandedNodeId.namespaceUri, stream);
110
+ }
111
+ if (encodingByte & 64 /* EnumNodeIdEncoding.ServerIndexFlag */) {
112
+ (0, integers_1.encodeUInt32)(expandedNodeId.serverIndex, stream);
113
+ }
114
+ }
115
+ exports.encodeExpandedNodeId = encodeExpandedNodeId;
116
+ function _decodeNodeId(encodingByte, stream, _nodeId) {
117
+ let value;
118
+ let namespace;
119
+ let identifierType;
120
+ /*jslint bitwise: true */
121
+ encodingByte &= 0x3f; // 1 to 5
122
+ switch (encodingByte) {
123
+ case 0 /* EnumNodeIdEncoding.TwoBytes */:
124
+ value = stream.readUInt8();
125
+ identifierType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
126
+ break;
127
+ case 1 /* EnumNodeIdEncoding.FourBytes */:
128
+ namespace = stream.readUInt8();
129
+ value = stream.readUInt16();
130
+ identifierType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
131
+ break;
132
+ case 2 /* EnumNodeIdEncoding.Numeric */:
133
+ namespace = stream.readUInt16();
134
+ value = stream.readUInt32();
135
+ identifierType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
136
+ break;
137
+ case 3 /* EnumNodeIdEncoding.String */:
138
+ namespace = stream.readUInt16();
139
+ value = (0, string_1.decodeString)(stream) || "";
140
+ identifierType = node_opcua_nodeid_1.NodeIdType.STRING;
141
+ break;
142
+ case 5 /* EnumNodeIdEncoding.ByteString */:
143
+ namespace = stream.readUInt16();
144
+ value = (0, byte_string_1.decodeByteString)(stream);
145
+ identifierType = node_opcua_nodeid_1.NodeIdType.BYTESTRING;
146
+ break;
147
+ default:
148
+ // istanbul ignore next
149
+ if (encodingByte !== 4 /* EnumNodeIdEncoding.Guid */) {
150
+ throw new Error("decodeNodeId: unknown encoding_byte = 0x" + encodingByte.toString(16));
151
+ }
152
+ namespace = stream.readUInt16();
153
+ value = (0, guid_1.decodeGuid)(stream);
154
+ identifierType = node_opcua_nodeid_1.NodeIdType.GUID;
155
+ (0, node_opcua_assert_1.assert)((0, guid_1.isValidGuid)(value));
156
+ break;
157
+ }
158
+ if (_nodeId === undefined) {
159
+ return new node_opcua_nodeid_1.NodeId(identifierType, value, namespace);
160
+ }
161
+ _nodeId.value = value;
162
+ _nodeId.identifierType = identifierType;
163
+ _nodeId.namespace = namespace || 0;
164
+ return _nodeId;
165
+ }
166
+ function decodeNodeId(stream, _nodeId) {
167
+ const encodingByte = stream.readUInt8();
168
+ return _decodeNodeId(encodingByte, stream, _nodeId);
169
+ }
170
+ exports.decodeNodeId = decodeNodeId;
171
+ function decodeExpandedNodeId(stream, _nodeId) {
172
+ const encodingByte = stream.readUInt8();
173
+ const expandedNodeId = _decodeNodeId(encodingByte, stream, _nodeId);
174
+ expandedNodeId.namespaceUri = null;
175
+ expandedNodeId.serverIndex = 0;
176
+ if (encodingByte & 128 /* EnumNodeIdEncoding.NamespaceUriFlag */) {
177
+ expandedNodeId.namespaceUri = (0, string_1.decodeString)(stream);
178
+ }
179
+ if (encodingByte & 64 /* EnumNodeIdEncoding.ServerIndexFlag */) {
180
+ expandedNodeId.serverIndex = (0, integers_1.decodeUInt32)(stream);
181
+ }
182
+ const e = expandedNodeId;
183
+ return new node_opcua_nodeid_1.ExpandedNodeId(e.identifierType, e.value, e.namespace, e.namespaceUri, e.serverIndex);
184
+ }
185
+ exports.decodeExpandedNodeId = decodeExpandedNodeId;
186
+ var node_opcua_nodeid_2 = require("node-opcua-nodeid");
187
+ Object.defineProperty(exports, "coerceNodeId", { enumerable: true, get: function () { return node_opcua_nodeid_2.coerceNodeId; } });
188
+ Object.defineProperty(exports, "coerceExpandedNodeId", { enumerable: true, get: function () { return node_opcua_nodeid_2.coerceExpandedNodeId; } });
189
+ //# sourceMappingURL=node_id.js.map