@activepieces/piece-microsoft-sharepoint 0.0.18 → 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.
Files changed (59) hide show
  1. package/package.json +2 -2
  2. package/src/i18n/de.json +81 -6
  3. package/src/i18n/es.json +81 -6
  4. package/src/i18n/fr.json +81 -6
  5. package/src/i18n/ja.json +81 -6
  6. package/src/i18n/nl.json +81 -6
  7. package/src/i18n/pt.json +81 -6
  8. package/src/i18n/translation.json +81 -6
  9. package/src/i18n/zh.json +81 -6
  10. package/src/index.js +45 -10
  11. package/src/index.js.map +1 -1
  12. package/src/lib/actions/copy-item-within-site.d.ts +8 -0
  13. package/src/lib/actions/copy-item-within-site.js +154 -0
  14. package/src/lib/actions/copy-item-within-site.js.map +1 -0
  15. package/src/lib/actions/copy-item.d.ts +10 -0
  16. package/src/lib/actions/copy-item.js +118 -0
  17. package/src/lib/actions/copy-item.js.map +1 -0
  18. package/src/lib/actions/find-file.d.ts +8 -0
  19. package/src/lib/actions/find-file.js +132 -0
  20. package/src/lib/actions/find-file.js.map +1 -0
  21. package/src/lib/actions/get-folder-contents.d.ts +9 -0
  22. package/src/lib/actions/get-folder-contents.js +107 -0
  23. package/src/lib/actions/get-folder-contents.js.map +1 -0
  24. package/src/lib/actions/get-site-information.d.ts +4 -0
  25. package/src/lib/actions/get-site-information.js +38 -0
  26. package/src/lib/actions/get-site-information.js.map +1 -0
  27. package/src/lib/actions/move-file.d.ts +7 -0
  28. package/src/lib/actions/move-file.js +149 -0
  29. package/src/lib/actions/move-file.js.map +1 -0
  30. package/src/lib/actions/publish-page.d.ts +4 -0
  31. package/src/lib/actions/publish-page.js +52 -0
  32. package/src/lib/actions/publish-page.js.map +1 -0
  33. package/src/lib/common/index.d.ts +7 -0
  34. package/src/lib/common/index.js +152 -22
  35. package/src/lib/common/index.js.map +1 -1
  36. package/src/lib/triggers/new-file-in-folder.d.ts +14 -0
  37. package/src/lib/triggers/new-file-in-folder.js +154 -0
  38. package/src/lib/triggers/new-file-in-folder.js.map +1 -0
  39. package/src/lib/triggers/new-file-in-subfolders.d.ts +14 -0
  40. package/src/lib/triggers/new-file-in-subfolders.js +150 -0
  41. package/src/lib/triggers/new-file-in-subfolders.js.map +1 -0
  42. package/src/lib/triggers/new-list-item.d.ts +11 -0
  43. package/src/lib/triggers/new-list-item.js +108 -0
  44. package/src/lib/triggers/new-list-item.js.map +1 -0
  45. package/src/lib/triggers/new-list.d.ts +8 -0
  46. package/src/lib/triggers/new-list.js +101 -0
  47. package/src/lib/triggers/new-list.js.map +1 -0
  48. package/src/lib/triggers/new-or-updated-file.d.ts +14 -0
  49. package/src/lib/triggers/new-or-updated-file.js +150 -0
  50. package/src/lib/triggers/new-or-updated-file.js.map +1 -0
  51. package/src/lib/triggers/new-or-updated-folder.d.ts +14 -0
  52. package/src/lib/triggers/new-or-updated-folder.js +150 -0
  53. package/src/lib/triggers/new-or-updated-folder.js.map +1 -0
  54. package/src/lib/triggers/new-or-updated-list.d.ts +8 -0
  55. package/src/lib/triggers/new-or-updated-list.js +101 -0
  56. package/src/lib/triggers/new-or-updated-list.js.map +1 -0
  57. package/src/lib/triggers/updated-list-item.d.ts +11 -0
  58. package/src/lib/triggers/updated-list-item.js +108 -0
  59. package/src/lib/triggers/updated-list-item.js.map +1 -0
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newListTrigger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ const clientState = 'activepieces_sharepoint_new_list_trigger';
10
+ exports.newListTrigger = (0, pieces_framework_1.createTrigger)({
11
+ auth: __1.microsoftSharePointAuth,
12
+ name: 'new_list',
13
+ displayName: 'New List',
14
+ description: 'Fires when a new list is created in a site.',
15
+ props: {
16
+ siteId: common_1.microsoftSharePointCommon.siteId,
17
+ },
18
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
19
+ sampleData: {
20
+ "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
21
+ "displayName": "Asset Management",
22
+ "description": "A new list to track company assets.",
23
+ "createdDateTime": "2025-09-26T14:45:00Z",
24
+ "lastModifiedDateTime": "2025-09-26T14:45:00Z",
25
+ "webUrl": "https://contoso.sharepoint.com/sites/MySite/Lists/Asset%20Management"
26
+ },
27
+ onEnable(context) {
28
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ const { siteId } = context.propsValue;
30
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
31
+ authProvider: {
32
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
33
+ },
34
+ });
35
+ try {
36
+ const expirationDateTime = new Date();
37
+ expirationDateTime.setDate(expirationDateTime.getDate() + 2);
38
+ const subscription = yield client.api('/subscriptions').post({
39
+ changeType: 'created',
40
+ notificationUrl: context.webhookUrl,
41
+ resource: `/sites/${siteId}/lists`,
42
+ expirationDateTime: expirationDateTime.toISOString(),
43
+ clientState: clientState,
44
+ });
45
+ yield context.store.put('subscriptionId', subscription.id);
46
+ }
47
+ catch (error) {
48
+ throw new Error(`Failed to create subscription: ${error.message || 'Unknown error'}`);
49
+ }
50
+ });
51
+ },
52
+ onDisable(context) {
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
+ const subscriptionId = yield context.store.get('subscriptionId');
55
+ if (subscriptionId) {
56
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
57
+ authProvider: {
58
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
59
+ },
60
+ });
61
+ try {
62
+ yield client.api(`/subscriptions/${subscriptionId}`).delete();
63
+ }
64
+ catch (error) {
65
+ console.warn(`Error deleting subscription ${subscriptionId}:`, error);
66
+ }
67
+ }
68
+ yield context.store.delete('subscriptionId');
69
+ });
70
+ },
71
+ run(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ var _a;
74
+ const notifications = (_a = context.payload.body) === null || _a === void 0 ? void 0 : _a.value;
75
+ if (!notifications || !Array.isArray(notifications)) {
76
+ return [];
77
+ }
78
+ const validNotifications = notifications.filter((notif) => notif.clientState === clientState);
79
+ if (validNotifications.length === 0) {
80
+ return [];
81
+ }
82
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
83
+ authProvider: {
84
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
85
+ },
86
+ });
87
+ const newListPayloads = [];
88
+ for (const notification of validNotifications) {
89
+ try {
90
+ const newList = yield client.api(notification.resource).get();
91
+ newListPayloads.push(newList);
92
+ }
93
+ catch (error) {
94
+ console.error('Error fetching list from notification:', error);
95
+ }
96
+ }
97
+ return newListPayloads;
98
+ });
99
+ },
100
+ });
101
+ //# sourceMappingURL=new-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-list.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/triggers/new-list.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAIwC;AACxC,sCAAsD;AACtD,8EAA2D;AAE3D,MAAM,WAAW,GAAG,0CAA0C,CAAC;AAElD,QAAA,cAAc,GAAG,IAAA,gCAAa,EAAC;IAC1C,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;KACzC;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAE7B,UAAU,EAAE;QACV,IAAI,EAAE,sCAAsC;QAC5C,aAAa,EAAE,kBAAkB;QACjC,aAAa,EAAE,qCAAqC;QACpD,iBAAiB,EAAE,sBAAsB;QACzC,sBAAsB,EAAE,sBAAsB;QAC9C,QAAQ,EAAE,sEAAsE;KACjF;IAEK,QA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,GAAG,EAAE,CAAC;oBAC9D,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;gBACjE,CAAC;YACL,CAAC;YACD,OAAO,eAAe,CAAC;QACzB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newOrUpdatedFileTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
+ folderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
7
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
9
+ folderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
10
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
11
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
12
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
13
+ folderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
14
+ }>;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newOrUpdatedFileTrigger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ const clientState = 'activepieces_sharepoint_new_or_updated_trigger';
10
+ exports.newOrUpdatedFileTrigger = (0, pieces_framework_1.createTrigger)({
11
+ auth: __1.microsoftSharePointAuth,
12
+ name: 'new_or_updated_file',
13
+ displayName: 'New or Updated File',
14
+ description: 'Fires when a file is created or updated in a given folder.',
15
+ props: {
16
+ siteId: common_1.microsoftSharePointCommon.siteId,
17
+ driveId: common_1.microsoftSharePointCommon.driveId,
18
+ folderId: pieces_framework_1.Property.Dropdown({
19
+ displayName: 'Folder to Monitor',
20
+ description: 'The folder to watch for new or updated files. Select "Root Folder" for the top-level folder of the drive.',
21
+ required: true,
22
+ refreshers: ['siteId', 'driveId'],
23
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
24
+ if (!auth || !siteId || !driveId) {
25
+ return {
26
+ disabled: true,
27
+ placeholder: 'Select a site and drive first.',
28
+ options: [],
29
+ };
30
+ }
31
+ const authValue = auth;
32
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
33
+ authProvider: {
34
+ getAccessToken: () => Promise.resolve(authValue.access_token),
35
+ },
36
+ });
37
+ const options = [
38
+ { label: 'Root Folder', value: 'root' },
39
+ ];
40
+ let response = yield client
41
+ .api(`/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
42
+ .get();
43
+ while (response.value.length > 0) {
44
+ for (const item of response.value) {
45
+ options.push({ label: item.name, value: item.id });
46
+ }
47
+ if (response['@odata.nextLink']) {
48
+ response = yield client.api(response['@odata.nextLink']).get();
49
+ }
50
+ else {
51
+ break;
52
+ }
53
+ }
54
+ return { disabled: false, options };
55
+ }),
56
+ }),
57
+ },
58
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
59
+ sampleData: {
60
+ "id": "01DRYVE_ID_GOES_HERE",
61
+ "name": "Updated-Financials.xlsx",
62
+ "webUrl": "https://contoso.sharepoint.com/Shared%20Documents/Updated-Financials.xlsx",
63
+ "size": 65432,
64
+ "createdDateTime": "2025-09-26T10:00:00Z",
65
+ "lastModifiedDateTime": "2025-09-26T14:34:00Z",
66
+ "file": {
67
+ "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
68
+ },
69
+ "parentReference": { "id": "PARENT_FOLDER_ID_HERE" }
70
+ },
71
+ onEnable(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ const { siteId, driveId, folderId } = context.propsValue;
74
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
75
+ authProvider: {
76
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
77
+ },
78
+ });
79
+ try {
80
+ const effectiveFolderId = folderId === 'root'
81
+ ? (yield client.api(`/drives/${driveId}/root`).get()).id
82
+ : folderId;
83
+ const expirationDateTime = new Date();
84
+ expirationDateTime.setDate(expirationDateTime.getDate() + 2);
85
+ const subscription = yield client.api('/subscriptions').post({
86
+ changeType: 'created,updated',
87
+ notificationUrl: context.webhookUrl,
88
+ resource: `/sites/${siteId}/drive/items/${effectiveFolderId}/children`,
89
+ expirationDateTime: expirationDateTime.toISOString(),
90
+ clientState: clientState,
91
+ });
92
+ yield context.store.put('subscriptionId', subscription.id);
93
+ }
94
+ catch (error) {
95
+ throw new Error(`Failed to create subscription: ${error.message || 'Unknown error'}`);
96
+ }
97
+ });
98
+ },
99
+ onDisable(context) {
100
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
101
+ const subscriptionId = yield context.store.get('subscriptionId');
102
+ if (subscriptionId) {
103
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
104
+ authProvider: {
105
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
106
+ },
107
+ });
108
+ try {
109
+ yield client.api(`/subscriptions/${subscriptionId}`).delete();
110
+ }
111
+ catch (error) {
112
+ console.warn(`Error deleting subscription ${subscriptionId}:`, error);
113
+ }
114
+ }
115
+ yield context.store.delete('subscriptionId');
116
+ });
117
+ },
118
+ run(context) {
119
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
120
+ var _a;
121
+ const notifications = (_a = context.payload.body) === null || _a === void 0 ? void 0 : _a.value;
122
+ if (!notifications || !Array.isArray(notifications)) {
123
+ return [];
124
+ }
125
+ const validNotifications = notifications.filter((notif) => notif.clientState === clientState);
126
+ if (validNotifications.length === 0) {
127
+ return [];
128
+ }
129
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
130
+ authProvider: {
131
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
132
+ },
133
+ });
134
+ const changedFilePayloads = [];
135
+ for (const notification of validNotifications) {
136
+ try {
137
+ const changedFile = yield client.api(notification.resource).get();
138
+ if (changedFile.file) {
139
+ changedFilePayloads.push(changedFile);
140
+ }
141
+ }
142
+ catch (error) {
143
+ console.error('Error fetching file from notification:', error);
144
+ }
145
+ }
146
+ return changedFilePayloads;
147
+ });
148
+ },
149
+ });
150
+ //# sourceMappingURL=new-or-updated-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-or-updated-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/triggers/new-or-updated-file.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAMwC;AACxC,sCAAsD;AACtD,8EAA2E;AAG3E,MAAM,WAAW,GAAG,gDAAgD,CAAC;AAExD,QAAA,uBAAuB,GAAG,IAAA,gCAAa,EAAC;IACnD,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,mBAAmB;YAChC,WAAW,EAAE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AC,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACpD,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,kBAAkB,GAAG,aAAa,CAAC,MAAM,CAC7C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAC7C,CAAC;YACF,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACrC,YAAY,EAAE;oBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBACjE;aACF,CAAC,CAAC;YAEL,MAAM,mBAAmB,GAAG,EAAE,CAAC;YAC/B,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;gBAC5C,IAAI,CAAC;oBACH,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;oBAClE,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;wBACnB,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC1C,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;gBACjE,CAAC;YACL,CAAC;YACD,OAAO,mBAAmB,CAAC;QAC7B,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newOrUpdatedFolderTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
+ parentFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
7
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
9
+ parentFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
10
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
11
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
12
+ driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
13
+ parentFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
14
+ }>;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newOrUpdatedFolderTrigger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ const clientState = 'activepieces_sharepoint_new_or_updated_folder_trigger';
10
+ exports.newOrUpdatedFolderTrigger = (0, pieces_framework_1.createTrigger)({
11
+ auth: __1.microsoftSharePointAuth,
12
+ name: 'new_or_updated_folder',
13
+ displayName: 'New or Updated Folder',
14
+ description: 'Fires when a folder is created or updated (e.g., name change).',
15
+ props: {
16
+ siteId: common_1.microsoftSharePointCommon.siteId,
17
+ driveId: common_1.microsoftSharePointCommon.driveId,
18
+ parentFolderId: pieces_framework_1.Property.Dropdown({
19
+ displayName: 'Parent Folder to Monitor',
20
+ description: 'The folder to watch for new or updated subfolders. Select "Root Folder" to monitor the top-level of the drive.',
21
+ required: true,
22
+ refreshers: ['siteId', 'driveId'],
23
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
24
+ if (!auth || !siteId || !driveId) {
25
+ return {
26
+ disabled: true,
27
+ placeholder: 'Select a site and drive first.',
28
+ options: [],
29
+ };
30
+ }
31
+ const authValue = auth;
32
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
33
+ authProvider: {
34
+ getAccessToken: () => Promise.resolve(authValue.access_token),
35
+ },
36
+ });
37
+ const options = [
38
+ { label: 'Root Folder', value: 'root' },
39
+ ];
40
+ let response = yield client
41
+ .api(`/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
42
+ .get();
43
+ while (response.value.length > 0) {
44
+ for (const item of response.value) {
45
+ options.push({ label: item.name, value: item.id });
46
+ }
47
+ if (response['@odata.nextLink']) {
48
+ response = yield client.api(response['@odata.nextLink']).get();
49
+ }
50
+ else {
51
+ break;
52
+ }
53
+ }
54
+ return { disabled: false, options };
55
+ }),
56
+ }),
57
+ },
58
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
59
+ sampleData: {
60
+ "id": "01DRYVE_FOLDER_ID_GOES_HERE",
61
+ "name": "Project Alpha",
62
+ "webUrl": "https://contoso.sharepoint.com/Shared%20Documents/Project%20Alpha",
63
+ "size": 0,
64
+ "createdDateTime": "2025-09-26T14:50:00Z",
65
+ "lastModifiedDateTime": "2025-09-26T14:50:00Z",
66
+ "folder": {
67
+ "childCount": 0
68
+ },
69
+ "parentReference": { "id": "PARENT_FOLDER_ID_HERE" }
70
+ },
71
+ onEnable(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ const { siteId, driveId, parentFolderId } = context.propsValue;
74
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
75
+ authProvider: {
76
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
77
+ },
78
+ });
79
+ try {
80
+ const effectiveParentId = parentFolderId === 'root'
81
+ ? (yield client.api(`/drives/${driveId}/root`).get()).id
82
+ : parentFolderId;
83
+ const expirationDateTime = new Date();
84
+ expirationDateTime.setDate(expirationDateTime.getDate() + 2);
85
+ const subscription = yield client.api('/subscriptions').post({
86
+ changeType: 'created,updated',
87
+ notificationUrl: context.webhookUrl,
88
+ resource: `/sites/${siteId}/drive/items/${effectiveParentId}/children`,
89
+ expirationDateTime: expirationDateTime.toISOString(),
90
+ clientState: clientState,
91
+ });
92
+ yield context.store.put('subscriptionId', subscription.id);
93
+ }
94
+ catch (error) {
95
+ throw new Error(`Failed to create subscription: ${error.message || 'Unknown error'}`);
96
+ }
97
+ });
98
+ },
99
+ onDisable(context) {
100
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
101
+ const subscriptionId = yield context.store.get('subscriptionId');
102
+ if (subscriptionId) {
103
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
104
+ authProvider: {
105
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
106
+ },
107
+ });
108
+ try {
109
+ yield client.api(`/subscriptions/${subscriptionId}`).delete();
110
+ }
111
+ catch (error) {
112
+ console.warn(`Error deleting subscription ${subscriptionId}:`, error);
113
+ }
114
+ }
115
+ yield context.store.delete('subscriptionId');
116
+ });
117
+ },
118
+ run(context) {
119
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
120
+ var _a;
121
+ const notifications = (_a = context.payload.body) === null || _a === void 0 ? void 0 : _a.value;
122
+ if (!notifications || !Array.isArray(notifications)) {
123
+ return [];
124
+ }
125
+ const validNotifications = notifications.filter((notif) => notif.clientState === clientState);
126
+ if (validNotifications.length === 0) {
127
+ return [];
128
+ }
129
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
130
+ authProvider: {
131
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
132
+ },
133
+ });
134
+ const folderPayloads = [];
135
+ for (const notification of validNotifications) {
136
+ try {
137
+ const changedItem = yield client.api(notification.resource).get();
138
+ if (changedItem.folder) {
139
+ folderPayloads.push(changedItem);
140
+ }
141
+ }
142
+ catch (error) {
143
+ console.error('Error fetching folder from notification:', error);
144
+ }
145
+ }
146
+ return folderPayloads;
147
+ });
148
+ },
149
+ });
150
+ //# sourceMappingURL=new-or-updated-folder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-or-updated-folder.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/triggers/new-or-updated-folder.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAMwC;AACxC,sCAAsD;AACtD,8EAA2E;AAG3E,MAAM,WAAW,GAAG,uDAAuD,CAAC;AAE/D,QAAA,yBAAyB,GAAG,IAAA,gCAAa,EAAC;IACrD,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,gEAAgE;IAC7E,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,cAAc,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAChC,WAAW,EAAE,0BAA0B;YACvC,WAAW,EAAE,gHAAgH;YAC7H,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;YACjC,OAAO,EAAE,KAAkC,EAAE,oDAA7B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;gBACvC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjC,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,gCAAgC;wBAC7C,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBACD,MAAM,SAAS,GAAG,IAEjB,CAAC;gBACF,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;oBACvC,YAA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AAC,IAAI,CAAC,YAAY,CAAC;iBACjE;aACJ,CAAC,CAAC;YAEH,MAAM,cAAc,GAAG,EAAE,CAAC;YAC1B,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;gBAC5C,IAAI,CAAC;oBACH,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;oBAClE,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;wBACrB,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;gBACnE,CAAC;YACL,CAAC;YACD,OAAO,cAAc,CAAC;QACxB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newOrUpdatedListTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
5
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
7
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ }>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newOrUpdatedListTrigger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const __1 = require("../../");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
9
+ const clientState = 'activepieces_sharepoint_new_or_updated_list_trigger';
10
+ exports.newOrUpdatedListTrigger = (0, pieces_framework_1.createTrigger)({
11
+ auth: __1.microsoftSharePointAuth,
12
+ name: 'new_or_updated_list',
13
+ displayName: 'New or Updated List',
14
+ description: 'Fires when a list is created or updated in a site.',
15
+ props: {
16
+ siteId: common_1.microsoftSharePointCommon.siteId,
17
+ },
18
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
19
+ sampleData: {
20
+ "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
21
+ "displayName": "Projects Tracker",
22
+ "description": "Updated list for tracking all ongoing projects.",
23
+ "createdDateTime": "2025-09-26T11:00:00Z",
24
+ "lastModifiedDateTime": "2025-09-26T14:55:00Z",
25
+ "webUrl": "https://contoso.sharepoint.com/sites/MySite/Lists/Projects%20Tracker"
26
+ },
27
+ onEnable(context) {
28
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ const { siteId } = context.propsValue;
30
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
31
+ authProvider: {
32
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
33
+ },
34
+ });
35
+ try {
36
+ const expirationDateTime = new Date();
37
+ expirationDateTime.setDate(expirationDateTime.getDate() + 2);
38
+ const subscription = yield client.api('/subscriptions').post({
39
+ changeType: 'created,updated',
40
+ notificationUrl: context.webhookUrl,
41
+ resource: `/sites/${siteId}/lists`,
42
+ expirationDateTime: expirationDateTime.toISOString(),
43
+ clientState: clientState,
44
+ });
45
+ yield context.store.put('subscriptionId', subscription.id);
46
+ }
47
+ catch (error) {
48
+ throw new Error(`Failed to create subscription: ${error.message || 'Unknown error'}`);
49
+ }
50
+ });
51
+ },
52
+ onDisable(context) {
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
54
+ const subscriptionId = yield context.store.get('subscriptionId');
55
+ if (subscriptionId) {
56
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
57
+ authProvider: {
58
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
59
+ },
60
+ });
61
+ try {
62
+ yield client.api(`/subscriptions/${subscriptionId}`).delete();
63
+ }
64
+ catch (error) {
65
+ console.warn(`Error deleting subscription ${subscriptionId}:`, error);
66
+ }
67
+ }
68
+ yield context.store.delete('subscriptionId');
69
+ });
70
+ },
71
+ run(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ var _a;
74
+ const notifications = (_a = context.payload.body) === null || _a === void 0 ? void 0 : _a.value;
75
+ if (!notifications || !Array.isArray(notifications)) {
76
+ return [];
77
+ }
78
+ const validNotifications = notifications.filter((notif) => notif.clientState === clientState);
79
+ if (validNotifications.length === 0) {
80
+ return [];
81
+ }
82
+ const client = microsoft_graph_client_1.Client.initWithMiddleware({
83
+ authProvider: {
84
+ getAccessToken: () => Promise.resolve(context.auth.access_token),
85
+ },
86
+ });
87
+ const listPayloads = [];
88
+ for (const notification of validNotifications) {
89
+ try {
90
+ const changedList = yield client.api(notification.resource).get();
91
+ listPayloads.push(changedList);
92
+ }
93
+ catch (error) {
94
+ console.error('Error fetching list from notification:', error);
95
+ }
96
+ }
97
+ return listPayloads;
98
+ });
99
+ },
100
+ });
101
+ //# sourceMappingURL=new-or-updated-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-or-updated-list.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/triggers/new-or-updated-list.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAIwC;AACxC,sCAAsD;AACtD,8EAA2D;AAE3D,MAAM,WAAW,GAAG,qDAAqD,CAAC;AAE7D,QAAA,uBAAuB,GAAG,IAAA,gCAAa,EAAC;IACnD,IAAI,EAAE,2BAAuB;IAC7B,IAAI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M,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACrC,YAAY,EAAE;oBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBACjE;aACJ,CAAC,CAAC;YAEH,MAAM,YAAY,GAAG,EAAE,CAAC;YACxB,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;gBAC5C,IAAI,CAAC;oBACH,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;oBAClE,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;gBACjE,CAAC;YACL,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const updatedListItemTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
4
+ listId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
6
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
7
+ listId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
8
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
9
+ siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
10
+ listId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
11
+ }>;