@superdurable/connector-airtable 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # Airtable TypeScript connector
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@superdurable/connector-airtable` supplies `listRecords`, `getRecord`,
4
+ `upsertRecords`, and `updateRecords` for Dex TypeScript Flows. The operation
5
+ specific Step factories, model validators, connection contracts, and mocks are
6
+ generated from [`connector.yaml`](../connector.yaml) and the Go model types.
7
+ After changing either source, run `go run ./cmd/connectorctl generate --lang
8
+ typescript connectors/airtable/connector.yaml` from the repository root.
9
+
10
+ ## Install and connect
11
+
12
+ ```sh
13
+ npm install @superdurable/connector-airtable @superdurable/connectors-sdk @superdurable/dex
14
+ ```
15
+
16
+ Use Node.js 22 or 24 and Dex TypeScript SDK 1.28.0 or later. Create a personal
17
+ access token at [Airtable > Developer Hub > Personal access tokens](https://airtable.com/create/tokens).
18
+ Grant `data.records:read` for the read operations and `data.records:write` for
19
+ the mutations, and select each base the Flow needs. Add `schema.bases:read` if
20
+ the Dex Web base and table pickers are used. Store the token as the private
21
+ `personal_access_token` credential in a Dex Web Connection. Its value must
22
+ never enter Flow input, Attributes, results, Streams, or logs.
23
+
24
+ At Worker startup, load the project with `loadFromEnvironment()` from
25
+ `@superdurable/connectors-sdk/projectconfig` and pass the static
26
+ `ConnectionName` to `newProjectConnection`. The [runnable example](examples/list-records/)
27
+ contains that code. The connection resolves the current private token before
28
+ every request; `endpoint` and `maxResponseBytes` use manifest defaults when
29
+ blank.
30
+
31
+ ## Operations
32
+
33
+ | Factory | Request | Happy branch |
34
+ | --- | --- | --- |
35
+ | `newListRecordsStep` | `POST /v0/{baseId}/{table}/listRecords` | `listed` |
36
+ | `newGetRecordStep` | `GET /v0/{baseId}/{table}/{recordId}` | `found` |
37
+ | `newUpsertRecordsStep` | `PATCH /v0/{baseId}/{table}` with `performUpsert` | `upserted` |
38
+ | `newUpdateRecordsStep` | `PATCH /v0/{baseId}/{table}` with record IDs | `updated` |
39
+
40
+ All other declared branches are optional. An unwired optional branch fails
41
+ the Flow. The two mutations derive a stable key from the Dex Call ID, but
42
+ Airtable has no idempotency header: merge fields make an upsert repeat safe,
43
+ and absolute field values make an update repeat safe. The upsert Step uses
44
+ sync durability because concurrent duplicate upserts could create two rows.
45
+
46
+ `listRecords` sends filters, fields, sort, view, page size, and offset in a
47
+ JSON body. Typed filters become an Airtable formula; a raw `formula` should
48
+ come from application code, not end users. `RecordPage.offset` carries the
49
+ next page cursor. Field values use Airtable's JSON cell types. A missing
50
+ field means Airtable omitted an empty cell, while explicit JSON `null` clears
51
+ one on write.
52
+
53
+ Failure and not-found branch results contain empty `records` and record ID
54
+ lists, and an empty `fields` map for a missing record.
55
+
56
+ ## Verify
57
+
58
+ ```sh
59
+ npm ci
60
+ npm run check
61
+ ```
62
+
63
+ With `dexcli dev` running and `DEX_FLOW_SERVICE_ADDRESS` set, run
64
+ `npm run test:integration`. The test runs the checked-in Flow through a real
65
+ Dex Worker and Client against a local Airtable HTTP fixture, including an
66
+ unwired authorization failure. The 33 shared provider scenarios compare
67
+ requests, outputs, branches, retries, and stable mutation keys with Go.
68
+ No live Airtable token, base, picker, or provider call was verified.
@@ -0,0 +1,158 @@
1
+ {
2
+ "connectorId": "airtable",
3
+ "releaseTag": "connectors/airtable/go/v0.23.0",
4
+ "package": {
5
+ "ecosystem": "npm",
6
+ "name": "@superdurable/connector-airtable",
7
+ "version": "0.1.1"
8
+ },
9
+ "factories": [
10
+ {
11
+ "name": "newListRecordsStep",
12
+ "kind": "query",
13
+ "operationId": "listRecords",
14
+ "fields": {
15
+ "stepType": "stepType",
16
+ "annotations": "annotations",
17
+ "connectionName": "connectionName",
18
+ "resultAttribute": "resultAttribute"
19
+ },
20
+ "branches": [
21
+ {
22
+ "id": "listed",
23
+ "field": "listed",
24
+ "optional": false
25
+ },
26
+ {
27
+ "id": "offsetExpired",
28
+ "field": "offsetExpired",
29
+ "optional": true
30
+ },
31
+ {
32
+ "id": "providerRejected",
33
+ "field": "providerRejected",
34
+ "optional": true
35
+ },
36
+ {
37
+ "id": "invalidResponse",
38
+ "field": "invalidResponse",
39
+ "optional": true
40
+ },
41
+ {
42
+ "id": "defect",
43
+ "field": "defect",
44
+ "optional": true
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "name": "newGetRecordStep",
50
+ "kind": "query",
51
+ "operationId": "getRecord",
52
+ "fields": {
53
+ "stepType": "stepType",
54
+ "annotations": "annotations",
55
+ "connectionName": "connectionName",
56
+ "resultAttribute": "resultAttribute"
57
+ },
58
+ "branches": [
59
+ {
60
+ "id": "found",
61
+ "field": "found",
62
+ "optional": false
63
+ },
64
+ {
65
+ "id": "notFound",
66
+ "field": "notFound",
67
+ "optional": true
68
+ },
69
+ {
70
+ "id": "providerRejected",
71
+ "field": "providerRejected",
72
+ "optional": true
73
+ },
74
+ {
75
+ "id": "invalidResponse",
76
+ "field": "invalidResponse",
77
+ "optional": true
78
+ },
79
+ {
80
+ "id": "defect",
81
+ "field": "defect",
82
+ "optional": true
83
+ }
84
+ ]
85
+ },
86
+ {
87
+ "name": "newUpsertRecordsStep",
88
+ "kind": "mutation",
89
+ "operationId": "upsertRecords",
90
+ "fields": {
91
+ "stepType": "stepType",
92
+ "annotations": "annotations",
93
+ "connectionName": "connectionName",
94
+ "resultAttribute": "resultAttribute"
95
+ },
96
+ "branches": [
97
+ {
98
+ "id": "upserted",
99
+ "field": "upserted",
100
+ "optional": false
101
+ },
102
+ {
103
+ "id": "providerRejected",
104
+ "field": "providerRejected",
105
+ "optional": true
106
+ },
107
+ {
108
+ "id": "invalidResponse",
109
+ "field": "invalidResponse",
110
+ "optional": true
111
+ },
112
+ {
113
+ "id": "defect",
114
+ "field": "defect",
115
+ "optional": true
116
+ }
117
+ ]
118
+ },
119
+ {
120
+ "name": "newUpdateRecordsStep",
121
+ "kind": "mutation",
122
+ "operationId": "updateRecords",
123
+ "fields": {
124
+ "stepType": "stepType",
125
+ "annotations": "annotations",
126
+ "connectionName": "connectionName",
127
+ "resultAttribute": "resultAttribute"
128
+ },
129
+ "branches": [
130
+ {
131
+ "id": "updated",
132
+ "field": "updated",
133
+ "optional": false
134
+ },
135
+ {
136
+ "id": "notFound",
137
+ "field": "notFound",
138
+ "optional": true
139
+ },
140
+ {
141
+ "id": "providerRejected",
142
+ "field": "providerRejected",
143
+ "optional": true
144
+ },
145
+ {
146
+ "id": "invalidResponse",
147
+ "field": "invalidResponse",
148
+ "optional": true
149
+ },
150
+ {
151
+ "id": "defect",
152
+ "field": "defect",
153
+ "optional": true
154
+ }
155
+ ]
156
+ }
157
+ ]
158
+ }
@@ -0,0 +1,252 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ var ConfigSchema = z.object({
4
+ "endpoint": z.string().optional(),
5
+ "maxResponseBytes": z.number().int().optional()
6
+ });
7
+ var FieldEqualityFilterSchema = z.strictObject({
8
+ "field": z.string(),
9
+ "text": z.string().optional(),
10
+ "number": z.number().optional(),
11
+ "checkbox": z.boolean().optional()
12
+ });
13
+ var RecordSortSchema = z.strictObject({
14
+ "field": z.string(),
15
+ "direction": z.string().optional()
16
+ });
17
+ var ListRecordsInputSchema = z.strictObject({
18
+ "baseId": z.string(),
19
+ "tableIdOrName": z.string(),
20
+ "filters": z.array(FieldEqualityFilterSchema).optional(),
21
+ "formula": z.string().optional(),
22
+ "fields": z.array(z.string()).optional(),
23
+ "sort": z.array(RecordSortSchema).optional(),
24
+ "viewIdOrName": z.string().optional(),
25
+ "pageSize": z.number().int().optional(),
26
+ "offset": z.string().optional()
27
+ });
28
+ var RecordSchema = z.strictObject({
29
+ "id": z.string(),
30
+ "createdTime": z.iso.datetime({ offset: true }),
31
+ "fields": z.record(z.string(), z.unknown().nullable()).nullable()
32
+ });
33
+ var RecordPageSchema = z.strictObject({
34
+ "records": z.array(RecordSchema).nullable(),
35
+ "offset": z.string().optional(),
36
+ "filterFormula": z.string().optional()
37
+ });
38
+ var GetRecordInputSchema = z.strictObject({
39
+ "baseId": z.string(),
40
+ "tableIdOrName": z.string(),
41
+ "recordId": z.string()
42
+ });
43
+ var RecordUpsertSchema = z.strictObject({
44
+ "fields": z.record(z.string(), z.unknown().nullable()).nullable()
45
+ });
46
+ var UpsertRecordsInputSchema = z.strictObject({
47
+ "baseId": z.string(),
48
+ "tableIdOrName": z.string(),
49
+ "fieldsToMergeOn": z.array(z.string()).nullable(),
50
+ "records": z.array(RecordUpsertSchema).nullable(),
51
+ "typecast": z.boolean().optional()
52
+ });
53
+ var UpsertedRecordsSchema = z.strictObject({
54
+ "records": z.array(RecordSchema).nullable(),
55
+ "createdRecordIds": z.array(z.string()).nullable(),
56
+ "updatedRecordIds": z.array(z.string()).nullable(),
57
+ "partialSuccessReasons": z.array(z.string()).optional()
58
+ });
59
+ var RecordUpdateSchema = z.strictObject({
60
+ "id": z.string(),
61
+ "fields": z.record(z.string(), z.unknown().nullable()).nullable()
62
+ });
63
+ var UpdateRecordsInputSchema = z.strictObject({
64
+ "baseId": z.string(),
65
+ "tableIdOrName": z.string(),
66
+ "records": z.array(RecordUpdateSchema).nullable(),
67
+ "typecast": z.boolean().optional()
68
+ });
69
+ var UpdatedRecordsSchema = z.strictObject({
70
+ "records": z.array(RecordSchema).nullable(),
71
+ "partialSuccessReasons": z.array(z.string()).optional()
72
+ });
73
+
74
+ // src/generated/definitions.ts
75
+ var ConnectorID = "airtable";
76
+ var ProviderID = "airtable";
77
+ var ListRecordsBranch = {
78
+ Listed: "listed",
79
+ OffsetExpired: "offsetExpired",
80
+ ProviderRejected: "providerRejected",
81
+ InvalidResponse: "invalidResponse",
82
+ Defect: "defect"
83
+ };
84
+ var ListRecordsBranchListed = ListRecordsBranch.Listed;
85
+ var ListRecordsBranchOffsetExpired = ListRecordsBranch.OffsetExpired;
86
+ var ListRecordsBranchProviderRejected = ListRecordsBranch.ProviderRejected;
87
+ var ListRecordsBranchInvalidResponse = ListRecordsBranch.InvalidResponse;
88
+ var ListRecordsBranchDefect = ListRecordsBranch.Defect;
89
+ var ListRecordsDefinition = {
90
+ operation: { connectorId: ConnectorID, operationId: "listRecords" },
91
+ branches: [
92
+ { id: "listed", description: "Airtable returned one bounded page of matching records; the page may be empty." },
93
+ { id: "offsetExpired", description: "Airtable no longer recognizes the offset cursor, so the listing must restart from the first page.", optional: true },
94
+ { id: "providerRejected", description: "Airtable conclusively rejected the list, such as an unknown base, table, view, or field, an invalid formula, a missing scope, or a rejected token.", optional: true },
95
+ { id: "invalidResponse", description: "Airtable returned an invalid or oversized list response.", optional: true },
96
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
97
+ ],
98
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
99
+ };
100
+ var ListRecordsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
101
+ var GetRecordBranch = {
102
+ Found: "found",
103
+ NotFound: "notFound",
104
+ ProviderRejected: "providerRejected",
105
+ InvalidResponse: "invalidResponse",
106
+ Defect: "defect"
107
+ };
108
+ var GetRecordBranchFound = GetRecordBranch.Found;
109
+ var GetRecordBranchNotFound = GetRecordBranch.NotFound;
110
+ var GetRecordBranchProviderRejected = GetRecordBranch.ProviderRejected;
111
+ var GetRecordBranchInvalidResponse = GetRecordBranch.InvalidResponse;
112
+ var GetRecordBranchDefect = GetRecordBranch.Defect;
113
+ var GetRecordDefinition = {
114
+ operation: { connectorId: ConnectorID, operationId: "getRecord" },
115
+ branches: [
116
+ { id: "found", description: "The record exists and was returned." },
117
+ { id: "notFound", description: "No record in the base has the record ID.", optional: true },
118
+ { id: "providerRejected", description: "Airtable conclusively rejected the read, such as an unknown base or table, a missing scope, or a rejected token.", optional: true },
119
+ { id: "invalidResponse", description: "Airtable returned an invalid or oversized record response.", optional: true },
120
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
121
+ ],
122
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
123
+ };
124
+ var GetRecordMetadata = { kind: "query", idempotency: "none", authorization: "required" };
125
+ var UpsertRecordsBranch = {
126
+ Upserted: "upserted",
127
+ ProviderRejected: "providerRejected",
128
+ InvalidResponse: "invalidResponse",
129
+ Defect: "defect"
130
+ };
131
+ var UpsertRecordsBranchUpserted = UpsertRecordsBranch.Upserted;
132
+ var UpsertRecordsBranchProviderRejected = UpsertRecordsBranch.ProviderRejected;
133
+ var UpsertRecordsBranchInvalidResponse = UpsertRecordsBranch.InvalidResponse;
134
+ var UpsertRecordsBranchDefect = UpsertRecordsBranch.Defect;
135
+ var UpsertRecordsDefinition = {
136
+ operation: { connectorId: ConnectorID, operationId: "upsertRecords" },
137
+ branches: [
138
+ { id: "upserted", description: "Airtable created each record without a match and updated each record that matched." },
139
+ { id: "providerRejected", description: "Airtable conclusively rejected the upsert, such as several existing records matching one merge key, an invalid cell value, a computed merge field, a missing scope, or a rejected token.", optional: true },
140
+ { id: "invalidResponse", description: "Airtable applied or rejected the upsert but returned an invalid or oversized response.", optional: true },
141
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
142
+ ],
143
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync" }
144
+ };
145
+ var UpsertRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
146
+ var UpdateRecordsBranch = {
147
+ Updated: "updated",
148
+ NotFound: "notFound",
149
+ ProviderRejected: "providerRejected",
150
+ InvalidResponse: "invalidResponse",
151
+ Defect: "defect"
152
+ };
153
+ var UpdateRecordsBranchUpdated = UpdateRecordsBranch.Updated;
154
+ var UpdateRecordsBranchNotFound = UpdateRecordsBranch.NotFound;
155
+ var UpdateRecordsBranchProviderRejected = UpdateRecordsBranch.ProviderRejected;
156
+ var UpdateRecordsBranchInvalidResponse = UpdateRecordsBranch.InvalidResponse;
157
+ var UpdateRecordsBranchDefect = UpdateRecordsBranch.Defect;
158
+ var UpdateRecordsDefinition = {
159
+ operation: { connectorId: ConnectorID, operationId: "updateRecords" },
160
+ branches: [
161
+ { id: "updated", description: "Airtable updated every record and returned it." },
162
+ { id: "notFound", description: "A record ID does not exist in the table.", optional: true },
163
+ { id: "providerRejected", description: "Airtable conclusively rejected the update, such as an invalid cell value, a computed field, a missing scope, or a rejected token.", optional: true },
164
+ { id: "invalidResponse", description: "Airtable applied or rejected the update but returned an invalid or oversized response.", optional: true },
165
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
166
+ ],
167
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
168
+ };
169
+ var UpdateRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
170
+
171
+ // src/generated/connection.ts
172
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
173
+ var Connection = class {
174
+ /** Stable provider and connection name. */
175
+ reference;
176
+ /** Bound provider operations. */
177
+ operations;
178
+ /** Validate a reference and bind operations. */
179
+ constructor(reference, operations) {
180
+ this.reference = ConnectionRefSchema.parse(reference);
181
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
182
+ if (!operations) throw new TypeError("connector operations are required");
183
+ this.operations = operations;
184
+ }
185
+ };
186
+ function newConnection(client, reference) {
187
+ if (!client) throw new TypeError("connector client is required");
188
+ return new Connection(reference, client);
189
+ }
190
+ function newConnectionWithOperations(operations, reference) {
191
+ return new Connection(reference, operations);
192
+ }
193
+ function newProjectConnection(project, connectionName, createClient) {
194
+ if (!project) throw new TypeError("loaded project is required");
195
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
196
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
197
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
198
+ return newConnection(createClient(project, connectionName), reference);
199
+ }
200
+
201
+ export {
202
+ ConfigSchema,
203
+ FieldEqualityFilterSchema,
204
+ RecordSortSchema,
205
+ ListRecordsInputSchema,
206
+ RecordSchema,
207
+ RecordPageSchema,
208
+ GetRecordInputSchema,
209
+ RecordUpsertSchema,
210
+ UpsertRecordsInputSchema,
211
+ UpsertedRecordsSchema,
212
+ RecordUpdateSchema,
213
+ UpdateRecordsInputSchema,
214
+ UpdatedRecordsSchema,
215
+ ConnectorID,
216
+ ProviderID,
217
+ ListRecordsBranch,
218
+ ListRecordsBranchListed,
219
+ ListRecordsBranchOffsetExpired,
220
+ ListRecordsBranchProviderRejected,
221
+ ListRecordsBranchInvalidResponse,
222
+ ListRecordsBranchDefect,
223
+ ListRecordsDefinition,
224
+ ListRecordsMetadata,
225
+ GetRecordBranch,
226
+ GetRecordBranchFound,
227
+ GetRecordBranchNotFound,
228
+ GetRecordBranchProviderRejected,
229
+ GetRecordBranchInvalidResponse,
230
+ GetRecordBranchDefect,
231
+ GetRecordDefinition,
232
+ GetRecordMetadata,
233
+ UpsertRecordsBranch,
234
+ UpsertRecordsBranchUpserted,
235
+ UpsertRecordsBranchProviderRejected,
236
+ UpsertRecordsBranchInvalidResponse,
237
+ UpsertRecordsBranchDefect,
238
+ UpsertRecordsDefinition,
239
+ UpsertRecordsMetadata,
240
+ UpdateRecordsBranch,
241
+ UpdateRecordsBranchUpdated,
242
+ UpdateRecordsBranchNotFound,
243
+ UpdateRecordsBranchProviderRejected,
244
+ UpdateRecordsBranchInvalidResponse,
245
+ UpdateRecordsBranchDefect,
246
+ UpdateRecordsDefinition,
247
+ UpdateRecordsMetadata,
248
+ Connection,
249
+ newConnection,
250
+ newConnectionWithOperations,
251
+ newProjectConnection
252
+ };