Zod schemas and TypeScript types for all data the Hungr API sends and receives. The API validates requests and generates its OpenAPI spec from them; the vendor portal parses responses with them. Browse them at docs.hungr.huzz.cc/types.
flowchart LR
subgraph src["src/<resource>.ts"]
direction TB
base["BaseSchema
id, createdAt, updatedAt"]
x["XSchema
the resource as returned"]
create["CreateXSchema
omits server-set fields"]
update["UpdateXSchema
CreateX.partial()"]
page["PaginationQuerySchema
limit, offset"]
filter["XFilterSchema
list query"]
list["XListSchema
paginated(X)"]
base --> x --> create --> update
x --> list
page --> filter
end
dist[/"dist/
npm run build"/]
api["apps/api
validates requests,
builds the OpenAPI spec"]
vendor["apps/vendor
parses responses,
validates forms"]
mobile["apps/mobile
Dart models with the same names"]
docs["apps/docs
/types/"]
src -- "tsc" --> dist
dist --> api
dist --> vendor
api -- "openapi.json" --> mobile
src -- "TypeDoc" --> docs
classDef app fill:#3b6fd833,stroke:#3b6fd8,stroke-width:2px
classDef core fill:#2f9e5733,stroke:#2f9e57,stroke-width:2px
classDef art fill:#d9a21b33,stroke:#d9a21b,stroke-width:2px
classDef group fill:transparent,stroke:#8a919c,stroke-dasharray:6 4
class base,x,create,update,page,filter,list core
class api,vendor,mobile,docs app
class dist art
class src group
Each resource file follows the same derivation; only the last schema in a chain gets refinements.
It's a workspace package, not published to npm. To add it to another workspace (here apps/vendor), from the repository root:
npm pkg set "dependencies.@hungr/types=*" -w apps/vendor
npm install
npm run build -w @hungr/types
Apps import the compiled dist/, so rebuild after every change (the API and portal scripts do this for you).
import { VendorSchema, type Vendor } from "@hungr/types"
const vendor: Vendor = VendorSchema.parse(await res.json())
Each resource X has XSchema/X (as returned), CreateX and UpdateX (request bodies), XFilter (list query) and XList (a page of results). IDs are strings, dates are ISO 8601 strings, and money is integer NZD cents.
Run from the repository root with -w @hungr/types.
| Script | What it does |
|---|---|
build |
Compiles src/ to dist/ |
test |
Vitest tests for schemas with refinements or transforms |
docs |
Builds, then writes the TypeDoc site to docs/ (Node 22.18+) |
No environment variables.
The package has no deployment of its own. A change to it runs api-test.yml and vendor-test.yml, redeploys the API, portal and docs site, and rebuilds the mobile app's API client. The types docs are published by the docs site.
npm test -w @hungr/types isn't run in CI; run it before pushing a schema change.