HOCO B2B
Team tasksAnis

SRV-03 — API contract v1 — oRPC contract package, OpenAPI export & mock server

Every V1 endpoint as a typed contract (Zod request/response, errors, pagination) in packages/contracts; OpenAPI 3.1 generated and published; Prism mock server so Imad builds against it the same day.

FieldDetails
Task codeSRV-03
PhaseP0 — Foundations (cadrage, UX/UI, architecture & contract)
Product scopeV1
StatusDone (Sun 18 Oct 2026)
StartSun 18 Oct 2026
DueSun 18 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsibleImad
Effort2.5 person-day(s) planned · 8 from scratch · size M
Area · appServer · server
Depends onSRV-02
UnblocksSRV-04, MOB-03
MilestonesAPI contract v1 published (OpenAPI + mock server)

Summary

Every V1 endpoint as a typed contract (Zod request/response, errors, pagination) in packages/contracts; OpenAPI 3.1 generated and published; Prism mock server so Imad builds against it the same day.

Description

Step 3 and the hand-off that unblocks the mobile track (milestone API contract v1 published): every V1 endpoint the reseller and delegate apps use is declared contract-first in packages/contracts with oRPC — Zod 4 request/response schemas, .route({ method, path }), declared error codes and the pagination conventions of AUTHORING §3 — and the OpenAPI 3.1 document is generated, published and served by a Prism mock server so Imad can build against it the same day (NFR-09, SYN-05). The schemas carry the 17 Oct decisions: catalog operations are auth: optional and return price: null with priceLocked: true for guests, availability is IN_STOCK/OUT_OF_STOCK only (no quantity fields), catalog.facets, events.stream, support.whatsapp and returns.create|list|get exist, assisted orders and after-sales tickets have their own shapes. Out of scope: admin groups beyond the shared primitives (each SRV module task adds its admin procedures) and implementation. Imad reviews it as the first consumer and generates the Dart client from it.

Note

Step 3 — the hand-off that unblocks the mobile track. Imad reviews it as the first consumer.

Subtasks

#SubtaskOwner
1Shared primitives: Money (centimes + currency), Price | null with priceLocked, Availability, cursor and page pagination envelopes, ErrorEnvelope and the stable error-code registryAnis
2Header contracts: Idempotency-Key required on idem operations, Accept-Language, X-App-Version / X-App-Platform / X-Device-Id, Idempotent-ReplayedAnis
3Contracts for auth, me (devices, app-config, reference wilayas/communes/lists), files, catalog (incl. facets, suggest, by-barcode), favoritesAnis
4Contracts for cart, orders (cancel, confirmAssisted, rejectAssisted, reorder, documents), returns, finance, promotions, profile and addressesAnis
5Contracts for support (tickets with AFTER_SALES items/issue/photos, contacts, whatsapp), notifications, events.stream event types, invitationsAnis
6Contracts for delegate-day, delegate-tours, delegate-resellers, delegate-orders and sync (batch item results with SyncItemResult, delta cursors)Anis
7OpenAPI 3.1 generation script with realistic examples per operation; publish openapi.json in CI and render it at /referenceAnis
8Prism mock server (Docker) fed by the generated document, deployed as mock-api-stagingAnis
9Breaking-change check in CI (oasdiff) and contract CHANGELOG with semantic versionAnis
10Contract review as first consumer and Dart client generation (hoco_api) without manual fixesImad

Deliverables

  • packages/contracts/src/{common,errors,auth,me,files,catalog,cart,orders,returns,finance,promotions,profile,support,notifications,invitations,delegate,sync}.ts
  • packages/contracts/scripts/openapi.ts producing openapi.json (CI artefact, served at /openapi.json)
  • Mock server Dokploy app mock-api-staging (Prism) and docker compose service for local use
  • packages/contracts/CHANGELOG.md (v1.0.0)

Acceptance criteria

  • Every V1 operation of the groups listed on the task exists with the method and path of endpoints.json (script diff = 0)
  • Catalog responses declare price as nullable with priceLocked; no reseller- or delegate-facing schema contains a stock quantity field (STK-07, AUTH-10)
  • Idempotency-Key is a required header on every operation flagged idem and on cart.checkout and sync.batch
  • Error responses use the envelope with codes from the registry (e.g. ORDER_MIN_AMOUNT_NOT_MET, STOCK_INSUFFICIENT, IDEMPOTENCY_KEY_REUSED)
  • The mock server answers every operation with a schema-valid example
  • Imad generates the Dart client from openapi.json and signs off the review

Requirements covered

RequirementTitleRelease
NFR-09Maintainability: automated tests, CI gates, typed contracts, documentationV1
SYN-05Sync queue handling retries, duplicates (idempotency), errors and conflictsV1

API surface

Test measures

  • Contract test: every route in the contract router is unique by method + path and matches endpoints.json
  • Spectral lint of openapi.json in CI
  • Schema round-trip test: each example validates against its Zod schema
  • Dart client generation job (smoke) run by Imad against the published document

Risks

  • Contract churn after Imad starts — semantic versioning, oasdiff breaking-change gate and a changelog entry for every change
  • OpenAPI generation gaps for oRPC features (SSE, file streams) — describe events.stream as text/event-stream with documented event schemas

KPI

  • Delivered by Sun 18 Oct 2026 within 2.5 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page