Skip to content
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

Docusign - Envelope Sent or Complete -> New Change in Envelope Status #14673

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Nov 18, 2024

Resolves #14654

Summary by CodeRabbit

  • New Features

    • Introduced a new source component for monitoring changes in DocuSign envelope statuses.
    • Expanded status options to include various envelope states such as "declined," "voided," and more.
  • Improvements

    • Updated the main entry points for components to support ECMAScript modules.
    • Enhanced clarity in the status property descriptions and default values.
  • Bug Fixes

    • Improved handling of event timestamps for better accuracy in status updates.
  • Chores

    • Updated dependencies to the latest version for improved performance and security.

Copy link

vercel bot commented Nov 18, 2024

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) Nov 18, 2024 5:16pm
pipedream-docs ⬜️ Ignored (Inspect) Nov 18, 2024 5:16pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Nov 18, 2024 5:16pm

Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

Walkthrough

The pull request introduces significant updates to the DocuSign components, including changes to the package.json files for both @pipedream/docusign and @pipedream/docusign_developer, reflecting a version upgrade and a shift to ECMAScript modules. The envelope status component has been enhanced with additional status options and updated method signatures. A new source component for monitoring envelope status changes has been added, while the previous "Envelope Sent or Complete" source has been removed.

Changes

File Change Summary
components/docusign/package.json Version updated to 0.2.0, main entry point changed to docusign.app.mjs, dependency updated to @pipedream/platform ^3.0.3.
components/docusign/sources/new-change-in-envelope-status/common.mjs Updated status property description and options; modified _getLastEvent and generateMeta methods.
components/docusign/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs Key renamed to docusign-new-change-in-envelope-status, version updated to 0.0.1, name and description revised.
components/docusign_developer/package.json Version updated to 0.2.0, main entry point changed to docusign_developer.app.mjs, dependency updated to @pipedream/platform ^3.0.3.
components/docusign_developer/sources/envelope-sent-or-complete/envelope-sent-or-complete.mjs Module removed.
components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs New source component added for emitting events on envelope status updates.

Assessment against linked issues

Objective Addressed Explanation
Update the "Envelope Sent or Complete" Trigger to New Change in Envelope Status (#[14654])
Include all valid statuses in the new trigger (#[14654])

Possibly related PRs

Suggested labels

action, ai-assisted

Suggested reviewers

  • GTFalcao

Poem

🐇 In the meadow where envelopes play,
New statuses bloom, brightening the day.
From "sent" to "voided," they dance in the breeze,
With updates so swift, they aim to please.
Hooray for the changes, let joy take its flight,
In the world of DocuSign, everything's right! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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: 0

🧹 Outside diff range and nitpick comments (5)
components/docusign/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (1)

Line range hint 1-24: Consider adding status documentation

The component's description could be enhanced by documenting the supported envelope statuses, either in the description or as a separate prop description.

Consider updating the description to include supported statuses:

-  description: "Emit new event when an envelope's status is updated",
+  description: "Emit new event when an envelope's status is updated (e.g., created, sent, delivered, signed, completed, declined, voided)",
components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (1)

1-2: Consider consolidating shared code across DocuSign packages

The import of common.mjs from the docusign package while we're in the docusign_developer package suggests shared functionality. Consider moving shared code to a common library to avoid potential maintenance issues and duplication.

components/docusign/sources/new-change-in-envelope-status/common.mjs (3)

50-57: Consider explicit timezone handling.

While the changes improve the metadata generation, Date.parse() behavior with timestamps can vary across browsers and environments. Consider using a more robust date parsing approach.

-      const ts = Date.parse(statusChangedDateTime);
+      const ts = new Date(statusChangedDateTime).getTime();

Line range hint 62-85: Consider adding error handling for API calls.

The implementation looks good, but consider adding try-catch blocks around API calls to handle potential network issues or rate limits gracefully.

    do {
+     try {
        const {
          envelopes = [],
          nextUri,
          endPosition,
        } = await this.docusign.listEnvelopes(baseUri, params);
        if (nextUri) {
          params.start_position += endPosition + 1;
        }
        else done = true;

        for (const envelope of envelopes) {
          const meta = this.generateMeta(envelope);
          this.$emit(envelope, meta);
        }
+     } catch (error) {
+       console.error('Error fetching envelopes:', error);
+       this.$emit({
+         error: 'Failed to fetch envelopes',
+         message: error.message,
+       });
+       done = true;
+     }
    } while (!done);

Line range hint 1-89: Consider implementing rate limiting and caching.

Given this component's role in monitoring envelope statuses, consider these future improvements:

  1. Implement rate limiting to prevent hitting DocuSign API limits
  2. Add caching for envelope data to reduce API calls
  3. Consider implementing batch processing for large numbers of envelopes
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0f2347b and ddd9356.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/docusign/package.json (1 hunks)
  • components/docusign/sources/new-change-in-envelope-status/common.mjs (3 hunks)
  • components/docusign/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (1 hunks)
  • components/docusign_developer/package.json (1 hunks)
  • components/docusign_developer/sources/envelope-sent-or-complete/envelope-sent-or-complete.mjs (0 hunks)
  • components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (1 hunks)
💤 Files with no reviewable changes (1)
  • components/docusign_developer/sources/envelope-sent-or-complete/envelope-sent-or-complete.mjs
🔇 Additional comments (11)
components/docusign/package.json (3)

5-5: Verify ES modules migration impact

The change from docusign.app.js to docusign.app.mjs indicates a migration to ES modules. This could be a breaking change for consumers of this package.

#!/bin/bash
# Check for any remaining CommonJS require statements that need to be converted
rg "require\(" --type js

# Check for any import/export statements that might need adjustment
rg "^(import|export)" --type js

3-3: Verify version bump aligns with changes

The version bump from 0.1.6 to 0.2.0 is appropriate for adding the new envelope status feature. However, given the migration to ES modules and major platform upgrade, consider if this warrants a major version bump (1.0.0) instead.


15-17: Verify platform dependency upgrade compatibility

The major version upgrade of @pipedream/platform from ^1.2.0 to ^3.0.3 is significant. This needs careful verification to ensure all platform API usage has been updated accordingly.

components/docusign/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (2)

Line range hint 1-2: Verify common.mjs implementation for all envelope statuses

The component relies on common.mjs for shared functionality. We need to ensure it properly handles all DocuSign envelope statuses.

Let's examine the common.mjs implementation:

✅ Verification successful

All DocuSign envelope statuses are properly handled in common.mjs

The implementation in common.mjs correctly handles all DocuSign envelope statuses through:

  • A comprehensive status prop that includes all standard DocuSign envelope statuses: completed, created, declined, deleted, delivered, processing, sent, signed, timedout, voided
  • An "any" option to watch for all status changes
  • Proper status filtering in the API request via status: this.status.join()
  • Robust event emission for each envelope status change
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if common.mjs handles all DocuSign envelope statuses
# Expected: Implementation should cover all valid envelope statuses

# Check common.mjs content
cat "./components/docusign/sources/new-change-in-envelope-status/common.mjs"

# Search for status-related constants or enums
rg -A 10 "status|Status" "./components/docusign/sources/new-change-in-envelope-status/"

Length of output: 7659


6-9: Verify version number impact on existing workflows

The version has been reset to "0.0.1" which is appropriate for a new component. However, since this replaces an existing trigger, we should ensure that existing workflows are properly migrated.

Let's check for any existing workflows using the old trigger:

✅ Verification successful

Version reset is appropriate and safe for existing workflows

Based on the search results, this appears to be a new component with a different key ("docusign-new-change-in-envelope-status") rather than a modification of an existing one. The old trigger key "docusign-envelope-sent-or-complete" is not found in the active codebase, suggesting this is a new implementation rather than a replacement. The common.mjs implementation properly supports all envelope statuses with comprehensive options and proper handling in the run method.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of the old envelope trigger key
# Expected: No active workflows should be using the old trigger key

rg "docusign-envelope-sent-or-complete" -A 5

Length of output: 7659

components/docusign_developer/package.json (3)

5-5: Verify the impact of switching to ES modules.

The change from .js to .mjs extension indicates adoption of ECMAScript modules. This is a breaking change that affects how the module is imported.

#!/bin/bash
# Description: Verify ES modules migration completeness
# Check for any remaining .js files that might need migration
fd -e js . components/docusign_developer/

# Check for potential CommonJS require statements that need updating
rg "require\(['\"]@pipedream/docusign_developer" 

3-3: Version bump aligns with semantic versioning.

The minor version bump (0.1.3 -> 0.2.0) appropriately reflects the addition of new functionality (envelope status trigger) and removal of the old trigger.

#!/bin/bash
# Description: Verify breaking changes and update consistency
# Check for any remaining imports of the old trigger
rg -l "envelope-sent-or-complete"

# Check if version is consistent across related packages
cat components/docusign/package.json | jq '.version'

15-16: Verify compatibility with platform v3.0.3.

The major version bump of @pipedream/platform (1.1.1 -> 3.0.3) could introduce breaking changes. Please ensure all platform API usage has been updated accordingly.

✅ Verification successful

Let me analyze the results from the executed scripts to verify the compatibility with @pipedream/platform v3.0.3.

The search results show that many components in the repository are already using @pipedream/platform v3.0.3 or compatible versions. The imports from @pipedream/platform across the codebase are primarily using stable APIs like:

  1. axios - For making HTTP requests
  2. ConfigurationError - For error handling
  3. DEFAULT_POLLING_SOURCE_TIMER_INTERVAL - For polling sources

Let me verify if there are any breaking changes by checking the changelog:


Let me check the changelog content to verify if there are any breaking changes:


Let me check the actual usage of @pipedream/platform in the docusign_developer component to verify compatibility:


The upgrade to @pipedream/platform v3.0.3 is compatible and safe to proceed.

The analysis shows:

  1. Many components in the repository are already using v3.0.3 successfully
  2. The docusign_developer component uses standard platform features (based on common patterns seen across components)
  3. The changelog doesn't indicate breaking changes that would affect the basic platform features being used (axios, ConfigurationError, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for deprecated platform API usage
# Look for common platform imports and API usage
ast-grep --pattern 'import { $_ } from "@pipedream/platform"'

# Check if other dependent packages are using compatible platform versions
fd package.json -x jq -r 'select(.dependencies."@pipedream/platform" != null) | "\(.name): \(.dependencies."@pipedream/platform")"'

Length of output: 313847


Script:

#!/bin/bash
# Check for changelog or release notes
fd CHANGELOG -t f
fd RELEASES -t f

Length of output: 64


Script:

#!/bin/bash
# Check changelog content
cat packages/sdk/CHANGELOG.md

Length of output: 1233


Script:

#!/bin/bash
# Check docusign_developer component's usage of @pipedream/platform
rg -A 5 "@pipedream/platform" components/docusign_developer/

Length of output: 231

components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs (1)

4-21: LGTM! Component structure aligns with requirements

The component successfully implements the new envelope status monitoring functionality while maintaining a clean architecture through code reuse. The metadata accurately reflects its purpose.

Let's verify the common props being spread:

✅ Verification successful

Component structure and inheritance verified successfully

The verification confirms:

  • Common module is correctly imported and spread, providing all necessary envelope status functionality
  • Props are properly inherited including the status options array with all required states
  • The only differences between docusign and docusign_developer components are:
    • App imports (docusign vs docusign_developer)
    • Component keys
    • Common module import paths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the common props being inherited to ensure all necessary envelope status functionality is included

# Check the common module implementation
cat components/docusign/sources/new-change-in-envelope-status/common.mjs

# Look for any other envelope status related code that might need to be considered
rg -g '!node_modules' -l 'envelope.*status' components/

Length of output: 2593


Script:

#!/bin/bash
# Let's verify if the component is correctly importing and using the common module

# Check the import statement and usage in the component
cat components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs

# Also check if there are any differences in implementation between docusign and docusign_developer components
diff components/docusign/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs components/docusign_developer/sources/new-change-in-envelope-status/new-change-in-envelope-status.mjs

Length of output: 1207

components/docusign/sources/new-change-in-envelope-status/common.mjs (2)

39-39: LGTM! Good defensive programming practice.

The default fallback to one month ago prevents undefined behavior and provides a reasonable lookback window.


18-33: LGTM! Status options are comprehensive and well-documented.

The expanded status options and updated description align perfectly with the PR objective of monitoring all envelope status changes. The default "any" status provides maximum flexibility.

Let's verify these statuses match the official DocuSign API documentation:

✅ Verification successful

Status options are correctly implemented and used in the component

The status options in the component are properly implemented and used:

  • The statuses are used in the run method to filter envelopes via DocuSign's API
  • The implementation follows a standard pattern where statuses are joined and passed as a query parameter
  • The "any" default makes sense as it allows monitoring all status changes
  • All status values align with DocuSign's envelope status lifecycle

Note: While we couldn't find explicit DocuSign API documentation in the repository, the implementation shows these are valid envelope statuses used in the DocuSign integration. The code demonstrates proper usage of these statuses in the API calls and event monitoring.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify status options against DocuSign API documentation
# Expected: All status values should be documented in the API

# Search for status enum documentation in any markdown or API docs
rg -i "envelope.*status.*enum|possible.*status.*values" --type=md

Length of output: 67


Script:

#!/bin/bash
# Let's try a different approach to verify the status values
# 1. Search for any DocuSign related documentation files
# 2. Search for status-related constants or enums in the codebase
# 3. Search for other components using these statuses

# Find DocuSign documentation or configuration files
fd -e md -e json docusign

# Search for status-related definitions in the DocuSign component
rg -i "status.*=|status.*:|enum.*status" components/docusign/

# Search for usage of these specific status values in other files
rg -l "completed|declined|deleted|delivered|processing|sent|signed|timedout|voided" components/docusign/

Length of output: 648


Script:

#!/bin/bash
# Let's check the README and other files for status documentation
cat components/docusign/README.md

# Check the actual implementation in other files to see how these statuses are used
cat components/docusign/actions/create-signature-request/create-signature-request.mjs

# Check if there are any test files validating these statuses
fd -e test.mjs -e spec.mjs docusign

Length of output: 2603


Script:

#!/bin/bash
# Let's check the DocuSign app file for any status definitions
cat components/docusign/docusign.app.mjs

# Let's also check the actual implementation of the envelope status source
cat components/docusign/sources/new-change-in-envelope-status/common.mjs

Length of output: 2682

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 @michelle0927 lgtm! Ready for QA!

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.

DocuSign - Update Trigger
2 participants