zod-to-x 1.4.6 → 1.4.7-dev.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/dist/lib/zod_ext.d.ts +8 -0
- package/dist/lib/zod_ext.js +16 -0
- package/dist/lib/zod_helpers.js +26 -25
- package/package.json +1 -1
package/dist/lib/zod_ext.d.ts
CHANGED
|
@@ -275,3 +275,11 @@ declare module "zod" {
|
|
|
275
275
|
* ```
|
|
276
276
|
*/
|
|
277
277
|
export declare function extendZod(zod: any): void;
|
|
278
|
+
/**
|
|
279
|
+
* Enforcing the same instance of Zod used by user. This resolves Bun incompatibilities.
|
|
280
|
+
*/
|
|
281
|
+
export declare class Extended {
|
|
282
|
+
private static zExt;
|
|
283
|
+
static getZ(): any;
|
|
284
|
+
static setZ(zod: any): void;
|
|
285
|
+
}
|
package/dist/lib/zod_ext.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Extended = void 0;
|
|
3
4
|
exports.extendZod = extendZod;
|
|
5
|
+
const zod_1 = require("zod");
|
|
4
6
|
function getZod2XConstructor() {
|
|
5
7
|
return function (opt, value) {
|
|
6
8
|
if (typeof opt === "string" && value !== undefined) {
|
|
@@ -66,4 +68,18 @@ function extendZod(zod /*typeof z ---> any type until solve type incompatibiliti
|
|
|
66
68
|
return newItem;
|
|
67
69
|
};
|
|
68
70
|
}
|
|
71
|
+
Extended.setZ(zod);
|
|
69
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Enforcing the same instance of Zod used by user. This resolves Bun incompatibilities.
|
|
75
|
+
*/
|
|
76
|
+
class Extended {
|
|
77
|
+
static getZ() {
|
|
78
|
+
return this.zExt;
|
|
79
|
+
}
|
|
80
|
+
static setZ(zod) {
|
|
81
|
+
this.zExt = zod;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.Extended = Extended;
|
|
85
|
+
Extended.zExt = zod_1.z;
|
package/dist/lib/zod_helpers.js
CHANGED
|
@@ -2,75 +2,76 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZodHelpers = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const zod_ext_1 = require("./zod_ext");
|
|
5
6
|
class ZodHelpers {
|
|
6
7
|
static isZodType(i) {
|
|
7
|
-
return i instanceof
|
|
8
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodType;
|
|
8
9
|
}
|
|
9
10
|
static isZodAny(i) {
|
|
10
|
-
return i instanceof
|
|
11
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodAny;
|
|
11
12
|
}
|
|
12
13
|
static isZodString(i) {
|
|
13
|
-
return i instanceof
|
|
14
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodString;
|
|
14
15
|
}
|
|
15
16
|
static isZodNumber(i) {
|
|
16
|
-
return i instanceof
|
|
17
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodNumber;
|
|
17
18
|
}
|
|
18
19
|
static isZodBigInt(i) {
|
|
19
|
-
return i instanceof
|
|
20
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodBigInt;
|
|
20
21
|
}
|
|
21
22
|
static isZodLiteral(i) {
|
|
22
|
-
return i instanceof
|
|
23
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodLiteral;
|
|
23
24
|
}
|
|
24
25
|
static isZodBoolean(i) {
|
|
25
|
-
return i instanceof
|
|
26
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodBoolean;
|
|
26
27
|
}
|
|
27
28
|
static isZodDate(i) {
|
|
28
|
-
return i instanceof
|
|
29
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodDate;
|
|
29
30
|
}
|
|
30
31
|
static isZodEnum(i) {
|
|
31
|
-
return i instanceof
|
|
32
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodEnum;
|
|
32
33
|
}
|
|
33
34
|
static isZodUnion(i) {
|
|
34
|
-
return i instanceof
|
|
35
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodUnion;
|
|
35
36
|
}
|
|
36
37
|
static isZodDiscriminatedUnion(i) {
|
|
37
|
-
return i instanceof
|
|
38
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodDiscriminatedUnion;
|
|
38
39
|
}
|
|
39
40
|
static isZodNativeEnum(i) {
|
|
40
|
-
return i instanceof
|
|
41
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodNativeEnum;
|
|
41
42
|
}
|
|
42
43
|
static isZodIntersection(i) {
|
|
43
|
-
return i instanceof
|
|
44
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodIntersection;
|
|
44
45
|
}
|
|
45
46
|
static isZodObject(i) {
|
|
46
|
-
return i instanceof
|
|
47
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodObject;
|
|
47
48
|
}
|
|
48
49
|
static isZodLazy(i) {
|
|
49
|
-
return i instanceof
|
|
50
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodLazy;
|
|
50
51
|
}
|
|
51
52
|
static isZodRecord(i) {
|
|
52
|
-
return i instanceof
|
|
53
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodRecord;
|
|
53
54
|
}
|
|
54
55
|
static isZodMap(i) {
|
|
55
|
-
return i instanceof
|
|
56
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodMap;
|
|
56
57
|
}
|
|
57
58
|
static isZodArray(i) {
|
|
58
|
-
return i instanceof
|
|
59
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodArray;
|
|
59
60
|
}
|
|
60
61
|
static isZodSet(i) {
|
|
61
|
-
return i instanceof
|
|
62
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodSet;
|
|
62
63
|
}
|
|
63
64
|
static isZodTuple(i) {
|
|
64
|
-
return i instanceof
|
|
65
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodTuple;
|
|
65
66
|
}
|
|
66
67
|
static isZodOptional(i) {
|
|
67
|
-
return i instanceof
|
|
68
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodOptional;
|
|
68
69
|
}
|
|
69
70
|
static isZodNullable(i) {
|
|
70
|
-
return i instanceof
|
|
71
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodNullable;
|
|
71
72
|
}
|
|
72
73
|
static isZodDefault(i) {
|
|
73
|
-
return i instanceof
|
|
74
|
+
return i instanceof zod_ext_1.Extended.getZ().ZodDefault;
|
|
74
75
|
}
|
|
75
76
|
static isZodAnyUnionType(i) {
|
|
76
77
|
return this.isZodUnion(i) || this.isZodDiscriminatedUnion(i);
|
|
@@ -127,10 +128,10 @@ class ZodHelpers {
|
|
|
127
128
|
}
|
|
128
129
|
static cloneZod(i) {
|
|
129
130
|
const zodType = i._def.typeName;
|
|
130
|
-
return new
|
|
131
|
+
return new (zod_ext_1.Extended.getZ()[zodType])(Object.assign({}, i._def));
|
|
131
132
|
}
|
|
132
133
|
static createZodObject(properties) {
|
|
133
|
-
return
|
|
134
|
+
return zod_ext_1.Extended.getZ().object(Object.fromEntries(properties));
|
|
134
135
|
}
|
|
135
136
|
static getZodNumberConstraints(i) {
|
|
136
137
|
const constraints = { isInt: this.isZodBigInt(i) };
|