@orpc/zod 1.14.9 → 1.14.10

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { custom, ZodFirstPartyTypeKind } from 'zod/v3';
2
2
  import wcmatch from 'wildcard-match';
3
- import { isObject, guard, toArray } from '@orpc/shared';
3
+ import { isObject, NullProtoObj, guard, toArray } from '@orpc/shared';
4
4
  import { JsonSchemaXNativeType } from '@orpc/json-schema';
5
5
  import { JSONSchemaFormat } from '@orpc/openapi';
6
6
  import escapeStringRegexp from 'escape-string-regexp';
@@ -210,14 +210,15 @@ function zodCoerceInternal(schema, value) {
210
210
  case ZodFirstPartyTypeKind.ZodObject: {
211
211
  const schema_ = schema;
212
212
  if (isObject(value)) {
213
- const newObj = {};
213
+ const newObj = new NullProtoObj();
214
+ const shape = schema_.shape;
214
215
  const keys = /* @__PURE__ */ new Set([
215
216
  ...Object.keys(value),
216
- ...Object.keys(schema_.shape)
217
+ ...Object.keys(shape)
217
218
  ]);
218
219
  for (const k of keys) {
219
220
  newObj[k] = zodCoerceInternal(
220
- schema_.shape[k] ?? schema_._def.catchall,
221
+ (Object.hasOwn(shape, k) ? shape[k] : void 0) ?? schema_._def.catchall,
221
222
  value[k]
222
223
  );
223
224
  }
@@ -228,7 +229,7 @@ function zodCoerceInternal(schema, value) {
228
229
  case ZodFirstPartyTypeKind.ZodRecord: {
229
230
  const schema_ = schema;
230
231
  if (isObject(value)) {
231
- const newObj = {};
232
+ const newObj = new NullProtoObj();
232
233
  for (const [k, v] of Object.entries(value)) {
233
234
  const key = zodCoerceInternal(schema_._def.keyType, k);
234
235
  const val = zodCoerceInternal(schema_._def.valueType, v);
@@ -1,4 +1,4 @@
1
- import { isObject, guard, intercept, toArray } from '@orpc/shared';
1
+ import { isObject, NullProtoObj, guard, intercept, toArray } from '@orpc/shared';
2
2
  import { JsonSchemaXNativeType } from '@orpc/json-schema';
3
3
  import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@orpc/openapi';
4
4
  import { registry, globalRegistry } from 'zod/v4/core';
@@ -107,13 +107,14 @@ class experimental_ZodSmartCoercionPlugin {
107
107
  return {};
108
108
  }
109
109
  if (isObject(value)) {
110
- const newObj = {};
110
+ const newObj = new NullProtoObj();
111
+ const shape = object._zod.def.shape;
111
112
  const keys = /* @__PURE__ */ new Set([
112
113
  ...Object.keys(value),
113
- ...Object.keys(object._zod.def.shape)
114
+ ...Object.keys(shape)
114
115
  ]);
115
116
  for (const k of keys) {
116
- const s = object._zod.def.shape[k] ?? object._zod.def.catchall;
117
+ const s = (Object.hasOwn(shape, k) ? shape[k] : void 0) ?? object._zod.def.catchall;
117
118
  newObj[k] = s ? this.#coerce(s, value[k]) : value[k];
118
119
  }
119
120
  return newObj;
@@ -126,7 +127,7 @@ class experimental_ZodSmartCoercionPlugin {
126
127
  return {};
127
128
  }
128
129
  if (isObject(value)) {
129
- const newObj = {};
130
+ const newObj = new NullProtoObj();
130
131
  for (const [k, v] of Object.entries(value)) {
131
132
  const key = this.#coerce(record._zod.def.keyType, k);
132
133
  const val = this.#coerce(record._zod.def.valueType, v);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/zod",
3
3
  "type": "module",
4
- "version": "1.14.9",
4
+ "version": "1.14.10",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -30,15 +30,15 @@
30
30
  ],
31
31
  "peerDependencies": {
32
32
  "zod": ">=3.25.0",
33
- "@orpc/contract": "1.14.9",
34
- "@orpc/server": "1.14.9"
33
+ "@orpc/server": "1.14.10",
34
+ "@orpc/contract": "1.14.10"
35
35
  },
36
36
  "dependencies": {
37
37
  "escape-string-regexp": "^5.0.0",
38
38
  "wildcard-match": "^5.1.4",
39
- "@orpc/json-schema": "1.14.9",
40
- "@orpc/shared": "1.14.9",
41
- "@orpc/openapi": "1.14.9"
39
+ "@orpc/json-schema": "1.14.10",
40
+ "@orpc/shared": "1.14.10",
41
+ "@orpc/openapi": "1.14.10"
42
42
  },
43
43
  "devDependencies": {
44
44
  "zod": "^4.3.6"