@layerzerolabs/zod-utils 0.2.66 → 0.2.67

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.
@@ -12,16 +12,16 @@
12
12
  CJS Build start
13
13
  ESM Build start
14
14
  ESM dist/index.js 4.09 KB
15
+ ESM dist/3NS47XY3.js 1.78 KB
15
16
  ESM dist/schema.js 212.00 B
16
- ESM dist/THJGESDP.js 1.77 KB
17
17
  ESM dist/index.js.map 11.03 KB
18
+ ESM dist/3NS47XY3.js.map 4.77 KB
18
19
  ESM dist/schema.js.map 70.00 B
19
- ESM dist/THJGESDP.js.map 4.76 KB
20
- ESM ⚡️ Build success in 212ms
20
+ ESM ⚡️ Build success in 180ms
21
21
  CJS dist/index.cjs 5.04 KB
22
+ CJS dist/KWZL3T47.cjs 1.97 KB
22
23
  CJS dist/schema.cjs 969.00 B
23
- CJS dist/GOAM7GGG.cjs 1.96 KB
24
24
  CJS dist/index.cjs.map 11.04 KB
25
+ CJS dist/KWZL3T47.cjs.map 4.77 KB
25
26
  CJS dist/schema.cjs.map 71.00 B
26
- CJS dist/GOAM7GGG.cjs.map 4.76 KB
27
- CJS ⚡️ Build success in 213ms
27
+ CJS ⚡️ Build success in 182ms
@@ -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:79739) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1775694520701 is not specified and it doesn't parse as CommonJS.
5
+ (node:66133) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1775770562286 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)
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2026 - LayerZero Labs Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any
4
+ person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the
6
+ Software without restriction, including without
7
+ limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software
10
+ is furnished to do so, subject to the following
11
+ conditions:
12
+ The above copyright notice and this permission notice
13
+ shall be included in all copies or substantial portions
14
+ of the Software.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
@@ -25,7 +25,7 @@ var schemaIsFunctionSchema = /* @__PURE__ */ __name((schema) => {
25
25
  }, "schemaIsFunctionSchema");
26
26
  var customSchema = /* @__PURE__ */ __name((validate) => z.custom(validate), "customSchema");
27
27
  var createFunctionPointerSchema = /* @__PURE__ */ __name(() => (
28
- // FIXME this can be a real schema
28
+ // TODO: replace with a concrete zod schema
29
29
  customSchema()
30
30
  ), "createFunctionPointerSchema");
31
31
  var brandedSchemaPropertyKey = "__BRANDED_SCHEMA_NAME";
@@ -46,5 +46,5 @@ var isBrandedWith = /* @__PURE__ */ __name((expected, schema) => {
46
46
  }, "isBrandedWith");
47
47
 
48
48
  export { __name, brandSchema, createFunctionPointerSchema, customSchema, functionSchema, isBrandedWith, schemaIsFunctionSchema };
49
- //# sourceMappingURL=THJGESDP.js.map
50
- //# sourceMappingURL=THJGESDP.js.map
49
+ //# sourceMappingURL=3NS47XY3.js.map
50
+ //# sourceMappingURL=3NS47XY3.js.map
@@ -1 +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","brandedSchemaPropertyKey","brandSchema","name","enumerable","configurable","isBrandedWith","expected"],"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;AAY3C,IAAMI,wBAAAA,GAA2B,uBAAA;AAG1B,IAAMC,8BAAc,MAAA,CAAA,CAA2BP,MAAAA,EAAgBQ,SAClEhB,MAAAA,CAAOC,cAAAA,CAAeO,QAAQM,wBAAAA,EAA0B;EACpDG,UAAAA,EAAY,KAAA;EACZC,YAAAA,EAAc,KAAA;EACdf,QAAAA,EAAU,KAAA;EACVD,KAAAA,EAAOc;AACX,CAAA,CAAA,EANuB,aAAA;AAQpB,IAAMG,aAAAA,mBAAgB,MAAA,CAAA,CACzBC,QAAAA,EACAZ,MAAAA,KAAAA;AAEA,EAAA,IAAI,EAAEM,4BAA4BM,QAAAA,CAAAA,EAAW;AACzC,IAAA,MAAM,IAAId,MAAM,qCAAA,CAAA;AACpB,EAAA;AAEA,EAAA,IAAI,EAAEQ,4BAA4BN,MAAAA,CAAAA,EAAS;AACvC,IAAA,OAAO,KAAA;AACX,EAAA;AAEA,EAAA,OAAOA,MAAAA,CAAOM,wBAAAA,CAAAA,KAA8BM,QAAAA,CAASN,wBAAAA,CAAAA;AACzD,CAAA,EAb6B,eAAA","file":"THJGESDP.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\n// utils for branding schemata with names\nconst brandedSchemaPropertyKey = '__BRANDED_SCHEMA_NAME' as const;\n\n/** Unavoidably, this mutates the underlying schema. Use with caution. */\nexport const brandSchema = <Schema extends z.ZodType>(schema: Schema, name: string): Schema =>\n Object.defineProperty(schema, brandedSchemaPropertyKey, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: name,\n });\n\nexport const isBrandedWith = <Branded extends z.ZodType>(\n expected: Branded,\n schema: z.ZodType,\n): schema is Branded => {\n if (!(brandedSchemaPropertyKey in expected)) {\n throw new Error('Branded model is not itself branded');\n }\n\n if (!(brandedSchemaPropertyKey in schema)) {\n return false;\n }\n\n return schema[brandedSchemaPropertyKey] === expected[brandedSchemaPropertyKey];\n};\n"]}
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","brandedSchemaPropertyKey","brandSchema","name","enumerable","configurable","isBrandedWith","expected"],"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;AAY3C,IAAMI,wBAAAA,GAA2B,uBAAA;AAG1B,IAAMC,8BAAc,MAAA,CAAA,CAA2BP,MAAAA,EAAgBQ,SAClEhB,MAAAA,CAAOC,cAAAA,CAAeO,QAAQM,wBAAAA,EAA0B;EACpDG,UAAAA,EAAY,KAAA;EACZC,YAAAA,EAAc,KAAA;EACdf,QAAAA,EAAU,KAAA;EACVD,KAAAA,EAAOc;AACX,CAAA,CAAA,EANuB,aAAA;AAQpB,IAAMG,aAAAA,mBAAgB,MAAA,CAAA,CACzBC,QAAAA,EACAZ,MAAAA,KAAAA;AAEA,EAAA,IAAI,EAAEM,4BAA4BM,QAAAA,CAAAA,EAAW;AACzC,IAAA,MAAM,IAAId,MAAM,qCAAA,CAAA;AACpB,EAAA;AAEA,EAAA,IAAI,EAAEQ,4BAA4BN,MAAAA,CAAAA,EAAS;AACvC,IAAA,OAAO,KAAA;AACX,EAAA;AAEA,EAAA,OAAOA,MAAAA,CAAOM,wBAAAA,CAAAA,KAA8BM,QAAAA,CAASN,wBAAAA,CAAAA;AACzD,CAAA,EAb6B,eAAA","file":"3NS47XY3.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 // TODO: replace with a concrete zod 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\n// utils for branding schemata with names\nconst brandedSchemaPropertyKey = '__BRANDED_SCHEMA_NAME' as const;\n\n/** Unavoidably, this mutates the underlying schema. Use with caution. */\nexport const brandSchema = <Schema extends z.ZodType>(schema: Schema, name: string): Schema =>\n Object.defineProperty(schema, brandedSchemaPropertyKey, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: name,\n });\n\nexport const isBrandedWith = <Branded extends z.ZodType>(\n expected: Branded,\n schema: z.ZodType,\n): schema is Branded => {\n if (!(brandedSchemaPropertyKey in expected)) {\n throw new Error('Branded model is not itself branded');\n }\n\n if (!(brandedSchemaPropertyKey in schema)) {\n return false;\n }\n\n return schema[brandedSchemaPropertyKey] === expected[brandedSchemaPropertyKey];\n};\n"]}
@@ -27,7 +27,7 @@ var schemaIsFunctionSchema = /* @__PURE__ */ __name((schema) => {
27
27
  }, "schemaIsFunctionSchema");
28
28
  var customSchema = /* @__PURE__ */ __name((validate) => zod.z.custom(validate), "customSchema");
29
29
  var createFunctionPointerSchema = /* @__PURE__ */ __name(() => (
30
- // FIXME this can be a real schema
30
+ // TODO: replace with a concrete zod schema
31
31
  customSchema()
32
32
  ), "createFunctionPointerSchema");
33
33
  var brandedSchemaPropertyKey = "__BRANDED_SCHEMA_NAME";
@@ -54,5 +54,5 @@ exports.customSchema = customSchema;
54
54
  exports.functionSchema = functionSchema;
55
55
  exports.isBrandedWith = isBrandedWith;
56
56
  exports.schemaIsFunctionSchema = schemaIsFunctionSchema;
57
- //# sourceMappingURL=GOAM7GGG.cjs.map
58
- //# sourceMappingURL=GOAM7GGG.cjs.map
57
+ //# sourceMappingURL=KWZL3T47.cjs.map
58
+ //# sourceMappingURL=KWZL3T47.cjs.map
@@ -1 +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","brandedSchemaPropertyKey","brandSchema","name","enumerable","configurable","isBrandedWith","expected"],"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;AAY3C,IAAMI,wBAAAA,GAA2B,uBAAA;AAG1B,IAAMC,8BAAc,MAAA,CAAA,CAA2BP,MAAAA,EAAgBQ,SAClEhB,MAAAA,CAAOC,cAAAA,CAAeO,QAAQM,wBAAAA,EAA0B;EACpDG,UAAAA,EAAY,KAAA;EACZC,YAAAA,EAAc,KAAA;EACdf,QAAAA,EAAU,KAAA;EACVD,KAAAA,EAAOc;AACX,CAAA,CAAA,EANuB,aAAA;AAQpB,IAAMG,aAAAA,mBAAgB,MAAA,CAAA,CACzBC,QAAAA,EACAZ,MAAAA,KAAAA;AAEA,EAAA,IAAI,EAAEM,4BAA4BM,QAAAA,CAAAA,EAAW;AACzC,IAAA,MAAM,IAAId,MAAM,qCAAA,CAAA;AACpB,EAAA;AAEA,EAAA,IAAI,EAAEQ,4BAA4BN,MAAAA,CAAAA,EAAS;AACvC,IAAA,OAAO,KAAA;AACX,EAAA;AAEA,EAAA,OAAOA,MAAAA,CAAOM,wBAAAA,CAAAA,KAA8BM,QAAAA,CAASN,wBAAAA,CAAAA;AACzD,CAAA,EAb6B,eAAA","file":"GOAM7GGG.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\n// utils for branding schemata with names\nconst brandedSchemaPropertyKey = '__BRANDED_SCHEMA_NAME' as const;\n\n/** Unavoidably, this mutates the underlying schema. Use with caution. */\nexport const brandSchema = <Schema extends z.ZodType>(schema: Schema, name: string): Schema =>\n Object.defineProperty(schema, brandedSchemaPropertyKey, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: name,\n });\n\nexport const isBrandedWith = <Branded extends z.ZodType>(\n expected: Branded,\n schema: z.ZodType,\n): schema is Branded => {\n if (!(brandedSchemaPropertyKey in expected)) {\n throw new Error('Branded model is not itself branded');\n }\n\n if (!(brandedSchemaPropertyKey in schema)) {\n return false;\n }\n\n return schema[brandedSchemaPropertyKey] === expected[brandedSchemaPropertyKey];\n};\n"]}
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","brandedSchemaPropertyKey","brandSchema","name","enumerable","configurable","isBrandedWith","expected"],"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;AAY3C,IAAMI,wBAAAA,GAA2B,uBAAA;AAG1B,IAAMC,8BAAc,MAAA,CAAA,CAA2BP,MAAAA,EAAgBQ,SAClEhB,MAAAA,CAAOC,cAAAA,CAAeO,QAAQM,wBAAAA,EAA0B;EACpDG,UAAAA,EAAY,KAAA;EACZC,YAAAA,EAAc,KAAA;EACdf,QAAAA,EAAU,KAAA;EACVD,KAAAA,EAAOc;AACX,CAAA,CAAA,EANuB,aAAA;AAQpB,IAAMG,aAAAA,mBAAgB,MAAA,CAAA,CACzBC,QAAAA,EACAZ,MAAAA,KAAAA;AAEA,EAAA,IAAI,EAAEM,4BAA4BM,QAAAA,CAAAA,EAAW;AACzC,IAAA,MAAM,IAAId,MAAM,qCAAA,CAAA;AACpB,EAAA;AAEA,EAAA,IAAI,EAAEQ,4BAA4BN,MAAAA,CAAAA,EAAS;AACvC,IAAA,OAAO,KAAA;AACX,EAAA;AAEA,EAAA,OAAOA,MAAAA,CAAOM,wBAAAA,CAAAA,KAA8BM,QAAAA,CAASN,wBAAAA,CAAAA;AACzD,CAAA,EAb6B,eAAA","file":"KWZL3T47.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 // TODO: replace with a concrete zod 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\n// utils for branding schemata with names\nconst brandedSchemaPropertyKey = '__BRANDED_SCHEMA_NAME' as const;\n\n/** Unavoidably, this mutates the underlying schema. Use with caution. */\nexport const brandSchema = <Schema extends z.ZodType>(schema: Schema, name: string): Schema =>\n Object.defineProperty(schema, brandedSchemaPropertyKey, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: name,\n });\n\nexport const isBrandedWith = <Branded extends z.ZodType>(\n expected: Branded,\n schema: z.ZodType,\n): schema is Branded => {\n if (!(brandedSchemaPropertyKey in expected)) {\n throw new Error('Branded model is not itself branded');\n }\n\n if (!(brandedSchemaPropertyKey in schema)) {\n return false;\n }\n\n return schema[brandedSchemaPropertyKey] === expected[brandedSchemaPropertyKey];\n};\n"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var GOAM7GGG_cjs = require('./GOAM7GGG.cjs');
3
+ var KWZL3T47_cjs = require('./KWZL3T47.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
- GOAM7GGG_cjs.__name(mapElement, "mapElement");
21
+ KWZL3T47_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__ */ GOAM7GGG_cjs.__name(() => mapElement(schema.def.getter()), "getter")
72
+ getter: /* @__PURE__ */ KWZL3T47_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,42 +108,42 @@ function mapOnSchema(schema, fn) {
108
108
  return schema;
109
109
  }
110
110
  }
111
- GOAM7GGG_cjs.__name(mapInner, "mapInner");
111
+ KWZL3T47_cjs.__name(mapInner, "mapInner");
112
112
  return fn(mapInner());
113
113
  }
114
- GOAM7GGG_cjs.__name(mapOnSchema, "mapOnSchema");
114
+ KWZL3T47_cjs.__name(mapOnSchema, "mapOnSchema");
115
115
  function zodDeepPartial(schema) {
116
116
  return mapOnSchema(schema, (s) => s?.optional?.());
117
117
  }
118
- GOAM7GGG_cjs.__name(zodDeepPartial, "zodDeepPartial");
118
+ KWZL3T47_cjs.__name(zodDeepPartial, "zodDeepPartial");
119
119
  function zodDeepRequired(schema) {
120
120
  return mapOnSchema(schema, (s) => s?.nonoptional?.());
121
121
  }
122
- GOAM7GGG_cjs.__name(zodDeepRequired, "zodDeepRequired");
122
+ KWZL3T47_cjs.__name(zodDeepRequired, "zodDeepRequired");
123
123
 
124
124
  Object.defineProperty(exports, "brandSchema", {
125
125
  enumerable: true,
126
- get: function () { return GOAM7GGG_cjs.brandSchema; }
126
+ get: function () { return KWZL3T47_cjs.brandSchema; }
127
127
  });
128
128
  Object.defineProperty(exports, "createFunctionPointerSchema", {
129
129
  enumerable: true,
130
- get: function () { return GOAM7GGG_cjs.createFunctionPointerSchema; }
130
+ get: function () { return KWZL3T47_cjs.createFunctionPointerSchema; }
131
131
  });
132
132
  Object.defineProperty(exports, "customSchema", {
133
133
  enumerable: true,
134
- get: function () { return GOAM7GGG_cjs.customSchema; }
134
+ get: function () { return KWZL3T47_cjs.customSchema; }
135
135
  });
136
136
  Object.defineProperty(exports, "functionSchema", {
137
137
  enumerable: true,
138
- get: function () { return GOAM7GGG_cjs.functionSchema; }
138
+ get: function () { return KWZL3T47_cjs.functionSchema; }
139
139
  });
140
140
  Object.defineProperty(exports, "isBrandedWith", {
141
141
  enumerable: true,
142
- get: function () { return GOAM7GGG_cjs.isBrandedWith; }
142
+ get: function () { return KWZL3T47_cjs.isBrandedWith; }
143
143
  });
144
144
  Object.defineProperty(exports, "schemaIsFunctionSchema", {
145
145
  enumerable: true,
146
- get: function () { return GOAM7GGG_cjs.schemaIsFunctionSchema; }
146
+ get: function () { return KWZL3T47_cjs.schemaIsFunctionSchema; }
147
147
  });
148
148
  exports.mapOnSchema = mapOnSchema;
149
149
  exports.zodDeepPartial = zodDeepPartial;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { __name } from './THJGESDP.js';
2
- export { brandSchema, createFunctionPointerSchema, customSchema, functionSchema, isBrandedWith, schemaIsFunctionSchema } from './THJGESDP.js';
1
+ import { __name } from './3NS47XY3.js';
2
+ export { brandSchema, createFunctionPointerSchema, customSchema, functionSchema, isBrandedWith, schemaIsFunctionSchema } from './3NS47XY3.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  var RESOLVING = Symbol("mapOnSchema/resolving");
package/dist/schema.cjs CHANGED
@@ -1,32 +1,32 @@
1
1
  'use strict';
2
2
 
3
- var GOAM7GGG_cjs = require('./GOAM7GGG.cjs');
3
+ var KWZL3T47_cjs = require('./KWZL3T47.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "brandSchema", {
8
8
  enumerable: true,
9
- get: function () { return GOAM7GGG_cjs.brandSchema; }
9
+ get: function () { return KWZL3T47_cjs.brandSchema; }
10
10
  });
11
11
  Object.defineProperty(exports, "createFunctionPointerSchema", {
12
12
  enumerable: true,
13
- get: function () { return GOAM7GGG_cjs.createFunctionPointerSchema; }
13
+ get: function () { return KWZL3T47_cjs.createFunctionPointerSchema; }
14
14
  });
15
15
  Object.defineProperty(exports, "customSchema", {
16
16
  enumerable: true,
17
- get: function () { return GOAM7GGG_cjs.customSchema; }
17
+ get: function () { return KWZL3T47_cjs.customSchema; }
18
18
  });
19
19
  Object.defineProperty(exports, "functionSchema", {
20
20
  enumerable: true,
21
- get: function () { return GOAM7GGG_cjs.functionSchema; }
21
+ get: function () { return KWZL3T47_cjs.functionSchema; }
22
22
  });
23
23
  Object.defineProperty(exports, "isBrandedWith", {
24
24
  enumerable: true,
25
- get: function () { return GOAM7GGG_cjs.isBrandedWith; }
25
+ get: function () { return KWZL3T47_cjs.isBrandedWith; }
26
26
  });
27
27
  Object.defineProperty(exports, "schemaIsFunctionSchema", {
28
28
  enumerable: true,
29
- get: function () { return GOAM7GGG_cjs.schemaIsFunctionSchema; }
29
+ get: function () { return KWZL3T47_cjs.schemaIsFunctionSchema; }
30
30
  });
31
31
  //# sourceMappingURL=schema.cjs.map
32
32
  //# sourceMappingURL=schema.cjs.map
package/dist/schema.js CHANGED
@@ -1,3 +1,3 @@
1
- export { brandSchema, createFunctionPointerSchema, customSchema, functionSchema, isBrandedWith, schemaIsFunctionSchema } from './THJGESDP.js';
1
+ export { brandSchema, createFunctionPointerSchema, customSchema, functionSchema, isBrandedWith, schemaIsFunctionSchema } from './3NS47XY3.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.66",
3
+ "version": "0.2.67",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,15 +15,15 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "dependencies": {
17
17
  "zod": "4.3.5",
18
- "@layerzerolabs/function-pointer": "0.2.66"
18
+ "@layerzerolabs/function-pointer": "0.2.67"
19
19
  },
20
20
  "devDependencies": {
21
21
  "tsup": "^8.4.0",
22
- "@layerzerolabs/typescript-configuration": "0.2.66",
23
- "@layerzerolabs/tsup-configuration": "0.2.66"
22
+ "@layerzerolabs/tsup-configuration": "0.2.67",
23
+ "@layerzerolabs/typescript-configuration": "0.2.67"
24
24
  },
25
25
  "publishConfig": {
26
- "access": "restricted",
26
+ "access": "public",
27
27
  "registry": "https://registry.npmjs.org/"
28
28
  },
29
29
  "externalRepoConfig": {
package/src/schema.ts CHANGED
@@ -47,7 +47,7 @@ export const customSchema = <T>(validate?: (data: any) => T) =>
47
47
  z.custom<T>(validate) as z.ZodType<T>;
48
48
 
49
49
  export const createFunctionPointerSchema = <T extends FunctionPointer>() =>
50
- // FIXME this can be a real schema
50
+ // TODO: replace with a concrete zod schema
51
51
  customSchema<T>();
52
52
 
53
53
  export type BuildZodObject<T extends object> = z.ZodObject<