@pipedream/topdesk 0.0.1 → 0.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/actions/create-incident/create-incident.mjs +415 -0
- package/actions/get-incident/get-incident.mjs +39 -0
- package/actions/get-incidents/get-incidents.mjs +87 -0
- package/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs +42 -0
- package/actions/get-knowledge-items/get-knowledge-items.mjs +124 -0
- package/actions/update-incident/update-incident.mjs +442 -0
- package/package.json +4 -1
- package/topdesk.app.mjs +701 -5
package/topdesk.app.mjs
CHANGED
|
@@ -1,11 +1,707 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "topdesk",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
incidentId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Incident ID",
|
|
10
|
+
description: "The UUID of the incident",
|
|
11
|
+
async options({ prevContext }) {
|
|
12
|
+
const { pageStart } = prevContext;
|
|
13
|
+
if (pageStart === null) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const incidents = await this.listIncidents({
|
|
17
|
+
params: {
|
|
18
|
+
pageStart,
|
|
19
|
+
pageSize: 100,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
options: incidents?.map((incident) => ({
|
|
24
|
+
label: incident.briefDescription
|
|
25
|
+
? `${incident.number} - ${incident.briefDescription}`
|
|
26
|
+
: incident.number,
|
|
27
|
+
value: incident.id,
|
|
28
|
+
})) || [],
|
|
29
|
+
context: {
|
|
30
|
+
pageStart: incidents.length === 100
|
|
31
|
+
? (pageStart || 0) + 100
|
|
32
|
+
: null,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
knowledgeItemId: {
|
|
38
|
+
type: "string",
|
|
39
|
+
label: "Knowledge Item ID",
|
|
40
|
+
description: "The UUID or number of the knowledge item",
|
|
41
|
+
async options({ prevContext }) {
|
|
42
|
+
const response = await this.listKnowledgeItems({
|
|
43
|
+
params: {
|
|
44
|
+
start: prevContext?.start || 0,
|
|
45
|
+
page_size: 100,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const items = response.item || [];
|
|
49
|
+
return {
|
|
50
|
+
options: items.map((item) => ({
|
|
51
|
+
label: `${item.number} - ${item.translation?.content?.title || "Untitled"}`,
|
|
52
|
+
value: item.id,
|
|
53
|
+
})),
|
|
54
|
+
context: {
|
|
55
|
+
start: response.next
|
|
56
|
+
? (prevContext?.start || 0) + 100
|
|
57
|
+
: null,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
operatorId: {
|
|
63
|
+
type: "string",
|
|
64
|
+
label: "Operator ID",
|
|
65
|
+
description: "The UUID of the operator",
|
|
66
|
+
async options({ prevContext }) {
|
|
67
|
+
const operators = await this.listOperators({
|
|
68
|
+
params: {
|
|
69
|
+
start: prevContext?.start || 0,
|
|
70
|
+
page_size: 100,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
options: operators?.map((operator) => ({
|
|
75
|
+
label: operator.dynamicName || `${operator.firstName} ${operator.surName}`,
|
|
76
|
+
value: operator.id,
|
|
77
|
+
})) || [],
|
|
78
|
+
context: {
|
|
79
|
+
start: operators?.length === 100
|
|
80
|
+
? (prevContext?.start || 0) + 100
|
|
81
|
+
: null,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
personId: {
|
|
87
|
+
type: "string",
|
|
88
|
+
label: "Person ID",
|
|
89
|
+
description: "The UUID of the person",
|
|
90
|
+
async options({ prevContext }) {
|
|
91
|
+
const persons = await this.listPersons({
|
|
92
|
+
params: {
|
|
93
|
+
start: prevContext?.start || 0,
|
|
94
|
+
page_size: 100,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
return persons.map((person) => ({
|
|
98
|
+
label: `${person.firstName} ${person.surName}`,
|
|
99
|
+
value: person.id,
|
|
100
|
+
})) || [];
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
categoryId: {
|
|
104
|
+
type: "string",
|
|
105
|
+
label: "Category ID",
|
|
106
|
+
description: "The UUID of the category",
|
|
107
|
+
optional: true,
|
|
108
|
+
async options() {
|
|
109
|
+
const response = await this.listCategories();
|
|
110
|
+
const items = response.item || [];
|
|
111
|
+
return items.map((item) => ({
|
|
112
|
+
label: item.parent
|
|
113
|
+
? `${item.parent.name} - ${item.name}`
|
|
114
|
+
: item.name,
|
|
115
|
+
value: item.id,
|
|
116
|
+
}));
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
subcategoryId: {
|
|
120
|
+
type: "string",
|
|
121
|
+
label: "Subcategory ID",
|
|
122
|
+
description: "The UUID of the subcategory",
|
|
123
|
+
optional: true,
|
|
124
|
+
async options({ categoryId }) {
|
|
125
|
+
if (!categoryId) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const response = await this.listCategories({
|
|
129
|
+
params: {
|
|
130
|
+
query: `parent.id==${categoryId}`,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const items = response.item || [];
|
|
134
|
+
return items.map((item) => ({
|
|
135
|
+
label: item.name,
|
|
136
|
+
value: item.id,
|
|
137
|
+
}));
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
callTypeId: {
|
|
141
|
+
type: "string",
|
|
142
|
+
label: "Call Type ID",
|
|
143
|
+
description: "The UUID of the call type",
|
|
144
|
+
optional: true,
|
|
145
|
+
async options() {
|
|
146
|
+
const response = await this.listCallTypes();
|
|
147
|
+
return response.map((item) => ({
|
|
148
|
+
label: item.name,
|
|
149
|
+
value: item.id,
|
|
150
|
+
}));
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
entryTypeId: {
|
|
154
|
+
type: "string",
|
|
155
|
+
label: "Entry Type ID",
|
|
156
|
+
description: "The UUID of the entry type",
|
|
157
|
+
optional: true,
|
|
158
|
+
async options() {
|
|
159
|
+
const response = await this.listEntryTypes();
|
|
160
|
+
return response.map((item) => ({
|
|
161
|
+
label: item.name,
|
|
162
|
+
value: item.id,
|
|
163
|
+
}));
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
impactId: {
|
|
167
|
+
type: "string",
|
|
168
|
+
label: "Impact ID",
|
|
169
|
+
description: "The UUID of the impact",
|
|
170
|
+
optional: true,
|
|
171
|
+
async options() {
|
|
172
|
+
const response = await this.listImpacts();
|
|
173
|
+
return response.map((item) => ({
|
|
174
|
+
label: item.name,
|
|
175
|
+
value: item.id,
|
|
176
|
+
}));
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
urgencyId: {
|
|
180
|
+
type: "string",
|
|
181
|
+
label: "Urgency ID",
|
|
182
|
+
description: "The UUID of the urgency",
|
|
183
|
+
optional: true,
|
|
184
|
+
async options() {
|
|
185
|
+
const response = await this.listUrgencies();
|
|
186
|
+
return response.map((item) => ({
|
|
187
|
+
label: item.name,
|
|
188
|
+
value: item.id,
|
|
189
|
+
}));
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
priorityId: {
|
|
193
|
+
type: "string",
|
|
194
|
+
label: "Priority ID",
|
|
195
|
+
description: "The UUID of the priority",
|
|
196
|
+
optional: true,
|
|
197
|
+
async options() {
|
|
198
|
+
const response = await this.listPriorities();
|
|
199
|
+
return response.map((item) => ({
|
|
200
|
+
label: item.name,
|
|
201
|
+
value: item.id,
|
|
202
|
+
}));
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
durationId: {
|
|
206
|
+
type: "string",
|
|
207
|
+
label: "Duration ID",
|
|
208
|
+
description: "The UUID of the duration",
|
|
209
|
+
optional: true,
|
|
210
|
+
async options() {
|
|
211
|
+
const response = await this.listDurations();
|
|
212
|
+
return response.map((item) => ({
|
|
213
|
+
label: item.name,
|
|
214
|
+
value: item.id,
|
|
215
|
+
}));
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
slaId: {
|
|
219
|
+
type: "string",
|
|
220
|
+
label: "SLA ID",
|
|
221
|
+
description: "The UUID of the SLA",
|
|
222
|
+
optional: true,
|
|
223
|
+
async options() {
|
|
224
|
+
const response = await this.listSLAs();
|
|
225
|
+
return response.results?.map((item) => ({
|
|
226
|
+
label: item.name,
|
|
227
|
+
value: item.id,
|
|
228
|
+
}));
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
processingStatusId: {
|
|
232
|
+
type: "string",
|
|
233
|
+
label: "Processing Status ID",
|
|
234
|
+
description: "The UUID of the processing status",
|
|
235
|
+
optional: true,
|
|
236
|
+
async options() {
|
|
237
|
+
const response = await this.listProcessingStatuses();
|
|
238
|
+
return response.map((item) => ({
|
|
239
|
+
label: item.name,
|
|
240
|
+
value: item.id,
|
|
241
|
+
}));
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
closureCodeId: {
|
|
245
|
+
type: "string",
|
|
246
|
+
label: "Closure Code ID",
|
|
247
|
+
description: "The UUID of the closure code",
|
|
248
|
+
optional: true,
|
|
249
|
+
async options() {
|
|
250
|
+
const response = await this.listClosureCodes();
|
|
251
|
+
return response.map((item) => ({
|
|
252
|
+
label: item.name,
|
|
253
|
+
value: item.id,
|
|
254
|
+
}));
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
locationId: {
|
|
258
|
+
type: "string",
|
|
259
|
+
label: "Location ID",
|
|
260
|
+
description: "The UUID of the location",
|
|
261
|
+
optional: true,
|
|
262
|
+
async options() {
|
|
263
|
+
const response = await this.listLocations({
|
|
264
|
+
params: {
|
|
265
|
+
pageSize: 100,
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
return response.map((item) => ({
|
|
269
|
+
label: item.name
|
|
270
|
+
? `${item.name}${item.roomNumber
|
|
271
|
+
? ` - ${item.roomNumber}`
|
|
272
|
+
: ""}`
|
|
273
|
+
: item.roomNumber || item.id,
|
|
274
|
+
value: item.id,
|
|
275
|
+
}));
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
branchId: {
|
|
279
|
+
type: "string",
|
|
280
|
+
label: "Branch ID",
|
|
281
|
+
description: "The UUID of the branch",
|
|
282
|
+
optional: true,
|
|
283
|
+
async options() {
|
|
284
|
+
const response = await this.listBranches();
|
|
285
|
+
return response.map((item) => ({
|
|
286
|
+
label: item.name,
|
|
287
|
+
value: item.id,
|
|
288
|
+
}));
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
operatorGroupId: {
|
|
292
|
+
type: "string",
|
|
293
|
+
label: "Operator Group ID",
|
|
294
|
+
description: "The UUID of the operator group",
|
|
295
|
+
optional: true,
|
|
296
|
+
async options({ prevContext }) {
|
|
297
|
+
const response = await this.listOperatorGroups({
|
|
298
|
+
params: {
|
|
299
|
+
start: prevContext?.start || 0,
|
|
300
|
+
page_size: 100,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
return {
|
|
304
|
+
options: response.map((item) => ({
|
|
305
|
+
label: item.groupName,
|
|
306
|
+
value: item.id,
|
|
307
|
+
})),
|
|
308
|
+
context: {
|
|
309
|
+
start: response.length === 100
|
|
310
|
+
? (prevContext?.start || 0) + 100
|
|
311
|
+
: null,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
supplierId: {
|
|
317
|
+
type: "string",
|
|
318
|
+
label: "Supplier ID",
|
|
319
|
+
description: "The UUID of the supplier",
|
|
320
|
+
optional: true,
|
|
321
|
+
async options({ prevContext }) {
|
|
322
|
+
const response = await this.listSuppliers({
|
|
323
|
+
params: {
|
|
324
|
+
start: prevContext?.start || 0,
|
|
325
|
+
page_size: 100,
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
options: response.map((item) => ({
|
|
330
|
+
label: item.name,
|
|
331
|
+
value: item.id,
|
|
332
|
+
})),
|
|
333
|
+
context: {
|
|
334
|
+
start: response.length === 100
|
|
335
|
+
? (prevContext?.start || 0) + 100
|
|
336
|
+
: null,
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
objectName: {
|
|
342
|
+
type: "string",
|
|
343
|
+
label: "Object Name",
|
|
344
|
+
description: "The UUID of the object (asset). Can only be set by operators.",
|
|
345
|
+
optional: true,
|
|
346
|
+
async options({ prevContext }) {
|
|
347
|
+
const response = await this.listAssets({
|
|
348
|
+
params: {
|
|
349
|
+
pageStart: prevContext?.pageStart || 0,
|
|
350
|
+
pageSize: 100,
|
|
351
|
+
fields: "name",
|
|
352
|
+
archived: false,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
const assets = response.dataSet || [];
|
|
356
|
+
return {
|
|
357
|
+
options: assets.map(({ name }) => name),
|
|
358
|
+
context: {
|
|
359
|
+
pageStart: assets.length === 100
|
|
360
|
+
? (prevContext?.pageStart || 0) + 100
|
|
361
|
+
: null,
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
briefDescription: {
|
|
367
|
+
type: "string",
|
|
368
|
+
label: "Brief Description",
|
|
369
|
+
description: "Brief description of the incident (max 80 characters)",
|
|
370
|
+
optional: true,
|
|
371
|
+
},
|
|
372
|
+
request: {
|
|
373
|
+
type: "string",
|
|
374
|
+
label: "Request",
|
|
375
|
+
description: "The initial request text. HTML tags are supported: `<i>`, `<em>`, `<b>`, `<strong>`, `<u>`, `<br>`, `<h5>`, `<h6>`",
|
|
376
|
+
optional: true,
|
|
377
|
+
},
|
|
378
|
+
action: {
|
|
379
|
+
type: "string",
|
|
380
|
+
label: "Action",
|
|
381
|
+
description: "The action text to add. HTML tags are supported: `<i>`, `<em>`, `<b>`, `<strong>`, `<u>`, `<br>`, `<h5>`, `<h6>`",
|
|
382
|
+
optional: true,
|
|
383
|
+
},
|
|
384
|
+
actionInvisibleForCaller: {
|
|
385
|
+
type: "boolean",
|
|
386
|
+
label: "Action Invisible For Caller",
|
|
387
|
+
description: "Whether the action is invisible for persons. Can only be set by operators.",
|
|
388
|
+
optional: true,
|
|
389
|
+
},
|
|
390
|
+
externalNumber: {
|
|
391
|
+
type: "string",
|
|
392
|
+
label: "External Number",
|
|
393
|
+
description: "External number (max 60 characters). Can only be set by operators.",
|
|
394
|
+
optional: true,
|
|
395
|
+
},
|
|
396
|
+
targetDate: {
|
|
397
|
+
type: "string",
|
|
398
|
+
label: "Target Date",
|
|
399
|
+
description: "Target date in ISO 8601 format (e.g., `2024-08-01T12:00:00.000+0200`). Can only be set by operators.",
|
|
400
|
+
optional: true,
|
|
401
|
+
},
|
|
402
|
+
onHold: {
|
|
403
|
+
type: "boolean",
|
|
404
|
+
label: "On Hold",
|
|
405
|
+
description: "Whether the incident is on hold. Can only be set by operators.",
|
|
406
|
+
optional: true,
|
|
407
|
+
},
|
|
408
|
+
responded: {
|
|
409
|
+
type: "boolean",
|
|
410
|
+
label: "Responded",
|
|
411
|
+
description: "Whether the incident is responded. SLM-licence is needed. Can only be set by operators.",
|
|
412
|
+
optional: true,
|
|
413
|
+
},
|
|
414
|
+
responseDate: {
|
|
415
|
+
type: "string",
|
|
416
|
+
label: "Response Date",
|
|
417
|
+
description: "Response date in ISO 8601 format. SLM-licence is needed. Can only be set by operators.",
|
|
418
|
+
optional: true,
|
|
419
|
+
},
|
|
420
|
+
completed: {
|
|
421
|
+
type: "boolean",
|
|
422
|
+
label: "Completed",
|
|
423
|
+
description: "Whether the incident is completed. Can only be set by operators.",
|
|
424
|
+
optional: true,
|
|
425
|
+
},
|
|
426
|
+
completedDate: {
|
|
427
|
+
type: "string",
|
|
428
|
+
label: "Completed Date",
|
|
429
|
+
description: "Completed date in ISO 8601 format. Can only be set by operators.",
|
|
430
|
+
optional: true,
|
|
431
|
+
},
|
|
432
|
+
closed: {
|
|
433
|
+
type: "boolean",
|
|
434
|
+
label: "Closed",
|
|
435
|
+
description: "Whether the incident is closed. Can only be set by operators.",
|
|
436
|
+
optional: true,
|
|
437
|
+
},
|
|
438
|
+
closedDate: {
|
|
439
|
+
type: "string",
|
|
440
|
+
label: "Closed Date",
|
|
441
|
+
description: "Closed date in ISO 8601 format. Can only be set by operators.",
|
|
442
|
+
optional: true,
|
|
443
|
+
},
|
|
444
|
+
majorCall: {
|
|
445
|
+
type: "boolean",
|
|
446
|
+
label: "Major Call",
|
|
447
|
+
description: "Whether the incident is a major call. Can only be set by operators.",
|
|
448
|
+
optional: true,
|
|
449
|
+
},
|
|
450
|
+
publishToSsd: {
|
|
451
|
+
type: "boolean",
|
|
452
|
+
label: "Publish To SSD",
|
|
453
|
+
description: "Whether to publish the incident to Self Service Desk. Can only be set by operators.",
|
|
454
|
+
optional: true,
|
|
455
|
+
},
|
|
456
|
+
optionalFields1: {
|
|
457
|
+
type: "object",
|
|
458
|
+
label: "Optional Fields 1",
|
|
459
|
+
description: "Optional fields tab 1 as a JSON object",
|
|
460
|
+
optional: true,
|
|
461
|
+
},
|
|
462
|
+
optionalFields2: {
|
|
463
|
+
type: "object",
|
|
464
|
+
label: "Optional Fields 2",
|
|
465
|
+
description: "Optional fields tab 2 as a JSON object",
|
|
466
|
+
optional: true,
|
|
467
|
+
},
|
|
468
|
+
},
|
|
5
469
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
470
|
+
getUrl(path) {
|
|
471
|
+
return `${this.$auth.api_url}${path}`;
|
|
472
|
+
},
|
|
473
|
+
getAuth() {
|
|
474
|
+
const {
|
|
475
|
+
username,
|
|
476
|
+
app_token: password,
|
|
477
|
+
} = this.$auth;
|
|
478
|
+
return {
|
|
479
|
+
username,
|
|
480
|
+
password,
|
|
481
|
+
};
|
|
482
|
+
},
|
|
483
|
+
_makeRequest({
|
|
484
|
+
$ = this, path, ...opts
|
|
485
|
+
}) {
|
|
486
|
+
return axios($, {
|
|
487
|
+
url: this.getUrl(path),
|
|
488
|
+
auth: this.getAuth(),
|
|
489
|
+
...opts,
|
|
490
|
+
});
|
|
491
|
+
},
|
|
492
|
+
post(opts = {}) {
|
|
493
|
+
return this._makeRequest({
|
|
494
|
+
method: "POST",
|
|
495
|
+
...opts,
|
|
496
|
+
});
|
|
497
|
+
},
|
|
498
|
+
patch(opts = {}) {
|
|
499
|
+
return this._makeRequest({
|
|
500
|
+
method: "PATCH",
|
|
501
|
+
...opts,
|
|
502
|
+
});
|
|
503
|
+
},
|
|
504
|
+
listIncidents(opts = {}) {
|
|
505
|
+
return this._makeRequest({
|
|
506
|
+
path: "/tas/api/incidents",
|
|
507
|
+
...opts,
|
|
508
|
+
});
|
|
509
|
+
},
|
|
510
|
+
getIncident({
|
|
511
|
+
incidentId, ...opts
|
|
512
|
+
} = {}) {
|
|
513
|
+
return this._makeRequest({
|
|
514
|
+
path: `/tas/api/incidents/id/${incidentId}`,
|
|
515
|
+
...opts,
|
|
516
|
+
});
|
|
517
|
+
},
|
|
518
|
+
createIncident(opts = {}) {
|
|
519
|
+
return this.post({
|
|
520
|
+
path: "/tas/api/incidents",
|
|
521
|
+
...opts,
|
|
522
|
+
});
|
|
523
|
+
},
|
|
524
|
+
updateIncident({
|
|
525
|
+
incidentId, ...opts
|
|
526
|
+
} = {}) {
|
|
527
|
+
return this.patch({
|
|
528
|
+
path: `/tas/api/incidents/id/${incidentId}`,
|
|
529
|
+
...opts,
|
|
530
|
+
});
|
|
531
|
+
},
|
|
532
|
+
listKnowledgeItems(opts = {}) {
|
|
533
|
+
return this._makeRequest({
|
|
534
|
+
path: "/services/knowledge-base-v1/knowledgeItems",
|
|
535
|
+
...opts,
|
|
536
|
+
});
|
|
537
|
+
},
|
|
538
|
+
getKnowledgeItem({
|
|
539
|
+
itemId, ...opts
|
|
540
|
+
} = {}) {
|
|
541
|
+
return this._makeRequest({
|
|
542
|
+
path: `/services/knowledge-base-v1/knowledgeItems/${itemId}`,
|
|
543
|
+
...opts,
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
listKnowledgeItemStatuses(opts = {}) {
|
|
547
|
+
return this._makeRequest({
|
|
548
|
+
path: "/services/knowledge-base-v1/knowledgeItemStatuses",
|
|
549
|
+
...opts,
|
|
550
|
+
});
|
|
551
|
+
},
|
|
552
|
+
listOperators(opts = {}) {
|
|
553
|
+
return this._makeRequest({
|
|
554
|
+
path: "/tas/api/operators",
|
|
555
|
+
...opts,
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
listPersons(opts = {}) {
|
|
559
|
+
return this._makeRequest({
|
|
560
|
+
path: "/tas/api/persons",
|
|
561
|
+
...opts,
|
|
562
|
+
});
|
|
563
|
+
},
|
|
564
|
+
listCategories(opts = {}) {
|
|
565
|
+
return this._makeRequest({
|
|
566
|
+
path: "/tas/api/categories",
|
|
567
|
+
...opts,
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
listCallTypes(opts = {}) {
|
|
571
|
+
return this._makeRequest({
|
|
572
|
+
path: "/tas/api/incidents/call_types",
|
|
573
|
+
...opts,
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
listEntryTypes(opts = {}) {
|
|
577
|
+
return this._makeRequest({
|
|
578
|
+
path: "/tas/api/incidents/entry_types",
|
|
579
|
+
...opts,
|
|
580
|
+
});
|
|
581
|
+
},
|
|
582
|
+
listImpacts(opts = {}) {
|
|
583
|
+
return this._makeRequest({
|
|
584
|
+
path: "/tas/api/incidents/impacts",
|
|
585
|
+
...opts,
|
|
586
|
+
});
|
|
587
|
+
},
|
|
588
|
+
listUrgencies(opts = {}) {
|
|
589
|
+
return this._makeRequest({
|
|
590
|
+
path: "/tas/api/incidents/urgencies",
|
|
591
|
+
...opts,
|
|
592
|
+
});
|
|
593
|
+
},
|
|
594
|
+
listPriorities(opts = {}) {
|
|
595
|
+
return this._makeRequest({
|
|
596
|
+
path: "/tas/api/incidents/priorities",
|
|
597
|
+
...opts,
|
|
598
|
+
});
|
|
599
|
+
},
|
|
600
|
+
listDurations(opts = {}) {
|
|
601
|
+
return this._makeRequest({
|
|
602
|
+
path: "/tas/api/incidents/durations",
|
|
603
|
+
...opts,
|
|
604
|
+
});
|
|
605
|
+
},
|
|
606
|
+
listSLAs(opts = {}) {
|
|
607
|
+
return this._makeRequest({
|
|
608
|
+
path: "/tas/api/incidents/slas",
|
|
609
|
+
...opts,
|
|
610
|
+
});
|
|
611
|
+
},
|
|
612
|
+
listProcessingStatuses(opts = {}) {
|
|
613
|
+
return this._makeRequest({
|
|
614
|
+
path: "/tas/api/incidents/statuses",
|
|
615
|
+
...opts,
|
|
616
|
+
});
|
|
617
|
+
},
|
|
618
|
+
listClosureCodes(opts = {}) {
|
|
619
|
+
return this._makeRequest({
|
|
620
|
+
path: "/tas/api/incidents/closure_codes",
|
|
621
|
+
...opts,
|
|
622
|
+
});
|
|
623
|
+
},
|
|
624
|
+
listLocations(opts = {}) {
|
|
625
|
+
return this._makeRequest({
|
|
626
|
+
path: "/tas/api/locations",
|
|
627
|
+
...opts,
|
|
628
|
+
});
|
|
629
|
+
},
|
|
630
|
+
listBranches(opts = {}) {
|
|
631
|
+
return this._makeRequest({
|
|
632
|
+
path: "/tas/api/branches",
|
|
633
|
+
...opts,
|
|
634
|
+
});
|
|
635
|
+
},
|
|
636
|
+
listOperatorGroups(opts = {}) {
|
|
637
|
+
return this._makeRequest({
|
|
638
|
+
path: "/tas/api/operatorgroups",
|
|
639
|
+
...opts,
|
|
640
|
+
});
|
|
641
|
+
},
|
|
642
|
+
listSuppliers(opts = {}) {
|
|
643
|
+
return this._makeRequest({
|
|
644
|
+
path: "/tas/api/suppliers",
|
|
645
|
+
...opts,
|
|
646
|
+
});
|
|
647
|
+
},
|
|
648
|
+
listAssets(opts = {}) {
|
|
649
|
+
return this._makeRequest({
|
|
650
|
+
path: "/tas/api/assetmgmt/assets",
|
|
651
|
+
...opts,
|
|
652
|
+
});
|
|
653
|
+
},
|
|
654
|
+
async *paginate({
|
|
655
|
+
fn,
|
|
656
|
+
fnArgs = {},
|
|
657
|
+
maxResults = 600,
|
|
658
|
+
dataField,
|
|
659
|
+
}) {
|
|
660
|
+
let resourcesCount = 0;
|
|
661
|
+
let start = 0;
|
|
662
|
+
|
|
663
|
+
while (true) {
|
|
664
|
+
const response = await fn({
|
|
665
|
+
...fnArgs,
|
|
666
|
+
params: {
|
|
667
|
+
...fnArgs.params,
|
|
668
|
+
start: start + (fnArgs.params?.page_size || 100),
|
|
669
|
+
page_size: (fnArgs.params?.page_size || 100),
|
|
670
|
+
},
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// Extract items from response based on dataField or use response directly
|
|
674
|
+
const items = dataField
|
|
675
|
+
? (response[dataField] || [])
|
|
676
|
+
: (Array.isArray(response)
|
|
677
|
+
? response
|
|
678
|
+
: []);
|
|
679
|
+
|
|
680
|
+
if (!items.length) {
|
|
681
|
+
console.log("No items found");
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
for (const item of items) {
|
|
686
|
+
yield item;
|
|
687
|
+
resourcesCount++;
|
|
688
|
+
|
|
689
|
+
if (maxResults && resourcesCount >= maxResults) {
|
|
690
|
+
console.log("Reached max results");
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
const hasNextPage = response.next || (items.length === 100);
|
|
696
|
+
|
|
697
|
+
if (!hasNextPage) {
|
|
698
|
+
console.log("No more pages found");
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// Auto-increment pagination parameters
|
|
703
|
+
start += (fnArgs.params?.page_size || 100);
|
|
704
|
+
}
|
|
9
705
|
},
|
|
10
706
|
},
|
|
11
|
-
};
|
|
707
|
+
};
|