Skip to main content

Write types once, use everywhere

Project description

SyncLangs

One centralized types file -> Multiple languages across all your codebases.

PyPI version Python versions License: MIT

SyncLangs is a developer tool that enables you to maintain a single source of truth for your type definitions. Define your structures once in a universal schema language (.syln) and automatically synchronize them as native, idiomatic types across Python, TypeScript, and multiple projects or packages simultaneously.

Why SyncLangs?

Modern full-stack applications often use different languages for frontend (TypeScript) and backend (Python). This creates type duplication, drift risk, and maintenance burden.

SyncLangs solves this by:

  • No more type drift - Define types once, generate native code for each language
  • Zero config start - Works immediately with sensible defaults
  • Fast watch mode - Regenerates in under 200ms on file save
  • Readable syntax - Human-readable .syln files, no verbose boilerplate

Quick Start

Installation

pip install synclangs
# or
pipx install synclangs

Initialize a Project

syln init

This creates:

  • syln.config.json - Configuration file
  • shared/example.syln - Example schema

Define Your Types

Create shared/user.syln:

## Represents a user in the system
type User {
  ## Unique identifier
  id: string

  ## User's email address
  email: string

  ## Display name (optional)
  name: string?

  ## Account active status
  isActive: bool

  ## User tags
  tags: list<string>

  ## Arbitrary metadata
  metadata: map<string, any>
}

Generate Code

syln generate

TypeScript Output (user.types.ts):

// Auto-generated by SyncLangs - DO NOT EDIT

export interface User {
  /** Unique identifier */
  id: string;
  /** User's email address */
  email: string;
  /** Display name (optional) */
  name?: string;
  /** Account active status */
  isActive: boolean;
  /** User tags */
  tags: string[];
  /** Arbitrary metadata */
  metadata: Record<string, any>;
}

Python Output (user_types.py):

# Auto-generated by SyncLangs - DO NOT EDIT

from dataclasses import dataclass
from typing import Any, Optional

@dataclass
class User:
    """Represents a user in the system"""
    id: str
    """Unique identifier"""
    email: str
    """User's email address"""
    is_active: bool
    """Account active status"""
    tags: list[str]
    """User tags"""
    metadata: dict[str, Any]
    """Arbitrary metadata"""
    name: Optional[str] = None
    """Display name (optional)"""

Watch Mode

syln watch

Changes to .syln files automatically regenerate output in under 200ms.

CLI Reference

Command Description
syln init Initialize a new project with config and example
syln generate Generate code from .syln files
syln check Validate schemas without generating
syln watch Watch mode with auto-regeneration
syln version Show version

Common Flags

Flag Short Description
--config -c Config file path (default: ./syln.config.json)
--input -i Input directory (default: ./shared)
--out-ts TypeScript output directory
--out-py Python output directory
--verbose -v Verbose logging
--dry-run Show what would be generated

Syntax Reference

Primitives

SyncLangs Python TypeScript
string str string
int int number
float float number
bool bool boolean
any Any any

Generics

SyncLangs Python TypeScript
list<T> list[T] T[]
map<K, V> dict[K, V] Record<K, V>

Nullable Types

type Example {
  required: string      # Required field
  optional: string?     # Optional field (nullable)
}

Imports

import { User, Address } from "./user.syln"

type Order {
  user: User
  shippingAddress: Address
}

Comments

# Regular comment (ignored in output)

## Doc comment (generates docstrings/JSDoc)
type User {
  ## The user's unique identifier
  id: string
}

Configuration

Create syln.config.json in your project root:

{
  "$schema": "https://synclangs.com/schema/v1.json",
  "version": "1.0",
  "input": "./shared",
  "outputs": {
    "typescript": {
      "enabled": true,
      "outDir": "./generated/ts",
      "fileExtension": ".types.ts"
    },
    "python": {
      "enabled": true,
      "outDir": "./generated/py",
      "fileExtension": "_types.py",
      "useDataclasses": true
    }
  },
  "options": {
    "watchDebounceMs": 100,
    "caseConversion": {
      "fields": {
        "python": "snake_case",
        "typescript": "camelCase"
      }
    },
    "generateIndex": true
  }
}

Error Messages

SyncLangs provides helpful error messages with file locations and suggestions:

Error: SY002 - Invalid type reference
  --> shared/user.syln:15:12
   |
15 |   role: Roles
   |         ^^^^^ Type 'Roles' not found. Did you mean 'Role'?
   |
Help: Import 'Roles' or define it in this file.

Documentation

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a PR.

License

MIT - see LICENSE


Made with care by SyncLangs

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 Distributions

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

synclangs-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

synclangs-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.2-cp313-cp313-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

synclangs-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

synclangs-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.2-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

synclangs-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

synclangs-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.2-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

synclangs-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

synclangs-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (14.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.2-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file synclangs-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 3230de914bfb49fb61fd7f1ab6aa18cc09db1ad398bd85611fe8dbc0cb777229
MD5 ced76e9b18ea69247cef7334eff842be
BLAKE2b-256 a84aa47d02681eeb2336759a47b8994ec679d8e438ca3f9a6e234568378027c6

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 85859d65f14f291e2d4060c2adf281fe7a36c1257e0f06d77c2935990ceddb81
MD5 754de31a686eda0b136171334b38dd7e
BLAKE2b-256 a190e0ec06c6df3940c4b1928ddf5ecb3735549b4f93721732084877c4e2311e

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a5fba301db9bb2b69c2641e5f8fdbccf8f49312df3cd8a284264f15ffd97edfe
MD5 0c53323fc19652a89cf972e71d4545da
BLAKE2b-256 2c4ee149902a0149c7c988ad1742bb79cb1f74d42464fc1463c0ef32e54be489

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 ee256f1ae7a560eb8503c756ba8bce5478008f64b0672871ad3efae7cc513ca4
MD5 c16f427d8123a0ef8bb646eccbdfeee8
BLAKE2b-256 8846029bd265a9ba098e8e053af2c497b4e17bba6d3711bb1d2c54181bce7c3f

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f0efcef8f420c3c270d06481d21bfbba20c6047e5aa8644033035b03170e22d1
MD5 61247b38db95c77a6ba42c2d749cfc82
BLAKE2b-256 6b1382449ce6095a4fac7851d2f0e7721825c6d5ba6de24f3c4f881ec5739866

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 057a87b0adbbfe467e015af2f14b0e0f1ebde8cfa441957410bede5d5e733b41
MD5 56c40ed2c0a9f3e71102d212e391490f
BLAKE2b-256 cdf8a0bf1148e0417e1beeaf099b7d89a83f120194a92aae5183d5bdce9456a1

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 fe74b613e8124718ceeb67e0b81f5d88bc674197014ded63a2bf2e611bbce77a
MD5 45585163914c8103282a17d0e61fdb5e
BLAKE2b-256 c052c0eaa8bad5878f683c21f45dcde093f427cc02597c6839e4a012d54454ab

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f3a494c5137b5b693fe148d0e6c3d2cd533442af09b56f6ae88f7fb146deb43
MD5 b2fb535a96448bec31089758d33bf8e3
BLAKE2b-256 3d6106de3715f1af6504d68b1db882f9415d123bba7f01cdacf5dc3875616ff7

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2bd5750ac7f2fd18f7ea4d44592844c38f37b053e356759e88029e6ed292d5ef
MD5 9e195fbd171c74dfca27a92c090ffd9a
BLAKE2b-256 36d8ea4101ae0b3a33cbd630f197f80ed79adb006efd172b10d51d71231fe725

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 f906e9a17462652df0ce8dc3cb62f439c60f48953be235c576a70e4f7ce8f4cf
MD5 80efdb0339d98b26afa094e30e29f4e9
BLAKE2b-256 8fcaa201b5e6d0455f96abd200c270e13b5f87d1ef55d4507d2fe695fa2b069c

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6a1e55d085ba419a869aba2dc978096063352cc1f3a1f9de15f7ce5c41e90eff
MD5 035cdcc1bfdda0febbf80817e6503012
BLAKE2b-256 e5a98c7c4163f23e763d41a93edc4e5cec2df0226ae283f9ed27f0d14665eb95

See more details on using hashes here.

File details

Details for the file synclangs-0.2.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ac706a035d870e0ac5622593a2cbace03a03892ef60b2f1ce681b626617f86e
MD5 301887d98f1018ae7de43c30b56b6204
BLAKE2b-256 4fca5d4ce010faef2c0f5080d331fef79fd483977d03962748d7e76262edd0f1

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