Skip to content

Commit bfe7991

Browse files
authored
Merge pull request #44 from yeliex/patch-1
feat: add ignoreForeignOnInputModel config to support include foreignIds in the generated input model
2 parents 0ebc659 + 80e2a08 commit bfe7991

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

biome.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
"linter": {
1616
"enabled": true,
1717
"rules": {
18-
"recommended": true
18+
"recommended": true,
19+
"correctness": {
20+
"noUnusedVariables": "warn"
21+
}
1922
}
2023
},
2124
"javascript": {

src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const configSchema = Type.Object(
3535
* Prevents the updatedAt field from being generated in the input model
3636
*/
3737
ignoreUpdatedAtOnInputModel: Type.Boolean({ default: true }),
38+
/**
39+
* Prevents the foreignId field from being generated in the input model
40+
*/
41+
ignoreForeignOnInputModel: Type.Boolean({ default: true }),
3842
/**
3943
* How the nullable union should be named
4044
*/
@@ -63,7 +67,7 @@ const configSchema = Type.Object(
6367
/**
6468
* When enabled, this option ensures that only primitive types are generated as JSON types.
6569
* This ensures compatibility with tooling that only supports the serilization to JSON primitive types.
66-
*
70+
*
6771
* This can be false (off), true (will result in formatted string type) or "transformer" which will use Tybepox transformers
6872
* to output native JS Date types but transforms those to strings on processing
6973
*

src/generators/plain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export function stringifyPlain(
8181
return undefined;
8282

8383
if (
84+
getConfig().ignoreForeignOnInputModel &&
8485
(isInputModelCreate || isInputModelUpdate) &&
8586
(field.name.toLowerCase().endsWith("id") ||
8687
field.name.toLowerCase().endsWith("foreign") ||

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ generatorHandler({
3333
try {
3434
await access(getConfig().output);
3535
await rm(getConfig().output, { recursive: true });
36-
} catch (error) {}
36+
} catch (_error) {}
3737

3838
await mkdir(getConfig().output, { recursive: true });
3939

0 commit comments

Comments
 (0)