@superdurable/connector-airtable 0.1.1 → 0.2.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/README.md +55 -8
- package/dex-connector.json +278 -6
- package/dist/{chunk-T4RPDDJS.js → chunk-RBINH2QY.js} +46 -4
- package/dist/{connection-C93OyKtn.d.ts → connection-D9d1yIrY.d.ts} +13 -5
- package/dist/index.d.ts +197 -15
- package/dist/index.js +750 -5
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Airtable TypeScript connector
|
|
2
2
|
|
|
3
3
|
`@superdurable/connector-airtable` supplies `listRecords`, `getRecord`,
|
|
4
|
-
`upsertRecords`, and `updateRecords` for Dex TypeScript Flows
|
|
4
|
+
`upsertRecords`, and `updateRecords` for Dex TypeScript Flows, and the
|
|
5
|
+
`recordChanged` poll Trigger at parity with the Go module. The operation
|
|
5
6
|
specific Step factories, model validators, connection contracts, and mocks are
|
|
6
7
|
generated from [`connector.yaml`](../connector.yaml) and the Go model types.
|
|
7
8
|
After changing either source, run `go run ./cmd/connectorctl generate --lang
|
|
@@ -13,11 +14,13 @@ typescript connectors/airtable/connector.yaml` from the repository root.
|
|
|
13
14
|
npm install @superdurable/connector-airtable @superdurable/connectors-sdk @superdurable/dex
|
|
14
15
|
```
|
|
15
16
|
|
|
16
|
-
Use Node.js 22 or 24 and Dex TypeScript SDK 1.
|
|
17
|
+
Use Node.js 22 or 24, Connectors SDK 0.12.0, and Dex TypeScript SDK 1.45.4 or
|
|
18
|
+
later. Create a personal
|
|
17
19
|
access token at [Airtable > Developer Hub > Personal access tokens](https://airtable.com/create/tokens).
|
|
18
20
|
Grant `data.records:read` for the read operations and `data.records:write` for
|
|
19
21
|
the mutations, and select each base the Flow needs. Add `schema.bases:read` if
|
|
20
|
-
the Dex Web base and
|
|
22
|
+
the Dex Web base, table, and field pickers or the `recordChanged` Trigger are
|
|
23
|
+
used. Store the token as the private
|
|
21
24
|
`personal_access_token` credential in a Dex Web Connection. Its value must
|
|
22
25
|
never enter Flow input, Attributes, results, Streams, or logs.
|
|
23
26
|
|
|
@@ -25,8 +28,8 @@ At Worker startup, load the project with `loadFromEnvironment()` from
|
|
|
25
28
|
`@superdurable/connectors-sdk/projectconfig` and pass the static
|
|
26
29
|
`ConnectionName` to `newProjectConnection`. The [runnable example](examples/list-records/)
|
|
27
30
|
contains that code. The connection resolves the current private token before
|
|
28
|
-
every request; `endpoint
|
|
29
|
-
blank.
|
|
31
|
+
every request; `endpoint`, `maxResponseBytes`, `pollInterval`, and
|
|
32
|
+
`pollPageSize` use manifest defaults when blank.
|
|
30
33
|
|
|
31
34
|
## Operations
|
|
32
35
|
|
|
@@ -53,6 +56,44 @@ one on write.
|
|
|
53
56
|
Failure and not-found branch results contain empty `records` and record ID
|
|
54
57
|
lists, and an empty `fields` map for a missing record.
|
|
55
58
|
|
|
59
|
+
## recordChanged Trigger
|
|
60
|
+
|
|
61
|
+
`recordChanged` starts a Flow for each record created or changed in one picked
|
|
62
|
+
table, as reported by a picked Last modified time field with a time of day. It
|
|
63
|
+
runs on the SDK's durable poll Trigger kit
|
|
64
|
+
(`@superdurable/connectors-sdk/pollingtrigger`) with the Go connector's
|
|
65
|
+
requests, cursor, and limits: one schema read to find the field's current
|
|
66
|
+
name, then `POST /v0/{baseId}/{tableId}/listRecords` filtered to changes after
|
|
67
|
+
the cursor's time minus six seconds, oldest first, in pages of the
|
|
68
|
+
connection's `pollPageSize`. The [connector README](../README.md#recordchanged)
|
|
69
|
+
describes the seed without backlog, the five-second overlap, the 2,000-record
|
|
70
|
+
bound, resumed scans, expired offsets, rate limits, and what the Trigger
|
|
71
|
+
cannot report.
|
|
72
|
+
|
|
73
|
+
| API | Use |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `defineRecordChangedTriggerBinding` | Declares the binding in a Flow's `getConnectorTriggerBindings`. |
|
|
76
|
+
| `newProjectRecordChangedTriggerRunner` | Durable runner for bindings saved in the project: each change is recorded in the binding's project Trigger inbox before its project poll cursor commits. |
|
|
77
|
+
| `newRecordChangedTriggerRunner` | Runner over explicit routes with cursors and targets, and an optional `requestLimiter`. |
|
|
78
|
+
| `newRecordChangedTrigger` | One binding's `TriggerRunner` with its cursor in memory, for tests and demonstrations. |
|
|
79
|
+
| `decodeRecordChangedEventPayload` | Decodes a replayed inbox payload written by Go, Python, or TypeScript. |
|
|
80
|
+
|
|
81
|
+
`RecordChangedEvent` carries `baseId`, `tableId`, `lastModifiedTime` (Go's
|
|
82
|
+
RFC 3339 UTC text), `isCreatedRecord`, and the `record` with fields keyed by
|
|
83
|
+
name. The event ID is the record ID and its modification time, such as
|
|
84
|
+
`recXXXXXXXXXXXXXX-20261115T090000123000000Z`. Times are kept as nanosecond
|
|
85
|
+
`bigint`s, so cursor tokens and event IDs match Go's byte for byte and Go and
|
|
86
|
+
TypeScript replicas can share a binding's cursor and inbox. `pollIntervalMs`
|
|
87
|
+
must be at least 1000 and `pollPageSize` from 1 to 100. A 429, or a per-base
|
|
88
|
+
request queue over two seconds, pauses every binding of the connection for at
|
|
89
|
+
least 30 seconds; other failed polls back off up to five minutes and keep the
|
|
90
|
+
cursor. The `logger` client option receives the runner's records, which never
|
|
91
|
+
carry field values, field names, or the token.
|
|
92
|
+
|
|
93
|
+
The [record-changed intake example](examples/record-changed-intake/) starts
|
|
94
|
+
one Flow per change, which reads its record back with the `getRecord` Step;
|
|
95
|
+
the Trigger and the Step share the static `airtable-intake` connection.
|
|
96
|
+
|
|
56
97
|
## Verify
|
|
57
98
|
|
|
58
99
|
```sh
|
|
@@ -61,8 +102,14 @@ npm run check
|
|
|
61
102
|
```
|
|
62
103
|
|
|
63
104
|
With `dexcli dev` running and `DEX_FLOW_SERVICE_ADDRESS` set, run
|
|
64
|
-
`npm run test:integration`. The
|
|
65
|
-
Dex Worker and Client against
|
|
66
|
-
unwired authorization failure
|
|
105
|
+
`npm run test:integration`. The tests run the checked-in Flows through a real
|
|
106
|
+
Dex Worker and Client against local Airtable fixtures: the list example,
|
|
107
|
+
including an unwired authorization failure, and the record-changed example,
|
|
108
|
+
where existing records start no Flow, each create and edit starts one, a
|
|
109
|
+
renamed field keeps working, a change made while the runner is stopped
|
|
110
|
+
arrives after a restart that first answers 503, and the example runner polls
|
|
111
|
+
the binding saved in the project. `test/record_changed_trigger.test.ts` runs
|
|
112
|
+
the Go fetcher scenarios and compares every cursor token and event ID with
|
|
113
|
+
digests the Go fetcher produced for the same scenarios. The 33 shared provider scenarios compare
|
|
67
114
|
requests, outputs, branches, retries, and stable mutation keys with Go.
|
|
68
115
|
No live Airtable token, base, picker, or provider call was verified.
|
package/dex-connector.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "airtable",
|
|
3
|
-
"releaseTag": "connectors/airtable/go/v0.
|
|
3
|
+
"releaseTag": "connectors/airtable/go/v0.24.0",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-airtable",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.2.0"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
10
|
{
|
|
11
11
|
"name": "newListRecordsStep",
|
|
12
12
|
"kind": "query",
|
|
13
13
|
"operationId": "listRecords",
|
|
14
|
+
"inputType": "ListRecordsInput",
|
|
15
|
+
"description": "List one bounded page of a table's records, filtered by typed field equality and an optional formula, with a field subset, sort, view, and offset cursor.",
|
|
14
16
|
"fields": {
|
|
15
17
|
"stepType": "stepType",
|
|
16
18
|
"annotations": "annotations",
|
|
@@ -43,12 +45,120 @@
|
|
|
43
45
|
"field": "defect",
|
|
44
46
|
"optional": true
|
|
45
47
|
}
|
|
46
|
-
]
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"$defs": {
|
|
51
|
+
"FieldEqualityFilter": {
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"description": "FieldEqualityFilter matches records whose field equals one typed value. Exactly one of Text, Number, and Checkbox is set; prefer the constructors TextFieldEquals, NumberFieldEquals, and CheckboxFieldEquals. The connector writes the filter as an Airtable formula such as {Policy Key} = \"refund-standard\", so it follows Airtable's formula comparison rules. A linked record, lookup, or multiple select field compares its displayed text, such as the linked records' primary field values joined by commas.",
|
|
54
|
+
"properties": {
|
|
55
|
+
"checkbox": {
|
|
56
|
+
"description": "Checkbox matches a checked box when true and an unchecked box when false.",
|
|
57
|
+
"type": "boolean"
|
|
58
|
+
},
|
|
59
|
+
"field": {
|
|
60
|
+
"description": "Field is the field name, or its field ID such as fldXXXXXXXXXXXXXX. A name cannot contain a brace or a backslash, because Airtable documents no escape for them inside a field reference; use the field ID instead.",
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
"number": {
|
|
64
|
+
"description": "Number matches a number, currency, percent, rating, duration, count, or autonumber field. It must be finite.",
|
|
65
|
+
"type": "number"
|
|
66
|
+
},
|
|
67
|
+
"text": {
|
|
68
|
+
"description": "Text matches a text, email, URL, phone, single select, or date field. It cannot contain a backslash or a control character such as a line break; use ListRecordsInput.Formula for such values.",
|
|
69
|
+
"type": "string"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"required": [
|
|
73
|
+
"field"
|
|
74
|
+
],
|
|
75
|
+
"type": "object"
|
|
76
|
+
},
|
|
77
|
+
"RecordSort": {
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"description": "RecordSort orders listed records by one field.",
|
|
80
|
+
"properties": {
|
|
81
|
+
"direction": {
|
|
82
|
+
"description": "Direction is asc or desc; blank sorts ascending.",
|
|
83
|
+
"enum": [
|
|
84
|
+
"asc",
|
|
85
|
+
"desc"
|
|
86
|
+
],
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"field": {
|
|
90
|
+
"description": "Field is the field name or field ID.",
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"required": [
|
|
95
|
+
"field"
|
|
96
|
+
],
|
|
97
|
+
"type": "object"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"description": "ListRecordsInput selects one page of a table's records. Filters and Formula combine with AND into Airtable's filterByFormula: typed equality filters are escaped by the connector, and Formula is passed through as written, so it should come from application code rather than end users. Leaving both blank lists every record. Without Sort or View, Airtable returns records in no particular order.",
|
|
102
|
+
"properties": {
|
|
103
|
+
"baseId": {
|
|
104
|
+
"description": "BaseID is the base ID, such as appXXXXXXXXXXXXXX, from the base picker.",
|
|
105
|
+
"type": "string"
|
|
106
|
+
},
|
|
107
|
+
"fields": {
|
|
108
|
+
"description": "Fields limits each returned record to these field names or IDs; blank returns every non-empty field.",
|
|
109
|
+
"items": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
"type": "array"
|
|
113
|
+
},
|
|
114
|
+
"filters": {
|
|
115
|
+
"description": "Filters match records whose fields equal typed values, at most 25.",
|
|
116
|
+
"items": {
|
|
117
|
+
"$ref": "#/$defs/FieldEqualityFilter"
|
|
118
|
+
},
|
|
119
|
+
"type": "array"
|
|
120
|
+
},
|
|
121
|
+
"formula": {
|
|
122
|
+
"description": "Formula is an optional raw Airtable formula, such as {Amount} > 100, ANDed with Filters.",
|
|
123
|
+
"type": "string"
|
|
124
|
+
},
|
|
125
|
+
"offset": {
|
|
126
|
+
"description": "Offset continues a listing from the previous page's Offset; blank starts at the first page.",
|
|
127
|
+
"type": "string"
|
|
128
|
+
},
|
|
129
|
+
"pageSize": {
|
|
130
|
+
"description": "PageSize is the most records returned, 1 to 100; zero returns up to 100.",
|
|
131
|
+
"type": "integer"
|
|
132
|
+
},
|
|
133
|
+
"sort": {
|
|
134
|
+
"description": "Sort orders the records and overrides View's order, at most 10 entries.",
|
|
135
|
+
"items": {
|
|
136
|
+
"$ref": "#/$defs/RecordSort"
|
|
137
|
+
},
|
|
138
|
+
"type": "array"
|
|
139
|
+
},
|
|
140
|
+
"tableIdOrName": {
|
|
141
|
+
"description": "TableIDOrName is the table ID, such as tblXXXXXXXXXXXXXX from the table picker, which survives renames, or the table name.",
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"viewIdOrName": {
|
|
145
|
+
"description": "ViewIDOrName limits the records to one view, in its order unless Sort is set.",
|
|
146
|
+
"type": "string"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"required": [
|
|
150
|
+
"baseId",
|
|
151
|
+
"tableIdOrName"
|
|
152
|
+
],
|
|
153
|
+
"type": "object"
|
|
154
|
+
}
|
|
47
155
|
},
|
|
48
156
|
{
|
|
49
157
|
"name": "newGetRecordStep",
|
|
50
158
|
"kind": "query",
|
|
51
159
|
"operationId": "getRecord",
|
|
160
|
+
"inputType": "GetRecordInput",
|
|
161
|
+
"description": "Read one record by record ID.",
|
|
52
162
|
"fields": {
|
|
53
163
|
"stepType": "stepType",
|
|
54
164
|
"annotations": "annotations",
|
|
@@ -81,12 +191,38 @@
|
|
|
81
191
|
"field": "defect",
|
|
82
192
|
"optional": true
|
|
83
193
|
}
|
|
84
|
-
]
|
|
194
|
+
],
|
|
195
|
+
"inputSchema": {
|
|
196
|
+
"additionalProperties": false,
|
|
197
|
+
"description": "GetRecordInput identifies one record.",
|
|
198
|
+
"properties": {
|
|
199
|
+
"baseId": {
|
|
200
|
+
"description": "BaseID is the base ID, such as appXXXXXXXXXXXXXX.",
|
|
201
|
+
"type": "string"
|
|
202
|
+
},
|
|
203
|
+
"recordId": {
|
|
204
|
+
"description": "RecordID is the record ID, such as recXXXXXXXXXXXXXX.",
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
207
|
+
"tableIdOrName": {
|
|
208
|
+
"description": "TableIDOrName is the table ID, such as tblXXXXXXXXXXXXXX, or the table name.",
|
|
209
|
+
"type": "string"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"required": [
|
|
213
|
+
"baseId",
|
|
214
|
+
"recordId",
|
|
215
|
+
"tableIdOrName"
|
|
216
|
+
],
|
|
217
|
+
"type": "object"
|
|
218
|
+
}
|
|
85
219
|
},
|
|
86
220
|
{
|
|
87
221
|
"name": "newUpsertRecordsStep",
|
|
88
222
|
"kind": "mutation",
|
|
89
223
|
"operationId": "upsertRecords",
|
|
224
|
+
"inputType": "UpsertRecordsInput",
|
|
225
|
+
"description": "Create or update up to 10 records matched by one to three merge fields, such as a case ID, so a repeated write updates the record it created.",
|
|
90
226
|
"fields": {
|
|
91
227
|
"stepType": "stepType",
|
|
92
228
|
"annotations": "annotations",
|
|
@@ -114,12 +250,79 @@
|
|
|
114
250
|
"field": "defect",
|
|
115
251
|
"optional": true
|
|
116
252
|
}
|
|
117
|
-
]
|
|
253
|
+
],
|
|
254
|
+
"inputSchema": {
|
|
255
|
+
"$defs": {
|
|
256
|
+
"RecordUpsert": {
|
|
257
|
+
"additionalProperties": false,
|
|
258
|
+
"description": "RecordUpsert is one record written by UpsertRecords.",
|
|
259
|
+
"properties": {
|
|
260
|
+
"fields": {
|
|
261
|
+
"additionalProperties": {},
|
|
262
|
+
"description": "Fields maps field names or IDs to cell values. It must hold a non-null value for every merge field, under the same name or ID the merge list uses.",
|
|
263
|
+
"type": [
|
|
264
|
+
"object",
|
|
265
|
+
"null"
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"required": [
|
|
270
|
+
"fields"
|
|
271
|
+
],
|
|
272
|
+
"type": "object"
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"additionalProperties": false,
|
|
276
|
+
"description": "UpsertRecordsInput creates or updates up to 10 records in one table. Airtable matches each record to an existing record whose merge fields equal the record's values for them: no match creates a record, one match updates it, leaving fields the write does not name unchanged, and several matches reject the whole request. A repeated write of the same input therefore updates the records the first write created instead of adding duplicates.",
|
|
277
|
+
"properties": {
|
|
278
|
+
"baseId": {
|
|
279
|
+
"description": "BaseID is the base ID, such as appXXXXXXXXXXXXXX.",
|
|
280
|
+
"type": "string"
|
|
281
|
+
},
|
|
282
|
+
"fieldsToMergeOn": {
|
|
283
|
+
"description": "FieldsToMergeOn names one to three fields whose values identify a record, such as a case ID. Airtable lists number, text, long text, single select, multiple select, and date fields as merge fields, never a computed field such as a formula, lookup, or rollup.",
|
|
284
|
+
"items": {
|
|
285
|
+
"type": "string"
|
|
286
|
+
},
|
|
287
|
+
"type": [
|
|
288
|
+
"array",
|
|
289
|
+
"null"
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
"records": {
|
|
293
|
+
"description": "Records are the one to ten records to write; no two may share merge values.",
|
|
294
|
+
"items": {
|
|
295
|
+
"$ref": "#/$defs/RecordUpsert"
|
|
296
|
+
},
|
|
297
|
+
"type": [
|
|
298
|
+
"array",
|
|
299
|
+
"null"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
"tableIdOrName": {
|
|
303
|
+
"description": "TableIDOrName is the table ID, such as tblXXXXXXXXXXXXXX, or the table name.",
|
|
304
|
+
"type": "string"
|
|
305
|
+
},
|
|
306
|
+
"typecast": {
|
|
307
|
+
"description": "Typecast lets Airtable convert text to the field's type, such as adding a new select option; false rejects a value of the wrong type.",
|
|
308
|
+
"type": "boolean"
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
"required": [
|
|
312
|
+
"baseId",
|
|
313
|
+
"fieldsToMergeOn",
|
|
314
|
+
"records",
|
|
315
|
+
"tableIdOrName"
|
|
316
|
+
],
|
|
317
|
+
"type": "object"
|
|
318
|
+
}
|
|
118
319
|
},
|
|
119
320
|
{
|
|
120
321
|
"name": "newUpdateRecordsStep",
|
|
121
322
|
"kind": "mutation",
|
|
122
323
|
"operationId": "updateRecords",
|
|
324
|
+
"inputType": "UpdateRecordsInput",
|
|
325
|
+
"description": "Set the named fields of up to 10 records by record ID, leaving every other field unchanged.",
|
|
123
326
|
"fields": {
|
|
124
327
|
"stepType": "stepType",
|
|
125
328
|
"annotations": "annotations",
|
|
@@ -152,7 +355,76 @@
|
|
|
152
355
|
"field": "defect",
|
|
153
356
|
"optional": true
|
|
154
357
|
}
|
|
155
|
-
]
|
|
358
|
+
],
|
|
359
|
+
"inputSchema": {
|
|
360
|
+
"$defs": {
|
|
361
|
+
"RecordUpdate": {
|
|
362
|
+
"additionalProperties": false,
|
|
363
|
+
"description": "RecordUpdate sets fields on one existing record.",
|
|
364
|
+
"properties": {
|
|
365
|
+
"fields": {
|
|
366
|
+
"additionalProperties": {},
|
|
367
|
+
"description": "Fields maps field names or IDs to their new cell values. Fields the update does not name keep their values.",
|
|
368
|
+
"type": [
|
|
369
|
+
"object",
|
|
370
|
+
"null"
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
"id": {
|
|
374
|
+
"description": "ID is the record ID, such as recXXXXXXXXXXXXXX.",
|
|
375
|
+
"type": "string"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"required": [
|
|
379
|
+
"fields",
|
|
380
|
+
"id"
|
|
381
|
+
],
|
|
382
|
+
"type": "object"
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
"additionalProperties": false,
|
|
386
|
+
"description": "UpdateRecordsInput updates up to 10 records in one table by record ID. Each value replaces the field's whole value, including every link of a linked record field, so repeating the same update leaves the records unchanged.",
|
|
387
|
+
"properties": {
|
|
388
|
+
"baseId": {
|
|
389
|
+
"description": "BaseID is the base ID, such as appXXXXXXXXXXXXXX.",
|
|
390
|
+
"type": "string"
|
|
391
|
+
},
|
|
392
|
+
"records": {
|
|
393
|
+
"description": "Records are the one to ten records to update, each named once.",
|
|
394
|
+
"items": {
|
|
395
|
+
"$ref": "#/$defs/RecordUpdate"
|
|
396
|
+
},
|
|
397
|
+
"type": [
|
|
398
|
+
"array",
|
|
399
|
+
"null"
|
|
400
|
+
]
|
|
401
|
+
},
|
|
402
|
+
"tableIdOrName": {
|
|
403
|
+
"description": "TableIDOrName is the table ID, such as tblXXXXXXXXXXXXXX, or the table name.",
|
|
404
|
+
"type": "string"
|
|
405
|
+
},
|
|
406
|
+
"typecast": {
|
|
407
|
+
"description": "Typecast lets Airtable convert text to the field's type, such as adding a new select option; false rejects a value of the wrong type.",
|
|
408
|
+
"type": "boolean"
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
"required": [
|
|
412
|
+
"baseId",
|
|
413
|
+
"records",
|
|
414
|
+
"tableIdOrName"
|
|
415
|
+
],
|
|
416
|
+
"type": "object"
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"name": "defineRecordChangedTriggerBinding",
|
|
421
|
+
"kind": "trigger",
|
|
422
|
+
"triggerName": "recordChanged",
|
|
423
|
+
"fields": {
|
|
424
|
+
"connectionName": "connectionName",
|
|
425
|
+
"bindingName": "bindingName",
|
|
426
|
+
"configurationUI": "configurationUI"
|
|
427
|
+
}
|
|
156
428
|
}
|
|
157
429
|
]
|
|
158
430
|
}
|
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
// src/generated/models.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
+
function isGoTimeJSON(value) {
|
|
6
|
+
const match = goTimeJSONPattern.exec(value);
|
|
7
|
+
if (!match) return false;
|
|
8
|
+
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
+
const year = Number(yearText);
|
|
10
|
+
const month = Number(monthText);
|
|
11
|
+
const day = Number(dayText);
|
|
12
|
+
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
+
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
+
}
|
|
16
|
+
function canonicalGoTimeJSON(value) {
|
|
17
|
+
const match = goTimeJSONPattern.exec(value);
|
|
18
|
+
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
+
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
+
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
+
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
+
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
+
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
+
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
+
}
|
|
26
|
+
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
3
27
|
var ConfigSchema = z.object({
|
|
4
28
|
"endpoint": z.string().optional(),
|
|
5
|
-
"maxResponseBytes": z.number().int().optional()
|
|
29
|
+
"maxResponseBytes": z.number().int().optional(),
|
|
30
|
+
"pollIntervalMs": z.number().int().optional(),
|
|
31
|
+
"pollPageSize": z.number().int().optional()
|
|
6
32
|
});
|
|
33
|
+
function decodeCredentials(value) {
|
|
34
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
35
|
+
const fields = value;
|
|
36
|
+
const allowed = /* @__PURE__ */ new Set(["personal_access_token"]);
|
|
37
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
38
|
+
if (fields["personal_access_token"] != null && !(typeof fields["personal_access_token"] === "string")) throw new TypeError("credential personal_access_token has an invalid type");
|
|
39
|
+
const credentials = {};
|
|
40
|
+
if (!fields["personal_access_token"]) throw new TypeError("credential personal_access_token is required");
|
|
41
|
+
credentials.personalAccessToken = new SecretString(fields["personal_access_token"] ?? "");
|
|
42
|
+
return credentials;
|
|
43
|
+
}
|
|
7
44
|
var FieldEqualityFilterSchema = z.strictObject({
|
|
8
45
|
"field": z.string(),
|
|
9
46
|
"text": z.string().optional(),
|
|
@@ -27,7 +64,7 @@ var ListRecordsInputSchema = z.strictObject({
|
|
|
27
64
|
});
|
|
28
65
|
var RecordSchema = z.strictObject({
|
|
29
66
|
"id": z.string(),
|
|
30
|
-
"createdTime":
|
|
67
|
+
"createdTime": GoTimeJSONSchema,
|
|
31
68
|
"fields": z.record(z.string(), z.unknown().nullable()).nullable()
|
|
32
69
|
});
|
|
33
70
|
var RecordPageSchema = z.strictObject({
|
|
@@ -140,7 +177,9 @@ var UpsertRecordsDefinition = {
|
|
|
140
177
|
{ id: "invalidResponse", description: "Airtable applied or rejected the upsert but returned an invalid or oversized response.", optional: true },
|
|
141
178
|
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
142
179
|
],
|
|
143
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync" }
|
|
180
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync" },
|
|
181
|
+
repeatOnUnknown: "limited",
|
|
182
|
+
maxSends: 3
|
|
144
183
|
};
|
|
145
184
|
var UpsertRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
146
185
|
var UpdateRecordsBranch = {
|
|
@@ -164,7 +203,9 @@ var UpdateRecordsDefinition = {
|
|
|
164
203
|
{ id: "invalidResponse", description: "Airtable applied or rejected the update but returned an invalid or oversized response.", optional: true },
|
|
165
204
|
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
166
205
|
],
|
|
167
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
206
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
|
|
207
|
+
repeatOnUnknown: "limited",
|
|
208
|
+
maxSends: 3
|
|
168
209
|
};
|
|
169
210
|
var UpdateRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
170
211
|
|
|
@@ -200,6 +241,7 @@ function newProjectConnection(project, connectionName, createClient) {
|
|
|
200
241
|
|
|
201
242
|
export {
|
|
202
243
|
ConfigSchema,
|
|
244
|
+
decodeCredentials,
|
|
203
245
|
FieldEqualityFilterSchema,
|
|
204
246
|
RecordSortSchema,
|
|
205
247
|
ListRecordsInputSchema,
|
|
@@ -7,17 +7,25 @@ interface Config {
|
|
|
7
7
|
endpoint?: string;
|
|
8
8
|
/** Maximum complete Airtable API response in bytes; leave blank to keep the safety limit, or enter a larger positive integer only when one page of records carries very long text or many attachments. Oversized responses select invalidResponse. */
|
|
9
9
|
maxResponseBytes?: number;
|
|
10
|
+
/** Delay between recordChanged Trigger polls of each picked table, as a Go duration of at least 1s such as 15s or 2m; leave blank for the shown interval, and lengthen it when many bindings share one base. Each poll normally makes one Airtable list request, and Airtable allows 5 requests per second per base and 50 per second per personal access token across every binding and Step. Runtime value in milliseconds. */
|
|
11
|
+
pollIntervalMs?: number;
|
|
12
|
+
/** Records one recordChanged poll request reads, a whole number from 1 up to Airtable's largest page of one hundred records; leave blank for a full page, and lower it only when records carry so much text or so many attachments that a page exceeds maxResponseBytes, since further changed records are read by an immediate follow-up request. */
|
|
13
|
+
pollPageSize?: number;
|
|
10
14
|
}
|
|
11
15
|
/** Runtime schema for manifest configuration. */
|
|
12
16
|
declare const ConfigSchema: z.ZodObject<{
|
|
13
17
|
endpoint: z.ZodOptional<z.ZodString>;
|
|
14
18
|
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
pollPageSize: z.ZodOptional<z.ZodNumber>;
|
|
15
21
|
}, z.core.$strip>;
|
|
16
22
|
/** Private connector credentials resolved by the host. */
|
|
17
23
|
interface Credentials {
|
|
18
24
|
/** Secret Airtable personal access token copied once from https://airtable.com/create/tokens after choosing Create new token; it starts with pat and is otherwise an opaque string, Dex Web stores it as a secret, and blank means no Airtable call can authenticate. */
|
|
19
25
|
personalAccessToken: SecretString;
|
|
20
26
|
}
|
|
27
|
+
/** Decode private credential fields for the connector. */
|
|
28
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
21
29
|
/** Host-owned source of private connector credentials. */
|
|
22
30
|
type CredentialSource = CredentialProvider<Credentials>;
|
|
23
31
|
/** FieldEqualityFilter matches records whose field equals one typed value.
|
|
@@ -223,14 +231,14 @@ declare const ListRecordsInputSchema: z.ZodObject<{
|
|
|
223
231
|
/** Runtime validator for Record. */
|
|
224
232
|
declare const RecordSchema: z.ZodObject<{
|
|
225
233
|
id: z.ZodString;
|
|
226
|
-
createdTime: z.
|
|
234
|
+
createdTime: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
227
235
|
fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
|
|
228
236
|
}, z.core.$strict>;
|
|
229
237
|
/** Runtime validator for RecordPage. */
|
|
230
238
|
declare const RecordPageSchema: z.ZodObject<{
|
|
231
239
|
records: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
232
240
|
id: z.ZodString;
|
|
233
|
-
createdTime: z.
|
|
241
|
+
createdTime: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
234
242
|
fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
|
|
235
243
|
}, z.core.$strict>>>;
|
|
236
244
|
offset: z.ZodOptional<z.ZodString>;
|
|
@@ -260,7 +268,7 @@ declare const UpsertRecordsInputSchema: z.ZodObject<{
|
|
|
260
268
|
declare const UpsertedRecordsSchema: z.ZodObject<{
|
|
261
269
|
records: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
262
270
|
id: z.ZodString;
|
|
263
|
-
createdTime: z.
|
|
271
|
+
createdTime: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
264
272
|
fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
|
|
265
273
|
}, z.core.$strict>>>;
|
|
266
274
|
createdRecordIds: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
@@ -286,7 +294,7 @@ declare const UpdateRecordsInputSchema: z.ZodObject<{
|
|
|
286
294
|
declare const UpdatedRecordsSchema: z.ZodObject<{
|
|
287
295
|
records: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
288
296
|
id: z.ZodString;
|
|
289
|
-
createdTime: z.
|
|
297
|
+
createdTime: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
290
298
|
fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
|
|
291
299
|
}, z.core.$strict>>>;
|
|
292
300
|
partialSuccessReasons: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -317,4 +325,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
|
|
|
317
325
|
/** Bind scripted operations to a named connection. */
|
|
318
326
|
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
319
327
|
|
|
320
|
-
export { Connection as C, type FieldEqualityFilter as F, type GetRecordInput as G, type ListRecordsInput as L, type Operations as O, type Record as R, type UpdateRecordsInput as U, type RecordPage as a, type UpdatedRecords as b, type UpsertRecordsInput as c, type UpsertedRecords as d, type Config as e, type Credentials as f, ConfigSchema as g, type CredentialSource as h, FieldEqualityFilterSchema as i, GetRecordInputSchema as j, ListRecordsInputSchema as k, RecordPageSchema as l, RecordSchema as m, type RecordSort as n, RecordSortSchema as o, type RecordUpdate as p, RecordUpdateSchema as q, type RecordUpsert as r, RecordUpsertSchema as s, UpdateRecordsInputSchema as t, UpdatedRecordsSchema as u, UpsertRecordsInputSchema as v, UpsertedRecordsSchema as w,
|
|
328
|
+
export { Connection as C, type FieldEqualityFilter as F, type GetRecordInput as G, type ListRecordsInput as L, type Operations as O, type Record as R, type UpdateRecordsInput as U, type RecordPage as a, type UpdatedRecords as b, type UpsertRecordsInput as c, type UpsertedRecords as d, type Config as e, type Credentials as f, ConfigSchema as g, type CredentialSource as h, FieldEqualityFilterSchema as i, GetRecordInputSchema as j, ListRecordsInputSchema as k, RecordPageSchema as l, RecordSchema as m, type RecordSort as n, RecordSortSchema as o, type RecordUpdate as p, RecordUpdateSchema as q, type RecordUpsert as r, RecordUpsertSchema as s, UpdateRecordsInputSchema as t, UpdatedRecordsSchema as u, UpsertRecordsInputSchema as v, UpsertedRecordsSchema as w, decodeCredentials as x, newConnection as y, newConnectionWithOperations as z };
|