@divyacon/piece-microsoft-outlook 0.0.0-stage → 0.1.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.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/add-label-to-email.d.ts +5 -0
- package/dist/lib/actions/add-label-to-email.d.ts.map +1 -0
- package/dist/lib/actions/add-label-to-email.js +44 -0
- package/dist/lib/actions/add-label-to-email.js.map +1 -0
- package/dist/lib/actions/create-draft-email.d.ts +10 -0
- package/dist/lib/actions/create-draft-email.d.ts.map +1 -0
- package/dist/lib/actions/create-draft-email.js +108 -0
- package/dist/lib/actions/create-draft-email.js.map +1 -0
- package/dist/lib/actions/download-email-attachment.d.ts +4 -0
- package/dist/lib/actions/download-email-attachment.d.ts.map +1 -0
- package/dist/lib/actions/download-email-attachment.js +44 -0
- package/dist/lib/actions/download-email-attachment.js.map +1 -0
- package/dist/lib/actions/find-email.d.ts +6 -0
- package/dist/lib/actions/find-email.d.ts.map +1 -0
- package/dist/lib/actions/find-email.js +67 -0
- package/dist/lib/actions/find-email.js.map +1 -0
- package/dist/lib/actions/forward-email.d.ts +6 -0
- package/dist/lib/actions/forward-email.d.ts.map +1 -0
- package/dist/lib/actions/forward-email.js +61 -0
- package/dist/lib/actions/forward-email.js.map +1 -0
- package/dist/lib/actions/move-email-to-folder.d.ts +5 -0
- package/dist/lib/actions/move-email-to-folder.d.ts.map +1 -0
- package/dist/lib/actions/move-email-to-folder.js +41 -0
- package/dist/lib/actions/move-email-to-folder.js.map +1 -0
- package/dist/lib/actions/remove-label-from-email.d.ts +5 -0
- package/dist/lib/actions/remove-label-from-email.d.ts.map +1 -0
- package/dist/lib/actions/remove-label-from-email.js +44 -0
- package/dist/lib/actions/remove-label-from-email.js.map +1 -0
- package/dist/lib/actions/reply-email.d.ts +10 -0
- package/dist/lib/actions/reply-email.d.ts.map +1 -0
- package/dist/lib/actions/reply-email.js +161 -0
- package/dist/lib/actions/reply-email.js.map +1 -0
- package/dist/lib/actions/request-approval-send-email.d.ts +6 -0
- package/dist/lib/actions/request-approval-send-email.d.ts.map +1 -0
- package/dist/lib/actions/request-approval-send-email.js +99 -0
- package/dist/lib/actions/request-approval-send-email.js.map +1 -0
- package/dist/lib/actions/send-draft-email.d.ts +4 -0
- package/dist/lib/actions/send-draft-email.d.ts.map +1 -0
- package/dist/lib/actions/send-draft-email.js +38 -0
- package/dist/lib/actions/send-draft-email.js.map +1 -0
- package/dist/lib/actions/send-email.d.ts +10 -0
- package/dist/lib/actions/send-email.d.ts.map +1 -0
- package/dist/lib/actions/send-email.js +111 -0
- package/dist/lib/actions/send-email.js.map +1 -0
- package/dist/lib/common/auth.d.ts +2 -0
- package/dist/lib/common/auth.d.ts.map +1 -0
- package/dist/lib/common/auth.js +88 -0
- package/dist/lib/common/auth.js.map +1 -0
- package/dist/lib/common/client.d.ts +16 -0
- package/dist/lib/common/client.d.ts.map +1 -0
- package/dist/lib/common/client.js +27 -0
- package/dist/lib/common/client.js.map +1 -0
- package/dist/lib/common/microsoft-cloud.d.ts +6 -0
- package/dist/lib/common/microsoft-cloud.d.ts.map +1 -0
- package/dist/lib/common/microsoft-cloud.js +57 -0
- package/dist/lib/common/microsoft-cloud.js.map +1 -0
- package/dist/lib/common/props.d.ts +10 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +124 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/triggers/new-attachment.d.ts +19 -0
- package/dist/lib/triggers/new-attachment.d.ts.map +1 -0
- package/dist/lib/triggers/new-attachment.js +129 -0
- package/dist/lib/triggers/new-attachment.js.map +1 -0
- package/dist/lib/triggers/new-email-in-folder.d.ts +11 -0
- package/dist/lib/triggers/new-email-in-folder.d.ts.map +1 -0
- package/dist/lib/triggers/new-email-in-folder.js +96 -0
- package/dist/lib/triggers/new-email-in-folder.js.map +1 -0
- package/dist/lib/triggers/new-email.d.ts +15 -0
- package/dist/lib/triggers/new-email.d.ts.map +1 -0
- package/dist/lib/triggers/new-email.js +120 -0
- package/dist/lib/triggers/new-email.js.map +1 -0
- package/package.json +47 -4
- package/src/index.ts +56 -0
- package/src/lib/actions/add-label-to-email.ts +41 -0
- package/src/lib/actions/create-draft-email.ts +106 -0
- package/src/lib/actions/download-email-attachment.ts +47 -0
- package/src/lib/actions/find-email.ts +72 -0
- package/src/lib/actions/forward-email.ts +64 -0
- package/src/lib/actions/move-email-to-folder.ts +36 -0
- package/src/lib/actions/remove-label-from-email.ts +43 -0
- package/src/lib/actions/reply-email.ts +158 -0
- package/src/lib/actions/request-approval-send-email.ts +105 -0
- package/src/lib/actions/send-draft-email.ts +33 -0
- package/src/lib/actions/send-email.ts +110 -0
- package/src/lib/common/auth.ts +85 -0
- package/src/lib/common/client.ts +26 -0
- package/src/lib/common/microsoft-cloud.ts +56 -0
- package/src/lib/common/props.ts +137 -0
- package/src/lib/triggers/new-attachment.ts +153 -0
- package/src/lib/triggers/new-email-in-folder.ts +95 -0
- package/src/lib/triggers/new-email.ts +126 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,uGAAuG;AACvG,qEAAqE;AACrE,gEAAqF;AACrF,uDAAmF;AACnF,qCAAyC;AAEzC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;CAehB,CAAC;AAEW,QAAA,oBAAoB,GAAG,4BAAS,CAAC,MAAM,CAAC;IACnD,WAAW,EAAE,QAAQ;IACrB,SAAS,EAAE,gDAAgD;IAC3D,KAAK,EAAE;QACL,KAAK,EAAE,wCAAsB;QAC7B,UAAU,EAAE,wCAAsB;QAClC,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAA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K,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACjG,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,gDAAgD,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
declare function createClient(auth: OAuth2PropertyValue): Client;
|
|
4
|
+
/**
|
|
5
|
+
* Delegated connections act as the signed-in user (`/me`). App-only
|
|
6
|
+
* (client-credentials) tokens have no user context, so they must address a
|
|
7
|
+
* specific mailbox via `/users/{id}`. Presence of the `mailbox` prop is what
|
|
8
|
+
* distinguishes the two, since the piece cannot read the connection's grant type.
|
|
9
|
+
*/
|
|
10
|
+
declare function mailboxPrefix(auth: OAuth2PropertyValue): string;
|
|
11
|
+
export declare const outlookCommon: {
|
|
12
|
+
createClient: typeof createClient;
|
|
13
|
+
mailboxPrefix: typeof mailboxPrefix;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAG3D,iBAAS,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAQvD;AAED;;;;;GAKG;AACH,iBAAS,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAGxD;AAED,eAAO,MAAM,aAAa;;;CAAkC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.outlookCommon = void 0;
|
|
4
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
5
|
+
const microsoft_cloud_1 = require("./microsoft-cloud");
|
|
6
|
+
function createClient(auth) {
|
|
7
|
+
const cloud = (0, microsoft_cloud_1.getMicrosoftCloudFromAuth)(auth);
|
|
8
|
+
return microsoft_graph_client_1.Client.initWithMiddleware({
|
|
9
|
+
authProvider: {
|
|
10
|
+
getAccessToken: () => Promise.resolve(auth.access_token),
|
|
11
|
+
},
|
|
12
|
+
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Delegated connections act as the signed-in user (`/me`). App-only
|
|
17
|
+
* (client-credentials) tokens have no user context, so they must address a
|
|
18
|
+
* specific mailbox via `/users/{id}`. Presence of the `mailbox` prop is what
|
|
19
|
+
* distinguishes the two, since the piece cannot read the connection's grant type.
|
|
20
|
+
*/
|
|
21
|
+
function mailboxPrefix(auth) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const mailbox = (_b = (_a = auth.props) === null || _a === void 0 ? void 0 : _a['mailbox']) === null || _b === void 0 ? void 0 : _b.trim();
|
|
24
|
+
return mailbox ? `/users/${encodeURIComponent(mailbox)}` : '/me';
|
|
25
|
+
}
|
|
26
|
+
exports.outlookCommon = { createClient, mailboxPrefix };
|
|
27
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":";;;AAGA,8EAA2D;AAC3D,uDAA+E;AAE/E,SAAS,YAAY,CAAC,IAAyB;IAC7C,MAAM,KAAK,GAAG,IAAA,2CAAyB,EAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,+BAAM,CAAC,kBAAkB,CAAC;QAC/B,YAAY,EAAE;YACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;SACzD;QACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;KAChC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAyB;;IAC9C,MAAM,OAAO,GAAG,MAAC,MAAA,IAAI,CAAC,KAAK,0CAAG,SAAS,CAAwB,0CAAE,IAAI,EAAE,CAAC;IACxE,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACnE,CAAC;AAEY,QAAA,aAAa,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OAuth2PropertyValue } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const microsoftCloudProperty: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
export declare const microsoftScopeProperty: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
|
|
4
|
+
export declare function getMicrosoftCloudFromAuth(auth: OAuth2PropertyValue): string;
|
|
5
|
+
export declare function getGraphBaseUrl(cloudLoginHost: string | undefined | null): string;
|
|
6
|
+
//# sourceMappingURL=microsoft-cloud.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microsoft-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/common/microsoft-cloud.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAY,MAAM,2BAA2B,CAAC;AAc1E,eAAO,MAAM,sBAAsB,0EAYjC,CAAC;AAEH,eAAO,MAAM,sBAAsB,0EAcjC,CAAC;AAMH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAE3E;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAGjF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftScopeProperty = exports.microsoftCloudProperty = void 0;
|
|
4
|
+
exports.getMicrosoftCloudFromAuth = getMicrosoftCloudFromAuth;
|
|
5
|
+
exports.getGraphBaseUrl = getGraphBaseUrl;
|
|
6
|
+
// Vendored from Activepieces packages/pieces/community/microsoft-outlook/src/lib/common/microsoft-cloud.ts (MIT).
|
|
7
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';
|
|
10
|
+
const GOV_LOGIN_HOST = 'login.microsoftonline.us';
|
|
11
|
+
const DELEGATED_SCOPE = 'Mail.ReadWrite Mail.Send Calendars.Read offline_access User.Read openid email profile';
|
|
12
|
+
const APP_ONLY_COMMERCIAL_SCOPE = 'https://graph.microsoft.com/.default';
|
|
13
|
+
const APP_ONLY_GOV_SCOPE = 'https://graph.microsoft.us/.default';
|
|
14
|
+
const GRAPH_BASE_URLS = {
|
|
15
|
+
[COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',
|
|
16
|
+
[GOV_LOGIN_HOST]: 'https://graph.microsoft.us',
|
|
17
|
+
};
|
|
18
|
+
exports.microsoftCloudProperty = pieces_framework_1.Property.StaticDropdown({
|
|
19
|
+
displayName: 'Cloud Environment',
|
|
20
|
+
description: 'Select your Microsoft cloud environment.',
|
|
21
|
+
required: true,
|
|
22
|
+
defaultValue: COMMERCIAL_LOGIN_HOST,
|
|
23
|
+
options: {
|
|
24
|
+
disabled: false,
|
|
25
|
+
options: [
|
|
26
|
+
{ label: 'Commercial (Global)', value: COMMERCIAL_LOGIN_HOST },
|
|
27
|
+
{ label: 'US Government (GCC High)', value: GOV_LOGIN_HOST },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
exports.microsoftScopeProperty = pieces_framework_1.Property.StaticDropdown({
|
|
32
|
+
displayName: 'Access Mode',
|
|
33
|
+
description: 'Pick the option matching your Grant Type. Use a Delegated option with the Authorization Code grant (acts as the signed-in user). Use an App-only option with the Client Credentials grant (acts as the application — also set Tenant ID and Mailbox), choosing the one that matches your Cloud Environment.',
|
|
34
|
+
required: true,
|
|
35
|
+
defaultValue: DELEGATED_SCOPE,
|
|
36
|
+
options: {
|
|
37
|
+
disabled: false,
|
|
38
|
+
options: [
|
|
39
|
+
{ label: 'Delegated — Commercial (Global)', value: DELEGATED_SCOPE },
|
|
40
|
+
{ label: 'App-only — Commercial (Global)', value: APP_ONLY_COMMERCIAL_SCOPE },
|
|
41
|
+
{ label: 'App-only — US Government (GCC High)', value: APP_ONLY_GOV_SCOPE },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
function resolveCloudHost(cloudLoginHost) {
|
|
46
|
+
return cloudLoginHost !== null && cloudLoginHost !== void 0 ? cloudLoginHost : COMMERCIAL_LOGIN_HOST;
|
|
47
|
+
}
|
|
48
|
+
function getMicrosoftCloudFromAuth(auth) {
|
|
49
|
+
var _a;
|
|
50
|
+
return resolveCloudHost((_a = auth.props) === null || _a === void 0 ? void 0 : _a['cloud']);
|
|
51
|
+
}
|
|
52
|
+
function getGraphBaseUrl(cloudLoginHost) {
|
|
53
|
+
var _a;
|
|
54
|
+
const host = resolveCloudHost(cloudLoginHost);
|
|
55
|
+
return (_a = GRAPH_BASE_URLS[host]) !== null && _a !== void 0 ? _a : GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=microsoft-cloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microsoft-cloud.js","sourceRoot":"","sources":["../../../src/lib/common/microsoft-cloud.ts"],"names":[],"mappings":";;;AAkDA,8DAEC;AAED,0CAGC;AAzDD,kHAAkH;AAClH,qEAAqE;AACrE,gEAA0E;AAE1E,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAC1D,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAElD,MAAM,eAAe,GAAG,uFAAuF,CAAC;AAChH,MAAM,yBAAyB,GAAG,sCAAsC,CAAC;AACzE,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAEjE,MAAM,eAAe,GAA2B;IAC9C,CAAC,qBAAqB,CAAC,EAAE,6BAA6B;IACtD,CAAC,cAAc,CAAC,EAAE,4BAA4B;CAC/C,CAAC;AAEW,QAAA,sBAAsB,GAAG,2BAAQ,CAAC,cAAc,CAAC;IAC5D,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,0CAA0C;IACvD,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|
5
|
+
};
|
|
6
|
+
export declare const messageIdDropdown: (params: DropdownParams) => import("@agnocon/pieces-framework").DropdownProperty<string | undefined, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string | undefined, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
7
|
+
export declare const draftMessageIdDropdown: (params: DropdownParams) => import("@agnocon/pieces-framework").DropdownProperty<string | undefined, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string | undefined, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
export declare const mailFolderIdDropdown: (params: DropdownParams) => import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":"AAQA,KAAK,cAAc,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,cAAc,+WAyCrD,CAAC;AAEJ,eAAO,MAAM,sBAAsB,WAAY,cAAc,+WAyC1D,CAAC;AAEJ,eAAO,MAAM,oBAAoB,WAAY,cAAc,uVAsCxD,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
// Vendored from Activepieces packages/pieces/community/microsoft-outlook/src/lib/common/props.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const auth_1 = require("./auth");
|
|
9
|
+
const client_1 = require("./client");
|
|
10
|
+
const messageIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
|
|
11
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
12
|
+
displayName: params.displayName,
|
|
13
|
+
description: params.description,
|
|
14
|
+
required: params.required,
|
|
15
|
+
refreshers: [],
|
|
16
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
17
|
+
if (!auth) {
|
|
18
|
+
return {
|
|
19
|
+
placeholder: 'Please connect your account first.',
|
|
20
|
+
disabled: true,
|
|
21
|
+
options: [],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const authValue = auth;
|
|
25
|
+
const client = client_1.outlookCommon.createClient(authValue);
|
|
26
|
+
try {
|
|
27
|
+
const response = yield client
|
|
28
|
+
.api(`${client_1.outlookCommon.mailboxPrefix(authValue)}/messages?$top=50&$select=id,subject,from,receivedDateTime`)
|
|
29
|
+
.orderby('receivedDateTime desc')
|
|
30
|
+
.get();
|
|
31
|
+
const messages = response.value;
|
|
32
|
+
return {
|
|
33
|
+
disabled: false,
|
|
34
|
+
options: messages.map((message) => ({
|
|
35
|
+
label: `${message.subject || 'No Subject'}`,
|
|
36
|
+
value: message.id,
|
|
37
|
+
})),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
disabled: true,
|
|
43
|
+
options: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
exports.messageIdDropdown = messageIdDropdown;
|
|
49
|
+
const draftMessageIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
|
|
50
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
51
|
+
displayName: params.displayName,
|
|
52
|
+
description: params.description,
|
|
53
|
+
required: params.required,
|
|
54
|
+
refreshers: [],
|
|
55
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
56
|
+
if (!auth) {
|
|
57
|
+
return {
|
|
58
|
+
placeholder: 'Please connect your account first.',
|
|
59
|
+
disabled: true,
|
|
60
|
+
options: [],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const authValue = auth;
|
|
64
|
+
const client = client_1.outlookCommon.createClient(authValue);
|
|
65
|
+
try {
|
|
66
|
+
const response = yield client
|
|
67
|
+
.api(`${client_1.outlookCommon.mailboxPrefix(authValue)}/mailFolders/drafts/messages?$top=50&$select=id,subject,from,receivedDateTime`)
|
|
68
|
+
.orderby('receivedDateTime desc')
|
|
69
|
+
.get();
|
|
70
|
+
const messages = response.value;
|
|
71
|
+
return {
|
|
72
|
+
disabled: false,
|
|
73
|
+
options: messages.map((message) => ({
|
|
74
|
+
label: `${message.subject || 'No Subject'}`,
|
|
75
|
+
value: message.id,
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
return {
|
|
81
|
+
disabled: true,
|
|
82
|
+
options: [],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
exports.draftMessageIdDropdown = draftMessageIdDropdown;
|
|
88
|
+
const mailFolderIdDropdown = (params) => pieces_framework_1.Property.Dropdown({
|
|
89
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
90
|
+
displayName: params.displayName,
|
|
91
|
+
description: params.description,
|
|
92
|
+
required: params.required,
|
|
93
|
+
refreshers: [],
|
|
94
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
95
|
+
if (!auth) {
|
|
96
|
+
return {
|
|
97
|
+
placeholder: 'Please connect your account first.',
|
|
98
|
+
disabled: true,
|
|
99
|
+
options: [],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const authValue = auth;
|
|
103
|
+
const client = client_1.outlookCommon.createClient(authValue);
|
|
104
|
+
try {
|
|
105
|
+
const response = yield client.api(`${client_1.outlookCommon.mailboxPrefix(authValue)}/mailFolders`).get();
|
|
106
|
+
const folders = response.value;
|
|
107
|
+
return {
|
|
108
|
+
disabled: false,
|
|
109
|
+
options: folders.map((folder) => ({
|
|
110
|
+
label: folder.displayName || folder.id || 'Unknown',
|
|
111
|
+
value: folder.id || '',
|
|
112
|
+
})),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return {
|
|
117
|
+
disabled: true,
|
|
118
|
+
options: [],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
exports.mailFolderIdDropdown = mailFolderIdDropdown;
|
|
124
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,wGAAwG;AACxG,qEAAqE;AACrE,gEAA0E;AAG1E,iCAA8C;AAC9C,qCAAyC;AAQlC,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,I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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,SAAS,GAAG,IAA2B,CAAC;QAC9C,MAAM,MAAM,GAAG,sBAAa,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAErD,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAmB,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAa,CAAC,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,GAAG,EAAE,CAAC;YAEjH,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;AAtCS,QAAA,oBAAoB,wBAsC7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newAttachmentTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
4
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
attachmentNameFilter: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
attachmentNameFilter: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
11
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
12
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
attachmentNameFilter: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
15
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
16
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
attachmentNameFilter: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=new-attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-attachment.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-attachment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,eAAe,EAA4B,MAAM,2BAA2B,CAAC;AAwDpG,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;EAgG/B,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newAttachmentTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/microsoft-outlook/src/lib/triggers/new-attachment.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
|
+
const auth_1 = require("../common/auth");
|
|
10
|
+
const client_1 = require("../common/client");
|
|
11
|
+
const props_1 = require("../common/props");
|
|
12
|
+
const pieces_framework_2 = require("@agnocon/pieces-framework");
|
|
13
|
+
function enrichAttachments(client, mailboxPrefix, messages, files, nameFilter, senderFilter) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const attachments = [];
|
|
17
|
+
for (const message of messages) {
|
|
18
|
+
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())) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const attachmentResponse = yield client
|
|
22
|
+
.api(`${mailboxPrefix}/messages/${message.id}/attachments`)
|
|
23
|
+
.get();
|
|
24
|
+
for (const attachment of attachmentResponse.value) {
|
|
25
|
+
const { contentBytes } = attachment, rest = tslib_1.__rest(attachment, ["contentBytes"]);
|
|
26
|
+
if (nameFilter && attachment.name && !attachment.name.toLowerCase().includes(nameFilter.toLowerCase())) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (attachment.name && contentBytes) {
|
|
30
|
+
const file = yield files.write({
|
|
31
|
+
fileName: attachment.name,
|
|
32
|
+
data: Buffer.from(contentBytes, 'base64'),
|
|
33
|
+
});
|
|
34
|
+
attachments.push(Object.assign({ file, messageId: message.id, messageSubject: message.subject, messageSender: message.sender, messageReceivedDateTime: message.receivedDateTime, parentFolderId: message.parentFolderId }, rest));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return attachments;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.newAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
42
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
43
|
+
name: 'newAttachment',
|
|
44
|
+
displayName: 'New Attachment',
|
|
45
|
+
description: 'Triggers when a new email containing one or more attachments arrives.',
|
|
46
|
+
aiMetadata: {
|
|
47
|
+
description: 'Fires once per attachment when a new email carrying one or more file attachments arrives, optionally scoped to a folder, sender, or attachment-name filter. Each fire represents a single attachment from a newly received message.',
|
|
48
|
+
},
|
|
49
|
+
props: {
|
|
50
|
+
folderId: (0, props_1.mailFolderIdDropdown)({
|
|
51
|
+
displayName: 'Folder',
|
|
52
|
+
description: 'Monitor attachments in a specific folder. Leave empty to monitor all folders.',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
sender: pieces_framework_1.Property.ShortText({
|
|
56
|
+
displayName: 'From (Sender Email)',
|
|
57
|
+
description: 'Filter emails from a specific sender (optional). Leave empty to for all senders.',
|
|
58
|
+
required: false,
|
|
59
|
+
}),
|
|
60
|
+
attachmentNameFilter: pieces_framework_1.Property.ShortText({
|
|
61
|
+
displayName: 'Attachment Name Filter',
|
|
62
|
+
description: 'Filter attachments by name (contains). Leave empty to include all attachments.',
|
|
63
|
+
required: false,
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
sampleData: {},
|
|
67
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
68
|
+
onEnable(context) {
|
|
69
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
yield context.store.put('lastPoll', Date.now());
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
onDisable(context) {
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
// return
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
test(context) {
|
|
79
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const { folderId, attachmentNameFilter, sender } = context.propsValue;
|
|
81
|
+
const client = client_1.outlookCommon.createClient(context.auth);
|
|
82
|
+
const baseUrl = folderId ? `${client_1.outlookCommon.mailboxPrefix(context.auth)}/mailFolders/${folderId}/messages` : `${client_1.outlookCommon.mailboxPrefix(context.auth)}/messages`;
|
|
83
|
+
const response = yield client
|
|
84
|
+
.api(`${baseUrl}?$filter=hasAttachments eq true`)
|
|
85
|
+
.top(10)
|
|
86
|
+
.get();
|
|
87
|
+
const attachments = yield enrichAttachments(client, client_1.outlookCommon.mailboxPrefix(context.auth), response.value, context.files, attachmentNameFilter, sender);
|
|
88
|
+
const items = attachments.map((attachment) => ({
|
|
89
|
+
epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
|
|
90
|
+
data: attachment,
|
|
91
|
+
}));
|
|
92
|
+
return items.map((item) => item.data);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
run(context) {
|
|
96
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const lastFetchEpochMS = yield context.store.get('lastPoll');
|
|
98
|
+
if ((0, pieces_framework_2.isNil)(lastFetchEpochMS)) {
|
|
99
|
+
throw new Error("lastPoll doesn't exist in the store.");
|
|
100
|
+
}
|
|
101
|
+
const { folderId, attachmentNameFilter, sender } = context.propsValue;
|
|
102
|
+
const client = client_1.outlookCommon.createClient(context.auth);
|
|
103
|
+
const baseUrl = folderId ? `${client_1.outlookCommon.mailboxPrefix(context.auth)}/mailFolders/${folderId}/messages` : `${client_1.outlookCommon.mailboxPrefix(context.auth)}/messages`;
|
|
104
|
+
let response = yield client
|
|
105
|
+
.api(`${baseUrl}?$filter=receivedDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()} and hasAttachments eq true`)
|
|
106
|
+
.orderby('receivedDateTime desc')
|
|
107
|
+
.get();
|
|
108
|
+
const messages = [];
|
|
109
|
+
while (response.value.length > 0) {
|
|
110
|
+
messages.push(...response.value);
|
|
111
|
+
if (response['@odata.nextLink']) {
|
|
112
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const attachments = yield enrichAttachments(client, client_1.outlookCommon.mailboxPrefix(context.auth), messages, context.files, attachmentNameFilter, sender);
|
|
119
|
+
const items = attachments.map((attachment) => ({
|
|
120
|
+
epochMilliSeconds: (0, dayjs_1.default)(attachment['messageReceivedDateTime']).valueOf(),
|
|
121
|
+
data: attachment,
|
|
122
|
+
}));
|
|
123
|
+
const newLastEpochMilliSeconds = items.reduce((acc, item) => Math.max(acc, item.epochMilliSeconds), lastFetchEpochMS);
|
|
124
|
+
yield context.store.put('lastPoll', newLastEpochMilliSeconds);
|
|
125
|
+
return items.filter((f) => f.epochMilliSeconds > lastFetchEpochMS).map((item) => item.data);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=new-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-attachment.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-attachment.ts"],"names":[],"mappings":";;;;AAAA,mHAAmH;AACnH,qEAAqE;AACrE,gEAAoG;AAGpG,0DAA0B;AAC1B,yCAAsD;AACtD,6CAAiD;AACjD,2CAAuD;AACvD,gEAAkD;AAElD,SAAe,iBAAiB,CAC/B,MAAc,EACd,aAAqB,EACrB,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,GAAG,aAAa,aAAa,OAAO,CAAC,EAAE,cAAc,CAAC;iBAC1D,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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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,sBAAa,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC;YAEtJ,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newEmailInFolderTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
folderId: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>> | import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-email-in-folder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-email-in-folder.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-email-in-folder.ts"],"names":[],"mappings":"AAGA,OAAO,EAGN,eAAe,EAEf,MAAM,2BAA2B,CAAC;AAmDnC,eAAO,MAAM,uBAAuB;;;;;;;;EAqClC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newEmailInFolderTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/microsoft-outlook/src/lib/triggers/new-email-in-folder.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
8
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
9
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
10
|
+
const auth_1 = require("../common/auth");
|
|
11
|
+
const client_1 = require("../common/client");
|
|
12
|
+
const props_1 = require("../common/props");
|
|
13
|
+
const polling = {
|
|
14
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
15
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
|
|
16
|
+
const client = client_1.outlookCommon.createClient(auth);
|
|
17
|
+
const messages = [];
|
|
18
|
+
const folderId = propsValue.folderId;
|
|
19
|
+
const filter = lastFetchEpochMS === 0
|
|
20
|
+
? '$top=10'
|
|
21
|
+
: `$filter=createdDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()}`;
|
|
22
|
+
let response = yield client
|
|
23
|
+
.api(`${client_1.outlookCommon.mailboxPrefix(auth)}/mailFolders/${folderId}/messages?${filter}`)
|
|
24
|
+
.orderby('createdDateTime desc')
|
|
25
|
+
.get();
|
|
26
|
+
if (lastFetchEpochMS === 0) {
|
|
27
|
+
for (const message of response.value) {
|
|
28
|
+
messages.push(message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
while (response.value.length > 0) {
|
|
33
|
+
for (const message of response.value) {
|
|
34
|
+
messages.push(message);
|
|
35
|
+
}
|
|
36
|
+
if (response['@odata.nextLink']) {
|
|
37
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return messages.map((message) => ({
|
|
45
|
+
epochMilliSeconds: (0, dayjs_1.default)(message.createdDateTime).valueOf(),
|
|
46
|
+
data: message,
|
|
47
|
+
}));
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
exports.newEmailInFolderTrigger = (0, pieces_framework_1.createTrigger)({
|
|
51
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
52
|
+
name: 'newEmailInFolder',
|
|
53
|
+
displayName: 'New Email in Folder',
|
|
54
|
+
description: 'Triggers when a new email is delivered into the specified folder.',
|
|
55
|
+
aiMetadata: {
|
|
56
|
+
description: 'Fires when a new message appears in the chosen Outlook mail folder. Each fire represents one new email added to that folder.',
|
|
57
|
+
},
|
|
58
|
+
props: {
|
|
59
|
+
folderId: (0, props_1.mailFolderIdDropdown)({
|
|
60
|
+
displayName: 'Folder',
|
|
61
|
+
description: '',
|
|
62
|
+
required: true,
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
sampleData: {},
|
|
66
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
67
|
+
onEnable(context) {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
70
|
+
auth: context.auth,
|
|
71
|
+
store: context.store,
|
|
72
|
+
propsValue: context.propsValue,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
onDisable(context) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
79
|
+
auth: context.auth,
|
|
80
|
+
store: context.store,
|
|
81
|
+
propsValue: context.propsValue,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
test(context) {
|
|
86
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
run(context) {
|
|
91
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=new-email-in-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-email-in-folder.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-email-in-folder.ts"],"names":[],"mappings":";;;;AAAA,wHAAwH;AACxH,qEAAqE;AACrE,0DAAgF;AAChF,gEAKmC;AAGnC,0DAA0B;AAC1B,yCAAsD;AACtD,6CAAiD;AACjD,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,MAAM,GAAG,sBAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEhD,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QAErC,MAAM,MAAM,GACX,gBAAgB,KAAK,CAAC;YACrB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,8BAA8B,IA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IAClC,WAAW,EAAE,mEAAmE;IAChF,UAAU,EAAE;QACX,WAAW,EAAE,8HAA8H;KAC3I;IACD,KAAK,EAAE;QACN,QAAQ,EAAE,IAAA,4BAAoB,EAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,EAAE;YACf,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;IACD,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ,CAAC,OAAO;;YACrB,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC9B,CAAC,CAAC;QACJ,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACtB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;gBACtC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC9B,CAAC,CAAC;QACJ,CAAC;KAAA;IACK,IAAI,CAAC,OAAO;;YACjB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newEmailTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
recipient: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
6
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
recipient: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
recipient: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
11
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
12
|
+
sender: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
recipient: import("@agnocon/pieces-framework").ShortTextProperty<false>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=new-email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-email.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-email.ts"],"names":[],"mappings":"AAGA,OAAO,EAEN,eAAe,EAGf,MAAM,2BAA2B,CAAC;AA6EnC,eAAO,MAAM,eAAe;;;;;;;;;;;;EA0C1B,CAAC"}
|