Skip to content

New Components - tave #14486

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions components/tave/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import tave from "../../tave.app.mjs";

export default {
key: "tave-create-contact",
name: "Create Contact",
description: "Creates a new contact in the Tave system. [See the documentation](https://tave.io/v2)",
version: "0.0.1",
type: "action",
props: {
tave,
contact: {
propDefinition: [
tave,
"contact",
],
},
},
async run({ $ }) {
const response = await this.tave.createContact(this.contact);
$.export("$summary", `Successfully created contact with name: ${response.name}`);
return response;
},
};
48 changes: 48 additions & 0 deletions components/tave/actions/create-job/create-job.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import tave from "../../tave.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/tave/actions/create-job/create-job.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "tave-create-job",
name: "Create Job",
description: "Creates a new job in the Táve system with associated items typically linked with a job. [See the documentation](https://tave.io/v2)",
version: "0.0.{{ts}}",
type: "action",
props: {
tave,
jobDetails: {
propDefinition: [
tave,
"jobDetails",
],
},
additionalItems: {
type: "string",
label: "Additional Items",
description: "Additional items for the job",
optional: true,
},
notes: {
type: "string",
label: "Notes",
description: "Additional notes for the job",
optional: true,
},
instructions: {
type: "string",
label: "Instructions",
description: "Additional instructions for the job",
optional: true,
},
},
async run({ $ }) {
const response = await this.tave.createJob({
...this.jobDetails,
additionalItems: this.additionalItems,
notes: this.notes,
instructions: this.instructions,
});

$.export("$summary", `Successfully created job with specifics: ${this.jobDetails.specifics}`);
return response;
},
};
24 changes: 24 additions & 0 deletions components/tave/actions/find-contact/find-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import tave from "../../tave.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/tave/actions/find-contact/find-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "tave-find-contact",
name: "Find Contact",
description: "Searches for an existing contact in the Tave system. [See the documentation](https://tave.io/v2)",
version: "0.0.{{ts}}",
type: "action",
props: {
tave,
searchContact: {
propDefinition: [
tave,
"searchContact",
],
},
},
async run({ $ }) {
const response = await this.tave.searchContact(this.searchContact);
$.export("$summary", `Successfully found contact(s) based on the query: ${this.searchContact}`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/tave/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"publishConfig": {
"access": "public"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import tave from "../../tave.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/tave/sources/new-contact-instant/new-contact-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "tave-new-contact-instant",
name: "New Contact Created",
description: "Emit new event when a contact is created. [See the documentation](https://tave.io/v2)",
version: "0.0.{{ts}}",
type: "source",
dedupe: "unique",
props: {
tave,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
clientId: {
propDefinition: [
tave,
"clientId",
],
},
},
methods: {
async _emitWebhookEvent(contact) {
this.$emit(contact, {
id: contact.id,
summary: `New contact created: ${contact.name}`,
ts: contact.createdAt
? Date.parse(contact.createdAt)
: Date.now(),
});
},
_getWebhookId() {
return this.db.get("webhookId");
},
_setWebhookId(id) {
this.db.set("webhookId", id);
},
},
hooks: {
async deploy() {
const events = await this.tave.emitNewContactEvent(this.clientId);
for (const event of events) {
this._emitWebhookEvent(event);
}
},
async activate() {
const hookId = await this.tave.emitNewContactEvent(this.clientId);
this._setWebhookId(hookId);
},
async deactivate() {
const hookId = this._getWebhookId();
if (hookId) {
await this.tave.emitNewContactEvent(this.clientId); // Assuming the method handles the deletion
}
},
},
async run(event) {
const contact = event.body;
this._emitWebhookEvent(contact);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import tave from "../../tave.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/tave/sources/new-order-booked-instant/new-order-booked-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "tave-new-order-booked-instant",
name: "New Order Booked",
description: "Emit new event when an order is booked, including manually booked orders in manager and electronic bookings in client access. [See the documentation](https://tave.io/v2)",
version: "0.0.{{ts}}",
type: "source",
dedupe: "unique",
props: {
tave,
http: {
type: "$.interface.http",
customResponse: true,
},
db: "$.service.db",
orderId: {
propDefinition: [
tave,
"orderId",
],
},
managerId: {
propDefinition: [
tave,
"managerId",
],
},
clientId: {
propDefinition: [
tave,
"clientId",
],
},
},
methods: {
_getWebhookId() {
return this.db.get("webhookId");
},
_setWebhookId(id) {
this.db.set("webhookId", id);
},
},
hooks: {
async deploy() {
const events = await this.tave.emitNewOrderEvent(this.orderId, this.managerId, this.clientId);
for (const event of events.slice(-50)) {
this.$emit(event, {
id: event.id,
summary: `New order booked with ID ${event.id}`,
ts: Date.parse(event.createdAt),
});
}
},
async activate() {
const hookId = await this.tave.emitNewOrderEvent(this.orderId, this.managerId, this.clientId);
this._setWebhookId(hookId);
},
async deactivate() {
const id = this._getWebhookId();
if (id) {
await this.tave._makeRequest({
method: "DELETE",
path: `/webhooks/${id}`,
});
}
},
},
async run(event) {
const { body } = event;
const expectedSignature = {}; // Add logic to compute expected signature
const webhookSignature = event.headers["x-webhook-signature"];

if (webhookSignature !== expectedSignature) {
this.http.respond({
status: 401,
body: "Unauthorized",
});
return;
}

this.http.respond({
status: 200,
body: "OK",
});

this.$emit(body, {
id: body.orderId,
summary: `Order booked: ${body.orderId}`,
ts: Date.parse(body.createdAt),
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import tave from "../../tave.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/tave/sources/new-payment-instant/new-payment-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "tave-new-payment-instant",
name: "New Payment Created",
description: "Emit new event when a new payment is created. [See the documentation](https://tave.io/v2/docs)",
version: "0.0.{{ts}}",
type: "source",
dedupe: "unique",
props: {
tave,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
paymentId: {
propDefinition: [
tave,
"paymentId",
],
},
orderId: {
propDefinition: [
tave,
"orderId",
],
optional: true,
},
},
methods: {
_getWebhookId() {
return this.db.get("webhookId");
},
_setWebhookId(id) {
this.db.set("webhookId", id);
},
},
hooks: {
async deploy() {
const events = await this.tave.emitNewPaymentEvent(this.paymentId, this.orderId);
for (const event of events) {
this.$emit(event, {
id: event.id,
summary: `Historical payment event for payment ID: ${event.id}`,
ts: Date.now(),
});
}
},
async activate() {
const hookId = await this.tave.emitNewPaymentEvent(this.paymentId, this.orderId);
this._setWebhookId(hookId);
},
async deactivate() {
const hookId = this._getWebhookId();

Check failure on line 56 in components/tave/sources/new-payment-instant/new-payment-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'hookId' is assigned a value but never used
// Implement the logic to delete the webhook, if supported by the API
},
},
async run(event) {
this.$emit(event.body, {
id: event.body.paymentId,
summary: `New payment created with ID: ${event.body.paymentId}`,
ts: Date.now(),
});
},
};
Loading
Loading