@scopieflows/app-microsoft-sharepoint 0.2.3
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/README.md +2 -0
- package/package.json +31 -0
- package/src/i18n/de.json +131 -0
- package/src/i18n/es.json +131 -0
- package/src/i18n/fr.json +131 -0
- package/src/i18n/ja.json +131 -0
- package/src/i18n/nl.json +131 -0
- package/src/i18n/pt.json +131 -0
- package/src/i18n/ru.json +49 -0
- package/src/i18n/translation.json +131 -0
- package/src/i18n/vi.json +49 -0
- package/src/i18n/zh.json +131 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +121 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/copy-item-within-site.d.ts +8 -0
- package/src/lib/actions/copy-item-within-site.js +155 -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/create-folder.d.ts +6 -0
- package/src/lib/actions/create-folder.js +44 -0
- package/src/lib/actions/create-folder.js.map +1 -0
- package/src/lib/actions/create-list-item.d.ts +5 -0
- package/src/lib/actions/create-list-item.js +43 -0
- package/src/lib/actions/create-list-item.js.map +1 -0
- package/src/lib/actions/create-list.d.ts +5 -0
- package/src/lib/actions/create-list.js +41 -0
- package/src/lib/actions/create-list.js.map +1 -0
- package/src/lib/actions/delete-list-item.d.ts +5 -0
- package/src/lib/actions/delete-list-item.js +33 -0
- package/src/lib/actions/delete-list-item.js.map +1 -0
- package/src/lib/actions/find-file.d.ts +8 -0
- package/src/lib/actions/find-file.js +133 -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 +108 -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 +151 -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/actions/search-list-item.d.ts +5 -0
- package/src/lib/actions/search-list-item.js +40 -0
- package/src/lib/actions/search-list-item.js.map +1 -0
- package/src/lib/actions/update-list-item.d.ts +6 -0
- package/src/lib/actions/update-list-item.js +42 -0
- package/src/lib/actions/update-list-item.js.map +1 -0
- package/src/lib/actions/upload-file.d.ts +7 -0
- package/src/lib/actions/upload-file.js +49 -0
- package/src/lib/actions/upload-file.js.map +1 -0
- package/src/lib/common/index.d.ts +14 -0
- package/src/lib/common/index.js +394 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/triggers/new-file-in-folder.d.ts +18 -0
- package/src/lib/triggers/new-file-in-folder.js +155 -0
- package/src/lib/triggers/new-file-in-folder.js.map +1 -0
- package/src/lib/triggers/new-file-in-subfolders.d.ts +18 -0
- package/src/lib/triggers/new-file-in-subfolders.js +151 -0
- package/src/lib/triggers/new-file-in-subfolders.js.map +1 -0
- package/src/lib/triggers/new-list-item.d.ts +14 -0
- package/src/lib/triggers/new-list-item.js +95 -0
- package/src/lib/triggers/new-list-item.js.map +1 -0
- package/src/lib/triggers/new-list.d.ts +10 -0
- package/src/lib/triggers/new-list.js +89 -0
- package/src/lib/triggers/new-list.js.map +1 -0
- package/src/lib/triggers/new-or-updated-file.d.ts +18 -0
- package/src/lib/triggers/new-or-updated-file.js +152 -0
- package/src/lib/triggers/new-or-updated-file.js.map +1 -0
- package/src/lib/triggers/new-or-updated-folder.d.ts +18 -0
- package/src/lib/triggers/new-or-updated-folder.js +152 -0
- package/src/lib/triggers/new-or-updated-folder.js.map +1 -0
- package/src/lib/triggers/new-or-updated-list.d.ts +10 -0
- package/src/lib/triggers/new-or-updated-list.js +103 -0
- package/src/lib/triggers/new-or-updated-list.js.map +1 -0
- package/src/lib/triggers/updated-list-item.d.ts +14 -0
- package/src/lib/triggers/updated-list-item.js +108 -0
- package/src/lib/triggers/updated-list-item.js.map +1 -0
package/src/i18n/zh.json
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"\n1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).\n2. From the left sidebar, go to **Microsoft Enfra ID**.\n3. Under **Manage**, click on **App registrations**.\n4. Click the **New registration** button.\n5. Enter a **Name** for your app.\n6. For **Supported account types**, choose:\n - **Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts**\n - Or select based on your requirement.\n7. In **Redirect URI**, select **Web** and ad": "\n1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).\n2. From the left sidebar, go to **Microsoft Enfra ID**.\n3. Under **Manage**, click on **App registrations**.\n4. Click the **New registration** button.\n5. Enter a **Name** for your app.\n6. For **Supported account types**, choose:\n - **Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts**\n - Or select based on your requirement.\n7. In **Redirect URI**, select **Web** and add the given URL: {{redirectUrl}}\n8. Click **Register**.\n9. After registration, you’ll be redirected to the app’s overview page. Copy the **Application (client) ID**.\n10. From the left menu, go to **Certificates & secrets**.\n - Under **Client secrets**, click **New client secret**.\n - Provide a description, set an expiry, and click **Add**.\n - Copy the **Value** of the client secret (this will not be shown again).\n11. Go to **API permissions** from the left menu.\n - Click **Add a permission**.\n - Select **Microsoft Graph**.\n - Add the following **Delegated permissions**:\n - Sites.Read.All\n - Sites.ReadWrite.All\n - Sites.Manage.All\n - Files.ReadWrite.All\n - openid\n - email\n - profile\n - offline_access\n - Click **Add permissions**.\n12. Copy your **Client ID** and **Client Secret**.\n",
|
|
3
|
+
"Create Folder": "Create Folder",
|
|
4
|
+
"Create List": "Create List",
|
|
5
|
+
"Create List Item": "Create List Item",
|
|
6
|
+
"Update List Item": "Update List Item",
|
|
7
|
+
"Delete List Item": "Delete List Item",
|
|
8
|
+
"Find List Item": "Find List Item",
|
|
9
|
+
"Upload File": "Upload File",
|
|
10
|
+
"Publish Page": "Publish Page",
|
|
11
|
+
"Copy File or Folder (Across Sites)": "Copy File or Folder (Across Sites)",
|
|
12
|
+
"Copy File or Folder (Within Site)": "Copy File or Folder (Within Site)",
|
|
13
|
+
"Move File": "Move File",
|
|
14
|
+
"Find File": "Find File",
|
|
15
|
+
"Get Folder Contents": "Get Folder Contents",
|
|
16
|
+
"Get Site Information": "Get Site Information",
|
|
17
|
+
"Custom API Call": "自定义 API 呼叫",
|
|
18
|
+
"Creates a new folder at path you specify.": "Creates a new folder at path you specify.",
|
|
19
|
+
"Creates a new list.": "Creates a new list.",
|
|
20
|
+
"Creates a new item in a list.": "Creates a new item in a list.",
|
|
21
|
+
"Updates an existing item in a list.": "Updates an existing item in a list.",
|
|
22
|
+
"Deletes an existing item from a list.": "Deletes an existing item from a list.",
|
|
23
|
+
"Finds a item in a list based on name.": "Finds a item in a list based on name.",
|
|
24
|
+
"Uploads a new file at path you specify.": "Uploads a new file at path you specify.",
|
|
25
|
+
"Publishes a SharePoint page, making it available to all users. If the page is checked out, it will be automatically checked in. Note: Pages with active approval flows will not publish until approval is complete.": "Publishes a SharePoint page, making it available to all users. If the page is checked out, it will be automatically checked in. Note: Pages with active approval flows will not publish until approval is complete.",
|
|
26
|
+
"Copy a file or folder from one site to another within the same tenant, with overwrite option.": "Copy a file or folder from one site to another within the same tenant, with overwrite option.",
|
|
27
|
+
"Copy a file or folder to another folder within the same site.": "Copy a file or folder to another folder within the same site.",
|
|
28
|
+
"Move a file from one folder to another within the same drive.": "Move a file from one folder to another within the same drive.",
|
|
29
|
+
"Look up a file by its name or path.": "Look up a file by its name or path.",
|
|
30
|
+
"List all files and subfolders in a specified folder, optionally with detailed metadata.": "List all files and subfolders in a specified folder, optionally with detailed metadata.",
|
|
31
|
+
"Fetch metadata of a SharePoint site (site ID, title, URL, description, etc.).": "Fetch metadata of a SharePoint site (site ID, title, URL, description, etc.).",
|
|
32
|
+
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
|
|
33
|
+
"Site": "Site",
|
|
34
|
+
"Drive": "Drive",
|
|
35
|
+
"Parent Folder": "父文件夹",
|
|
36
|
+
"Folder Name": "文件夹名称",
|
|
37
|
+
"List Name": "List Name",
|
|
38
|
+
"List Description": "List Description",
|
|
39
|
+
"List": "List",
|
|
40
|
+
"List Columns": "List Columns",
|
|
41
|
+
"List Item": "List Item",
|
|
42
|
+
"Title": "标题",
|
|
43
|
+
"File": "文件",
|
|
44
|
+
"File Name": "File Name",
|
|
45
|
+
"Page": "Page",
|
|
46
|
+
"Source File or Folder": "Source File or Folder",
|
|
47
|
+
"Destination Drive": "Destination Drive",
|
|
48
|
+
"Destination Folder": "Destination Folder",
|
|
49
|
+
"New Name (Optional)": "New Name (Optional)",
|
|
50
|
+
"Conflict Behavior": "Conflict Behavior",
|
|
51
|
+
"File to Move": "File to Move",
|
|
52
|
+
"Find Method": "Find Method",
|
|
53
|
+
"File Path": "File Path",
|
|
54
|
+
"Search Query": "Search Query",
|
|
55
|
+
"Folder to Search In (Optional)": "Folder to Search In (Optional)",
|
|
56
|
+
"Folder": "Folder",
|
|
57
|
+
"Include Custom Metadata": "Include Custom Metadata",
|
|
58
|
+
"Page Size": "Page Size",
|
|
59
|
+
"Select Fields (Optional)": "Select Fields (Optional)",
|
|
60
|
+
"Order By (Optional)": "Order By (Optional)",
|
|
61
|
+
"Method": "方法",
|
|
62
|
+
"Headers": "信头",
|
|
63
|
+
"Query Parameters": "查询参数",
|
|
64
|
+
"Body Type": "Body Type",
|
|
65
|
+
"Body": "正文内容",
|
|
66
|
+
"Response is Binary ?": "Response is Binary ?",
|
|
67
|
+
"No Error on Failure": "失败时没有错误",
|
|
68
|
+
"Timeout (in seconds)": "超时(秒)",
|
|
69
|
+
"Follow redirects": "Follow redirects",
|
|
70
|
+
"Parent folder,like \"/demo/\" or \"/docs/assignment/\".Leave it default if you want to create folder at the root (**/**) level.": "Parent folder,like \"/demo/\" or \"/docs/assignment/\".Leave it default if you want to create folder at the root (**/**) level.",
|
|
71
|
+
"Item title to search": "Item title to search",
|
|
72
|
+
"The file or url you want to upload": "The file or url you want to upload",
|
|
73
|
+
"Parent folder, like \"/demo/\" or \"/docs/assignment/\".Leave it default if you want to create folder at the root (**CHANGE THIS BACK//**) level.": "Parent folder, like \"/demo/\" or \"/docs/assignment/\".Leave it default if you want to create folder at the root (**CHANGE THIS BACK//**) level.",
|
|
74
|
+
"The folder to copy the item into. Defaults to the root of the drive.": "The folder to copy the item into. Defaults to the root of the drive.",
|
|
75
|
+
"A new name for the copied item. If not provided, the original name is used.": "A new name for the copied item. If not provided, the original name is used.",
|
|
76
|
+
"Action to take if a file with the same name already exists.": "Action to take if a file with the same name already exists.",
|
|
77
|
+
"The folder to copy the item into. Select \"Root\" to copy to the top level of the drive.": "The folder to copy the item into. Select \"Root\" to copy to the top level of the drive.",
|
|
78
|
+
"Action to take if a file with the same name already exists in the destination.": "Action to take if a file with the same name already exists in the destination.",
|
|
79
|
+
"The file you want to move.": "The file you want to move.",
|
|
80
|
+
"The folder to move the file into. Select \"Root\" to move to the top level of the drive.": "The folder to move the file into. Select \"Root\" to move to the top level of the drive.",
|
|
81
|
+
"Provide a new name to rename the file during the move.": "Provide a new name to rename the file during the move.",
|
|
82
|
+
"Choose how to find the file.": "Choose how to find the file.",
|
|
83
|
+
"The exact path to the file from the drive's root. **Required if finding by path.** Example: `Documents/Reports/Q1-Report.docx`": "The exact path to the file from the drive's root. **Required if finding by path.** Example: `Documents/Reports/Q1-Report.docx`",
|
|
84
|
+
"The file name or keyword to search for. **Required if searching by name.** Example: `Q1-Report.docx`": "The file name or keyword to search for. **Required if searching by name.** Example: `Q1-Report.docx`",
|
|
85
|
+
"The folder to search within. If not specified, the entire drive will be searched. **Only applies when searching by name.**": "The folder to search within. If not specified, the entire drive will be searched. **Only applies when searching by name.**",
|
|
86
|
+
"The folder whose contents you want to list. Select \"Root Folder\" for the top-level folder.": "The folder whose contents you want to list. Select \"Root Folder\" for the top-level folder.",
|
|
87
|
+
"Check this to include SharePoint-specific metadata (custom columns). This may slow down the request.": "Check this to include SharePoint-specific metadata (custom columns). This may slow down the request.",
|
|
88
|
+
"The maximum number of items to return. The API default is 200. If more items exist, the output will contain a field `@odata.nextLink` that you can use in a custom API call to get the next page.": "The maximum number of items to return. The API default is 200. If more items exist, the output will contain a field `@odata.nextLink` that you can use in a custom API call to get the next page.",
|
|
89
|
+
"A comma-separated list of properties to return. Example: `id,name,size,webUrl`": "A comma-separated list of properties to return. Example: `id,name,size,webUrl`",
|
|
90
|
+
"Specifies how to sort the returned items. Example: `name asc` or `lastModifiedDateTime desc`": "Specifies how to sort the returned items. Example: `name asc` or `lastModifiedDateTime desc`",
|
|
91
|
+
"A comma-separated list of properties to return. If left blank, all default properties are returned. Example: `id,displayName,webUrl,description`": "A comma-separated list of properties to return. If left blank, all default properties are returned. Example: `id,displayName,webUrl,description`",
|
|
92
|
+
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
|
|
93
|
+
"Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",
|
|
94
|
+
"Fail on conflict": "Fail on conflict",
|
|
95
|
+
"Overwrite existing file": "Overwrite existing file",
|
|
96
|
+
"Rename with a number": "Rename with a number",
|
|
97
|
+
"Find by Exact Path": "Find by Exact Path",
|
|
98
|
+
"Search by Name": "Search by Name",
|
|
99
|
+
"GET": "获取",
|
|
100
|
+
"POST": "帖子",
|
|
101
|
+
"PATCH": "PATCH",
|
|
102
|
+
"PUT": "弹出",
|
|
103
|
+
"DELETE": "删除",
|
|
104
|
+
"HEAD": "黑色",
|
|
105
|
+
"None": "无",
|
|
106
|
+
"JSON": "JSON",
|
|
107
|
+
"Form Data": "表单数据",
|
|
108
|
+
"Raw": "原始文件",
|
|
109
|
+
"New File in Folder": "New File in Folder",
|
|
110
|
+
"New File in Subfolders": "New File in Subfolders",
|
|
111
|
+
"New or Updated File": "New or Updated File",
|
|
112
|
+
"New or Updated Folder": "New or Updated Folder",
|
|
113
|
+
"New List Item": "New List Item",
|
|
114
|
+
"Updated List Item": "Updated List Item",
|
|
115
|
+
"New List": "New List",
|
|
116
|
+
"New or Updated List": "New or Updated List",
|
|
117
|
+
"Fires when a new file is created or added in a specific folder.": "Fires when a new file is created or added in a specific folder.",
|
|
118
|
+
"Fires when a new file is added anywhere in the first-level subfolders of a folder. Note: This trigger will not monitor subfolders created after the flow is activated.": "Fires when a new file is added anywhere in the first-level subfolders of a folder. Note: This trigger will not monitor subfolders created after the flow is activated.",
|
|
119
|
+
"Triggers when a file is created or updated in a given folder.": "Triggers when a file is created or updated in a given folder.",
|
|
120
|
+
"Triggers when a folder is created or updated (e.g., name change).": "Triggers when a folder is created or updated (e.g., name change).",
|
|
121
|
+
"Triggers when a new item is created in a SharePoint list.": "Triggers when a new item is created in a SharePoint list.",
|
|
122
|
+
"Fires when an existing item in a SharePoint list is updated.": "Fires when an existing item in a SharePoint list is updated.",
|
|
123
|
+
"Triggers when a new list is created in a site.": "Triggers when a new list is created in a site.",
|
|
124
|
+
"Triggers when a list is created or updated in a site.": "Triggers when a list is created or updated in a site.",
|
|
125
|
+
"Folder to Monitor": "Folder to Monitor",
|
|
126
|
+
"Parent Folder to Monitor": "Parent Folder to Monitor",
|
|
127
|
+
"The folder to watch for new files. Select \"Root Folder\" for the top-level folder of the drive.": "The folder to watch for new files. Select \"Root Folder\" for the top-level folder of the drive.",
|
|
128
|
+
"The parent folder whose subfolders you want to monitor.": "The parent folder whose subfolders you want to monitor.",
|
|
129
|
+
"The folder to watch for new or updated files. Select \"Root Folder\" for the top-level folder of the drive.": "The folder to watch for new or updated files. Select \"Root Folder\" for the top-level folder of the drive.",
|
|
130
|
+
"The folder to watch for new or updated subfolders. Select \"Root Folder\" to monitor the top-level of the drive.": "The folder to watch for new or updated subfolders. Select \"Root Folder\" to monitor the top-level of the drive."
|
|
131
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const microsoftSharePointAuth: import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>;
|
|
2
|
+
export declare const microsoftSharePoint: import("@scopieflows/pieces-framework").Piece<import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftSharePoint = exports.microsoftSharePointAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/pieces-framework");
|
|
6
|
+
const shared_1 = require("@scopieflows/shared");
|
|
7
|
+
const pieces_common_1 = require("@scopieflows/pieces-common");
|
|
8
|
+
const create_folder_1 = require("./lib/actions/create-folder");
|
|
9
|
+
const create_list_1 = require("./lib/actions/create-list");
|
|
10
|
+
const create_list_item_1 = require("./lib/actions/create-list-item");
|
|
11
|
+
const update_list_item_1 = require("./lib/actions/update-list-item");
|
|
12
|
+
const delete_list_item_1 = require("./lib/actions/delete-list-item");
|
|
13
|
+
const search_list_item_1 = require("./lib/actions/search-list-item");
|
|
14
|
+
const upload_file_1 = require("./lib/actions/upload-file");
|
|
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");
|
|
30
|
+
const authDesc = `
|
|
31
|
+
1. Sign in to [Microsoft Azure Portal](https://portal.azure.com/).
|
|
32
|
+
2. From the left sidebar, go to **Microsoft Enfra ID**.
|
|
33
|
+
3. Under **Manage**, click on **App registrations**.
|
|
34
|
+
4. Click the **New registration** button.
|
|
35
|
+
5. Enter a **Name** for your app.
|
|
36
|
+
6. For **Supported account types**, choose:
|
|
37
|
+
- **Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant) and personal Microsoft accounts**
|
|
38
|
+
- Or select based on your requirement.
|
|
39
|
+
7. In **Redirect URI**, select **Web** and add the given URL: {{redirectUrl}}
|
|
40
|
+
8. Click **Register**.
|
|
41
|
+
9. After registration, you’ll be redirected to the app’s overview page. Copy the **Application (client) ID**.
|
|
42
|
+
10. From the left menu, go to **Certificates & secrets**.
|
|
43
|
+
- Under **Client secrets**, click **New client secret**.
|
|
44
|
+
- Provide a description, set an expiry, and click **Add**.
|
|
45
|
+
- Copy the **Value** of the client secret (this will not be shown again).
|
|
46
|
+
11. Go to **API permissions** from the left menu.
|
|
47
|
+
- Click **Add a permission**.
|
|
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
|
|
54
|
+
- openid
|
|
55
|
+
- email
|
|
56
|
+
- profile
|
|
57
|
+
- offline_access
|
|
58
|
+
- Click **Add permissions**.
|
|
59
|
+
12. Copy your **Client ID** and **Client Secret**.
|
|
60
|
+
`;
|
|
61
|
+
exports.microsoftSharePointAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
62
|
+
description: authDesc,
|
|
63
|
+
authUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
|
64
|
+
tokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
|
65
|
+
required: true,
|
|
66
|
+
scope: [
|
|
67
|
+
'openid',
|
|
68
|
+
'email',
|
|
69
|
+
'profile',
|
|
70
|
+
'offline_access',
|
|
71
|
+
'Sites.Read.All',
|
|
72
|
+
'Sites.ReadWrite.All',
|
|
73
|
+
'Sites.Manage.All',
|
|
74
|
+
'Files.ReadWrite.All',
|
|
75
|
+
],
|
|
76
|
+
prompt: 'omit'
|
|
77
|
+
});
|
|
78
|
+
exports.microsoftSharePoint = (0, pieces_framework_1.createPiece)({
|
|
79
|
+
displayName: 'Microsoft SharePoint',
|
|
80
|
+
auth: exports.microsoftSharePointAuth,
|
|
81
|
+
minimumSupportedRelease: '0.78.0',
|
|
82
|
+
logoUrl: '/pieces/microsoft-sharepoint.png',
|
|
83
|
+
categories: [shared_1.PieceCategory.CONTENT_AND_FILES],
|
|
84
|
+
authors: ['kishanprmr', 'pranith124', 'onyedikachi-david'],
|
|
85
|
+
actions: [
|
|
86
|
+
create_folder_1.createFolderAction,
|
|
87
|
+
create_list_1.createListAction,
|
|
88
|
+
create_list_item_1.createListItemAction,
|
|
89
|
+
update_list_item_1.updateListItemAction,
|
|
90
|
+
delete_list_item_1.deleteListItemAction,
|
|
91
|
+
search_list_item_1.findListItemAction,
|
|
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,
|
|
100
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
101
|
+
auth: exports.microsoftSharePointAuth,
|
|
102
|
+
baseUrl: () => 'https://graph.microsoft.com/v1.0',
|
|
103
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
return ({
|
|
105
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
106
|
+
});
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
],
|
|
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
|
+
],
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-sharepoint/src/index.ts"],"names":[],"mappings":";;;;AAAA,oEAIuC;AACvC,gDAAoD;AACpD,8DAAuE;AAGvE,+DAAiE;AACjE,2DAA6D;AAC7D,qEAAsE;AACtE,qEAAsE;AACtE,qEAAsE;AACtE,qEAAoE;AACpE,2DAAuD;AAGvD,6DAA+D;AAC/D,uDAAyD;AACzD,+EAA+E;AAC/E,uDAAyD;AACzD,uDAAyD;AACzD,2EAA4E;AAC5E,6EAA8E;AA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AAA;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("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
3
|
+
driveId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
4
|
+
itemId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
5
|
+
destinationFolderId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
6
|
+
newName: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
conflictBehavior: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,155 @@
|
|
|
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("@scopieflows/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
|
+
auth: __1.microsoftSharePointAuth,
|
|
27
|
+
displayName: 'Destination Folder',
|
|
28
|
+
description: 'The folder to copy the item into. Select "Root" to copy to the top level of the drive.',
|
|
29
|
+
required: true,
|
|
30
|
+
refreshers: ['siteId', 'driveId'],
|
|
31
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, siteId, driveId }) {
|
|
32
|
+
if (!auth || !siteId || !driveId) {
|
|
33
|
+
return {
|
|
34
|
+
disabled: true,
|
|
35
|
+
placeholder: 'Select a site and drive first.',
|
|
36
|
+
options: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const authValue = auth;
|
|
40
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
41
|
+
authProvider: {
|
|
42
|
+
getAccessToken: () => Promise.resolve(authValue.access_token),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const options = [
|
|
46
|
+
{ label: 'Root', value: 'root' }
|
|
47
|
+
];
|
|
48
|
+
let response = yield client
|
|
49
|
+
.api(`/sites/${siteId}/drives/${driveId}/root/children?$filter=folder ne null&$select=id,name`)
|
|
50
|
+
.get();
|
|
51
|
+
while (response.value.length > 0) {
|
|
52
|
+
for (const item of response.value) {
|
|
53
|
+
options.push({
|
|
54
|
+
label: item.name,
|
|
55
|
+
value: item.id,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (response['@odata.nextLink']) {
|
|
59
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { disabled: false, options };
|
|
66
|
+
}),
|
|
67
|
+
}),
|
|
68
|
+
newName: pieces_framework_1.Property.ShortText({
|
|
69
|
+
displayName: 'New Name (Optional)',
|
|
70
|
+
description: 'A new name for the copied item. If not provided, the original name is used.',
|
|
71
|
+
required: false,
|
|
72
|
+
}),
|
|
73
|
+
conflictBehavior: pieces_framework_1.Property.StaticDropdown({
|
|
74
|
+
displayName: 'Conflict Behavior',
|
|
75
|
+
description: 'Action to take if a file with the same name already exists in the destination.',
|
|
76
|
+
required: true,
|
|
77
|
+
options: {
|
|
78
|
+
options: [
|
|
79
|
+
{ label: 'Fail on conflict', value: 'fail' },
|
|
80
|
+
{ label: 'Overwrite existing file', value: 'replace' },
|
|
81
|
+
{ label: 'Rename with a number', value: 'rename' },
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
defaultValue: 'fail',
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
|
+
run(context) {
|
|
88
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const { siteId, driveId, itemId, destinationFolderId, newName, conflictBehavior } = context.propsValue;
|
|
91
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
92
|
+
authProvider: {
|
|
93
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const effectiveDestinationId = destinationFolderId === 'root'
|
|
97
|
+
? (yield client.api(`/drives/${driveId}/root`).get()).id
|
|
98
|
+
: destinationFolderId;
|
|
99
|
+
const body = {
|
|
100
|
+
parentReference: {
|
|
101
|
+
id: effectiveDestinationId,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
if (newName) {
|
|
105
|
+
body.name = newName;
|
|
106
|
+
}
|
|
107
|
+
let initialResponse;
|
|
108
|
+
try {
|
|
109
|
+
initialResponse = yield client
|
|
110
|
+
.api(`/drives/${driveId}/items/${itemId}/copy`)
|
|
111
|
+
.responseType(microsoft_graph_client_1.ResponseType.RAW)
|
|
112
|
+
.query({ '@microsoft.graph.conflictBehavior': conflictBehavior })
|
|
113
|
+
.post(body);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (error.statusCode === 400) {
|
|
117
|
+
throw new Error(`Invalid request: ${error.message || 'Check your input parameters'}`);
|
|
118
|
+
}
|
|
119
|
+
if (error.statusCode === 403) {
|
|
120
|
+
throw new Error('Insufficient permissions to copy this item. Requires Files.ReadWrite or higher.');
|
|
121
|
+
}
|
|
122
|
+
if (error.statusCode === 404) {
|
|
123
|
+
throw new Error('Source item not found. Please verify the site, drive, and item IDs.');
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`Failed to initiate copy operation: ${error.message || 'Unknown error'}`);
|
|
126
|
+
}
|
|
127
|
+
const monitorUrl = initialResponse.headers.get('Location');
|
|
128
|
+
if (!monitorUrl) {
|
|
129
|
+
throw new Error('Could not get monitor URL from copy operation response.');
|
|
130
|
+
}
|
|
131
|
+
let attempts = polling_timeout_secs * 1000 / polling_delay_ms;
|
|
132
|
+
while (attempts > 0) {
|
|
133
|
+
const monitorResponse = yield client.api(monitorUrl).get();
|
|
134
|
+
if (monitorResponse.status === 'completed') {
|
|
135
|
+
return {
|
|
136
|
+
success: true,
|
|
137
|
+
status: 'completed',
|
|
138
|
+
resourceId: monitorResponse.resourceId,
|
|
139
|
+
resourceLocation: monitorResponse.resourceLocation,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (monitorResponse.status === 'failed') {
|
|
143
|
+
const errorDetails = ((_a = monitorResponse.error) === null || _a === void 0 ? void 0 : _a.details)
|
|
144
|
+
? monitorResponse.error.details.map((d) => d.message || d.code).join(', ')
|
|
145
|
+
: ((_b = monitorResponse.error) === null || _b === void 0 ? void 0 : _b.message) || 'Unknown error';
|
|
146
|
+
throw new Error(`Copy operation failed: ${errorDetails}`);
|
|
147
|
+
}
|
|
148
|
+
yield delay(polling_delay_ms);
|
|
149
|
+
attempts--;
|
|
150
|
+
}
|
|
151
|
+
throw new Error('Copy operation timed out after 120 seconds.');
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
//# 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,oEAKuC;AACvC,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,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AAC;gBAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,QAAQ,GAAG,oBAAoB,GAAG,IAAI,GAAG,gBAAgB,CAAC;YAC9D,OAAO,QAAQ,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("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
3
|
+
driveId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
4
|
+
itemId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
5
|
+
destination_site_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
6
|
+
destination_drive_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
7
|
+
destination_folder_id: import("@scopieflows/pieces-framework").DropdownProperty<string, false, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
8
|
+
new_name: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
conflict_behavior: import("@scopieflows/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("@scopieflows/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,oEAAuE;AACvE,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,GAA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
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const createFolderAction: import("@scopieflows/pieces-framework").IAction<import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
|
|
2
|
+
siteId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
3
|
+
driveId: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
|
|
4
|
+
parentFolder: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
folderName: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}>;
|