@cabloy/zod-query 2.1.12 → 2.1.14
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/index.js +4 -1
- package/dist/lib/query.d.ts +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -123,12 +123,15 @@ const isUndefined = obj => typeof obj === 'undefined';
|
|
|
123
123
|
const isNil = val => isUndefined(val) || val === null;
|
|
124
124
|
|
|
125
125
|
let ZodMetadata;
|
|
126
|
-
|
|
126
|
+
let shouldAdapt;
|
|
127
|
+
function setParseAdapter(zodMetadata, policy) {
|
|
127
128
|
ZodMetadata = zodMetadata;
|
|
129
|
+
shouldAdapt = policy;
|
|
128
130
|
z.core.setParseAdapter(__parseAdapter);
|
|
129
131
|
}
|
|
130
132
|
function __parseAdapter(inst, parse) {
|
|
131
133
|
return (payload, _) => {
|
|
134
|
+
if (shouldAdapt?.() === false) return parse(payload, _);
|
|
132
135
|
const type = inst.type;
|
|
133
136
|
switch (type) {
|
|
134
137
|
case 'string':
|
package/dist/lib/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare function setParseAdapter(zodMetadata: any): void;
|
|
2
|
+
export declare function setParseAdapter(zodMetadata: any, policy?: () => boolean): void;
|
|
3
3
|
export declare function coerceWithNil(value: any, fn?: Function): any;
|
|
4
4
|
export declare function getInnerTypeName(schema: z.ZodType): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "any" | "array" | "default" | "transform" | "enum" | "intersection" | "literal" | "never" | "null" | "nullable" | "nonoptional" | "optional" | "pipe" | "readonly" | "record" | "tuple" | "union" | "unknown" | "void" | "date" | "map" | "int" | "file" | "set" | "success" | "prefault" | "catch" | "nan" | "template_literal" | "promise" | "lazy" | "custom";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabloy/zod-query",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "2.1.14",
|
|
4
|
+
"gitHead": "adfc560c7fbe18fe6aa24a768172c21cf89d7b04",
|
|
5
5
|
"description": "zod-query",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ioc",
|
|
@@ -41,5 +41,8 @@
|
|
|
41
41
|
"prepublishOnly": "npm run tsc:publish",
|
|
42
42
|
"prepack": "clean-package",
|
|
43
43
|
"postpack": "clean-package restore"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"zod": "^4.3.6"
|
|
44
47
|
}
|
|
45
48
|
}
|