Skip to content

Conversation

@jcortes
Copy link
Collaborator

@jcortes jcortes commented Oct 23, 2025

WHY

Resolves #18806

Summary by CodeRabbit

Release Notes

  • New Features

    • Create new incidents with customizable details and metadata
    • Retrieve single or multiple incidents with filtering, sorting, and pagination
    • Update existing incidents with status and assignment changes
    • List and retrieve knowledge items with language and query filtering
    • Access knowledge item statuses
  • Chores

    • Updated component version and dependencies

@jcortes jcortes self-assigned this Oct 23, 2025
@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Oct 23, 2025 5:01pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Oct 23, 2025 5:01pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Walkthrough

This 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

Cohort / File(s) Summary
App Infrastructure
components/topdesk/topdesk.app.mjs
Added propDefinitions (incidentId, knowledgeItemId, operatorId, personId) with dynamic async options; introduced 15+ methods including HTTP helpers (getUrl, getAuth, _makeRequest, post, patch), resource fetchers (listIncidents, getIncident, createIncident, updateIncident, listKnowledgeItems, getKnowledgeItem, listKnowledgeItemStatuses, listOperators, listPersons), and a generic async paginator.
Package Configuration
components/topdesk/package.json
Bumped version from 0.0.1 to 0.1.0; added dependency on "@pipedream/platform": "^3.1.0".
Incident Actions
components/topdesk/actions/create-incident/create-incident.mjs, get-incident/get-incident.mjs, update-incident/update-incident.mjs
Three action modules for managing incidents: create accepts callerLookupId, status, briefDescription, request, action, operatorId and nested ID fields; get retrieves incident by ID; update modifies incident with optional fields and ID-wrapped relations. All include metadata, props schemas, annotations, and async run methods.
Incident Listing
components/topdesk/actions/get-incidents/get-incidents.mjs
Action module that retrieves multiple incidents using pagination, supporting maxResults, sort, query, fields filtering, and an all-results flag; aggregates and exports incident count.
Knowledge Item Actions
components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs, get-knowledge-item-statuses/get-knowledge-item-statuses.mjs
Two action modules: get-knowledge-items lists items with maxResults, fields, query, and language filtering via pagination; get-knowledge-item-statuses lists statuses with optional archived filter. Both export summary counts.

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
Loading

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

🐰 Topdesk tales now hop and play,
Incidents dance in Pipedream's way,
Knowledge springs from depths of REST,
Paginate with pagination blessed,
Six new actions, hopping spree—
Integration done by bunny glee! 🥬✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "[Components] Topdesk - new components" is concise, clear, and directly related to the main change in the changeset. It accurately conveys that this PR introduces new Topdesk-related components to the codebase. The title is specific enough to help a teammate understand the primary change without being overly broad or vague. While it doesn't enumerate all endpoints, that level of detail is not expected in a PR title.
Linked Issues Check ✅ Passed The PR fully implements all endpoints requested in linked issue #18806. The Knowledge Base endpoints are covered by get-knowledge-items.mjs and get-knowledge-item-statuses.mjs, and the Incidents endpoints are covered by get-incidents.mjs (GET /incidents), create-incident.mjs (POST /incidents), get-incident.mjs (GET /incidents/id/{id}), and update-incident.mjs (PUT /incidents/id/{id}). The topdesk.app.mjs file provides the core implementation with methods supporting all these actions, including pagination, HTTP request handling, and dynamic propDefinitions for related resources.
Out of Scope Changes Check ✅ Passed All code changes are directly related to implementing the Topdesk integration as specified in issue #18806. The six new action modules directly correspond to the requested endpoints, and the topdesk.app.mjs file provides the necessary core implementation. Additional helper methods like listOperators and listPersons, along with supporting fields like operatorId and personId in the action modules, are reasonable supporting features that enable the incident management actions to function properly (e.g., for operator/person assignment dropdowns). The package.json updates are necessary dependency additions. No unrelated changes have been introduced.
Description Check ✅ Passed The PR description includes the required "## WHY" section from the template and references the linked issue #18806 that resolves this work. While the description is minimal and could be more detailed about the specific components being added, it satisfies the template requirement and provides sufficient context through the issue reference for reviewers to understand the scope of changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch topdesk-new-components

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jcortes jcortes force-pushed the topdesk-new-components branch from 7599331 to 3426e13 Compare October 23, 2025 17:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 differences

If listKnowledgeItemStatuses returns 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 action

This 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 optional

You already accept both string[] and string. Consider extracting this join-to-string logic into a small helper in topdesk.app.mjs to DRY across actions (incidents uses same pattern).

components/topdesk/actions/get-incidents/get-incidents.mjs (1)

67-74: Fields input type vs normalization

Prop fields is typed as string (comma-separated), but runtime also supports string[]. Either keep as-is (tolerant) or switch prop type to string[] with options for a curated list (like knowledge items) for better UX.

components/topdesk/actions/create-incident/create-incident.mjs (2)

20-30: Enforce partial incident requirements

If 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 actions

This 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 UX

Create 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 it

If 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 API

Description 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 too

You 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

📥 Commits

Reviewing files that changed from the base of the PR and between b42b428 and 3426e13.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 fine

Package 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: LGTM

Prop definition and call pattern are consistent. Summary uses response.id, which matches expected payloads.

If propDefinitions.incidentId supports 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 shape

Returning 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 endpoints

The code assumes listKnowledgeItemStatuses returns { results: [...] } (accessing response.results?.length), but other similar list methods like listOperators and listPersons are 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 .results property
components/topdesk/actions/get-knowledge-items/get-knowledge-items.mjs (1)

73-78: No action required — language parameter is correctly implemented

The TOPdesk knowledge-base-v1 API supports filtering knowledge items by language using the language code, and the current implementation correctly passes the language parameter 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 needed

TOPdesk'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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[APP] Topdesk

1 participant