@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @dudousxd/nestjs-codegen
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f432450: Internal refactors (behavior-preserving): share `renderModule` across the zod/valibot adapters via a `createChainModuleRenderer` factory, and dedupe the nested-reference array-wrap + presence tail in `buildProperty` (`dto-to-ir`) behind a single `asField` closure.
|
|
8
|
+
|
|
3
9
|
## 0.5.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli/main.cjs
CHANGED
|
@@ -2571,37 +2571,28 @@ function buildProperty(prop, classFile, ctx) {
|
|
|
2571
2571
|
const typeNode = prop.getTypeNode();
|
|
2572
2572
|
const typeText = typeNode?.getText() ?? "unknown";
|
|
2573
2573
|
const isArrayType = !!typeNode && import_ts_morph4.Node.isArrayTypeNode(typeNode);
|
|
2574
|
+
const asField = (child) => applyPresence(
|
|
2575
|
+
has("IsArray") || isArrayType ? { kind: "array", element: child } : child,
|
|
2576
|
+
decorators
|
|
2577
|
+
);
|
|
2574
2578
|
const discriminator = resolveDiscriminator(dec("Type"));
|
|
2575
2579
|
if (discriminator) {
|
|
2576
2580
|
const options = discriminator.subTypes.map(
|
|
2577
2581
|
(name) => buildNestedReference(name, classFile, ctx)
|
|
2578
2582
|
);
|
|
2579
|
-
|
|
2580
|
-
kind: "union",
|
|
2581
|
-
options,
|
|
2582
|
-
discriminator: discriminator.property
|
|
2583
|
-
};
|
|
2584
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2585
|
-
const node2 = wrapArray ? { kind: "array", element: unionNode } : unionNode;
|
|
2586
|
-
return applyPresence(node2, decorators);
|
|
2583
|
+
return asField({ kind: "union", options, discriminator: discriminator.property });
|
|
2587
2584
|
}
|
|
2588
2585
|
const propTypeParam = singularClassName(typeText);
|
|
2589
2586
|
if (propTypeParam && ctx.typeBindings.has(propTypeParam)) {
|
|
2590
2587
|
const bound = ctx.typeBindings.get(propTypeParam);
|
|
2591
|
-
|
|
2592
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2593
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
2594
|
-
return applyPresence(node2, decorators);
|
|
2588
|
+
return asField(buildNestedReference(bound, classFile, ctx));
|
|
2595
2589
|
}
|
|
2596
2590
|
const typeRefName = resolveTypeFactoryName(dec("Type"));
|
|
2597
2591
|
if (has("ValidateNested") || typeRefName) {
|
|
2598
2592
|
const typeArgs = genericTypeArgNames(typeNode);
|
|
2599
2593
|
const childName = typeRefName ?? singularClassName(typeText);
|
|
2600
2594
|
if (childName) {
|
|
2601
|
-
|
|
2602
|
-
const wrapArray = has("IsArray") || isArrayType;
|
|
2603
|
-
const node2 = wrapArray ? { kind: "array", element: childNode } : childNode;
|
|
2604
|
-
return applyPresence(node2, decorators);
|
|
2595
|
+
return asField(buildNestedReference(childName, classFile, ctx, typeArgs));
|
|
2605
2596
|
}
|
|
2606
2597
|
}
|
|
2607
2598
|
let base = baseFromType(typeText, isArrayType);
|
|
@@ -4457,7 +4448,7 @@ async function watch(config, onChange) {
|
|
|
4457
4448
|
}
|
|
4458
4449
|
|
|
4459
4450
|
// src/index.ts
|
|
4460
|
-
var VERSION = "0.5.
|
|
4451
|
+
var VERSION = "0.5.2";
|
|
4461
4452
|
|
|
4462
4453
|
// src/cli/codegen.ts
|
|
4463
4454
|
async function runCodegen(opts = {}) {
|