-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis 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
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
Assessment against linked issues
Poem
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
components/influxdb_cloud/actions/update-bucket/update-bucket.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 5
🧹 Nitpick comments (8)
components/influxdb_cloud/common/utils.mjs (1)
9-22
: Consider adding JSDoc comments for better documentationWhile 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 detailsWhile 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 detailsThe 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
norshardGroupDurationSeconds
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 orderAfter
slice(-max)
, the array keeps the newest items but the subsequentforEach
still iterates from earliest to latest inside the sliced window.
If you intend to emit in true chronological order (oldest first) useslice(-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 WHATWGURL
helper to avoid double slash / missing slash edge-casesManual string concatenation can yield
//api/v2
or duplicate segments if the base already contains/api/v2
. The built-inURL
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
📒 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 utilityThe 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 appropriateThe 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 descriptionThe 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 formatThe 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 optionsThe 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) butshardGroupDurationSeconds
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. Whenpage = 0
you requestoffset = 0
, good; whenpage = 1
you requestoffset = 50
, also fine.
Just confirm the API uses absolute offset, not “page number”. If the API expectsoffset = (page-1) * limit
, the current calculation will skip the first page.
Double-check with real data.
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, I just added a small suggestion. But to save time, I'm moving it to "Ready for QA"
components/influxdb_cloud/actions/update-bucket/update-bucket.mjs
Outdated
Show resolved
Hide resolved
Co-authored-by: Luan Cazarine <luanhc@gmail.com>
/approve |
Resolves #15155
Summary by CodeRabbit
New Features
Improvements