@codependix/output 0.0.3

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.
@@ -0,0 +1,1303 @@
1
+ import { ConsoleLogger as e, Global as t, Injectable as n, Module as r, Scope as i } from "@nestjs/common";
2
+ import { existsSync as a, mkdirSync as o, readFileSync as s, writeFileSync as c } from "node:fs";
3
+ import l from "node:path";
4
+ import { CODEPENDIX_GRAPH_TYPES as u, ConfigurationModule as d, ConfigurationService as f, InputError as ee } from "@codependix/configuration";
5
+ import { NeighborhoodModule as te, NeighborhoodService as p, WorkspaceGraphModule as ne, WorkspaceGraphService as m } from "@codependix/nx-projects";
6
+ import h from "pino";
7
+ import { FileImportsWorkspaceGraphModule as re, FileImportsWorkspaceGraphService as g, PythonModule as _, PythonService as v, TypescriptModule as y, TypescriptService as b } from "@codependix/file-imports";
8
+ import { ModuleGraphModule as ie, ModuleGraphService as x, NestjsModulesWorkspaceGraphModule as ae, NestjsModulesWorkspaceGraphService as S, NestjsProjectModule as C, NestjsProjectService as w } from "@codependix/nestjs-modules";
9
+ import { BoundaryCheckModule as oe, BoundaryReportService as se } from "@codependix/boundaries";
10
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/anchors/anchors.constants.ts
11
+ var T = (e) => `<!-- codependix:start name="${e}" -->`, E = (e) => `<!-- codependix:end name="${e}" -->`, D = "## 🕸️ Codependix", O = class extends Error {
12
+ constructor(e, t) {
13
+ super(`Anchor "${e}" not found in ${t}`), this.name = "AnchorNotFoundError";
14
+ }
15
+ };
16
+ //#endregion
17
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
18
+ function k(e, t) {
19
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
20
+ }
21
+ //#endregion
22
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
23
+ function A(e, t, n, r) {
24
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
25
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
26
+ else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
27
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
28
+ }
29
+ //#endregion
30
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/anchors/anchors.service.ts
31
+ var j = class {
32
+ constructor() {}
33
+ appendCodependixSection(e) {
34
+ let t = e.fileContent.trimEnd();
35
+ return `${t.length === 0 ? "" : `${t}\n\n`}${D}\n\n${e.introLine}\n\n${e.subsectionBlock}\n`;
36
+ }
37
+ buildAnchorPattern(e) {
38
+ let t = this.escapeForPattern(T(e)), n = this.escapeForPattern(E(e));
39
+ return new RegExp(String.raw`${t}\n([\s\S]*?)\n${n}`, "u");
40
+ }
41
+ escapeForPattern(e) {
42
+ return e.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`);
43
+ }
44
+ insertIntoCodependixSection(e) {
45
+ let { fileContent: t, headingMatch: n, subsectionBlock: r } = e, i = n.index + n[0].length, a = t.slice(i), o = /\n#{1,2} /u.exec(a)?.index ?? a.length, s = a.slice(0, o).trimEnd(), c = a.slice(o), l = c.length === 0 ? "\n" : c.replace(/^\n/u, "\n\n");
46
+ return `${t.slice(0, i)}${s}\n\n${r}${l}`;
47
+ }
48
+ checkAnchor(e) {
49
+ let t = this.extractAnchorContent(e);
50
+ if (t === void 0) throw new O(e.anchorName, e.filePath);
51
+ return {
52
+ currentContent: t,
53
+ freshContent: e.freshContent,
54
+ isCurrent: t.trim() === e.freshContent.trim()
55
+ };
56
+ }
57
+ extractAnchorContent(e) {
58
+ return this.buildAnchorPattern(e.anchorName).exec(e.fileContent)?.[1];
59
+ }
60
+ hasAnchor(e) {
61
+ return this.buildAnchorPattern(e.anchorName).test(e.fileContent);
62
+ }
63
+ insertAnchorSection(e) {
64
+ let t = this.wrapInAnchors(e.anchorName, e.content), n = e.subheading === void 0 ? t : `### ${e.subheading}\n\n${t}`, r = RegExp(`^${this.escapeForPattern(D)}$`, "mu").exec(e.fileContent);
65
+ return r === null ? this.appendCodependixSection({
66
+ fileContent: e.fileContent,
67
+ introLine: e.introLine,
68
+ subsectionBlock: n
69
+ }) : this.insertIntoCodependixSection({
70
+ fileContent: e.fileContent,
71
+ headingMatch: r,
72
+ subsectionBlock: n
73
+ });
74
+ }
75
+ replaceAnchorContent(e) {
76
+ if (!this.hasAnchor(e)) throw new O(e.anchorName, e.filePath);
77
+ let t = T(e.anchorName), n = E(e.anchorName), r = e.newContent.trim();
78
+ return e.fileContent.replace(this.buildAnchorPattern(e.anchorName), () => `${t}\n${r}\n${n}`);
79
+ }
80
+ wrapInAnchors(e, t) {
81
+ return [
82
+ T(e),
83
+ t.trim(),
84
+ E(e)
85
+ ].join("\n");
86
+ }
87
+ };
88
+ j = A([n(), k("design:paramtypes", [])], j);
89
+ //#endregion
90
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/anchors/anchors.module.ts
91
+ var M = class {};
92
+ M = A([r({
93
+ controllers: [],
94
+ exports: [j],
95
+ imports: [],
96
+ providers: [j]
97
+ })], M);
98
+ //#endregion
99
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/graph-run/graph-run.constants.ts
100
+ var ce = Object.freeze({
101
+ failures: [],
102
+ results: []
103
+ }), le = Object.freeze({
104
+ failures: [],
105
+ results: [],
106
+ workspaceEntry: void 0
107
+ }), ue = "fileImports", N = "File Imports", P = "Dependency graphs exported by [codependix](https://github.com/Organizzolini/codebase/tree/main/packages/ic-suite/codependix/codependix-cli), regenerated by `nx run codebase:codependix:write`.", de = "nestjsModules", F = "NestJS Module Graph", fe = "nxProjects", pe = "Nx Neighborhood", me = "Python File Imports", I = "workspace", L = "json", R = "markdown", z = [L, R], he = {
108
+ fileImports: N,
109
+ nestjsModules: F,
110
+ nxProjects: pe
111
+ }, B = class {
112
+ anchorsService;
113
+ constructor(e) {
114
+ this.anchorsService = e;
115
+ }
116
+ printConsole(e) {
117
+ let t = e.format === "json" ? this.renderJson(e.graphs) : this.renderMarkdown(e.graphs);
118
+ process.stdout.write(`${t}\n`);
119
+ }
120
+ renderJson(e) {
121
+ let t = {};
122
+ for (let n of u) {
123
+ let r = e[n];
124
+ r !== void 0 && (t[n] = r.json);
125
+ }
126
+ return JSON.stringify(t, null, 2);
127
+ }
128
+ renderMarkdown(e) {
129
+ let t = "";
130
+ for (let n of u) {
131
+ let r = e[n];
132
+ r !== void 0 && (t = this.anchorsService.insertAnchorSection({
133
+ anchorName: n,
134
+ content: r.markdown,
135
+ fileContent: t,
136
+ introLine: P,
137
+ subheading: he[n]
138
+ }));
139
+ }
140
+ return t;
141
+ }
142
+ writeFile(e) {
143
+ let t = l.resolve(e.workingDirectory, e.path);
144
+ o(l.dirname(t), { recursive: !0 }), c(t, `${e.content}\n`, "utf8");
145
+ }
146
+ resolveFormat(e) {
147
+ if (e === void 0) return {
148
+ errors: [],
149
+ format: R
150
+ };
151
+ let t = z.find((t) => t === e);
152
+ return t === void 0 ? {
153
+ errors: [`--format does not accept "${e}". It takes one of ${z.map((e) => `"${e}"`).join(" and ")}, as in "--format ${R}".`],
154
+ format: R
155
+ } : {
156
+ errors: [],
157
+ format: t
158
+ };
159
+ }
160
+ run(e) {
161
+ this.printConsole(e), e.jsonOutputPath !== void 0 && this.writeFile({
162
+ content: this.renderJson(e.graphs),
163
+ path: e.jsonOutputPath,
164
+ workingDirectory: e.workingDirectory
165
+ }), e.markdownOutputPath !== void 0 && this.writeFile({
166
+ content: this.renderMarkdown(e.graphs),
167
+ path: e.markdownOutputPath,
168
+ workingDirectory: e.workingDirectory
169
+ });
170
+ }
171
+ };
172
+ B = A([n(), k("design:paramtypes", [j === void 0 ? Object : j])], B);
173
+ //#endregion
174
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/combined-output/combined-output.module.ts
175
+ var V = class {};
176
+ V = A([r({
177
+ controllers: [],
178
+ exports: [B],
179
+ imports: [M],
180
+ providers: [B]
181
+ })], V);
182
+ //#endregion
183
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/delivery/delivery.service.ts
184
+ var H = class {
185
+ anchorsService;
186
+ constructor(e) {
187
+ this.anchorsService = e;
188
+ }
189
+ checkAnchoredMarkdown(e) {
190
+ let t = l.resolve(e.absoluteRoot, e.path);
191
+ if (!a(t)) throw new O(e.anchorName, t);
192
+ let n = s(t, "utf8");
193
+ if (!this.anchorsService.hasAnchor({
194
+ anchorName: e.anchorName,
195
+ fileContent: n,
196
+ filePath: t
197
+ })) {
198
+ e.stalePaths.push(e.path), e.staleExports.push({
199
+ anchor: e.anchorName,
200
+ difference: "graph",
201
+ path: e.path
202
+ });
203
+ return;
204
+ }
205
+ let r = this.anchorsService.checkAnchor({
206
+ anchorName: e.anchorName,
207
+ fileContent: n,
208
+ filePath: t,
209
+ freshContent: e.content
210
+ });
211
+ r.isCurrent || (e.stalePaths.push(e.path), e.staleExports.push({
212
+ anchor: e.anchorName,
213
+ difference: this.classifyDifference(r.currentContent, e.content, "markdown"),
214
+ path: e.path
215
+ }));
216
+ }
217
+ classifyDifference(e, t, n) {
218
+ if (n === "json") {
219
+ try {
220
+ let n = JSON.parse(e), r = JSON.parse(t);
221
+ if (JSON.stringify(n) === JSON.stringify(r)) return "formatting";
222
+ } catch {
223
+ return "graph";
224
+ }
225
+ return "graph";
226
+ }
227
+ let r = e.replaceAll(/\s+/gu, " ").trim();
228
+ return r === t.replaceAll(/\s+/gu, " ").trim() && r.length > 0 ? "formatting" : "graph";
229
+ }
230
+ deliverJson(e) {
231
+ let t = l.resolve(e.absoluteRoot, e.path);
232
+ if (e.mode === "check") {
233
+ let n = this.readFileOrEmpty(t);
234
+ n !== e.content && (e.stalePaths.push(e.path), e.staleExports.push({
235
+ anchor: void 0,
236
+ difference: this.classifyDifference(n, e.content, "json"),
237
+ path: e.path
238
+ }));
239
+ return;
240
+ }
241
+ o(l.dirname(t), { recursive: !0 }), c(t, e.content, "utf8");
242
+ }
243
+ deliverMarkdown(e) {
244
+ if (e.anchor === void 0) {
245
+ let t = l.resolve(e.absoluteRoot, e.path), n = `${e.content}\n`;
246
+ if (e.mode === "check") {
247
+ let r = this.readFileOrEmpty(t);
248
+ r !== n && (e.stalePaths.push(e.path), e.staleExports.push({
249
+ anchor: void 0,
250
+ difference: this.classifyDifference(r, n, "markdown"),
251
+ path: e.path
252
+ }));
253
+ return;
254
+ }
255
+ o(l.dirname(t), { recursive: !0 }), c(t, n, "utf8");
256
+ return;
257
+ }
258
+ if (e.mode === "check") {
259
+ this.checkAnchoredMarkdown({
260
+ absoluteRoot: e.absoluteRoot,
261
+ anchorName: e.anchor,
262
+ content: e.content,
263
+ path: e.path,
264
+ staleExports: e.staleExports,
265
+ stalePaths: e.stalePaths
266
+ });
267
+ return;
268
+ }
269
+ this.writeAnchoredMarkdown({
270
+ absoluteRoot: e.absoluteRoot,
271
+ anchorName: e.anchor,
272
+ content: e.content,
273
+ markdownSection: e.markdownSection,
274
+ path: e.path
275
+ });
276
+ }
277
+ readFileOrEmpty(e) {
278
+ try {
279
+ return s(e, "utf8");
280
+ } catch {
281
+ return "";
282
+ }
283
+ }
284
+ resolveJsonDelivery(e) {
285
+ let { jsonContent: t, resolvedOutput: n } = e;
286
+ if (!(n.target !== "both" && n.target !== "json" || n.json === void 0) && t !== void 0) return {
287
+ content: t,
288
+ path: n.json.path
289
+ };
290
+ }
291
+ resolveMarkdownDelivery(e) {
292
+ let { markdownContent: t, resolvedOutput: n } = e;
293
+ if (!(n.target !== "both" && n.target !== "markdown" || n.markdown === void 0) && t !== void 0) return {
294
+ anchor: n.markdown.anchor,
295
+ content: t,
296
+ path: n.markdown.path
297
+ };
298
+ }
299
+ writeAnchoredMarkdown(e) {
300
+ let t = l.resolve(e.absoluteRoot, e.path);
301
+ if (!a(t)) throw new O(e.anchorName, t);
302
+ let n = s(t, "utf8");
303
+ if (!this.anchorsService.hasAnchor({
304
+ anchorName: e.anchorName,
305
+ fileContent: n,
306
+ filePath: t
307
+ })) {
308
+ this.writeAutoCreatedAnchorSection({
309
+ anchorName: e.anchorName,
310
+ content: e.content,
311
+ fileContent: n,
312
+ markdownSection: e.markdownSection,
313
+ resolvedPath: t
314
+ });
315
+ return;
316
+ }
317
+ let r = this.anchorsService.replaceAnchorContent({
318
+ anchorName: e.anchorName,
319
+ fileContent: n,
320
+ filePath: t,
321
+ newContent: e.content
322
+ });
323
+ r !== n && c(t, r, "utf8");
324
+ }
325
+ writeAutoCreatedAnchorSection(e) {
326
+ if (e.markdownSection === void 0) throw new O(e.anchorName, e.resolvedPath);
327
+ let t = this.anchorsService.insertAnchorSection({
328
+ anchorName: e.anchorName,
329
+ content: e.content,
330
+ fileContent: e.fileContent,
331
+ introLine: e.markdownSection.introLine,
332
+ subheading: e.markdownSection.subheading
333
+ });
334
+ return c(e.resolvedPath, t, "utf8"), !0;
335
+ }
336
+ deliverGraphOutput(e) {
337
+ let { markdownSection: t, mode: n, project: r } = e, i = [], a = [], o = this.resolveJsonDelivery(e), s = this.resolveMarkdownDelivery(e);
338
+ return o !== void 0 && this.deliverJson({
339
+ absoluteRoot: r.absoluteRoot,
340
+ content: o.content,
341
+ mode: n,
342
+ path: o.path,
343
+ staleExports: i,
344
+ stalePaths: a
345
+ }), s !== void 0 && this.deliverMarkdown({
346
+ absoluteRoot: r.absoluteRoot,
347
+ anchor: s.anchor,
348
+ content: s.content,
349
+ markdownSection: t,
350
+ mode: n,
351
+ path: s.path,
352
+ staleExports: i,
353
+ stalePaths: a
354
+ }), {
355
+ isCurrent: a.length === 0,
356
+ projectName: r.name,
357
+ staleExports: i,
358
+ stalePaths: a
359
+ };
360
+ }
361
+ renderJson(e) {
362
+ return `${JSON.stringify(e, null, 2)}\n`;
363
+ }
364
+ };
365
+ H = A([n(), k("design:paramtypes", [j === void 0 ? Object : j])], H);
366
+ //#endregion
367
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/delivery/delivery.module.ts
368
+ var U = class {};
369
+ U = A([r({
370
+ controllers: [],
371
+ exports: [H],
372
+ imports: [M],
373
+ providers: [H]
374
+ })], U);
375
+ //#endregion
376
+ //#region packages/logger/src/modules/logger/logger.constants.ts
377
+ var ge = /^(\p{Extended_Pictographic}️?(?:‍\p{Extended_Pictographic}️?)*)\s+/u, _e = /^([A-Za-z]+)/, ve = /* @__PURE__ */ new Set([
378
+ "built",
379
+ "cut",
380
+ "found",
381
+ "got",
382
+ "kept",
383
+ "left",
384
+ "lost",
385
+ "made",
386
+ "put",
387
+ "ran",
388
+ "read",
389
+ "rebuilt",
390
+ "sent",
391
+ "set",
392
+ "split",
393
+ "took",
394
+ "wrote"
395
+ ]), ye = /* @__PURE__ */ new Set([
396
+ "CommandFactory",
397
+ "ExceptionHandler",
398
+ "GraphQLModule",
399
+ "InstanceLoader",
400
+ "NestApplication",
401
+ "NestFactory",
402
+ "RouterExplorer",
403
+ "RoutesResolver",
404
+ "TypeOrmModule"
405
+ ]), W, G = class extends e {
406
+ static {
407
+ W = this;
408
+ }
409
+ constructor() {
410
+ super();
411
+ }
412
+ static isProduction = process.env.NODE_ENV === "production";
413
+ static rootLogger;
414
+ static writesToStandardError = !1;
415
+ child = W.root;
416
+ static createRootLogger() {
417
+ let e = process.env.LOG_LEVEL ?? "info";
418
+ return W.isProduction ? W.writesToStandardError ? h({ level: e }, h.destination(2)) : h({ level: e }) : h({
419
+ level: e,
420
+ transport: {
421
+ options: {
422
+ colorize: !0,
423
+ destination: W.writesToStandardError ? 2 : 1,
424
+ ignore: "pid,hostname,emoji",
425
+ messageFormat: "{emoji} {msg}",
426
+ singleLine: !0
427
+ },
428
+ target: "pino-pretty"
429
+ }
430
+ });
431
+ }
432
+ static logToStandardError() {
433
+ if (W.rootLogger !== void 0) {
434
+ process.emitWarning("LoggerService.logToStandardError() was called after the first log line, so log lines still go to standard output and anything piping that stream will read them as data. Call it as the first statement of the application's bootstrap.");
435
+ return;
436
+ }
437
+ W.writesToStandardError = !0;
438
+ }
439
+ assertConventionalMessage(e) {
440
+ if (W.isProduction || this.shouldSkipConventionalMessageValidation(e.context)) return;
441
+ let t = this.getConventionalMessageViolation(e.parsed);
442
+ if (t !== void 0) throw Error(t);
443
+ }
444
+ buildBindings(e) {
445
+ return this.assertConventionalMessage({
446
+ context: e.context,
447
+ parsed: e.parsed
448
+ }), {
449
+ ...e.data,
450
+ context: e.context,
451
+ ...W.isProduction ? {} : { emoji: e.parsed.emoji }
452
+ };
453
+ }
454
+ getConventionalMessageViolation(e) {
455
+ let t = e.emoji, n = e.text;
456
+ if (t === void 0) return `Log message must start with an emoji naming its subject, then a verb: "${n}"`;
457
+ let r = _e.exec(n)?.[1];
458
+ if (r === void 0 || !this.isConventionalVerb(r)) return `Log message must begin with a verb in present progressive or past tense, got "${r ?? ""}": "${t} ${n}"`;
459
+ }
460
+ isConventionalVerb(e) {
461
+ let t = e.toLowerCase();
462
+ return t.endsWith("ing") || t.endsWith("ed") || ve.has(t);
463
+ }
464
+ parseMessage(e) {
465
+ let t = String(e), n = ge.exec(t), r = n?.[1];
466
+ return r === void 0 ? {
467
+ emoji: void 0,
468
+ text: t
469
+ } : {
470
+ emoji: r,
471
+ text: t.slice(n?.[0].length)
472
+ };
473
+ }
474
+ shouldSkipConventionalMessageValidation(e) {
475
+ return e !== void 0 && ye.has(e);
476
+ }
477
+ static get root() {
478
+ return W.rootLogger ??= W.createRootLogger(), W.rootLogger;
479
+ }
480
+ buildErrorLogEntry(e, t) {
481
+ let n = t instanceof Error ? t.stack || t.message : String(t);
482
+ return {
483
+ errorMessage: n,
484
+ logLine: `[${(/* @__PURE__ */ new Date()).toISOString()}] ${e}: ${n}\n`
485
+ };
486
+ }
487
+ createTimestampedOutputLogFilePath(e) {
488
+ let t = l.join(process.cwd(), "output");
489
+ return a(t) || o(t, { recursive: !0 }), l.join(t, `${e}-${(/* @__PURE__ */ new Date()).toISOString().replaceAll(/[:.]/g, "-")}.log`);
490
+ }
491
+ debug(e, t, n) {
492
+ let r = this.parseMessage(e);
493
+ this.child.debug(this.buildBindings({
494
+ context: t ?? this.context,
495
+ data: n,
496
+ parsed: r
497
+ }), r.text);
498
+ }
499
+ error(e, t, n) {
500
+ let r = this.parseMessage(e), i = typeof n == "object" ? n : void 0, a = typeof n == "string" ? n : this.context;
501
+ this.child.error({
502
+ ...this.buildBindings({
503
+ context: a,
504
+ data: i,
505
+ parsed: r
506
+ }),
507
+ stack: t
508
+ }, r.text);
509
+ }
510
+ info(e, t, n) {
511
+ let r = this.parseMessage(e);
512
+ this.child.info(this.buildBindings({
513
+ context: t ?? this.context,
514
+ data: n,
515
+ parsed: r
516
+ }), r.text);
517
+ }
518
+ log(e, t, n) {
519
+ this.info(e, t, n);
520
+ }
521
+ setContext(e) {
522
+ super.setContext(e), this.child = W.root.child({ context: e });
523
+ }
524
+ verbose(e, t, n) {
525
+ let r = this.parseMessage(e);
526
+ this.child.trace(this.buildBindings({
527
+ context: t ?? this.context,
528
+ data: n,
529
+ parsed: r
530
+ }), r.text);
531
+ }
532
+ warn(e, t, n) {
533
+ let r = this.parseMessage(e);
534
+ this.child.warn(this.buildBindings({
535
+ context: t ?? this.context,
536
+ data: n,
537
+ parsed: r
538
+ }), r.text);
539
+ }
540
+ };
541
+ G = W = A([n({ scope: i.TRANSIENT }), k("design:paramtypes", [])], G);
542
+ //#endregion
543
+ //#region packages/logger/src/modules/logger/logger.module.ts
544
+ var K = class {};
545
+ K = A([t(), r({
546
+ controllers: [],
547
+ exports: [G],
548
+ imports: [],
549
+ providers: [G]
550
+ })], K);
551
+ //#endregion
552
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/project-graphs/project-graphs.service.ts
553
+ var q = class {
554
+ configurationService;
555
+ deliveryService;
556
+ moduleGraphService;
557
+ neighborhoodService;
558
+ nestjsProjectService;
559
+ typescriptService;
560
+ constructor(e, t, n, r, i, a) {
561
+ this.configurationService = e, this.deliveryService = t, this.moduleGraphService = n, this.neighborhoodService = r, this.nestjsProjectService = i, this.typescriptService = a;
562
+ }
563
+ buildMarkdownSection(e) {
564
+ return {
565
+ introLine: P,
566
+ subheading: e
567
+ };
568
+ }
569
+ buildNeighborhoodJsonExport(e) {
570
+ return {
571
+ dependencies: e.dependencies,
572
+ dependents: e.dependents,
573
+ edges: e.edges,
574
+ projectName: e.projectName
575
+ };
576
+ }
577
+ collectProjectFailure(e, t) {
578
+ return {
579
+ error: t instanceof Error ? t.message : String(t),
580
+ projectName: e
581
+ };
582
+ }
583
+ resolveProjectOutput(e) {
584
+ let { context: t, graphType: n, project: r } = e;
585
+ return this.configurationService.resolveForProject({
586
+ configuration: t.configuration,
587
+ graphType: n,
588
+ projectConfiguration: t.projectConfigurations.get(r.name),
589
+ projectName: r.name,
590
+ projectRoot: l.relative(t.workingDirectory, r.absoluteRoot),
591
+ projectTags: t.projects.find((e) => e.name === r.name)?.tags
592
+ });
593
+ }
594
+ runImportProject(e) {
595
+ let { mode: t, project: n, resolvedOutput: r } = e, i = this.typescriptService.buildProgram(n), a = this.typescriptService.buildGraph(i), o = a;
596
+ return this.deliveryService.deliverGraphOutput({
597
+ jsonContent: r.json === void 0 ? void 0 : this.deliveryService.renderJson(o),
598
+ markdownContent: r.markdown === void 0 ? void 0 : this.typescriptService.renderMermaid(a),
599
+ markdownSection: this.buildMarkdownSection(N),
600
+ mode: t,
601
+ project: n,
602
+ resolvedOutput: r
603
+ });
604
+ }
605
+ async runNestjsProject(e) {
606
+ let { mode: t, project: n, resolvedOutput: r } = e, i = await this.nestjsProjectService.exploreProject(n), a = this.moduleGraphService.buildGraph(i, n.name), o = a;
607
+ return this.deliveryService.deliverGraphOutput({
608
+ jsonContent: r.json === void 0 ? void 0 : this.deliveryService.renderJson(o),
609
+ markdownContent: r.markdown === void 0 ? void 0 : this.moduleGraphService.renderMermaid(a),
610
+ markdownSection: this.buildMarkdownSection(F),
611
+ mode: t,
612
+ project: n,
613
+ resolvedOutput: r
614
+ });
615
+ }
616
+ runNxProject(e) {
617
+ let { mode: t, neighborhood: n, project: r, resolvedOutput: i } = e;
618
+ return this.deliveryService.deliverGraphOutput({
619
+ jsonContent: i.json === void 0 ? void 0 : this.deliveryService.renderJson(this.buildNeighborhoodJsonExport(n)),
620
+ markdownContent: i.markdown === void 0 ? void 0 : this.neighborhoodService.renderMermaid(n),
621
+ markdownSection: this.buildMarkdownSection(pe),
622
+ mode: t,
623
+ project: r,
624
+ resolvedOutput: i
625
+ });
626
+ }
627
+ runFileImportsProjects(e) {
628
+ let t = this.typescriptService.discoverProjects(e.projects), n = [], r = [];
629
+ for (let i of t) {
630
+ let t = this.resolveProjectOutput({
631
+ context: e,
632
+ graphType: ue,
633
+ project: i
634
+ });
635
+ if (t.target !== "none") try {
636
+ n.push(this.runImportProject({
637
+ mode: e.mode,
638
+ project: i,
639
+ resolvedOutput: t
640
+ }));
641
+ } catch (e) {
642
+ r.push(this.collectProjectFailure(i.name, e));
643
+ }
644
+ }
645
+ return {
646
+ failures: r,
647
+ results: n
648
+ };
649
+ }
650
+ async runNestjsModulesProjects(e) {
651
+ let t = this.nestjsProjectService.discoverProjects(e.projects), n = [], r = [];
652
+ for (let i of t) {
653
+ let t = this.resolveProjectOutput({
654
+ context: e,
655
+ graphType: de,
656
+ project: i
657
+ });
658
+ if (t.target !== "none") try {
659
+ n.push(await this.runNestjsProject({
660
+ mode: e.mode,
661
+ project: i,
662
+ resolvedOutput: t
663
+ }));
664
+ } catch (e) {
665
+ r.push(this.collectProjectFailure(i.name, e));
666
+ }
667
+ }
668
+ return {
669
+ failures: r,
670
+ results: n
671
+ };
672
+ }
673
+ runNxProjectsGraphs(e) {
674
+ let { context: t, neighborhoods: n } = e, r = [], i = [];
675
+ for (let e of t.projects) {
676
+ let a = n.get(e.name), o = this.resolveProjectOutput({
677
+ context: t,
678
+ graphType: fe,
679
+ project: e
680
+ });
681
+ if (a !== void 0 && o.target !== "none") try {
682
+ r.push(this.runNxProject({
683
+ mode: t.mode,
684
+ neighborhood: a,
685
+ project: e,
686
+ resolvedOutput: o
687
+ }));
688
+ } catch (t) {
689
+ i.push(this.collectProjectFailure(e.name, t));
690
+ }
691
+ }
692
+ return {
693
+ failures: i,
694
+ results: r
695
+ };
696
+ }
697
+ };
698
+ q = A([n(), k("design:paramtypes", [
699
+ f === void 0 ? Object : f,
700
+ H === void 0 ? Object : H,
701
+ x === void 0 ? Object : x,
702
+ p === void 0 ? Object : p,
703
+ w === void 0 ? Object : w,
704
+ b === void 0 ? Object : b
705
+ ])], q);
706
+ //#endregion
707
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/project-graphs/project-graphs.module.ts
708
+ var be = class {};
709
+ be = A([r({
710
+ controllers: [],
711
+ exports: [q],
712
+ imports: [
713
+ d,
714
+ U,
715
+ ie,
716
+ te,
717
+ C,
718
+ y
719
+ ],
720
+ providers: [q]
721
+ })], be);
722
+ //#endregion
723
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/python-imports/python-imports.service.ts
724
+ var J = class {
725
+ configurationService;
726
+ deliveryService;
727
+ pythonService;
728
+ constructor(e, t, n) {
729
+ this.configurationService = e, this.deliveryService = t, this.pythonService = n;
730
+ }
731
+ buildMarkdownSection() {
732
+ return {
733
+ introLine: P,
734
+ subheading: me
735
+ };
736
+ }
737
+ collectProjectFailure(e, t) {
738
+ return {
739
+ error: t instanceof Error ? t.message : String(t),
740
+ projectName: e
741
+ };
742
+ }
743
+ resolveProjectOutput(e) {
744
+ let { context: t, project: n } = e;
745
+ return this.configurationService.resolveForProject({
746
+ configuration: t.configuration,
747
+ graphType: ue,
748
+ projectConfiguration: t.projectConfigurations.get(n.name),
749
+ projectName: n.name,
750
+ projectRoot: l.relative(t.workingDirectory, n.absoluteRoot),
751
+ projectTags: t.projects.find((e) => e.name === n.name)?.tags
752
+ });
753
+ }
754
+ runProject(e) {
755
+ let { mode: t, project: n, resolvedOutput: r } = e, i = this.pythonService.buildGraph(n), a = i;
756
+ return this.deliveryService.deliverGraphOutput({
757
+ jsonContent: r.json === void 0 ? void 0 : this.deliveryService.renderJson(a),
758
+ markdownContent: r.markdown === void 0 ? void 0 : this.pythonService.renderMermaid(i),
759
+ markdownSection: this.buildMarkdownSection(),
760
+ mode: t,
761
+ project: n,
762
+ resolvedOutput: r
763
+ });
764
+ }
765
+ runGraphs(e) {
766
+ let t = this.pythonService.discoverProjects(e.projects), n = [], r = [];
767
+ for (let i of t) {
768
+ let t = this.resolveProjectOutput({
769
+ context: e,
770
+ project: i
771
+ });
772
+ if (t.target !== "none") try {
773
+ n.push(this.runProject({
774
+ mode: e.mode,
775
+ project: i,
776
+ resolvedOutput: t
777
+ }));
778
+ } catch (e) {
779
+ r.push(this.collectProjectFailure(i.name, e));
780
+ }
781
+ }
782
+ return {
783
+ failures: r,
784
+ results: n
785
+ };
786
+ }
787
+ };
788
+ J = A([n(), k("design:paramtypes", [
789
+ f === void 0 ? Object : f,
790
+ H === void 0 ? Object : H,
791
+ v === void 0 ? Object : v
792
+ ])], J);
793
+ //#endregion
794
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/python-imports/python-imports.module.ts
795
+ var Y = class {};
796
+ Y = A([r({
797
+ controllers: [],
798
+ exports: [J],
799
+ imports: [
800
+ d,
801
+ U,
802
+ _
803
+ ],
804
+ providers: [J]
805
+ })], Y);
806
+ //#endregion
807
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/workspace-graphs/workspace-graphs.service.ts
808
+ var X = class {
809
+ configurationService;
810
+ deliveryService;
811
+ fileImportsWorkspaceGraphService;
812
+ moduleGraphService;
813
+ nestjsModulesWorkspaceGraphService;
814
+ nestjsProjectService;
815
+ pythonService;
816
+ typescriptService;
817
+ workspaceGraphService;
818
+ constructor(e, t, n, r, i, a, o, s, c) {
819
+ this.configurationService = e, this.deliveryService = t, this.fileImportsWorkspaceGraphService = n, this.moduleGraphService = r, this.nestjsModulesWorkspaceGraphService = i, this.nestjsProjectService = a, this.pythonService = o, this.typescriptService = s, this.workspaceGraphService = c;
820
+ }
821
+ buildMarkdownSection(e) {
822
+ return {
823
+ introLine: P,
824
+ subheading: e
825
+ };
826
+ }
827
+ async buildNestjsModuleGraphs(e) {
828
+ let t = this.nestjsProjectService.discoverProjects(e), n = [];
829
+ for (let e of t) {
830
+ let t = await this.nestjsProjectService.exploreProject(e);
831
+ n.push(this.moduleGraphService.buildGraph(t, e.name));
832
+ }
833
+ return n;
834
+ }
835
+ buildTypescriptGraphs(e) {
836
+ return this.typescriptService.discoverProjects(e).map((e) => this.typescriptService.buildGraph(this.typescriptService.buildProgram(e)));
837
+ }
838
+ deliverWorkspaceGraph(e) {
839
+ return this.deliveryService.deliverGraphOutput({
840
+ jsonContent: e.resolvedOutput.json === void 0 ? void 0 : this.deliveryService.renderJson(e.jsonExport),
841
+ markdownContent: e.resolvedOutput.markdown === void 0 ? void 0 : e.markdownContent,
842
+ markdownSection: this.buildMarkdownSection(e.markdownSubheading),
843
+ mode: e.mode,
844
+ project: {
845
+ absoluteRoot: e.workingDirectory,
846
+ name: I
847
+ },
848
+ resolvedOutput: e.resolvedOutput
849
+ });
850
+ }
851
+ runFileImportsWorkspaceGraph(e) {
852
+ let { configuration: t, mode: n, workingDirectory: r } = e, i = this.configurationService.resolveForWorkspace(t, ue);
853
+ if (i.target === "none") return {
854
+ entry: void 0,
855
+ result: void 0
856
+ };
857
+ let a = this.buildTypescriptGraphs(e.selectedProjects), o = this.pythonService.discoverProjects(e.selectedProjects).map((e) => this.pythonService.buildGraph(e)), s = this.fileImportsWorkspaceGraphService.buildWorkspaceGraph({
858
+ pythonGraphs: o,
859
+ typescriptGraphs: a
860
+ }), c = s, l = this.fileImportsWorkspaceGraphService.renderMermaid(s);
861
+ return {
862
+ entry: {
863
+ json: c,
864
+ markdown: l
865
+ },
866
+ result: this.deliverWorkspaceGraph({
867
+ jsonExport: c,
868
+ markdownContent: l,
869
+ markdownSubheading: N,
870
+ mode: n,
871
+ resolvedOutput: i,
872
+ workingDirectory: r
873
+ })
874
+ };
875
+ }
876
+ async runNestjsModulesWorkspaceGraph(e) {
877
+ let { configuration: t, mode: n, workingDirectory: r } = e, i = this.configurationService.resolveForWorkspace(t, de);
878
+ if (i.target === "none") return {
879
+ entry: void 0,
880
+ result: void 0
881
+ };
882
+ let a = await this.buildNestjsModuleGraphs(e.selectedProjects), o = this.nestjsModulesWorkspaceGraphService.buildWorkspaceGraph(a), s = o, c = this.nestjsModulesWorkspaceGraphService.renderMermaid(o);
883
+ return {
884
+ entry: {
885
+ json: s,
886
+ markdown: c
887
+ },
888
+ result: this.deliverWorkspaceGraph({
889
+ jsonExport: s,
890
+ markdownContent: c,
891
+ markdownSubheading: F,
892
+ mode: n,
893
+ resolvedOutput: i,
894
+ workingDirectory: r
895
+ })
896
+ };
897
+ }
898
+ runNxWorkspaceGraph(e) {
899
+ let { configuration: t, graph: n, mode: r, workingDirectory: i } = e, a = this.configurationService.resolveForWorkspace(t, fe);
900
+ if (a.target === "none") return {
901
+ entry: void 0,
902
+ result: void 0
903
+ };
904
+ let o = this.workspaceGraphService.buildWorkspaceGraph(n, e.selectedProjects), s = o, c = this.workspaceGraphService.renderMermaid(o);
905
+ return {
906
+ entry: {
907
+ json: s,
908
+ markdown: c
909
+ },
910
+ result: this.deliverWorkspaceGraph({
911
+ jsonExport: s,
912
+ markdownContent: c,
913
+ markdownSubheading: void 0,
914
+ mode: r,
915
+ resolvedOutput: a,
916
+ workingDirectory: i
917
+ })
918
+ };
919
+ }
920
+ };
921
+ X = A([n(), k("design:paramtypes", [
922
+ f === void 0 ? Object : f,
923
+ H === void 0 ? Object : H,
924
+ g === void 0 ? Object : g,
925
+ x === void 0 ? Object : x,
926
+ S === void 0 ? Object : S,
927
+ w === void 0 ? Object : w,
928
+ v === void 0 ? Object : v,
929
+ b === void 0 ? Object : b,
930
+ m === void 0 ? Object : m
931
+ ])], X);
932
+ //#endregion
933
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/workspace-graphs/workspace-graphs.module.ts
934
+ var xe = class {};
935
+ xe = A([r({
936
+ controllers: [],
937
+ exports: [X],
938
+ imports: [
939
+ d,
940
+ U,
941
+ re,
942
+ ie,
943
+ ae,
944
+ C,
945
+ _,
946
+ y,
947
+ ne
948
+ ],
949
+ providers: [X]
950
+ })], xe);
951
+ //#endregion
952
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/graph-run/graph-run.service.ts
953
+ var Se, Z = Se = class {
954
+ logger;
955
+ neighborhoodService;
956
+ projectGraphsService;
957
+ pythonImportsService;
958
+ workspaceGraphsService;
959
+ constructor(e, t, n, r, i) {
960
+ this.logger = e, this.neighborhoodService = t, this.projectGraphsService = n, this.pythonImportsService = r, this.workspaceGraphsService = i, this.logger.setContext(Se.name);
961
+ }
962
+ collectCombinedGraphs(e) {
963
+ let { importsOutcome: t, nestjsOutcome: n, nxOutcome: r } = e, i = {};
964
+ return r.workspaceEntry !== void 0 && (i.nxProjects = r.workspaceEntry), t.workspaceEntry !== void 0 && (i.fileImports = t.workspaceEntry), n.workspaceEntry !== void 0 && (i.nestjsModules = n.workspaceEntry), i;
965
+ }
966
+ collectProjectFailure(e, t) {
967
+ return {
968
+ error: t instanceof Error ? t.message : String(t),
969
+ projectName: e
970
+ };
971
+ }
972
+ collectWorkspaceOutcome(e) {
973
+ try {
974
+ let t = e.build();
975
+ return t.result !== void 0 && e.results.push(t.result), t.entry;
976
+ } catch (t) {
977
+ e.failures.push(this.collectProjectFailure(I, t));
978
+ return;
979
+ }
980
+ }
981
+ async run(e) {
982
+ let { enabledGraphTypes: t } = e, n = t.has("nxProjects") ? this.runNxGraphs(e) : le, r = t.has("nestjsModules") ? await this.runNestjsGraphs(e) : le, i = t.has("fileImports") ? this.runImportGraphs(e) : le, a = t.has("fileImports") ? this.runPythonImportGraphs(e) : ce;
983
+ return {
984
+ combinedGraphs: this.collectCombinedGraphs({
985
+ importsOutcome: i,
986
+ nestjsOutcome: r,
987
+ nxOutcome: n
988
+ }),
989
+ outcome: {
990
+ failures: [
991
+ ...n.failures,
992
+ ...r.failures,
993
+ ...i.failures,
994
+ ...a.failures
995
+ ],
996
+ results: [
997
+ ...n.results,
998
+ ...r.results,
999
+ ...i.results,
1000
+ ...a.results
1001
+ ]
1002
+ }
1003
+ };
1004
+ }
1005
+ runImportGraphs(e) {
1006
+ let { failures: t, results: n } = this.projectGraphsService.runFileImportsProjects(e);
1007
+ return {
1008
+ failures: t,
1009
+ results: n,
1010
+ workspaceEntry: this.collectWorkspaceOutcome({
1011
+ build: () => this.workspaceGraphsService.runFileImportsWorkspaceGraph(e),
1012
+ failures: t,
1013
+ results: n
1014
+ })
1015
+ };
1016
+ }
1017
+ async runNestjsGraphs(e) {
1018
+ let { failures: t, results: n } = await this.projectGraphsService.runNestjsModulesProjects(e), r;
1019
+ try {
1020
+ let t = await this.workspaceGraphsService.runNestjsModulesWorkspaceGraph(e);
1021
+ r = t.entry, t.result !== void 0 && n.push(t.result);
1022
+ } catch (e) {
1023
+ t.push(this.collectProjectFailure(I, e));
1024
+ }
1025
+ return {
1026
+ failures: t,
1027
+ results: n,
1028
+ workspaceEntry: r
1029
+ };
1030
+ }
1031
+ runNxGraphs(e) {
1032
+ let t = this.neighborhoodService.buildNeighborhoods(e.graph, e.projects), { failures: n, results: r } = this.projectGraphsService.runNxProjectsGraphs({
1033
+ context: e,
1034
+ neighborhoods: t
1035
+ });
1036
+ return {
1037
+ failures: n,
1038
+ results: r,
1039
+ workspaceEntry: this.collectWorkspaceOutcome({
1040
+ build: () => this.workspaceGraphsService.runNxWorkspaceGraph(e),
1041
+ failures: n,
1042
+ results: r
1043
+ })
1044
+ };
1045
+ }
1046
+ runPythonImportGraphs(e) {
1047
+ return this.pythonImportsService.runGraphs(e);
1048
+ }
1049
+ };
1050
+ Z = Se = A([n(), k("design:paramtypes", [
1051
+ G === void 0 ? Object : G,
1052
+ p === void 0 ? Object : p,
1053
+ q === void 0 ? Object : q,
1054
+ J === void 0 ? Object : J,
1055
+ X === void 0 ? Object : X
1056
+ ])], Z);
1057
+ //#endregion
1058
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/graph-run/graph-run.module.ts
1059
+ var Ce = class {};
1060
+ Ce = A([r({
1061
+ controllers: [],
1062
+ exports: [Z],
1063
+ imports: [
1064
+ K,
1065
+ te,
1066
+ be,
1067
+ Y,
1068
+ xe
1069
+ ],
1070
+ providers: [Z]
1071
+ })], Ce);
1072
+ //#endregion
1073
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/path-query/path-query.constants.ts
1074
+ var we = " → ", Te = "mermaid", Ee = [
1075
+ L,
1076
+ R,
1077
+ Te
1078
+ ], De = "graph LR", Oe = (e, t) => `_No path connects "${e}" to "${t}"._`, Q = class {
1079
+ fileImportsWorkspaceGraphService;
1080
+ moduleGraphService;
1081
+ nestjsModulesWorkspaceGraphService;
1082
+ nestjsProjectService;
1083
+ pythonService;
1084
+ typescriptService;
1085
+ workspaceGraphService;
1086
+ constructor(e, t, n, r, i, a, o) {
1087
+ this.fileImportsWorkspaceGraphService = e, this.moduleGraphService = t, this.nestjsModulesWorkspaceGraphService = n, this.nestjsProjectService = r, this.pythonService = i, this.typescriptService = a, this.workspaceGraphService = o;
1088
+ }
1089
+ buildAdjacency(e) {
1090
+ let t = /* @__PURE__ */ new Map();
1091
+ for (let n of e) {
1092
+ let e = t.get(n.source) ?? [];
1093
+ e.push(n.target), t.set(n.source, e);
1094
+ }
1095
+ for (let [e, n] of t) t.set(e, n.toSorted());
1096
+ return t;
1097
+ }
1098
+ async buildNestjsModuleGraphs(e) {
1099
+ let t = this.nestjsProjectService.discoverProjects(e), n = [];
1100
+ for (let e of t) {
1101
+ let t = await this.nestjsProjectService.exploreProject(e);
1102
+ n.push(this.moduleGraphService.buildGraph(t, e.name));
1103
+ }
1104
+ return n;
1105
+ }
1106
+ isKnownNode(e, t, n) {
1107
+ return t?.includes(e) === !0 || n.some((t) => t.source === e || t.target === e);
1108
+ }
1109
+ queryFileImports(e) {
1110
+ let t = this.pythonService.discoverProjects(e.context.selectedProjects).map((e) => this.pythonService.buildGraph(e)), n = this.typescriptService.discoverProjects(e.context.selectedProjects).map((e) => this.typescriptService.buildGraph(this.typescriptService.buildProgram(e))), r = this.fileImportsWorkspaceGraphService.buildWorkspaceGraph({
1111
+ pythonGraphs: t,
1112
+ typescriptGraphs: n
1113
+ });
1114
+ return this.findShortestPath({
1115
+ edges: r.edges,
1116
+ from: e.from,
1117
+ nodes: r.fileNames,
1118
+ to: e.to
1119
+ });
1120
+ }
1121
+ async queryNestjsModules(e) {
1122
+ let t = await this.buildNestjsModuleGraphs(e.context.selectedProjects), n = this.nestjsModulesWorkspaceGraphService.buildWorkspaceGraph(t);
1123
+ return this.findShortestPath({
1124
+ edges: n.edges,
1125
+ from: e.from,
1126
+ nodes: n.moduleNames,
1127
+ to: e.to
1128
+ });
1129
+ }
1130
+ queryNxProjects(e) {
1131
+ let t = this.workspaceGraphService.buildWorkspaceGraph(e.context.graph, e.context.selectedProjects);
1132
+ return this.findShortestPath({
1133
+ edges: t.edges,
1134
+ from: e.from,
1135
+ nodes: t.projectNames,
1136
+ to: e.to
1137
+ });
1138
+ }
1139
+ renderMarkdown(e) {
1140
+ let t = [];
1141
+ for (let n of u) {
1142
+ let r = e[n];
1143
+ if (r === void 0) continue;
1144
+ let i = `### ${he[n]}`, a = r.path === null || r.path.length === 0 ? Oe(r.from, r.to) : r.path.map((e) => `\`${e}\``).join(we);
1145
+ t.push(`${i}\n\n${a}`);
1146
+ }
1147
+ return t.join("\n\n");
1148
+ }
1149
+ renderMermaid(e) {
1150
+ let t = [];
1151
+ for (let n of u) {
1152
+ let r = e[n];
1153
+ r !== void 0 && t.push(this.renderMermaidSection(r));
1154
+ }
1155
+ return t.join("\n\n");
1156
+ }
1157
+ renderMermaidSection(e) {
1158
+ let t = e.path;
1159
+ if (t === null || t.length === 0) return Oe(e.from, e.to);
1160
+ let n = [
1161
+ "```mermaid",
1162
+ De,
1163
+ ...t.map((e) => ` ${this.toMermaidId(e)}["${e}"]`)
1164
+ ];
1165
+ for (let e = 0; e + 1 < t.length; e++) {
1166
+ let r = t[e], i = t[e + 1];
1167
+ r !== void 0 && i !== void 0 && n.push(` ${this.toMermaidId(r)} --> ${this.toMermaidId(i)}`);
1168
+ }
1169
+ return n.push("```"), n.join("\n");
1170
+ }
1171
+ searchBfs(e, t, n) {
1172
+ let r = [[e, [e]]], i = /* @__PURE__ */ new Set([e]), a = r.shift();
1173
+ for (; a !== void 0;) {
1174
+ let [e, o] = a;
1175
+ if (e === t) return o;
1176
+ for (let t of n.get(e) ?? []) i.has(t) || (i.add(t), r.push([t, [...o, t]]));
1177
+ a = r.shift();
1178
+ }
1179
+ return null;
1180
+ }
1181
+ toMermaidId(e) {
1182
+ return e.replaceAll(/[^\dA-Za-z]/gu, "_");
1183
+ }
1184
+ findShortestPath(e) {
1185
+ let { edges: t, from: n, nodes: r, to: i } = e;
1186
+ return !this.isKnownNode(n, r, t) || !this.isKnownNode(i, r, t) ? null : n === i ? [n] : this.searchBfs(n, i, this.buildAdjacency(t));
1187
+ }
1188
+ async query(e) {
1189
+ let { context: t, from: n, to: r } = e, i = {};
1190
+ return t.enabledGraphTypes.has("nxProjects") && (i.nxProjects = {
1191
+ from: n,
1192
+ path: this.queryNxProjects(e),
1193
+ to: r
1194
+ }), t.enabledGraphTypes.has("fileImports") && (i.fileImports = {
1195
+ from: n,
1196
+ path: this.queryFileImports(e),
1197
+ to: r
1198
+ }), t.enabledGraphTypes.has("nestjsModules") && (i.nestjsModules = {
1199
+ from: n,
1200
+ path: await this.queryNestjsModules(e),
1201
+ to: r
1202
+ }), i;
1203
+ }
1204
+ render(e) {
1205
+ return e.format === "json" ? JSON.stringify(e.results, null, 2) : e.format === "mermaid" ? this.renderMermaid(e.results) : this.renderMarkdown(e.results);
1206
+ }
1207
+ resolveFormat(e) {
1208
+ if (e === void 0) return {
1209
+ errors: [],
1210
+ format: R
1211
+ };
1212
+ let t = Ee.find((t) => t === e);
1213
+ return t === void 0 ? {
1214
+ errors: [`--format does not accept "${e}". It takes one of ${Ee.map((e) => `"${e}"`).join(" and ")}, as in "--format ${R}".`],
1215
+ format: R
1216
+ } : {
1217
+ errors: [],
1218
+ format: t
1219
+ };
1220
+ }
1221
+ };
1222
+ Q = A([n(), k("design:paramtypes", [
1223
+ g === void 0 ? Object : g,
1224
+ x === void 0 ? Object : x,
1225
+ S === void 0 ? Object : S,
1226
+ w === void 0 ? Object : w,
1227
+ v === void 0 ? Object : v,
1228
+ b === void 0 ? Object : b,
1229
+ m === void 0 ? Object : m
1230
+ ])], Q);
1231
+ //#endregion
1232
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/path-query/path-query.module.ts
1233
+ var ke = class {};
1234
+ ke = A([r({
1235
+ controllers: [],
1236
+ exports: [Q],
1237
+ imports: [
1238
+ re,
1239
+ ie,
1240
+ ae,
1241
+ C,
1242
+ _,
1243
+ y,
1244
+ ne
1245
+ ],
1246
+ providers: [Q]
1247
+ })], ke);
1248
+ //#endregion
1249
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/reporting/reporting.service.ts
1250
+ var Ae, $ = Ae = class {
1251
+ boundaryReportService;
1252
+ logger;
1253
+ constructor(e, t) {
1254
+ this.boundaryReportService = e, this.logger = t, this.logger.setContext(Ae.name);
1255
+ }
1256
+ reportBoundaries(e) {
1257
+ return e.failures.length > 0 && this.logger.error("💥 Failed running codependix", void 0, { failures: e.failures }), e.violations.length > 0 && this.logger.error("🕸️ Found codependix boundary violations", void 0, {
1258
+ summary: this.boundaryReportService.renderSummary(e.violations),
1259
+ violations: this.boundaryReportService.renderViolations(e.violations)
1260
+ }), e.failures.length === 0 && e.violations.length === 0;
1261
+ }
1262
+ reportEmptySelection(e) {
1263
+ e > 0 || this.logger.warn("🕸️ Selected no project to export", void 0, { hint: "name the projects that participate in the configuration's include list" });
1264
+ }
1265
+ reportFailure(e) {
1266
+ this.logger.error(e instanceof ee ? "🕸️ Rejected the command line" : "💥 Failed running codependix", void 0, { reason: e instanceof Error ? e.message : String(e) }), process.exitCode = 1;
1267
+ }
1268
+ reportOutcome(e) {
1269
+ let t = e.results.filter((e) => !e.isCurrent), n = [...new Set(t.map((e) => e.projectName))];
1270
+ if (e.failures.length > 0 && this.logger.error("💥 Failed running codependix", void 0, { failures: e.failures }), n.length > 0) {
1271
+ let e = [...new Map(t.flatMap((e) => e.staleExports.map((t) => [`${e.projectName}:${t.path}:${t.anchor ?? ""}`, {
1272
+ ...t.anchor !== void 0 && { anchor: t.anchor },
1273
+ difference: t.difference,
1274
+ path: t.path,
1275
+ project: e.projectName
1276
+ }]))).values()];
1277
+ this.logger.error("🕸️ Found stale codependix exports", void 0, {
1278
+ exports: e,
1279
+ projects: n
1280
+ });
1281
+ }
1282
+ return e.failures.length === 0 && n.length === 0;
1283
+ }
1284
+ reportPassOutcomes(e) {
1285
+ let t = e.exportRun === void 0 || this.reportOutcome(e.exportRun.outcome), n = e.boundaryOutcome === void 0 || this.reportBoundaries(e.boundaryOutcome);
1286
+ return t && n;
1287
+ }
1288
+ reportSuccess(e) {
1289
+ e.exportOutcome !== void 0 && this.logger.info("🕸️ Verified every configured codependix export is current", void 0, { projects: e.exportOutcome.results.length }), e.boundaryOutcome !== void 0 && this.logger.info("🕸️ Verified every declared codependix boundary holds");
1290
+ }
1291
+ };
1292
+ $ = Ae = A([n(), k("design:paramtypes", [se === void 0 ? Object : se, G === void 0 ? Object : G])], $);
1293
+ //#endregion
1294
+ //#region packages/ic-suite/codependix/codependix-output/src/modules/reporting/reporting.module.ts
1295
+ var je = class {};
1296
+ je = A([r({
1297
+ controllers: [],
1298
+ exports: [$],
1299
+ imports: [oe, K],
1300
+ providers: [$]
1301
+ })], je);
1302
+ //#endregion
1303
+ export { O as AnchorNotFoundError, M as AnchorsModule, j as AnchorsService, D as CODEPENDIX_SECTION_HEADING, V as CombinedOutputModule, B as CombinedOutputService, U as DeliveryModule, H as DeliveryService, L as FORMAT_JSON, R as FORMAT_MARKDOWN, Te as FORMAT_MERMAID, z as FORMAT_NAMES, Ce as GraphRunModule, Z as GraphRunService, P as MARKDOWN_SECTION_INTRO_LINE, we as PATH_ARROW, Ee as PATH_FORMAT_NAMES, De as PATH_MERMAID_HEADER, ke as PathQueryModule, Q as PathQueryService, je as ReportingModule, $ as ReportingService, E as buildEndMarker, Oe as buildNoPathMessage, T as buildStartMarker };