raiton 6.11.0-beta.29 → 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.
- package/CHANGELOG.md +22 -0
- package/benchmarks/README.md +3 -3
- package/build/bin/index.mjs +2329 -361
- package/build/types/core/artifact-mount.d.ts +19 -0
- package/build/types/core/bridge/classifier.d.ts +30 -0
- package/build/types/core/bridge/definition.d.ts +10 -0
- package/build/types/core/bridge/diagnostics.d.ts +43 -0
- package/build/types/core/bridge/index.d.ts +8 -0
- package/build/types/core/bridge/loader.d.ts +75 -0
- package/build/types/core/bridge/packages.d.ts +27 -0
- package/build/types/core/bridge/paths.d.ts +37 -0
- package/build/types/core/bridge/registry.d.ts +50 -0
- package/build/types/core/bridge/resolver.d.ts +32 -0
- package/build/types/core/builder.d.ts +8 -1
- package/build/types/core/controller/builder.d.ts +9 -0
- package/build/types/core/controller/compiler.d.ts +8 -1
- package/build/types/core/controller/tracker.d.ts +10 -3
- package/build/types/core/hooks.d.ts +2 -0
- package/build/types/core/index.d.ts +1 -0
- package/build/types/core/injection/injection.d.ts +24 -0
- package/build/types/core/middleware/pipeline.d.ts +12 -1
- package/build/types/core/scheduler/manager.d.ts +5 -0
- package/build/types/framework/artifacts.d.ts +5 -0
- package/build/types/framework/constants/decorators.constant.d.ts +8 -0
- package/build/types/manifest/schema.d.ts +77 -0
- package/build/types/types/artifact.d.ts +16 -0
- package/build/types/types/bridge.d.ts +109 -0
- package/build/types/types/index.d.ts +1 -0
- package/docs/AGENTS.md +1 -1
- package/docs/CLAUDE.md +1 -1
- package/docs/generated/config-schema.json +26 -0
- package/docs/generated/manifest-schema.json +110 -0
- package/docs/generated/manifest.json +1 -1
- package/docs/llms-full.txt +176 -2
- package/docs/llms.txt +1 -1
- package/docs/user-guide/README.md +1 -0
- package/docs/user-guide/artifact-bridge.md +170 -0
- package/package.json +1 -1
- package/source/bin/project-utils.ts +9 -0
- package/source/commands/artifact.command.ts +24 -9
- package/source/commands/build.command.ts +3 -1
- package/source/commands/docs.command.ts +1 -0
- package/source/commands/doctor.command.ts +53 -1
- package/source/commands/inspect.command.ts +3 -0
- package/source/commands/start.command.ts +3 -1
- package/source/commands/why.command.ts +4 -0
- package/source/core/artifact-mount.ts +126 -0
- package/source/core/bridge/classifier.ts +112 -0
- package/source/core/bridge/definition.ts +35 -0
- package/source/core/bridge/diagnostics.ts +175 -0
- package/source/core/bridge/index.ts +8 -0
- package/source/core/bridge/loader.ts +914 -0
- package/source/core/bridge/packages.ts +196 -0
- package/source/core/bridge/paths.ts +152 -0
- package/source/core/bridge/registry.ts +177 -0
- package/source/core/bridge/resolver.ts +183 -0
- package/source/core/builder.ts +146 -7
- package/source/core/config/schema.ts +54 -9
- package/source/core/controller/builder.ts +49 -31
- package/source/core/controller/compiler.ts +13 -4
- package/source/core/controller/tracker.ts +29 -7
- package/source/core/hooks.ts +5 -0
- package/source/core/index.ts +2 -1
- package/source/core/injection/injection.ts +67 -0
- package/source/core/middleware/pipeline.ts +33 -2
- package/source/core/scheduler/manager.ts +15 -0
- package/source/core/thread.ts +21 -0
- package/source/framework/artifacts.ts +10 -0
- package/source/framework/constants/decorators.constant.ts +35 -27
- package/source/manifest/manifest.ts +46 -0
- package/source/manifest/schema.ts +48 -0
- package/source/types/artifact.ts +16 -0
- package/source/types/bridge.ts +136 -0
- package/source/types/index.ts +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApplicationInterface } from "../types/application.ts";
|
|
2
|
+
import type { ArtifactKind, ArtifactOrigin } from "../types/bridge.ts";
|
|
3
|
+
import type { ConstructorType } from "../types/contruct.ts";
|
|
4
|
+
import type { ArtifactClassification } from "../framework/artifacts.ts";
|
|
5
|
+
import { type MountedArtifactRecord } from "./bridge/registry.ts";
|
|
6
|
+
export declare function kindForClassification(classification: ArtifactClassification): ArtifactKind;
|
|
7
|
+
export declare function isMountableClassification(classification: ArtifactClassification | null | undefined): boolean;
|
|
8
|
+
export interface MountArtifactOptions {
|
|
9
|
+
origin: ArtifactOrigin;
|
|
10
|
+
file?: string;
|
|
11
|
+
package?: string;
|
|
12
|
+
/** Reject a DI name collision instead of silently keeping the existing class. */
|
|
13
|
+
strictInjectables?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reuse the existing compilers to mount an already imported artifact. This is
|
|
17
|
+
* the single path shared by the suffix scan and the artifact bridge.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mountArtifact(construct: ConstructorType, kind: ArtifactKind, application: ApplicationInterface, options: MountArtifactOptions): Promise<MountedArtifactRecord>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ArtifactKind, ArtifactBridgeDefinition } from "../../types/bridge.ts";
|
|
2
|
+
import type { ConstructorType } from "../../types/contruct.ts";
|
|
3
|
+
export type ClassifiedConstruct = {
|
|
4
|
+
construct: ConstructorType;
|
|
5
|
+
name: string;
|
|
6
|
+
kind: ArtifactKind;
|
|
7
|
+
};
|
|
8
|
+
export declare function isClass(value: unknown): value is ConstructorType;
|
|
9
|
+
/**
|
|
10
|
+
* Classify a class from decorator metadata only. Suffix classification remains
|
|
11
|
+
* authoritative for scanned files; this function is used by the bridge and by
|
|
12
|
+
* multi-artifact module resolution.
|
|
13
|
+
*/
|
|
14
|
+
export declare function classifyConstruct(construct: unknown): ClassifiedConstruct | null;
|
|
15
|
+
export declare function isBridgeDefinition(value: unknown): value is ArtifactBridgeDefinition;
|
|
16
|
+
export declare function moduleExports(imported: any): any[];
|
|
17
|
+
export interface ResolveArtifactsOptions {
|
|
18
|
+
kinds?: ArtifactKind[];
|
|
19
|
+
}
|
|
20
|
+
export interface ResolvedModuleArtifact {
|
|
21
|
+
name: string;
|
|
22
|
+
kind: ArtifactKind;
|
|
23
|
+
construct: ConstructorType;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Plural counterpart of `resolveArtifact()`: inspect every named export and
|
|
27
|
+
* the default export, keep all decorated classes and deduplicate by identity.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveArtifacts(imported: any, options?: ResolveArtifactsOptions): ResolvedModuleArtifact[];
|
|
30
|
+
export declare function exportNames(imported: any): string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArtifactBridgeDefinition, ArtifactBridgeEntry } from "../../types/bridge.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Public helper used by `artifacts.bridge.ts` files.
|
|
4
|
+
*
|
|
5
|
+
* The preferred form is `{ artifacts: [...] }`; a bare array is accepted for
|
|
6
|
+
* convenience. Validation happens here so the runtime receives a normalized
|
|
7
|
+
* manifest.
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineArtifactBridge(definition: ArtifactBridgeDefinition | ArtifactBridgeEntry[]): ArtifactBridgeDefinition;
|
|
10
|
+
export declare function isArtifactBridgeDefinition(value: unknown): value is ArtifactBridgeDefinition;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BridgeDiagnostic, BridgeDiagnosticSeverity } from "../../types/bridge.ts";
|
|
2
|
+
export declare const BRIDGE_DOCS_PATH = "user-guide/artifact-bridge.md";
|
|
3
|
+
export interface BridgeDiagnosticDefinition {
|
|
4
|
+
severity: BridgeDiagnosticSeverity;
|
|
5
|
+
message: string;
|
|
6
|
+
action: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Stable bridge diagnostic codes. Codes are additive and never renamed so CLI
|
|
10
|
+
* output, tests and documentation links stay valid across releases.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BRIDGE_DIAGNOSTICS: Record<string, BridgeDiagnosticDefinition>;
|
|
13
|
+
export declare const SUPPORTED_HOOK_NAMES: readonly ["onRequest", "preParsing", "preHandler", "onSend", "onResponse"];
|
|
14
|
+
export interface BridgeDiagnosticOptions {
|
|
15
|
+
message?: string;
|
|
16
|
+
action?: string;
|
|
17
|
+
location?: string;
|
|
18
|
+
entry?: string;
|
|
19
|
+
module?: string;
|
|
20
|
+
package?: string;
|
|
21
|
+
severity?: BridgeDiagnosticSeverity;
|
|
22
|
+
}
|
|
23
|
+
export declare function bridgeDiagnostic(code: string, options?: BridgeDiagnosticOptions): BridgeDiagnostic;
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown by the bridge loader and the builders. The `code` is stable and
|
|
26
|
+
* is reused by `raiton doctor` and the CLI error envelope.
|
|
27
|
+
*/
|
|
28
|
+
export declare class BridgeError extends Error {
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly diagnostic: BridgeDiagnostic;
|
|
31
|
+
readonly entry?: string;
|
|
32
|
+
readonly module?: string;
|
|
33
|
+
constructor(code: string, options?: BridgeDiagnosticOptions);
|
|
34
|
+
toJSON(): {
|
|
35
|
+
code: string;
|
|
36
|
+
message: string;
|
|
37
|
+
action: string;
|
|
38
|
+
docsUrl: string;
|
|
39
|
+
location?: string | undefined;
|
|
40
|
+
entry?: string | undefined;
|
|
41
|
+
module?: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ApplicationInterface } from "../../types/application.ts";
|
|
2
|
+
import type { ArtifactBridgeDefinition, ArtifactBridgeDescriptor, ArtifactBridgeEntry, BridgeDiagnostic, HookBridgeDescriptor, MiddlewareBridgeDescriptor, PluginBridgeDescriptor, ResolvedBridgeArtifact } from "../../types/bridge.ts";
|
|
3
|
+
import { type MountedArtifactRecord } from "./registry.ts";
|
|
4
|
+
import { MiddlewarePipeline } from "../middleware/pipeline.ts";
|
|
5
|
+
export interface BridgeLoadOptions {
|
|
6
|
+
workdir?: string;
|
|
7
|
+
development?: boolean;
|
|
8
|
+
/** Force a cache-busting import of local bridge modules. */
|
|
9
|
+
cacheBust?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface BridgeState {
|
|
12
|
+
descriptor: ArtifactBridgeDescriptor | null;
|
|
13
|
+
sourceFile: string | null;
|
|
14
|
+
runtimeFile: string | null;
|
|
15
|
+
loaded: boolean;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
missing: boolean;
|
|
18
|
+
packages: string[];
|
|
19
|
+
artifacts: ResolvedBridgeArtifact[];
|
|
20
|
+
unresolved: ArtifactBridgeDescriptor["unresolved"];
|
|
21
|
+
diagnostics: BridgeDiagnostic[];
|
|
22
|
+
localFiles: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface EntryContext {
|
|
25
|
+
origin: "bridge" | "package";
|
|
26
|
+
package?: string;
|
|
27
|
+
directories: Array<string | undefined>;
|
|
28
|
+
cacheBust: boolean;
|
|
29
|
+
location?: string;
|
|
30
|
+
packageRoot?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class BridgeLoader {
|
|
33
|
+
protected static _state: BridgeState;
|
|
34
|
+
static get state(): BridgeState;
|
|
35
|
+
static get current(): ArtifactBridgeDescriptor | null;
|
|
36
|
+
static reset(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve, import and validate the bridge. This never mounts artifacts and
|
|
39
|
+
* never throws for a missing default bridge file.
|
|
40
|
+
*/
|
|
41
|
+
static load(options?: BridgeLoadOptions): Promise<BridgeState>;
|
|
42
|
+
/**
|
|
43
|
+
* Mount every resolved artifact through the existing pipelines. Idempotent
|
|
44
|
+
* against the scan and against repeated calls.
|
|
45
|
+
*/
|
|
46
|
+
static mount(application: ApplicationInterface): Promise<BridgeLoader>;
|
|
47
|
+
/**
|
|
48
|
+
* Development hot reload: load the new manifest, diff by stable key and
|
|
49
|
+
* reconcile bridge-owned routes/middleware/hooks only.
|
|
50
|
+
*/
|
|
51
|
+
static reload(options?: BridgeLoadOptions): Promise<BridgeState>;
|
|
52
|
+
/**
|
|
53
|
+
* Non-throwing checks used by `raiton doctor`.
|
|
54
|
+
*/
|
|
55
|
+
static diagnose(workdir?: string): BridgeDiagnostic[];
|
|
56
|
+
protected static definitionFrom(imported: any, runtimeFile: string): ArtifactBridgeDefinition;
|
|
57
|
+
protected static resolveEntries(entries: ArtifactBridgeEntry[], context: EntryContext, state: {
|
|
58
|
+
diagnostics: BridgeDiagnostic[];
|
|
59
|
+
unresolved: ArtifactBridgeDescriptor["unresolved"];
|
|
60
|
+
}, depth?: number): Promise<ResolvedBridgeArtifact[]>;
|
|
61
|
+
protected static resolveModuleEntry(specifier: string, context: EntryContext, state: {
|
|
62
|
+
diagnostics: BridgeDiagnostic[];
|
|
63
|
+
unresolved: ArtifactBridgeDescriptor["unresolved"];
|
|
64
|
+
}, depth: number): Promise<ResolvedBridgeArtifact[]>;
|
|
65
|
+
protected static resolveDescriptor(entry: MiddlewareBridgeDescriptor | HookBridgeDescriptor | PluginBridgeDescriptor | Record<string, any>, context: EntryContext): ResolvedBridgeArtifact;
|
|
66
|
+
protected static adoptAll(artifacts: ResolvedBridgeArtifact[]): void;
|
|
67
|
+
protected static mountArtifact(artifact: ResolvedBridgeArtifact, application: ApplicationInterface, strict: boolean): Promise<void>;
|
|
68
|
+
protected static unmountArtifact(record: MountedArtifactRecord | undefined, application: ApplicationInterface): void;
|
|
69
|
+
protected static mountedRecord(artifact: ResolvedBridgeArtifact): MountedArtifactRecord | undefined;
|
|
70
|
+
protected static stableKey(artifact: ResolvedBridgeArtifact): string;
|
|
71
|
+
protected static identityOf(artifact: ResolvedBridgeArtifact): unknown;
|
|
72
|
+
protected static fileForConstruct(construct: unknown): string | undefined;
|
|
73
|
+
protected static middlewareInstance(artifact: ResolvedBridgeArtifact): any;
|
|
74
|
+
protected static hasMiddleware(pipeline: MiddlewarePipeline, name: string, instance: any): boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ArtifactBridgeEntry } from "../../types/bridge.ts";
|
|
2
|
+
import type { BridgeDiagnostic } from "../../types/bridge.ts";
|
|
3
|
+
export interface PackageBridgeEntry {
|
|
4
|
+
entry: ArtifactBridgeEntry;
|
|
5
|
+
package: string;
|
|
6
|
+
packageRoot: string;
|
|
7
|
+
location: string;
|
|
8
|
+
origin: "package";
|
|
9
|
+
}
|
|
10
|
+
export interface PackageDiscoveryResult {
|
|
11
|
+
packages: string[];
|
|
12
|
+
entries: PackageBridgeEntry[];
|
|
13
|
+
diagnostics: BridgeDiagnostic[];
|
|
14
|
+
}
|
|
15
|
+
export interface DiscoverPackagesOptions {
|
|
16
|
+
/** Only inspect these packages (already filtered). */
|
|
17
|
+
allowlist?: string[];
|
|
18
|
+
/** Set to false to disable package discovery entirely. */
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
/** Emit info diagnostics for discovered packages. */
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Inspect direct dependencies only. There is deliberately no recursive
|
|
25
|
+
* `node_modules` walk: each package is resolved by name from the project root.
|
|
26
|
+
*/
|
|
27
|
+
export declare function discoverPackageArtifacts(workdir: string, options?: DiscoverPackagesOptions): PackageDiscoveryResult;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const BRIDGE_FILENAME = "artifacts.bridge";
|
|
2
|
+
export declare const COMPILED_BRIDGE_FILENAME = "artifacts.bridge.mjs";
|
|
3
|
+
export interface BridgeSourceResolution {
|
|
4
|
+
/** Bridge source file, or null when absent. */
|
|
5
|
+
file: string | null;
|
|
6
|
+
/** Programmatic project root. */
|
|
7
|
+
workdir: string;
|
|
8
|
+
/** Configured root directory, absolute. */
|
|
9
|
+
rootDir: string;
|
|
10
|
+
/** True when `artifacts.bridge` explicitly configured the path. */
|
|
11
|
+
explicit: boolean;
|
|
12
|
+
/** True when `artifacts.bridge === false`. */
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
/** Path that was expected (configured or default). */
|
|
15
|
+
expected: string | null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the bridge source from configuration. This is intentionally cheap:
|
|
19
|
+
* only a bounded list of extension candidates is probed, never a directory
|
|
20
|
+
* walk.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveBridgeSource(workdir?: string): BridgeSourceResolution;
|
|
23
|
+
export declare function compiledBridgeFile(workdir?: string): string;
|
|
24
|
+
export interface RuntimeBridgeResolution extends BridgeSourceResolution {
|
|
25
|
+
/** File actually imported at runtime. */
|
|
26
|
+
runtimeFile: string | null;
|
|
27
|
+
/** True when the runtime expects a compiled bridge. */
|
|
28
|
+
requiresCompiled: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Select the bridge file for the current runtime. Bun and Deno import the
|
|
32
|
+
* source directly; Node uses the compiled `.raiton/server/artifacts.bridge.mjs`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveRuntimeBridge(workdir?: string): RuntimeBridgeResolution;
|
|
35
|
+
export declare function isSameFile(left: string | null | undefined, right: string | null | undefined): boolean;
|
|
36
|
+
export declare function isWithin(parent: string, file: string): boolean;
|
|
37
|
+
export declare function relativeTo(workdir: string, file?: string | null): string | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ArtifactKind, ArtifactOrigin, BridgeManifestArtifact } from "../../types/bridge.ts";
|
|
2
|
+
import type { Route } from "../router/route.ts";
|
|
3
|
+
import type { HookHandlerCallable, HookNameType } from "../../types/core.ts";
|
|
4
|
+
export interface MountedArtifactRecord {
|
|
5
|
+
/** Stable logical key used by the bridge diff. */
|
|
6
|
+
key: string;
|
|
7
|
+
name: string;
|
|
8
|
+
kind: ArtifactKind;
|
|
9
|
+
origin: ArtifactOrigin;
|
|
10
|
+
construct?: unknown;
|
|
11
|
+
package?: string;
|
|
12
|
+
file?: string;
|
|
13
|
+
routes?: Route[];
|
|
14
|
+
middlewareName?: string;
|
|
15
|
+
hookName?: HookNameType;
|
|
16
|
+
handler?: HookHandlerCallable;
|
|
17
|
+
pluginName?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function artifactKey(record: Pick<MountedArtifactRecord, "kind" | "name" | "file" | "package">): string;
|
|
20
|
+
/**
|
|
21
|
+
* Central identity registry. It never mounts anything: it records what has
|
|
22
|
+
* already been mounted so the scan and the bridge cannot duplicate routes,
|
|
23
|
+
* middleware, hooks or instances.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ArtifactRegistry {
|
|
26
|
+
protected static readonly byConstruct: WeakMap<object, MountedArtifactRecord>;
|
|
27
|
+
protected static readonly byKey: Map<string, MountedArtifactRecord>;
|
|
28
|
+
protected static readonly excludedFiles: Set<string>;
|
|
29
|
+
static clear(): void;
|
|
30
|
+
/** Remove only bridge-owned records, leaving scan records intact. */
|
|
31
|
+
static clearBridge(): void;
|
|
32
|
+
static add(record: MountedArtifactRecord): MountedArtifactRecord;
|
|
33
|
+
static getByKey(key: string): MountedArtifactRecord | undefined;
|
|
34
|
+
static getByConstruct(construct: unknown): MountedArtifactRecord | undefined;
|
|
35
|
+
static hasConstruct(construct: unknown): boolean;
|
|
36
|
+
static remove(key: string): MountedArtifactRecord | undefined;
|
|
37
|
+
static records(): MountedArtifactRecord[];
|
|
38
|
+
static recordsByOrigin(origin: ArtifactOrigin): MountedArtifactRecord[];
|
|
39
|
+
static routeInfo(route: Route): MountedArtifactRecord | undefined;
|
|
40
|
+
static excludeFile(filename: string): void;
|
|
41
|
+
static isExcludedFile(filename: string): boolean;
|
|
42
|
+
static setExcludedFiles(files: Iterable<string>): void;
|
|
43
|
+
static excluded(): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Inventory used by `raiton artifact`. Compiled scan artifacts and bridge
|
|
46
|
+
* artifacts come from the registry; DI definitions that were never mounted
|
|
47
|
+
* as routes are added as `di` entries.
|
|
48
|
+
*/
|
|
49
|
+
static describeArtifacts(workdir: string): BridgeManifestArtifact[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const LOCAL_PATH_PATTERN: RegExp;
|
|
2
|
+
export declare const REMOTE_URL_PATTERN: RegExp;
|
|
3
|
+
export declare function isLocalPathSpecifier(specifier: string): boolean;
|
|
4
|
+
export declare function isRemoteSpecifier(specifier: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Best-effort package name for an import specifier. Used for diagnostics and
|
|
7
|
+
* manifest package attribution only.
|
|
8
|
+
*/
|
|
9
|
+
export declare function packageNameFromSpecifier(specifier: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a local path relative to the bridge/package directory first, then
|
|
12
|
+
* the project root. This also keeps compiled Node bridges usable when local
|
|
13
|
+
* entries are expressed relative to the source root.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveLocalModule(specifier: string, directories: Array<string | undefined>): string | null;
|
|
16
|
+
export interface ResolvedBridgeModule {
|
|
17
|
+
/** Absolute file path, or a builtin/runtime specifier. */
|
|
18
|
+
file: string;
|
|
19
|
+
/** Package name when the specifier is a bare package import. */
|
|
20
|
+
package?: string;
|
|
21
|
+
/** True when the module lives in `node_modules`. */
|
|
22
|
+
external: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function resolveBridgeModule(specifier: string, options: {
|
|
25
|
+
directories: Array<string | undefined>;
|
|
26
|
+
workdir: string;
|
|
27
|
+
}): ResolvedBridgeModule;
|
|
28
|
+
export declare function importBridgeModule(resolved: ResolvedBridgeModule, options?: {
|
|
29
|
+
cacheBust?: boolean;
|
|
30
|
+
}): Promise<any>;
|
|
31
|
+
export declare function resolvePackageJson(packageName: string, workdir: string): string | null;
|
|
32
|
+
export declare function readJsonFile<T = any>(filename: string): T;
|
|
@@ -10,13 +10,14 @@ export declare class RaitonBuilder implements BuilderInterface {
|
|
|
10
10
|
protected _bootstrapperFile: string | null;
|
|
11
11
|
protected _compiledVersionNumber: number;
|
|
12
12
|
protected _watcher?: fs.FSWatcher;
|
|
13
|
+
protected _bridgeWatcher?: fs.FSWatcher;
|
|
13
14
|
constructor(workdir: string, options?: BuilderConfigInterface);
|
|
14
15
|
get source(): string | null;
|
|
15
16
|
get out(): string | null;
|
|
16
17
|
get bootstrapper(): string | null;
|
|
17
18
|
get bootstrapperFile(): string | null;
|
|
18
19
|
get watcher(): fs.FSWatcher | undefined;
|
|
19
|
-
protected parse(filename: string, type?: WatchEventType): Promise<{
|
|
20
|
+
protected parse(filename: string, type?: WatchEventType): Promise<import("./bridge/loader.ts").BridgeState | {
|
|
20
21
|
filename: string;
|
|
21
22
|
timestamp: number;
|
|
22
23
|
version: number;
|
|
@@ -36,6 +37,12 @@ export declare class RaitonBuilder implements BuilderInterface {
|
|
|
36
37
|
protected listenHmrMcp(): void;
|
|
37
38
|
protected listenHmrScheduler(): void;
|
|
38
39
|
protected build(thread: ThreadInterface): Promise<this>;
|
|
40
|
+
/**
|
|
41
|
+
* Node production cannot dynamically import TypeScript files. Validate the
|
|
42
|
+
* compiled manifest after the build so a local `.ts` entry fails at build
|
|
43
|
+
* time with an actionable diagnostic instead of at startup.
|
|
44
|
+
*/
|
|
45
|
+
protected validateBridgeOutput(): Promise<this>;
|
|
39
46
|
protected typecheck(): Promise<this>;
|
|
40
47
|
protected compile(): Promise<this>;
|
|
41
48
|
boot(): Promise<any>;
|
|
@@ -4,6 +4,15 @@ export declare class ControllerBuilder {
|
|
|
4
4
|
static scan(workdir: string): Promise<any[]>;
|
|
5
5
|
static loadDiArtifact(filename: string, version?: number, timestamp?: number): Promise<void>;
|
|
6
6
|
static build<T>({ filename, version, timestamp }: BuilderHMRDeclarationInterface, classification?: ArtifactClassification | null): Promise<T | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Compile an artifact that is already imported. The bridge uses this method
|
|
9
|
+
* so it does not re-import classes by path and does not duplicate any
|
|
10
|
+
* compiler logic.
|
|
11
|
+
*/
|
|
12
|
+
static buildArtifact<T>(artifact: any, classification: ArtifactClassification, origin?: "scan" | "bridge", options?: {
|
|
13
|
+
file?: string;
|
|
14
|
+
package?: string;
|
|
15
|
+
}): Promise<T | undefined>;
|
|
7
16
|
static recompile(modulo: any, filename: string): Promise<void>;
|
|
8
17
|
}
|
|
9
18
|
interface ArtifactKinds {
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { ApplicationInterface } from "../../types/application.ts";
|
|
2
|
-
|
|
2
|
+
import { type RouteOrigin } from "./tracker.ts";
|
|
3
|
+
export interface CompileControllerOptions {
|
|
4
|
+
/** Route ownership. Bridge routes are tracked separately from scan routes. */
|
|
5
|
+
origin?: RouteOrigin;
|
|
6
|
+
/** Optional tracker key, used by the bridge to isolate same-name controllers. */
|
|
7
|
+
trackerKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function compileController(ControllerClass: any, app: ApplicationInterface, options?: CompileControllerOptions): any;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { Route } from "../router/index.ts";
|
|
2
|
+
export type RouteOrigin = "scan" | "bridge";
|
|
3
|
+
/**
|
|
4
|
+
* Route ownership tracker. Bridge-owned routes use a distinct key so removing a
|
|
5
|
+
* bridge controller can never delete a local controller route that happens to
|
|
6
|
+
* share the same class name.
|
|
7
|
+
*/
|
|
2
8
|
export declare class ControllerRouteTracker {
|
|
3
|
-
static getRoutes(controllerName: string): Route[];
|
|
4
|
-
static setRoutes(controllerName: string, routes: Route[]): void;
|
|
9
|
+
static getRoutes(controllerName: string, origin?: RouteOrigin, key?: string): Route[];
|
|
10
|
+
static setRoutes(controllerName: string, routes: Route[], origin?: RouteOrigin, key?: string): void;
|
|
5
11
|
static removeRoutes(controllerName: string, router: {
|
|
6
12
|
remove(route: Route): void;
|
|
7
|
-
}): void;
|
|
13
|
+
}, origin?: RouteOrigin, key?: string): void;
|
|
8
14
|
static clear(): void;
|
|
15
|
+
static has(controllerName: string, origin?: RouteOrigin, key?: string): boolean;
|
|
9
16
|
}
|
|
@@ -10,5 +10,7 @@ export declare class HookStore {
|
|
|
10
10
|
*/
|
|
11
11
|
replaceAll(name: HookNameType, handler: HookHandlerCallable): void;
|
|
12
12
|
has(name: HookNameType): boolean;
|
|
13
|
+
/** True when a hook already contains this exact handler. */
|
|
14
|
+
hasHandler(name: HookNameType, handler: HookHandlerCallable): boolean;
|
|
13
15
|
run(name: HookNameType, ctx: any): Promise<void>;
|
|
14
16
|
}
|
|
@@ -16,6 +16,30 @@ export declare class Injection {
|
|
|
16
16
|
static defaultScope: symbol;
|
|
17
17
|
static get instances(): Map<string, Map<any, any>>;
|
|
18
18
|
static has(name: string): boolean;
|
|
19
|
+
static definition(name: string): ContainerDefinitionInterface | undefined;
|
|
20
|
+
static hasConstruct(construct: ConstructorType): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Adopt a class that was decorated in another copy of the framework (or in
|
|
23
|
+
* a package whose container is not the host container).
|
|
24
|
+
*
|
|
25
|
+
* Returns:
|
|
26
|
+
* - `adopted` when the class was unknown and registered in this container;
|
|
27
|
+
* - `existing` when the same class is already registered;
|
|
28
|
+
* - `collision` when a different class owns the normalized name;
|
|
29
|
+
* - `unregistered` when the class has no injectable metadata.
|
|
30
|
+
*/
|
|
31
|
+
static adopt(construct: ConstructorType): {
|
|
32
|
+
status: "adopted" | "existing" | "collision" | "unregistered";
|
|
33
|
+
name: string;
|
|
34
|
+
existing?: ContainerDefinitionInterface;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Replace a definition owned by the bridge during hot reload. Unlike
|
|
38
|
+
* `adopt()` this is not a collision: the caller has already established
|
|
39
|
+
* ownership of the previous class.
|
|
40
|
+
*/
|
|
41
|
+
static replace(name: string, construct: ConstructorType): typeof this;
|
|
42
|
+
static unregister(name: string): typeof this;
|
|
19
43
|
static clear(): void;
|
|
20
44
|
protected static normalizeName(name: string): string;
|
|
21
45
|
static registry(name: string, construct: ConstructorType, lifetime?: LifetimeEnum, scope?: Symbol): typeof this;
|
|
@@ -5,8 +5,19 @@ export declare class MiddlewarePipeline {
|
|
|
5
5
|
private terminalRunner?;
|
|
6
6
|
private invalidate;
|
|
7
7
|
use(mw: MiddlewareType): this;
|
|
8
|
+
/** True when this exact middleware instance/function is already mounted. */
|
|
9
|
+
has(mw: MiddlewareType): boolean;
|
|
10
|
+
/** True when a middleware with this name is already mounted. */
|
|
11
|
+
hasName(name: string): boolean;
|
|
12
|
+
/** Snapshot used by diagnostics and tests. */
|
|
13
|
+
entries(): readonly MiddlewareType[];
|
|
8
14
|
replace(name: string, mw: MiddlewareType): this;
|
|
9
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Remove a middleware by stable name or by identity. Identity removal is
|
|
17
|
+
* used by the artifact bridge when a descriptor name differs from the
|
|
18
|
+
* middleware function name.
|
|
19
|
+
*/
|
|
20
|
+
remove(nameOrMiddleware: string | MiddlewareType): this;
|
|
10
21
|
clear(): this;
|
|
11
22
|
run(ctx: any, ...extra: MiddlewareType[]): Promise<void>;
|
|
12
23
|
}
|
|
@@ -20,6 +20,11 @@ export declare class SchedulerManager implements SchedulerControlInterface {
|
|
|
20
20
|
mapQueue(queue: string, backendName: string): this;
|
|
21
21
|
get backends(): Map<string, QueueBackendInterface>;
|
|
22
22
|
register(name: string, instance: any, jobs: JobMetaInterface[]): this;
|
|
23
|
+
/**
|
|
24
|
+
* Remove one or more registered jobs. Used when a bridge-declared
|
|
25
|
+
* scheduler is removed during hot reload.
|
|
26
|
+
*/
|
|
27
|
+
unregister(names: string | string[]): this;
|
|
23
28
|
start(): Promise<void>;
|
|
24
29
|
stop(): Promise<void>;
|
|
25
30
|
has(name: string): boolean;
|
|
@@ -10,6 +10,11 @@ export declare class Artifacts {
|
|
|
10
10
|
static register(type: string): typeof Artifacts;
|
|
11
11
|
static registerMany(...types: string[]): typeof Artifacts;
|
|
12
12
|
static is(filename: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The bridge file must never be classified as an artifact, even if a custom
|
|
15
|
+
* type named `bridge` is registered.
|
|
16
|
+
*/
|
|
17
|
+
static isBridge(filename: string): boolean;
|
|
13
18
|
static classify(filename: string): ArtifactClassification | null;
|
|
14
19
|
static reload(modulo: any, filename?: string): void;
|
|
15
20
|
static reloadDi(modulo: any, filename?: string): void;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator metadata keys.
|
|
3
|
+
*
|
|
4
|
+
* `Symbol.for` is used deliberately: artifact packages compiled separately must
|
|
5
|
+
* expose metadata readable by the host application even when two copies of the
|
|
6
|
+
* framework coexist in `node_modules`. Local `Symbol()` values would make each
|
|
7
|
+
* copy unable to see the other's decorators (see spec 004, FR-048).
|
|
8
|
+
*/
|
|
1
9
|
export declare const METADATA_KEYS: {
|
|
2
10
|
CONTROLLERS: symbol;
|
|
3
11
|
SOCKETS: symbol;
|
|
@@ -21,6 +21,8 @@ export declare const RouteManifestSchema: import("@sinclair/typebox").TObject<{
|
|
|
21
21
|
handler: import("@sinclair/typebox").TString;
|
|
22
22
|
file: import("@sinclair/typebox").TString;
|
|
23
23
|
line: import("@sinclair/typebox").TNumber;
|
|
24
|
+
origin: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"scan">, import("@sinclair/typebox").TLiteral<"bridge">]>>;
|
|
25
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
24
26
|
input: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
25
27
|
output: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
26
28
|
inputSchema: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
@@ -80,6 +82,39 @@ export declare const McpServerManifestSchema: import("@sinclair/typebox").TObjec
|
|
|
80
82
|
prompts: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>>;
|
|
81
83
|
resources: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>>;
|
|
82
84
|
}>;
|
|
85
|
+
export declare const BridgeArtifactManifestSchema: import("@sinclair/typebox").TObject<{
|
|
86
|
+
name: import("@sinclair/typebox").TString;
|
|
87
|
+
kind: import("@sinclair/typebox").TString;
|
|
88
|
+
origin: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"scan">, import("@sinclair/typebox").TLiteral<"bridge">]>;
|
|
89
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
90
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
91
|
+
}>;
|
|
92
|
+
export declare const BridgeUnresolvedManifestSchema: import("@sinclair/typebox").TObject<{
|
|
93
|
+
entry: import("@sinclair/typebox").TString;
|
|
94
|
+
reason: import("@sinclair/typebox").TString;
|
|
95
|
+
code: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
96
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
97
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const BridgeManifestSchema: import("@sinclair/typebox").TObject<{
|
|
100
|
+
file: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
101
|
+
loaded: import("@sinclair/typebox").TBoolean;
|
|
102
|
+
packages: import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>;
|
|
103
|
+
artifacts: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
104
|
+
name: import("@sinclair/typebox").TString;
|
|
105
|
+
kind: import("@sinclair/typebox").TString;
|
|
106
|
+
origin: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"scan">, import("@sinclair/typebox").TLiteral<"bridge">]>;
|
|
107
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
108
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
109
|
+
}>>;
|
|
110
|
+
unresolved: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
111
|
+
entry: import("@sinclair/typebox").TString;
|
|
112
|
+
reason: import("@sinclair/typebox").TString;
|
|
113
|
+
code: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
114
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
115
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
116
|
+
}>>;
|
|
117
|
+
}>;
|
|
83
118
|
export declare const ProjectManifestSchema: import("@sinclair/typebox").TObject<{
|
|
84
119
|
schemaVersion: import("@sinclair/typebox").TString;
|
|
85
120
|
generatedAt: import("@sinclair/typebox").TString;
|
|
@@ -101,6 +136,8 @@ export declare const ProjectManifestSchema: import("@sinclair/typebox").TObject<
|
|
|
101
136
|
handler: import("@sinclair/typebox").TString;
|
|
102
137
|
file: import("@sinclair/typebox").TString;
|
|
103
138
|
line: import("@sinclair/typebox").TNumber;
|
|
139
|
+
origin: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"scan">, import("@sinclair/typebox").TLiteral<"bridge">]>>;
|
|
140
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
104
141
|
input: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
105
142
|
output: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
106
143
|
inputSchema: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
@@ -149,6 +186,25 @@ export declare const ProjectManifestSchema: import("@sinclair/typebox").TObject<
|
|
|
149
186
|
prompts: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>>;
|
|
150
187
|
resources: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>>;
|
|
151
188
|
}>>;
|
|
189
|
+
bridge: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
190
|
+
file: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
|
|
191
|
+
loaded: import("@sinclair/typebox").TBoolean;
|
|
192
|
+
packages: import("@sinclair/typebox").TArray<import("../contracts/typebox.ts").TSchema>;
|
|
193
|
+
artifacts: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
194
|
+
name: import("@sinclair/typebox").TString;
|
|
195
|
+
kind: import("@sinclair/typebox").TString;
|
|
196
|
+
origin: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"scan">, import("@sinclair/typebox").TLiteral<"bridge">]>;
|
|
197
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
198
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
199
|
+
}>>;
|
|
200
|
+
unresolved: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
201
|
+
entry: import("@sinclair/typebox").TString;
|
|
202
|
+
reason: import("@sinclair/typebox").TString;
|
|
203
|
+
code: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
204
|
+
package: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
205
|
+
file: import("@sinclair/typebox").TOptional<import("../contracts/typebox.ts").TSchema>;
|
|
206
|
+
}>>;
|
|
207
|
+
}>>;
|
|
152
208
|
}>;
|
|
153
209
|
export interface McpToolAnnotationsManifest {
|
|
154
210
|
title?: string;
|
|
@@ -197,6 +253,8 @@ export interface ProjectRouteManifest {
|
|
|
197
253
|
handler: string;
|
|
198
254
|
file: string;
|
|
199
255
|
line: number;
|
|
256
|
+
origin?: "scan" | "bridge";
|
|
257
|
+
package?: string;
|
|
200
258
|
input?: string;
|
|
201
259
|
output?: string;
|
|
202
260
|
inputSchema?: Record<string, any>;
|
|
@@ -226,6 +284,25 @@ export interface ProjectManifest {
|
|
|
226
284
|
config: Record<string, string>;
|
|
227
285
|
env: string[];
|
|
228
286
|
mcp: McpServerManifest[];
|
|
287
|
+
bridge?: {
|
|
288
|
+
file: string | null;
|
|
289
|
+
loaded: boolean;
|
|
290
|
+
packages: string[];
|
|
291
|
+
artifacts: Array<{
|
|
292
|
+
name: string;
|
|
293
|
+
kind: string;
|
|
294
|
+
origin: "scan" | "bridge";
|
|
295
|
+
package?: string;
|
|
296
|
+
file?: string;
|
|
297
|
+
}>;
|
|
298
|
+
unresolved: Array<{
|
|
299
|
+
entry: string;
|
|
300
|
+
reason: string;
|
|
301
|
+
code?: string;
|
|
302
|
+
package?: string;
|
|
303
|
+
file?: string;
|
|
304
|
+
}>;
|
|
305
|
+
};
|
|
229
306
|
}
|
|
230
307
|
export interface ManifestValidationResult {
|
|
231
308
|
valid: boolean;
|