easy-airtable-api 0.0.16 → 0.1.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/CHANGELOG.md +16 -0
- package/README.md +224 -1
- package/easy-airtable-api-0.1.0.tgz +0 -0
- package/lib/bases.d.ts +18 -0
- package/lib/bases.js +40 -0
- package/lib/codegen/emit-typescript.js +43 -30
- package/lib/codegen/identifiers.d.ts +4 -0
- package/lib/codegen/identifiers.js +24 -2
- package/lib/codegen/load-schema.js +1 -1
- package/lib/codegen/map-field.d.ts +12 -13
- package/lib/codegen/map-field.js +74 -56
- package/lib/codegen/normalize-schema.js +31 -13
- package/lib/codegen/types.d.ts +2 -0
- package/lib/index.d.ts +8 -3
- package/lib/index.js +3 -1
- package/lib/records.d.ts +110 -9
- package/lib/records.js +111 -22
- package/lib/requests.d.ts +64 -5
- package/lib/requests.js +280 -30
- package/lib/types/bases.d.ts +8 -40
- package/lib/types/fields.d.ts +12 -10
- package/lib/types/records.d.ts +8 -0
- package/package.json +7 -6
package/lib/codegen/map-field.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { getChoices, getRecordValue, stringifyUnion } from './utils.js';
|
|
2
|
+
const FIELD_TYPE_ALIASES = {
|
|
3
|
+
attachment: 'multipleAttachments',
|
|
4
|
+
linkToAnotherRecord: 'multipleRecordLinks',
|
|
5
|
+
multipleLookupValues: 'lookup',
|
|
6
|
+
};
|
|
2
7
|
const READONLY_FIELD_TYPES = new Set([
|
|
3
8
|
'aiText',
|
|
4
9
|
'autoNumber',
|
|
@@ -23,6 +28,9 @@ const COMPUTED_FIELD_TYPES = new Set([
|
|
|
23
28
|
'rollup',
|
|
24
29
|
'syncSource',
|
|
25
30
|
]);
|
|
31
|
+
function canonicalizeFieldType(type) {
|
|
32
|
+
return FIELD_TYPE_ALIASES[type] ?? type;
|
|
33
|
+
}
|
|
26
34
|
function resolveUnknown(field, unknownFieldBehavior, reason) {
|
|
27
35
|
const warning = reason
|
|
28
36
|
? `${field.name}: ${reason}`
|
|
@@ -30,13 +38,18 @@ function resolveUnknown(field, unknownFieldBehavior, reason) {
|
|
|
30
38
|
if (unknownFieldBehavior === 'error') {
|
|
31
39
|
throw new Error(warning);
|
|
32
40
|
}
|
|
33
|
-
return {
|
|
41
|
+
return {
|
|
42
|
+
type: 'unknown',
|
|
43
|
+
warning,
|
|
44
|
+
collection: 'scalar',
|
|
45
|
+
};
|
|
34
46
|
}
|
|
35
47
|
function resolveUnknownArray(field, unknownFieldBehavior, reason) {
|
|
36
48
|
const resolved = resolveUnknown(field, unknownFieldBehavior, reason);
|
|
37
49
|
return {
|
|
38
50
|
type: 'unknown[]',
|
|
39
51
|
warning: resolved.warning,
|
|
52
|
+
collection: 'array',
|
|
40
53
|
};
|
|
41
54
|
}
|
|
42
55
|
function buildEnumType(field, enumMode) {
|
|
@@ -67,10 +80,12 @@ function mapResultDescriptor(descriptor, field, enumMode, unknownFieldBehavior)
|
|
|
67
80
|
}).read;
|
|
68
81
|
}
|
|
69
82
|
export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
83
|
+
const canonicalType = canonicalizeFieldType(field.type);
|
|
84
|
+
const normalizedField = canonicalType === field.type ? field : { ...field, type: canonicalType };
|
|
85
|
+
const readonly = READONLY_FIELD_TYPES.has(canonicalType);
|
|
86
|
+
const computed = COMPUTED_FIELD_TYPES.has(canonicalType);
|
|
87
|
+
const linkedTableId = getRecordValue(normalizedField.options, 'linkedTableId');
|
|
88
|
+
switch (canonicalType) {
|
|
74
89
|
case 'singleLineText':
|
|
75
90
|
case 'multilineText':
|
|
76
91
|
case 'richText':
|
|
@@ -80,15 +95,15 @@ export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
|
80
95
|
case 'date':
|
|
81
96
|
case 'dateTime':
|
|
82
97
|
return {
|
|
83
|
-
read: { type: 'string' },
|
|
84
|
-
create: { type: 'string' },
|
|
85
|
-
update: { type: 'string' },
|
|
98
|
+
read: { type: 'string', collection: 'scalar' },
|
|
99
|
+
create: { type: 'string', collection: 'scalar' },
|
|
100
|
+
update: { type: 'string', collection: 'scalar' },
|
|
86
101
|
readonly,
|
|
87
102
|
computed,
|
|
88
103
|
};
|
|
89
104
|
case 'aiText':
|
|
90
105
|
return {
|
|
91
|
-
read: { type: '
|
|
106
|
+
read: { type: 'AICell', collection: 'scalar' },
|
|
92
107
|
readonly,
|
|
93
108
|
computed,
|
|
94
109
|
};
|
|
@@ -98,114 +113,112 @@ export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
|
98
113
|
case 'rating':
|
|
99
114
|
case 'duration':
|
|
100
115
|
return {
|
|
101
|
-
read: { type: 'number' },
|
|
102
|
-
create: { type: 'number' },
|
|
103
|
-
update: { type: 'number' },
|
|
116
|
+
read: { type: 'number', collection: 'scalar' },
|
|
117
|
+
create: { type: 'number', collection: 'scalar' },
|
|
118
|
+
update: { type: 'number', collection: 'scalar' },
|
|
104
119
|
readonly,
|
|
105
120
|
computed,
|
|
106
121
|
};
|
|
107
122
|
case 'checkbox':
|
|
108
123
|
return {
|
|
109
|
-
read: { type: 'boolean' },
|
|
110
|
-
create: { type: 'boolean' },
|
|
111
|
-
update: { type: 'boolean' },
|
|
124
|
+
read: { type: 'boolean', collection: 'scalar' },
|
|
125
|
+
create: { type: 'boolean', collection: 'scalar' },
|
|
126
|
+
update: { type: 'boolean', collection: 'scalar' },
|
|
112
127
|
readonly,
|
|
113
128
|
computed,
|
|
114
129
|
};
|
|
115
130
|
case 'singleSelect': {
|
|
116
|
-
const enumType = buildEnumType(
|
|
131
|
+
const enumType = buildEnumType(normalizedField, enumMode) ?? 'string';
|
|
117
132
|
return {
|
|
118
|
-
read: { type: enumType },
|
|
119
|
-
create: { type: enumType },
|
|
120
|
-
update: { type: enumType },
|
|
133
|
+
read: { type: enumType, collection: 'scalar' },
|
|
134
|
+
create: { type: enumType, collection: 'scalar' },
|
|
135
|
+
update: { type: enumType, collection: 'scalar' },
|
|
121
136
|
readonly,
|
|
122
137
|
computed,
|
|
123
138
|
enumTypeAlias: enumType,
|
|
124
139
|
};
|
|
125
140
|
}
|
|
126
141
|
case 'multipleSelects': {
|
|
127
|
-
const enumType = buildEnumType(
|
|
142
|
+
const enumType = buildEnumType(normalizedField, enumMode) ?? 'string';
|
|
128
143
|
return {
|
|
129
|
-
read: { type: `Array<${enumType}
|
|
130
|
-
create: { type: `Array<${enumType}
|
|
131
|
-
update: { type: `Array<${enumType}
|
|
144
|
+
read: { type: `Array<${enumType}>`, collection: 'array' },
|
|
145
|
+
create: { type: `Array<${enumType}>`, collection: 'array' },
|
|
146
|
+
update: { type: `Array<${enumType}>`, collection: 'array' },
|
|
132
147
|
readonly,
|
|
133
148
|
computed,
|
|
134
149
|
enumTypeAlias: enumType,
|
|
135
150
|
};
|
|
136
151
|
}
|
|
137
152
|
case 'multipleAttachments':
|
|
138
|
-
case 'attachment':
|
|
139
153
|
return {
|
|
140
|
-
read: { type: 'Attachment[]' },
|
|
141
|
-
create: { type: 'AttachmentWrite[]' },
|
|
142
|
-
update: { type: 'AttachmentWrite[]' },
|
|
154
|
+
read: { type: 'Attachment[]', collection: 'array' },
|
|
155
|
+
create: { type: 'AttachmentWrite[]', collection: 'array' },
|
|
156
|
+
update: { type: 'AttachmentWrite[]', collection: 'array' },
|
|
143
157
|
readonly,
|
|
144
158
|
computed,
|
|
145
159
|
};
|
|
146
160
|
case 'singleCollaborator':
|
|
147
161
|
return {
|
|
148
|
-
read: { type: 'Collaborator' },
|
|
149
|
-
create: { type: '
|
|
150
|
-
update: { type: '
|
|
162
|
+
read: { type: 'Collaborator', collection: 'scalar' },
|
|
163
|
+
create: { type: 'CollaboratorWrite', collection: 'scalar' },
|
|
164
|
+
update: { type: 'CollaboratorWrite', collection: 'scalar' },
|
|
151
165
|
readonly,
|
|
152
166
|
computed,
|
|
153
167
|
};
|
|
154
168
|
case 'multipleCollaborators':
|
|
155
169
|
return {
|
|
156
|
-
read: { type: 'Collaborator[]' },
|
|
157
|
-
create: { type: '
|
|
158
|
-
update: { type: '
|
|
170
|
+
read: { type: 'Collaborator[]', collection: 'array' },
|
|
171
|
+
create: { type: 'CollaboratorWrite[]', collection: 'array' },
|
|
172
|
+
update: { type: 'CollaboratorWrite[]', collection: 'array' },
|
|
159
173
|
readonly,
|
|
160
174
|
computed,
|
|
161
175
|
};
|
|
162
176
|
case 'multipleRecordLinks':
|
|
163
|
-
case 'linkToAnotherRecord':
|
|
164
177
|
return {
|
|
165
|
-
read: { type: 'string[]' },
|
|
166
|
-
create: { type: 'string[]' },
|
|
167
|
-
update: { type: 'string[]' },
|
|
178
|
+
read: { type: 'string[]', collection: 'array' },
|
|
179
|
+
create: { type: 'string[]', collection: 'array' },
|
|
180
|
+
update: { type: 'string[]', collection: 'array' },
|
|
168
181
|
readonly,
|
|
169
182
|
computed,
|
|
170
183
|
linkedTableId,
|
|
171
184
|
};
|
|
172
185
|
case 'barcode':
|
|
173
186
|
return {
|
|
174
|
-
read: { type: '
|
|
175
|
-
create: { type: '
|
|
176
|
-
update: { type: '
|
|
187
|
+
read: { type: 'BarcodeCell', collection: 'scalar' },
|
|
188
|
+
create: { type: 'BarcodeWrite', collection: 'scalar' },
|
|
189
|
+
update: { type: 'BarcodeWrite', collection: 'scalar' },
|
|
177
190
|
readonly,
|
|
178
191
|
computed,
|
|
179
192
|
};
|
|
180
193
|
case 'createdTime':
|
|
181
194
|
case 'lastModifiedTime':
|
|
182
195
|
return {
|
|
183
|
-
read: { type: 'string' },
|
|
196
|
+
read: { type: 'string', collection: 'scalar' },
|
|
184
197
|
readonly,
|
|
185
198
|
computed,
|
|
186
199
|
};
|
|
187
200
|
case 'createdBy':
|
|
188
201
|
case 'lastModifiedBy':
|
|
189
202
|
return {
|
|
190
|
-
read: { type: 'Collaborator' },
|
|
203
|
+
read: { type: 'Collaborator', collection: 'scalar' },
|
|
191
204
|
readonly,
|
|
192
205
|
computed,
|
|
193
206
|
};
|
|
194
207
|
case 'button':
|
|
195
208
|
return {
|
|
196
|
-
read: { type: '
|
|
209
|
+
read: { type: 'ButtonCell', collection: 'scalar' },
|
|
197
210
|
readonly,
|
|
198
211
|
computed,
|
|
199
212
|
};
|
|
200
213
|
case 'count':
|
|
201
214
|
case 'autoNumber':
|
|
202
215
|
return {
|
|
203
|
-
read: { type: 'number' },
|
|
216
|
+
read: { type: 'number', collection: 'scalar' },
|
|
204
217
|
readonly,
|
|
205
218
|
computed,
|
|
206
219
|
};
|
|
207
220
|
case 'formula': {
|
|
208
|
-
const result = mapResultDescriptor(getRecordValue(
|
|
221
|
+
const result = mapResultDescriptor(getRecordValue(normalizedField.options, 'result'), normalizedField, enumMode, unknownFieldBehavior);
|
|
209
222
|
return {
|
|
210
223
|
read: result,
|
|
211
224
|
readonly,
|
|
@@ -213,10 +226,10 @@ export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
|
213
226
|
};
|
|
214
227
|
}
|
|
215
228
|
case 'rollup': {
|
|
216
|
-
const result = getRecordValue(
|
|
229
|
+
const result = getRecordValue(normalizedField.options, 'result');
|
|
217
230
|
const mapped = result
|
|
218
|
-
? mapResultDescriptor(result,
|
|
219
|
-
: resolveUnknown(
|
|
231
|
+
? mapResultDescriptor(result, normalizedField, enumMode, unknownFieldBehavior)
|
|
232
|
+
: resolveUnknown(normalizedField, unknownFieldBehavior, 'rollup result metadata is missing');
|
|
220
233
|
return {
|
|
221
234
|
read: mapped,
|
|
222
235
|
readonly,
|
|
@@ -224,20 +237,24 @@ export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
|
224
237
|
};
|
|
225
238
|
}
|
|
226
239
|
case 'lookup': {
|
|
227
|
-
const result = getRecordValue(
|
|
240
|
+
const result = getRecordValue(normalizedField.options, 'result');
|
|
228
241
|
const mapped = result
|
|
229
|
-
? mapResultDescriptor(result,
|
|
230
|
-
: resolveUnknownArray(
|
|
242
|
+
? mapResultDescriptor(result, normalizedField, enumMode, unknownFieldBehavior)
|
|
243
|
+
: resolveUnknownArray(normalizedField, unknownFieldBehavior, 'lookup result metadata is missing');
|
|
231
244
|
return {
|
|
232
|
-
read: mapped.
|
|
233
|
-
?
|
|
234
|
-
: {
|
|
245
|
+
read: mapped.collection === 'array'
|
|
246
|
+
? mapped
|
|
247
|
+
: {
|
|
248
|
+
...mapped,
|
|
249
|
+
type: mapped.type === 'unknown' ? 'unknown[]' : `Array<${mapped.type}>`,
|
|
250
|
+
collection: 'array',
|
|
251
|
+
},
|
|
235
252
|
readonly,
|
|
236
253
|
computed,
|
|
237
254
|
};
|
|
238
255
|
}
|
|
239
256
|
default: {
|
|
240
|
-
const unknown = resolveUnknown(
|
|
257
|
+
const unknown = resolveUnknown(normalizedField, unknownFieldBehavior);
|
|
241
258
|
return {
|
|
242
259
|
read: unknown,
|
|
243
260
|
create: readonly ? undefined : unknown,
|
|
@@ -248,7 +265,7 @@ export function mapFieldTypes({ field, enumMode, unknownFieldBehavior, }) {
|
|
|
248
265
|
}
|
|
249
266
|
}
|
|
250
267
|
}
|
|
251
|
-
export function mapFieldToNormalizedField({ field, enumMode, unknownFieldBehavior, tsKey, tsTypeName, }) {
|
|
268
|
+
export function mapFieldToNormalizedField({ field, enumMode, unknownFieldBehavior, tsKey, tsConstKey, tsTypeName, }) {
|
|
252
269
|
const mapped = mapFieldTypes({
|
|
253
270
|
field,
|
|
254
271
|
enumMode,
|
|
@@ -263,6 +280,7 @@ export function mapFieldToNormalizedField({ field, enumMode, unknownFieldBehavio
|
|
|
263
280
|
id: field.id,
|
|
264
281
|
name: field.name,
|
|
265
282
|
tsKey,
|
|
283
|
+
tsConstKey,
|
|
266
284
|
tsTypeName,
|
|
267
285
|
airtableType: field.type,
|
|
268
286
|
readonly: mapped.readonly,
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { makeUniquePascalNames, toPascalCase } from './identifiers.js';
|
|
1
|
+
import { makeUniqueConstKeys, makeUniquePascalNames, toPascalCase, toSafeConstKey, } from './identifiers.js';
|
|
2
2
|
import { mapFieldToNormalizedField } from './map-field.js';
|
|
3
3
|
import { compareByNameThenId, ensureArray } from './utils.js';
|
|
4
|
+
function countBy(items, getKey) {
|
|
5
|
+
const counts = new Map();
|
|
6
|
+
items.forEach((item) => {
|
|
7
|
+
const key = getKey(item);
|
|
8
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
9
|
+
});
|
|
10
|
+
return counts;
|
|
11
|
+
}
|
|
4
12
|
export function normalizeSchema({ schema, tableNameOrId, enumMode, unknownFieldBehavior, }) {
|
|
5
13
|
const filters = new Set(ensureArray(tableNameOrId));
|
|
6
14
|
const selectedTables = [...schema.tables]
|
|
@@ -15,34 +23,43 @@ export function normalizeSchema({ schema, tableNameOrId, enumMode, unknownFieldB
|
|
|
15
23
|
}
|
|
16
24
|
const warnings = [];
|
|
17
25
|
const tableNames = makeUniquePascalNames(selectedTables);
|
|
18
|
-
const
|
|
19
|
-
selectedTables
|
|
20
|
-
|
|
21
|
-
sanitizedTableNameCounts.set(baseName, (sanitizedTableNameCounts.get(baseName) ?? 0) + 1);
|
|
22
|
-
});
|
|
26
|
+
const tableConstKeys = makeUniqueConstKeys(selectedTables);
|
|
27
|
+
const tableTypeNameCounts = countBy(selectedTables, (table) => toPascalCase(table.name));
|
|
28
|
+
const tableConstKeyCounts = countBy(selectedTables, (table) => toSafeConstKey(table.name));
|
|
23
29
|
const tables = selectedTables.map((table) => {
|
|
24
30
|
const tsName = tableNames.get(table.id) ?? table.name;
|
|
25
|
-
|
|
31
|
+
const tsConstKey = tableConstKeys.get(table.id) ?? table.name;
|
|
32
|
+
if ((tableTypeNameCounts.get(toPascalCase(table.name)) ?? 0) > 1) {
|
|
26
33
|
warnings.push(`Table name collision detected for ${table.name}. Generated type name ${tsName} includes a stable suffix.`);
|
|
27
34
|
}
|
|
35
|
+
if ((tableConstKeyCounts.get(toSafeConstKey(table.name)) ?? 0) > 1) {
|
|
36
|
+
warnings.push(`Table const key collision detected for ${table.name}. Generated tables key ${tsConstKey} includes a stable suffix.`);
|
|
37
|
+
}
|
|
28
38
|
const fieldNames = makeUniquePascalNames(table.fields);
|
|
29
|
-
const
|
|
30
|
-
table.fields
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
39
|
+
const fieldConstKeys = makeUniqueConstKeys(table.fields);
|
|
40
|
+
const exactFieldNameCounts = countBy(table.fields, (field) => field.name);
|
|
41
|
+
const fieldTypeNameCounts = countBy(table.fields, (field) => toPascalCase(field.name));
|
|
42
|
+
const fieldConstKeyCounts = countBy(table.fields, (field) => toSafeConstKey(field.name));
|
|
34
43
|
const fields = table.fields.map((field) => {
|
|
35
44
|
const fieldTsName = fieldNames.get(field.id) ?? field.name;
|
|
45
|
+
const fieldTsConstKey = fieldConstKeys.get(field.id) ?? field.name;
|
|
36
46
|
const normalizedField = mapFieldToNormalizedField({
|
|
37
47
|
field,
|
|
38
48
|
enumMode,
|
|
39
49
|
unknownFieldBehavior,
|
|
40
50
|
tsKey: field.name,
|
|
51
|
+
tsConstKey: fieldTsConstKey,
|
|
41
52
|
tsTypeName: `${tsName}${fieldTsName}`,
|
|
42
53
|
});
|
|
43
|
-
if ((
|
|
54
|
+
if ((exactFieldNameCounts.get(field.name) ?? 0) > 1) {
|
|
55
|
+
warnings.push(`Duplicate field name detected for ${table.name}.${field.name}. Generated interfaces merge the colliding fields into a union.`);
|
|
56
|
+
}
|
|
57
|
+
if ((fieldTypeNameCounts.get(toPascalCase(field.name)) ?? 0) > 1) {
|
|
44
58
|
warnings.push(`Field name collision detected for ${table.name}.${field.name}. Generated helper type name ${normalizedField.tsTypeName} includes a stable suffix.`);
|
|
45
59
|
}
|
|
60
|
+
if ((fieldConstKeyCounts.get(toSafeConstKey(field.name)) ?? 0) > 1) {
|
|
61
|
+
warnings.push(`Field const key collision detected for ${table.name}.${field.name}. Generated fields key ${normalizedField.tsConstKey} includes a stable suffix.`);
|
|
62
|
+
}
|
|
46
63
|
warnings.push(...normalizedField.warnings.map((warning) => `${table.name}.${warning}`));
|
|
47
64
|
return normalizedField;
|
|
48
65
|
});
|
|
@@ -50,6 +67,7 @@ export function normalizeSchema({ schema, tableNameOrId, enumMode, unknownFieldB
|
|
|
50
67
|
id: table.id,
|
|
51
68
|
name: table.name,
|
|
52
69
|
tsName,
|
|
70
|
+
tsConstKey,
|
|
53
71
|
primaryFieldId: table.primaryFieldId,
|
|
54
72
|
fields,
|
|
55
73
|
};
|
package/lib/codegen/types.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface NormalizedTable {
|
|
|
41
41
|
id: string;
|
|
42
42
|
name: string;
|
|
43
43
|
tsName: string;
|
|
44
|
+
tsConstKey: string;
|
|
44
45
|
primaryFieldId: string;
|
|
45
46
|
fields: NormalizedField[];
|
|
46
47
|
}
|
|
@@ -48,6 +49,7 @@ export interface NormalizedField {
|
|
|
48
49
|
id: string;
|
|
49
50
|
name: string;
|
|
50
51
|
tsKey: string;
|
|
52
|
+
tsConstKey: string;
|
|
51
53
|
tsTypeName: string;
|
|
52
54
|
airtableType: string;
|
|
53
55
|
readonly: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
export { getRecord, getRecords, createRecord, createRecords, updateRecord, updateRecords, updateRecordsUpsert, deleteRecords, } from './records.js';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { getRecord, getRecordsPage, iterateRecordsPages, getRecords, createRecord, createRecords, updateRecord, replaceRecord, updateRecords, replaceRecords, updateRecordsUpsert, deleteRecord, deleteRecords, } from './records.js';
|
|
2
|
+
export { listBases, createBase, getBaseSchema } from './bases.js';
|
|
3
|
+
export { airtableRequestRaw, AirtableApiError } from './requests.js';
|
|
4
|
+
export type { AirtableRetryOptions } from './requests.js';
|
|
5
|
+
export type { AirtableRecord, GeneratedRecordFieldsCompatibleGetRecordOptions, GeneratedRecordFieldsCompatibleGetRecordsOptions, } from './types/records.js';
|
|
6
|
+
export type { CreateBaseFieldConfig, CreateBaseRequestBody, CreateBaseResponse, CreateBaseTableConfig, ListBasesResponse, } from './types/bases.js';
|
|
7
|
+
export type { AirtableBaseSchema, AirtableFieldSchema, AirtableTableSchema, AirtableViewSchema, } from './types/metadata.js';
|
|
8
|
+
export type { AICell, Attachment, AttachmentWrite, Barcode, BarcodeCell, BarcodeWrite, ButtonCell, ButtonFieldValue, Collaborator, CollaboratorWrite, } from './types/fields.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { getRecord, getRecords, createRecord, createRecords, updateRecord, updateRecords, updateRecordsUpsert, deleteRecords, } from './records.js';
|
|
1
|
+
export { getRecord, getRecordsPage, iterateRecordsPages, getRecords, createRecord, createRecords, updateRecord, replaceRecord, updateRecords, replaceRecords, updateRecordsUpsert, deleteRecord, deleteRecords, } from './records.js';
|
|
2
|
+
export { listBases, createBase, getBaseSchema } from './bases.js';
|
|
3
|
+
export { airtableRequestRaw, AirtableApiError } from './requests.js';
|
package/lib/records.d.ts
CHANGED
|
@@ -1,17 +1,76 @@
|
|
|
1
|
-
import { AirtableRecord, DeleteRecordsResponse, GetRecordsQueryParameters } from './types/records.js';
|
|
2
|
-
|
|
1
|
+
import { AirtableRecord, DeleteRecordResponse, DeleteRecordsResponse, GeneratedRecordFieldsCompatibleGetRecordOptions, GeneratedRecordFieldsCompatibleGetRecordsOptions, GetRecordQueryParameters, GetRecordsQueryParameters } from './types/records.js';
|
|
2
|
+
import type { AirtableRetryOptions } from './requests.js';
|
|
3
|
+
export declare function getRecord<Fields>({ apiKey, baseId, tableId, recordId, options, retry, }: {
|
|
3
4
|
apiKey: string;
|
|
4
5
|
baseId: string;
|
|
5
6
|
tableId: string;
|
|
6
7
|
recordId: string;
|
|
8
|
+
options?: GeneratedRecordFieldsCompatibleGetRecordOptions;
|
|
9
|
+
retry?: AirtableRetryOptions;
|
|
7
10
|
}): Promise<AirtableRecord<Fields>>;
|
|
8
|
-
export declare function
|
|
11
|
+
export declare function getRecord({ apiKey, baseId, tableId, recordId, options, retry, }: {
|
|
12
|
+
apiKey: string;
|
|
13
|
+
baseId: string;
|
|
14
|
+
tableId: string;
|
|
15
|
+
recordId: string;
|
|
16
|
+
options?: GetRecordQueryParameters;
|
|
17
|
+
retry?: AirtableRetryOptions;
|
|
18
|
+
}): Promise<AirtableRecord<Record<string, unknown>>>;
|
|
19
|
+
export declare function getRecordsPage<Fields>({ apiKey, baseId, tableId, options, retry, }: {
|
|
20
|
+
apiKey: string;
|
|
21
|
+
baseId: string;
|
|
22
|
+
tableId: string;
|
|
23
|
+
options?: GeneratedRecordFieldsCompatibleGetRecordsOptions;
|
|
24
|
+
retry?: AirtableRetryOptions;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
records: AirtableRecord<Fields>[];
|
|
27
|
+
offset?: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare function getRecordsPage({ apiKey, baseId, tableId, options, retry, }: {
|
|
9
30
|
apiKey: string;
|
|
10
31
|
baseId: string;
|
|
11
32
|
tableId: string;
|
|
12
33
|
options?: GetRecordsQueryParameters;
|
|
34
|
+
retry?: AirtableRetryOptions;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
records: AirtableRecord<Record<string, unknown>>[];
|
|
37
|
+
offset?: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function iterateRecordsPages<Fields>({ apiKey, baseId, tableId, options, retry, }: {
|
|
40
|
+
apiKey: string;
|
|
41
|
+
baseId: string;
|
|
42
|
+
tableId: string;
|
|
43
|
+
options?: GeneratedRecordFieldsCompatibleGetRecordsOptions;
|
|
44
|
+
retry?: AirtableRetryOptions;
|
|
45
|
+
}): AsyncGenerator<{
|
|
46
|
+
records: AirtableRecord<Fields>[];
|
|
47
|
+
offset?: string;
|
|
48
|
+
}>;
|
|
49
|
+
export declare function iterateRecordsPages({ apiKey, baseId, tableId, options, retry, }: {
|
|
50
|
+
apiKey: string;
|
|
51
|
+
baseId: string;
|
|
52
|
+
tableId: string;
|
|
53
|
+
options?: GetRecordsQueryParameters;
|
|
54
|
+
retry?: AirtableRetryOptions;
|
|
55
|
+
}): AsyncGenerator<{
|
|
56
|
+
records: AirtableRecord<Record<string, unknown>>[];
|
|
57
|
+
offset?: string;
|
|
58
|
+
}>;
|
|
59
|
+
export declare function getRecords<Fields>({ apiKey, baseId, tableId, options, retry, }: {
|
|
60
|
+
apiKey: string;
|
|
61
|
+
baseId: string;
|
|
62
|
+
tableId: string;
|
|
63
|
+
options?: GeneratedRecordFieldsCompatibleGetRecordsOptions;
|
|
64
|
+
retry?: AirtableRetryOptions;
|
|
13
65
|
}): Promise<AirtableRecord<Fields>[]>;
|
|
14
|
-
export declare function
|
|
66
|
+
export declare function getRecords({ apiKey, baseId, tableId, options, retry, }: {
|
|
67
|
+
apiKey: string;
|
|
68
|
+
baseId: string;
|
|
69
|
+
tableId: string;
|
|
70
|
+
options?: GetRecordsQueryParameters;
|
|
71
|
+
retry?: AirtableRetryOptions;
|
|
72
|
+
}): Promise<AirtableRecord<Record<string, unknown>>[]>;
|
|
73
|
+
export declare function updateRecord<Fields>({ apiKey, baseId, tableId, recordId, fields, options, retry, }: {
|
|
15
74
|
apiKey: string;
|
|
16
75
|
baseId: string;
|
|
17
76
|
tableId: string;
|
|
@@ -22,8 +81,21 @@ export declare function updateRecord<Fields>({ apiKey, baseId, tableId, recordId
|
|
|
22
81
|
returnFieldsByFieldId?: boolean;
|
|
23
82
|
overwriteFieldsNotSpecified?: boolean;
|
|
24
83
|
};
|
|
84
|
+
retry?: AirtableRetryOptions;
|
|
25
85
|
}): Promise<AirtableRecord<Fields>>;
|
|
26
|
-
export declare function
|
|
86
|
+
export declare function replaceRecord<Fields>({ apiKey, baseId, tableId, recordId, fields, options, retry, }: {
|
|
87
|
+
apiKey: string;
|
|
88
|
+
baseId: string;
|
|
89
|
+
tableId: string;
|
|
90
|
+
recordId: string;
|
|
91
|
+
fields: Fields;
|
|
92
|
+
options?: {
|
|
93
|
+
typecast?: boolean;
|
|
94
|
+
returnFieldsByFieldId?: boolean;
|
|
95
|
+
};
|
|
96
|
+
retry?: AirtableRetryOptions;
|
|
97
|
+
}): Promise<AirtableRecord<Fields>>;
|
|
98
|
+
export declare function updateRecords<Fields>({ apiKey, baseId, tableId, records, options, retry, }: {
|
|
27
99
|
apiKey: string;
|
|
28
100
|
baseId: string;
|
|
29
101
|
tableId: string;
|
|
@@ -37,10 +109,28 @@ export declare function updateRecords<Fields>({ apiKey, baseId, tableId, records
|
|
|
37
109
|
overwriteFieldsNotSpecified?: boolean;
|
|
38
110
|
requestInterval?: number;
|
|
39
111
|
};
|
|
112
|
+
retry?: AirtableRetryOptions;
|
|
40
113
|
}): Promise<{
|
|
41
114
|
records: AirtableRecord<Fields>[];
|
|
42
115
|
}>;
|
|
43
|
-
export declare function
|
|
116
|
+
export declare function replaceRecords<Fields>({ apiKey, baseId, tableId, records, options, retry, }: {
|
|
117
|
+
apiKey: string;
|
|
118
|
+
baseId: string;
|
|
119
|
+
tableId: string;
|
|
120
|
+
records: {
|
|
121
|
+
id: string;
|
|
122
|
+
fields: Fields;
|
|
123
|
+
}[];
|
|
124
|
+
options?: {
|
|
125
|
+
typecast?: boolean;
|
|
126
|
+
returnFieldsByFieldId?: boolean;
|
|
127
|
+
requestInterval?: number;
|
|
128
|
+
};
|
|
129
|
+
retry?: AirtableRetryOptions;
|
|
130
|
+
}): Promise<{
|
|
131
|
+
records: AirtableRecord<Fields>[];
|
|
132
|
+
}>;
|
|
133
|
+
export declare function updateRecordsUpsert<Fields>({ apiKey, baseId, tableId, records, options, retry, }: {
|
|
44
134
|
apiKey: string;
|
|
45
135
|
baseId: string;
|
|
46
136
|
tableId: string;
|
|
@@ -55,12 +145,20 @@ export declare function updateRecordsUpsert<Fields>({ apiKey, baseId, tableId, r
|
|
|
55
145
|
overwriteFieldsNotSpecified?: boolean;
|
|
56
146
|
requestInterval?: number;
|
|
57
147
|
};
|
|
148
|
+
retry?: AirtableRetryOptions;
|
|
58
149
|
}): Promise<{
|
|
59
150
|
createdRecords: string[];
|
|
60
151
|
updatedRecords: string[];
|
|
61
152
|
records: AirtableRecord<Fields>[];
|
|
62
153
|
}>;
|
|
63
|
-
export declare function
|
|
154
|
+
export declare function deleteRecord({ apiKey, baseId, tableId, recordId, retry, }: {
|
|
155
|
+
apiKey: string;
|
|
156
|
+
baseId: string;
|
|
157
|
+
tableId: string;
|
|
158
|
+
recordId: string;
|
|
159
|
+
retry?: AirtableRetryOptions;
|
|
160
|
+
}): Promise<DeleteRecordResponse>;
|
|
161
|
+
export declare function deleteRecords({ apiKey, baseId, tableId, recordIds, options, retry, }: {
|
|
64
162
|
apiKey: string;
|
|
65
163
|
baseId: string;
|
|
66
164
|
tableId: string;
|
|
@@ -68,8 +166,9 @@ export declare function deleteRecords({ apiKey, baseId, tableId, recordIds, opti
|
|
|
68
166
|
options?: {
|
|
69
167
|
requestInterval?: number;
|
|
70
168
|
};
|
|
169
|
+
retry?: AirtableRetryOptions;
|
|
71
170
|
}): Promise<DeleteRecordsResponse>;
|
|
72
|
-
export declare function createRecord<Fields>({ apiKey, baseId, tableId, fields, options, }: {
|
|
171
|
+
export declare function createRecord<Fields>({ apiKey, baseId, tableId, fields, options, retry, }: {
|
|
73
172
|
apiKey: string;
|
|
74
173
|
baseId: string;
|
|
75
174
|
tableId: string;
|
|
@@ -78,8 +177,9 @@ export declare function createRecord<Fields>({ apiKey, baseId, tableId, fields,
|
|
|
78
177
|
typecast?: boolean;
|
|
79
178
|
returnFieldsByFieldId?: boolean;
|
|
80
179
|
};
|
|
180
|
+
retry?: AirtableRetryOptions;
|
|
81
181
|
}): Promise<AirtableRecord<Fields>>;
|
|
82
|
-
export declare function createRecords<Fields>({ apiKey, baseId, tableId, records, options, }: {
|
|
182
|
+
export declare function createRecords<Fields>({ apiKey, baseId, tableId, records, options, retry, }: {
|
|
83
183
|
apiKey: string;
|
|
84
184
|
baseId: string;
|
|
85
185
|
tableId: string;
|
|
@@ -91,6 +191,7 @@ export declare function createRecords<Fields>({ apiKey, baseId, tableId, records
|
|
|
91
191
|
returnFieldsByFieldId?: boolean;
|
|
92
192
|
requestInterval?: number;
|
|
93
193
|
};
|
|
194
|
+
retry?: AirtableRetryOptions;
|
|
94
195
|
}): Promise<{
|
|
95
196
|
records: AirtableRecord<Fields>[];
|
|
96
197
|
}>;
|