zod-to-x 2.0.1-dev.3 → 2.0.1
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.
- package/README.md +3 -2
- package/dist/converters/protobuf_v3/options.d.ts +6 -0
- package/dist/converters/protobuf_v3/options.js +1 -0
- package/dist/converters/protobuf_v3/runner.d.ts +1 -1
- package/dist/converters/protobuf_v3/runner.js +1 -1
- package/dist/transpilers/cpp/runner.js +1 -0
- package/dist/transpilers/typescript/runner.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
[`@zod-to-x`](https://github.com/rroumenov/zod-to-x`) is a Zod-based library designed to establish a centralized methodology for defining data structures. It allows you to transpile these definitions into various programming languages in a clear and straightforward way. This tool addresses a fundamental requirement of any software: having a clear understanding of the data it handles.
|
|
20
20
|
|
|
21
|
-
<span style="color: red;">**Important Announcement:**</span> `zod-to-x@2.0.0` has been released, introducing migration to Zod V4. At this stage, only the existent behavior has been migrated, while new features like Literal Templates are still under analysis. Additionally, `zod-to-x@1.X.Y` will continue to be maintained for Zod V3, and any new transpilation languages will also be supported in version 1.
|
|
21
|
+
<span style="color: red;">**Important Announcement:**</span> `zod-to-x@2.0.0` has been released, introducing migration to Zod V4. At this stage, only the existent behavior has been migrated, while new features like Literal Templates are still under analysis. Only the complete Zod V4 version will be supported, **not v4-mini**. Additionally, `zod-to-x@1.X.Y` will continue to be maintained for Zod V3, and any new transpilation languages will also be supported in version 1.
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -521,8 +521,9 @@ In case of use of Google protobuf to improve communication performance, you can
|
|
|
521
521
|
- **packageName**: Name of the protobuf file package.
|
|
522
522
|
- **header**: Text to add as a comment at the beginning of the output.
|
|
523
523
|
- **indent**: Number of spaces to use for indentation in the generated code. Defaults to 4 if not specified.
|
|
524
|
-
- **includeComments**: Determines whether to include comments in the transpiled code. Defaults to true
|
|
524
|
+
- **includeComments**: Determines whether to include comments in the transpiled code. Defaults to `true`.
|
|
525
525
|
- **keepKeys**: Specifies whether property names should follow the Google Protobuf naming convention (false) or remain as originally defined (true). The default is `false`.
|
|
526
|
+
- **encodeDoubleAsInt**: Double values will be represented as integers in the proto file. Defaults to `false`.
|
|
526
527
|
|
|
527
528
|
- Limitations:
|
|
528
529
|
- ZodTuple is supported only for items of the same type.
|
|
@@ -9,5 +9,11 @@ export interface IZod2ProtoV3Opt extends IZodToXOpt {
|
|
|
9
9
|
* language's naming conventions. If set to true, the original property names are preserved.
|
|
10
10
|
*/
|
|
11
11
|
keepKeys?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* If true, double values will be represented as integers in the generated protobuf file.
|
|
14
|
+
* This could be useful when integer representation could be done with int32 or smaller because
|
|
15
|
+
* output will be more compact. Default is false.
|
|
16
|
+
*/
|
|
17
|
+
encodeDoubleAsInt?: boolean;
|
|
12
18
|
}
|
|
13
19
|
export declare const defaultOpts: IZod2ProtoV3Opt;
|
|
@@ -16,4 +16,4 @@ import { IZod2ProtoV3Opt } from "./options";
|
|
|
16
16
|
* definition.
|
|
17
17
|
* @returns The Protocol Buffers v3 definition as a string.
|
|
18
18
|
*/
|
|
19
|
-
export declare function zod2ProtoV3(schema: ZodObject<any>, opt?: Pick<IZod2AstOpt, "strict"> & Pick<IZod2ProtoV3Opt, "packageName" | "keepKeys" | "header" | "indent" | "includeComments">): string;
|
|
19
|
+
export declare function zod2ProtoV3(schema: ZodObject<any>, opt?: Pick<IZod2AstOpt, "strict"> & Pick<IZod2ProtoV3Opt, "packageName" | "keepKeys" | "header" | "indent" | "includeComments" | "encodeDoubleAsInt">): string;
|
|
@@ -34,7 +34,7 @@ class Zod2ProtoV3 extends core_1.Zod2X {
|
|
|
34
34
|
this.getBooleanType = () => "bool";
|
|
35
35
|
this.getStringType = () => "string";
|
|
36
36
|
this.getNumberType = (isInt, range) => {
|
|
37
|
-
if (!isInt) {
|
|
37
|
+
if (!isInt && this.opt.encodeDoubleAsInt !== true) {
|
|
38
38
|
return "double";
|
|
39
39
|
}
|
|
40
40
|
if ((range === null || range === void 0 ? void 0 : range.min) >= number_limits_1.UINT32_RANGES[0]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-to-x",
|
|
3
|
-
"version": "2.0.1
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Multi language types generation from Zod schemas.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"*.ts": "prettier --write"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"zod": ">=3.25.28"
|
|
48
|
+
"zod": ">=3.25.28 <3.25.50"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"case": "1.6.3"
|