@callidescope/configuration 0.0.0-stage → 0.0.1

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,900 @@
1
+ import { z as e } from "zod";
2
+ import { Injectable as t, Module as n } from "@nestjs/common";
3
+ import r from "prompts";
4
+ import { existsSync as i } from "node:fs";
5
+ import { readFile as a } from "node:fs/promises";
6
+ import o from "node:path";
7
+ import { fileURLToPath as s } from "node:url";
8
+ import { createJiti as c } from "jiti";
9
+ import { parse as l } from "jsonc-parser";
10
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/configuration.constants.ts
11
+ var u = [
12
+ "callidescope.config.ts",
13
+ "callidescope.config.mts",
14
+ "callidescope.config.cts",
15
+ "callidescope.config.js",
16
+ "callidescope.config.mjs",
17
+ "callidescope.config.cjs",
18
+ "callidescope.config.json",
19
+ "callidescope.config.jsonc"
20
+ ], d = /* @__PURE__ */ new Set([
21
+ ".cjs",
22
+ ".cts",
23
+ ".js",
24
+ ".json",
25
+ ".jsonc",
26
+ ".mjs",
27
+ ".mts",
28
+ ".ts"
29
+ ]), f = [".git", "pnpm-workspace.yaml"], p = [
30
+ "**/.conformetry/**",
31
+ "**/.nx/**",
32
+ "**/coverage/**",
33
+ "**/dist/**",
34
+ "**/node_modules/**",
35
+ "**/output/**"
36
+ ], ee = 6, m = [
37
+ "Command",
38
+ "Cron",
39
+ "Delete",
40
+ "Get",
41
+ "Mutation",
42
+ "OnEvent",
43
+ "Option",
44
+ "Patch",
45
+ "Post",
46
+ "Put",
47
+ "Query",
48
+ "ResolveField",
49
+ "SubscribeMessage"
50
+ ], te = 2, h = [
51
+ "markdown",
52
+ "mermaid",
53
+ "json"
54
+ ], g = "markdown", ne = "## 🔭 Callidescope", re = "# 🔭 Callidescope", ie = 3, ae = "<!-- callidescope:start -->", oe = "<!-- callidescope:end -->", _ = new Intl.ListFormat("en", {
55
+ style: "long",
56
+ type: "conjunction"
57
+ }), se = (e) => typeof e.permission == "string" ? e.permission === "permitted" ? [e.field] : [] : Object.entries(e.permission).filter(([, e]) => e === "permitted").map(([t]) => `${e.field}.${t}`), v = {
58
+ directories: "forbidden",
59
+ entryPoints: "permitted",
60
+ exclude: "permitted",
61
+ excludeCallees: "forbidden",
62
+ excludeFrom: "forbidden",
63
+ limits: "permitted",
64
+ write: {
65
+ json: "forbidden",
66
+ markdown: "permitted",
67
+ mermaid: "permitted"
68
+ }
69
+ }, ce = new Set(Object.entries(v).filter(([, e]) => typeof e != "string").map(([e]) => e)), y = new Set(Object.entries(v).flatMap(([e, t]) => se({
70
+ field: e,
71
+ permission: t
72
+ }))), le = _.format(y), ue = {
73
+ entryPoints: [
74
+ "addresses",
75
+ "decorators",
76
+ "includeExportedFunctions",
77
+ "includeOrphans",
78
+ "includeTests"
79
+ ],
80
+ exclude: [],
81
+ limits: ["maximumBreadth", "maximumDepth"],
82
+ write: ["markdown", "mermaid"]
83
+ }, b = class extends Error {
84
+ constructor(e) {
85
+ super(`Unknown configuration file type: ${e}`), this.name = "UnknownConfigurationFileTypeError";
86
+ }
87
+ }, x = () => e.custom((e) => typeof e == "function", { message: "Expected a function" }), de = e.strictObject({
88
+ maximumBreadth: e.number().int().positive().optional(),
89
+ maximumDepth: e.number().int().positive().optional()
90
+ }).optional(), fe = e.strictObject({
91
+ addresses: e.array(e.string()).optional(),
92
+ decorators: e.array(e.string()).optional(),
93
+ includeExportedFunctions: e.boolean().optional(),
94
+ includeOrphans: e.boolean().optional(),
95
+ includeTests: e.boolean().optional()
96
+ }).optional(), S = e.strictObject({
97
+ description: e.string().optional(),
98
+ endMarker: e.string().optional(),
99
+ heading: e.string().optional(),
100
+ path: e.string(),
101
+ previewCount: e.number().int().nonnegative().optional(),
102
+ render: x().optional(),
103
+ startMarker: e.string().optional(),
104
+ writeBlock: x().optional()
105
+ }).optional(), pe = e.strictObject({
106
+ json: e.strictObject({
107
+ indentation: e.number().int().nonnegative().optional(),
108
+ path: e.string()
109
+ }).optional(),
110
+ markdown: S,
111
+ mermaid: S
112
+ }).optional(), C = e.strictObject({
113
+ directories: e.array(e.string()).optional(),
114
+ entryPoints: fe,
115
+ exclude: e.array(e.string()).optional(),
116
+ excludeCallees: e.array(e.string()).optional(),
117
+ excludeFrom: e.array(e.string()).optional(),
118
+ ignoreCallees: e.never().optional(),
119
+ limits: de,
120
+ output: e.never().optional(),
121
+ write: pe
122
+ }), w = class extends Error {
123
+ constructor(e) {
124
+ super(`Configuration file not found: ${e}`), this.name = "ConfigurationFileNotFoundError";
125
+ }
126
+ }, T = class extends Error {
127
+ constructor(e) {
128
+ let t = e.cause instanceof Error ? e.cause.message : "It could not be read";
129
+ super(`Failed to read the callidescope configuration for ${e.project} at ${e.configurationPath}: ${t}`, { cause: e.cause }), this.name = "ProjectConfigurationError";
130
+ }
131
+ }, E = class extends Error {
132
+ constructor(e) {
133
+ super(`${e.project} sets ${e.field}, which only the workspace configuration may set. A project configuration may set ${le}.`), this.name = "ProjectConfigurationFieldNotPermittedError";
134
+ }
135
+ }, D = class extends Error {
136
+ constructor(e) {
137
+ super(`${e.project} leaves ${e.field} out of its callidescope configuration, which must be complete. Spread the workspace's projectDefaults and override what this project means to.`), this.name = "ProjectConfigurationIncompleteError";
138
+ }
139
+ }, O = class extends Error {
140
+ constructor(e) {
141
+ super(`${e} is traced but has no callidescope.config.ts. Every traced project declares its own, spreading the workspace's projectDefaults and overriding what it means to.`), this.name = "ProjectConfigurationMissingError";
142
+ }
143
+ }, k = class extends Error {
144
+ constructor(e) {
145
+ super(e), this.name = "InputError";
146
+ }
147
+ }, A = (e) => new k(`${e} is required, and stdin is not a terminal so it cannot be asked for.`), j = (e) => new k(`${e} was not answered.`);
148
+ //#endregion
149
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
150
+ function M(e, t) {
151
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
152
+ }
153
+ //#endregion
154
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
155
+ function N(e, t, n, r) {
156
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
157
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
158
+ 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);
159
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
160
+ }
161
+ //#endregion
162
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/input/input.service.ts
163
+ var P = class {
164
+ constructor() {}
165
+ promptRunner = r;
166
+ assertCanPrompt(e) {
167
+ if (!this.isAtTerminal()) throw A(e);
168
+ }
169
+ completeSuggestions(e) {
170
+ let t = e.input.trim(), n = e.suggestions.filter((e) => e.toLowerCase().includes(t.toLowerCase()));
171
+ return n.length === 0 && t.length > 0 ? [t] : n;
172
+ }
173
+ isAtTerminal() {
174
+ return process.stdin.isTTY;
175
+ }
176
+ parseCommaDelimitedOption(e) {
177
+ return e === void 0 ? [] : e.split(",").map((e) => e.trim()).filter(Boolean);
178
+ }
179
+ parseOptionalOption(e) {
180
+ let t = e?.trim();
181
+ return t === void 0 || t.length === 0 ? void 0 : t;
182
+ }
183
+ async promptForAutocompleteMultiselect(e) {
184
+ this.assertCanPrompt(e.subject);
185
+ let t = (await this.promptRunner({
186
+ choices: e.suggestions.map((e) => ({
187
+ title: e,
188
+ value: e
189
+ })),
190
+ message: e.message,
191
+ name: "value",
192
+ suggest: async (t) => await Promise.resolve(this.completeSuggestions({
193
+ input: t,
194
+ suggestions: e.suggestions
195
+ }).map((e) => ({
196
+ title: e,
197
+ value: e
198
+ }))),
199
+ type: "autocompleteMultiselect"
200
+ })).value;
201
+ if (!Array.isArray(t)) throw j(e.subject);
202
+ let n = t;
203
+ if (n.length === 0) throw j(e.subject);
204
+ let r = n.filter((e) => typeof e == "string");
205
+ if (r.length !== n.length) throw Error("Prompt resolved to something other than a list of text.");
206
+ return r;
207
+ }
208
+ async promptForSelect(e) {
209
+ this.assertCanPrompt(e.subject);
210
+ let t = (await this.promptRunner({
211
+ choices: e.choices.map((e) => ({
212
+ title: e,
213
+ value: e
214
+ })),
215
+ message: e.message,
216
+ name: "value",
217
+ type: "select"
218
+ })).value;
219
+ if (t === void 0) throw j(e.subject);
220
+ let n = e.choices.find((e) => e === t);
221
+ if (n === void 0) throw Error(`Prompt did not resolve to one of: ${e.choices.join(", ")}.`);
222
+ return n;
223
+ }
224
+ };
225
+ P = N([t(), M("design:paramtypes", [])], P);
226
+ //#endregion
227
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/input/input.module.ts
228
+ var F = class {};
229
+ F = N([n({
230
+ controllers: [],
231
+ exports: [P],
232
+ imports: [],
233
+ providers: [P]
234
+ })], F);
235
+ //#endregion
236
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/flag-resolution/flag-resolution.constants.ts
237
+ var me = (e) => `--format does not accept "${e}". It takes one of ${h.map((e) => `"${e}"`).join(", ")}.`, I = (e) => `${e.flag} overrides a destination the configuration does not declare. Add \`${e.field}\` to the configuration this run reads, then use ${e.flag} to send it somewhere else.`, L = (e) => `${e.flag} does not accept "${e.value}". It takes "true" or "false", or the flag on its own for "true".`, R = (e) => `${e.flag} does not accept "${e.value}". It takes a positive whole number.`, he = (e) => `${e.flag} overrides a value the configuration does not declare. Add \`${e.field}\` to the configuration this run reads, then use ${e.flag} to change it.`, z = (e) => new k(e.join(" ")), B = class {
238
+ constructor() {}
239
+ resolveCount(e) {
240
+ if (e.flagged === void 0) return;
241
+ if (e.configured === void 0) {
242
+ e.errors.push(he({
243
+ field: e.field,
244
+ flag: e.flag
245
+ }));
246
+ return;
247
+ }
248
+ let t = Number(e.flagged);
249
+ if (!Number.isInteger(t) || t <= 0) {
250
+ e.errors.push(R({
251
+ flag: e.flag,
252
+ value: e.flagged
253
+ }));
254
+ return;
255
+ }
256
+ return t;
257
+ }
258
+ resolveDestination(e) {
259
+ if (e.flagged === void 0) return e.configured;
260
+ if (e.configured === void 0) {
261
+ e.errors.push(I({
262
+ field: e.field,
263
+ flag: e.flag
264
+ }));
265
+ return;
266
+ }
267
+ return {
268
+ ...e.configured,
269
+ path: e.flagged
270
+ };
271
+ }
272
+ resolveEntryPoints(e) {
273
+ let { configured: t, errors: n, flags: r } = e;
274
+ return {
275
+ addresses: this.resolveList({
276
+ configured: t.addresses,
277
+ flagged: r.entryPointAddresses
278
+ }),
279
+ decorators: this.resolveList({
280
+ configured: t.decorators,
281
+ flagged: r.entryPointDecorators
282
+ }),
283
+ includeExportedFunctions: this.resolveSwitch({
284
+ configured: t.includeExportedFunctions,
285
+ errors: n,
286
+ flag: "--include-exported-functions",
287
+ flagged: r.includeExportedFunctions
288
+ }),
289
+ includeOrphans: this.resolveSwitch({
290
+ configured: t.includeOrphans,
291
+ errors: n,
292
+ flag: "--include-orphans",
293
+ flagged: r.includeOrphans
294
+ }),
295
+ includeTests: this.resolveSwitch({
296
+ configured: t.includeTests,
297
+ errors: n,
298
+ flag: "--include-tests",
299
+ flagged: r.includeTests
300
+ })
301
+ };
302
+ }
303
+ resolveExclude(e) {
304
+ return e.flagged === void 0 || e.flagged.length === 0 ? e.configured : [.../* @__PURE__ */ new Set([...p, ...e.flagged])];
305
+ }
306
+ resolveFormat(e) {
307
+ if (e.flagged === void 0) return g;
308
+ let t = h.find((t) => t === e.flagged);
309
+ return t === void 0 ? (e.errors.push(me(e.flagged)), g) : t;
310
+ }
311
+ resolveLimitOverrides(e) {
312
+ let { configured: t, errors: n, flags: r } = e, i = {}, a = this.resolveCount({
313
+ configured: t.maximumBreadth,
314
+ errors: n,
315
+ field: "limits.maximumBreadth",
316
+ flag: "--maximum-breadth",
317
+ flagged: r.maximumBreadth
318
+ }), o = this.resolveCount({
319
+ configured: t.maximumDepth,
320
+ errors: n,
321
+ field: "limits.maximumDepth",
322
+ flag: "--maximum-depth",
323
+ flagged: r.maximumDepth
324
+ });
325
+ return a !== void 0 && (i.maximumBreadth = a), o !== void 0 && (i.maximumDepth = o), i;
326
+ }
327
+ resolveLimits(e) {
328
+ let { configured: t, overrides: n } = e, r = n.maximumBreadth ?? t.maximumBreadth, i = n.maximumDepth ?? t.maximumDepth;
329
+ return r === void 0 ? { maximumDepth: i } : {
330
+ maximumBreadth: r,
331
+ maximumDepth: i
332
+ };
333
+ }
334
+ resolveList(e) {
335
+ return e.flagged === void 0 || e.flagged.length === 0 ? e.configured : [...e.flagged];
336
+ }
337
+ resolveSwitch(e) {
338
+ return e.flagged === void 0 ? e.configured : e.flagged === !0 ? !0 : e.flagged === "true" || e.flagged === "false" ? e.flagged === "true" : (e.errors.push(L({
339
+ flag: e.flag,
340
+ value: e.flagged
341
+ })), e.configured);
342
+ }
343
+ resolveWrite(e) {
344
+ let { configured: t, errors: n, flags: r } = e;
345
+ return {
346
+ json: this.resolveDestination({
347
+ configured: t.json,
348
+ errors: n,
349
+ field: "write.json",
350
+ flag: "--json",
351
+ flagged: r.json
352
+ }),
353
+ markdown: this.resolveDestination({
354
+ configured: t.markdown,
355
+ errors: n,
356
+ field: "write.markdown",
357
+ flag: "--markdown",
358
+ flagged: r.markdown
359
+ }),
360
+ mermaid: this.resolveDestination({
361
+ configured: t.mermaid,
362
+ errors: n,
363
+ field: "write.mermaid",
364
+ flag: "--mermaid",
365
+ flagged: r.mermaid
366
+ })
367
+ };
368
+ }
369
+ resolveRunFlags(e) {
370
+ let { configuration: t, flags: n } = e, r = [], i = this.resolveFormat({
371
+ errors: r,
372
+ flagged: n.format
373
+ }), a = this.resolveLimitOverrides({
374
+ configured: t.limits,
375
+ errors: r,
376
+ flags: n
377
+ });
378
+ return {
379
+ configuration: {
380
+ ...t,
381
+ directories: this.resolveList({
382
+ configured: t.directories,
383
+ flagged: n.directories
384
+ }),
385
+ entryPoints: this.resolveEntryPoints({
386
+ configured: t.entryPoints,
387
+ errors: r,
388
+ flags: n
389
+ }),
390
+ exclude: this.resolveExclude({
391
+ configured: t.exclude,
392
+ flagged: n.exclude
393
+ }),
394
+ excludeCallees: this.resolveList({
395
+ configured: t.excludeCallees,
396
+ flagged: n.excludeCallees
397
+ }),
398
+ limits: this.resolveLimits({
399
+ configured: t.limits,
400
+ overrides: a
401
+ }),
402
+ write: this.resolveWrite({
403
+ configured: t.write,
404
+ errors: r,
405
+ flags: n
406
+ })
407
+ },
408
+ errors: r,
409
+ format: i,
410
+ limitOverrides: a
411
+ };
412
+ }
413
+ };
414
+ B = N([t(), M("design:paramtypes", [])], B);
415
+ //#endregion
416
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/flag-resolution/flag-resolution.module.ts
417
+ var V = class {};
418
+ V = N([n({
419
+ controllers: [],
420
+ exports: [B],
421
+ imports: [],
422
+ providers: [B]
423
+ })], V);
424
+ //#endregion
425
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/run-plan/run-plan.constants.ts
426
+ var H = "breadth", U = "depth", W = "reports", G = [
427
+ H,
428
+ U,
429
+ W
430
+ ], ge = ",", K = [
431
+ "json",
432
+ "markdown",
433
+ "mermaid"
434
+ ], q = class {
435
+ flagResolutionService;
436
+ constructor(e) {
437
+ this.flagResolutionService = e;
438
+ }
439
+ describeAcceptedCheckNames(e) {
440
+ return `${e}. It takes a comma-separated set drawn from ${G.map((e) => `"${e}"`).join(" and ")}, as in "--check ${G.join(",")}".`;
441
+ }
442
+ readCheckNames(e, t) {
443
+ if (e === void 0) return /* @__PURE__ */ new Set();
444
+ if (e === !0) return t.push(this.describeAcceptedCheckNames("--check needs a value")), /* @__PURE__ */ new Set();
445
+ let n = e.split(",").map((e) => e.trim()).filter((e) => e !== "");
446
+ return n.length === 0 ? (t.push(this.describeAcceptedCheckNames("--check needs a value")), /* @__PURE__ */ new Set()) : this.validateCheckNames(n, t);
447
+ }
448
+ validateCheckNames(e, t) {
449
+ let n = /* @__PURE__ */ new Set();
450
+ for (let r of e) {
451
+ if (G.includes(r)) {
452
+ n.add(r);
453
+ continue;
454
+ }
455
+ t.push(this.describeAcceptedCheckNames(`--check does not accept "${r}"`));
456
+ }
457
+ return n;
458
+ }
459
+ async prepareLookup(e, t) {
460
+ let n = process.cwd(), { authored: r, configuration: i, path: a } = await t.loadConfigurationFile({
461
+ configurationPath: e.config,
462
+ searchDirectory: n
463
+ }), { configuration: o, errors: s, format: c } = this.flagResolutionService.resolveRunFlags({
464
+ configuration: i,
465
+ flags: {
466
+ directories: e.directories,
467
+ entryPointAddresses: e.entryPointAddresses,
468
+ entryPointDecorators: e.entryPointDecorators,
469
+ exclude: e.exclude,
470
+ excludeCallees: e.excludeCallees,
471
+ format: e.format,
472
+ includeExportedFunctions: e.includeExportedFunctions,
473
+ includeOrphans: e.includeOrphans,
474
+ includeTests: e.includeTests
475
+ }
476
+ });
477
+ if (s.length > 0) throw z(s);
478
+ return {
479
+ authoredLimits: r.limits,
480
+ configuration: o,
481
+ configurationPath: a,
482
+ format: c,
483
+ workspaceRoot: n
484
+ };
485
+ }
486
+ async prepareRun(e, t) {
487
+ let { errors: n, mode: r } = this.selectMode(e);
488
+ if (n.length > 0) return {
489
+ errors: n,
490
+ run: void 0
491
+ };
492
+ let i = process.cwd(), { authored: a, configuration: o, path: s } = await t.loadConfigurationFile({
493
+ configurationPath: e.config,
494
+ searchDirectory: i
495
+ }), { configuration: c, errors: l, format: u, limitOverrides: d } = this.flagResolutionService.resolveRunFlags({
496
+ configuration: o,
497
+ flags: {
498
+ check: e.check,
499
+ directories: e.directories,
500
+ entryPointAddresses: e.entryPointAddresses,
501
+ entryPointDecorators: e.entryPointDecorators,
502
+ exclude: e.exclude,
503
+ excludeCallees: e.excludeCallees,
504
+ format: e.format,
505
+ includeExportedFunctions: e.includeExportedFunctions,
506
+ includeOrphans: e.includeOrphans,
507
+ includeTests: e.includeTests,
508
+ json: e.json,
509
+ markdown: e.markdown,
510
+ maximumBreadth: e.maximumBreadth,
511
+ maximumDepth: e.maximumDepth,
512
+ mermaid: e.mermaid,
513
+ write: e.write
514
+ }
515
+ });
516
+ return l.length > 0 ? {
517
+ errors: l,
518
+ run: void 0
519
+ } : {
520
+ errors: l,
521
+ run: {
522
+ authoredLimits: a.limits,
523
+ configuration: c,
524
+ configurationPath: s,
525
+ format: u,
526
+ limitOverrides: d,
527
+ mode: r,
528
+ workspaceRoot: i
529
+ }
530
+ };
531
+ }
532
+ selectMode(e) {
533
+ let t = [], n = this.readCheckNames(e.check, t), r = e.write === !0;
534
+ r && n.has("reports") && t.push(`--write cannot be combined with --check ${W}: a report cannot be stale in the run that just wrote it. Drop one of them, or run --write and --check ${W} separately.`);
535
+ let i = K.filter((t) => e[t] !== void 0);
536
+ if (i.length > 0 && !r && !n.has("reports")) {
537
+ let e = i.length === 1;
538
+ t.push(`${i.map((e) => `--${e}`).join(" and ")} ${e ? "names a destination" : "name destinations"} but nothing writes or compares ${e ? "it" : "them"}. Add --write to write ${e ? "it" : "them"}, or --check ${W} to fail on ${e ? "it" : "them"} being out of date.`);
539
+ }
540
+ return {
541
+ errors: t,
542
+ mode: {
543
+ checksBreadth: n.has(H),
544
+ checksDepth: n.has(U),
545
+ checksReports: n.has(W),
546
+ writes: r
547
+ }
548
+ };
549
+ }
550
+ touchesFiles(e) {
551
+ return e.checksReports || e.writes;
552
+ }
553
+ };
554
+ q = N([t(), M("design:paramtypes", [B === void 0 ? Object : B])], q);
555
+ //#endregion
556
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/run-plan/run-plan.module.ts
557
+ var J = class {};
558
+ J = N([n({
559
+ controllers: [],
560
+ exports: [q],
561
+ imports: [V],
562
+ providers: [q]
563
+ })], J);
564
+ //#endregion
565
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/configuration-file.service.ts
566
+ var Y = class {
567
+ constructor() {}
568
+ findConfigurationFile(e) {
569
+ let t = o.resolve(e);
570
+ for (;;) {
571
+ let e = this.findConfigurationFileAt(t);
572
+ if (e !== void 0) return e;
573
+ let n = o.dirname(t);
574
+ if (n === t) return;
575
+ t = n;
576
+ }
577
+ }
578
+ findRepositoryRoot() {
579
+ let e = o.resolve(process.cwd());
580
+ for (;;) {
581
+ let t = e;
582
+ if (f.some((e) => i(o.join(t, e)))) return e;
583
+ let n = o.dirname(e);
584
+ if (n === e) return;
585
+ e = n;
586
+ }
587
+ }
588
+ async loadConfigurationModule(e) {
589
+ if (e.extension === ".json" || e.extension === ".jsonc") return this.loadJsonConfiguration(e);
590
+ let t = await c(s(import.meta.url)).import(e.configurationPath, { default: !0 });
591
+ if (typeof t != "object" || !t) return {};
592
+ let n = t.default;
593
+ return typeof n == "object" && n ? n : t;
594
+ }
595
+ async loadJsonConfiguration(e) {
596
+ let t = await a(e.configurationPath, "utf8");
597
+ return e.extension === ".jsonc" ? l(t) : JSON.parse(t);
598
+ }
599
+ resolveConfigurationPath(e) {
600
+ let t = o.resolve(e);
601
+ if (i(t)) return t;
602
+ let n = this.findRepositoryRoot();
603
+ if (n === void 0) throw new w(t);
604
+ let r = o.resolve(n, e);
605
+ if (!i(r)) throw new w(t);
606
+ return r;
607
+ }
608
+ resolveEntryPoints(e) {
609
+ let t = e ?? {};
610
+ return {
611
+ addresses: t.addresses ?? [],
612
+ decorators: t.decorators ?? [...m],
613
+ includeExportedFunctions: t.includeExportedFunctions ?? !0,
614
+ includeOrphans: t.includeOrphans ?? !0,
615
+ includeTests: t.includeTests ?? !1
616
+ };
617
+ }
618
+ resolveExclude(e) {
619
+ return [.../* @__PURE__ */ new Set([...p, ...e ?? []])];
620
+ }
621
+ resolveJsonOutput(e) {
622
+ if (e?.json !== void 0) return {
623
+ indentation: e.json.indentation ?? 2,
624
+ path: e.json.path
625
+ };
626
+ }
627
+ resolveLimits(e) {
628
+ let t = e ?? {};
629
+ return {
630
+ maximumBreadth: t.maximumBreadth,
631
+ maximumDepth: t.maximumDepth ?? 6
632
+ };
633
+ }
634
+ resolveMarkdownDestination(e) {
635
+ if (e !== void 0) return {
636
+ description: e.description,
637
+ endMarker: e.endMarker ?? "<!-- callidescope:end -->",
638
+ heading: e.heading ?? "# 🔭 Callidescope",
639
+ path: e.path,
640
+ previewCount: e.previewCount ?? 3,
641
+ render: e.render,
642
+ startMarker: e.startMarker ?? "<!-- callidescope:start -->",
643
+ writeBlock: e.writeBlock
644
+ };
645
+ }
646
+ findConfigurationFileAt(e) {
647
+ for (let t of u) {
648
+ let n = o.join(e, t);
649
+ if (i(n)) return n;
650
+ }
651
+ }
652
+ async loadConfiguration(e = {}) {
653
+ let { configuration: t } = await this.loadConfigurationFile(e);
654
+ return t;
655
+ }
656
+ async loadConfigurationFile(e = {}) {
657
+ let t = e.configurationPath === void 0 ? this.findConfigurationFile(e.searchDirectory ?? process.cwd()) : this.resolveConfigurationPath(e.configurationPath);
658
+ if (t === void 0) return {
659
+ authored: {},
660
+ configuration: this.resolveConfiguration({}),
661
+ path: void 0
662
+ };
663
+ let n = o.extname(t).toLowerCase();
664
+ if (!d.has(n)) throw new b(t);
665
+ let r = C.parse(await this.loadConfigurationModule({
666
+ configurationPath: t,
667
+ extension: n
668
+ }));
669
+ return {
670
+ authored: r,
671
+ configuration: this.resolveConfiguration(r),
672
+ path: t
673
+ };
674
+ }
675
+ resolveConfiguration(e) {
676
+ return {
677
+ directories: e.directories ?? [],
678
+ entryPoints: this.resolveEntryPoints(e.entryPoints),
679
+ exclude: this.resolveExclude(e.exclude),
680
+ excludeCallees: e.excludeCallees ?? [],
681
+ excludeFrom: e.excludeFrom ?? [],
682
+ limits: this.resolveLimits(e.limits),
683
+ write: {
684
+ json: this.resolveJsonOutput(e.write),
685
+ markdown: this.resolveMarkdownDestination(e.write?.markdown),
686
+ mermaid: this.resolveMarkdownDestination(e.write?.mermaid)
687
+ }
688
+ };
689
+ }
690
+ };
691
+ Y = N([t(), M("design:paramtypes", [])], Y);
692
+ //#endregion
693
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/configuration-file.module.ts
694
+ var X = class {};
695
+ X = N([n({
696
+ controllers: [],
697
+ exports: [Y],
698
+ imports: [],
699
+ providers: [Y]
700
+ })], X);
701
+ //#endregion
702
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/project-configuration.service.ts
703
+ var Z = class {
704
+ constructor() {}
705
+ assertComplete(e) {
706
+ let t = this.findMissingField(e.authored);
707
+ if (t !== void 0) throw new D({
708
+ field: t,
709
+ project: e.project
710
+ });
711
+ }
712
+ assertNoForbiddenFields(e) {
713
+ let t = this.findForbiddenField(e.authored);
714
+ if (t !== void 0) throw new E({
715
+ field: t,
716
+ project: e.project
717
+ });
718
+ }
719
+ buildProjectLimits(e) {
720
+ let { limits: t } = e.projectConfiguration.configuration;
721
+ return {
722
+ maximumBreadth: this.overrideLimit({
723
+ declared: t.maximumBreadth,
724
+ override: e.overrides?.maximumBreadth
725
+ }),
726
+ maximumDepth: this.overrideLimit({
727
+ declared: t.maximumDepth,
728
+ override: e.overrides?.maximumDepth
729
+ }) ?? t.maximumDepth,
730
+ path: e.projectConfiguration.path
731
+ };
732
+ }
733
+ buildWorkspaceLimits(e) {
734
+ let { maximumBreadth: t, maximumDepth: n } = e.workspaceConfiguration.limits, r = e.workspaceAuthoredLimits;
735
+ return {
736
+ maximumBreadth: t,
737
+ maximumDepth: n,
738
+ path: r?.maximumBreadth !== void 0 || r?.maximumDepth !== void 0 ? e.workspaceConfigurationPath : void 0
739
+ };
740
+ }
741
+ findForbiddenField(e) {
742
+ let t = { ...e };
743
+ for (let [e, n] of Object.entries(t)) {
744
+ if (n === void 0) continue;
745
+ let t = ce.has(e) ? this.findForbiddenMember({
746
+ field: e,
747
+ value: n
748
+ }) : this.readForbiddenField(e);
749
+ if (t !== void 0) return t;
750
+ }
751
+ }
752
+ findForbiddenMember(e) {
753
+ if (typeof e.value != "object" || e.value === null) return e.field;
754
+ let t = { ...e.value };
755
+ for (let [n, r] of Object.entries(t)) {
756
+ let t = `${e.field}.${n}`;
757
+ if (r !== void 0 && !y.has(t)) return t;
758
+ }
759
+ }
760
+ findMissingField(e) {
761
+ let t = { ...e };
762
+ for (let [e, n] of Object.entries(ue)) {
763
+ if (!(e in t)) return e;
764
+ let r = t[e];
765
+ if (n.length === 0) continue;
766
+ if (typeof r != "object" || !r) return e;
767
+ let i = n.find((e) => !(e in r));
768
+ if (i !== void 0) return `${e}.${i}`;
769
+ }
770
+ }
771
+ async loadProjectConfiguration(e) {
772
+ try {
773
+ let t = await e.reader.loadConfigurationFile({ configurationPath: e.configurationPath });
774
+ return {
775
+ authored: t.authored,
776
+ configuration: t.configuration,
777
+ path: t.path,
778
+ project: e.project
779
+ };
780
+ } catch (t) {
781
+ throw new T({
782
+ cause: t,
783
+ configurationPath: e.configurationPath,
784
+ project: e.project
785
+ });
786
+ }
787
+ }
788
+ overrideLimit(e) {
789
+ return e.declared === void 0 ? void 0 : e.override ?? e.declared;
790
+ }
791
+ readForbiddenField(e) {
792
+ return y.has(e) ? void 0 : e;
793
+ }
794
+ async loadProjectConfigurations(e, t) {
795
+ let n = e.workspaceConfigurationPath === void 0 ? void 0 : o.resolve(e.workspaceRoot, e.workspaceConfigurationPath), r = [];
796
+ for (let i of e.projects) {
797
+ let a = t.findConfigurationFileAt(o.resolve(e.workspaceRoot, i));
798
+ if (a === void 0) throw new O(i);
799
+ if (a === n) continue;
800
+ let s = await this.loadProjectConfiguration({
801
+ configurationPath: a,
802
+ project: i,
803
+ reader: t
804
+ });
805
+ this.assertNoForbiddenFields(s), this.assertComplete(s), r.push(s);
806
+ }
807
+ return r;
808
+ }
809
+ resolveLimits(e) {
810
+ let t = this.buildWorkspaceLimits(e), n = new Map(e.projectConfigurations.map((t) => [t.project, this.buildProjectLimits({
811
+ overrides: e.limitOverrides,
812
+ projectConfiguration: t
813
+ })]));
814
+ return {
815
+ byProject: new Map(e.projects.map((e) => [e, n.get(e) ?? t])),
816
+ workspace: t
817
+ };
818
+ }
819
+ };
820
+ Z = N([t(), M("design:paramtypes", [])], Z);
821
+ //#endregion
822
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/configuration.service.ts
823
+ var Q = class {
824
+ configurationFileService;
825
+ inputService;
826
+ projectConfigurationService;
827
+ runPlanService;
828
+ constructor(e, t, n, r) {
829
+ this.configurationFileService = e, this.inputService = t, this.projectConfigurationService = n, this.runPlanService = r;
830
+ }
831
+ findConfigurationFileAt(e) {
832
+ return this.configurationFileService.findConfigurationFileAt(e);
833
+ }
834
+ async loadConfigurationFile(e = {}) {
835
+ return await this.configurationFileService.loadConfigurationFile(e);
836
+ }
837
+ async loadProjectConfigurations(e) {
838
+ return await this.projectConfigurationService.loadProjectConfigurations(e, this);
839
+ }
840
+ parseCommaDelimitedOption(e) {
841
+ return this.inputService.parseCommaDelimitedOption(e);
842
+ }
843
+ parseOptionalOption(e) {
844
+ return this.inputService.parseOptionalOption(e);
845
+ }
846
+ async prepareLookup(e) {
847
+ return await this.runPlanService.prepareLookup(e, this);
848
+ }
849
+ async prepareRun(e) {
850
+ return await this.runPlanService.prepareRun(e, this);
851
+ }
852
+ async promptForAutocompleteMultiselect(e) {
853
+ return await this.inputService.promptForAutocompleteMultiselect(e);
854
+ }
855
+ async promptForSelect(e) {
856
+ return await this.inputService.promptForSelect(e);
857
+ }
858
+ resolveConfiguration(e) {
859
+ return this.configurationFileService.resolveConfiguration(e);
860
+ }
861
+ async resolveFormatOption(e) {
862
+ if (e.format !== void 0 || !this.inputService.isAtTerminal()) return e;
863
+ let t = await this.promptForSelect({
864
+ choices: h,
865
+ message: "Which output format?",
866
+ subject: "An output format (--format)"
867
+ });
868
+ return {
869
+ ...e,
870
+ format: t
871
+ };
872
+ }
873
+ resolveLimits(e) {
874
+ return this.projectConfigurationService.resolveLimits(e);
875
+ }
876
+ touchesFiles(e) {
877
+ return this.runPlanService.touchesFiles(e);
878
+ }
879
+ };
880
+ Q = N([t(), M("design:paramtypes", [
881
+ Y === void 0 ? Object : Y,
882
+ P === void 0 ? Object : P,
883
+ Z === void 0 ? Object : Z,
884
+ q === void 0 ? Object : q
885
+ ])], Q);
886
+ //#endregion
887
+ //#region packages/ic-suite/callidescope/callidescope-configuration/src/modules/configuration/configuration.module.ts
888
+ var $ = class {};
889
+ $ = N([n({
890
+ controllers: [],
891
+ exports: [Q],
892
+ imports: [
893
+ X,
894
+ F,
895
+ J
896
+ ],
897
+ providers: [Q, Z]
898
+ })], $);
899
+ //#endregion
900
+ export { h as CALLIDESCOPE_OUTPUT_FORMATS, H as CHECK_BREADTH, U as CHECK_DEPTH, G as CHECK_NAMES, W as CHECK_REPORTS, ge as CHECK_SEPARATOR, u as CONFIGURATION_FILE_NAMES, w as ConfigurationFileNotFoundError, $ as ConfigurationModule, Q as ConfigurationService, m as DEFAULT_ENTRY_POINT_DECORATORS, p as DEFAULT_EXCLUDE_GLOBS, te as DEFAULT_JSON_INDENTATION, oe as DEFAULT_MARKDOWN_END_MARKER, ae as DEFAULT_MARKDOWN_START_MARKER, ee as DEFAULT_MAXIMUM_DEPTH, g as DEFAULT_OUTPUT_FORMAT, ie as DEFAULT_PREVIEW_COUNT, ne as DEFAULT_PROJECT_README_HEADING, re as DEFAULT_RUN_HEADING, K as DESTINATION_FLAG_NAMES, k as InputError, T as ProjectConfigurationError, E as ProjectConfigurationFieldNotPermittedError, D as ProjectConfigurationIncompleteError, O as ProjectConfigurationMissingError, f as REPOSITORY_ROOT_MARKERS, d as SUPPORTED_CONFIGURATION_EXTENSIONS, b as UnknownConfigurationFileTypeError, C as callidescopeConfigurationSchema, z as flagResolutionError, A as missingInputError, j as promptCancelledError };