@pipedream/topdesk 0.0.1 → 0.2.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.
@@ -0,0 +1,415 @@
1
+ import app from "../../topdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "topdesk-create-incident",
5
+ name: "Create Incident",
6
+ description: "Creates a new incident. [See the documentation](https://developers.topdesk.com/explorer/?page=incident#/incident/createIncident)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ app,
11
+ callerLookupId: {
12
+ type: "string",
13
+ label: "Caller Lookup ID",
14
+ description: "Lookup value for filling in a registered caller's contact details (UUID). **Required** - you must specify either this field or provide caller details manually.",
15
+ propDefinition: [
16
+ app,
17
+ "personId",
18
+ ],
19
+ },
20
+ status: {
21
+ type: "string",
22
+ label: "Status",
23
+ description: "Status of the incident. Can only be set by operators.",
24
+ optional: true,
25
+ options: [
26
+ "firstLine",
27
+ "secondLine",
28
+ "partial",
29
+ ],
30
+ },
31
+ briefDescription: {
32
+ propDefinition: [
33
+ app,
34
+ "briefDescription",
35
+ ],
36
+ },
37
+ request: {
38
+ propDefinition: [
39
+ app,
40
+ "request",
41
+ ],
42
+ },
43
+ action: {
44
+ propDefinition: [
45
+ app,
46
+ "action",
47
+ ],
48
+ },
49
+ actionInvisibleForCaller: {
50
+ propDefinition: [
51
+ app,
52
+ "actionInvisibleForCaller",
53
+ ],
54
+ },
55
+ categoryId: {
56
+ propDefinition: [
57
+ app,
58
+ "categoryId",
59
+ ],
60
+ },
61
+ subcategoryId: {
62
+ propDefinition: [
63
+ app,
64
+ "subcategoryId",
65
+ ({ categoryId }) => ({
66
+ categoryId,
67
+ }),
68
+ ],
69
+ },
70
+ callTypeId: {
71
+ propDefinition: [
72
+ app,
73
+ "callTypeId",
74
+ ],
75
+ },
76
+ entryTypeId: {
77
+ propDefinition: [
78
+ app,
79
+ "entryTypeId",
80
+ ],
81
+ },
82
+ externalNumber: {
83
+ propDefinition: [
84
+ app,
85
+ "externalNumber",
86
+ ],
87
+ },
88
+ objectName: {
89
+ propDefinition: [
90
+ app,
91
+ "objectName",
92
+ ],
93
+ },
94
+ locationId: {
95
+ propDefinition: [
96
+ app,
97
+ "locationId",
98
+ ],
99
+ },
100
+ branchId: {
101
+ propDefinition: [
102
+ app,
103
+ "branchId",
104
+ ],
105
+ },
106
+ mainIncidentId: {
107
+ type: "string",
108
+ label: "Main Incident ID",
109
+ description: "Main incident UUID, required for creating a partial incident. Can only be set by operators.",
110
+ optional: true,
111
+ },
112
+ impact: {
113
+ propDefinition: [
114
+ app,
115
+ "impactId",
116
+ ],
117
+ },
118
+ urgency: {
119
+ propDefinition: [
120
+ app,
121
+ "urgencyId",
122
+ ],
123
+ },
124
+ priority: {
125
+ propDefinition: [
126
+ app,
127
+ "priorityId",
128
+ ],
129
+ },
130
+ duration: {
131
+ propDefinition: [
132
+ app,
133
+ "durationId",
134
+ ],
135
+ },
136
+ targetDate: {
137
+ propDefinition: [
138
+ app,
139
+ "targetDate",
140
+ ],
141
+ },
142
+ slaId: {
143
+ propDefinition: [
144
+ app,
145
+ "slaId",
146
+ ],
147
+ },
148
+ onHold: {
149
+ propDefinition: [
150
+ app,
151
+ "onHold",
152
+ ],
153
+ },
154
+ operatorId: {
155
+ propDefinition: [
156
+ app,
157
+ "operatorId",
158
+ ],
159
+ label: "Operator",
160
+ description: "The operator assigned to the incident. Can only be set by operators.",
161
+ optional: true,
162
+ },
163
+ operatorGroupId: {
164
+ propDefinition: [
165
+ app,
166
+ "operatorGroupId",
167
+ ],
168
+ },
169
+ supplierId: {
170
+ propDefinition: [
171
+ app,
172
+ "supplierId",
173
+ ],
174
+ },
175
+ processingStatusId: {
176
+ propDefinition: [
177
+ app,
178
+ "processingStatusId",
179
+ ],
180
+ },
181
+ responded: {
182
+ propDefinition: [
183
+ app,
184
+ "responded",
185
+ ],
186
+ },
187
+ responseDate: {
188
+ propDefinition: [
189
+ app,
190
+ "responseDate",
191
+ ],
192
+ },
193
+ completed: {
194
+ propDefinition: [
195
+ app,
196
+ "completed",
197
+ ],
198
+ },
199
+ completedDate: {
200
+ propDefinition: [
201
+ app,
202
+ "completedDate",
203
+ ],
204
+ },
205
+ closed: {
206
+ propDefinition: [
207
+ app,
208
+ "closed",
209
+ ],
210
+ },
211
+ closedDate: {
212
+ propDefinition: [
213
+ app,
214
+ "closedDate",
215
+ ],
216
+ },
217
+ closureCodeId: {
218
+ propDefinition: [
219
+ app,
220
+ "closureCodeId",
221
+ ],
222
+ },
223
+ majorCall: {
224
+ propDefinition: [
225
+ app,
226
+ "majorCall",
227
+ ],
228
+ },
229
+ publishToSsd: {
230
+ propDefinition: [
231
+ app,
232
+ "publishToSsd",
233
+ ],
234
+ },
235
+ optionalFields1: {
236
+ propDefinition: [
237
+ app,
238
+ "optionalFields1",
239
+ ],
240
+ },
241
+ optionalFields2: {
242
+ propDefinition: [
243
+ app,
244
+ "optionalFields2",
245
+ ],
246
+ },
247
+ },
248
+ annotations: {
249
+ readOnlyHint: false,
250
+ destructiveHint: false,
251
+ openWorldHint: true,
252
+ idempotentHint: false,
253
+ },
254
+ async run({ $ }) {
255
+ const {
256
+ app,
257
+ callerLookupId,
258
+ status,
259
+ briefDescription,
260
+ request,
261
+ action,
262
+ actionInvisibleForCaller,
263
+ categoryId,
264
+ subcategoryId,
265
+ callTypeId,
266
+ entryTypeId,
267
+ externalNumber,
268
+ objectName,
269
+ locationId,
270
+ branchId,
271
+ mainIncidentId,
272
+ impact,
273
+ urgency,
274
+ priority,
275
+ duration,
276
+ targetDate,
277
+ slaId,
278
+ onHold,
279
+ operatorId,
280
+ operatorGroupId,
281
+ supplierId,
282
+ processingStatusId,
283
+ responded,
284
+ responseDate,
285
+ completed,
286
+ completedDate,
287
+ closed,
288
+ closedDate,
289
+ closureCodeId,
290
+ majorCall,
291
+ publishToSsd,
292
+ optionalFields1,
293
+ optionalFields2,
294
+ } = this;
295
+
296
+ // Fields that take { id: value } structure
297
+ const idFields = [
298
+ {
299
+ value: callerLookupId,
300
+ key: "callerLookup",
301
+ },
302
+ {
303
+ value: categoryId,
304
+ key: "category",
305
+ },
306
+ {
307
+ value: subcategoryId,
308
+ key: "subcategory",
309
+ },
310
+ {
311
+ value: callTypeId,
312
+ key: "callType",
313
+ },
314
+ {
315
+ value: entryTypeId,
316
+ key: "entryType",
317
+ },
318
+ {
319
+ value: locationId,
320
+ key: "location",
321
+ },
322
+ {
323
+ value: branchId,
324
+ key: "branch",
325
+ },
326
+ {
327
+ value: mainIncidentId,
328
+ key: "mainIncident",
329
+ },
330
+ {
331
+ value: impact,
332
+ key: "impact",
333
+ },
334
+ {
335
+ value: urgency,
336
+ key: "urgency",
337
+ },
338
+ {
339
+ value: priority,
340
+ key: "priority",
341
+ },
342
+ {
343
+ value: duration,
344
+ key: "duration",
345
+ },
346
+ {
347
+ value: slaId,
348
+ key: "sla",
349
+ },
350
+ {
351
+ value: operatorId,
352
+ key: "operator",
353
+ },
354
+ {
355
+ value: operatorGroupId,
356
+ key: "operatorGroup",
357
+ },
358
+ {
359
+ value: supplierId,
360
+ key: "supplier",
361
+ },
362
+ {
363
+ value: processingStatusId,
364
+ key: "processingStatus",
365
+ },
366
+ {
367
+ value: closureCodeId,
368
+ key: "closureCode",
369
+ },
370
+ ];
371
+
372
+ const response = await app.createIncident({
373
+ $,
374
+ data: {
375
+ status,
376
+ briefDescription,
377
+ request,
378
+ action,
379
+ actionInvisibleForCaller,
380
+ externalNumber,
381
+ targetDate,
382
+ onHold,
383
+ responded,
384
+ responseDate,
385
+ completed,
386
+ completedDate,
387
+ closed,
388
+ closedDate,
389
+ majorCall,
390
+ publishToSsd,
391
+ optionalFields1,
392
+ optionalFields2,
393
+ ...(objectName && {
394
+ object: {
395
+ name: objectName,
396
+ },
397
+ }),
398
+ ...idFields.reduce((acc, {
399
+ value, key,
400
+ }) => ({
401
+ ...acc,
402
+ ...value && {
403
+ [key]: {
404
+ id: value,
405
+ },
406
+ },
407
+ }), {}),
408
+ },
409
+ });
410
+
411
+ $.export("$summary", `Successfully created incident with ID \`${response.id}\``);
412
+
413
+ return response;
414
+ },
415
+ };
@@ -0,0 +1,39 @@
1
+ import app from "../../topdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "topdesk-get-incident",
5
+ name: "Get Incident",
6
+ description: "Returns an incident by ID. [See the documentation](https://developers.topdesk.com/explorer/?page=incident#/incident/getIncidentById)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ app,
11
+ incidentId: {
12
+ propDefinition: [
13
+ app,
14
+ "incidentId",
15
+ ],
16
+ },
17
+ },
18
+ annotations: {
19
+ readOnlyHint: true,
20
+ destructiveHint: false,
21
+ openWorldHint: true,
22
+ idempotentHint: true,
23
+ },
24
+ async run({ $ }) {
25
+ const {
26
+ app,
27
+ incidentId,
28
+ } = this;
29
+
30
+ const response = await app.getIncident({
31
+ $,
32
+ incidentId,
33
+ });
34
+
35
+ $.export("$summary", `Successfully retrieved incident with ID \`${response.id}\``);
36
+
37
+ return response;
38
+ },
39
+ };
@@ -0,0 +1,87 @@
1
+ import app from "../../topdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "topdesk-get-incidents",
5
+ name: "Get Incidents",
6
+ description: "Returns a list of incidents. [See the documentation](https://developers.topdesk.com/explorer/?page=incident#/incident/getIncidents)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ app,
11
+ maxResults: {
12
+ type: "integer",
13
+ label: "Max Results",
14
+ description: "Maximum number of incidents to return. Leave empty to return all incidents.",
15
+ optional: true,
16
+ },
17
+ sort: {
18
+ type: "string",
19
+ label: "Sort",
20
+ description: "The sort order of the returned incidents (e.g., `callDate:asc,creationDate:desc`)",
21
+ optional: true,
22
+ },
23
+ query: {
24
+ type: "string",
25
+ label: "Query",
26
+ description: "A FIQL string to select which incidents should be returned. [See the documentation](https://developers.topdesk.com/tutorial.html#query)",
27
+ optional: true,
28
+ },
29
+ fields: {
30
+ type: "string",
31
+ label: "Fields",
32
+ description: "A comma-separated list of which fields should be returned. By default all fields will be returned.",
33
+ optional: true,
34
+ },
35
+ all: {
36
+ type: "boolean",
37
+ label: "All",
38
+ description: "When set to true, will return all incidents including partials and archived. Otherwise only firstLine and secondLine incidents are returned.",
39
+ optional: true,
40
+ default: false,
41
+ },
42
+ },
43
+ annotations: {
44
+ readOnlyHint: true,
45
+ destructiveHint: false,
46
+ openWorldHint: true,
47
+ idempotentHint: true,
48
+ },
49
+ async run({ $ }) {
50
+ const {
51
+ app,
52
+ maxResults,
53
+ sort,
54
+ query,
55
+ fields,
56
+ all,
57
+ } = this;
58
+
59
+ const incidents = [];
60
+ const paginator = app.paginate({
61
+ fn: app.listIncidents,
62
+ fnArgs: {
63
+ $,
64
+ params: {
65
+ sort,
66
+ query,
67
+ fields: Array.isArray(fields) && fields?.length
68
+ ? fields.join(",")
69
+ : typeof fields === "string" && fields.length
70
+ ? fields
71
+ : undefined,
72
+ all,
73
+ page_size: 100,
74
+ },
75
+ },
76
+ maxResults,
77
+ });
78
+
79
+ for await (const incident of paginator) {
80
+ incidents.push(incident);
81
+ }
82
+
83
+ $.export("$summary", `Successfully retrieved \`${incidents.length}\` incident(s)`);
84
+
85
+ return incidents;
86
+ },
87
+ };
@@ -0,0 +1,42 @@
1
+ import app from "../../topdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "topdesk-get-knowledge-item-statuses",
5
+ name: "Get Knowledge Item Statuses",
6
+ description: "Returns the list of possible Knowledge Item statuses. [See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Searchlists/getStatuses)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ app,
11
+ archived: {
12
+ type: "boolean",
13
+ label: "Archived",
14
+ description: "Whether to show archived entries. Leave unset for all entries, or specify true/false for only archived or only active entries, respectively.",
15
+ optional: true,
16
+ },
17
+ },
18
+ annotations: {
19
+ readOnlyHint: true,
20
+ destructiveHint: false,
21
+ openWorldHint: true,
22
+ idempotentHint: true,
23
+ },
24
+ async run({ $ }) {
25
+ const {
26
+ app,
27
+ archived,
28
+ } = this;
29
+
30
+ const response = await app.listKnowledgeItemStatuses({
31
+ $,
32
+ params: {
33
+ archived,
34
+ },
35
+ });
36
+
37
+ const statusCount = response.results?.length || 0;
38
+ $.export("$summary", `Successfully retrieved \`${statusCount}\` knowledge item status(es)`);
39
+
40
+ return response;
41
+ },
42
+ };
@@ -0,0 +1,124 @@
1
+ import app from "../../topdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "topdesk-get-knowledge-items",
5
+ name: "Get Knowledge Items",
6
+ description: "Returns a list of Knowledge Items. [See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Knowledge%20Items/getKnowledgeItems)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ app,
11
+ maxResults: {
12
+ type: "integer",
13
+ label: "Max Results",
14
+ description: "Maximum number of knowledge items to return. Leave empty to return all items.",
15
+ optional: true,
16
+ },
17
+ fields: {
18
+ type: "string[]",
19
+ label: "Fields",
20
+ description: "Additional fields to include in the response. ID and number are always included.",
21
+ optional: true,
22
+ options: [
23
+ "parent",
24
+ "visibility",
25
+ "urls",
26
+ "news",
27
+ "manager",
28
+ "status",
29
+ "standardSolution",
30
+ "externalLink",
31
+ "language",
32
+ "title",
33
+ "description",
34
+ "content",
35
+ "commentsForOperators",
36
+ "keywords",
37
+ "creator",
38
+ "modifier",
39
+ "creationDate",
40
+ "modificationDate",
41
+ "translation.creator",
42
+ "translation.modifier",
43
+ "translation.creationDate",
44
+ "translation.modificationDate",
45
+ "availableTranslations",
46
+ ],
47
+ },
48
+ query: {
49
+ type: "string",
50
+ label: "Query",
51
+ description: `A FIQL query to filter the response. Use semicolons to combine multiple conditions.
52
+
53
+ **Available filter fields:**
54
+ - \`parent.id\`, \`parent.number\`
55
+ - \`visibility.sspVisibility\`, \`visibility.sspVisibleFrom\`, \`visibility.sspVisibleUntil\`
56
+ - \`visibility.sspVisibilityFilteredOnBranches\`, \`visibility.operatorVisibilityFilteredOnBranches\`
57
+ - \`visibility.publicKnowledgeItem\`, \`visibility.branches.id\`, \`visibility.branches.name\`
58
+ - \`manager.id\`, \`manager.name\`
59
+ - \`status.id\`, \`status.name\`
60
+ - \`standardSolution.id\`, \`standardSolution.name\`
61
+ - \`externalLink.id\`, \`externalLink.type\`, \`externalLink.date\`
62
+ - \`archived\`, \`news\`
63
+
64
+ **Operators:**
65
+ - \`==\` (equals), \`!=\` (not equals)
66
+ - \`=gt=\` (greater than), \`=ge=\` (greater than or equal)
67
+ - \`=lt=\` (less than), \`=le=\` (less than or equal)
68
+ - \`=in=\` (in list), \`=out=\` (not in list)
69
+
70
+ **Example:** \`parent.id==3fa85f64-5717-4562-b3fc-2c963f66afa6;externalLink.id=in=(oneTool,otherTool)\`
71
+
72
+ [See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Knowledge%20Items/getKnowledgeItems) for more information.`,
73
+ optional: true,
74
+ },
75
+ language: {
76
+ type: "string",
77
+ label: "Language",
78
+ description: "The language of the Knowledge Item content, in BCP 47 format (e.g., `en`)",
79
+ optional: true,
80
+ },
81
+ },
82
+ annotations: {
83
+ readOnlyHint: true,
84
+ destructiveHint: false,
85
+ openWorldHint: true,
86
+ },
87
+ async run({ $ }) {
88
+ const {
89
+ app,
90
+ maxResults,
91
+ fields,
92
+ query,
93
+ language,
94
+ } = this;
95
+
96
+ const items = [];
97
+ const paginator = app.paginate({
98
+ fn: app.listKnowledgeItems,
99
+ fnArgs: {
100
+ $,
101
+ params: {
102
+ fields: Array.isArray(fields) && fields?.length
103
+ ? fields.join(",")
104
+ : typeof fields === "string" && fields.length
105
+ ? fields
106
+ : undefined,
107
+ query,
108
+ language,
109
+ page_size: 100,
110
+ },
111
+ },
112
+ maxResults,
113
+ dataField: "item",
114
+ });
115
+
116
+ for await (const item of paginator) {
117
+ items.push(item);
118
+ }
119
+
120
+ $.export("$summary", `Successfully retrieved \`${items.length}\` knowledge item(s)`);
121
+
122
+ return items;
123
+ },
124
+ };