Skip to content

ConnectWise actions improvements #16091

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 8 commits into from
Apr 2, 2025
Merged

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Mar 31, 2025

Closes #16016

Summary by CodeRabbit

  • New Features
    • Enhanced the contact creation process with the ability to designate a primary contact and include extra parameters.
    • Upgraded ticket creation to allow the addition of one or more notes alongside each new ticket.
  • Chores
    • Updated the component's version for overall improvements.

Copy link

vercel bot commented Mar 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 2, 2025 2:00am
pipedream-docs ⬜️ Ignored (Inspect) Apr 2, 2025 2:00am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 2, 2025 2:00am

Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Walkthrough

This pull request updates several actions within the ConnectWise PSA component. The create-contact action now supports an optional primary contact flag (isDefault) and additional parameters (additionalOptions) via JSON parsing, and its version is updated from 0.0.1 to 0.1.0. The create-ticket action introduces an optional note property and a new method to add notes after ticket creation. Additionally, two JSON parsing utility functions are added, and the package version is incremented from 0.1.1 to 0.2.0.

Changes

File(s) Change Summary
components/connectwise_psa/actions/create-contact/create-contact.mjs Updated version from "0.0.1" to "0.1.0". Added isDefault (boolean) and additionalOptions (object) properties to props. Updated the run method to incorporate these new properties using parseObjectEntries.
components/connectwise_psa/actions/create-ticket/create-ticket.mjs Added an optional note property (array of strings) to props and a new createTicketNote method to send a POST request for ticket notes. Modified the run logic to check for notes, iterate as needed, and include note responses in the final output.
components/connectwise_psa/common/utils.mjs Introduced optionalParseAsJSON and exported parseObjectEntries functions for JSON parsing of object entries with error handling.
components/connectwise_psa/package.json Updated the package version from "0.1.1" to "0.2.0".

Assessment against linked issues

Objective Addressed Explanation
Enhance Create Contact Workflow with extra optional fields (#16016)
Add ticket note creation capability in Create Ticket Workflow (#16016)

Possibly related PRs

  • PipedreamHQ/pipedream#14453: Introduces an additionalOptions property in the company action, which is conceptually similar to the changes in create-contact.
  • PipedreamHQ/pipedream#12182: Modifies create-contact.mjs to introduce the action for creating a contact, related by the context of contact creation.
  • PipedreamHQ/pipedream#14427: Introduces a new contact creation module in a different context, indicating related functionality.

Suggested labels

action

Suggested reviewers

  • michelle0927

Poem

I'm a rabbit with a hop in my stride,
Code carrots fresh and changes wide.
New flags and notes now dance in line,
JSON magic makes the code shine!
With every leap, I cheer in delight—
Happy hops for our update tonight!
🐰✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/connectwise_psa/actions/create-contact/create-contact.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 862879a and 3fc57a3.

📒 Files selected for processing (1)
  • components/connectwise_psa/actions/create-contact/create-contact.mjs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/connectwise_psa/actions/create-contact/create-contact.mjs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🧹 Nitpick comments (1)
components/connectwise_psa/common/utils.mjs (1)

9-22: Consider adding null/undefined check.

The function handles string and object inputs well, but might throw an error if value is null or undefined when calling Object.entries(obj).

 export function parseObjectEntries(value) {
+  if (!value) return {};
   const obj = typeof value === "string"
     ? JSON.parse(value)
     : value;
   return Object.fromEntries(
     Object.entries(obj).map(([
       key,
       value,
     ]) => [
       key,
       optionalParseAsJSON(value),
     ]),
   );
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 554fa94 and a58e065.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • components/connectwise_psa/actions/create-contact/create-contact.mjs (3 hunks)
  • components/connectwise_psa/actions/create-ticket/create-ticket.mjs (3 hunks)
  • components/connectwise_psa/common/utils.mjs (1 hunks)
  • components/connectwise_psa/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (11)
components/connectwise_psa/package.json (1)

3-3: Version bump is appropriate.

The version increment from 0.1.1 to 0.1.2 properly reflects the feature additions in this PR, following semantic versioning principles where the patch version is increased for backward-compatible features.

components/connectwise_psa/common/utils.mjs (1)

1-7: Good utility function implementation.

This helper function safely attempts to parse JSON and gracefully falls back to the original value if parsing fails, preventing runtime errors.

components/connectwise_psa/actions/create-contact/create-contact.mjs (4)

8-8: Version update is appropriate.

The version bump from 0.0.1 to 0.1.0 correctly reflects the addition of new features to this action.


95-100: Good addition of primary contact flag.

Adding the isDefault property enhances the functionality by allowing users to specify whether the contact is the primary contact for the company.


101-105: Feature enhancement with additionalOptions.

This new property provides excellent flexibility by allowing users to include additional parameters in the request beyond the predefined props.


160-161: Good implementation of new properties.

The code correctly implements the new isDefault property and properly handles the additionalOptions using the parseObjectEntries utility function.

components/connectwise_psa/actions/create-ticket/create-ticket.mjs (5)

7-7: Version update is appropriate.

The version update to 0.1.0 properly reflects the addition of note functionality to the ticket creation action.


34-39: Good addition of note property.

Adding the ability to include notes during ticket creation enhances the utility of this action. The property is well-defined with appropriate types and description.


41-50: Well-implemented API method.

The createTicketNote method is properly implemented to make API requests for creating notes associated with a ticket.


72-92: Robust note creation implementation.

The implementation correctly handles:

  1. Checking if notes exist before processing
  2. Converting single notes to array format for consistent handling
  3. Creating each note via API calls
  4. Collecting responses for return value

The use of optional chaining (note?.length) is a good practice for handling potentially undefined values.


93-104: Thoughtful response handling.

The code elegantly:

  1. Provides a clear summary message that adapts based on whether notes were added
  2. Structures the return object to include both the ticket and notes information
  3. Only includes the notes property when notes were actually created

This approach maintains backward compatibility while enhancing the response with new information.

jcortes
jcortes previously approved these changes Apr 1, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @GTFalcao lgtm! Ready for QA!

@GTFalcao
Copy link
Collaborator Author

GTFalcao commented Apr 2, 2025

/approve

@jcortes jcortes merged commit 5654d23 into master Apr 2, 2025
11 checks passed
@jcortes jcortes deleted the 16016-connectwise-improvement branch April 2, 2025 15:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConnectWise Workflow Enhancement
3 participants