Skip to main content

Check TypeScript types against their corresponding backend models to assure that all fields have been accounted for.

Project description

TS Backend Check logo

rtd pr_ci python_package_ci issues python pypi pypistatus license coc matrix

Check TypeScript types against backend models

ts-backend-check is a Python package used to check TypeScript types against their corresponding backend models to assure that all fields have been accounted for.

Contents

Usage

Installation

pip install ts-backend-check

Command Options

  • backend-model-file (bmf): Path to the backend model file (e.g. Python class)
  • typescript-file (tsf): Path to the TypeScript interface/type file

Basic Usage

The CLI provides a simple interface to check TypeScript types against backend models:

# Show help and available commands:
ts-backend-check --help

# Check a TypeScript type against a backend model:
ts-backend-check -bmf <backend-model-file> -tsf <typescript-file>

Example success and error outputs for the CLI are:

ts-backend-check -bmf backend/models/user.py -tsf frontend/types/user.ts
✅ Success: All backend models are synced with their corresponding TypeScript interfaces for the provided files.
ts-backend-check -bmf backend/models/user.py -tsf frontend/types/user.ts

❌ ts-backend-check error: There are inconsistencies between the provided backend models and TypeScript interfaces. Please see the output below for details.

Field 'user_name' (camelCase: 'userName') from model 'UserModel' is missing in the TypeScript interfaces.
Expected to find this field in the frontend interface: User
To ignore this field, add the following comment to the TypeScript interface: '// ts-backend-check: ignore field userName'

Please fix the 1 field above to have the backend models of backend/models/user.py synced with the typescript interfaces of frontend/types/user.ts.

Contributing

Public Matrix Chat

activist uses Matrix for internal communication. You're more than welcome to join us in our public chat rooms to share ideas, ask questions or just say hi to the team :) We'd suggest that you use the Element client and Element X for a mobile app.

Please see the contribution guidelines if you are interested in contributing. Work that is in progress or could be implemented is tracked in the issues and projects.

[!NOTE] Just because an issue is assigned on GitHub doesn't mean the team isn't open to your contribution! Feel free to write in the issues and we can potentially reassign it to you.

Also check the -next release- and -priority- labels in the issues for those that are most important, as well as those marked good first issue that are tailored for first-time contributors. For those new to coding or our tech stack, we've collected links to helpful documentation pages in the contribution guidelines.

We would be happy to discuss granting you further rights as a contributor after your first pull requests, with a maintainer role then being possible after continued interest in the project. activist seeks to be an inclusive, diverse and supportive organization. We'd love to have you on the team!

How you can help

Environment setup

  1. First and foremost, please see the suggested IDE setup in the dropdown below to make sure that your editor is ready for development.

[!IMPORTANT]

Suggested IDE setup

VS Code

Install the following extensions:

  1. Fork the ts-backend-check repo, clone your fork, and configure the remotes:

[!NOTE]

Consider using SSH

Alternatively to using HTTPS as in the instructions below, consider SSH to interact with GitHub from the terminal. SSH allows you to connect without a user-pass authentication flow.

To run git commands with SSH, remember then to substitute the HTTPS URL, https://github.com/..., with the SSH one, git@github.com:....

  • e.g. Cloning now becomes git clone git@github.com:<your-username>/ts-backend-check.git

GitHub also has their documentation on how to Generate a new SSH key 🔑

# Clone your fork of the repo into the current directory.
git clone https://github.com/<your-username>/ts-backend-check.git
# Navigate to the newly cloned directory.
cd ts-backend-check
# Assign the original repo to a remote called "upstream".
git remote add upstream https://github.com/activist-org/ts-backend-check.git
  • Now, if you run git remote -v you should see two remote repositories named:
    • origin (forked repository)
    • upstream (ts-backend-check repository)
  1. Create a virtual environment, activate it and install dependencies:

    # Unix or MacOS:
    python3 -m venv venv
    source venv/bin/activate
    
    # Windows:
    python -m venv venv
    venv\Scripts\activate.bat
    
    # After activating venv:
    pip install --upgrade pip
    pip install -r requirements-dev.txt
    
    # To install the CLI for local development:
    pip install -e .
    

You're now ready to work on ts-backend-check!

[!NOTE] Feel free to contact the team in the Development room on Matrix if you're having problems getting your environment setup!

Contributors

Thanks to all our amazing contributors! ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ts_backend_check-1.2.2-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file ts_backend_check-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ts_backend_check-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1d37f6611e76f768e79b646afacb2f7d7a92c90b9885ff2932f073442ae1997
MD5 6bb207784836697c9a696ae4b5d6e0be
BLAKE2b-256 e54ba2420c9fdf5264b6221ac2797ec1a825ae4e9968391b56e0289618a068da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page