@orpc/zod 0.35.1 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -9
- package/dist/src/coercer.d.ts +5 -4
- package/package.json +4 -2
package/dist/index.js
CHANGED
@@ -31,14 +31,17 @@ var guard = (func, shouldGuard) => {
|
|
31
31
|
import {
|
32
32
|
ZodFirstPartyTypeKind
|
33
33
|
} from "zod";
|
34
|
-
var
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
var ZodAutoCoercePlugin = class {
|
35
|
+
beforeCreateProcedureClient(clientOptions) {
|
36
|
+
clientOptions.interceptors ??= [];
|
37
|
+
clientOptions.interceptors.unshift((options) => {
|
38
|
+
const inputSchema = options.procedure["~orpc"].inputSchema;
|
39
|
+
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
40
|
+
return options.next();
|
41
|
+
}
|
42
|
+
const coercedInput = zodCoerceInternal(inputSchema, options.input, { bracketNotation: true });
|
43
|
+
return options.next({ ...options, input: coercedInput });
|
44
|
+
});
|
42
45
|
}
|
43
46
|
};
|
44
47
|
function zodCoerceInternal(schema, value, options) {
|
@@ -957,7 +960,7 @@ export {
|
|
957
960
|
NON_LOGIC_KEYWORDS,
|
958
961
|
UNDEFINED_JSON_SCHEMA,
|
959
962
|
UNSUPPORTED_JSON_SCHEMA,
|
960
|
-
|
963
|
+
ZodAutoCoercePlugin,
|
961
964
|
ZodToJsonSchemaConverter,
|
962
965
|
blob,
|
963
966
|
file,
|
package/dist/src/coercer.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
|
4
|
-
|
1
|
+
import type { Context } from '@orpc/server';
|
2
|
+
import type { Plugin } from '@orpc/server/plugins';
|
3
|
+
import type { WellCreateProcedureClientOptions } from '@orpc/server/standard';
|
4
|
+
export declare class ZodAutoCoercePlugin<TContext extends Context> implements Plugin<TContext> {
|
5
|
+
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>): void;
|
5
6
|
}
|
6
7
|
//# sourceMappingURL=coercer.d.ts.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/zod",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.36.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -29,9 +29,11 @@
|
|
29
29
|
"dist"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@orpc/
|
32
|
+
"@orpc/server": "0.36.1",
|
33
|
+
"@orpc/openapi": "0.36.1"
|
33
34
|
},
|
34
35
|
"dependencies": {
|
36
|
+
"@standard-schema/spec": "^1.0.0",
|
35
37
|
"json-schema-typed": "^8.0.1",
|
36
38
|
"wildcard-match": "^5.1.3",
|
37
39
|
"zod": "^3.24.1"
|