-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Notion API Key - migrate components from Notion #16412
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 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
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
Assessment against linked issues
Suggested labels
Suggested reviewers
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/notion_api_key/sources/updated-page-id/updated-page-id.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 due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
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: 2
🧹 Nitpick comments (2)
components/notion_api_key/notion_api_key.app.mjs (1)
10-14: Consider making the Notion API version configurableThe 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 adjustmentsThis 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
propDefinitionhave their app reference updated- App-type properties without
propDefinitionare 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
propsmight 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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 to0.1.0appropriately reflects the introduction of the Notion API Key integration.
14-18: Verify added dependencies and their versions
Please confirm that:
@notionhq/client@^2.3.0is the minimum required version and compatible with our usage.@pipedream/notion@^0.6.2aligns 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.mjsand the base Notion search action.- Uses
adjustPropDefinitionsto inject the app context and filter out redundant props.- Spreads the original action config (
others), then overrideskey,version,name,description, andprops(including thenotionapp 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
adjustPropDefinitionsand injectsnotion: appintoprops.- Sets a unique
keyand initialversion.
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
adjustPropDefinitionsusage.- Export with overridden
key,version, metadata, and injectednotionprop.
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:
- Maintaining consistent structure across different component types
- Maximizing code reuse from the existing Notion integration
- Properly namespacing all components with the "notion_api_key-" prefix
- 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 goodThe code follows a clean pattern for adapting common Notion components to work with the API key authentication. It correctly:
- Extracts metadata from the common source
- Adjusts property definitions for the new context
- Sets a unique key and version
- 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 patternThe 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.mjsis 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" fiLength of output: 344
Verify the module import path
It looks like the file@pipedream/notion/actions/duplicate-page/duplicate-page.mjswasn’t found in your localnode_modules. Please ensure:
- The
@pipedream/notionpackage 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 goodThe 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 patternThe 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 actionThis implementation cleanly adapts the common Notion
retrieve-blockaction 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 authenticationThe 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 actionThis 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 eventsThe 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:
- Imports the required dependencies (app, common action, and utility function)
- Extracts metadata from the common action
- Adjusts property definitions for the Notion API Key context
- 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:
- Imports the app instance specific to the Notion API Key
- Leverages common functionality from the Notion package
- Uses the utility function to adapt property definitions
- 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:
- Imports the necessary dependencies
- Extracts relevant metadata (name, description, type) from the common action
- Adjusts property definitions to work with the Notion API Key context
- 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:
- Imports the app instance and common source module
- Uses the adjustPropDefinitions utility function to modify property definitions
- Creates a properly namespaced key for the new source
- 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.
components/notion_api_key/sources/updated-page-by-id/updated-page-by-id.mjs
Outdated
Show resolved
Hide resolved
components/notion_api_key/actions/retrieve-database-content/retrieve-database-content.mjs
Show resolved
Hide resolved
jcortes
left a comment
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 lgtm! Ready for QA!
Resolves #16259
Summary by CodeRabbit