@drivelock/n8n-nodes-drivelock 0.1.3 → 0.2.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 (66) hide show
  1. package/README.md +40 -0
  2. package/dist/credentials/DrivelockApi.credentials.js +2 -2
  3. package/dist/credentials/DrivelockApi.credentials.js.map +1 -1
  4. package/dist/nodes/Drivelock/Drivelock.node.d.ts +6 -0
  5. package/dist/nodes/Drivelock/Drivelock.node.js +639 -105
  6. package/dist/nodes/Drivelock/Drivelock.node.js.map +1 -1
  7. package/dist/nodes/Drivelock/helper/CustomPropertyHelper.js.map +1 -0
  8. package/dist/nodes/Drivelock/helper/FilterBuilder.d.ts +25 -0
  9. package/dist/nodes/Drivelock/helper/FilterBuilder.js +153 -0
  10. package/dist/nodes/Drivelock/helper/FilterBuilder.js.map +1 -0
  11. package/dist/nodes/Drivelock/{GenericFunctions.d.ts → helper/GenericFunctions.d.ts} +1 -1
  12. package/dist/nodes/Drivelock/helper/GenericFunctions.js +77 -0
  13. package/dist/nodes/Drivelock/helper/GenericFunctions.js.map +1 -0
  14. package/dist/nodes/Drivelock/helper/ValidationHelpers.d.ts +6 -0
  15. package/dist/nodes/Drivelock/helper/ValidationHelpers.js +64 -0
  16. package/dist/nodes/Drivelock/helper/ValidationHelpers.js.map +1 -0
  17. package/dist/nodes/Drivelock/{utils.d.ts → helper/utils.d.ts} +1 -1
  18. package/dist/nodes/Drivelock/helper/utils.js.map +1 -0
  19. package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.d.ts +2 -0
  20. package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js +121 -0
  21. package/dist/nodes/Drivelock/operations/ApplicationRuleOperations.js.map +1 -0
  22. package/dist/nodes/Drivelock/{BinariesOperations.js → operations/BinariesOperations.js} +56 -10
  23. package/dist/nodes/Drivelock/operations/BinariesOperations.js.map +1 -0
  24. package/dist/nodes/Drivelock/operations/ComputerOperations.d.ts +2 -0
  25. package/dist/nodes/Drivelock/operations/ComputerOperations.js +284 -0
  26. package/dist/nodes/Drivelock/operations/ComputerOperations.js.map +1 -0
  27. package/dist/nodes/Drivelock/{CustomPropertyOperations.js → operations/CustomPropertyOperations.js} +13 -7
  28. package/dist/nodes/Drivelock/operations/CustomPropertyOperations.js.map +1 -0
  29. package/dist/nodes/Drivelock/operations/DeviceRuleOperations.d.ts +2 -0
  30. package/dist/nodes/Drivelock/operations/DeviceRuleOperations.js +130 -0
  31. package/dist/nodes/Drivelock/operations/DeviceRuleOperations.js.map +1 -0
  32. package/dist/nodes/Drivelock/operations/DriveRuleOperations.d.ts +2 -0
  33. package/dist/nodes/Drivelock/operations/DriveRuleOperations.js +130 -0
  34. package/dist/nodes/Drivelock/operations/DriveRuleOperations.js.map +1 -0
  35. package/dist/nodes/Drivelock/operations/EntityBinariesOperations.d.ts +2 -0
  36. package/dist/nodes/Drivelock/operations/EntityBinariesOperations.js +347 -0
  37. package/dist/nodes/Drivelock/operations/EntityBinariesOperations.js.map +1 -0
  38. package/dist/nodes/Drivelock/operations/EntityOperations.d.ts +2 -0
  39. package/dist/nodes/Drivelock/operations/EntityOperations.js +340 -0
  40. package/dist/nodes/Drivelock/operations/EntityOperations.js.map +1 -0
  41. package/dist/nodes/Drivelock/operations/FilterOperations.d.ts +2 -0
  42. package/dist/nodes/Drivelock/operations/FilterOperations.js +184 -0
  43. package/dist/nodes/Drivelock/operations/FilterOperations.js.map +1 -0
  44. package/dist/nodes/Drivelock/operations/GroupOperations.d.ts +2 -0
  45. package/dist/nodes/Drivelock/operations/GroupOperations.js +74 -0
  46. package/dist/nodes/Drivelock/operations/GroupOperations.js.map +1 -0
  47. package/dist/nodes/Drivelock/operations/PolicyOperations.d.ts +2 -0
  48. package/dist/nodes/Drivelock/operations/PolicyOperations.js +96 -0
  49. package/dist/nodes/Drivelock/operations/PolicyOperations.js.map +1 -0
  50. package/dist/package.json +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +1 -1
  53. package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.d.ts +0 -2
  54. package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.js +0 -50
  55. package/dist/nodes/Drivelock/ApplicationRulePropertyOperations.js.map +0 -1
  56. package/dist/nodes/Drivelock/BinariesOperations.js.map +0 -1
  57. package/dist/nodes/Drivelock/CustomPropertyHelper.js.map +0 -1
  58. package/dist/nodes/Drivelock/CustomPropertyOperations.js.map +0 -1
  59. package/dist/nodes/Drivelock/GenericFunctions.js +0 -48
  60. package/dist/nodes/Drivelock/GenericFunctions.js.map +0 -1
  61. package/dist/nodes/Drivelock/utils.js.map +0 -1
  62. /package/dist/nodes/Drivelock/{CustomPropertyHelper.d.ts → helper/CustomPropertyHelper.d.ts} +0 -0
  63. /package/dist/nodes/Drivelock/{CustomPropertyHelper.js → helper/CustomPropertyHelper.js} +0 -0
  64. /package/dist/nodes/Drivelock/{utils.js → helper/utils.js} +0 -0
  65. /package/dist/nodes/Drivelock/{BinariesOperations.d.ts → operations/BinariesOperations.d.ts} +0 -0
  66. /package/dist/nodes/Drivelock/{CustomPropertyOperations.d.ts → operations/CustomPropertyOperations.d.ts} +0 -0
@@ -34,16 +34,98 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Drivelock = void 0;
37
- const GenericFunctions_1 = require("./GenericFunctions");
38
37
  const n8n_workflow_1 = require("n8n-workflow");
39
- const CustomPropertyOperations_1 = require("./CustomPropertyOperations");
40
- const BinariesOperations_1 = require("./BinariesOperations");
41
- const customPropHelper = __importStar(require("./CustomPropertyHelper"));
42
- const ApplicationRulePropertyOperations_1 = require("./ApplicationRulePropertyOperations");
38
+ const GenericFunctions_1 = require("./helper/GenericFunctions");
39
+ const FilterBuilder_1 = require("./helper/FilterBuilder");
40
+ const ValidationHelpers_1 = require("./helper/ValidationHelpers");
41
+ const customPropHelper = __importStar(require("./helper/CustomPropertyHelper"));
42
+ const ApplicationRuleOperations_1 = require("./operations/ApplicationRuleOperations");
43
+ const BinariesOperations_1 = require("./operations/BinariesOperations");
44
+ const ComputerOperations_1 = require("./operations/ComputerOperations");
45
+ const CustomPropertyOperations_1 = require("./operations/CustomPropertyOperations");
46
+ const DeviceRuleOperations_1 = require("./operations/DeviceRuleOperations");
47
+ const DriveRuleOperations_1 = require("./operations/DriveRuleOperations");
48
+ const EntityOperations_1 = require("./operations/EntityOperations");
49
+ const GroupOperations_1 = require("./operations/GroupOperations");
50
+ const PolicyOperations_1 = require("./operations/PolicyOperations");
51
+ function extractResponseData(response) {
52
+ if (!response)
53
+ return { success: true };
54
+ if (typeof response === 'string')
55
+ return { data: response };
56
+ if (typeof response === 'object' && response !== null) {
57
+ const responseObj = response;
58
+ const { errorId, error, data, total, additionalInfo, ...rest } = responseObj;
59
+ const result = {
60
+ success: !error,
61
+ };
62
+ if (errorId !== undefined && errorId !== null)
63
+ result.errorId = errorId;
64
+ if (error !== undefined && error !== null)
65
+ result.error = error;
66
+ if (data !== undefined)
67
+ result.data = data;
68
+ if (total !== undefined)
69
+ result.total = total;
70
+ if (additionalInfo !== undefined && additionalInfo !== null) {
71
+ result.additionalInfo = additionalInfo;
72
+ }
73
+ for (const key of Object.keys(rest)) {
74
+ if (rest[key] !== undefined && rest[key] !== null) {
75
+ result[key] = rest[key];
76
+ }
77
+ }
78
+ return result;
79
+ }
80
+ return { success: true, data: response };
81
+ }
82
+ function getControlRuleConfig(operation) {
83
+ if (operation.includes('Collection')) {
84
+ return { ruleSubPath: 'collections', bodyKey: 'collections' };
85
+ }
86
+ if (operation.includes('Behavior')) {
87
+ return { ruleSubPath: 'behaviorRules', bodyKey: 'rules' };
88
+ }
89
+ return { ruleSubPath: 'rules', bodyKey: 'rules' };
90
+ }
91
+ async function executeControlRuleOperation(execFns, controlPath, dataParamName, operation, i) {
92
+ const configId = execFns.getNodeParameter('configId', i);
93
+ const configVersion = execFns.getNodeParameter('configVersion', i);
94
+ const { ruleSubPath, bodyKey } = getControlRuleConfig(operation);
95
+ const basePath = `/api/administration/${controlPath}/${ruleSubPath}`;
96
+ if (operation.startsWith('get')) {
97
+ const qs = {};
98
+ if (configVersion > 0)
99
+ qs.configVersion = configVersion;
100
+ const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, 'GET', `${basePath}/${configId}`, {}, qs);
101
+ return extractResponseData(response);
102
+ }
103
+ if (operation.startsWith('create') || operation.startsWith('update')) {
104
+ const dataStr = execFns.getNodeParameter(dataParamName, i);
105
+ const parsedData = (0, ValidationHelpers_1.parseJsonParameter)(dataStr, execFns.getNode(), i, dataParamName);
106
+ const body = { configId };
107
+ if (configVersion > 0)
108
+ body.configVersion = configVersion;
109
+ body[bodyKey] = parsedData;
110
+ const method = operation.startsWith('create') ? 'POST' : 'PATCH';
111
+ const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, method, basePath, body);
112
+ return extractResponseData(response);
113
+ }
114
+ if (operation.startsWith('delete')) {
115
+ const ruleIdsStr = execFns.getNodeParameter('ruleIds', i);
116
+ const ruleIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(ruleIdsStr, execFns.getNode(), i, 'ruleIds');
117
+ const body = { configId, ruleIds };
118
+ if (configVersion > 0)
119
+ body.configVersion = configVersion;
120
+ const response = await GenericFunctions_1.driveLockApiRequest.call(execFns, 'DELETE', basePath, body);
121
+ return extractResponseData(response);
122
+ }
123
+ throw new n8n_workflow_1.NodeOperationError(execFns.getNode(), `Unknown operation: ${operation}`);
124
+ }
43
125
  class Drivelock {
44
126
  constructor() {
45
127
  this.description = {
46
- displayName: 'DriveLock',
128
+ displayName: 'DriveLock API',
47
129
  name: 'drivelock',
48
130
  icon: 'file:drivelock.svg',
49
131
  group: ['transform'],
@@ -52,7 +134,7 @@ class Drivelock {
52
134
  subtitle: '={{$if($parameter["operation"], $parameter["operation"] + " : ", "") + $parameter["resource"]}}',
53
135
  description: 'Consume DriveLock API',
54
136
  defaults: {
55
- name: 'DriveLock Software',
137
+ name: 'DriveLock API',
56
138
  },
57
139
  inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
58
140
  outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
@@ -60,8 +142,8 @@ class Drivelock {
60
142
  {
61
143
  name: 'driveLockApi',
62
144
  required: true,
63
- testedBy: 'driveLockApiTest'
64
- }
145
+ testedBy: 'driveLockApiTest',
146
+ },
65
147
  ],
66
148
  usableAsTool: true,
67
149
  properties: [
@@ -72,30 +154,50 @@ class Drivelock {
72
154
  noDataExpression: true,
73
155
  options: [
74
156
  {
75
- name: 'Manage Computer',
76
- value: 'computers',
77
- description: 'Manage the computers',
157
+ name: 'Application Rule',
158
+ value: 'applicationRules',
159
+ description: 'Manage application rules',
78
160
  },
79
161
  {
80
- name: 'Manage User',
81
- value: 'users',
82
- description: 'Manage the users',
162
+ name: 'Computer',
163
+ value: 'computer',
164
+ description: 'Manage computers',
83
165
  },
84
166
  {
85
- name: 'Manage Device',
86
- value: 'devices',
87
- description: 'Manage the devices',
167
+ name: 'Device Rule',
168
+ value: 'deviceRules',
169
+ description: 'Manage device rules',
88
170
  },
89
171
  {
90
- name: 'Manage Software',
91
- value: 'software',
92
- description: 'Manage the software',
172
+ name: 'Drive Rule',
173
+ value: 'driveRules',
174
+ description: 'Manage drive rules',
93
175
  },
94
176
  {
95
- name: 'Manage Binary',
177
+ name: 'Binary',
96
178
  value: 'binaries',
97
179
  description: 'Manage binaries',
98
180
  },
181
+ {
182
+ name: 'Entity',
183
+ value: 'entity',
184
+ description: 'Manage entities',
185
+ },
186
+ {
187
+ name: 'Group',
188
+ value: 'group',
189
+ description: 'Manage groups',
190
+ },
191
+ {
192
+ name: 'Policy',
193
+ value: 'policy',
194
+ description: 'Manage policies',
195
+ },
196
+ {
197
+ name: 'Tool',
198
+ value: 'tool',
199
+ description: 'Tool to handle DriveLock node data',
200
+ },
99
201
  {
100
202
  name: 'Manage Schema Extention',
101
203
  value: 'customproperty',
@@ -104,56 +206,204 @@ class Drivelock {
104
206
  ],
105
207
  default: 'customproperty',
106
208
  },
107
- ...CustomPropertyOperations_1.customPropertyOperations,
209
+ {
210
+ displayName: 'Operation',
211
+ name: 'operation',
212
+ type: 'options',
213
+ noDataExpression: true,
214
+ displayOptions: {
215
+ show: {
216
+ resource: ['tool'],
217
+ },
218
+ },
219
+ options: [
220
+ {
221
+ name: 'Change JSON Data-Return to Item Array',
222
+ value: 'changeoutput',
223
+ description: 'Change the output',
224
+ action: 'Change JSON data return to item array',
225
+ },
226
+ ],
227
+ default: 'changeoutput',
228
+ },
229
+ ...ApplicationRuleOperations_1.applicationRuleOperations,
108
230
  ...BinariesOperations_1.binariesOperations,
109
- ...ApplicationRulePropertyOperations_1.applicationRulePropertyOperations,
231
+ ...ComputerOperations_1.computerOperations,
232
+ ...CustomPropertyOperations_1.customPropertyOperations,
233
+ ...DeviceRuleOperations_1.deviceRuleOperations,
234
+ ...DriveRuleOperations_1.driveRuleOperations,
235
+ ...EntityOperations_1.entityOperations,
236
+ ...GroupOperations_1.groupOperations,
237
+ ...PolicyOperations_1.policyOperations,
110
238
  ],
111
239
  };
112
240
  this.methods = {
113
241
  loadOptions: {
114
- async getSchemaExtentions() {
242
+ async getBinaryProps() {
115
243
  var _a;
116
- const returnData = [];
244
+ const allOptions = (((_a = BinariesOperations_1.binariesOperations.find((field) => field.name === 'properties')) === null || _a === void 0 ? void 0 : _a.options) || []);
245
+ return allOptions.map((option) => ({
246
+ name: option.value,
247
+ value: option.value,
248
+ }));
249
+ },
250
+ async getSchemaExtentions() {
117
251
  const customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
118
252
  const resource = this.getNodeParameter('resource');
119
253
  let schemaExtention;
120
- if (resource == "customproperty") {
254
+ if (resource === 'customproperty') {
121
255
  const schema = this.getNodeParameter('schema');
122
256
  schemaExtention = `${schema}Extensions`;
123
257
  }
124
- else if (resource == "binaries") {
125
- schemaExtention = `AcBinariesExtensions`;
258
+ else if (resource === 'binaries') {
259
+ schemaExtention = 'AcBinariesExtensions';
260
+ }
261
+ else {
262
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
263
+ message: `Unsupported resource for schema extensions: ${resource}`,
264
+ });
265
+ }
266
+ if (Array.isArray(customSchemes.data)) {
267
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
268
+ }
269
+ else if (!customSchemes.data.customProps) {
270
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
271
+ }
272
+ const extensionGroupItems = customSchemes.data.customProps[schemaExtention];
273
+ if (!extensionGroupItems) {
274
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
275
+ message: `Schema extension '${schemaExtention}' not found`,
276
+ });
126
277
  }
278
+ return Object.keys(extensionGroupItems).map((key) => ({
279
+ name: key,
280
+ value: key,
281
+ }));
282
+ },
283
+ async getEntityExtentions() {
284
+ const customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
285
+ const entityName = this.getNodeParameter('entityName');
286
+ const schemaExtention = `${entityName}Extensions`;
127
287
  if (Array.isArray(customSchemes.data)) {
128
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. data should be an object" });
288
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
129
289
  }
130
290
  else if (!customSchemes.data.customProps) {
131
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. object is missing" });
132
- }
133
- const extensionGroupItems = (_a = customSchemes.data.customProps) === null || _a === void 0 ? void 0 : _a[schemaExtention];
134
- Object.entries(extensionGroupItems).forEach(([key,]) => {
135
- const propertyName = key;
136
- const propertyId = key;
137
- returnData.push({
138
- name: propertyName,
139
- value: propertyId,
291
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
292
+ }
293
+ const extensionGroupItems = customSchemes.data.customProps[schemaExtention];
294
+ if (!extensionGroupItems) {
295
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
296
+ message: `Schema extension '${schemaExtention}' not found`,
297
+ });
298
+ }
299
+ return Object.keys(extensionGroupItems).map((key) => ({
300
+ name: key,
301
+ value: key,
302
+ }));
303
+ },
304
+ async getComputerIds() {
305
+ const response = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/Computers', {}, { take: 200, select: 'id,name', getTotalCount: false });
306
+ if (!Array.isArray(response.data))
307
+ return [];
308
+ return response.data.map((item) => {
309
+ var _a, _b, _c;
310
+ return ({
311
+ name: (_b = (_a = item.name) !== null && _a !== void 0 ? _a : item.id) !== null && _b !== void 0 ? _b : 'Unknown',
312
+ value: (_c = item.id) !== null && _c !== void 0 ? _c : '',
313
+ });
314
+ });
315
+ },
316
+ async getEntityIds() {
317
+ const entityName = this.getNodeParameter('entityName', 0);
318
+ const response = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', `/api/administration/entity/${entityName}`, {}, { take: 200, select: 'id,name', getTotalCount: false });
319
+ if (!Array.isArray(response.data))
320
+ return [];
321
+ return response.data.map((item) => {
322
+ var _a, _b, _c;
323
+ return ({
324
+ name: (_b = (_a = item.name) !== null && _a !== void 0 ? _a : item.id) !== null && _b !== void 0 ? _b : 'Unknown',
325
+ value: (_c = item.id) !== null && _c !== void 0 ? _c : '',
326
+ });
327
+ });
328
+ },
329
+ async getDeviceRuleIds() {
330
+ const qs = { take: 200, select: 'id,name', getTotalCount: false };
331
+ try {
332
+ const configId = this.getNodeParameter('configId', 0);
333
+ if (configId)
334
+ qs.configId = configId;
335
+ }
336
+ catch { }
337
+ try {
338
+ const configVersion = this.getNodeParameter('configVersion', 0);
339
+ if (configVersion)
340
+ qs.configVersion = configVersion;
341
+ }
342
+ catch { }
343
+ const response = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/deviceControl/rules', {}, qs);
344
+ if (!Array.isArray(response.data))
345
+ return [];
346
+ return response.data.map((item) => {
347
+ var _a, _b, _c;
348
+ return ({
349
+ name: (_b = (_a = item.name) !== null && _a !== void 0 ? _a : item.id) !== null && _b !== void 0 ? _b : 'Unknown',
350
+ value: (_c = item.id) !== null && _c !== void 0 ? _c : '',
351
+ });
352
+ });
353
+ },
354
+ async getDriveRuleIds() {
355
+ const qs = { take: 200, select: 'id,name', getTotalCount: false };
356
+ try {
357
+ const configId = this.getNodeParameter('configId', 0);
358
+ if (configId)
359
+ qs.configId = configId;
360
+ }
361
+ catch { }
362
+ try {
363
+ const configVersion = this.getNodeParameter('configVersion', 0);
364
+ if (configVersion)
365
+ qs.configVersion = configVersion;
366
+ }
367
+ catch { }
368
+ const response = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/driveControl/rules', {}, qs);
369
+ if (!Array.isArray(response.data))
370
+ return [];
371
+ return response.data.map((item) => {
372
+ var _a, _b, _c;
373
+ return ({
374
+ name: (_b = (_a = item.name) !== null && _a !== void 0 ? _a : item.id) !== null && _b !== void 0 ? _b : 'Unknown',
375
+ value: (_c = item.id) !== null && _c !== void 0 ? _c : '',
140
376
  });
141
377
  });
142
- return returnData;
143
378
  },
144
379
  },
145
380
  };
146
381
  }
147
382
  async execute() {
148
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
383
+ var _a;
149
384
  const items = this.getInputData();
150
385
  const returnData = [];
151
386
  const length = items.length;
387
+ const resource = this.getNodeParameter('resource', 0);
388
+ const operation = this.getNodeParameter('operation', 0);
152
389
  for (let i = 0; i < length; i++) {
153
390
  try {
154
- const resource = this.getNodeParameter('resource', i);
155
- const operation = this.getNodeParameter('operation', i);
156
- if (resource === 'customproperty') {
391
+ if (resource === 'tool') {
392
+ if (operation === 'changeoutput') {
393
+ const toolOutput = items.flatMap((item) => {
394
+ var _a;
395
+ const dataArray = (_a = item === null || item === void 0 ? void 0 : item.json) === null || _a === void 0 ? void 0 : _a.data;
396
+ if (!Array.isArray(dataArray)) {
397
+ return [];
398
+ }
399
+ return dataArray.map((dataItem) => ({
400
+ json: dataItem,
401
+ }));
402
+ });
403
+ return [toolOutput];
404
+ }
405
+ }
406
+ else if (resource === 'customproperty') {
157
407
  const schema = this.getNodeParameter('schema', i);
158
408
  const schemaExtention = `${schema}Extensions`;
159
409
  if (operation === 'check') {
@@ -161,54 +411,51 @@ class Drivelock {
161
411
  const customProperties = this.getNodeParameter('customProperties', i).customPropertyValues;
162
412
  let customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
163
413
  if (Array.isArray(customSchemes.data)) {
164
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. data should be an object" });
414
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
165
415
  }
166
416
  else if (!customSchemes.data.customProps) {
167
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. object is missing" });
417
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
168
418
  }
169
- let checkResult = customPropHelper.checkPropsAndTypes((_b = (_a = customSchemes.data) === null || _a === void 0 ? void 0 : _a.customProps) === null || _b === void 0 ? void 0 : _b[schemaExtention], customProperties);
170
- let allPropertiesFound = !Object.values(checkResult).some(v => v.name !== true);
171
- let allDataTypesCorrect = !Object.values(checkResult).some(v => v.datatype !== true);
172
- let allNotChanged = !Object.values(checkResult).some(v => v.changed !== false);
173
- if (allDataTypesCorrect && (createOrUpdateIfNotExists || !allNotChanged)) {
174
- const adjustedProps = customPropHelper.adjustProps(checkResult, schemaExtention, (_c = customSchemes.data) === null || _c === void 0 ? void 0 : _c.customProps, customProperties);
175
- const endpoint = `/api/administration/entity/customSchema/setCustomSchemas`;
176
- const body = { "customProps": adjustedProps };
419
+ let checkResult = customPropHelper.checkPropsAndTypes(customSchemes.data.customProps[schemaExtention], customProperties);
420
+ let allPropertiesFound = Object.values(checkResult).every((v) => v.name === true);
421
+ let allDataTypesCorrect = Object.values(checkResult).every((v) => v.datatype === true);
422
+ let allNotChanged = Object.values(checkResult).every((v) => v.changed === false);
423
+ if (allDataTypesCorrect && createOrUpdateIfNotExists) {
424
+ const adjustedProps = customPropHelper.adjustProps(checkResult, schemaExtention, customSchemes.data.customProps, customProperties);
425
+ const endpoint = '/api/administration/entity/customSchema/setCustomSchemas';
426
+ const body = { customProps: adjustedProps };
177
427
  const updateResult = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', endpoint, body, {}, { returnFullResponse: true });
178
- if (updateResult.statusCode !== 200) {
179
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The update errored for some reasons - returned not with status-code 200. ${updateResult.body}`, { itemIndex: i });
428
+ const statusCode = updateResult.statusCode;
429
+ if (statusCode !== undefined && statusCode !== 200) {
430
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The update errored - returned status-code ${statusCode}. ${JSON.stringify(updateResult.body)}`, { itemIndex: i });
180
431
  }
181
- else {
182
- customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
183
- if (Array.isArray(customSchemes.data)) {
184
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. data should be an object" });
185
- }
186
- else if (!customSchemes.data.customProps) {
187
- throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: "invalid API response. object is missing" });
188
- }
189
- checkResult = customPropHelper.checkPropsAndTypes((_e = (_d = customSchemes.data) === null || _d === void 0 ? void 0 : _d.customProps) === null || _e === void 0 ? void 0 : _e[schemaExtention], customProperties);
190
- allPropertiesFound = !Object.values(checkResult).some(v => v.name !== true);
191
- allDataTypesCorrect = !Object.values(checkResult).some(v => v.datatype !== true);
192
- allNotChanged = !Object.values(checkResult).some(v => v.changed !== false);
432
+ customSchemes = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', '/api/administration/entity/customSchema/getCustomSchemas', {});
433
+ if (Array.isArray(customSchemes.data)) {
434
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. data should be an object' });
435
+ }
436
+ else if (!customSchemes.data.customProps) {
437
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'invalid API response. object is missing' });
193
438
  }
439
+ checkResult = customPropHelper.checkPropsAndTypes(customSchemes.data.customProps[schemaExtention], customProperties);
440
+ allPropertiesFound = Object.values(checkResult).every((v) => v.name === true);
441
+ allDataTypesCorrect = Object.values(checkResult).every((v) => v.datatype === true);
442
+ allNotChanged = Object.values(checkResult).every((v) => v.changed === false);
194
443
  }
195
- const success = (allPropertiesFound && allDataTypesCorrect);
444
+ const success = allPropertiesFound && allDataTypesCorrect;
196
445
  const responseData = { allPropertiesFound, allDataTypesCorrect, allNotChanged, details: checkResult };
197
446
  if (success) {
198
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
199
- returnData.push(...executionData);
447
+ returnData.push(responseData);
200
448
  }
201
449
  else {
202
450
  const outputData = JSON.stringify(responseData);
203
451
  if (!createOrUpdateIfNotExists) {
204
- const errorMsg = `Please configure the Custom properties proper here or in DOC. Tick the 'Create properties ...' Button to create missing entires here (or in DOC).\n\nCheck says ${outputData}`;
205
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMsg, { itemIndex: i });
452
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Please configure the Custom properties proper here or in DOC. Tick the 'Create properties ...' Button to create missing entries here (or in DOC).\n\nCheck says ${outputData}`, { itemIndex: i });
206
453
  }
207
454
  else if (!allPropertiesFound) {
208
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `While trying to create Some custom properties are missing or have incorrect data types. Details: ${outputData}`, { itemIndex: i });
455
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `While trying to create: Some custom properties are missing or have incorrect data types. Details: ${outputData}`, { itemIndex: i });
209
456
  }
210
457
  else if (!allDataTypesCorrect) {
211
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Some custom properties are missing or have incorrect data types. Details: ${outputData}`, { itemIndex: i });
458
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Some custom properties have incorrect data types. Details: ${outputData}`, { itemIndex: i });
212
459
  }
213
460
  }
214
461
  }
@@ -218,76 +465,363 @@ class Drivelock {
218
465
  const payload = customPropHelper.createSetPayload(customPropertyId.value, updateProperties);
219
466
  const url = `/api/administration/entity/customSchema/setCustomData/${schemaExtention}`;
220
467
  await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', url, payload);
221
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ success: true, payload: payload }), { itemData: { item: i } });
222
- returnData.push(...executionData);
468
+ returnData.push({ success: true, payload });
223
469
  }
224
470
  }
225
471
  else if (resource === 'binaries') {
226
472
  if (operation === 'getAll') {
227
- const endpoint = `/api/administration/entity/AcBinaries`;
473
+ const endpoint = '/api/administration/entity/AcBinaries';
228
474
  const returnAll = this.getNodeParameter('returnAll', i);
229
475
  const getFullObject = this.getNodeParameter('getFullObject', i);
230
- let select_fields;
476
+ let selectFields;
231
477
  if (!getFullObject) {
232
478
  const propertiesToInclude = this.getNodeParameter('properties', i);
233
479
  const extentionPropertiesToInclude = this.getNodeParameter('extentionproperties', i);
234
480
  if (Array.isArray(propertiesToInclude)) {
235
- select_fields = propertiesToInclude.map(key => `${key}`).join(',');
481
+ selectFields = propertiesToInclude.join(',');
236
482
  }
237
483
  if (Array.isArray(extentionPropertiesToInclude)) {
238
- const select_extentionfields = extentionPropertiesToInclude.map(key => `extensions.${key}`).join(',');
239
- if (select_extentionfields)
240
- select_fields += `,${select_extentionfields}`;
484
+ const extFields = extentionPropertiesToInclude
485
+ .map((key) => `extensions.${key}`)
486
+ .join(',');
487
+ if (extFields) {
488
+ selectFields = selectFields ? `${selectFields},${extFields}` : extFields;
489
+ }
241
490
  }
242
491
  }
243
492
  const qs = {
244
493
  sortBy: '-extensions.VirusTotalLastFetch',
245
494
  select: null,
246
- query: null,
247
495
  getTotalCount: true,
248
496
  getFullObjects: getFullObject,
249
497
  getAsFlattenedList: false,
250
498
  };
251
- if (!getFullObject)
252
- qs.select = `id,${select_fields},`;
253
- qs.take = 10;
499
+ if (!getFullObject && selectFields) {
500
+ qs.select = `id,${selectFields}`;
501
+ }
502
+ const pageSize = 500;
503
+ qs.take = pageSize;
504
+ const filterMode = this.getNodeParameter('filterMode', i, 'builder');
505
+ const filterRaw = this.getNodeParameter('filterRaw', i, '');
506
+ const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
507
+ const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
508
+ const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
509
+ if (builtQuery)
510
+ qs.query = builtQuery;
511
+ let limit = -1;
254
512
  if (!returnAll) {
255
- const limit = this.getNodeParameter('limit', i);
513
+ limit = this.getNodeParameter('limit', i);
256
514
  if (qs.take > limit)
257
515
  qs.take = limit;
258
516
  }
259
517
  const responseData = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', endpoint, {}, qs);
260
- const total = (_f = responseData.total) !== null && _f !== void 0 ? _f : 0;
261
- if (total > qs.take) {
262
- while (((_g = responseData.data) === null || _g === void 0 ? void 0 : _g.length) < total) {
263
- qs.skip = (_h = responseData.data) === null || _h === void 0 ? void 0 : _h.length;
264
- const additionalData = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', endpoint, {}, qs);
265
- if (!Array.isArray(additionalData.data)) {
266
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Some custom properties are missing or have incorrect data types. Details`, { itemIndex: i });
518
+ const total = (_a = responseData.total) !== null && _a !== void 0 ? _a : 0;
519
+ if (Array.isArray(responseData.data)) {
520
+ const targetCount = returnAll ? total : Math.min(limit, total);
521
+ if (responseData.data.length < targetCount) {
522
+ while (responseData.data.length < targetCount) {
523
+ qs.skip = responseData.data.length;
524
+ if (!returnAll) {
525
+ const remaining = limit - responseData.data.length;
526
+ qs.take = Math.min(pageSize, remaining);
527
+ }
528
+ try {
529
+ const additionalData = await (GenericFunctions_1.driveLockApiRequest).call(this, 'GET', endpoint, {}, qs);
530
+ if (!Array.isArray(additionalData.data)) {
531
+ responseData.paginationWarning =
532
+ 'Unexpected API response during pagination: data is not an array. Returning partial results.';
533
+ break;
534
+ }
535
+ responseData.data.push(...additionalData.data);
536
+ if (!returnAll && responseData.data.length >= limit)
537
+ break;
538
+ }
539
+ catch (error) {
540
+ responseData.paginationWarning =
541
+ `Pagination stopped after fetching ${responseData.data.length} of ${targetCount} items: ${error.message}`;
542
+ break;
543
+ }
267
544
  }
268
- responseData.data.push(...additionalData.data);
269
545
  }
270
546
  }
271
- responseData.n8nProcessedTotal = (_j = responseData.data) === null || _j === void 0 ? void 0 : _j.length;
272
- if (responseData) {
273
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
274
- returnData.push(...executionData);
275
- }
547
+ responseData.n8nProcessedTotal = Array.isArray(responseData.data)
548
+ ? responseData.data.length
549
+ : 0;
550
+ returnData.push(responseData);
551
+ }
552
+ }
553
+ else if (resource === 'computer') {
554
+ if (operation === 'delete') {
555
+ const computerIdsStr = this.getNodeParameter('computerIds', i);
556
+ const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
557
+ const deleteRecoveryData = this.getNodeParameter('deleteRecoveryData', i);
558
+ const deleteEvents = this.getNodeParameter('deleteEvents', i);
559
+ const deleteGroupDefinitions = this.getNodeParameter('deleteGroupDefinitions', i);
560
+ const body = {
561
+ computerIds,
562
+ deleteRecoveryData,
563
+ deleteEvents,
564
+ deleteGroupDefinitions,
565
+ };
566
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/delete', body);
567
+ returnData.push(extractResponseData(response));
568
+ }
569
+ else if (operation === 'executeActions') {
570
+ const computerIdsStr = this.getNodeParameter('computerIds', i);
571
+ const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
572
+ const actionsStr = this.getNodeParameter('actions', i);
573
+ const notifyAgent = this.getNodeParameter('notifyAgent', i);
574
+ const actions = (0, ValidationHelpers_1.parseJsonParameter)(actionsStr, this.getNode(), i, 'actions');
575
+ const body = { computerIds, actions, notifyAgent };
576
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/actions', body);
577
+ returnData.push(extractResponseData(response));
578
+ }
579
+ else if (operation === 'onlineUnlock') {
580
+ const computerId = this.getNodeParameter('computerId', i);
581
+ const unlockDataStr = this.getNodeParameter('unlockData', i);
582
+ const data = (0, ValidationHelpers_1.parseJsonParameter)(unlockDataStr, this.getNode(), i, 'unlockData');
583
+ const body = { computerId, data };
584
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/online/unlock', body);
585
+ returnData.push(extractResponseData(response));
586
+ }
587
+ else if (operation === 'stopOnlineUnlock') {
588
+ const computerId = this.getNodeParameter('computerId', i);
589
+ const body = { computerId };
590
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/online/stopUnlock', body);
591
+ returnData.push(extractResponseData(response));
592
+ }
593
+ else if (operation === 'markForRejoin') {
594
+ const computerIdsStr = this.getNodeParameter('computerIds', i);
595
+ const computerIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(computerIdsStr, this.getNode(), i, 'computerIds');
596
+ const allowToRejoin = this.getNodeParameter('allowToRejoin', i);
597
+ const body = { computerIds, allowToRejoin };
598
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/markAgentForRejoin', body);
599
+ returnData.push(extractResponseData(response));
600
+ }
601
+ else if (operation === 'clearAgentIdToken') {
602
+ const computerId = this.getNodeParameter('computerId', i);
603
+ const body = { computerId };
604
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/clearAgentIdToken', body);
605
+ returnData.push(extractResponseData(response));
606
+ }
607
+ else if (operation === 'setImageFlag') {
608
+ const computerId = this.getNodeParameter('computerId', i);
609
+ const imageFlag = this.getNodeParameter('imageFlag', i);
610
+ const body = { computerId, imageFlag };
611
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/setImageFlag', body);
612
+ returnData.push(extractResponseData(response));
613
+ }
614
+ else if (operation === 'stopOnlineUnlocks') {
615
+ const computerIdsStr = this.getNodeParameter('computerIds', i);
616
+ const computerIds = computerIdsStr.split(',').map((id) => id.trim()).filter(Boolean);
617
+ const body = { computerIds };
618
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/stopOnlineUnlocks', body);
619
+ returnData.push(extractResponseData(response));
620
+ }
621
+ else if (operation === 'bitlockerRecovery') {
622
+ const recoveryId = this.getNodeParameter('recoveryId', i);
623
+ const body = { recoveryId };
624
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/recovery/bitlockerRecovery', body);
625
+ returnData.push(extractResponseData(response));
626
+ }
627
+ else if (operation === 'bitlocker2goRecovery') {
628
+ const recoveryId = this.getNodeParameter('recoveryId', i);
629
+ const body = { recoveryId };
630
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/computer/recovery/bitlocker2goRecovery', body);
631
+ returnData.push(extractResponseData(response));
632
+ }
633
+ }
634
+ else if (resource === 'entity') {
635
+ const entityName = this.getNodeParameter('entityName', i);
636
+ if (operation === 'getList') {
637
+ const additionalFields = this.getNodeParameter('additionalFields', i);
638
+ const qs = {};
639
+ if (additionalFields.select)
640
+ qs.select = additionalFields.select;
641
+ if (additionalFields.sortBy)
642
+ qs.sortBy = additionalFields.sortBy;
643
+ if (additionalFields.groupBy)
644
+ qs.groupBy = additionalFields.groupBy;
645
+ if (additionalFields.skip !== undefined)
646
+ qs.skip = additionalFields.skip;
647
+ if (additionalFields.take !== undefined)
648
+ qs.take = additionalFields.take;
649
+ if (additionalFields.getTotalCount !== undefined)
650
+ qs.getTotalCount = additionalFields.getTotalCount;
651
+ if (additionalFields.includeLinkedObjects !== undefined)
652
+ qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
653
+ if (additionalFields.getFullObjects !== undefined)
654
+ qs.getFullObjects = additionalFields.getFullObjects;
655
+ if (additionalFields.getAsFlattenedList !== undefined)
656
+ qs.getAsFlattenedList = additionalFields.getAsFlattenedList;
657
+ const filterMode = this.getNodeParameter('filterMode', i, 'builder');
658
+ const filterRaw = this.getNodeParameter('filterRaw', i, '');
659
+ const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
660
+ const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
661
+ const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
662
+ if (builtQuery)
663
+ qs.query = builtQuery;
664
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}`, {}, qs);
665
+ returnData.push(extractResponseData(response));
666
+ }
667
+ else if (operation === 'getCount') {
668
+ const additionalFields = this.getNodeParameter('additionalFields', i);
669
+ const qs = {};
670
+ if (additionalFields.groupBy)
671
+ qs.groupBy = additionalFields.groupBy;
672
+ const filterMode = this.getNodeParameter('filterMode', i, 'builder');
673
+ const filterRaw = this.getNodeParameter('filterRaw', i, '');
674
+ const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
675
+ const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
676
+ const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
677
+ if (builtQuery)
678
+ qs.query = builtQuery;
679
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/count`, {}, qs);
680
+ returnData.push(extractResponseData(response));
681
+ }
682
+ else if (operation === 'getById') {
683
+ const entityId = this.getNodeParameter('entityId', i);
684
+ const includeLinkedObjects = this.getNodeParameter('includeLinkedObjects', i);
685
+ const qs = { includeLinkedObjects };
686
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/${entityId}`, {}, qs);
687
+ returnData.push(extractResponseData(response));
688
+ }
689
+ else if (operation === 'export') {
690
+ const exportFormat = this.getNodeParameter('exportFormat', i);
691
+ const additionalFields = this.getNodeParameter('additionalFields', i);
692
+ const exportOptions = this.getNodeParameter('exportOptions', i);
693
+ const qs = { exportFormat };
694
+ if (additionalFields.select)
695
+ qs.select = additionalFields.select;
696
+ if (additionalFields.sortBy)
697
+ qs.sortBy = additionalFields.sortBy;
698
+ if (additionalFields.groupBy)
699
+ qs.groupBy = additionalFields.groupBy;
700
+ if (additionalFields.skip !== undefined)
701
+ qs.skip = additionalFields.skip;
702
+ if (additionalFields.take !== undefined)
703
+ qs.take = additionalFields.take;
704
+ if (additionalFields.includeLinkedObjects !== undefined)
705
+ qs.includeLinkedObjects = additionalFields.includeLinkedObjects;
706
+ if (additionalFields.getFullObjects !== undefined)
707
+ qs.getFullObjects = additionalFields.getFullObjects;
708
+ if (additionalFields.getAsFlattenedList !== undefined)
709
+ qs.getAsFlattenedList = additionalFields.getAsFlattenedList;
710
+ if (additionalFields.maskUserProperties !== undefined)
711
+ qs.maskUserProperties = additionalFields.maskUserProperties;
712
+ if (additionalFields.maskComputerProperties !== undefined)
713
+ qs.maskComputerProperties = additionalFields.maskComputerProperties;
714
+ const filterMode = this.getNodeParameter('filterMode', i, 'builder');
715
+ const filterRaw = this.getNodeParameter('filterRaw', i, '');
716
+ const filterCombinator = this.getNodeParameter('filterCombinator', i, 'and');
717
+ const filterGroupsParam = this.getNodeParameter('filterGroups', i, { groups: [] });
718
+ const builtQuery = (0, FilterBuilder_1.buildFilterQuery)(filterMode, filterRaw, filterCombinator, filterGroupsParam);
719
+ if (builtQuery)
720
+ qs.query = builtQuery;
721
+ if (exportOptions.readability !== undefined)
722
+ qs.readability = exportOptions.readability;
723
+ if (exportOptions.separator)
724
+ qs.separator = exportOptions.separator;
725
+ if (exportOptions.language)
726
+ qs.language = exportOptions.language;
727
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/entity/${entityName}/export`, {}, qs, { json: false });
728
+ returnData.push(extractResponseData(response));
729
+ }
730
+ else if (operation === 'getPermissions') {
731
+ const entityId = this.getNodeParameter('entityId', i);
732
+ const body = { entityName, entityId };
733
+ const permResponse = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/entity/getEntityPermissions', body);
734
+ returnData.push(extractResponseData(permResponse));
735
+ }
736
+ }
737
+ else if (resource === 'group') {
738
+ if (operation === 'addComputersToGroup') {
739
+ const groupId = this.getNodeParameter('groupId', i);
740
+ const membershipsStr = this.getNodeParameter('memberships', i);
741
+ const memberships = (0, ValidationHelpers_1.parseJsonParameter)(membershipsStr, this.getNode(), i, 'memberships');
742
+ const body = { groupId, memberships };
743
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/group/definedGroupMemberships/computers', body);
744
+ returnData.push(extractResponseData(response));
745
+ }
746
+ else if (operation === 'removeGroupMemberships') {
747
+ const membershipIdsStr = this.getNodeParameter('membershipIds', i);
748
+ const membershipIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(membershipIdsStr, this.getNode(), i, 'membershipIds');
749
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'DELETE', '/api/administration/group/definedGroupMemberships', membershipIds);
750
+ returnData.push(extractResponseData(response));
751
+ }
752
+ }
753
+ else if (resource === 'applicationRules') {
754
+ returnData.push(await executeControlRuleOperation(this, 'applicationControl', 'rules', operation, i));
755
+ }
756
+ else if (resource === 'deviceRules') {
757
+ if (operation === 'getRule') {
758
+ const ruleId = this.getNodeParameter('ruleId', i);
759
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/deviceControl/rules/${ruleId}`);
760
+ returnData.push(extractResponseData(response));
761
+ }
762
+ else {
763
+ returnData.push(await executeControlRuleOperation(this, 'deviceControl', 'rulesData', operation, i));
764
+ }
765
+ }
766
+ else if (resource === 'driveRules') {
767
+ if (operation === 'getRule') {
768
+ const ruleId = this.getNodeParameter('ruleId', i);
769
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/driveControl/rules/${ruleId}`);
770
+ returnData.push(extractResponseData(response));
771
+ }
772
+ else {
773
+ returnData.push(await executeControlRuleOperation(this, 'driveControl', 'rulesData', operation, i));
774
+ }
775
+ }
776
+ else if (resource === 'policy') {
777
+ if (operation === 'get') {
778
+ const policyId = this.getNodeParameter('policyId', i);
779
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/policy/${policyId}`);
780
+ returnData.push(extractResponseData(response));
781
+ }
782
+ else if (operation === 'create') {
783
+ const policyDataStr = this.getNodeParameter('policyData', i);
784
+ const policyData = (0, ValidationHelpers_1.parseJsonParameter)(policyDataStr, this.getNode(), i, 'policyData');
785
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', '/api/administration/policy', policyData);
786
+ returnData.push(extractResponseData(response));
787
+ }
788
+ else if (operation === 'update') {
789
+ const policyId = this.getNodeParameter('policyId', i);
790
+ const policyDataStr = this.getNodeParameter('policyData', i);
791
+ const policyData = (0, ValidationHelpers_1.parseJsonParameter)(policyDataStr, this.getNode(), i, 'policyData');
792
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'PATCH', `/api/administration/policy/${policyId}`, policyData);
793
+ returnData.push(extractResponseData(response));
794
+ }
795
+ else if (operation === 'delete') {
796
+ const policyId = this.getNodeParameter('policyId', i);
797
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'DELETE', `/api/administration/policy/${policyId}`);
798
+ returnData.push(extractResponseData(response));
799
+ }
800
+ else if (operation === 'getAssignments') {
801
+ const policyId = this.getNodeParameter('policyId', i);
802
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'GET', `/api/administration/policy/${policyId}/assignments`);
803
+ returnData.push(extractResponseData(response));
804
+ }
805
+ else if (operation === 'assignToGroups') {
806
+ const policyId = this.getNodeParameter('policyId', i);
807
+ const groupIdsStr = this.getNodeParameter('groupIds', i);
808
+ const groupIds = (0, ValidationHelpers_1.validateCommaSeparatedIds)(groupIdsStr, this.getNode(), i, 'groupIds');
809
+ const body = { policyId, groupIds };
810
+ const response = await GenericFunctions_1.driveLockApiRequest.call(this, 'POST', `/api/administration/policy/${policyId}/assign`, body);
811
+ returnData.push(extractResponseData(response));
276
812
  }
277
813
  }
278
814
  }
279
815
  catch (error) {
280
816
  if (this.continueOnFail()) {
281
- const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
282
- returnData.push(...executionErrorData);
817
+ returnData.push({ error: error.message });
283
818
  continue;
284
819
  }
285
820
  throw error;
286
821
  }
287
822
  }
288
- return [returnData];
823
+ return [this.helpers.returnJsonArray(returnData)];
289
824
  }
290
- ;
291
825
  }
292
826
  exports.Drivelock = Drivelock;
293
827
  //# sourceMappingURL=Drivelock.node.js.map