Skip to content

Commit cd04a13

Browse files
authored
Microsoft Outlook - add pagination to props and actions (#16255)
* pagination * versions * pnpm-lock.yaml * remove console.log * update
1 parent 30f6165 commit cd04a13

File tree

18 files changed

+167
-63
lines changed

18 files changed

+167
-63
lines changed

components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "microsoft_outlook-add-label-to-email",
66
name: "Add Label to Email",
77
description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
8-
version: "0.0.4",
8+
version: "0.0.5",
99
type: "action",
1010
props: {
1111
microsoftOutlook,

components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-approve-workflow",
55
name: "Approve Workflow",
66
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/create-contact/create-contact.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-contact",
6-
version: "0.0.11",
6+
version: "0.0.12",
77
name: "Create Contact",
8-
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
8+
description: "Add a contact to the root Contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {
1010
microsoftOutlook,
1111
givenName: {

components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-draft-email",
6-
version: "0.0.11",
6+
version: "0.0.12",
77
name: "Create Draft Email",
8-
description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
8+
description: "Create a draft email, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
99
props: {
1010
microsoftOutlook,
1111
recipients: {

components/microsoft_outlook/actions/find-contacts/find-contacts.mjs

+32-13
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,50 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-find-contacts",
6-
version: "0.0.11",
6+
version: "0.0.12",
77
name: "Find Contacts",
8-
description: "Finds contacts with given search string",
8+
description: "Finds contacts with the given search string. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
99
props: {
1010
microsoftOutlook,
1111
searchString: {
1212
label: "Search string",
1313
description: "Provide email address, given name, surname or display name (case sensitive)",
1414
type: "string",
1515
},
16+
maxResults: {
17+
propDefinition: [
18+
microsoftOutlook,
19+
"maxResults",
20+
],
21+
},
1622
},
1723
async run({ $ }) {
18-
const contactList = await this.microsoftOutlook.listContacts({
19-
$,
20-
});
21-
const relatedContacts = contactList.value.filter((c) => {
22-
return c.displayName.includes(this.searchString) ||
23-
c.givenName.includes(this.searchString) ||
24-
c.surname.includes(this.searchString) ||
25-
c.emailAddresses.find((e) =>
26-
e.address == this.searchString ||
27-
e.name.includes(this.searchString));
24+
const contacts = this.microsoftOutlook.paginate({
25+
fn: this.microsoftOutlook.listContacts,
26+
args: {
27+
$,
28+
},
2829
});
30+
31+
const relatedContacts = [];
32+
for await (const contact of contacts) {
33+
if (
34+
contact?.displayName?.includes(this.searchString) ||
35+
contact?.givenName?.includes(this.searchString) ||
36+
contact?.surname?.includes(this.searchString) ||
37+
contact?.emailAddresses?.find(
38+
(e) => e?.address == this.searchString || e?.name?.includes(this.searchString),
39+
)
40+
) {
41+
relatedContacts.push(contact);
42+
if (this.maxResults && relatedContacts.length >= this.maxResults) {
43+
break;
44+
}
45+
}
46+
}
47+
2948
// eslint-disable-next-line multiline-ternary
30-
$.export("$summary", `${relatedContacts.length} contact${relatedContacts.length != 1 ? "s" : ""} has been filtered.`);
49+
$.export("$summary", `${relatedContacts.length} matching contact${relatedContacts.length != 1 ? "s" : ""} found`);
3150
return relatedContacts;
3251
},
3352
};

components/microsoft_outlook/actions/find-email/find-email.mjs

+21-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-find-email",
55
name: "Find Email",
66
description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
microsoftOutlook,
@@ -15,23 +15,32 @@ export default {
1515
optional: true,
1616
},
1717
maxResults: {
18-
type: "integer",
19-
label: "Max Results",
20-
description: "The maximum number of results to return",
21-
optional: true,
18+
propDefinition: [
19+
microsoftOutlook,
20+
"maxResults",
21+
],
2222
},
2323
},
2424
async run({ $ }) {
25-
const { value } = await this.microsoftOutlook.listMessages({
26-
$,
27-
params: {
28-
"$filter": this.filter,
29-
"$top": this.maxResults,
25+
const items = this.microsoftOutlook.paginate({
26+
fn: this.microsoftOutlook.listMessages,
27+
args: {
28+
$,
29+
params: {
30+
"$filter": this.filter,
31+
},
3032
},
33+
max: this.maxResults,
3134
});
32-
$.export("$summary", `Successfully retrieved ${value.length} message${value.length != 1
35+
36+
const emails = [];
37+
for await (const item of items) {
38+
emails.push(item);
39+
}
40+
41+
$.export("$summary", `Successfully retrieved ${emails.length} message${emails.length != 1
3342
? "s"
3443
: ""}.`);
35-
return value;
44+
return emails;
3645
},
3746
};

components/microsoft_outlook/actions/list-contacts/list-contacts.mjs

+24-8
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,41 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-list-contacts",
6-
version: "0.0.11",
6+
version: "0.0.12",
77
name: "List Contacts",
8-
description: "Get a contact collection from the default contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
8+
description: "Get a contact collection from the default contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
99
props: {
1010
microsoftOutlook,
1111
filterAddress: {
12-
label: "Email adress",
12+
label: "Email Address",
1313
description: "If this is given, only contacts with the given address will be retrieved.",
1414
type: "string",
1515
optional: true,
1616
},
17+
maxResults: {
18+
propDefinition: [
19+
microsoftOutlook,
20+
"maxResults",
21+
],
22+
},
1723
},
1824
async run({ $ }) {
19-
const response = await this.microsoftOutlook.listContacts({
20-
$,
21-
filterAddress: this.filterAddress,
25+
const items = this.microsoftOutlook.paginate({
26+
fn: this.microsoftOutlook.listContacts,
27+
args: {
28+
$,
29+
filterAddress: this.filterAddress,
30+
},
31+
max: this.maxResults,
2232
});
33+
34+
const contacts = [];
35+
for await (const item of items) {
36+
contacts.push(item);
37+
}
38+
2339
// eslint-disable-next-line multiline-ternary
24-
$.export("$summary", `${response.value.length} contact${response.value.length != 1 ? "s" : ""} has been retrieved.`);
25-
return response.value;
40+
$.export("$summary", `${contacts.length} contact${contacts.length != 1 ? "s" : ""} retrieved.`);
41+
return contacts;
2642
},
2743
};

components/microsoft_outlook/actions/list-folders/list-folders.mjs

+21-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,34 @@ export default {
44
key: "microsoft_outlook-list-folders",
55
name: "List Folders",
66
description: "Retrieves a list of all folders in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
microsoftOutlook,
11+
maxResults: {
12+
propDefinition: [
13+
microsoftOutlook,
14+
"maxResults",
15+
],
16+
},
1117
},
1218
async run({ $ }) {
13-
const { value } = await this.microsoftOutlook.listFolders({
14-
$,
19+
const items = this.microsoftOutlook.paginate({
20+
fn: this.microsoftOutlook.listFolders,
21+
args: {
22+
$,
23+
},
24+
max: this.maxResults,
1525
});
16-
$.export("$summary", `Successfully retrieved ${value.length} folder${value.length != 1
26+
27+
const folders = [];
28+
for await (const item of items) {
29+
folders.push(item);
30+
}
31+
32+
$.export("$summary", `Successfully retrieved ${folders.length} folder${folders.length != 1
1733
? "s"
1834
: ""}.`);
19-
return value;
35+
return folders;
2036
},
2137
};

components/microsoft_outlook/actions/list-labels/list-labels.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-list-labels",
55
name: "List Labels",
66
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)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/move-email-to-folder/move-email-to-folder.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-move-email-to-folder",
55
name: "Move Email to Folder",
66
description: "Moves an email to the specified folder in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-move)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-remove-label-from-email",
55
name: "Remove Label from Email",
66
description: "Removes a label/category from an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/reply-to-email/reply-to-email.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-reply-to-email",
55
name: "Reply to Email",
66
description: "Reply to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-reply)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/send-email/send-email.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-send-email",
6-
version: "0.0.12",
6+
version: "0.0.13",
77
name: "Send Email",
88
description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
99
props: {

components/microsoft_outlook/actions/update-contact/update-contact.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-update-contact",
6-
version: "0.0.11",
6+
version: "0.0.12",
77
name: "Update Contact",
88
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {

0 commit comments

Comments
 (0)