-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - offlight #14064
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 - offlight #14064
Changes from 3 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,63 @@ | ||
| import offlight from "../../offlight.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "offlight-create-task", | ||
| name: "Create Task", | ||
| description: "Initiates the creation of a new task in Offlight. [See the documentation](https://www.offlight.work/docs/zapeir-api)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| offlight, | ||
| taskName: { | ||
| type: "string", | ||
| label: "Task Name", | ||
| description: "The name of the task.", | ||
| }, | ||
| taskNote: { | ||
| type: "string", | ||
| label: "Task Note", | ||
| description: "A note about the task.", | ||
| optional: true, | ||
| }, | ||
| taskDeadline: { | ||
| type: "string", | ||
| label: "Task Deadline", | ||
| description: "The deadline of the task. **In ISO 8601 format (YYY-MM-DD)**.", | ||
| optional: true, | ||
| }, | ||
| identifier: { | ||
| type: "string", | ||
| label: "Identifier", | ||
| description: "A unique identifier for the task.", | ||
| optional: true, | ||
| }, | ||
| sourceName: { | ||
| type: "string", | ||
| label: "Source Name", | ||
| description: "The source name of the task.", | ||
| optional: true, | ||
| }, | ||
| sourceLink: { | ||
| type: "string", | ||
| label: "Source Link", | ||
| description: "The source link of the task.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.offlight.createTask({ | ||
| $, | ||
| data: { | ||
| task_name: this.taskName, | ||
| task_note: this.taskNote, | ||
| task_deadline: this.taskDeadline, | ||
| identifier: this.identifier, | ||
| source_name: this.sourceName, | ||
| source_link: this.sourceLink, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| $.export("$summary", `Task successfully created with ID: ${response.id}`); | ||
| return response; | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
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,53 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "offlight", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.offlight.work"; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _headers() { | ||
| return { | ||
| "x-api-key": `${this.$auth.api_token}`, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| headers: this._headers(), | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| createTask(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/zapier/task", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| getDoneTasks(opts = {}) { | ||
| return this._makeRequest({ | ||
| ...opts, | ||
| method: "GET", | ||
| path: "/zapier/doneTasks", | ||
| }); | ||
| }, | ||
| createWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/zapier/webhook", | ||
| ...opts, | ||
| }); | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| deleteWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "DELETE", | ||
| path: "/zapier/webhook", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
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/offlight", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream OFFLIGHT Components", | ||
| "main": "offlight.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,9 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.1" | ||
| } | ||
| } | ||
| } | ||
|
|
||
55 changes: 55 additions & 0 deletions
55
components/offlight/sources/new-task-done-instant/new-task-done-instant.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,55 @@ | ||
| import offlight from "../../offlight.app.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| key: "offlight-new-task-done-instant", | ||
| name: "New Task Done (Instant)", | ||
| description: "Emit new event when a task is marked as complete.", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| offlight, | ||
| http: { | ||
| type: "$.interface.http", | ||
| }, | ||
| db: "$.service.db", | ||
| }, | ||
| methods: { | ||
| emitTask(task) { | ||
| this.$emit(task, { | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id: task.id, | ||
| summary: `Task ${task.name} marked as done`, | ||
| ts: Date.parse(task.doneAt), | ||
| }); | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async deploy() { | ||
| const tasks = await this.offlight.getDoneTasks(); | ||
| for (const task of tasks) { | ||
| this.emitTask(task); | ||
| } | ||
| }, | ||
| async activate() { | ||
| await this.offlight.createWebhook({ | ||
| data: { | ||
| purpose: "doneTask", | ||
| hookUrl: this.http.endpoint, | ||
| }, | ||
| }); | ||
| }, | ||
| async deactivate() { | ||
| await this.offlight.deleteWebhook({ | ||
| data: { | ||
| purpose: "doneTask", | ||
| hookUrl: this.http.endpoint, | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ body }) { | ||
| this.emitTask(body); | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
18 changes: 18 additions & 0 deletions
18
components/offlight/sources/new-task-done-instant/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,18 @@ | ||
| export default { | ||
| "createdAt": "2024-09-23T19:18:54.995Z", | ||
| "updatedAt": "2024-09-23T20:10:26.000Z", | ||
| "plannedDate": null, | ||
| "doneAt": "2024-09-23T20:10:25.136Z", | ||
| "deletedAt": null, | ||
| "id": "4e73c28d-0e2f-4352-9c86-62048255e1b8", | ||
| "name": "🤵 Welcome to OFFLIGHT", | ||
| "note": null, | ||
| "status": "done", | ||
| "deadline": null, | ||
| "goal": null, | ||
| "source": "admin", | ||
| "identifier": null, | ||
| "sourceName": null, | ||
| "link": null, | ||
| "creator": 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.