zod-nest 3.2.3 → 3.2.5

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,5 +1,5 @@
1
- import { isZodDto, ZodNestError, ZodValidationException, defaultRegistry, ZOD_DTO_SYMBOL, ZOD_NEST_DTO_EXTENSION, flattenObjectIntersection, resolveSchemaRef, isZodObject, registerSchema, expandObjectSchema, paramSchemaBody, COMPONENTS_SCHEMAS_PREFIX, isZodSchema, buildToJsonSchemaOptions, resolveAnonId, ANON_RESPONSE_PREFIX, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION } from './chunk-7IPDYJNI.mjs';
2
- export { COMPONENTS_SCHEMAS_PREFIX, ZOD_DTO_SYMBOL, ZOD_NEST_DTO_EXTENSION, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION, ZodNestError, ZodNestUnrepresentableError, ZodValidationException, createRegistry, defaultRegistry, extend, getLineage, isZodDto, isZodSchema, registerSchema, toOpenApi } from './chunk-7IPDYJNI.mjs';
1
+ import { isZodDto, ZodNestError, ZodValidationException, defaultRegistry, ZOD_DTO_SYMBOL, ZOD_NEST_DTO_EXTENSION, flattenObjectIntersection, resolveSchemaRef, isZodObject, registerSchema, expandObjectSchema, paramSchemaBody, COMPONENTS_SCHEMAS_PREFIX, isZodSchema, buildToJsonSchemaOptions, resolveAnonId, ANON_RESPONSE_PREFIX, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION } from './chunk-YRTGPVSJ.mjs';
2
+ export { COMPONENTS_SCHEMAS_PREFIX, ZOD_DTO_SYMBOL, ZOD_NEST_DTO_EXTENSION, ZOD_NEST_ERROR_DUPLICATE_ID, ZOD_NEST_ERROR_EXTENSION, ZodNestError, ZodNestUnrepresentableError, ZodValidationException, createRegistry, defaultRegistry, extend, getLineage, isZodDto, isZodSchema, registerSchema, toOpenApi } from './chunk-YRTGPVSJ.mjs';
3
3
  import { singleton, __name } from './chunk-MPNAA53V.mjs';
4
4
  export { overrideJSONSchema } from './chunk-MPNAA53V.mjs';
5
5
  import { InternalServerErrorException, HttpStatus, Injectable, Optional, Inject, Logger, RequestMethod, applyDecorators } from '@nestjs/common';
@@ -769,12 +769,17 @@ var ZodBody = /* @__PURE__ */ __name((schema, options) => {
769
769
  });
770
770
  }, "ZodBody");
771
771
  var resolveBodySchema = /* @__PURE__ */ __name((schema, options) => {
772
+ const registry = options?.registry ?? defaultRegistry;
772
773
  if (options?.flatten === true) {
773
- return flattenObjectIntersection(schema, options.registry ?? defaultRegistry, "@ZodBody");
774
+ const merged = flattenObjectIntersection(schema, registry, "@ZodBody");
775
+ return resolveSchemaRef(merged, {
776
+ registry,
777
+ deferAnonInline: true
778
+ }).ref;
774
779
  }
775
780
  return resolveSchemaRef(schema, {
776
781
  id: options?.id,
777
- registry: options?.registry,
782
+ registry,
778
783
  deferAnonInline: true
779
784
  }).ref;
780
785
  }, "resolveBodySchema");
@@ -1040,6 +1045,17 @@ var bulkEmit = /* @__PURE__ */ __name((opts) => {
1040
1045
  outputSchemas: runPass(opts, "output", knownIds)
1041
1046
  };
1042
1047
  }, "bulkEmit");
1048
+ var scopeToKnownIds = /* @__PURE__ */ __name((zodRegistry, knownIds) => {
1049
+ const scoped = z.registry();
1050
+ for (const [id, schema] of zodRegistry._idmap) {
1051
+ if (knownIds.has(id)) {
1052
+ scoped.add(schema, {
1053
+ id
1054
+ });
1055
+ }
1056
+ }
1057
+ return scoped;
1058
+ }, "scopeToKnownIds");
1043
1059
  var runPass = /* @__PURE__ */ __name((opts, io, knownIds) => {
1044
1060
  const built = buildToJsonSchemaOptions({
1045
1061
  registry: opts.registry,
@@ -1049,7 +1065,7 @@ var runPass = /* @__PURE__ */ __name((opts, io, knownIds) => {
1049
1065
  reused: "inline",
1050
1066
  uri: URI
1051
1067
  });
1052
- const raw = z.toJSONSchema(opts.registry.zodRegistry, built.options);
1068
+ const raw = z.toJSONSchema(scopeToKnownIds(opts.registry.zodRegistry, knownIds), built.options);
1053
1069
  built.consumeUnrepresentable();
1054
1070
  const filtered = /* @__PURE__ */ new Map();
1055
1071
  for (const [id, schema] of Object.entries(raw.schemas)) {