Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jansedlon committed Jun 6, 2024
1 parent 01f07bc commit bf3a541
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
11 changes: 8 additions & 3 deletions packages/generator/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { GeneratorOptions } from '@prisma/generator-helper'
import {
flatten,
type InferIssue,
type InferOutput,
flatten,
object,
optional,
safeParse,
Expand All @@ -22,7 +22,10 @@ const Config = object({
})
export type Config = InferOutput<typeof Config>

type ConfigSchemaIssues = [InferIssue<typeof Config>, ...InferIssue<typeof Config>[]]
type ConfigSchemaIssues = [
InferIssue<typeof Config>,
...InferIssue<typeof Config>[],
]

export function parseConfig(config: GeneratorOptions['generator']['config']) {
const parsing = safeParse(Config, config)
Expand All @@ -31,7 +34,9 @@ export function parseConfig(config: GeneratorOptions['generator']['config']) {
}

class ConfigError extends Error {
constructor(issues: [InferIssue<typeof Config>, ...InferIssue<typeof Config>[]]) {
constructor(
issues: [InferIssue<typeof Config>, ...InferIssue<typeof Config>[]]
) {
super(`[prisma-generator-drizzle] Invalid Config:\n${formatError(issues)}`)
this.name = 'ConfigError'
}
Expand Down
10 changes: 4 additions & 6 deletions packages/generator/src/lib/valibot-schema.ts
Original file line number Diff line number Diff line change
@@ -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
})
)
2 changes: 1 addition & 1 deletion packages/generator/src/shared/date-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit bf3a541

Please sign in to comment.