-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - stripo #15511
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 - stripo #15511
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
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,26 @@ | ||
| import stripo from "../../stripo.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "stripo-get-raw-html", | ||
| name: "Get Raw HTML & CSS", | ||
| description: "Retrieves the HTML and CSS code of the selected email message in Stripo. [See the documentation](https://api.stripo.email/reference/getrawemail)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| stripo, | ||
| emailId: { | ||
| propDefinition: [ | ||
| stripo, | ||
| "emailId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.stripo.getRawHtml({ | ||
| $, | ||
| emailId: this.emailId, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved HTML & CSS from email with ID: ${this.emailId}`); | ||
| 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import stripo from "../../stripo.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "stripo-remove-email", | ||
| name: "Remove Email", | ||
| description: "Removes an existing message from the user's project in Stripo. [See the documentation](https://api.stripo.email/reference/deleteemail)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| stripo, | ||
| emailId: { | ||
| propDefinition: [ | ||
| stripo, | ||
| "emailId", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.stripo.removeEmail({ | ||
| $, | ||
| emailId: this.emailId, | ||
| }); | ||
| $.export("$summary", `Successfully removed email with ID: ${this.emailId}`); | ||
| 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import stripo from "../../stripo.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "stripo-search-emails", | ||
| name: "Search Emails", | ||
| description: "Searches existing emails by search query in Stripo. [See the documentation](https://api.stripo.email/reference/findemails)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| stripo, | ||
| query: { | ||
| propDefinition: [ | ||
| stripo, | ||
| "query", | ||
| ], | ||
| }, | ||
| maxResults: { | ||
| type: "integer", | ||
| label: "Max Results", | ||
| description: "The maximum number of results to return", | ||
| default: 100, | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const results = this.stripo.paginate({ | ||
| fn: this.stripo.listEmails, | ||
| params: { | ||
| queryStr: this.query, | ||
| }, | ||
| max: this.maxResults, | ||
| }); | ||
|
|
||
| const emails = []; | ||
| for await (const item of results) { | ||
| emails.push(item); | ||
| } | ||
|
|
||
| $.export("$summary", `Successfully retrieved ${emails.length} email${emails.length === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return emails; | ||
| }, | ||
| }; |
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
84 changes: 84 additions & 0 deletions
84
components/stripo/sources/new-email-created/new-email-created.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,84 @@ | ||
| import stripo from "../../stripo.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| key: "stripo-new-email-created", | ||
| name: "New Email Created", | ||
| description: "Emit new event when a new email is created in Stripo. [See the documentation](https://api.stripo.email/reference/findemails)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| stripo, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| query: { | ||
| propDefinition: [ | ||
| stripo, | ||
| "query", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastTs() { | ||
| return this.db.get("lastTs") || 0; | ||
| }, | ||
| _setLastTs(lastTs) { | ||
| this.db.set("lastTs", lastTs); | ||
| }, | ||
| generateMeta(email) { | ||
| return { | ||
| id: email.emailId, | ||
| summary: `New Email: ${email.name}`, | ||
| ts: Date.parse(email.updatedTime), | ||
| }; | ||
| }, | ||
| async processEvent(max) { | ||
| const lastTs = this._getLastTs(); | ||
|
|
||
| const results = this.stripo.paginate({ | ||
| fn: this.stripo.listEmails, | ||
| params: { | ||
| queryStr: this.query, | ||
| sortingColumn: "createdTime", | ||
| sortingAsc: false, | ||
| }, | ||
| max, | ||
| }); | ||
|
|
||
| const emails = []; | ||
| for await (const item of results) { | ||
| const ts = Date.parse(item.updatedTime); | ||
| if (ts >= lastTs) { | ||
| emails.push(item); | ||
| } | ||
| } | ||
|
|
||
| if (!emails.length) { | ||
| return; | ||
| } | ||
|
|
||
| this._setLastTs(Date.parse(emails[0].updatedTime)); | ||
|
|
||
| emails.reverse().forEach((email) => { | ||
| const meta = this.generateMeta(email); | ||
| this.$emit(email, meta); | ||
| }); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| await this.processEvent(25); | ||
| }, | ||
| }, | ||
| async run() { | ||
| await this.processEvent(); | ||
| }, | ||
| sampleEmit, | ||
| }; |
11 changes: 11 additions & 0 deletions
11
components/stripo/sources/new-email-created/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,11 @@ | ||
| export default { | ||
| "emailId": 9031276, | ||
| "name": "New Message", | ||
| "editorUrl": "https://my.stripo.email/cabinet/#/template-editor/?emailId=9031276&projectId=1189279&type=EMAIL", | ||
| "previewUrl": "https://viewstripo.email/575439dc-9d57-4e3f-989e-23a1a63971901738788020521", | ||
| "updatedTime": "2025-02-05T20:40:34.46", | ||
| "hasAmp": false, | ||
| "preheader": null, | ||
| "title": "", | ||
| "previewImage": "https://doc.stripocdn.email/content/guids/cabinet-icons/87baef10-e401-11ef-a29e-e99b514f747b.png" | ||
| } |
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,11 +1,98 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "stripo", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| emailId: { | ||
| type: "string", | ||
| label: "Email ID", | ||
| description: "The identifier of an email", | ||
| async options({ page }) { | ||
| const { data } = await this.listEmails({ | ||
| params: { | ||
| page, | ||
| }, | ||
| }); | ||
| return data?.map(({ | ||
| emailId: value, name: label, | ||
| }) => ({ | ||
| value, | ||
| label, | ||
| })) || []; | ||
| }, | ||
| }, | ||
| query: { | ||
| type: "string", | ||
| label: "Query", | ||
| description: "The query to search for", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://my.stripo.email/emailgeneration/v1"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, | ||
| path, | ||
| ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| headers: { | ||
| "Stripo-Api-Auth": this.$auth.api_key, | ||
| "Content-Type": "application/json", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| listEmails(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/emails", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getRawHtml({ | ||
| emailId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| path: `/raw-email/${emailId}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| removeEmail({ | ||
| emailId, ...opts | ||
| }) { | ||
| return this._makeRequest({ | ||
| method: "DELETE", | ||
| path: `/emails/${emailId}`, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| async *paginate({ | ||
| fn, params, max, | ||
| }) { | ||
| params = { | ||
| ...params, | ||
| page: 0, | ||
| }; | ||
| let totalResults, count = 0; | ||
| do { | ||
| const { | ||
| data, total, | ||
| } = await fn({ | ||
| params, | ||
| }); | ||
| totalResults = total; | ||
| for (const item of data) { | ||
| yield item; | ||
| count++; | ||
| if (max && count >= max) { | ||
| return; | ||
| } | ||
| } | ||
| } while (count < totalResults); | ||
| }, | ||
| }, | ||
| }; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.