diff --git a/components/sharepoint/actions/create-folder/create-folder.mjs b/components/sharepoint/actions/create-folder/create-folder.mjs index 39fccb2ef9907..9a8b7623b278f 100644 --- a/components/sharepoint/actions/create-folder/create-folder.mjs +++ b/components/sharepoint/actions/create-folder/create-folder.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-create-folder", name: "Create Folder", description: "Create a new folder in SharePoint. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online)", - version: "0.0.2", + version: "0.0.3", type: "action", annotations: { destructiveHint: false, diff --git a/components/sharepoint/actions/create-item/create-item.mjs b/components/sharepoint/actions/create-item/create-item.mjs index 46f5d062a50b3..9f3793644971a 100644 --- a/components/sharepoint/actions/create-item/create-item.mjs +++ b/components/sharepoint/actions/create-item/create-item.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-create-item", name: "Create Item", description: "Create a new item in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=http)", - version: "0.0.8", + version: "0.0.9", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/sharepoint/actions/create-link/create-link.mjs b/components/sharepoint/actions/create-link/create-link.mjs index fd819504e1c14..abdef71087249 100644 --- a/components/sharepoint/actions/create-link/create-link.mjs +++ b/components/sharepoint/actions/create-link/create-link.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-create-link", name: "Create Link", description: "Create a sharing link for a DriveItem. [See the documentation](https://docs.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http)", - version: "0.0.3", + version: "0.0.4", type: "action", annotations: { destructiveHint: false, diff --git a/components/sharepoint/actions/create-list/create-list.mjs b/components/sharepoint/actions/create-list/create-list.mjs index e6b4fa5e8296c..311c800b470cc 100644 --- a/components/sharepoint/actions/create-list/create-list.mjs +++ b/components/sharepoint/actions/create-list/create-list.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-create-list", name: "Create List", description: "Create a new list in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http)", - version: "0.0.8", + version: "0.0.9", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/sharepoint/actions/download-file/download-file.mjs b/components/sharepoint/actions/download-file/download-file.mjs index 6dbb8946954f4..567f197af5fc5 100644 --- a/components/sharepoint/actions/download-file/download-file.mjs +++ b/components/sharepoint/actions/download-file/download-file.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-download-file", name: "Download File", description: "Download a Microsoft Sharepoint file to the /tmp directory. [See the documentation](https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http)", - version: "0.0.8", + version: "0.0.9", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs b/components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs index 8bde35edb42b2..3d88ab2ad0aaa 100644 --- a/components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs +++ b/components/sharepoint/actions/find-file-by-name/find-file-by-name.mjs @@ -6,7 +6,7 @@ export default { key: "sharepoint-find-file-by-name", name: "Find File by Name", description: "Search for a file or folder by name. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search)", - version: "0.1.0", + version: "0.1.1", type: "action", annotations: { destructiveHint: false, diff --git a/components/sharepoint/actions/get-excel-table/get-excel-table.mjs b/components/sharepoint/actions/get-excel-table/get-excel-table.mjs index 909d5c298225a..081d7a9241d4b 100644 --- a/components/sharepoint/actions/get-excel-table/get-excel-table.mjs +++ b/components/sharepoint/actions/get-excel-table/get-excel-table.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-get-excel-table", name: "Get Excel Table", description: "Retrieve a table from an Excel spreadsheet stored in Sharepoint [See the documentation](https://learn.microsoft.com/en-us/graph/api/table-range?view=graph-rest-1.0&tabs=http)", - version: "0.0.2", + version: "0.0.3", type: "action", annotations: { destructiveHint: false, diff --git a/components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs b/components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs index 397f4c715f40e..8a8e222e77aae 100644 --- a/components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs +++ b/components/sharepoint/actions/get-file-by-id/get-file-by-id.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-get-file-by-id", name: "Get File by ID", description: "Retrieves a file by ID. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get)", - version: "0.0.2", + version: "0.0.3", type: "action", annotations: { destructiveHint: false, @@ -39,12 +39,21 @@ export default { ], description: "The file to retrieve. You can either search for the file here or provide a custom *File ID*.", }, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, }, async run({ $ }) { const response = await this.sharepoint.getDriveItem({ $, siteId: this.siteId, fileId: this.fileId, + params: { + select: this.select, + }, }); $.export("$summary", `Successfully retrieved file with ID: ${this.fileId}`); return response; diff --git a/components/sharepoint/actions/get-site/get-site.mjs b/components/sharepoint/actions/get-site/get-site.mjs new file mode 100644 index 0000000000000..2ff0e9ccaeadd --- /dev/null +++ b/components/sharepoint/actions/get-site/get-site.mjs @@ -0,0 +1,40 @@ +import sharepoint from "../../sharepoint.app.mjs"; + +export default { + key: "sharepoint-get-site", + name: "Get Site", + description: "Get a site in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + sharepoint, + siteId: { + propDefinition: [ + sharepoint, + "siteId", + ], + }, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, + }, + async run({ $ }) { + const response = await this.sharepoint.getSite({ + $, + siteId: this.siteId, + params: { + select: this.select, + }, + }); + $.export("$summary", `Successfully retrieved site with ID: ${this.siteId}`); + return response; + }, +}; diff --git a/components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs b/components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs index 183960650d4ad..74ae87550f728 100644 --- a/components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs +++ b/components/sharepoint/actions/list-files-in-folder/list-files-in-folder.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-list-files-in-folder", name: "List Files in Folder", description: "Retrieves a list of the files and/or folders directly within a folder. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children)", - version: "0.0.2", + version: "0.0.3", type: "action", annotations: { destructiveHint: false, @@ -44,18 +44,37 @@ export default { "excludeFolders", ], }, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, + orderBy: { + type: "string", + label: "Order By", + description: "The field to order the results by", + default: "lastModifiedDateTime", + optional: true, + }, }, async run({ $ }) { + const params = { + select: this.select, + orderby: this.orderBy, + }; const response = this.folderId ? await this.sharepoint.listDriveItemsInFolder({ $, driveId: this.driveId, folderId: this.folderId, + params, }) : await this.sharepoint.listDriveItems({ $, siteId: this.siteId, driveId: this.driveId, + params, }); const values = this.excludeFolders ? response.value.filter(({ folder }) => !folder) diff --git a/components/sharepoint/actions/list-sites/list-sites.mjs b/components/sharepoint/actions/list-sites/list-sites.mjs new file mode 100644 index 0000000000000..2ed4fd5f7d2a8 --- /dev/null +++ b/components/sharepoint/actions/list-sites/list-sites.mjs @@ -0,0 +1,57 @@ +import sharepoint from "../../sharepoint.app.mjs"; + +export default { + key: "sharepoint-list-sites", + name: "List Sites", + description: "List all sites in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-list?view=graph-rest-1.0&tabs=http)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + sharepoint, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, + maxResults: { + propDefinition: [ + sharepoint, + "maxResults", + ], + }, + }, + async run({ $ }) { + const sites = []; + let count = 0; + + const results = this.sharepoint.paginate({ + fn: this.sharepoint.listAllSites, + args: { + $, + params: { + select: this.select, + }, + }, + }); + + for await (const site of results) { + sites.push(site); + count++; + if (this.maxResults && count >= this.maxResults) { + break; + } + } + + $.export("$summary", `Successfully listed ${count} site${count === 1 + ? "" + : "s"}`); + + return sites; + }, +}; diff --git a/components/sharepoint/actions/search-files/search-files.mjs b/components/sharepoint/actions/search-files/search-files.mjs new file mode 100644 index 0000000000000..d4fb084eca14d --- /dev/null +++ b/components/sharepoint/actions/search-files/search-files.mjs @@ -0,0 +1,84 @@ +import sharepoint from "../../sharepoint.app.mjs"; + +export default { + key: "sharepoint-search-files", + name: "Search Files", + description: "Search for files in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + sharepoint, + queryString: { + type: "string", + label: "Query String", + description: "The search query containing the search terms", + }, + queryTemplate: { + type: "string", + label: "Query Template", + description: "Provides a way to decorate the query string. Supports both KQL and query variables. Example: `({searchTerms}) AuthorOWSUSER:Adventure` [See the documentation](https://learn.microsoft.com/en-us/graph/search-concept-query-template) for more information.", + optional: true, + }, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, + size: { + propDefinition: [ + sharepoint, + "maxResults", + ], + max: 500, + }, + sortField: { + type: "string", + label: "Sort Field", + description: "The field to sort the results by", + default: "lastModifiedDateTime", + optional: true, + }, + descending: { + type: "boolean", + label: "Descending", + description: "Whether to sort the results in descending order", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.sharepoint.searchQuery({ + $, + data: { + requests: [ + { + entityTypes: [ + "driveItem", + ], + query: { + queryString: this.queryString, + queryTemplate: this.queryTemplate, + }, + fields: this.select + ? this.select.split(",").map((f) => f.trim()) + : undefined, + size: this.size, + sortProperties: [ + { + name: this.sortField, + isDescending: this.descending, + }, + ], + }, + ], + }, + }); + $.export("$summary", `Successfully searched for ${this.queryString}`); + return response; + }, +}; diff --git a/components/sharepoint/actions/search-sites/search-sites.mjs b/components/sharepoint/actions/search-sites/search-sites.mjs new file mode 100644 index 0000000000000..a3b32ee550a5b --- /dev/null +++ b/components/sharepoint/actions/search-sites/search-sites.mjs @@ -0,0 +1,63 @@ +import sharepoint from "../../sharepoint.app.mjs"; + +export default { + key: "sharepoint-search-sites", + name: "Search Sites", + description: "Search for sites in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0&tabs=http)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + sharepoint, + query: { + type: "string", + label: "Query", + description: "The query to search for", + }, + select: { + propDefinition: [ + sharepoint, + "select", + ], + }, + maxResults: { + propDefinition: [ + sharepoint, + "maxResults", + ], + }, + }, + async run({ $ }) { + const sites = []; + let count = 0; + + const results = this.sharepoint.paginate({ + fn: this.sharepoint.listAllSites, + args: { + $, + params: { + search: this.query, + select: this.select, + }, + }, + }); + + for await (const site of results) { + sites.push(site); + count++; + if (this.maxResults && count >= this.maxResults) { + break; + } + } + + $.export("$summary", `Successfully listed ${count} site${count === 1 + ? "" + : "s"}`); + + return sites; + }, +}; diff --git a/components/sharepoint/actions/select-files/select-files.mjs b/components/sharepoint/actions/select-files/select-files.mjs index c513b8cf7febe..328f2c04e4f8d 100644 --- a/components/sharepoint/actions/select-files/select-files.mjs +++ b/components/sharepoint/actions/select-files/select-files.mjs @@ -4,7 +4,7 @@ export default { key: "sharepoint-select-files", name: "Select Files", description: "A file picker action that allows browsing and selecting one or more files from SharePoint. Returns the selected files' metadata including pre-authenticated download URLs. [See the documentation](https://learn.microsoft.com/en-us/graph/api/driveitem-get)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, @@ -19,42 +19,39 @@ export default { "siteId", ], withLabel: true, - reloadProps: true, }, driveId: { propDefinition: [ sharepoint, "driveId", (c) => ({ - siteId: c.siteId?.__lv?.value || c.siteId, + siteId: c.siteId?.value || c.siteId, }), ], withLabel: true, - reloadProps: true, }, folderId: { propDefinition: [ sharepoint, "folderId", (c) => ({ - siteId: c.siteId?.__lv?.value || c.siteId, - driveId: c.driveId?.__lv?.value || c.driveId, + siteId: c.siteId?.value || c.siteId, + driveId: c.driveId?.value || c.driveId, }), ], label: "Folder", description: "The folder to browse. Leave empty to browse the root of the drive.", optional: true, withLabel: true, - reloadProps: true, }, fileOrFolderIds: { propDefinition: [ sharepoint, "fileOrFolderId", (c) => ({ - siteId: c.siteId?.__lv?.value || c.siteId, - driveId: c.driveId?.__lv?.value || c.driveId, - folderId: c.folderId?.__lv?.value || c.folderId, + siteId: c.siteId?.value || c.siteId, + driveId: c.driveId?.value || c.driveId, + folderId: c.folderId?.value || c.folderId, }), ], type: "string[]", @@ -66,8 +63,8 @@ export default { methods: { resolveValue(prop) { if (!prop) return null; - if (typeof prop === "object" && prop.__lv) { - return prop.__lv.value; + if (typeof prop === "object" && prop?.value) { + return prop.value; } return prop; }, diff --git a/components/sharepoint/actions/update-item/update-item.mjs b/components/sharepoint/actions/update-item/update-item.mjs index b379d517933b7..e5420a584914b 100644 --- a/components/sharepoint/actions/update-item/update-item.mjs +++ b/components/sharepoint/actions/update-item/update-item.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-update-item", name: "Update Item", description: "Updates an existing item in Microsoft Sharepoint. [See the documentation](https://learn.microsoft.com/en-us/graph/api/listitem-update?view=graph-rest-1.0&tabs=http)", - version: "0.0.8", + version: "0.0.9", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/sharepoint/actions/upload-file/upload-file.mjs b/components/sharepoint/actions/upload-file/upload-file.mjs index a25b796c9da1f..253ebeb4e3444 100644 --- a/components/sharepoint/actions/upload-file/upload-file.mjs +++ b/components/sharepoint/actions/upload-file/upload-file.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-upload-file", name: "Upload File", description: "Upload a file to OneDrive. [See the documentation](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online)", - version: "0.0.2", + version: "0.0.3", type: "action", annotations: { destructiveHint: false, diff --git a/components/sharepoint/package.json b/components/sharepoint/package.json index 462b4b8cf6581..87a22f08f17ea 100644 --- a/components/sharepoint/package.json +++ b/components/sharepoint/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/sharepoint", - "version": "0.5.1", + "version": "0.6.0", "description": "Pipedream Microsoft Sharepoint Online Components", "main": "sharepoint.app.mjs", "keywords": [ diff --git a/components/sharepoint/sharepoint.app.mjs b/components/sharepoint/sharepoint.app.mjs index 88c193eac5c75..d6a90c1f502f0 100644 --- a/components/sharepoint/sharepoint.app.mjs +++ b/components/sharepoint/sharepoint.app.mjs @@ -8,12 +8,20 @@ export default { type: "string", label: "Site", description: "Identifier of a site", - async options({ prevContext }) { + useQuery: true, + async options({ + prevContext, query, + }) { const args = prevContext?.nextLink ? { url: prevContext.nextLink, } : {}; + if (query) { + args.params = { + search: query, + }; + } const response = await this.listAllSites(args); const options = response.value?.map(({ id: value, displayName: label, @@ -266,6 +274,19 @@ export default { description: "Set to `true` to return only files in the response. Defaults to `false`", optional: true, }, + select: { + type: "string", + label: "Select", + description: "A comma-separated list of properties to return in the response", + optional: true, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + optional: true, + default: 100, + }, fileOrFolderId: { type: "string", label: "File or Folder", @@ -331,15 +352,29 @@ export default { ...args, }); }, + getSite({ + siteId, ...args + }) { + return this._makeRequest({ + path: `/sites/${siteId}`, + ...args, + }); + }, listSites(args = {}) { return this._makeRequest({ path: "/me/followedSites", ...args, }); }, - listAllSites(args = {}) { + listAllSites({ + params = {}, ...args + } = {}) { + if (!params.search) { + params.search = "*"; + } return this._makeRequest({ - path: "/sites?search=*", + path: "/sites", + params, ...args, }); }, @@ -503,6 +538,13 @@ export default { ...args, }); }, + searchQuery(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/search/query", + ...args, + }); + }, async *paginate({ fn, args, }) { diff --git a/components/sharepoint/sources/new-file-created/new-file-created.mjs b/components/sharepoint/sources/new-file-created/new-file-created.mjs index 3a18e2c505a3c..f026d7b86601b 100644 --- a/components/sharepoint/sources/new-file-created/new-file-created.mjs +++ b/components/sharepoint/sources/new-file-created/new-file-created.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-new-file-created", name: "New File Created", description: "Emit new event when a new file is created in Microsoft Sharepoint.", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", props: { diff --git a/components/sharepoint/sources/new-folder-created/new-folder-created.mjs b/components/sharepoint/sources/new-folder-created/new-folder-created.mjs index 30fe4f6214dd7..fd5e87fa68ae8 100644 --- a/components/sharepoint/sources/new-folder-created/new-folder-created.mjs +++ b/components/sharepoint/sources/new-folder-created/new-folder-created.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-new-folder-created", name: "New Folder Created", description: "Emit new event when a new folder is created in Microsoft Sharepoint.", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", props: { diff --git a/components/sharepoint/sources/new-list-item/new-list-item.mjs b/components/sharepoint/sources/new-list-item/new-list-item.mjs index 154bba971c0b1..2e22470784afc 100644 --- a/components/sharepoint/sources/new-list-item/new-list-item.mjs +++ b/components/sharepoint/sources/new-list-item/new-list-item.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-new-list-item", name: "New List Item", description: "Emit new event when a new list item is created in Microsoft Sharepoint.", - version: "0.0.7", + version: "0.0.8", type: "source", dedupe: "unique", props: { diff --git a/components/sharepoint/sources/updated-list-item/updated-list-item.mjs b/components/sharepoint/sources/updated-list-item/updated-list-item.mjs index ac180ee43070d..b938a9ca84887 100644 --- a/components/sharepoint/sources/updated-list-item/updated-list-item.mjs +++ b/components/sharepoint/sources/updated-list-item/updated-list-item.mjs @@ -5,7 +5,7 @@ export default { key: "sharepoint-updated-list-item", name: "Updated List Item", description: "Emit new event when a list item is updated in Microsoft Sharepoint.", - version: "0.0.7", + version: "0.0.8", type: "source", dedupe: "unique", props: {