easy-airtable-api 0.0.10 → 0.0.12

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 CHANGED
@@ -60,6 +60,16 @@ const records = await getRecords<Fields>({
60
60
 
61
61
  ## Changelog
62
62
 
63
+ ### 0.0.12
64
+
65
+ - Reverted making apiKey, baseId, tableId default to undefined
66
+ - Added option to customize delay between requests via options.requestInterval
67
+
68
+ ### 0.0.11
69
+
70
+ - Make apiKey, baseId, tableId default to undefined #12
71
+ - Missing .js in utils import #13
72
+
63
73
  ### 0.0.10
64
74
 
65
75
  - Fixed deleteRecords implementation errors.
package/lib/requests.d.ts CHANGED
@@ -35,6 +35,7 @@ export declare function updateRecords<Fields>({ apiKey, baseId, tableId, records
35
35
  typecast?: boolean;
36
36
  returnFieldsByFieldId?: boolean;
37
37
  overwriteFieldsNotSpecified?: boolean;
38
+ requestInterval?: number;
38
39
  };
39
40
  }): Promise<{
40
41
  records: AirtableRecord<Fields>[];
@@ -52,15 +53,19 @@ export declare function updateRecordsUpsert<Fields>({ apiKey, baseId, tableId, r
52
53
  typecast?: boolean;
53
54
  returnFieldsByFieldId?: boolean;
54
55
  overwriteFieldsNotSpecified?: boolean;
56
+ requestInterval?: number;
55
57
  };
56
58
  }): Promise<{
57
59
  createdRecords: string[];
58
60
  updatedRecords: string[];
59
61
  records: AirtableRecord<Fields>[];
60
62
  }>;
61
- export declare function deleteRecords({ apiKey, baseId, tableId, recordIds, }: {
63
+ export declare function deleteRecords({ apiKey, baseId, tableId, recordIds, options, }: {
62
64
  apiKey: string;
63
65
  baseId: string;
64
66
  tableId: string;
65
67
  recordIds: string[];
68
+ options?: {
69
+ requestInterval?: number;
70
+ };
66
71
  }): 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,
@@ -29,7 +29,7 @@ export async function getRecords({ apiKey, baseId, tableId, options, }) {
29
29
  records = records.concat(response.records);
30
30
  currentOffset = response.offset;
31
31
  if (currentOffset)
32
- await delay(500);
32
+ await delay(options?.requestInterval ?? 500);
33
33
  } while (currentOffset);
34
34
  return records;
35
35
  }
@@ -83,7 +83,7 @@ export async function updateRecords({ apiKey, baseId, tableId, records, options,
83
83
  },
84
84
  });
85
85
  combinedResults = combinedResults.concat(result.records);
86
- await delay(500);
86
+ await delay(options?.requestInterval ?? 500);
87
87
  }
88
88
  return { records: combinedResults };
89
89
  }
@@ -120,7 +120,7 @@ export async function updateRecordsUpsert({ apiKey, baseId, tableId, records, op
120
120
  allCreatedRecords = allCreatedRecords.concat(result.createdRecords);
121
121
  allUpdatedRecords = allUpdatedRecords.concat(result.updatedRecords);
122
122
  allRecords = allRecords.concat(result.records);
123
- await delay(500);
123
+ await delay(options?.requestInterval ?? 500);
124
124
  }
125
125
  return {
126
126
  createdRecords: allCreatedRecords,
@@ -128,7 +128,7 @@ export async function updateRecordsUpsert({ apiKey, baseId, tableId, records, op
128
128
  records: allRecords,
129
129
  };
130
130
  }
131
- export async function deleteRecords({ apiKey, baseId, tableId, recordIds, }) {
131
+ export async function deleteRecords({ apiKey, baseId, tableId, recordIds, options, }) {
132
132
  if (!Array.isArray(recordIds) || recordIds.length === 0) {
133
133
  throw new Error('The record ids array is empty or not provided. Please provide a non-empty array of record ids to delete the records.');
134
134
  }
@@ -148,7 +148,7 @@ export async function deleteRecords({ apiKey, baseId, tableId, recordIds, }) {
148
148
  method: 'DELETE',
149
149
  });
150
150
  combinedResults = combinedResults.concat(result.records);
151
- await delay(500);
151
+ await delay(options?.requestInterval ?? 500);
152
152
  }
153
153
  return { records: combinedResults };
154
154
  }
@@ -28,6 +28,7 @@ export interface GetRecordsQueryParameters {
28
28
  fields?: string[];
29
29
  returnFieldsByFieldId?: boolean;
30
30
  recordMetadata?: RecordMetadataOptions[];
31
+ requestInterval?: number;
31
32
  }
32
33
  type RecordField = {
33
34
  [key: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-airtable-api",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "description": "An easy way to connect to Airtable via their API.",
6
6
  "main": "lib/index.js",