diff --git a/components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs b/components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs index b6a7f53f09d22..f2fe8ce589359 100644 --- a/components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs +++ b/components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs @@ -5,7 +5,7 @@ export default { key: "microsoft_outlook-add-label-to-email", name: "Add Label to Email", description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, diff --git a/components/microsoft_outlook/actions/create-contact/create-contact.mjs b/components/microsoft_outlook/actions/create-contact/create-contact.mjs index f48497b73c67f..eee6d78089425 100644 --- a/components/microsoft_outlook/actions/create-contact/create-contact.mjs +++ b/components/microsoft_outlook/actions/create-contact/create-contact.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-create-contact", - version: "0.0.9", + version: "0.0.10", name: "Create Contact", description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)", props: { diff --git a/components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs b/components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs index 39cbb4b432896..d01b0283ede10 100644 --- a/components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs +++ b/components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-create-draft-email", - version: "0.0.9", + version: "0.0.10", name: "Create Draft Email", description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)", props: { diff --git a/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs b/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs index a3c95a1921ca2..63b8aa83f8428 100644 --- a/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs +++ b/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-find-contacts", - version: "0.0.9", + version: "0.0.10", name: "Find Contacts", description: "Finds contacts with given search string", props: { diff --git a/components/microsoft_outlook/actions/find-email/find-email.mjs b/components/microsoft_outlook/actions/find-email/find-email.mjs new file mode 100644 index 0000000000000..50d9b821ea507 --- /dev/null +++ b/components/microsoft_outlook/actions/find-email/find-email.mjs @@ -0,0 +1,37 @@ +import microsoftOutlook from "../../microsoft_outlook.app.mjs"; + +export default { + key: "microsoft_outlook-find-email", + name: "Find Email", + description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)", + version: "0.0.1", + type: "action", + props: { + microsoftOutlook, + filter: { + type: "string", + label: "Filter", + description: "Filters results. For example, `contains(subject, 'meet for lunch?')` will include messages whose subject contains ‘meet for lunch?’. [See documentation](https://learn.microsoft.com/en-us/graph/filter-query-parameter) for the full list of operations.", + optional: true, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + optional: true, + }, + }, + async run({ $ }) { + const { value } = await this.microsoftOutlook.listMessages({ + $, + params: { + "$filter": this.filter, + "$top": this.maxResults, + }, + }); + $.export("$summary", `Successfully retrieved ${value.length} message${value.length != 1 + ? "s" + : ""}.`); + return value; + }, +}; diff --git a/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs b/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs index 05fedbf0a169b..415d6387a04ef 100644 --- a/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs +++ b/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-list-contacts", - version: "0.0.9", + version: "0.0.10", name: "List Contacts", description: "Get a contact collection from the default contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)", props: { diff --git a/components/microsoft_outlook/actions/list-folders/list-folders.mjs b/components/microsoft_outlook/actions/list-folders/list-folders.mjs new file mode 100644 index 0000000000000..73de1ea228345 --- /dev/null +++ b/components/microsoft_outlook/actions/list-folders/list-folders.mjs @@ -0,0 +1,21 @@ +import microsoftOutlook from "../../microsoft_outlook.app.mjs"; + +export default { + key: "microsoft_outlook-list-folders", + name: "List Folders", + description: "Retrieves a list of all folders in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders)", + version: "0.0.1", + type: "action", + props: { + microsoftOutlook, + }, + async run({ $ }) { + const { value } = await this.microsoftOutlook.listFolders({ + $, + }); + $.export("$summary", `Successfully retrieved ${value.length} folder${value.length != 1 + ? "s" + : ""}.`); + return value; + }, +}; diff --git a/components/microsoft_outlook/actions/list-labels/list-labels.mjs b/components/microsoft_outlook/actions/list-labels/list-labels.mjs index 3fe9aaca57a55..c201c5c2d2571 100644 --- a/components/microsoft_outlook/actions/list-labels/list-labels.mjs +++ b/components/microsoft_outlook/actions/list-labels/list-labels.mjs @@ -4,7 +4,7 @@ export default { key: "microsoft_outlook-list-labels", name: "List Labels", description: "Get all the labels/categories that have been defined for a user. [See the documentation](https://learn.microsoft.com/en-us/graph/api/outlookuser-list-mastercategories)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, diff --git a/components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs b/components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs new file mode 100644 index 0000000000000..b0e036542ec2a --- /dev/null +++ b/components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs @@ -0,0 +1,38 @@ +import microsoftOutlook from "../../microsoft_outlook.app.mjs"; + +export default { + key: "microsoft_outlook-move-email-to-folder", + name: "Move Email to Folder", + description: "Moves an email to the specified folder in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-move)", + version: "0.0.1", + type: "action", + props: { + microsoftOutlook, + messageId: { + propDefinition: [ + microsoftOutlook, + "messageId", + ], + }, + folderId: { + propDefinition: [ + microsoftOutlook, + "folderIds", + ], + type: "string", + label: "Folder ID", + description: "The identifier of the folder to move the selected message to", + }, + }, + async run({ $ }) { + const response = await this.microsoftOutlook.moveMessage({ + $, + messageId: this.messageId, + data: { + destinationId: this.folderId, + }, + }); + $.export("$summary", `Successfully moved email to folder with ID: ${this.folderId}`); + return response; + }, +}; diff --git a/components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs b/components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs index c14897e78a5f7..4a4c00dd64965 100644 --- a/components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs +++ b/components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs @@ -4,7 +4,7 @@ export default { key: "microsoft_outlook-remove-label-from-email", name: "Remove Label from Email", description: "Removes a label/category from an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, diff --git a/components/microsoft_outlook/actions/send-email/send-email.mjs b/components/microsoft_outlook/actions/send-email/send-email.mjs index a115d700b24bc..db0d421e58ab5 100644 --- a/components/microsoft_outlook/actions/send-email/send-email.mjs +++ b/components/microsoft_outlook/actions/send-email/send-email.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-send-email", - version: "0.0.10", + version: "0.0.11", name: "Send Email", description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)", props: { diff --git a/components/microsoft_outlook/actions/update-contact/update-contact.mjs b/components/microsoft_outlook/actions/update-contact/update-contact.mjs index d794448b3c51b..3e33b9cfbc94e 100644 --- a/components/microsoft_outlook/actions/update-contact/update-contact.mjs +++ b/components/microsoft_outlook/actions/update-contact/update-contact.mjs @@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-update-contact", - version: "0.0.9", + version: "0.0.10", name: "Update Contact", description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)", props: { diff --git a/components/microsoft_outlook/microsoft_outlook.app.mjs b/components/microsoft_outlook/microsoft_outlook.app.mjs index 1edd230f1e5cb..0542d02b3a5f0 100644 --- a/components/microsoft_outlook/microsoft_outlook.app.mjs +++ b/components/microsoft_outlook/microsoft_outlook.app.mjs @@ -143,6 +143,20 @@ export default { })) || []; }, }, + folderIds: { + type: "string[]", + label: "Folder IDs to Monitor", + description: "Specify the folder IDs or names in Outlook that you want to monitor for new emails. Leave empty to monitor all folders (excluding \"Sent Items\" and \"Drafts\").", + async options() { + const { value: folders } = await this.listFolders(); + return folders?.map(({ + id: value, displayName: label, + }) => ({ + value, + label, + })) || []; + }, + }, }, methods: { _getUrl(path) { @@ -335,6 +349,21 @@ export default { ...args, }); }, + listFolders(args = {}) { + return this._makeRequest({ + path: "/me/mailFolders", + ...args, + }); + }, + moveMessage({ + messageId, ...args + }) { + return this._makeRequest({ + method: "POST", + path: `/me/messages/${messageId}/move`, + ...args, + }); + }, updateMessage({ messageId, ...args }) { diff --git a/components/microsoft_outlook/package.json b/components/microsoft_outlook/package.json index 3db6ebf4d86c3..582c9520cea8f 100644 --- a/components/microsoft_outlook/package.json +++ b/components/microsoft_outlook/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/microsoft_outlook", - "version": "1.1.1", + "version": "1.2.0", "description": "Pipedream Microsoft Outlook Components", "main": "microsoft_outlook.app.mjs", "keywords": [ diff --git a/components/microsoft_outlook/sources/new-contact/new-contact.mjs b/components/microsoft_outlook/sources/new-contact/new-contact.mjs index 83a0490883875..d1fe6815e160b 100644 --- a/components/microsoft_outlook/sources/new-contact/new-contact.mjs +++ b/components/microsoft_outlook/sources/new-contact/new-contact.mjs @@ -5,7 +5,7 @@ export default { key: "microsoft_outlook-new-contact", name: "New Contact Event (Instant)", description: "Emit new event when a new Contact is created", - version: "0.0.10", + version: "0.0.11", type: "source", hooks: { ...common.hooks, diff --git a/components/microsoft_outlook/sources/new-email/new-email.mjs b/components/microsoft_outlook/sources/new-email/new-email.mjs index 476f8b0af1c84..b5eca7cc7064f 100644 --- a/components/microsoft_outlook/sources/new-email/new-email.mjs +++ b/components/microsoft_outlook/sources/new-email/new-email.mjs @@ -7,25 +7,17 @@ export default { key: "microsoft_outlook-new-email", name: "New Email Event (Instant)", description: "Emit new event when an email is received in specified folders.", - version: "0.0.13", + version: "0.0.14", type: "source", dedupe: "unique", props: { ...common.props, folderIds: { - type: "string[]", - label: "Folder IDs to Monitor", - description: "Specify the folder IDs or names in Outlook that you want to monitor for new emails. Leave empty to monitor all folders (excluding \"Sent Items\" and \"Drafts\").", + propDefinition: [ + common.props.microsoftOutlook, + "folderIds", + ], optional: true, - async options() { - const { value: folders } = await this.listFolders(); - return folders?.map(({ - id: value, displayName: label, - }) => ({ - value, - label, - })) || []; - }, }, }, hooks: { @@ -56,13 +48,8 @@ export default { }, methods: { ...common.methods, - listFolders() { - return this.microsoftOutlook._makeRequest({ - path: "/me/mailFolders", - }); - }, async getFolderIdByName(name) { - const { value: folders } = await this.listFolders(); + const { value: folders } = await this.microsoftOutlook.listFolders(); const folder = folders.find(({ displayName }) => displayName === name); return folder?.id; }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 74e2588af2eb8..4b569e3cc0e53 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32201,6 +32201,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: