Construct a client

Call DataApi with a target layout and adapter. While Typegen constructs clients automatically, DataApi is available for manual configuration.

Use a generated client

Typegen generates import-ready clients for each layout declared in adk.config.json:

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

const response = await ContactsLayout.list({ limit: 25 });

Generated clients configure the layout name, WebViewerAdapter, and runtime Zod schemas. Regenerate clients whenever layout objects change. See Generate types with Typegen.

Create a client manually

DataApi is a factory function invoked without new:

Copy
import { DataApi, WebViewerAdapter } from "@adk/fmdapi";
import { ZContacts, ZContactsPortals } from "../Contacts";

export const ContactsLayout = DataApi({
  adapter: new WebViewerAdapter({
    scriptName: "ADK_execute_data_api",
  }),
  layout: "API_Contacts",
  schema: {
    fieldData: ZContacts,
    portalData: ZContactsPortals,
  },
});

DataApi options

Option Type Required Description
adapter Adapter Yes Adapter instance routing operations to FileMaker (defaults to WebViewerAdapter).
layout string Yes Target FileMaker layout name.
schema.fieldData StandardSchemaV1<FieldData> No Schema validating record field data (compatible with Zod).
schema.portalData Record<string, StandardSchemaV1> No Schemas validating related portal rows by portal name.

Warning  Deprecated options: The legacy zodValidators configuration option is obsolete. Use schema or re-run Typegen to regenerate clients.

Client method summary

DataApi returns an object exposing the following methods:

  • Query: list, listAll, get, find, findOne, findFirst, maybeFindFirst, and findAll.

  • Mutations: create, update, and delete.

  • Layout and binary: layoutMetadata and containerUpload.

See Record methods and pagination and WebViewerAdapter.