@dudousxd/nestjs-codegen 0.5.1 → 0.5.2
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/CHANGELOG.md +6 -0
- package/dist/cli/main.cjs +8 -17
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.js +8 -17
- package/dist/cli/main.js.map +1 -1
- package/dist/extension/index.d.cts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/{index-B0mS84Jj.d.cts → index-_qRai4M3.d.cts} +1 -1
- package/dist/{index-B0mS84Jj.d.ts → index-_qRai4M3.d.ts} +1 -1
- package/dist/index.cjs +48 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +45 -17
- package/dist/index.js.map +1 -1
- package/dist/nest/index.cjs +7 -16
- package/dist/nest/index.cjs.map +1 -1
- package/dist/nest/index.d.cts +1 -1
- package/dist/nest/index.d.ts +1 -1
- package/dist/nest/index.js +7 -16
- package/dist/nest/index.js.map +1 -1
- package/package.json +2 -2
package/dist/nest/index.cjs
CHANGED
|
@@ -584,37 +584,28 @@ function buildProperty(prop, classFile, ctx) {
|
|
|
584
584
|
const typeNode = prop.getTypeNode();
|
|
585
585
|
const typeText = typeNode?.getText() ?? "unknown";
|
|
586
586
|
const isArrayType = !!typeNode && import_ts_morph2.Node.isArrayTypeNode(typeNode);
|
|
587
|
+
const asField = (child) => applyPresence(
|
|
588
|
+
has("IsArray") || isArrayType ? { kind: "array", element: child } : child,
|
|
589
|
+
decorators
|
|
590
|
+
);
|
|
587
591
|
const discriminator = resolveDiscriminator(dec("Type"));
|
|
588
592
|
if (discriminator) {
|
|
589
593
|
const options = discriminator.subTypes.map(
|
|
590
594
|
(name) => buildNestedReference(name, classFile, ctx)
|
|
591
595
|
);
|
|
592
|
-
|
|
593
|
-
kind: "union",
|
|
594
|
-
options,
|
|
595
|
-
discriminator: discriminator.property
|
|
596
|
-
};
|
|
597
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
598
|
-
const node2 = wrapArray ? { kind: "array", element: unionNode } : unionNode;
|
|
599
|
-
return applyPresence(node2, decorators);
|
|
596
|
+
return asField({ kind: "union", options, discriminator: discriminator.property });
|
|
600
597
|
}
|
|
601
598
|
const propTypeParam = singularClassName(typeText);
|
|
602
599
|
if (propTypeParam && ctx.typeBindings.has(propTypeParam)) {
|
|
603
600
|
const bound = ctx.typeBindings.get(propTypeParam);
|
|
604
|
-
|
|
605
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
606
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
607
|
-
return applyPresence(node2, decorators);
|
|
601
|
+
return asField(buildNestedReference(bound, classFile, ctx));
|
|
608
602
|
}
|
|
609
603
|
const typeRefName = resolveTypeFactoryName(dec("Type"));
|
|
610
604
|
if (has("ValidateNested") || typeRefName) {
|
|
611
605
|
const typeArgs = genericTypeArgNames(typeNode);
|
|
612
606
|
const childName = typeRefName ?? singularClassName(typeText);
|
|
613
607
|
if (childName) {
|
|
614
|
-
|
|
615
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
616
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
617
|
-
return applyPresence(node2, decorators);
|
|
608
|
+
return asField(buildNestedReference(childName, classFile, ctx, typeArgs));
|
|
618
609
|
}
|
|
619
610
|
}
|
|
620
611
|
let base = baseFromType(typeText, isArrayType);
|