Generate types with Typegen

Typegen reads the FileMaker layouts listed in an app's adt.config.json and generates TypeScript types, runtime schemas, and ready-to-use Data API clients. This keeps the app's data layer aligned with the fields and portals on those layouts.

Configure the layouts

Each Web Viewer app has an adt.config.json in its app directory. Its layouts array names the FileMaker layouts Typegen reads:

Copy
{
  "config": {
    "type": "fmdapi",
    "path": "./src/config/schemas/filemaker",
    "layouts": [
      { "layoutName": "Contacts", "schemaName": "Contacts" },
      { "layoutName": "Orders", "schemaName": "Orders" }
    ]
  }
}

layoutName is the exact FileMaker layout name. schemaName is the TypeScript name used for its schema, types, and client.

See adt.config.json for the complete configuration format.

Warning  These FileMaker layouts are app dependencies FileMaker does not show that a layout is referenced by adt.config.json. Deleting or renaming a listed layout breaks the generated client at runtime.

Run Typegen

Run Typegen from the Web Viewer app directory:

Copy
pnpm typegen

The app's package script invokes the same adt typegen feature that coding agents use. Typegen reads layout metadata from FileMaker and writes the generated files under the configured path.

Note  Requires Agent Access Typegen reads layout metadata through FileMaker Pro's Agent Access, not the filemaker CLI. FileMaker Pro 26.1 or later must be running with the file open, Agent Access turned on, and ADT's file components installed. See System Requirements.

Options

Flag Description
--config <path> Read a config file at a custom path instead of adt.config.json.
--reset-overrides Recreate every layout override file and discard its manual changes.

adt typegen init [--config <path>] creates a starter configuration file. Apps created by ADT already include one.

Generated files

For each layout, Typegen writes a schema, an override file, and an optional client under path:

Copy
src/config/schemas/filemaker/
├── Contacts.ts
├── generated/
│   └── Contacts.ts
└── client/
    ├── Contacts.ts
    └── index.ts
File Rewritten on each run Contents
generated/<Schema>.ts Yes Generated Zod schema and inferred TypeScript type, or TypeScript types alone when validator is false. It also contains value-list and portal definitions.
<Schema>.ts No Preserved override file that re-exports the generated schema and types. Custom validation and transformations belong here.
client/<Schema>.ts Yes A DataApi client configured with the layout, schema, and WebViewerAdapter.
client/index.ts Yes Named exports for every generated layout client.

With the default clientSuffix of "Layout", a schema named Contacts is exported as ContactsLayout.

Set generateClient to false for a config or layout to omit its client file. The schema and preserved override file are still generated.

Generated portals and value lists

Typegen discovers portals from the layout metadata. It generates a schema and type for each portal plus a combined Z<Schema>Portals and T<Schema>Portals map. The generated client attaches that map as portalData.

The layout's valueLists setting controls whether fields with attached value lists accept any string or validate against the listed values. Typegen exports the discovered values even when valueLists is "ignore".

See Validation and transformation for generated schema names and preserved overrides.

Regenerate after FileMaker changes

Run Typegen again after adding, removing, renaming, or changing a field, value list, or portal on a configured layout. Generated files are replaced, while the root-level override files remain unchanged.

Typegen reports schema changes through the regenerated TypeScript definitions. Fix the resulting type errors in the app rather than editing files under generated/ or client/.

Use the client

Import the generated client from its client directory:

Copy
import { ContactsLayout } from "@/config/schemas/filemaker/client";

const response = await ContactsLayout.find({
  query: { Status: "Active" },
  limit: 25,
});

See Use a typed data client for record operations and application data-loading patterns.