-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] Topdesk - new components #18844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jcortes
wants to merge
1
commit into
master
Choose a base branch
from
topdesk-new-components
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
411 changes: 411 additions & 0 deletions
411
components/topdesk/actions/create-incident/create-incident.mjs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
87
components/topdesk/actions/get-incidents/get-incidents.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
| }, | ||
| }, | ||
| 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; | ||
| }, | ||
| }; | ||
42 changes: 42 additions & 0 deletions
42
components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
122 changes: 122 additions & 0 deletions
122
components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| 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:** | ||
| - \`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)\``, | ||
| 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; | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.