@orpc/zod 0.35.1 → 0.36.0

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 CHANGED
@@ -31,14 +31,17 @@ var guard = (func, shouldGuard) => {
31
31
  import {
32
32
  ZodFirstPartyTypeKind
33
33
  } from "zod";
34
- var ZodCoercer = class {
35
- coerce(schema, value) {
36
- if (!schema || schema["~standard"].vendor !== "zod") {
37
- return value;
38
- }
39
- const zodSchema = schema;
40
- const coerced = zodCoerceInternal(zodSchema, value, { bracketNotation: true });
41
- return coerced;
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
- ZodCoercer,
963
+ ZodAutoCoercePlugin,
961
964
  ZodToJsonSchemaConverter,
962
965
  blob,
963
966
  file,
@@ -1,6 +1,7 @@
1
- import type { Schema } from '@orpc/contract';
2
- import type { SchemaCoercer } from '@orpc/openapi/standard';
3
- export declare class ZodCoercer implements SchemaCoercer {
4
- coerce(schema: Schema, value: unknown): unknown;
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.35.1",
4
+ "version": "0.36.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -29,7 +29,8 @@
29
29
  "dist"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@orpc/openapi": "0.35.1"
32
+ "@orpc/openapi": "0.36.0",
33
+ "@orpc/server": "0.36.0"
33
34
  },
34
35
  "dependencies": {
35
36
  "json-schema-typed": "^8.0.1",