@pipedream/microsoft_outlook 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook-add-label-to-email",
6
6
  name: "Add Label to Email",
7
7
  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",
9
9
  type: "action",
10
10
  props: {
11
11
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-approve-workflow",
5
5
  name: "Approve Workflow",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-create-contact",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  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)",
9
9
  props: {
10
10
  microsoftOutlook,
11
11
  givenName: {
@@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-create-draft-email",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  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)",
9
9
  props: {
10
10
  microsoftOutlook,
11
11
  recipients: {
@@ -3,9 +3,9 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-find-contacts",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  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)",
9
9
  props: {
10
10
  microsoftOutlook,
11
11
  searchString: {
@@ -13,21 +13,40 @@ export default {
13
13
  description: "Provide email address, given name, surname or display name (case sensitive)",
14
14
  type: "string",
15
15
  },
16
+ maxResults: {
17
+ propDefinition: [
18
+ microsoftOutlook,
19
+ "maxResults",
20
+ ],
21
+ },
16
22
  },
17
23
  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
+ },
28
29
  });
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
+
29
48
  // 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`);
31
50
  return relatedContacts;
32
51
  },
33
52
  };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-find-email",
5
5
  name: "Find Email",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -15,23 +15,32 @@ export default {
15
15
  optional: true,
16
16
  },
17
17
  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
+ ],
22
22
  },
23
23
  },
24
24
  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
+ },
30
32
  },
33
+ max: this.maxResults,
31
34
  });
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
33
42
  ? "s"
34
43
  : ""}.`);
35
- return value;
44
+ return emails;
36
45
  },
37
46
  };
@@ -3,25 +3,41 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-list-contacts",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  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)",
9
9
  props: {
10
10
  microsoftOutlook,
11
11
  filterAddress: {
12
- label: "Email adress",
12
+ label: "Email Address",
13
13
  description: "If this is given, only contacts with the given address will be retrieved.",
14
14
  type: "string",
15
15
  optional: true,
16
16
  },
17
+ maxResults: {
18
+ propDefinition: [
19
+ microsoftOutlook,
20
+ "maxResults",
21
+ ],
22
+ },
17
23
  },
18
24
  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,
22
32
  });
33
+
34
+ const contacts = [];
35
+ for await (const item of items) {
36
+ contacts.push(item);
37
+ }
38
+
23
39
  // 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;
26
42
  },
27
43
  };
@@ -4,18 +4,34 @@ export default {
4
4
  key: "microsoft_outlook-list-folders",
5
5
  name: "List Folders",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
11
+ maxResults: {
12
+ propDefinition: [
13
+ microsoftOutlook,
14
+ "maxResults",
15
+ ],
16
+ },
11
17
  },
12
18
  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,
15
25
  });
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
17
33
  ? "s"
18
34
  : ""}.`);
19
- return value;
35
+ return folders;
20
36
  },
21
37
  };
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-list-labels",
5
5
  name: "List Labels",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-move-email-to-folder",
5
5
  name: "Move Email to Folder",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-remove-label-from-email",
5
5
  name: "Remove Label from Email",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-reply-to-email",
5
5
  name: "Reply to Email",
6
6
  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",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-send-email",
6
- version: "0.0.12",
6
+ version: "0.0.13",
7
7
  name: "Send Email",
8
8
  description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
9
9
  props: {
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-update-contact",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  name: "Update Contact",
8
8
  description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
9
9
  props: {
@@ -3,6 +3,7 @@ import fs from "fs";
3
3
  import path from "path";
4
4
  import { encode } from "js-base64";
5
5
  import mime from "mime-types";
6
+ const DEFAULT_LIMIT = 50;
6
7
 
7
8
  export default {
8
9
  type: "app",
@@ -62,8 +63,14 @@ export default {
62
63
  label: "Contact",
63
64
  description: "The contact to be updated",
64
65
  type: "string",
65
- async options() {
66
- const contactResponse = await this.listContacts();
66
+ async options({ page }) {
67
+ const limit = DEFAULT_LIMIT;
68
+ const contactResponse = await this.listContacts({
69
+ params: {
70
+ $top: limit,
71
+ $skip: limit * page,
72
+ },
73
+ });
67
74
  return contactResponse.value.map((co) => ({
68
75
  label: co.displayName,
69
76
  value: co.id,
@@ -127,7 +134,7 @@ export default {
127
134
  label: "Message ID",
128
135
  description: "The identifier of the message to update",
129
136
  async options({ page }) {
130
- const limit = 50;
137
+ const limit = DEFAULT_LIMIT;
131
138
  const { value } = await this.listMessages({
132
139
  params: {
133
140
  $top: limit,
@@ -147,8 +154,14 @@ export default {
147
154
  type: "string[]",
148
155
  label: "Folder IDs to Monitor",
149
156
  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\").",
150
- async options() {
151
- const { value: folders } = await this.listFolders();
157
+ async options({ page }) {
158
+ const limit = DEFAULT_LIMIT;
159
+ const { value: folders } = await this.listFolders({
160
+ params: {
161
+ $top: limit,
162
+ $skip: limit * page,
163
+ },
164
+ });
152
165
  return folders?.map(({
153
166
  id: value, displayName: label,
154
167
  }) => ({
@@ -157,6 +170,13 @@ export default {
157
170
  })) || [];
158
171
  },
159
172
  },
173
+ maxResults: {
174
+ type: "integer",
175
+ label: "Max Results",
176
+ description: "The maximum number of results to return",
177
+ default: 100,
178
+ optional: true,
179
+ },
160
180
  },
161
181
  methods: {
162
182
  _getUrl(path) {
@@ -304,16 +324,15 @@ export default {
304
324
  filterAddress,
305
325
  ...args
306
326
  } = {}) {
307
- const paramsContainer = {};
327
+ args.params = {
328
+ ...args?.params,
329
+ };
308
330
  if (filterAddress) {
309
- paramsContainer.params = {
310
- "$filter": `emailAddresses/any(a:a/address eq '${filterAddress}')`,
311
- };
331
+ args.params["$filter"] = `emailAddresses/any(a:a/address eq '${filterAddress}')`;
312
332
  }
313
333
  return await this._makeRequest({
314
334
  method: "GET",
315
335
  path: "/me/contacts",
316
- ...paramsContainer,
317
336
  ...args,
318
337
  });
319
338
  },
@@ -384,5 +403,30 @@ export default {
384
403
  ...args,
385
404
  });
386
405
  },
406
+ async *paginate({
407
+ fn, args = {}, max,
408
+ }) {
409
+ const limit = DEFAULT_LIMIT;
410
+ args = {
411
+ ...args,
412
+ params: {
413
+ ...args?.params,
414
+ $top: limit,
415
+ $skip: 0,
416
+ },
417
+ };
418
+ let total, count = 0;
419
+ do {
420
+ const { value } = await fn(args);
421
+ for (const item of value) {
422
+ yield item;
423
+ if (max && ++count >= max) {
424
+ return;
425
+ }
426
+ }
427
+ total = value?.length;
428
+ args.params["$skip"] += limit;
429
+ } while (total);
430
+ },
387
431
  },
388
432
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Pipedream Microsoft Outlook Components",
5
5
  "main": "microsoft_outlook.app.mjs",
6
6
  "keywords": [
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook-new-contact",
6
6
  name: "New Contact Event (Instant)",
7
7
  description: "Emit new event when a new Contact is created",
8
- version: "0.0.12",
8
+ version: "0.0.13",
9
9
  type: "source",
10
10
  hooks: {
11
11
  ...common.hooks,
@@ -7,7 +7,7 @@ export default {
7
7
  key: "microsoft_outlook-new-email",
8
8
  name: "New Email Event (Instant)",
9
9
  description: "Emit new event when an email is received in specified folders.",
10
- version: "0.0.15",
10
+ version: "0.0.16",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  props: {