@flakemetry/contracts
v0.2.1
Published
Shared zod schemas and inferred types across ingestion, api, worker and web
Readme
@flakemetry/contracts
The single source of truth for Flakemetry data shapes: zod schemas and their inferred types, shared by the SDK, ingestion API, worker and dashboard.
Install
pnpm add @flakemetry/contractsWhat is in here
- Ingestion contract —
ingestRunBatchSchema, the normalized run/execution payload every transport converges on. - OTel test conventions —
SPAN_NAMES,RESOURCE_ATTR,SPAN_ATTRare defined here, so the wire format and the schemas cannot drift apart. Documented in otel-conventions.md. - OTLP mapping —
otlpTraceRequestSchemavalidates an OTLP/HTTP JSON export andotlpToIngestBatchnormalizes it into the ingestion contract. - Query DTOs — inputs and results for the read API (runs list, run detail, test detail, flaky board, RCA).
- Config —
flakemetryConfigSchemaplus layered merging and environment overrides.
import { ingestRunBatchSchema, otlpToIngestBatch, otlpTraceRequestSchema } from '@flakemetry/contracts'
const otlp = otlpTraceRequestSchema.parse(requestBody)
const batch = ingestRunBatchSchema.parse(otlpToIngestBatch(otlp))Everything is a zod schema first and a TypeScript type second, so validation and typing never disagree.
License
MIT © Andrii Kohut
