@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.
- package/package.json +2 -2
- package/src/i18n/de.json +81 -6
- package/src/i18n/es.json +81 -6
- package/src/i18n/fr.json +81 -6
- package/src/i18n/ja.json +81 -6
- package/src/i18n/nl.json +81 -6
- package/src/i18n/pt.json +81 -6
- package/src/i18n/translation.json +81 -6
- package/src/i18n/zh.json +81 -6
- package/src/index.js +45 -10
- package/src/index.js.map +1 -1
- package/src/lib/actions/copy-item-within-site.d.ts +8 -0
- package/src/lib/actions/copy-item-within-site.js +154 -0
- package/src/lib/actions/copy-item-within-site.js.map +1 -0
- package/src/lib/actions/copy-item.d.ts +10 -0
- package/src/lib/actions/copy-item.js +118 -0
- package/src/lib/actions/copy-item.js.map +1 -0
- package/src/lib/actions/find-file.d.ts +8 -0
- package/src/lib/actions/find-file.js +132 -0
- package/src/lib/actions/find-file.js.map +1 -0
- package/src/lib/actions/get-folder-contents.d.ts +9 -0
- package/src/lib/actions/get-folder-contents.js +107 -0
- package/src/lib/actions/get-folder-contents.js.map +1 -0
- package/src/lib/actions/get-site-information.d.ts +4 -0
- package/src/lib/actions/get-site-information.js +38 -0
- package/src/lib/actions/get-site-information.js.map +1 -0
- package/src/lib/actions/move-file.d.ts +7 -0
- package/src/lib/actions/move-file.js +149 -0
- package/src/lib/actions/move-file.js.map +1 -0
- package/src/lib/actions/publish-page.d.ts +4 -0
- package/src/lib/actions/publish-page.js +52 -0
- package/src/lib/actions/publish-page.js.map +1 -0
- package/src/lib/common/index.d.ts +7 -0
- package/src/lib/common/index.js +152 -22
- package/src/lib/common/index.js.map +1 -1
- package/src/lib/triggers/new-file-in-folder.d.ts +14 -0
- package/src/lib/triggers/new-file-in-folder.js +154 -0
- package/src/lib/triggers/new-file-in-folder.js.map +1 -0
- package/src/lib/triggers/new-file-in-subfolders.d.ts +14 -0
- package/src/lib/triggers/new-file-in-subfolders.js +150 -0
- package/src/lib/triggers/new-file-in-subfolders.js.map +1 -0
- package/src/lib/triggers/new-list-item.d.ts +11 -0
- package/src/lib/triggers/new-list-item.js +108 -0
- package/src/lib/triggers/new-list-item.js.map +1 -0
- package/src/lib/triggers/new-list.d.ts +8 -0
- package/src/lib/triggers/new-list.js +101 -0
- package/src/lib/triggers/new-list.js.map +1 -0
- package/src/lib/triggers/new-or-updated-file.d.ts +14 -0
- package/src/lib/triggers/new-or-updated-file.js +150 -0
- package/src/lib/triggers/new-or-updated-file.js.map +1 -0
- package/src/lib/triggers/new-or-updated-folder.d.ts +14 -0
- package/src/lib/triggers/new-or-updated-folder.js +150 -0
- package/src/lib/triggers/new-or-updated-folder.js.map +1 -0
- package/src/lib/triggers/new-or-updated-list.d.ts +8 -0
- package/src/lib/triggers/new-or-updated-list.js +101 -0
- package/src/lib/triggers/new-or-updated-list.js.map +1 -0
- package/src/lib/triggers/updated-list-item.d.ts +11 -0
- package/src/lib/triggers/updated-list-item.js +108 -0
- package/src/lib/triggers/updated-list-item.js.map +1 -0
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.microsoftSharePoint = exports.microsoftSharePointAuth = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
6
|
const shared_1 = require("@activepieces/shared");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
8
|
const create_folder_1 = require("./lib/actions/create-folder");
|
|
8
9
|
const create_list_1 = require("./lib/actions/create-list");
|
|
9
10
|
const create_list_item_1 = require("./lib/actions/create-list-item");
|
|
@@ -11,7 +12,21 @@ const update_list_item_1 = require("./lib/actions/update-list-item");
|
|
|
11
12
|
const delete_list_item_1 = require("./lib/actions/delete-list-item");
|
|
12
13
|
const search_list_item_1 = require("./lib/actions/search-list-item");
|
|
13
14
|
const upload_file_1 = require("./lib/actions/upload-file");
|
|
14
|
-
const
|
|
15
|
+
const publish_page_1 = require("./lib/actions/publish-page");
|
|
16
|
+
const copy_item_1 = require("./lib/actions/copy-item");
|
|
17
|
+
const copy_item_within_site_1 = require("./lib/actions/copy-item-within-site");
|
|
18
|
+
const move_file_1 = require("./lib/actions/move-file");
|
|
19
|
+
const find_file_1 = require("./lib/actions/find-file");
|
|
20
|
+
const get_folder_contents_1 = require("./lib/actions/get-folder-contents");
|
|
21
|
+
const get_site_information_1 = require("./lib/actions/get-site-information");
|
|
22
|
+
const new_file_in_folder_1 = require("./lib/triggers/new-file-in-folder");
|
|
23
|
+
const new_file_in_subfolders_1 = require("./lib/triggers/new-file-in-subfolders");
|
|
24
|
+
const new_or_updated_file_1 = require("./lib/triggers/new-or-updated-file");
|
|
25
|
+
const new_or_updated_folder_1 = require("./lib/triggers/new-or-updated-folder");
|
|
26
|
+
const new_list_item_1 = require("./lib/triggers/new-list-item");
|
|
27
|
+
const updated_list_item_1 = require("./lib/triggers/updated-list-item");
|
|
28
|
+
const new_list_1 = require("./lib/triggers/new-list");
|
|
29
|
+
const new_or_updated_list_1 = require("./lib/triggers/new-or-updated-list");
|
|
15
30
|
const authDesc = `
|
|
16
31
|
1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).
|
|
17
32
|
2. From the left sidebar, go to **Microsoft Enfra ID**.
|
|
@@ -30,14 +45,16 @@ const authDesc = `
|
|
|
30
45
|
- Copy the **Value** of the client secret (this will not be shown again).
|
|
31
46
|
11. Go to **API permissions** from the left menu.
|
|
32
47
|
- Click **Add a permission**.
|
|
33
|
-
- Select **
|
|
34
|
-
- Add the following
|
|
35
|
-
|
|
36
|
-
-
|
|
48
|
+
- Select **Microsoft Graph**.
|
|
49
|
+
- Add the following **Delegated permissions**:
|
|
50
|
+
- Sites.Read.All
|
|
51
|
+
- Sites.ReadWrite.All
|
|
52
|
+
- Sites.Manage.All
|
|
53
|
+
- Files.ReadWrite.All
|
|
37
54
|
- openid
|
|
38
55
|
- email
|
|
39
56
|
- profile
|
|
40
|
-
|
|
57
|
+
- offline_access
|
|
41
58
|
- Click **Add permissions**.
|
|
42
59
|
12. Copy your **Client ID** and **Client Secret**.
|
|
43
60
|
`;
|
|
@@ -51,8 +68,10 @@ exports.microsoftSharePointAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
|
51
68
|
'email',
|
|
52
69
|
'profile',
|
|
53
70
|
'offline_access',
|
|
71
|
+
'Sites.Read.All',
|
|
72
|
+
'Sites.ReadWrite.All',
|
|
54
73
|
'Sites.Manage.All',
|
|
55
|
-
'Files.ReadWrite',
|
|
74
|
+
'Files.ReadWrite.All',
|
|
56
75
|
],
|
|
57
76
|
prompt: 'omit'
|
|
58
77
|
});
|
|
@@ -62,7 +81,7 @@ exports.microsoftSharePoint = (0, pieces_framework_1.createPiece)({
|
|
|
62
81
|
minimumSupportedRelease: '0.27.1',
|
|
63
82
|
logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-sharepoint.png',
|
|
64
83
|
categories: [shared_1.PieceCategory.CONTENT_AND_FILES],
|
|
65
|
-
authors: ['kishanprmr'],
|
|
84
|
+
authors: ['kishanprmr', 'pranith124', 'onyedikachi-david'],
|
|
66
85
|
actions: [
|
|
67
86
|
create_folder_1.createFolderAction,
|
|
68
87
|
create_list_1.createListAction,
|
|
@@ -71,9 +90,16 @@ exports.microsoftSharePoint = (0, pieces_framework_1.createPiece)({
|
|
|
71
90
|
delete_list_item_1.deleteListItemAction,
|
|
72
91
|
search_list_item_1.findListItemAction,
|
|
73
92
|
upload_file_1.uploadFile,
|
|
93
|
+
publish_page_1.publishPageAction,
|
|
94
|
+
copy_item_1.copyItemAction,
|
|
95
|
+
copy_item_within_site_1.copyItemWithinSiteAction,
|
|
96
|
+
move_file_1.moveFileAction,
|
|
97
|
+
find_file_1.findFileAction,
|
|
98
|
+
get_folder_contents_1.getFolderContentsAction,
|
|
99
|
+
get_site_information_1.getSiteInformationAction,
|
|
74
100
|
(0, pieces_common_1.createCustomApiCallAction)({
|
|
75
101
|
auth: exports.microsoftSharePointAuth,
|
|
76
|
-
baseUrl: () => 'https://graph.microsoft.com/v1.0
|
|
102
|
+
baseUrl: () => 'https://graph.microsoft.com/v1.0',
|
|
77
103
|
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
78
104
|
return ({
|
|
79
105
|
Authorization: `Bearer ${auth.access_token}`,
|
|
@@ -81,6 +107,15 @@ exports.microsoftSharePoint = (0, pieces_framework_1.createPiece)({
|
|
|
81
107
|
}),
|
|
82
108
|
}),
|
|
83
109
|
],
|
|
84
|
-
triggers: [
|
|
110
|
+
triggers: [
|
|
111
|
+
new_file_in_folder_1.newFileInFolderTrigger,
|
|
112
|
+
new_file_in_subfolders_1.newFileInSubfoldersTrigger,
|
|
113
|
+
new_or_updated_file_1.newOrUpdatedFileTrigger,
|
|
114
|
+
new_or_updated_folder_1.newOrUpdatedFolderTrigger,
|
|
115
|
+
new_list_item_1.newListItemTrigger,
|
|
116
|
+
updated_list_item_1.updatedListItemTrigger,
|
|
117
|
+
new_list_1.newListTrigger,
|
|
118
|
+
new_or_updated_list_1.newOrUpdatedListTrigger,
|
|
119
|
+
],
|
|
85
120
|
});
|
|
86
121
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-sharepoint/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,+DAAiE;AACjE,2DAA6D;AAC7D,qEAAsE;AACtE,qEAAsE;AACtE,qEAAsE;AACtE,qEAAoE;AACpE,2DAAuD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-sharepoint/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,+DAAwE;AAGxE,+DAAiE;AACjE,2DAA6D;AAC7D,qEAAsE;AACt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,GAAG,EAAE,CAAC,kCAAkC;YACjD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACtE,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE;QACR,2CAAsB;QACtB,mDAA0B;QAC1B,6CAAuB;QACvB,iDAAyB;QACzB,kCAAkB;QAClB,0CAAsB;QACtB,yBAAc;QACd,6CAAuB;KACxB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const copyItemWithinSiteAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
itemId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
5
|
+
destinationFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
6
|
+
newName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
conflictBehavior: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyItemWithinSiteAction = 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 polling_delay_ms = 2000;
|
|
10
|
+
const polling_timeout_secs = 120;
|
|
11
|
+
function delay(ms) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.copyItemWithinSiteAction = (0, pieces_framework_1.createAction)({
|
|
17
|
+
auth: __1.microsoftSharePointAuth,
|
|
18
|
+
name: 'microsoft_sharepoint_copy_item_within_site',
|
|
19
|
+
displayName: 'Copy File or Folder (Within Site)',
|
|
20
|
+
description: 'Copy a file or folder to another folder within the same site.',
|
|
21
|
+
props: {
|
|
22
|
+
siteId: common_1.microsoftSharePointCommon.siteId,
|
|
23
|
+
driveId: common_1.microsoftSharePointCommon.driveId,
|
|
24
|
+
itemId: common_1.microsoftSharePointCommon.itemId,
|
|
25
|
+
destinationFolderId: pieces_framework_1.Property.Dropdown({
|
|
26
|
+
displayName: 'Destination Folder',
|
|
27
|
+
description: 'The folder to copy the item into. Select "Root" to copy to the top level of the drive.',
|
|
28
|
+
required: true,
|
|
29
|
+
refreshers: ['siteId', 'driveId'],
|
|
30
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
|
|
31
|
+
if (!auth || !siteId || !driveId) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
placeholder: 'Select a site and drive first.',
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const authValue = auth;
|
|
39
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
40
|
+
authProvider: {
|
|
41
|
+
getAccessToken: () => Promise.resolve(authValue.access_token),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const options = [
|
|
45
|
+
{ label: 'Root', value: 'root' }
|
|
46
|
+
];
|
|
47
|
+
let response = yield client
|
|
48
|
+
.api(`/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
|
|
49
|
+
.get();
|
|
50
|
+
while (response.value.length > 0) {
|
|
51
|
+
for (const item of response.value) {
|
|
52
|
+
options.push({
|
|
53
|
+
label: item.name,
|
|
54
|
+
value: item.id,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (response['@odata.nextLink']) {
|
|
58
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { disabled: false, options };
|
|
65
|
+
}),
|
|
66
|
+
}),
|
|
67
|
+
newName: pieces_framework_1.Property.ShortText({
|
|
68
|
+
displayName: 'New Name (Optional)',
|
|
69
|
+
description: 'A new name for the copied item. If not provided, the original name is used.',
|
|
70
|
+
required: false,
|
|
71
|
+
}),
|
|
72
|
+
conflictBehavior: pieces_framework_1.Property.StaticDropdown({
|
|
73
|
+
displayName: 'Conflict Behavior',
|
|
74
|
+
description: 'Action to take if a file with the same name already exists in the destination.',
|
|
75
|
+
required: true,
|
|
76
|
+
options: {
|
|
77
|
+
options: [
|
|
78
|
+
{ label: 'Fail on conflict', value: 'fail' },
|
|
79
|
+
{ label: 'Overwrite existing file', value: 'replace' },
|
|
80
|
+
{ label: 'Rename with a number', value: 'rename' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
defaultValue: 'fail',
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
run(context) {
|
|
87
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const { siteId, driveId, itemId, destinationFolderId, newName, conflictBehavior } = context.propsValue;
|
|
90
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
91
|
+
authProvider: {
|
|
92
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const effectiveDestinationId = destinationFolderId === 'root'
|
|
96
|
+
? (yield client.api(`/drives/${driveId}/root`).get()).id
|
|
97
|
+
: destinationFolderId;
|
|
98
|
+
const body = {
|
|
99
|
+
parentReference: {
|
|
100
|
+
id: effectiveDestinationId,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
if (newName) {
|
|
104
|
+
body.name = newName;
|
|
105
|
+
}
|
|
106
|
+
let initialResponse;
|
|
107
|
+
try {
|
|
108
|
+
initialResponse = yield client
|
|
109
|
+
.api(`/drives/${driveId}/items/${itemId}/copy`)
|
|
110
|
+
.responseType(microsoft_graph_client_1.ResponseType.RAW)
|
|
111
|
+
.query({ '@microsoft.graph.conflictBehavior': conflictBehavior })
|
|
112
|
+
.post(body);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error.statusCode === 400) {
|
|
116
|
+
throw new Error(`Invalid request: ${error.message || 'Check your input parameters'}`);
|
|
117
|
+
}
|
|
118
|
+
if (error.statusCode === 403) {
|
|
119
|
+
throw new Error('Insufficient permissions to copy this item. Requires Files.ReadWrite or higher.');
|
|
120
|
+
}
|
|
121
|
+
if (error.statusCode === 404) {
|
|
122
|
+
throw new Error('Source item not found. Please verify the site, drive, and item IDs.');
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`Failed to initiate copy operation: ${error.message || 'Unknown error'}`);
|
|
125
|
+
}
|
|
126
|
+
const monitorUrl = initialResponse.headers.get('Location');
|
|
127
|
+
if (!monitorUrl) {
|
|
128
|
+
throw new Error('Could not get monitor URL from copy operation response.');
|
|
129
|
+
}
|
|
130
|
+
let attempts = polling_timeout_secs * 1000 / polling_delay_ms;
|
|
131
|
+
while (attempts > 0) {
|
|
132
|
+
const monitorResponse = yield client.api(monitorUrl).get();
|
|
133
|
+
if (monitorResponse.status === 'completed') {
|
|
134
|
+
return {
|
|
135
|
+
success: true,
|
|
136
|
+
status: 'completed',
|
|
137
|
+
resourceId: monitorResponse.resourceId,
|
|
138
|
+
resourceLocation: monitorResponse.resourceLocation,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (monitorResponse.status === 'failed') {
|
|
142
|
+
const errorDetails = ((_a = monitorResponse.error) === null || _a === void 0 ? void 0 : _a.details)
|
|
143
|
+
? monitorResponse.error.details.map((d) => d.message || d.code).join(', ')
|
|
144
|
+
: ((_b = monitorResponse.error) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error';
|
|
145
|
+
throw new Error(`Copy operation failed: ${errorDetails}`);
|
|
146
|
+
}
|
|
147
|
+
yield delay(polling_delay_ms);
|
|
148
|
+
attempts--;
|
|
149
|
+
}
|
|
150
|
+
throw new Error('Copy operation timed out after 120 seconds.');
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
//# sourceMappingURL=copy-item-within-site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-item-within-site.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/copy-item-within-site.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAKwC;AACxC,sCAAsD;AACtD,8EAAyF;AAGzF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,SAAe,KAAK,CAAC,EAAU;;QAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CAAA;AAEY,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,4CAA4C;IAClD,WAAW,EAAE,mCAAmC;IAChD,WAAW,EAAE,+DAA+D;IAC5E,KAAK,EAAE;QACL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,mBAAmB,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACrC,WAAW,EAAE,oBAAoB;YACjC,WAAW,EAAE,wFAAwF;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AAQ,GAAG,CAAC,EAAE,CAAC;gBACpB,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAC;gBAC3D,IAAI,eAAe,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;oBAC3C,OAAO;wBACL,OAAO,EAAE,IAAI;wBACb,MAAM,EAAE,WAAW;wBACnB,UAAU,EAAE,eAAe,CAAC,UAAU;wBACtC,gBAAgB,EAAE,eAAe,CAAC,gBAAgB;qBACnD,CAAC;gBACJ,CAAC;gBACD,IAAI,eAAe,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;oBACxC,MAAM,YAAY,GAAG,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,OAAO;wBACjD,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBAC/E,CAAC,CAAC,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,OAAO,KAAI,eAAe,CAAC;oBACtD,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBACD,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAC9B,QAAQ,EAAE,CAAC;YACb,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const copyItemAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
itemId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
5
|
+
destination_site_id: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
6
|
+
destination_drive_id: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
7
|
+
destination_folder_id: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
8
|
+
new_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
conflict_behavior: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyItemAction = 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 polling_delay_ms = 2000;
|
|
10
|
+
const polling_timeout_secs = 120;
|
|
11
|
+
function delay(ms) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.copyItemAction = (0, pieces_framework_1.createAction)({
|
|
17
|
+
auth: __1.microsoftSharePointAuth,
|
|
18
|
+
name: 'microsoft_sharepoint_copy_item',
|
|
19
|
+
displayName: 'Copy File or Folder (Across Sites)',
|
|
20
|
+
description: 'Copy a file or folder from one site to another within the same tenant, with overwrite option.',
|
|
21
|
+
props: {
|
|
22
|
+
siteId: common_1.microsoftSharePointCommon.siteId,
|
|
23
|
+
driveId: common_1.microsoftSharePointCommon.driveId,
|
|
24
|
+
itemId: common_1.microsoftSharePointCommon.itemId,
|
|
25
|
+
destination_site_id: common_1.microsoftSharePointCommon.siteId,
|
|
26
|
+
destination_drive_id: common_1.microsoftSharePointCommon.createDriveDropdown({
|
|
27
|
+
displayName: 'Destination Drive',
|
|
28
|
+
refreshers: ['destination_site_id'],
|
|
29
|
+
}),
|
|
30
|
+
destination_folder_id: common_1.microsoftSharePointCommon.destinationFolderId,
|
|
31
|
+
new_name: pieces_framework_1.Property.ShortText({
|
|
32
|
+
displayName: 'New Name (Optional)',
|
|
33
|
+
description: 'A new name for the copied item. If not provided, the original name is used.',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
conflict_behavior: pieces_framework_1.Property.StaticDropdown({
|
|
37
|
+
displayName: 'Conflict Behavior',
|
|
38
|
+
description: 'Action to take if a file with the same name already exists.',
|
|
39
|
+
required: true,
|
|
40
|
+
options: {
|
|
41
|
+
options: [
|
|
42
|
+
{ label: 'Fail on conflict', value: 'fail' },
|
|
43
|
+
{ label: 'Overwrite existing file', value: 'replace' },
|
|
44
|
+
{ label: 'Rename with a number', value: 'rename' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
defaultValue: 'fail',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
run(context) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const { siteId, driveId, itemId, destination_drive_id, destination_folder_id, new_name, conflict_behavior, } = context.propsValue;
|
|
54
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
55
|
+
authProvider: {
|
|
56
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const body = {
|
|
60
|
+
parentReference: {
|
|
61
|
+
driveId: destination_drive_id,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
if (destination_folder_id) {
|
|
65
|
+
body.parentReference.id = destination_folder_id;
|
|
66
|
+
}
|
|
67
|
+
if (new_name) {
|
|
68
|
+
body.name = new_name;
|
|
69
|
+
}
|
|
70
|
+
let initialResponse;
|
|
71
|
+
try {
|
|
72
|
+
initialResponse = yield client
|
|
73
|
+
.api(`/drives/${driveId}/items/${itemId}/copy`)
|
|
74
|
+
.responseType(microsoft_graph_client_1.ResponseType.RAW)
|
|
75
|
+
.query({ '@microsoft.graph.conflictBehavior': conflict_behavior })
|
|
76
|
+
.post(body);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (error.statusCode === 400) {
|
|
80
|
+
throw new Error(`Invalid request: ${error.message || 'Check your input parameters'}`);
|
|
81
|
+
}
|
|
82
|
+
if (error.statusCode === 403) {
|
|
83
|
+
throw new Error('Insufficient permissions to copy this item. Requires Files.ReadWrite or higher.');
|
|
84
|
+
}
|
|
85
|
+
if (error.statusCode === 404) {
|
|
86
|
+
throw new Error('Source item not found. Please verify the site, drive, and item IDs.');
|
|
87
|
+
}
|
|
88
|
+
throw new Error(`Failed to initiate copy operation: ${error.message || 'Unknown error'}`);
|
|
89
|
+
}
|
|
90
|
+
const monitorUrl = initialResponse.headers.get('Location');
|
|
91
|
+
if (!monitorUrl) {
|
|
92
|
+
throw new Error('Could not get monitor URL from copy operation response.');
|
|
93
|
+
}
|
|
94
|
+
let attempts = polling_timeout_secs * 1000 / polling_delay_ms;
|
|
95
|
+
while (attempts > 0) {
|
|
96
|
+
const monitorResponse = yield client.api(monitorUrl).get();
|
|
97
|
+
if (monitorResponse.status === 'completed') {
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
status: 'completed',
|
|
101
|
+
resourceId: monitorResponse.resourceId,
|
|
102
|
+
resourceLocation: monitorResponse.resourceLocation,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (monitorResponse.status === 'failed') {
|
|
106
|
+
const errorDetails = ((_a = monitorResponse.error) === null || _a === void 0 ? void 0 : _a.details)
|
|
107
|
+
? monitorResponse.error.details.map((d) => d.message || d.code).join(', ')
|
|
108
|
+
: ((_b = monitorResponse.error) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error';
|
|
109
|
+
throw new Error(`Copy operation failed: ${errorDetails}`);
|
|
110
|
+
}
|
|
111
|
+
yield delay(polling_delay_ms);
|
|
112
|
+
attempts--;
|
|
113
|
+
}
|
|
114
|
+
throw new Error('Copy operation timed out after 120 seconds.');
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=copy-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-item.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/copy-item.ts"],"names":[],"mappings":";;;;AAAA,8BAAiD;AACjD,qEAAwE;AACxE,sCAAsD;AACtD,8EAAyE;AAEzE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,SAAe,KAAK,CAAC,EAAU;;QAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CAAA;AAEY,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,2BAAuB;IAC7B,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,oCAAoC;IACjD,WAAW,EACT,+FAA+F;IACjG,KAAK,EAAE;QAEL,MAAM,EAAE,kCAAyB,CAAC,MAAM;QACxC,OAAO,EAAE,kCAAyB,CAAC,OAAO;QAC1C,MAAM,EAAE,kCAAyB,CAAC,MAAM;QAExC,mBAAmB,EAAE,kCAAyB,CAAC,MAAM;QACrD,oBAAoB,EAAE,kCAAyB,CAAC,mBAAmB,CAAC;YAClE,WAAW,EAAE,mBAAmB;YAChC,UAAU,EAAE,CAAC,qBAAqB,CAAC;SACpC,CAAC;QACF,qBAAqB,EAAE,kCAAyB,CAAC,mBAAmB;QAEpE,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC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eAAe,CAAC,UAAU;wBACtC,gBAAgB,EAAE,eAAe,CAAC,gBAAgB;qBACnD,CAAC;gBACJ,CAAC;gBACD,IAAI,eAAe,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;oBACxC,MAAM,YAAY,GAAG,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,OAAO;wBACjD,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;wBAC/E,CAAC,CAAC,CAAA,MAAA,eAAe,CAAC,KAAK,0CAAE,OAAO,KAAI,eAAe,CAAC;oBACtD,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBACD,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAC9B,QAAQ,EAAE,CAAC;YACb,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const findFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
findMethod: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
5
|
+
filePath: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
searchQuery: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
searchFolderId: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFileAction = 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
|
+
exports.findFileAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: __1.microsoftSharePointAuth,
|
|
11
|
+
name: 'microsoft_sharepoint_find_file',
|
|
12
|
+
displayName: 'Find File',
|
|
13
|
+
description: 'Look up a file by its name or path.',
|
|
14
|
+
props: {
|
|
15
|
+
siteId: common_1.microsoftSharePointCommon.siteId,
|
|
16
|
+
driveId: common_1.microsoftSharePointCommon.driveId,
|
|
17
|
+
findMethod: pieces_framework_1.Property.StaticDropdown({
|
|
18
|
+
displayName: 'Find Method',
|
|
19
|
+
description: 'Choose how to find the file.',
|
|
20
|
+
required: true,
|
|
21
|
+
options: {
|
|
22
|
+
options: [
|
|
23
|
+
{ label: 'Find by Exact Path', value: 'path' },
|
|
24
|
+
{ label: 'Search by Name', value: 'search' },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
defaultValue: 'search',
|
|
28
|
+
}),
|
|
29
|
+
filePath: pieces_framework_1.Property.ShortText({
|
|
30
|
+
displayName: 'File Path',
|
|
31
|
+
description: "The exact path to the file from the drive's root. **Required if finding by path.** Example: `Documents/Reports/Q1-Report.docx`",
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
searchQuery: pieces_framework_1.Property.ShortText({
|
|
35
|
+
displayName: 'Search Query',
|
|
36
|
+
description: "The file name or keyword to search for. **Required if searching by name.** Example: `Q1-Report.docx`",
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
searchFolderId: pieces_framework_1.Property.Dropdown({
|
|
40
|
+
displayName: 'Folder to Search In (Optional)',
|
|
41
|
+
description: 'The folder to search within. If not specified, the entire drive will be searched. **Only applies when searching by name.**',
|
|
42
|
+
required: false,
|
|
43
|
+
refreshers: ['siteId', 'driveId'],
|
|
44
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
|
|
45
|
+
if (!auth || !siteId || !driveId) {
|
|
46
|
+
return {
|
|
47
|
+
disabled: true,
|
|
48
|
+
placeholder: 'Select a site and drive first.',
|
|
49
|
+
options: [],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const authValue = auth;
|
|
53
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
54
|
+
authProvider: {
|
|
55
|
+
getAccessToken: () => Promise.resolve(authValue.access_token),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const options = [];
|
|
59
|
+
let response = yield client
|
|
60
|
+
.api(`/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
|
|
61
|
+
.get();
|
|
62
|
+
while (response.value.length > 0) {
|
|
63
|
+
for (const item of response.value) {
|
|
64
|
+
options.push({ label: item.name, value: item.id });
|
|
65
|
+
}
|
|
66
|
+
if (response['@odata.nextLink']) {
|
|
67
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { disabled: false, options };
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
run(context) {
|
|
78
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const { driveId, findMethod, filePath, searchQuery, searchFolderId } = context.propsValue;
|
|
80
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
81
|
+
authProvider: {
|
|
82
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
if (findMethod === 'path') {
|
|
86
|
+
if (!filePath)
|
|
87
|
+
throw new Error("File Path is required when finding by path.");
|
|
88
|
+
const cleanPath = filePath.startsWith('/') ? filePath.substring(1) : filePath;
|
|
89
|
+
try {
|
|
90
|
+
const result = yield client.api(`/drives/${driveId}/root:/${encodeURI(cleanPath)}`).get();
|
|
91
|
+
return {
|
|
92
|
+
success: true,
|
|
93
|
+
files: [result]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
const error = e;
|
|
98
|
+
if (error.statusCode === 404) {
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
files: []
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Failed to find file by path: ${error.message || 'Unknown error'}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
if (!searchQuery)
|
|
109
|
+
throw new Error("Search Query is required when searching by name.");
|
|
110
|
+
let searchUrl = `/drives/${driveId}/`;
|
|
111
|
+
if (searchFolderId) {
|
|
112
|
+
searchUrl += `items/${searchFolderId}/`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
searchUrl += 'root/';
|
|
116
|
+
}
|
|
117
|
+
searchUrl += `search(q='${encodeURIComponent(searchQuery)}')`;
|
|
118
|
+
try {
|
|
119
|
+
const response = yield client.api(searchUrl).get();
|
|
120
|
+
return {
|
|
121
|
+
success: true,
|
|
122
|
+
files: response.value || []
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw new Error(`Failed to search for file: ${error.message || 'Unknown error'}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=find-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-sharepoint/src/lib/actions/find-file.ts"],"names":[],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AAc,GAAG,CAAC;gBAC5C,CAAC;qBAAM,CAAC;oBACJ,SAAS,IAAI,OAAO,CAAC;gBACzB,CAAC;gBACD,SAAS,IAAI,aAAa,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC;gBAE9D,IAAI,CAAC;oBACD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC;oBACnD,OAAO;wBACH,OAAO,EAAE,IAAI;wBACb,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;qBAC9B,CAAC;gBACN,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;gBACtF,CAAC;YACL,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getFolderContentsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
driveId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
folderId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
5
|
+
includeCustomFields: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
top: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
7
|
+
select: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
orderby: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
}>;
|