@activepieces/piece-microsoft-sharepoint 0.1.2 → 0.2.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.
- package/package.json +10 -15
- package/src/i18n/translation.json +5 -5
- package/src/lib/actions/copy-item-within-site.d.ts +4 -4
- package/src/lib/actions/copy-item-within-site.js +1 -0
- package/src/lib/actions/copy-item-within-site.js.map +1 -1
- package/src/lib/actions/copy-item.d.ts +6 -6
- package/src/lib/actions/create-folder.d.ts +2 -2
- package/src/lib/actions/create-list-item.d.ts +3 -3
- package/src/lib/actions/create-list.d.ts +1 -1
- package/src/lib/actions/delete-list-item.d.ts +3 -3
- package/src/lib/actions/find-file.d.ts +3 -3
- package/src/lib/actions/find-file.js +1 -0
- package/src/lib/actions/find-file.js.map +1 -1
- package/src/lib/actions/get-folder-contents.d.ts +3 -3
- package/src/lib/actions/get-folder-contents.js +1 -0
- package/src/lib/actions/get-folder-contents.js.map +1 -1
- package/src/lib/actions/get-site-information.d.ts +1 -1
- package/src/lib/actions/move-file.d.ts +4 -4
- package/src/lib/actions/move-file.js +2 -0
- package/src/lib/actions/move-file.js.map +1 -1
- package/src/lib/actions/publish-page.d.ts +2 -2
- package/src/lib/actions/search-list-item.d.ts +2 -2
- package/src/lib/actions/update-list-item.d.ts +4 -4
- package/src/lib/actions/upload-file.d.ts +2 -2
- package/src/lib/common/index.d.ts +9 -9
- package/src/lib/common/index.js +9 -0
- package/src/lib/common/index.js.map +1 -1
- package/src/lib/triggers/new-file-in-folder.d.ts +9 -9
- package/src/lib/triggers/new-file-in-folder.js +1 -0
- package/src/lib/triggers/new-file-in-folder.js.map +1 -1
- package/src/lib/triggers/new-file-in-subfolders.d.ts +9 -9
- package/src/lib/triggers/new-file-in-subfolders.js +1 -0
- package/src/lib/triggers/new-file-in-subfolders.js.map +1 -1
- package/src/lib/triggers/new-list-item.d.ts +6 -6
- package/src/lib/triggers/new-list-item.js +64 -77
- package/src/lib/triggers/new-list-item.js.map +1 -1
- package/src/lib/triggers/new-list.d.ts +3 -3
- package/src/lib/triggers/new-list.js +59 -71
- package/src/lib/triggers/new-list.js.map +1 -1
- package/src/lib/triggers/new-or-updated-file.d.ts +9 -9
- package/src/lib/triggers/new-or-updated-file.js +83 -81
- package/src/lib/triggers/new-or-updated-file.js.map +1 -1
- package/src/lib/triggers/new-or-updated-folder.d.ts +9 -9
- package/src/lib/triggers/new-or-updated-folder.js +83 -81
- package/src/lib/triggers/new-or-updated-folder.js.map +1 -1
- package/src/lib/triggers/new-or-updated-list.d.ts +3 -3
- package/src/lib/triggers/new-or-updated-list.js +71 -69
- package/src/lib/triggers/new-or-updated-list.js.map +1 -1
- package/src/lib/triggers/updated-list-item.d.ts +6 -6
|
@@ -6,95 +6,97 @@ const __1 = require("../../");
|
|
|
6
6
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
-
const
|
|
9
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS }) {
|
|
14
|
+
const { siteId } = propsValue;
|
|
15
|
+
const isTestMode = lastFetchEpochMS === 0;
|
|
16
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
17
|
+
authProvider: {
|
|
18
|
+
getAccessToken: () => Promise.resolve(auth.access_token),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const lists = [];
|
|
22
|
+
let response = yield client
|
|
23
|
+
.api(`/sites/${siteId}/lists`)
|
|
24
|
+
.get();
|
|
25
|
+
let stop = false;
|
|
26
|
+
while (!stop && response.value.length > 0) {
|
|
27
|
+
for (const item of response.value) {
|
|
28
|
+
const modifiedMs = (0, dayjs_1.default)(item.lastModifiedDateTime).valueOf();
|
|
29
|
+
if (isTestMode) {
|
|
30
|
+
lists.push(item);
|
|
31
|
+
if (lists.length >= 10) {
|
|
32
|
+
stop = true;
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (modifiedMs < lastFetchEpochMS) {
|
|
37
|
+
stop = true;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
lists.push(item);
|
|
41
|
+
}
|
|
42
|
+
if (stop || !response['@odata.nextLink'])
|
|
43
|
+
break;
|
|
44
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
45
|
+
}
|
|
46
|
+
lists.sort((a, b) => {
|
|
47
|
+
const aDate = (0, dayjs_1.default)(a.lastModifiedDateTime);
|
|
48
|
+
const bDate = (0, dayjs_1.default)(b.lastModifiedDateTime);
|
|
49
|
+
return bDate.diff(aDate);
|
|
50
|
+
});
|
|
51
|
+
return lists.map((list) => ({
|
|
52
|
+
epochMilliSeconds: (0, dayjs_1.default)(list.lastModifiedDateTime).valueOf(),
|
|
53
|
+
data: list,
|
|
54
|
+
}));
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
10
57
|
exports.newOrUpdatedListTrigger = (0, pieces_framework_1.createTrigger)({
|
|
11
58
|
auth: __1.microsoftSharePointAuth,
|
|
12
59
|
name: 'new_or_updated_list',
|
|
13
60
|
displayName: 'New or Updated List',
|
|
14
|
-
description: '
|
|
61
|
+
description: 'Triggers when a list is created or updated in a site.',
|
|
15
62
|
props: {
|
|
16
63
|
siteId: common_1.microsoftSharePointCommon.siteId,
|
|
17
64
|
},
|
|
18
|
-
type: pieces_framework_1.TriggerStrategy.
|
|
65
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
19
66
|
sampleData: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
67
|
+
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
68
|
+
displayName: 'Projects Tracker',
|
|
69
|
+
description: 'Updated list for tracking all ongoing projects.',
|
|
70
|
+
createdDateTime: '2025-09-26T11:00:00Z',
|
|
71
|
+
lastModifiedDateTime: '2025-09-26T14:55:00Z',
|
|
72
|
+
webUrl: 'https://contoso.sharepoint.com/sites/MySite/Lists/Projects%20Tracker',
|
|
26
73
|
},
|
|
27
74
|
onEnable(context) {
|
|
28
75
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
76
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
77
|
+
auth: context.auth,
|
|
78
|
+
store: context.store,
|
|
79
|
+
propsValue: context.propsValue,
|
|
34
80
|
});
|
|
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
81
|
});
|
|
51
82
|
},
|
|
52
83
|
onDisable(context) {
|
|
53
84
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.warn(`Error deleting subscription ${subscriptionId}:`, error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
yield context.store.delete('subscriptionId');
|
|
85
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
86
|
+
auth: context.auth,
|
|
87
|
+
store: context.store,
|
|
88
|
+
propsValue: context.propsValue,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
test(context) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
69
95
|
});
|
|
70
96
|
},
|
|
71
97
|
run(context) {
|
|
72
98
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
|
|
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;
|
|
99
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
98
100
|
});
|
|
99
101
|
},
|
|
100
102
|
});
|
|
@@ -1 +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,
|
|
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,8EAA2E;AAC3E,+DAAqF;AACrF,0DAA0B;AAO1B,MAAM,OAAO,GAAsF;IAClG,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE;QACnD,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;QAC9B,MAAM,UAAU,GAAG,gBAAgB,KAAK,CAAC,CAAC;QAE1C,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;SACD,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,EAAE,CAAC;QAEjB,IAAI,QAAQ,GAAmB,MAAM,MAAM;aACzC,GAAG,CAAC,UAAU,MAAM,QAAQ,CAAC;aAC7B,GAAG,EAAE,CAAC;QAER,IAAI,IAAI,GAAG,KAAK,CAAC;QAEjB,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAe,EAAE,CAAC;gBAC7C,MAAM,UAAU,GAAG,IAAA,eAAK,EAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;g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AuD;IACpE,KAAK,EAAE;QACN,MAAM,EAAE,kCAAyB,CAAC,MAAM;KACxC;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IAE7B,UAAU,EAAE;QACX,EAAE,EAAE,sCAAsC;QAC1C,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,iDAAiD;QAC9D,eAAe,EAAE,sBAAsB;QACvC,oBAAoB,EAAE,sBAAsB;QAC5C,MAAM,EAAE,sEAAsE;KAC9E;IACK,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"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
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
|
|
3
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
4
|
+
listId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
5
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
|
|
6
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
7
|
+
listId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
8
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
|
|
9
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
10
|
+
listId: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
11
11
|
}>;
|