@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/cli/main.js
CHANGED
|
@@ -2547,37 +2547,28 @@ function buildProperty(prop, classFile, ctx) {
|
|
|
2547
2547
|
const typeNode = prop.getTypeNode();
|
|
2548
2548
|
const typeText = typeNode?.getText() ?? "unknown";
|
|
2549
2549
|
const isArrayType = !!typeNode && Node3.isArrayTypeNode(typeNode);
|
|
2550
|
+
const asField = (child) => applyPresence(
|
|
2551
|
+
has("IsArray") || isArrayType ? { kind: "array", element: child } : child,
|
|
2552
|
+
decorators
|
|
2553
|
+
);
|
|
2550
2554
|
const discriminator = resolveDiscriminator(dec("Type"));
|
|
2551
2555
|
if (discriminator) {
|
|
2552
2556
|
const options = discriminator.subTypes.map(
|
|
2553
2557
|
(name) => buildNestedReference(name, classFile, ctx)
|
|
2554
2558
|
);
|
|
2555
|
-
|
|
2556
|
-
kind: "union",
|
|
2557
|
-
options,
|
|
2558
|
-
discriminator: discriminator.property
|
|
2559
|
-
};
|
|
2560
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2561
|
-
const node2 = wrapArray ? { kind: "array", element: unionNode } : unionNode;
|
|
2562
|
-
return applyPresence(node2, decorators);
|
|
2559
|
+
return asField({ kind: "union", options, discriminator: discriminator.property });
|
|
2563
2560
|
}
|
|
2564
2561
|
const propTypeParam = singularClassName(typeText);
|
|
2565
2562
|
if (propTypeParam && ctx.typeBindings.has(propTypeParam)) {
|
|
2566
2563
|
const bound = ctx.typeBindings.get(propTypeParam);
|
|
2567
|
-
|
|
2568
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2569
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
2570
|
-
return applyPresence(node2, decorators);
|
|
2564
|
+
return asField(buildNestedReference(bound, classFile, ctx));
|
|
2571
2565
|
}
|
|
2572
2566
|
const typeRefName = resolveTypeFactoryName(dec("Type"));
|
|
2573
2567
|
if (has("ValidateNested") || typeRefName) {
|
|
2574
2568
|
const typeArgs = genericTypeArgNames(typeNode);
|
|
2575
2569
|
const childName = typeRefName ?? singularClassName(typeText);
|
|
2576
2570
|
if (childName) {
|
|
2577
|
-
|
|
2578
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2579
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
2580
|
-
return applyPresence(node2, decorators);
|
|
2571
|
+
return asField(buildNestedReference(childName, classFile, ctx, typeArgs));
|
|
2581
2572
|
}
|
|
2582
2573
|
}
|
|
2583
2574
|
let base = baseFromType(typeText, isArrayType);
|
|
@@ -4438,7 +4429,7 @@ async function watch(config, onChange) {
|
|
|
4438
4429
|
}
|
|
4439
4430
|
|
|
4440
4431
|
// src/index.ts
|
|
4441
|
-
var VERSION = "0.5.
|
|
4432
|
+
var VERSION = "0.5.2";
|
|
4442
4433
|
|
|
4443
4434
|
// src/cli/codegen.ts
|
|
4444
4435
|
async function runCodegen(opts = {}) {
|