Anarchitecture Bricks Docs

Repository documentation hub for packages, guides, and generated references.

TS Contracts Guide

Intent

This guide applies local ADR-0016 and Accepted Meta ADR-0012. It distinguishes canonical public HTTP contracts from local domain models and the transitional TypeBox implementation. For UI behavior, see the Design/UI Systems Guide.

Contract Ownership Model

Contracts epic #1 provides extraction, releases and conformance tooling. Completed Contracts #2 provides foundations only. 3-tier #485 tracks adoption: #486 establishes these rules; #487 audits the baseline; later children consume and verify available artifacts. Do not claim publication or adoption from governance acceptance, or invent canonical package imports.

The frozen #487 legacy API audit records immutable source evidence, real runtime checks and semantic discrepancies for Contracts extraction. It is baseline evidence, not a second contract authority.

Domain Contract Matrix

Domain Current local TS package Angular consumer Nest consumer
Forms @anarchitects/forms-ts @anarchitects/forms-angular @anarchitects/forms-nest
Auth @anarchitects/auth-ts @anarchitects/auth-angular @anarchitects/auth-nest
Identity @anarchitects/identity-ts @anarchitects/identity-angular @anarchitects/identity-nest
Newsletter @anarchitects/newsletter-ts @anarchitects/newsletter-angular @anarchitects/newsletter-nest

These are existing local package names, not names of canonical contract packages. All four domains' shared public HTTP authority belongs to Contracts. Each consumer must record the immutable contract version and capabilities it actually verifies. Missing DDD capabilities are unsupported, not assumed equivalent.

Forms TS Contracts

Continue using @anarchitects/forms-ts public exports for current form definitions, renderer models, dynamic validation and transitional submission DTOs. Forms owns configurable intake; typed business operations belong to their domains. Separating public wire definitions from internal form models must not move domain logic into Contracts or change field-validation/error semantics incidentally.

Auth TS Contracts

Continue using @anarchitects/auth-ts public exports for current lifecycle DTOs, profiles and shared auth models. Its policy vocabulary and evaluation semantics remain local under ADR-0014. Canonical HTTP policy schemas must map without loss to that model. Do not expose Better Auth internals, change session-first behavior or replace authentication/authorization providers as part of contract extraction.

Consumer Mapping (Angular and Nest)

Contract Change Workflow

  1. Read all Meta/local ADRs, relevant guides and the applicable canonical contract version and compatibility rules. If required artifacts are unavailable, report the dependency and limit work to authorized governance/audit scope.
  2. Freeze and audit source revisions, TypeBox DTOs/validators, controller metadata, generated OpenAPI, Angular usage and actual HTTP behavior. Classify discrepancies; neither the generator nor the current runtime alone proves the intended contract.
  3. Coordinate canonical Zod schema/operation authoring and review in Contracts. Preserve the audited wire behavior or obtain an explicit versioned breaking-change migration. Review coercion, defaults, optional/null fields, unknown keys, refinements, serialization, error/status and header semantics.
  4. After immutable artifacts are available, pin the chosen version and implement local compatibility bindings. Verify Nest 12 Standard Schema against exact versions; preserve Nest 11 patch-only support without feature backports.
  5. Regenerate local OpenAPI and compare with canonical OpenAPI 3.1, then verify real HTTP, Angular/generated clients, public exports and clean packed consumers. Keep the working generator and baseline tests throughout the transition.
  6. Retire redundant local operation/schema authoring only after conformance is proven. Publish a capability/version support matrix and reviewed migration/release evidence. Complete 3-tier and claimed-capability DDD adoption before separate Nest 12-native modernization; each child issue has its own reviewed PR.

Compatibility Rules

Verification Checklist

Newsletter integration

See Newsletter integration for current provider examples, Forms-backed signup, implementation OpenAPI and browser/database regression. The migration guide separates reusable capabilities from host policy and app-local data migration.