zod-to-x 1.4.6-dev.1 → 1.4.6-dev.2
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,4 +1,4 @@
|
|
|
1
|
-
import { ASTCommon } from "./ast_common";
|
|
1
|
+
import { ASTCommon, ASTDefintion } from "./ast_common";
|
|
2
2
|
/**
|
|
3
3
|
* Handle ZodString
|
|
4
4
|
*/
|
|
@@ -29,7 +29,7 @@ export declare class ASTNumber extends ASTCommon {
|
|
|
29
29
|
export declare class ASTLiteral extends ASTCommon {
|
|
30
30
|
name?: string;
|
|
31
31
|
value: any;
|
|
32
|
-
|
|
32
|
+
parentEnum?: ASTDefintion;
|
|
33
33
|
parentEnumKey?: string;
|
|
34
34
|
constructor(data: ASTLiteral & ASTCommon);
|
|
35
35
|
}
|
package/dist/core/ast_node.js
CHANGED
|
@@ -416,7 +416,7 @@ class Zod2Ast {
|
|
|
416
416
|
* @returns
|
|
417
417
|
*/
|
|
418
418
|
_zodToAST(schema, opt) {
|
|
419
|
-
var _a, _b, _c, _d, _e
|
|
419
|
+
var _a, _b, _c, _d, _e;
|
|
420
420
|
const def = schema._def;
|
|
421
421
|
if (zod_helpers_1.ZodHelpers.isZodString(schema)) {
|
|
422
422
|
return new core_1.ASTString({ description: schema.description });
|
|
@@ -474,17 +474,18 @@ class Zod2Ast {
|
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
else if (zod_helpers_1.ZodHelpers.isZodLiteral(schema)) {
|
|
477
|
-
let
|
|
477
|
+
let parentEnum = undefined;
|
|
478
478
|
let parentEnumKey = undefined;
|
|
479
479
|
if ((_b = schema._zod2x) === null || _b === void 0 ? void 0 : _b.parentEnum) {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
480
|
+
parentEnumKey = (_d = this._getEnumValues((_c = schema._zod2x) === null || _c === void 0 ? void 0 : _c.parentEnum).find((i) => i[1] === def.value)) === null || _d === void 0 ? void 0 : _d[0];
|
|
481
|
+
parentEnum = this._zodToAST((_e = schema._zod2x) === null || _e === void 0 ? void 0 : _e.parentEnum, {
|
|
482
|
+
isInjectedEnum: true,
|
|
483
|
+
});
|
|
483
484
|
}
|
|
484
485
|
return new core_1.ASTLiteral({
|
|
485
486
|
value: def.value,
|
|
486
487
|
description: schema.description,
|
|
487
|
-
|
|
488
|
+
parentEnum: parentEnum,
|
|
488
489
|
parentEnumKey,
|
|
489
490
|
});
|
|
490
491
|
}
|
package/dist/core/transpiler.js
CHANGED
|
@@ -87,8 +87,8 @@ class Zod2X {
|
|
|
87
87
|
varType = this.getDateType();
|
|
88
88
|
}
|
|
89
89
|
else if (token instanceof core_1.ASTLiteral) {
|
|
90
|
-
const parentEnum = token.
|
|
91
|
-
? [token.
|
|
90
|
+
const parentEnum = token.parentEnumKey && token.parentEnum
|
|
91
|
+
? [this.getAttributeType(token.parentEnum), token.parentEnumKey]
|
|
92
92
|
: undefined;
|
|
93
93
|
varType = this.getLiteralStringType(token.value, parentEnum);
|
|
94
94
|
}
|