Skip to content

Commit

Permalink
feat(code-gen): re-instantiate T.array().convert()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dirkdev98 committed May 14, 2023
1 parent d704a67 commit d3aabbd
Show file tree
Hide file tree
Showing 18 changed files with 4,665 additions and 4,351 deletions.
176 changes: 96 additions & 80 deletions packages/cli/src/generated/cli/validators.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions packages/cli/src/generated/common/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,12 @@ export type CliCommandDefinitionInput = {
| undefined;
watchSettings?:
| {
extensions?: string[] | string | undefined;
ignorePatterns?: string[] | string | undefined;
extensions?: string[] | undefined;
ignorePatterns?: string[] | undefined;
}
| undefined;
subCommands?:
| CliCommandDefinitionInput[]
| CliCommandDefinitionInput
| undefined;
flags?: CliFlagDefinitionInput[] | CliFlagDefinitionInput | undefined;
subCommands?: CliCommandDefinitionInput[] | undefined;
flags?: CliFlagDefinitionInput[] | undefined;
executor?:
| ((
logger: import("@compas/stdlib").Logger,
Expand Down
50 changes: 19 additions & 31 deletions packages/code-gen/src/generated/common/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,24 +565,20 @@ export type StructureCrudDefinitionInput = {
fieldOptions: {
readable?:
| {
$omit?: string[] | string | undefined;
$pick?: string[] | string | undefined;
$omit?: string[] | undefined;
$pick?: string[] | undefined;
}
| undefined;
readableType?: StructureReferenceDefinitionInput | undefined;
writable?:
| {
$omit?: string[] | string | undefined;
$pick?: string[] | string | undefined;
$omit?: string[] | undefined;
$pick?: string[] | undefined;
}
| undefined;
};
inlineRelations:
| StructureCrudDefinitionInput[]
| StructureCrudDefinitionInput;
nestedRelations:
| StructureCrudDefinitionInput[]
| StructureCrudDefinitionInput;
inlineRelations: StructureCrudDefinitionInput[];
nestedRelations: StructureCrudDefinitionInput[];
};

export type StructureDateDefinitionInput = {
Expand Down Expand Up @@ -635,9 +631,7 @@ export type StructureExtendDefinitionInput = {
validator?: {} | undefined;
keys: { [key: string]: StructureTypeSystemDefinitionInput };
reference: StructureReferenceDefinitionInput;
relations:
| StructureRelationDefinitionInput[]
| StructureRelationDefinitionInput;
relations: StructureRelationDefinitionInput[];
};

export type StructureFileDefinitionInput = {
Expand All @@ -655,7 +649,7 @@ export type StructureFileDefinitionInput = {
}
| undefined;
validator: {
mimeTypes?: string[] | string | undefined;
mimeTypes?: string[] | undefined;
};
};

Expand Down Expand Up @@ -698,7 +692,7 @@ export type StructureNumberDefinitionInput = {
max?: number | undefined;
allowNull?: boolean | "true" | "false" | undefined;
};
oneOf?: number[] | number | undefined;
oneOf?: number[] | undefined;
};

export type StructureObjectDefinitionInput = {
Expand Down Expand Up @@ -731,9 +725,7 @@ export type StructureObjectDefinitionInput = {
schema?: string | undefined;
}
| undefined;
relations:
| StructureRelationDefinitionInput[]
| StructureRelationDefinitionInput;
relations: StructureRelationDefinitionInput[];
};

export type StructureOmitDefinitionInput = {
Expand All @@ -754,7 +746,7 @@ export type StructureOmitDefinitionInput = {
allowNull?: boolean | "true" | "false" | undefined;
strict: boolean | "true" | "false";
};
keys: string[] | string;
keys: string[];
reference: StructureTypeSystemDefinitionInput;
};

Expand All @@ -776,7 +768,7 @@ export type StructurePickDefinitionInput = {
allowNull?: boolean | "true" | "false" | undefined;
strict: boolean | "true" | "false";
};
keys: string[] | string;
keys: string[];
reference: StructureTypeSystemDefinitionInput;
};

Expand All @@ -802,9 +794,9 @@ export type StructureStringDefinitionInput = {
max?: number | undefined;
pattern?: string | undefined;
allowNull?: boolean | "true" | "false" | undefined;
disallowedCharacters?: string[] | string | undefined;
disallowedCharacters?: string[] | undefined;
};
oneOf?: string[] | string | undefined;
oneOf?: string[] | undefined;
};

export type StructureUuidDefinitionInput = {
Expand Down Expand Up @@ -866,9 +858,7 @@ export type StructureAnyOfDefinitionInput = {
discriminant?: string | undefined;
}
| undefined;
values:
| StructureTypeSystemDefinitionInput[]
| StructureTypeSystemDefinitionInput;
values: StructureTypeSystemDefinitionInput[];
};

/**
Expand Down Expand Up @@ -1273,8 +1263,8 @@ export type StructureRouteInvalidationDefinitionInput = {
useSharedQuery?: boolean | "true" | "false" | undefined;
specification?:
| {
params: { [key: string]: string[] | string };
query: { [key: string]: string[] | string };
params: { [key: string]: string[] };
query: { [key: string]: string[] };
}
| undefined;
};
Expand All @@ -1298,15 +1288,13 @@ export type StructureRouteDefinitionInput = {
method: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "PATCH";
idempotent: boolean | "true" | "false";
path: string;
tags: string[] | string;
tags: string[];
query?: StructureReferenceDefinitionInput | undefined;
params?: StructureReferenceDefinitionInput | undefined;
body?: StructureReferenceDefinitionInput | undefined;
files?: StructureReferenceDefinitionInput | undefined;
response?: StructureReferenceDefinitionInput | undefined;
invalidations:
| StructureRouteInvalidationDefinitionInput[]
| StructureRouteInvalidationDefinitionInput;
invalidations: StructureRouteInvalidationDefinitionInput[];
metadata?:
| {
requestBodyType?: "json" | "form-data" | undefined;
Expand Down
Loading

0 comments on commit d3aabbd

Please sign in to comment.