@tallwatch/contracts
v0.1.2
Published
Shared Zod schemas and TypeScript types for the Tallwatch REST API.
Readme
@tallwatch/contracts
The shared Zod-schema layer. Every cross-boundary payload (REST, queue, webhook, MCP) is defined here exactly once; TS types are inferred via z.infer.
Why a separate package
- The api validates inbound; the web/probers/workers infer outbound TS types. Single source of truth, renaming a field is one change,
tscflags every consumer. - Web depends on
@tallwatch/contracts(zero runtime DB code) so the bundler never accidentally pulls inpgor Drizzle. - Terraform provider + MCP server both codegen from these same schemas (
zod-to-openapi, MCP tool spec generation).
Layout
src/
├── common.ts # Region, ErrorClass, ProbeStatus, Uuid, IsoTimestamp
├── monitors.ts # MonitorConfig discriminated union + Monitor wire type + Create/Update/List
├── monitors/probes.ts # ProbeJob (api → prober), ProbeResult (prober → api)
├── incidents.ts # IncidentEvent (source of truth), Incident (projection), Ack/Resolve
├── alerts.ts # AlertChannel, EscalationPolicy, OnCallSchedule, OnCallOverride
├── webhooks.ts # Canonical outbound WebhookPayload (the default template substitutes against this)
└── index.ts # Re-exports everythingUsage
// In /api, validate inbound
import { CreateMonitorSchema } from "@tallwatch/contracts";
const parsed = CreateMonitorSchema.parse(req.body);
// In /web, typed forms
import type { Monitor, CreateMonitor } from "@tallwatch/contracts";
// In /probers, typed jobs and results
import { ProbeJobSchema, ProbeResultSchema } from "@tallwatch/contracts/probes";