airtable-ts 1.6.0 → 1.6.2
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/dist/getAirtableTsTable.js +20 -45
- package/package.json +2 -3
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getAirtableTsTable = void 0;
|
|
37
|
-
const axios_1 = __importStar(require("axios"));
|
|
38
4
|
const AirtableTsError_1 = require("./AirtableTsError");
|
|
39
5
|
const getAirtableTsTable = async (airtable, table, options) => {
|
|
40
6
|
const airtableTable = airtable.base(table.baseId).table(table.tableId);
|
|
@@ -78,25 +44,34 @@ const getAirtableBaseSchema = async (baseId, options) => {
|
|
|
78
44
|
suggestion: 'Provide a valid Airtable API key when initializing AirtableTs.',
|
|
79
45
|
});
|
|
80
46
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
47
|
+
const baseURL = options.endpointUrl ?? 'https://api.airtable.com';
|
|
48
|
+
const url = `${baseURL}/v0/meta/bases/${baseId}/tables`;
|
|
49
|
+
const controller = new AbortController();
|
|
50
|
+
const timeoutId = options.requestTimeout
|
|
51
|
+
? setTimeout(() => {
|
|
52
|
+
controller.abort();
|
|
53
|
+
}, options.requestTimeout)
|
|
54
|
+
: undefined;
|
|
55
|
+
const response = await fetch(url, {
|
|
56
|
+
signal: controller.signal,
|
|
85
57
|
headers: {
|
|
86
58
|
Authorization: `Bearer ${options.apiKey}`,
|
|
87
59
|
...options.customHeaders,
|
|
88
60
|
},
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
61
|
+
});
|
|
62
|
+
if (timeoutId) {
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
}
|
|
65
|
+
if (!response.ok) {
|
|
66
|
+
const errorData = await response.text();
|
|
93
67
|
throw new AirtableTsError_1.AirtableTsError({
|
|
94
|
-
message: `Failed to get base schema: ${
|
|
68
|
+
message: `Failed to get base schema: Status: ${response.status}. Data: ${errorData}`,
|
|
95
69
|
type: AirtableTsError_1.ErrorType.API_ERROR,
|
|
96
70
|
suggestion: 'Ensure the API token is correct, and has `schema.bases:read` permission to the target base.',
|
|
97
71
|
});
|
|
98
|
-
}
|
|
99
|
-
const
|
|
72
|
+
}
|
|
73
|
+
const data = await response.json();
|
|
74
|
+
const baseSchema = data.tables;
|
|
100
75
|
if (baseSchemaCache.size > 100) {
|
|
101
76
|
baseSchemaCache.clear();
|
|
102
77
|
// If you're seeing this warning, then we probably either need to:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "airtable-ts",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "A type-safe Airtable SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adam Jones (domdomegg)",
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"prepublishOnly": "npm run clean && npm run build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"airtable": "^0.12.2"
|
|
26
|
-
"axios": "^1.6.8"
|
|
25
|
+
"airtable": "^0.12.2"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@tsconfig/node-lts": "^22.0.1",
|