zod-to-x 1.6.0 → 1.6.1-dev.0
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.
|
@@ -254,6 +254,6 @@ class Zod2ProtoV3 extends core_1.Zod2X {
|
|
|
254
254
|
* @returns The Protocol Buffers v3 definition as a string.
|
|
255
255
|
*/
|
|
256
256
|
function zod2ProtoV3(schema, opt = {}) {
|
|
257
|
-
const astNode = new core_1.Zod2Ast({ strict: opt.strict }).build(schema);
|
|
257
|
+
const astNode = new core_1.Zod2Ast({ strict: opt.strict, skipBasicTypes: true }).build(schema);
|
|
258
258
|
return new Zod2ProtoV3(opt).transpile(astNode);
|
|
259
259
|
}
|
package/dist/core/ast_node.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export interface IZod2AstOpt {
|
|
|
12
12
|
* the schema.
|
|
13
13
|
*/
|
|
14
14
|
layer?: IZod2xLayerMetadata;
|
|
15
|
+
/**
|
|
16
|
+
* If true, aliased basic types (string, number, boolean, etc.) from layered modeling
|
|
17
|
+
* will not be extracted as named AST nodes. Instead, they will be inlined as their
|
|
18
|
+
* underlying type. Useful for targets like Protobuf that don't support type aliases.
|
|
19
|
+
* Default is false.
|
|
20
|
+
*/
|
|
21
|
+
skipBasicTypes?: boolean;
|
|
15
22
|
}
|
|
16
23
|
/**
|
|
17
24
|
* This class creates AST nodes used to transpile Zod Schemas to other languages.
|
package/dist/core/ast_node.js
CHANGED
|
@@ -476,7 +476,7 @@ class Zod2Ast {
|
|
|
476
476
|
}
|
|
477
477
|
_getAliasAst(schema, item) {
|
|
478
478
|
var _a;
|
|
479
|
-
if (((_a = schema._zod2x) === null || _a === void 0 ? void 0 : _a.typeName) === undefined) {
|
|
479
|
+
if (((_a = schema._zod2x) === null || _a === void 0 ? void 0 : _a.typeName) === undefined || this.opt.skipBasicTypes === true) {
|
|
480
480
|
return item;
|
|
481
481
|
}
|
|
482
482
|
const { name, parentFile, parentNamespace, aliasOf } = this._getNames(schema);
|