n8n-nodes-qlik-cloud 1.0.0 → 1.0.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.
- package/dist/credentials/QlikCloudApi.credentials.d.ts +7 -0
- package/dist/credentials/QlikCloudApi.credentials.js +33 -0
- package/dist/credentials/QlikCloudOAuth2Api.credentials.d.ts +9 -0
- package/dist/credentials/QlikCloudOAuth2Api.credentials.js +72 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/nodes/QlikCloud/QlikCloud.node.d.ts +5 -0
- package/dist/nodes/QlikCloud/QlikCloud.node.js +346 -0
- package/dist/nodes/QlikCloud/resources/apps/index.d.ts +11 -0
- package/dist/nodes/QlikCloud/resources/apps/index.js +391 -0
- package/dist/nodes/QlikCloud/resources/assistants/index.d.ts +7 -0
- package/dist/nodes/QlikCloud/resources/assistants/index.js +219 -0
- package/dist/nodes/QlikCloud/resources/audits/index.d.ts +7 -0
- package/dist/nodes/QlikCloud/resources/audits/index.js +213 -0
- package/dist/nodes/QlikCloud/resources/items/index.d.ts +9 -0
- package/dist/nodes/QlikCloud/resources/items/index.js +352 -0
- package/dist/nodes/QlikCloud/shared/transport.d.ts +2 -0
- package/dist/nodes/QlikCloud/shared/transport.js +34 -0
- package/dist/shared/transport.d.ts +2 -0
- package/dist/shared/transport.js +32 -0
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/nodes/QlikCloud/QlikCloud.node.ts +318 -320
- package/src/{shared → nodes/QlikCloud/shared}/transport.ts +9 -7
|
@@ -3,17 +3,326 @@ import type {
|
|
|
3
3
|
INodeExecutionData,
|
|
4
4
|
INodeType,
|
|
5
5
|
INodeTypeDescription,
|
|
6
|
-
GenericValue,
|
|
7
|
-
IGetNodeParameterOptions,
|
|
8
6
|
} from 'n8n-workflow';
|
|
9
7
|
import { NodeOperationError } from 'n8n-workflow';
|
|
10
8
|
|
|
11
|
-
import { qlikApiRequest } from '
|
|
9
|
+
import { qlikApiRequest } from './shared/transport';
|
|
12
10
|
import { appDescription } from './resources/apps/index';
|
|
13
11
|
import { assistantDescription } from './resources/assistants/index';
|
|
14
12
|
import { auditDescription } from './resources/audits/index';
|
|
15
13
|
import { itemDescription } from './resources/items/index';
|
|
16
14
|
|
|
15
|
+
async function handleAppsResource(operation: string, context: IExecuteFunctions): Promise<any> {
|
|
16
|
+
if (operation === 'getAll') {
|
|
17
|
+
const returnAll = context.getNodeParameter('returnAll', 0) as boolean;
|
|
18
|
+
const limit = returnAll ? undefined : (context.getNodeParameter('limit', 0) as number);
|
|
19
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
20
|
+
|
|
21
|
+
const qs: any = {};
|
|
22
|
+
if (limit) {
|
|
23
|
+
qs.limit = limit;
|
|
24
|
+
}
|
|
25
|
+
if (options.name) {
|
|
26
|
+
qs.name = options.name;
|
|
27
|
+
}
|
|
28
|
+
if (options.spaceId) {
|
|
29
|
+
qs.spaceId = options.spaceId;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/apps', undefined, qs);
|
|
33
|
+
return response.data || response;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (operation === 'get') {
|
|
37
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
38
|
+
return await qlikApiRequest.call(context, 'GET', `/api/v1/apps/${appId}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (operation === 'create') {
|
|
42
|
+
const name = context.getNodeParameter('name', 0) as string;
|
|
43
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
44
|
+
|
|
45
|
+
const body = { attributes: { name } };
|
|
46
|
+
if (options.description) {
|
|
47
|
+
(body.attributes as any).description = options.description;
|
|
48
|
+
}
|
|
49
|
+
if (options.locale) {
|
|
50
|
+
(body.attributes as any).locale = options.locale;
|
|
51
|
+
}
|
|
52
|
+
if (options.spaceId) {
|
|
53
|
+
(body.attributes as any).spaceId = options.spaceId;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return await qlikApiRequest.call(context, 'POST', '/api/v1/apps', body);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (operation === 'update') {
|
|
60
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
61
|
+
const body = context.getNodeParameter('body', 0) as any;
|
|
62
|
+
return await qlikApiRequest.call(context, 'PUT', `/api/v1/apps/${appId}`, body);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (operation === 'delete') {
|
|
66
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
67
|
+
await qlikApiRequest.call(context, 'DELETE', `/api/v1/apps/${appId}`);
|
|
68
|
+
return { success: true };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (operation === 'copy') {
|
|
72
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
73
|
+
const name = context.getNodeParameter('name', 0) as string;
|
|
74
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
75
|
+
|
|
76
|
+
const body = { attributes: { name } };
|
|
77
|
+
if (options.description) {
|
|
78
|
+
(body.attributes as any).description = options.description;
|
|
79
|
+
}
|
|
80
|
+
if (options.spaceId) {
|
|
81
|
+
(body.attributes as any).spaceId = options.spaceId;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return await qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/copy`, body);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (operation === 'export') {
|
|
88
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
89
|
+
return await qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/export`, {});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (operation === 'publish') {
|
|
93
|
+
const appId = context.getNodeParameter('appId', 0) as string;
|
|
94
|
+
const options = context.getNodeParameter('publishOptions', 0) as any;
|
|
95
|
+
|
|
96
|
+
const body: any = {};
|
|
97
|
+
if (options.spaceId) {
|
|
98
|
+
body.spaceId = options.spaceId;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return await qlikApiRequest.call(context, 'POST', `/api/v1/apps/${appId}/publish`, body);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (operation === 'privileges') {
|
|
105
|
+
return await qlikApiRequest.call(context, 'GET', '/api/v1/apps/privileges');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
throw new NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function handleAssistantsResource(operation: string, context: IExecuteFunctions): Promise<any> {
|
|
112
|
+
if (operation === 'getAll') {
|
|
113
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
114
|
+
|
|
115
|
+
const qs: any = {};
|
|
116
|
+
if (options.limit) {
|
|
117
|
+
qs.limit = options.limit;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return await qlikApiRequest.call(context, 'GET', '/api/v1/assistants', undefined, qs);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (operation === 'get') {
|
|
124
|
+
const assistantId = context.getNodeParameter('assistantId', 0) as string;
|
|
125
|
+
return await qlikApiRequest.call(context, 'GET', `/api/v1/assistants/${assistantId}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (operation === 'create') {
|
|
129
|
+
const name = context.getNodeParameter('name', 0) as string;
|
|
130
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
131
|
+
|
|
132
|
+
const body: any = { name };
|
|
133
|
+
if (options.description) {
|
|
134
|
+
body.description = options.description;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return await qlikApiRequest.call(context, 'POST', '/api/v1/assistants', body);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (operation === 'search') {
|
|
141
|
+
const assistantId = context.getNodeParameter('assistantId', 0) as string;
|
|
142
|
+
const query = context.getNodeParameter('query', 0) as string;
|
|
143
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
144
|
+
|
|
145
|
+
const body: any = { text: query };
|
|
146
|
+
if (options.topN) {
|
|
147
|
+
body.topN = options.topN;
|
|
148
|
+
}
|
|
149
|
+
if (options.mode) {
|
|
150
|
+
body.mode = options.mode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return await qlikApiRequest.call(
|
|
154
|
+
context,
|
|
155
|
+
'POST',
|
|
156
|
+
`/api/v1/assistants/${assistantId}/actions/search`,
|
|
157
|
+
body,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (operation === 'delete') {
|
|
162
|
+
const assistantId = context.getNodeParameter('assistantId', 0) as string;
|
|
163
|
+
await qlikApiRequest.call(context, 'DELETE', `/api/v1/assistants/${assistantId}`);
|
|
164
|
+
return { success: true };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
throw new NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function handleAuditsResource(operation: string, context: IExecuteFunctions): Promise<any> {
|
|
171
|
+
if (operation === 'getAll') {
|
|
172
|
+
const returnAll = context.getNodeParameter('returnAll', 0) as boolean;
|
|
173
|
+
const limit = returnAll ? undefined : (context.getNodeParameter('limit', 0) as number);
|
|
174
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
175
|
+
|
|
176
|
+
const qs: any = {};
|
|
177
|
+
if (limit) {
|
|
178
|
+
qs.limit = limit;
|
|
179
|
+
}
|
|
180
|
+
if (options.eventType) {
|
|
181
|
+
qs.eventType = options.eventType;
|
|
182
|
+
}
|
|
183
|
+
if (options.userId) {
|
|
184
|
+
qs.userId = options.userId;
|
|
185
|
+
}
|
|
186
|
+
if (options.source) {
|
|
187
|
+
qs.source = options.source;
|
|
188
|
+
}
|
|
189
|
+
if (options.eventTime) {
|
|
190
|
+
qs.eventTime = options.eventTime;
|
|
191
|
+
}
|
|
192
|
+
if (options.sort) {
|
|
193
|
+
qs.sort = options.sort;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/audits', undefined, qs);
|
|
197
|
+
return response.data || response;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (operation === 'get') {
|
|
201
|
+
const auditId = context.getNodeParameter('auditId', 0) as string;
|
|
202
|
+
return await qlikApiRequest.call(context, 'GET', `/api/v1/audits/${auditId}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (operation === 'getSources') {
|
|
206
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/audits/sources');
|
|
207
|
+
return response.data || response;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (operation === 'getTypes') {
|
|
211
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/audits/types');
|
|
212
|
+
return response.data || response;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (operation === 'getSettings') {
|
|
216
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/audits/settings');
|
|
217
|
+
return response.data || response;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
throw new NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function handleItemsResource(operation: string, context: IExecuteFunctions): Promise<any> {
|
|
224
|
+
if (operation === 'getAll') {
|
|
225
|
+
const returnAll = context.getNodeParameter('returnAll', 0) as boolean;
|
|
226
|
+
const limit = returnAll ? undefined : (context.getNodeParameter('limit', 0) as number);
|
|
227
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
228
|
+
|
|
229
|
+
const qs: any = {};
|
|
230
|
+
if (limit) {
|
|
231
|
+
qs.limit = limit;
|
|
232
|
+
}
|
|
233
|
+
if (options.name) {
|
|
234
|
+
qs.name = options.name;
|
|
235
|
+
}
|
|
236
|
+
if (options.resourceType) {
|
|
237
|
+
qs.resourceType = options.resourceType;
|
|
238
|
+
}
|
|
239
|
+
if (options.spaceId) {
|
|
240
|
+
qs.spaceId = options.spaceId;
|
|
241
|
+
}
|
|
242
|
+
if (options.ownerId) {
|
|
243
|
+
qs.ownerId = options.ownerId;
|
|
244
|
+
}
|
|
245
|
+
if (options.sort) {
|
|
246
|
+
qs.sort = options.sort;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/items', undefined, qs);
|
|
250
|
+
return response.data || response;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (operation === 'get') {
|
|
254
|
+
const itemId = context.getNodeParameter('itemId', 0) as string;
|
|
255
|
+
return await qlikApiRequest.call(context, 'GET', `/api/v1/items/${itemId}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (operation === 'update') {
|
|
259
|
+
const itemId = context.getNodeParameter('itemId', 0) as string;
|
|
260
|
+
const body = context.getNodeParameter('body', 0) as any;
|
|
261
|
+
return await qlikApiRequest.call(context, 'PUT', `/api/v1/items/${itemId}`, body);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (operation === 'delete') {
|
|
265
|
+
const itemId = context.getNodeParameter('itemId', 0) as string;
|
|
266
|
+
await qlikApiRequest.call(context, 'DELETE', `/api/v1/items/${itemId}`);
|
|
267
|
+
return { success: true };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (operation === 'collections') {
|
|
271
|
+
const itemId = context.getNodeParameter('itemId', 0) as string;
|
|
272
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
273
|
+
|
|
274
|
+
const qs: any = {};
|
|
275
|
+
if (options.limit) {
|
|
276
|
+
qs.limit = options.limit;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const response = await qlikApiRequest.call(
|
|
280
|
+
context,
|
|
281
|
+
'GET',
|
|
282
|
+
`/api/v1/items/${itemId}/collections`,
|
|
283
|
+
undefined,
|
|
284
|
+
qs,
|
|
285
|
+
);
|
|
286
|
+
return response.data || response;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (operation === 'publishedItems') {
|
|
290
|
+
const itemId = context.getNodeParameter('itemId', 0) as string;
|
|
291
|
+
const options = context.getNodeParameter('options', 0) as any;
|
|
292
|
+
|
|
293
|
+
const qs: any = {};
|
|
294
|
+
if (options.limit) {
|
|
295
|
+
qs.limit = options.limit;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const response = await qlikApiRequest.call(
|
|
299
|
+
context,
|
|
300
|
+
'GET',
|
|
301
|
+
`/api/v1/items/${itemId}/publisheditems`,
|
|
302
|
+
undefined,
|
|
303
|
+
qs,
|
|
304
|
+
);
|
|
305
|
+
return response.data || response;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (operation === 'settings') {
|
|
309
|
+
const settingsOperation = context.getNodeParameter('settingsOperation', 0) as string;
|
|
310
|
+
|
|
311
|
+
if (settingsOperation === 'get') {
|
|
312
|
+
const response = await qlikApiRequest.call(context, 'GET', '/api/v1/items/settings');
|
|
313
|
+
return response.data || response;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (settingsOperation === 'patch') {
|
|
317
|
+
const body = context.getNodeParameter('body', 0) as any;
|
|
318
|
+
const response = await qlikApiRequest.call(context, 'PATCH', '/api/v1/items/settings', body);
|
|
319
|
+
return response.data || response;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
throw new NodeOperationError(context.getNode(), `Unknown operation: ${operation}`);
|
|
324
|
+
}
|
|
325
|
+
|
|
17
326
|
export class QlikCloud implements INodeType {
|
|
18
327
|
description: INodeTypeDescription = {
|
|
19
328
|
displayName: 'Qlik Cloud',
|
|
@@ -73,7 +382,7 @@ export class QlikCloud implements INodeType {
|
|
|
73
382
|
|
|
74
383
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
75
384
|
const items = this.getInputData();
|
|
76
|
-
let responseData;
|
|
385
|
+
let responseData: any;
|
|
77
386
|
const returnData: INodeExecutionData[] = [];
|
|
78
387
|
|
|
79
388
|
const resource = this.getNodeParameter('resource', 0) as string;
|
|
@@ -82,17 +391,17 @@ export class QlikCloud implements INodeType {
|
|
|
82
391
|
for (let i = 0; i < items.length; i++) {
|
|
83
392
|
try {
|
|
84
393
|
if (resource === 'apps') {
|
|
85
|
-
responseData = await
|
|
394
|
+
responseData = await handleAppsResource(operation, this);
|
|
86
395
|
} else if (resource === 'assistants') {
|
|
87
|
-
responseData = await
|
|
396
|
+
responseData = await handleAssistantsResource(operation, this);
|
|
88
397
|
} else if (resource === 'audits') {
|
|
89
|
-
responseData = await
|
|
398
|
+
responseData = await handleAuditsResource(operation, this);
|
|
90
399
|
} else if (resource === 'items') {
|
|
91
|
-
responseData = await
|
|
400
|
+
responseData = await handleItemsResource(operation, this);
|
|
92
401
|
}
|
|
93
402
|
|
|
94
403
|
const executionData = this.helpers.constructExecutionMetaData(
|
|
95
|
-
this.helpers.returnJsonArray(responseData
|
|
404
|
+
this.helpers.returnJsonArray(Array.isArray(responseData) ? responseData : [responseData]),
|
|
96
405
|
{ itemData: { item: i } },
|
|
97
406
|
);
|
|
98
407
|
returnData.push(...executionData);
|
|
@@ -110,315 +419,4 @@ export class QlikCloud implements INodeType {
|
|
|
110
419
|
|
|
111
420
|
return [returnData];
|
|
112
421
|
}
|
|
113
|
-
|
|
114
|
-
private async handleAppsResource(operation: string): Promise<any> {
|
|
115
|
-
if (operation === 'getAll') {
|
|
116
|
-
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
|
117
|
-
const limit = returnAll ? undefined : (this.getNodeParameter('limit', 0) as number);
|
|
118
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
119
|
-
|
|
120
|
-
const qs: any = {};
|
|
121
|
-
if (limit) {
|
|
122
|
-
qs.limit = limit;
|
|
123
|
-
}
|
|
124
|
-
if (options.name) {
|
|
125
|
-
qs.name = options.name;
|
|
126
|
-
}
|
|
127
|
-
if (options.spaceId) {
|
|
128
|
-
qs.spaceId = options.spaceId;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/apps', undefined, qs);
|
|
132
|
-
return response.data || response;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (operation === 'get') {
|
|
136
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
137
|
-
return await qlikApiRequest.call(this, 'GET', `/api/v1/apps/${appId}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (operation === 'create') {
|
|
141
|
-
const name = this.getNodeParameter('name', 0) as string;
|
|
142
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
143
|
-
|
|
144
|
-
const body = { attributes: { name } };
|
|
145
|
-
if (options.description) {
|
|
146
|
-
(body.attributes as any).description = options.description;
|
|
147
|
-
}
|
|
148
|
-
if (options.locale) {
|
|
149
|
-
(body.attributes as any).locale = options.locale;
|
|
150
|
-
}
|
|
151
|
-
if (options.spaceId) {
|
|
152
|
-
(body.attributes as any).spaceId = options.spaceId;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return await qlikApiRequest.call(this, 'POST', '/api/v1/apps', body);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (operation === 'update') {
|
|
159
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
160
|
-
const body = this.getNodeParameter('body', 0) as any;
|
|
161
|
-
return await qlikApiRequest.call(this, 'PUT', `/api/v1/apps/${appId}`, body);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (operation === 'delete') {
|
|
165
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
166
|
-
await qlikApiRequest.call(this, 'DELETE', `/api/v1/apps/${appId}`);
|
|
167
|
-
return { success: true };
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (operation === 'copy') {
|
|
171
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
172
|
-
const name = this.getNodeParameter('name', 0) as string;
|
|
173
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
174
|
-
|
|
175
|
-
const body = { attributes: { name } };
|
|
176
|
-
if (options.description) {
|
|
177
|
-
(body.attributes as any).description = options.description;
|
|
178
|
-
}
|
|
179
|
-
if (options.spaceId) {
|
|
180
|
-
(body.attributes as any).spaceId = options.spaceId;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return await qlikApiRequest.call(this, 'POST', `/api/v1/apps/${appId}/copy`, body);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (operation === 'export') {
|
|
187
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
188
|
-
return await qlikApiRequest.call(this, 'POST', `/api/v1/apps/${appId}/export`, {});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (operation === 'publish') {
|
|
192
|
-
const appId = this.getNodeParameter('appId', 0) as string;
|
|
193
|
-
const options = this.getNodeParameter('publishOptions', 0) as any;
|
|
194
|
-
|
|
195
|
-
const body: any = {};
|
|
196
|
-
if (options.spaceId) {
|
|
197
|
-
body.spaceId = options.spaceId;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return await qlikApiRequest.call(this, 'POST', `/api/v1/apps/${appId}/publish`, body);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (operation === 'privileges') {
|
|
204
|
-
return await qlikApiRequest.call(this, 'GET', '/api/v1/apps/privileges');
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
throw new NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private async handleAssistantsResource(operation: string): Promise<any> {
|
|
211
|
-
if (operation === 'getAll') {
|
|
212
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
213
|
-
|
|
214
|
-
const qs: any = {};
|
|
215
|
-
if (options.limit) {
|
|
216
|
-
qs.limit = options.limit;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return await qlikApiRequest.call(this, 'GET', '/api/v1/assistants', undefined, qs);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (operation === 'get') {
|
|
223
|
-
const assistantId = this.getNodeParameter('assistantId', 0) as string;
|
|
224
|
-
return await qlikApiRequest.call(this, 'GET', `/api/v1/assistants/${assistantId}`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (operation === 'create') {
|
|
228
|
-
const name = this.getNodeParameter('name', 0) as string;
|
|
229
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
230
|
-
|
|
231
|
-
const body: any = { name };
|
|
232
|
-
if (options.description) {
|
|
233
|
-
body.description = options.description;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return await qlikApiRequest.call(this, 'POST', '/api/v1/assistants', body);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (operation === 'search') {
|
|
240
|
-
const assistantId = this.getNodeParameter('assistantId', 0) as string;
|
|
241
|
-
const query = this.getNodeParameter('query', 0) as string;
|
|
242
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
243
|
-
|
|
244
|
-
const body: any = { text: query };
|
|
245
|
-
if (options.topN) {
|
|
246
|
-
body.topN = options.topN;
|
|
247
|
-
}
|
|
248
|
-
if (options.mode) {
|
|
249
|
-
body.mode = options.mode;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return await qlikApiRequest.call(
|
|
253
|
-
this,
|
|
254
|
-
'POST',
|
|
255
|
-
`/api/v1/assistants/${assistantId}/actions/search`,
|
|
256
|
-
body,
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (operation === 'delete') {
|
|
261
|
-
const assistantId = this.getNodeParameter('assistantId', 0) as string;
|
|
262
|
-
await qlikApiRequest.call(this, 'DELETE', `/api/v1/assistants/${assistantId}`);
|
|
263
|
-
return { success: true };
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
throw new NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private async handleAuditsResource(operation: string): Promise<any> {
|
|
270
|
-
if (operation === 'getAll') {
|
|
271
|
-
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
|
272
|
-
const limit = returnAll ? undefined : (this.getNodeParameter('limit', 0) as number);
|
|
273
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
274
|
-
|
|
275
|
-
const qs: any = {};
|
|
276
|
-
if (limit) {
|
|
277
|
-
qs.limit = limit;
|
|
278
|
-
}
|
|
279
|
-
if (options.eventType) {
|
|
280
|
-
qs.eventType = options.eventType;
|
|
281
|
-
}
|
|
282
|
-
if (options.userId) {
|
|
283
|
-
qs.userId = options.userId;
|
|
284
|
-
}
|
|
285
|
-
if (options.source) {
|
|
286
|
-
qs.source = options.source;
|
|
287
|
-
}
|
|
288
|
-
if (options.eventTime) {
|
|
289
|
-
qs.eventTime = options.eventTime;
|
|
290
|
-
}
|
|
291
|
-
if (options.sort) {
|
|
292
|
-
qs.sort = options.sort;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/audits', undefined, qs);
|
|
296
|
-
return response.data || response;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (operation === 'get') {
|
|
300
|
-
const auditId = this.getNodeParameter('auditId', 0) as string;
|
|
301
|
-
return await qlikApiRequest.call(this, 'GET', `/api/v1/audits/${auditId}`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (operation === 'getSources') {
|
|
305
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/audits/sources');
|
|
306
|
-
return response.data || response;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (operation === 'getTypes') {
|
|
310
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/audits/types');
|
|
311
|
-
return response.data || response;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (operation === 'getSettings') {
|
|
315
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/audits/settings');
|
|
316
|
-
return response.data || response;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
throw new NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private async handleItemsResource(operation: string): Promise<any> {
|
|
323
|
-
if (operation === 'getAll') {
|
|
324
|
-
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
|
325
|
-
const limit = returnAll ? undefined : (this.getNodeParameter('limit', 0) as number);
|
|
326
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
327
|
-
|
|
328
|
-
const qs: any = {};
|
|
329
|
-
if (limit) {
|
|
330
|
-
qs.limit = limit;
|
|
331
|
-
}
|
|
332
|
-
if (options.name) {
|
|
333
|
-
qs.name = options.name;
|
|
334
|
-
}
|
|
335
|
-
if (options.resourceType) {
|
|
336
|
-
qs.resourceType = options.resourceType;
|
|
337
|
-
}
|
|
338
|
-
if (options.spaceId) {
|
|
339
|
-
qs.spaceId = options.spaceId;
|
|
340
|
-
}
|
|
341
|
-
if (options.ownerId) {
|
|
342
|
-
qs.ownerId = options.ownerId;
|
|
343
|
-
}
|
|
344
|
-
if (options.sort) {
|
|
345
|
-
qs.sort = options.sort;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/items', undefined, qs);
|
|
349
|
-
return response.data || response;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
if (operation === 'get') {
|
|
353
|
-
const itemId = this.getNodeParameter('itemId', 0) as string;
|
|
354
|
-
return await qlikApiRequest.call(this, 'GET', `/api/v1/items/${itemId}`);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (operation === 'update') {
|
|
358
|
-
const itemId = this.getNodeParameter('itemId', 0) as string;
|
|
359
|
-
const body = this.getNodeParameter('body', 0) as any;
|
|
360
|
-
return await qlikApiRequest.call(this, 'PUT', `/api/v1/items/${itemId}`, body);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (operation === 'delete') {
|
|
364
|
-
const itemId = this.getNodeParameter('itemId', 0) as string;
|
|
365
|
-
await qlikApiRequest.call(this, 'DELETE', `/api/v1/items/${itemId}`);
|
|
366
|
-
return { success: true };
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (operation === 'collections') {
|
|
370
|
-
const itemId = this.getNodeParameter('itemId', 0) as string;
|
|
371
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
372
|
-
|
|
373
|
-
const qs: any = {};
|
|
374
|
-
if (options.limit) {
|
|
375
|
-
qs.limit = options.limit;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const response = await qlikApiRequest.call(
|
|
379
|
-
this,
|
|
380
|
-
'GET',
|
|
381
|
-
`/api/v1/items/${itemId}/collections`,
|
|
382
|
-
undefined,
|
|
383
|
-
qs,
|
|
384
|
-
);
|
|
385
|
-
return response.data || response;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (operation === 'publishedItems') {
|
|
389
|
-
const itemId = this.getNodeParameter('itemId', 0) as string;
|
|
390
|
-
const options = this.getNodeParameter('options', 0) as any;
|
|
391
|
-
|
|
392
|
-
const qs: any = {};
|
|
393
|
-
if (options.limit) {
|
|
394
|
-
qs.limit = options.limit;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const response = await qlikApiRequest.call(
|
|
398
|
-
this,
|
|
399
|
-
'GET',
|
|
400
|
-
`/api/v1/items/${itemId}/publisheditems`,
|
|
401
|
-
undefined,
|
|
402
|
-
qs,
|
|
403
|
-
);
|
|
404
|
-
return response.data || response;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (operation === 'settings') {
|
|
408
|
-
const settingsOperation = this.getNodeParameter('settingsOperation', 0) as string;
|
|
409
|
-
|
|
410
|
-
if (settingsOperation === 'get') {
|
|
411
|
-
const response = await qlikApiRequest.call(this, 'GET', '/api/v1/items/settings');
|
|
412
|
-
return response.data || response;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (settingsOperation === 'patch') {
|
|
416
|
-
const body = this.getNodeParameter('body', 0) as any;
|
|
417
|
-
const response = await qlikApiRequest.call(this, 'PATCH', '/api/v1/items/settings', body);
|
|
418
|
-
return response.data || response;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
throw new NodeOperationError(this.getNode(), `Unknown operation: ${operation}`);
|
|
423
|
-
}
|
|
424
422
|
}
|