From bab3fcaaf8aeb70b603f4a22e43462e602faa9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sedlo=C5=88?= Date: Thu, 6 Jun 2024 06:52:39 +0200 Subject: [PATCH 1/4] refactor: upgrade valibot to v0.31 --- bun.lockb | Bin 164256 -> 164288 bytes packages/generator/package.json | 2 +- packages/generator/src/lib/config.ts | 20 ++--- packages/generator/src/lib/valibot-schema.ts | 23 ++---- packages/generator/src/shared/date-mode.ts | 4 +- .../generator-context/module-resolution.ts | 9 ++- packages/usage/package.json | 76 +++++++++--------- packages/usage/src/lib/mysql.ts | 4 +- packages/usage/src/lib/postgres.ts | 4 +- 9 files changed, 68 insertions(+), 74 deletions(-) diff --git a/bun.lockb b/bun.lockb index 188ff582b98b947614d2b8f8977723c1a736e840..bc94b7f959c6114c57946acc62734b2f968ad562 100755 GIT binary patch delta 13797 zcmcgzd0dsn`hVxZ5ndD(#RU(_qHM~(bP$ABaz#bNv|MmO)}w45z{Cx-G|@I1YwCK{ zEbE$9W?dt-YnFNy6csfqyQXHAYni6z{`)@foLA~r_s^f7K0NcCdFGjCo^9rwGrjtR z+x92io)7m6-*RYWMBo`!9JF?SKOu*r0_a#rasSi(A zRG)T|%l-mPTvlhP-a_cu7C5?%?4Jip>Xm2N!}7`$_BtF zLED3V14?}MY?`Gg`5k0`k*(NPWGgEN(fc!blc`g0!!VUug@qVYIzuXyslEXbB<(CH z?cg{l?Qn{%ILB6;U$&O}IdzJf;pMQ0;m-eZW66|?JX*|fXCb#aMR+apmKwK&HOWfY zsL~m90pIA`32=0z(;yE z_{cT(`pbQUc9(nwS!H2)g<1KZpr0&%9sMM?Jh!N{5_(khkn?te!jSEL#}JldvlsID z&OQlC1Em@lK*{(gL1|epP*SJ01KY~N@(W9*D3QTZU8g{P%(+|DH9%T*Z;0&n=qd3O zdscQX;%6~1?QTCPiSz9x$G3x@mU$19yp)$!Rz4kC+jA?*Y>TV zz3SkH{-jU4DVxKj!1GXq1a9Xw=0R0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TFtecB(F_`<=aa8W_yilnaVi zgdAIt+@xV7U#$F%<=93R$*-{Xc%+H}XQzGY&Ja*N!r{YQ;eQ9R%~yr(Zr_d?QS-2) zfx&!txXKp!!I$SU(;G%!7t=7+W74w^ z{lk^p`ZO?CKjJIn3qqRTy&Vl)4rg;h^~*mwQirmx|P1$s56%AvV$|dd_ir!BxPhQHt_k;MithJugvq0iKJQE>=q_g6$Mm)0t^3%E`5?2$ zroMffTb^5NVTbVLDOM@pB2I#V?Oyr>%8D#5`rrRCMRL)ME$kx^#Vr1Tt?`pnOGvA^ zCVI`?IqPy4VEVe_rhUn4U0?Hwi4xO^t=$xP$vQe}&e|~>1AICHQ?}1*JF4mZR1MRM#5=?~66%7JR`tPx3VvC(A7-{ts4Xp +export type Config = InferOutput + +type ConfigSchemaIssues = [InferIssue, ...InferIssue[]] export function parseConfig(config: GeneratorOptions['generator']['config']) { const parsing = safeParse(Config, config) @@ -29,13 +31,13 @@ export function parseConfig(config: GeneratorOptions['generator']['config']) { } class ConfigError extends Error { - constructor(issues: SchemaIssues) { + constructor(issues: [InferIssue, ...InferIssue[]]) { super(`[prisma-generator-drizzle] Invalid Config:\n${formatError(issues)}`) this.name = 'ConfigError' } } -function formatError(issues: SchemaIssues) { +function formatError(issues: ConfigSchemaIssues) { let message = '' const flattened = flatten(issues) @@ -43,7 +45,7 @@ function formatError(issues: SchemaIssues) { message += `\n- ${flattened.root}` } - for (const [key, issues] of Object.entries(flattened.nested)) { + for (const [key, issues] of Object.entries(flattened.nested ?? {})) { message += `\n- ${key}: ${issues}` } diff --git a/packages/generator/src/lib/valibot-schema.ts b/packages/generator/src/lib/valibot-schema.ts index 6cb6d71..30364be 100644 --- a/packages/generator/src/lib/valibot-schema.ts +++ b/packages/generator/src/lib/valibot-schema.ts @@ -1,22 +1,13 @@ -import { coerce, picklist } from 'valibot' +import { boolean, pipe, string, union } from 'valibot' import { - type BaseSchema, - type OptionalSchema, - type Output, transform, } from 'valibot' -export function withDefault>( - schema: Schema, - value: Output -) { - return transform(schema, (val) => val ?? value) -} +export const BooleanInStr = pipe( + union([string(), boolean()]), + transform(value => { + if (typeof value === 'string') return value.toLowerCase() === 'true'; -export const BooleanInStr = transform( - coerce(picklist(['true', 'false']), (value) => { - if (typeof value !== 'string') return value - return value.toLowerCase() - }), - (value) => value === 'true' + return value; + }) ) diff --git a/packages/generator/src/shared/date-mode.ts b/packages/generator/src/shared/date-mode.ts index 7dd5d18..c5356e4 100644 --- a/packages/generator/src/shared/date-mode.ts +++ b/packages/generator/src/shared/date-mode.ts @@ -1,9 +1,9 @@ -import { literal, parse, union } from 'valibot' +import { parse, picklist } from 'valibot' import type { ParsableField } from '~/lib/adapter/adapter' import { getDirective } from '~/lib/directive' import { getGenerator } from './generator-context' -export const DateMode = union([literal('string'), literal('date')]) +export const DateMode = picklist(['string', 'date']); export function getDateMode(field: ParsableField) { const directive = getDirective(field, 'drizzle.dateMode') diff --git a/packages/generator/src/shared/generator-context/module-resolution.ts b/packages/generator/src/shared/generator-context/module-resolution.ts index 5ae935e..9f12c27 100644 --- a/packages/generator/src/shared/generator-context/module-resolution.ts +++ b/packages/generator/src/shared/generator-context/module-resolution.ts @@ -1,11 +1,12 @@ import fs from 'node:fs' import path from 'node:path' -import { brand, object, parse, string, transform } from 'valibot' +import { brand, object, parse, pipe, string, toLowerCase } from 'valibot' import stripJsonComments from '~/lib/strip-json-comments' -export const ModuleResolution = brand( - transform(string(), (value) => value.toLowerCase()), - 'ModuleResolution' +export const ModuleResolution = pipe( + string(), + toLowerCase(), + brand('ModuleResolution') ) export function resolveModuleResolution() { diff --git a/packages/usage/package.json b/packages/usage/package.json index 14887ed..b246266 100644 --- a/packages/usage/package.json +++ b/packages/usage/package.json @@ -1,40 +1,40 @@ { - "name": "usage", - "private": true, - "version": "1.0.0", - "license": "MIT", - "type": "module", - "scripts": { - "start": "bun run src/index.ts", - "test": "bun test --preload tests/setup.ts", - "generate": "prisma generate", - "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", - "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", - "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", - "clone:sqlite": "bun run scripts/cloneSqlite.ts", - "clone:mysql": "bun run scripts/cloneMysql.ts" - }, - "dependencies": { - "@paralleldrive/cuid2": "^2.2.2", - "@prisma/client": "5.10.2", - "better-sqlite3": "^9.4.3", - "date-fns": "^3.3.1", - "decimal.js": "^10.4.3", - "drizzle-orm": "^0.30.1", - "mysql2": "^3.9.2", - "pg": "^8.11.3", - "postgres": "^3.4.3", - "uuid": "^9.0.1", - "valibot": "^0.30.0" - }, - "devDependencies": { - "@types/better-sqlite3": "^7.6.9", - "@types/node": "20.11.25", - "@types/pg": "^8.11.2", - "@types/uuid": "^9.0.8", - "bun-types": "^1.0.30", - "prisma": "5.10.2", - "prisma-generator-drizzle": "workspace:*", - "typescript": "5.4.2" - } + "name": "usage", + "private": true, + "version": "1.0.0", + "license": "MIT", + "type": "module", + "scripts": { + "start": "bun run src/index.ts", + "test": "bun test --preload tests/setup.ts", + "generate": "prisma generate", + "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", + "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", + "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", + "clone:sqlite": "bun run scripts/cloneSqlite.ts", + "clone:mysql": "bun run scripts/cloneMysql.ts" + }, + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "@prisma/client": "5.10.2", + "better-sqlite3": "^9.4.3", + "date-fns": "^3.3.1", + "decimal.js": "^10.4.3", + "drizzle-orm": "^0.30.1", + "mysql2": "^3.9.2", + "pg": "^8.11.3", + "postgres": "^3.4.3", + "uuid": "^9.0.1", + "valibot": "0.31.0-rc.12" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.9", + "@types/node": "20.11.25", + "@types/pg": "^8.11.2", + "@types/uuid": "^9.0.8", + "bun-types": "^1.0.30", + "prisma": "5.10.2", + "prisma-generator-drizzle": "workspace:*", + "typescript": "5.4.2" + } } diff --git a/packages/usage/src/lib/mysql.ts b/packages/usage/src/lib/mysql.ts index de1fec9..7e61329 100644 --- a/packages/usage/src/lib/mysql.ts +++ b/packages/usage/src/lib/mysql.ts @@ -1,11 +1,11 @@ import { drizzle } from 'drizzle-orm/mysql2' import mysql from 'mysql2/promise' import { schema } from 'prisma/mysql/drizzle/schema' -import { url, object, parse, string } from 'valibot' +import { url, object, parse, string, pipe } from 'valibot' const env = parse( object({ - MYSQL_DATABASE_URL: string([url()]), + MYSQL_DATABASE_URL: pipe(string(), url()), }), process.env ) diff --git a/packages/usage/src/lib/postgres.ts b/packages/usage/src/lib/postgres.ts index 280c497..cf950e6 100644 --- a/packages/usage/src/lib/postgres.ts +++ b/packages/usage/src/lib/postgres.ts @@ -1,11 +1,11 @@ import { drizzle } from 'drizzle-orm/postgres-js' import postgres from 'postgres' import { schema } from 'prisma/drizzle/schema' -import { url, object, parse, string } from 'valibot' +import { url, object, parse, string, pipe } from 'valibot' const env = parse( object({ - PG_DATABASE_URL: string([url()]), + PG_DATABASE_URL: pipe(string(), url()), }), process.env ) From c458bced20af6c231c36d7ca1e0d2e1cadad26aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sedlo=C5=88?= Date: Thu, 6 Jun 2024 06:54:33 +0200 Subject: [PATCH 2/4] chore: revent indentation --- packages/usage/package.json | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/packages/usage/package.json b/packages/usage/package.json index b246266..5a0e901 100644 --- a/packages/usage/package.json +++ b/packages/usage/package.json @@ -1,40 +1,40 @@ { - "name": "usage", - "private": true, - "version": "1.0.0", - "license": "MIT", - "type": "module", - "scripts": { - "start": "bun run src/index.ts", - "test": "bun test --preload tests/setup.ts", - "generate": "prisma generate", - "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", - "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", - "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", - "clone:sqlite": "bun run scripts/cloneSqlite.ts", - "clone:mysql": "bun run scripts/cloneMysql.ts" - }, - "dependencies": { - "@paralleldrive/cuid2": "^2.2.2", - "@prisma/client": "5.10.2", - "better-sqlite3": "^9.4.3", - "date-fns": "^3.3.1", - "decimal.js": "^10.4.3", - "drizzle-orm": "^0.30.1", - "mysql2": "^3.9.2", - "pg": "^8.11.3", - "postgres": "^3.4.3", - "uuid": "^9.0.1", - "valibot": "0.31.0-rc.12" - }, - "devDependencies": { - "@types/better-sqlite3": "^7.6.9", - "@types/node": "20.11.25", - "@types/pg": "^8.11.2", - "@types/uuid": "^9.0.8", - "bun-types": "^1.0.30", - "prisma": "5.10.2", - "prisma-generator-drizzle": "workspace:*", - "typescript": "5.4.2" - } + "name": "usage", + "private": true, + "version": "1.0.0", + "license": "MIT", + "type": "module", + "scripts": { + "start": "bun run src/index.ts", + "test": "bun test --preload tests/setup.ts", + "generate": "prisma generate", + "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", + "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", + "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", + "clone:sqlite": "bun run scripts/cloneSqlite.ts", + "clone:mysql": "bun run scripts/cloneMysql.ts" + }, + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "@prisma/client": "5.10.2", + "better-sqlite3": "^9.4.3", + "date-fns": "^3.3.1", + "decimal.js": "^10.4.3", + "drizzle-orm": "^0.30.1", + "mysql2": "^3.9.2", + "pg": "^8.11.3", + "postgres": "^3.4.3", + "uuid": "^9.0.1", + "valibot": "0.31.0-rc.12" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.9", + "@types/node": "20.11.25", + "@types/pg": "^8.11.2", + "@types/uuid": "^9.0.8", + "bun-types": "^1.0.30", + "prisma": "5.10.2", + "prisma-generator-drizzle": "workspace:*", + "typescript": "5.4.2" + } } From 01f07bce6ca5e19b17861ee017140fdd9591a9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sedlo=C5=88?= Date: Thu, 6 Jun 2024 06:55:11 +0200 Subject: [PATCH 3/4] chore: reindent using tabs --- packages/usage/package.json | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/packages/usage/package.json b/packages/usage/package.json index 5a0e901..51b9998 100644 --- a/packages/usage/package.json +++ b/packages/usage/package.json @@ -1,40 +1,40 @@ { - "name": "usage", - "private": true, - "version": "1.0.0", - "license": "MIT", - "type": "module", - "scripts": { - "start": "bun run src/index.ts", - "test": "bun test --preload tests/setup.ts", - "generate": "prisma generate", - "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", - "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", - "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", - "clone:sqlite": "bun run scripts/cloneSqlite.ts", - "clone:mysql": "bun run scripts/cloneMysql.ts" - }, - "dependencies": { - "@paralleldrive/cuid2": "^2.2.2", - "@prisma/client": "5.10.2", - "better-sqlite3": "^9.4.3", - "date-fns": "^3.3.1", - "decimal.js": "^10.4.3", - "drizzle-orm": "^0.30.1", - "mysql2": "^3.9.2", - "pg": "^8.11.3", - "postgres": "^3.4.3", - "uuid": "^9.0.1", - "valibot": "0.31.0-rc.12" - }, - "devDependencies": { - "@types/better-sqlite3": "^7.6.9", - "@types/node": "20.11.25", - "@types/pg": "^8.11.2", - "@types/uuid": "^9.0.8", - "bun-types": "^1.0.30", - "prisma": "5.10.2", - "prisma-generator-drizzle": "workspace:*", - "typescript": "5.4.2" - } + "name": "usage", + "private": true, + "version": "1.0.0", + "license": "MIT", + "type": "module", + "scripts": { + "start": "bun run src/index.ts", + "test": "bun test --preload tests/setup.ts", + "generate": "prisma generate", + "pushreset:postgres": "bun prisma db push --schema prisma/schema.prisma --force-reset --accept-data-loss", + "pushreset:mysql": "bun prisma db push --schema prisma/mysql/schema.prisma --force-reset --accept-data-loss", + "pushreset:sqlite": "bun prisma db push --schema prisma/sqlite/schema.prisma --force-reset --accept-data-loss", + "clone:sqlite": "bun run scripts/cloneSqlite.ts", + "clone:mysql": "bun run scripts/cloneMysql.ts" + }, + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "@prisma/client": "5.10.2", + "better-sqlite3": "^9.4.3", + "date-fns": "^3.3.1", + "decimal.js": "^10.4.3", + "drizzle-orm": "^0.30.1", + "mysql2": "^3.9.2", + "pg": "^8.11.3", + "postgres": "^3.4.3", + "uuid": "^9.0.1", + "valibot": "0.31.0-rc.12" + }, + "devDependencies": { + "@types/better-sqlite3": "^7.6.9", + "@types/node": "20.11.25", + "@types/pg": "^8.11.2", + "@types/uuid": "^9.0.8", + "bun-types": "^1.0.30", + "prisma": "5.10.2", + "prisma-generator-drizzle": "workspace:*", + "typescript": "5.4.2" + } } From bf3a541d1c195d4b63f740047cc96b97bd275a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sedlo=C5=88?= Date: Thu, 6 Jun 2024 06:59:01 +0200 Subject: [PATCH 4/4] chore: formatting --- packages/generator/src/lib/config.ts | 11 ++++++++--- packages/generator/src/lib/valibot-schema.ts | 10 ++++------ packages/generator/src/shared/date-mode.ts | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/generator/src/lib/config.ts b/packages/generator/src/lib/config.ts index a1f1fbd..0adfe1a 100644 --- a/packages/generator/src/lib/config.ts +++ b/packages/generator/src/lib/config.ts @@ -1,8 +1,8 @@ import type { GeneratorOptions } from '@prisma/generator-helper' import { - flatten, type InferIssue, type InferOutput, + flatten, object, optional, safeParse, @@ -22,7 +22,10 @@ const Config = object({ }) export type Config = InferOutput -type ConfigSchemaIssues = [InferIssue, ...InferIssue[]] +type ConfigSchemaIssues = [ + InferIssue, + ...InferIssue[], +] export function parseConfig(config: GeneratorOptions['generator']['config']) { const parsing = safeParse(Config, config) @@ -31,7 +34,9 @@ export function parseConfig(config: GeneratorOptions['generator']['config']) { } class ConfigError extends Error { - constructor(issues: [InferIssue, ...InferIssue[]]) { + constructor( + issues: [InferIssue, ...InferIssue[]] + ) { super(`[prisma-generator-drizzle] Invalid Config:\n${formatError(issues)}`) this.name = 'ConfigError' } diff --git a/packages/generator/src/lib/valibot-schema.ts b/packages/generator/src/lib/valibot-schema.ts index 30364be..6621f5b 100644 --- a/packages/generator/src/lib/valibot-schema.ts +++ b/packages/generator/src/lib/valibot-schema.ts @@ -1,13 +1,11 @@ import { boolean, pipe, string, union } from 'valibot' -import { - transform, -} from 'valibot' +import { transform } from 'valibot' export const BooleanInStr = pipe( union([string(), boolean()]), - transform(value => { - if (typeof value === 'string') return value.toLowerCase() === 'true'; + transform((value) => { + if (typeof value === 'string') return value.toLowerCase() === 'true' - return value; + return value }) ) diff --git a/packages/generator/src/shared/date-mode.ts b/packages/generator/src/shared/date-mode.ts index c5356e4..3c77817 100644 --- a/packages/generator/src/shared/date-mode.ts +++ b/packages/generator/src/shared/date-mode.ts @@ -3,7 +3,7 @@ import type { ParsableField } from '~/lib/adapter/adapter' import { getDirective } from '~/lib/directive' import { getGenerator } from './generator-context' -export const DateMode = picklist(['string', 'date']); +export const DateMode = picklist(['string', 'date']) export function getDateMode(field: ParsableField) { const directive = getDirective(field, 'drizzle.dateMode')