Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Nov 14, 2025

Resolves #10963

Summary by CodeRabbit

  • New Features

    • Added Optimoroute actions: Create Order, Search Orders, Update Order Status, Get Routes, Get Mobile Events, and Start Planning
    • Added a mobile-event source (real-time mobile events trigger) with a sample test event
    • Added an "After Tag" property and centralized API request handling for Optimoroute (improved error/reporting)
  • Chores

    • Component version bumped to 0.1.0

@vercel
Copy link

vercel bot commented Nov 14, 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 Nov 19, 2025 4:05pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Nov 19, 2025 4:05pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Adds six new Optimoroute action modules, a polling source and test event fixture, centralizes HTTP requests and route wrappers in the Optimoroute app module, and bumps the component package version and dependencies.

Changes

Cohort / File(s) Summary
Action modules
components/optimoroute/actions/create-order/create-order.mjs, components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs, components/optimoroute/actions/get-routes/get-routes.mjs, components/optimoroute/actions/search-orders/search-orders.mjs, components/optimoroute/actions/start-planning/start-planning.mjs, components/optimoroute/actions/update-order-status/update-order-status.mjs
Added six new action exports. Each defines metadata, props, annotations, and an async run({ $ }) that maps inputs to the Optimoroute app client calls (e.g., createOrder, getMobileEvents, getRoutes, searchOrders, startPlanning, updateOrderStatus), exports a summary, and returns the API response.
App module
components/optimoroute/optimoroute.app.mjs
Added afterTag propDefinition; implemented _baseUrl() and _makeRequest({ $, path, params, ...opts }) to centralize API requests, inject api_key, and surface errors; added route wrappers: getRoutes, getMobileEvents, searchOrders (POST /search_orders), createOrder (POST /create_order), startPlanning (POST /start_planning), updateOrderStatus (POST /update_completion_details).
Source module
components/optimoroute/sources/new-mobile-event/new-mobile-event.mjs
New polling source that persists afterTag in db; provides _getAfterTag, _setAfterTag, generateMeta, an async generator paginateEvents(afterTag) for paginated fetches, processEvents(limit) to emit events, a deploy() hook to seed on deploy, and run() to process on timer.
Test event
components/optimoroute/sources/new-mobile-event/test-event.mjs
New sample/test event object export containing static mobile event fields for use with the source.
Package configuration
components/optimoroute/package.json
Version bumped from 0.0.1 to 0.1.0; added dependencies: { "@pipedream/platform": "^3.1.1" }.

Sequence Diagram(s)

sequenceDiagram
    participant Timer
    participant Source as new-mobile-event source
    participant Pagination as paginateEvents()
    participant App as optimoroute.app
    participant API as Optimoroute API
    participant DB as State (db)
    participant Emit

    Timer->>Source: run()
    activate Source
    Source->>DB: _getAfterTag()
    DB-->>Source: afterTag
    Source->>Pagination: paginateEvents(afterTag)
    activate Pagination
    loop pages
        Pagination->>App: getMobileEvents({ after_tag })
        App->>API: HTTP GET /v1/... (api_key injected)
        API-->>App: { events[], after_tag }
        App-->>Pagination: response
        Pagination->>Source: yield event
        Source->>Source: generateMeta(event)
        Source->>Emit: $emit(event, metadata)
    end
    Pagination->>DB: _setAfterTag(newAfterTag)
    deactivate Pagination
    deactivate Source
Loading
sequenceDiagram
    participant Action as Action (e.g., create-order)
    participant Run as run({ $ })
    participant App as optimoroute.app
    participant Helper as _makeRequest()
    participant API as Optimoroute API

    Action->>Run: invoked
    activate Run
    Run->>Run: map props -> payload
    Run->>App: createOrder(payload)
    activate App
    App->>Helper: _makeRequest({ path, params })
    activate Helper
    Helper->>API: HTTP POST /v1/path (api_key added)
    API-->>Helper: response / error
    alt success
        Helper-->>App: response
    else error
        Helper-->>App: throw ConfigurationError
    end
    App-->>Run: response
    Run->>Action: export summary + return response
    deactivate Run
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review pagination and async generator logic plus afterTag persistence in components/optimoroute/sources/new-mobile-event/new-mobile-event.mjs.
  • Verify _makeRequest error handling, status-code parsing, and api_key injection in components/optimoroute/optimoroute.app.mjs.
  • Confirm payload transformations (array/object shapes) in start-planning and create-order, and status/type option correctness in update-order-status.
  • Check action prop definitions, summary strings, and that POST paths match API expectations.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is extremely minimal, containing only 'Resolves #10963' without any substantive explanation of the changes, implementation approach, or testing performed. Expand the description to explain what components were added, why they were added, and summarize the key implementation details or testing results.
Title check ❓ Inconclusive The title 'OptimoRoute - new components' is generic and overly vague. It lacks specificity about what components are being added and does not convey meaningful information about the changeset. Use a more specific title that describes the actual components added, e.g., 'Add OptimoRoute integration with actions and event sources' or similar descriptive phrasing.
Linked Issues check ❓ Inconclusive The linked issue #10963 provides insufficient detail about objectives or acceptance criteria, making it impossible to validate whether the PR meets explicit requirements. Review the linked issue to establish clear coding requirements, acceptance criteria, and implementation expectations that can be used to assess the PR's completeness.
✅ Passed checks (2 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed All changes appear related to OptimoRoute component integration: six new action modules, one new event source module, supporting files, and app infrastructure updates are all in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 issue-10963

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef0fbda and d1d9448.

📒 Files selected for processing (1)
  • components/optimoroute/actions/start-planning/start-planning.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-08T16:42:59.225Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 14229
File: components/americommerce/actions/update-customer/update-customer.mjs:89-94
Timestamp: 2024-10-08T16:42:59.225Z
Learning: When defining boolean properties in AmeriCommerce components (e.g., in `update-customer.mjs`), ensure that the label and description are consistent and clearly indicate the intent, especially when using negations like "No Account", to avoid confusion.

Applied to files:

  • components/optimoroute/actions/start-planning/start-planning.mjs
🧬 Code graph analysis (1)
components/optimoroute/actions/start-planning/start-planning.mjs (1)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
⏰ 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: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (2)
components/optimoroute/actions/start-planning/start-planning.mjs (2)

21-26: Good fix: orderNumbers prop is now correctly used

The previous critical issue where this.orderIds was referenced but the prop was named orderNumbers has been resolved. The code now correctly uses this.orderNumbers throughout (see lines 129-133).


91-94: Good fix: lockType description now correctly references startsWith

The description on line 94 now correctly references the startsWith prop name. The previous inconsistency has been resolved.


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.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01e49b6 and 522ed90.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/optimoroute/actions/create-order/create-order.mjs (1 hunks)
  • components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (1 hunks)
  • components/optimoroute/actions/get-routes/get-routes.mjs (1 hunks)
  • components/optimoroute/actions/search-orders/search-orders.mjs (1 hunks)
  • components/optimoroute/actions/start-planning/start-planning.mjs (1 hunks)
  • components/optimoroute/actions/update-order-status/update-order-status.mjs (1 hunks)
  • components/optimoroute/optimoroute.app.mjs (1 hunks)
  • components/optimoroute/package.json (2 hunks)
  • components/optimoroute/sources/new-mobile-event/new-mobile-event.mjs (1 hunks)
  • components/optimoroute/sources/new-mobile-event/test-event.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-12-12T19:23:09.039Z
Learnt from: jcortes
Repo: PipedreamHQ/pipedream PR: 14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like `fs` to `package.json` dependencies, as they are native modules provided by the Node.js runtime.

Applied to files:

  • components/optimoroute/package.json
📚 Learning: 2024-10-10T19:18:27.998Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 14265
File: components/the_magic_drip/sources/common.mjs:35-43
Timestamp: 2024-10-10T19:18:27.998Z
Learning: In `components/the_magic_drip/sources/common.mjs`, when processing items in `getAndProcessData`, `savedIds` is intentionally updated with IDs of both emitted and non-emitted items to avoid emitting retroactive events upon first deployment and ensure only new events are emitted as they occur.

Applied to files:

  • components/optimoroute/sources/new-mobile-event/new-mobile-event.mjs
📚 Learning: 2025-09-15T22:01:11.472Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 18362
File: components/leonardo_ai/actions/generate-image/generate-image.mjs:103-105
Timestamp: 2025-09-15T22:01:11.472Z
Learning: In Pipedream components, pipedream/platform's axios implementation automatically excludes undefined values from HTTP requests, so there's no need to manually check for truthiness before including properties in request payloads.

Applied to files:

  • components/optimoroute/optimoroute.app.mjs
🧬 Code graph analysis (7)
components/optimoroute/actions/update-order-status/update-order-status.mjs (2)
components/optimoroute/actions/create-order/create-order.mjs (1)
  • response (93-108)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (2)
components/optimoroute/actions/search-orders/search-orders.mjs (1)
  • response (46-57)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/actions/search-orders/search-orders.mjs (3)
components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (1)
  • response (24-29)
components/optimoroute/actions/get-routes/get-routes.mjs (1)
  • response (53-63)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/actions/get-routes/get-routes.mjs (2)
components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (1)
  • response (24-29)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/actions/create-order/create-order.mjs (1)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/actions/start-planning/start-planning.mjs (1)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
components/optimoroute/optimoroute.app.mjs (6)
components/optimoroute/actions/create-order/create-order.mjs (1)
  • response (93-108)
components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (1)
  • response (24-29)
components/optimoroute/actions/get-routes/get-routes.mjs (1)
  • response (53-63)
components/optimoroute/actions/search-orders/search-orders.mjs (1)
  • response (46-57)
components/optimoroute/actions/start-planning/start-planning.mjs (1)
  • response (113-133)
components/optimoroute/actions/update-order-status/update-order-status.mjs (1)
  • response (62-74)
⏰ 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). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (7)
components/optimoroute/package.json (1)

3-17: Version bump and platform dependency look correct

The version bump and addition of @pipedream/platform as the only dependency are appropriate for the new axios-based app methods, and avoid adding any Node core modules to dependencies. Based on learnings.

components/optimoroute/sources/new-mobile-event/test-event.mjs (1)

1-10: Sample event payload is straightforward and usable

Static export shape is clear and matches an expected Optimoroute mobile event (status, timestamps, order and driver identifiers). No issues from a component perspective.

components/optimoroute/actions/update-order-status/update-order-status.mjs (1)

1-78: Update Order Status action wiring looks correct

Props, status enum, payload shape (updates array with orderNo and nested status) and the exported summary are all consistent and align with the described endpoint.

components/optimoroute/actions/get-mobile-events/get-mobile-events.mjs (1)

1-33: Get Mobile Events action is consistent and robust

afterTag reuse via propDefinition, mapping to after_tag in params, and the summary using response?.events?.length are all consistent with the app client and other actions.

components/optimoroute/actions/get-routes/get-routes.mjs (1)

3-67: Make routes summary resilient to missing routes array

The action wiring into this.optimoroute.getRoutes and params mapping looks good. The summary, however, assumes routes is always present:

$.export("$summary", `Routes found: ${response.routes.length}`);

To avoid a runtime error if routes is absent or null, you can mirror the defensive pattern:

-    $.export("$summary", `Routes found: ${response.routes.length}`);
+    const count = response?.routes?.length ?? 0;
+    $.export("$summary", `Routes found: ${count}`);

This keeps the step from failing solely due to an unexpected response shape.

⛔ Skipped due to learnings
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-10-08T15:33:38.240Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
components/optimoroute/sources/new-mobile-event/new-mobile-event.mjs (2)

36-55: Verify getMobileEvents call shape and ensure dedupe id is truly unique

Here getMobileEvents is called with only a params object:

const {
  events = [], tag, remainingEvents,
} = await this.optimoroute.getMobileEvents({
  params: {
    after_tag: afterTag,
  },
});

In other places (e.g., the startPlanning action), Optimoroute app methods appear to expect a payload that includes $ (e.g. { $, data }). If getMobileEvents follows the same pattern, you’ll likely need to pass the source context as well, for example:

-        } = await this.optimoroute.getMobileEvents({
-          params: {
-            after_tag: afterTag,
-          },
-        });
+        } = await this.optimoroute.getMobileEvents({
+          $: this,
+          params: {
+            after_tag: afterTag,
+          },
+        });

Also, generateMeta uses event.unixTimestamp as the id for a dedupe: "unique" source (Lines 29–35). Please confirm that unixTimestamp is guaranteed unique per event; if not, consider a composite id like ${event.orderNo}-${event.unixTimestamp}.


56-79: Pagination + afterTag persistence pattern looks good for avoiding retroactive floods

processEvents consumes the entire paginateEvents iterator, then optionally limits emissions (e.g., last 10 on deploy), while paginateEvents only updates afterTag once there are no remaining events. This means:

  • On first deploy you advance the cursor across all historical events but only emit a small tail batch.
  • On subsequent runs you only fetch and emit newly arrived events.

This matches the “advance state even for non-emitted items to avoid retroactive events” pattern used in other sources. Based on learnings

GTFalcao
GTFalcao previously approved these changes Nov 17, 2025
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.

LGTM!

@vunguyenhung
Copy link
Collaborator

@vunguyenhung
Copy link
Collaborator

Hello everyone, I have tested this PR and there're some test cases failed or needed improvement.

Please check test reports below for more information:

@michelle0927
Copy link
Collaborator Author

@vunguyenhung FYI, For "Update Order Status", I had to "dispatch" the order to drivers before I could update the status of an order.

Screenshot 2025-11-18 at 11 37 31 AM

@vunguyenhung
Copy link
Collaborator

Hello everyone, I have tested this PR and there're some test cases failed or needed improvement.

Please check test reports below for more information:

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

♻️ Duplicate comments (1)
components/optimoroute/actions/start-planning/start-planning.mjs (1)

91-109: Align lockType description with startsWith prop name

The description at line 94 still references "startWith" but the actual prop name is startsWith (lines 75-89). Update to reference the correct prop name for consistency.

Apply this diff:

-      description: "Lock type. Applicable if startWith is set to CURRENT",
+      description: "Lock type. Applicable if startsWith is set to CURRENT",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e42acbb and ef0fbda.

📒 Files selected for processing (1)
  • components/optimoroute/actions/start-planning/start-planning.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-08T16:42:59.225Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 14229
File: components/americommerce/actions/update-customer/update-customer.mjs:89-94
Timestamp: 2024-10-08T16:42:59.225Z
Learning: When defining boolean properties in AmeriCommerce components (e.g., in `update-customer.mjs`), ensure that the label and description are consistent and clearly indicate the intent, especially when using negations like "No Account", to avoid confusion.

Applied to files:

  • components/optimoroute/actions/start-planning/start-planning.mjs
🧬 Code graph analysis (1)
components/optimoroute/actions/start-planning/start-planning.mjs (2)
components/optimoroute/actions/update-order-status/update-order-status.mjs (1)
  • response (62-74)
components/optimoroute/optimoroute.app.mjs (1)
  • response (23-30)
⏰ 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). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (1)
components/optimoroute/actions/start-planning/start-planning.mjs (1)

1-13: LGTM: Component metadata and setup

The import, metadata, and annotations are correctly structured for a new Optimoroute action component.

@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test reports

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit 6f9a2f5 into master Nov 20, 2025
10 checks passed
@michelle0927 michelle0927 deleted the issue-10963 branch November 20, 2025 15:52
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.

[Components] optimoroute

4 participants