- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Microsoft Dynamics - new sources #18882
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
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
 | 
| WalkthroughThis PR adds five new account-level event source modules to the Microsoft Dynamics 365 Sales component (new account created, account ownership changed, account status changed, contact added to account, new account activity). It introduces an  Changes
 Sequence DiagramsequenceDiagram
    participant User
    participant Source
    participant Common
    participant DB
    participant API
    User->>Source: Initialize source instance
    Source->>Common: Extend common base configuration
    Note over Source: Inherits getResourceFn, getArgs,<br/>getTsField, generateMeta patterns
    Source->>DB: _getStoredState() (e.g., ownershipIds, statuses)
    DB-->>Source: Previous state (or empty)
    Source->>API: getResourceFn() returns resource (e.g., listAccounts)
    Source->>API: getArgs() builds request params
    API-->>Source: Fetch results with ordering/filters
    
    Source->>Source: getRelevantResults(results)
    Note over Source: Compare current state vs. stored state<br/>Detect changes (new, modified, status changed)
    
    Source->>DB: _setStoredState(newState) - Update mappings
    DB-->>Source: State persisted
    
    Source->>Source: For each relevant result: generateMeta(item)
    Note over Source: Build event metadata:<br/>Unique ID, summary, timestamp
    
    Source-->>User: Emit detected events with metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 
 Possibly related PRs
 Suggested labels
 Suggested reviewers
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
 ✅ Passed checks (2 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  | 
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: 7
🧹 Nitpick comments (1)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (1)
1-55: Consider abstracting the change-detection pattern.This file and
account-status-changed.mjsshare nearly identical logic—both track a field in the database, detect changes, and emit events. The only differences are the field name (_ownerid_valuevs.statuscode) and the storage key.You could create a shared base class or helper that accepts the field name as a parameter to reduce duplication.
This is a low-priority refactoring suggestion that could improve maintainability if you add more change-tracking sources in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (19)
- components/microsoft_dynamics_365_sales/actions/create-custom-entity/create-custom-entity.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/actions/find-contact/find-contact.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/microsoft_dynamics_365_sales.app.mjs(2 hunks)
- components/microsoft_dynamics_365_sales/package.json(1 hunks)
- components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/new-opportunity-activity/new-opportunity-activity.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/new-opportunity-created/new-opportunity-created.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-close-date-updated/opportunity-close-date-updated.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-close-probability-updated/opportunity-close-probability-updated.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-estimated-value-updated/opportunity-estimated-value-updated.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-marked-won-or-lost/opportunity-marked-won-or-lost.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-ownership-changed/opportunity-ownership-changed.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-reopened/opportunity-reopened.mjs(1 hunks)
- components/microsoft_dynamics_365_sales/sources/opportunity-stage-updated/opportunity-stage-updated.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (4)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (3)
relevantResults(37-37)
account(38-38)
ts(48-48)components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs (1)
ts(37-37)
components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (4)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs (1)
ts(37-37)
components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs (1)
components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (1)
account(38-38)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (2)
relevantResults(34-34)
ts(47-47)components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
relevantResults(34-34)
ts(47-47)
⏰ 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: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (22)
components/microsoft_dynamics_365_sales/sources/opportunity-stage-updated/opportunity-stage-updated.mjs (1)
8-8: Version bump aligns with release cycle.The version update from 0.0.2 to 0.0.3 is part of the broader component versioning for this PR. No functional changes detected.
components/microsoft_dynamics_365_sales/sources/new-opportunity-activity/new-opportunity-activity.mjs (1)
8-8: Verify if this version bump is intentional.The only change in this file is a version increment from 0.0.1 to 0.0.2 with no accompanying functional modifications. Given that the PR's stated objectives focus on new account-level event sources (not opportunity-level sources), clarify whether this version bump is:
- Intentional as part of a release strategy (e.g., bumping all related modules)
- Or collateral/unintended churn that should be removed
components/microsoft_dynamics_365_sales/sources/opportunity-estimated-value-updated/opportunity-estimated-value-updated.mjs (1)
8-8: Clarify the rationale for versioning this module.This file is being version-bumped from 0.0.2 to 0.0.3 with no logic or behavior changes. The PR objectives focus on implementing account-level event triggers, but this module handles opportunity estimated-value updates—a distinct concern. The AI summary notes that "multiple unrelated source and action modules updated their exported version metadata" across this PR.
Please clarify whether this version bump is intentional as part of a coordinated versioning strategy, a dependency-driven change, or if it should be reverted.
components/microsoft_dynamics_365_sales/sources/opportunity-close-probability-updated/opportunity-close-probability-updated.mjs (1)
8-8: LGTM! Version bump aligns with PR-wide updates.The version increment from 0.0.2 to 0.0.3 is appropriate for maintaining consistency across the component's sources. No functional changes introduced.
components/microsoft_dynamics_365_sales/sources/opportunity-marked-won-or-lost/opportunity-marked-won-or-lost.mjs (1)
1-85: Version bump aligns with coordinated updates across modules.This file's version increment to
0.0.2appears appropriately scoped as part of a coordinated release. The source module logic itself is sound—state tracking, filtering, and deduplication are all correct. No behavioral changes detected.components/microsoft_dynamics_365_sales/sources/opportunity-close-date-updated/opportunity-close-date-updated.mjs (1)
8-8: LGTM! Version bump is appropriate.The patch version increment aligns with the broader component updates in this PR. No functional changes to this source module.
components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (1)
8-8: LGTM!The version bump from a templated version to "0.0.2" is appropriate and aligns with the broader PR's version synchronization across the Microsoft Dynamics 365 Sales component.
components/microsoft_dynamics_365_sales/sources/opportunity-ownership-changed/opportunity-ownership-changed.mjs (1)
8-8: Verify the necessity of this version bump and file inclusion in the PR.The review comment raises valid concerns that cannot be automatically verified:
Why this file needs a version bump: This is an opportunity-related source, not account-related. No functional changes are visible in the file. Clarify whether changes to the common module, package-level updates, or other factors justify the version bump.
Whether this file should be in this PR: Confirm this file's inclusion aligns with the stated objective of adding five NEW account-level event triggers, or if it was added unintentionally.
Please review and confirm these changes are intentional and necessary.
components/microsoft_dynamics_365_sales/package.json (1)
3-3: LGTM!The version bump to 0.4.0 appropriately reflects the addition of new account-level event sources.
components/microsoft_dynamics_365_sales/actions/create-custom-entity/create-custom-entity.mjs (1)
9-9: LGTM!Version bump is appropriate for this maintenance release.
components/microsoft_dynamics_365_sales/sources/new-opportunity-created/new-opportunity-created.mjs (1)
8-8: LGTM!Version bump is appropriate for this maintenance release.
components/microsoft_dynamics_365_sales/sources/opportunity-reopened/opportunity-reopened.mjs (1)
8-8: LGTM!Version bump is appropriate for this maintenance release.
components/microsoft_dynamics_365_sales/actions/find-contact/find-contact.mjs (1)
7-7: LGTM!Version bump is appropriate for this maintenance release.
components/microsoft_dynamics_365_sales/microsoft_dynamics_365_sales.app.mjs (2)
57-70: LGTM!The new
accountIdprop definition follows the same pattern as existing props (contactId,opportunityId) and correctly implements async options fetching.
136-141: LGTM!The
listAccountsmethod follows the established pattern and correctly implements the accounts endpoint.components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs (1)
13-25: LGTM!The resource configuration correctly retrieves accounts ordered by creation date descending, which is appropriate for detecting new accounts.
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (3)
13-18: LGTM!The state persistence helpers correctly store and retrieve status mappings using the Pipedream database.
19-31: LGTM!The configuration appropriately uses
modifiedonfor tracking status changes, as status changes will update the modification timestamp.
32-45: LGTM!The change detection logic correctly:
- Identifies status changes by comparing stored vs. current values
- Prevents false positives on the first run (Line 37)
- Persists updated state for future comparisons
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (3)
13-18: LGTM!The state persistence helpers correctly store and retrieve ownership ID mappings.
19-31: LGTM!The configuration appropriately uses
modifiedonfor tracking ownership changes.
32-45: LGTM!The change detection logic correctly identifies ownership changes and prevents false positives on the first run.
        
          
                ...microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs
          
            Show resolved
            Hide resolved
        
              
          
                ...nents/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs
          
            Show resolved
            Hide resolved
        
              
          
                ...s/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs
          
            Show resolved
            Hide resolved
        
              
          
                ...s/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs
          
            Show resolved
            Hide resolved
        
              
          
                components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs
          
            Show resolved
            Hide resolved
        
              
          
                components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs
          
            Show resolved
            Hide resolved
        
              
          
                components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs
          
            Show resolved
            Hide resolved
        
      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.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #18818
Summary by CodeRabbit
New Features
Chores