@orpc/zod 0.0.0-next.e565b64 → 0.0.0-next.e6490f2

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/README.md CHANGED
@@ -49,14 +49,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
49
49
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
50
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
51
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
- - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
52
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
53
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
53
54
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
54
- - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
55
- - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
56
- - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
57
- - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
55
+ - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
58
56
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
57
+ - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
60
58
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
61
59
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
62
60
  - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
@@ -138,7 +138,7 @@ declare const experimental_JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
138
138
  unevaluatedProperties?: JSONSchema;
139
139
  uniqueItems?: boolean;
140
140
  writeOnly?: boolean;
141
- }, zod_v4_core.$ZodType<unknown, unknown>>;
141
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
142
142
  /**
143
143
  * Zod registry for customizing generated JSON schema, only useful for .input
144
144
  *
@@ -217,7 +217,7 @@ declare const experimental_JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<
217
217
  unevaluatedProperties?: JSONSchema;
218
218
  uniqueItems?: boolean;
219
219
  writeOnly?: boolean;
220
- }, zod_v4_core.$ZodType<unknown, unknown>>;
220
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
221
221
  /**
222
222
  * Zod registry for customizing generated JSON schema, only useful for .input
223
223
  *
@@ -296,7 +296,7 @@ declare const experimental_JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry
296
296
  unevaluatedProperties?: JSONSchema;
297
297
  uniqueItems?: boolean;
298
298
  writeOnly?: boolean;
299
- }, zod_v4_core.$ZodType<unknown, unknown>>;
299
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
300
300
 
301
301
  export { experimental_JSON_SCHEMA_INPUT_REGISTRY, experimental_JSON_SCHEMA_OUTPUT_REGISTRY, experimental_JSON_SCHEMA_REGISTRY, experimental_ZodSmartCoercionPlugin, experimental_ZodToJsonSchemaConverter };
302
302
  export type { experimental_ZodToJsonSchemaOptions };
@@ -138,7 +138,7 @@ declare const experimental_JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
138
138
  unevaluatedProperties?: JSONSchema;
139
139
  uniqueItems?: boolean;
140
140
  writeOnly?: boolean;
141
- }, zod_v4_core.$ZodType<unknown, unknown>>;
141
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
142
142
  /**
143
143
  * Zod registry for customizing generated JSON schema, only useful for .input
144
144
  *
@@ -217,7 +217,7 @@ declare const experimental_JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<
217
217
  unevaluatedProperties?: JSONSchema;
218
218
  uniqueItems?: boolean;
219
219
  writeOnly?: boolean;
220
- }, zod_v4_core.$ZodType<unknown, unknown>>;
220
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
221
221
  /**
222
222
  * Zod registry for customizing generated JSON schema, only useful for .input
223
223
  *
@@ -296,7 +296,7 @@ declare const experimental_JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry
296
296
  unevaluatedProperties?: JSONSchema;
297
297
  uniqueItems?: boolean;
298
298
  writeOnly?: boolean;
299
- }, zod_v4_core.$ZodType<unknown, unknown>>;
299
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
300
300
 
301
301
  export { experimental_JSON_SCHEMA_INPUT_REGISTRY, experimental_JSON_SCHEMA_OUTPUT_REGISTRY, experimental_JSON_SCHEMA_REGISTRY, experimental_ZodSmartCoercionPlugin, experimental_ZodToJsonSchemaConverter };
302
302
  export type { experimental_ZodToJsonSchemaOptions };
@@ -100,8 +100,7 @@ class experimental_ZodSmartCoercionPlugin {
100
100
  }
101
101
  return value;
102
102
  }
103
- case "object":
104
- case "interface": {
103
+ case "object": {
105
104
  const object = schema;
106
105
  if (value === void 0) {
107
106
  return {};
@@ -165,9 +164,21 @@ class experimental_ZodSmartCoercionPlugin {
165
164
  return this.#coerce(union._zod.def.options[0], value);
166
165
  }
167
166
  if (isObject(value)) {
167
+ const discriminator = "discriminator" in union._zod.def && typeof union._zod.def.discriminator === "string" ? union._zod.def.discriminator : void 0;
168
168
  for (const option of union._zod.def.options) {
169
- if (option._zod.disc && this.#matchDiscriminators(value, option._zod.disc)) {
170
- return this.#coerce(option, value);
169
+ if (!option._zod.propValues) {
170
+ continue;
171
+ }
172
+ if (discriminator !== void 0) {
173
+ if (option._zod.propValues[discriminator]?.has(value[discriminator])) {
174
+ return this.#coerce(option, value);
175
+ }
176
+ } else {
177
+ for (const key in option._zod.propValues) {
178
+ if (option._zod.propValues[key]?.has(value[key])) {
179
+ return this.#coerce(option, value);
180
+ }
181
+ }
171
182
  }
172
183
  }
173
184
  }
@@ -255,30 +266,6 @@ class experimental_ZodSmartCoercionPlugin {
255
266
  }
256
267
  return value;
257
268
  }
258
- /**
259
- * This function is inspired from Zod, because it's not exported
260
- * https://github.com/colinhacks/zod/blob/v4/packages/core/src/schemas.ts#L1903C1-L1921C2
261
- */
262
- #matchDiscriminators(input, discs) {
263
- for (const [key, value] of discs) {
264
- const data = input[key];
265
- if (value.values.size && !value.values.has(data)) {
266
- return false;
267
- }
268
- if (value.maps.length === 0) {
269
- continue;
270
- }
271
- if (!isObject(data)) {
272
- return false;
273
- }
274
- for (const m of value.maps) {
275
- if (!this.#matchDiscriminators(data, m)) {
276
- return false;
277
- }
278
- }
279
- }
280
- return true;
281
- }
282
269
  }
283
270
 
284
271
  const experimental_JSON_SCHEMA_REGISTRY = registry();
@@ -320,7 +307,7 @@ class experimental_ZodToJsonSchemaConverter {
320
307
  case "string": {
321
308
  const string = schema2;
322
309
  const json = { type: "string" };
323
- const { minimum, maximum, format, pattern, contentEncoding } = string._zod.bag;
310
+ const { minimum, maximum, format, patterns, contentEncoding } = string._zod.bag;
324
311
  if (typeof minimum === "number") {
325
312
  json.minLength = minimum;
326
313
  }
@@ -333,8 +320,15 @@ class experimental_ZodToJsonSchemaConverter {
333
320
  if (typeof format === "string" && format !== "regex" && json.contentEncoding === void 0) {
334
321
  json.format = this.#handleStringFormat(format);
335
322
  }
336
- if (pattern instanceof RegExp && json.contentEncoding === void 0 && json.format === void 0) {
337
- json.pattern = pattern.source;
323
+ if (patterns instanceof Set && json.contentEncoding === void 0 && json.format === void 0) {
324
+ for (const pattern of patterns) {
325
+ if (json.pattern === void 0) {
326
+ json.pattern = pattern.source;
327
+ } else {
328
+ json.allOf ??= [];
329
+ json.allOf.push({ pattern: pattern.source });
330
+ }
331
+ }
338
332
  }
339
333
  if (format === "jwt" && json.contentEncoding === void 0 && json.format === void 0 && json.pattern === void 0) {
340
334
  json.pattern = /^[\w-]+\.[\w-]+\.[\w-]+$/.source;
@@ -621,7 +615,7 @@ class experimental_ZodToJsonSchemaConverter {
621
615
  if (global) {
622
616
  return {
623
617
  description: global.description,
624
- examples: global.examples
618
+ examples: Array.isArray(global.examples) ? global.examples : void 0
625
619
  };
626
620
  }
627
621
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/zod",
3
3
  "type": "module",
4
- "version": "0.0.0-next.e565b64",
4
+ "version": "0.0.0-next.e6490f2",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -30,17 +30,17 @@
30
30
  ],
31
31
  "peerDependencies": {
32
32
  "zod": ">=3.24.2",
33
- "@orpc/contract": "0.0.0-next.e565b64",
34
- "@orpc/server": "0.0.0-next.e565b64"
33
+ "@orpc/contract": "0.0.0-next.e6490f2",
34
+ "@orpc/server": "0.0.0-next.e6490f2"
35
35
  },
36
36
  "dependencies": {
37
37
  "escape-string-regexp": "^5.0.0",
38
38
  "wildcard-match": "^5.1.3",
39
- "@orpc/openapi": "0.0.0-next.e565b64",
40
- "@orpc/shared": "0.0.0-next.e565b64"
39
+ "@orpc/openapi": "0.0.0-next.e6490f2",
40
+ "@orpc/shared": "0.0.0-next.e6490f2"
41
41
  },
42
42
  "devDependencies": {
43
- "zod": "^3.25.11",
43
+ "zod": "^3.25.49",
44
44
  "zod-to-json-schema": "^3.24.5"
45
45
  },
46
46
  "scripts": {