quicktype-core 23.0.64 → 23.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StringTypeMapping } from "TypeBuilder";
|
|
2
|
+
import { ConvenienceRenderer } from "../ConvenienceRenderer";
|
|
2
3
|
import { Namer } from "../Naming";
|
|
3
4
|
import { RenderContext } from "../Renderer";
|
|
4
5
|
import { BooleanOption, Option, OptionValues } from "../RendererOptions";
|
|
5
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
6
6
|
import { Sourcelike } from "../Source";
|
|
7
|
-
import {
|
|
7
|
+
import { TargetLanguage } from "../TargetLanguage";
|
|
8
|
+
import { ClassProperty, Type } from "../Type";
|
|
8
9
|
export declare const typeScriptZodOptions: {
|
|
9
10
|
justSchema: BooleanOption;
|
|
10
11
|
};
|
|
11
12
|
export declare class TypeScriptZodTargetLanguage extends TargetLanguage {
|
|
12
13
|
protected getOptions(): Option<any>[];
|
|
13
14
|
constructor(displayName?: string, names?: string[], extension?: string);
|
|
15
|
+
get stringTypeMapping(): StringTypeMapping;
|
|
14
16
|
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
15
17
|
[name: string]: any;
|
|
16
18
|
}): TypeScriptZodRenderer;
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypeScriptZodRenderer = exports.TypeScriptZodTargetLanguage = exports.typeScriptZodOptions = void 0;
|
|
4
4
|
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const
|
|
5
|
+
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
6
6
|
const Naming_1 = require("../Naming");
|
|
7
7
|
const RendererOptions_1 = require("../RendererOptions");
|
|
8
|
+
const TargetLanguage_1 = require("../TargetLanguage");
|
|
9
|
+
const TypeUtils_1 = require("../TypeUtils");
|
|
8
10
|
const Acronyms_1 = require("../support/Acronyms");
|
|
9
11
|
const Strings_1 = require("../support/Strings");
|
|
10
|
-
const TargetLanguage_1 = require("../TargetLanguage");
|
|
11
|
-
const JavaScript_1 = require("./JavaScript");
|
|
12
12
|
const Support_1 = require("../support/Support");
|
|
13
|
-
const
|
|
13
|
+
const JavaScript_1 = require("./JavaScript");
|
|
14
14
|
exports.typeScriptZodOptions = {
|
|
15
15
|
justSchema: new RendererOptions_1.BooleanOption("just-schema", "Schema only", false)
|
|
16
16
|
};
|
|
@@ -21,6 +21,12 @@ class TypeScriptZodTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
|
21
21
|
constructor(displayName = "TypeScript Zod", names = ["typescript-zod"], extension = "ts") {
|
|
22
22
|
super(displayName, names, extension);
|
|
23
23
|
}
|
|
24
|
+
get stringTypeMapping() {
|
|
25
|
+
const mapping = new Map();
|
|
26
|
+
const dateTimeType = "date-time";
|
|
27
|
+
mapping.set("date-time", dateTimeType);
|
|
28
|
+
return mapping;
|
|
29
|
+
}
|
|
24
30
|
makeRenderer(renderContext, untypedOptionValues) {
|
|
25
31
|
return new TypeScriptZodRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.typeScriptZodOptions, untypedOptionValues));
|
|
26
32
|
}
|
|
@@ -70,6 +76,9 @@ class TypeScriptZodRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
70
76
|
const children = Array.from(unionType.getChildren()).map((type) => this.typeMapTypeFor(type, false));
|
|
71
77
|
return ["z.union([", ...(0, collection_utils_1.arrayIntercalate)(", ", children), "])"];
|
|
72
78
|
}, _transformedStringType => {
|
|
79
|
+
if (_transformedStringType.kind === "date-time") {
|
|
80
|
+
return "z.coerce.date()";
|
|
81
|
+
}
|
|
73
82
|
return "z.string()";
|
|
74
83
|
});
|
|
75
84
|
if (required) {
|