Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 23, 2025

Resolves #16259

Summary by CodeRabbit

  • New Features
    • Introduced a suite of Notion API key-based actions, including creating, updating, duplicating, appending, searching, and retrieving pages, blocks, comments, and database content.
    • Added new event sources for detecting new comments, new databases, new pages, updated pages, and page/subpage updates in Notion.
  • Enhancements
    • Improved Notion API integration with a utility for streamlined property configuration and a new Notion client setup.
    • Updated package dependencies and version for enhanced compatibility and stability.

@vercel
Copy link

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 23, 2025

Walkthrough

This update introduces a new Notion (Internal Integration - API Key) app and a suite of actions and sources tailored for it. The implementation wraps and adapts existing common Notion actions and sources to work with API key authentication, utilizing a utility function to adjust property definitions for compatibility. The app module is enhanced to instantiate the Notion client using an API key. The package manifest is updated to include necessary dependencies. The changes enable the Notion API key app to support various actions (e.g., querying databases, creating pages) and sources (e.g., new page, updated page) by leveraging and customizing existing shared logic.

Changes

Files/Paths Change Summary
components/notion_api_key/actions/*/*.mjs Added new action modules for append-block, create-comment, create-page, create-page-from-database, duplicate-page, query-database, retrieve-block, retrieve-database-content, retrieve-database-schema, retrieve-page, retrieve-page-property-item, search, and update-page. Each wraps a common Notion action for API key integration.
components/notion_api_key/sources/*/*.mjs Added new source modules for new-comment-created, new-database, new-page, page-or-subpage-updated, updated-page, and updated-page-id, each adapting a common Notion source for API key use.
components/notion_api_key/common/utils.mjs Introduced adjustPropDefinitions utility to adapt prop definitions for the API key app context.
components/notion_api_key/notion_api_key.app.mjs Enhanced app module: imports Notion client, integrates common methods, adds _getNotionClient, removes unused properties.
components/notion_api_key/package.json Updated version to 0.1.0, added dependencies for @notionhq/client and @pipedream/notion.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant APIKeyApp
    participant CommonAction
    participant NotionClient

    User->>APIKeyApp: Triggers action (e.g., Create Page)
    APIKeyApp->>CommonAction: Calls shared logic with adjusted props
    APIKeyApp->>NotionClient: Instantiates client with API key
    CommonAction->>NotionClient: Performs Notion API operation
    NotionClient-->>CommonAction: Returns result
    CommonAction-->>APIKeyApp: Returns processed data
    APIKeyApp-->>User: Returns final result
Loading

Assessment against linked issues

Objective Addressed Explanation
Add Notion (Internal Integration - API Key) app (#16259)
Support Query Databases action for API key app (#16259)
Support Create Page from Database action for API key app (#16259)
Reuse/adapt other existing Notion actions and triggers for API key app (#16259)

Suggested labels

ai-assisted

Suggested reviewers

  • GTFalcao

Poem

A rabbit hopped through Notion's door,
With API keys and actions galore!
Wrapped and adapted, each trigger and flow,
Now Notion with secrets is ready to go.
The code is all tidy, dependencies new—
Hooray for the builders, and carrots for you! 🥕

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/notion_api_key/sources/updated-page-id/updated-page-id.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 bc019ed and 1105c2a.

📒 Files selected for processing (1)
  • components/notion_api_key/sources/updated-page-id/updated-page-id.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/notion_api_key/sources/updated-page-id/updated-page-id.mjs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components

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

🧹 Nitpick comments (2)
components/notion_api_key/notion_api_key.app.mjs (1)

10-14: Consider making the Notion API version configurable

The Notion API version "2022-02-22" is hardcoded. To future-proof the implementation, consider making this configurable or using the latest version by default.

  _getNotionClient() {
    return new notion.Client({
      auth: this.$auth.api_secret,
-     notionVersion: "2022-02-22",
+     notionVersion: this.$auth.api_version || "2022-02-22",
    });
  },
components/notion_api_key/common/utils.mjs (1)

1-40: Well-designed utility function for property definition adjustments

This utility intelligently handles different types of property definitions to adapt them for use with the Notion API key app:

  • String properties are preserved
  • Properties with propDefinition have their app reference updated
  • App-type properties without propDefinition are removed
  • All other properties are maintained as-is

The implementation is robust and serves as the foundation for all the component adaptations in this PR.

Consider adding defensive checks for edge cases where props might be null or undefined, although this is unlikely in the current controlled usage.

export function adjustPropDefinitions(props, app) {
+  if (!props) return {};
  return Object.fromEntries(
    Object.entries(props).map(([
      key,
      prop,
    ]) => {
      if (typeof prop === "string") return [
        key,
        prop,
      ];
      const {
        propDefinition, ...otherValues
      } = prop;
-      if (propDefinition) {
+      if (propDefinition && Array.isArray(propDefinition) && propDefinition.length > 0) {
        const [
          , ...otherDefs
        ] = propDefinition;
        return [
          key,
          {
            propDefinition: [
              app,
              ...otherDefs,
            ],
            ...otherValues,
          },
        ];
      }
      return [
        key,
        otherValues.type === "app"
          ? null
          : otherValues,
      ];
    })
      .filter(([
        , value,
      ]) => value),
  );
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 106b401 and bc019ed.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (22)
  • components/notion_api_key/actions/append-block/append-block.mjs (1 hunks)
  • components/notion_api_key/actions/create-comment/create-comment.mjs (1 hunks)
  • components/notion_api_key/actions/create-page-from-database/create-page-from-database.mjs (1 hunks)
  • components/notion_api_key/actions/create-page/create-page.mjs (1 hunks)
  • components/notion_api_key/actions/duplicate-page/duplicate-page.mjs (1 hunks)
  • components/notion_api_key/actions/query-database/query-database.mjs (1 hunks)
  • components/notion_api_key/actions/retrieve-block/retrieve-block.mjs (1 hunks)
  • components/notion_api_key/actions/retrieve-database-content/retrieve-database-content.mjs (1 hunks)
  • components/notion_api_key/actions/retrieve-database-schema/retrieve-database-schema.mjs (1 hunks)
  • components/notion_api_key/actions/retrieve-page-property-item/retrieve-page-property-item.mjs (1 hunks)
  • components/notion_api_key/actions/retrieve-page/retrieve-page.mjs (1 hunks)
  • components/notion_api_key/actions/search/search.mjs (1 hunks)
  • components/notion_api_key/actions/update-page/update-page.mjs (1 hunks)
  • components/notion_api_key/common/utils.mjs (1 hunks)
  • components/notion_api_key/notion_api_key.app.mjs (1 hunks)
  • components/notion_api_key/package.json (2 hunks)
  • components/notion_api_key/sources/new-comment-created/new-comment-created.mjs (1 hunks)
  • components/notion_api_key/sources/new-database/new-database.mjs (1 hunks)
  • components/notion_api_key/sources/new-page/new-page.mjs (1 hunks)
  • components/notion_api_key/sources/page-or-subpage-updated/page-or-subpage-updated.mjs (1 hunks)
  • components/notion_api_key/sources/updated-page-by-id/updated-page-by-id.mjs (1 hunks)
  • components/notion_api_key/sources/updated-page/updated-page.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Pull Request Checks
components/notion_api_key/sources/updated-page-by-id/updated-page-by-id.mjs

[error] 1-1: Module not found error: Cannot find module '@pipedream/notion/sources/updated-page-by-id/updated-page-by-id.mjs' imported from this file. Node.js ERR_MODULE_NOT_FOUND.

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
🔇 Additional comments (23)
components/notion_api_key/package.json (2)

3-3: Approve version bump
Bumping the package version to 0.1.0 appropriately reflects the introduction of the Notion API Key integration.


14-18: Verify added dependencies and their versions
Please confirm that:

  • @notionhq/client@^2.3.0 is the minimum required version and compatible with our usage.
  • @pipedream/notion@^0.6.2 aligns with the shared module’s latest stable release.
    A quick check against npm (or a vulnerability scan) would ensure there are no breaking changes or known security issues.
components/notion_api_key/actions/search/search.mjs (1)

1-22: Pattern-consistent action customization looks good
The module correctly:

  • Imports the local notion_api_key.app.mjs and the base Notion search action.
  • Uses adjustPropDefinitions to inject the app context and filter out redundant props.
  • Spreads the original action config (others), then overrides key, version, name, description, and props (including the notion app instance).
    This implementation aligns perfectly with other API key–based action modules.
components/notion_api_key/sources/new-page/new-page.mjs (1)

1-22: Source module correctly bound to API key app
Imports, prop adjustments, and the export structure follow the established pattern for API key–based sources:

  • Destructures metadata from the common new-page source.
  • Applies adjustPropDefinitions and injects notion: app into props.
  • Sets a unique key and initial version.
    Consistent with other customized sources.
components/notion_api_key/actions/append-block/append-block.mjs (1)

1-22: Append-block action adaptation is correct
The file faithfully replicates the integration pattern:

  • Local app and common action imports.
  • Metadata destructuring and adjustPropDefinitions usage.
  • Export with overridden key, version, metadata, and injected notion prop.
    No issues found.
components/notion_api_key/actions/create-page/create-page.mjs (1)

1-22: Create-page action customization approved
Consistent approach:

  • Imports the API key app and common create-page action.
  • Destructures and adjusts props via the shared utility.
  • Exports merged config with a unique key, version, and full metadata.
    Matches the pattern across all new components.
components/notion_api_key/actions/update-page/update-page.mjs (1)

1-22: Well-structured module for Notion API key integration!

This implementation follows a clean, modular approach by reusing the existing Notion action while adapting it for API key authentication. The structure effectively:

  • Imports the necessary dependencies
  • Extracts and reuses metadata from the common implementation
  • Adjusts props for API key compatibility
  • Exports a properly configured module with appropriate namespace and version
components/notion_api_key/actions/retrieve-page-property-item/retrieve-page-property-item.mjs (1)

1-22: Consistent implementation pattern maintained!

This module correctly follows the same pattern established in other Notion API key integration files, maintaining consistency across the component. The implementation efficiently:

  • Reuses the common Notion component
  • Properly namespaces the action with "notion_api_key-" prefix
  • Adjusts property definitions for API key compatibility
  • Sets appropriate version number
components/notion_api_key/sources/updated-page/updated-page.mjs (1)

1-22: Pattern consistently applied to source components!

The implementation correctly extends the established pattern to Notion sources, demonstrating a systematic approach across the entire integration. The code:

  • Maintains the same clean structure used in action components
  • Properly imports from the common Notion source
  • Correctly namespaces the event source
  • Adjusts props for API key authentication

This consistency between actions and sources shows thoughtful design across component types.

components/notion_api_key/actions/create-page-from-database/create-page-from-database.mjs (1)

1-22: Consistent pattern continues to be well applied!

This module maintains the established pattern for adapting Notion components to use API key authentication. The implementation:

  • Follows the same clean structure as other components
  • Properly reuses common functionality
  • Adjusts properties appropriately for the API key context
  • Uses correct namespacing and versioning

Looking at all the reviewed files, the PR demonstrates an excellent approach to component migration by:

  1. Maintaining consistent structure across different component types
  2. Maximizing code reuse from the existing Notion integration
  3. Properly namespacing all components with the "notion_api_key-" prefix
  4. Using utility functions to standardize property adjustments
components/notion_api_key/sources/updated-page-by-id/updated-page-by-id.mjs (1)

1-22: Implementation pattern looks good

The code follows a clean pattern for adapting common Notion components to work with the API key authentication. It correctly:

  1. Extracts metadata from the common source
  2. Adjusts property definitions for the new context
  3. Sets a unique key and version
  4. Includes the Notion API key app instance

This approach promotes code reuse while providing proper customization for the API key integration.

🧰 Tools
🪛 GitHub Actions: Pull Request Checks

[error] 1-1: Module not found error: Cannot find module '@pipedream/notion/sources/updated-page-by-id/updated-page-by-id.mjs' imported from this file. Node.js ERR_MODULE_NOT_FOUND.

components/notion_api_key/actions/duplicate-page/duplicate-page.mjs (2)

1-22: Consistent implementation pattern

The code maintains the same pattern as other components in this PR, which is excellent for maintainability. It properly customizes the common Notion action for the API key integration while reusing most of the original functionality.


2-2:

❓ Verification inconclusive

Verify the module import path

Similar to the source file, ensure that the path @pipedream/notion/actions/duplicate-page/duplicate-page.mjs is correct and the module exists in the package.


🏁 Script executed:

#!/bin/bash
# Verify if the specific module exists
if [ -f "node_modules/@pipedream/notion/actions/duplicate-page/duplicate-page.mjs" ]; then
  echo "Module exists at the specified path"
else
  echo "Module does not exist at the specified path"
  # List available action modules to find the correct path
  find node_modules/@pipedream/notion/actions -type f -name "*.mjs" | grep -i "duplicate"
fi

Length of output: 344


Verify the module import path
It looks like the file @pipedream/notion/actions/duplicate-page/duplicate-page.mjs wasn’t found in your local node_modules. Please ensure:

  • The @pipedream/notion package is installed (npm install @pipedream/notion).
  • The file exists at that exact path under node_modules/@pipedream/notion/actions/duplicate-page/duplicate-page.mjs.
  • If the module has moved or been renamed, update the import to point to the correct location.
components/notion_api_key/notion_api_key.app.mjs (1)

1-17: Implementation looks good

The app module effectively extends the common Notion module while adding API key specific functionality. The pattern of reusing common functionality while providing customization for API key authentication is well-implemented.

components/notion_api_key/actions/retrieve-database-content/retrieve-database-content.mjs (1)

1-22: Consistent implementation pattern

The code maintains the same clean pattern as other components in this PR, properly customizing the common Notion action for the API key integration while reusing most of the original functionality.

components/notion_api_key/actions/retrieve-block/retrieve-block.mjs (1)

1-22: Well-structured adaptation of the common Notion retrieve-block action

This implementation cleanly adapts the common Notion retrieve-block action to work with the API key authentication. The pattern of extracting metadata, adjusting properties, and setting a unique key is effective and maintainable.

components/notion_api_key/sources/new-comment-created/new-comment-created.mjs (1)

1-22: Clean adaptation of the Notion comment source for API key authentication

The implementation follows the same consistent pattern seen across other components, adapting the common Notion source while maintaining its core functionality. The component is properly namespaced with the notion_api_key- prefix and correctly integrates with the API key app.

components/notion_api_key/actions/retrieve-database-schema/retrieve-database-schema.mjs (1)

1-22: Consistent adaptation of the database schema retrieval action

This follows the same effective pattern used across all Notion API key components - importing the common functionality, adjusting property definitions, and exporting a properly configured action with the right app context.

components/notion_api_key/sources/new-database/new-database.mjs (1)

1-22: Properly implemented source for new database events

The implementation maintains consistency with other components in the Notion API key integration, allowing for code reuse while ensuring the component is properly configured for API key authentication.

components/notion_api_key/actions/create-comment/create-comment.mjs (1)

1-22: The implementation looks well-structured and follows a consistent pattern.

This code effectively adapts the common Notion "create-comment" action to work with the Notion API Key integration. The approach of reusing existing functionality while customizing just the necessary components is an efficient pattern.

The code:

  1. Imports the required dependencies (app, common action, and utility function)
  2. Extracts metadata from the common action
  3. Adjusts property definitions for the Notion API Key context
  4. Exports a customized action that maintains the original functionality while integrating with the new app context
components/notion_api_key/actions/query-database/query-database.mjs (1)

1-22: Clean implementation that follows the established pattern.

This implementation of the "query-database" action for the Notion API Key integration follows the same consistent pattern as other actions in this PR. It properly:

  1. Imports the app instance specific to the Notion API Key
  2. Leverages common functionality from the Notion package
  3. Uses the utility function to adapt property definitions
  4. Exports a customized action with the appropriate key and version

The consistent structure across actions promotes maintainability and reduces the potential for bugs.

components/notion_api_key/actions/retrieve-page/retrieve-page.mjs (1)

1-22: Implementation correctly adapts the retrieve-page action.

The code follows the established pattern for adapting Notion actions to work with the Notion API Key integration:

  1. Imports the necessary dependencies
  2. Extracts relevant metadata (name, description, type) from the common action
  3. Adjusts property definitions to work with the Notion API Key context
  4. Exports a customized action with a proper namespace, version, and props

This approach maximizes code reuse while providing the necessary customization for the new authentication context.

components/notion_api_key/sources/page-or-subpage-updated/page-or-subpage-updated.mjs (1)

1-22: Source implementation follows the consistent adaptation pattern.

This source module for detecting updates to Notion pages or subpages correctly implements the same adaptation pattern used throughout this PR:

  1. Imports the app instance and common source module
  2. Uses the adjustPropDefinitions utility function to modify property definitions
  3. Creates a properly namespaced key for the new source
  4. Includes the Notion API Key app instance in the props

This consistent approach across both actions and sources ensures that the entire Notion API Key integration works coherently as a unified component.

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 @michelle0927 lgtm! Ready for QA!

@michelle0927 michelle0927 merged commit 4212f14 into master Apr 25, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-16259 branch April 25, 2025 14:42
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.

[APP] Notion (Internal Integration - API Key)

3 participants