Skip to content

Commit 727cbe4

Browse files
committed
Merge branch '0.41' of github.com:drizzle-team/drizzle-orm into drizzle-kit/fix-pg-enums-default-values
2 parents 75cdefe + f1c2dd6 commit 727cbe4

File tree

128 files changed

+8662
-8354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+8662
-8354
lines changed

Diff for: .github/workflows/release-feature-branch.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- drizzle-seed
2828
- drizzle-typebox
2929
- drizzle-valibot
30+
- drizzle-arktype
3031
- other
3132
runs-on: ubuntu-20.04
3233
services:
@@ -195,7 +196,7 @@ jobs:
195196
docker compose -f docker-neon.yml down
196197
;;
197198
198-
drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot)
199+
drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot|drizzle-arktype)
199200
(cd .. && pnpm test --filter ${{ matrix.shard }})
200201
;;
201202
@@ -228,6 +229,7 @@ jobs:
228229
- drizzle-seed
229230
- drizzle-typebox
230231
- drizzle-valibot
232+
- drizzle-arktype
231233
- eslint-plugin-drizzle
232234
runs-on: ubuntu-20.04
233235
steps:
@@ -321,6 +323,7 @@ jobs:
321323
- drizzle-seed
322324
- drizzle-typebox
323325
- drizzle-valibot
326+
- drizzle-arktype
324327
- eslint-plugin-drizzle
325328
runs-on: ubuntu-20.04
326329
permissions:

Diff for: .github/workflows/release-latest.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- drizzle-seed
2222
- drizzle-typebox
2323
- drizzle-valibot
24+
- drizzle-arktype
2425
- other
2526
runs-on: ubuntu-20.04
2627
services:
@@ -179,7 +180,7 @@ jobs:
179180
docker compose -f docker-neon.yml down
180181
;;
181182
182-
drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot)
183+
drizzle-orm|drizzle-kit|drizzle-zod|drizzle-seed|drizzle-typebox|drizzle-valibot|drizzle-arktype)
183184
(cd .. && pnpm test --filter ${{ matrix.shard }})
184185
;;
185186
@@ -210,6 +211,7 @@ jobs:
210211
- drizzle-seed
211212
- drizzle-typebox
212213
- drizzle-valibot
214+
- drizzle-arktype
213215
- eslint-plugin-drizzle
214216
runs-on: ubuntu-20.04
215217
steps:
@@ -298,6 +300,7 @@ jobs:
298300
- drizzle-seed
299301
- drizzle-typebox
300302
- drizzle-valibot
303+
- drizzle-arktype
301304
- eslint-plugin-drizzle
302305
runs-on: ubuntu-20.04
303306
services:

Diff for: .github/workflows/unpublish-release-feature-branch.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
- drizzle-zod
1414
- drizzle-typebox
1515
- drizzle-valibot
16+
- drizzle-arktype
1617
- eslint-plugin-drizzle
1718
runs-on: ubuntu-20.04
1819
steps:

Diff for: changelogs/drizzle-arktype/0.1.2.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
`drizzle-arktype` is a plugin for [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm) that allows you to generate [arktype](https://arktype.io/) schemas from Drizzle ORM schemas.
2+
3+
**Features**
4+
5+
- Create a select schema for tables, views and enums.
6+
- Create insert and update schemas for tables.
7+
- Supports all dialects: PostgreSQL, MySQL and SQLite.
8+
9+
# Usage
10+
11+
```ts
12+
import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
13+
import { createInsertSchema, createSelectSchema } from 'drizzle-arktype';
14+
import { type } from 'arktype';
15+
16+
const users = pgTable('users', {
17+
id: serial('id').primaryKey(),
18+
name: text('name').notNull(),
19+
email: text('email').notNull(),
20+
role: text('role', { enum: ['admin', 'user'] }).notNull(),
21+
createdAt: timestamp('created_at').notNull().defaultNow(),
22+
});
23+
24+
// Schema for inserting a user - can be used to validate API requests
25+
const insertUserSchema = createInsertSchema(users);
26+
27+
// Schema for updating a user - can be used to validate API requests
28+
const updateUserSchema = createUpdateSchema(users);
29+
30+
// Schema for selecting a user - can be used to validate API responses
31+
const selectUserSchema = createSelectSchema(users);
32+
33+
// Overriding the fields
34+
const insertUserSchema = createInsertSchema(users, {
35+
role: type('string'),
36+
});
37+
38+
// Refining the fields - useful if you want to change the fields before they become nullable/optional in the final schema
39+
const insertUserSchema = createInsertSchema(users, {
40+
id: (schema) => schema.atLeast(1),
41+
role: type('string'),
42+
});
43+
44+
// Usage
45+
46+
const isUserValid = parse(insertUserSchema, {
47+
name: 'John Doe',
48+
49+
role: 'admin',
50+
});
51+
```
52+
53+
thanks @L-Mario564

Diff for: changelogs/drizzle-typebox/0.3.1.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Exports all types, including internal ones to avoid type issues.
2+
- Properly handle infinitely recursive types in custom JSON column types.
3+
4+
thanks @L-Mario564

Diff for: changelogs/drizzle-valibot/0.4.1.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Exports all types, including internal ones to avoid type issues.
2+
- Properly handle infinitely recursive types in custom JSON column types.
3+
4+
thanks @L-Mario564

Diff for: changelogs/drizzle-zod/0.7.1.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### Bug fixes
2+
3+
- [[BUG]: createInsertSchema from [email protected] does not infer types correctly but returns unknown for every value](https://github.com/drizzle-team/drizzle-orm/issues/3907)
4+
- [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869)
5+
6+
thanks @L-Mario564

Diff for: drizzle-arktype/README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
`drizzle-arktype` is a plugin for [Drizzle ORM](https://github.com/drizzle-team/drizzle-orm) that allows you to generate [arktype](https://arktype.io/) schemas from Drizzle ORM schemas.
2+
3+
**Features**
4+
5+
- Create a select schema for tables, views and enums.
6+
- Create insert and update schemas for tables.
7+
- Supports all dialects: PostgreSQL, MySQL and SQLite.
8+
9+
# Usage
10+
11+
```ts
12+
import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
13+
import { createInsertSchema, createSelectSchema } from 'drizzle-arktype';
14+
import { type } from 'arktype';
15+
16+
const users = pgTable('users', {
17+
id: serial('id').primaryKey(),
18+
name: text('name').notNull(),
19+
email: text('email').notNull(),
20+
role: text('role', { enum: ['admin', 'user'] }).notNull(),
21+
createdAt: timestamp('created_at').notNull().defaultNow(),
22+
});
23+
24+
// Schema for inserting a user - can be used to validate API requests
25+
const insertUserSchema = createInsertSchema(users);
26+
27+
// Schema for updating a user - can be used to validate API requests
28+
const updateUserSchema = createUpdateSchema(users);
29+
30+
// Schema for selecting a user - can be used to validate API responses
31+
const selectUserSchema = createSelectSchema(users);
32+
33+
// Overriding the fields
34+
const insertUserSchema = createInsertSchema(users, {
35+
role: type('string'),
36+
});
37+
38+
// Refining the fields - useful if you want to change the fields before they become nullable/optional in the final schema
39+
const insertUserSchema = createInsertSchema(users, {
40+
id: (schema) => schema.atLeast(1),
41+
role: type('string'),
42+
});
43+
44+
// Usage
45+
46+
const isUserValid = parse(insertUserSchema, {
47+
name: 'John Doe',
48+
49+
role: 'admin',
50+
});
51+
```

Diff for: drizzle-arktype/package.json

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "drizzle-arktype",
3+
"version": "0.1.2",
4+
"description": "Generate arktype schemas from Drizzle ORM schemas",
5+
"type": "module",
6+
"scripts": {
7+
"build": "tsx scripts/build.ts",
8+
"b": "pnpm build",
9+
"test:types": "cd tests && tsc",
10+
"pack": "(cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
11+
"publish": "npm publish package.tgz",
12+
"test": "vitest run"
13+
},
14+
"exports": {
15+
".": {
16+
"import": {
17+
"types": "./index.d.mts",
18+
"default": "./index.mjs"
19+
},
20+
"require": {
21+
"types": "./index.d.cjs",
22+
"default": "./index.cjs"
23+
},
24+
"types": "./index.d.ts",
25+
"default": "./index.mjs"
26+
}
27+
},
28+
"main": "./index.cjs",
29+
"module": "./index.mjs",
30+
"types": "./index.d.ts",
31+
"publishConfig": {
32+
"provenance": true
33+
},
34+
"repository": {
35+
"type": "git",
36+
"url": "git+https://github.com/drizzle-team/drizzle-orm.git"
37+
},
38+
"keywords": [
39+
"arktype",
40+
"validate",
41+
"validation",
42+
"schema",
43+
"drizzle",
44+
"orm",
45+
"pg",
46+
"mysql",
47+
"postgresql",
48+
"postgres",
49+
"sqlite",
50+
"database",
51+
"sql",
52+
"typescript",
53+
"ts"
54+
],
55+
"author": "Drizzle Team",
56+
"license": "Apache-2.0",
57+
"peerDependencies": {
58+
"arktype": ">=2.0.0",
59+
"drizzle-orm": ">=0.36.0"
60+
},
61+
"devDependencies": {
62+
"@rollup/plugin-typescript": "^11.1.0",
63+
"@types/node": "^18.15.10",
64+
"arktype": "^2.1.10",
65+
"cpy": "^10.1.0",
66+
"drizzle-orm": "link:../drizzle-orm/dist",
67+
"json-rules-engine": "7.3.0",
68+
"rimraf": "^5.0.0",
69+
"rollup": "^3.20.7",
70+
"vite-tsconfig-paths": "^4.3.2",
71+
"vitest": "^1.6.0",
72+
"zx": "^7.2.2"
73+
}
74+
}

Diff for: drizzle-arktype/rollup.config.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import typescript from '@rollup/plugin-typescript';
2+
import { defineConfig } from 'rollup';
3+
4+
export default defineConfig([
5+
{
6+
input: 'src/index.ts',
7+
output: [
8+
{
9+
format: 'esm',
10+
dir: 'dist',
11+
entryFileNames: '[name].mjs',
12+
chunkFileNames: '[name]-[hash].mjs',
13+
sourcemap: true,
14+
},
15+
{
16+
format: 'cjs',
17+
dir: 'dist',
18+
entryFileNames: '[name].cjs',
19+
chunkFileNames: '[name]-[hash].cjs',
20+
sourcemap: true,
21+
},
22+
],
23+
external: [
24+
/^drizzle-orm\/?/,
25+
'arktype',
26+
],
27+
plugins: [
28+
typescript({
29+
tsconfig: 'tsconfig.build.json',
30+
}),
31+
],
32+
},
33+
]);

Diff for: drizzle-arktype/scripts/build.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env -S pnpm tsx
2+
import 'zx/globals';
3+
import cpy from 'cpy';
4+
5+
await fs.remove('dist');
6+
await $`rollup --config rollup.config.ts --configPlugin typescript`;
7+
await $`resolve-tspaths`;
8+
await fs.copy('README.md', 'dist/README.md');
9+
await cpy('dist/**/*.d.ts', 'dist', {
10+
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'),
11+
});
12+
await cpy('dist/**/*.d.ts', 'dist', {
13+
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'),
14+
});
15+
await fs.copy('package.json', 'dist/package.json');
16+
await $`scripts/fix-imports.ts`;

0 commit comments

Comments
 (0)