raiton 6.11.1-beta.30 → 6.12.0-beta.31

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 (73) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/bin/index.mjs +2329 -361
  3. package/build/types/core/artifact-mount.d.ts +19 -0
  4. package/build/types/core/bridge/classifier.d.ts +30 -0
  5. package/build/types/core/bridge/definition.d.ts +10 -0
  6. package/build/types/core/bridge/diagnostics.d.ts +43 -0
  7. package/build/types/core/bridge/index.d.ts +8 -0
  8. package/build/types/core/bridge/loader.d.ts +75 -0
  9. package/build/types/core/bridge/packages.d.ts +27 -0
  10. package/build/types/core/bridge/paths.d.ts +37 -0
  11. package/build/types/core/bridge/registry.d.ts +50 -0
  12. package/build/types/core/bridge/resolver.d.ts +32 -0
  13. package/build/types/core/builder.d.ts +8 -1
  14. package/build/types/core/controller/builder.d.ts +9 -0
  15. package/build/types/core/controller/compiler.d.ts +8 -1
  16. package/build/types/core/controller/tracker.d.ts +10 -3
  17. package/build/types/core/hooks.d.ts +2 -0
  18. package/build/types/core/index.d.ts +1 -0
  19. package/build/types/core/injection/injection.d.ts +24 -0
  20. package/build/types/core/middleware/pipeline.d.ts +12 -1
  21. package/build/types/core/scheduler/manager.d.ts +5 -0
  22. package/build/types/framework/artifacts.d.ts +5 -0
  23. package/build/types/framework/constants/decorators.constant.d.ts +8 -0
  24. package/build/types/manifest/schema.d.ts +77 -0
  25. package/build/types/types/artifact.d.ts +16 -0
  26. package/build/types/types/bridge.d.ts +109 -0
  27. package/build/types/types/index.d.ts +1 -0
  28. package/docs/AGENTS.md +1 -1
  29. package/docs/CLAUDE.md +1 -1
  30. package/docs/generated/config-schema.json +26 -0
  31. package/docs/generated/manifest-schema.json +110 -0
  32. package/docs/generated/manifest.json +1 -1
  33. package/docs/llms-full.txt +176 -2
  34. package/docs/llms.txt +1 -1
  35. package/docs/user-guide/README.md +1 -0
  36. package/docs/user-guide/artifact-bridge.md +170 -0
  37. package/package.json +1 -1
  38. package/source/bin/project-utils.ts +9 -0
  39. package/source/commands/artifact.command.ts +24 -9
  40. package/source/commands/build.command.ts +3 -1
  41. package/source/commands/docs.command.ts +1 -0
  42. package/source/commands/doctor.command.ts +53 -1
  43. package/source/commands/inspect.command.ts +3 -0
  44. package/source/commands/start.command.ts +3 -1
  45. package/source/commands/why.command.ts +4 -0
  46. package/source/core/artifact-mount.ts +126 -0
  47. package/source/core/bridge/classifier.ts +112 -0
  48. package/source/core/bridge/definition.ts +35 -0
  49. package/source/core/bridge/diagnostics.ts +175 -0
  50. package/source/core/bridge/index.ts +8 -0
  51. package/source/core/bridge/loader.ts +914 -0
  52. package/source/core/bridge/packages.ts +196 -0
  53. package/source/core/bridge/paths.ts +152 -0
  54. package/source/core/bridge/registry.ts +177 -0
  55. package/source/core/bridge/resolver.ts +183 -0
  56. package/source/core/builder.ts +146 -7
  57. package/source/core/config/schema.ts +54 -9
  58. package/source/core/controller/builder.ts +49 -31
  59. package/source/core/controller/compiler.ts +13 -4
  60. package/source/core/controller/tracker.ts +29 -7
  61. package/source/core/hooks.ts +5 -0
  62. package/source/core/index.ts +2 -1
  63. package/source/core/injection/injection.ts +67 -0
  64. package/source/core/middleware/pipeline.ts +33 -2
  65. package/source/core/scheduler/manager.ts +15 -0
  66. package/source/core/thread.ts +21 -0
  67. package/source/framework/artifacts.ts +10 -0
  68. package/source/framework/constants/decorators.constant.ts +35 -27
  69. package/source/manifest/manifest.ts +46 -0
  70. package/source/manifest/schema.ts +48 -0
  71. package/source/types/artifact.ts +16 -0
  72. package/source/types/bridge.ts +136 -0
  73. package/source/types/index.ts +1 -0
@@ -0,0 +1,196 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import {RaitonConfig} from "../config/config.ts";
4
+ import type {ArtifactBridgeEntry} from "../../types/bridge.ts";
5
+ import type {BridgeDiagnostic} from "../../types/bridge.ts";
6
+ import {bridgeDiagnostic} from "./diagnostics.ts";
7
+ import {readJsonFile, resolvePackageJson} from "./resolver.ts";
8
+
9
+ import hostPackage from "../../../package.json" with {type: "json"};
10
+
11
+ export interface PackageBridgeEntry {
12
+ entry: ArtifactBridgeEntry;
13
+ package: string;
14
+ packageRoot: string;
15
+ location: string;
16
+ origin: "package";
17
+ }
18
+
19
+ export interface PackageDiscoveryResult {
20
+ packages: string[];
21
+ entries: PackageBridgeEntry[];
22
+ diagnostics: BridgeDiagnostic[];
23
+ }
24
+
25
+ function major(version: string | undefined): number | null {
26
+ if (!version) return null;
27
+ const match = String(version).replace(/^[^\d]*/, "").match(/^(\d+)/);
28
+ return match ? Number(match[1]) : null;
29
+ }
30
+
31
+ function directDependencies(packageJson: any): string[] {
32
+ return [...new Set([
33
+ ...Object.keys(packageJson?.dependencies ?? {}),
34
+ ...Object.keys(packageJson?.devDependencies ?? {}),
35
+ ])].sort();
36
+ }
37
+
38
+ function isStringArray(value: unknown): value is string[] {
39
+ return Array.isArray(value) && value.every(item => typeof item === "string" && item.trim().length > 0);
40
+ }
41
+
42
+ /**
43
+ * Normalize `package.json#raiton.artifacts`.
44
+ *
45
+ * Accepted forms:
46
+ * - `"./dist/artifacts.bridge.js"`
47
+ * - `["./dist/users.controller.js", "./dist/users.service.js"]`
48
+ * - `{ "artifacts": [...] }` (a bridge definition serialized in JSON)
49
+ */
50
+ function normalizeField(field: unknown): ArtifactBridgeEntry[] | null {
51
+ if (typeof field === "string" && field.trim()) return [field];
52
+ if (isStringArray(field)) return field;
53
+ if (Array.isArray(field)) {
54
+ const entries = field.filter(item =>
55
+ typeof item === "string"
56
+ || (item && typeof item === "object" && Array.isArray((item as any).artifacts)));
57
+ return entries.length === field.length ? entries as ArtifactBridgeEntry[] : null;
58
+ }
59
+ if (field && typeof field === "object" && Array.isArray((field as any).artifacts)) {
60
+ return (field as any).artifacts as ArtifactBridgeEntry[];
61
+ }
62
+ return null;
63
+ }
64
+
65
+ export interface DiscoverPackagesOptions {
66
+ /** Only inspect these packages (already filtered). */
67
+ allowlist?: string[];
68
+ /** Set to false to disable package discovery entirely. */
69
+ enabled?: boolean;
70
+ /** Emit info diagnostics for discovered packages. */
71
+ verbose?: boolean;
72
+ }
73
+
74
+ /**
75
+ * Inspect direct dependencies only. There is deliberately no recursive
76
+ * `node_modules` walk: each package is resolved by name from the project root.
77
+ */
78
+ export function discoverPackageArtifacts(
79
+ workdir: string,
80
+ options: DiscoverPackagesOptions = {},
81
+ ): PackageDiscoveryResult {
82
+ const config = RaitonConfig.get("artifacts");
83
+ const enabled = options.enabled ?? config?.packages ?? true;
84
+ if (!enabled) return {packages: [], entries: [], diagnostics: []};
85
+
86
+ const packageFile = path.join(workdir, "package.json");
87
+ if (!fs.existsSync(packageFile)) return {packages: [], entries: [], diagnostics: []};
88
+
89
+ let projectPackage: any;
90
+ try {
91
+ projectPackage = readJsonFile(packageFile);
92
+ } catch (error: any) {
93
+ return {
94
+ packages: [],
95
+ entries: [],
96
+ diagnostics: [bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
97
+ message: `Cannot read project package.json: ${error?.message ?? error}`,
98
+ location: packageFile,
99
+ })],
100
+ };
101
+ }
102
+
103
+ const allowlist = options.allowlist ?? config?.packageAllowlist;
104
+ const allowSet = allowlist?.length ? new Set(allowlist) : null;
105
+ const dependencies = directDependencies(projectPackage)
106
+ .filter(name => !allowSet || allowSet.has(name));
107
+
108
+ const entries: PackageBridgeEntry[] = [];
109
+ const packages: string[] = [];
110
+ const diagnostics: BridgeDiagnostic[] = [];
111
+ const hostMajor = major(hostPackage.version);
112
+
113
+ for (const name of dependencies) {
114
+ const packageJsonFile = resolvePackageJson(name, workdir);
115
+ if (!packageJsonFile) continue;
116
+
117
+ let packageJson: any;
118
+ try {
119
+ packageJson = readJsonFile(packageJsonFile);
120
+ } catch (error: any) {
121
+ diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
122
+ package: name,
123
+ message: `Cannot read ${name}/package.json: ${error?.message ?? error}`,
124
+ location: packageJsonFile,
125
+ }));
126
+ continue;
127
+ }
128
+
129
+ const field = packageJson?.raiton?.artifacts;
130
+ if (field === undefined) continue;
131
+
132
+ const normalized = normalizeField(field);
133
+ if (!normalized) {
134
+ diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
135
+ package: name,
136
+ message: `${name} declares an invalid package.json#raiton.artifacts field`,
137
+ location: packageJsonFile,
138
+ }));
139
+ continue;
140
+ }
141
+
142
+ const packageRoot = path.dirname(packageJsonFile);
143
+ packages.push(name);
144
+
145
+ // ABI / packaging contract checks.
146
+ if (packageJson.dependencies?.raiton) {
147
+ diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
148
+ package: name,
149
+ message: `${name} embeds Raiton in dependencies instead of peerDependencies`,
150
+ action: "Move `raiton` to peerDependencies and rebuild the package.",
151
+ location: packageJsonFile,
152
+ }));
153
+ }
154
+ const peer = packageJson.peerDependencies?.raiton;
155
+ const peerMajor = major(peer);
156
+ if (peer && hostMajor !== null && peerMajor !== null && peerMajor !== hostMajor) {
157
+ diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
158
+ package: name,
159
+ message: `${name} targets Raiton ${peer}, host is ${hostPackage.version}`,
160
+ action: "Align the package's raiton peerDependency with the host major version and rebuild it.",
161
+ location: packageJsonFile,
162
+ }));
163
+ }
164
+ const nested = path.join(packageRoot, "node_modules", "raiton", "package.json");
165
+ if (fs.existsSync(nested)) {
166
+ diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
167
+ package: name,
168
+ message: `${name} contains its own copy of Raiton`,
169
+ action: "Remove the nested raiton copy and declare `raiton` as a peerDependency.",
170
+ location: nested,
171
+ }));
172
+ }
173
+
174
+ for (const entry of normalized) {
175
+ entries.push({
176
+ entry,
177
+ package: name,
178
+ packageRoot,
179
+ location: packageJsonFile,
180
+ origin: "package",
181
+ });
182
+ }
183
+
184
+ if (options.verbose) {
185
+ diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
186
+ severity: "info",
187
+ package: name,
188
+ message: `${name} declares ${normalized.length} bridge artifact(s)`,
189
+ action: "No action required.",
190
+ location: packageJsonFile,
191
+ }));
192
+ }
193
+ }
194
+
195
+ return {packages, entries, diagnostics};
196
+ }
@@ -0,0 +1,152 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import {RaitonConfig} from "../config/config.ts";
4
+ import {RaitonDirectories} from "../directories.ts";
5
+ import {isNodeUsed} from "../../bin/constants.ts";
6
+
7
+ export const BRIDGE_FILENAME = "artifacts.bridge";
8
+ export const COMPILED_BRIDGE_FILENAME = "artifacts.bridge.mjs";
9
+
10
+ const BRIDGE_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"] as const;
11
+
12
+ export interface BridgeSourceResolution {
13
+ /** Bridge source file, or null when absent. */
14
+ file: string | null;
15
+ /** Programmatic project root. */
16
+ workdir: string;
17
+ /** Configured root directory, absolute. */
18
+ rootDir: string;
19
+ /** True when `artifacts.bridge` explicitly configured the path. */
20
+ explicit: boolean;
21
+ /** True when `artifacts.bridge === false`. */
22
+ disabled: boolean;
23
+ /** Path that was expected (configured or default). */
24
+ expected: string | null;
25
+ }
26
+
27
+ function candidatesFor(base: string): string[] {
28
+ const extension = path.extname(base).toLowerCase();
29
+ if (BRIDGE_EXTENSIONS.includes(extension as any)) {
30
+ const stem = base.slice(0, -extension.length);
31
+ return [...new Set([
32
+ base,
33
+ ...BRIDGE_EXTENSIONS.map(candidate => `${stem}${candidate}`),
34
+ ])];
35
+ }
36
+ return BRIDGE_EXTENSIONS.map(candidate => `${base}${candidate}`);
37
+ }
38
+
39
+ function firstExisting(candidates: string[]): string | null {
40
+ for (const candidate of candidates) {
41
+ try {
42
+ if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) return candidate;
43
+ } catch {
44
+ // Ignore unreadable candidates.
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /**
51
+ * Resolve the bridge source from configuration. This is intentionally cheap:
52
+ * only a bounded list of extension candidates is probed, never a directory
53
+ * walk.
54
+ */
55
+ export function resolveBridgeSource(workdir = process.cwd()): BridgeSourceResolution {
56
+ const rootDir = path.resolve(workdir, RaitonConfig.get("rootDir") || "./");
57
+ const configured = RaitonConfig.get("artifacts")?.bridge;
58
+
59
+ if (configured === false) {
60
+ return {file: null, workdir, rootDir, explicit: false, disabled: true, expected: null};
61
+ }
62
+
63
+ if (typeof configured === "string" && configured.trim()) {
64
+ const absolute = path.isAbsolute(configured)
65
+ ? configured
66
+ : null;
67
+ const bases = absolute
68
+ ? [absolute]
69
+ : [...new Set([
70
+ path.resolve(workdir, configured),
71
+ path.resolve(rootDir, configured),
72
+ ])];
73
+
74
+ const candidates = bases.flatMap(candidatesFor);
75
+ return {
76
+ file: firstExisting(candidates),
77
+ workdir,
78
+ rootDir,
79
+ explicit: true,
80
+ disabled: false,
81
+ expected: bases[0],
82
+ };
83
+ }
84
+
85
+ const expected = path.join(rootDir, BRIDGE_FILENAME);
86
+ return {
87
+ file: firstExisting(candidatesFor(expected)),
88
+ workdir,
89
+ rootDir,
90
+ explicit: false,
91
+ disabled: false,
92
+ expected: candidatesFor(expected)[0],
93
+ };
94
+ }
95
+
96
+ export function compiledBridgeFile(workdir = process.cwd()): string {
97
+ return path.join(RaitonDirectories.server(workdir), COMPILED_BRIDGE_FILENAME);
98
+ }
99
+
100
+ export interface RuntimeBridgeResolution extends BridgeSourceResolution {
101
+ /** File actually imported at runtime. */
102
+ runtimeFile: string | null;
103
+ /** True when the runtime expects a compiled bridge. */
104
+ requiresCompiled: boolean;
105
+ }
106
+
107
+ /**
108
+ * Select the bridge file for the current runtime. Bun and Deno import the
109
+ * source directly; Node uses the compiled `.raiton/server/artifacts.bridge.mjs`.
110
+ */
111
+ export function resolveRuntimeBridge(workdir = process.cwd()): RuntimeBridgeResolution {
112
+ const source = resolveBridgeSource(workdir);
113
+ if (isNodeUsed) {
114
+ const compiled = compiledBridgeFile(workdir);
115
+ if (fs.existsSync(compiled)) {
116
+ // Production may ship only `.raiton/server`, without the source
117
+ // tree. The compiled bridge is then the bridge file.
118
+ return {
119
+ ...source,
120
+ file: source.file ?? compiled,
121
+ runtimeFile: compiled,
122
+ requiresCompiled: true,
123
+ };
124
+ }
125
+ }
126
+ if (!source.file) {
127
+ return {...source, runtimeFile: null, requiresCompiled: isNodeUsed};
128
+ }
129
+ if (!isNodeUsed) {
130
+ return {...source, runtimeFile: source.file, requiresCompiled: false};
131
+ }
132
+ return {
133
+ ...source,
134
+ runtimeFile: source.file,
135
+ requiresCompiled: true,
136
+ };
137
+ }
138
+
139
+ export function isSameFile(left: string | null | undefined, right: string | null | undefined): boolean {
140
+ if (!left || !right) return false;
141
+ return path.resolve(left) === path.resolve(right);
142
+ }
143
+
144
+ export function isWithin(parent: string, file: string): boolean {
145
+ const relative = path.relative(path.resolve(parent), path.resolve(file));
146
+ return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
147
+ }
148
+
149
+ export function relativeTo(workdir: string, file?: string | null): string | undefined {
150
+ if (!file) return undefined;
151
+ return path.relative(workdir, file).split(path.sep).join("/");
152
+ }
@@ -0,0 +1,177 @@
1
+ import path from "node:path";
2
+ import {Injection} from "../injection/injection.ts";
3
+ import type {ArtifactKind, ArtifactOrigin, BridgeManifestArtifact} from "../../types/bridge.ts";
4
+ import type {Route} from "../router/route.ts";
5
+ import type {HookHandlerCallable, HookNameType} from "../../types/core.ts";
6
+
7
+ export interface MountedArtifactRecord {
8
+ /** Stable logical key used by the bridge diff. */
9
+ key: string;
10
+ name: string;
11
+ kind: ArtifactKind;
12
+ origin: ArtifactOrigin;
13
+ construct?: unknown;
14
+ package?: string;
15
+ file?: string;
16
+ routes?: Route[];
17
+ middlewareName?: string;
18
+ hookName?: HookNameType;
19
+ handler?: HookHandlerCallable;
20
+ pluginName?: string;
21
+ }
22
+
23
+ export function artifactKey(record: Pick<MountedArtifactRecord, "kind" | "name" | "file" | "package">): string {
24
+ return [record.kind, record.name, record.file ?? "", record.package ?? ""].join("|");
25
+ }
26
+
27
+ /**
28
+ * Central identity registry. It never mounts anything: it records what has
29
+ * already been mounted so the scan and the bridge cannot duplicate routes,
30
+ * middleware, hooks or instances.
31
+ */
32
+ export class ArtifactRegistry {
33
+ protected static readonly byConstruct = new WeakMap<object, MountedArtifactRecord>();
34
+ protected static readonly byKey = new Map<string, MountedArtifactRecord>();
35
+ protected static readonly excludedFiles = new Set<string>();
36
+
37
+ static clear(): void {
38
+ this.byKey.clear();
39
+ this.excludedFiles.clear();
40
+ }
41
+
42
+ /** Remove only bridge-owned records, leaving scan records intact. */
43
+ static clearBridge(): void {
44
+ for (const [key, record] of [...this.byKey]) {
45
+ if (record.origin === "bridge" || record.origin === "package") {
46
+ this.byKey.delete(key);
47
+ }
48
+ }
49
+ }
50
+
51
+ static add(record: MountedArtifactRecord): MountedArtifactRecord {
52
+ const existing = this.byKey.get(record.key);
53
+ if (existing) return existing;
54
+ this.byKey.set(record.key, record);
55
+ if (record.construct && (typeof record.construct === "function" || typeof record.construct === "object")) {
56
+ this.byConstruct.set(record.construct as object, record);
57
+ }
58
+ return record;
59
+ }
60
+
61
+ static getByKey(key: string): MountedArtifactRecord | undefined {
62
+ return this.byKey.get(key);
63
+ }
64
+
65
+ static getByConstruct(construct: unknown): MountedArtifactRecord | undefined {
66
+ if (!construct || (typeof construct !== "function" && typeof construct !== "object")) return undefined;
67
+ const record = this.byConstruct.get(construct as object);
68
+ if (!record) return undefined;
69
+ return this.byKey.get(record.key) === record ? record : undefined;
70
+ }
71
+
72
+ static hasConstruct(construct: unknown): boolean {
73
+ return Boolean(this.getByConstruct(construct));
74
+ }
75
+
76
+ static remove(key: string): MountedArtifactRecord | undefined {
77
+ const record = this.byKey.get(key);
78
+ if (!record) return undefined;
79
+ this.byKey.delete(key);
80
+ if (record.construct && (typeof record.construct === "function" || typeof record.construct === "object")) {
81
+ const mapped = this.byConstruct.get(record.construct as object);
82
+ if (mapped === record) {
83
+ // WeakMap has no delete-by-value semantics we can observe; the
84
+ // keyed map is authoritative and `getByConstruct` is guarded by
85
+ // the record still being present in `byKey`.
86
+ this.byConstruct.delete(record.construct as object);
87
+ }
88
+ }
89
+ return record;
90
+ }
91
+
92
+ static records(): MountedArtifactRecord[] {
93
+ return [...this.byKey.values()];
94
+ }
95
+
96
+ static recordsByOrigin(origin: ArtifactOrigin): MountedArtifactRecord[] {
97
+ return this.records().filter(record => record.origin === origin);
98
+ }
99
+
100
+ static routeInfo(route: Route): MountedArtifactRecord | undefined {
101
+ for (const record of this.byKey.values()) {
102
+ if (record.routes?.includes(route)) return record;
103
+ }
104
+ const controllerClass = (route.handler as any)?._raitonMeta?.controllerClass;
105
+ if (controllerClass) {
106
+ const record = this.getByConstruct(controllerClass);
107
+ if (record) return record;
108
+ }
109
+ return undefined;
110
+ }
111
+
112
+ static excludeFile(filename: string): void {
113
+ this.excludedFiles.add(path.resolve(filename));
114
+ }
115
+
116
+ static isExcludedFile(filename: string): boolean {
117
+ return this.excludedFiles.has(path.resolve(filename));
118
+ }
119
+
120
+ static setExcludedFiles(files: Iterable<string>): void {
121
+ this.excludedFiles.clear();
122
+ for (const file of files) this.excludeFile(file);
123
+ }
124
+
125
+ static excluded(): string[] {
126
+ return [...this.excludedFiles];
127
+ }
128
+
129
+ /**
130
+ * Inventory used by `raiton artifact`. Compiled scan artifacts and bridge
131
+ * artifacts come from the registry; DI definitions that were never mounted
132
+ * as routes are added as `di` entries.
133
+ */
134
+ static describeArtifacts(workdir: string): BridgeManifestArtifact[] {
135
+ const output: BridgeManifestArtifact[] = [];
136
+ const seenConstructs = new Set<unknown>();
137
+ const seenNames = new Set<string>();
138
+
139
+ const add = (record: {
140
+ name: string;
141
+ kind: ArtifactKind;
142
+ origin: ArtifactOrigin;
143
+ construct?: unknown;
144
+ package?: string;
145
+ file?: string;
146
+ }) => {
147
+ if (seenNames.has(`${record.kind}:${record.name}`)) return;
148
+ seenNames.add(`${record.kind}:${record.name}`);
149
+ if (record.construct) seenConstructs.add(record.construct);
150
+ output.push({
151
+ name: record.name,
152
+ kind: record.kind,
153
+ origin: record.origin === "scan" ? "scan" : "bridge",
154
+ ...(record.package ? {package: record.package} : {}),
155
+ ...(record.file ? {file: path.relative(workdir, record.file).split(path.sep).join("/")} : {}),
156
+ });
157
+ };
158
+
159
+ for (const record of this.records()) add(record);
160
+
161
+ for (const definition of Injection.classes.values()) {
162
+ if (seenConstructs.has(definition.construct)) continue;
163
+ if (seenNames.has(`di:${definition.name}`)) continue;
164
+ const file = Injection.getArtifactPath(definition.name);
165
+ add({
166
+ name: definition.name,
167
+ kind: "di",
168
+ origin: "scan",
169
+ construct: definition.construct,
170
+ ...(file ? {file} : {}),
171
+ });
172
+ }
173
+
174
+ return output.sort((left, right) =>
175
+ `${left.origin}:${left.kind}:${left.name}`.localeCompare(`${right.origin}:${right.kind}:${right.name}`));
176
+ }
177
+ }