easy-airtable-api 0.0.9 → 0.0.11
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 +17 -8
- package/lib/requests.d.ts +20 -20
- package/lib/requests.js +3 -5
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -30,10 +30,10 @@ type Fields = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
const record = await getRecord<Fields>({
|
|
33
|
-
apiKey:
|
|
34
|
-
baseId:
|
|
35
|
-
tableId:
|
|
36
|
-
recordId:
|
|
33
|
+
apiKey: "apiKey",
|
|
34
|
+
baseId: "baseId",
|
|
35
|
+
tableId: "tableId",
|
|
36
|
+
recordId: "recordId",
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -49,9 +49,9 @@ type Fields = {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const records = await getRecords<Fields>({
|
|
52
|
-
apiKey:
|
|
53
|
-
baseId:
|
|
54
|
-
tableId:
|
|
52
|
+
apiKey: "apiKey",
|
|
53
|
+
baseId: "baseId",
|
|
54
|
+
tableId: "tableId",
|
|
55
55
|
options: {
|
|
56
56
|
maxRecords: 500,
|
|
57
57
|
},
|
|
@@ -60,6 +60,15 @@ const records = await getRecords<Fields>({
|
|
|
60
60
|
|
|
61
61
|
## Changelog
|
|
62
62
|
|
|
63
|
+
### 0.0.11
|
|
64
|
+
|
|
65
|
+
- Make apiKey, baseId, tableId default to undefined #12
|
|
66
|
+
- Missing .js in utils import #13
|
|
67
|
+
|
|
68
|
+
### 0.0.10
|
|
69
|
+
|
|
70
|
+
- Fixed deleteRecords implementation errors.
|
|
71
|
+
|
|
63
72
|
### 0.0.9
|
|
64
73
|
|
|
65
74
|
- Implemented the deleteRecords method.
|
|
@@ -104,4 +113,4 @@ const records = await getRecords<Fields>({
|
|
|
104
113
|
|
|
105
114
|
### 0.0.1
|
|
106
115
|
|
|
107
|
-
- Initial project setup with no real functionality implemented.
|
|
116
|
+
- Initial project setup with no real functionality implemented.
|
package/lib/requests.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { AirtableRecord,
|
|
1
|
+
import { AirtableRecord, DeleteRecordsResponse, GetRecordsQueryParameters } from './types/records';
|
|
2
2
|
export declare function getRecord<Fields>({ apiKey, baseId, tableId, recordId, }: {
|
|
3
|
-
apiKey
|
|
4
|
-
baseId
|
|
5
|
-
tableId
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseId?: string;
|
|
5
|
+
tableId?: string;
|
|
6
6
|
recordId: string;
|
|
7
7
|
}): Promise<AirtableRecord<Fields>>;
|
|
8
8
|
export declare function getRecords<Fields>({ apiKey, baseId, tableId, options, }: {
|
|
9
|
-
apiKey
|
|
10
|
-
baseId
|
|
11
|
-
tableId
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
baseId?: string;
|
|
11
|
+
tableId?: string;
|
|
12
12
|
options?: GetRecordsQueryParameters;
|
|
13
13
|
}): Promise<AirtableRecord<Fields>[]>;
|
|
14
14
|
export declare function updateRecord<Fields>({ apiKey, baseId, tableId, recordId, fields, options, }: {
|
|
15
|
-
apiKey
|
|
16
|
-
baseId
|
|
17
|
-
tableId
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
baseId?: string;
|
|
17
|
+
tableId?: string;
|
|
18
18
|
recordId: string;
|
|
19
19
|
fields: Fields;
|
|
20
20
|
options?: {
|
|
@@ -24,9 +24,9 @@ export declare function updateRecord<Fields>({ apiKey, baseId, tableId, recordId
|
|
|
24
24
|
};
|
|
25
25
|
}): Promise<AirtableRecord<Fields>>;
|
|
26
26
|
export declare function updateRecords<Fields>({ apiKey, baseId, tableId, records, options, }: {
|
|
27
|
-
apiKey
|
|
28
|
-
baseId
|
|
29
|
-
tableId
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
baseId?: string;
|
|
29
|
+
tableId?: string;
|
|
30
30
|
records: {
|
|
31
31
|
id: string;
|
|
32
32
|
fields: Fields;
|
|
@@ -40,9 +40,9 @@ export declare function updateRecords<Fields>({ apiKey, baseId, tableId, records
|
|
|
40
40
|
records: AirtableRecord<Fields>[];
|
|
41
41
|
}>;
|
|
42
42
|
export declare function updateRecordsUpsert<Fields>({ apiKey, baseId, tableId, records, options, }: {
|
|
43
|
-
apiKey
|
|
44
|
-
baseId
|
|
45
|
-
tableId
|
|
43
|
+
apiKey?: string;
|
|
44
|
+
baseId?: string;
|
|
45
|
+
tableId?: string;
|
|
46
46
|
records: {
|
|
47
47
|
id?: string;
|
|
48
48
|
fields: Fields;
|
|
@@ -59,8 +59,8 @@ export declare function updateRecordsUpsert<Fields>({ apiKey, baseId, tableId, r
|
|
|
59
59
|
records: AirtableRecord<Fields>[];
|
|
60
60
|
}>;
|
|
61
61
|
export declare function deleteRecords({ apiKey, baseId, tableId, recordIds, }: {
|
|
62
|
-
apiKey
|
|
63
|
-
baseId
|
|
64
|
-
tableId
|
|
65
|
-
recordIds:
|
|
62
|
+
apiKey?: string;
|
|
63
|
+
baseId?: string;
|
|
64
|
+
tableId?: string;
|
|
65
|
+
recordIds: string[];
|
|
66
66
|
}): Promise<DeleteRecordsResponse>;
|
package/lib/requests.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { request } from 'https';
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
-
import { delay } from './utils';
|
|
3
|
+
import { delay } from './utils.js';
|
|
4
4
|
export async function getRecord({ apiKey, baseId, tableId, recordId, }) {
|
|
5
5
|
return await airtableRequest({
|
|
6
6
|
apiKey,
|
|
@@ -139,15 +139,13 @@ export async function deleteRecords({ apiKey, baseId, tableId, recordIds, }) {
|
|
|
139
139
|
}
|
|
140
140
|
let combinedResults = [];
|
|
141
141
|
for (const chunk of chunks) {
|
|
142
|
+
const query = chunk.map((id) => `records[]=${id}`).join('&');
|
|
142
143
|
const result = await airtableRequest({
|
|
143
144
|
apiKey,
|
|
144
145
|
baseId,
|
|
145
146
|
tableId,
|
|
146
|
-
endpoint:
|
|
147
|
+
endpoint: `?${query}`,
|
|
147
148
|
method: 'DELETE',
|
|
148
|
-
body: {
|
|
149
|
-
records: chunk,
|
|
150
|
-
},
|
|
151
149
|
});
|
|
152
150
|
combinedResults = combinedResults.concat(result.records);
|
|
153
151
|
await delay(500);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-airtable-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "An easy way to connect to Airtable via their API.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
18
18
|
"test": "vitest",
|
|
19
19
|
"testGetRecords": "vitest get-records.test.ts",
|
|
20
|
-
"testUpdateRecords": "vitest update-records.test.ts"
|
|
20
|
+
"testUpdateRecords": "vitest update-records.test.ts",
|
|
21
|
+
"testDeleteRecords": "vitest delete-records.test.ts"
|
|
21
22
|
},
|
|
22
23
|
"keywords": [
|
|
23
24
|
"airtable"
|