Skip to content

New Components - lucca #16154

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

Merged
merged 9 commits into from
Apr 9, 2025
Merged

New Components - lucca #16154

merged 9 commits into from
Apr 9, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Apr 2, 2025

Resolves #16101.

Summary by CodeRabbit

  • New Features

    • Introduced new functionality for processing leave requests, with options to approve or deny.
    • Added capabilities to update user profiles with enriched input options.
    • Enhanced the application’s integration, offering customizable selections for users, leave requests, legal entities, departments, and nationalities.
    • Rolled out automated event sources to streamline workflows for new expense reports, leave requests, and user onboarding.
    • Added a new constant to improve configuration management.
  • Chores

    • Updated the package version and dependencies for improved platform compatibility.

@luancazarine luancazarine added the ai-assisted Content generated by AI, with human refinement and modification label Apr 2, 2025
Copy link

vercel bot commented Apr 2, 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 8, 2025 9:25pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 8, 2025 9:25pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 8, 2025 9:25pm

Copy link
Contributor

coderabbitai bot commented Apr 2, 2025

Walkthrough

The pull request introduces multiple new modules and enhancements for the Lucca integration. New action modules for approving leave requests and updating user information have been added, along with several event source modules for new leave requests, new expense reports, and new user creations. Enhancements include new constants, additional properties in the app configuration, and a suite of supporting methods for API interaction and event emission. Package version and dependency updates are also included.

Changes

File(s) Change Summary
components/lucca/actions/approve-leave-request/*.mjs
components/lucca/actions/update-user-info/*.mjs
Introduced two new action modules for approving leave requests and updating user info. Each exports an object with metadata and an asynchronous run method invoking corresponding Lucca API calls.
components/lucca/common/constants.mjs
components/lucca/lucca.app.mjs
components/lucca/package.json
Added a new constant (LIMIT), updated the app’s prop definitions to include additional IDs, added new methods for API requests and data retrieval, and bumped package version with new dependency.
components/lucca/sources/common/base.mjs Introduced a new base module for event sourcing with methods for managing event IDs, emitting events, and a deploy hook.
components/lucca/sources/new-expense-report/* Added a new expense report source module and its test event to emit and summarize new expense report events.
components/lucca/sources/new-leave-request/* Added a new leave request source module and its corresponding test event for emitting new leave request events with summary generation.
components/lucca/sources/new-user/* Added a new user source module and its test event to support the emission and summarization of new user creation events.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant ApproveAction as ApproveLeaveRequestAction
    participant LuccaApp as LuccaApp API
    Client->>ApproveAction: Call run(context) with leaveRequestId, approved, comment
    ApproveAction->>LuccaApp: approveLeaveRequest(leaveRequestId, {approved, comment})
    LuccaApp-->>ApproveAction: API Response
    ApproveAction-->>Client: Return summary and API response
Loading
sequenceDiagram
    participant Source as NewLeaveRequestSource
    participant Base as CommonBaseModule
    participant LuccaApp as LuccaApp API
    participant DB as Database
    Source->>Base: run() to emit events
    Base->>DB: _getLastId()
    Base->>LuccaApp: listLeaveRequests() call
    LuccaApp-->>Base: Return leave requests
    Base->>DB: _setLastId(newLastId)
    Base-->>Source: Emit new leave request events with summary
Loading

Assessment against linked issues

Objective Addressed Explanation
Emit new event when a new leave request, expense report, or user is created (#16101)
Approve a pending leave request and update user profile information with the respective optional fields (#16101)

Suggested reviewers

  • lcaresia

Poem

Oh, what a hop and a skip,
New features bloom with each script,
Leave requests approved with glee,
User updates run smoothly and free,
Event trails dance in code so neat,
A rabbit cheers with a beat! 🐇🎉

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/lucca/actions/update-user-info/update-user-info.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)

components/lucca/lucca.app.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)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Sources
 - New Leave Request
 - New User
 - New Expense Report

Actions
 - Approve Leave Request
 - Update User Info
Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

I left a few comments regarding possibly optimizing props and descriptions.

Also, this PR is labeled as a draft - I assume it is ready for review since it was moved to the relevant column.

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

Please convert the PR to in-progress if it is no longer a draft, and update pnpm-lock as the automated checks are failing. Moving this to QA to speed it up

@luancazarine luancazarine marked this pull request as ready for review April 7, 2025 18:37
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 (14)
components/lucca/common/constants.mjs (1)

1-1: Consider adding a comment to explain the purpose of this constant.

The LIMIT constant is exported without any documentation about its purpose or where it's used. Adding a brief comment would help other developers understand its significance in the Lucca integration.

+// Maximum number of items to retrieve per API request
 export const LIMIT = 100;
components/lucca/actions/approve-leave-request/approve-leave-request.mjs (1)

30-42: Consider handling errors explicitly in the run method.

While the current implementation will naturally throw errors when the API call fails, adding explicit error handling would improve the user experience by providing more context.

 async run({ $ }) {
-    const response = await this.lucca.approveLeaveRequest({
-      $,
-      leaveRequestId: this.leaveRequestId,
-      data: {
-        approved: this.approved,
-        comment: this.comment,
-      },
-    });
-
-    $.export("$summary", `Leave request ${this.leaveRequestId} was successfully processed.`);
-    return response;
+    try {
+      const response = await this.lucca.approveLeaveRequest({
+        $,
+        leaveRequestId: this.leaveRequestId,
+        data: {
+          approved: this.approved,
+          comment: this.comment,
+        },
+      });
+
+      $.export("$summary", `Leave request ${this.leaveRequestId} was successfully ${this.approved ? 'approved' : 'denied'}.`);
+      return response;
+    } catch (error) {
+      $.export("$summary", `Failed to process leave request: ${error.message}`);
+      throw error;
+    }
 },
components/lucca/sources/new-user/test-event.mjs (1)

1-67: Sample event structure is well-defined but has some inconsistencies.

The test event provides a comprehensive structure for a user object, which is good for testing and documentation. However, there are a few inconsistencies to note:

  1. The casing convention is inconsistent - most properties use camelCase, but userWorkCycles has PascalCase properties (Id, OwnerID, etc.)
  2. The picture object uses href while other objects use url for similar purposes
  3. Generic placeholders like "<string>" could be replaced with more realistic sample data

Consider standardizing the casing convention across all properties and using more realistic sample data to improve the usefulness of this test event.

components/lucca/sources/new-user/new-user.mjs (1)

17-19: Consider enhancing the user summary with more identifiable information.

The current summary only includes the user's name, but in enterprise environments, it might be helpful to include additional identifying information like email or employee ID.

Consider enhancing the summary to include more identifiable information:

  getSummary(item) {
-    return `New User: ${item.name}`;
+    return `New User: ${item.name}${item.employeeNumber ? ` (ID: ${item.employeeNumber})` : ''}`;
  },
components/lucca/sources/new-leave-request/new-leave-request.mjs (1)

17-19: Consider enhancing leave request summary with more context.

The current summary only includes the leave request ID, which isn't very descriptive for users. Including information about the requester or date range would make the notification more useful.

Consider enhancing the summary to include more context about the leave request:

  getSummary(item) {
-    return `New Leave Request with ID: ${item.id}`;
+    return `New Leave Request with ID: ${item.id}${item.leavePeriod?.ownerName ? ` from ${item.leavePeriod.ownerName}` : ''}`;
  },
components/lucca/sources/new-expense-report/new-expense-report.mjs (1)

17-19: Consider enhancing expense report summary with additional context.

The current summary only includes the expense report name. Adding information about the amount or creator would make the notification more useful for workflow automation.

Consider enhancing the summary to include more context about the expense report:

  getSummary(item) {
-    return `New expense report: ${item.name}`;
+    return `New expense report: ${item.name}${item.ownerName ? ` from ${item.ownerName}` : ''}`;
  },
components/lucca/sources/new-expense-report/test-event.mjs (3)

1-49: Consider clarifying placeholder fields.
Some fields have placeholder values like "<string>" or "<any>". While this might be sufficient for demonstrative or testing purposes, consider replacing them with real or more descriptive placeholder data to avoid confusion and ensure that consumers understand the expected data format.


50-131: Ensure attendee data reflects real-world scenarios.
The attendees.internal and attendees.external arrays are comprehensive, but some fields (e.g., birthDate, lastName, etc.) are all placeholders. If this test event is used for integration or acceptance testing, consider providing realistic or reproducible data to better mimic actual user data.


132-181: Consider storing large sample data separately.
This module exports an extensive object for demonstration. If this data grows over time or is reused in multiple places, you might separate it into a JSON fixture or a shared constant for maintainability.

components/lucca/sources/common/base.mjs (1)

39-53: Potential concurrency concerns.
If this source can run concurrently (e.g., multiple instances or short intervals), storing the last ID in this way might risk overwriting. A potential solution is to use a locking mechanism or a distributed store with version checks. However, if concurrency is not a concern in your environment, this is fine as is.

components/lucca/actions/update-user-info/update-user-info.mjs (2)

3-16: Uniformly apply async options for ID props.
You've already used propDefinition with async options for userId. Consider consistently applying a similar approach for other ID fields (e.g., managerId) so that users can conveniently look up valid IDs without manually typing them.


17-157: Validate data for complex fields.
Properties like birthDate and mail have minimal validation in this component. If calling the underlying API with invalid data is a concern, consider introducing format checks (e.g., ensuring birthDate is in "YYYY-MM-DD"). This can prevent unexpected backend errors.

components/lucca/lucca.app.mjs (2)

7-43: Check performance for large datasets.
When listing users or leave requests, you fetch with a paging param. For organizations with a very large user base, scrolling or searching could be slow or incomplete. Consider adding filtering or search parameters, or providing a descriptive label for each user if needed.

Would you like help adding more advanced search or filtering logic to your options?


158-182: Handle empty items.
In the paginate method, the code destructures items from the response without additional null checks. If the API returns an unexpected payload without items, this could throw an error. Consider adding either a fallback or a short-circuit check.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d8a832 and 111bcfc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • components/lucca/actions/approve-leave-request/approve-leave-request.mjs (1 hunks)
  • components/lucca/actions/update-user-info/update-user-info.mjs (1 hunks)
  • components/lucca/common/constants.mjs (1 hunks)
  • components/lucca/lucca.app.mjs (1 hunks)
  • components/lucca/package.json (2 hunks)
  • components/lucca/sources/common/base.mjs (1 hunks)
  • components/lucca/sources/new-expense-report/new-expense-report.mjs (1 hunks)
  • components/lucca/sources/new-expense-report/test-event.mjs (1 hunks)
  • components/lucca/sources/new-leave-request/new-leave-request.mjs (1 hunks)
  • components/lucca/sources/new-leave-request/test-event.mjs (1 hunks)
  • components/lucca/sources/new-user/new-user.mjs (1 hunks)
  • components/lucca/sources/new-user/test-event.mjs (1 hunks)
🔇 Additional comments (8)
components/lucca/package.json (1)

3-3: LGTM! Version bump and dependencies look appropriate.

The version update from 0.0.1 to 0.1.0 reflects the significant additions to the Lucca integration. The addition of the @pipedream/platform dependency is also appropriate for a Pipedream component.

Also applies to: 14-17

components/lucca/sources/new-leave-request/test-event.mjs (1)

1-50: LGTM! Well-structured test event for leave request.

The test event provides a comprehensive example of a leave request structure with all necessary fields for testing. The placeholder values are appropriate for sample data.

components/lucca/actions/approve-leave-request/approve-leave-request.mjs (1)

3-43: LGTM! Well-implemented action for approving/denying leave requests.

The action is well-structured with clear props and follows Pipedream's component patterns. The documentation link and export summary provide good context for users.

components/lucca/sources/new-user/new-user.mjs (1)

4-22: Well-structured source component with good documentation.

The component follows the established pattern for source components, extending the common base module and properly defining the required configuration. The inclusion of documentation link in the description is helpful for developers.

components/lucca/sources/new-leave-request/new-leave-request.mjs (1)

4-22: Well-structured source component with proper documentation link.

The component follows the established pattern for source components, extending the common base module and properly defining the required configuration.

components/lucca/sources/new-expense-report/new-expense-report.mjs (1)

4-22: Well-structured source component with appropriate documentation link.

The component follows the established pattern for source components, extending the common base module and properly defining the required configuration. The documentation link in the description is valuable for developers.

components/lucca/sources/common/base.mjs (1)

22-38:

❓ Verification inconclusive

Validate item ordering in the API response.
Here, the code breaks out of the loop once it encounters an item.id <= lastId. This assumes the items are sorted strictly in descending order by ID. Verify that the API reliably provides items in descending order; otherwise, some newer items might get missed.


🏁 Script executed:

#!/bin/bash
# This script verifies that the API returns descending IDs in the getFunction() call.
# We'll look for a sorting param or relevant docs in the codebase.

rg -A 10 'orderBy:' 

Length of output: 63877


Action Required: Confirm API's Descending Sort Behavior

  • The code in components/lucca/sources/common/base.mjs explicitly sets orderBy: "id,desc" when calling the paginate method. This indicates an expectation that the API returns items in descending order by their ID.
  • The loop logic (if (item.id <= lastId) break;) relies on this ordering to avoid processing items with previously seen IDs.
  • Please verify that the Lucca API reliably honors the orderBy: "id,desc" parameter so that no new items are inadvertently skipped. If there's any doubt, consider adding tests or safeguards to ensure consistent ordering.
components/lucca/lucca.app.mjs (1)

133-141:

✅ Verification successful

Confirm request method for approvals.
The approveLeaveRequest method uses a POST request to "/leaveRequests/{leaveRequestId}/approvals". Ensure indeed that the Lucca API expects a POST for this route instead of PATCH, PUT, or another HTTP verb.


🏁 Script executed:

#!/bin/bash
# Checking code and doc references to confirm the correct method for leaveRequests approvals
rg -A 5 'leaveRequests'

Length of output: 1523


Action: Confirmed POST method for approvals endpoint

The approveLeaveRequest method consistently uses a POST request for the /leaveRequests/{leaveRequestId}/approvals endpoint, and our grep search shows no alternative HTTP methods (such as PATCH or PUT) being used for this route. This suggests that the Lucca API expects a POST for leave approvals. However, if there’s any uncertainty, please cross-check with the official Lucca API documentation.

  • Verified usage in components/lucca/lucca.app.mjs (lines 133-141).
  • No conflicting HTTP verbs were detected in related code sections.

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/lucca/actions/update-user-info/update-user-info.mjs (1)

4-122: Consider converting additional ID props to use async options
Props like calendarId remain simple integers. If the Lucca API supports listing possible calendar IDs, you could implement an async options pattern, similar to userId or legalEntityId, to guide users with valid choices and reduce input errors.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 111bcfc and 034a886.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • components/lucca/actions/update-user-info/update-user-info.mjs (1 hunks)
  • components/lucca/lucca.app.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (5)
components/lucca/actions/update-user-info/update-user-info.mjs (2)

1-3: Imports look good
No issues here.


123-139:

✅ Verification successful

Looks solid—verify references to ensure consistent usage
The data is destructured and sent as a single object to updateUserProfile, which is fine. Double-check that upstream code sets these props correctly.

Here's a script to locate references to update-user-info or updateUserProfile across the codebase, checking for consistent usage:


🏁 Script executed:

#!/bin/bash
rg -A 5 "update-user-info" 
rg -A 5 "updateUserProfile"

Length of output: 1545


Verified: Consistent Usage of updateUserProfile References

The code in components/lucca/actions/update-user-info/update-user-info.mjs correctly destructures the properties and passes them as a single object to lucca.updateUserProfile. Our reference search confirms that:

  • The action file sets the relevant properties ($, userId, ...data) consistently.
  • The upstream implementation in components/lucca/lucca.app.mjs appropriately receives { userId, ...opts } and constructs the request as expected.

Everything aligns with the intended usage. Please ensure that all upstream modules maintain these prop settings.

components/lucca/lucca.app.mjs (3)

1-3: Import statements align with dependencies
No concerns here—axios usage is appropriate for requests.


7-98: Proactive use of async options
Listing items for userId, leaveRequestId, legalEntityId, departmentId, and nationalityId helps users avoid input mistakes. This structure is clear and user-friendly.


177-202: Clean and straightforward pagination implementation
Your do-while loop and limiting logic appear correct. Good approach in returning early once maxResults is reached.

@luancazarine
Copy link
Collaborator Author

/approve

@luancazarine luancazarine merged commit 0d5fd08 into master Apr 9, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-16101 branch April 9, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai-assisted Content generated by AI, with human refinement and modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] lucca
2 participants