Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
415 changes: 415 additions & 0 deletions components/topdesk/actions/create-incident/create-incident.mjs

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions components/topdesk/actions/get-incident/get-incident.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import app from "../../topdesk.app.mjs";

export default {
key: "topdesk-get-incident",
name: "Get Incident",
description: "Returns an incident by ID. [See the documentation](https://developers.topdesk.com/explorer/?page=incident#/incident/getIncidentById)",
version: "0.0.1",
type: "action",
props: {
app,
incidentId: {
propDefinition: [
app,
"incidentId",
],
},
},
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
idempotentHint: true,
},
async run({ $ }) {
const {
app,
incidentId,
} = this;

const response = await app.getIncident({
$,
incidentId,
});

$.export("$summary", `Successfully retrieved incident with ID \`${response.id}\``);

return response;
},
};
87 changes: 87 additions & 0 deletions components/topdesk/actions/get-incidents/get-incidents.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import app from "../../topdesk.app.mjs";

export default {
key: "topdesk-get-incidents",
name: "Get Incidents",
description: "Returns a list of incidents. [See the documentation](https://developers.topdesk.com/explorer/?page=incident#/incident/getIncidents)",
version: "0.0.1",
type: "action",
props: {
app,
maxResults: {
type: "integer",
label: "Max Results",
description: "Maximum number of incidents to return. Leave empty to return all incidents.",
optional: true,
},
sort: {
type: "string",
label: "Sort",
description: "The sort order of the returned incidents (e.g., `callDate:asc,creationDate:desc`)",
optional: true,
},
query: {
type: "string",
label: "Query",
description: "A FIQL string to select which incidents should be returned. [See the documentation](https://developers.topdesk.com/tutorial.html#query)",
optional: true,
},
fields: {
type: "string",
label: "Fields",
description: "A comma-separated list of which fields should be returned. By default all fields will be returned.",
optional: true,
},
all: {
type: "boolean",
label: "All",
description: "When set to true, will return all incidents including partials and archived. Otherwise only firstLine and secondLine incidents are returned.",
optional: true,
default: false,
},
Comment on lines +35 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Confirm the ‘all’ filter name

Is all a valid query flag for GET /incidents? If the API expects different flags (e.g., archived/partials), adjust accordingly.


🌐 Web query:

TOPdesk incidents GET query parameters: which param(s) include archived and partial incidents? Is there an `all` flag?

💡 Result:

Short answer:

  • To include archived incidents use the archived query parameter (e.g. &archived=true). [1][2]
  • To include partial incidents filter by status (status=partial) or use a FIQL query (the incidents API supports status values like firstLine, secondLine, partial). [2][3]
  • There is no single global "all" flag — omit filters or combine the appropriate parameters/queries (completed, closed, resolved, archived, status / FIQL) to get the set you want. [1][2]

Sources:

  1. TOPdesk docs — Retrieving a list / card selection (incidents endpoint usage).
  2. TOPdeskPS / TOPdesk API examples (Get‑TdIncident shows archived, completed, closed, resolved and status/partial usage).
  3. TOPdesk integrations / FIQL notes (incidents support FIQL and status filtering).

Remove invalid 'all' parameter — TOPdesk API doesn't support it

The TOPdesk incidents API has no single all flag. To include archived incidents, use archived=true. For partial incidents, filter by status=partial or use FIQL queries. Refactor this parameter to use the correct API-supported parameters instead.

🤖 Prompt for AI Agents
In components/topdesk/actions/get-incidents/get-incidents.mjs around lines 35 to
41, remove the invalid "all" parameter and replace it with API-supported
parameters: add an optional boolean "archived" (maps to archived=true when set)
and an optional "status" (enum or string) or a "fiql" string parameter to allow
filtering partial incidents (e.g., status=partial or FIQL queries). Update the
parameter labels/descriptions to explain their mapping to TOPdesk query params
and ensure defaults reflect current behavior (archived default false); wire
these new params into the request builder so they are translated into the
correct query string parameters instead of using a non-existent "all" flag.

},
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
idempotentHint: true,
},
async run({ $ }) {
const {
app,
maxResults,
sort,
query,
fields,
all,
} = this;

const incidents = [];
const paginator = app.paginate({
fn: app.listIncidents,
fnArgs: {
$,
params: {
sort,
query,
fields: Array.isArray(fields) && fields?.length
? fields.join(",")
: typeof fields === "string" && fields.length
? fields
: undefined,
all,
page_size: 100,
},
},
maxResults,
});

for await (const incident of paginator) {
incidents.push(incident);
}

$.export("$summary", `Successfully retrieved \`${incidents.length}\` incident(s)`);

return incidents;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../topdesk.app.mjs";

export default {
key: "topdesk-get-knowledge-item-statuses",
name: "Get Knowledge Item Statuses",
description: "Returns the list of possible Knowledge Item statuses. [See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Searchlists/getStatuses)",
version: "0.0.1",
type: "action",
props: {
app,
archived: {
type: "boolean",
label: "Archived",
description: "Whether to show archived entries. Leave unset for all entries, or specify true/false for only archived or only active entries, respectively.",
optional: true,
},
},
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
idempotentHint: true,
},
async run({ $ }) {
const {
app,
archived,
} = this;

const response = await app.listKnowledgeItemStatuses({
$,
params: {
archived,
},
});

const statusCount = response.results?.length || 0;
$.export("$summary", `Successfully retrieved \`${statusCount}\` knowledge item status(es)`);

return response;
},
};
124 changes: 124 additions & 0 deletions components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import app from "../../topdesk.app.mjs";

export default {
key: "topdesk-get-knowledge-items",
name: "Get Knowledge Items",
description: "Returns a list of Knowledge Items. [See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Knowledge%20Items/getKnowledgeItems)",
version: "0.0.1",
type: "action",
props: {
app,
maxResults: {
type: "integer",
label: "Max Results",
description: "Maximum number of knowledge items to return. Leave empty to return all items.",
optional: true,
},
fields: {
type: "string[]",
label: "Fields",
description: "Additional fields to include in the response. ID and number are always included.",
optional: true,
options: [
"parent",
"visibility",
"urls",
"news",
"manager",
"status",
"standardSolution",
"externalLink",
"language",
"title",
"description",
"content",
"commentsForOperators",
"keywords",
"creator",
"modifier",
"creationDate",
"modificationDate",
"translation.creator",
"translation.modifier",
"translation.creationDate",
"translation.modificationDate",
"availableTranslations",
],
},
query: {
type: "string",
label: "Query",
description: `A FIQL query to filter the response. Use semicolons to combine multiple conditions.

**Available filter fields:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest linking to the associated documentation page instead of listing all the filters here. It would keep the description more concise while also providing the information and guaranteeing it will be up-to-date.

- \`parent.id\`, \`parent.number\`
- \`visibility.sspVisibility\`, \`visibility.sspVisibleFrom\`, \`visibility.sspVisibleUntil\`
- \`visibility.sspVisibilityFilteredOnBranches\`, \`visibility.operatorVisibilityFilteredOnBranches\`
- \`visibility.publicKnowledgeItem\`, \`visibility.branches.id\`, \`visibility.branches.name\`
- \`manager.id\`, \`manager.name\`
- \`status.id\`, \`status.name\`
- \`standardSolution.id\`, \`standardSolution.name\`
- \`externalLink.id\`, \`externalLink.type\`, \`externalLink.date\`
- \`archived\`, \`news\`

**Operators:**
- \`==\` (equals), \`!=\` (not equals)
- \`=gt=\` (greater than), \`=ge=\` (greater than or equal)
- \`=lt=\` (less than), \`=le=\` (less than or equal)
- \`=in=\` (in list), \`=out=\` (not in list)

**Example:** \`parent.id==3fa85f64-5717-4562-b3fc-2c963f66afa6;externalLink.id=in=(oneTool,otherTool)\`

[See the documentation](https://developers.topdesk.com/explorer/?page=knowledge-base#/Knowledge%20Items/getKnowledgeItems) for more information.`,
optional: true,
},
language: {
type: "string",
label: "Language",
description: "The language of the Knowledge Item content, in BCP 47 format (e.g., `en`)",
optional: true,
},
},
annotations: {
readOnlyHint: true,
destructiveHint: false,
openWorldHint: true,
},
async run({ $ }) {
const {
app,
maxResults,
fields,
query,
language,
} = this;

const items = [];
const paginator = app.paginate({
fn: app.listKnowledgeItems,
fnArgs: {
$,
params: {
fields: Array.isArray(fields) && fields?.length
? fields.join(",")
: typeof fields === "string" && fields.length
? fields
: undefined,
query,
language,
page_size: 100,
},
},
maxResults,
dataField: "item",
});

for await (const item of paginator) {
items.push(item);
}

$.export("$summary", `Successfully retrieved \`${items.length}\` knowledge item(s)`);

return items;
},
};
Loading
Loading