@mnemonica/tactica 0.4.8 → 0.4.9

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 CHANGED
@@ -861,7 +861,8 @@ interface TacticaPlugin {
861
861
  appTokens?: Record<string, InstrumentationKind>;
862
862
  // factory calls inside listed decorators' args: factory method name ->
863
863
  // kind + which factory-call argument holds the target class (default 0)
864
- decoratorArgFactories?: Record<string, { kind: InstrumentationKind; targetArg?: number }>;
864
+ // + whether the factory constructs that target (instantiation)
865
+ decoratorArgFactories?: Record<string, { kind: InstrumentationKind; targetArg?: number; instantiation?: boolean }>;
865
866
  // opt in to shape-based `consumer.apply(Mw).forRoutes(...)` detection
866
867
  middlewareWiring?: boolean;
867
868
  }
@@ -871,7 +872,7 @@ Programmatic callers pass plugins directly: `new MnemonicaAnalyzer(program, plug
871
872
 
872
873
  - **Heritage** — `class X implements <plugin-listed interface>` (matched by interface identifier name). Bare declarations carry scope `module` (attachment statically unknown).
873
874
  - **Decorator sites** — plugin-listed decorators on classes, methods, or method parameters, including inline instances (`@Register(new Impl(…))`). One point per referenced class; scope is `controller:<Name>` or `method:<Class>.<method>` (parameter-decorated sites take the enclosing method's scope — the attachment is the handler, not the argument name).
874
- - **Decorator-arg factories** — a `CallExpression` argument of the form `<anything>.<factory>(…)` inside a listed decorator's args (class, method, or parameter position), e.g. `@UsePipes(mvp.forType(Dto))` and the parameter form `@Body(mvp.forType(Entity, Dto))`: when `<factory>` is plugin-listed, a point of the configured `kind` is emitted with the class in `targetArg` (default 0) as the target. Factory calls whose method name is not listed are ignored, as are listed factories whose configured position is not an identifier. Points resolve `location`/`code` to the target's declaration and dedupe exactly like other decorator sites.
875
+ - **Decorator-arg factories** — a `CallExpression` argument of the form `<anything>.<factory>(…)` inside a listed decorator's args (class, method, or parameter position), e.g. `@UsePipes(mvp.forType(Dto))` and the parameter form `@Body(mvp.forType(Entity, Dto))`: when `<factory>` is plugin-listed, a point of the configured `kind` is emitted with the class in `targetArg` (default 0) as the target. Factory calls whose method name is not listed are ignored, as are listed factories whose configured position is not an identifier. Points resolve `location`/`code` to the target's declaration and dedupe exactly like other decorator sites. With `instantiation: true` the plugin declares that the factory constructs its target on the caller's behalf (a pipe running `new Target(body)` per request): when the target argument resolves to a defined type — a `lookup()` alias, a type name, or a type path — the factory call is also recorded in `usages.json` and `flow.json` as an `instantiation` of that type, `constructorText` being the argument text.
875
876
  - **Global providers** — `{ provide: <plugin-listed token>, useClass: X }` object literals → scope `global`. `useExisting`/`useFactory` without `useClass` are skipped.
876
877
  - **Middleware wiring** — `consumer.apply(Mw).forRoutes(...)` inside a class's `configure()` method → scope `module`, targets from `forRoutes` arguments when statically readable. Requires `middlewareWiring: true` from any loaded plugin.
877
878
 
package/lib/analyzer.d.ts CHANGED
@@ -579,6 +579,13 @@ export declare class MnemonicaAnalyzer {
579
579
  * chain resolution for property accesses).
580
580
  */
581
581
  private resolveConstructionFnTypePath;
582
+ /**
583
+ * Resolve an expression passed where a constructor is expected (the
584
+ * Ctor of call/apply/bind, a plugin factory's constructed target) to a
585
+ * defined type's fullPath: value scope for identifiers, chain
586
+ * resolution for property accesses.
587
+ */
588
+ private resolveCtorArgTypePath;
582
589
  /**
583
590
  * instance.fork(...) / instance.clone(...) on a tracked variable —
584
591
  * runtime returns `this`, so the result carries the source type.
@@ -988,6 +995,14 @@ export declare class MnemonicaAnalyzer {
988
995
  * referenced class identifier.
989
996
  */
990
997
  private collectInstrumentationDecorator;
998
+ /**
999
+ * A plugin-listed decorator-arg factory with `instantiation: true`
1000
+ * (`@Body(mvp.forType(Entity, Dto))`) constructs the type at its
1001
+ * target argument later, at runtime: record the factory call as that
1002
+ * type's `instantiation` usage and flow, the same as call/apply. A
1003
+ * target that resolves to no defined type records nothing.
1004
+ */
1005
+ private recordFactoryConstruction;
991
1006
  /**
992
1007
  * Detect global registrations: object literals shaped like
993
1008
  * `{ provide: <plugin-listed token>, useClass: X }`.