Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8160 components microsoft excel #8212

Merged
merged 7 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 0 additions & 3 deletions components/microsoft_excel/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import microsoftExcel from "../../microsoft_excel.app.mjs";

export default {
key: "microsoft_excel-add-a-worksheet-tablerow",
name: "Add A Worksheet Tablerow",
version: "0.0.1",
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: {
microsoftExcel,
itemId: {
propDefinition: [
microsoftExcel,
"itemId",
],
},
tableId: {
propDefinition: [
microsoftExcel,
"tableId",
({ itemId }) => ({
itemId,
}),
],
},
values: {
propDefinition: [
microsoftExcel,
"values",
],
},
},
async run({ $ }) {
const {
microsoftExcel,
itemId,
tableId,
values,
} = this;

const response = await microsoftExcel.addRow({
$,
itemId,
tableId,
data: {
values: JSON.parse(values),
},
});

$.export("$summary", "The rows were successfully added!");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import microsoftExcel from "../../microsoft_excel.app.mjs";

export default {
key: "microsoft_excel-update-worksheet-tablerow",
name: "Update Worksheet Tablerow",
version: "0.0.1",
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: {
microsoftExcel,
itemId: {
propDefinition: [
microsoftExcel,
"itemId",
],
},
tableId: {
propDefinition: [
microsoftExcel,
"tableId",
({ itemId }) => ({
itemId,
}),
],
},
rowId: {
propDefinition: [
microsoftExcel,
"rowId",
({
itemId, tableId,
}) => ({
itemId,
tableId,
}),
],
},
values: {
propDefinition: [
microsoftExcel,
"values",
],
description: "Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cells that contain errors return the error string.",
},
},
async run({ $ }) {
const {
microsoftExcel,
itemId,
tableId,
rowId,
values,
} = this;

const response = await microsoftExcel.updateRow({
$,
itemId,
tableId,
rowId,
data: {
values: JSON.parse(values),
},
});

$.export("$summary", `The row with index: ${rowId} was successfully updated!`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/microsoft_excel/app/microsoft_excel.app.ts

This file was deleted.

148 changes: 148 additions & 0 deletions components/microsoft_excel/microsoft_excel.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "microsoft_excel",
propDefinitions: {
itemId: {
type: "string",
label: "Item Id",
description: "The Id of the item you want to use.",
async options() {
const { value } = await this.listItems();

return value.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
rowId: {
type: "string",
label: "Row Id",
description: "The Id of the row you want to use.",
async options({
itemId, tableId,
}) {
const { value } = await this.listRows({
itemId,
tableId,
});

return value.map(({
index: value, values,
}) => ({
label: JSON.stringify(values),
value,
}));
},
},
tableId: {
type: "string",
label: "Table Id",
description: "The Id of the table you want to use.",
async options({ itemId }) {
const { value } = await this.listTables({
itemId,
});

return value.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
values: {
type: "string",
label: "Values",
description: "A 2-dimensional array of unformatted values of the table row. [See the documentation to get the data format](https://learn.microsoft.com/en-us/graph/api/tablerowcollection-add?view=graph-rest-1.0&tabs=http).",
},
},
methods: {
_apiUrl() {
return "https://graph.microsoft.com/v1.0";
},
_getHeaders() {
return {
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
const config = {
url: `${this._apiUrl()}/${path}`,
headers: this._getHeaders(),
...opts,
};

return axios($, config);
},
addRow({
itemId, tableId, ...args
}) {
return this._makeRequest({
method: "POST",
path: `me/drive/items/${itemId}/workbook/tables/${tableId}/rows`,
...args,
});
},
createHook(args = {}) {
return this._makeRequest({
method: "POST",
path: "subscriptions",
...args,
});
},
deleteHook(hookId) {
return this._makeRequest({
method: "DELETE",
path: `subscriptions/${hookId}`,
});
},
listItems(args = {}) {
return this._makeRequest({
path: "me/drive/root/children",
...args,
});
},
listRows({
itemId, tableId, ...args
}) {
return this._makeRequest({
path: `me/drive/items/${itemId}/workbook/tables/${tableId}/rows`,
...args,
});
},
listTables({
itemId, ...args
}) {
return this._makeRequest({
path: `me/drive/items/${itemId}/workbook/tables`,
...args,
});
},
updateRow({
itemId, tableId, rowId, ...args
}) {
return this._makeRequest({
method: "PATCH",
path: `me/drive/items/${itemId}/workbook/tables/${tableId}/rows/${rowId}`,
...args,
});
},
updateSubscription({
hookId, ...args
}) {
return this._makeRequest({
method: "PATCH",
path: `subscriptions/${hookId}`,
...args,
});
},
},
};
11 changes: 7 additions & 4 deletions components/microsoft_excel/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "@pipedream/microsoft_excel",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Microsoft Excel Components",
"main": "dist/app/microsoft_excel.app.mjs",
"main": "microsoft_excel.app.mjs",
"keywords": [
"pipedream",
"microsoft_excel"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/microsoft_excel",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1",
"moment": "^2.29.4"
}
}
}
Loading
Loading