-
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
Merged
Merged
New Components - typefully #15217
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
components/typefully/actions/create-draft/create-draft.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import typefully from "../../typefully.app.mjs"; | ||
|
||
export default { | ||
key: "typefully-create-draft", | ||
name: "Create Draft", | ||
description: "Creates a new draft in Typefully. [See the documentation](https://support.typefully.com/en/articles/8718287-typefully-api#h_df59629cbf)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
typefully, | ||
content: { | ||
propDefinition: [ | ||
typefully, | ||
"content", | ||
], | ||
}, | ||
threadify: { | ||
propDefinition: [ | ||
typefully, | ||
"threadify", | ||
], | ||
optional: true, | ||
}, | ||
share: { | ||
propDefinition: [ | ||
typefully, | ||
"share", | ||
], | ||
optional: true, | ||
}, | ||
autoRetweetEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoRetweetEnabled", | ||
], | ||
optional: true, | ||
}, | ||
autoPlugEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoPlugEnabled", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.typefully.createDraft({ | ||
$, | ||
data: { | ||
content: this.content, | ||
threadify: this.threadify, | ||
share: this.share, | ||
auto_retweet_enabled: this.autoRetweetEnabled, | ||
auto_plug_enabled: this.autoPlugEnabled, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Created draft with ID: ${response.id}.`); | ||
return response; | ||
}, | ||
}; |
62 changes: 62 additions & 0 deletions
62
components/typefully/actions/schedule-draft-next-slot/schedule-draft-next-slot.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import typefully from "../../typefully.app.mjs"; | ||
|
||
export default { | ||
key: "typefully-schedule-draft-next-slot", | ||
name: "Schedule Draft Next Slot", | ||
description: "Schedules an existing draft for publication in the next available time slot. [See the documentation](https://support.typefully.com/en/articles/8718287-typefully-api#h_df59629cbf)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
typefully, | ||
content: { | ||
propDefinition: [ | ||
typefully, | ||
"content", | ||
], | ||
}, | ||
threadify: { | ||
propDefinition: [ | ||
typefully, | ||
"threadify", | ||
], | ||
optional: true, | ||
}, | ||
share: { | ||
propDefinition: [ | ||
typefully, | ||
"share", | ||
], | ||
optional: true, | ||
}, | ||
autoRetweetEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoRetweetEnabled", | ||
], | ||
optional: true, | ||
}, | ||
autoPlugEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoPlugEnabled", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
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, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Draft scheduled successfully with ID: ${response.id}.`); | ||
return response; | ||
}, | ||
}; |
68 changes: 68 additions & 0 deletions
68
components/typefully/actions/schedule-draft/schedule-draft.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import typefully from "../../typefully.app.mjs"; | ||
|
||
export default { | ||
key: "typefully-schedule-draft", | ||
name: "Schedule Draft", | ||
description: "Schedules a draft for publication at a specific date and time. [See the documentation](https://support.typefully.com/en/articles/8718287-typefully-api#h_df59629cbf)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
typefully, | ||
content: { | ||
propDefinition: [ | ||
typefully, | ||
"content", | ||
], | ||
}, | ||
threadify: { | ||
propDefinition: [ | ||
typefully, | ||
"threadify", | ||
], | ||
optional: true, | ||
}, | ||
share: { | ||
propDefinition: [ | ||
typefully, | ||
"share", | ||
], | ||
optional: true, | ||
}, | ||
scheduleDate: { | ||
propDefinition: [ | ||
typefully, | ||
"scheduleDate", | ||
], | ||
}, | ||
autoRetweetEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoRetweetEnabled", | ||
], | ||
optional: true, | ||
}, | ||
autoPlugEnabled: { | ||
propDefinition: [ | ||
typefully, | ||
"autoPlugEnabled", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.typefully.createDraft({ | ||
$, | ||
data: { | ||
"content": this.content, | ||
"threadify": this.threadify, | ||
"share": this.share, | ||
"schedule-date": this.scheduleDate, | ||
"auto_retweet_enabled": this.autoRetweetEnabled, | ||
"auto_plug_enabled": this.autoPlugEnabled, | ||
}, | ||
}); | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$.export("$summary", `Draft scheduled successfully with ID: ${response.id}.`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/typefully", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Typefully Components", | ||
"main": "typefully.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
import typefully from "../../typefully.app.mjs"; | ||
|
||
export default { | ||
props: { | ||
typefully, | ||
db: "$.service.db", | ||
timer: { | ||
type: "$.interface.timer", | ||
default: { | ||
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
_getLastId() { | ||
return this.db.get("lastId") || 0; | ||
}, | ||
_setLastId(lastId) { | ||
this.db.set("lastId", lastId); | ||
}, | ||
async emitEvent(maxResults = false) { | ||
const lastId = this._getLastId(); | ||
const fn = await this.getFunction(); | ||
const response = await fn(); | ||
|
||
let responseArray = []; | ||
for await (const item of response) { | ||
if (item.id <= lastId) break; | ||
responseArray.push(item); | ||
} | ||
|
||
if (responseArray.length) { | ||
if (maxResults && (responseArray.length > maxResults)) { | ||
responseArray.length = maxResults; | ||
} | ||
this._setLastId(responseArray[0].id); | ||
} | ||
|
||
for (const item of responseArray.reverse()) { | ||
this.$emit(item, { | ||
id: item.id, | ||
summary: this.getSummary(item), | ||
ts: Date.parse(new Date()), | ||
}); | ||
} | ||
}, | ||
}, | ||
hooks: { | ||
async deploy() { | ||
await this.emitEvent(25); | ||
}, | ||
}, | ||
async run() { | ||
await this.emitEvent(); | ||
}, | ||
}; |
22 changes: 22 additions & 0 deletions
22
components/typefully/sources/new-draft-published/new-draft-published.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import common from "../common/base.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "typefully-new-draft-published", | ||
name: "New Draft Published", | ||
description: "Emit new event when a draft is published to Twitter via Typefully.", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
methods: { | ||
...common.methods, | ||
getFunction() { | ||
return this.typefully.getRecentlyPublishedDrafts; | ||
}, | ||
getSummary(draft) { | ||
return `Draft Published: ${draft.id}`; | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
15 changes: 15 additions & 0 deletions
15
components/typefully/sources/new-draft-published/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
"id": 123, | ||
"status": "published", | ||
"html": "content test", | ||
"num_tweets": 1, | ||
"last_edited": null, | ||
"scheduled_date": null, | ||
"published_on": "2025-01-09T10:22:11Z", | ||
"share_url": "https://typefully.com/t/nb9Lxx13df", | ||
"twitter_url": null, | ||
"linkedin_url": null, | ||
"text_first_tweet": "content", | ||
"html_first_tweet": "content", | ||
"text_preview_linkedin": null | ||
} |
22 changes: 22 additions & 0 deletions
22
components/typefully/sources/new-draft-scheduled/new-draft-scheduled.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import common from "../common/base.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "typefully-new-draft-scheduled", | ||
name: "New Draft Scheduled", | ||
description: "Emit new event when a draft is scheduled for publication.", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
methods: { | ||
...common.methods, | ||
getFunction() { | ||
return this.typefully.getRecentlyScheduledDrafts; | ||
}, | ||
getSummary(draft) { | ||
return `Scheduled draft: ${draft.id}`; | ||
}, | ||
}, | ||
sampleEmit, | ||
}; |
15 changes: 15 additions & 0 deletions
15
components/typefully/sources/new-draft-scheduled/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
"id": 123, | ||
"status": "scheduled", | ||
"html": "content test", | ||
"num_tweets": 1, | ||
"last_edited": null, | ||
"scheduled_date": "2025-01-09T10:22:11Z", | ||
"published_on": null, | ||
"share_url": "https://typefully.com/t/nb9Lxx13df", | ||
"twitter_url": null, | ||
"linkedin_url": null, | ||
"text_first_tweet": "content", | ||
"html_first_tweet": "content", | ||
"text_preview_linkedin": null | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.