@activepieces/piece-microsoft-outlook 0.3.5 → 0.4.0

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.
Files changed (73) hide show
  1. package/package.json +7 -13
  2. package/src/index.js +40 -63
  3. package/src/index.d.ts +0 -2
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/actions/add-label-to-email.d.ts +0 -5
  7. package/src/lib/actions/add-label-to-email.d.ts.map +0 -1
  8. package/src/lib/actions/add-label-to-email.js +0 -48
  9. package/src/lib/actions/add-label-to-email.js.map +0 -1
  10. package/src/lib/actions/create-draft-email.d.ts +0 -10
  11. package/src/lib/actions/create-draft-email.d.ts.map +0 -1
  12. package/src/lib/actions/create-draft-email.js +0 -112
  13. package/src/lib/actions/create-draft-email.js.map +0 -1
  14. package/src/lib/actions/download-email-attachment.d.ts +0 -4
  15. package/src/lib/actions/download-email-attachment.d.ts.map +0 -1
  16. package/src/lib/actions/download-email-attachment.js +0 -48
  17. package/src/lib/actions/download-email-attachment.js.map +0 -1
  18. package/src/lib/actions/find-email.d.ts +0 -6
  19. package/src/lib/actions/find-email.d.ts.map +0 -1
  20. package/src/lib/actions/find-email.js +0 -71
  21. package/src/lib/actions/find-email.js.map +0 -1
  22. package/src/lib/actions/forward-email.d.ts +0 -6
  23. package/src/lib/actions/forward-email.d.ts.map +0 -1
  24. package/src/lib/actions/forward-email.js +0 -65
  25. package/src/lib/actions/forward-email.js.map +0 -1
  26. package/src/lib/actions/move-email-to-folder.d.ts +0 -5
  27. package/src/lib/actions/move-email-to-folder.d.ts.map +0 -1
  28. package/src/lib/actions/move-email-to-folder.js +0 -45
  29. package/src/lib/actions/move-email-to-folder.js.map +0 -1
  30. package/src/lib/actions/remove-label-from-email.d.ts +0 -5
  31. package/src/lib/actions/remove-label-from-email.d.ts.map +0 -1
  32. package/src/lib/actions/remove-label-from-email.js +0 -48
  33. package/src/lib/actions/remove-label-from-email.js.map +0 -1
  34. package/src/lib/actions/reply-email.d.ts +0 -10
  35. package/src/lib/actions/reply-email.d.ts.map +0 -1
  36. package/src/lib/actions/reply-email.js +0 -172
  37. package/src/lib/actions/reply-email.js.map +0 -1
  38. package/src/lib/actions/request-approval-send-email.d.ts +0 -6
  39. package/src/lib/actions/request-approval-send-email.d.ts.map +0 -1
  40. package/src/lib/actions/request-approval-send-email.js +0 -108
  41. package/src/lib/actions/request-approval-send-email.js.map +0 -1
  42. package/src/lib/actions/send-draft-email.d.ts +0 -4
  43. package/src/lib/actions/send-draft-email.d.ts.map +0 -1
  44. package/src/lib/actions/send-draft-email.js +0 -42
  45. package/src/lib/actions/send-draft-email.js.map +0 -1
  46. package/src/lib/actions/send-email.d.ts +0 -10
  47. package/src/lib/actions/send-email.d.ts.map +0 -1
  48. package/src/lib/actions/send-email.js +0 -115
  49. package/src/lib/actions/send-email.js.map +0 -1
  50. package/src/lib/common/auth.d.ts +0 -2
  51. package/src/lib/common/auth.d.ts.map +0 -1
  52. package/src/lib/common/auth.js +0 -51
  53. package/src/lib/common/auth.js.map +0 -1
  54. package/src/lib/common/microsoft-cloud.d.ts +0 -5
  55. package/src/lib/common/microsoft-cloud.d.ts.map +0 -1
  56. package/src/lib/common/microsoft-cloud.js +0 -38
  57. package/src/lib/common/microsoft-cloud.js.map +0 -1
  58. package/src/lib/common/props.d.ts +0 -10
  59. package/src/lib/common/props.d.ts.map +0 -1
  60. package/src/lib/common/props.js +0 -141
  61. package/src/lib/common/props.js.map +0 -1
  62. package/src/lib/triggers/new-attachment.d.ts +0 -19
  63. package/src/lib/triggers/new-attachment.d.ts.map +0 -1
  64. package/src/lib/triggers/new-attachment.js +0 -139
  65. package/src/lib/triggers/new-attachment.js.map +0 -1
  66. package/src/lib/triggers/new-email-in-folder.d.ts +0 -11
  67. package/src/lib/triggers/new-email-in-folder.d.ts.map +0 -1
  68. package/src/lib/triggers/new-email-in-folder.js +0 -99
  69. package/src/lib/triggers/new-email-in-folder.js.map +0 -1
  70. package/src/lib/triggers/new-email.d.ts +0 -15
  71. package/src/lib/triggers/new-email.d.ts.map +0 -1
  72. package/src/lib/triggers/new-email.js +0 -123
  73. package/src/lib/triggers/new-email.js.map +0 -1
@@ -1,141 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mailFolderIdDropdown = exports.draftMessageIdDropdown = exports.messageIdDropdown = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const microsoft_cloud_1 = require("./microsoft-cloud");
7
- const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
8
- const auth_1 = require("./auth");
9
- const messageIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
10
- auth: auth_1.microsoftOutlookAuth,
11
- displayName: params.displayName,
12
- description: params.description,
13
- required: params.required,
14
- refreshers: [],
15
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
16
- var _b;
17
- if (!auth) {
18
- return {
19
- placeholder: 'Please connect your account first.',
20
- disabled: true,
21
- options: [],
22
- };
23
- }
24
- const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
25
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
26
- authProvider: {
27
- getAccessToken: () => Promise.resolve(auth.access_token),
28
- },
29
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
30
- });
31
- try {
32
- const response = yield client
33
- .api('/me/messages?$top=50&$select=id,subject,from,receivedDateTime')
34
- .orderby('receivedDateTime desc')
35
- .get();
36
- const messages = response.value;
37
- return {
38
- disabled: false,
39
- options: messages.map((message) => ({
40
- label: `${message.subject || 'No Subject'}`,
41
- value: message.id,
42
- })),
43
- };
44
- }
45
- catch (error) {
46
- return {
47
- disabled: true,
48
- options: [],
49
- };
50
- }
51
- }),
52
- });
53
- exports.messageIdDropdown = messageIdDropdown;
54
- const draftMessageIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
55
- auth: auth_1.microsoftOutlookAuth,
56
- displayName: params.displayName,
57
- description: params.description,
58
- required: params.required,
59
- refreshers: [],
60
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
61
- var _b;
62
- if (!auth) {
63
- return {
64
- placeholder: 'Please connect your account first.',
65
- disabled: true,
66
- options: [],
67
- };
68
- }
69
- const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
70
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
71
- authProvider: {
72
- getAccessToken: () => Promise.resolve(auth.access_token),
73
- },
74
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
75
- });
76
- try {
77
- const response = yield client
78
- .api('/me/mailFolders/drafts/messages?$top=50&$select=id,subject,from,receivedDateTime')
79
- .orderby('receivedDateTime desc')
80
- .get();
81
- const messages = response.value;
82
- return {
83
- disabled: false,
84
- options: messages.map((message) => ({
85
- label: `${message.subject || 'No Subject'}`,
86
- value: message.id,
87
- })),
88
- };
89
- }
90
- catch (error) {
91
- return {
92
- disabled: true,
93
- options: [],
94
- };
95
- }
96
- }),
97
- });
98
- exports.draftMessageIdDropdown = draftMessageIdDropdown;
99
- const mailFolderIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
100
- auth: auth_1.microsoftOutlookAuth,
101
- displayName: params.displayName,
102
- description: params.description,
103
- required: params.required,
104
- refreshers: [],
105
- options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
106
- var _b;
107
- if (!auth) {
108
- return {
109
- placeholder: 'Please connect your account first.',
110
- disabled: true,
111
- options: [],
112
- };
113
- }
114
- const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
115
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
116
- authProvider: {
117
- getAccessToken: () => Promise.resolve(auth.access_token),
118
- },
119
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
120
- });
121
- try {
122
- const response = yield client.api('/me/mailFolders').get();
123
- const folders = response.value;
124
- return {
125
- disabled: false,
126
- options: folders.map((folder) => ({
127
- label: folder.displayName || folder.id || 'Unknown',
128
- value: folder.id || '',
129
- })),
130
- };
131
- }
132
- catch (error) {
133
- return {
134
- disabled: true,
135
- options: [],
136
- };
137
- }
138
- }),
139
- });
140
- exports.mailFolderIdDropdown = mailFolderIdDropdown;
141
- //# sourceMappingURL=props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E,uDAAoD;AACpD,8EAA2E;AAE3E,iCAA8C;AAQvC,MAAM,iBAAiB,GAAG,CAAC,MAAsB,EAAE,EAAE,CAC3D,2BAAQ,CAAC,QAAQ,CAAC;IACjB,IAAI,EAAE,2BAAoB;IAC1B,WAAW,EAAE,MAAM,CAAC,WAAW;IAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;IAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;IACzB,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO;gBACN,WAAW,EAAE,oCAAoC;gBACjD,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,MAAC,IAA4B,CAAC,KAAK,0CAAG,OAAO,CAAuB,CAAC;QACnF,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;YACxC,YAAY,EAAE;gBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAE,IAA4B,CAAC,YAAY,CAAC;aACjF;YACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAmB,MAAM,MAAM;iBAC3C,GA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AK,0CAAG,OAAO,CAAuB,CAAC;QACnF,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;YACxC,YAAY,EAAE;gBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAE,IAA4B,CAAC,YAAY,CAAC;aACjF;YACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAmB,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAE,CAAC;YAE3E,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAqB,CAAC;YAE/C,OAAO;gBACN,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBACjC,KAAK,EAAE,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,EAAE,IAAI,SAAS;oBACnD,KAAK,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE;iBACtB,CAAC,CAAC;aACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO;gBACN,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACX,CAAC;QACH,CAAC;IACF,CAAC,CAAA;CACD,CAAC,CAAC;AA3CS,QAAA,oBAAoB,wBA2C7B"}
@@ -1,19 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const newAttachmentTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
4
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
- attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
7
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
8
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
- attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
11
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
12
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
13
- attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
15
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
16
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
17
- attachmentNameFilter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
18
- }>;
19
- //# sourceMappingURL=new-attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-attachment.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAA4B,MAAM,gCAAgC,CAAC;AAuDzG,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;EAyG/B,CAAC"}
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newAttachmentTrigger = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const microsoft_cloud_1 = require("../common/microsoft-cloud");
7
- const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
8
- const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
9
- const auth_1 = require("../common/auth");
10
- const props_1 = require("../common/props");
11
- const shared_1 = require("@activepieces/shared");
12
- function enrichAttachments(client, messages, files, nameFilter, senderFilter) {
13
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
- var _a, _b;
15
- const attachments = [];
16
- for (const message of messages) {
17
- if (senderFilter && ((_b = (_a = message.sender) === null || _a === void 0 ? void 0 : _a.emailAddress) === null || _b === void 0 ? void 0 : _b.address) && !message.sender.emailAddress.address.toLowerCase().includes(senderFilter.toLowerCase())) {
18
- continue;
19
- }
20
- const attachmentResponse = yield client
21
- .api(`/me/messages/${message.id}/attachments`)
22
- .get();
23
- for (const attachment of attachmentResponse.value) {
24
- const { contentBytes } = attachment, rest = tslib_1.__rest(attachment, ["contentBytes"]);
25
- if (nameFilter && attachment.name && !attachment.name.toLowerCase().includes(nameFilter.toLowerCase())) {
26
- continue;
27
- }
28
- if (attachment.name && contentBytes) {
29
- const file = yield files.write({
30
- fileName: attachment.name,
31
- data: Buffer.from(contentBytes, 'base64'),
32
- });
33
- attachments.push(Object.assign({ file, messageId: message.id, messageSubject: message.subject, messageSender: message.sender, messageReceivedDateTime: message.receivedDateTime, parentFolderId: message.parentFolderId }, rest));
34
- }
35
- }
36
- }
37
- return attachments;
38
- });
39
- }
40
- exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
41
- auth: auth_1.microsoftOutlookAuth,
42
- name: 'newAttachment',
43
- displayName: 'New Attachment',
44
- description: 'Triggers when a new email containing one or more attachments arrives.',
45
- props: {
46
- folderId: (0, props_1.mailFolderIdDropdown)({
47
- displayName: 'Folder',
48
- description: 'Monitor attachments in a specific folder. Leave empty to monitor all folders.',
49
- required: false,
50
- }),
51
- sender: pieces_framework_1.Property.ShortText({
52
- displayName: 'From (Sender Email)',
53
- description: 'Filter emails from a specific sender (optional). Leave empty to for all senders.',
54
- required: false,
55
- }),
56
- attachmentNameFilter: pieces_framework_1.Property.ShortText({
57
- displayName: 'Attachment Name Filter',
58
- description: 'Filter attachments by name (contains). Leave empty to include all attachments.',
59
- required: false,
60
- }),
61
- },
62
- sampleData: {},
63
- type: pieces_framework_1.TriggerStrategy.POLLING,
64
- onEnable(context) {
65
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
- yield context.store.put('lastPoll', Date.now());
67
- });
68
- },
69
- onDisable(context) {
70
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
- // return
72
- });
73
- },
74
- test(context) {
75
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
- var _a;
77
- const { folderId, attachmentNameFilter, sender } = context.propsValue;
78
- const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
79
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
80
- authProvider: {
81
- getAccessToken: () => Promise.resolve(context.auth.access_token),
82
- },
83
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
84
- });
85
- const baseUrl = folderId ? `/me/mailFolders/${folderId}/messages` : '/me/messages';
86
- const response = yield client
87
- .api(`${baseUrl}?$filter=hasAttachments eq true`)
88
- .top(10)
89
- .get();
90
- const attachments = yield enrichAttachments(client, response.value, context.files, attachmentNameFilter, sender);
91
- const items = attachments.map((attachment) => ({
92
- epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
93
- data: attachment,
94
- }));
95
- return items.map((item) => item.data);
96
- });
97
- },
98
- run(context) {
99
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
- var _a;
101
- const lastFetchEpochMS = yield context.store.get('lastPoll');
102
- if ((0, shared_1.isNil)(lastFetchEpochMS)) {
103
- throw new Error("lastPoll doesn't exist in the store.");
104
- }
105
- const { folderId, attachmentNameFilter, sender } = context.propsValue;
106
- const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
107
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
108
- authProvider: {
109
- getAccessToken: () => Promise.resolve(context.auth.access_token),
110
- },
111
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
112
- });
113
- const baseUrl = folderId ? `/me/mailFolders/${folderId}/messages` : '/me/messages';
114
- let response = yield client
115
- .api(`${baseUrl}?$filter=receivedDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()} and hasAttachments eq true`)
116
- .orderby('receivedDateTime desc')
117
- .get();
118
- const messages = [];
119
- while (response.value.length > 0) {
120
- messages.push(...response.value);
121
- if (response['@odata.nextLink']) {
122
- response = yield client.api(response['@odata.nextLink']).get();
123
- }
124
- else {
125
- break;
126
- }
127
- }
128
- const attachments = yield enrichAttachments(client, messages, context.files, attachmentNameFilter, sender);
129
- const items = attachments.map((attachment) => ({
130
- epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
131
- data: attachment,
132
- }));
133
- const newLastEpochMilliSeconds = items.reduce((acc, item) => Math.max(acc, item.epochMilliSeconds), lastFetchEpochMS);
134
- yield context.store.put('lastPoll', newLastEpochMilliSeconds);
135
- return items.filter((f) => f.epochMilliSeconds > lastFetchEpochMS).map((item) => item.data);
136
- });
137
- },
138
- });
139
- //# sourceMappingURL=new-attachment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-attachment.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-attachment.ts"],"names":[],"mappings":";;;;AAAA,qEAAyG;AACzG,+DAA4D;AAC5D,8EAA2E;AAE3E,0DAA0B;AAC1B,yCAAsD;AACtD,2CAAuD;AACvD,iDAA6C;AAE7C,SAAe,iBAAiB,CAC/B,MAAc,EACd,QAAmB,EACnB,KAAmB,EACnB,UAAmB,EACnB,YAAqB;;;QAErB,MAAM,WAAW,GAA0B,EAAE,CAAC;QAE9C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAChC,IAAI,YAAY,KAAI,MAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,YAAY,0CAAE,OAAO,CAAA,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACtJ,SAAS;YACV,CAAC;YAED,MAAM,kBAAkB,GAAmB,MAAM,MAAM;iBACrD,GAAG,CAAC,gBAAgB,OAAO,CAAC,EAAE,cAAc,CAAC;iBAC7C,GAAG,EAAE,CAAC;YAER,KAAK,MAAM,UAAU,IAAI,kBAAkB,CAAC,KAAyB,EAAE,CAAC;gBACvE,MAAM,EAAE,YAAY,KAAc,UAAU,EAAnB,IAAI,kBAAK,UAAU,EAAtC,gBAAyB,CAAa,CAAC;gBAE7C,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;oBACxG,SAAS;gBACV,CAAC;gBAED,IAAI,UAAU,CAAC,IAAI,IAAI,YAAY,EAAE,CAAC;oBACrC,MAAM,IA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,CAAC,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;gBAChE,CAAC;qBAAM,CAAC;oBACP,MAAM;gBACP,CAAC;YACF,CAAC;YACD,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC;YAE3G,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC9C,iBAAiB,EAAE,IAAA,eAAK,EAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,OAAO,EAAE;gBACzE,IAAI,EAAE,UAAU;aAChB,CAAC,CAAC,CAAC;YAEJ,MAAM,wBAAwB,GAAG,KAAK,CAAC,MAAM,CAC5C,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,EACpD,gBAAgB,CAChB,CAAC;YACF,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;YAC9D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7F,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const newEmailInFolderTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
4
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
5
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
6
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
7
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
8
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
9
- folderId: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
10
- }>;
11
- //# sourceMappingURL=new-email-in-folder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-email-in-folder.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-email-in-folder.ts"],"names":[],"mappings":"AAEA,OAAO,EAGN,eAAe,EAEf,MAAM,gCAAgC,CAAC;AAwDxC,eAAO,MAAM,uBAAuB;;;;;;;;EAkClC,CAAC"}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newEmailInFolderTrigger = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const microsoft_cloud_1 = require("../common/microsoft-cloud");
7
- const pieces_framework_1 = require("@activepieces/pieces-framework");
8
- const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
- const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
10
- const auth_1 = require("../common/auth");
11
- const props_1 = require("../common/props");
12
- const polling = {
13
- strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
14
- items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
15
- var _b;
16
- const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
17
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
18
- authProvider: {
19
- getAccessToken: () => Promise.resolve(auth.access_token),
20
- },
21
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
22
- });
23
- const messages = [];
24
- const folderId = propsValue.folderId;
25
- const filter = lastFetchEpochMS === 0
26
- ? '$top=10'
27
- : `$filter=createdDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()}`;
28
- let response = yield client
29
- .api(`/me/mailFolders/${folderId}/messages?${filter}`)
30
- .orderby('createdDateTime desc')
31
- .get();
32
- if (lastFetchEpochMS === 0) {
33
- for (const message of response.value) {
34
- messages.push(message);
35
- }
36
- }
37
- else {
38
- while (response.value.length > 0) {
39
- for (const message of response.value) {
40
- messages.push(message);
41
- }
42
- if (response['@odata.nextLink']) {
43
- response = yield client.api(response['@odata.nextLink']).get();
44
- }
45
- else {
46
- break;
47
- }
48
- }
49
- }
50
- return messages.map((message) => ({
51
- epochMilliSeconds: (0, dayjs_1.default)(message.createdDateTime).valueOf(),
52
- data: message,
53
- }));
54
- }),
55
- };
56
- exports.newEmailInFolderTrigger = (0, pieces_framework_1.createTrigger)({
57
- auth: auth_1.microsoftOutlookAuth,
58
- name: 'newEmailInFolder',
59
- displayName: 'New Email in Folder',
60
- description: 'Triggers when a new email is delivered into the specified folder.',
61
- props: {
62
- folderId: (0, props_1.mailFolderIdDropdown)({
63
- displayName: 'Folder',
64
- description: '',
65
- required: true,
66
- }),
67
- },
68
- sampleData: {},
69
- type: pieces_framework_1.TriggerStrategy.POLLING,
70
- onEnable(context) {
71
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
72
- yield pieces_common_1.pollingHelper.onEnable(polling, {
73
- auth: context.auth,
74
- store: context.store,
75
- propsValue: context.propsValue,
76
- });
77
- });
78
- },
79
- onDisable(context) {
80
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
- yield pieces_common_1.pollingHelper.onDisable(polling, {
82
- auth: context.auth,
83
- store: context.store,
84
- propsValue: context.propsValue,
85
- });
86
- });
87
- },
88
- test(context) {
89
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
90
- return yield pieces_common_1.pollingHelper.test(polling, context);
91
- });
92
- },
93
- run(context) {
94
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
95
- return yield pieces_common_1.pollingHelper.poll(polling, context);
96
- });
97
- },
98
- });
99
- //# sourceMappingURL=new-email-in-folder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-email-in-folder.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-email-in-folder.ts"],"names":[],"mappings":";;;;AAAA,+DAAqF;AACrF,+DAA4D;AAC5D,qEAKwC;AACxC,8EAA2E;AAE3E,0DAA0B;AAC1B,yCAAsD;AACtD,2CAAuD;AAEvD,MAAM,OAAO,GAAmG;IAC/G,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE;;QACnD,MAAM,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GAAG,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,15 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const newEmailTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
- recipient: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
6
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
- recipient: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
9
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
- recipient: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
- }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
12
- sender: import("@activepieces/pieces-framework").ShortTextProperty<false>;
13
- recipient: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
- }>;
15
- //# sourceMappingURL=new-email.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-email.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-email.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,eAAe,EAGf,MAAM,gCAAgC,CAAC;AAkFxC,eAAO,MAAM,eAAe;;;;;;;;;;;;EAuC1B,CAAC"}
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newEmailTrigger = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_common_1 = require("@activepieces/pieces-common");
6
- const microsoft_cloud_1 = require("../common/microsoft-cloud");
7
- const pieces_framework_1 = require("@activepieces/pieces-framework");
8
- const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
- const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
10
- const auth_1 = require("../common/auth");
11
- const polling = {
12
- strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
13
- items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
14
- var _b;
15
- const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
16
- const client = microsoft_graph_client_1.Client.initWithMiddleware({
17
- authProvider: {
18
- getAccessToken: () => Promise.resolve(auth.access_token),
19
- },
20
- baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
21
- });
22
- const messages = [];
23
- const filter = lastFetchEpochMS === 0
24
- ? '$top=10'
25
- : `$filter=receivedDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()}`;
26
- let response = yield client
27
- .api(`/me/mailFolders/inbox/messages?${filter}`)
28
- .orderby('receivedDateTime desc')
29
- .get();
30
- if (lastFetchEpochMS === 0) {
31
- for (const message of response.value) {
32
- messages.push(message);
33
- }
34
- }
35
- else {
36
- while (response.value.length > 0) {
37
- for (const message of response.value) {
38
- messages.push(message);
39
- }
40
- if (response['@odata.nextLink']) {
41
- response = yield client.api(response['@odata.nextLink']).get();
42
- }
43
- else {
44
- break;
45
- }
46
- }
47
- }
48
- let filteredMessages = messages;
49
- if (propsValue === null || propsValue === void 0 ? void 0 : propsValue.sender) {
50
- filteredMessages = filteredMessages.filter((message) => {
51
- var _a, _b, _c, _d;
52
- const messageSenderEmail = (_c = (_b = (_a = message.from) === null || _a === void 0 ? void 0 : _a.emailAddress) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.toLowerCase();
53
- const filterSenderEmail = (_d = propsValue.sender) === null || _d === void 0 ? void 0 : _d.toLowerCase();
54
- return messageSenderEmail === filterSenderEmail;
55
- });
56
- }
57
- if (propsValue === null || propsValue === void 0 ? void 0 : propsValue.recipient) {
58
- filteredMessages = filteredMessages.filter((message) => {
59
- var _a;
60
- const hasRecipient = (_a = message.toRecipients) === null || _a === void 0 ? void 0 : _a.some((recipient) => {
61
- var _a, _b, _c;
62
- const recipientEmail = (_b = (_a = recipient.emailAddress) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.toLowerCase();
63
- const filterRecipientEmail = (_c = propsValue.recipient) === null || _c === void 0 ? void 0 : _c.toLowerCase();
64
- return recipientEmail === filterRecipientEmail;
65
- });
66
- return hasRecipient;
67
- });
68
- }
69
- return filteredMessages.map((message) => ({
70
- epochMilliSeconds: (0, dayjs_1.default)(message.receivedDateTime).valueOf(),
71
- data: message,
72
- }));
73
- }),
74
- };
75
- exports.newEmailTrigger = (0, pieces_framework_1.createTrigger)({
76
- auth: auth_1.microsoftOutlookAuth,
77
- name: 'newEmail',
78
- displayName: 'New Email',
79
- description: 'Triggers when a new email is received in the inbox.',
80
- props: {
81
- sender: pieces_framework_1.Property.ShortText({
82
- displayName: 'From (Sender Email)',
83
- description: 'Filter emails from a specific sender (optional). Leave empty to for all senders.',
84
- required: false,
85
- }),
86
- recipient: pieces_framework_1.Property.ShortText({
87
- displayName: 'To (Recipient Email)',
88
- description: 'Filter emails to a specific recipient (optional). Leave empty to for all recipients.',
89
- required: false,
90
- }),
91
- },
92
- sampleData: {},
93
- type: pieces_framework_1.TriggerStrategy.POLLING,
94
- onEnable(context) {
95
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
- yield pieces_common_1.pollingHelper.onEnable(polling, {
97
- auth: context.auth,
98
- store: context.store,
99
- propsValue: context.propsValue,
100
- });
101
- });
102
- },
103
- onDisable(context) {
104
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
105
- yield pieces_common_1.pollingHelper.onDisable(polling, {
106
- auth: context.auth,
107
- store: context.store,
108
- propsValue: context.propsValue,
109
- });
110
- });
111
- },
112
- test(context) {
113
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
114
- return yield pieces_common_1.pollingHelper.test(polling, context);
115
- });
116
- },
117
- run(context) {
118
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
119
- return yield pieces_common_1.pollingHelper.poll(polling, context);
120
- });
121
- },
122
- });
123
- //# sourceMappingURL=new-email.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-email.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-email.ts"],"names":[],"mappings":";;;;AAAA,+DAAqF;AACrF,+DAA4D;AAC5D,qEAKwC;AACxC,8EAA2E;AAE3E,0DAA0B;AAC1B,yCAAsD;AAEtD,MAAM,OAAO,GAGR;IACJ,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE;;QACnD,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAG,OAAO,CAAuB,CAAC;QAC1D,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;YACxC,YAAY,EAAE;gBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;aACxD;YACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;SAC/B,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,MAAM,GACX,gBAAgB,KAAK,CAAC;YACrB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,+BAA+B,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAE3E,IAAI,QAAQ,GAAmB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