diff --git a/components/microsoft_excel/actions/add-a-worksheet-tablerow/add-a-worksheet-tablerow.mjs b/components/microsoft_excel/actions/add-a-worksheet-tablerow/add-a-worksheet-tablerow.mjs index d51a3cbe7c595..def9938547828 100644 --- a/components/microsoft_excel/actions/add-a-worksheet-tablerow/add-a-worksheet-tablerow.mjs +++ b/components/microsoft_excel/actions/add-a-worksheet-tablerow/add-a-worksheet-tablerow.mjs @@ -4,7 +4,7 @@ import microsoftExcel from "../../microsoft_excel.app.mjs"; export default { key: "microsoft_excel-add-a-worksheet-tablerow", name: "Add A Worksheet Tablerow", - version: "0.0.2", + version: "0.0.3", description: "Adds rows to the end of specific table. [See the documentation](https://learn.microsoft.com/en-us/graph/api/tablerowcollection-add?view=graph-rest-1.0&tabs=http)", type: "action", props: { diff --git a/components/microsoft_excel/actions/update-worksheet-tablerow/update-worksheet-tablerow.mjs b/components/microsoft_excel/actions/update-worksheet-tablerow/update-worksheet-tablerow.mjs index 0b56aca87471f..aef3833a11baa 100644 --- a/components/microsoft_excel/actions/update-worksheet-tablerow/update-worksheet-tablerow.mjs +++ b/components/microsoft_excel/actions/update-worksheet-tablerow/update-worksheet-tablerow.mjs @@ -3,7 +3,7 @@ import microsoftExcel from "../../microsoft_excel.app.mjs"; export default { key: "microsoft_excel-update-worksheet-tablerow", name: "Update Worksheet Tablerow", - version: "0.0.2", + version: "0.0.3", description: "Update the properties of tablerow object. `(Only for work or school account)` [See the documentation](https://learn.microsoft.com/en-us/graph/api/tablerow-update?view=graph-rest-1.0&tabs=http)", type: "action", props: { diff --git a/components/microsoft_excel/microsoft_excel.app.mjs b/components/microsoft_excel/microsoft_excel.app.mjs index d1f8359545e20..60c8d28404756 100644 --- a/components/microsoft_excel/microsoft_excel.app.mjs +++ b/components/microsoft_excel/microsoft_excel.app.mjs @@ -9,7 +9,7 @@ export default { label: "Folder Id", description: "The ID of the folder where the item is located.", async options() { - const folders = await this.listFolders(); + const folders = await this.listFolderOptions(); return [ "root", ...folders, @@ -120,38 +120,6 @@ export default { path: `subscriptions/${hookId}`, }); }, - async listFolders({ - folderId = null, - prefix = "", ...args - } = {}) { - const foldersArray = []; - const { value: items } = await this._makeRequest({ - path: folderId - ? `/me/drive/items/${folderId}/children` - : "me/drive/root/children", - ...args, - }); - - const folders = items.filter((item) => item.folder); - for (const { - id, name, folder: { childCount = null }, - } of folders) { - foldersArray.push({ - value: id, - label: `${prefix}${name}`, - }); - - if (childCount) { - const children = await this.listFolders({ - folderId: id, - prefix: prefix + "-", - }); - foldersArray.push(...children); - } - } - - return foldersArray; - }, listItems({ folderId, ...args }) { @@ -196,5 +164,87 @@ export default { ...args, }); }, + batch(args = {}) { + return this._makeRequest({ + method: "POST", + path: "$batch", + ...args, + }); + }, + async listFolderOptions({ + folderId = null, prefix = "", batchLimit = 20, ...args + } = {}) { + const options = []; + const stack = [ + { + folderId, + prefix, + }, + ]; + const history = []; + + try { + while (stack.length) { + const currentBatch = []; + while (stack.length && currentBatch.length < batchLimit) { + const { + folderId, + prefix, + } = stack.shift(); + history.push({ + folderId, + prefix, + }); + currentBatch.push({ + id: folderId || "root", + method: "GET", + url: folderId + ? `/me/drive/items/${folderId}/children?$filter=folder ne null` + : "/me/drive/root/children?$filter=folder ne null", + }); + } + + const { responses: batchResponses } = + await this.batch({ + ...args, + data: { + ...args?.data, + requests: currentBatch, + }, + }); + + batchResponses.forEach(({ + id, status, body, + }) => { + if (status === 200) { + body.value.forEach((item) => { + const { + id, name, folder: { childCount }, parentReference: { id: parentId }, + } = item; + const prefix = history.find(({ folderId }) => folderId === parentId)?.prefix || ""; + const currentLabel = `${prefix}${name}`; + options.push({ + value: id, + label: currentLabel, + }); + + if (childCount) { + stack.push({ + folderId: id, + prefix: `${currentLabel}/`, + }); + } + }); + } else { + console.error(`Error in batch request ${id}:`, JSON.stringify(body)); + } + }); + } + } catch (error) { + console.error("Error listing folders:", error); + } + + return options; + }, }, }; diff --git a/components/microsoft_excel/package.json b/components/microsoft_excel/package.json index 037913b3cf3ce..c81189006ac23 100644 --- a/components/microsoft_excel/package.json +++ b/components/microsoft_excel/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/microsoft_excel", - "version": "0.1.1", + "version": "0.1.2", "description": "Pipedream Microsoft Excel Components", "main": "microsoft_excel.app.mjs", "keywords": [ @@ -13,7 +13,7 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1", + "@pipedream/platform": "^3.0.1", "moment": "^2.29.4" } } diff --git a/components/microsoft_excel/sources/new-item-updated/new-item-updated.mjs b/components/microsoft_excel/sources/new-item-updated/new-item-updated.mjs index 11fb38d1410ac..3f8f9e29f8ddc 100644 --- a/components/microsoft_excel/sources/new-item-updated/new-item-updated.mjs +++ b/components/microsoft_excel/sources/new-item-updated/new-item-updated.mjs @@ -7,7 +7,7 @@ export default { key: "microsoft_excel-new-item-updated", name: "New Item Updated (Instant)", description: "Emit new event when an item is updated.", - version: "0.0.2", + version: "0.0.3", type: "source", props: { microsoftExcel, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 87019953169ea..425f9b01140e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5956,10 +5956,10 @@ importers: components/microsoft_excel: specifiers: - '@pipedream/platform': ^1.5.1 + '@pipedream/platform': ^3.0.1 moment: ^2.29.4 dependencies: - '@pipedream/platform': 1.5.1 + '@pipedream/platform': 3.0.1 moment: 2.29.4 components/microsoft_onedrive: