Skip to content

New Components - guru #16623

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 4 commits into from
May 13, 2025
Merged

New Components - guru #16623

merged 4 commits into from
May 13, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented May 9, 2025

Resolves #13217.

Summary by CodeRabbit

  • New Features

    • Introduced actions for creating Guru cards, linking tags to cards, and exporting cards to PDF.
    • Added instant event sources for new card creation, card updates, and announcement reads, enabling real-time automation.
    • Provided dynamic selection options for collections, folders, tags, and cards within the Guru integration.
  • Improvements

    • Updated integration structure and dependencies for enhanced functionality and maintainability.
  • Chores

    • Removed obsolete files and reorganized internal configuration.

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

vercel bot commented May 9, 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 May 13, 2025 0:19am
pipedream-docs ⬜️ Ignored (Inspect) May 13, 2025 0:19am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 13, 2025 0:19am

Copy link
Contributor

coderabbitai bot commented May 9, 2025

Walkthrough

This update introduces a new Guru integration package, implementing several actions and instant event sources for the Guru platform. It adds support for creating cards, linking tags, exporting cards to PDF, and emitting events for announcement reads, card creations, and card updates. Supporting utility modules, constants, and a comprehensive app definition are included.

Changes

File(s) Change Summary
components/guru/actions/add-tag-to-card/add-tag-to-card.mjs
.../create-card/create-card.mjs
.../export-card-to-pdf/export-card-to-pdf.mjs
Added new action modules for adding tags to cards, creating cards, and exporting cards to PDF in Guru.
components/guru/sources/announcement-read-instant/announcement-read-instant.mjs
.../test-event.mjs
.../card-updated-instant/card-updated-instant.mjs
.../test-event.mjs
.../new-card-instant/new-card-instant.mjs
.../test-event.mjs
Added new instant event source modules and sample event fixtures for announcement reads, card updates, and card creations.
components/guru/sources/common/base.mjs Added a common base module for webhook lifecycle management and event emission.
components/guru/common/constants.mjs Introduced and exported SHARE_STATUS_OPTIONS constant.
components/guru/common/utils.mjs Added and exported parseObject utility function for safe JSON parsing.
components/guru/guru.app.mjs Added new Guru app module with property definitions and API interaction methods.
components/guru/package.json Updated package metadata, entry point, version, and dependencies.
components/guru/.gitignore
components/guru/app/guru.app.ts
Deleted obsolete .gitignore and TypeScript app definition.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant GuruApp
    participant GuruAPI

    User->>Action: Trigger (e.g., create card, add tag)
    Action->>GuruApp: Call method (e.g., createCard, linkTagToCard)
    GuruApp->>GuruAPI: Make API request
    GuruAPI-->>GuruApp: Return response
    GuruApp-->>Action: Return result
    Action-->>User: Summary/confirmation
Loading
sequenceDiagram
    participant Guru
    participant WebhookSource
    participant BaseModule
    participant Platform

    Guru-->>WebhookSource: Send webhook event (e.g., card-created)
    WebhookSource->>BaseModule: Handle event (run method)
    BaseModule->>Platform: Emit event with summary and timestamp
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement announcement-read-instant source emitting 'alert-read' events (#13217)
Implement new-card-instant source emitting 'card-created' events (#13217)
Implement card-updated-instant source emitting 'card-updated' events (#13217)
Implement create-card action with required/optional props (#13217)
Implement add-tag-to-card action with card and tag IDs (#13217)
Implement export-folder-to-pdf action (#13217) Only export-card-to-pdf action is implemented; export-folder-to-pdf action is missing.

Suggested reviewers

  • jcortes

Poem

In Guru’s warren, new features sprout,
Cards and tags now hop about!
Announcements read, events appear,
With webhooks swift, there’s nothing to fear.
PDFs exported, actions abound—
CodeRabbit’s paws patter, making things sound.
🐇✨

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/guru/sources/common/base.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)

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 5c57d9a and 64eb713.

📒 Files selected for processing (1)
  • components/guru/sources/common/base.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/guru/sources/common/base.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

Sources
 - Announcement Read (Instant)
 - New Card (Instant)
 - Card Updated (Instant)

Actions
 - Create Card
 - Add Tag To Card
 - Export Card To PDF
@luancazarine luancazarine marked this pull request as ready for review May 12, 2025 19:54
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: 6

🧹 Nitpick comments (8)
components/guru/sources/new-card-instant/test-event.mjs (1)

2-9: Consider using different UUIDs for event, card, and collection identifiers.

Currently, the same UUID "64753163-9817-4500-9651-96177c32e3d1" is used for the event ID, cardId, and collectionId. While functionally valid for testing, using distinct identifiers would make the test event more realistic and prevent potential confusion when referencing these values.

  "id":"64753163-9817-4500-9651-96177c32e3d1",
  "eventType":"card-created",
  "user":"[email protected]",
  "eventDate":"2021-04-13T13:53:00.000+0000",
  "properties":{
-   "cardId":"64753163-9817-4500-9651-96177c32e3d1",
-   "collectionId":"64753163-9817-4500-9651-96177c32e3d1",
+   "cardId":"a5b86572-1c3d-4e8f-9a7b-3d2e6f8c9d0e",
+   "collectionId":"b6c97683-2d4e-5f9a-0b8c-4e3f7a9d0b1f",
    "source": "UI"
components/guru/common/utils.mjs (2)

1-24: Add JSDoc comments to document the parseObject utility.

This utility function handles various input formats well, but would benefit from documentation explaining its purpose and behavior.

+/**
+ * Parses JSON strings into objects safely, without throwing errors.
+ * When given an array, it attempts to parse each string element.
+ * When given a non-array string, it attempts to parse it as JSON.
+ * Returns the input unchanged if it's not a string or parsing fails.
+ *
+ * @param {any} obj - The input to parse (string, array, or any other type)
+ * @returns {any} - Parsed object(s) or the original input if parsing fails
+ */
export const parseObject = (obj) => {
  if (!obj) return undefined;

  if (Array.isArray(obj)) {
    return obj.map((item) => {
      if (typeof item === "string") {
        try {
          return JSON.parse(item);
        } catch (e) {
          return item;
        }
      }
      return item;
    });
  }
  if (typeof obj === "string") {
    try {
      return JSON.parse(obj);
    } catch (e) {
      return obj;
    }
  }
  return obj;
};

2-2: Consider handling empty strings consistently.

Currently, empty strings will return undefined because they're falsy in JavaScript. Consider whether empty strings should return themselves rather than undefined for more consistent behavior.

-  if (!obj) return undefined;
+  if (obj === null || obj === undefined) return undefined;
components/guru/actions/add-tag-to-card/add-tag-to-card.mjs (1)

17-25: Consider using singular naming for the tag property.

The property is named "tags" but the description and implementation suggest it only accepts a single tag ID. Consider renaming this property to "tagId" to better match its usage and improve clarity.

-    tags: {
+    tagId: {
      propDefinition: [
        guru,
-       "tags",
+       "tagId",
      ],
      type: "string",
      label: "Tag",
      description: "The ID of the tag to add to the card",
    },

Update the run method accordingly:

    const response = await this.guru.linkTagToCard({
      $,
      cardId: this.cardId,
-     tagId: this.tags,
+     tagId: this.tagId,
    });

-   $.export("$summary", `Successfully linked tag ${this.tags} to card ${this.cardId}`);
+   $.export("$summary", `Successfully linked tag ${this.tagId} to card ${this.cardId}`);
components/guru/sources/common/base.mjs (2)

19-21: Add abstract method placeholders

You're relying on child components to implement getEventType() and getSummary() methods, but they aren't defined here as abstract methods.

Consider adding placeholder methods that throw errors to make it clear they need to be implemented:

  getExtraData() {
    return {};
  },
+ getEventType() {
+   throw new Error("getEventType() must be implemented by the child component");
+ },
+ getSummary(body) {
+   throw new Error("getSummary(body) must be implemented by the child component");
+ },

40-46: Handle potential errors in event date parsing

The Date.parse() method will return NaN if the date string is invalid, which could lead to unexpected behavior.

Add a fallback for the timestamp:

  async run({ body }) {
+   const timestamp = Date.parse(body.eventDate) || Date.now();
    this.$emit(body, {
      id: body.id,
      summary: this.getSummary(body),
-     ts: Date.parse(body.eventDate),
+     ts: timestamp,
    });
  },
components/guru/actions/create-card/create-card.mjs (1)

51-65: Add error handling for API call

The current implementation doesn't handle potential API errors explicitly.

Wrap the API call in a try/catch block:

   async run({ $ }) {
+    try {
       const response = await this.guru.createCard({
         $,
         data: {
           preferredPhrase: this.title,
           content: this.content,
           shareStatus: this.shareStatus,
           collection: {
             id: this.collection,
           },
           folderIds: parseObject(this.folderIds),
           tags: parseObject(this.tags)?.map((item) => ({
             id: item,
           })),
         },
       });
+      $.export("$summary", `Created card "${this.title}" successfully`);
+      return response;
+    } catch (error) {
+      $.export("$summary", `Failed to create card: ${error.message}`);
+      throw error;
+    }
-    $.export("$summary", `Created card "${this.title}" successfully`);
-    return response;
   },
components/guru/guru.app.mjs (1)

149-188: Comprehensive set of API methods for listing resources and managing webhooks.

The implementation includes methods for:

  • Listing various Guru resources (collections, folders, tags, cards)
  • Creating and deleting webhooks for the instant sources

The listCards() method correctly sets returnFullResponse: true to access the headers needed for pagination.

A small improvement would be to add error handling for API responses, particularly for cases where expected data might be missing.

Consider adding basic error handling to the API methods, particularly for the list* methods that are used in property options, to gracefully handle empty responses or API errors:

listTags({
  teamId, ...opts
}) {
  return this._makeRequest({
    path: `/teams/${teamId}/tagcategories`,
    ...opts,
+   }).catch(error => {
+     console.error(`Error listing tags: ${error.message}`);
+     return []; // Return empty array to prevent options loader failures
+   });
  });
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db6a41c and 5c57d9a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • components/guru/.gitignore (0 hunks)
  • components/guru/actions/add-tag-to-card/add-tag-to-card.mjs (1 hunks)
  • components/guru/actions/create-card/create-card.mjs (1 hunks)
  • components/guru/actions/export-card-to-pdf/export-card-to-pdf.mjs (1 hunks)
  • components/guru/app/guru.app.ts (0 hunks)
  • components/guru/common/constants.mjs (1 hunks)
  • components/guru/common/utils.mjs (1 hunks)
  • components/guru/guru.app.mjs (1 hunks)
  • components/guru/package.json (1 hunks)
  • components/guru/sources/announcement-read-instant/announcement-read-instant.mjs (1 hunks)
  • components/guru/sources/announcement-read-instant/test-event.mjs (1 hunks)
  • components/guru/sources/card-updated-instant/card-updated-instant.mjs (1 hunks)
  • components/guru/sources/card-updated-instant/test-event.mjs (1 hunks)
  • components/guru/sources/common/base.mjs (1 hunks)
  • components/guru/sources/new-card-instant/new-card-instant.mjs (1 hunks)
  • components/guru/sources/new-card-instant/test-event.mjs (1 hunks)
💤 Files with no reviewable changes (2)
  • components/guru/.gitignore
  • components/guru/app/guru.app.ts
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/guru/sources/card-updated-instant/card-updated-instant.mjs

[warning] 7-7:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name

🔇 Additional comments (15)
components/guru/common/constants.mjs (1)

1-4: Clean, well-defined constant for share status options.

The constant clearly defines the available share status options for Guru cards, which helps maintain consistency throughout the integration.

components/guru/package.json (3)

3-3: Version bump to 0.1.0 appropriately reflects new features.

The version increase from 0.0.3 to 0.1.0 correctly follows semantic versioning for the addition of new components.


5-5: Simplified main entry point location.

Changing the main entry point from "dist/app/guru.app.mjs" to "guru.app.mjs" simplifies imports and file structure.


15-16: Added dependency on Pipedream platform package.

Adding the @pipedream/platform dependency formalizes the integration's reliance on the Pipedream framework.

components/guru/sources/announcement-read-instant/test-event.mjs (1)

1-11: Test event structure looks good and matches expected Guru webhook payload.

The test event object correctly models a Guru announcement read event with the required properties:

  • Unique id field
  • Proper eventType ("alert-read")
  • User identification
  • Timestamp in ISO 8601 format
  • Properties containing relevant IDs for the card and collection

This test fixture will work well for simulating webhook payloads during development and testing.

components/guru/sources/card-updated-instant/test-event.mjs (1)

1-11: Test event structure looks good and matches expected Guru webhook payload.

The test event object correctly models a Guru card updated event with the required properties:

  • Unique id field
  • Proper eventType ("card-updated")
  • User identification
  • Timestamp in ISO 8601 format
  • Properties containing relevant IDs for the card and collection

This test fixture will work well for simulating webhook payloads during development and testing.

components/guru/actions/add-tag-to-card/add-tag-to-card.mjs (2)

1-2: Import looks good.

The module correctly imports the Guru app to utilize its API methods.


3-26: Component definition looks good with clear metadata and properties.

The action component is well structured with:

  • Descriptive name and key
  • Helpful description with documentation link
  • Appropriate version for a new component (0.0.1)
  • Correctly typed as "action"
  • Well-defined props using propDefinitions from the Guru app
components/guru/sources/card-updated-instant/card-updated-instant.mjs (3)

1-3: Imports look good.

The module correctly imports the common base functionality and sample event for testing.


12-20: Methods implementation looks good.

The source component correctly:

  • Extends common methods from the base
  • Specifies the event type as "card-updated"
  • Provides a clear summary format with the card ID

The implementation follows best practices for extending the base component.


21-22: Sample emitter assignment looks good.

Correctly assigns the imported test event as the sample emitter for this source.

components/guru/sources/new-card-instant/new-card-instant.mjs (1)

1-22: Looks good!

The implementation correctly extends the base component and implements the required methods. The summary clearly identifies the new card by its ID.

components/guru/sources/announcement-read-instant/announcement-read-instant.mjs (1)

1-22: Clean implementation of an instant Guru announcement read source component.

This component extends a common base module and correctly implements the specific functionality for handling announcement read events. The component properly defines:

  1. A unique key identifier
  2. Clear name and description with documentation link
  3. Appropriate dedupe strategy
  4. Required methods for event handling:
    • getEventType() that returns the correct event type "alert-read"
    • getSummary() to format the event output

The implementation follows the expected pattern for Pipedream instant source components.

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

1-104: Well-structured app definition with comprehensive property definitions.

The app module provides a clean implementation of property definitions with async option loaders for collections, folders, tags, and cards. The authentication setup correctly uses the username and API key from app authentication.

The property definitions follow best practices:

  • Each includes descriptive labels and descriptions
  • Option loaders correctly handle API responses and transform them to the expected format
  • The card ID option loader properly implements pagination using the Link header

105-148: Well-implemented API request methods with proper encapsulation.

The implementation provides:

  • A generic _makeRequest() method that encapsulates common request logic
  • Specific methods for user info, card creation, and tag linking
  • Proper handling of HTTP methods, paths, and additional options

The exportCardToPdf() method correctly sets responseType: "stream" to handle binary data for PDF downloads.

jcortes
jcortes previously approved these changes May 12, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @luancazarine lgtm! Just a minor change. Ready for QA!

@luancazarine
Copy link
Collaborator Author

/approve

@luancazarine luancazarine merged commit 848305f into master May 13, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-13217 branch May 13, 2025 15:43
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] guru
2 participants