@zerodot/airtable 1.0.0 → 1.0.1
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 +67 -13
- package/dist/index.cjs +7 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,22 +1,76 @@
|
|
|
1
1
|
# @zerodot/airtable
|
|
2
2
|
|
|
3
|
-
Airtable
|
|
3
|
+
<img src="https://raw.githubusercontent.com/zerodot-io/nodes/main/packages/airtable/airtable.svg" alt="Airtable logo" width="48" height="48">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Read and write records in Airtable tables. List, get, create, update, and delete records in your bases. Connect with a personal access token from Airtable.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- The credential test calls `GET /v0/meta/whoami`.
|
|
9
|
+
In zerodot, go to **System > Nodes** and install **Airtable**.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Manual: install `@zerodot/airtable` where the web app and the worker run, and add it to `ZERODOT_NODE_PACKAGES`.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
## Nodes
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
### Airtable (`airtable.api`)
|
|
17
16
|
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
- **Record**: list, get, create, update, delete
|
|
18
|
+
|
|
19
|
+
**Base and table.** Every operation needs **Base ID**, for example `appXXXXXXXXXXXXXX`. It also needs **Table ID or Name**, the ID or the name of the table in the base.
|
|
20
|
+
|
|
21
|
+
**Get, update, and delete.** These need **Record ID**, for example `recXXXXXXXXXXXXXX`.
|
|
22
|
+
|
|
23
|
+
**Create and update.** These need **Fields**, an object of field values. Keys are field names or field IDs. **Typecast** lets Airtable convert text values to the type of the field. **Return Fields by Field ID** returns the fields with their IDs as keys. **Update** sends a PATCH request with the fields you set.
|
|
24
|
+
|
|
25
|
+
**List.** These settings change the result:
|
|
26
|
+
|
|
27
|
+
- **Fields**: only return these fields. Leave empty to return all fields.
|
|
28
|
+
- **Filter by Formula**: an Airtable formula. For example, `{Done}=1` returns the records where the field `Done` is 1.
|
|
29
|
+
- **View**: the name or ID of a view in the table.
|
|
30
|
+
- **Sort**: a JSON array. For example, `[{"field":"Name","direction":"asc"}]`. Each item needs a `field`. `direction` is optional.
|
|
31
|
+
- **Max Records**: the most records that Airtable returns in total.
|
|
32
|
+
- **Page Size**: records per page, up to 100.
|
|
33
|
+
- **Return Fields by Field ID**: see above.
|
|
34
|
+
|
|
35
|
+
Without **Return All**, the node sends one request and returns one page. The output has `records` and, when more pages exist, an `offset`. The node has no input for an offset, so it cannot read the next page. Use **Return All** to read more records.
|
|
36
|
+
|
|
37
|
+
With **Return All**, the node follows the `offset` of each page until there are no more records. It stops at **Limit** records. The default is 100, and the maximum is 5000. If **Max Records** is set, the node also stops at that number, and the smaller of the two wins. Each request asks for **Page Size** records, up to 100. The default is 100.
|
|
38
|
+
|
|
39
|
+
**Output.** List returns `{ "records": [...] }` with Return All, or the Airtable answer for one page without it. Get, create, and update return the record as Airtable sends it, with `id`, `fields`, and `createdTime`. Delete returns the Airtable answer, for example `{ "records": [{ "id": "rec...", "deleted": true }] }`.
|
|
40
|
+
|
|
41
|
+
**Destructive operations.** **Delete** removes one record. Each run deletes one record ID. The node does not ask for a confirmation.
|
|
42
|
+
|
|
43
|
+
**Binary data.** The node does not read or write binary data.
|
|
44
|
+
|
|
45
|
+
**Limits and retries.** Each call has a timeout. The default is 30 seconds. On HTTP `429`, the node waits for the `Retry-After` seconds, or 30 seconds when the header is missing. It retries up to 3 times. It does not retry when the wait is longer than 30 seconds. The node does not follow redirects.
|
|
46
|
+
|
|
47
|
+
Error messages include the Airtable message and the error type. Hints are added for these statuses:
|
|
48
|
+
|
|
49
|
+
- `401`: the access token was not accepted.
|
|
50
|
+
- `403`: the token may lack access to the base or table.
|
|
51
|
+
- `404`: check the base, table, and record IDs.
|
|
52
|
+
- `422`: check the fields, formula, view, or record IDs.
|
|
53
|
+
- `429`: the rate limit was reached.
|
|
54
|
+
- `503`: Airtable is not available.
|
|
55
|
+
|
|
56
|
+
## Credentials
|
|
57
|
+
|
|
58
|
+
### Airtable Personal Access Token (`airtable.personalAccessToken`)
|
|
59
|
+
|
|
60
|
+
- **Access Token** (`accessToken`): the personal access token. This value is secret.
|
|
61
|
+
|
|
62
|
+
The token needs access to the bases and tables that you use. The node does not set scopes.
|
|
63
|
+
|
|
64
|
+
The test of the credential calls `GET /v0/meta/whoami`.
|
|
65
|
+
|
|
66
|
+
Setup:
|
|
67
|
+
|
|
68
|
+
1. Open the Airtable Builder Hub at `https://airtable.com/create/tokens`.
|
|
69
|
+
2. Create a personal access token. Give it access to the bases that you use.
|
|
70
|
+
3. Copy the token.
|
|
71
|
+
4. In zerodot, create an **Airtable Personal Access Token** credential.
|
|
72
|
+
5. Paste the token into **Access Token**. Save and test the credential.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
AGPL-3.0-only
|
package/dist/index.cjs
CHANGED
|
@@ -156,18 +156,19 @@ async function callAirtableListPage(access, request, options) {
|
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* A list. Follows `offset` until it has `limit` records, or all records when `limit` is null.
|
|
159
|
+
* `pageSize` is the records asked for per request, up to 100.
|
|
159
160
|
*/
|
|
160
|
-
async function callAirtableList(access, request, limit, options) {
|
|
161
|
+
async function callAirtableList(access, request, limit, options, pageSize = PAGE_SIZE) {
|
|
161
162
|
const wanted = Math.min(limit ?? 5e3, MAX_ITEMS);
|
|
162
163
|
const items = [];
|
|
163
164
|
let offset;
|
|
164
165
|
while (items.length < wanted) {
|
|
165
|
-
const
|
|
166
|
+
const size = Math.min(pageSize, PAGE_SIZE, wanted - items.length);
|
|
166
167
|
const page = await callAirtableListPage(access, {
|
|
167
168
|
...request,
|
|
168
169
|
query: {
|
|
169
170
|
...request.query,
|
|
170
|
-
pageSize,
|
|
171
|
+
pageSize: size,
|
|
171
172
|
...offset ? { offset } : {}
|
|
172
173
|
}
|
|
173
174
|
}, options);
|
|
@@ -511,13 +512,15 @@ const nodes = [(0, _zerodot_node_sdk.defineNode)({
|
|
|
511
512
|
if (config.returnAll) {
|
|
512
513
|
const query = { ...request.query ?? {} };
|
|
513
514
|
delete query.maxRecords;
|
|
515
|
+
delete query.pageSize;
|
|
514
516
|
delete query.offset;
|
|
517
|
+
const total = config.maxRecords === void 0 ? config.limit : Math.min(config.limit, config.maxRecords);
|
|
515
518
|
return {
|
|
516
519
|
port: "out",
|
|
517
520
|
data: { records: await callAirtableList(access, {
|
|
518
521
|
...request,
|
|
519
522
|
query
|
|
520
|
-
},
|
|
523
|
+
}, total, options, config.pageSize) }
|
|
521
524
|
};
|
|
522
525
|
}
|
|
523
526
|
return {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodot/airtable",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Work with Airtable records. List, get, create, update, and delete records in your bases.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
|
+
"homepage": "https://github.com/zerodot-io/nodes/tree/main/packages/airtable",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/zerodot-io/nodes.git",
|