raiton 6.8.6-beta.21 → 6.8.8-beta.24
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.
- package/CHANGELOG.md +13 -0
- package/build/bin/index.mjs +25 -2
- package/package.json +2 -1
- package/source/core/controller/builder.ts +42 -1
- package/tests/artifact-resolution.test.ts +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [6.8.8-beta.24](https://github.com/protorians/raiton/compare/v6.8.7-beta.22...v6.8.8-beta.24) (2026-10-30)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* fix:version ([66e4a81](https://github.com/protorians/raiton/commit/66e4a81d212a72fbcc947775d97ef20f09ac5989))
|
|
6
|
+
|
|
7
|
+
## [6.8.7-beta.22](https://github.com/protorians/raiton/compare/v6.8.6-beta.21...v6.8.7-beta.22) (2026-10-30)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* chore(test): ajoute le script test (bun test) ([4b25595](https://github.com/protorians/raiton/commit/4b2559542894fed96ba6deef38427f197d3e5da9))
|
|
12
|
+
* fix(core): retrouve l'artefact décoré parmi les exports nommés ([3f60b91](https://github.com/protorians/raiton/commit/3f60b914851cd920b96376d04be3efde9f968a95))
|
|
13
|
+
|
|
1
14
|
## [6.8.6-beta.21](https://github.com/protorians/raiton/compare/v6.8.3-beta.19...v6.8.6-beta.21) (2026-10-22)
|
|
2
15
|
|
|
3
16
|
### Bug Fixes
|
package/build/bin/index.mjs
CHANGED
|
@@ -25658,7 +25658,7 @@ class ControllerBuilder {
|
|
|
25658
25658
|
if (!isController && !isSocket && !isMcp && !isScheduler)
|
|
25659
25659
|
return;
|
|
25660
25660
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
25661
|
-
const artifact = imported
|
|
25661
|
+
const artifact = resolveArtifact(imported, { isController, isSocket, isMcp, isScheduler });
|
|
25662
25662
|
if (!artifact)
|
|
25663
25663
|
return;
|
|
25664
25664
|
if (!RaitonThread.current?.application)
|
|
@@ -25698,6 +25698,27 @@ class ControllerBuilder {
|
|
|
25698
25698
|
}
|
|
25699
25699
|
}
|
|
25700
25700
|
}
|
|
25701
|
+
function resolveArtifact(imported, kinds) {
|
|
25702
|
+
if (!imported || typeof imported !== "object")
|
|
25703
|
+
return imported;
|
|
25704
|
+
const keys = [];
|
|
25705
|
+
if (kinds.isController)
|
|
25706
|
+
keys.push(METADATA_KEYS.CONTROLLERS);
|
|
25707
|
+
if (kinds.isSocket)
|
|
25708
|
+
keys.push(METADATA_KEYS.SOCKETS);
|
|
25709
|
+
if (kinds.isMcp)
|
|
25710
|
+
keys.push(METADATA_KEYS.MCP);
|
|
25711
|
+
if (kinds.isScheduler)
|
|
25712
|
+
keys.push(METADATA_KEYS.SCHEDULER);
|
|
25713
|
+
const decorated = Object.values(imported).find((candidate) => isDecoratedArtifact(candidate, keys));
|
|
25714
|
+
return decorated ?? imported.default ?? imported;
|
|
25715
|
+
}
|
|
25716
|
+
function isDecoratedArtifact(candidate, keys) {
|
|
25717
|
+
if (typeof candidate !== "function")
|
|
25718
|
+
return false;
|
|
25719
|
+
const prototype = candidate.prototype;
|
|
25720
|
+
return keys.some((key) => (prototype ? Boolean(Reflect.getMetadata(key, prototype)) : false) || Boolean(Reflect.getMetadata(key, candidate)));
|
|
25721
|
+
}
|
|
25701
25722
|
var init_builder4 = __esm(() => {
|
|
25702
25723
|
init_compiler();
|
|
25703
25724
|
init_builder();
|
|
@@ -25707,6 +25728,7 @@ var init_builder4 = __esm(() => {
|
|
|
25707
25728
|
init_injection2();
|
|
25708
25729
|
init_framework();
|
|
25709
25730
|
init_artifacts();
|
|
25731
|
+
init_constants();
|
|
25710
25732
|
init_tracker();
|
|
25711
25733
|
});
|
|
25712
25734
|
|
|
@@ -30097,7 +30119,7 @@ var {
|
|
|
30097
30119
|
// package.json
|
|
30098
30120
|
var package_default = {
|
|
30099
30121
|
name: "raiton",
|
|
30100
|
-
version: "6.8.
|
|
30122
|
+
version: "6.8.8-beta.24",
|
|
30101
30123
|
private: false,
|
|
30102
30124
|
type: "module",
|
|
30103
30125
|
description: "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
|
|
@@ -30138,6 +30160,7 @@ var package_default = {
|
|
|
30138
30160
|
"dev:node": "node build/bin/index.mjs dev",
|
|
30139
30161
|
"dev:deno": "deno task dev",
|
|
30140
30162
|
build: "bun build source/bin/index.ts --target=node --format=esm --outfile=build/bin/index.mjs",
|
|
30163
|
+
test: "bun test tests",
|
|
30141
30164
|
start: "bun run source/bin/index.ts start",
|
|
30142
30165
|
"start:node": "node build/bin/index.mjs start",
|
|
30143
30166
|
"start:deno": "deno task start",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raiton",
|
|
3
|
-
"version": "6.8.
|
|
3
|
+
"version": "6.8.8-beta.24",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dev:node": "node build/bin/index.mjs dev",
|
|
42
42
|
"dev:deno": "deno task dev",
|
|
43
43
|
"build": "bun build source/bin/index.ts --target=node --format=esm --outfile=build/bin/index.mjs",
|
|
44
|
+
"test": "bun test tests",
|
|
44
45
|
"start": "bun run source/bin/index.ts start",
|
|
45
46
|
"start:node": "node build/bin/index.mjs start",
|
|
46
47
|
"start:deno": "deno task start",
|
|
@@ -9,6 +9,7 @@ import {RaitonThread} from "../thread.ts";
|
|
|
9
9
|
import {Injection} from "../injection/index.ts";
|
|
10
10
|
import {isControllerArtifact, isSocketArtifact, isMcpArtifact, isSchedulerArtifact} from "../../framework/index.ts";
|
|
11
11
|
import {Artifacts} from "../../framework/artifacts.ts";
|
|
12
|
+
import {METADATA_KEYS} from "../../framework/constants/index.ts";
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import {ControllerRouteTracker} from "./tracker.ts";
|
|
14
15
|
|
|
@@ -58,7 +59,7 @@ export class ControllerBuilder {
|
|
|
58
59
|
return undefined;
|
|
59
60
|
|
|
60
61
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
|
|
61
|
-
const artifact = imported
|
|
62
|
+
const artifact = resolveArtifact(imported, {isController, isSocket, isMcp, isScheduler});
|
|
62
63
|
|
|
63
64
|
if (!artifact) return undefined;
|
|
64
65
|
if (!RaitonThread.current?.application) return undefined;
|
|
@@ -104,3 +105,43 @@ export class ControllerBuilder {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
108
|
+
|
|
109
|
+
interface ArtifactKinds {
|
|
110
|
+
isController: boolean;
|
|
111
|
+
isSocket: boolean;
|
|
112
|
+
isMcp: boolean;
|
|
113
|
+
isScheduler: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sélectionne la classe réellement décorée parmi les exports d'un fichier
|
|
117
|
+
* d'artefact.
|
|
118
|
+
*
|
|
119
|
+
* Les fichiers peuvent exporter leur artefact en `default` **ou** en export
|
|
120
|
+
* nommé (les exemples de la documentation Raiton utilisent `export class
|
|
121
|
+
* MathServer`). L'ancien `imported.default || imported` retombait sur l'objet
|
|
122
|
+
* namespace du module pour un export nommé : `compileMcp` enregistrait alors un
|
|
123
|
+
* serveur fantôme (nom et métadonnées vides) sur le même chemin HTTP.
|
|
124
|
+
*/
|
|
125
|
+
export function resolveArtifact(imported: any, kinds: ArtifactKinds): any {
|
|
126
|
+
if (!imported || typeof imported !== 'object') return imported;
|
|
127
|
+
|
|
128
|
+
const keys: symbol[] = [];
|
|
129
|
+
if (kinds.isController) keys.push(METADATA_KEYS.CONTROLLERS);
|
|
130
|
+
if (kinds.isSocket) keys.push(METADATA_KEYS.SOCKETS);
|
|
131
|
+
if (kinds.isMcp) keys.push(METADATA_KEYS.MCP);
|
|
132
|
+
if (kinds.isScheduler) keys.push(METADATA_KEYS.SCHEDULER);
|
|
133
|
+
|
|
134
|
+
const decorated = Object.values(imported)
|
|
135
|
+
.find((candidate) => isDecoratedArtifact(candidate, keys));
|
|
136
|
+
|
|
137
|
+
return decorated ?? imported.default ?? imported;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isDecoratedArtifact(candidate: any, keys: symbol[]): boolean {
|
|
141
|
+
if (typeof candidate !== 'function') return false;
|
|
142
|
+
const prototype = candidate.prototype;
|
|
143
|
+
return keys.some((key) =>
|
|
144
|
+
(prototype ? Boolean(Reflect.getMetadata(key, prototype)) : false)
|
|
145
|
+
|| Boolean(Reflect.getMetadata(key, candidate)),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import {describe, expect, it} from "bun:test";
|
|
3
|
+
import {resolveArtifact} from "../source/core/controller/builder.ts";
|
|
4
|
+
import {METADATA_KEYS} from "../source/framework/constants/decorators.constant.ts";
|
|
5
|
+
|
|
6
|
+
const ALL = {isController: false, isSocket: false, isMcp: false, isScheduler: false};
|
|
7
|
+
|
|
8
|
+
function serverMetadata(path = "/mcp") {
|
|
9
|
+
return {
|
|
10
|
+
name: "named-server",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
path,
|
|
13
|
+
tools: [],
|
|
14
|
+
prompts: [],
|
|
15
|
+
resources: [],
|
|
16
|
+
resourceTemplates: [],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("résolution des artefacts exportés", () => {
|
|
21
|
+
it("retrouve un serveur MCP exporté en nommé", () => {
|
|
22
|
+
class MathServer {
|
|
23
|
+
add() {
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Reflect.defineMetadata(METADATA_KEYS.MCP, serverMetadata(), MathServer.prototype);
|
|
29
|
+
|
|
30
|
+
const artifact = resolveArtifact({MathServer}, {...ALL, isMcp: true});
|
|
31
|
+
|
|
32
|
+
expect(artifact).toBe(MathServer);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("retrouve un contrôleur exporté en nommé, même avec d’autres exports", () => {
|
|
36
|
+
class ListUsersController {}
|
|
37
|
+
class Unused {}
|
|
38
|
+
|
|
39
|
+
Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS, {prefix: "/users", routes: [], middlewares: {}}, ListUsersController.prototype);
|
|
40
|
+
|
|
41
|
+
const artifact = resolveArtifact(
|
|
42
|
+
{ListUsersController, Unused, helper: () => undefined},
|
|
43
|
+
{...ALL, isController: true},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(artifact).toBe(ListUsersController);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("conserve l’export default quand aucun artefact n’est décoré", () => {
|
|
50
|
+
class Plain {}
|
|
51
|
+
|
|
52
|
+
expect(resolveArtifact({default: Plain, other: 1}, {...ALL, isMcp: true})).toBe(Plain);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("retombe sur le module importé quand aucun export n’est exploitable", () => {
|
|
56
|
+
const imported = {helper: () => undefined};
|
|
57
|
+
|
|
58
|
+
expect(resolveArtifact(imported, {...ALL, isMcp: true})).toBe(imported);
|
|
59
|
+
});
|
|
60
|
+
});
|