Skip to content

New Components - influxdb_cloud #16469

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 2 commits into from
Apr 30, 2025
Merged

New Components - influxdb_cloud #16469

merged 2 commits into from
Apr 30, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 29, 2025

Resolves #15155

Summary by CodeRabbit

  • New Features

    • Added actions to InfluxDB Cloud integration for running scripts, updating buckets, and writing data.
    • Introduced sources to emit events when new buckets or scripts are created, or when tasks are completed.
    • Enhanced app integration with support for bucket/script selection, API pagination, and comprehensive API interaction.
  • Improvements

    • Added utility functions for flexible data parsing.
    • Provided a reusable base for building event sources with polling and deduplication.
    • Updated package version to 0.7.0.

Copy link

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

Copy link
Contributor

coderabbitai bot commented Apr 29, 2025

Walkthrough

This update introduces a comprehensive InfluxDB Cloud integration, adding a new app component with full API interaction capabilities, including pagination and utility helpers. Three new actions are implemented: writing data to a bucket, invoking a script, and updating a bucket. Additionally, three polling sources are provided to emit events for new bucket creation, new script creation, and task completion, each leveraging a shared base source for common polling logic. Supporting utilities and property definitions for dynamic selection of buckets and scripts are included, and the package version is incremented to reflect these enhancements.

Changes

File(s) Change Summary
components/influxdb_cloud/influxdb_cloud.app.mjs Implements the InfluxDB Cloud app with API methods for buckets, scripts, tasks, pagination, property definitions, and request helpers.
components/influxdb_cloud/actions/invoke-script/invoke-script.mjs
components/influxdb_cloud/actions/update-bucket/update-bucket.mjs
components/influxdb_cloud/actions/write-data/write-data.mjs
Adds three new actions: "Invoke Script" (runs a script by ID), "Update Bucket" (updates a bucket's details), and "Write Data" (writes line protocol data to a bucket), each using the app's API methods and property definitions.
components/influxdb_cloud/sources/common/base.mjs Introduces a reusable base class for polling sources, handling state, pagination, event emission, and abstract methods for resource-specific logic.
components/influxdb_cloud/sources/new-bucket-created/new-bucket-created.mjs
components/influxdb_cloud/sources/new-script-created/new-script-created.mjs
components/influxdb_cloud/sources/new-task-completed/new-task-completed.mjs
Adds three new polling sources: "New Bucket Created," "New Script Created," and "New Task Completed," each extending the base source and specifying resource fetching and summary logic.
components/influxdb_cloud/common/utils.mjs Adds utility functions for optional JSON parsing and processing object entries, used in parameter handling.
components/influxdb_cloud/package.json Updates the package version from 0.6.0 to 0.7.0.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action/Source
    participant InfluxDBCloudApp
    participant InfluxDB Cloud API

    User->>Action/Source: Triggers action or polling source
    Action/Source->>InfluxDBCloudApp: Calls API method (e.g., writeData, updateBucket, listBuckets)
    InfluxDBCloudApp->>InfluxDB Cloud API: Makes HTTP request
    InfluxDB Cloud API-->>InfluxDBCloudApp: Returns API response
    InfluxDBCloudApp-->>Action/Source: Returns processed data
    Action/Source-->>User: Emits event or returns result
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement "new-bucket-created", "new-script-created", and "new-task-created" polling sources (#15155)
Implement "write-data" action to write data points to a bucket (#15155)
Implement "invoke-script" action to run a Flux script and return the result (#15155)
Implement "update-bucket" action to update a bucket's name and retention policy (#15155)

Poem

A hop, a skip, a cloud in the sky,
InfluxDB’s features now multiply!
Buckets and scripts, events galore,
With actions and sources, we open the door.
The rabbit now cheers, with data to write—
“Update, invoke, and poll with delight!”
Version bumped up, let’s hop through the night! 🐇✨

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/influxdb_cloud/actions/update-bucket/update-bucket.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 793dcc6 and 829e38b.

📒 Files selected for processing (1)
  • components/influxdb_cloud/actions/update-bucket/update-bucket.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/influxdb_cloud/actions/update-bucket/update-bucket.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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 generate sequence diagram to generate a sequence diagram of the changes in this 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: 5

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

9-22: Consider adding JSDoc comments for better documentation

While the function is well-implemented and handles various input types appropriately, adding JSDoc comments would improve documentation and make the utility more maintainable.

+/**
+ * Parses object values as JSON where possible
+ * @param {Object|string} value - Object or JSON string to process
+ * @returns {Object} Object with values parsed from JSON where possible
+ */
export function parseObjectEntries(value) {
  const obj = typeof value === "string"
    ? JSON.parse(value)
    : value;
  return Object.fromEntries(
    Object.entries(obj).map(([
      key,
      value,
    ]) => [
      key,
      optionalParseAsJSON(value),
    ]),
  );
}
components/influxdb_cloud/actions/invoke-script/invoke-script.mjs (1)

25-37: Consider enhancing the success message with response details

While the current implementation works well, the success message could be more informative by including additional details from the response, such as execution status or result summary.

- $.export("$summary", `Successfully invoked script with ID: ${this.scriptId}`);
+ $.export("$summary", `Successfully invoked script with ID: ${this.scriptId}${response.success ? " with success" : ""}`);
components/influxdb_cloud/actions/write-data/write-data.mjs (1)

47-48: Enhance success message with operation details

The current success message is generic. Consider including more specific information about the operation, such as the bucket ID or data size.

- $.export("$summary", "Successfully wrote data to bucket");
+ $.export("$summary", `Successfully wrote data to bucket: ${this.bucketId}`);
components/influxdb_cloud/actions/update-bucket/update-bucket.mjs (2)

38-39: Fix typo in label.

There's a typo in the label for shardGroupDurationSeconds - it says "Shared" instead of "Shard".

-      label: "Shared Group Duration Seconds",
+      label: "Shard Group Duration Seconds",

43-61: Consider conditional inclusion of retention rules.

The action always includes retention rules in the update payload, even if neither everySeconds nor shardGroupDurationSeconds is provided. Consider conditionally including them only when at least one relevant parameter is specified.

-        retentionRules: [
-          {
-            everySeconds: this.everySeconds,
-            shardGroupDurationSeconds: this.shardGroupDurationSeconds,
-            type: "expire",
-          },
-        ],
+        ...(this.everySeconds !== undefined || this.shardGroupDurationSeconds !== undefined
+          ? {
+              retentionRules: [
+                {
+                  everySeconds: this.everySeconds,
+                  shardGroupDurationSeconds: this.shardGroupDurationSeconds,
+                  type: "expire",
+                },
+              ],
+            }
+          : {}),
components/influxdb_cloud/sources/common/base.mjs (2)

60-63: Emit newest → oldest to keep chronological order

After slice(-max), the array keeps the newest items but the subsequent forEach still iterates from earliest to latest inside the sliced window.
If you intend to emit in true chronological order (oldest first) use slice(-max).reverse() or sort explicitly.


64-69: Potential memory spike when historical backlog is huge

items aggregates every unseen record before emitting. When a long period has elapsed (or the initial back-fill is large), this may hold thousands of objects in memory.
Stream the events immediately instead of buffering, or put an upper bound on collected items per page.

components/influxdb_cloud/influxdb_cloud.app.mjs (1)

48-60: Build URLs with the WHATWG URL helper to avoid double slash / missing slash edge-cases

Manual string concatenation can yield //api/v2 or duplicate segments if the base already contains /api/v2. The built-in URL class removes that category of bugs and keeps the code intent clearer.

-      let { url } = this.$auth;
-      if (version === "v2") {
-        url += (url.endsWith("/")
-          ? ""
-          : "/") + "api/v2";
-      } else {
-        url = url.endsWith("/")
-          ? url.slice(0, -1)
-          : url;
-      }
-      return url;
+      const base = new URL(this.$auth.url);
+      if (version === "v2") base.pathname = `${base.pathname.replace(/\/$/, "")}/api/v2`;
+      return base.toString().replace(/\/$/, "");
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 759d1f6 and 793dcc6.

📒 Files selected for processing (10)
  • components/influxdb_cloud/actions/invoke-script/invoke-script.mjs (1 hunks)
  • components/influxdb_cloud/actions/update-bucket/update-bucket.mjs (1 hunks)
  • components/influxdb_cloud/actions/write-data/write-data.mjs (1 hunks)
  • components/influxdb_cloud/common/utils.mjs (1 hunks)
  • components/influxdb_cloud/influxdb_cloud.app.mjs (1 hunks)
  • components/influxdb_cloud/package.json (1 hunks)
  • components/influxdb_cloud/sources/common/base.mjs (1 hunks)
  • components/influxdb_cloud/sources/new-bucket-created/new-bucket-created.mjs (1 hunks)
  • components/influxdb_cloud/sources/new-script-created/new-script-created.mjs (1 hunks)
  • components/influxdb_cloud/sources/new-task-completed/new-task-completed.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (11)
components/influxdb_cloud/common/utils.mjs (1)

1-7: Good error handling in the JSON parsing utility

The function correctly handles potential JSON parsing errors by returning the original value when parsing fails, which is a robust approach for optional JSON parsing.

components/influxdb_cloud/package.json (1)

3-3: Version bump is appropriate

The version bump from 0.6.0 to 0.7.0 correctly follows semantic versioning principles for the addition of new features (invoke-script, write-data actions).

components/influxdb_cloud/actions/invoke-script/invoke-script.mjs (1)

18-23: Well-defined parameters object with clear description

The params property is properly defined with a comprehensive description explaining how the key-value pairs map to the script parameters.

components/influxdb_cloud/actions/write-data/write-data.mjs (2)

17-21: Good documentation for line protocol format

The description for the data parameter includes both a link to the documentation and a helpful example, which is excellent for user guidance.


22-33: Well-defined precision parameter with appropriate options

The precision parameter is properly defined with clear options that match the InfluxDB API requirements.

components/influxdb_cloud/sources/new-bucket-created/new-bucket-created.mjs (1)

1-23: Looks good - well-structured source component.

The implementation follows a clean pattern of extending the common base source to create a specialized bucket monitoring source. The code reuses shared logic while only implementing the bucket-specific methods needed. The source properly utilizes the InfluxDB Cloud app's bucket listing functionality and provides appropriate summary formatting.

components/influxdb_cloud/sources/new-task-completed/new-task-completed.mjs (1)

1-26: LGTM - well-structured source component with appropriate timestamp tracking.

This source component correctly extends the common base source with task-specific implementations. The addition of the getTsField() method that returns "latestCompleted" is particularly important for properly tracking completed tasks based on their timestamp, enabling accurate incremental polling.

components/influxdb_cloud/sources/new-script-created/new-script-created.mjs (1)

1-23: LGTM - consistent with other source components.

This source follows the same pattern as the other InfluxDB Cloud source components, which promotes code consistency across the integration. The implementation correctly specializes for script resources while leveraging the shared polling and event emission logic from the common base.

components/influxdb_cloud/actions/update-bucket/update-bucket.mjs (2)

50-56: Validate the API behavior when passing retention rules with default values.

When this.everySeconds is set to its default value (2592000) but shardGroupDurationSeconds is not provided, ensure that the API correctly handles a retention rule with only one of the two parameters specified.


1-8: Overall implementation looks good.

The action is well-structured with appropriate metadata, documentation links, and version information. The properties have descriptive labels and clear descriptions that help users understand what they're configuring.

components/influxdb_cloud/influxdb_cloud.app.mjs (1)

12-25: Off-by-one risk in option paging

page supplied by Pipedream starts at 0. When page = 0 you request offset = 0, good; when page = 1 you request offset = 50, also fine.
Just confirm the API uses absolute offset, not “page number”. If the API expects offset = (page-1) * limit, the current calculation will skip the first page.
Double-check with real data.

luancazarine
luancazarine previously approved these changes Apr 29, 2025
Copy link
Collaborator

@luancazarine luancazarine 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, I just added a small suggestion. But to save time, I'm moving it to "Ready for QA"

Co-authored-by: Luan Cazarine <luanhc@gmail.com>
@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit 6a181ef into master Apr 30, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-15155 branch April 30, 2025 20: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] influxdb_cloud
2 participants