diff --git a/components/calendarhero/.gitignore b/components/calendarhero/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/calendarhero/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/calendarhero/actions/list-meeting-types/list-meeting-types.mjs b/components/calendarhero/actions/list-meeting-types/list-meeting-types.mjs new file mode 100644 index 0000000000000..d6e6b2c643ad5 --- /dev/null +++ b/components/calendarhero/actions/list-meeting-types/list-meeting-types.mjs @@ -0,0 +1,22 @@ +import app from "../../calendarhero.app.mjs"; + +export default { + key: "calendarhero-list-meeting-types", + name: "List Meeting Types", + description: "Get the user's meeting types. [See the documentation](https://api.calendarhero.com/documentation#/user/getUserMeeting).", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.listMeetingTypes({ + $, + }); + const { length } = Object.keys(response ?? {}); + $.export("$summary", `Successfully listed ${length} meeting type${length === 1 + ? "" + : "s"}`); + return response; + }, +}; diff --git a/components/calendarhero/actions/list-meetings/list-meetings.mjs b/components/calendarhero/actions/list-meetings/list-meetings.mjs new file mode 100644 index 0000000000000..345faee5a1ccd --- /dev/null +++ b/components/calendarhero/actions/list-meetings/list-meetings.mjs @@ -0,0 +1,36 @@ +import app from "../../calendarhero.app.mjs"; + +export default { + key: "calendarhero-list-meetings", + name: "List Meetings", + description: "Get the user's meetings within a timeframe. [See the documentation](https://api.calendarhero.com/documentation#/meeting/getMeeting).", + version: "0.0.1", + type: "action", + props: { + app, + start: { + type: "string", + label: "Start Date/Time", + description: "Initial date/time of the period to list events, in ISO 8601 format, e.g. `2025-03-10T09:00:00Z`", + }, + end: { + type: "string", + label: "End Date/Time", + description: "End date/time of the period to list events, in ISO 8601 format, e.g. `2025-03-14T18:00:00Z`", + }, + }, + async run({ $ }) { + const { + app, ...params + } = this; + const response = await app.listMeetings({ + $, + params, + }); + const { length } = response; + $.export("$summary", `Successfully listed ${length} meeting${length === 1 + ? "" + : "s"}`); + return response; + }, +}; diff --git a/components/calendarhero/app/calendarhero.app.ts b/components/calendarhero/app/calendarhero.app.ts deleted file mode 100644 index cb8324d949b42..0000000000000 --- a/components/calendarhero/app/calendarhero.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "calendarhero", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); diff --git a/components/calendarhero/calendarhero.app.mjs b/components/calendarhero/calendarhero.app.mjs new file mode 100644 index 0000000000000..7da9fd166443a --- /dev/null +++ b/components/calendarhero/calendarhero.app.mjs @@ -0,0 +1,51 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "calendarhero", + propDefinitions: {}, + methods: { + async _makeRequest({ + $ = this, headers, ...args + } = {}) { + return axios($, { + baseURL: "https://api.calendarhero.com", + headers: { + ...headers, + Authorization: `${this.$auth.api_key}`, + }, + ...args, + }); + }, + listMeetings(args) { + return this._makeRequest({ + url: "/meeting", + ...args, + }); + }, + listMeetingTypes(args) { + return this._makeRequest({ + url: "/user/meeting", + ...args, + }); + }, + createWebhook({ + event, ...args + }) { + return this._makeRequest({ + method: "post", + url: `webhook/${event}`, + ...args, + }); + }, + deleteWebhook({ + event, ...args + }) { + return this._makeRequest({ + method: "delete", + url: `webhook/${event}`, + ...args, + }); + }, + }, +}; diff --git a/components/calendarhero/common/constants.mjs b/components/calendarhero/common/constants.mjs new file mode 100644 index 0000000000000..0e1cfb5aaa550 --- /dev/null +++ b/components/calendarhero/common/constants.mjs @@ -0,0 +1,34 @@ +export const WEBHOOK_EVENT_TYPE_OPTIONS = [ + { + label: "New Meeting Request", + value: "new_meeting_request", + }, + { + label: "Meeting Request Succeeded", + value: "meeting_request_success", + }, + { + label: "Meeting Request Expired", + value: "meeting_request_expired", + }, + { + label: "Meeting Request Cancelled", + value: "meeting_request_cancelled", + }, + { + label: "Meeting Rescheduled", + value: "meeting_rescheduled", + }, + { + label: "Meeting Started", + value: "meeting_started", + }, + { + label: "Meeting Completed", + value: "meeting_completed", + }, + { + label: "New Contact Added", + value: "new_contact_added", + }, +]; diff --git a/components/calendarhero/package.json b/components/calendarhero/package.json index 095518b53d39b..4cfb5bc9fb1d2 100644 --- a/components/calendarhero/package.json +++ b/components/calendarhero/package.json @@ -1,18 +1,18 @@ { "name": "@pipedream/calendarhero", - "version": "0.0.3", + "version": "0.1.0", "description": "Pipedream CalendarHero Components", - "main": "dist/app/calendarhero.app.mjs", + "main": "calendarhero.app.mjs", "keywords": [ "pipedream", "calendarhero" ], - "files": [ - "dist" - ], "homepage": "https://pipedream.com/apps/calendarhero", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/calendarhero/sources/new-event-instant/new-event-instant.mjs b/components/calendarhero/sources/new-event-instant/new-event-instant.mjs new file mode 100644 index 0000000000000..6ef157603c442 --- /dev/null +++ b/components/calendarhero/sources/new-event-instant/new-event-instant.mjs @@ -0,0 +1,61 @@ +import app from "../../calendarhero.app.mjs"; +import { WEBHOOK_EVENT_TYPE_OPTIONS } from "../../common/constants.mjs"; + +export default { + key: "calendarhero-new-event-instant", + name: "New Event (Instant)", + description: + "Emit new event when a selected type of CalendarHero event occurs. [See the documentation](https://api.calendarhero.com/documentation#/webhook/postWebhookEvent)", + type: "source", + version: "0.0.1", + dedupe: "unique", + props: { + app, + http: "$.interface.http", + event: { + type: "string", + label: "Event Type", + description: "Select the type of event that will trigger this source", + options: WEBHOOK_EVENT_TYPE_OPTIONS, + }, + }, + hooks: { + async activate() { + const { + app, + event, + http: { endpoint: hookUrl }, + } = this; + await app.createWebhook({ + event, + data: { + hookUrl, + }, + }); + }, + async deactivate() { + const { + app, + event, + http: { endpoint: hookUrl }, + } = this; + await app.deleteWebhook({ + event, + data: { + hookUrl, + }, + }); + }, + }, + async run({ body }) { + const ts = Date.now(); + const id = body.id ?? ts; + this.$emit(body, { + id, + summary: `New event${id + ? ` (ID ${id})` + : ""}`, + ts, + }); + }, +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f247fe651b2bf..a37cad3ea33e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1930,7 +1930,11 @@ importers: specifier: ^1.3.3 version: 1.3.3 - components/calendarhero: {} + components/calendarhero: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/calendly_v2: dependencies: @@ -8563,8 +8567,7 @@ importers: components/nusii_proposals: {} - components/nutrient_document_web_services_api: - specifiers: {} + components/nutrient_document_web_services_api: {} components/nutshell: dependencies: @@ -10777,8 +10780,7 @@ importers: components/runpod: {} - components/runsignup: - specifiers: {} + components/runsignup: {} components/runware: dependencies: @@ -13653,8 +13655,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/wafrow: - specifiers: {} + components/wafrow: {} components/waitless: {} @@ -34204,6 +34205,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: