zod-nest 3.3.0 → 3.5.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/README.md +2 -2
- package/dist/{chunk-BYRNJLNK.js → chunk-3D4FM53F.js} +11 -11
- package/dist/{chunk-BYRNJLNK.js.map → chunk-3D4FM53F.js.map} +1 -1
- package/dist/{chunk-YRTGPVSJ.mjs → chunk-6HU5TMFO.mjs} +4 -3
- package/dist/chunk-6HU5TMFO.mjs.map +1 -0
- package/dist/{chunk-Q3SWJZBB.js → chunk-J2MGUXBB.js} +4 -2
- package/dist/chunk-J2MGUXBB.js.map +1 -0
- package/dist/{chunk-T4H5ECKV.mjs → chunk-YUY5LICA.mjs} +3 -3
- package/dist/{chunk-T4H5ECKV.mjs.map → chunk-YUY5LICA.mjs.map} +1 -1
- package/dist/express/index.js +9 -9
- package/dist/express/index.mjs +3 -3
- package/dist/fastify/index.js +6 -6
- package/dist/fastify/index.mjs +3 -3
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +280 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-Q3SWJZBB.js.map +0 -1
- package/dist/chunk-YRTGPVSJ.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJ2MGUXBB_js = require('./chunk-J2MGUXBB.js');
|
|
4
4
|
var chunkEV5I5HGT_js = require('./chunk-EV5I5HGT.js');
|
|
5
5
|
var common = require('@nestjs/common');
|
|
6
6
|
var zod = require('zod');
|
|
@@ -39,7 +39,7 @@ var buildSiblingClass = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parent, schema)
|
|
|
39
39
|
}
|
|
40
40
|
static schema = schema;
|
|
41
41
|
static io = "output";
|
|
42
|
-
static [
|
|
42
|
+
static [chunkJ2MGUXBB_js.ZOD_DTO_SYMBOL] = true;
|
|
43
43
|
static get id() {
|
|
44
44
|
return parent.id;
|
|
45
45
|
}
|
|
@@ -54,7 +54,7 @@ var buildSiblingClass = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parent, schema)
|
|
|
54
54
|
}
|
|
55
55
|
static _OPENAPI_METADATA_FACTORY() {
|
|
56
56
|
return {
|
|
57
|
-
[
|
|
57
|
+
[chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION]: makeZodDtoMarker(parent.id, "output")
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
};
|
|
@@ -92,14 +92,14 @@ var resolveFallbackId = /* @__PURE__ */ chunkEV5I5HGT_js.__name((className) => {
|
|
|
92
92
|
return fallback;
|
|
93
93
|
}, "resolveFallbackId");
|
|
94
94
|
var createZodDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
95
|
-
const registry = options?.registry ??
|
|
95
|
+
const registry = options?.registry ?? chunkJ2MGUXBB_js.defaultRegistry;
|
|
96
96
|
const io = "input";
|
|
97
97
|
let cachedId;
|
|
98
98
|
const ensureRegistered = /* @__PURE__ */ chunkEV5I5HGT_js.__name((className) => {
|
|
99
99
|
if (cachedId !== void 0) {
|
|
100
100
|
return cachedId;
|
|
101
101
|
}
|
|
102
|
-
const named =
|
|
102
|
+
const named = chunkJ2MGUXBB_js.registerSchema(schema, registry, {
|
|
103
103
|
id: options?.id,
|
|
104
104
|
expose: options?.expose
|
|
105
105
|
});
|
|
@@ -119,7 +119,7 @@ var createZodDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) =>
|
|
|
119
119
|
}
|
|
120
120
|
static schema = schema;
|
|
121
121
|
static io = io;
|
|
122
|
-
static [
|
|
122
|
+
static [chunkJ2MGUXBB_js.ZOD_DTO_SYMBOL] = true;
|
|
123
123
|
static get id() {
|
|
124
124
|
return ensureRegistered(this.name);
|
|
125
125
|
}
|
|
@@ -134,7 +134,7 @@ var createZodDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) =>
|
|
|
134
134
|
}
|
|
135
135
|
static _OPENAPI_METADATA_FACTORY() {
|
|
136
136
|
return {
|
|
137
|
-
[
|
|
137
|
+
[chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION]: makeZodDtoMarker(ensureRegistered(this.name), io)
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
};
|
|
@@ -247,15 +247,28 @@ var createValidationLogger = /* @__PURE__ */ chunkEV5I5HGT_js.__name((opts) => {
|
|
|
247
247
|
};
|
|
248
248
|
}, "createValidationLogger");
|
|
249
249
|
var DEFAULT_CONTENT_TYPE = "application/json";
|
|
250
|
-
var
|
|
250
|
+
var SEQUENTIAL_DEFAULT_MEDIA_TYPES = [
|
|
251
251
|
"text/event-stream",
|
|
252
|
-
"application/x-ndjson"
|
|
252
|
+
"application/x-ndjson"
|
|
253
|
+
];
|
|
254
|
+
var SEQUENTIAL_MEDIA_TYPES = [
|
|
255
|
+
...SEQUENTIAL_DEFAULT_MEDIA_TYPES,
|
|
256
|
+
"application/jsonl",
|
|
257
|
+
"application/json-seq",
|
|
258
|
+
"application/geo+json-seq",
|
|
259
|
+
"multipart/mixed"
|
|
260
|
+
];
|
|
261
|
+
var OPAQUE_STREAM_MEDIA_TYPES = [
|
|
253
262
|
"application/octet-stream",
|
|
254
263
|
"application/pdf",
|
|
255
264
|
"image/*",
|
|
256
265
|
"audio/*",
|
|
257
266
|
"video/*"
|
|
258
267
|
];
|
|
268
|
+
var DEFAULT_STREAM_CONTENT_TYPES = [
|
|
269
|
+
...SEQUENTIAL_DEFAULT_MEDIA_TYPES,
|
|
270
|
+
...OPAQUE_STREAM_MEDIA_TYPES
|
|
271
|
+
];
|
|
259
272
|
var PREFIX_WILDCARD_SUFFIX = "/*";
|
|
260
273
|
var normalizeContentType = /* @__PURE__ */ chunkEV5I5HGT_js.__name((contentType) => {
|
|
261
274
|
const semicolonIndex = contentType.indexOf(";");
|
|
@@ -295,6 +308,18 @@ var matchesStream = /* @__PURE__ */ chunkEV5I5HGT_js.__name((contentType, matche
|
|
|
295
308
|
}
|
|
296
309
|
return false;
|
|
297
310
|
}, "matchesStream");
|
|
311
|
+
var SEQUENTIAL_MATCHER = normalizeStreamMatcher(SEQUENTIAL_MEDIA_TYPES);
|
|
312
|
+
var OPAQUE_MATCHER = normalizeStreamMatcher(OPAQUE_STREAM_MEDIA_TYPES);
|
|
313
|
+
var isSequentialMediaType = /* @__PURE__ */ chunkEV5I5HGT_js.__name((contentType) => matchesStream(contentType, SEQUENTIAL_MATCHER), "isSequentialMediaType");
|
|
314
|
+
var isItemStreamVariant = /* @__PURE__ */ chunkEV5I5HGT_js.__name((variant, contentType) => {
|
|
315
|
+
if (variant.stream !== true) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
if (isSequentialMediaType(contentType)) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
return !matchesStream(contentType, OPAQUE_MATCHER);
|
|
322
|
+
}, "isItemStreamVariant");
|
|
298
323
|
var isHeaderEntry = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => {
|
|
299
324
|
if (value === null || typeof value !== "object") {
|
|
300
325
|
return false;
|
|
@@ -420,7 +445,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
420
445
|
chunkEV5I5HGT_js.__name(_ts_param, "_ts_param");
|
|
421
446
|
var isZodSchema2 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && "_zod" in value, "isZodSchema");
|
|
422
447
|
var isOptionsObject = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && !isZodSchema2(value), "isOptionsObject");
|
|
423
|
-
var defaultExceptionFactory = /* @__PURE__ */ chunkEV5I5HGT_js.__name((zodError, argMetadata) => new
|
|
448
|
+
var defaultExceptionFactory = /* @__PURE__ */ chunkEV5I5HGT_js.__name((zodError, argMetadata) => new chunkJ2MGUXBB_js.ZodValidationException(zodError, argMetadata), "defaultExceptionFactory");
|
|
424
449
|
exports.ZodValidationPipe = class _ZodValidationPipe {
|
|
425
450
|
static {
|
|
426
451
|
chunkEV5I5HGT_js.__name(this, "ZodValidationPipe");
|
|
@@ -458,7 +483,7 @@ exports.ZodValidationPipe = class _ZodValidationPipe {
|
|
|
458
483
|
return this.explicitSchema;
|
|
459
484
|
}
|
|
460
485
|
const metatype = metadata.metatype;
|
|
461
|
-
if (!
|
|
486
|
+
if (!chunkJ2MGUXBB_js.isZodDto(metatype)) {
|
|
462
487
|
return void 0;
|
|
463
488
|
}
|
|
464
489
|
return metatype.schema;
|
|
@@ -468,7 +493,7 @@ exports.ZodValidationPipe = class _ZodValidationPipe {
|
|
|
468
493
|
return this.explicitDtoName;
|
|
469
494
|
}
|
|
470
495
|
const metatype = metadata.metatype;
|
|
471
|
-
if (
|
|
496
|
+
if (chunkJ2MGUXBB_js.isZodDto(metatype)) {
|
|
472
497
|
return metatype.name;
|
|
473
498
|
}
|
|
474
499
|
return "schema";
|
|
@@ -481,7 +506,7 @@ exports.ZodValidationPipe = class _ZodValidationPipe {
|
|
|
481
506
|
dtoName: void 0
|
|
482
507
|
};
|
|
483
508
|
}
|
|
484
|
-
if (
|
|
509
|
+
if (chunkJ2MGUXBB_js.isZodDto(arg)) {
|
|
485
510
|
return {
|
|
486
511
|
schema: arg.schema,
|
|
487
512
|
factory: void 0,
|
|
@@ -503,8 +528,8 @@ exports.ZodValidationPipe = class _ZodValidationPipe {
|
|
|
503
528
|
};
|
|
504
529
|
}
|
|
505
530
|
const optionSchema = arg.schema;
|
|
506
|
-
const dtoName =
|
|
507
|
-
const resolvedSchema =
|
|
531
|
+
const dtoName = chunkJ2MGUXBB_js.isZodDto(optionSchema) ? optionSchema.name : void 0;
|
|
532
|
+
const resolvedSchema = chunkJ2MGUXBB_js.isZodDto(optionSchema) ? optionSchema.schema : optionSchema;
|
|
508
533
|
return {
|
|
509
534
|
schema: resolvedSchema,
|
|
510
535
|
factory: arg.createValidationException,
|
|
@@ -560,14 +585,14 @@ var schemaToOutputDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema) => {
|
|
|
560
585
|
if (cached !== void 0) {
|
|
561
586
|
return cached;
|
|
562
587
|
}
|
|
563
|
-
const namedId =
|
|
588
|
+
const namedId = chunkJ2MGUXBB_js.registerSchema(schema);
|
|
564
589
|
if (namedId !== void 0) {
|
|
565
590
|
const dto2 = createZodDto(schema).Output;
|
|
566
591
|
responseDtoCache.set(schema, dto2);
|
|
567
592
|
return dto2;
|
|
568
593
|
}
|
|
569
|
-
const anonId =
|
|
570
|
-
|
|
594
|
+
const anonId = chunkJ2MGUXBB_js.resolveAnonId(schema, chunkJ2MGUXBB_js.ANON_RESPONSE_PREFIX);
|
|
595
|
+
chunkJ2MGUXBB_js.registerSchema(schema, chunkJ2MGUXBB_js.defaultRegistry, {
|
|
571
596
|
id: anonId,
|
|
572
597
|
anonymous: true
|
|
573
598
|
});
|
|
@@ -578,10 +603,10 @@ var schemaToOutputDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema) => {
|
|
|
578
603
|
return dto;
|
|
579
604
|
}, "schemaToOutputDto");
|
|
580
605
|
var toResponseDto = /* @__PURE__ */ chunkEV5I5HGT_js.__name((entry, index) => {
|
|
581
|
-
if (
|
|
606
|
+
if (chunkJ2MGUXBB_js.isZodDto(entry)) {
|
|
582
607
|
return entry;
|
|
583
608
|
}
|
|
584
|
-
if (
|
|
609
|
+
if (chunkJ2MGUXBB_js.isZodSchema(entry)) {
|
|
585
610
|
return schemaToOutputDto(entry);
|
|
586
611
|
}
|
|
587
612
|
const where = index === void 0 ? "@ZodResponse({ type })" : `@ZodResponse({ type }) element [${index}]`;
|
|
@@ -621,24 +646,29 @@ var buildTupleSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((dtos) => ({
|
|
|
621
646
|
})),
|
|
622
647
|
items: false
|
|
623
648
|
}), "buildTupleSchema");
|
|
624
|
-
var buildContentResponseOptions = /* @__PURE__ */ chunkEV5I5HGT_js.__name((base, contentType, schema) => {
|
|
649
|
+
var buildContentResponseOptions = /* @__PURE__ */ chunkEV5I5HGT_js.__name((base, contentType, schema, markItemStream) => {
|
|
650
|
+
const mediaType = markItemStream ? {
|
|
651
|
+
schema,
|
|
652
|
+
[chunkJ2MGUXBB_js.ZOD_NEST_ITEM_STREAM_EXTENSION]: true
|
|
653
|
+
} : {
|
|
654
|
+
schema
|
|
655
|
+
};
|
|
625
656
|
return {
|
|
626
657
|
...base,
|
|
627
658
|
content: {
|
|
628
|
-
[contentType]:
|
|
629
|
-
schema
|
|
630
|
-
}
|
|
659
|
+
[contentType]: mediaType
|
|
631
660
|
}
|
|
632
661
|
};
|
|
633
662
|
}, "buildContentResponseOptions");
|
|
634
663
|
var applyCustomContentResponse = /* @__PURE__ */ chunkEV5I5HGT_js.__name((variant, base, contentType, target, propertyKey, descriptor) => {
|
|
664
|
+
const markItemStream = isItemStreamVariant(variant, contentType);
|
|
635
665
|
if (variant.kind === "single") {
|
|
636
666
|
const dto = variant.dto;
|
|
637
667
|
swagger.ApiExtraModels(asDtoFunction(dto))(target, propertyKey, descriptor);
|
|
638
668
|
const schema = {
|
|
639
669
|
$ref: swagger.getSchemaPath(asDtoFunction(dto))
|
|
640
670
|
};
|
|
641
|
-
swagger.ApiResponse(buildContentResponseOptions(base, contentType, schema))(target, propertyKey, descriptor);
|
|
671
|
+
swagger.ApiResponse(buildContentResponseOptions(base, contentType, schema, markItemStream))(target, propertyKey, descriptor);
|
|
642
672
|
return;
|
|
643
673
|
}
|
|
644
674
|
const dtos = variant.dto;
|
|
@@ -651,10 +681,10 @@ var applyCustomContentResponse = /* @__PURE__ */ chunkEV5I5HGT_js.__name((varian
|
|
|
651
681
|
$ref: swagger.getSchemaPath(asDtoFunction(dto))
|
|
652
682
|
}
|
|
653
683
|
};
|
|
654
|
-
swagger.ApiResponse(buildContentResponseOptions(base, contentType, schema))(target, propertyKey, descriptor);
|
|
684
|
+
swagger.ApiResponse(buildContentResponseOptions(base, contentType, schema, markItemStream))(target, propertyKey, descriptor);
|
|
655
685
|
return;
|
|
656
686
|
}
|
|
657
|
-
swagger.ApiResponse(buildContentResponseOptions(base, contentType, buildTupleSchema(dtos)))(target, propertyKey, descriptor);
|
|
687
|
+
swagger.ApiResponse(buildContentResponseOptions(base, contentType, buildTupleSchema(dtos), markItemStream))(target, propertyKey, descriptor);
|
|
658
688
|
}, "applyCustomContentResponse");
|
|
659
689
|
var applySwaggerResponseDecorator = /* @__PURE__ */ chunkEV5I5HGT_js.__name((variant, effectiveStatus, effectiveContentType, target, propertyKey, descriptor) => {
|
|
660
690
|
const base = {
|
|
@@ -773,15 +803,15 @@ var ZodBody = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
|
773
803
|
});
|
|
774
804
|
}, "ZodBody");
|
|
775
805
|
var resolveBodySchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
776
|
-
const registry = options?.registry ??
|
|
806
|
+
const registry = options?.registry ?? chunkJ2MGUXBB_js.defaultRegistry;
|
|
777
807
|
if (options?.flatten === true) {
|
|
778
|
-
const merged =
|
|
779
|
-
return
|
|
808
|
+
const merged = chunkJ2MGUXBB_js.flattenObjectIntersection(schema, registry, "@ZodBody");
|
|
809
|
+
return chunkJ2MGUXBB_js.resolveSchemaRef(merged, {
|
|
780
810
|
registry,
|
|
781
811
|
deferAnonInline: true
|
|
782
812
|
}).ref;
|
|
783
813
|
}
|
|
784
|
-
return
|
|
814
|
+
return chunkJ2MGUXBB_js.resolveSchemaRef(schema, {
|
|
785
815
|
id: options?.id,
|
|
786
816
|
registry,
|
|
787
817
|
deferAnonInline: true
|
|
@@ -816,27 +846,27 @@ var appendQueryMarker = /* @__PURE__ */ chunkEV5I5HGT_js.__name((dtoId, ref) =>
|
|
|
816
846
|
|
|
817
847
|
// src/decorators/zod-query.decorator.ts
|
|
818
848
|
var ZodQuery = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
819
|
-
if (!
|
|
820
|
-
throw new
|
|
849
|
+
if (!chunkJ2MGUXBB_js.isZodObject(schema)) {
|
|
850
|
+
throw new chunkJ2MGUXBB_js.ZodNestError(`@ZodQuery requires a \`z.object({...})\` schema (got \`${schema._zod.def.type}\`). Each property of the object becomes one OpenAPI parameter. For non-object body shapes (intersections, unions, primitives), use \`@ZodBody\` instead.`);
|
|
821
851
|
}
|
|
822
|
-
const registry = options?.registry ??
|
|
823
|
-
const id =
|
|
852
|
+
const registry = options?.registry ?? chunkJ2MGUXBB_js.defaultRegistry;
|
|
853
|
+
const id = chunkJ2MGUXBB_js.registerSchema(schema, registry, {
|
|
824
854
|
id: options?.id
|
|
825
855
|
});
|
|
826
856
|
if (id !== void 0) {
|
|
827
857
|
return appendQueryMarker(id, options?.ref);
|
|
828
858
|
}
|
|
829
859
|
if (options?.ref === true) {
|
|
830
|
-
throw new
|
|
860
|
+
throw new chunkJ2MGUXBB_js.ZodNestError(`@ZodQuery({ ref: true }) requires a named schema \u2014 there is no component to \`$ref\`. Name the schema via \`.meta({ id: 'Foo' })\` or pass the \`id\` option, or drop \`ref\` to expand per property.`);
|
|
831
861
|
}
|
|
832
|
-
const expanded =
|
|
862
|
+
const expanded = chunkJ2MGUXBB_js.expandObjectSchema(schema, {
|
|
833
863
|
id: options?.id,
|
|
834
864
|
registry,
|
|
835
865
|
decoratorName: "@ZodQuery"
|
|
836
866
|
});
|
|
837
867
|
return common.applyDecorators(...expanded.map(({ name, required, resolution }) => swagger.ApiQuery({
|
|
838
868
|
name,
|
|
839
|
-
schema:
|
|
869
|
+
schema: chunkJ2MGUXBB_js.paramSchemaBody(resolution),
|
|
840
870
|
required
|
|
841
871
|
})));
|
|
842
872
|
}, "ZodQuery");
|
|
@@ -846,7 +876,7 @@ var API_PARAMETERS_KEY = "swagger/apiParameters";
|
|
|
846
876
|
|
|
847
877
|
// src/decorators/zod-headers.decorator.ts
|
|
848
878
|
var ZodHeaders = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
849
|
-
const expanded =
|
|
879
|
+
const expanded = chunkJ2MGUXBB_js.expandObjectSchema(schema, {
|
|
850
880
|
id: options?.id,
|
|
851
881
|
registry: options?.registry,
|
|
852
882
|
decoratorName: "@ZodHeaders"
|
|
@@ -855,7 +885,7 @@ var ZodHeaders = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
|
855
885
|
name,
|
|
856
886
|
in: "header",
|
|
857
887
|
required,
|
|
858
|
-
schema:
|
|
888
|
+
schema: chunkJ2MGUXBB_js.paramSchemaBody(resolution)
|
|
859
889
|
}));
|
|
860
890
|
return (_target, _propertyKey, descriptor) => {
|
|
861
891
|
const handler = descriptor.value;
|
|
@@ -872,7 +902,7 @@ var ZodHeaders = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
|
872
902
|
|
|
873
903
|
// src/decorators/zod-cookies.decorator.ts
|
|
874
904
|
var ZodCookies = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
875
|
-
const expanded =
|
|
905
|
+
const expanded = chunkJ2MGUXBB_js.expandObjectSchema(schema, {
|
|
876
906
|
id: options?.id,
|
|
877
907
|
registry: options?.registry,
|
|
878
908
|
decoratorName: "@ZodCookies"
|
|
@@ -881,7 +911,7 @@ var ZodCookies = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, options) => {
|
|
|
881
911
|
name,
|
|
882
912
|
in: "cookie",
|
|
883
913
|
required,
|
|
884
|
-
schema:
|
|
914
|
+
schema: chunkJ2MGUXBB_js.paramSchemaBody(resolution)
|
|
885
915
|
}));
|
|
886
916
|
return (_target, _propertyKey, descriptor) => {
|
|
887
917
|
const handler = descriptor.value;
|
|
@@ -1041,6 +1071,101 @@ var ZodNestModule = class _ZodNestModule {
|
|
|
1041
1071
|
};
|
|
1042
1072
|
}
|
|
1043
1073
|
};
|
|
1074
|
+
|
|
1075
|
+
// src/document/http-methods.ts
|
|
1076
|
+
var OPENAPI_OPERATION_KEYS = [
|
|
1077
|
+
"get",
|
|
1078
|
+
"put",
|
|
1079
|
+
"post",
|
|
1080
|
+
"delete",
|
|
1081
|
+
"options",
|
|
1082
|
+
"head",
|
|
1083
|
+
"patch",
|
|
1084
|
+
"trace",
|
|
1085
|
+
"query"
|
|
1086
|
+
];
|
|
1087
|
+
var EXTENSION_OPERATION_KEYS = [
|
|
1088
|
+
"search",
|
|
1089
|
+
"propfind",
|
|
1090
|
+
"proppatch",
|
|
1091
|
+
"mkcol",
|
|
1092
|
+
"copy",
|
|
1093
|
+
"move",
|
|
1094
|
+
"lock",
|
|
1095
|
+
"unlock"
|
|
1096
|
+
];
|
|
1097
|
+
var HTTP_METHODS = [
|
|
1098
|
+
...OPENAPI_OPERATION_KEYS,
|
|
1099
|
+
...EXTENSION_OPERATION_KEYS
|
|
1100
|
+
];
|
|
1101
|
+
var ADDITIONAL_OPERATIONS_KEY = "additionalOperations";
|
|
1102
|
+
var isRecord = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object", "isRecord");
|
|
1103
|
+
var operationsOfPathItem = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem) => {
|
|
1104
|
+
const operations = [];
|
|
1105
|
+
for (const method of HTTP_METHODS) {
|
|
1106
|
+
const operation = pathItem[method];
|
|
1107
|
+
if (isRecord(operation)) {
|
|
1108
|
+
operations.push(operation);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const additional = pathItem[ADDITIONAL_OPERATIONS_KEY];
|
|
1112
|
+
if (isRecord(additional)) {
|
|
1113
|
+
for (const operation of Object.values(additional)) {
|
|
1114
|
+
if (isRecord(operation)) {
|
|
1115
|
+
operations.push(operation);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return operations;
|
|
1120
|
+
}, "operationsOfPathItem");
|
|
1121
|
+
var forEachOperation = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, fn) => {
|
|
1122
|
+
const paths = doc.paths;
|
|
1123
|
+
if (!isRecord(paths)) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
for (const pathItem of Object.values(paths)) {
|
|
1127
|
+
if (!isRecord(pathItem)) {
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
for (const operation of operationsOfPathItem(pathItem)) {
|
|
1131
|
+
fn(operation);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}, "forEachOperation");
|
|
1135
|
+
|
|
1136
|
+
// src/document/additional-operations.ts
|
|
1137
|
+
var isRecord2 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object", "isRecord");
|
|
1138
|
+
var relocateExtensionOperations = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc) => {
|
|
1139
|
+
const paths = doc.paths;
|
|
1140
|
+
if (!isRecord2(paths)) {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
for (const pathItem of Object.values(paths)) {
|
|
1144
|
+
if (!isRecord2(pathItem)) {
|
|
1145
|
+
continue;
|
|
1146
|
+
}
|
|
1147
|
+
relocateInPathItem(pathItem);
|
|
1148
|
+
}
|
|
1149
|
+
}, "relocateExtensionOperations");
|
|
1150
|
+
var relocateInPathItem = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem) => {
|
|
1151
|
+
const relocated = {};
|
|
1152
|
+
for (const method of EXTENSION_OPERATION_KEYS) {
|
|
1153
|
+
const operation = pathItem[method];
|
|
1154
|
+
if (!isRecord2(operation)) {
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
relocated[method.toUpperCase()] = operation;
|
|
1158
|
+
delete pathItem[method];
|
|
1159
|
+
}
|
|
1160
|
+
if (Object.keys(relocated).length === 0) {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const existing = pathItem[ADDITIONAL_OPERATIONS_KEY];
|
|
1164
|
+
pathItem[ADDITIONAL_OPERATIONS_KEY] = isRecord2(existing) ? {
|
|
1165
|
+
...relocated,
|
|
1166
|
+
...existing
|
|
1167
|
+
} : relocated;
|
|
1168
|
+
}, "relocateInPathItem");
|
|
1044
1169
|
var URI = /* @__PURE__ */ chunkEV5I5HGT_js.__name((id) => `#/components/schemas/${id}`, "URI");
|
|
1045
1170
|
var bulkEmit = /* @__PURE__ */ chunkEV5I5HGT_js.__name((opts) => {
|
|
1046
1171
|
const knownIds = new Set(opts.registry.ids());
|
|
@@ -1061,7 +1186,7 @@ var scopeToKnownIds = /* @__PURE__ */ chunkEV5I5HGT_js.__name((zodRegistry, know
|
|
|
1061
1186
|
return scoped;
|
|
1062
1187
|
}, "scopeToKnownIds");
|
|
1063
1188
|
var runPass = /* @__PURE__ */ chunkEV5I5HGT_js.__name((opts, io, knownIds) => {
|
|
1064
|
-
const built =
|
|
1189
|
+
const built = chunkJ2MGUXBB_js.buildToJsonSchemaOptions({
|
|
1065
1190
|
registry: opts.registry,
|
|
1066
1191
|
io,
|
|
1067
1192
|
override: opts.override,
|
|
@@ -1080,46 +1205,6 @@ var runPass = /* @__PURE__ */ chunkEV5I5HGT_js.__name((opts, io, knownIds) => {
|
|
|
1080
1205
|
return filtered;
|
|
1081
1206
|
}, "runPass");
|
|
1082
1207
|
|
|
1083
|
-
// src/document/http-methods.ts
|
|
1084
|
-
var HTTP_METHODS = [
|
|
1085
|
-
"get",
|
|
1086
|
-
"put",
|
|
1087
|
-
"post",
|
|
1088
|
-
"delete",
|
|
1089
|
-
"options",
|
|
1090
|
-
"head",
|
|
1091
|
-
"patch",
|
|
1092
|
-
"trace",
|
|
1093
|
-
"query",
|
|
1094
|
-
"search",
|
|
1095
|
-
"propfind",
|
|
1096
|
-
"proppatch",
|
|
1097
|
-
"mkcol",
|
|
1098
|
-
"copy",
|
|
1099
|
-
"move",
|
|
1100
|
-
"lock",
|
|
1101
|
-
"unlock"
|
|
1102
|
-
];
|
|
1103
|
-
var forEachOperation = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, fn) => {
|
|
1104
|
-
const paths = doc.paths;
|
|
1105
|
-
if (paths === null || typeof paths !== "object") {
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
for (const pathItem of Object.values(paths)) {
|
|
1109
|
-
if (pathItem === null || typeof pathItem !== "object") {
|
|
1110
|
-
continue;
|
|
1111
|
-
}
|
|
1112
|
-
const pathRecord = pathItem;
|
|
1113
|
-
for (const method of HTTP_METHODS) {
|
|
1114
|
-
const op = pathRecord[method];
|
|
1115
|
-
if (op === null || typeof op !== "object") {
|
|
1116
|
-
continue;
|
|
1117
|
-
}
|
|
1118
|
-
fn(op);
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}, "forEachOperation");
|
|
1122
|
-
|
|
1123
1208
|
// src/document/walk-refs.ts
|
|
1124
1209
|
var walkRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, visit) => {
|
|
1125
1210
|
if (node === null || typeof node !== "object") {
|
|
@@ -1177,7 +1262,7 @@ var readMarker = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema) => {
|
|
|
1177
1262
|
if (!isPlainRecord2(schema.properties)) {
|
|
1178
1263
|
return void 0;
|
|
1179
1264
|
}
|
|
1180
|
-
const marker = schema.properties[
|
|
1265
|
+
const marker = schema.properties[chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION];
|
|
1181
1266
|
if (!isZodDtoMarker(marker)) {
|
|
1182
1267
|
return void 0;
|
|
1183
1268
|
}
|
|
@@ -1192,22 +1277,12 @@ var collectInputExposedIds = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, class
|
|
|
1192
1277
|
if (!isPlainRecord2(pathItem)) {
|
|
1193
1278
|
continue;
|
|
1194
1279
|
}
|
|
1195
|
-
for (const operation of
|
|
1280
|
+
for (const operation of operationsOfPathItem(pathItem)) {
|
|
1196
1281
|
collectRefsFromOperation(operation, classToDtoId, knownIds, ids);
|
|
1197
1282
|
}
|
|
1198
1283
|
}
|
|
1199
1284
|
return ids;
|
|
1200
1285
|
}, "collectInputExposedIds");
|
|
1201
|
-
var operationsOf = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem) => {
|
|
1202
|
-
const out = [];
|
|
1203
|
-
for (const method of HTTP_METHODS) {
|
|
1204
|
-
const op = pathItem[method];
|
|
1205
|
-
if (isPlainRecord2(op)) {
|
|
1206
|
-
out.push(op);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
return out;
|
|
1210
|
-
}, "operationsOf");
|
|
1211
1286
|
var collectRefsFromOperation = /* @__PURE__ */ chunkEV5I5HGT_js.__name((operation, classToDtoId, knownIds, ids) => {
|
|
1212
1287
|
if (isPlainRecord2(operation.requestBody)) {
|
|
1213
1288
|
collectRefsFromContent(operation.requestBody.content, classToDtoId, knownIds, ids);
|
|
@@ -1249,10 +1324,10 @@ var collectRefFromSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema, clas
|
|
|
1249
1324
|
return;
|
|
1250
1325
|
}
|
|
1251
1326
|
walkRefs(schema, (ref) => {
|
|
1252
|
-
if (!ref.startsWith(
|
|
1327
|
+
if (!ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX)) {
|
|
1253
1328
|
return void 0;
|
|
1254
1329
|
}
|
|
1255
|
-
const className = ref.slice(
|
|
1330
|
+
const className = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1256
1331
|
const renamed = classToDtoId.get(className);
|
|
1257
1332
|
if (renamed !== void 0) {
|
|
1258
1333
|
ids.add(renamed);
|
|
@@ -1269,7 +1344,7 @@ var collectOutputExposedIds = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, clas
|
|
|
1269
1344
|
if (!isPlainRecord2(pathItem)) {
|
|
1270
1345
|
continue;
|
|
1271
1346
|
}
|
|
1272
|
-
for (const operation of
|
|
1347
|
+
for (const operation of operationsOfPathItem(pathItem)) {
|
|
1273
1348
|
collectRefsFromResponses(operation.responses, classToDtoId, knownIds, ids);
|
|
1274
1349
|
}
|
|
1275
1350
|
}
|
|
@@ -1288,7 +1363,7 @@ var collectRefsFromResponses = /* @__PURE__ */ chunkEV5I5HGT_js.__name((response
|
|
|
1288
1363
|
}, "collectRefsFromResponses");
|
|
1289
1364
|
|
|
1290
1365
|
// src/document/errors.ts
|
|
1291
|
-
var ZodNestDocumentError = class extends
|
|
1366
|
+
var ZodNestDocumentError = class extends chunkJ2MGUXBB_js.ZodNestError {
|
|
1292
1367
|
static {
|
|
1293
1368
|
chunkEV5I5HGT_js.__name(this, "ZodNestDocumentError");
|
|
1294
1369
|
}
|
|
@@ -1308,10 +1383,10 @@ var assertNoDanglingRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
|
1308
1383
|
const schemas = doc.components?.schemas ?? {};
|
|
1309
1384
|
const dangling = [];
|
|
1310
1385
|
walkRefs(doc, (ref) => {
|
|
1311
|
-
if (!ref.startsWith(
|
|
1386
|
+
if (!ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX)) {
|
|
1312
1387
|
return void 0;
|
|
1313
1388
|
}
|
|
1314
|
-
const target = ref.slice(
|
|
1389
|
+
const target = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1315
1390
|
if (!(target in schemas)) {
|
|
1316
1391
|
dangling.push(ref);
|
|
1317
1392
|
}
|
|
@@ -1327,7 +1402,7 @@ ${lines.join("\n")}`, {
|
|
|
1327
1402
|
});
|
|
1328
1403
|
}, "assertNoDanglingRefs");
|
|
1329
1404
|
var hintFor = /* @__PURE__ */ chunkEV5I5HGT_js.__name((ref, collected) => {
|
|
1330
|
-
const id = ref.slice(
|
|
1405
|
+
const id = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1331
1406
|
const usedInput = collected.inputExposedIds.has(id);
|
|
1332
1407
|
const usedOutput = collected.outputExposedIds.has(id);
|
|
1333
1408
|
if (usedInput && usedOutput) {
|
|
@@ -1406,7 +1481,7 @@ var buildRefQueryParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body)
|
|
|
1406
1481
|
style: "form",
|
|
1407
1482
|
explode: true,
|
|
1408
1483
|
schema: {
|
|
1409
|
-
$ref: `${
|
|
1484
|
+
$ref: `${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${marker.dtoId}`
|
|
1410
1485
|
}
|
|
1411
1486
|
};
|
|
1412
1487
|
}, "buildRefQueryParam");
|
|
@@ -1482,7 +1557,7 @@ var pruneOrphanObjectSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc) => {
|
|
|
1482
1557
|
return;
|
|
1483
1558
|
}
|
|
1484
1559
|
let referenced = false;
|
|
1485
|
-
const targetRef = `${
|
|
1560
|
+
const targetRef = `${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}Object`;
|
|
1486
1561
|
walkRefs(doc, (ref) => {
|
|
1487
1562
|
if (ref === targetRef) {
|
|
1488
1563
|
referenced = true;
|
|
@@ -1512,10 +1587,10 @@ var closeOverRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((seed, bodies) => {
|
|
|
1512
1587
|
continue;
|
|
1513
1588
|
}
|
|
1514
1589
|
walkRefs(body, (ref) => {
|
|
1515
|
-
if (!ref.startsWith(
|
|
1590
|
+
if (!ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX)) {
|
|
1516
1591
|
return void 0;
|
|
1517
1592
|
}
|
|
1518
|
-
const target = ref.slice(
|
|
1593
|
+
const target = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1519
1594
|
if (out.has(target)) {
|
|
1520
1595
|
return void 0;
|
|
1521
1596
|
}
|
|
@@ -1548,7 +1623,7 @@ var inlineAnonymousBodies = /* @__PURE__ */ chunkEV5I5HGT_js.__name(({ doc, regi
|
|
|
1548
1623
|
]) {
|
|
1549
1624
|
const body = schemas[key];
|
|
1550
1625
|
if (isPlainRecord4(body)) {
|
|
1551
|
-
bodyByRef.set(`${
|
|
1626
|
+
bodyByRef.set(`${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${key}`, body);
|
|
1552
1627
|
}
|
|
1553
1628
|
}
|
|
1554
1629
|
}
|
|
@@ -1560,7 +1635,7 @@ var inlineAnonymousBodies = /* @__PURE__ */ chunkEV5I5HGT_js.__name(({ doc, regi
|
|
|
1560
1635
|
}
|
|
1561
1636
|
inlineRefs(doc.paths, bodyByRef);
|
|
1562
1637
|
for (const ref of bodyByRef.keys()) {
|
|
1563
|
-
delete schemas[ref.slice(
|
|
1638
|
+
delete schemas[ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length)];
|
|
1564
1639
|
}
|
|
1565
1640
|
}, "inlineAnonymousBodies");
|
|
1566
1641
|
var refsWithin = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schemas, bodyByRef) => {
|
|
@@ -1599,6 +1674,64 @@ var inlineRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, bodyByRef) => {
|
|
|
1599
1674
|
inlineRefs(value, bodyByRef);
|
|
1600
1675
|
}
|
|
1601
1676
|
}, "inlineRefs");
|
|
1677
|
+
|
|
1678
|
+
// src/document/item-schema.ts
|
|
1679
|
+
var isRecord3 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object", "isRecord");
|
|
1680
|
+
var applyItemSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts) => {
|
|
1681
|
+
forEachOperation(doc, (operation) => {
|
|
1682
|
+
visitContentHolder(operation.requestBody, opts.emit);
|
|
1683
|
+
const responses = operation.responses;
|
|
1684
|
+
if (!isRecord3(responses)) {
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
for (const response of Object.values(responses)) {
|
|
1688
|
+
visitContentHolder(response, opts.emit);
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}, "applyItemSchema");
|
|
1692
|
+
var visitContentHolder = /* @__PURE__ */ chunkEV5I5HGT_js.__name((holder, emit) => {
|
|
1693
|
+
if (!isRecord3(holder)) {
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const content = holder.content;
|
|
1697
|
+
if (!isRecord3(content)) {
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
for (const [mediaTypeKey, mediaType] of Object.entries(content)) {
|
|
1701
|
+
if (!isRecord3(mediaType)) {
|
|
1702
|
+
continue;
|
|
1703
|
+
}
|
|
1704
|
+
rewriteMediaType(mediaTypeKey, mediaType, emit);
|
|
1705
|
+
}
|
|
1706
|
+
}, "visitContentHolder");
|
|
1707
|
+
var rewriteMediaType = /* @__PURE__ */ chunkEV5I5HGT_js.__name((mediaTypeKey, mediaType, emit) => {
|
|
1708
|
+
const marked = mediaType[chunkJ2MGUXBB_js.ZOD_NEST_ITEM_STREAM_EXTENSION] === true;
|
|
1709
|
+
delete mediaType[chunkJ2MGUXBB_js.ZOD_NEST_ITEM_STREAM_EXTENSION];
|
|
1710
|
+
if (!emit) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
if (!marked && !isSequentialMediaType(mediaTypeKey)) {
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
const itemSchema = itemSchemaOf(mediaType.schema);
|
|
1717
|
+
if (itemSchema === void 0) {
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
mediaType.itemSchema = itemSchema;
|
|
1721
|
+
delete mediaType.schema;
|
|
1722
|
+
}, "rewriteMediaType");
|
|
1723
|
+
var itemSchemaOf = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema) => {
|
|
1724
|
+
if (!isRecord3(schema)) {
|
|
1725
|
+
return void 0;
|
|
1726
|
+
}
|
|
1727
|
+
if (schema.type !== "array") {
|
|
1728
|
+
return schema;
|
|
1729
|
+
}
|
|
1730
|
+
if (Object.keys(schema).length !== 2 || !("items" in schema)) {
|
|
1731
|
+
return void 0;
|
|
1732
|
+
}
|
|
1733
|
+
return isRecord3(schema.items) ? schema.items : void 0;
|
|
1734
|
+
}, "itemSchemaOf");
|
|
1602
1735
|
var mergeSchemas = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
1603
1736
|
const { doc, inputSchemas, outputSchemas, collected, collisions } = params;
|
|
1604
1737
|
const schemas = ensureComponentsSchemas(doc);
|
|
@@ -1698,7 +1831,7 @@ var isMarkerPlaceholder = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => {
|
|
|
1698
1831
|
if (properties === null || typeof properties !== "object") {
|
|
1699
1832
|
return false;
|
|
1700
1833
|
}
|
|
1701
|
-
const marker = properties[
|
|
1834
|
+
const marker = properties[chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION];
|
|
1702
1835
|
return isZodDtoMarker(marker);
|
|
1703
1836
|
}, "isMarkerPlaceholder");
|
|
1704
1837
|
var canonicalEqual = /* @__PURE__ */ chunkEV5I5HGT_js.__name((a, b) => {
|
|
@@ -1724,7 +1857,7 @@ var decorateIfPresent = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schemas, key) =
|
|
|
1724
1857
|
}
|
|
1725
1858
|
schemas[key] = {
|
|
1726
1859
|
description: `ERROR: duplicate zod-nest id <${key.replace(/Output$/, "")}>`,
|
|
1727
|
-
[
|
|
1860
|
+
[chunkJ2MGUXBB_js.ZOD_NEST_ERROR_EXTENSION]: chunkJ2MGUXBB_js.ZOD_NEST_ERROR_DUPLICATE_ID
|
|
1728
1861
|
};
|
|
1729
1862
|
}, "decorateIfPresent");
|
|
1730
1863
|
|
|
@@ -1777,8 +1910,8 @@ var addRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, titleById) =>
|
|
|
1777
1910
|
return;
|
|
1778
1911
|
}
|
|
1779
1912
|
const ref = node.$ref;
|
|
1780
|
-
if (typeof ref === "string" && ref.startsWith(
|
|
1781
|
-
const title = titleById.get(ref.slice(
|
|
1913
|
+
if (typeof ref === "string" && ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX) && node.title === void 0) {
|
|
1914
|
+
const title = titleById.get(ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length));
|
|
1782
1915
|
if (title !== void 0) {
|
|
1783
1916
|
node.title = title;
|
|
1784
1917
|
}
|
|
@@ -1793,15 +1926,15 @@ var rewriteRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
|
1793
1926
|
const { doc, renames, divergentOutputIds } = params;
|
|
1794
1927
|
if (renames.size > 0) {
|
|
1795
1928
|
walkRefs(doc, (ref) => {
|
|
1796
|
-
if (!ref.startsWith(
|
|
1929
|
+
if (!ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX)) {
|
|
1797
1930
|
return void 0;
|
|
1798
1931
|
}
|
|
1799
|
-
const target = ref.slice(
|
|
1932
|
+
const target = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1800
1933
|
const renamed = renames.get(target);
|
|
1801
1934
|
if (renamed === void 0) {
|
|
1802
1935
|
return void 0;
|
|
1803
1936
|
}
|
|
1804
|
-
return `${
|
|
1937
|
+
return `${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${renamed}`;
|
|
1805
1938
|
});
|
|
1806
1939
|
}
|
|
1807
1940
|
if (divergentOutputIds.size === 0) {
|
|
@@ -1816,24 +1949,20 @@ var rewriteRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
|
1816
1949
|
}
|
|
1817
1950
|
}, "rewriteRefs");
|
|
1818
1951
|
var rewriteResponseSubtree = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem, divergentOutputIds) => {
|
|
1819
|
-
for (const
|
|
1820
|
-
const op = pathItem[method];
|
|
1821
|
-
if (op === null || typeof op !== "object") {
|
|
1822
|
-
continue;
|
|
1823
|
-
}
|
|
1952
|
+
for (const op of operationsOfPathItem(pathItem)) {
|
|
1824
1953
|
const responses = op.responses;
|
|
1825
1954
|
if (responses === null || typeof responses !== "object") {
|
|
1826
1955
|
continue;
|
|
1827
1956
|
}
|
|
1828
1957
|
walkRefs(responses, (ref) => {
|
|
1829
|
-
if (!ref.startsWith(
|
|
1958
|
+
if (!ref.startsWith(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX)) {
|
|
1830
1959
|
return void 0;
|
|
1831
1960
|
}
|
|
1832
|
-
const target = ref.slice(
|
|
1961
|
+
const target = ref.slice(chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX.length);
|
|
1833
1962
|
if (!divergentOutputIds.has(target)) {
|
|
1834
1963
|
return void 0;
|
|
1835
1964
|
}
|
|
1836
|
-
return `${
|
|
1965
|
+
return `${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${target}${OUTPUT_SUFFIX}`;
|
|
1837
1966
|
});
|
|
1838
1967
|
}
|
|
1839
1968
|
}, "rewriteResponseSubtree");
|
|
@@ -1875,10 +2004,10 @@ var stripMarkerFromSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schema) =>
|
|
|
1875
2004
|
return;
|
|
1876
2005
|
}
|
|
1877
2006
|
const props = properties;
|
|
1878
|
-
if (!(
|
|
2007
|
+
if (!(chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION in props)) {
|
|
1879
2008
|
return;
|
|
1880
2009
|
}
|
|
1881
|
-
delete props[
|
|
2010
|
+
delete props[chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION];
|
|
1882
2011
|
if (Object.keys(props).length === 0) {
|
|
1883
2012
|
delete schema.properties;
|
|
1884
2013
|
}
|
|
@@ -1900,7 +2029,7 @@ var withForcedExposure = /* @__PURE__ */ chunkEV5I5HGT_js.__name((collected, reg
|
|
|
1900
2029
|
};
|
|
1901
2030
|
}, "withForcedExposure");
|
|
1902
2031
|
var applyZodNest = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts = {}) => {
|
|
1903
|
-
const registry = opts.registry ??
|
|
2032
|
+
const registry = opts.registry ?? chunkJ2MGUXBB_js.defaultRegistry;
|
|
1904
2033
|
const collected = collectUsage(doc, registry);
|
|
1905
2034
|
const exposed = withForcedExposure(collected, registry);
|
|
1906
2035
|
const { inputSchemas, outputSchemas } = bulkEmit({
|
|
@@ -1939,73 +2068,80 @@ var applyZodNest = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts = {}) => {
|
|
|
1939
2068
|
doc,
|
|
1940
2069
|
collected: extended
|
|
1941
2070
|
});
|
|
1942
|
-
|
|
2071
|
+
const openApiVersion = resolveOpenApiVersion(doc);
|
|
2072
|
+
if (openApiVersion.startsWith("3.2.")) {
|
|
2073
|
+
relocateExtensionOperations(doc);
|
|
2074
|
+
}
|
|
2075
|
+
applyItemSchema(doc, {
|
|
2076
|
+
emit: openApiVersion.startsWith("3.2.")
|
|
2077
|
+
});
|
|
2078
|
+
doc.openapi = openApiVersion;
|
|
1943
2079
|
return doc;
|
|
1944
2080
|
}, "applyZodNest");
|
|
1945
2081
|
|
|
1946
2082
|
Object.defineProperty(exports, "COMPONENTS_SCHEMAS_PREFIX", {
|
|
1947
2083
|
enumerable: true,
|
|
1948
|
-
get: function () { return
|
|
2084
|
+
get: function () { return chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX; }
|
|
1949
2085
|
});
|
|
1950
2086
|
Object.defineProperty(exports, "ZOD_DTO_SYMBOL", {
|
|
1951
2087
|
enumerable: true,
|
|
1952
|
-
get: function () { return
|
|
2088
|
+
get: function () { return chunkJ2MGUXBB_js.ZOD_DTO_SYMBOL; }
|
|
1953
2089
|
});
|
|
1954
2090
|
Object.defineProperty(exports, "ZOD_NEST_DTO_EXTENSION", {
|
|
1955
2091
|
enumerable: true,
|
|
1956
|
-
get: function () { return
|
|
2092
|
+
get: function () { return chunkJ2MGUXBB_js.ZOD_NEST_DTO_EXTENSION; }
|
|
1957
2093
|
});
|
|
1958
2094
|
Object.defineProperty(exports, "ZOD_NEST_ERROR_DUPLICATE_ID", {
|
|
1959
2095
|
enumerable: true,
|
|
1960
|
-
get: function () { return
|
|
2096
|
+
get: function () { return chunkJ2MGUXBB_js.ZOD_NEST_ERROR_DUPLICATE_ID; }
|
|
1961
2097
|
});
|
|
1962
2098
|
Object.defineProperty(exports, "ZOD_NEST_ERROR_EXTENSION", {
|
|
1963
2099
|
enumerable: true,
|
|
1964
|
-
get: function () { return
|
|
2100
|
+
get: function () { return chunkJ2MGUXBB_js.ZOD_NEST_ERROR_EXTENSION; }
|
|
1965
2101
|
});
|
|
1966
2102
|
Object.defineProperty(exports, "ZodNestError", {
|
|
1967
2103
|
enumerable: true,
|
|
1968
|
-
get: function () { return
|
|
2104
|
+
get: function () { return chunkJ2MGUXBB_js.ZodNestError; }
|
|
1969
2105
|
});
|
|
1970
2106
|
Object.defineProperty(exports, "ZodNestUnrepresentableError", {
|
|
1971
2107
|
enumerable: true,
|
|
1972
|
-
get: function () { return
|
|
2108
|
+
get: function () { return chunkJ2MGUXBB_js.ZodNestUnrepresentableError; }
|
|
1973
2109
|
});
|
|
1974
2110
|
Object.defineProperty(exports, "ZodValidationException", {
|
|
1975
2111
|
enumerable: true,
|
|
1976
|
-
get: function () { return
|
|
2112
|
+
get: function () { return chunkJ2MGUXBB_js.ZodValidationException; }
|
|
1977
2113
|
});
|
|
1978
2114
|
Object.defineProperty(exports, "createRegistry", {
|
|
1979
2115
|
enumerable: true,
|
|
1980
|
-
get: function () { return
|
|
2116
|
+
get: function () { return chunkJ2MGUXBB_js.createRegistry; }
|
|
1981
2117
|
});
|
|
1982
2118
|
Object.defineProperty(exports, "defaultRegistry", {
|
|
1983
2119
|
enumerable: true,
|
|
1984
|
-
get: function () { return
|
|
2120
|
+
get: function () { return chunkJ2MGUXBB_js.defaultRegistry; }
|
|
1985
2121
|
});
|
|
1986
2122
|
Object.defineProperty(exports, "extend", {
|
|
1987
2123
|
enumerable: true,
|
|
1988
|
-
get: function () { return
|
|
2124
|
+
get: function () { return chunkJ2MGUXBB_js.extend; }
|
|
1989
2125
|
});
|
|
1990
2126
|
Object.defineProperty(exports, "getLineage", {
|
|
1991
2127
|
enumerable: true,
|
|
1992
|
-
get: function () { return
|
|
2128
|
+
get: function () { return chunkJ2MGUXBB_js.getLineage; }
|
|
1993
2129
|
});
|
|
1994
2130
|
Object.defineProperty(exports, "isZodDto", {
|
|
1995
2131
|
enumerable: true,
|
|
1996
|
-
get: function () { return
|
|
2132
|
+
get: function () { return chunkJ2MGUXBB_js.isZodDto; }
|
|
1997
2133
|
});
|
|
1998
2134
|
Object.defineProperty(exports, "isZodSchema", {
|
|
1999
2135
|
enumerable: true,
|
|
2000
|
-
get: function () { return
|
|
2136
|
+
get: function () { return chunkJ2MGUXBB_js.isZodSchema; }
|
|
2001
2137
|
});
|
|
2002
2138
|
Object.defineProperty(exports, "registerSchema", {
|
|
2003
2139
|
enumerable: true,
|
|
2004
|
-
get: function () { return
|
|
2140
|
+
get: function () { return chunkJ2MGUXBB_js.registerSchema; }
|
|
2005
2141
|
});
|
|
2006
2142
|
Object.defineProperty(exports, "toOpenApi", {
|
|
2007
2143
|
enumerable: true,
|
|
2008
|
-
get: function () { return
|
|
2144
|
+
get: function () { return chunkJ2MGUXBB_js.toOpenApi; }
|
|
2009
2145
|
});
|
|
2010
2146
|
Object.defineProperty(exports, "overrideJSONSchema", {
|
|
2011
2147
|
enumerable: true,
|
|
@@ -2014,6 +2150,7 @@ Object.defineProperty(exports, "overrideJSONSchema", {
|
|
|
2014
2150
|
exports.DEFAULT_MAX_LOGGED_VALUE_BYTES = DEFAULT_MAX_LOGGED_VALUE_BYTES;
|
|
2015
2151
|
exports.DEFAULT_REDACT_KEYS = DEFAULT_REDACT_KEYS;
|
|
2016
2152
|
exports.DEFAULT_STREAM_CONTENT_TYPES = DEFAULT_STREAM_CONTENT_TYPES;
|
|
2153
|
+
exports.SEQUENTIAL_MEDIA_TYPES = SEQUENTIAL_MEDIA_TYPES;
|
|
2017
2154
|
exports.ZOD_NEST_OPTIONS = ZOD_NEST_OPTIONS;
|
|
2018
2155
|
exports.ZOD_RESPONSES_METADATA_KEY = ZOD_RESPONSES_METADATA_KEY;
|
|
2019
2156
|
exports.ZodBody = ZodBody;
|