Skip to content

leancodepl/contractsgenerator-typescript

Repository files navigation

LeanCode TypeScript Contracts Generator

Packages

  • Contracts Generator - utility for generating contracts/client/schema from backend contracts
  • Admin App Generator - package for generating strongly typed components from generated schema and client

Available plugins

  • contracts - type generation
  • client - api factory generation; requires contracts to also be used
  • raw - prepend/append text to generated file;
  • admin - api components schema generation; used by Admin App Generator

Development

Local publish

To test your changes to the codebase you can publish all packages to local registry (Verdaccio) and then pull those packages to your project. To start local registry run

npx nx run local-registry

this will override your default registry in npm config. To publish all packages to local registry run

npx nx run local-publish --ver={VERSION_IN_#.#.#_OR_#.#.#-PREFIX.#} --tag={TAG}

Protobuf

Server and clients communicate using protobuf. Specific .proto contract file is being copied from the server repository to libs/schema/src/lib/protocol/contracts.proto. This is important to note that when contracts file is updated on the backend side then updating process is entirely manual. After you copy new contracts.proto file the libs/schema/src/lib/protocol/index.js and libs/schema/src/lib/protocol/index.d.ts need to be updated. Those files are automatically generated by running npx nx run schema:proto.