Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
Binary file modified bun.lockb
Binary file not shown.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 2 additions & 3 deletions src/annotations/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ export function generateTypeboxOptions({
input?: ReturnType<typeof extractAnnotations>;
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)) {
Expand Down
6 changes: 5 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*
Expand Down
7 changes: 4 additions & 3 deletions src/generators/plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -31,7 +31,7 @@ export function processPlain(models: DMMF.Model[] | Readonly<DMMF.Model[]>) {
export function stringifyPlain(
data: DMMF.Model,
isInputModelCreate = false,
isInputModelUpdate = false
isInputModelUpdate = false,
) {
const annotations = extractAnnotations(data.documentation);

Expand Down Expand Up @@ -81,6 +81,7 @@ export function stringifyPlain(
return undefined;

if (
getConfig().ignoreForeignOnInputModel &&
(isInputModelCreate || isInputModelUpdate) &&
(field.name.toLowerCase().endsWith("id") ||
field.name.toLowerCase().endsWith("foreign") ||
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/generators/where.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down