λx.1Λ
Convex Community9mo ago
8 replies
λx.1

convex-schema-parser

convex-schema-parser

A simple dev tool which generates typed
Python
and
Rust
api clients. It is intended to run alongside
convex dev
.
E.g. you might have to work on multiple other frontends/backends which use your convex deployment and are not
TypeScript
. You would then point
convex-schema-parser
via a
.yaml
to your local convex repo and where to write the generated clients. E.g.:

# Configuration for the Convex Client Generator.

# (Required) The absolute path to the root of your Convex project.
# This is the directory that contains the `convex/` folder and `package.json`.
# ABSOLUTE: SO no `~`/`$HOME`, etc.
project_path: /path/to/your/convex/project

# (Required) The absolute path to the generated TypeScript declarations, relative to `project_path`.
declarations_dir: /path/to/your/tmp/declarations

# (Required) A list of generation targets. You can have one or more.
targets:
  # Example 1: Generate a Rust client for a backend service.
  - lang: Rust
    # A list of one or more output files for this target.
    output:
      - ../my-rust-app/src/convex_api.rs
      - ../my-other-app/src/convex_api.rs

  # Example 2: Generate a Python client for data scripts.
  - lang: Python
    output:
      - ../scripts/lib/convex_client.py


convex-schema-parser dev
uses this file and watches for changes in your convex repo. If the public convex interface changes it will update your generated clients. Rust will catch any potential errors and in Python with something like
basedpyright
you can follow the type-hints.

For any language holds: you decide what the module name is and include it directly in your source-tree. This way you limit the possibility to forget to change/update some other backend of yours whilst making changes to your convex repo.

The
generate
cmd can be used for CI.

More is explained in detail in the repos README itself. Hope others might give feedback/make use of it (:
GitHub
Parses your
schema.ts
and generates types for Python/Rust - ParsonosAI/convex-schema-parser
GitHub - ParsonosAI/convex-schema-parser: Parses your `schema.ts` a...
Was this page helpful?