Skip to content

Commit 6d7b258

Browse files
committed
Microsoft Excel: fixing timeout listing folders
1 parent 950a2d1 commit 6d7b258

File tree

6 files changed

+47
-29
lines changed

6 files changed

+47
-29
lines changed

components/microsoft_excel/actions/add-a-worksheet-tablerow/add-a-worksheet-tablerow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import microsoftExcel from "../../microsoft_excel.app.mjs";
44
export default {
55
key: "microsoft_excel-add-a-worksheet-tablerow",
66
name: "Add A Worksheet Tablerow",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
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)",
99
type: "action",
1010
props: {

components/microsoft_excel/actions/update-worksheet-tablerow/update-worksheet-tablerow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftExcel from "../../microsoft_excel.app.mjs";
33
export default {
44
key: "microsoft_excel-update-worksheet-tablerow",
55
name: "Update Worksheet Tablerow",
6-
version: "0.0.2",
6+
version: "0.0.3",
77
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)",
88
type: "action",
99
props: {

components/microsoft_excel/microsoft_excel.app.mjs

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,51 @@ export default {
121121
});
122122
},
123123
async listFolders({
124-
folderId = null,
125-
prefix = "", ...args
124+
folderId = null, prefix = "", ...args
126125
} = {}) {
127126
const foldersArray = [];
128-
const { value: items } = await this._makeRequest({
129-
path: folderId
130-
? `/me/drive/items/${folderId}/children`
131-
: "me/drive/root/children",
132-
...args,
133-
});
134-
135-
const folders = items.filter((item) => item.folder);
136-
for (const {
137-
id, name, folder: { childCount = null },
138-
} of folders) {
139-
foldersArray.push({
140-
value: id,
141-
label: `${prefix}${name}`,
142-
});
127+
const stack = [
128+
{
129+
folderId,
130+
prefix,
131+
},
132+
];
143133

144-
if (childCount) {
145-
const children = await this.listFolders({
146-
folderId: id,
147-
prefix: prefix + "-",
134+
try {
135+
while (stack.length) {
136+
const {
137+
folderId, prefix,
138+
} = stack.pop();
139+
const { value: folders } = await this._makeRequest({
140+
path: folderId
141+
? `/me/drive/items/${folderId}/children`
142+
: "me/drive/root/children",
143+
params: {
144+
["$filter"]: "folder ne null",
145+
},
146+
...args,
148147
});
149-
foldersArray.push(...children);
148+
149+
for (const {
150+
id, name, folder: { childCount = null },
151+
} of folders) {
152+
153+
const currentLabel = `${prefix}${name}`;
154+
foldersArray.push({
155+
value: id,
156+
label: currentLabel,
157+
});
158+
159+
if (childCount) {
160+
stack.push({
161+
folderId: id,
162+
prefix: `${currentLabel}/`,
163+
});
164+
}
165+
}
150166
}
167+
} catch (error) {
168+
console.error("Error listing folders:", error);
151169
}
152170

153171
return foldersArray;

components/microsoft_excel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_excel",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Pipedream Microsoft Excel Components",
55
"main": "microsoft_excel.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.5.1",
16+
"@pipedream/platform": "^3.0.1",
1717
"moment": "^2.29.4"
1818
}
1919
}

components/microsoft_excel/sources/new-item-updated/new-item-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "microsoft_excel-new-item-updated",
88
name: "New Item Updated (Instant)",
99
description: "Emit new event when an item is updated.",
10-
version: "0.0.2",
10+
version: "0.0.3",
1111
type: "source",
1212
props: {
1313
microsoftExcel,

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)