@crvouga/mockingbird-service-airtable

中文文档
1.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 2931

Stateful Airtable emulator: OAuth, base schemas, fields and validated records.

原始使用文档
文档目录7 节
  1. Install
  2. Usage
  3. Surface and state
  4. Test controls
  5. Oracle and tests
  6. Deliberately not modelled
  7. API

@crvouga/mockingbird-service-airtable

Local emulators. Real API contracts. Part of Mockingbird.

WIP Airtable OAuth and forms-integration emulator. Only synthetic fixtures belong here.

Install

bun add @crvouga/mockingbird-service-airtable

Usage

import { createServer } from "@crvouga/mockingbird-service-airtable/server"

const server = await createServer()

// The application's own HTTP call (airtable.js has no metadata API). Only the origin changes.
const response = await fetch(`${server.url}/v0/meta/bases`, {
  headers: { authorization: "Bearer mock_airtable_token" },
})
const { bases } = (await response.json()) as { bases: { id: string; name: string }[] }
console.log(bases.map((base) => base.id)) // ["appMockBase"]

await server.close()

Run mockingbird-airtable serve --port 12130. Inject its origin for both the API and OAuth origin in the optional integration; consumer endpoint wiring is separate.

Surface and state

  • POST /oauth2/v1/token: form-encoded authorization-code and refresh grants. Confidential clients require Basic credentials; public clients use body client_id. Codes require S256 PKCE and exact redirect/client binding, expire by clock, and are consumed before verifier checks so even a rejected verifier cannot replay them. Refresh rotates both tokens; access lasts 60 minutes and refresh 60 days. Scope reduction is allowed. The documented trailing space in token_type: "Bearer " is retained.
  • GET /v0/meta/whoami: user id and scopes, plus email only with user.email:read.
  • GET /v0/meta/bases: accessible bases/permission levels and opaque offset pages (pageSize, default 1000).
  • GET /v0/meta/bases/{baseId}/tables: table schemas/fields/views for accessible bases.
  • POST /v0/meta/bases/{baseId}/tables/{tableId}/fields: add supported form-field schemas and retain options.
  • POST /v0/{baseId}/{tableId}: up to ten records, or one top-level fields object. Accept field ids or names; persist only after every input record validates. Empty cells are omitted. returnFieldsByFieldId controls response keys. Table name aliases work.

Default bearer mock_airtable_token, refresh mock_airtable_refresh, client mock_client / mock_client_secret; base appMockBase, table tblMockTable, field fldMockName named Name. Default scopes permit schema reads/writes, record writes, and synthetic email. Grant scopes and base roles gate operations independently. Missing/inaccessible bases yield 403; invalid/expired access yields 401; invalid cells yield 422 without partial records.

Seed bases, tables, grants, clients, codes, and records using constructor options or standard admin state. Fields supported for typed form writes: singleLineText, multilineText, richText, email, url, phoneNumber, number, percent, currency, duration, rating, checkbox, date, dateTime, singleSelect and multipleSelects. Options for choices, precision and checkbox appearance are retained; select values must name a seeded choice. Scalar validation covers wire types rather than every vendor presentation constraint. Unknown field types fail instead of silently accepting arbitrary values.

Test controls

Standard relocatable /__admin health, state, reset, clock, Timeline checkpoints, request journal, metrics and faults. Header namespaces, /__admin/ns/<name> paths and bearer mappings isolate records/grants. Journals contain metadata only, not OAuth bodies or submitted form values. Presets: unauthorized, rate_limited (429, retry-after 30), invalid_schema (422), server_error, connection_drop. Generic fault rules add latency. No webhooks required.

Oracle and tests

Follows official Airtable OAuth, identity, bases, schema, field creation, record creation and errors references. No successful live OAuth or SaaS writes were performed; no credentials used.

bun test runs raw-fetch acceptance, every-operation self-parity and divergence detection. The consumer is a faithful wire-surface port, not inaccessible private source. bun run parity requires AIRTABLE_ACCESS_TOKEN; it performs only a read-only identity-envelope probe, never printing identifiers.

Deliberately not modelled

No actual SaaS writes, formulas/computed columns, linked records, attachments, collaborators, views editing, collaboration UI or production-integration activation. No typecast conversion, complete field-option/presentation validation, real quota accounting, exact error prose or internal offset format. Schema seeding may contain additional metadata; writes validate only the listed form-field types. OAuth retry grace/conflict timing, authorization UI and enterprise policy discovery are not simulated; fault controls can script these errors. Tokens/ids are local deterministic stand-ins.

API

Root runtime exports: AirtableAPI, AIRTABLE_NAMESPACE, createRuntime, AIRTABLE_PRESETS, document, operationIds, supportedOperationIds. Types: AirtableAPIOptions, Field, Table, Base, Grant, Client, OAuthCode, StoredRecord, AirtableRuntimeOptions, AirtableRuntime, OperationId, SupportedOperationId.

/server exports createServer, serveTarget, DEFAULT_PORT; types AirtableServerOptions, AirtableServer.

版本与发布记录

@crvouga/mockingbird-service-airtable 共发布 22 个版本,首次发布于 2026/10/05;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.11.0latest2026/11/11今天
1.10.92026/11/038 天前
1.10.82026/11/038 天前
1.10.72026/11/038 天前
1.10.62026/11/038 天前
1.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-airtable 的常见问题

@crvouga/mockingbird-service-airtable 是什么?

Stateful Airtable emulator: OAuth, base schemas, fields and validated records.

如何安装 @crvouga/mockingbird-service-airtable?

在项目目录运行 npm install @crvouga/mockingbird-service-airtable,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-airtable,可以用 npx mockingbird-airtable 直接运行。

@crvouga/mockingbird-service-airtable 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crvouga/mockingbird-service-airtable 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crvouga/mockingbird-service-airtable 可以商用吗?

@crvouga/mockingbird-service-airtable 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-airtable 的下载量有多少?

根据 npm 官方下载统计,@crvouga/mockingbird-service-airtable 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,931 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crvouga/mockingbird-service-airtable 还在维护吗?

最新版本 1.11.0 发布于 2026/11/11(今天);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。