From c0899523bfab56f91be48dce7ca3dd923b0c00ed Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Tue, 24 Jun 2025 23:48:32 -0300 Subject: [PATCH 1/9] pnpm --- pnpm-lock.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b516660cfcfd5..f4ed2c37caba3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5392,8 +5392,7 @@ importers: components/godial: {} - components/goformz: - specifiers: {} + components/goformz: {} components/gohighlevel: dependencies: @@ -8487,8 +8486,7 @@ importers: components/mollie: {} - components/momentum_ams: - specifiers: {} + components/momentum_ams: {} components/monday: dependencies: @@ -9467,8 +9465,7 @@ importers: components/order_sender: {} - components/orderspace: - specifiers: {} + components/orderspace: {} components/originality_ai: dependencies: From 25fe0157e35588677006a2f666cd21e558e9aefa Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 25 Jun 2025 00:36:13 -0300 Subject: [PATCH 2/9] Yay.com new actions --- .../create-outbound-call.mjs | 55 +++++++ .../actions/get-documents/get-documents.mjs | 18 +++ .../get-phone-books/get-phone-books.mjs | 18 +++ components/yay_com/app/yay_com.app.mjs | 144 ++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 components/yay_com/actions/create-outbound-call/create-outbound-call.mjs create mode 100644 components/yay_com/actions/get-documents/get-documents.mjs create mode 100644 components/yay_com/actions/get-phone-books/get-phone-books.mjs create mode 100644 components/yay_com/app/yay_com.app.mjs diff --git a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs new file mode 100644 index 0000000000000..fafafc5141fa0 --- /dev/null +++ b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs @@ -0,0 +1,55 @@ +import yay_com from "../../app/yay_com.app.mjs"; + +export default { + key: "yay_com-create-outbound-call", + name: "Create Outbound Call", + description: "Initiates an outbound call to a specified number. [See documentation](https://www.yay.com/voip/api-docs/calls/outbound-call/)", + version: "0.0.1", + type: "action", + props: { + yay_com, + userUuid: { + propDefinition: [ + yay_com, + "sipUser", + ], + }, + destination: { + propDefinition: [ + yay_com, + "destination", + ], + }, + displayName: { + propDefinition: [ + yay_com, + "displayName", + ], + }, + sipUsers: { + propDefinition: [ + yay_com, + "sipUsers", + ], + }, + huntGroups: { + propDefinition: [ + yay_com, + "huntGroups", + ], + }, + }, + async run({ $ }) { + const response = await this.yay_com.createOutboundCall({ + $, + userUuid: this.userUuid, + destination: this.destination, + displayName: this.displayName, + sipUsers: this.sipUsers || [], + huntGroups: this.huntGroups || [], + }); + + $.export("$summary", `Successfully initiated outbound call to ${this.destination}`); + return response; + }, +}; diff --git a/components/yay_com/actions/get-documents/get-documents.mjs b/components/yay_com/actions/get-documents/get-documents.mjs new file mode 100644 index 0000000000000..25e9e34abdc85 --- /dev/null +++ b/components/yay_com/actions/get-documents/get-documents.mjs @@ -0,0 +1,18 @@ +import yay_com from "../../app/yay_com.app.mjs"; + +export default { + key: "yay_com-get-documents", + name: "Get Documents", + description: "Retrieves a list of documents. [See documentation](https://www.yay.com/voip/api-docs/account/document/)", + version: "0.0.1", + type: "action", + props: { + yay_com, + }, + async run({ $ }) { + const response = await this.yay_com.listDocuments($); + const documents = response.data || []; + $.export("$summary", `Successfully retrieved ${documents.length} document(s)`); + return response; + }, +}; diff --git a/components/yay_com/actions/get-phone-books/get-phone-books.mjs b/components/yay_com/actions/get-phone-books/get-phone-books.mjs new file mode 100644 index 0000000000000..09d8226fc9f09 --- /dev/null +++ b/components/yay_com/actions/get-phone-books/get-phone-books.mjs @@ -0,0 +1,18 @@ +import yay_com from "../../app/yay_com.app.mjs"; + +export default { + key: "yay_com-get-phone-books", + name: "Get Phone Books", + description: "Retrieves a list of phone books. [See documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book/)", + version: "0.0.1", + type: "action", + props: { + yay_com, + }, + async run({ $ }) { + const response = await this.yay_com.listPhoneBooks($); + const phoneBooks = response.data || []; + $.export("$summary", `Successfully retrieved ${phoneBooks.length} phone book(s)`); + return response; + }, +}; diff --git a/components/yay_com/app/yay_com.app.mjs b/components/yay_com/app/yay_com.app.mjs new file mode 100644 index 0000000000000..c576c07631a8b --- /dev/null +++ b/components/yay_com/app/yay_com.app.mjs @@ -0,0 +1,144 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "yay_com", + propDefinitions: { + sipUser: { + type: "string", + label: "SIP User", + description: "The SIP user to make the outbound call for", + async options() { + const { result } = await this.listSipUsers(); + return result?.map(({ + uuid: value, display_name, user_name, + }) => ({ + label: display_name || user_name, + value, + })) || []; + }, + }, + sipUsers: { + type: "string[]", + label: "SIP Users", + description: "List of SIP users who will receive the outbound call request", + optional: true, + async options() { + const { result } = await this.listSipUsers(); + return result?.map(({ + uuid: value, display_name, user_name, + }) => ({ + label: display_name || user_name, + value, + })) || []; + }, + }, + huntGroups: { + type: "string[]", + label: "Hunt Groups", + description: "List of hunt groups who will receive the outbound call request", + optional: true, + async options() { + const { result } = await this.listHuntGroups(); + return result?.map(({ + uuid: value, name: label, + }) => ({ + label, + value, + })) || []; + }, + }, + destination: { + type: "string", + label: "Destination", + description: "The destination phone number to call (in E164 format for outbound calls). You may also provide extension numbers of your hunt groups, users and call routes.", + }, + displayName: { + type: "string", + label: "Display Name", + description: "What display name should be sent to the user, this will show as the name on their phone (where supported)", + optional: true, + }, + }, + methods: { + _getBaseUrl() { + return `https://${this.$auth.api_hostname}`; + }, + _getHeaders() { + return { + "x-auth-reseller": `${this.$auth.reseller}`, + "x-auth-user": `${this.$auth.user}`, + "x-auth-password": `${this.$auth.password}`, + }; + }, + async _makeRequest({ + $ = this, + path, + ...args + }) { + return axios($, { + url: `${this._getBaseUrl()}${path}`, + headers: this._getHeaders(), + ...args, + }); + }, + async listSipUsers($) { + return this._makeRequest({ + $, + path: "/voip/user", + }); + }, + async listHuntGroups($) { + return this._makeRequest({ + $, + path: "/voip/group", + }); + }, + async listPhoneBooks($) { + return this._makeRequest({ + $, + path: "/phone-books", + }); + }, + async listDocuments($) { + return this._makeRequest({ + $, + path: "/account/documents", + }); + }, + async createOutboundCall({ + $, + userUuid, + destination, + displayName, + sipUsers = [], + huntGroups = [], + }) { + // Combine sipUsers and huntGroups into the targets array + const targets = [ + ...sipUsers.map((uuid) => ({ + type: "sipuser", + uuid, + })), + ...huntGroups.map((uuid) => ({ + type: "huntgroup", + uuid, + })), + ]; + + return this._makeRequest({ + $, + method: "POST", + path: "/calls/outbound", + data: { + user_uuid: userUuid, + destination, + display_name: displayName, + ...(targets.length > 0 && { + targets, + }), + }, + }); + }, + }, +}; From 04c6c45a9fca1673c7bac18bb46db02d0c8f1aad Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 25 Jun 2025 02:19:03 -0300 Subject: [PATCH 3/9] Adjustments --- .../actions/get-documents/get-documents.mjs | 18 ++- components/yay_com/app/yay_com.app.mjs | 144 ----------------- components/yay_com/yay_com.app.mjs | 146 +++++++++++++++++- 3 files changed, 155 insertions(+), 153 deletions(-) delete mode 100644 components/yay_com/app/yay_com.app.mjs diff --git a/components/yay_com/actions/get-documents/get-documents.mjs b/components/yay_com/actions/get-documents/get-documents.mjs index 25e9e34abdc85..8e62adf13a834 100644 --- a/components/yay_com/actions/get-documents/get-documents.mjs +++ b/components/yay_com/actions/get-documents/get-documents.mjs @@ -1,18 +1,26 @@ -import yay_com from "../../app/yay_com.app.mjs"; +import yay_com from "../../yay_com.app.mjs"; export default { key: "yay_com-get-documents", name: "Get Documents", - description: "Retrieves a list of documents. [See documentation](https://www.yay.com/voip/api-docs/account/document/)", + description: + "Retrieves a list of documents. [See documentation](https://www.yay.com/voip/api-docs/account/document/)", version: "0.0.1", type: "action", props: { yay_com, }, async run({ $ }) { - const response = await this.yay_com.listDocuments($); - const documents = response.data || []; - $.export("$summary", `Successfully retrieved ${documents.length} document(s)`); + const response = await this.yay_com.listDocuments({ + $, + }); + const { length } = response; + $.export( + "$summary", + `Successfully retrieved ${length} document${length === 1 + ? "" + : "s"}`, + ); return response; }, }; diff --git a/components/yay_com/app/yay_com.app.mjs b/components/yay_com/app/yay_com.app.mjs deleted file mode 100644 index c576c07631a8b..0000000000000 --- a/components/yay_com/app/yay_com.app.mjs +++ /dev/null @@ -1,144 +0,0 @@ -import { axios } from "@pipedream/platform"; - -export default { - type: "app", - app: "yay_com", - propDefinitions: { - sipUser: { - type: "string", - label: "SIP User", - description: "The SIP user to make the outbound call for", - async options() { - const { result } = await this.listSipUsers(); - return result?.map(({ - uuid: value, display_name, user_name, - }) => ({ - label: display_name || user_name, - value, - })) || []; - }, - }, - sipUsers: { - type: "string[]", - label: "SIP Users", - description: "List of SIP users who will receive the outbound call request", - optional: true, - async options() { - const { result } = await this.listSipUsers(); - return result?.map(({ - uuid: value, display_name, user_name, - }) => ({ - label: display_name || user_name, - value, - })) || []; - }, - }, - huntGroups: { - type: "string[]", - label: "Hunt Groups", - description: "List of hunt groups who will receive the outbound call request", - optional: true, - async options() { - const { result } = await this.listHuntGroups(); - return result?.map(({ - uuid: value, name: label, - }) => ({ - label, - value, - })) || []; - }, - }, - destination: { - type: "string", - label: "Destination", - description: "The destination phone number to call (in E164 format for outbound calls). You may also provide extension numbers of your hunt groups, users and call routes.", - }, - displayName: { - type: "string", - label: "Display Name", - description: "What display name should be sent to the user, this will show as the name on their phone (where supported)", - optional: true, - }, - }, - methods: { - _getBaseUrl() { - return `https://${this.$auth.api_hostname}`; - }, - _getHeaders() { - return { - "x-auth-reseller": `${this.$auth.reseller}`, - "x-auth-user": `${this.$auth.user}`, - "x-auth-password": `${this.$auth.password}`, - }; - }, - async _makeRequest({ - $ = this, - path, - ...args - }) { - return axios($, { - url: `${this._getBaseUrl()}${path}`, - headers: this._getHeaders(), - ...args, - }); - }, - async listSipUsers($) { - return this._makeRequest({ - $, - path: "/voip/user", - }); - }, - async listHuntGroups($) { - return this._makeRequest({ - $, - path: "/voip/group", - }); - }, - async listPhoneBooks($) { - return this._makeRequest({ - $, - path: "/phone-books", - }); - }, - async listDocuments($) { - return this._makeRequest({ - $, - path: "/account/documents", - }); - }, - async createOutboundCall({ - $, - userUuid, - destination, - displayName, - sipUsers = [], - huntGroups = [], - }) { - // Combine sipUsers and huntGroups into the targets array - const targets = [ - ...sipUsers.map((uuid) => ({ - type: "sipuser", - uuid, - })), - ...huntGroups.map((uuid) => ({ - type: "huntgroup", - uuid, - })), - ]; - - return this._makeRequest({ - $, - method: "POST", - path: "/calls/outbound", - data: { - user_uuid: userUuid, - destination, - display_name: displayName, - ...(targets.length > 0 && { - targets, - }), - }, - }); - }, - }, -}; diff --git a/components/yay_com/yay_com.app.mjs b/components/yay_com/yay_com.app.mjs index 0218c54955d7f..a1e101bb45100 100644 --- a/components/yay_com/yay_com.app.mjs +++ b/components/yay_com/yay_com.app.mjs @@ -1,11 +1,149 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "yay_com", - propDefinitions: {}, + propDefinitions: { + sipUser: { + type: "string", + label: "SIP User", + description: "The SIP user to make the outbound call for", + async options() { + const { result } = await this.listSipUsers(); + return result?.map(({ + uuid: value, display_name, user_name, + }) => ({ + label: display_name || user_name, + value, + })) || []; + }, + }, + sipUsers: { + type: "string[]", + label: "SIP Users", + description: "List of SIP users who will receive the outbound call request", + optional: true, + async options() { + const { result } = await this.listSipUsers(); + return result?.map(({ + uuid: value, display_name, user_name, + }) => ({ + label: display_name || user_name, + value, + })) || []; + }, + }, + huntGroups: { + type: "string[]", + label: "Hunt Groups", + description: "List of hunt groups who will receive the outbound call request", + optional: true, + async options() { + const { result } = await this.listHuntGroups(); + return result?.map(({ + uuid: value, name: label, + }) => ({ + label, + value, + })) || []; + }, + }, + destination: { + type: "string", + label: "Destination", + description: "The destination phone number to call (in E164 format for outbound calls). You may also provide extension numbers of your hunt groups, users and call routes.", + }, + displayName: { + type: "string", + label: "Display Name", + description: "What display name should be sent to the user, this will show as the name on their phone (where supported)", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _getBaseUrl() { + return `https://${this.$auth.api_hostname}`; + }, + _getHeaders() { + return { + "x-auth-reseller": `${this.$auth.reseller}`, + "x-auth-user": `${this.$auth.user}`, + "x-auth-password": `${this.$auth.password}`, + }; + }, + async _makeRequest({ + $ = this, + path, + headers, + ...args + }) { + const response = await axios($, { + url: `${this._getBaseUrl()}${path}`, + headers: { + ...headers, + ...this._getHeaders(), + }, + ...args, + }); + return response.result; + }, + async listSipUsers(args) { + return this._makeRequest({ + path: "/voip/user", + ...args, + }); + }, + async listHuntGroups(args) { + return this._makeRequest({ + path: "/voip/group", + ...args, + }); + }, + async listPhoneBooks(args) { + return this._makeRequest({ + path: "/phone-book", + ...args, + }); + }, + async listDocuments(args) { + return this._makeRequest({ + path: "/account/document", + ...args, + }); + }, + async createOutboundCall({ + $, + userUuid, + destination, + displayName, + sipUsers = [], + huntGroups = [], + }) { + // Combine sipUsers and huntGroups into the targets array + const targets = [ + ...sipUsers.map((uuid) => ({ + type: "sipuser", + uuid, + })), + ...huntGroups.map((uuid) => ({ + type: "huntgroup", + uuid, + })), + ]; + + return this._makeRequest({ + $, + method: "POST", + path: "/calls/outbound", + data: { + user_uuid: userUuid, + destination, + display_name: displayName, + ...(targets.length > 0 && { + targets, + }), + }, + }); }, }, }; From 6af21c21b27ffb77a141b1bb62da422d6a831c41 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 25 Jun 2025 02:32:55 -0300 Subject: [PATCH 4/9] Adjustments --- .../create-outbound-call.mjs | 46 +++++++++++++------ .../actions/get-documents/get-documents.mjs | 6 +-- .../get-phone-books/get-phone-books.mjs | 14 ++++-- components/yay_com/package.json | 2 +- components/yay_com/yay_com.app.mjs | 31 +------------ 5 files changed, 48 insertions(+), 51 deletions(-) diff --git a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs index fafafc5141fa0..06f8ed404292c 100644 --- a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs +++ b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs @@ -1,4 +1,5 @@ -import yay_com from "../../app/yay_com.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; +import yayCom from "../../yay_com.app.mjs"; export default { key: "yay_com-create-outbound-call", @@ -7,46 +8,65 @@ export default { version: "0.0.1", type: "action", props: { - yay_com, + yayCom, userUuid: { propDefinition: [ - yay_com, + yayCom, "sipUser", ], }, destination: { propDefinition: [ - yay_com, + yayCom, "destination", ], }, displayName: { propDefinition: [ - yay_com, + yayCom, "displayName", ], }, sipUsers: { propDefinition: [ - yay_com, + yayCom, "sipUsers", ], }, huntGroups: { propDefinition: [ - yay_com, + yayCom, "huntGroups", ], }, }, async run({ $ }) { - const response = await this.yay_com.createOutboundCall({ + // Combine sipUsers and huntGroups into the targets array + const targets = [ + ...(this.sipUsers?.map((uuid) => ({ + type: "sipuser", + uuid, + })) || []), + ...(this.huntGroups?.map((uuid) => ({ + type: "huntgroup", + uuid, + })) || []), + ]; + + if (!targets.length) { + throw new ConfigurationError("Please provide at least one target (SIP user or hunt group)"); + } + + const response = await this.yayCom.createOutboundCall({ $, - userUuid: this.userUuid, - destination: this.destination, - displayName: this.displayName, - sipUsers: this.sipUsers || [], - huntGroups: this.huntGroups || [], + data: { + user_uuid: this.userUuid, + destination: this.destination, + display_name: this.displayName, + ...(targets.length > 0 && { + targets, + }), + }, }); $.export("$summary", `Successfully initiated outbound call to ${this.destination}`); diff --git a/components/yay_com/actions/get-documents/get-documents.mjs b/components/yay_com/actions/get-documents/get-documents.mjs index 8e62adf13a834..c5c5ab92f7eb9 100644 --- a/components/yay_com/actions/get-documents/get-documents.mjs +++ b/components/yay_com/actions/get-documents/get-documents.mjs @@ -1,4 +1,4 @@ -import yay_com from "../../yay_com.app.mjs"; +import yayCom from "../../yay_com.app.mjs"; export default { key: "yay_com-get-documents", @@ -8,10 +8,10 @@ export default { version: "0.0.1", type: "action", props: { - yay_com, + yayCom, }, async run({ $ }) { - const response = await this.yay_com.listDocuments({ + const response = await this.yayCom.listDocuments({ $, }); const { length } = response; diff --git a/components/yay_com/actions/get-phone-books/get-phone-books.mjs b/components/yay_com/actions/get-phone-books/get-phone-books.mjs index 09d8226fc9f09..896ca40262970 100644 --- a/components/yay_com/actions/get-phone-books/get-phone-books.mjs +++ b/components/yay_com/actions/get-phone-books/get-phone-books.mjs @@ -1,4 +1,4 @@ -import yay_com from "../../app/yay_com.app.mjs"; +import yayCom from "../../yay_com.app.mjs"; export default { key: "yay_com-get-phone-books", @@ -7,12 +7,16 @@ export default { version: "0.0.1", type: "action", props: { - yay_com, + yayCom, }, async run({ $ }) { - const response = await this.yay_com.listPhoneBooks($); - const phoneBooks = response.data || []; - $.export("$summary", `Successfully retrieved ${phoneBooks.length} phone book(s)`); + const response = await this.yayCom.listPhoneBooks({ + $, + }); + const { length } = response; + $.export("$summary", `Successfully retrieved ${length} phone book${length === 1 + ? "" + : "s"}`); return response; }, }; diff --git a/components/yay_com/package.json b/components/yay_com/package.json index 994ca7e4b9554..98b13fa30e8a7 100644 --- a/components/yay_com/package.json +++ b/components/yay_com/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/yay_com/yay_com.app.mjs b/components/yay_com/yay_com.app.mjs index a1e101bb45100..bb202e3acc53e 100644 --- a/components/yay_com/yay_com.app.mjs +++ b/components/yay_com/yay_com.app.mjs @@ -111,38 +111,11 @@ export default { ...args, }); }, - async createOutboundCall({ - $, - userUuid, - destination, - displayName, - sipUsers = [], - huntGroups = [], - }) { - // Combine sipUsers and huntGroups into the targets array - const targets = [ - ...sipUsers.map((uuid) => ({ - type: "sipuser", - uuid, - })), - ...huntGroups.map((uuid) => ({ - type: "huntgroup", - uuid, - })), - ]; - + async createOutboundCall(args) { return this._makeRequest({ - $, method: "POST", path: "/calls/outbound", - data: { - user_uuid: userUuid, - destination, - display_name: displayName, - ...(targets.length > 0 && { - targets, - }), - }, + ...args, }); }, }, From 89f40af46c9aa013fa9823243a706e2652e9c564 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 25 Jun 2025 03:55:27 -0300 Subject: [PATCH 5/9] Adding polling source --- components/yay_com/sources/common/polling.mjs | 49 ++++++++++++++++++ .../new-contact-added/new-contact-added.mjs | 50 +++++++++++++++++++ components/yay_com/yay_com.app.mjs | 44 +++++++++++++--- 3 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 components/yay_com/sources/common/polling.mjs create mode 100644 components/yay_com/sources/new-contact-added/new-contact-added.mjs diff --git a/components/yay_com/sources/common/polling.mjs b/components/yay_com/sources/common/polling.mjs new file mode 100644 index 0000000000000..9eff4cd6a2704 --- /dev/null +++ b/components/yay_com/sources/common/polling.mjs @@ -0,0 +1,49 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import yayCom from "../../yay_com.app.mjs"; + +export default { + props: { + yayCom, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getSavedIds() { + return this.db.get("savedIds") || []; + }, + _setSavedIds(ids) { + this.db.set("savedIds", ids); + }, + async startEvent() { + const savedIds = this._getSavedIds(); + const items = await this.getItems(savedIds); + + const newIds = []; + for (const item of items) { + const id = this.getItemId(item); + if (!savedIds.includes(id)) { + const meta = this.generateMeta(item); + this.$emit(item, meta); + newIds.push(id); + } + } + + if (newIds.length > 0) { + // Keep only the most recent IDs to prevent the array from growing indefinitely + const ids = [ + ...savedIds, + ...newIds, + ].slice(-100); + this._setSavedIds(ids); + } + }, + }, + async run() { + await this.startEvent(); + }, +}; diff --git a/components/yay_com/sources/new-contact-added/new-contact-added.mjs b/components/yay_com/sources/new-contact-added/new-contact-added.mjs new file mode 100644 index 0000000000000..af7bdd3551a41 --- /dev/null +++ b/components/yay_com/sources/new-contact-added/new-contact-added.mjs @@ -0,0 +1,50 @@ +import common from "../common/polling.mjs"; + +export default { + ...common, + key: "yay_com-new-contact-added", + name: "New Contact Added", + description: "Emit new event when a new contact is added to a phone book. [See the documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book-contact/)", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + ...common.props, + phoneBookId: { + propDefinition: [ + common.props.yayCom, + "phoneBookId", + ], + }, + }, + methods: { + ...common.methods, + generateMeta(contact) { + const name = this.getItemId(contact); + return { + id: name, + summary: `New Contact: ${name}`, + ts: Date.now(), + }; + }, + getItemId(contact) { + let name = `${contact.first_name} ${contact.last_name}`; + if (!name.trim()) { + name = contact.company_name; + } + return name; + }, + async getItems() { + const { phoneBookId } = this; + const contacts = await this.yayCom.listPhoneBookContacts({ + phoneBookId, + params: { + sort: "id", + limit: 100, + uuid: phoneBookId, + }, + }); + return contacts || []; + }, + }, +}; diff --git a/components/yay_com/yay_com.app.mjs b/components/yay_com/yay_com.app.mjs index bb202e3acc53e..63684456cb49a 100644 --- a/components/yay_com/yay_com.app.mjs +++ b/components/yay_com/yay_com.app.mjs @@ -9,8 +9,8 @@ export default { label: "SIP User", description: "The SIP user to make the outbound call for", async options() { - const { result } = await this.listSipUsers(); - return result?.map(({ + const users = await this.listSipUsers(); + return users?.map(({ uuid: value, display_name, user_name, }) => ({ label: display_name || user_name, @@ -24,8 +24,8 @@ export default { description: "List of SIP users who will receive the outbound call request", optional: true, async options() { - const { result } = await this.listSipUsers(); - return result?.map(({ + const users = await this.listSipUsers(); + return users?.map(({ uuid: value, display_name, user_name, }) => ({ label: display_name || user_name, @@ -39,8 +39,22 @@ export default { description: "List of hunt groups who will receive the outbound call request", optional: true, async options() { - const { result } = await this.listHuntGroups(); - return result?.map(({ + const groups = await this.listHuntGroups(); + return groups?.map(({ + uuid: value, name: label, + }) => ({ + label, + value, + })) || []; + }, + }, + phoneBookId: { + type: "string", + label: "Phone Book", + description: "The phone book to monitor for new contacts", + async options() { + const books = await this.listPhoneBooks(); + return books?.map(({ uuid: value, name: label, }) => ({ label, @@ -101,7 +115,23 @@ export default { }, async listPhoneBooks(args) { return this._makeRequest({ - path: "/phone-book", + path: "/voip/phone-book", + ...args, + }); + }, + async listPhoneBookContacts({ + phoneBookId, ...args + }) { + return this._makeRequest({ + path: `/voip/phone-book/${phoneBookId}`, + ...args, + }); + }, + async listMailboxMessages({ + mailboxId, ...args + }) { + return this._makeRequest({ + path: `/voip/mailbox/${mailboxId}/messages`, ...args, }); }, From 4e533db33515ca2b73fc44aa410add322b2a2a86 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 25 Jun 2025 04:00:22 -0300 Subject: [PATCH 6/9] Adjustments --- .../create-outbound-call.mjs | 11 ++++++----- .../actions/get-documents/get-documents.mjs | 2 +- .../actions/get-phone-books/get-phone-books.mjs | 2 +- .../new-contact-added/new-contact-added.mjs | 2 +- components/yay_com/yay_com.app.mjs | 17 +---------------- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs index 06f8ed404292c..0bc9d819cac8f 100644 --- a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs +++ b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs @@ -4,7 +4,7 @@ import yayCom from "../../yay_com.app.mjs"; export default { key: "yay_com-create-outbound-call", name: "Create Outbound Call", - description: "Initiates an outbound call to a specified number. [See documentation](https://www.yay.com/voip/api-docs/calls/outbound-call/)", + description: "Initiates an outbound call to a specified number. [See the documentation](https://www.yay.com/voip/api-docs/calls/outbound-call/)", version: "0.0.1", type: "action", props: { @@ -30,8 +30,11 @@ export default { sipUsers: { propDefinition: [ yayCom, - "sipUsers", + "sipUser", ], + type: "string[]", + description: "One or more SIP users who will receive the outbound call request", + optional: true, }, huntGroups: { propDefinition: [ @@ -63,9 +66,7 @@ export default { user_uuid: this.userUuid, destination: this.destination, display_name: this.displayName, - ...(targets.length > 0 && { - targets, - }), + targets, }, }); diff --git a/components/yay_com/actions/get-documents/get-documents.mjs b/components/yay_com/actions/get-documents/get-documents.mjs index c5c5ab92f7eb9..e57d0c70f1377 100644 --- a/components/yay_com/actions/get-documents/get-documents.mjs +++ b/components/yay_com/actions/get-documents/get-documents.mjs @@ -4,7 +4,7 @@ export default { key: "yay_com-get-documents", name: "Get Documents", description: - "Retrieves a list of documents. [See documentation](https://www.yay.com/voip/api-docs/account/document/)", + "Retrieves all documents available. [See the documentation](https://www.yay.com/voip/api-docs/account/document/)", version: "0.0.1", type: "action", props: { diff --git a/components/yay_com/actions/get-phone-books/get-phone-books.mjs b/components/yay_com/actions/get-phone-books/get-phone-books.mjs index 896ca40262970..717c52b2a7320 100644 --- a/components/yay_com/actions/get-phone-books/get-phone-books.mjs +++ b/components/yay_com/actions/get-phone-books/get-phone-books.mjs @@ -3,7 +3,7 @@ import yayCom from "../../yay_com.app.mjs"; export default { key: "yay_com-get-phone-books", name: "Get Phone Books", - description: "Retrieves a list of phone books. [See documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book/)", + description: "Retrieves all phone books available. [See the documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book/)", version: "0.0.1", type: "action", props: { diff --git a/components/yay_com/sources/new-contact-added/new-contact-added.mjs b/components/yay_com/sources/new-contact-added/new-contact-added.mjs index af7bdd3551a41..7d9941355f517 100644 --- a/components/yay_com/sources/new-contact-added/new-contact-added.mjs +++ b/components/yay_com/sources/new-contact-added/new-contact-added.mjs @@ -4,7 +4,7 @@ export default { ...common, key: "yay_com-new-contact-added", name: "New Contact Added", - description: "Emit new event when a new contact is added to a phone book. [See the documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book-contact/)", + description: "Emit new event when a contact is added to a phone book. [See the documentation](https://www.yay.com/voip/api-docs/phone-books/phone-book-contact/)", version: "0.0.1", type: "source", dedupe: "unique", diff --git a/components/yay_com/yay_com.app.mjs b/components/yay_com/yay_com.app.mjs index 63684456cb49a..f9e9d13051d69 100644 --- a/components/yay_com/yay_com.app.mjs +++ b/components/yay_com/yay_com.app.mjs @@ -18,25 +18,10 @@ export default { })) || []; }, }, - sipUsers: { - type: "string[]", - label: "SIP Users", - description: "List of SIP users who will receive the outbound call request", - optional: true, - async options() { - const users = await this.listSipUsers(); - return users?.map(({ - uuid: value, display_name, user_name, - }) => ({ - label: display_name || user_name, - value, - })) || []; - }, - }, huntGroups: { type: "string[]", label: "Hunt Groups", - description: "List of hunt groups who will receive the outbound call request", + description: "One or more hunt groups who will receive the outbound call request", optional: true, async options() { const groups = await this.listHuntGroups(); From b2c63a762109873ad2f5bdfb6f59183f565093c4 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 26 Jun 2025 19:52:02 -0300 Subject: [PATCH 7/9] Adding source deploy + package bump --- components/yay_com/package.json | 5 ++++- components/yay_com/sources/common/polling.mjs | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/yay_com/package.json b/components/yay_com/package.json index 98b13fa30e8a7..62a171dc5373b 100644 --- a/components/yay_com/package.json +++ b/components/yay_com/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/yay_com", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Yay.com Components", "main": "yay_com.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/yay_com/sources/common/polling.mjs b/components/yay_com/sources/common/polling.mjs index 9eff4cd6a2704..f5bf0ad9bf2bb 100644 --- a/components/yay_com/sources/common/polling.mjs +++ b/components/yay_com/sources/common/polling.mjs @@ -19,7 +19,7 @@ export default { _setSavedIds(ids) { this.db.set("savedIds", ids); }, - async startEvent() { + async startEvent(maxItems) { const savedIds = this._getSavedIds(); const items = await this.getItems(savedIds); @@ -28,7 +28,9 @@ export default { const id = this.getItemId(item); if (!savedIds.includes(id)) { const meta = this.generateMeta(item); - this.$emit(item, meta); + if (maxItems === undefined || (typeof maxItems === "number" && --maxItems >= 0)) { + this.$emit(item, meta); + } newIds.push(id); } } @@ -46,4 +48,9 @@ export default { async run() { await this.startEvent(); }, + hooks: { + async deploy() { + await this.startEvent(5); + }, + }, }; From 80f4e92b706535708b393ee060b15225e232e318 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 26 Jun 2025 19:57:27 -0300 Subject: [PATCH 8/9] pnpm --- pnpm-lock.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f4ed2c37caba3..29227eddf06b3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15087,7 +15087,11 @@ importers: specifier: ^1.2.0 version: 1.6.6 - components/yay_com: {} + components/yay_com: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/yelp: dependencies: From 251cef71996303080858355f8e3a357ce04f2c01 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 26 Jun 2025 20:00:05 -0300 Subject: [PATCH 9/9] Description updates --- .../actions/create-outbound-call/create-outbound-call.mjs | 1 + components/yay_com/yay_com.app.mjs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs index 0bc9d819cac8f..f00c013d1ce89 100644 --- a/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs +++ b/components/yay_com/actions/create-outbound-call/create-outbound-call.mjs @@ -32,6 +32,7 @@ export default { yayCom, "sipUser", ], + label: "Target SIP Users", type: "string[]", description: "One or more SIP users who will receive the outbound call request", optional: true, diff --git a/components/yay_com/yay_com.app.mjs b/components/yay_com/yay_com.app.mjs index f9e9d13051d69..3011f0c33831c 100644 --- a/components/yay_com/yay_com.app.mjs +++ b/components/yay_com/yay_com.app.mjs @@ -6,7 +6,7 @@ export default { propDefinitions: { sipUser: { type: "string", - label: "SIP User", + label: "SIP User ID", description: "The SIP user to make the outbound call for", async options() { const users = await this.listSipUsers(); @@ -20,7 +20,7 @@ export default { }, huntGroups: { type: "string[]", - label: "Hunt Groups", + label: "Target Hunt Groups", description: "One or more hunt groups who will receive the outbound call request", optional: true, async options() {