Skip to content

Commit d3aabbd

Browse files
committed
feat(code-gen): re-instantiate T.array().convert()
BREAKING CHANGE: - JS validators don't automatically convert single values to arrays anymore. Adding this as the default caused performance problems with the Typescript compiler and complex recursive types. It also caused a bad DX, where setting an empty array and trying to push later would result in a type error. Also not every planned target language has support to type this correctly anyway, so it should be used sparingly.
1 parent d704a67 commit d3aabbd

File tree

18 files changed

+4665
-4351
lines changed

18 files changed

+4665
-4351
lines changed

packages/cli/src/generated/cli/validators.js

Lines changed: 96 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/generated/common/types.d.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,12 @@ export type CliCommandDefinitionInput = {
127127
| undefined;
128128
watchSettings?:
129129
| {
130-
extensions?: string[] | string | undefined;
131-
ignorePatterns?: string[] | string | undefined;
130+
extensions?: string[] | undefined;
131+
ignorePatterns?: string[] | undefined;
132132
}
133133
| undefined;
134-
subCommands?:
135-
| CliCommandDefinitionInput[]
136-
| CliCommandDefinitionInput
137-
| undefined;
138-
flags?: CliFlagDefinitionInput[] | CliFlagDefinitionInput | undefined;
134+
subCommands?: CliCommandDefinitionInput[] | undefined;
135+
flags?: CliFlagDefinitionInput[] | undefined;
139136
executor?:
140137
| ((
141138
logger: import("@compas/stdlib").Logger,

packages/code-gen/src/generated/common/types.d.ts

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -565,24 +565,20 @@ export type StructureCrudDefinitionInput = {
565565
fieldOptions: {
566566
readable?:
567567
| {
568-
$omit?: string[] | string | undefined;
569-
$pick?: string[] | string | undefined;
568+
$omit?: string[] | undefined;
569+
$pick?: string[] | undefined;
570570
}
571571
| undefined;
572572
readableType?: StructureReferenceDefinitionInput | undefined;
573573
writable?:
574574
| {
575-
$omit?: string[] | string | undefined;
576-
$pick?: string[] | string | undefined;
575+
$omit?: string[] | undefined;
576+
$pick?: string[] | undefined;
577577
}
578578
| undefined;
579579
};
580-
inlineRelations:
581-
| StructureCrudDefinitionInput[]
582-
| StructureCrudDefinitionInput;
583-
nestedRelations:
584-
| StructureCrudDefinitionInput[]
585-
| StructureCrudDefinitionInput;
580+
inlineRelations: StructureCrudDefinitionInput[];
581+
nestedRelations: StructureCrudDefinitionInput[];
586582
};
587583

588584
export type StructureDateDefinitionInput = {
@@ -635,9 +631,7 @@ export type StructureExtendDefinitionInput = {
635631
validator?: {} | undefined;
636632
keys: { [key: string]: StructureTypeSystemDefinitionInput };
637633
reference: StructureReferenceDefinitionInput;
638-
relations:
639-
| StructureRelationDefinitionInput[]
640-
| StructureRelationDefinitionInput;
634+
relations: StructureRelationDefinitionInput[];
641635
};
642636

643637
export type StructureFileDefinitionInput = {
@@ -655,7 +649,7 @@ export type StructureFileDefinitionInput = {
655649
}
656650
| undefined;
657651
validator: {
658-
mimeTypes?: string[] | string | undefined;
652+
mimeTypes?: string[] | undefined;
659653
};
660654
};
661655

@@ -698,7 +692,7 @@ export type StructureNumberDefinitionInput = {
698692
max?: number | undefined;
699693
allowNull?: boolean | "true" | "false" | undefined;
700694
};
701-
oneOf?: number[] | number | undefined;
695+
oneOf?: number[] | undefined;
702696
};
703697

704698
export type StructureObjectDefinitionInput = {
@@ -731,9 +725,7 @@ export type StructureObjectDefinitionInput = {
731725
schema?: string | undefined;
732726
}
733727
| undefined;
734-
relations:
735-
| StructureRelationDefinitionInput[]
736-
| StructureRelationDefinitionInput;
728+
relations: StructureRelationDefinitionInput[];
737729
};
738730

739731
export type StructureOmitDefinitionInput = {
@@ -754,7 +746,7 @@ export type StructureOmitDefinitionInput = {
754746
allowNull?: boolean | "true" | "false" | undefined;
755747
strict: boolean | "true" | "false";
756748
};
757-
keys: string[] | string;
749+
keys: string[];
758750
reference: StructureTypeSystemDefinitionInput;
759751
};
760752

@@ -776,7 +768,7 @@ export type StructurePickDefinitionInput = {
776768
allowNull?: boolean | "true" | "false" | undefined;
777769
strict: boolean | "true" | "false";
778770
};
779-
keys: string[] | string;
771+
keys: string[];
780772
reference: StructureTypeSystemDefinitionInput;
781773
};
782774

@@ -802,9 +794,9 @@ export type StructureStringDefinitionInput = {
802794
max?: number | undefined;
803795
pattern?: string | undefined;
804796
allowNull?: boolean | "true" | "false" | undefined;
805-
disallowedCharacters?: string[] | string | undefined;
797+
disallowedCharacters?: string[] | undefined;
806798
};
807-
oneOf?: string[] | string | undefined;
799+
oneOf?: string[] | undefined;
808800
};
809801

810802
export type StructureUuidDefinitionInput = {
@@ -866,9 +858,7 @@ export type StructureAnyOfDefinitionInput = {
866858
discriminant?: string | undefined;
867859
}
868860
| undefined;
869-
values:
870-
| StructureTypeSystemDefinitionInput[]
871-
| StructureTypeSystemDefinitionInput;
861+
values: StructureTypeSystemDefinitionInput[];
872862
};
873863

874864
/**
@@ -1273,8 +1263,8 @@ export type StructureRouteInvalidationDefinitionInput = {
12731263
useSharedQuery?: boolean | "true" | "false" | undefined;
12741264
specification?:
12751265
| {
1276-
params: { [key: string]: string[] | string };
1277-
query: { [key: string]: string[] | string };
1266+
params: { [key: string]: string[] };
1267+
query: { [key: string]: string[] };
12781268
}
12791269
| undefined;
12801270
};
@@ -1298,15 +1288,13 @@ export type StructureRouteDefinitionInput = {
12981288
method: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "PATCH";
12991289
idempotent: boolean | "true" | "false";
13001290
path: string;
1301-
tags: string[] | string;
1291+
tags: string[];
13021292
query?: StructureReferenceDefinitionInput | undefined;
13031293
params?: StructureReferenceDefinitionInput | undefined;
13041294
body?: StructureReferenceDefinitionInput | undefined;
13051295
files?: StructureReferenceDefinitionInput | undefined;
13061296
response?: StructureReferenceDefinitionInput | undefined;
1307-
invalidations:
1308-
| StructureRouteInvalidationDefinitionInput[]
1309-
| StructureRouteInvalidationDefinitionInput;
1297+
invalidations: StructureRouteInvalidationDefinitionInput[];
13101298
metadata?:
13111299
| {
13121300
requestBodyType?: "json" | "form-data" | undefined;

0 commit comments

Comments
 (0)