@pipedream/spreadsheet_com 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/actions/create-rows/create-rows.mjs +66 -0
- package/actions/list-workbook-id-options/list-workbook-id-options.mjs +34 -0
- package/actions/update-rows/update-rows.mjs +58 -0
- package/common/utils.mjs +13 -0
- package/package.json +6 -5
- package/sources/row-updated/row-updated.mjs +125 -0
- package/sources/row-updated/test-event.mjs +19 -0
- package/spreadsheet_com.app.mjs +170 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The Spreadsheet.com API provides programmatic access to manage sheets, rows, and other data within Spreadsheet.com. Integrating this API into Pipedream allows you to automate tasks like updating rows based on external triggers, syncing data between multiple platforms, or even processing data using custom logic. With Pipedream, you can craft workflows that react in real-time to events, schedule data manipulation tasks, and connect to countless other services via their APIs.
|
|
4
|
+
|
|
5
|
+
# Example Use Cases
|
|
6
|
+
|
|
7
|
+
- **Sync Spreadsheet.com with Google Calendar**: When a new event is scheduled in Google Calendar, a Pipedream workflow can trigger to create or update a corresponding row in a Spreadsheet.com sheet, keeping a detailed log of your events and their details for easy tracking and analysis.
|
|
8
|
+
|
|
9
|
+
- **Manage Customer Support Tickets**: When a new support ticket is submitted through a platform like Zendesk, trigger a Pipedream workflow to add the ticket details to Spreadsheet.com. Further automation can notify support staff via Slack or email and update the ticket status in Spreadsheet.com based on follow-up actions.
|
|
10
|
+
|
|
11
|
+
- **Process E-commerce Orders**: Connect Spreadsheet.com to an e-commerce platform like Shopify. Each time an order is placed, a Pipedream workflow fires, adding order details to a sheet. It can also perform inventory checks, update stock levels, and send a restock request to your supplier if inventory runs low.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { parseArray } from "../../common/utils.mjs";
|
|
2
|
+
import spreadsheetCom from "../../spreadsheet_com.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "spreadsheet_com-create-rows",
|
|
6
|
+
name: "Create Rows",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
description: "Adds new row(s) after last row that has data. Empty data sets are ignored. Provide data for at least 1 column. [See the documentation](https://developer.spreadsheet.com/#tag/Rows/operation/createRows)",
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
spreadsheetCom,
|
|
17
|
+
workbookId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
spreadsheetCom,
|
|
20
|
+
"workbookId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
worksheetId: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
spreadsheetCom,
|
|
26
|
+
"worksheetId",
|
|
27
|
+
({ workbookId }) => ({
|
|
28
|
+
workbookId,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
position: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Position",
|
|
35
|
+
description: "Position at which the row is to be added in the worksheet. If not specified, row is added after the last non-empty row in the worksheet. E.g. `S3vBb3FZRQuFtW1mrj0U2g:before`. [Where to find row Ids](https://developer.spreadsheet.com/#section/Using-the-API/Extract-Resource-IDs)",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
rowsData: {
|
|
39
|
+
type: "string[]",
|
|
40
|
+
label: "Rows Data",
|
|
41
|
+
description: "Data row(s) to add. Each entry have the following sample format: `{ \"cellData\": [ { \"field\": \"A\", \"data\": \"Person\" }, { \"field\": \"B\", \"data\": \"Region\" } ] }`. Rows without any column data will be ignored. Maximum of 100 entries can be provided. [See the documentation](https://developer.spreadsheet.com/#tag/Rows/operation/createRows).",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
async run({ $ }) {
|
|
45
|
+
const {
|
|
46
|
+
spreadsheetCom,
|
|
47
|
+
worksheetId,
|
|
48
|
+
position,
|
|
49
|
+
rowsData,
|
|
50
|
+
} = this;
|
|
51
|
+
|
|
52
|
+
const response = await spreadsheetCom.createRows({
|
|
53
|
+
$,
|
|
54
|
+
worksheetId,
|
|
55
|
+
params: {
|
|
56
|
+
position,
|
|
57
|
+
},
|
|
58
|
+
data: parseArray(rowsData),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
$.export("$summary", `New row(s) with Id(s): ${(response.ids).toString()} ${response.ids.length > 1
|
|
62
|
+
? "were"
|
|
63
|
+
: "was"} successfully created!`);
|
|
64
|
+
return response;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import spreadsheet_com from "../../spreadsheet_com.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "spreadsheet_com-list-workbook-id-options",
|
|
5
|
+
name: "List Workbook Id Options",
|
|
6
|
+
description: "Retrieves available options for the Workbook Id field.",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
spreadsheet_com,
|
|
16
|
+
page: {
|
|
17
|
+
type: "integer",
|
|
18
|
+
label: "Page",
|
|
19
|
+
description: "The page of results to retrieve.",
|
|
20
|
+
min: 0,
|
|
21
|
+
default: 0,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
const options = await spreadsheet_com.propDefinitions.workbookId.options
|
|
26
|
+
.call(this.spreadsheet_com, {
|
|
27
|
+
page: this.page,
|
|
28
|
+
});
|
|
29
|
+
$.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
|
|
30
|
+
? ""
|
|
31
|
+
: "s"}`);
|
|
32
|
+
return options;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { parseArray } from "../../common/utils.mjs";
|
|
2
|
+
import spreadsheetCom from "../../spreadsheet_com.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "spreadsheet_com-update-rows",
|
|
6
|
+
name: "Update Rows",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
13
|
+
description: "Update existing row(s). [See the documentation](https://developer.spreadsheet.com/#tag/Rows/operation/updateRows)",
|
|
14
|
+
type: "action",
|
|
15
|
+
props: {
|
|
16
|
+
spreadsheetCom,
|
|
17
|
+
workbookId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
spreadsheetCom,
|
|
20
|
+
"workbookId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
worksheetId: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
spreadsheetCom,
|
|
26
|
+
"worksheetId",
|
|
27
|
+
({ workbookId }) => ({
|
|
28
|
+
workbookId,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
rowsData: {
|
|
33
|
+
type: "string[]",
|
|
34
|
+
label: "Rows Data",
|
|
35
|
+
description: "Data row(s) to update. Each entry have the following sample format: `{ \"_id\": \"WTwPho0VQp-goWf_xtSMgQ\", \"cellData\": [ { \"field\": \"A\", \"data\": \"Person\" }, { \"field\": \"B\", \"data\": \"Region\" } ] }`. Response will contain list of row ids for which the operation was successful. Maximum of 100 entries can be provided. [Where to find row Ids](https://developer.spreadsheet.com/#section/Using-the-API/Extract-Resource-IDs)",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
async run({ $ }) {
|
|
39
|
+
const {
|
|
40
|
+
spreadsheetCom,
|
|
41
|
+
worksheetId,
|
|
42
|
+
rowsData,
|
|
43
|
+
} = this;
|
|
44
|
+
|
|
45
|
+
const parsedData = parseArray(rowsData);
|
|
46
|
+
|
|
47
|
+
const response = await spreadsheetCom.updateRows({
|
|
48
|
+
$,
|
|
49
|
+
worksheetId,
|
|
50
|
+
data: parsedData,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
$.export("$summary", `The row${parsedData.length > 1
|
|
54
|
+
? "s were"
|
|
55
|
+
: " was"} successfully updated!`);
|
|
56
|
+
return response;
|
|
57
|
+
},
|
|
58
|
+
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const LIMIT = 100;
|
|
2
|
+
|
|
3
|
+
export const parseArray = (array) => {
|
|
4
|
+
if (Array.isArray(array)) {
|
|
5
|
+
return array.map((item) => {
|
|
6
|
+
if (typeof item != "object") {
|
|
7
|
+
return JSON.parse(item);
|
|
8
|
+
}
|
|
9
|
+
return item;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return JSON.parse(array);
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/spreadsheet_com",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pipedream Spreadsheet.com Components",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "spreadsheet_com.app.mjs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pipedream",
|
|
8
8
|
"spreadsheet_com"
|
|
9
9
|
],
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
10
|
"homepage": "https://pipedream.com/apps/spreadsheet_com",
|
|
14
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"moment": "^2.29.4",
|
|
17
|
+
"@pipedream/platform": "^1.6.8"
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigurationError, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
3
|
+
} from "@pipedream/platform";
|
|
4
|
+
import moment from "moment";
|
|
5
|
+
import spreadsheetCom from "../../spreadsheet_com.app.mjs";
|
|
6
|
+
import sampleEmit from "./test-event.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "spreadsheet_com-row-updated",
|
|
10
|
+
name: "New Row Updated",
|
|
11
|
+
version: "0.0.1",
|
|
12
|
+
description: "Emit new event when a row is updated.",
|
|
13
|
+
type: "source",
|
|
14
|
+
dedupe: "unique",
|
|
15
|
+
props: {
|
|
16
|
+
spreadsheetCom,
|
|
17
|
+
db: "$.service.db",
|
|
18
|
+
timer: {
|
|
19
|
+
label: "Polling interval",
|
|
20
|
+
description: "Pipedream will poll the Spreadsheet.com on this schedule",
|
|
21
|
+
type: "$.interface.timer",
|
|
22
|
+
default: {
|
|
23
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
workbookId: {
|
|
27
|
+
propDefinition: [
|
|
28
|
+
spreadsheetCom,
|
|
29
|
+
"workbookId",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
worksheetId: {
|
|
33
|
+
propDefinition: [
|
|
34
|
+
spreadsheetCom,
|
|
35
|
+
"worksheetId",
|
|
36
|
+
({ workbookId }) => ({
|
|
37
|
+
workbookId,
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
_getLastDate() {
|
|
44
|
+
return this.db.get("lastDate") || 0;
|
|
45
|
+
},
|
|
46
|
+
_setLastDate(lastDate) {
|
|
47
|
+
this.db.set("lastDate", lastDate);
|
|
48
|
+
},
|
|
49
|
+
_getSortColumn() {
|
|
50
|
+
return this.db.get("sortColumn");
|
|
51
|
+
},
|
|
52
|
+
_setSortColumn(sortColumn) {
|
|
53
|
+
this.db.set("sortColumn", sortColumn);
|
|
54
|
+
},
|
|
55
|
+
async startEvent(maxResults = 0) {
|
|
56
|
+
const {
|
|
57
|
+
spreadsheetCom,
|
|
58
|
+
worksheetId,
|
|
59
|
+
} = this;
|
|
60
|
+
|
|
61
|
+
const lastDate = this._getLastDate();
|
|
62
|
+
const items = spreadsheetCom.paginate({
|
|
63
|
+
fn: spreadsheetCom.listRows,
|
|
64
|
+
maxResults,
|
|
65
|
+
worksheetId,
|
|
66
|
+
params: {
|
|
67
|
+
sort: {
|
|
68
|
+
"options": [
|
|
69
|
+
{
|
|
70
|
+
"column": this._getSortColumn(),
|
|
71
|
+
"sortType": "desc",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
let responseArray = [];
|
|
79
|
+
|
|
80
|
+
for await (const item of items) {
|
|
81
|
+
if (moment(item.updatedAt).isSameOrBefore(lastDate)) break;
|
|
82
|
+
responseArray.push(item);
|
|
83
|
+
}
|
|
84
|
+
if (responseArray.length) this._setLastDate(responseArray[0].updatedAt);
|
|
85
|
+
|
|
86
|
+
for (const item of responseArray.reverse()) {
|
|
87
|
+
this.$emit(
|
|
88
|
+
item,
|
|
89
|
+
{
|
|
90
|
+
id: item._id + item.updatedAt,
|
|
91
|
+
summary: `The row with id: "${item._id}" was updated!`,
|
|
92
|
+
ts: item.updatedAt,
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
async getUpdatedAtColumn() {
|
|
98
|
+
const { spreadsheetCom } = this;
|
|
99
|
+
const columns = spreadsheetCom.paginate({
|
|
100
|
+
fn: spreadsheetCom.listColumns,
|
|
101
|
+
worksheetId: this.worksheetId,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
let sortColumn;
|
|
105
|
+
for await (const column of columns) {
|
|
106
|
+
if (column.dataType === "UPDATED_AT") {
|
|
107
|
+
sortColumn = column.field;
|
|
108
|
+
this._setSortColumn(column.field);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!sortColumn) throw new ConfigurationError("This worksheet doesn't have a column of type UPDATED_AT.");
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
hooks: {
|
|
116
|
+
async deploy() {
|
|
117
|
+
await this.getUpdatedAtColumn();
|
|
118
|
+
await this.startEvent(25);
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
async run() {
|
|
122
|
+
await this.startEvent();
|
|
123
|
+
},
|
|
124
|
+
sampleEmit,
|
|
125
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"_id": "S3vBb3FZRQuFtW1mrj0U2g",
|
|
3
|
+
"createdAt": "2022-08-03T19:00:54.620Z",
|
|
4
|
+
"updatedAt": "2022-08-03T19:00:54.620Z",
|
|
5
|
+
"createdBy": "ocxAVW3oRSajt9yOKg7B-Q",
|
|
6
|
+
"updatedBy": "ocxAVW3oRSajt9yOKg7B-Q",
|
|
7
|
+
"cellData": [
|
|
8
|
+
{
|
|
9
|
+
"field": "col_1",
|
|
10
|
+
"data": "Person",
|
|
11
|
+
"dataType": "AUTOMATIC"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"field": "col_2",
|
|
15
|
+
"data": "Region",
|
|
16
|
+
"dataType": "AUTOMATIC"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
import { LIMIT } from "./common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
type: "app",
|
|
6
|
+
app: "spreadsheet_com",
|
|
7
|
+
propDefinitions: {
|
|
8
|
+
columnId: {
|
|
9
|
+
type: "string",
|
|
10
|
+
label: "Column Id",
|
|
11
|
+
description: "Unique column identifier in the worksheet.",
|
|
12
|
+
async options({
|
|
13
|
+
page, worksheetId,
|
|
14
|
+
}) {
|
|
15
|
+
const { items } = await this.listColumns({
|
|
16
|
+
worksheetId,
|
|
17
|
+
params: {
|
|
18
|
+
limit: LIMIT,
|
|
19
|
+
offset: LIMIT * page,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return items.map(({ field }) => field);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
workbookId: {
|
|
27
|
+
type: "string",
|
|
28
|
+
label: "Workbook Id",
|
|
29
|
+
description: "ID of the workbook.",
|
|
30
|
+
async options({ page }) {
|
|
31
|
+
const { items } = await this.listWorkbooks({
|
|
32
|
+
params: {
|
|
33
|
+
limit: LIMIT,
|
|
34
|
+
offset: LIMIT * page,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return items.map(({
|
|
39
|
+
_id: value, name: label,
|
|
40
|
+
}) => ({
|
|
41
|
+
label,
|
|
42
|
+
value,
|
|
43
|
+
}));
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
worksheetId: {
|
|
47
|
+
type: "string",
|
|
48
|
+
label: "Worksheet Id",
|
|
49
|
+
description: "ID of the worksheet.",
|
|
50
|
+
async options({
|
|
51
|
+
page, workbookId,
|
|
52
|
+
}) {
|
|
53
|
+
const { items } = await this.listWorksheets({
|
|
54
|
+
workbookId,
|
|
55
|
+
params: {
|
|
56
|
+
limit: LIMIT,
|
|
57
|
+
offset: LIMIT * page,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return items.map(({
|
|
62
|
+
_id: value, name: label,
|
|
63
|
+
}) => ({
|
|
64
|
+
label,
|
|
65
|
+
value,
|
|
66
|
+
}));
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
methods: {
|
|
71
|
+
_apiUrl() {
|
|
72
|
+
return "https://api.spreadsheet.com/v1";
|
|
73
|
+
},
|
|
74
|
+
_getHeaders() {
|
|
75
|
+
return {
|
|
76
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
_makeRequest({
|
|
81
|
+
$ = this, path, ...opts
|
|
82
|
+
}) {
|
|
83
|
+
const config = {
|
|
84
|
+
url: `${this._apiUrl()}/${path}`,
|
|
85
|
+
headers: this._getHeaders(),
|
|
86
|
+
...opts,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return axios($, config);
|
|
90
|
+
},
|
|
91
|
+
createRows({
|
|
92
|
+
worksheetId, ...args
|
|
93
|
+
}) {
|
|
94
|
+
return this._makeRequest({
|
|
95
|
+
method: "POST",
|
|
96
|
+
path: `worksheets/${worksheetId}/rows`,
|
|
97
|
+
...args,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
updateRows({
|
|
101
|
+
worksheetId, ...args
|
|
102
|
+
}) {
|
|
103
|
+
return this._makeRequest({
|
|
104
|
+
method: "PUT",
|
|
105
|
+
path: `worksheets/${worksheetId}/rows`,
|
|
106
|
+
...args,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
listColumns({
|
|
110
|
+
worksheetId, ...args
|
|
111
|
+
}) {
|
|
112
|
+
return this._makeRequest({
|
|
113
|
+
path: `worksheets/${worksheetId}/columns`,
|
|
114
|
+
...args,
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
listRows({
|
|
118
|
+
worksheetId, ...args
|
|
119
|
+
}) {
|
|
120
|
+
return this._makeRequest({
|
|
121
|
+
path: `worksheets/${worksheetId}/rows`,
|
|
122
|
+
...args,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
listWorkbooks(args = {}) {
|
|
126
|
+
return this._makeRequest({
|
|
127
|
+
path: "workbooks",
|
|
128
|
+
...args,
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
listWorksheets({
|
|
132
|
+
workbookId, ...args
|
|
133
|
+
}) {
|
|
134
|
+
return this._makeRequest({
|
|
135
|
+
path: `workbooks/${workbookId}/worksheets`,
|
|
136
|
+
...args,
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
async *paginate({
|
|
140
|
+
fn, params = {}, maxResults = null, ...args
|
|
141
|
+
}) {
|
|
142
|
+
let hasMore = false;
|
|
143
|
+
let count = 0;
|
|
144
|
+
let page = 0;
|
|
145
|
+
|
|
146
|
+
do {
|
|
147
|
+
params.limit = LIMIT;
|
|
148
|
+
params.offset = LIMIT * page;
|
|
149
|
+
page++;
|
|
150
|
+
const {
|
|
151
|
+
items,
|
|
152
|
+
hasMore: hasMoreItems,
|
|
153
|
+
} = await fn({
|
|
154
|
+
params,
|
|
155
|
+
...args,
|
|
156
|
+
});
|
|
157
|
+
for (const d of items) {
|
|
158
|
+
yield d;
|
|
159
|
+
|
|
160
|
+
if (maxResults && ++count === maxResults) {
|
|
161
|
+
return count;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
hasMore = hasMoreItems;
|
|
166
|
+
|
|
167
|
+
} while (hasMore);
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
};
|