@zerodev/data-api-contract
v0.2.0
Published
Public runtime schemas and TypeScript types for the ZeroDev Data API
Readme
@zerodev/data-api-contract
Public runtime schemas and TypeScript types for the ZeroDev Data API.
The package is the source of truth for JSON exchanged between Data API clients and the server. The Data API uses the same Zod schemas for Fastify validation and response serialization that TypeScript clients can use for runtime validation and inferred types.
Scope
The package contains public request and response contracts. It does not contain Fastify route handlers, Zerion provider schemas, authentication, or OpenAPI generation.
The package is browser-safe and ships ESM, CommonJS, and declaration entrypoints.
pnpm add @zerodev/data-api-contract zodInside this workspace, build it before consuming it from another workspace package:
pnpm --filter @zerodev/data-api-contract buildExample
import {
type TransactionHistoryResponse,
TransactionHistoryResponseSchema,
} from '@zerodev/data-api-contract';
const value: unknown = await response.json();
const transactionHistory: TransactionHistoryResponse =
TransactionHistoryResponseSchema.parse(value);Test fixtures
@zerodev/data-api-contract/fixtures exports one transaction-history item per shape the Data API produces, keyed by a stable id, for tests and stories on the client side. Each item is the exact mapper output for a Zerion input in the Data API test suite, including which optional keys are omitted.
import {
TRANSACTION_HISTORY_FIXTURES,
TRANSACTION_HISTORY_FIXTURE_IDS,
} from '@zerodev/data-api-contract/fixtures';
const approval = TRANSACTION_HISTORY_FIXTURES.approveUnlimited;Ids are never removed. The values behind them are test data, not part of the API's stability promise, and may change in any release to track the mapper. The subpath is a separate module graph: importing only the root entry never loads the fixtures.
The subpath also exports KERNEL_ACCOUNT_FIXTURE: a Sepolia-verified owner EOA, the Kernel address the Data API derives from it, and the DATA_API_KERNEL_ACCOUNT config used. The SDK asserts its connector derives the same address, so a Kernel config change on either side fails a test before it ships.
