zod-to-x 1.4.7-dev.1 → 1.4.7-dev.3
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/dist/lib/zod_helpers.d.ts +3 -0
- package/dist/lib/zod_helpers.js +50 -23
- package/package.json +6 -6
|
@@ -7,6 +7,9 @@ type ZodNumberConstraints = {
|
|
|
7
7
|
max?: number;
|
|
8
8
|
isInt: boolean;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Zod's typeName is checked insted of instanceof to resolve Bun incomatibilities.
|
|
12
|
+
*/
|
|
10
13
|
export declare class ZodHelpers {
|
|
11
14
|
static isZodType(i: ZodTypeAny): boolean;
|
|
12
15
|
static isZodAny(i: ZodTypeAny): i is z.ZodAny;
|
package/dist/lib/zod_helpers.js
CHANGED
|
@@ -3,75 +3,102 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZodHelpers = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zod_ext_1 = require("./zod_ext");
|
|
6
|
+
/**
|
|
7
|
+
* Zod's typeName is checked insted of instanceof to resolve Bun incomatibilities.
|
|
8
|
+
*/
|
|
6
9
|
class ZodHelpers {
|
|
7
10
|
static isZodType(i) {
|
|
8
|
-
|
|
11
|
+
var _a;
|
|
12
|
+
return zod_1.ZodFirstPartyTypeKind[(_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName] !== undefined;
|
|
9
13
|
}
|
|
10
14
|
static isZodAny(i) {
|
|
11
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodAny;
|
|
12
17
|
}
|
|
13
18
|
static isZodString(i) {
|
|
14
|
-
|
|
19
|
+
var _a;
|
|
20
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodString;
|
|
15
21
|
}
|
|
16
22
|
static isZodNumber(i) {
|
|
17
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodNumber;
|
|
18
25
|
}
|
|
19
26
|
static isZodBigInt(i) {
|
|
20
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodBigInt;
|
|
21
29
|
}
|
|
22
30
|
static isZodLiteral(i) {
|
|
23
|
-
|
|
31
|
+
var _a;
|
|
32
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodLiteral;
|
|
24
33
|
}
|
|
25
34
|
static isZodBoolean(i) {
|
|
26
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodBoolean;
|
|
27
37
|
}
|
|
28
38
|
static isZodDate(i) {
|
|
29
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodDate;
|
|
30
41
|
}
|
|
31
42
|
static isZodEnum(i) {
|
|
32
|
-
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodEnum;
|
|
33
45
|
}
|
|
34
46
|
static isZodUnion(i) {
|
|
35
|
-
|
|
47
|
+
var _a;
|
|
48
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodUnion;
|
|
36
49
|
}
|
|
37
50
|
static isZodDiscriminatedUnion(i) {
|
|
38
|
-
|
|
51
|
+
var _a;
|
|
52
|
+
return (((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) ===
|
|
53
|
+
zod_1.ZodFirstPartyTypeKind.ZodDiscriminatedUnion);
|
|
39
54
|
}
|
|
40
55
|
static isZodNativeEnum(i) {
|
|
41
|
-
|
|
56
|
+
var _a;
|
|
57
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodNativeEnum;
|
|
42
58
|
}
|
|
43
59
|
static isZodIntersection(i) {
|
|
44
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
return (((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodIntersection);
|
|
45
62
|
}
|
|
46
63
|
static isZodObject(i) {
|
|
47
|
-
|
|
64
|
+
var _a;
|
|
65
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodObject;
|
|
48
66
|
}
|
|
49
67
|
static isZodLazy(i) {
|
|
50
|
-
|
|
68
|
+
var _a;
|
|
69
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodLazy;
|
|
51
70
|
}
|
|
52
71
|
static isZodRecord(i) {
|
|
53
|
-
|
|
72
|
+
var _a;
|
|
73
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodRecord;
|
|
54
74
|
}
|
|
55
75
|
static isZodMap(i) {
|
|
56
|
-
|
|
76
|
+
var _a;
|
|
77
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodMap;
|
|
57
78
|
}
|
|
58
79
|
static isZodArray(i) {
|
|
59
|
-
|
|
80
|
+
var _a;
|
|
81
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodArray;
|
|
60
82
|
}
|
|
61
83
|
static isZodSet(i) {
|
|
62
|
-
|
|
84
|
+
var _a;
|
|
85
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodSet;
|
|
63
86
|
}
|
|
64
87
|
static isZodTuple(i) {
|
|
65
|
-
|
|
88
|
+
var _a;
|
|
89
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodTuple;
|
|
66
90
|
}
|
|
67
91
|
static isZodOptional(i) {
|
|
68
|
-
|
|
92
|
+
var _a;
|
|
93
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodOptional;
|
|
69
94
|
}
|
|
70
95
|
static isZodNullable(i) {
|
|
71
|
-
|
|
96
|
+
var _a;
|
|
97
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodNullable;
|
|
72
98
|
}
|
|
73
99
|
static isZodDefault(i) {
|
|
74
|
-
|
|
100
|
+
var _a;
|
|
101
|
+
return ((_a = i === null || i === void 0 ? void 0 : i._def) === null || _a === void 0 ? void 0 : _a.typeName) === zod_1.ZodFirstPartyTypeKind.ZodDefault;
|
|
75
102
|
}
|
|
76
103
|
static isZodAnyUnionType(i) {
|
|
77
104
|
return this.isZodUnion(i) || this.isZodDiscriminatedUnion(i);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod-to-x",
|
|
3
|
-
"version": "1.4.7-dev.
|
|
3
|
+
"version": "1.4.7-dev.3",
|
|
4
4
|
"description": "Multi language types generation from Zod schemas.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "npm run clear_dist && tsc && tsc-alias",
|
|
12
12
|
"build:debug": "npm run clear_dist && tsc --project tsconfig.dev.json && tsc-alias",
|
|
13
13
|
"format:check": "prettier --check .",
|
|
14
|
-
"test": "find ./test -name \"err-*\" -delete &&
|
|
14
|
+
"test": "find ./test -name \"err-*\" -delete && vitest --run",
|
|
15
15
|
"test:cpp": "bash ./test/test_zod2cpp/test_cpp.sh",
|
|
16
16
|
"ts-run": "ts-node -r tsconfig-paths/register",
|
|
17
17
|
"prepare": "husky"
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
"case": "1.6.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@
|
|
54
|
+
"@vitest/coverage-v8": "^3.1.3",
|
|
55
|
+
"@vitest/ui": "^3.1.3",
|
|
56
|
+
"diff": "^8.0.1",
|
|
55
57
|
"husky": "^9.1.7",
|
|
56
|
-
"jest": "^29.7.0",
|
|
57
|
-
"jest-diff": "^29.7.0",
|
|
58
58
|
"lint-staged": "^15.2.11",
|
|
59
59
|
"prettier": "^3.4.2",
|
|
60
60
|
"protobufjs": "7.4.0",
|
|
61
|
-
"ts-jest": "^29.2.5",
|
|
62
61
|
"ts-node": "^10.9.2",
|
|
63
62
|
"tsc-alias": "^1.8.10",
|
|
64
63
|
"tsconfig-paths": "4.2.0",
|
|
65
64
|
"typescript": "^5.6.3",
|
|
65
|
+
"vitest": "^3.1.3",
|
|
66
66
|
"zod-to-json-schema": "^3.21.4"
|
|
67
67
|
}
|
|
68
68
|
}
|