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
@@ -5,4 +5,20 @@ export interface ArtifactEntry {
5
5
  }
6
6
  export interface ArtifactsConfigInterface {
7
7
  types: string[];
8
+ /**
9
+ * Bridge file location, relative to the workdir or the rootDir.
10
+ * `false` disables bridge discovery entirely.
11
+ * @default "artifacts.bridge.ts" in the rootDir
12
+ */
13
+ bridge?: string | false;
14
+ /**
15
+ * Discover direct dependencies that declare `package.json#raiton.artifacts`.
16
+ * @default true
17
+ */
18
+ packages?: boolean;
19
+ /**
20
+ * Optional allowlist of self-describing packages. When provided, only these
21
+ * direct dependencies are considered.
22
+ */
23
+ packageAllowlist?: string[];
8
24
  }
@@ -0,0 +1,109 @@
1
+ import type { ConstructorType } from "./contruct.ts";
2
+ import type { HookHandlerCallable, HookNameType } from "./core.ts";
3
+ import type { MiddlewareType } from "./middleware.ts";
4
+ import type { PluginInterface } from "./plugin.ts";
5
+ import type { Route } from "../core/router/route.ts";
6
+ /**
7
+ * Semantic kind of an artifact resolved by the framework.
8
+ *
9
+ * `di` covers services, repositories and any other injectable class. The
10
+ * remaining kinds match the existing compilers and application pipelines.
11
+ */
12
+ export type ArtifactKind = "controller" | "socket" | "mcp" | "scheduler" | "di" | "middleware" | "hook" | "plugin";
13
+ /** Where an artifact came from. */
14
+ export type ArtifactOrigin = "scan" | "bridge" | "package";
15
+ export interface MiddlewareBridgeDescriptor {
16
+ middleware: MiddlewareType | ConstructorType;
17
+ /** Stable name used for replacement and removal. Defaults to the function name. */
18
+ name?: string;
19
+ /**
20
+ * Relative order between bridge middleware. In v1, declarations are
21
+ * mounted in the order they appear in `artifacts`; `order` is reserved for
22
+ * future finer-grained ordering and may be omitted.
23
+ */
24
+ order?: number;
25
+ }
26
+ export interface HookBridgeDescriptor {
27
+ hook: HookNameType;
28
+ handler: HookHandlerCallable;
29
+ name?: string;
30
+ }
31
+ export interface PluginBridgeDescriptor {
32
+ plugin: PluginInterface;
33
+ name?: string;
34
+ }
35
+ /**
36
+ * A bridge entry is intentionally explicit: a decorated class/function, a
37
+ * module or local path, or one of the application descriptor forms.
38
+ */
39
+ export type ArtifactBridgeEntry = ConstructorType | string | MiddlewareBridgeDescriptor | HookBridgeDescriptor | PluginBridgeDescriptor;
40
+ export interface ArtifactBridgeDefinition {
41
+ /** Declarative allowlist of artifacts to mount. */
42
+ artifacts: ArtifactBridgeEntry[];
43
+ /** Additive metadata; ignored by the v1 loader. */
44
+ [key: string]: unknown;
45
+ }
46
+ export interface ResolvedBridgeArtifact {
47
+ name: string;
48
+ kind: ArtifactKind;
49
+ construct?: unknown;
50
+ origin: "bridge" | "package";
51
+ package?: string;
52
+ file?: string;
53
+ middleware?: MiddlewareType;
54
+ middlewareName?: string;
55
+ hook?: HookNameType;
56
+ handler?: HookHandlerCallable;
57
+ plugin?: PluginInterface;
58
+ routes?: Route[];
59
+ }
60
+ export interface UnresolvedBridgeArtifact {
61
+ entry: unknown;
62
+ reason: string;
63
+ code?: string;
64
+ package?: string;
65
+ file?: string;
66
+ }
67
+ export interface ArtifactBridgeDescriptor {
68
+ /** Bridge file as declared by the project (source path when available). */
69
+ readonly file: string;
70
+ /** Runtime file actually imported (compiled file on Node production). */
71
+ readonly runtimeFile?: string;
72
+ readonly loaded: boolean;
73
+ readonly packages: string[];
74
+ readonly artifacts: ResolvedBridgeArtifact[];
75
+ readonly unresolved: UnresolvedBridgeArtifact[];
76
+ readonly localFiles: string[];
77
+ }
78
+ export interface BridgeManifestArtifact {
79
+ name: string;
80
+ kind: ArtifactKind;
81
+ origin: "scan" | "bridge";
82
+ package?: string;
83
+ file?: string;
84
+ }
85
+ export interface BridgeManifestSection {
86
+ file: string | null;
87
+ loaded: boolean;
88
+ packages: string[];
89
+ artifacts: BridgeManifestArtifact[];
90
+ unresolved: Array<{
91
+ entry: string;
92
+ reason: string;
93
+ code?: string;
94
+ package?: string;
95
+ file?: string;
96
+ }>;
97
+ }
98
+ export type BridgeDiagnosticSeverity = "error" | "warning" | "info";
99
+ export interface BridgeDiagnostic {
100
+ code: string;
101
+ severity: BridgeDiagnosticSeverity;
102
+ message: string;
103
+ action: string;
104
+ docsUrl: string;
105
+ location?: string;
106
+ entry?: string;
107
+ module?: string;
108
+ package?: string;
109
+ }
@@ -10,6 +10,7 @@ export type * from "./parseable.ts";
10
10
  export type * from "./values.ts";
11
11
  export type * from "./utilities.ts";
12
12
  export type * from "./artifact.ts";
13
+ export type * from "./bridge.ts";
13
14
  export type * from "./middleware.ts";
14
15
  export type * from "./core.ts";
15
16
  export type * from "./plugin.ts";
package/docs/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AGENTS.md — Raiton conventions
2
2
 
3
- This repository uses **Raiton** (raiton 6.10.0-beta.28).
3
+ This repository uses **Raiton** (raiton 6.11.1-beta.30).
4
4
 
5
5
  ## Deterministic commands
6
6
 
package/docs/CLAUDE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AGENTS.md — Raiton conventions
2
2
 
3
- This repository uses **Raiton** (raiton 6.10.0-beta.28).
3
+ This repository uses **Raiton** (raiton 6.11.1-beta.30).
4
4
 
5
5
  ## Deterministic commands
6
6
 
@@ -48,6 +48,32 @@
48
48
  "type": "string"
49
49
  },
50
50
  "uniqueItems": true
51
+ },
52
+ "bridge": {
53
+ "oneOf": [
54
+ {
55
+ "type": "string",
56
+ "minLength": 1
57
+ },
58
+ {
59
+ "const": false
60
+ }
61
+ ],
62
+ "description": "Bridge file path relative to the workdir or rootDir; false disables discovery."
63
+ },
64
+ "packages": {
65
+ "type": "boolean",
66
+ "default": true,
67
+ "description": "Discover direct dependencies declaring package.json#raiton.artifacts."
68
+ },
69
+ "packageAllowlist": {
70
+ "type": "array",
71
+ "items": {
72
+ "type": "string",
73
+ "minLength": 1
74
+ },
75
+ "uniqueItems": true,
76
+ "description": "Restrict package discovery to these direct dependencies."
51
77
  }
52
78
  }
53
79
  },
@@ -92,6 +92,21 @@
92
92
  "line": {
93
93
  "type": "number"
94
94
  },
95
+ "origin": {
96
+ "anyOf": [
97
+ {
98
+ "const": "scan",
99
+ "type": "string"
100
+ },
101
+ {
102
+ "const": "bridge",
103
+ "type": "string"
104
+ }
105
+ ]
106
+ },
107
+ "package": {
108
+ "type": "string"
109
+ },
95
110
  "input": {
96
111
  "type": "string"
97
112
  },
@@ -307,6 +322,101 @@
307
322
  }
308
323
  }
309
324
  }
325
+ },
326
+ "bridge": {
327
+ "type": "object",
328
+ "required": [
329
+ "file",
330
+ "loaded",
331
+ "packages",
332
+ "artifacts",
333
+ "unresolved"
334
+ ],
335
+ "properties": {
336
+ "file": {
337
+ "anyOf": [
338
+ {
339
+ "type": "string"
340
+ },
341
+ {
342
+ "type": "null"
343
+ }
344
+ ]
345
+ },
346
+ "loaded": {
347
+ "type": "boolean"
348
+ },
349
+ "packages": {
350
+ "type": "array",
351
+ "items": {
352
+ "type": "string"
353
+ }
354
+ },
355
+ "artifacts": {
356
+ "type": "array",
357
+ "items": {
358
+ "type": "object",
359
+ "required": [
360
+ "name",
361
+ "kind",
362
+ "origin"
363
+ ],
364
+ "properties": {
365
+ "name": {
366
+ "type": "string"
367
+ },
368
+ "kind": {
369
+ "type": "string"
370
+ },
371
+ "origin": {
372
+ "anyOf": [
373
+ {
374
+ "const": "scan",
375
+ "type": "string"
376
+ },
377
+ {
378
+ "const": "bridge",
379
+ "type": "string"
380
+ }
381
+ ]
382
+ },
383
+ "package": {
384
+ "type": "string"
385
+ },
386
+ "file": {
387
+ "type": "string"
388
+ }
389
+ }
390
+ }
391
+ },
392
+ "unresolved": {
393
+ "type": "array",
394
+ "items": {
395
+ "type": "object",
396
+ "required": [
397
+ "entry",
398
+ "reason"
399
+ ],
400
+ "properties": {
401
+ "entry": {
402
+ "type": "string"
403
+ },
404
+ "reason": {
405
+ "type": "string"
406
+ },
407
+ "code": {
408
+ "type": "string"
409
+ },
410
+ "package": {
411
+ "type": "string"
412
+ },
413
+ "file": {
414
+ "type": "string"
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
310
420
  }
311
421
  }
312
422
  }
@@ -3,7 +3,7 @@
3
3
  "generatedAt": "generated",
4
4
  "framework": {
5
5
  "name": "raiton",
6
- "version": "6.10.0-beta.28"
6
+ "version": "6.11.1-beta.30"
7
7
  },
8
8
  "runtime": "unknown",
9
9
  "project": {
@@ -40,7 +40,7 @@
40
40
 
41
41
  ## Project inventory
42
42
 
43
- - Framework: raiton 6.10.0-beta.28
43
+ - Framework: raiton 6.11.1-beta.30
44
44
  - Runtime: unknown
45
45
  - Manifest schema: 1.0.0
46
46
  - Routes: 0
@@ -668,6 +668,180 @@ Cette convention aide à identifier rapidement le domaine et le rôle du service
668
668
  [← api](api/README.md) | [plugins →](plugins.md)
669
669
 
670
670
 
671
+ <!-- user-guide/artifact-bridge.md -->
672
+
673
+ # Artifact Bridge
674
+
675
+ Le bridge d'artefacts permet de monter du code que le scan par suffixe ne peut
676
+ pas découvrir : artefacts fournis par des packages npm, fichiers locaux hors
677
+ convention, middleware et hooks applicatifs.
678
+
679
+ > Le bridge est **optionnel**. Sans `artifacts.bridge.ts`, le comportement de
680
+ > l'application est strictement identique au scan par suffixe.
681
+
682
+ ## Fichier
683
+
684
+ Par défaut, Raiton découvre `artifacts.bridge.ts` dans le `rootDir` du projet
685
+ (`source/` par défaut).
686
+
687
+ ```ts
688
+ // source/artifacts.bridge.ts
689
+ import {defineArtifactBridge} from "raiton/core";
690
+
691
+ import {UsersController} from "@acme/users";
692
+ import {AuthMiddleware} from "@acme/auth";
693
+ import {auditHook} from "./hooks/audit.ts";
694
+ import {LegacyController} from "./legacy/handlers.ts";
695
+
696
+ export default defineArtifactBridge({
697
+ artifacts: [
698
+ // Classes déjà importées (forme recommandée)
699
+ UsersController,
700
+
701
+ // Modules : tous les exports décorés sont inspectés
702
+ "@acme/analytics",
703
+ "@acme/legacy/dist/index.js",
704
+
705
+ // Fichier local hors convention
706
+ "./legacy/handlers.ts",
707
+
708
+ // Middleware applicatif
709
+ {middleware: AuthMiddleware, name: "acme-auth"},
710
+
711
+ // Hook applicatif
712
+ {hook: "onRequest", handler: auditHook, name: "acme-audit"},
713
+ ],
714
+ });
715
+ ```
716
+
717
+ Le bridge ne remplace pas `main.ts` : le bootstrap, la configuration et les
718
+ plugins restent dans `main.ts`.
719
+
720
+ ## Configuration
721
+
722
+ ```ts
723
+ // raiton.config.ts
724
+ export default {
725
+ rootDir: "./source",
726
+ artifacts: {
727
+ // Chemin explicite, relatif au workdir ou au rootDir.
728
+ // `false` désactive complètement le bridge.
729
+ bridge: "./artifacts.bridge.ts",
730
+ // Découverte des dépendances directes auto-descriptives (défaut : true).
731
+ packages: true,
732
+ // Restriction optionnelle à certains packages.
733
+ packageAllowlist: ["@acme/users"],
734
+ },
735
+ };
736
+ ```
737
+
738
+ ## Types d'entrées
739
+
740
+ | Entrée | Résultat |
741
+ |---|---|
742
+ | `UsersController` | Classification par métadonnées de décorateurs |
743
+ | `"@acme/users"` | Import du module, inspection de tous les exports nommés et `default` |
744
+ | `"./legacy/handlers.ts"` | Fichier local hors convention |
745
+ | `{middleware, name?, order?}` | Middleware global, après les middleware intégrés |
746
+ | `{hook, handler, name?}` | Hook global (`onRequest`, `preParsing`, `preHandler`, `onSend`, `onResponse`) |
747
+ | `{plugin}` | Délégation à `application.register(plugin)` |
748
+
749
+ Une fonction sans métadonnée et sans descripteur est ambiguë : elle est rejetée
750
+ avec `BRIDGE_ARTIFACT_AMBIGUOUS`.
751
+
752
+ ## Packages auto-descriptifs
753
+
754
+ Une dépendance **directe** peut déclarer ses artefacts :
755
+
756
+ ```json
757
+ {
758
+ "name": "@acme/users",
759
+ "peerDependencies": {"raiton": "^6"},
760
+ "raiton": {
761
+ "artifacts": [
762
+ "./dist/users.controller.js",
763
+ "./dist/users.service.js"
764
+ ]
765
+ }
766
+ }
767
+ ```
768
+
769
+ Ou exposer un module bridge :
770
+
771
+ ```json
772
+ {
773
+ "raiton": {
774
+ "artifacts": "./dist/artifacts.bridge.js"
775
+ }
776
+ }
777
+ ```
778
+
779
+ Contrat de package :
780
+
781
+ - déclarer `raiton` en `peerDependency`, jamais l'embarquer ;
782
+ - ne pas livrer une copie imbriquée de Raiton ;
783
+ - livrer du JavaScript exécutable par le runtime cible ;
784
+ - importer `reflect-metadata` une seule fois au niveau de l'application.
785
+
786
+ Les dépendances transitives ne sont pas découvertes. Il n'y a aucun scan
787
+ récursif de `node_modules`.
788
+
789
+ ## CLI
790
+
791
+ ```bash
792
+ raiton artifact --dump --json # origine scan/bridge, type, package, fichier
793
+ raiton inspect --json # section `bridge` du manifeste
794
+ raiton why GET /users # origine de la route
795
+ raiton doctor # diagnostics du bridge
796
+ ```
797
+
798
+ `build`, `dev` et `start` chargent le bridge automatiquement. Sur Node.js, le
799
+ bridge est compilé dans `.raiton/server/artifacts.bridge.mjs` ; `raiton build`
800
+ doit être exécuté avant `raiton start`.
801
+
802
+ ## Rechargement à chaud
803
+
804
+ - Bun et Deno : le fichier bridge est surveillé ; ajouts, retraits et
805
+ modifications sont réconciliés sans redémarrage complet.
806
+ - Node.js : le redémarrage contrôlé existant est utilisé.
807
+ - Les modules de packages externes ne sont pas surveillés : redémarrez après
808
+ leur mise à jour.
809
+
810
+ Le rechargement ne retire que les artefacts possédés par le bridge. Les routes,
811
+ instances, middleware et hooks découverts par le scan local restent intacts.
812
+
813
+ ## Diagnostics
814
+
815
+ Tous les codes sont stables et pointent vers ce guide :
816
+
817
+ | Code | Cause |
818
+ |---|---|
819
+ | `BRIDGE_FILE_NOT_FOUND` | Chemin configuré introuvable |
820
+ | `BRIDGE_FILE_INVALID_EXPORT` | Export par défaut absent ou invalide |
821
+ | `BRIDGE_IMPORT_FAILED` | Exception à l'import |
822
+ | `BRIDGE_MODULE_NOT_FOUND` | Spécificateur non résolvable |
823
+ | `BRIDGE_ENTRY_INVALID` | Entrée non supportée |
824
+ | `BRIDGE_ARTIFACT_NOT_FOUND` | Module sans artefact décoré |
825
+ | `BRIDGE_ARTIFACT_AMBIGUOUS` | Fonction sans métadonnée ni descripteur |
826
+ | `BRIDGE_NAME_COLLISION` | Deux classes partagent le même nom DI |
827
+ | `BRIDGE_ABI_MISMATCH` | Copie de Raiton incompatible dans un package |
828
+ | `BRIDGE_RUNTIME_UNSUPPORTED` | Entrée TypeScript sur un runtime qui ne la lit pas |
829
+ | `BRIDGE_NOT_BUNDLED` | Bridge non compilé pour Node.js |
830
+ | `BRIDGE_PACKAGE_FIELD_INVALID` | `package.json#raiton.artifacts` invalide |
831
+ | `BRIDGE_HOOK_UNKNOWN` | Hook non supporté |
832
+
833
+ Les codes `BRIDGE_ARTIFACT_DUPLICATE` et `BRIDGE_DUPLICATE_MOUNT` sont
834
+ informatifs : le premier artefact rencontré est conservé.
835
+
836
+ ## Performance
837
+
838
+ Le bridge absent ne coûte que quelques vérifications d'existence. Les entrées
839
+ constituent une allowlist explicite ; aucun glob non borné ni scan récursif de
840
+ `node_modules` n'est exécuté. Le chargement d'un bridge de 50 entrées doit rester
841
+ sous le budget de démarrage documenté par la spec 001, hors import des modules
842
+ externes.
843
+
844
+
671
845
  <!-- user-guide/contracts.md -->
672
846
 
673
847
  # Contrats schema-first
@@ -1334,7 +1508,7 @@ Ce découpage garde l’application lisible quand le nombre de routes augmente.
1334
1508
  "generatedAt": "generated",
1335
1509
  "framework": {
1336
1510
  "name": "raiton",
1337
- "version": "6.10.0-beta.28"
1511
+ "version": "6.11.1-beta.30"
1338
1512
  },
1339
1513
  "runtime": "unknown",
1340
1514
  "project": {
package/docs/llms.txt CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  ## Project inventory
42
42
 
43
- - Framework: raiton 6.10.0-beta.28
43
+ - Framework: raiton 6.11.1-beta.30
44
44
  - Runtime: unknown
45
45
  - Manifest schema: 1.0.0
46
46
  - Routes: 0
@@ -15,6 +15,7 @@ Ce dossier décrit comment utiliser Raiton pour créer un serveur d'API.
15
15
  | [env.md](env.md) | Lire les variables d'environnement |
16
16
  | [encryption.md](encryption.md) | Hasher et vérifier des secrets |
17
17
  | [injection.md](injection.md) | Injecter des services et séparer la logique métier |
18
+ | [artifact-bridge.md](artifact-bridge.md) | Monter des artefacts de packages, fichiers hors convention, middleware et hooks |
18
19
  | [middleware.md](middleware.md) | Exécuter des règles transverses sur les requêtes |
19
20
  | [responses.md](responses.md) | Structurer les réponses et les erreurs |
20
21
  | [contracts.md](contracts.md) | Contrats schema-first : validation, types, OpenAPI et client |