@nexus-ioc/graph-analyzer 0.1.0 → 0.2.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +63 -26
  3. package/dist/analyzer/circular-dependency-detector.d.ts +29 -9
  4. package/dist/analyzer/circular-dependency-detector.js +106 -63
  5. package/dist/analyzer/circular-dependency-detector.js.map +1 -1
  6. package/dist/analyzer/module-depth-analyzer.d.ts +10 -13
  7. package/dist/analyzer/module-depth-analyzer.js +40 -52
  8. package/dist/analyzer/module-depth-analyzer.js.map +1 -1
  9. package/dist/analyzer/provider-scope-analyzer.d.ts +7 -44
  10. package/dist/analyzer/provider-scope-analyzer.js +13 -84
  11. package/dist/analyzer/provider-scope-analyzer.js.map +1 -1
  12. package/dist/analyzer/unused-provider-detector.d.ts +11 -9
  13. package/dist/analyzer/unused-provider-detector.js +35 -55
  14. package/dist/analyzer/unused-provider-detector.js.map +1 -1
  15. package/dist/cli.js +34 -129
  16. package/dist/cli.js.map +1 -1
  17. package/dist/config/config-loader.js +3 -27
  18. package/dist/config/config-loader.js.map +1 -1
  19. package/dist/config/config-schema.d.ts +2 -16
  20. package/dist/config/config-schema.js +0 -18
  21. package/dist/config/config-schema.js.map +1 -1
  22. package/dist/graph/build-nexus-graph-model.d.ts +13 -0
  23. package/dist/graph/build-nexus-graph-model.js +202 -0
  24. package/dist/graph/build-nexus-graph-model.js.map +1 -0
  25. package/dist/graph/nexus-graph-model.d.ts +112 -0
  26. package/dist/graph/nexus-graph-model.js +10 -0
  27. package/dist/graph/nexus-graph-model.js.map +1 -0
  28. package/dist/graph/scope-resolution.d.ts +16 -0
  29. package/dist/graph/scope-resolution.js +46 -0
  30. package/dist/graph/scope-resolution.js.map +1 -0
  31. package/dist/index.d.ts +27 -29
  32. package/dist/index.js +34 -34
  33. package/dist/index.js.map +1 -1
  34. package/dist/interfaces/graph-output.interface.d.ts +49 -14
  35. package/dist/utils/error-formatter.js +1 -6
  36. package/dist/utils/error-formatter.js.map +1 -1
  37. package/dist/utils/validator.d.ts +0 -5
  38. package/dist/utils/validator.js +0 -60
  39. package/dist/utils/validator.js.map +1 -1
  40. package/dist/visualize/json-formatter.d.ts +5 -6
  41. package/dist/visualize/json-formatter.js +49 -47
  42. package/dist/visualize/json-formatter.js.map +1 -1
  43. package/package.json +5 -4
  44. package/dist/interfaces/providers.interface.d.ts +0 -10
  45. package/dist/interfaces/providers.interface.js +0 -3
  46. package/dist/interfaces/providers.interface.js.map +0 -1
  47. package/dist/parser/dependency-extractor.d.ts +0 -88
  48. package/dist/parser/dependency-extractor.js +0 -334
  49. package/dist/parser/dependency-extractor.js.map +0 -1
  50. package/dist/parser/parse-entry-file.d.ts +0 -15
  51. package/dist/parser/parse-entry-file.js +0 -46
  52. package/dist/parser/parse-entry-file.js.map +0 -1
  53. package/dist/parser/parse-imports.d.ts +0 -15
  54. package/dist/parser/parse-imports.js +0 -65
  55. package/dist/parser/parse-imports.js.map +0 -1
  56. package/dist/parser/parse-ns-module.d.ts +0 -39
  57. package/dist/parser/parse-ns-module.js +0 -122
  58. package/dist/parser/parse-ns-module.js.map +0 -1
  59. package/dist/parser/parse-provider.d.ts +0 -2
  60. package/dist/parser/parse-provider.js +0 -7
  61. package/dist/parser/parse-provider.js.map +0 -1
  62. package/dist/parser/parse-ts-config.d.ts +0 -10
  63. package/dist/parser/parse-ts-config.js +0 -40
  64. package/dist/parser/parse-ts-config.js.map +0 -1
  65. package/dist/parser/parser-rec.d.ts +0 -1
  66. package/dist/parser/parser-rec.js +0 -52
  67. package/dist/parser/parser-rec.js.map +0 -1
  68. package/dist/parser/parser.d.ts +0 -1
  69. package/dist/parser/parser.js +0 -61
  70. package/dist/parser/parser.js.map +0 -1
  71. package/dist/parser/provider/class-parser.d.ts +0 -20
  72. package/dist/parser/provider/class-parser.js +0 -137
  73. package/dist/parser/provider/class-parser.js.map +0 -1
  74. package/dist/parser/provider/providers-parser.d.ts +0 -9
  75. package/dist/parser/provider/providers-parser.js +0 -32
  76. package/dist/parser/provider/providers-parser.js.map +0 -1
  77. package/dist/parser/provider/use-class-parser.d.ts +0 -25
  78. package/dist/parser/provider/use-class-parser.js +0 -161
  79. package/dist/parser/provider/use-class-parser.js.map +0 -1
  80. package/dist/parser/provider/use-factory-parser.d.ts +0 -15
  81. package/dist/parser/provider/use-factory-parser.js +0 -53
  82. package/dist/parser/provider/use-factory-parser.js.map +0 -1
  83. package/dist/parser/provider/use-value-parser.d.ts +0 -13
  84. package/dist/parser/provider/use-value-parser.js +0 -41
  85. package/dist/parser/provider/use-value-parser.js.map +0 -1
  86. package/dist/parser/rules.d.ts +0 -10
  87. package/dist/parser/rules.js +0 -37
  88. package/dist/parser/rules.js.map +0 -1
  89. package/dist/visualize/generator.d.ts +0 -26
  90. package/dist/visualize/generator.js +0 -75
  91. package/dist/visualize/generator.js.map +0 -1
  92. package/dist/visualize/graph-analyzer.d.ts +0 -126
  93. package/dist/visualize/graph-analyzer.js +0 -199
  94. package/dist/visualize/graph-analyzer.js.map +0 -1
  95. package/dist/visualize/html-generator.d.ts +0 -71
  96. package/dist/visualize/html-generator.js +0 -1312
  97. package/dist/visualize/html-generator.js.map +0 -1
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildNexusGraphModel = buildNexusGraphModel;
4
+ const scope_resolution_1 = require("./scope-resolution");
5
+ /**
6
+ * Builds the `NexusGraphModel` the analyzers in this package operate on,
7
+ * from `@nexus-ioc/type-checker`'s semantic `NexusApplication`. Every node
8
+ * is keyed by `NexusClass.id`/`NexusToken.id` (a stable `file:line:col`),
9
+ * not by rendered name — two classes named alike in different files never
10
+ * collide here.
11
+ *
12
+ * `application.classes[0]` is always the entry point's own class (see
13
+ * `NexusApplicationAnalyzer.analyze`, which seeds and processes it first).
14
+ */
15
+ function buildNexusGraphModel(application) {
16
+ const classesById = indexClassesById(application.classes);
17
+ const modules = new Map();
18
+ for (const nexusClass of application.classes) {
19
+ if (!nexusClass.module)
20
+ continue;
21
+ modules.set(nexusClass.id, {
22
+ name: moduleName(nexusClass),
23
+ id: nexusClass.id,
24
+ path: nexusClass.source.fileName,
25
+ isGlobal: nexusClass.isGlobal,
26
+ imports: nexusClass.module.imports.map((entry) => buildModuleReference(entry.module, classesById)),
27
+ exports: nexusClass.module.exports.map((entry) => buildModuleReference(entry.token, classesById)),
28
+ providers: nexusClass.module.providers.map((provider) => buildProviderNode(provider, classesById)),
29
+ });
30
+ }
31
+ const graphModel = {
32
+ entryModuleId: application.classes[0]?.id ?? "",
33
+ modules,
34
+ };
35
+ const scopes = application.scopes ?? [];
36
+ if (scopes.length > 1) {
37
+ applyScopes(graphModel, application, classesById);
38
+ }
39
+ return graphModel;
40
+ }
41
+ /**
42
+ * Adds child-scope information to a graph built from an application that
43
+ * declares `children`: `scopes`, each module's `scope` and `children`, and
44
+ * `crossScope` on dependencies a child-scope provider gets from an ancestor
45
+ * scope. A module present in several scopes is tagged with the first one.
46
+ */
47
+ function applyScopes(graphModel, application, classesById) {
48
+ const { modules } = graphModel;
49
+ graphModel.scopes = application.scopes.map((scope) => {
50
+ const graphScope = {
51
+ rootId: scope.rootId,
52
+ moduleIds: scope.classIds.filter((id) => modules.has(id)),
53
+ };
54
+ if (scope.declaredInId !== undefined) {
55
+ graphScope.declaredInId = scope.declaredInId;
56
+ }
57
+ if (scope.parentRootId !== undefined) {
58
+ graphScope.parentRootId = scope.parentRootId;
59
+ }
60
+ return graphScope;
61
+ });
62
+ for (const scope of graphModel.scopes) {
63
+ for (const moduleId of scope.moduleIds) {
64
+ const module = modules.get(moduleId);
65
+ if (module && module.scope === undefined)
66
+ module.scope = scope.rootId;
67
+ }
68
+ }
69
+ for (const nexusClass of application.classes) {
70
+ const module = modules.get(nexusClass.id);
71
+ const children = (nexusClass.module?.children ?? []).filter((child) => child.module !== undefined);
72
+ if (module && children.length > 0) {
73
+ module.children = children.map((child) => buildModuleReference(child.module, classesById));
74
+ }
75
+ }
76
+ const scopeIndex = new scope_resolution_1.GraphScopeIndex(graphModel);
77
+ for (const module of modules.values()) {
78
+ const scope = module.scope;
79
+ if (scope === undefined)
80
+ continue;
81
+ for (const provider of module.providers) {
82
+ for (const dependency of provider.dependencies) {
83
+ if (!dependency.tokenId)
84
+ continue;
85
+ const providingScope = scopeIndex.providingScope(scope, dependency.tokenId);
86
+ if (providingScope !== undefined && providingScope !== scope) {
87
+ dependency.crossScope = true;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ function moduleName(nexusClass) {
94
+ if (!nexusClass)
95
+ return "";
96
+ return (nexusClass.name ??
97
+ `<anonymous:${nexusClass.source.fileName}:${nexusClass.source.start}>`);
98
+ }
99
+ function buildModuleReference(token, classesById) {
100
+ const id = tokenIdentity(token) ?? "";
101
+ return {
102
+ id,
103
+ name: renderToken(token),
104
+ path: classesById.get(id)?.source.fileName,
105
+ };
106
+ }
107
+ function buildProviderNode(provider, classesById) {
108
+ const implementationToken = provider.kind === "useClass" ? provider.useClass : provider.provide;
109
+ const implementationClass = resolveImplementationClass(implementationToken, classesById);
110
+ return {
111
+ token: renderToken(provider.provide),
112
+ id: tokenIdentity(provider.provide) ?? "",
113
+ type: renderProviderType(provider.kind),
114
+ scope: provider.scope ? renderToken(provider.scope) : undefined,
115
+ useClass: provider.kind === "useClass" ? renderToken(provider.useClass) : undefined,
116
+ dependencies: provider.kind === "useFactory"
117
+ ? provider.factoryInject.map((token) => ({
118
+ token: renderToken(token),
119
+ tokenId: tokenIdentity(token),
120
+ optional: false,
121
+ }))
122
+ : resolveClassDependencies(implementationClass),
123
+ undeclaredDependencies: buildUndeclaredDependencies(implementationClass),
124
+ };
125
+ }
126
+ function resolveImplementationClass(token, classesById) {
127
+ if (token?.kind !== "reference")
128
+ return undefined;
129
+ return classesById.get(token.id);
130
+ }
131
+ function resolveClassDependencies(nexusClass) {
132
+ if (!nexusClass)
133
+ return [];
134
+ return nexusClass.dependencies.map((dependency) => ({
135
+ token: renderToken(dependency.token),
136
+ tokenId: tokenIdentity(dependency.token),
137
+ optional: dependency.optional,
138
+ }));
139
+ }
140
+ function buildUndeclaredDependencies(nexusClass) {
141
+ if (!nexusClass)
142
+ return [];
143
+ return nexusClass.undeclaredDependencies.map((dependency) => ({
144
+ location: dependency.location,
145
+ name: dependency.name,
146
+ token: renderToken(dependency.inferredType),
147
+ isInferredTypeInjectable: dependency.isInferredTypeInjectable,
148
+ }));
149
+ }
150
+ function renderProviderType(kind) {
151
+ switch (kind) {
152
+ case "class":
153
+ return "Class";
154
+ case "useClass":
155
+ return "UseClass";
156
+ case "useValue":
157
+ return "UseValue";
158
+ case "useFactory":
159
+ return "UseFactory";
160
+ }
161
+ }
162
+ function renderToken(token) {
163
+ if (!token)
164
+ return "<unknown>";
165
+ switch (token.kind) {
166
+ case "string":
167
+ return token.value;
168
+ case "reference":
169
+ return token.symbol.getName();
170
+ case "symbol":
171
+ return token.declaration ? token.declaration.getName() : "<symbol>";
172
+ case "expression":
173
+ return "<expression>";
174
+ }
175
+ }
176
+ /**
177
+ * Collision-free identity for a token, as opposed to `renderToken()`'s
178
+ * human-readable label. Analyzers must match/key by this, never by the
179
+ * rendered name — see `NexusGraphModel`'s doc comment.
180
+ */
181
+ function tokenIdentity(token) {
182
+ if (!token)
183
+ return undefined;
184
+ switch (token.kind) {
185
+ case "string":
186
+ return `string:${token.value}`;
187
+ case "reference":
188
+ return token.id;
189
+ case "symbol":
190
+ return token.id ? `symbol:${token.id}` : undefined;
191
+ case "expression":
192
+ return undefined;
193
+ }
194
+ }
195
+ function indexClassesById(classes) {
196
+ const map = new Map();
197
+ for (const nexusClass of classes) {
198
+ map.set(nexusClass.id, nexusClass);
199
+ }
200
+ return map;
201
+ }
202
+ //# sourceMappingURL=build-nexus-graph-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-nexus-graph-model.js","sourceRoot":"","sources":["../../src/graph/build-nexus-graph-model.ts"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EAAE,CAAC;QAClC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * String-keyed intermediate representation of a Nexus IoC application graph,
3
+ * built from `@nexus-ioc/type-checker`'s `NexusApplication`/`NexusApplicationGraph`.
4
+ * The four analyzers in this package operate on this shape rather than on
5
+ * `ts.Program`/`ts.Symbol` directly, keeping their algorithms (DFS, BFS)
6
+ * independent of the underlying semantic-analysis layer.
7
+ */
8
+ export interface GraphProviderDependency {
9
+ /** Rendered identity of the dependency's token. */
10
+ token: string;
11
+ /** Internal-only collision-free identity of the resolved dependency
12
+ * (`NexusToken.id`-derived), when resolvable — never serialized to
13
+ * public JSON. Analyzers must match dependencies by this, not `token`. */
14
+ tokenId?: string;
15
+ optional: boolean;
16
+ /** Set (to `true`) only when the provider lives in a child scope and the
17
+ * dependency is provided by an ancestor scope instead of its own.
18
+ *
19
+ * Approximate: "provided" means some module of the scope registers the
20
+ * token, not that the token is visible to the provider's module under
21
+ * imports/exports rules (this model has no `ts.Program` to apply them).
22
+ * For the visibility-correct answer use `@nexus-ioc/type-checker`'s
23
+ * `NexusResolvedDependency.fromParentScope`. */
24
+ crossScope?: boolean;
25
+ }
26
+ /** A constructor parameter or property whose type resolves to a class but
27
+ * carries no `@Inject` — a likely-missing-decorator diagnostic, not a real
28
+ * dependency edge. Mirrors `@nexus-ioc/type-checker`'s
29
+ * `NexusUndeclaredDependency`, rendered down to display strings. */
30
+ export interface GraphUndeclaredDependency {
31
+ location: "constructor" | "property";
32
+ name: string;
33
+ /** Rendered identity of the inferred class type. */
34
+ token: string;
35
+ isInferredTypeInjectable: boolean;
36
+ }
37
+ export interface GraphProviderNode {
38
+ /** Rendered identity of the provider's `provide` token. */
39
+ token: string;
40
+ /** Internal-only collision-free identity of this provider's `provide`
41
+ * token — never serialized to public JSON. Analyzers must match
42
+ * providers by this, not `token`. */
43
+ id: string;
44
+ type: "Class" | "UseValue" | "UseFactory" | "UseClass";
45
+ /** Rendered scope token, if the provider declares one (e.g. "Transient"). */
46
+ scope?: string;
47
+ /**
48
+ * Every dependency this provider's resolution can cycle through:
49
+ * constructor/property-injected dependencies of the underlying class for
50
+ * `Class`/`UseClass` providers, and `inject` tokens for `UseFactory`
51
+ * providers. Merging both into one list is what lets circular-dependency
52
+ * detection cover constructor-injection cycles *and* factory-inject
53
+ * cycles, which neither prior implementation did on its own.
54
+ */
55
+ dependencies: GraphProviderDependency[];
56
+ /** Constructor parameters/properties that look like dependencies but have
57
+ * no `@Inject` — see `GraphUndeclaredDependency`. */
58
+ undeclaredDependencies: GraphUndeclaredDependency[];
59
+ /** Rendered identity of the `useClass` token, for `UseClass` providers. */
60
+ useClass?: string;
61
+ }
62
+ /** A reference to a module or exported token from `GraphModuleNode.imports`/
63
+ * `exports`. `path` disambiguates same-named modules/tokens declared in
64
+ * different files — the reason renderers can resolve edges correctly even
65
+ * when `name` collides. `id` is internal-only (never serialized to public
66
+ * JSON); the public `ModuleInfo.imports`/`exports` shape is `{name, path}`. */
67
+ export interface GraphModuleReference {
68
+ /** Internal-only collision-free identity — never serialized to public JSON. */
69
+ id: string;
70
+ name: string;
71
+ path?: string;
72
+ }
73
+ export interface GraphModuleNode {
74
+ name: string;
75
+ /** Internal-only collision-free identity of this module (this node's key
76
+ * in `NexusGraphModel.modules`) — never serialized to public JSON. */
77
+ id: string;
78
+ path: string;
79
+ isGlobal: boolean;
80
+ /** Modules imported by this module. */
81
+ imports: GraphModuleReference[];
82
+ /** Tokens this module exports. */
83
+ exports: GraphModuleReference[];
84
+ providers: GraphProviderNode[];
85
+ /** `rootId` of the (first) scope this module belongs to. Present only
86
+ * when the application has child scopes (`NexusGraphModel.scopes`). */
87
+ scope?: string;
88
+ /** Statically resolved `@Module({ children })` entries. Present only when
89
+ * non-empty. Children are not imports: they open a child scope. */
90
+ children?: GraphModuleReference[];
91
+ }
92
+ /** A container scope: the application root, or a child module's scope.
93
+ * Mirrors `@nexus-ioc/type-checker`'s `NexusScope`, restricted to modules. */
94
+ export interface GraphScope {
95
+ rootId: string;
96
+ /** Module id that declares this child scope; absent for the root scope. */
97
+ declaredInId?: string;
98
+ /** Parent scope's `rootId`; absent for the root scope. */
99
+ parentRootId?: string;
100
+ /** Ids of the modules in this scope, in discovery order. */
101
+ moduleIds: string[];
102
+ }
103
+ export interface NexusGraphModel {
104
+ entryModuleId: string;
105
+ /** Keyed by `GraphModuleNode.id`, not `name` — two modules named alike in
106
+ * different files never collide here. */
107
+ modules: Map<string, GraphModuleNode>;
108
+ /** Root scope first, then each child scope. Present only when the
109
+ * application declares at least one child scope via `children`; a
110
+ * single-scope application leaves it `undefined`. */
111
+ scopes?: GraphScope[];
112
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * String-keyed intermediate representation of a Nexus IoC application graph,
4
+ * built from `@nexus-ioc/type-checker`'s `NexusApplication`/`NexusApplicationGraph`.
5
+ * The four analyzers in this package operate on this shape rather than on
6
+ * `ts.Program`/`ts.Symbol` directly, keeping their algorithms (DFS, BFS)
7
+ * independent of the underlying semantic-analysis layer.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=nexus-graph-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-graph-model.js","sourceRoot":"","sources":["../../src/graph/nexus-graph-model.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
@@ -0,0 +1,16 @@
1
+ import type { NexusGraphModel } from "./nexus-graph-model";
2
+ /**
3
+ * Scope lookups over `NexusGraphModel.scopes`. A token needed in a child
4
+ * scope is created by the nearest scope (the scope itself first, then its
5
+ * ancestors) that registers a provider for it — the runtime's "local first,
6
+ * then through the parent link" rule, approximated by "registered anywhere
7
+ * in the scope" rather than by full module visibility.
8
+ */
9
+ export declare class GraphScopeIndex {
10
+ private readonly scopesByRootId;
11
+ private readonly providerIdsByScope;
12
+ constructor(graphModel: NexusGraphModel);
13
+ /** `rootId` of the nearest scope, starting at `scopeRootId`, that
14
+ * registers `tokenId`; `undefined` when no scope on the chain does. */
15
+ providingScope(scopeRootId: string, tokenId: string): string | undefined;
16
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphScopeIndex = void 0;
4
+ /**
5
+ * Scope lookups over `NexusGraphModel.scopes`. A token needed in a child
6
+ * scope is created by the nearest scope (the scope itself first, then its
7
+ * ancestors) that registers a provider for it — the runtime's "local first,
8
+ * then through the parent link" rule, approximated by "registered anywhere
9
+ * in the scope" rather than by full module visibility.
10
+ */
11
+ class GraphScopeIndex {
12
+ constructor(graphModel) {
13
+ this.scopesByRootId = new Map();
14
+ this.providerIdsByScope = new Map();
15
+ for (const scope of graphModel.scopes ?? []) {
16
+ this.scopesByRootId.set(scope.rootId, scope);
17
+ const providerIds = new Set();
18
+ for (const moduleId of scope.moduleIds) {
19
+ for (const provider of graphModel.modules.get(moduleId)?.providers ??
20
+ []) {
21
+ providerIds.add(provider.id);
22
+ }
23
+ }
24
+ this.providerIdsByScope.set(scope.rootId, providerIds);
25
+ }
26
+ }
27
+ /** `rootId` of the nearest scope, starting at `scopeRootId`, that
28
+ * registers `tokenId`; `undefined` when no scope on the chain does. */
29
+ providingScope(scopeRootId, tokenId) {
30
+ const seen = new Set();
31
+ let current = this.scopesByRootId.get(scopeRootId);
32
+ while (current && !seen.has(current.rootId)) {
33
+ seen.add(current.rootId);
34
+ if (this.providerIdsByScope.get(current.rootId)?.has(tokenId)) {
35
+ return current.rootId;
36
+ }
37
+ current =
38
+ current.parentRootId !== undefined
39
+ ? this.scopesByRootId.get(current.parentRootId)
40
+ : undefined;
41
+ }
42
+ return undefined;
43
+ }
44
+ }
45
+ exports.GraphScopeIndex = GraphScopeIndex;
46
+ //# sourceMappingURL=scope-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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C,EAAE,CAAC;gBAC/D,OAAO,OAAO,CAAC,MAAM,CAAC;YACvB,CAAC;YACD,OAAO;gBACN,OAAO,CAAC,YAAY,KAAK,SAAS;oBACjC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;oBAC/C,CAAC,CAAC,SAAS,CAAC;QACf,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAtCD,0CAsCC"}
package/dist/index.d.ts CHANGED
@@ -2,40 +2,38 @@
2
2
  * @packageDocumentation
3
3
  * Nexus IoC Graph Analyzer - Static analysis tool for dependency injection graphs
4
4
  *
5
- * This package provides tools to analyze and visualize Nexus IoC dependency injection graphs
6
- * without executing code. It uses TypeScript's AST to extract metadata about modules, providers,
7
- * and their dependencies.
5
+ * This package statically analyzes Nexus IoC dependency injection graphs
6
+ * without executing code. Graph construction and semantic resolution are
7
+ * delegated to `@nexus-ioc/type-checker`; this package builds a string-keyed
8
+ * `NexusGraphModel` on top of it and runs analyses that don't belong in a
9
+ * generic semantic layer: circular dependency detection (modules and
10
+ * providers), unused-provider detection, module depth/fan-in/fan-out
11
+ * metrics, and provider scope-mismatch detection.
8
12
  *
9
13
  * @example
10
14
  * ```typescript
11
- * import { GraphAnalyzer, ParseEntryFile, ParseTsConfig } from 'graph-analyzer';
15
+ * import {
16
+ * createNexusAnalyzer,
17
+ * createNexusApplicationAnalyzer,
18
+ * createNexusProgram,
19
+ * findApplicationEntryPoint,
20
+ * } from '@nexus-ioc/type-checker';
21
+ * import { buildNexusGraphModel, JsonFormatter } from '@nexus-ioc/graph-analyzer';
12
22
  *
13
- * // Parse entry file
14
- * const tsConfig = new ParseTsConfig(configContent, basePath);
15
- * const entryFile = new ParseEntryFile(sourceFile, 'src/main.ts', tsConfig);
16
- * entryFile.parse();
23
+ * const program = createNexusProgram(['src/main.ts'], './tsconfig.json');
24
+ * const entryPoint = findApplicationEntryPoint(program, 'src/main.ts')!;
25
+ * const analyzer = createNexusAnalyzer(program);
26
+ * const application = createNexusApplicationAnalyzer(analyzer).analyze(entryPoint);
27
+ * const graphModel = buildNexusGraphModel(application);
17
28
  *
18
- * // Build graph and analyze
19
- * const graph = new Map();
20
- * graph.set('entry', entryFile);
21
- *
22
- * const analyzer = new GraphAnalyzer(graph, 'src/main.ts', {
23
- * outputFormat: 'json'
24
- * });
25
- *
26
- * const output = analyzer.parse();
29
+ * const output = new JsonFormatter(graphModel, 'src/main.ts', true).format();
27
30
  * ```
28
31
  */
29
- export type { GraphMetadata, GraphOutput, ModuleInfo, ProviderInfo, } from "./interfaces/graph-output.interface";
30
- export type { ProvidersInterface } from "./interfaces/providers.interface";
31
- export type { Dependency } from "./parser/dependency-extractor";
32
- export { DependencyExtractor } from "./parser/dependency-extractor";
33
- export { ParseEntryFile } from "./parser/parse-entry-file";
34
- export { ParseNsModule } from "./parser/parse-ns-module";
35
- export { ParseTsConfig } from "./parser/parse-ts-config";
36
- export { GraphGenerator } from "./visualize/generator";
37
- export type { GraphAnalyzerOptions } from "./visualize/graph-analyzer";
38
- export { GraphAnalyzer } from "./visualize/graph-analyzer";
39
- export type { HtmlGeneratorOptions } from "./visualize/html-generator";
40
- export { HtmlGenerator } from "./visualize/html-generator";
32
+ export { type CircularDependency, type CircularDependencyAnalysis, CircularDependencyDetector, } from "./analyzer/circular-dependency-detector";
33
+ export { type DepthLevel, type ModuleDepthAnalysis, ModuleDepthAnalyzer, type ModuleDepthInfo, } from "./analyzer/module-depth-analyzer";
34
+ export { type ProviderScope, type ProviderScopeAnalysis, ProviderScopeAnalyzer, type ProviderScopeInfo, } from "./analyzer/provider-scope-analyzer";
35
+ export { type UnusedProvider, type UnusedProviderAnalysis, UnusedProviderDetector, } from "./analyzer/unused-provider-detector";
36
+ export { buildNexusGraphModel } from "./graph/build-nexus-graph-model";
37
+ export type { GraphModuleNode, GraphModuleReference, GraphProviderDependency, GraphProviderNode, GraphUndeclaredDependency, NexusGraphModel, } from "./graph/nexus-graph-model";
38
+ export type { DependencyInfo, GraphAnalysis, GraphMetadata, GraphOutput, ModuleInfo, ModuleReferenceInfo, ProviderInfo, } from "./interfaces/graph-output.interface";
41
39
  export { JsonFormatter } from "./visualize/json-formatter";
package/dist/index.js CHANGED
@@ -3,48 +3,48 @@
3
3
  * @packageDocumentation
4
4
  * Nexus IoC Graph Analyzer - Static analysis tool for dependency injection graphs
5
5
  *
6
- * This package provides tools to analyze and visualize Nexus IoC dependency injection graphs
7
- * without executing code. It uses TypeScript's AST to extract metadata about modules, providers,
8
- * and their dependencies.
6
+ * This package statically analyzes Nexus IoC dependency injection graphs
7
+ * without executing code. Graph construction and semantic resolution are
8
+ * delegated to `@nexus-ioc/type-checker`; this package builds a string-keyed
9
+ * `NexusGraphModel` on top of it and runs analyses that don't belong in a
10
+ * generic semantic layer: circular dependency detection (modules and
11
+ * providers), unused-provider detection, module depth/fan-in/fan-out
12
+ * metrics, and provider scope-mismatch detection.
9
13
  *
10
14
  * @example
11
15
  * ```typescript
12
- * import { GraphAnalyzer, ParseEntryFile, ParseTsConfig } from 'graph-analyzer';
16
+ * import {
17
+ * createNexusAnalyzer,
18
+ * createNexusApplicationAnalyzer,
19
+ * createNexusProgram,
20
+ * findApplicationEntryPoint,
21
+ * } from '@nexus-ioc/type-checker';
22
+ * import { buildNexusGraphModel, JsonFormatter } from '@nexus-ioc/graph-analyzer';
13
23
  *
14
- * // Parse entry file
15
- * const tsConfig = new ParseTsConfig(configContent, basePath);
16
- * const entryFile = new ParseEntryFile(sourceFile, 'src/main.ts', tsConfig);
17
- * entryFile.parse();
24
+ * const program = createNexusProgram(['src/main.ts'], './tsconfig.json');
25
+ * const entryPoint = findApplicationEntryPoint(program, 'src/main.ts')!;
26
+ * const analyzer = createNexusAnalyzer(program);
27
+ * const application = createNexusApplicationAnalyzer(analyzer).analyze(entryPoint);
28
+ * const graphModel = buildNexusGraphModel(application);
18
29
  *
19
- * // Build graph and analyze
20
- * const graph = new Map();
21
- * graph.set('entry', entryFile);
22
- *
23
- * const analyzer = new GraphAnalyzer(graph, 'src/main.ts', {
24
- * outputFormat: 'json'
25
- * });
26
- *
27
- * const output = analyzer.parse();
30
+ * const output = new JsonFormatter(graphModel, 'src/main.ts', true).format();
28
31
  * ```
29
32
  */
30
33
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.JsonFormatter = exports.HtmlGenerator = exports.GraphAnalyzer = exports.GraphGenerator = exports.ParseTsConfig = exports.ParseNsModule = exports.ParseEntryFile = exports.DependencyExtractor = void 0;
32
- var dependency_extractor_1 = require("./parser/dependency-extractor");
33
- Object.defineProperty(exports, "DependencyExtractor", { enumerable: true, get: function () { return dependency_extractor_1.DependencyExtractor; } });
34
- // Parser exports
35
- var parse_entry_file_1 = require("./parser/parse-entry-file");
36
- Object.defineProperty(exports, "ParseEntryFile", { enumerable: true, get: function () { return parse_entry_file_1.ParseEntryFile; } });
37
- var parse_ns_module_1 = require("./parser/parse-ns-module");
38
- Object.defineProperty(exports, "ParseNsModule", { enumerable: true, get: function () { return parse_ns_module_1.ParseNsModule; } });
39
- var parse_ts_config_1 = require("./parser/parse-ts-config");
40
- Object.defineProperty(exports, "ParseTsConfig", { enumerable: true, get: function () { return parse_ts_config_1.ParseTsConfig; } });
41
- var generator_1 = require("./visualize/generator");
42
- Object.defineProperty(exports, "GraphGenerator", { enumerable: true, get: function () { return generator_1.GraphGenerator; } });
43
- // Main exports for programmatic use
44
- var graph_analyzer_1 = require("./visualize/graph-analyzer");
45
- Object.defineProperty(exports, "GraphAnalyzer", { enumerable: true, get: function () { return graph_analyzer_1.GraphAnalyzer; } });
46
- var html_generator_1 = require("./visualize/html-generator");
47
- Object.defineProperty(exports, "HtmlGenerator", { enumerable: true, get: function () { return html_generator_1.HtmlGenerator; } });
34
+ exports.JsonFormatter = exports.buildNexusGraphModel = exports.UnusedProviderDetector = exports.ProviderScopeAnalyzer = exports.ModuleDepthAnalyzer = exports.CircularDependencyDetector = void 0;
35
+ // Analyzers
36
+ var circular_dependency_detector_1 = require("./analyzer/circular-dependency-detector");
37
+ Object.defineProperty(exports, "CircularDependencyDetector", { enumerable: true, get: function () { return circular_dependency_detector_1.CircularDependencyDetector; } });
38
+ var module_depth_analyzer_1 = require("./analyzer/module-depth-analyzer");
39
+ Object.defineProperty(exports, "ModuleDepthAnalyzer", { enumerable: true, get: function () { return module_depth_analyzer_1.ModuleDepthAnalyzer; } });
40
+ var provider_scope_analyzer_1 = require("./analyzer/provider-scope-analyzer");
41
+ Object.defineProperty(exports, "ProviderScopeAnalyzer", { enumerable: true, get: function () { return provider_scope_analyzer_1.ProviderScopeAnalyzer; } });
42
+ var unused_provider_detector_1 = require("./analyzer/unused-provider-detector");
43
+ Object.defineProperty(exports, "UnusedProviderDetector", { enumerable: true, get: function () { return unused_provider_detector_1.UnusedProviderDetector; } });
44
+ // Graph construction (built on top of @nexus-ioc/type-checker)
45
+ var build_nexus_graph_model_1 = require("./graph/build-nexus-graph-model");
46
+ Object.defineProperty(exports, "buildNexusGraphModel", { enumerable: true, get: function () { return build_nexus_graph_model_1.buildNexusGraphModel; } });
47
+ // Report output (data only — no rendering; see @nexus-ioc/graph-visualizer for PNG/HTML)
48
48
  var json_formatter_1 = require("./visualize/json-formatter");
49
49
  Object.defineProperty(exports, "JsonFormatter", { enumerable: true, get: function () { return json_formatter_1.JsonFormatter; } });
50
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAWH,sEAAoE;AAA3D,2HAAA,mBAAmB,OAAA;AAC5B,iBAAiB;AACjB,8DAA2D;AAAlD,kHAAA,cAAc,OAAA;AACvB,4DAAyD;AAAhD,gHAAA,aAAa,OAAA;AACtB,4DAAyD;AAAhD,gHAAA,aAAa,OAAA;AACtB,mDAAuD;AAA9C,2GAAA,cAAc,OAAA;AAEvB,oCAAoC;AACpC,6DAA2D;AAAlD,+GAAA,aAAa,OAAA;AAEtB,6DAA2D;AAAlD,+GAAA,aAAa,OAAA;AACtB,6DAA2D;AAAlD,+GAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAEH,YAAY;AACZ,wFAIiD;AADhD,0IAAA,0BAA0B,OAAA;AAE3B,0EAK0C;AAFzC,4HAAA,mBAAmB,OAAA;AAGpB,8EAK4C;AAF3C,gIAAA,qBAAqB,OAAA;AAGtB,gFAI6C;AAD5C,kIAAA,sBAAsB,OAAA;AAEvB,+DAA+D;AAC/D,2EAAuE;AAA9D,+HAAA,oBAAoB,OAAA;AAmB7B,yFAAyF;AACzF,6DAA2D;AAAlD,+GAAA,aAAa,OAAA"}