@layerzerolabs/zod-utils 0.2.46 → 0.2.48
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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/dist/{EK3R2JUO.cjs → GR4ZG7N6.cjs} +2 -2
- package/dist/GR4ZG7N6.cjs.map +1 -0
- package/dist/{DWFVFIJK.js → R6AQXXPU.js} +2 -2
- package/dist/R6AQXXPU.js.map +1 -0
- package/dist/index.cjs +11 -11
- package/dist/index.js +2 -2
- package/dist/schema.cjs +5 -5
- package/dist/schema.js +1 -1
- package/package.json +4 -4
- package/src/schema.ts +6 -6
- package/dist/DWFVFIJK.js.map +0 -1
- package/dist/EK3R2JUO.cjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[34mESM[39m Build start
|
|
14
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m4.79 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/schema.cjs [22m[32m709.00 B[39m
|
|
16
|
-
[32mCJS[39m [1mdist/EK3R2JUO.cjs [22m[32m1.29 KB[39m
|
|
17
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[32m11.04 KB[39m
|
|
18
|
-
[32mCJS[39m [1mdist/schema.cjs.map [22m[32m71.00 B[39m
|
|
19
|
-
[32mCJS[39m [1mdist/EK3R2JUO.cjs.map [22m[32m3.22 KB[39m
|
|
20
|
-
[32mCJS[39m ⚡️ Build success in 214ms
|
|
21
14
|
[32mESM[39m [1mdist/schema.js [22m[32m184.00 B[39m
|
|
15
|
+
[32mESM[39m [1mdist/R6AQXXPU.js [22m[32m1.14 KB[39m
|
|
22
16
|
[32mESM[39m [1mdist/index.js [22m[32m4.06 KB[39m
|
|
23
|
-
[32mESM[39m [1mdist/
|
|
17
|
+
[32mESM[39m [1mdist/R6AQXXPU.js.map [22m[32m3.22 KB[39m
|
|
24
18
|
[32mESM[39m [1mdist/schema.js.map [22m[32m70.00 B[39m
|
|
25
|
-
[32mESM[39m [1mdist/DWFVFIJK.js.map [22m[32m3.22 KB[39m
|
|
26
19
|
[32mESM[39m [1mdist/index.js.map [22m[32m11.03 KB[39m
|
|
27
|
-
[32mESM[39m ⚡️ Build success in
|
|
20
|
+
[32mESM[39m ⚡️ Build success in 120ms
|
|
21
|
+
[32mCJS[39m [1mdist/schema.cjs [22m[32m709.00 B[39m
|
|
22
|
+
[32mCJS[39m [1mdist/GR4ZG7N6.cjs [22m[32m1.29 KB[39m
|
|
23
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m4.79 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/GR4ZG7N6.cjs.map [22m[32m3.23 KB[39m
|
|
25
|
+
[32mCJS[39m [1mdist/schema.cjs.map [22m[32m71.00 B[39m
|
|
26
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m11.04 KB[39m
|
|
27
|
+
[32mCJS[39m ⚡️ Build success in 120ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> @layerzerolabs/zod-utils@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/zod-utils
|
|
3
3
|
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
|
|
4
4
|
|
|
5
|
-
(node:
|
|
5
|
+
(node:48391) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1772907261065 is not specified and it doesn't parse as CommonJS.
|
|
6
6
|
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
7
|
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
8
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
@@ -36,5 +36,5 @@ exports.createFunctionPointerSchema = createFunctionPointerSchema;
|
|
|
36
36
|
exports.customSchema = customSchema;
|
|
37
37
|
exports.functionSchema = functionSchema;
|
|
38
38
|
exports.schemaIsFunctionSchema = schemaIsFunctionSchema;
|
|
39
|
-
//# sourceMappingURL=
|
|
40
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=GR4ZG7N6.cjs.map
|
|
40
|
+
//# sourceMappingURL=GR4ZG7N6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts"],"names":["functionSchemaTag","Symbol","functionSchema","input","output","obj","z","object","Object","defineProperty","value","writable","parse","i","Error","schemaIsFunctionSchema","schema","hasOwn","customSchema","validate","custom","createFunctionPointerSchema"],"mappings":";;;;;;AAUA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAAA,MAAMC,GAAAA,GAAMC,MAAEC,MAAAA,CAAO;AACjBJ,IAAAA,KAAAA;AACAC,IAAAA;GACJ,CAAA;AACAI,EAAAA,MAAAA,CAAOC,cAAAA,CAAeJ,KAAKL,iBAAAA,EAAmB;IAAEU,KAAAA,EAAO,IAAA;IAAMC,QAAAA,EAAU;GAAM,CAAA;AAI7EN,EAAAA,GAAAA,CAAIO,KAAAA,GAAQ,CAACC,CAAAA,KAAAA;AACT,IAAA,IAAI,OAAOA,MAAM,UAAA,EAAY;AACzB,MAAA,MAAM,IAAIC,KAAAA,CAAM,CAAA,EAAGD,CAAAA,CAAAA,kBAAAA,CAAqB,CAAA;AAC5C,IAAA;AAGA,IAAA,OAAOA,CAAAA;AACX,EAAA,CAAA;AACA,EAAA,OAAOR,GAAAA;AACX,CAAA,EAxB8B,gBAAA;AA0BvB,IAAMU,sBAAAA,2BACTC,MAAAA,KAAAA;AAEA,EAAA,OAAOR,MAAAA,CAAOS,MAAAA,CAAOD,MAAAA,EAAQhB,iBAAAA,CAAAA;AACjC,CAAA,EAJsC,wBAAA;AAM/B,IAAMkB,+BAAe,MAAA,CAAA,CAAIC,QAAAA,KAC5Bb,KAAAA,CAAEc,MAAAA,CAAUD,QAAAA,CAAAA,EADY,cAAA;AAGrB,IAAME,2BAAAA,mBAA8B,MAAA,CAAA;;EAEvCH,YAAAA;AAFuC,CAAA,EAAA,6BAAA","file":"GR4ZG7N6.cjs","sourcesContent":["import { z } from 'zod';\n\nimport type { FunctionPointer } from '@layerzerolabs/function-pointer';\n\nexport type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T extends []\n ? Output\n : T extends [infer Head, ...infer Tail extends z.ZodType[]]\n ? InferredArray<Tail, [...Output, z.infer<Head>]>\n : never;\n\nconst functionSchemaTag = Symbol('__FUNCTION_SCHEMA_TAG');\n\n// This essentially replicates the functionality of z.function in zod v3\nexport const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodType>({\n input,\n output,\n}: {\n input: Input;\n output: Output;\n}) => {\n const obj = z.object({\n input,\n output,\n });\n Object.defineProperty(obj, functionSchemaTag, { value: true, writable: false });\n // We don't expect the function to actually be an object with an input field and an output field\n // so we override the parse function. We can't actually parse functions since input and output\n // types are lost at runtime, but we can check the runtime type of the object\n obj.parse = (i) => {\n if (typeof i !== 'function') {\n throw new Error(`${i} is not a function`);\n }\n // The return type here just has to match the inference of z.object,\n // the actual inference of the schema will be the z.ZodType custom\n return i as any;\n };\n return obj as unknown as z.ZodType<(...args: z.infer<Input>) => z.infer<Output>>;\n};\n\nexport const schemaIsFunctionSchema = (\n schema: z.ZodType,\n): schema is ReturnType<typeof functionSchema> => {\n return Object.hasOwn(schema, functionSchemaTag);\n};\n\nexport const customSchema = <T>(validate?: (data: any) => T) =>\n z.custom<T>(validate) as z.ZodType<T>;\n\nexport const createFunctionPointerSchema = <T extends FunctionPointer>() =>\n // FIXME this can be a real schema\n customSchema<T>();\n\nexport type BuildZodObject<T extends object> = z.ZodObject<\n {\n [K in keyof T]: z.ZodType<T[K]>;\n },\n z.core.$strip\n>;\n"]}
|
|
@@ -30,5 +30,5 @@ var createFunctionPointerSchema = /* @__PURE__ */ __name(() => (
|
|
|
30
30
|
), "createFunctionPointerSchema");
|
|
31
31
|
|
|
32
32
|
export { __name, createFunctionPointerSchema, customSchema, functionSchema, schemaIsFunctionSchema };
|
|
33
|
-
//# sourceMappingURL=
|
|
34
|
-
//# sourceMappingURL=
|
|
33
|
+
//# sourceMappingURL=R6AQXXPU.js.map
|
|
34
|
+
//# sourceMappingURL=R6AQXXPU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema.ts"],"names":["functionSchemaTag","Symbol","functionSchema","input","output","obj","z","object","Object","defineProperty","value","writable","parse","i","Error","schemaIsFunctionSchema","schema","hasOwn","customSchema","validate","custom","createFunctionPointerSchema"],"mappings":";;;;AAUA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAAA,MAAMC,GAAAA,GAAMC,EAAEC,MAAAA,CAAO;AACjBJ,IAAAA,KAAAA;AACAC,IAAAA;GACJ,CAAA;AACAI,EAAAA,MAAAA,CAAOC,cAAAA,CAAeJ,KAAKL,iBAAAA,EAAmB;IAAEU,KAAAA,EAAO,IAAA;IAAMC,QAAAA,EAAU;GAAM,CAAA;AAI7EN,EAAAA,GAAAA,CAAIO,KAAAA,GAAQ,CAACC,CAAAA,KAAAA;AACT,IAAA,IAAI,OAAOA,MAAM,UAAA,EAAY;AACzB,MAAA,MAAM,IAAIC,KAAAA,CAAM,CAAA,EAAGD,CAAAA,CAAAA,kBAAAA,CAAqB,CAAA;AAC5C,IAAA;AAGA,IAAA,OAAOA,CAAAA;AACX,EAAA,CAAA;AACA,EAAA,OAAOR,GAAAA;AACX,CAAA,EAxB8B,gBAAA;AA0BvB,IAAMU,sBAAAA,2BACTC,MAAAA,KAAAA;AAEA,EAAA,OAAOR,MAAAA,CAAOS,MAAAA,CAAOD,MAAAA,EAAQhB,iBAAAA,CAAAA;AACjC,CAAA,EAJsC,wBAAA;AAM/B,IAAMkB,+BAAe,MAAA,CAAA,CAAIC,QAAAA,KAC5Bb,CAAAA,CAAEc,MAAAA,CAAUD,QAAAA,CAAAA,EADY,cAAA;AAGrB,IAAME,2BAAAA,mBAA8B,MAAA,CAAA;;EAEvCH,YAAAA;AAFuC,CAAA,EAAA,6BAAA","file":"R6AQXXPU.js","sourcesContent":["import { z } from 'zod';\n\nimport type { FunctionPointer } from '@layerzerolabs/function-pointer';\n\nexport type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T extends []\n ? Output\n : T extends [infer Head, ...infer Tail extends z.ZodType[]]\n ? InferredArray<Tail, [...Output, z.infer<Head>]>\n : never;\n\nconst functionSchemaTag = Symbol('__FUNCTION_SCHEMA_TAG');\n\n// This essentially replicates the functionality of z.function in zod v3\nexport const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodType>({\n input,\n output,\n}: {\n input: Input;\n output: Output;\n}) => {\n const obj = z.object({\n input,\n output,\n });\n Object.defineProperty(obj, functionSchemaTag, { value: true, writable: false });\n // We don't expect the function to actually be an object with an input field and an output field\n // so we override the parse function. We can't actually parse functions since input and output\n // types are lost at runtime, but we can check the runtime type of the object\n obj.parse = (i) => {\n if (typeof i !== 'function') {\n throw new Error(`${i} is not a function`);\n }\n // The return type here just has to match the inference of z.object,\n // the actual inference of the schema will be the z.ZodType custom\n return i as any;\n };\n return obj as unknown as z.ZodType<(...args: z.infer<Input>) => z.infer<Output>>;\n};\n\nexport const schemaIsFunctionSchema = (\n schema: z.ZodType,\n): schema is ReturnType<typeof functionSchema> => {\n return Object.hasOwn(schema, functionSchemaTag);\n};\n\nexport const customSchema = <T>(validate?: (data: any) => T) =>\n z.custom<T>(validate) as z.ZodType<T>;\n\nexport const createFunctionPointerSchema = <T extends FunctionPointer>() =>\n // FIXME this can be a real schema\n customSchema<T>();\n\nexport type BuildZodObject<T extends object> = z.ZodObject<\n {\n [K in keyof T]: z.ZodType<T[K]>;\n },\n z.core.$strip\n>;\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var GR4ZG7N6_cjs = require('./GR4ZG7N6.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
6
|
var RESOLVING = Symbol("mapOnSchema/resolving");
|
|
@@ -18,7 +18,7 @@ function mapOnSchema(schema, fn) {
|
|
|
18
18
|
results.set(s, result);
|
|
19
19
|
return result;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
GR4ZG7N6_cjs.__name(mapElement, "mapElement");
|
|
22
22
|
function mapInner() {
|
|
23
23
|
if (schema instanceof zod.z.ZodObject) {
|
|
24
24
|
const newShape = {};
|
|
@@ -69,7 +69,7 @@ function mapOnSchema(schema, fn) {
|
|
|
69
69
|
return new zod.z.ZodLazy({
|
|
70
70
|
...schema.def,
|
|
71
71
|
// NB: This leaks `fn` into the schema, but there is no other way to support recursive schemas
|
|
72
|
-
getter: /* @__PURE__ */
|
|
72
|
+
getter: /* @__PURE__ */ GR4ZG7N6_cjs.__name(() => mapElement(schema.def.getter()), "getter")
|
|
73
73
|
});
|
|
74
74
|
} else if (schema instanceof zod.z.ZodPromise) {
|
|
75
75
|
return new zod.z.ZodPromise({
|
|
@@ -108,34 +108,34 @@ function mapOnSchema(schema, fn) {
|
|
|
108
108
|
return schema;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
GR4ZG7N6_cjs.__name(mapInner, "mapInner");
|
|
112
112
|
return fn(mapInner());
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
GR4ZG7N6_cjs.__name(mapOnSchema, "mapOnSchema");
|
|
115
115
|
function zodDeepPartial(schema) {
|
|
116
116
|
return mapOnSchema(schema, (s) => s?.optional?.());
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
GR4ZG7N6_cjs.__name(zodDeepPartial, "zodDeepPartial");
|
|
119
119
|
function zodDeepRequired(schema) {
|
|
120
120
|
return mapOnSchema(schema, (s) => s?.nonoptional?.());
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
GR4ZG7N6_cjs.__name(zodDeepRequired, "zodDeepRequired");
|
|
123
123
|
|
|
124
124
|
Object.defineProperty(exports, "createFunctionPointerSchema", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return GR4ZG7N6_cjs.createFunctionPointerSchema; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "customSchema", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return GR4ZG7N6_cjs.customSchema; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "functionSchema", {
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
134
|
+
get: function () { return GR4ZG7N6_cjs.functionSchema; }
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "schemaIsFunctionSchema", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return GR4ZG7N6_cjs.schemaIsFunctionSchema; }
|
|
139
139
|
});
|
|
140
140
|
exports.mapOnSchema = mapOnSchema;
|
|
141
141
|
exports.zodDeepPartial = zodDeepPartial;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __name } from './
|
|
2
|
-
export { createFunctionPointerSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './
|
|
1
|
+
import { __name } from './R6AQXXPU.js';
|
|
2
|
+
export { createFunctionPointerSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './R6AQXXPU.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
var RESOLVING = Symbol("mapOnSchema/resolving");
|
package/dist/schema.cjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var GR4ZG7N6_cjs = require('./GR4ZG7N6.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "createFunctionPointerSchema", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return GR4ZG7N6_cjs.createFunctionPointerSchema; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "customSchema", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return GR4ZG7N6_cjs.customSchema; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "functionSchema", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return GR4ZG7N6_cjs.functionSchema; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "schemaIsFunctionSchema", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return GR4ZG7N6_cjs.schemaIsFunctionSchema; }
|
|
22
22
|
});
|
|
23
23
|
//# sourceMappingURL=schema.cjs.map
|
|
24
24
|
//# sourceMappingURL=schema.cjs.map
|
package/dist/schema.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createFunctionPointerSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './
|
|
1
|
+
export { createFunctionPointerSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './R6AQXXPU.js';
|
|
2
2
|
//# sourceMappingURL=schema.js.map
|
|
3
3
|
//# sourceMappingURL=schema.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/zod-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.48",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"zod": "4.3.5",
|
|
18
|
-
"@layerzerolabs/function-pointer": "0.2.
|
|
18
|
+
"@layerzerolabs/function-pointer": "0.2.48"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsup": "^8.4.0",
|
|
22
|
-
"@layerzerolabs/
|
|
23
|
-
"@layerzerolabs/
|
|
22
|
+
"@layerzerolabs/tsup-configuration": "0.2.48",
|
|
23
|
+
"@layerzerolabs/typescript-configuration": "0.2.48"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "restricted",
|
package/src/schema.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T
|
|
|
10
10
|
|
|
11
11
|
const functionSchemaTag = Symbol('__FUNCTION_SCHEMA_TAG');
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// This essentially replicates the functionality of z.function in zod v3
|
|
14
14
|
export const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodType>({
|
|
15
15
|
input,
|
|
16
16
|
output,
|
|
@@ -23,15 +23,15 @@ export const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodTyp
|
|
|
23
23
|
output,
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(obj, functionSchemaTag, { value: true, writable: false });
|
|
26
|
-
//
|
|
27
|
-
//so we override the parse function.
|
|
28
|
-
//types are lost at runtime, but we can check the runtime type of the object
|
|
26
|
+
// We don't expect the function to actually be an object with an input field and an output field
|
|
27
|
+
// so we override the parse function. We can't actually parse functions since input and output
|
|
28
|
+
// types are lost at runtime, but we can check the runtime type of the object
|
|
29
29
|
obj.parse = (i) => {
|
|
30
30
|
if (typeof i !== 'function') {
|
|
31
31
|
throw new Error(`${i} is not a function`);
|
|
32
32
|
}
|
|
33
|
-
//
|
|
34
|
-
//the actual inference of the schema will be the z.ZodType custom
|
|
33
|
+
// The return type here just has to match the inference of z.object,
|
|
34
|
+
// the actual inference of the schema will be the z.ZodType custom
|
|
35
35
|
return i as any;
|
|
36
36
|
};
|
|
37
37
|
return obj as unknown as z.ZodType<(...args: z.infer<Input>) => z.infer<Output>>;
|
package/dist/DWFVFIJK.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema.ts"],"names":["functionSchemaTag","Symbol","functionSchema","input","output","obj","z","object","Object","defineProperty","value","writable","parse","i","Error","schemaIsFunctionSchema","schema","hasOwn","customSchema","validate","custom","createFunctionPointerSchema"],"mappings":";;;;AAUA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAAA,MAAMC,GAAAA,GAAMC,EAAEC,MAAAA,CAAO;AACjBJ,IAAAA,KAAAA;AACAC,IAAAA;GACJ,CAAA;AACAI,EAAAA,MAAAA,CAAOC,cAAAA,CAAeJ,KAAKL,iBAAAA,EAAmB;IAAEU,KAAAA,EAAO,IAAA;IAAMC,QAAAA,EAAU;GAAM,CAAA;AAI7EN,EAAAA,GAAAA,CAAIO,KAAAA,GAAQ,CAACC,CAAAA,KAAAA;AACT,IAAA,IAAI,OAAOA,MAAM,UAAA,EAAY;AACzB,MAAA,MAAM,IAAIC,KAAAA,CAAM,CAAA,EAAGD,CAAAA,CAAAA,kBAAAA,CAAqB,CAAA;AAC5C,IAAA;AAGA,IAAA,OAAOA,CAAAA;AACX,EAAA,CAAA;AACA,EAAA,OAAOR,GAAAA;AACX,CAAA,EAxB8B,gBAAA;AA0BvB,IAAMU,sBAAAA,2BACTC,MAAAA,KAAAA;AAEA,EAAA,OAAOR,MAAAA,CAAOS,MAAAA,CAAOD,MAAAA,EAAQhB,iBAAAA,CAAAA;AACjC,CAAA,EAJsC,wBAAA;AAM/B,IAAMkB,+BAAe,MAAA,CAAA,CAAIC,QAAAA,KAC5Bb,CAAAA,CAAEc,MAAAA,CAAUD,QAAAA,CAAAA,EADY,cAAA;AAGrB,IAAME,2BAAAA,mBAA8B,MAAA,CAAA;;EAEvCH,YAAAA;AAFuC,CAAA,EAAA,6BAAA","file":"DWFVFIJK.js","sourcesContent":["import { z } from 'zod';\n\nimport type { FunctionPointer } from '@layerzerolabs/function-pointer';\n\nexport type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T extends []\n ? Output\n : T extends [infer Head, ...infer Tail extends z.ZodType[]]\n ? InferredArray<Tail, [...Output, z.infer<Head>]>\n : never;\n\nconst functionSchemaTag = Symbol('__FUNCTION_SCHEMA_TAG');\n\n//this essentially replicates the functionality of z.function in zod v3\nexport const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodType>({\n input,\n output,\n}: {\n input: Input;\n output: Output;\n}) => {\n const obj = z.object({\n input,\n output,\n });\n Object.defineProperty(obj, functionSchemaTag, { value: true, writable: false });\n //we don't expect the function to actually be an object with an input field and an output field\n //so we override the parse function. we can't actually parse functions since input and output\n //types are lost at runtime, but we can check the runtime type of the object\n obj.parse = (i) => {\n if (typeof i !== 'function') {\n throw new Error(`${i} is not a function`);\n }\n //the return type here just has to match the inference of z.object,\n //the actual inference of the schema will be the z.ZodType custom\n return i as any;\n };\n return obj as unknown as z.ZodType<(...args: z.infer<Input>) => z.infer<Output>>;\n};\n\nexport const schemaIsFunctionSchema = (\n schema: z.ZodType,\n): schema is ReturnType<typeof functionSchema> => {\n return Object.hasOwn(schema, functionSchemaTag);\n};\n\nexport const customSchema = <T>(validate?: (data: any) => T) =>\n z.custom<T>(validate) as z.ZodType<T>;\n\nexport const createFunctionPointerSchema = <T extends FunctionPointer>() =>\n // FIXME this can be a real schema\n customSchema<T>();\n\nexport type BuildZodObject<T extends object> = z.ZodObject<\n {\n [K in keyof T]: z.ZodType<T[K]>;\n },\n z.core.$strip\n>;\n"]}
|
package/dist/EK3R2JUO.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schema.ts"],"names":["functionSchemaTag","Symbol","functionSchema","input","output","obj","z","object","Object","defineProperty","value","writable","parse","i","Error","schemaIsFunctionSchema","schema","hasOwn","customSchema","validate","custom","createFunctionPointerSchema"],"mappings":";;;;;;AAUA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAAA,MAAMC,GAAAA,GAAMC,MAAEC,MAAAA,CAAO;AACjBJ,IAAAA,KAAAA;AACAC,IAAAA;GACJ,CAAA;AACAI,EAAAA,MAAAA,CAAOC,cAAAA,CAAeJ,KAAKL,iBAAAA,EAAmB;IAAEU,KAAAA,EAAO,IAAA;IAAMC,QAAAA,EAAU;GAAM,CAAA;AAI7EN,EAAAA,GAAAA,CAAIO,KAAAA,GAAQ,CAACC,CAAAA,KAAAA;AACT,IAAA,IAAI,OAAOA,MAAM,UAAA,EAAY;AACzB,MAAA,MAAM,IAAIC,KAAAA,CAAM,CAAA,EAAGD,CAAAA,CAAAA,kBAAAA,CAAqB,CAAA;AAC5C,IAAA;AAGA,IAAA,OAAOA,CAAAA;AACX,EAAA,CAAA;AACA,EAAA,OAAOR,GAAAA;AACX,CAAA,EAxB8B,gBAAA;AA0BvB,IAAMU,sBAAAA,2BACTC,MAAAA,KAAAA;AAEA,EAAA,OAAOR,MAAAA,CAAOS,MAAAA,CAAOD,MAAAA,EAAQhB,iBAAAA,CAAAA;AACjC,CAAA,EAJsC,wBAAA;AAM/B,IAAMkB,+BAAe,MAAA,CAAA,CAAIC,QAAAA,KAC5Bb,KAAAA,CAAEc,MAAAA,CAAUD,QAAAA,CAAAA,EADY,cAAA;AAGrB,IAAME,2BAAAA,mBAA8B,MAAA,CAAA;;EAEvCH,YAAAA;AAFuC,CAAA,EAAA,6BAAA","file":"EK3R2JUO.cjs","sourcesContent":["import { z } from 'zod';\n\nimport type { FunctionPointer } from '@layerzerolabs/function-pointer';\n\nexport type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T extends []\n ? Output\n : T extends [infer Head, ...infer Tail extends z.ZodType[]]\n ? InferredArray<Tail, [...Output, z.infer<Head>]>\n : never;\n\nconst functionSchemaTag = Symbol('__FUNCTION_SCHEMA_TAG');\n\n//this essentially replicates the functionality of z.function in zod v3\nexport const functionSchema = <Input extends z.ZodTuple, Output extends z.ZodType>({\n input,\n output,\n}: {\n input: Input;\n output: Output;\n}) => {\n const obj = z.object({\n input,\n output,\n });\n Object.defineProperty(obj, functionSchemaTag, { value: true, writable: false });\n //we don't expect the function to actually be an object with an input field and an output field\n //so we override the parse function. we can't actually parse functions since input and output\n //types are lost at runtime, but we can check the runtime type of the object\n obj.parse = (i) => {\n if (typeof i !== 'function') {\n throw new Error(`${i} is not a function`);\n }\n //the return type here just has to match the inference of z.object,\n //the actual inference of the schema will be the z.ZodType custom\n return i as any;\n };\n return obj as unknown as z.ZodType<(...args: z.infer<Input>) => z.infer<Output>>;\n};\n\nexport const schemaIsFunctionSchema = (\n schema: z.ZodType,\n): schema is ReturnType<typeof functionSchema> => {\n return Object.hasOwn(schema, functionSchemaTag);\n};\n\nexport const customSchema = <T>(validate?: (data: any) => T) =>\n z.custom<T>(validate) as z.ZodType<T>;\n\nexport const createFunctionPointerSchema = <T extends FunctionPointer>() =>\n // FIXME this can be a real schema\n customSchema<T>();\n\nexport type BuildZodObject<T extends object> = z.ZodObject<\n {\n [K in keyof T]: z.ZodType<T[K]>;\n },\n z.core.$strip\n>;\n"]}
|