-
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughThis PR introduces a Topdesk integration for Pipedream with six new action modules (create/read/update incidents, list/read knowledge items and statuses), comprehensive app-level API methods including pagination support, propDefinitions for dynamic field options, and dependency/version updates to the Topdesk component. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Action
participant App
participant API as Topdesk API
User->>Action: Trigger action with props
Action->>Action: Destructure props & format params
alt Paginated Action (list operations)
Action->>App: app.paginate({ fn, fnArgs, maxResults })
loop For each page
App->>API: HTTP request (GET with page_size, start)
API-->>App: Items batch + pagination context
App-->>Action: Yield items batch
end
else Single Record Action (create/get/update)
Action->>App: app.createIncident/getIncident/updateIncident(data)
App->>API: HTTP POST/GET/PATCH with auth headers
API-->>App: Response (incident data)
App-->>Action: Parsed response
end
Action->>Action: Aggregate results
Action->>Action: $.export("$summary", metadata)
Action-->>User: Return response/items array
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Rationale: This introduces a comprehensive Topdesk integration spanning multiple action modules with distinct but patterned implementations, substantial app-layer infrastructure (15+ methods with pagination logic), API request handling, and propDefinitions for dynamic options. While the patterns are consistent (reducing cognitive load), the breadth of new methods, pagination logic density, and need to verify API contract adherence across create/read/update/list operations warrant careful review. Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7599331 to
3426e13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (10)
components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs (1)
30-41: Harden summary count against response shape differencesIf
listKnowledgeItemStatusesreturns an array (not{ results }), the count will read 0. Make the summary resilient.Apply:
- const statusCount = response.results?.length || 0; + const statusCount = Array.isArray(response) + ? response.length + : (response?.results?.length ?? 0);components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (2)
80-84: Add idempotent hint for read-only actionThis action performs a GET; mark it as idempotent for consistency with other read actions.
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true, + idempotentHint: true, },
100-108: Field normalization is solid; minor cleanup optionalYou already accept both
string[]andstring. Consider extracting this join-to-string logic into a small helper intopdesk.app.mjsto DRY across actions (incidents uses same pattern).components/topdesk/actions/get-incidents/get-incidents.mjs (1)
67-74: Fields input type vs normalizationProp
fieldsis typed asstring(comma-separated), but runtime also supportsstring[]. Either keep as-is (tolerant) or switch prop type tostring[]withoptionsfor a curated list (like knowledge items) for better UX.components/topdesk/actions/create-incident/create-incident.mjs (2)
20-30: Enforce partial incident requirementsIf status “partial” is selected, Topdesk requires a mainIncident reference. Add a simple guard to prevent invalid payloads.
async run({ $ }) { const { app, callerLookupId, status, + // ... mainIncidentId, // ... } = this; + if (status === "partial" && !mainIncidentId) { + throw new Error("Main Incident ID is required when status is 'partial'."); + }Also applies to: 103-108
293-371: Deduplicate id-wrapping logic across actionsThis idFields → reduce pattern is duplicated in update-incident. Extract a small helper to keep both in sync.
+// helpers/id.js (new) +export const wrapIds = (pairs = []) => + pairs.reduce((acc, { value, key }) => value ? { ...acc, [key]: { id: value } } : acc, {});Then:
- ...idFields.reduce((acc, { value, key }) => ({ ...acc, ...value && { [key]: { id: value } } }), {}), + ...wrapIds(idFields),components/topdesk/actions/update-incident/update-incident.mjs (2)
17-22: Use propDefinition for caller lookup for consistent UXCreate action uses the app’s personId selector; this action takes a raw string. Unify to reuse dynamic options and labels.
- callerLookupId: { - type: "string", - label: "Caller Lookup ID", - description: "Lookup value for filling in a registered caller's contact details (UUID). Can only be set by operators.", - optional: true, - }, + callerLookupId: { + propDefinition: [app, "personId"], + label: "Caller Lookup ID", + description: "Lookup value for a registered caller (UUID). Can only be set by operators.", + optional: true, + },
392-429: Allow status update if API supports itIf the API allows updating status, expose a status prop and forward it like the create action does. Keeps parity for users moving an incident to second line, etc.
+ status: { + type: "string", + label: "Status", + optional: true, + options: ["firstLine","secondLine","partial"], + },And include in data.
- data: { + data: { + status, briefDescription,components/topdesk/topdesk.app.mjs (2)
37-61: Knowledge item option: description vs APIDescription says “UUID or number”, but app.getKnowledgeItem uses an ID path parameter. If numbers aren’t valid IDs, adjust description or implement number lookup via query.
139-166: Consider exposing GET helpers tooYou added post/patch convenience methods; adding get(opts) keeps call sites uniform.
post(opts = {}) { return this._makeRequest({ method: "POST", ...opts, }); }, + get(opts = {}) { + return this._makeRequest({ + method: "GET", + ...opts, + }); + }, patch(opts = {}) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (8)
components/topdesk/actions/create-incident/create-incident.mjs(1 hunks)components/topdesk/actions/get-incident/get-incident.mjs(1 hunks)components/topdesk/actions/get-incidents/get-incidents.mjs(1 hunks)components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs(1 hunks)components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs(1 hunks)components/topdesk/actions/update-incident/update-incident.mjs(1 hunks)components/topdesk/package.json(2 hunks)components/topdesk/topdesk.app.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (7)
components/topdesk/actions/get-incident/get-incident.mjs (2)
components/topdesk/actions/create-incident/create-incident.mjs (1)
response(373-405)components/topdesk/actions/update-incident/update-incident.mjs (1)
response(392-429)
components/topdesk/actions/create-incident/create-incident.mjs (1)
components/topdesk/actions/update-incident/update-incident.mjs (2)
idFields(317-390)response(392-429)
components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs (4)
components/topdesk/actions/create-incident/create-incident.mjs (1)
response(373-405)components/topdesk/actions/get-incident/get-incident.mjs (1)
response(30-33)components/topdesk/actions/update-incident/update-incident.mjs (1)
response(392-429)components/topdesk/topdesk.app.mjs (2)
response(42-47)response(209-216)
components/topdesk/actions/update-incident/update-incident.mjs (1)
components/topdesk/actions/create-incident/create-incident.mjs (2)
idFields(294-371)response(373-405)
components/topdesk/actions/get-incidents/get-incidents.mjs (2)
components/topdesk/topdesk.app.mjs (1)
incidents(16-21)components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (1)
paginator(95-112)
components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (2)
components/topdesk/topdesk.app.mjs (2)
items(48-48)items(219-223)components/topdesk/actions/get-incidents/get-incidents.mjs (1)
paginator(60-77)
components/topdesk/topdesk.app.mjs (6)
components/topdesk/actions/get-incidents/get-incidents.mjs (1)
incidents(59-59)components/topdesk/actions/create-incident/create-incident.mjs (1)
response(373-405)components/topdesk/actions/get-incident/get-incident.mjs (1)
response(30-33)components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs (1)
response(30-35)components/topdesk/actions/update-incident/update-incident.mjs (1)
response(392-429)components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (1)
items(94-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/topdesk/package.json (1)
3-17: Version bump and dependency look finePackage version and dependency addition align with new actions using platform helpers. No issues from this diff.
components/topdesk/actions/get-incident/get-incident.mjs (1)
24-37: LGTMProp definition and call pattern are consistent. Summary uses
response.id, which matches expected payloads.If
propDefinitions.incidentIdsupports search / dynamic options, ensure it handles archived incidents as needed.components/topdesk/actions/get-incidents/get-incidents.mjs (1)
83-85: Good summary and return shapeReturning the aggregated array and exporting a count summary matches other actions.
components/topdesk/actions/get-knowledge-item-statuses/get-knowledge-item-statuses.mjs (1)
24-41: Verify response structure consistency across endpointsThe code assumes
listKnowledgeItemStatusesreturns{ results: [...] }(accessingresponse.results?.length), but other similar list methods likelistOperatorsandlistPersonsare treated as direct arrays in their usage. This inconsistency warrants manual verification:
- Check if "Searchlists" endpoints (knowledgeItemStatuses) have a different contract than other list endpoints
- Confirm whether the Topdesk API actually returns
{ results: [...] }for this endpoint, or if it should return an array directly like other list methods- If it returns an array, the code should be simplified to access the array length directly without the
.resultspropertycomponents/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (1)
73-78: No action required — language parameter is correctly implementedThe TOPdesk knowledge-base-v1 API supports filtering knowledge items by language using the language code, and the current implementation correctly passes the
languageparameter as a query parameter. The code will not produce silent no-ops; language filtering will work as intended.components/topdesk/actions/update-incident/update-incident.mjs (1)
6-8: PATCH is supported by TOPdesk API — no changes neededTOPdesk's Incident API supports both PATCH for partial updates and PUT for full replacement. The current implementation correctly uses PATCH at line 162 in
topdesk.app.mjs, called consistently from line 392 in the update-incident action. The documentation reference is also accurate.
WHY
Resolves #18806
Summary by CodeRabbit
Release Notes
New Features
Chores