@superdurable/connector-airtable 0.2.0 → 0.2.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.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "connectorId": "airtable",
3
- "releaseTag": "connectors/airtable/go/v0.24.0",
3
+ "releaseTag": "connectors/airtable/go/v0.24.1",
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-airtable",
7
- "version": "0.2.0"
7
+ "version": "0.2.1"
8
8
  },
9
9
  "factories": [
10
10
  {
@@ -30,14 +30,28 @@ var ConfigSchema = z.object({
30
30
  "pollIntervalMs": z.number().int().optional(),
31
31
  "pollPageSize": z.number().int().optional()
32
32
  });
33
+ var CredentialMaterialError = class extends TypeError {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = "CredentialMaterialError";
37
+ }
38
+ };
39
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
40
+ "project credential decoding failed",
41
+ "shared project credential decoding failed",
42
+ "project credential decoding failed: this connector version does not support shared credentials"
43
+ ]);
44
+ function isCredentialMaterialError(error) {
45
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
46
+ }
33
47
  function decodeCredentials(value) {
34
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
48
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
35
49
  const fields = value;
36
50
  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");
51
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
52
+ if (fields["personal_access_token"] != null && !(typeof fields["personal_access_token"] === "string")) throw new CredentialMaterialError("credential personal_access_token has an invalid type");
39
53
  const credentials = {};
40
- if (!fields["personal_access_token"]) throw new TypeError("credential personal_access_token is required");
54
+ if (!fields["personal_access_token"]) throw new CredentialMaterialError("credential personal_access_token is required");
41
55
  credentials.personalAccessToken = new SecretString(fields["personal_access_token"] ?? "");
42
56
  return credentials;
43
57
  }
@@ -174,12 +188,11 @@ var UpsertRecordsDefinition = {
174
188
  branches: [
175
189
  { id: "upserted", description: "Airtable created each record without a match and updated each record that matched." },
176
190
  { 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 },
177
- { id: "invalidResponse", description: "Airtable applied or rejected the upsert but returned an invalid or oversized response.", optional: true },
191
+ { id: "invalidResponse", description: "Kept for compatibility and no longer selected: an invalid or oversized upsert response now retries, because repeating the upsert is safe.", optional: true },
178
192
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
179
193
  ],
180
194
  stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync" },
181
- repeatOnUnknown: "limited",
182
- maxSends: 3
195
+ repeatOnUnknown: "safe"
183
196
  };
184
197
  var UpsertRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
185
198
  var UpdateRecordsBranch = {
@@ -200,12 +213,11 @@ var UpdateRecordsDefinition = {
200
213
  { id: "updated", description: "Airtable updated every record and returned it." },
201
214
  { id: "notFound", description: "A record ID does not exist in the table.", optional: true },
202
215
  { 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 },
203
- { id: "invalidResponse", description: "Airtable applied or rejected the update but returned an invalid or oversized response.", optional: true },
216
+ { id: "invalidResponse", description: "Kept for compatibility and no longer selected: an invalid or oversized update response now retries, because repeating absolute values is safe.", optional: true },
204
217
  { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
205
218
  ],
206
219
  stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
207
- repeatOnUnknown: "limited",
208
- maxSends: 3
220
+ repeatOnUnknown: "safe"
209
221
  };
210
222
  var UpdateRecordsMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
211
223
 
@@ -241,6 +253,8 @@ function newProjectConnection(project, connectionName, createClient) {
241
253
 
242
254
  export {
243
255
  ConfigSchema,
256
+ CredentialMaterialError,
257
+ isCredentialMaterialError,
244
258
  decodeCredentials,
245
259
  FieldEqualityFilterSchema,
246
260
  RecordSortSchema,
@@ -5,7 +5,7 @@ import { z } from 'zod';
5
5
  interface Config {
6
6
  /** Airtable Web API base URL; leave blank for Airtable's public API host. Enter an absolute HTTPS URL only for an explicitly supported compatible gateway, or a loopback HTTP URL for a local test server. The base and table pickers always call Airtable's public API host. */
7
7
  endpoint?: string;
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. */
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 read responses select invalidResponse; an oversized write response retries the repeat-safe write. */
9
9
  maxResponseBytes?: number;
10
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
11
  pollIntervalMs?: number;
@@ -24,6 +24,12 @@ interface Credentials {
24
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. */
25
25
  personalAccessToken: SecretString;
26
26
  }
27
+ /** Stored credential material that fails the connector credential checks, so no retry can succeed. */
28
+ declare class CredentialMaterialError extends TypeError {
29
+ constructor(message: string);
30
+ }
31
+ /** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
32
+ declare function isCredentialMaterialError(error: unknown): boolean;
27
33
  /** Decode private credential fields for the connector. */
28
34
  declare function decodeCredentials(value: unknown): Credentials;
29
35
  /** Host-owned source of private connector credentials. */
@@ -325,4 +331,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
325
331
  /** Bind scripted operations to a named connection. */
326
332
  declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
327
333
 
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 };
334
+ export { newConnection as A, newConnectionWithOperations as B, 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, CredentialMaterialError as h, type CredentialSource as i, FieldEqualityFilterSchema as j, GetRecordInputSchema as k, ListRecordsInputSchema as l, RecordPageSchema as m, RecordSchema as n, type RecordSort as o, RecordSortSchema as p, type RecordUpdate as q, RecordUpdateSchema as r, type RecordUpsert as s, RecordUpsertSchema as t, UpdateRecordsInputSchema as u, UpdatedRecordsSchema as v, UpsertRecordsInputSchema as w, UpsertedRecordsSchema as x, decodeCredentials as y, isCredentialMaterialError as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GetRecordInput, R as Record$1, C as Connection, L as ListRecordsInput, a as RecordPage, U as UpdateRecordsInput, b as UpdatedRecords, c as UpsertRecordsInput, d as UpsertedRecords, e as Config, f as Credentials, O as Operations } from './connection-D9d1yIrY.js';
2
- export { g as ConfigSchema, h as CredentialSource, F as FieldEqualityFilter, i as FieldEqualityFilterSchema, j as GetRecordInputSchema, k as ListRecordsInputSchema, l as RecordPageSchema, m as RecordSchema, n as RecordSort, o as RecordSortSchema, p as RecordUpdate, q as RecordUpdateSchema, r as RecordUpsert, s as RecordUpsertSchema, t as UpdateRecordsInputSchema, u as UpdatedRecordsSchema, v as UpsertRecordsInputSchema, w as UpsertedRecordsSchema, x as decodeCredentials, y as newConnection, z as newConnectionWithOperations } from './connection-D9d1yIrY.js';
1
+ import { G as GetRecordInput, R as Record$1, C as Connection, L as ListRecordsInput, a as RecordPage, U as UpdateRecordsInput, b as UpdatedRecords, c as UpsertRecordsInput, d as UpsertedRecords, e as Config, f as Credentials, O as Operations } from './connection-D07xrUMb.js';
2
+ export { g as ConfigSchema, h as CredentialMaterialError, i as CredentialSource, F as FieldEqualityFilter, j as FieldEqualityFilterSchema, k as GetRecordInputSchema, l as ListRecordsInputSchema, m as RecordPageSchema, n as RecordSchema, o as RecordSort, p as RecordSortSchema, q as RecordUpdate, r as RecordUpdateSchema, s as RecordUpsert, t as RecordUpsertSchema, u as UpdateRecordsInputSchema, v as UpdatedRecordsSchema, w as UpsertRecordsInputSchema, x as UpsertedRecordsSchema, y as decodeCredentials, z as isCredentialMaterialError, A as newConnection, B as newConnectionWithOperations } from './connection-D07xrUMb.js';
3
3
  import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
4
  import { QueryDefinition, MutationDefinition, QueryStepConfig, Query, QueryResult, MutationStepConfig, Mutation, MutationResult, QueryStep, MutationStep, Call, QueryAttempt, MutationAttempt, TriggerLogger, CredentialProvider, ReceiptDraft, Failure, TriggerTarget, ConnectorConfigurationUI, TriggerDefinition, TriggerBindingDefinition, TriggerRunner } from '@superdurable/connectors-sdk';
5
5
  import { StepTarget } from '@superdurable/dex';
@@ -75,7 +75,7 @@ declare const UpsertRecordsBranch: {
75
75
  declare const UpsertRecordsBranchUpserted: "upserted";
76
76
  /** 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. */
77
77
  declare const UpsertRecordsBranchProviderRejected: "providerRejected";
78
- /** Airtable applied or rejected the upsert but returned an invalid or oversized response. */
78
+ /** Kept for compatibility and no longer selected: an invalid or oversized upsert response now retries, because repeating the upsert is safe. */
79
79
  declare const UpsertRecordsBranchInvalidResponse: "invalidResponse";
80
80
  /** Local input, connection configuration, or connector definition is invalid. */
81
81
  declare const UpsertRecordsBranchDefect: "defect";
@@ -101,7 +101,7 @@ declare const UpdateRecordsBranchUpdated: "updated";
101
101
  declare const UpdateRecordsBranchNotFound: "notFound";
102
102
  /** Airtable conclusively rejected the update, such as an invalid cell value, a computed field, a missing scope, or a rejected token. */
103
103
  declare const UpdateRecordsBranchProviderRejected: "providerRejected";
104
- /** Airtable applied or rejected the update but returned an invalid or oversized response. */
104
+ /** Kept for compatibility and no longer selected: an invalid or oversized update response now retries, because repeating absolute values is safe. */
105
105
  declare const UpdateRecordsBranchInvalidResponse: "invalidResponse";
106
106
  /** Local input, connection configuration, or connector definition is invalid. */
107
107
  declare const UpdateRecordsBranchDefect: "defect";
@@ -168,10 +168,12 @@ interface UpsertRecordsStepConfig<StepInput, OperationInput = UpsertRecordsInput
168
168
  upserted: StepTarget<MutationResult<OperationOutput>>;
169
169
  /** 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. */
170
170
  providerRejected?: StepTarget<MutationResult<OperationOutput>>;
171
- /** Airtable applied or rejected the upsert but returned an invalid or oversized response. */
171
+ /** Kept for compatibility and no longer selected: an invalid or oversized upsert response now retries, because repeating the upsert is safe. */
172
172
  invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
173
173
  /** Local input, connection configuration, or connector definition is invalid. */
174
174
  defect?: StepTarget<MutationResult<OperationOutput>>;
175
+ /** Accepted for compatibility; ignored because the operation is safe to repeat. */
176
+ maxSends?: number;
175
177
  }
176
178
  /** Build the upsertRecords Step from a named connection. */
177
179
  declare function newUpsertRecordsStep<StepInput, OperationInput = UpsertRecordsInput, OperationOutput = UpsertedRecords>(configuration: UpsertRecordsStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
@@ -189,10 +191,12 @@ interface UpdateRecordsStepConfig<StepInput, OperationInput = UpdateRecordsInput
189
191
  notFound?: StepTarget<MutationResult<OperationOutput>>;
190
192
  /** Airtable conclusively rejected the update, such as an invalid cell value, a computed field, a missing scope, or a rejected token. */
191
193
  providerRejected?: StepTarget<MutationResult<OperationOutput>>;
192
- /** Airtable applied or rejected the update but returned an invalid or oversized response. */
194
+ /** Kept for compatibility and no longer selected: an invalid or oversized update response now retries, because repeating absolute values is safe. */
193
195
  invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
194
196
  /** Local input, connection configuration, or connector definition is invalid. */
195
197
  defect?: StepTarget<MutationResult<OperationOutput>>;
198
+ /** Accepted for compatibility; ignored because the operation is safe to repeat. */
199
+ maxSends?: number;
196
200
  }
197
201
  /** Build the updateRecords Step from a named connection. */
198
202
  declare function newUpdateRecordsStep<StepInput, OperationInput = UpdateRecordsInput, OperationOutput = UpdatedRecords>(configuration: UpdateRecordsStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
@@ -258,6 +262,8 @@ interface ExchangeFailure {
258
262
  retryAfterMs: number;
259
263
  /** Correlation receipt after a provider attempt. */
260
264
  receipt: ReceiptDraft;
265
+ /** HTTP status of the provider answer, or undefined when no status arrived. */
266
+ status?: number;
261
267
  }
262
268
  /** Successful bounded response or classified failure. */
263
269
  type ExchangeResult = {
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  ConfigSchema,
3
3
  Connection,
4
4
  ConnectorID,
5
+ CredentialMaterialError,
5
6
  FieldEqualityFilterSchema,
6
7
  GetRecordBranch,
7
8
  GetRecordBranchDefect,
@@ -47,10 +48,11 @@ import {
47
48
  UpsertRecordsMetadata,
48
49
  UpsertedRecordsSchema,
49
50
  decodeCredentials,
51
+ isCredentialMaterialError,
50
52
  newConnection,
51
53
  newConnectionWithOperations,
52
54
  newProjectConnection
53
- } from "./chunk-RBINH2QY.js";
55
+ } from "./chunk-XPD7RWH6.js";
54
56
 
55
57
  // src/generated/steps.ts
56
58
  import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
@@ -77,7 +79,7 @@ function newGetRecordStep(configuration) {
77
79
  ] });
78
80
  }
79
81
  function newUpsertRecordsStep(configuration) {
80
- const { connection, connectionName, upserted, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
82
+ const { connection, connectionName, upserted, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
81
83
  if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
82
84
  return newMutationStep({ ...stepConfiguration, operation: connection.operations.upsertRecords(), connection: connection.reference, branches: [
83
85
  goToBranch("upserted", upserted),
@@ -87,7 +89,7 @@ function newUpsertRecordsStep(configuration) {
87
89
  ] });
88
90
  }
89
91
  function newUpdateRecordsStep(configuration) {
90
- const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
92
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
91
93
  if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
92
94
  return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateRecords(), connection: connection.reference, branches: [
93
95
  goToBranch("updated", updated),
@@ -105,6 +107,7 @@ import { z } from "zod";
105
107
  // src/client.ts
106
108
  import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
107
109
  import { ReauthorizationRequiredError, SecretString } from "@superdurable/connectors-sdk";
110
+ import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
108
111
 
109
112
  // src/operations.ts
110
113
  import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
@@ -213,8 +216,8 @@ var UpsertRecordsOperation = class {
213
216
  if ([...createdRecordIds, ...updatedRecordIds].some((id) => !writtenIds.has(id)) || createdRecordIds.some((id) => updatedRecordIds.includes(id))) throw new Error("invalid upsert IDs");
214
217
  const partialSuccessReasons = decodePartialSuccessReasons(body.details);
215
218
  return newMutationBranch("upserted", { records, createdRecordIds, updatedRecordIds, ...partialSuccessReasons.length ? { partialSuccessReasons } : {} }, this.client.receipt(call, objectId));
216
- } catch {
217
- return mutationFailure("upsertRecords", "invalidResponse", "PROTOCOL", zeroUpserted, this.client.receipt(call, objectId));
219
+ } catch (error) {
220
+ return unusableAnswerRetry("upsertRecords", error);
218
221
  }
219
222
  }
220
223
  };
@@ -251,8 +254,8 @@ var UpdateRecordsOperation = class {
251
254
  if (records.some((record) => !requestedIds.has(record.id))) throw new Error("unexpected updated record");
252
255
  const partialSuccessReasons = decodePartialSuccessReasons(body.details);
253
256
  return newMutationBranch("updated", { records, ...partialSuccessReasons.length ? { partialSuccessReasons } : {} }, this.client.receipt(call, objectId));
254
- } catch {
255
- return mutationFailure("updateRecords", "invalidResponse", "PROTOCOL", zeroUpdated, this.client.receipt(call, objectId));
257
+ } catch (error) {
258
+ return unusableAnswerRetry("updateRecords", error);
256
259
  }
257
260
  }
258
261
  };
@@ -261,8 +264,10 @@ function queryOutcome(outcome, zero, rejectedBranch, notFoundBranch = rejectedBr
261
264
  const branch = outcome.disposition === "notFound" ? notFoundBranch : outcome.disposition === "offsetExpired" ? "offsetExpired" : outcome.disposition === "rejected" ? rejectedBranch : outcome.disposition;
262
265
  return newQueryBranch(branch, zero, outcome.receipt, outcome.failure);
263
266
  }
267
+ var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
264
268
  function mutationOutcome(outcome, zero, rejectedBranch, notFoundBranch = rejectedBranch) {
265
- if (outcome.disposition === "retry") return newMutationRetry(outcome.failure, outcome.retryAfterMs);
269
+ const isUnknownStatus = outcome.status !== void 0 && (outcome.status < 200 || outcome.status >= 300) && !definiteRefusalStatuses.has(outcome.status);
270
+ if (outcome.disposition === "retry" || outcome.disposition === "invalidResponse" || isUnknownStatus) return newMutationRetry(outcome.failure, outcome.retryAfterMs);
266
271
  const branch = outcome.disposition === "notFound" ? notFoundBranch : outcome.disposition === "rejected" || outcome.disposition === "offsetExpired" ? rejectedBranch : outcome.disposition;
267
272
  return newMutationBranch(branch, zero, outcome.receipt, outcome.failure);
268
273
  }
@@ -275,6 +280,9 @@ function mutationDefect(operation, zero, error) {
275
280
  function queryFailure(operation, branch, kind, zero, receipt, error) {
276
281
  return newQueryBranch(branch, zero, receipt, { kind, provider: "airtable", operation, message: error instanceof Error ? error.message : "Airtable response is invalid" });
277
282
  }
283
+ function unusableAnswerRetry(operation, error) {
284
+ return newMutationRetry({ kind: "PROTOCOL", provider: "airtable", operation, message: error instanceof Error ? error.message : "Airtable response is invalid" });
285
+ }
278
286
  function mutationFailure(operation, branch, kind, zero, receipt, error) {
279
287
  return newMutationBranch(branch, zero, receipt, { kind, provider: "airtable", operation, message: error instanceof Error ? error.message : "Airtable response is invalid" });
280
288
  }
@@ -483,16 +491,16 @@ var AirtableClient = class {
483
491
  return { outcome: this.failure("retry", operation, "AVAILABILITY", "the Step ended while waiting for an Airtable request slot") };
484
492
  }
485
493
  }
486
- let token;
494
+ let credentials;
487
495
  try {
488
- const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
489
- if (!(credentials.personalAccessToken instanceof SecretString)) throw new TypeError("invalid Airtable token");
490
- token = credentials.personalAccessToken.reveal();
491
- if (!isHeaderSafeCredential(token)) throw new TypeError("invalid Airtable token");
496
+ credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
492
497
  } catch (error) {
493
498
  if (error instanceof ReauthorizationRequiredError) return { outcome: this.failure("rejected", operation, "AUTHENTICATION", "the Airtable connection must be authorized again") };
494
- return { outcome: this.failure("defect", operation, "AUTHENTICATION", "Airtable connection credentials are unavailable") };
499
+ if (isTerminalCredentialError(error)) return { outcome: this.failure("defect", operation, "AUTHENTICATION", "Airtable connection credentials are unavailable") };
500
+ return { outcome: this.failure("retry", operation, "AVAILABILITY", "Airtable connection credentials are temporarily unavailable") };
495
501
  }
502
+ const token = credentials.personalAccessToken instanceof SecretString ? credentials.personalAccessToken.reveal() : "";
503
+ if (!token || !isHeaderSafeCredential(token)) return { outcome: this.failure("defect", operation, "AUTHENTICATION", "Airtable connection credentials are unavailable") };
496
504
  let encoded;
497
505
  try {
498
506
  if (body !== void 0) encoded = Buffer.from(JSON.stringify(body), "utf8");
@@ -513,11 +521,11 @@ var AirtableClient = class {
513
521
  signal: call.context.cancellationSignal
514
522
  });
515
523
  } catch (error) {
516
- if (error instanceof BodyTooLargeError) return { outcome: this.failure("invalidResponse", operation, "RESPONSE_TOO_LARGE", "Airtable response exceeds the configured size limit", receipt) };
524
+ if (error instanceof BodyTooLargeError) return { outcome: { ...this.failure("invalidResponse", operation, "RESPONSE_TOO_LARGE", "Airtable response exceeds the configured size limit", receipt), ...error.status !== void 0 ? { status: error.status } : {} } };
517
525
  return { outcome: this.failure("retry", operation, "TRANSPORT", "Airtable did not return a complete response", receipt) };
518
526
  }
519
527
  if (response.status >= 200 && response.status < 300) return { response };
520
- return { outcome: this.classifyResponse(operation, baseId, response, receipt) };
528
+ return { outcome: { ...this.classifyResponse(operation, baseId, response, receipt), status: response.status } };
521
529
  }
522
530
  reserveRequestSlot(baseId) {
523
531
  const now = this.now().getTime();
@@ -547,6 +555,9 @@ var AirtableClient = class {
547
555
  return { disposition, failure: { kind, provider: "airtable", operation, message }, receipt, retryAfterMs };
548
556
  }
549
557
  };
558
+ function isTerminalCredentialError(error) {
559
+ return error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || isCredentialMaterialError(error);
560
+ }
550
561
  function header(response, name) {
551
562
  const value = response.headers[name];
552
563
  return Array.isArray(value) ? value[0] ?? "" : value ?? "";
@@ -609,7 +620,7 @@ import {
609
620
  } from "@superdurable/connectors-sdk";
610
621
  import { newBindingPoller, newBindingTriggerSource, newMemoryCursorStore, newRunner } from "@superdurable/connectors-sdk/pollingtrigger";
611
622
  import {
612
- ObjectNotFoundError,
623
+ ObjectNotFoundError as ObjectNotFoundError2,
613
624
  decodeTriggerConfiguration,
614
625
  newDurableTriggerTarget,
615
626
  parseTriggerPayloadJSON
@@ -1261,7 +1272,7 @@ function newProjectRecordChangedTriggerRunner(project, connectionName, routes, o
1261
1272
  try {
1262
1273
  configuration = decodeTriggerConfiguration(project.configuration, key, RecordChangedTriggerConfigurationSchema);
1263
1274
  } catch (error) {
1264
- if (error instanceof ObjectNotFoundError) throw new TypeError(`Airtable recordChanged binding ${name} has no saved configuration; pick the base, table, and field in Dex Web and restart`, { cause: error });
1275
+ if (error instanceof ObjectNotFoundError2) throw new TypeError(`Airtable recordChanged binding ${name} has no saved configuration; pick the base, table, and field in Dex Web and restart`, { cause: error });
1265
1276
  throw new TypeError(`Airtable recordChanged binding ${name} configuration: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1266
1277
  }
1267
1278
  const target = newDurableTriggerTarget(project.triggerInbox(key), key, route.target, { ...options.logger ? { logger: options.logger } : {}, decodePayload: decodeRecordChangedEventPayload });
@@ -1304,6 +1315,7 @@ export {
1304
1315
  ConfigSchema,
1305
1316
  Connection,
1306
1317
  ConnectorID,
1318
+ CredentialMaterialError,
1307
1319
  FieldEqualityFilterSchema,
1308
1320
  GetRecordBranch,
1309
1321
  GetRecordBranchDefect,
@@ -1370,6 +1382,7 @@ export {
1370
1382
  decodeCredentials,
1371
1383
  decodeRecordChangedEventPayload,
1372
1384
  defineRecordChangedTriggerBinding,
1385
+ isCredentialMaterialError,
1373
1386
  newConnection,
1374
1387
  newConnectionWithOperations,
1375
1388
  newGetRecordStep,
package/dist/mock.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
2
2
  import { Failure } from '@superdurable/connectors-sdk';
3
- import { O as Operations, C as Connection, L as ListRecordsInput, a as RecordPage, G as GetRecordInput, R as Record, c as UpsertRecordsInput, d as UpsertedRecords, U as UpdateRecordsInput, b as UpdatedRecords, F as FieldEqualityFilter, n as RecordSort, p as RecordUpdate, r as RecordUpsert } from './connection-D9d1yIrY.js';
3
+ import { O as Operations, C as Connection, L as ListRecordsInput, a as RecordPage, G as GetRecordInput, R as Record, c as UpsertRecordsInput, d as UpsertedRecords, U as UpdateRecordsInput, b as UpdatedRecords, F as FieldEqualityFilter, o as RecordSort, q as RecordUpdate, s as RecordUpsert } from './connection-D07xrUMb.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Go zero value for FieldEqualityFilter in scripted cases. */
package/dist/mock.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  UpsertRecordsInputSchema,
19
19
  UpsertedRecordsSchema,
20
20
  newConnectionWithOperations
21
- } from "./chunk-RBINH2QY.js";
21
+ } from "./chunk-XPD7RWH6.js";
22
22
 
23
23
  // src/generated/mock.ts
24
24
  import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-airtable",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Airtable record operations and the recordChanged poll Trigger for Dex Flows",
5
5
  "repository": {
6
6
  "type": "git",