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 3a9af81066342..23d0df5a27034 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.4", + version: "0.0.5", type: "action", props: { microsoftOutlook, diff --git a/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs b/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs index 4c72815021825..a4a04c320b2c4 100644 --- a/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs +++ b/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs @@ -4,7 +4,7 @@ export default { key: "microsoft_outlook-approve-workflow", name: "Approve Workflow", description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)", - 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 d2c48e56ee64f..c76b7c9841721 100644 --- a/components/microsoft_outlook/actions/create-contact/create-contact.mjs +++ b/components/microsoft_outlook/actions/create-contact/create-contact.mjs @@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-create-contact", - version: "0.0.11", + version: "0.0.12", 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)", + description: "Add a contact to the root Contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)", props: { microsoftOutlook, givenName: { 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 bdd2a959de37c..00f81f8961387 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,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-create-draft-email", - version: "0.0.11", + version: "0.0.12", name: "Create Draft Email", - description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)", + description: "Create a draft email, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-messages)", props: { microsoftOutlook, recipients: { diff --git a/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs b/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs index c1f4c263c9f28..aefcad73d8da1 100644 --- a/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs +++ b/components/microsoft_outlook/actions/find-contacts/find-contacts.mjs @@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-find-contacts", - version: "0.0.11", + version: "0.0.12", name: "Find Contacts", - description: "Finds contacts with given search string", + description: "Finds contacts with the given search string. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)", props: { microsoftOutlook, searchString: { @@ -13,21 +13,40 @@ export default { description: "Provide email address, given name, surname or display name (case sensitive)", type: "string", }, + maxResults: { + propDefinition: [ + microsoftOutlook, + "maxResults", + ], + }, }, async run({ $ }) { - const contactList = await this.microsoftOutlook.listContacts({ - $, - }); - const relatedContacts = contactList.value.filter((c) => { - return c.displayName.includes(this.searchString) || - c.givenName.includes(this.searchString) || - c.surname.includes(this.searchString) || - c.emailAddresses.find((e) => - e.address == this.searchString || - e.name.includes(this.searchString)); + const contacts = this.microsoftOutlook.paginate({ + fn: this.microsoftOutlook.listContacts, + args: { + $, + }, }); + + const relatedContacts = []; + for await (const contact of contacts) { + if ( + contact?.displayName?.includes(this.searchString) || + contact?.givenName?.includes(this.searchString) || + contact?.surname?.includes(this.searchString) || + contact?.emailAddresses?.find( + (e) => e?.address == this.searchString || e?.name?.includes(this.searchString), + ) + ) { + relatedContacts.push(contact); + if (this.maxResults && relatedContacts.length >= this.maxResults) { + break; + } + } + } + // eslint-disable-next-line multiline-ternary - $.export("$summary", `${relatedContacts.length} contact${relatedContacts.length != 1 ? "s" : ""} has been filtered.`); + $.export("$summary", `${relatedContacts.length} matching contact${relatedContacts.length != 1 ? "s" : ""} found`); return relatedContacts; }, }; diff --git a/components/microsoft_outlook/actions/find-email/find-email.mjs b/components/microsoft_outlook/actions/find-email/find-email.mjs index b467534ae8408..72fb7cbba9d6b 100644 --- a/components/microsoft_outlook/actions/find-email/find-email.mjs +++ b/components/microsoft_outlook/actions/find-email/find-email.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, @@ -15,23 +15,32 @@ export default { optional: true, }, maxResults: { - type: "integer", - label: "Max Results", - description: "The maximum number of results to return", - optional: true, + propDefinition: [ + microsoftOutlook, + "maxResults", + ], }, }, async run({ $ }) { - const { value } = await this.microsoftOutlook.listMessages({ - $, - params: { - "$filter": this.filter, - "$top": this.maxResults, + const items = this.microsoftOutlook.paginate({ + fn: this.microsoftOutlook.listMessages, + args: { + $, + params: { + "$filter": this.filter, + }, }, + max: this.maxResults, }); - $.export("$summary", `Successfully retrieved ${value.length} message${value.length != 1 + + const emails = []; + for await (const item of items) { + emails.push(item); + } + + $.export("$summary", `Successfully retrieved ${emails.length} message${emails.length != 1 ? "s" : ""}.`); - return value; + return emails; }, }; diff --git a/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs b/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs index 9b8ef94065dd8..022e1ff6ff601 100644 --- a/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs +++ b/components/microsoft_outlook/actions/list-contacts/list-contacts.mjs @@ -3,25 +3,41 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs"; export default { type: "action", key: "microsoft_outlook-list-contacts", - version: "0.0.11", + version: "0.0.12", 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)", + description: "Get a contact collection from the default contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)", props: { microsoftOutlook, filterAddress: { - label: "Email adress", + label: "Email Address", description: "If this is given, only contacts with the given address will be retrieved.", type: "string", optional: true, }, + maxResults: { + propDefinition: [ + microsoftOutlook, + "maxResults", + ], + }, }, async run({ $ }) { - const response = await this.microsoftOutlook.listContacts({ - $, - filterAddress: this.filterAddress, + const items = this.microsoftOutlook.paginate({ + fn: this.microsoftOutlook.listContacts, + args: { + $, + filterAddress: this.filterAddress, + }, + max: this.maxResults, }); + + const contacts = []; + for await (const item of items) { + contacts.push(item); + } + // eslint-disable-next-line multiline-ternary - $.export("$summary", `${response.value.length} contact${response.value.length != 1 ? "s" : ""} has been retrieved.`); - return response.value; + $.export("$summary", `${contacts.length} contact${contacts.length != 1 ? "s" : ""} retrieved.`); + return contacts; }, }; diff --git a/components/microsoft_outlook/actions/list-folders/list-folders.mjs b/components/microsoft_outlook/actions/list-folders/list-folders.mjs index 8985c862ecb1b..7d13a27985183 100644 --- a/components/microsoft_outlook/actions/list-folders/list-folders.mjs +++ b/components/microsoft_outlook/actions/list-folders/list-folders.mjs @@ -4,18 +4,34 @@ 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.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, + maxResults: { + propDefinition: [ + microsoftOutlook, + "maxResults", + ], + }, }, async run({ $ }) { - const { value } = await this.microsoftOutlook.listFolders({ - $, + const items = this.microsoftOutlook.paginate({ + fn: this.microsoftOutlook.listFolders, + args: { + $, + }, + max: this.maxResults, }); - $.export("$summary", `Successfully retrieved ${value.length} folder${value.length != 1 + + const folders = []; + for await (const item of items) { + folders.push(item); + } + + $.export("$summary", `Successfully retrieved ${folders.length} folder${folders.length != 1 ? "s" : ""}.`); - return value; + return folders; }, }; diff --git a/components/microsoft_outlook/actions/list-labels/list-labels.mjs b/components/microsoft_outlook/actions/list-labels/list-labels.mjs index 58e5106665756..eeae28070eb10 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.4", + version: "0.0.5", 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 index 893f6ff270340..7a6e551df79ce 100644 --- 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 @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", type: "action", props: { microsoftOutlook, 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 cf60aae5f57d4..79c9840a6c857 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.4", + version: "0.0.5", type: "action", props: { microsoftOutlook, diff --git a/components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs b/components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs index 1427326ad7c3d..60575e033553a 100644 --- a/components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs +++ b/components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs @@ -4,7 +4,7 @@ export default { key: "microsoft_outlook-reply-to-email", name: "Reply to Email", description: "Reply to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-reply)", - version: "0.0.1", + version: "0.0.2", 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 2d29ea135ff52..c0c776e009903 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.12", + version: "0.0.13", 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 c1ec99c8fe460..cb389b05e7ed1 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.11", + version: "0.0.12", 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 408c69c7602b7..c648457cb9cce 100644 --- a/components/microsoft_outlook/microsoft_outlook.app.mjs +++ b/components/microsoft_outlook/microsoft_outlook.app.mjs @@ -3,6 +3,7 @@ import fs from "fs"; import path from "path"; import { encode } from "js-base64"; import mime from "mime-types"; +const DEFAULT_LIMIT = 50; export default { type: "app", @@ -62,8 +63,14 @@ export default { label: "Contact", description: "The contact to be updated", type: "string", - async options() { - const contactResponse = await this.listContacts(); + async options({ page }) { + const limit = DEFAULT_LIMIT; + const contactResponse = await this.listContacts({ + params: { + $top: limit, + $skip: limit * page, + }, + }); return contactResponse.value.map((co) => ({ label: co.displayName, value: co.id, @@ -127,7 +134,7 @@ export default { label: "Message ID", description: "The identifier of the message to update", async options({ page }) { - const limit = 50; + const limit = DEFAULT_LIMIT; const { value } = await this.listMessages({ params: { $top: limit, @@ -147,8 +154,14 @@ export default { 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(); + async options({ page }) { + const limit = DEFAULT_LIMIT; + const { value: folders } = await this.listFolders({ + params: { + $top: limit, + $skip: limit * page, + }, + }); return folders?.map(({ id: value, displayName: label, }) => ({ @@ -157,6 +170,13 @@ export default { })) || []; }, }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + default: 100, + optional: true, + }, }, methods: { _getUrl(path) { @@ -304,16 +324,15 @@ export default { filterAddress, ...args } = {}) { - const paramsContainer = {}; + args.params = { + ...args?.params, + }; if (filterAddress) { - paramsContainer.params = { - "$filter": `emailAddresses/any(a:a/address eq '${filterAddress}')`, - }; + args.params["$filter"] = `emailAddresses/any(a:a/address eq '${filterAddress}')`; } return await this._makeRequest({ method: "GET", path: "/me/contacts", - ...paramsContainer, ...args, }); }, @@ -384,5 +403,30 @@ export default { ...args, }); }, + async *paginate({ + fn, args = {}, max, + }) { + const limit = DEFAULT_LIMIT; + args = { + ...args, + params: { + ...args?.params, + $top: limit, + $skip: 0, + }, + }; + let total, count = 0; + do { + const { value } = await fn(args); + for (const item of value) { + yield item; + if (max && ++count >= max) { + return; + } + } + total = value?.length; + args.params["$skip"] += limit; + } while (total); + }, }, }; diff --git a/components/microsoft_outlook/package.json b/components/microsoft_outlook/package.json index 9a396a3de3fd8..df31991cbb3f1 100644 --- a/components/microsoft_outlook/package.json +++ b/components/microsoft_outlook/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/microsoft_outlook", - "version": "1.4.0", + "version": "1.4.1", "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 dd6fb5eff9ee7..080c130eae44e 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.12", + version: "0.0.13", 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 acf6f348e7b5a..0b1eac16900ef 100644 --- a/components/microsoft_outlook/sources/new-email/new-email.mjs +++ b/components/microsoft_outlook/sources/new-email/new-email.mjs @@ -7,7 +7,7 @@ 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.15", + version: "0.0.16", type: "source", dedupe: "unique", props: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 88c0fcbfb9798..7dede75861dfa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4308,8 +4308,7 @@ importers: components/facebook_conversions: {} - components/facebook_graph_api: - specifiers: {} + components/facebook_graph_api: {} components/facebook_groups: dependencies: @@ -4929,8 +4928,7 @@ importers: components/gatekeeper: {} - components/gather: - specifiers: {} + components/gather: {} components/gatherup: dependencies: