n8n-nodes-qlik-cloud 1.0.17 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/credentials/QlikCloudOAuth2Api.credentials.js +21 -21
- package/dist/nodes/QlikCloud/QlikCloud.node.js +405 -133
- package/dist/nodes/QlikCloud/resources/apps/index.d.ts +36 -0
- package/dist/nodes/QlikCloud/resources/apps/index.js +1115 -111
- package/dist/nodes/QlikCloud/resources/assistants/index.js +27 -7
- package/dist/nodes/QlikCloud/shared/transport.d.ts +2 -2
- package/dist/nodes/QlikCloud/shared/transport.js +16 -9
- package/package.json +2 -3
- package/src/credentials/QlikCloudOAuth2Api.credentials.ts +25 -28
- package/src/nodes/QlikCloud/QlikCloud.node.ts +530 -136
- package/src/nodes/QlikCloud/resources/apps/index.ts +1151 -110
- package/src/nodes/QlikCloud/resources/assistants/index.ts +27 -7
- package/src/nodes/QlikCloud/shared/transport.ts +21 -11
|
@@ -8,6 +8,10 @@ const index_2 = require("./resources/assistants/index");
|
|
|
8
8
|
const index_3 = require("./resources/audits/index");
|
|
9
9
|
const index_4 = require("./resources/items/index");
|
|
10
10
|
const DEFAULT_PAGE_SIZE = 100;
|
|
11
|
+
const BINARY_DOWNLOAD_OPTIONS = {
|
|
12
|
+
json: false,
|
|
13
|
+
encoding: 'arraybuffer',
|
|
14
|
+
};
|
|
11
15
|
function extractPageItems(response) {
|
|
12
16
|
const payload = response?.data ?? response;
|
|
13
17
|
if (Array.isArray(payload)) {
|
|
@@ -58,87 +62,339 @@ async function fetchPaginatedResults(context, endpoint, filters, limit, pageSize
|
|
|
58
62
|
} while (cursor && (limit === undefined || collected.length < limit));
|
|
59
63
|
return limit === undefined ? collected : collected.slice(0, limit);
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
65
|
+
function encodeMediaPath(path) {
|
|
66
|
+
return encodeURIComponent(path).replace(/%2F/g, '/');
|
|
67
|
+
}
|
|
68
|
+
async function handleAppsResource(operation, context, itemIndex) {
|
|
69
|
+
switch (operation) {
|
|
70
|
+
case 'getAll': {
|
|
71
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
72
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
73
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
74
|
+
const qs = {};
|
|
75
|
+
if (options.name) {
|
|
76
|
+
qs.name = options.name;
|
|
77
|
+
}
|
|
78
|
+
if (options.spaceId) {
|
|
79
|
+
qs.spaceId = options.spaceId;
|
|
80
|
+
}
|
|
81
|
+
return await fetchPaginatedResults(context, '/api/v1/apps', qs, limit);
|
|
82
|
+
}
|
|
83
|
+
case 'get': {
|
|
84
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
85
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}`);
|
|
86
|
+
}
|
|
87
|
+
case 'create': {
|
|
88
|
+
const name = context.getNodeParameter('name', itemIndex);
|
|
89
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
90
|
+
const body = { attributes: { name } };
|
|
91
|
+
if (options.description) {
|
|
92
|
+
body.attributes.description = options.description;
|
|
93
|
+
}
|
|
94
|
+
if (options.locale) {
|
|
95
|
+
body.attributes.locale = options.locale;
|
|
96
|
+
}
|
|
97
|
+
if (options.spaceId) {
|
|
98
|
+
body.attributes.spaceId = options.spaceId;
|
|
99
|
+
}
|
|
100
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', '/api/v1/apps', body);
|
|
101
|
+
}
|
|
102
|
+
case 'update': {
|
|
103
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
104
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
105
|
+
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}`, body);
|
|
106
|
+
}
|
|
107
|
+
case 'delete': {
|
|
108
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
109
|
+
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}`);
|
|
110
|
+
return { success: true };
|
|
111
|
+
}
|
|
112
|
+
case 'copy': {
|
|
113
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
114
|
+
const name = context.getNodeParameter('name', itemIndex);
|
|
115
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
116
|
+
const body = { attributes: { name } };
|
|
117
|
+
if (options.description) {
|
|
118
|
+
body.attributes.description = options.description;
|
|
119
|
+
}
|
|
120
|
+
if (options.spaceId) {
|
|
121
|
+
body.attributes.spaceId = options.spaceId;
|
|
122
|
+
}
|
|
123
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/copy`, body);
|
|
124
|
+
}
|
|
125
|
+
case 'export': {
|
|
126
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
127
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/export`, {});
|
|
128
|
+
}
|
|
129
|
+
case 'publish': {
|
|
130
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
131
|
+
const options = context.getNodeParameter('publishOptions', itemIndex);
|
|
132
|
+
const body = {};
|
|
133
|
+
if (options.spaceId) {
|
|
134
|
+
body.spaceId = options.spaceId;
|
|
135
|
+
}
|
|
136
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/publish`, body);
|
|
137
|
+
}
|
|
138
|
+
case 'republish': {
|
|
139
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
140
|
+
const options = context.getNodeParameter('publishOptions', itemIndex);
|
|
141
|
+
const body = {};
|
|
142
|
+
if (options.spaceId) {
|
|
143
|
+
body.spaceId = options.spaceId;
|
|
144
|
+
}
|
|
145
|
+
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}/publish`, body);
|
|
146
|
+
}
|
|
147
|
+
case 'dataLineage': {
|
|
148
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
149
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/data/lineage`);
|
|
150
|
+
}
|
|
151
|
+
case 'dataMetadata': {
|
|
152
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
153
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/data/metadata`);
|
|
154
|
+
}
|
|
155
|
+
case 'listInsights': {
|
|
156
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
157
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/insight-analyses`);
|
|
158
|
+
}
|
|
159
|
+
case 'recommendInsights': {
|
|
160
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
161
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
162
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
163
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/insight-analyses/actions/recommend`, payload);
|
|
164
|
+
}
|
|
165
|
+
case 'getInsightModel': {
|
|
166
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
167
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/insight-analyses/model`);
|
|
168
|
+
}
|
|
169
|
+
case 'mediaGetFile': {
|
|
170
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
171
|
+
const path = context.getNodeParameter('path', itemIndex);
|
|
172
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
173
|
+
const response = await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/media/files/${encodeMediaPath(path)}`, undefined, undefined, true, BINARY_DOWNLOAD_OPTIONS);
|
|
174
|
+
const data = response.body ?? response;
|
|
175
|
+
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
176
|
+
const binary = await context.helpers.prepareBinaryData(buffer, path);
|
|
177
|
+
return { json: {}, binary: { [binaryProperty]: binary } };
|
|
178
|
+
}
|
|
179
|
+
case 'mediaUploadFile': {
|
|
180
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
181
|
+
const path = context.getNodeParameter('path', itemIndex);
|
|
182
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
183
|
+
const contentType = context.getNodeParameter('contentType', itemIndex);
|
|
184
|
+
const buffer = await context.helpers.getBinaryDataBuffer(itemIndex, binaryProperty);
|
|
185
|
+
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}/media/files/${encodeMediaPath(path)}`, buffer, undefined, false, {
|
|
186
|
+
json: false,
|
|
187
|
+
headers: { 'Content-Type': contentType },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
case 'mediaDeleteFile': {
|
|
191
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
192
|
+
const path = context.getNodeParameter('path', itemIndex);
|
|
193
|
+
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}/media/files/${encodeMediaPath(path)}`);
|
|
194
|
+
return { success: true };
|
|
195
|
+
}
|
|
196
|
+
case 'mediaList': {
|
|
197
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
198
|
+
const path = context.getNodeParameter('path', itemIndex);
|
|
199
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/media/list/${encodeMediaPath(path)}`);
|
|
200
|
+
}
|
|
201
|
+
case 'mediaThumbnail': {
|
|
202
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
203
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
204
|
+
const response = await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/media/thumbnail`, undefined, undefined, true, BINARY_DOWNLOAD_OPTIONS);
|
|
205
|
+
const data = response.body ?? response;
|
|
206
|
+
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
207
|
+
const binary = await context.helpers.prepareBinaryData(buffer, 'thumbnail.png');
|
|
208
|
+
return { json: {}, binary: { [binaryProperty]: binary } };
|
|
209
|
+
}
|
|
210
|
+
case 'changeObjectOwner': {
|
|
211
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
212
|
+
const objectId = context.getNodeParameter('objectId', itemIndex);
|
|
213
|
+
const ownerId = context.getNodeParameter('ownerId', itemIndex);
|
|
214
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/objects/${objectId}/actions/change-owner`, { ownerId });
|
|
215
|
+
}
|
|
216
|
+
case 'updateOwner': {
|
|
217
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
218
|
+
const ownerId = context.getNodeParameter('ownerId', itemIndex);
|
|
219
|
+
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}/owner`, { ownerId });
|
|
220
|
+
}
|
|
221
|
+
case 'reloadLogs': {
|
|
222
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
223
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
224
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
225
|
+
return await fetchPaginatedResults(context, `/api/v1/apps/${appId}/reloads/logs`, {}, limit);
|
|
226
|
+
}
|
|
227
|
+
case 'reloadLog': {
|
|
228
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
229
|
+
const reloadId = context.getNodeParameter('reloadId', itemIndex);
|
|
230
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/reloads/logs/${reloadId}`);
|
|
231
|
+
}
|
|
232
|
+
case 'reloadMetadata': {
|
|
233
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
234
|
+
const reloadId = context.getNodeParameter('reloadId', itemIndex);
|
|
235
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/reloads/metadata/${reloadId}`);
|
|
236
|
+
}
|
|
237
|
+
case 'reportFiltersGetAll': {
|
|
238
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
239
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
240
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
241
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
242
|
+
const qs = {};
|
|
243
|
+
if (options.filter)
|
|
244
|
+
qs.filter = options.filter;
|
|
245
|
+
if (options.filterTypes)
|
|
246
|
+
qs.filterTypes = options.filterTypes;
|
|
247
|
+
if (options.page !== undefined)
|
|
248
|
+
qs.page = options.page;
|
|
249
|
+
if (options.sort)
|
|
250
|
+
qs.sort = options.sort;
|
|
251
|
+
if (!returnAll && limit !== undefined)
|
|
252
|
+
qs.limit = limit;
|
|
253
|
+
return await fetchPaginatedResults(context, `/api/v1/apps/${appId}/report-filters`, qs, limit);
|
|
254
|
+
}
|
|
255
|
+
case 'reportFiltersCreate': {
|
|
256
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
257
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
258
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
259
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/report-filters`, payload);
|
|
260
|
+
}
|
|
261
|
+
case 'reportFiltersGet': {
|
|
262
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
263
|
+
const filterId = context.getNodeParameter('filterId', itemIndex);
|
|
264
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/report-filters/${filterId}`);
|
|
265
|
+
}
|
|
266
|
+
case 'reportFiltersUpdate': {
|
|
267
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
268
|
+
const filterId = context.getNodeParameter('filterId', itemIndex);
|
|
269
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
270
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
271
|
+
return await transport_1.qlikApiRequest.call(context, 'PATCH', `/api/v1/apps/${appId}/report-filters/${filterId}`, payload);
|
|
272
|
+
}
|
|
273
|
+
case 'reportFiltersDelete': {
|
|
274
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
275
|
+
const filterId = context.getNodeParameter('filterId', itemIndex);
|
|
276
|
+
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}/report-filters/${filterId}`);
|
|
277
|
+
return { success: true };
|
|
278
|
+
}
|
|
279
|
+
case 'reportFiltersCount': {
|
|
280
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
281
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
282
|
+
const qs = {};
|
|
283
|
+
if (options.filter)
|
|
284
|
+
qs.filter = options.filter;
|
|
285
|
+
if (options.filterTypes)
|
|
286
|
+
qs.filterTypes = options.filterTypes;
|
|
287
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/report-filters/actions/count`, undefined, qs);
|
|
288
|
+
}
|
|
289
|
+
case 'scriptsGetAll': {
|
|
290
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
291
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/scripts`);
|
|
292
|
+
}
|
|
293
|
+
case 'scriptsCreate': {
|
|
294
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
295
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
296
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
297
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/scripts`, payload);
|
|
298
|
+
}
|
|
299
|
+
case 'scriptsGet': {
|
|
300
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
301
|
+
const scriptId = context.getNodeParameter('scriptId', itemIndex);
|
|
302
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/scripts/${scriptId}`);
|
|
303
|
+
}
|
|
304
|
+
case 'scriptsUpdate': {
|
|
305
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
306
|
+
const scriptId = context.getNodeParameter('scriptId', itemIndex);
|
|
307
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
308
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
309
|
+
return await transport_1.qlikApiRequest.call(context, 'PATCH', `/api/v1/apps/${appId}/scripts/${scriptId}`, payload);
|
|
310
|
+
}
|
|
311
|
+
case 'scriptsDelete': {
|
|
312
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
313
|
+
const scriptId = context.getNodeParameter('scriptId', itemIndex);
|
|
314
|
+
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}/scripts/${scriptId}`);
|
|
315
|
+
return { success: true };
|
|
316
|
+
}
|
|
317
|
+
case 'moveToSpace': {
|
|
318
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
319
|
+
const spaceId = context.getNodeParameter('spaceId', itemIndex);
|
|
320
|
+
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}/space`, { spaceId });
|
|
321
|
+
}
|
|
322
|
+
case 'removeFromSpace': {
|
|
323
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
324
|
+
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}/space`);
|
|
325
|
+
return { success: true };
|
|
326
|
+
}
|
|
327
|
+
case 'evaluationsGetAll': {
|
|
328
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
329
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}/evaluations`);
|
|
330
|
+
}
|
|
331
|
+
case 'evaluationsCreate': {
|
|
332
|
+
const appId = context.getNodeParameter('appId', itemIndex);
|
|
333
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
334
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
335
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/evaluations`, payload);
|
|
336
|
+
}
|
|
337
|
+
case 'evaluationsCompare': {
|
|
338
|
+
const baseEvaluationId = context.getNodeParameter('baseEvaluationId', itemIndex);
|
|
339
|
+
const comparisonEvaluationId = context.getNodeParameter('comparisonEvaluationId', itemIndex);
|
|
340
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/evaluations/${baseEvaluationId}/actions/compare/${comparisonEvaluationId}`);
|
|
341
|
+
}
|
|
342
|
+
case 'evaluationsDownloadCompare': {
|
|
343
|
+
const baseEvaluationId = context.getNodeParameter('baseEvaluationId', itemIndex);
|
|
344
|
+
const comparisonEvaluationId = context.getNodeParameter('comparisonEvaluationId', itemIndex);
|
|
345
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
346
|
+
const response = await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/evaluations/${baseEvaluationId}/actions/compare/${comparisonEvaluationId}/actions/download`, undefined, undefined, true, BINARY_DOWNLOAD_OPTIONS);
|
|
347
|
+
const data = response.body ?? response;
|
|
348
|
+
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
349
|
+
const binary = await context.helpers.prepareBinaryData(buffer, 'comparison');
|
|
350
|
+
return { json: {}, binary: { [binaryProperty]: binary } };
|
|
351
|
+
}
|
|
352
|
+
case 'evaluationGet': {
|
|
353
|
+
const evaluationId = context.getNodeParameter('evaluationId', itemIndex);
|
|
354
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/evaluations/${evaluationId}`);
|
|
355
|
+
}
|
|
356
|
+
case 'evaluationDownload': {
|
|
357
|
+
const evaluationId = context.getNodeParameter('evaluationId', itemIndex);
|
|
358
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
359
|
+
const response = await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/apps/evaluations/${evaluationId}/actions/download`, undefined, undefined, true, BINARY_DOWNLOAD_OPTIONS);
|
|
360
|
+
const data = response.body ?? response;
|
|
361
|
+
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
362
|
+
const binary = await context.helpers.prepareBinaryData(buffer, 'evaluation');
|
|
363
|
+
return { json: {}, binary: { [binaryProperty]: binary } };
|
|
364
|
+
}
|
|
365
|
+
case 'importApp': {
|
|
366
|
+
const binaryProperty = context.getNodeParameter('binaryProperty', itemIndex);
|
|
367
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
368
|
+
const qs = {};
|
|
369
|
+
if (options.name)
|
|
370
|
+
qs.name = options.name;
|
|
371
|
+
if (options.spaceId)
|
|
372
|
+
qs.spaceId = options.spaceId;
|
|
373
|
+
const buffer = await context.helpers.getBinaryDataBuffer(itemIndex, binaryProperty);
|
|
374
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', '/api/v1/apps/import', buffer, qs, false, { json: false, headers: { 'Content-Type': 'application/octet-stream' } });
|
|
375
|
+
}
|
|
376
|
+
case 'validateScript': {
|
|
377
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
378
|
+
const payload = typeof body === 'string' ? JSON.parse(body) : body;
|
|
379
|
+
return await transport_1.qlikApiRequest.call(context, 'POST', '/api/v1/apps/validatescript', payload);
|
|
380
|
+
}
|
|
381
|
+
case 'privileges': {
|
|
382
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
383
|
+
const qs = {};
|
|
384
|
+
if (options.role)
|
|
385
|
+
qs.role = options.role;
|
|
386
|
+
return await transport_1.qlikApiRequest.call(context, 'GET', '/api/v1/apps/privileges', undefined, qs);
|
|
387
|
+
}
|
|
388
|
+
default:
|
|
389
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
132
390
|
}
|
|
133
|
-
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
134
391
|
}
|
|
135
|
-
async function handleAssistantsResource(operation, context) {
|
|
392
|
+
async function handleAssistantsResource(operation, context, itemIndex) {
|
|
136
393
|
if (operation === 'getAll') {
|
|
137
|
-
const
|
|
394
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
395
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
396
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
138
397
|
const qs = {};
|
|
139
|
-
if (options.limit) {
|
|
140
|
-
qs.limit = options.limit;
|
|
141
|
-
}
|
|
142
398
|
if (options.next) {
|
|
143
399
|
qs.next = options.next;
|
|
144
400
|
}
|
|
@@ -148,18 +404,21 @@ async function handleAssistantsResource(operation, context) {
|
|
|
148
404
|
if (options.sort) {
|
|
149
405
|
qs.sort = options.sort;
|
|
150
406
|
}
|
|
151
|
-
|
|
407
|
+
if (!returnAll && options.limit) {
|
|
408
|
+
qs.limit = options.limit;
|
|
409
|
+
}
|
|
410
|
+
return await fetchPaginatedResults(context, '/api/v1/assistants', qs, limit);
|
|
152
411
|
}
|
|
153
412
|
if (operation === 'get') {
|
|
154
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
413
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
155
414
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/assistants/${assistantId}`);
|
|
156
415
|
}
|
|
157
416
|
if (operation === 'create') {
|
|
158
|
-
const name = context.getNodeParameter('name',
|
|
159
|
-
const title = context.getNodeParameter('title',
|
|
160
|
-
const description = context.getNodeParameter('description',
|
|
161
|
-
const spaceId = context.getNodeParameter('spaceId',
|
|
162
|
-
const options = context.getNodeParameter('options',
|
|
417
|
+
const name = context.getNodeParameter('name', itemIndex);
|
|
418
|
+
const title = context.getNodeParameter('title', itemIndex);
|
|
419
|
+
const description = context.getNodeParameter('description', itemIndex);
|
|
420
|
+
const spaceId = context.getNodeParameter('spaceId', itemIndex);
|
|
421
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
163
422
|
const body = { name, title, description, spaceId };
|
|
164
423
|
if (options.tags) {
|
|
165
424
|
body.tags = options.tags.split(',').map((tag) => tag.trim());
|
|
@@ -178,15 +437,15 @@ async function handleAssistantsResource(operation, context) {
|
|
|
178
437
|
return await transport_1.qlikApiRequest.call(context, 'POST', '/api/v1/assistants', body);
|
|
179
438
|
}
|
|
180
439
|
if (operation === 'update') {
|
|
181
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
182
|
-
const body = context.getNodeParameter('body',
|
|
440
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
441
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
183
442
|
const patchOps = typeof body === 'string' ? JSON.parse(body) : body;
|
|
184
443
|
return await transport_1.qlikApiRequest.call(context, 'PATCH', `/api/v1/assistants/${assistantId}`, patchOps);
|
|
185
444
|
}
|
|
186
445
|
if (operation === 'search') {
|
|
187
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
188
|
-
const query = context.getNodeParameter('query',
|
|
189
|
-
const options = context.getNodeParameter('options',
|
|
446
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
447
|
+
const query = context.getNodeParameter('query', itemIndex);
|
|
448
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
190
449
|
const body = { text: query };
|
|
191
450
|
if (options.topN) {
|
|
192
451
|
body.topN = options.topN;
|
|
@@ -197,18 +456,18 @@ async function handleAssistantsResource(operation, context) {
|
|
|
197
456
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/actions/search`, body);
|
|
198
457
|
}
|
|
199
458
|
if (operation === 'getFeedback') {
|
|
200
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
459
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
201
460
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/assistants/${assistantId}/feedback`);
|
|
202
461
|
}
|
|
203
462
|
if (operation === 'bulkSearchSources') {
|
|
204
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
205
|
-
const chunkIds = context.getNodeParameter('chunkIds',
|
|
463
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
464
|
+
const chunkIds = context.getNodeParameter('chunkIds', itemIndex);
|
|
206
465
|
const body = typeof chunkIds === 'string' ? JSON.parse(chunkIds) : chunkIds;
|
|
207
466
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/sources/plaintexts`, { chunkIds: body });
|
|
208
467
|
}
|
|
209
468
|
if (operation === 'listStarters') {
|
|
210
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
211
|
-
const options = context.getNodeParameter('options',
|
|
469
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
470
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
212
471
|
const qs = {};
|
|
213
472
|
if (options.limit) {
|
|
214
473
|
qs.limit = options.limit;
|
|
@@ -216,9 +475,9 @@ async function handleAssistantsResource(operation, context) {
|
|
|
216
475
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/assistants/${assistantId}/starters`, undefined, qs);
|
|
217
476
|
}
|
|
218
477
|
if (operation === 'createStarter') {
|
|
219
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
220
|
-
const question = context.getNodeParameter('question',
|
|
221
|
-
const options = context.getNodeParameter('options',
|
|
478
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
479
|
+
const question = context.getNodeParameter('question', itemIndex);
|
|
480
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
222
481
|
const body = { question };
|
|
223
482
|
if (options.followups) {
|
|
224
483
|
body.followups = typeof options.followups === 'string'
|
|
@@ -231,8 +490,8 @@ async function handleAssistantsResource(operation, context) {
|
|
|
231
490
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/starters`, body);
|
|
232
491
|
}
|
|
233
492
|
if (operation === 'listThreads') {
|
|
234
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
235
|
-
const options = context.getNodeParameter('options',
|
|
493
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
494
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
236
495
|
const qs = {};
|
|
237
496
|
if (options.limit) {
|
|
238
497
|
qs.limit = options.limit;
|
|
@@ -243,16 +502,16 @@ async function handleAssistantsResource(operation, context) {
|
|
|
243
502
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/assistants/${assistantId}/threads`, undefined, qs);
|
|
244
503
|
}
|
|
245
504
|
if (operation === 'createThread') {
|
|
246
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
247
|
-
const name = context.getNodeParameter('name',
|
|
505
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
506
|
+
const name = context.getNodeParameter('name', itemIndex);
|
|
248
507
|
const body = { name };
|
|
249
508
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/threads`, body);
|
|
250
509
|
}
|
|
251
510
|
if (operation === 'streamThread') {
|
|
252
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
253
|
-
const threadId = context.getNodeParameter('threadId',
|
|
254
|
-
const messages = context.getNodeParameter('messages',
|
|
255
|
-
const options = context.getNodeParameter('options',
|
|
511
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
512
|
+
const threadId = context.getNodeParameter('threadId', itemIndex);
|
|
513
|
+
const messages = context.getNodeParameter('messages', itemIndex);
|
|
514
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
256
515
|
const body = {
|
|
257
516
|
messages: typeof messages === 'string' ? JSON.parse(messages) : messages,
|
|
258
517
|
};
|
|
@@ -264,24 +523,24 @@ async function handleAssistantsResource(operation, context) {
|
|
|
264
523
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/threads/${threadId}/actions/stream`, body);
|
|
265
524
|
}
|
|
266
525
|
if (operation === 'invokeThread') {
|
|
267
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
268
|
-
const threadId = context.getNodeParameter('threadId',
|
|
269
|
-
const message = context.getNodeParameter('message',
|
|
526
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
527
|
+
const threadId = context.getNodeParameter('threadId', itemIndex);
|
|
528
|
+
const message = context.getNodeParameter('message', itemIndex);
|
|
270
529
|
const body = { message };
|
|
271
530
|
return await transport_1.qlikApiRequest.call(context, 'POST', `/api/v1/assistants/${assistantId}/threads/${threadId}/actions/invoke`, body);
|
|
272
531
|
}
|
|
273
532
|
if (operation === 'delete') {
|
|
274
|
-
const assistantId = context.getNodeParameter('assistantId',
|
|
533
|
+
const assistantId = context.getNodeParameter('assistantId', itemIndex);
|
|
275
534
|
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/assistants/${assistantId}`);
|
|
276
535
|
return { success: true };
|
|
277
536
|
}
|
|
278
537
|
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
279
538
|
}
|
|
280
|
-
async function handleAuditsResource(operation, context) {
|
|
539
|
+
async function handleAuditsResource(operation, context, itemIndex) {
|
|
281
540
|
if (operation === 'getAll') {
|
|
282
|
-
const returnAll = context.getNodeParameter('returnAll',
|
|
283
|
-
const limit = returnAll ? undefined : context.getNodeParameter('limit',
|
|
284
|
-
const options = context.getNodeParameter('options',
|
|
541
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
542
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
543
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
285
544
|
const qs = {};
|
|
286
545
|
if (options.eventType) {
|
|
287
546
|
qs.eventType = options.eventType;
|
|
@@ -301,7 +560,7 @@ async function handleAuditsResource(operation, context) {
|
|
|
301
560
|
return await fetchPaginatedResults(context, '/api/v1/audits', qs, limit);
|
|
302
561
|
}
|
|
303
562
|
if (operation === 'get') {
|
|
304
|
-
const auditId = context.getNodeParameter('auditId',
|
|
563
|
+
const auditId = context.getNodeParameter('auditId', itemIndex);
|
|
305
564
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/audits/${auditId}`);
|
|
306
565
|
}
|
|
307
566
|
if (operation === 'getSources') {
|
|
@@ -318,11 +577,11 @@ async function handleAuditsResource(operation, context) {
|
|
|
318
577
|
}
|
|
319
578
|
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
320
579
|
}
|
|
321
|
-
async function handleItemsResource(operation, context) {
|
|
580
|
+
async function handleItemsResource(operation, context, itemIndex) {
|
|
322
581
|
if (operation === 'getAll') {
|
|
323
|
-
const returnAll = context.getNodeParameter('returnAll',
|
|
324
|
-
const limit = returnAll ? undefined : context.getNodeParameter('limit',
|
|
325
|
-
const options = context.getNodeParameter('options',
|
|
582
|
+
const returnAll = context.getNodeParameter('returnAll', itemIndex);
|
|
583
|
+
const limit = returnAll ? undefined : context.getNodeParameter('limit', itemIndex);
|
|
584
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
326
585
|
const qs = {};
|
|
327
586
|
if (options.name) {
|
|
328
587
|
qs.name = options.name;
|
|
@@ -342,22 +601,22 @@ async function handleItemsResource(operation, context) {
|
|
|
342
601
|
return await fetchPaginatedResults(context, '/api/v1/items', qs, limit);
|
|
343
602
|
}
|
|
344
603
|
if (operation === 'get') {
|
|
345
|
-
const itemId = context.getNodeParameter('itemId',
|
|
604
|
+
const itemId = context.getNodeParameter('itemId', itemIndex);
|
|
346
605
|
return await transport_1.qlikApiRequest.call(context, 'GET', `/api/v1/items/${itemId}`);
|
|
347
606
|
}
|
|
348
607
|
if (operation === 'update') {
|
|
349
|
-
const itemId = context.getNodeParameter('itemId',
|
|
350
|
-
const body = context.getNodeParameter('body',
|
|
608
|
+
const itemId = context.getNodeParameter('itemId', itemIndex);
|
|
609
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
351
610
|
return await transport_1.qlikApiRequest.call(context, 'PUT', `/api/v1/items/${itemId}`, body);
|
|
352
611
|
}
|
|
353
612
|
if (operation === 'delete') {
|
|
354
|
-
const itemId = context.getNodeParameter('itemId',
|
|
613
|
+
const itemId = context.getNodeParameter('itemId', itemIndex);
|
|
355
614
|
await transport_1.qlikApiRequest.call(context, 'DELETE', `/api/v1/items/${itemId}`);
|
|
356
615
|
return { success: true };
|
|
357
616
|
}
|
|
358
617
|
if (operation === 'collections') {
|
|
359
|
-
const itemId = context.getNodeParameter('itemId',
|
|
360
|
-
const options = context.getNodeParameter('options',
|
|
618
|
+
const itemId = context.getNodeParameter('itemId', itemIndex);
|
|
619
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
361
620
|
const qs = {};
|
|
362
621
|
if (options.limit) {
|
|
363
622
|
qs.limit = options.limit;
|
|
@@ -366,8 +625,8 @@ async function handleItemsResource(operation, context) {
|
|
|
366
625
|
return response.data || response;
|
|
367
626
|
}
|
|
368
627
|
if (operation === 'publishedItems') {
|
|
369
|
-
const itemId = context.getNodeParameter('itemId',
|
|
370
|
-
const options = context.getNodeParameter('options',
|
|
628
|
+
const itemId = context.getNodeParameter('itemId', itemIndex);
|
|
629
|
+
const options = context.getNodeParameter('options', itemIndex);
|
|
371
630
|
const qs = {};
|
|
372
631
|
if (options.limit) {
|
|
373
632
|
qs.limit = options.limit;
|
|
@@ -376,13 +635,13 @@ async function handleItemsResource(operation, context) {
|
|
|
376
635
|
return response.data || response;
|
|
377
636
|
}
|
|
378
637
|
if (operation === 'settings') {
|
|
379
|
-
const settingsOperation = context.getNodeParameter('settingsOperation',
|
|
638
|
+
const settingsOperation = context.getNodeParameter('settingsOperation', itemIndex);
|
|
380
639
|
if (settingsOperation === 'get') {
|
|
381
640
|
const response = await transport_1.qlikApiRequest.call(context, 'GET', '/api/v1/items/settings');
|
|
382
641
|
return response.data || response;
|
|
383
642
|
}
|
|
384
643
|
if (settingsOperation === 'patch') {
|
|
385
|
-
const body = context.getNodeParameter('body',
|
|
644
|
+
const body = context.getNodeParameter('body', itemIndex);
|
|
386
645
|
const response = await transport_1.qlikApiRequest.call(context, 'PATCH', '/api/v1/items/settings', body);
|
|
387
646
|
return response.data || response;
|
|
388
647
|
}
|
|
@@ -456,18 +715,31 @@ class QlikCloud {
|
|
|
456
715
|
for (let i = 0; i < items.length; i++) {
|
|
457
716
|
try {
|
|
458
717
|
if (resource === 'apps') {
|
|
459
|
-
responseData = await handleAppsResource(operation, this);
|
|
718
|
+
responseData = await handleAppsResource(operation, this, i);
|
|
460
719
|
}
|
|
461
720
|
else if (resource === 'assistants') {
|
|
462
|
-
responseData = await handleAssistantsResource(operation, this);
|
|
721
|
+
responseData = await handleAssistantsResource(operation, this, i);
|
|
463
722
|
}
|
|
464
723
|
else if (resource === 'audits') {
|
|
465
|
-
responseData = await handleAuditsResource(operation, this);
|
|
724
|
+
responseData = await handleAuditsResource(operation, this, i);
|
|
466
725
|
}
|
|
467
726
|
else if (resource === 'items') {
|
|
468
|
-
responseData = await handleItemsResource(operation, this);
|
|
727
|
+
responseData = await handleItemsResource(operation, this, i);
|
|
469
728
|
}
|
|
470
|
-
const
|
|
729
|
+
const responses = Array.isArray(responseData) ? responseData : [responseData];
|
|
730
|
+
const executionItems = responses.map((data) => {
|
|
731
|
+
if (data.binary !== undefined || data.json !== undefined) {
|
|
732
|
+
const asItem = data;
|
|
733
|
+
if (asItem.json === undefined) {
|
|
734
|
+
asItem.json = {};
|
|
735
|
+
}
|
|
736
|
+
return asItem;
|
|
737
|
+
}
|
|
738
|
+
return { json: data };
|
|
739
|
+
});
|
|
740
|
+
const executionData = this.helpers.constructExecutionMetaData(executionItems, {
|
|
741
|
+
itemData: { item: i },
|
|
742
|
+
});
|
|
471
743
|
returnData.push(...executionData);
|
|
472
744
|
}
|
|
473
745
|
catch (error) {
|