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,35 @@
1
+ import type {ArtifactBridgeDefinition, ArtifactBridgeEntry} from "../../types/bridge.ts";
2
+ import {BridgeError} from "./diagnostics.ts";
3
+
4
+ /**
5
+ * Public helper used by `artifacts.bridge.ts` files.
6
+ *
7
+ * The preferred form is `{ artifacts: [...] }`; a bare array is accepted for
8
+ * convenience. Validation happens here so the runtime receives a normalized
9
+ * manifest.
10
+ */
11
+ export function defineArtifactBridge(
12
+ definition: ArtifactBridgeDefinition | ArtifactBridgeEntry[],
13
+ ): ArtifactBridgeDefinition {
14
+ const artifacts = Array.isArray(definition)
15
+ ? definition
16
+ : definition?.artifacts;
17
+
18
+ if (!Array.isArray(artifacts)) {
19
+ throw new BridgeError("BRIDGE_FILE_INVALID_EXPORT", {
20
+ message: "defineArtifactBridge() requires an `artifacts` array",
21
+ action: "Call defineArtifactBridge({ artifacts: [...] }).",
22
+ entry: "artifacts",
23
+ });
24
+ }
25
+
26
+ return Array.isArray(definition)
27
+ ? {artifacts}
28
+ : {...definition, artifacts};
29
+ }
30
+
31
+ export function isArtifactBridgeDefinition(value: unknown): value is ArtifactBridgeDefinition {
32
+ return Boolean(value)
33
+ && typeof value === "object"
34
+ && Array.isArray((value as any).artifacts);
35
+ }
@@ -0,0 +1,175 @@
1
+ import {ERROR_CATALOG, errorDocsUrl} from "../../framework/errors/catalog.ts";
2
+ import {HttpStatus} from "../../framework/enums/http-status.enum.ts";
3
+ import type {BridgeDiagnostic, BridgeDiagnosticSeverity} from "../../types/bridge.ts";
4
+
5
+ export const BRIDGE_DOCS_PATH = "user-guide/artifact-bridge.md";
6
+
7
+ export interface BridgeDiagnosticDefinition {
8
+ severity: BridgeDiagnosticSeverity;
9
+ message: string;
10
+ action: string;
11
+ }
12
+
13
+ /**
14
+ * Stable bridge diagnostic codes. Codes are additive and never renamed so CLI
15
+ * output, tests and documentation links stay valid across releases.
16
+ */
17
+ export const BRIDGE_DIAGNOSTICS: Record<string, BridgeDiagnosticDefinition> = {
18
+ BRIDGE_FILE_NOT_FOUND: {
19
+ severity: "error",
20
+ message: "The configured artifacts bridge file was not found",
21
+ action: "Create the file or fix `artifacts.bridge` in raiton.config.*.",
22
+ },
23
+ BRIDGE_FILE_INVALID_EXPORT: {
24
+ severity: "error",
25
+ message: "The artifacts bridge does not export a valid definition",
26
+ action: "Export `defineArtifactBridge({ artifacts: [...] })` as the default export.",
27
+ },
28
+ BRIDGE_IMPORT_FAILED: {
29
+ severity: "error",
30
+ message: "The artifacts bridge module failed to load",
31
+ action: "Fix the import error reported by the runtime, then retry.",
32
+ },
33
+ BRIDGE_MODULE_NOT_FOUND: {
34
+ severity: "error",
35
+ message: "A bridge module specifier could not be resolved",
36
+ action: "Check the package name, local path and that the dependency is installed.",
37
+ },
38
+ BRIDGE_ENTRY_INVALID: {
39
+ severity: "error",
40
+ message: "A bridge entry is not a supported declaration",
41
+ action: "Use a decorated class/function, a module specifier, a local path, or a middleware/hook/plugin descriptor.",
42
+ },
43
+ BRIDGE_ARTIFACT_NOT_FOUND: {
44
+ severity: "error",
45
+ message: "The declared module does not expose a decorated artifact",
46
+ action: "Export a decorated controller/socket/MCP/scheduler/injectable, or remove the entry.",
47
+ },
48
+ BRIDGE_ARTIFACT_AMBIGUOUS: {
49
+ severity: "error",
50
+ message: "A bridge entry is ambiguous",
51
+ action: "Decorate the class or use `{ middleware }`, `{ hook }` or `{ plugin }` explicitly.",
52
+ },
53
+ BRIDGE_ARTIFACT_DUPLICATE: {
54
+ severity: "info",
55
+ message: "The same bridge artifact is declared more than once",
56
+ action: "Remove the duplicate declaration; only the first one is mounted.",
57
+ },
58
+ BRIDGE_NAME_COLLISION: {
59
+ severity: "error",
60
+ message: "Two different classes share the same injection name",
61
+ action: "Rename one class or use `@Injectable(lifetime, \"unique:name\")`.",
62
+ },
63
+ BRIDGE_ABI_MISMATCH: {
64
+ severity: "error",
65
+ message: "A package embeds an incompatible copy of Raiton",
66
+ action: "Declare `raiton` in `peerDependencies`, remove it from `dependencies`, and rebuild the package.",
67
+ },
68
+ BRIDGE_RUNTIME_UNSUPPORTED: {
69
+ severity: "error",
70
+ message: "The bridge entry cannot run on the current runtime",
71
+ action: "Compile the package/file to JavaScript or use a runtime that supports TypeScript.",
72
+ },
73
+ BRIDGE_NOT_BUNDLED: {
74
+ severity: "error",
75
+ message: "The artifacts bridge has not been compiled for this production runtime",
76
+ action: "Run `raiton build` before `raiton start` or the inspection command.",
77
+ },
78
+ BRIDGE_PACKAGE_FIELD_INVALID: {
79
+ severity: "error",
80
+ message: "A package declares an invalid `package.json#raiton.artifacts` field",
81
+ action: "Use a string, an array of strings, or a bridge definition object.",
82
+ },
83
+ BRIDGE_HOOK_UNKNOWN: {
84
+ severity: "error",
85
+ message: "A bridge hook name is not supported",
86
+ action: "Use one of: onRequest, preParsing, preHandler, onSend, onResponse.",
87
+ },
88
+ BRIDGE_DUPLICATE_MOUNT: {
89
+ severity: "info",
90
+ message: "The artifact was already mounted by the suffix scan",
91
+ action: "Remove the bridge entry if the scan already covers the file.",
92
+ },
93
+ };
94
+
95
+ export const SUPPORTED_HOOK_NAMES = [
96
+ "onRequest",
97
+ "preParsing",
98
+ "preHandler",
99
+ "onSend",
100
+ "onResponse",
101
+ ] as const;
102
+
103
+ // Bridge diagnostics are part of the stable public error catalogue so HTTP
104
+ // payloads and CLI diagnostics share the same code, hint and docs URL.
105
+ for (const [code, definition] of Object.entries(BRIDGE_DIAGNOSTICS)) {
106
+ if (ERROR_CATALOG[code]) continue;
107
+ ERROR_CATALOG[code] = {
108
+ code,
109
+ status: HttpStatus.INTERNAL_SERVER_ERROR,
110
+ message: definition.message,
111
+ docsPath: BRIDGE_DOCS_PATH,
112
+ hint: definition.action,
113
+ };
114
+ }
115
+
116
+ export interface BridgeDiagnosticOptions {
117
+ message?: string;
118
+ action?: string;
119
+ location?: string;
120
+ entry?: string;
121
+ module?: string;
122
+ package?: string;
123
+ severity?: BridgeDiagnosticSeverity;
124
+ }
125
+
126
+ export function bridgeDiagnostic(
127
+ code: string,
128
+ options: BridgeDiagnosticOptions = {},
129
+ ): BridgeDiagnostic {
130
+ const definition = BRIDGE_DIAGNOSTICS[code] ?? BRIDGE_DIAGNOSTICS.BRIDGE_ENTRY_INVALID;
131
+ return {
132
+ code,
133
+ severity: options.severity ?? definition.severity,
134
+ message: options.message ?? definition.message,
135
+ action: options.action ?? definition.action,
136
+ docsUrl: errorDocsUrl(BRIDGE_DOCS_PATH),
137
+ ...(options.location ? {location: options.location} : {}),
138
+ ...(options.entry ? {entry: options.entry} : {}),
139
+ ...(options.module ? {module: options.module} : {}),
140
+ ...(options.package ? {package: options.package} : {}),
141
+ };
142
+ }
143
+
144
+ /**
145
+ * Error thrown by the bridge loader and the builders. The `code` is stable and
146
+ * is reused by `raiton doctor` and the CLI error envelope.
147
+ */
148
+ export class BridgeError extends Error {
149
+ public readonly code: string;
150
+ public readonly diagnostic: BridgeDiagnostic;
151
+ public readonly entry?: string;
152
+ public readonly module?: string;
153
+
154
+ constructor(code: string, options: BridgeDiagnosticOptions = {}) {
155
+ const diagnostic = bridgeDiagnostic(code, options);
156
+ super(diagnostic.message);
157
+ this.name = "BridgeError";
158
+ this.code = code;
159
+ this.diagnostic = diagnostic;
160
+ this.entry = options.entry;
161
+ this.module = options.module;
162
+ }
163
+
164
+ toJSON() {
165
+ return {
166
+ code: this.code,
167
+ message: this.message,
168
+ action: this.diagnostic.action,
169
+ docsUrl: this.diagnostic.docsUrl,
170
+ ...(this.diagnostic.location ? {location: this.diagnostic.location} : {}),
171
+ ...(this.diagnostic.entry ? {entry: this.diagnostic.entry} : {}),
172
+ ...(this.diagnostic.module ? {module: this.diagnostic.module} : {}),
173
+ };
174
+ }
175
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./diagnostics.ts";
2
+ export * from "./definition.ts";
3
+ export * from "./classifier.ts";
4
+ export * from "./registry.ts";
5
+ export * from "./paths.ts";
6
+ export * from "./resolver.ts";
7
+ export * from "./packages.ts";
8
+ export * from "./loader.ts";