Skip to content

New Components - pexels #16498

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

New Components - pexels #16498

merged 7 commits into from
May 7, 2025

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Apr 30, 2025

Resolves #16496.

Summary by CodeRabbit

  • New Features
    • Added integration with Pexels, enabling users to search for photos, retrieve photo details, and download photos directly.
    • Introduced sources that emit events for new curated photos and photos matching specific search queries.
    • Provided filtering options for photo searches, including orientation, size, and color.
  • Improvements
    • Enhanced user experience with predefined option lists for photo orientation, size, and color selection.

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

vercel bot commented Apr 30, 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 6, 2025 11:46am
pipedream-docs ⬜️ Ignored (Inspect) May 6, 2025 11:46am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 6, 2025 11:46am

Copy link
Contributor

coderabbitai bot commented Apr 30, 2025

Walkthrough

This update introduces a comprehensive Pexels integration, adding actions for searching photos, retrieving photo details, and downloading photos, as well as polling sources for new curated photos and new photos by search. It includes supporting constants, sample event data, and a fully implemented Pexels app module with API interaction and pagination.

Changes

Files/Group Change Summary
components/pexels/actions/download-photo/download-photo.mjs New action to download a Pexels photo by ID and save it to a specified file path, streaming the file from the API and handling file system operations.
components/pexels/actions/get-photo-details/get-photo-details.mjs New action to retrieve detailed information about a photo using its ID from the Pexels API.
components/pexels/actions/search-photos/search-photos.mjs New action to search for photos on Pexels using a query and optional filters (orientation, size, color, etc.), returning matching results.
components/pexels/package.json Downgraded package version, updated "@pipedream/platform" dependency, and added "stream" as a new dependency.
components/pexels/pexels.app.mjs Full implementation of the Pexels app module, including property definitions, API request methods, and pagination support.
components/pexels/sources/common/base.mjs New base source component for polling Pexels APIs, handling deduplication, event emission, and state persistence.
components/pexels/sources/new-curated-photo/new-curated-photo.mjs New polling source that emits events for new curated photos added to Pexels, extending the base polling source.
components/pexels/sources/new-curated-photo/test-event.mjs New sample event data module exporting a curated photo object for testing or demonstration.
components/pexels/sources/new-photo-by-search/new-photo-by-search.mjs New polling source that emits events for new photos matching a search query, with filter options, extending the base polling source.
components/pexels/sources/new-photo-by-search/test-event.mjs New sample event data module exporting a photo object for testing or demonstration.
components/pexels/common/constants.mjs New module exporting arrays of orientation, size, and color options for use in filters and UI components.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant PexelsApp
    participant PexelsAPI
    participant FileSystem

    User->>Action: Trigger Download Photo with photoId, filePath
    Action->>PexelsApp: getPhoto(photoId)
    PexelsApp->>PexelsAPI: GET /photos/:id
    PexelsAPI-->>PexelsApp: Photo metadata (includes src URL)
    PexelsApp-->>Action: Photo metadata
    Action->>PexelsAPI: GET photo.src.original (stream)
    PexelsAPI-->>Action: Photo file stream
    Action->>FileSystem: Write stream to filePath
    FileSystem-->>Action: File write complete
    Action-->>User: Return summary with photoId and filePath
Loading
sequenceDiagram
    participant Source
    participant PexelsApp
    participant PexelsAPI
    participant DB
    participant User

    Source->>DB: Get last processed photo ID
    Source->>PexelsApp: searchPhotos/getCuratedPhotos(params)
    PexelsApp->>PexelsAPI: API Request
    PexelsAPI-->>PexelsApp: Photo results
    PexelsApp-->>Source: Photo results
    Source->>DB: Set last processed photo ID
    Source->>User: Emit new photo events (if new)
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement "new-photo-by-search" polling source (search, filter, emit new photos) (#16496)
Implement "new-curated-photo" polling source (emit new curated photos) (#16496)
Implement "search-photos" action (search with filters) (#16496)
Implement "get-photo-details" action (retrieve by ID) (#16496)
Implement "download-photo" action (download by ID, save to file) (#16496)

Suggested labels

action

Suggested reviewers

  • lcaresia

Poem

A rabbit hopped through fields of light,
Downloading photos, what a sight!
Searching, polling, details found,
Curated wonders all around.
With every hop, new art appears—
Pexels magic for bunny peers!
🐇✨

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/pexels/actions/search-photos/search-photos.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 8d28924 and 1655925.

📒 Files selected for processing (1)
  • components/pexels/actions/search-photos/search-photos.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/pexels/actions/search-photos/search-photos.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • 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.

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
 - New Photo By Search
 - New Curated Photo

Actions
 - Search Photos
 - Get Photo Details
 - Download Photo
@luancazarine luancazarine marked this pull request as ready for review May 1, 2025 14:45
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: 4

🧹 Nitpick comments (3)
components/pexels/sources/new-photo-by-search/test-event.mjs (1)

1-22: Well-structured test event with comprehensive photo metadata

The test event provides a complete representation of a Pexels photo object with all expected properties, which is excellent for testing. It includes ID, dimensions, URLs, photographer information, and all required image source variations.

One minor inconsistency: the alt text description (line 21) mentions "Brown Rocks During Golden Hour" which doesn't seem to match the image URL description "trees-during-day-3573351" (line 5).

-  "alt": "Brown Rocks During Golden Hour"
+  "alt": "Trees During Day"
components/pexels/sources/new-curated-photo/test-event.mjs (1)

1-22: Complete test event with all required fields

The test event provides a comprehensive representation of a curated Pexels photo with all the necessary fields for testing.

Similar to the previous file, there's an inconsistency between the alt text (line 21) which mentions "Brown Rocks During Golden Hour" and the image URL description (line 5) which indicates "woman-in-white-long-sleeved-top-and-skirt-standing-on-field".

-  "alt": "Brown Rocks During Golden Hour"
+  "alt": "Woman in White Long Sleeved Top and Skirt Standing on Field"
components/pexels/actions/search-photos/search-photos.mjs (1)

1-65: Action component looks solid with room for minor improvements

The search photos action is implemented correctly with proper props and API call. A few suggestions for enhancement:

  1. Consider adding default values for page and perPage directly in the prop definitions rather than only in the run method.
  2. Add a min value for the perPage prop to match API requirements (if any).
  3. Consider adding validation for the searchQuery to ensure it's not empty before making the API call.
    page: {
      type: "Integer",
      label: "Page",
      description: "The page number you are requesting",
      optional: true,
+     default: 1,
    },
    perPage: {
      type: "Integer",
      label: "Per Page",
      description: "The number of results you are requesting per page",
      max: 80,
+     min: 1,
+     default: 15,
      optional: true,
    },

And in the run method:

    const response = await this.pexels.searchPhotos({
      $,
      params: {
        query: this.searchQuery,
        orientation: this.orientation,
        size: this.size,
        color: this.color,
-       page: this.page || 1,
-       per_page: this.perPage || 15,
+       page: this.page,
+       per_page: this.perPage,
      },
    });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 159d440 and 5081f89.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • common/constants.mjs (1 hunks)
  • components/pexels/actions/download-photo/download-photo.mjs (1 hunks)
  • components/pexels/actions/get-photo-details/get-photo-details.mjs (1 hunks)
  • components/pexels/actions/search-photos/search-photos.mjs (1 hunks)
  • components/pexels/package.json (2 hunks)
  • components/pexels/pexels.app.mjs (1 hunks)
  • components/pexels/sources/common/base.mjs (1 hunks)
  • components/pexels/sources/new-curated-photo/new-curated-photo.mjs (1 hunks)
  • components/pexels/sources/new-curated-photo/test-event.mjs (1 hunks)
  • components/pexels/sources/new-photo-by-search/new-photo-by-search.mjs (1 hunks)
  • components/pexels/sources/new-photo-by-search/test-event.mjs (1 hunks)
🔇 Additional comments (20)
common/constants.mjs (3)

1-14: Well-structured orientation options array

The ORIENTATION_OPTIONS constant is well-structured with clear labels and values that match the Pexels API parameters. The array format with label-value pairs works well for UI selection components.


16-29: Size options include helpful megapixel information

Good implementation of the SIZE_OPTIONS constant. Including the megapixel information in the labels (24MP, 12MP, 4MP) provides useful context for users selecting image sizes.


31-80: Comprehensive color options provided

The COLOR_OPTIONS array provides a thorough selection of color filters matching the Pexels API capabilities. The consistent structure with label-value pairs allows for easy rendering in dropdown menus.

components/pexels/package.json (1)

3-3: Version reset to 0.1.0 for new implementation

Appropriate version reset to 0.1.0 for this new integration. This follows semantic versioning practices for new implementations.

components/pexels/actions/get-photo-details/get-photo-details.mjs (2)

3-17: Well-defined action with proper metadata and props

The action has appropriate metadata including a descriptive name, helpful description with documentation link, and proper version number. The props are correctly defined, importing the Pexels app and leveraging its propDefinition for photoId.


18-25: Clean implementation with informative summary

The run method is efficiently implemented, properly passing the context ($) and photoId to the Pexels API. The exported summary message provides clear confirmation of the action's success.

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

11-43: Well-structured property definitions

The property definitions are comprehensive and well-organized, with clear labels and descriptions. The use of imported constants for option values ensures consistency across the application.


44-81: API methods implementation looks good

The implementation of the base methods and specific API endpoints is clean and follows best practices. The code correctly handles authorization and URL construction.

components/pexels/sources/new-curated-photo/new-curated-photo.mjs (1)

1-22: Well-implemented source component

This source component follows best practices by extending the common base component and implementing only the methods it needs to override. The dedupe strategy, key naming, and descriptions are all appropriate.

components/pexels/sources/common/base.mjs (2)

1-24: Props and basic methods are well-defined

The props and basic state management methods are correctly implemented, with appropriate defaults for the timer interval.


53-61: Hooks and run method implemented correctly

The deploy hook with the limit of 25 items is a good approach to seed initial state without overwhelming the system. The run method correctly calls emitEvent without a limit for regular polling.

components/pexels/sources/new-photo-by-search/new-photo-by-search.mjs (5)

1-3: Code imports look good.

Clean imports that follow the standard pattern for Pipedream components.


4-11: Component metadata is well-structured.

The component extends the common base component and includes appropriate metadata. The key, name, description (with documentation link), version, type, and deduplication strategy are all well-defined.


12-38: Props definition is well-organized.

The component properly inherits common props and adds specific props for search filtering. All props use propDefinitions from the Pexels app for consistency.


39-55: Methods implementation looks correct.

The component implements three key methods:

  1. getFunction() - Returns the appropriate Pexels API search function
  2. getParams() - Passes all configured search parameters to the API
  3. getSummary() - Generates a descriptive message for emitted events

The implementation follows Pipedream's source component patterns.


56-57: Sample emit inclusion is a good practice.

Including a sample event emitter allows users to preview the data structure this source will emit.

components/pexels/actions/download-photo/download-photo.mjs (4)

1-6: Imports are appropriate for the file download task.

The component correctly imports the necessary modules for HTTP requests, file system operations, and stream utilities.


7-13: Component metadata is well-defined.

The component has an appropriate key, name, description with documentation link, version, and type.


13-26: Props definition provides good user guidance.

The component properly defines props for the Pexels app instance, photo ID, and destination file path. The description for the file path property includes helpful documentation about the /tmp directory limitations in Pipedream.


27-36: File stream retrieval method looks good.

The getFileStream method correctly sets up an HTTP request with stream response type for efficient file downloading.

lcaresia
lcaresia previously approved these changes May 2, 2025
@luancazarine
Copy link
Collaborator Author

/approve

@luancazarine luancazarine merged commit a7094ae into master May 7, 2025
11 checks passed
@luancazarine luancazarine deleted the issue-16496 branch May 7, 2025 18:56
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] pexels
2 participants