WU / DOCSUNIVERSAL MICROFRONTENDS
EN

Contracts, types and translators

Generate TypeScript clients and verify contract changes with adaptations for older versions.

Requires WU CLI 1.2.0 and WU Framework 4.0.0 for application APIs. Check wu --version and the project dependencies.

wu contracts types counter-v1.json --out client.d.ts
wu contracts types counter-v1.json counter-v2.json --out clients.d.ts
wu contracts check counter-v1.json counter-v2.json --json
wu contracts check counter-v1.json counter-v2.json --translators translators.mjs --json

JSON files contain the descriptor accepted by defineService. The CLI loads wu-framework/services from the project, not a global copy. Each file must be valid JSON and no larger than 1 MiB. types writes TypeScript declarations to stdout or a separate .d.ts file with --out.

With multiple contracts, names are ServiceClientV1, ServiceClientV2, and so on. If they share a major, the full version is included, such as ServiceClient_1_2_0. check takes exactly the previous and next contracts; it does not accept --out. types does not accept --json or --translators.

Compatibility with translators

The --translators module exports an array as default or translators. Each entry has definition and methods, matching what provideService accepts. The check moves covered changes into translated; uncovered changes remain in changes. Use versioned services to implement and test translators.

Exit Meaning
0 Compatible contract or types generated.
1 Uncovered incompatible changes.
2 Invalid file, descriptor, dependency or option.

A compatible result verifies contract structure, not that translator functions are correct for every value. Exercise input and output examples, validation failures and permissions against the runtime before changing the provider.

BUILD WU WITH US

Found a bug? Have an idea?

Your experience improves WU. Tell us what went wrong or help support its development.