Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions components/offlight/actions/create-task/create-task.mjs
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 (YYYY-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,
},
});

$.export("$summary", `Task successfully created with ID: ${response.id}`);
return response;
},
};
52 changes: 47 additions & 5 deletions components/offlight/offlight.app.mjs
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";
},
_headers() {
return {
"x-api-key": `${this.$auth.api_token}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
createTask(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/zapier/task",
...opts,
});
},
getDoneTasks(opts = {}) {
return this._makeRequest({
...opts,
method: "GET",
path: "/zapier/doneTasks",
});
},
createWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/zapier/webhook",
...opts,
});
},
deleteWebhook(opts = {}) {
return this._makeRequest({
method: "DELETE",
path: "/zapier/webhook",
...opts,
});
},
},
};
};
8 changes: 6 additions & 2 deletions components/offlight/package.json
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": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.1"
}
}
}

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, {
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,
},
});
},
},
async run({ body }) {
this.emitTask(body);
},
sampleEmit,
};
18 changes: 18 additions & 0 deletions components/offlight/sources/new-task-done-instant/test-event.mjs
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
}
Loading
Loading