node-opcua-file-transfer 2.64.0 → 2.64.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.
@@ -1,310 +1,310 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ClientFile = exports.OpenFileMode = void 0;
13
- const node_opcua_data_model_1 = require("node-opcua-data-model");
14
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
- const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
16
- const node_opcua_status_code_1 = require("node-opcua-status-code");
17
- const node_opcua_variant_1 = require("node-opcua-variant");
18
- const node_opcua_constants_1 = require("node-opcua-constants");
19
- const node_opcua_debug_1 = require("node-opcua-debug");
20
- const debugLog = (0, node_opcua_debug_1.make_debugLog)("FileType");
21
- const errorLog = (0, node_opcua_debug_1.make_errorLog)("FileType");
22
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("FileType");
23
- const open_mode_1 = require("../open_mode");
24
- var open_mode_2 = require("../open_mode");
25
- Object.defineProperty(exports, "OpenFileMode", { enumerable: true, get: function () { return open_mode_2.OpenFileMode; } });
26
- /**
27
- *
28
- *
29
- */
30
- class ClientFile {
31
- constructor(session, nodeId) {
32
- this.fileHandle = 0;
33
- this.session = session;
34
- this.fileNodeId = nodeId;
35
- }
36
- open(mode) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- if (mode === null || mode === undefined) {
39
- throw new Error("expecting a validMode " + open_mode_1.OpenFileMode[mode]);
40
- }
41
- if (this.fileHandle) {
42
- throw new Error("File has already be opened");
43
- }
44
- yield this.ensureInitialized();
45
- const result = yield this.session.call({
46
- inputArguments: [
47
- { dataType: node_opcua_variant_1.DataType.Byte, value: mode }
48
- ],
49
- methodId: this.openMethodNodeId,
50
- objectId: this.fileNodeId
51
- });
52
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
53
- debugLog("Cannot open file : ");
54
- throw new Error("cannot open file statusCode = " + result.statusCode.toString() + " mode = " + open_mode_1.OpenFileMode[mode]);
55
- }
56
- this.fileHandle = result.outputArguments[0].value;
57
- return this.fileHandle;
58
- });
59
- }
60
- close() {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- if (!this.fileHandle) {
63
- throw new Error("File has not been opened yet");
64
- }
65
- yield this.ensureInitialized();
66
- const result = yield this.session.call({
67
- inputArguments: [
68
- { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }
69
- ],
70
- methodId: this.closeMethodNodeId,
71
- objectId: this.fileNodeId
72
- });
73
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
74
- debugLog("Cannot close file : ");
75
- throw new Error("cannot close file statusCode = " + result.statusCode.toString());
76
- }
77
- this.fileHandle = 0;
78
- });
79
- }
80
- getPosition() {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- yield this.ensureInitialized();
83
- if (!this.fileHandle) {
84
- throw new Error("File has not been opened yet");
85
- }
86
- const result = yield this.session.call({
87
- inputArguments: [
88
- { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }
89
- ],
90
- methodId: this.getPositionNodeId,
91
- objectId: this.fileNodeId
92
- });
93
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
94
- throw new Error("Error " + result.statusCode.toString());
95
- }
96
- return result.outputArguments[0].value;
97
- });
98
- }
99
- setPosition(position) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- yield this.ensureInitialized();
102
- if (!this.fileHandle) {
103
- throw new Error("File has not been opened yet");
104
- }
105
- if (typeof position === "number") {
106
- position = [0, position];
107
- }
108
- const result = yield this.session.call({
109
- inputArguments: [
110
- { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
111
- {
112
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
113
- dataType: node_opcua_variant_1.DataType.UInt64,
114
- value: position
115
- }
116
- ],
117
- methodId: this.setPositionNodeId,
118
- objectId: this.fileNodeId
119
- });
120
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
121
- throw new Error("Error " + result.statusCode.toString());
122
- }
123
- return;
124
- });
125
- }
126
- read(bytesToRead) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- yield this.ensureInitialized();
129
- if (!this.fileHandle) {
130
- throw new Error("File has not been opened yet");
131
- }
132
- const result = yield this.session.call({
133
- inputArguments: [
134
- { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
135
- {
136
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
137
- dataType: node_opcua_variant_1.DataType.Int32,
138
- value: bytesToRead
139
- }
140
- ],
141
- methodId: this.readNodeId,
142
- objectId: this.fileNodeId
143
- });
144
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
145
- throw new Error("Error " + result.statusCode.toString());
146
- }
147
- if (!result.outputArguments || result.outputArguments[0].dataType !== node_opcua_variant_1.DataType.ByteString) {
148
- throw new Error("Error invalid output");
149
- }
150
- return result.outputArguments[0].value;
151
- });
152
- }
153
- write(data) {
154
- return __awaiter(this, void 0, void 0, function* () {
155
- yield this.ensureInitialized();
156
- if (!this.fileHandle) {
157
- throw new Error("File has not been opened yet");
158
- }
159
- const result = yield this.session.call({
160
- inputArguments: [
161
- { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
162
- {
163
- arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
164
- dataType: node_opcua_variant_1.DataType.ByteString,
165
- value: data
166
- }
167
- ],
168
- methodId: this.writeNodeId,
169
- objectId: this.fileNodeId
170
- });
171
- if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
172
- throw new Error("Error " + result.statusCode.toString());
173
- }
174
- return;
175
- });
176
- }
177
- openCount() {
178
- return __awaiter(this, void 0, void 0, function* () {
179
- yield this.ensureInitialized();
180
- const nodeToRead = { nodeId: this.openCountNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
181
- const dataValue = yield this.session.read(nodeToRead);
182
- if (doDebug) {
183
- debugLog(" OpenCount ", nodeToRead.nodeId.toString(), dataValue.toString());
184
- }
185
- return dataValue.value.value;
186
- });
187
- }
188
- size() {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- yield this.ensureInitialized();
191
- const nodeToRead = { nodeId: this.sizeNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
192
- const dataValue = yield this.session.read(nodeToRead);
193
- return dataValue.value.value;
194
- });
195
- }
196
- // eslint-disable-next-line max-statements
197
- extractMethodsIds() {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- if (ClientFile.useGlobalMethod) {
200
- debugLog("Using GlobalMethodId");
201
- this.openMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Open);
202
- this.closeMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Close);
203
- this.setPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_SetPosition);
204
- this.getPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_GetPosition);
205
- this.writeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Write);
206
- this.readNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Read);
207
- const browsePaths = [
208
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
209
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
210
- ];
211
- const results = yield this.session.translateBrowsePath(browsePaths);
212
- if (results[0].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
213
- throw new Error("fileType object does not expose mandatory OpenCount Property");
214
- }
215
- if (results[1].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
216
- throw new Error("fileType object does not expose mandatory Size Property");
217
- }
218
- this.openCountNodeId = results[0].targets[0].targetId;
219
- this.sizeNodeId = results[1].targets[0].targetId;
220
- return;
221
- }
222
- const browsePaths = [
223
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Open"),
224
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Close"),
225
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/SetPosition"),
226
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/GetPosition"),
227
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Write"),
228
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Read"),
229
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
230
- (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
231
- ];
232
- const results = yield this.session.translateBrowsePath(browsePaths);
233
- if (results[0].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
234
- throw new Error("fileType object does not expose mandatory Open Method");
235
- }
236
- if (results[1].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
237
- throw new Error("fileType object does not expose mandatory Close Method");
238
- }
239
- if (results[2].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
240
- throw new Error("fileType object does not expose mandatory SetPosition Method");
241
- }
242
- if (results[3].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
243
- throw new Error("fileType object does not expose mandatory GetPosition Method");
244
- }
245
- if (results[4].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
246
- throw new Error("fileType object does not expose mandatory Write Method");
247
- }
248
- if (results[5].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
249
- throw new Error("fileType object does not expose mandatory Read Method");
250
- }
251
- if (results[6].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
252
- throw new Error("fileType object does not expose mandatory OpenCount Variable");
253
- }
254
- if (results[7].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
255
- throw new Error("fileType object does not expose mandatory Size Variable");
256
- }
257
- if (false && doDebug) {
258
- results.map((x) => debugLog(x.toString()));
259
- }
260
- this.openMethodNodeId = results[0].targets[0].targetId;
261
- this.closeMethodNodeId = results[1].targets[0].targetId;
262
- this.setPositionNodeId = results[2].targets[0].targetId;
263
- this.getPositionNodeId = results[3].targets[0].targetId;
264
- this.writeNodeId = results[4].targets[0].targetId;
265
- this.readNodeId = results[5].targets[0].targetId;
266
- this.openCountNodeId = results[6].targets[0].targetId;
267
- this.sizeNodeId = results[7].targets[0].targetId;
268
- });
269
- }
270
- ensureInitialized() {
271
- return __awaiter(this, void 0, void 0, function* () {
272
- if (!this.openMethodNodeId) {
273
- yield this.extractMethodsIds();
274
- }
275
- });
276
- }
277
- }
278
- exports.ClientFile = ClientFile;
279
- ClientFile.useGlobalMethod = false;
280
- /**
281
- * 5.2.10 UserRolePermissions
282
- *
283
- * The optional UserRolePermissions Attribute specifies the Permissions that apply to a Node for
284
- * all Roles granted to current Session. The value of the Attribute is an array of
285
- * RolePermissionType Structures (see Table 8).
286
- * Clients may determine their effective Permissions by logically ORing the Permissions for each
287
- * Role in the array.
288
- * The value of this Attribute is derived from the rules used by the Server to map Sessions to
289
- * Roles. This mapping may be vendor specific or it may use the standard Role model defined in 4.8.
290
- * This Attribute shall not be writeable.
291
- * If not specified, the value of DefaultUserRolePermissions Property from the Namespace
292
- * Metadata Object associated with the Node is used instead. If the NamespaceMetadata Object
293
- * does not define the Property or does not exist, then the Server does not publish any information
294
- * about Roles mapped to the current Session.
295
- *
296
- *
297
- * 5.2.11 AccessRestrictions
298
- * The optional AccessRestrictions Attribute specifies the AccessRestrictions that apply to a Node.
299
- * Its data type is defined in 8.56. If a Server supports AccessRestrictions for a particular
300
- * Namespace it adds the DefaultAccessRestrictions Property to the NamespaceMetadata Object
301
- * for that Namespace (see Figure 8). If a particular Node in the Namespace needs to override
302
- * the default value the Server adds the AccessRestrictions Attribute to the Node.
303
- * If a Server implements a vendor specific access restriction model for a Namespace, it does not
304
- * add the DefaultAccessRestrictions Property to the NamespaceMetadata Object.
305
- *
306
- *
307
- * DefaultAccessRestrictions
308
- *
309
- */
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ClientFile = exports.OpenFileMode = void 0;
13
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
14
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
+ const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
16
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
17
+ const node_opcua_variant_1 = require("node-opcua-variant");
18
+ const node_opcua_constants_1 = require("node-opcua-constants");
19
+ const node_opcua_debug_1 = require("node-opcua-debug");
20
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)("FileType");
21
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)("FileType");
22
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("FileType");
23
+ const open_mode_1 = require("../open_mode");
24
+ var open_mode_2 = require("../open_mode");
25
+ Object.defineProperty(exports, "OpenFileMode", { enumerable: true, get: function () { return open_mode_2.OpenFileMode; } });
26
+ /**
27
+ *
28
+ *
29
+ */
30
+ class ClientFile {
31
+ constructor(session, nodeId) {
32
+ this.fileHandle = 0;
33
+ this.session = session;
34
+ this.fileNodeId = nodeId;
35
+ }
36
+ open(mode) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ if (mode === null || mode === undefined) {
39
+ throw new Error("expecting a validMode " + open_mode_1.OpenFileMode[mode]);
40
+ }
41
+ if (this.fileHandle) {
42
+ throw new Error("File has already be opened");
43
+ }
44
+ yield this.ensureInitialized();
45
+ const result = yield this.session.call({
46
+ inputArguments: [
47
+ { dataType: node_opcua_variant_1.DataType.Byte, value: mode }
48
+ ],
49
+ methodId: this.openMethodNodeId,
50
+ objectId: this.fileNodeId
51
+ });
52
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
53
+ debugLog("Cannot open file : ");
54
+ throw new Error("cannot open file statusCode = " + result.statusCode.toString() + " mode = " + open_mode_1.OpenFileMode[mode]);
55
+ }
56
+ this.fileHandle = result.outputArguments[0].value;
57
+ return this.fileHandle;
58
+ });
59
+ }
60
+ close() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ if (!this.fileHandle) {
63
+ throw new Error("File has not been opened yet");
64
+ }
65
+ yield this.ensureInitialized();
66
+ const result = yield this.session.call({
67
+ inputArguments: [
68
+ { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }
69
+ ],
70
+ methodId: this.closeMethodNodeId,
71
+ objectId: this.fileNodeId
72
+ });
73
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
74
+ debugLog("Cannot close file : ");
75
+ throw new Error("cannot close file statusCode = " + result.statusCode.toString());
76
+ }
77
+ this.fileHandle = 0;
78
+ });
79
+ }
80
+ getPosition() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ yield this.ensureInitialized();
83
+ if (!this.fileHandle) {
84
+ throw new Error("File has not been opened yet");
85
+ }
86
+ const result = yield this.session.call({
87
+ inputArguments: [
88
+ { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }
89
+ ],
90
+ methodId: this.getPositionNodeId,
91
+ objectId: this.fileNodeId
92
+ });
93
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
94
+ throw new Error("Error " + result.statusCode.toString());
95
+ }
96
+ return result.outputArguments[0].value;
97
+ });
98
+ }
99
+ setPosition(position) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ yield this.ensureInitialized();
102
+ if (!this.fileHandle) {
103
+ throw new Error("File has not been opened yet");
104
+ }
105
+ if (typeof position === "number") {
106
+ position = [0, position];
107
+ }
108
+ const result = yield this.session.call({
109
+ inputArguments: [
110
+ { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
111
+ {
112
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
113
+ dataType: node_opcua_variant_1.DataType.UInt64,
114
+ value: position
115
+ }
116
+ ],
117
+ methodId: this.setPositionNodeId,
118
+ objectId: this.fileNodeId
119
+ });
120
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
121
+ throw new Error("Error " + result.statusCode.toString());
122
+ }
123
+ return;
124
+ });
125
+ }
126
+ read(bytesToRead) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ yield this.ensureInitialized();
129
+ if (!this.fileHandle) {
130
+ throw new Error("File has not been opened yet");
131
+ }
132
+ const result = yield this.session.call({
133
+ inputArguments: [
134
+ { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
135
+ {
136
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
137
+ dataType: node_opcua_variant_1.DataType.Int32,
138
+ value: bytesToRead
139
+ }
140
+ ],
141
+ methodId: this.readNodeId,
142
+ objectId: this.fileNodeId
143
+ });
144
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
145
+ throw new Error("Error " + result.statusCode.toString());
146
+ }
147
+ if (!result.outputArguments || result.outputArguments[0].dataType !== node_opcua_variant_1.DataType.ByteString) {
148
+ throw new Error("Error invalid output");
149
+ }
150
+ return result.outputArguments[0].value;
151
+ });
152
+ }
153
+ write(data) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ yield this.ensureInitialized();
156
+ if (!this.fileHandle) {
157
+ throw new Error("File has not been opened yet");
158
+ }
159
+ const result = yield this.session.call({
160
+ inputArguments: [
161
+ { dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
162
+ {
163
+ arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
164
+ dataType: node_opcua_variant_1.DataType.ByteString,
165
+ value: data
166
+ }
167
+ ],
168
+ methodId: this.writeNodeId,
169
+ objectId: this.fileNodeId
170
+ });
171
+ if (result.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
172
+ throw new Error("Error " + result.statusCode.toString());
173
+ }
174
+ return;
175
+ });
176
+ }
177
+ openCount() {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ yield this.ensureInitialized();
180
+ const nodeToRead = { nodeId: this.openCountNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
181
+ const dataValue = yield this.session.read(nodeToRead);
182
+ if (doDebug) {
183
+ debugLog(" OpenCount ", nodeToRead.nodeId.toString(), dataValue.toString());
184
+ }
185
+ return dataValue.value.value;
186
+ });
187
+ }
188
+ size() {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ yield this.ensureInitialized();
191
+ const nodeToRead = { nodeId: this.sizeNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
192
+ const dataValue = yield this.session.read(nodeToRead);
193
+ return dataValue.value.value;
194
+ });
195
+ }
196
+ // eslint-disable-next-line max-statements
197
+ extractMethodsIds() {
198
+ return __awaiter(this, void 0, void 0, function* () {
199
+ if (ClientFile.useGlobalMethod) {
200
+ debugLog("Using GlobalMethodId");
201
+ this.openMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Open);
202
+ this.closeMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Close);
203
+ this.setPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_SetPosition);
204
+ this.getPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_GetPosition);
205
+ this.writeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Write);
206
+ this.readNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Read);
207
+ const browsePaths = [
208
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
209
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
210
+ ];
211
+ const results = yield this.session.translateBrowsePath(browsePaths);
212
+ if (results[0].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
213
+ throw new Error("fileType object does not expose mandatory OpenCount Property");
214
+ }
215
+ if (results[1].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
216
+ throw new Error("fileType object does not expose mandatory Size Property");
217
+ }
218
+ this.openCountNodeId = results[0].targets[0].targetId;
219
+ this.sizeNodeId = results[1].targets[0].targetId;
220
+ return;
221
+ }
222
+ const browsePaths = [
223
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Open"),
224
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Close"),
225
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/SetPosition"),
226
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/GetPosition"),
227
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Write"),
228
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Read"),
229
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
230
+ (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
231
+ ];
232
+ const results = yield this.session.translateBrowsePath(browsePaths);
233
+ if (results[0].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
234
+ throw new Error("fileType object does not expose mandatory Open Method");
235
+ }
236
+ if (results[1].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
237
+ throw new Error("fileType object does not expose mandatory Close Method");
238
+ }
239
+ if (results[2].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
240
+ throw new Error("fileType object does not expose mandatory SetPosition Method");
241
+ }
242
+ if (results[3].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
243
+ throw new Error("fileType object does not expose mandatory GetPosition Method");
244
+ }
245
+ if (results[4].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
246
+ throw new Error("fileType object does not expose mandatory Write Method");
247
+ }
248
+ if (results[5].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
249
+ throw new Error("fileType object does not expose mandatory Read Method");
250
+ }
251
+ if (results[6].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
252
+ throw new Error("fileType object does not expose mandatory OpenCount Variable");
253
+ }
254
+ if (results[7].statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
255
+ throw new Error("fileType object does not expose mandatory Size Variable");
256
+ }
257
+ if (false && doDebug) {
258
+ results.map((x) => debugLog(x.toString()));
259
+ }
260
+ this.openMethodNodeId = results[0].targets[0].targetId;
261
+ this.closeMethodNodeId = results[1].targets[0].targetId;
262
+ this.setPositionNodeId = results[2].targets[0].targetId;
263
+ this.getPositionNodeId = results[3].targets[0].targetId;
264
+ this.writeNodeId = results[4].targets[0].targetId;
265
+ this.readNodeId = results[5].targets[0].targetId;
266
+ this.openCountNodeId = results[6].targets[0].targetId;
267
+ this.sizeNodeId = results[7].targets[0].targetId;
268
+ });
269
+ }
270
+ ensureInitialized() {
271
+ return __awaiter(this, void 0, void 0, function* () {
272
+ if (!this.openMethodNodeId) {
273
+ yield this.extractMethodsIds();
274
+ }
275
+ });
276
+ }
277
+ }
278
+ exports.ClientFile = ClientFile;
279
+ ClientFile.useGlobalMethod = false;
280
+ /**
281
+ * 5.2.10 UserRolePermissions
282
+ *
283
+ * The optional UserRolePermissions Attribute specifies the Permissions that apply to a Node for
284
+ * all Roles granted to current Session. The value of the Attribute is an array of
285
+ * RolePermissionType Structures (see Table 8).
286
+ * Clients may determine their effective Permissions by logically ORing the Permissions for each
287
+ * Role in the array.
288
+ * The value of this Attribute is derived from the rules used by the Server to map Sessions to
289
+ * Roles. This mapping may be vendor specific or it may use the standard Role model defined in 4.8.
290
+ * This Attribute shall not be writeable.
291
+ * If not specified, the value of DefaultUserRolePermissions Property from the Namespace
292
+ * Metadata Object associated with the Node is used instead. If the NamespaceMetadata Object
293
+ * does not define the Property or does not exist, then the Server does not publish any information
294
+ * about Roles mapped to the current Session.
295
+ *
296
+ *
297
+ * 5.2.11 AccessRestrictions
298
+ * The optional AccessRestrictions Attribute specifies the AccessRestrictions that apply to a Node.
299
+ * Its data type is defined in 8.56. If a Server supports AccessRestrictions for a particular
300
+ * Namespace it adds the DefaultAccessRestrictions Property to the NamespaceMetadata Object
301
+ * for that Namespace (see Figure 8). If a particular Node in the Namespace needs to override
302
+ * the default value the Server adds the AccessRestrictions Attribute to the Node.
303
+ * If a Server implements a vendor specific access restriction model for a Namespace, it does not
304
+ * add the DefaultAccessRestrictions Property to the NamespaceMetadata Object.
305
+ *
306
+ *
307
+ * DefaultAccessRestrictions
308
+ *
309
+ */
310
310
  //# sourceMappingURL=client_file.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- /**
2
- * @module node-opcua-file-transfer
3
- */
4
- export * from "./client/client_file";
5
- export * from "./server/file_type_helpers";
1
+ /**
2
+ * @module node-opcua-file-transfer
3
+ */
4
+ export * from "./client/client_file";
5
+ export * from "./server/file_type_helpers";