diff --git a/biome.json b/biome.json index 5968645..00eb99f 100644 --- a/biome.json +++ b/biome.json @@ -1,20 +1,37 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", - "organizeImports": { - "enabled": true + "$schema": "https://biomejs.dev/schemas/2.1.3/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": false + }, + "formatter": { + "enabled": true, + "indentStyle": "space" }, "linter": { "enabled": true, "rules": { - "recommended": true + "recommended": true, + "correctness": { + "noUnusedVariables": "warn" + } } }, - "formatter": { - "indentStyle": "space" + "javascript": { + "formatter": { + "quoteStyle": "double" + } }, - "vcs": { - "clientKind": "git", + "assist": { "enabled": true, - "useIgnoreFile": true + "actions": { + "source": { + "organizeImports": "on" + } + } } } diff --git a/bun.lockb b/bun.lockb index 78cfba4..c6f002f 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index d1a3051..a1d496e 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,20 @@ "dev": "bun run build && bunx prisma generate", "build": "bun run typecheck && bun build.ts", "lint": "biome check --write .", + "format": "bun run lint", "typecheck": "tsc --noEmit" }, "dependencies": { - "@prisma/generator-helper": "^5.22.0", + "@prisma/generator-helper": "^6.13.0", "@sinclair/typebox": "^0.34.3", - "prettier": "^3.3.3" + "prettier": "^3.6.2" }, "devDependencies": { - "@biomejs/biome": "^1.9.4", - "@prisma/client": "5.22.0", + "@biomejs/biome": "^2.1.3", + "@prisma/client": "6.13.0", "@types/bun": "latest", - "esbuild": "^0.24.0", - "prisma": "5.22.0", - "typescript": "^5.6.3" + "esbuild": "^0.25.8", + "prisma": "6.13.0", + "typescript": "^5.9.2" } } diff --git a/src/annotations/options.ts b/src/annotations/options.ts index 3947b8d..9b66f72 100644 --- a/src/annotations/options.ts +++ b/src/annotations/options.ts @@ -8,11 +8,10 @@ export function generateTypeboxOptions({ input?: ReturnType; exludeAdditionalProperties?: boolean; } = {}): string { - if(exludeAdditionalProperties === undefined) { - exludeAdditionalProperties = !getConfig().additionalProperties + if (exludeAdditionalProperties === undefined) { + exludeAdditionalProperties = !getConfig().additionalProperties; } - const stringifiedOptions: string[] = []; for (const annotation of input?.annotations ?? []) { if (isOptionsVariant(annotation)) { diff --git a/src/config.ts b/src/config.ts index ed7ced5..85bf5f9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,6 +35,10 @@ const configSchema = Type.Object( * Prevents the updatedAt field from being generated in the input model */ ignoreUpdatedAtOnInputModel: Type.Boolean({ default: true }), + /** + * Prevents the foreignId field from being generated in the input model + */ + ignoreForeignOnInputModel: Type.Boolean({ default: true }), /** * How the nullable union should be named */ @@ -63,7 +67,7 @@ const configSchema = Type.Object( /** * When enabled, this option ensures that only primitive types are generated as JSON types. * This ensures compatibility with tooling that only supports the serilization to JSON primitive types. - * + * * This can be false (off), true (will result in formatted string type) or "transformer" which will use Tybepox transformers * to output native JS Date types but transforms those to strings on processing * diff --git a/src/generators/plain.ts b/src/generators/plain.ts index f127ae7..ac9e710 100644 --- a/src/generators/plain.ts +++ b/src/generators/plain.ts @@ -8,8 +8,8 @@ import { getConfig } from "../config"; import type { ProcessedModel } from "../model"; import { processedEnums } from "./enum"; import { - type PrimitivePrismaFieldType, isPrimitivePrismaFieldType, + type PrimitivePrismaFieldType, stringifyPrimitiveType, } from "./primitiveField"; import { wrapWithArray } from "./wrappers/array"; @@ -31,7 +31,7 @@ export function processPlain(models: DMMF.Model[] | Readonly) { export function stringifyPlain( data: DMMF.Model, isInputModelCreate = false, - isInputModelUpdate = false + isInputModelUpdate = false, ) { const annotations = extractAnnotations(data.documentation); @@ -81,6 +81,7 @@ export function stringifyPlain( return undefined; if ( + getConfig().ignoreForeignOnInputModel && (isInputModelCreate || isInputModelUpdate) && (field.name.toLowerCase().endsWith("id") || field.name.toLowerCase().endsWith("foreign") || @@ -114,7 +115,7 @@ export function stringifyPlain( } else if (processedEnums.find((e) => e.name === field.type)) { // biome-ignore lint/style/noNonNullAssertion: we checked this manually stringifiedType = processedEnums.find( - (e) => e.name === field.type + (e) => e.name === field.type, )!.stringRepresentation; } else { return undefined; diff --git a/src/generators/where.ts b/src/generators/where.ts index aad4306..95492d2 100644 --- a/src/generators/where.ts +++ b/src/generators/where.ts @@ -8,8 +8,8 @@ import { getConfig } from "../config"; import type { ProcessedModel } from "../model"; import { processedEnums } from "./enum"; import { - type PrimitivePrismaFieldType, isPrimitivePrismaFieldType, + type PrimitivePrismaFieldType, stringifyPrimitiveType, } from "./primitiveField"; import { wrapWithArray } from "./wrappers/array"; diff --git a/src/index.ts b/src/index.ts index 00f42bc..bb3dfb3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,7 +33,7 @@ generatorHandler({ try { await access(getConfig().output); await rm(getConfig().output, { recursive: true }); - } catch (error) {} + } catch (_error) {} await mkdir(getConfig().output, { recursive: true });