@dudousxd/nestjs-codegen 0.17.2 → 0.18.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-DCF9QSPY.cjs';
2
- export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-DCF9QSPY.cjs';
1
+ import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-Dyf4ttwU.cjs';
2
+ export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-Dyf4ttwU.cjs';
3
3
  import { ClassDeclaration, SourceFile, Project } from 'ts-morph';
4
4
 
5
5
  declare function defineConfig(c: UserConfig): UserConfig;
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
382
382
  }
383
383
  declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
384
384
 
385
- declare const VERSION = "0.17.2";
385
+ declare const VERSION = "0.18.0";
386
386
 
387
387
  export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-DCF9QSPY.js';
2
- export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-DCF9QSPY.js';
1
+ import { U as UserConfig, R as ResolvedConfig, a as RouteDescriptor, S as SchemaNode, b as RenderContext, c as SchemaModule, d as RenderedModule, e as ResolvedFormsConfig, V as ValidationAdapter, C as CodegenExtension, E as ExtensionContext, f as SerializationMode } from './index-Dyf4ttwU.js';
2
+ export { A as AdapterUsage, g as ContractDescriptor, h as ContractSource, i as ControllerRef, N as NumberCheck, j as ScopeConfig, k as StringCheck, T as TypeRef, l as ValidationOption, r as resolveAdapter } from './index-Dyf4ttwU.js';
3
3
  import { ClassDeclaration, SourceFile, Project } from 'ts-morph';
4
4
 
5
5
  declare function defineConfig(c: UserConfig): UserConfig;
@@ -382,6 +382,6 @@ interface FastDiscoveryOptions {
382
382
  }
383
383
  declare function discoverContractsFast(opts: FastDiscoveryOptions): Promise<RouteDescriptor[]>;
384
384
 
385
- declare const VERSION = "0.17.2";
385
+ declare const VERSION = "0.18.0";
386
386
 
387
387
  export { type ChainModuleRendererOptions, CodegenError, type CodegenManifest, ConfigError, DriftGuardError, type EntryPoint, type FastDiscoveryOptions, type JsonSchema, type MocksEmitOptions, type OpenApiDocument, type OpenApiEmitOptions, type OpenApiInfo, RenderContext, RenderedModule, ResolvedConfig, RouteDescriptor, SchemaModule, SchemaNode, type TsTypeContext, UserConfig, VERSION, ValidationAdapter, type WatchOptions, type Watcher, acquireLock, buildMocksFile, buildOpenApiSpec, createChainModuleRenderer, defineConfig, discoverContractsFast, emitApi, emitForms, emitMocks, emitOpenApi, emitRoutes, extractSchemaFromDto, generate, loadConfig, renderTsType, resolveConfig, schemaModuleToJsonSchema, schemaNodeToJsonSchema, toObjectKey, typeNameFor, watch };
package/dist/index.js CHANGED
@@ -3512,23 +3512,52 @@ function resolveInheritedMethods(cls) {
3512
3512
  const returnedClass = resolveReturnedClass(factoryDecl);
3513
3513
  if (!returnedClass) return void 0;
3514
3514
  const classArgs = [];
3515
+ const namedClassArgs = {};
3515
3516
  for (const arg of expr.getArguments()) {
3516
- if (!Node5.isIdentifier(arg)) continue;
3517
- const decl = arg.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => Node5.isClassDeclaration(n));
3518
- if (decl) {
3519
- classArgs.push({
3520
- name: decl.getName() ?? arg.getText(),
3521
- filePath: decl.getSourceFile().getFilePath()
3522
- });
3517
+ const positional = resolveClassReference(arg);
3518
+ if (positional) {
3519
+ classArgs.push(positional);
3520
+ continue;
3521
+ }
3522
+ if (!Node5.isObjectLiteralExpression(arg)) continue;
3523
+ for (const prop of arg.getProperties()) {
3524
+ const named = resolvePropertyClassReference(prop);
3525
+ if (!named) continue;
3526
+ namedClassArgs[named.key] ??= named.ref;
3523
3527
  }
3524
3528
  }
3525
3529
  return {
3526
3530
  methods: returnedClass.getMethods(),
3527
3531
  factoryName: callee.getText(),
3528
3532
  factoryFilePath: factoryDecl.getSourceFile().getFilePath(),
3529
- classArgs
3533
+ classArgs,
3534
+ namedClassArgs
3530
3535
  };
3531
3536
  }
3537
+ function resolveClassReference(node) {
3538
+ const expr = unwrapExpression(node);
3539
+ if (!Node5.isIdentifier(expr)) return void 0;
3540
+ const decl = expr.getDefinitions().map((d) => d.getDeclarationNode()).find((n) => n !== void 0 && Node5.isClassDeclaration(n));
3541
+ if (!decl) return void 0;
3542
+ return {
3543
+ name: decl.getName() ?? expr.getText(),
3544
+ filePath: decl.getSourceFile().getFilePath()
3545
+ };
3546
+ }
3547
+ function resolvePropertyClassReference(prop) {
3548
+ if (Node5.isShorthandPropertyAssignment(prop)) {
3549
+ const ref2 = resolveClassReference(prop.getNameNode());
3550
+ return ref2 ? { key: prop.getName(), ref: ref2 } : void 0;
3551
+ }
3552
+ if (!Node5.isPropertyAssignment(prop)) return void 0;
3553
+ const init = prop.getInitializer();
3554
+ if (!init) return void 0;
3555
+ const ref = resolveClassReference(init);
3556
+ if (!ref) return void 0;
3557
+ const nameNode = prop.getNameNode();
3558
+ const key = Node5.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName();
3559
+ return { key, ref };
3560
+ }
3532
3561
  var mixinTypeProject;
3533
3562
  function getMixinTypeProject() {
3534
3563
  mixinTypeProject ??= new Project3({
@@ -3558,7 +3587,7 @@ function resolveInstantiatedReturnType(cls, methodName) {
3558
3587
 
3559
3588
  // src/discovery/filter-for.ts
3560
3589
  function resolveMixinEntityClass(mixin, project) {
3561
- const entityArg = mixin?.classArgs[0];
3590
+ const entityArg = mixin?.namedClassArgs?.entity ?? mixin?.classArgs[0];
3562
3591
  if (!entityArg) return void 0;
3563
3592
  const file = project.getSourceFile(entityArg.filePath) ?? project.addSourceFileAtPathIfExists(entityArg.filePath);
3564
3593
  return file?.getClass(entityArg.name);
@@ -4810,7 +4839,8 @@ function extractFromSourceFile(sourceFile, project) {
4810
4839
  const mixinBinding = inherited ? {
4811
4840
  factoryName: inherited.factoryName,
4812
4841
  factoryFilePath: inherited.factoryFilePath,
4813
- classArgs: inherited.classArgs
4842
+ classArgs: inherited.classArgs,
4843
+ namedClassArgs: inherited.namedClassArgs
4814
4844
  } : void 0;
4815
4845
  const ownMethods = cls.getMethods();
4816
4846
  const ownNames = new Set(ownMethods.map((m) => m.getName()));
@@ -5125,7 +5155,7 @@ function createChainModuleRenderer(opts) {
5125
5155
  }
5126
5156
 
5127
5157
  // src/index.ts
5128
- var VERSION = "0.17.2";
5158
+ var VERSION = "0.18.0";
5129
5159
  export {
5130
5160
  CodegenError,
5131
5161
  ConfigError,