From a332e9549e724cffab8f1158053f92e2ad17ffc0 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Tue, 1 Oct 2024 15:07:34 -0300 Subject: [PATCH 1/5] helpspot init --- .../actions/create-request/create-request.mjs | 65 +++++++++ .../actions/update-request/update-request.mjs | 34 +++++ components/helpspot/helpspot.app.mjs | 132 +++++++++++++++++- components/helpspot/package.json | 2 +- .../sources/new-request/new-request.mjs | 65 +++++++++ .../sources/new-search/new-search.mjs | 78 +++++++++++ .../sources/request-update/request-update.mjs | 72 ++++++++++ 7 files changed, 442 insertions(+), 6 deletions(-) create mode 100644 components/helpspot/actions/create-request/create-request.mjs create mode 100644 components/helpspot/actions/update-request/update-request.mjs create mode 100644 components/helpspot/sources/new-request/new-request.mjs create mode 100644 components/helpspot/sources/new-search/new-search.mjs create mode 100644 components/helpspot/sources/request-update/request-update.mjs diff --git a/components/helpspot/actions/create-request/create-request.mjs b/components/helpspot/actions/create-request/create-request.mjs new file mode 100644 index 0000000000000..5ab45fb9ecded --- /dev/null +++ b/components/helpspot/actions/create-request/create-request.mjs @@ -0,0 +1,65 @@ +import helpspot from "../../helpspot.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "helpspot-create-request", + name: "Create Request", + description: "Creates a new user request. At least one of the following props is needed: first name, last name, user id, email, or phone. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + version: "0.0.1", + type: "action", + props: { + helpspot, + note: { + type: "string", + label: "Note", + description: "The note content for the request", + }, + firstName: { + propDefinition: [ + helpspot, + "firstName", + ], + }, + lastName: { + propDefinition: [ + helpspot, + "lastName", + ], + }, + userId: { + propDefinition: [ + helpspot, + "userId", + ], + }, + email: { + propDefinition: [ + helpspot, + "email", + ], + }, + phone: { + propDefinition: [ + helpspot, + "phone", + ], + }, + }, + async run({ $ }) { + if (!this.firstName && !this.lastName && !this.userId && !this.email && !this.phone) { + throw new Error("You must provide at least one of the following: first name, last name, user ID, email, or phone."); + } + + const response = await this.helpspot.createRequest({ + note: this.note, + firstName: this.firstName, + lastName: this.lastName, + userId: this.userId, + email: this.email, + phone: this.phone, + }); + + $.export("$summary", `Successfully created request with access key: ${response.accesskey}`); + return response; + }, +}; diff --git a/components/helpspot/actions/update-request/update-request.mjs b/components/helpspot/actions/update-request/update-request.mjs new file mode 100644 index 0000000000000..c10dc5a2cbf92 --- /dev/null +++ b/components/helpspot/actions/update-request/update-request.mjs @@ -0,0 +1,34 @@ +import helpspot from "../../helpspot.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "helpspot-update-request", + name: "Update Request", + description: "Updates an existing user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + version: "0.0.{{ts}}", + type: "action", + props: { + helpspot, + xRequestId: { + propDefinition: [ + helpspot, + "xRequestId", + ], + }, + note: { + propDefinition: [ + helpspot, + "note", + ], + }, + }, + async run({ $ }) { + const params = { + xRequestId: this.xRequestId, + note: this.note, + }; + const response = await this.helpspot.updateRequest(params); + $.export("$summary", `Successfully updated request with ID ${this.xRequestId}`); + return response; + }, +}; diff --git a/components/helpspot/helpspot.app.mjs b/components/helpspot/helpspot.app.mjs index 982fb6ada862d..00a00b6f11be3 100644 --- a/components/helpspot/helpspot.app.mjs +++ b/components/helpspot/helpspot.app.mjs @@ -1,11 +1,133 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "helpspot", - propDefinitions: {}, + propDefinitions: { + searchQuery: { + type: "string", + label: "Search Query", + description: "The search query to search for requests", + }, + requestId: { + type: "string", + label: "Request ID", + description: "The ID of the request to update", + }, + xRequestId: { + type: "string", + label: "XRequest ID", + description: "The XRequest ID needed to identify the specific request that needs to be updated", + }, + firstName: { + type: "string", + label: "First Name", + description: "The first name of the user. Required if no other identification details are provided", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "The last name of the user. Required if no other identification details are provided", + optional: true, + }, + userId: { + type: "string", + label: "User ID", + description: "The user ID of the user. Required if no other identification details are provided", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "The email of the user. Required if no other identification details are provided", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "The phone number of the user. Required if no other identification details are provided", + optional: true, + }, + note: { + type: "string", + label: "Note", + description: "The note content for the request", + }, + accessKey: { + type: "string", + label: "Access Key", + description: "The access key for the specific request", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://yourdomain.helpspot.com/api/index.php"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path = "/", headers, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + }, + }); + }, + async createRequest({ + note, firstName, lastName, userId, email, phone, + }) { + const params = new URLSearchParams(); + params.append("method", "request.create"); + params.append("tNote", note); + if (firstName) params.append("sFirstName", firstName); + if (lastName) params.append("sLastName", lastName); + if (userId) params.append("sUserId", userId); + if (email) params.append("sEmail", email); + if (phone) params.append("sPhone", phone); + return this._makeRequest({ + method: "POST", + data: params, + }); + }, + async updateRequest({ + xRequestId, note, + }) { + const params = new URLSearchParams(); + params.append("method", "request.update"); + params.append("accesskey", xRequestId); + params.append("tNote", note); + return this._makeRequest({ + method: "POST", + data: params, + }); + }, + async searchRequests({ searchQuery }) { + const params = new URLSearchParams(); + params.append("method", "request.search"); + params.append("query", searchQuery); + return this._makeRequest({ + method: "POST", + data: params, + }); + }, + async getRequest({ requestId }) { + const params = new URLSearchParams(); + params.append("method", "request.get"); + params.append("accesskey", requestId); + return this._makeRequest({ + method: "GET", + params, + }); + }, + async emitNewRequest() { + // Implementation to poll for new requests or subscribe to webhooks if supported. + }, + async emitUpdatedRequest({ requestId }) { + // Implementation to poll for updated requests or subscribe to webhooks if supported. }, }, -}; \ No newline at end of file +}; diff --git a/components/helpspot/package.json b/components/helpspot/package.json index 95d10790828f2..5f992a1f918c3 100644 --- a/components/helpspot/package.json +++ b/components/helpspot/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/helpspot/sources/new-request/new-request.mjs b/components/helpspot/sources/new-request/new-request.mjs new file mode 100644 index 0000000000000..9b746e22816ff --- /dev/null +++ b/components/helpspot/sources/new-request/new-request.mjs @@ -0,0 +1,65 @@ +import helpspot from "../../helpspot.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "helpspot-new-request", + name: "New Request Created", + description: "Emit new event when a new request is created. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + helpspot, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: 60, + }, + }, + }, + methods: { + _getLastRequestId() { + return this.db.get("lastRequestId") || null; + }, + _setLastRequestId(id) { + this.db.set("lastRequestId", id); + }, + async emitNewRequests() { + const lastRequestId = this._getLastRequestId(); + const searchQuery = lastRequestId + ? `xRequest>${lastRequestId}` + : "Date_Created:[* TO NOW]"; + + const newRequests = await this.helpspot.searchRequests({ + searchQuery, + }); + + for (const request of newRequests) { + this.$emit(request, { + id: request.xRequest, + summary: `New Request: ${request.xRequest}`, + ts: Date.parse(request.dtGMTOpened), + }); + } + + if (newRequests.length) { + this._setLastRequestId(newRequests[newRequests.length - 1].xRequest); + } + }, + }, + hooks: { + async deploy() { + await this.emitNewRequests(); + }, + async activate() { + await this.emitNewRequests(); + }, + async deactivate() { + // Clean up any resources if needed + }, + }, + async run() { + await this.emitNewRequests(); + }, +}; diff --git a/components/helpspot/sources/new-search/new-search.mjs b/components/helpspot/sources/new-search/new-search.mjs new file mode 100644 index 0000000000000..9080d3c3460e6 --- /dev/null +++ b/components/helpspot/sources/new-search/new-search.mjs @@ -0,0 +1,78 @@ +import { axios } from "@pipedream/platform"; +import helpspot from "../../helpspot.app.mjs"; + +export default { + key: "helpspot-new-search", + name: "New Search Event", + description: "Emit new event based on a search. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + helpspot, + db: "$.service.db", + searchQuery: { + propDefinition: [ + helpspot, + "searchQuery", + ], + }, + timer: { + type: "$.interface.timer", + label: "Poll Schedule", + description: "Pipedream will poll the HelpSpot API on this schedule", + default: { + intervalSeconds: 3600, + }, + }, + }, + methods: { + _getLastSearchId() { + return this.db.get("lastSearchId") || null; + }, + _setLastSearchId(id) { + this.db.set("lastSearchId", id); + }, + }, + hooks: { + async deploy() { + const results = await this.helpspot.searchRequests({ + searchQuery: this.searchQuery, + }); + const lastResult = results[results.length - 1]; + + if (lastResult) { + this._setLastSearchId(lastResult.xRequest); + } + + for (const result of results.slice(0, 50)) { + this.$emit(result, { + id: result.xRequest, + summary: `New request: ${result.sTitle || result.sFirstName || result.sLastName || result.tNote}`, + ts: Date.parse(result.dtGMTOpened), + }); + } + }, + }, + async run() { + const lastSearchId = this._getLastSearchId(); + const results = await this.helpspot.searchRequests({ + searchQuery: this.searchQuery, + }); + + for (const result of results) { + if (!lastSearchId || result.xRequest > lastSearchId) { + this.$emit(result, { + id: result.xRequest, + summary: `New request: ${result.sTitle || result.sFirstName || result.sLastName || result.tNote}`, + ts: Date.parse(result.dtGMTOpened), + }); + } + } + + const newLastResult = results[results.length - 1]; + if (newLastResult) { + this._setLastSearchId(newLastResult.xRequest); + } + }, +}; diff --git a/components/helpspot/sources/request-update/request-update.mjs b/components/helpspot/sources/request-update/request-update.mjs new file mode 100644 index 0000000000000..e62ed59d7d14c --- /dev/null +++ b/components/helpspot/sources/request-update/request-update.mjs @@ -0,0 +1,72 @@ +import helpspot from "../../helpspot.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "helpspot-request-update", + name: "Request Update", + description: "Emit new event when a request is updated. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + helpspot, + db: "$.service.db", + requestId: { + propDefinition: [ + helpspot, + "requestId", + ], + }, + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: 60 * 15, // Poll every 15 minutes + }, + }, + }, + methods: { + _getLastUpdated() { + return this.db.get("lastUpdated") ?? null; + }, + _setLastUpdated(ts) { + this.db.set("lastUpdated", ts); + }, + }, + hooks: { + async deploy() { + // Fetch initial data + const request = await this.helpspot.getRequest({ + requestId: this.requestId, + }); + if (request.request_history && request.request_history.length > 0) { + // Emit the most recent history record, if available + const latestHistory = request.request_history[0]; + this.$emit(latestHistory, { + id: latestHistory.xRequestHistory, + summary: `New update for request: ${latestHistory.xRequest}`, + ts: Date.parse(latestHistory.dtGMTChange), + }); + this._setLastUpdated(latestHistory.dtGMTChange); + } + }, + }, + async run() { + const lastUpdated = this._getLastUpdated(); + const request = await this.helpspot.getRequest({ + requestId: this.requestId, + }); + if (request.request_history && request.request_history.length > 0) { + for (const historyItem of request.request_history) { + const historyTimestamp = Date.parse(historyItem.dtGMTChange); + if (!lastUpdated || historyTimestamp > Date.parse(lastUpdated)) { + this.$emit(historyItem, { + id: historyItem.xRequestHistory, + summary: `Update for request: ${historyItem.xRequest}`, + ts: historyTimestamp, + }); + this._setLastUpdated(historyItem.dtGMTChange); + } + } + } + }, +}; From 44ee8d99950eb2d6612a47a33d5404ce504aaf94 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 3 Oct 2024 17:52:59 -0300 Subject: [PATCH 2/5] [Components] helpspot #14147 Sources - New Request - New Request Updated Actions - Update Request - Create Request --- .../helpspot/actions/common/request-base.mjs | 131 ++++++++ .../actions/create-request/create-request.mjs | 86 ++---- .../actions/update-request/update-request.mjs | 63 ++-- components/helpspot/common/constants.mjs | 82 +++++ components/helpspot/common/utils.mjs | 24 ++ components/helpspot/helpspot.app.mjs | 285 ++++++++++++------ components/helpspot/package.json | 6 +- components/helpspot/sources/common/base.mjs | 55 ++++ .../sources/new-request/new-request.mjs | 72 ++--- .../sources/new-request/test-event.mjs | 53 ++++ .../sources/new-search/new-search.mjs | 78 ----- .../sources/request-update/request-update.mjs | 96 +++--- .../sources/request-update/test-event.mjs | 172 +++++++++++ 13 files changed, 842 insertions(+), 361 deletions(-) create mode 100644 components/helpspot/actions/common/request-base.mjs create mode 100644 components/helpspot/common/constants.mjs create mode 100644 components/helpspot/common/utils.mjs create mode 100644 components/helpspot/sources/common/base.mjs create mode 100644 components/helpspot/sources/new-request/test-event.mjs delete mode 100644 components/helpspot/sources/new-search/new-search.mjs create mode 100644 components/helpspot/sources/request-update/test-event.mjs diff --git a/components/helpspot/actions/common/request-base.mjs b/components/helpspot/actions/common/request-base.mjs new file mode 100644 index 0000000000000..39d9f75a96ca0 --- /dev/null +++ b/components/helpspot/actions/common/request-base.mjs @@ -0,0 +1,131 @@ +import { + NOTE_IS_HTML, + NOTE_TYPE_OPTIONS, + OPENED_VIA_OPTIONS, +} from "../../common/constants.mjs"; +import helpspot from "../../helpspot.app.mjs"; + +export default { + props: { + helpspot, + tNote: { + type: "string", + label: "Note", + description: "The note of the request", + }, + xCategory: { + propDefinition: [ + helpspot, + "xCategory", + ], + }, + fNoteType: { + type: "string", + label: "Note Type", + description: "The type of the note", + options: NOTE_TYPE_OPTIONS, + optional: true, + }, + fNoteIsHTML: { + type: "string", + label: "Note Is HTML?", + description: "whether the note is HTML or text", + optional: true, + options: NOTE_IS_HTML, + }, + sTitle: { + type: "string", + label: "Subject", + description: "The title used as email subject", + optional: true, + }, + xStatus: { + propDefinition: [ + helpspot, + "xStatus", + ], + optional: true, + }, + sUserId: { + type: "string", + label: "User Id", + description: "The Id of the customer", + optional: true, + }, + sFirstName: { + type: "string", + label: "First Name", + description: "The first name of the request creator", + optional: true, + }, + sLastName: { + type: "string", + label: "Last Name", + description: "The last name of the request creator", + optional: true, + }, + sEmail: { + type: "string", + label: "Email", + description: "The email of the request creator", + optional: true, + }, + sPhone: { + type: "string", + label: "Phone", + description: "The phone number of the request creator", + optional: true, + }, + fUrgent: { + type: "boolean", + label: "Urgent", + description: "Whether the request is urgent or not", + optional: true, + }, + fOpenedVia: { + type: "integer", + label: "Opened Via", + description: "Request opened via", + options: OPENED_VIA_OPTIONS, + optional: true, + }, + emailFrom: { + propDefinition: [ + helpspot, + "emailFrom", + ], + optional: true, + }, + emailCC: { + type: "string[]", + label: "Email CC", + description: "A list of emails to CC on the request", + optional: true, + }, + emailBCC: { + type: "string[]", + label: "Email BCC", + description: "A list of emails to BCC on the request", + optional: true, + }, + emailStaff: { + propDefinition: [ + helpspot, + "emailStaff", + ], + optional: true, + }, + }, + async run({ $ }) { + await this.getValidation(); + + const fn = this.getFunction(); + const response = await fn({ + $, + data: this.getData(), + }); + + $.export("$summary", this.getSummary(response)); + return response; + }, +}; diff --git a/components/helpspot/actions/create-request/create-request.mjs b/components/helpspot/actions/create-request/create-request.mjs index 5ab45fb9ecded..550591c2f86e2 100644 --- a/components/helpspot/actions/create-request/create-request.mjs +++ b/components/helpspot/actions/create-request/create-request.mjs @@ -1,65 +1,45 @@ -import helpspot from "../../helpspot.app.mjs"; -import { axios } from "@pipedream/platform"; +import { parseObject } from "../../common/utils.mjs"; +import common from "../common/request-base.mjs"; export default { + ...common, key: "helpspot-create-request", name: "Create Request", - description: "Creates a new user request. At least one of the following props is needed: first name, last name, user id, email, or phone. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + description: "Creates a new user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=164#private.request.create)", version: "0.0.1", type: "action", - props: { - helpspot, - note: { - type: "string", - label: "Note", - description: "The note content for the request", + methods: { + getValidation() { + if (!this.sFirstName && !this.sLastName && !this.sUserId && !this.sEmail && !this.sPhone) { + throw new Error("You must provide at least one of the following: First Name, Last Name, User ID, Email, or Phone."); + } }, - firstName: { - propDefinition: [ - helpspot, - "firstName", - ], + getFunction() { + return this.helpspot.createRequest; }, - lastName: { - propDefinition: [ - helpspot, - "lastName", - ], + getData() { + return { + tNote: this.tNote, + xCategory: this.xCategory, + fNoteType: this.fNoteType && parseInt(this.fNoteType), + fNoteIsHTML: this.fNoteIsHTML && parseInt(this.fNoteIsHTML), + sTitle: this.sTitle, + xStatus: this.xStatus, + sUserId: this.sUserId, + sFirstName: this.sFirstName, + sLastName: this.sLastName, + sEmail: this.sEmail, + sPhone: this.sPhone, + fUrgent: +this.fUrgent, + fOpenedVia: this.fOpenedVia, + email_from: this.emailFrom, + email_cc: parseObject(this.emailCC)?.join(), + email_bcc: parseObject(this.emailBCC)?.join(), + email_staff: parseObject(this.emailStaff)?.join(), + }; }, - userId: { - propDefinition: [ - helpspot, - "userId", - ], + getSummary(response) { + return `Successfully created request with Id: ${response.xRequest}`; }, - email: { - propDefinition: [ - helpspot, - "email", - ], - }, - phone: { - propDefinition: [ - helpspot, - "phone", - ], - }, - }, - async run({ $ }) { - if (!this.firstName && !this.lastName && !this.userId && !this.email && !this.phone) { - throw new Error("You must provide at least one of the following: first name, last name, user ID, email, or phone."); - } - - const response = await this.helpspot.createRequest({ - note: this.note, - firstName: this.firstName, - lastName: this.lastName, - userId: this.userId, - email: this.email, - phone: this.phone, - }); - - $.export("$summary", `Successfully created request with access key: ${response.accesskey}`); - return response; }, }; diff --git a/components/helpspot/actions/update-request/update-request.mjs b/components/helpspot/actions/update-request/update-request.mjs index c10dc5a2cbf92..0f8202da5c03e 100644 --- a/components/helpspot/actions/update-request/update-request.mjs +++ b/components/helpspot/actions/update-request/update-request.mjs @@ -1,34 +1,53 @@ -import helpspot from "../../helpspot.app.mjs"; -import { axios } from "@pipedream/platform"; +import { parseObject } from "../../common/utils.mjs"; +import common from "../common/request-base.mjs"; export default { + ...common, key: "helpspot-update-request", name: "Update Request", - description: "Updates an existing user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", - version: "0.0.{{ts}}", + description: "Updates an existing user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=164#private.request.update)", + version: "0.0.1", type: "action", props: { - helpspot, - xRequestId: { + ...common.props, + xRequest: { propDefinition: [ - helpspot, - "xRequestId", - ], - }, - note: { - propDefinition: [ - helpspot, - "note", + common.props.helpspot, + "xRequest", ], }, }, - async run({ $ }) { - const params = { - xRequestId: this.xRequestId, - note: this.note, - }; - const response = await this.helpspot.updateRequest(params); - $.export("$summary", `Successfully updated request with ID ${this.xRequestId}`); - return response; + methods: { + getValidation() { + return true; + }, + getFunction() { + return this.helpspot.updateRequest; + }, + getData() { + return { + xRequest: this.xRequest, + tNote: this.tNote, + xCategory: this.xCategory, + fNoteType: this.fNoteType && parseInt(this.fNoteType), + fNoteIsHTML: this.fNoteIsHTML && parseInt(this.fNoteIsHTML), + sTitle: this.sTitle, + xStatus: this.xStatus, + sUserId: this.sUserId, + sFirstName: this.sFirstName, + sLastName: this.sLastName, + sEmail: this.sEmail, + sPhone: this.sPhone, + fUrgent: +this.fUrgent, + fOpenedVia: this.fOpenedVia, + email_from: this.emailFrom, + email_cc: parseObject(this.emailCC)?.join(), + email_bcc: parseObject(this.emailBCC)?.join(), + email_staff: parseObject(this.emailStaff)?.join(), + }; + }, + getSummary() { + return `Successfully updated request with ID ${this.xRequest}`; + }, }, }; diff --git a/components/helpspot/common/constants.mjs b/components/helpspot/common/constants.mjs new file mode 100644 index 0000000000000..4c3264b552835 --- /dev/null +++ b/components/helpspot/common/constants.mjs @@ -0,0 +1,82 @@ +export const LIMIT = 100; + +export const NOTE_TYPE_OPTIONS = [ + { + label: "Private", + value: "0", + }, + { + label: "Public", + value: "1", + }, + { + label: "External", + value: "2", + }, +]; + +export const NOTE_IS_HTML = [ + { + label: "Text", + value: "0", + }, + { + label: "HTML", + value: "1", + }, +]; + +export const OPENED_VIA_OPTIONS = [ + { + label: "Email", + value: 1, + }, + { + label: "Phone", + value: 2, + }, + { + label: "Walk In", + value: 3, + }, + { + label: "Mail", + value: 4, + }, + { + label: "Other", + value: 5, + }, + { + label: "Web Service", + value: 6, + }, + { + label: "Web Form", + value: 7, + }, + { + label: "Forum", + value: 8, + }, + { + label: "Instant Messenger", + value: 9, + }, + { + label: "Fax", + value: 10, + }, + { + label: "Voicemail", + value: 11, + }, + { + label: "Staff Initiated", + value: 12, + }, + { + label: "Tab Widget", + value: 13, + }, +]; diff --git a/components/helpspot/common/utils.mjs b/components/helpspot/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/helpspot/common/utils.mjs @@ -0,0 +1,24 @@ +export const parseObject = (obj) => { + if (!obj) return undefined; + + if (Array.isArray(obj)) { + return obj.map((item) => { + if (typeof item === "string") { + try { + return JSON.parse(item); + } catch (e) { + return item; + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/helpspot/helpspot.app.mjs b/components/helpspot/helpspot.app.mjs index 00a00b6f11be3..5c05332f988d2 100644 --- a/components/helpspot/helpspot.app.mjs +++ b/components/helpspot/helpspot.app.mjs @@ -1,133 +1,224 @@ import { axios } from "@pipedream/platform"; +import { LIMIT } from "./common/constants.mjs"; export default { type: "app", app: "helpspot", propDefinitions: { - searchQuery: { + xCategory: { type: "string", - label: "Search Query", - description: "The search query to search for requests", - }, - requestId: { - type: "string", - label: "Request ID", - description: "The ID of the request to update", - }, - xRequestId: { - type: "string", - label: "XRequest ID", - description: "The XRequest ID needed to identify the specific request that needs to be updated", - }, - firstName: { - type: "string", - label: "First Name", - description: "The first name of the user. Required if no other identification details are provided", - optional: true, - }, - lastName: { - type: "string", - label: "Last Name", - description: "The last name of the user. Required if no other identification details are provided", - optional: true, - }, - userId: { - type: "string", - label: "User ID", - description: "The user ID of the user. Required if no other identification details are provided", - optional: true, - }, - email: { - type: "string", - label: "Email", - description: "The email of the user. Required if no other identification details are provided", - optional: true, - }, - phone: { + label: "Category", + description: "The category id of the request.", + async options({ page }) { + const { category } = await this.listCategories({ + params: { + page, + }, + }); + + return Object.entries(category).map(([ + , { + xCategory: value, sCategory: label, + }, + ]) => ({ + label, + value, + })); + }, + }, + emailFrom: { type: "string", - label: "Phone", - description: "The phone number of the user. Required if no other identification details are provided", - optional: true, - }, - note: { + label: "Send Email From", + description: "The ID of the mailbox to send emails from", + async options({ page }) { + const { mailbox } = await this.listMailboxes({ + params: { + page, + }, + }); + + return mailbox.map(({ + xMailbox: value, sReplyName, sReplyEmail, + }) => ({ + label: `${sReplyName} - ${sReplyEmail}`, + value, + })); + }, + }, + emailStaff: { + type: "string[]", + label: "Email Staff", + description: "List of staff to email", + async options({ page }) { + const { person } = await this.listActiveStaff({ + params: { + page, + }, + }); + + return person.map(({ + xPerson: value, sFname, sLname, sEmail, + }) => ({ + label: `${sFname} ${sLname} - ${sEmail}`, + value, + })); + }, + }, + xStatus: { type: "string", - label: "Note", - description: "The note content for the request", - }, - accessKey: { + label: "Status", + description: "Select a status of the request", + async options({ page }) { + const { status } = await this.listStatuses({ + params: { + page, + }, + }); + + return status.map(({ + xStatus: value, sStatus: label, + }) => ({ + label, + value, + })); + }, + }, + xRequest: { type: "string", - label: "Access Key", - description: "The access key for the specific request", + label: "Request Id", + description: "The Id of the request", + async options({ page }) { + const { request } = await this.listRequests({ + params: { + page, + }, + }); + + return request.map(({ + xRequest: value, sTitle: label, + }) => ({ + label, + value, + })); + }, }, }, methods: { _baseUrl() { - return "https://yourdomain.helpspot.com/api/index.php"; + return `https://${this.$auth.subdomain}.helpspot.com/api/index.php`; + }, + _headers() { + return { + "Authorization": `Bearer ${this.$auth.api_token}`, + "content-type": "multipart/form-data", + }; }, - async _makeRequest(opts = {}) { - const { - $ = this, method = "GET", path = "/", headers, ...otherOpts - } = opts; + _makeRequest({ + $ = this, methodParam, params, ...opts + }) { return axios($, { - ...otherOpts, - method, - url: this._baseUrl() + path, - headers: { - ...headers, + url: this._baseUrl(), + headers: this._headers(), + params: { + ...params, + method: methodParam, + output: "json", }, + ...opts, }); }, - async createRequest({ - note, firstName, lastName, userId, email, phone, - }) { - const params = new URLSearchParams(); - params.append("method", "request.create"); - params.append("tNote", note); - if (firstName) params.append("sFirstName", firstName); - if (lastName) params.append("sLastName", lastName); - if (userId) params.append("sUserId", userId); - if (email) params.append("sEmail", email); - if (phone) params.append("sPhone", phone); + createRequest(opts = {}) { return this._makeRequest({ method: "POST", - data: params, + methodParam: "private.request.create", + ...opts, }); }, - async updateRequest({ - xRequestId, note, - }) { - const params = new URLSearchParams(); - params.append("method", "request.update"); - params.append("accesskey", xRequestId); - params.append("tNote", note); + getRequest(opts = {}) { return this._makeRequest({ - method: "POST", - data: params, + methodParam: "private.request.get", + ...opts, }); }, - async searchRequests({ searchQuery }) { - const params = new URLSearchParams(); - params.append("method", "request.search"); - params.append("query", searchQuery); + listCategories(opts = {}) { return this._makeRequest({ - method: "POST", - data: params, + methodParam: "private.request.getCategories", + ...opts, }); }, - async getRequest({ requestId }) { - const params = new URLSearchParams(); - params.append("method", "request.get"); - params.append("accesskey", requestId); + listMailboxes(opts = {}) { return this._makeRequest({ - method: "GET", - params, + methodParam: "private.request.getMailboxes", + ...opts, }); }, - async emitNewRequest() { - // Implementation to poll for new requests or subscribe to webhooks if supported. + listActiveStaff(opts = {}) { + return this._makeRequest({ + methodParam: "private.util.getActiveStaff", + ...opts, + }); }, - async emitUpdatedRequest({ requestId }) { - // Implementation to poll for updated requests or subscribe to webhooks if supported. + listStatuses(opts = {}) { + return this._makeRequest({ + methodParam: "private.request.getStatusTypes", + ...opts, + }); + }, + listRequests(opts = {}) { + return this._makeRequest({ + methodParam: "private.request.search", + ...opts, + }); + }, + listChanges(opts = {}) { + return this._makeRequest({ + methodParam: "private.request.getChanged", + ...opts, + }); + }, + multiGet(opts = {}) { + return this._makeRequest({ + methodParam: "private.request.multiGet", + ...opts, + }); + }, + updateRequest(opts = {}) { + return this._makeRequest({ + method: "POST", + methodParam: "private.request.update", + ...opts, + }); + }, + async *paginate({ + fn, params = {}, maxResults = null, field, ...opts + }) { + let hasMore = false; + let count = 0; + let page = 0; + + do { + params.length = LIMIT; + params.start = LIMIT * page++; + const response = await fn({ + params, + ...opts, + }); + + for (const d of response[field]) { + yield await this.getRequest({ + params: { + xRequest: d.xRequest || d, + }, + }); + + if (maxResults && ++count === maxResults) { + return count; + } + } + + hasMore = response[field].length; + + } while (hasMore); }, }, }; diff --git a/components/helpspot/package.json b/components/helpspot/package.json index 5f992a1f918c3..0a8d7a9ce0e6c 100644 --- a/components/helpspot/package.json +++ b/components/helpspot/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/helpspot", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream HelpSpot Components", "main": "helpspot.app.mjs", "keywords": [ @@ -11,5 +11,9 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } + diff --git a/components/helpspot/sources/common/base.mjs b/components/helpspot/sources/common/base.mjs new file mode 100644 index 0000000000000..3b29537ebc08d --- /dev/null +++ b/components/helpspot/sources/common/base.mjs @@ -0,0 +1,55 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import helpspot from "../../helpspot.app.mjs"; + +export default { + props: { + helpspot, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastDate() { + return this.db.get("lastDate") || 1; + }, + _setLastDate(lastDate) { + this.db.set("lastDate", lastDate); + }, + _getMaxDate({ request_history: { item } }) { + const history = Object.entries(item).map(([ + , item, + ]) => item.dtGMTChange); + return Date.parse(history[history.length - 1]) / 1000; + }, + async emitEvent(maxResults = false) { + const lastDate = this._getLastDate(); + let responseArray = await this.getItems(maxResults, lastDate); + + if (responseArray.length) { + this._setLastDate(responseArray[0].lastDate); + } + + for (const item of responseArray.reverse()) { + const ts = Date.parse(new Date()); + + this.$emit(item, { + id: `${item.xRequest}-${ts}`, + summary: this.getSummary(item), + ts: ts, + }); + } + }, + }, + hooks: { + async deploy() { + await this.emitEvent(25); + }, + }, + async run() { + await this.emitEvent(); + }, +}; diff --git a/components/helpspot/sources/new-request/new-request.mjs b/components/helpspot/sources/new-request/new-request.mjs index 9b746e22816ff..0da3826c719fc 100644 --- a/components/helpspot/sources/new-request/new-request.mjs +++ b/components/helpspot/sources/new-request/new-request.mjs @@ -1,65 +1,37 @@ -import helpspot from "../../helpspot.app.mjs"; -import { axios } from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "helpspot-new-request", name: "New Request Created", - description: "Emit new event when a new request is created. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", - version: "0.0.{{ts}}", + description: "Emit new event when a new request is created.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - helpspot, - db: "$.service.db", - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: 60, - }, - }, - }, methods: { - _getLastRequestId() { - return this.db.get("lastRequestId") || null; - }, - _setLastRequestId(id) { - this.db.set("lastRequestId", id); + ...common.methods, + getSummary({ xRequest }) { + return `New Request: ${xRequest}`; }, - async emitNewRequests() { - const lastRequestId = this._getLastRequestId(); - const searchQuery = lastRequestId - ? `xRequest>${lastRequestId}` - : "Date_Created:[* TO NOW]"; + async getItems(maxResults, lastDate) { + const responseArray = []; - const newRequests = await this.helpspot.searchRequests({ - searchQuery, + const response = this.helpspot.paginate({ + fn: this.helpspot.listRequests, + field: "request", + params: { + afterDate: lastDate, + }, + maxResults, }); - for (const request of newRequests) { - this.$emit(request, { - id: request.xRequest, - summary: `New Request: ${request.xRequest}`, - ts: Date.parse(request.dtGMTOpened), - }); - } - - if (newRequests.length) { - this._setLastRequestId(newRequests[newRequests.length - 1].xRequest); + for await (const item of response) { + item.lastDate = Date.parse(item.dtGMTOpened) / 100; + responseArray.push(item); } + return responseArray; }, }, - hooks: { - async deploy() { - await this.emitNewRequests(); - }, - async activate() { - await this.emitNewRequests(); - }, - async deactivate() { - // Clean up any resources if needed - }, - }, - async run() { - await this.emitNewRequests(); - }, + sampleEmit, }; diff --git a/components/helpspot/sources/new-request/test-event.mjs b/components/helpspot/sources/new-request/test-event.mjs new file mode 100644 index 0000000000000..c41ce457b8f47 --- /dev/null +++ b/components/helpspot/sources/new-request/test-event.mjs @@ -0,0 +1,53 @@ +export default { + "xRequest": 12416, + "fOpenedVia": "Phone", + "xOpenedViaId": 0, + "xPortal": 0, + "xMailboxToSendFrom": 0, + "xPersonOpenedBy": "Username", + "xPersonAssignedTo": "Username", + "fOpen": 1, + "xStatus": "Active", + "fUrgent": 0, + "xCategory": "Other", + "dtGMTOpened": "Oct 3, 2024", + "dtGMTClosed": "", + "iLastReplyBy": "Username", + "fTrash": 0, + "dtGMTTrashed": "", + "sRequestPassword": "eiCkgBIZEBkslivbqLsk", + "sTitle": "Title test", + "sUserId": "", + "sFirstName": "First Name", + "sLastName": "", + "sEmail": "", + "sPhone": "", + "fullname": "Full Name", + "request_history": { + "item": { + "34": { + "xRequestHistory": 34, + "xRequest": 12416, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 12:02 PM", + "fPublic": 1, + "fInitial": 1, + "fNoteIsHTML": 1, + "fMergedFromRequest": 0, + "tNote": "

Note test

", + "tEmailHeaders": "", + "fPinned": 0, + "cc": "", + "bcc": "", + "to": "", + "staff_notified": [ + "" + ], + "external": 0, + "person_type": "staff", + "files": [] + } + } + }, + "lastDate": 17279136000 +} \ No newline at end of file diff --git a/components/helpspot/sources/new-search/new-search.mjs b/components/helpspot/sources/new-search/new-search.mjs deleted file mode 100644 index 9080d3c3460e6..0000000000000 --- a/components/helpspot/sources/new-search/new-search.mjs +++ /dev/null @@ -1,78 +0,0 @@ -import { axios } from "@pipedream/platform"; -import helpspot from "../../helpspot.app.mjs"; - -export default { - key: "helpspot-new-search", - name: "New Search Event", - description: "Emit new event based on a search. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", - version: "0.0.{{ts}}", - type: "source", - dedupe: "unique", - props: { - helpspot, - db: "$.service.db", - searchQuery: { - propDefinition: [ - helpspot, - "searchQuery", - ], - }, - timer: { - type: "$.interface.timer", - label: "Poll Schedule", - description: "Pipedream will poll the HelpSpot API on this schedule", - default: { - intervalSeconds: 3600, - }, - }, - }, - methods: { - _getLastSearchId() { - return this.db.get("lastSearchId") || null; - }, - _setLastSearchId(id) { - this.db.set("lastSearchId", id); - }, - }, - hooks: { - async deploy() { - const results = await this.helpspot.searchRequests({ - searchQuery: this.searchQuery, - }); - const lastResult = results[results.length - 1]; - - if (lastResult) { - this._setLastSearchId(lastResult.xRequest); - } - - for (const result of results.slice(0, 50)) { - this.$emit(result, { - id: result.xRequest, - summary: `New request: ${result.sTitle || result.sFirstName || result.sLastName || result.tNote}`, - ts: Date.parse(result.dtGMTOpened), - }); - } - }, - }, - async run() { - const lastSearchId = this._getLastSearchId(); - const results = await this.helpspot.searchRequests({ - searchQuery: this.searchQuery, - }); - - for (const result of results) { - if (!lastSearchId || result.xRequest > lastSearchId) { - this.$emit(result, { - id: result.xRequest, - summary: `New request: ${result.sTitle || result.sFirstName || result.sLastName || result.tNote}`, - ts: Date.parse(result.dtGMTOpened), - }); - } - } - - const newLastResult = results[results.length - 1]; - if (newLastResult) { - this._setLastSearchId(newLastResult.xRequest); - } - }, -}; diff --git a/components/helpspot/sources/request-update/request-update.mjs b/components/helpspot/sources/request-update/request-update.mjs index e62ed59d7d14c..154c8b39e76d6 100644 --- a/components/helpspot/sources/request-update/request-update.mjs +++ b/components/helpspot/sources/request-update/request-update.mjs @@ -1,72 +1,48 @@ -import helpspot from "../../helpspot.app.mjs"; -import { axios } from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "helpspot-request-update", - name: "Request Update", - description: "Emit new event when a request is updated. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)", + name: "New Request Updated", + description: "Emit new event when a request is updated.", version: "0.0.1", type: "source", - dedupe: "unique", - props: { - helpspot, - db: "$.service.db", - requestId: { - propDefinition: [ - helpspot, - "requestId", - ], - }, - timer: { - type: "$.interface.timer", - default: { - intervalSeconds: 60 * 15, // Poll every 15 minutes - }, - }, - }, methods: { - _getLastUpdated() { - return this.db.get("lastUpdated") ?? null; - }, - _setLastUpdated(ts) { - this.db.set("lastUpdated", ts); + ...common.methods, + getSummary({ xRequest }) { + return `New request updated: ${xRequest}`; }, - }, - hooks: { - async deploy() { - // Fetch initial data - const request = await this.helpspot.getRequest({ - requestId: this.requestId, + async getItems(maxResults, lastDate) { + const { xRequest } = await this.helpspot.listChanges({ + params: { + dtGMTChange: lastDate, + }, + }); + + if (!xRequest.length) return []; + + let { request: items } = await this.helpspot.multiGet({ + params: { + xRequest, + }, }); - if (request.request_history && request.request_history.length > 0) { - // Emit the most recent history record, if available - const latestHistory = request.request_history[0]; - this.$emit(latestHistory, { - id: latestHistory.xRequestHistory, - summary: `New update for request: ${latestHistory.xRequest}`, - ts: Date.parse(latestHistory.dtGMTChange), - }); - this._setLastUpdated(latestHistory.dtGMTChange); + + items.reverse(); + + if (maxResults && items.length > maxResults) { + items.length = maxResults; } - }, - }, - async run() { - const lastUpdated = this._getLastUpdated(); - const request = await this.helpspot.getRequest({ - requestId: this.requestId, - }); - if (request.request_history && request.request_history.length > 0) { - for (const historyItem of request.request_history) { - const historyTimestamp = Date.parse(historyItem.dtGMTChange); - if (!lastUpdated || historyTimestamp > Date.parse(lastUpdated)) { - this.$emit(historyItem, { - id: historyItem.xRequestHistory, - summary: `Update for request: ${historyItem.xRequest}`, - ts: historyTimestamp, - }); - this._setLastUpdated(historyItem.dtGMTChange); - } + + const responseArray = []; + + for (const item of items) { + item.lastDate = this._getMaxDate(item); + responseArray.push(item); } - } + + return responseArray; + }, }, + sampleEmit, }; diff --git a/components/helpspot/sources/request-update/test-event.mjs b/components/helpspot/sources/request-update/test-event.mjs new file mode 100644 index 0000000000000..d366e94fdef11 --- /dev/null +++ b/components/helpspot/sources/request-update/test-event.mjs @@ -0,0 +1,172 @@ +export default { + "xRequest": 12410, + "fOpenedVia": "Web Service", + "xOpenedViaId": 0, + "xPortal": 0, + "xMailboxToSendFrom": 1, + "xPersonOpenedBy": "Username", + "xPersonAssignedTo": "", + "fOpen": 1, + "xStatus": "Escalated", + "fUrgent": 1, + "xCategory": "Server", + "dtGMTOpened": "Oct 3, 2024", + "dtGMTClosed": "", + "iLastReplyBy": "Username", + "fTrash": 0, + "dtGMTTrashed": "", + "sRequestPassword": "QrdtUSeDqXzYpfnBULov", + "sTitle": "Re: subject test", + "sUserId": "", + "sFirstName": "First Name", + "sLastName": "Last name", + "sEmail": "user@email.com", + "sPhone": "11111111111", + "fullname": "Full Name", + "request_history": { + "item": { + "24": { + "xRequestHistory": 24, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 10:01 AM", + "fPublic": 0, + "fInitial": 1, + "fNoteIsHTML": 1, + "fMergedFromRequest": 0, + "tLog": "", + "tNote": "

note test

", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "25": { + "xRequestHistory": 25, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 10:08 AM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 1, + "fMergedFromRequest": 0, + "tLog": "", + "tNote": "

note 06

", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "26": { + "xRequestHistory": 26, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 10:08 AM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 0, + "fMergedFromRequest": 0, + "tLog": "Request Changed:", + "tNote": "note test", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "27": { + "xRequestHistory": 27, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 10:10 AM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 0, + "fMergedFromRequest": 0, + "tLog": "", + "tNote": "note test", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "28": { + "xRequestHistory": 28, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 10:10 AM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 0, + "fMergedFromRequest": 0, + "tLog": "Request Changed:", + "tNote": "", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "40": { + "xRequestHistory": 40, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 04:43 PM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 0, + "fMergedFromRequest": 0, + "tLog": "Request Changed:", + "tNote": "", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + }, + "48": { + "xRequestHistory": 48, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 04:45 PM", + "fPublic": 1, + "fInitial": 0, + "fNoteIsHTML": 1, + "fMergedFromRequest": 0, + "tNote": "

note test

", + "tEmailHeaders": "", + "fPinned": 0, + "cc": "test@email.com", + "bcc": "test@bcc.com", + "to": "", + "staff_notified": [ + "" + ], + "external": 0, + "person_type": "staff", + "files": [] + }, + "49": { + "xRequestHistory": 49, + "xRequest": 12410, + "xPerson": "Username", + "dtGMTChange": "Oct 3 2024, 04:45 PM", + "fPublic": 0, + "fInitial": 0, + "fNoteIsHTML": 0, + "fMergedFromRequest": 0, + "tLog": "Request Changed:", + "tNote": "", + "tEmailHeaders": "", + "fPinned": 0, + "external": 0, + "person_type": "staff", + "files": [] + } + } + }, + "lastDate": 1727973900 +} \ No newline at end of file From 1fe704fea242d9a52c8c6a623924e3aaa1febede Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 3 Oct 2024 17:54:12 -0300 Subject: [PATCH 3/5] pnpm update --- pnpm-lock.yaml | 107 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7aba44d1406f2..66e8d75f3dce3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4412,7 +4412,10 @@ importers: '@pipedream/platform': 1.6.0 components/helpspot: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/helpwise: specifiers: {} @@ -12853,55 +12856,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: - resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sts': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sts' - - aws-crt - dev: false - /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13137,7 +13091,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 + '@aws-sdk/client-sso-oidc': 3.600.0 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13179,6 +13133,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: + resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + dev: false + /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17505,7 +17508,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 From 674529da18db853a0ef5dd496ebb9af9ff866341 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 7 Oct 2024 10:50:30 -0300 Subject: [PATCH 4/5] some adjusts --- components/helpspot/sources/common/base.mjs | 2 +- components/helpspot/sources/request-update/request-update.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/helpspot/sources/common/base.mjs b/components/helpspot/sources/common/base.mjs index 3b29537ebc08d..de53604c54645 100644 --- a/components/helpspot/sources/common/base.mjs +++ b/components/helpspot/sources/common/base.mjs @@ -34,7 +34,7 @@ export default { } for (const item of responseArray.reverse()) { - const ts = Date.parse(new Date()); + const ts = item.lastDate; this.$emit(item, { id: `${item.xRequest}-${ts}`, diff --git a/components/helpspot/sources/request-update/request-update.mjs b/components/helpspot/sources/request-update/request-update.mjs index 154c8b39e76d6..d616290cf0c66 100644 --- a/components/helpspot/sources/request-update/request-update.mjs +++ b/components/helpspot/sources/request-update/request-update.mjs @@ -8,6 +8,7 @@ export default { description: "Emit new event when a request is updated.", version: "0.0.1", type: "source", + dedupe: "unique", methods: { ...common.methods, getSummary({ xRequest }) { From c6f56d4fea70f602d7edb1aee98256beb8cb56ef Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Wed, 9 Oct 2024 13:40:12 +0700 Subject: [PATCH 5/5] Update components/helpspot/sources/new-request/new-request.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- components/helpspot/sources/new-request/new-request.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/helpspot/sources/new-request/new-request.mjs b/components/helpspot/sources/new-request/new-request.mjs index 0da3826c719fc..14d6f68cb6714 100644 --- a/components/helpspot/sources/new-request/new-request.mjs +++ b/components/helpspot/sources/new-request/new-request.mjs @@ -27,7 +27,7 @@ export default { }); for await (const item of response) { - item.lastDate = Date.parse(item.dtGMTOpened) / 100; + item.lastDate = Date.parse(item.dtGMTOpened) / 1000; responseArray.push(item); } return responseArray;