Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cef2f0a
feature: add base files
coopbri Nov 18, 2025
b806b97
test: add drizzle emitter tester fixture and basic test
coopbri Nov 18, 2025
453a9fa
build(deps): add Biome, Changesets
coopbri Nov 18, 2025
b72b80d
build(pkg): add metadata
coopbri Nov 18, 2025
5999af3
feature(code-quality): add code quality configs
coopbri Nov 18, 2025
95f531c
feature: add changesets support
coopbri Nov 18, 2025
df4be0e
docs: add license
coopbri Nov 18, 2025
67765ba
feature: add `.env`
coopbri Nov 18, 2025
e968461
chore: format
coopbri Nov 18, 2025
6646363
feature: add Tiltfile
coopbri Nov 18, 2025
14b3cc8
ci: add workflows
coopbri Nov 18, 2025
f5c6a23
docs: add README
coopbri Nov 18, 2025
1258d8d
chore: format
coopbri Nov 18, 2025
100a880
chore: format
coopbri Nov 18, 2025
a5f8d27
feature(tilt): add install resource
coopbri Nov 18, 2025
7b41c5c
build(scripts): add `pretest` build script
coopbri Nov 18, 2025
48c1a8e
ci(publish): fix scripts
coopbri Nov 18, 2025
ede9303
ci(test): add build step
coopbri Nov 18, 2025
4eaabd6
chore: format
coopbri Nov 18, 2025
e4483eb
docs(readme): add logo
coopbri Nov 18, 2025
dee221e
docs(readme): reduce logo size
coopbri Nov 18, 2025
61df87d
docs(readme): reduce logo size
coopbri Nov 18, 2025
9fb31d1
docs(readme): update project status warning
coopbri Nov 18, 2025
b1f3280
docs(readme): add TypeSpec link
coopbri Nov 18, 2025
e5b6046
docs(readme): add TSP emitter docs link
coopbri Nov 18, 2025
df06791
docs(readme,installation): add development flag
coopbri Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "omnidotdev/typespec-drizzle" }
],
"commit": false,
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DO_NOT_TRACK=1
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Commit ⚙️

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
# check author permissions
check:
runs-on: ubuntu-latest
outputs:
has-permissions: ${{ steps.checkPermissions.outputs.require-result }}
steps:
- name: Check permissions
id: checkPermissions
uses: actions-cool/check-user-permission@v2
with:
# require repo write access to trigger the package preview
require: "write"
# build and publish the preview package
publish:
needs: check
# publish the preview package only if permissions check passed
if: needs.check.outputs.has-permissions == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun i
- name: Build package
run: bun run build
- name: Publish package
run: bunx pkg-pr-new publish
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release 🏗️

on:
push:
branches: [master]

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Handle release 🦋
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun i
- name: Create release PR or publish package
id: changesets
uses: changesets/action@v1
with:
publish: bun release
title: "feature(release): version packages"
commit: "ci(changesets): version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test 🧪

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
test_unit:
name: Run unit tests 🃏
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.42
# - uses: ArtiomTr/jest-coverage-report-action@v2
# with:
# package-manager: bun
# test-script: bun test:coverage
# annotations: failed-tests
# TODO replace below with commented job above, blocked by Bun not yet supporting a JSON coverage reporter for the action to consume nor generate (similar: https://github.com/oven-sh/bun/issues/4099)
- name: Install dependencies
run: bun install
# NB: build is necessary for test fixtures to resolve paths properly
- name: Build project
run: bun run build
- name: Run unit tests
run: bun test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun biome check --write --staged --no-errors-on-unmatched src
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) Omni LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# TypeSpec Drizzle Emitter

<div align="center">
<img src="/assets/logo.png" width="150" />

[Join Omni community on Discord](https://discord.gg/omnidotdev)

[![version](https://img.shields.io/github/v/release/omnidotdev/typespec-drizzle?sort=semver)](https://github.com/omnidotdev/typespec-drizzle/releases)
[![build](https://img.shields.io/github/actions/workflow/status/omnidotdev/typespec-drizzle/release.yml)](https://github.com/omnidotdev/typespec-drizzle/actions/workflows/release.yml)
[![license: MIT](https://img.shields.io/github/license/omnidotdev/typespec-drizzle)](https://github.com/omnidotdev/typespec-drizzle/blob/master/LICENSE.md)

</div>

A [TypeSpec](https://typespec.io) emitter that generates [Drizzle ORM](https://orm.drizzle.team) schema definitions and types from TypeSpec specifications. Learn about TypeSpec emitters [here](https://typespec.io/docs/extending-typespec/emitters-basics).

> [!IMPORTANT]
> **Project Status:** 🚧 This project is **brand new**. Use at your own risk.

## Overview

This emitter allows you to define your database schema using TypeSpec's type-safe language and automatically generate Drizzle ORM schema files, enabling a single source of truth for your database schema definitions alongside other artifacts.

## Features

- Generate Drizzle schema definitions from TypeSpec models
- Type-safe database schema generation
- Support for common database types and constraints
- Integration with TypeSpec's existing ecosystem

## Installation

```sh
bun add -D @omnidotdev/typespec-drizzle
```

## Usage

### Basic Usage

1. Add the emitter to your TypeSpec configuration (`tspconfig.yaml`):

```yaml
emit:
- "@omnidotdev/typespec-drizzle"
```

2. Define your models in TypeSpec:

```typespec
import "@omnidotdev/typespec-drizzle";

model User {
id: string;
email: string;
name: string;
createdAt: utcDateTime;
}

model Post {
id: string;
title: string;
content: string;
authorId: string;
publishedAt?: utcDateTime;
}
```

3. Run the TypeSpec compiler:

```sh
tsp compile .
```

The emitter will generate Drizzle schema files in the output directory.

## Getting Started

### Local Development

Use [Tilt](https://tilt.dev) for a unified development experience:

```sh
tilt up
```

or manually install and build:

```sh
bun install
bun run build # or `bun run build:watch`
```

Tests can be run with `bun test`.

## Contributing

See Omni's [contributing docs](https://docs.omni.dev/contributing/overview).

## License

The code in this repository is licensed under MIT, &copy; Omni LLC. See [LICENSE.md](LICENSE.md) for more information.
28 changes: 28 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("ext://dotenv", "dotenv")
dotenv()

local_resource(
"install",
"bun install",
)

local_resource(
"build",
"bun run build",
auto_init=False,
trigger_mode=TRIGGER_MODE_MANUAL
)

local_resource(
"build:watch",
serve_cmd="bun build:watch",
auto_init=False,
trigger_mode=TRIGGER_MODE_MANUAL
)

local_resource(
"test",
"bun test",
auto_init=False,
trigger_mode=TRIGGER_MODE_MANUAL
)
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// see https://biomejs.dev/reference/configuration
{
"$schema": "https://biomejs.dev/schemas/2.3.6/schema.json",
"assist": {
"actions": {
"source": {
"organizeImports": {
"options": {
"groups": [
{ "type": false, "source": [":BUN:", ":NODE:"] },
":BLANK_LINE:",
{
"type": false,
// TODO look into this for TS `baseUrl` (https://github.com/omnidotdev/golden/pull/1#discussion_r2487186008)
"source": [":PACKAGE:", ":PACKAGE_WITH_PROTOCOL:"]
},
":BLANK_LINE:",
{ "type": false, "source": ["**"] },
":BLANK_LINE:",
{ "type": true }
]
}
}
}
}
},
"files": {
"includes": [
"**",
"!!**/*.gen.*",
"!!**/.cache",
"!!**/build",
"!!**/bun.lock",
"!!**/dist",
"!!**/generated",
"!!**/node_modules",
"!!**/out",
"!!**/public",
"!!**/vendor",
"!!**/certificates"
]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
"rules": {
"correctness": {
"noUnusedImports": {
"fix": "safe",
"level": "error"
}
},
"nursery": {
"useSortedClasses": {
"fix": "safe",
"level": "error",
"options": {
"attributes": ["class", "className"],
"functions": ["cn", "clsx", "classnames", "cva", "tv"]
}
}
},
"style": {
"useImportType": {
"level": "error",
"options": { "style": "separatedType" }
}
},
"suspicious": {
"noArrayIndexKey": "warn",
"noConsole": {
"level": "error",
"options": { "allow": ["error", "warn"] }
}
}
}
}
}
Loading
Loading