-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
4,344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Test & Build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test-and-build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run tests | ||
run: pnpm test | ||
|
||
- name: Type check tests | ||
run: pnpm run test:types | ||
|
||
- name: Build | ||
run: pnpm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,59 @@ | ||
# drizzle-zero | ||
Generate Zero schemas from Drizzle ORM schemas | ||
|
||
Generate [Zero](https://github.com/rocicorp/mono) schemas from [Drizzle ORM](https://orm.drizzle.team) schemas. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install drizzle-zero | ||
# or | ||
yarn add drizzle-zero | ||
# or | ||
pnpm add drizzle-zero | ||
``` | ||
|
||
## Usage | ||
|
||
Here's a simple example of how to convert a Drizzle schema to a Zero schema: | ||
|
||
```ts | ||
import { pgTable, text } from 'drizzle-orm/pg-core'; | ||
import { createSchema, createTableSchema } from '@rocicorp/zero'; | ||
import { drizzleToZero } from 'drizzle-zero'; | ||
|
||
// Define your Drizzle table | ||
const userTable = pgTable("user", { | ||
id: text("id").primaryKey(), | ||
name: text("name").notNull(), | ||
}); | ||
|
||
// Convert to Zero schema | ||
const userSchema = createTableSchema( | ||
drizzleToZero(userTable, { | ||
id: true, | ||
name: true, | ||
}) | ||
); | ||
|
||
// Create your Zero schema | ||
export const schema = createSchema({ | ||
version: 1, | ||
tables: { | ||
user: userSchema, | ||
}, | ||
}); | ||
``` | ||
|
||
## Features | ||
|
||
- Convert Drizzle ORM schemas to Zero schemas | ||
- Handles all Drizzle column types that are supported by Zero | ||
- Type-safe schema generation | ||
|
||
## Limitations | ||
|
||
- Relationships are not supported yet | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "drizzle-zero", | ||
"version": "0.0.1-alpha.1", | ||
"description": "Generate Zero schemas from Drizzle ORM schemas", | ||
"type": "module", | ||
"scripts": { | ||
"build": "tsup src/index.ts --format cjs,esm --dts", | ||
"test:types": "cd tests && tsc", | ||
"publish": "npm publish package.tgz", | ||
"test": "vitest run" | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/BriefHQ/drizzle-zero.git" | ||
}, | ||
"keywords": [ | ||
"zero", | ||
"sync", | ||
"schema", | ||
"drizzle", | ||
"orm", | ||
"pg", | ||
"postgresql", | ||
"postgres", | ||
"database", | ||
"typescript", | ||
"ts" | ||
], | ||
"author": "Brief", | ||
"license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@rocicorp/zero": ">=0.8.2024121204", | ||
"drizzle-orm": ">=0.36.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.2", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.7.2", | ||
"vite-tsconfig-paths": "^5.1.4", | ||
"vitest": "^2.1.8", | ||
"zod": "^3.20.2" | ||
} | ||
} |
Oops, something went wrong.