Skip to content

Commit b0342a0

Browse files
committed
[Components] Topdesk - new components
1 parent 36a8917 commit b0342a0

File tree

9 files changed

+1859
-7
lines changed

9 files changed

+1859
-7
lines changed

components/topdesk/actions/create-incident/create-incident.mjs

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.1",
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+
};
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.1",
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+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.1",
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+
};
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.1",
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+
};

0 commit comments

Comments
 (0)