npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

airtool

v0.1.2

Published

Typed Airtable utilities with schema-aware helpers.

Downloads

378

Readme

airtool

Typed Airtable SDK helpers with schema-aware parsing, field mapping, and retry/pagination utilities.

Features

  • Typed table definitions with ID-to-field mapping
  • Parse and validate records with your schema library
  • Typed CRUD helpers (single + batch)
  • Field selection with required-field merging
  • Optional client wrapper with retry/backoff
  • Lightweight and ESM-first

Requirements

  • Node.js >= 24

Install

pnpm add airtool airtable

Quick start

import {
  createAirtableBase,
  fetchAllRecords,
  pickFields,
  type AirtableTableDefinition,
} from 'airtool';
import { z } from 'zod';

const DealsSchema = z.object({
  name: z.string(),
  status: z.string(),
});

const DealsRecordSchema = z.object({
  id: z.string(),
  fields: DealsSchema,
});

const dealsTable = {
  name: 'Deals',
  tableId: 'tbl123',
  mappings: {
    name: 'fldName',
    status: 'fldStatus',
  },
  requiredFields: ['name', 'status'],
  schema: DealsSchema,
  recordSchema: DealsRecordSchema,
} satisfies AirtableTableDefinition<z.infer<typeof DealsSchema>>;

const base = createAirtableBase({ apiKey: process.env.AIRTABLE_API_KEY!, baseId: 'app123' });
const records = await fetchAllRecords(base, dealsTable, {
  fields: pickFields(dealsTable, 'name', 'status'),
});

console.log(records[0].fields.name);

Using with airtypes

Generate table definitions with airtypes, then import them directly into airtool:

import { createAirtableClient, pickFields } from 'airtool';
import { dealsTable } from './airtable-types.js';

const client = createAirtableClient({
  apiKey: process.env.AIRTABLE_API_KEY!,
  baseId: dealsTable.baseId!,
});

const deals = client.table(dealsTable);
const records = await deals.fetchAllRecords({
  fields: pickFields(dealsTable, 'name', 'status'),
});

airtypes can also emit requiredFields per table (via required_fields in its config), which airtool merges into typed list queries automatically.

Client wrapper (recommended)

import { createAirtableClient } from 'airtool';

const client = createAirtableClient(
  { apiKey: process.env.AIRTABLE_API_KEY!, baseId: 'app123' },
  { retry: { maxRetries: 3 }, logger: console },
);

const deals = client.table(dealsTable);
const record = await deals.fetchRecord('rec123');

Config providers (optional)

import { setAirtableConfigProvider, withAirtable } from 'airtool';

setAirtableConfigProvider(() => ({
  apiKey: process.env.AIRTABLE_API_KEY!,
  baseIds: {
    main: 'app123',
  },
}));

await withAirtable('main', async ({ base }) => {
  // use base here
});

Field selection & required fields

  • pickFields(table, ...) returns typed keys (not IDs).
  • requiredFields are always included for typed list queries.
const fields = pickFields(dealsTable, 'status');
// requiredFields + fields are fetched and parsed

Validation modes

mapFieldsToAirtable supports:

  • validate: 'full' (strict)
  • validate: 'partial' (default)
  • validate: false

Typecast writes

Set typecast: true when you want Airtable to create missing select or multiselect options during writes (requires creator permissions on the base).

await updateRecord(base, dealsTable, recordId, { status: 'New Option' }, { typecast: true });

Pagination

import { forEachPage } from 'airtool';

await forEachPage(base, 'tbl123', { view: 'Grid view' }, async (records) => {
  // process one page at a time
});

Retry policy

Retry/backoff is enabled via the client wrapper. Defaults:

  • Exponential backoff, capped
  • Retries on 429 and 5xx errors
const client = createAirtableClient(
  { apiKey: process.env.AIRTABLE_API_KEY!, baseId: 'app123' },
  { retry: { maxRetries: 5, minDelayMs: 200, maxDelayMs: 3000 } },
);

Build, test, release

pnpm lint
pnpm test
pnpm build
pnpm publish --access public

License

MIT