Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
116 changes: 83 additions & 33 deletions components/microsoft_excel/microsoft_excel.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}) {
Expand Down Expand Up @@ -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;
},
},
};
4 changes: 2 additions & 2 deletions components/microsoft_excel/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -13,7 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1",
"@pipedream/platform": "^3.0.1",
"moment": "^2.29.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading