-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - typefully #15217
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
New Components - typefully #15217
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the WalkthroughThis pull request introduces comprehensive support for the Typefully application in Pipedream, adding multiple components for draft management. The changes include new sources for tracking draft publications and scheduling, as well as actions for creating and scheduling drafts. The implementation provides a robust integration with the Typefully API, enabling users to interact with drafts through various methods like creating, scheduling, and monitoring draft statuses. Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
Sources - New Draft Published - New Draft Scheduled Actions - Create Draft - Schedule Draft Next Slot - Schedule Draft
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: 3
🧹 Nitpick comments (6)
components/typefully/sources/common/base.mjs (1)
44-44
: Simplify timestamp assignment usingDate.now()
The use of
Date.parse(new Date())
can be simplified for better readability and efficiency.Apply this diff to streamline the timestamp assignment:
- ts: Date.parse(new Date()), + ts: Date.now(),components/typefully/typefully.app.mjs (2)
90-96
: Add input validation for createDraft methodThe method should validate the required fields in the request data before making the API call.
createDraft(opts = {}) { + const { data } = opts; + if (!data?.content) { + throw new Error("Draft content is required"); + } return this._makeRequest({ method: "POST", path: "/drafts/", ...opts, }); }
66-70
: Add date format validation for scheduleDate propThe scheduleDate prop should include a pattern to validate the ISO format.
scheduleDate: { type: "string", label: "Schedule Date", description: "Date to schedule the draft (ISO format - YYYY-MM-DDTHH:MM:SSZ)", + pattern: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$", + examples: ["2025-01-15T14:30:00Z"], },components/typefully/actions/schedule-draft/schedule-draft.mjs (1)
3-68
: Consider extracting common code to a shared utilityThere's significant code duplication between create-draft.mjs and schedule-draft.mjs. Consider creating a shared utility for common functionality.
Create a new file
components/typefully/common/draft-utils.mjs
:export const transformDraftData = (data) => { return { content: data.content, threadify: data.threadify, share: data.share, auto_retweet_enabled: data.autoRetweetEnabled, auto_plug_enabled: data.autoPlugEnabled, ...(data.scheduleDate && { schedule_date: data.scheduleDate }), }; }; export const validateScheduleDate = (date) => { const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/; if (!dateRegex.test(date)) { throw new Error("Invalid schedule date format. Expected: YYYY-MM-DDTHH:MM:SSZ"); } };components/typefully/actions/schedule-draft-next-slot/schedule-draft-next-slot.mjs (2)
46-57
: Extract "next-free-slot" to a constant and improve error handlingThe hardcoded value should be defined as a constant, and error handling should be improved.
+const NEXT_FREE_SLOT = "next-free-slot"; + async run({ $ }) { + const transformedData = { + content: this.content, + threadify: this.threadify, + share: this.share, + schedule_date: NEXT_FREE_SLOT, + auto_retweet_enabled: this.autoRetweetEnabled, + auto_plug_enabled: this.autoPlugEnabled, + }; + const response = await this.typefully.createDraft({ $, - data: { - "content": this.content, - "threadify": this.threadify, - "share": this.share, - "schedule-date": "next-free-slot", - "auto_retweet_enabled": this.autoRetweetEnabled, - "auto_plug_enabled": this.autoPlugEnabled, - }, + data: transformedData, }); + + if (!response?.id) { + throw new Error("Failed to schedule draft: Invalid response from API"); + }
3-62
: Add rate limiting considerationsSince this component uses the "next-free-slot" feature, it's important to consider rate limiting to prevent overwhelming the scheduling system.
Consider implementing a delay between consecutive calls to this endpoint. You can add this to the app's
_makeRequest
method or implement it specifically for this action.Example implementation in
typefully.app.mjs
:const RATE_LIMIT_DELAY = 1000; // 1 second async _makeRequest({ $ = this, path, ...opts }) { if (path.includes('/drafts/') && opts.method === 'POST') { await new Promise(resolve => setTimeout(resolve, RATE_LIMIT_DELAY)); } // ... rest of the implementation }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
components/typefully/actions/create-draft/create-draft.mjs
(1 hunks)components/typefully/actions/schedule-draft-next-slot/schedule-draft-next-slot.mjs
(1 hunks)components/typefully/actions/schedule-draft/schedule-draft.mjs
(1 hunks)components/typefully/package.json
(2 hunks)components/typefully/sources/common/base.mjs
(1 hunks)components/typefully/sources/new-draft-published/new-draft-published.mjs
(1 hunks)components/typefully/sources/new-draft-published/test-event.mjs
(1 hunks)components/typefully/sources/new-draft-scheduled/new-draft-scheduled.mjs
(1 hunks)components/typefully/sources/new-draft-scheduled/test-event.mjs
(1 hunks)components/typefully/typefully.app.mjs
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- components/typefully/sources/new-draft-scheduled/test-event.mjs
- components/typefully/sources/new-draft-published/test-event.mjs
🔇 Additional comments (4)
components/typefully/sources/new-draft-scheduled/new-draft-scheduled.mjs (1)
14-20
: Methods are correctly implementedThe
getFunction
andgetSummary
methods are properly defined and extend the base module as expected.components/typefully/sources/new-draft-published/new-draft-published.mjs (1)
14-20
: Methods are correctly implementedThe
getFunction
andgetSummary
methods are properly defined and extend the base module as expected.components/typefully/package.json (2)
3-3
: LGTM! Version bump follows semantic versioning.The minor version increment from 0.0.1 to 0.1.0 correctly reflects the addition of new features (Typefully components) while maintaining backward compatibility.
15-17
: Verify the @pipedream/platform version.Let's ensure we're using the latest stable version of the platform package.
✅ Verification successful
The package is already using the latest version (3.0.3)
The current version specification
^3.0.3
in package.json is correct and up-to-date.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check latest version of @pipedream/platform npm view @pipedream/platform versions --json | jq -r '.[-1]' # Check for any breaking changes or deprecation notices in recent versions npm view @pipedream/platform@">3.0.3" version --jsonLength of output: 754
/approve |
Resolves #15184.
Summary by CodeRabbit
Release Notes for Typefully Integration
New Features
Improvements
Version Update