@layerzerolabs/zod-utils 0.2.6 → 0.2.8
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 +9 -9
- package/.turbo/turbo-lint.log +4 -0
- package/dist/{WBHGMCS2.cjs → BJTH56SG.cjs} +2 -2
- package/dist/BJTH56SG.cjs.map +1 -0
- package/dist/{25UQQMRA.js → MOA3PLKL.js} +2 -2
- package/dist/MOA3PLKL.js.map +1 -0
- package/dist/index.cjs +15 -15
- package/dist/index.js +2 -2
- package/dist/schema.cjs +9 -9
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -1
- package/package.json +4 -5
- package/src/schema.ts +1 -1
- package/dist/25UQQMRA.js.map +0 -1
- package/dist/WBHGMCS2.cjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,23 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts, src/schema.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/zod-utils/tsup.config.ts
|
|
9
9
|
[34mCLI[39m Target: ES2023
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[32m4.21 KB[39m
|
|
14
13
|
[32mESM[39m [1mdist/schema.js [22m[32m332.00 B[39m
|
|
15
|
-
[32mESM[39m [1mdist/
|
|
16
|
-
[32mESM[39m [1mdist/index.js
|
|
17
|
-
[32mESM[39m [1mdist/25UQQMRA.js.map [22m[32m5.92 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/MOA3PLKL.js [22m[32m1.95 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/index.js [22m[32m4.21 KB[39m
|
|
18
16
|
[32mESM[39m [1mdist/schema.js.map [22m[32m70.00 B[39m
|
|
19
|
-
[32mESM[39m
|
|
17
|
+
[32mESM[39m [1mdist/MOA3PLKL.js.map [22m[32m5.93 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m11.03 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 116ms
|
|
20
20
|
[32mCJS[39m [1mdist/schema.cjs [22m[32m1.38 KB[39m
|
|
21
|
-
[32mCJS[39m [1mdist/WBHGMCS2.cjs [22m[32m2.29 KB[39m
|
|
22
21
|
[32mCJS[39m [1mdist/index.cjs [22m[32m5.45 KB[39m
|
|
23
|
-
[32mCJS[39m [1mdist/
|
|
22
|
+
[32mCJS[39m [1mdist/BJTH56SG.cjs [22m[32m2.29 KB[39m
|
|
24
23
|
[32mCJS[39m [1mdist/index.cjs.map [22m[32m11.04 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/BJTH56SG.cjs.map [22m[32m5.93 KB[39m
|
|
25
25
|
[32mCJS[39m [1mdist/schema.cjs.map [22m[32m71.00 B[39m
|
|
26
|
-
[32mCJS[39m ⚡️ Build success in
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 117ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -2,3 +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:26707) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1766521042476 is not specified and it doesn't parse as CommonJS.
|
|
6
|
+
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
|
+
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
|
+
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
@@ -50,5 +50,5 @@ exports.createFunctionPointerWithArgsSchema = createFunctionPointerWithArgsSchem
|
|
|
50
50
|
exports.customSchema = customSchema;
|
|
51
51
|
exports.functionSchema = functionSchema;
|
|
52
52
|
exports.schemaIsFunctionSchema = schemaIsFunctionSchema;
|
|
53
|
-
//# sourceMappingURL=
|
|
54
|
-
//# sourceMappingURL=
|
|
53
|
+
//# sourceMappingURL=BJTH56SG.cjs.map
|
|
54
|
+
//# sourceMappingURL=BJTH56SG.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","pointer","createFunctionPointerWithArgsSchema","shape","args","createExtendableFunctionPointerWithCurriedArgsSchema","array","any","bindFunctionPointerArgs","params","bindPartialFunctionPointerArgs"],"mappings":";;;;;;AAwBA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAAA,MAAMC,GAAAA,GAAMC,KAAEC,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,CAA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n\nimport type {\n FunctionPointer,\n UnderlyingMethodOfFunctionPointer,\n} from '@layerzerolabs/function-pointer';\n\ntype IsPromise<T> =\n T extends z.ZodOptional<infer I>\n ? IsPromise<I>\n : T extends z.ZodDefault<infer I>\n ? IsPromise<I>\n : T extends z.ZodNullable<infer I>\n ? IsPromise<I>\n : T extends z.ZodPromise<any>\n ? true\n : false;\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<\n (\n ...args: z.infer<Input>\n //z.ZodPromise<T> infers as T, not Promise<T>\n ) => IsPromise<Output> extends true ? Promise<z.infer<Output>> : z.infer<Output>\n >;\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 = FunctionPointer>() =>\n z.object({\n // FIXME this can be a real schema\n pointer: customSchema<T>(),\n });\n\nexport const createFunctionPointerWithArgsSchema = <\n T extends FunctionPointer = FunctionPointer,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<T>().shape.pointer,\n args: customSchema<Parameters<UnderlyingMethodOfFunctionPointer<T>>>(),\n });\n\nexport type ConstrainedGenericFunctionPointer<_ReturnType extends Promise<any>> = FunctionPointer<\n ReturnType<<T extends (...args: any[]) => _ReturnType>() => T>\n>;\n\n// This type doesn't work correctly\nexport const createExtendableFunctionPointerWithCurriedArgsSchema = <\n _BaseArgs extends any[],\n _ReturnType extends Promise<any>,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<\n // FIXME type args correctly\n ConstrainedGenericFunctionPointer<_ReturnType>\n >().shape.pointer,\n args: z.array(z.any()),\n });\n\nexport const bindFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n}) => params;\n\nexport const bindPartialFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Partial<Parameters<UnderlyingMethodOfFunctionPointer<T>>>;\n}) => params;\n\nexport type FunctionPointerWithArgs<T extends FunctionPointer> = {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n};\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"]}
|
|
@@ -40,5 +40,5 @@ var bindFunctionPointerArgs = /* @__PURE__ */ __name((params) => params, "bindFu
|
|
|
40
40
|
var bindPartialFunctionPointerArgs = /* @__PURE__ */ __name((params) => params, "bindPartialFunctionPointerArgs");
|
|
41
41
|
|
|
42
42
|
export { __name, bindFunctionPointerArgs, bindPartialFunctionPointerArgs, createExtendableFunctionPointerWithCurriedArgsSchema, createFunctionPointerSchema, createFunctionPointerWithArgsSchema, customSchema, functionSchema, schemaIsFunctionSchema };
|
|
43
|
-
//# sourceMappingURL=
|
|
44
|
-
//# sourceMappingURL=
|
|
43
|
+
//# sourceMappingURL=MOA3PLKL.js.map
|
|
44
|
+
//# sourceMappingURL=MOA3PLKL.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","pointer","createFunctionPointerWithArgsSchema","shape","args","createExtendableFunctionPointerWithCurriedArgsSchema","array","any","bindFunctionPointerArgs","params","bindPartialFunctionPointerArgs"],"mappings":";;;;AAwBA,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;AAMX,CAAA,EA7B8B,gBAAA;AA+BvB,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,MACvCf,CAAAA,CAAEC,MAAAA,CAAO;;AAELe,EAAAA,OAAAA,EAASJ,YAAAA;AACb,CAAA,CAAA,EAJuC,6BAAA;AAMpC,IAAMK,mCAAAA,mBAAsC,MAAA,CAAA,MAG/CjB,CAAAA,CAAEC,MAAAA,CAAO;EACLe,OAAAA,EAASD,2BAAAA,GAAiCG,KAAAA,CAAMF,OAAAA;AAChDG,EAAAA,IAAAA,EAAMP,YAAAA;AACV,CAAA,CAAA,EAN+C,qCAAA;AAa5C,IAAMQ,oDAAAA,mBAAuD,MAAA,CAAA,MAIhEpB,CAAAA,CAAEC,MAAAA,CAAO;EACLe,OAAAA,EAASD,2BAAAA,GAGLG,KAAAA,CAAMF,OAAAA;AACVG,EAAAA,IAAAA,EAAMnB,CAAAA,CAAEqB,KAAAA,CAAMrB,CAAAA,CAAEsB,GAAAA,EAAG;AACvB,CAAA,CAAA,EAVgE,sDAAA;AAY7D,IAAMC,uBAAAA,mBAA0B,MAAA,CAAA,CAA4BC,MAAAA,KAG7DA,MAAAA,EAHiC,yBAAA;AAKhC,IAAMC,8BAAAA,mBAAiC,MAAA,CAAA,CAA4BD,MAAAA,KAGpEA,MAAAA,EAHwC,gCAAA","file":"MOA3PLKL.js","sourcesContent":["import { z } from 'zod/v4';\n\nimport type {\n FunctionPointer,\n UnderlyingMethodOfFunctionPointer,\n} from '@layerzerolabs/function-pointer';\n\ntype IsPromise<T> =\n T extends z.ZodOptional<infer I>\n ? IsPromise<I>\n : T extends z.ZodDefault<infer I>\n ? IsPromise<I>\n : T extends z.ZodNullable<infer I>\n ? IsPromise<I>\n : T extends z.ZodPromise<any>\n ? true\n : false;\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<\n (\n ...args: z.infer<Input>\n //z.ZodPromise<T> infers as T, not Promise<T>\n ) => IsPromise<Output> extends true ? Promise<z.infer<Output>> : z.infer<Output>\n >;\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 = FunctionPointer>() =>\n z.object({\n // FIXME this can be a real schema\n pointer: customSchema<T>(),\n });\n\nexport const createFunctionPointerWithArgsSchema = <\n T extends FunctionPointer = FunctionPointer,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<T>().shape.pointer,\n args: customSchema<Parameters<UnderlyingMethodOfFunctionPointer<T>>>(),\n });\n\nexport type ConstrainedGenericFunctionPointer<_ReturnType extends Promise<any>> = FunctionPointer<\n ReturnType<<T extends (...args: any[]) => _ReturnType>() => T>\n>;\n\n// This type doesn't work correctly\nexport const createExtendableFunctionPointerWithCurriedArgsSchema = <\n _BaseArgs extends any[],\n _ReturnType extends Promise<any>,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<\n // FIXME type args correctly\n ConstrainedGenericFunctionPointer<_ReturnType>\n >().shape.pointer,\n args: z.array(z.any()),\n });\n\nexport const bindFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n}) => params;\n\nexport const bindPartialFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Partial<Parameters<UnderlyingMethodOfFunctionPointer<T>>>;\n}) => params;\n\nexport type FunctionPointerWithArgs<T extends FunctionPointer> = {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n};\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 BJTH56SG_cjs = require('./BJTH56SG.cjs');
|
|
4
4
|
var v4 = require('zod/v4');
|
|
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
|
+
BJTH56SG_cjs.__name(mapElement, "mapElement");
|
|
22
22
|
function mapInner() {
|
|
23
23
|
if (schema instanceof v4.z.ZodObject) {
|
|
24
24
|
const newShape = {};
|
|
@@ -69,7 +69,7 @@ function mapOnSchema(schema, fn) {
|
|
|
69
69
|
return new v4.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__ */ BJTH56SG_cjs.__name(() => mapElement(schema.def.getter()), "getter")
|
|
73
73
|
});
|
|
74
74
|
} else if (schema instanceof v4.z.ZodPromise) {
|
|
75
75
|
return new v4.z.ZodPromise({
|
|
@@ -108,50 +108,50 @@ function mapOnSchema(schema, fn) {
|
|
|
108
108
|
return schema;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
BJTH56SG_cjs.__name(mapInner, "mapInner");
|
|
112
112
|
return fn(mapInner());
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
BJTH56SG_cjs.__name(mapOnSchema, "mapOnSchema");
|
|
115
115
|
function zodDeepPartial(schema) {
|
|
116
116
|
return mapOnSchema(schema, (s) => s?.optional?.());
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
BJTH56SG_cjs.__name(zodDeepPartial, "zodDeepPartial");
|
|
119
119
|
function zodDeepRequired(schema) {
|
|
120
120
|
return mapOnSchema(schema, (s) => s?.nonoptional?.());
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
BJTH56SG_cjs.__name(zodDeepRequired, "zodDeepRequired");
|
|
123
123
|
|
|
124
124
|
Object.defineProperty(exports, "bindFunctionPointerArgs", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return BJTH56SG_cjs.bindFunctionPointerArgs; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "bindPartialFunctionPointerArgs", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return BJTH56SG_cjs.bindPartialFunctionPointerArgs; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "createExtendableFunctionPointerWithCurriedArgsSchema", {
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: function () { return
|
|
134
|
+
get: function () { return BJTH56SG_cjs.createExtendableFunctionPointerWithCurriedArgsSchema; }
|
|
135
135
|
});
|
|
136
136
|
Object.defineProperty(exports, "createFunctionPointerSchema", {
|
|
137
137
|
enumerable: true,
|
|
138
|
-
get: function () { return
|
|
138
|
+
get: function () { return BJTH56SG_cjs.createFunctionPointerSchema; }
|
|
139
139
|
});
|
|
140
140
|
Object.defineProperty(exports, "createFunctionPointerWithArgsSchema", {
|
|
141
141
|
enumerable: true,
|
|
142
|
-
get: function () { return
|
|
142
|
+
get: function () { return BJTH56SG_cjs.createFunctionPointerWithArgsSchema; }
|
|
143
143
|
});
|
|
144
144
|
Object.defineProperty(exports, "customSchema", {
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: function () { return
|
|
146
|
+
get: function () { return BJTH56SG_cjs.customSchema; }
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(exports, "functionSchema", {
|
|
149
149
|
enumerable: true,
|
|
150
|
-
get: function () { return
|
|
150
|
+
get: function () { return BJTH56SG_cjs.functionSchema; }
|
|
151
151
|
});
|
|
152
152
|
Object.defineProperty(exports, "schemaIsFunctionSchema", {
|
|
153
153
|
enumerable: true,
|
|
154
|
-
get: function () { return
|
|
154
|
+
get: function () { return BJTH56SG_cjs.schemaIsFunctionSchema; }
|
|
155
155
|
});
|
|
156
156
|
exports.mapOnSchema = mapOnSchema;
|
|
157
157
|
exports.zodDeepPartial = zodDeepPartial;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { __name } from './
|
|
2
|
-
export { bindFunctionPointerArgs, bindPartialFunctionPointerArgs, createExtendableFunctionPointerWithCurriedArgsSchema, createFunctionPointerSchema, createFunctionPointerWithArgsSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './
|
|
1
|
+
import { __name } from './MOA3PLKL.js';
|
|
2
|
+
export { bindFunctionPointerArgs, bindPartialFunctionPointerArgs, createExtendableFunctionPointerWithCurriedArgsSchema, createFunctionPointerSchema, createFunctionPointerWithArgsSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './MOA3PLKL.js';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
5
|
var RESOLVING = Symbol("mapOnSchema/resolving");
|
package/dist/schema.cjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var BJTH56SG_cjs = require('./BJTH56SG.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "bindFunctionPointerArgs", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return BJTH56SG_cjs.bindFunctionPointerArgs; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "bindPartialFunctionPointerArgs", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return BJTH56SG_cjs.bindPartialFunctionPointerArgs; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "createExtendableFunctionPointerWithCurriedArgsSchema", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return BJTH56SG_cjs.createExtendableFunctionPointerWithCurriedArgsSchema; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "createFunctionPointerSchema", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return BJTH56SG_cjs.createFunctionPointerSchema; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "createFunctionPointerWithArgsSchema", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return BJTH56SG_cjs.createFunctionPointerWithArgsSchema; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "customSchema", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return BJTH56SG_cjs.customSchema; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "functionSchema", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return BJTH56SG_cjs.functionSchema; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "schemaIsFunctionSchema", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return BJTH56SG_cjs.schemaIsFunctionSchema; }
|
|
38
38
|
});
|
|
39
39
|
//# sourceMappingURL=schema.cjs.map
|
|
40
40
|
//# sourceMappingURL=schema.cjs.map
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import type { FunctionPointer, UnderlyingMethodOfFunctionPointer } from '@layerzerolabs/
|
|
2
|
+
import type { FunctionPointer, UnderlyingMethodOfFunctionPointer } from '@layerzerolabs/function-pointer';
|
|
3
3
|
type IsPromise<T> = T extends z.ZodOptional<infer I> ? IsPromise<I> : T extends z.ZodDefault<infer I> ? IsPromise<I> : T extends z.ZodNullable<infer I> ? IsPromise<I> : T extends z.ZodPromise<any> ? true : false;
|
|
4
4
|
export type InferredArray<T extends z.ZodType[], Output extends any[] = []> = T extends [] ? Output : T extends [infer Head, ...infer Tail extends z.ZodType[]] ? InferredArray<Tail, [...Output, z.infer<Head>]> : never;
|
|
5
5
|
export declare const functionSchema: <Input extends z.ZodTuple, Output extends z.ZodType>({ input, output, }: {
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,KAAK,EACR,eAAe,EACf,iCAAiC,EACpC,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,KAAK,EACR,eAAe,EACf,iCAAiC,EACpC,MAAM,iCAAiC,CAAC;AAEzC,KAAK,SAAS,CAAC,CAAC,IACZ,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CA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AC,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,SAAS,CACtD;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,EACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAChB,CAAC"}
|
package/dist/schema.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { bindFunctionPointerArgs, bindPartialFunctionPointerArgs, createExtendableFunctionPointerWithCurriedArgsSchema, createFunctionPointerSchema, createFunctionPointerWithArgsSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './
|
|
1
|
+
export { bindFunctionPointerArgs, bindPartialFunctionPointerArgs, createExtendableFunctionPointerWithCurriedArgsSchema, createFunctionPointerSchema, createFunctionPointerWithArgsSchema, customSchema, functionSchema, schemaIsFunctionSchema } from './MOA3PLKL.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.8",
|
|
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": "3.25.56",
|
|
18
|
-
"@layerzerolabs/
|
|
18
|
+
"@layerzerolabs/function-pointer": "0.2.8"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsup": "^8.4.0",
|
|
22
|
-
"@layerzerolabs/
|
|
23
|
-
"@layerzerolabs/
|
|
22
|
+
"@layerzerolabs/tsup-configuration": "0.2.8",
|
|
23
|
+
"@layerzerolabs/typescript-configuration": "0.2.8"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "restricted",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsup",
|
|
31
|
-
"clean": "rm -rf ./node_modules .turbo ./dist",
|
|
32
31
|
"lint": "eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)"
|
|
33
32
|
}
|
|
34
33
|
}
|
package/src/schema.ts
CHANGED
package/dist/25UQQMRA.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","pointer","createFunctionPointerWithArgsSchema","shape","args","createExtendableFunctionPointerWithCurriedArgsSchema","array","any","bindFunctionPointerArgs","params","bindPartialFunctionPointerArgs"],"mappings":";;;;AAwBA,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,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layerzerolabs/common-utils';\n\ntype IsPromise<T> =\n T extends z.ZodOptional<infer I>\n ? IsPromise<I>\n : T extends z.ZodDefault<infer I>\n ? IsPromise<I>\n : T extends z.ZodNullable<infer I>\n ? IsPromise<I>\n : T extends z.ZodPromise<any>\n ? true\n : false;\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<\n (\n ...args: z.infer<Input>\n //z.ZodPromise<T> infers as T, not Promise<T>\n ) => IsPromise<Output> extends true ? Promise<z.infer<Output>> : z.infer<Output>\n >;\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 = FunctionPointer>() =>\n z.object({\n // FIXME this can be a real schema\n pointer: customSchema<T>(),\n });\n\nexport const createFunctionPointerWithArgsSchema = <\n T extends FunctionPointer = FunctionPointer,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<T>().shape.pointer,\n args: customSchema<Parameters<UnderlyingMethodOfFunctionPointer<T>>>(),\n });\n\nexport type ConstrainedGenericFunctionPointer<_ReturnType extends Promise<any>> = FunctionPointer<\n ReturnType<<T extends (...args: any[]) => _ReturnType>() => T>\n>;\n\n// This type doesn't work correctly\nexport const createExtendableFunctionPointerWithCurriedArgsSchema = <\n _BaseArgs extends any[],\n _ReturnType extends Promise<any>,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<\n // FIXME type args correctly\n ConstrainedGenericFunctionPointer<_ReturnType>\n >().shape.pointer,\n args: z.array(z.any()),\n });\n\nexport const bindFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n}) => params;\n\nexport const bindPartialFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Partial<Parameters<UnderlyingMethodOfFunctionPointer<T>>>;\n}) => params;\n\nexport type FunctionPointerWithArgs<T extends FunctionPointer> = {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n};\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/WBHGMCS2.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","pointer","createFunctionPointerWithArgsSchema","shape","args","createExtendableFunctionPointerWithCurriedArgsSchema","array","any","bindFunctionPointerArgs","params","bindPartialFunctionPointerArgs"],"mappings":";;;;;;AAwBA,IAAMA,iBAAAA,GAAoBC,OAAO,uBAAA,CAAA;AAG1B,IAAMC,cAAAA,mBAAiB,MAAA,CAAA,CAAqD,EAC/EC,KAAAA,EACAC,QAAM,KAIT;AACG,EAA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EAASD,2BAAAA,GAGLG,KAAAA,CAAMF,OAAAA;AACVG,EAAAA,IAAAA,EAAMnB,IAAAA,CAAEqB,KAAAA,CAAMrB,IAAAA,CAAEsB,GAAAA,EAAG;AACvB,CAAA,CAAA,EAVgE,sDAAA;AAY7D,IAAMC,uBAAAA,mBAA0B,MAAA,CAAA,CAA4BC,MAAAA,KAG7DA,MAAAA,EAHiC,yBAAA;AAKhC,IAAMC,8BAAAA,mBAAiC,MAAA,CAAA,CAA4BD,MAAAA,KAGpEA,MAAAA,EAHwC,gCAAA","file":"WBHGMCS2.cjs","sourcesContent":["import { z } from 'zod/v4';\n\nimport type {\n FunctionPointer,\n UnderlyingMethodOfFunctionPointer,\n} from '@layerzerolabs/common-utils';\n\ntype IsPromise<T> =\n T extends z.ZodOptional<infer I>\n ? IsPromise<I>\n : T extends z.ZodDefault<infer I>\n ? IsPromise<I>\n : T extends z.ZodNullable<infer I>\n ? IsPromise<I>\n : T extends z.ZodPromise<any>\n ? true\n : false;\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<\n (\n ...args: z.infer<Input>\n //z.ZodPromise<T> infers as T, not Promise<T>\n ) => IsPromise<Output> extends true ? Promise<z.infer<Output>> : z.infer<Output>\n >;\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 = FunctionPointer>() =>\n z.object({\n // FIXME this can be a real schema\n pointer: customSchema<T>(),\n });\n\nexport const createFunctionPointerWithArgsSchema = <\n T extends FunctionPointer = FunctionPointer,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<T>().shape.pointer,\n args: customSchema<Parameters<UnderlyingMethodOfFunctionPointer<T>>>(),\n });\n\nexport type ConstrainedGenericFunctionPointer<_ReturnType extends Promise<any>> = FunctionPointer<\n ReturnType<<T extends (...args: any[]) => _ReturnType>() => T>\n>;\n\n// This type doesn't work correctly\nexport const createExtendableFunctionPointerWithCurriedArgsSchema = <\n _BaseArgs extends any[],\n _ReturnType extends Promise<any>,\n>() =>\n z.object({\n pointer: createFunctionPointerSchema<\n // FIXME type args correctly\n ConstrainedGenericFunctionPointer<_ReturnType>\n >().shape.pointer,\n args: z.array(z.any()),\n });\n\nexport const bindFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n}) => params;\n\nexport const bindPartialFunctionPointerArgs = <T extends FunctionPointer>(params: {\n pointer: T;\n args: Partial<Parameters<UnderlyingMethodOfFunctionPointer<T>>>;\n}) => params;\n\nexport type FunctionPointerWithArgs<T extends FunctionPointer> = {\n pointer: T;\n args: Parameters<UnderlyingMethodOfFunctionPointer<T>>;\n};\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"]}
|