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.
- package/CHANGELOG.md +16 -0
- 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
package/build/bin/index.mjs
CHANGED
|
@@ -3144,7 +3144,7 @@ var package_default;
|
|
|
3144
3144
|
var init_package = __esm(() => {
|
|
3145
3145
|
package_default = {
|
|
3146
3146
|
name: "raiton",
|
|
3147
|
-
version: "6.
|
|
3147
|
+
version: "6.12.0-beta.31",
|
|
3148
3148
|
private: false,
|
|
3149
3149
|
type: "module",
|
|
3150
3150
|
description: "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
|
|
@@ -4386,13 +4386,39 @@ function validateConfig(input) {
|
|
|
4386
4386
|
if (config.artifacts !== undefined) {
|
|
4387
4387
|
if (typeof config.artifacts !== "object" || config.artifacts === null) {
|
|
4388
4388
|
errors.push({ field: "artifacts", message: "artifacts must be an object" });
|
|
4389
|
-
} else
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4389
|
+
} else {
|
|
4390
|
+
if (config.artifacts.types !== undefined && (!Array.isArray(config.artifacts.types) || config.artifacts.types.some((type) => typeof type !== "string"))) {
|
|
4391
|
+
errors.push({
|
|
4392
|
+
field: "artifacts.types",
|
|
4393
|
+
message: "artifacts.types must be an array of strings",
|
|
4394
|
+
expected: "string[]",
|
|
4395
|
+
received: describe(config.artifacts.types)
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
if (config.artifacts.bridge !== undefined && config.artifacts.bridge !== false && (typeof config.artifacts.bridge !== "string" || !config.artifacts.bridge.trim())) {
|
|
4399
|
+
errors.push({
|
|
4400
|
+
field: "artifacts.bridge",
|
|
4401
|
+
message: "artifacts.bridge must be a non-empty string or false",
|
|
4402
|
+
expected: "string|false",
|
|
4403
|
+
received: describe(config.artifacts.bridge)
|
|
4404
|
+
});
|
|
4405
|
+
}
|
|
4406
|
+
if (config.artifacts.packages !== undefined && typeof config.artifacts.packages !== "boolean") {
|
|
4407
|
+
errors.push({
|
|
4408
|
+
field: "artifacts.packages",
|
|
4409
|
+
message: "artifacts.packages must be a boolean",
|
|
4410
|
+
expected: "boolean",
|
|
4411
|
+
received: describe(config.artifacts.packages)
|
|
4412
|
+
});
|
|
4413
|
+
}
|
|
4414
|
+
if (config.artifacts.packageAllowlist !== undefined && (!Array.isArray(config.artifacts.packageAllowlist) || config.artifacts.packageAllowlist.some((name) => typeof name !== "string" || !name.trim()))) {
|
|
4415
|
+
errors.push({
|
|
4416
|
+
field: "artifacts.packageAllowlist",
|
|
4417
|
+
message: "artifacts.packageAllowlist must be an array of non-empty strings",
|
|
4418
|
+
expected: "string[]",
|
|
4419
|
+
received: describe(config.artifacts.packageAllowlist)
|
|
4420
|
+
});
|
|
4421
|
+
}
|
|
4396
4422
|
}
|
|
4397
4423
|
}
|
|
4398
4424
|
if (config.devPage !== undefined && config.devPage.path !== undefined && (typeof config.devPage.path !== "string" || !config.devPage.path.startsWith("/"))) {
|
|
@@ -4585,7 +4611,22 @@ function getConfigJsonSchema() {
|
|
|
4585
4611
|
artifacts: {
|
|
4586
4612
|
type: "object",
|
|
4587
4613
|
properties: {
|
|
4588
|
-
types: { type: "array", items: { type: "string" }, uniqueItems: true }
|
|
4614
|
+
types: { type: "array", items: { type: "string" }, uniqueItems: true },
|
|
4615
|
+
bridge: {
|
|
4616
|
+
oneOf: [{ type: "string", minLength: 1 }, { const: false }],
|
|
4617
|
+
description: "Bridge file path relative to the workdir or rootDir; false disables discovery."
|
|
4618
|
+
},
|
|
4619
|
+
packages: {
|
|
4620
|
+
type: "boolean",
|
|
4621
|
+
default: true,
|
|
4622
|
+
description: "Discover direct dependencies declaring package.json#raiton.artifacts."
|
|
4623
|
+
},
|
|
4624
|
+
packageAllowlist: {
|
|
4625
|
+
type: "array",
|
|
4626
|
+
items: { type: "string", minLength: 1 },
|
|
4627
|
+
uniqueItems: true,
|
|
4628
|
+
description: "Restrict package discovery to these direct dependencies."
|
|
4629
|
+
}
|
|
4589
4630
|
}
|
|
4590
4631
|
},
|
|
4591
4632
|
observability: {
|
|
@@ -4884,32 +4925,32 @@ function parseCookie(cookieHeader) {
|
|
|
4884
4925
|
var METADATA_KEYS;
|
|
4885
4926
|
var init_decorators_constant = __esm(() => {
|
|
4886
4927
|
METADATA_KEYS = {
|
|
4887
|
-
CONTROLLERS: Symbol("controller:meta"),
|
|
4888
|
-
SOCKETS: Symbol("socket:meta"),
|
|
4889
|
-
SOCKET_EVENTS: Symbol("socket:event:meta"),
|
|
4890
|
-
ROUTE_PARAMETERS: Symbol("route:meta"),
|
|
4891
|
-
GRAFTS: Symbol("graft:meta"),
|
|
4892
|
-
CONTAINER: Symbol("container:meta"),
|
|
4893
|
-
INJECT_PARAMETERS: Symbol("inject:parameters"),
|
|
4894
|
-
INJECT_PROPERTIES: Symbol("inject:properties"),
|
|
4895
|
-
API_RESPONSES: Symbol("api:responses"),
|
|
4896
|
-
API_REQUEST_BODY: Symbol("api:requestBody"),
|
|
4897
|
-
API_PARAMETERS: Symbol("api:parameters"),
|
|
4898
|
-
API_ENUMS: Symbol("api:enums"),
|
|
4899
|
-
API_TAGS: Symbol("api:tags"),
|
|
4900
|
-
API_OPERATION: Symbol("api:operation"),
|
|
4901
|
-
API_SECURITY: Symbol("api:security"),
|
|
4902
|
-
API_PROPERTY: Symbol("api:property"),
|
|
4903
|
-
ROUTE_INTERACTION: Symbol("route:interaction"),
|
|
4904
|
-
CACHE: Symbol("route:cache"),
|
|
4905
|
-
HEALTH_CHECK: Symbol("health:check"),
|
|
4906
|
-
MCP: Symbol("mcp:meta"),
|
|
4907
|
-
MCP_ELEMENTS: Symbol("mcp:elements"),
|
|
4908
|
-
MCP_ARGUMENTS: Symbol("mcp:arguments"),
|
|
4909
|
-
SCHEDULER: Symbol("scheduler:meta"),
|
|
4910
|
-
CONTRACT_INPUT: Symbol("contract:input"),
|
|
4911
|
-
CONTRACT_OUTPUT: Symbol("contract:output"),
|
|
4912
|
-
PUBLIC_EXPORT: Symbol("docs:public-export")
|
|
4928
|
+
CONTROLLERS: Symbol.for("raiton:controller:meta"),
|
|
4929
|
+
SOCKETS: Symbol.for("raiton:socket:meta"),
|
|
4930
|
+
SOCKET_EVENTS: Symbol.for("raiton:socket:event:meta"),
|
|
4931
|
+
ROUTE_PARAMETERS: Symbol.for("raiton:route:meta"),
|
|
4932
|
+
GRAFTS: Symbol.for("raiton:graft:meta"),
|
|
4933
|
+
CONTAINER: Symbol.for("raiton:container:meta"),
|
|
4934
|
+
INJECT_PARAMETERS: Symbol.for("raiton:inject:parameters"),
|
|
4935
|
+
INJECT_PROPERTIES: Symbol.for("raiton:inject:properties"),
|
|
4936
|
+
API_RESPONSES: Symbol.for("raiton:api:responses"),
|
|
4937
|
+
API_REQUEST_BODY: Symbol.for("raiton:api:requestBody"),
|
|
4938
|
+
API_PARAMETERS: Symbol.for("raiton:api:parameters"),
|
|
4939
|
+
API_ENUMS: Symbol.for("raiton:api:enums"),
|
|
4940
|
+
API_TAGS: Symbol.for("raiton:api:tags"),
|
|
4941
|
+
API_OPERATION: Symbol.for("raiton:api:operation"),
|
|
4942
|
+
API_SECURITY: Symbol.for("raiton:api:security"),
|
|
4943
|
+
API_PROPERTY: Symbol.for("raiton:api:property"),
|
|
4944
|
+
ROUTE_INTERACTION: Symbol.for("raiton:route:interaction"),
|
|
4945
|
+
CACHE: Symbol.for("raiton:route:cache"),
|
|
4946
|
+
HEALTH_CHECK: Symbol.for("raiton:health:check"),
|
|
4947
|
+
MCP: Symbol.for("raiton:mcp:meta"),
|
|
4948
|
+
MCP_ELEMENTS: Symbol.for("raiton:mcp:elements"),
|
|
4949
|
+
MCP_ARGUMENTS: Symbol.for("raiton:mcp:arguments"),
|
|
4950
|
+
SCHEDULER: Symbol.for("raiton:scheduler:meta"),
|
|
4951
|
+
CONTRACT_INPUT: Symbol.for("raiton:contract:input"),
|
|
4952
|
+
CONTRACT_OUTPUT: Symbol.for("raiton:contract:output"),
|
|
4953
|
+
PUBLIC_EXPORT: Symbol.for("raiton:docs:public-export")
|
|
4913
4954
|
};
|
|
4914
4955
|
});
|
|
4915
4956
|
|
|
@@ -6570,6 +6611,51 @@ var init_injection = __esm(() => {
|
|
|
6570
6611
|
static has(name) {
|
|
6571
6612
|
return this._classes.has(this.normalizeName(name));
|
|
6572
6613
|
}
|
|
6614
|
+
static definition(name) {
|
|
6615
|
+
return this._classes.get(this.normalizeName(name));
|
|
6616
|
+
}
|
|
6617
|
+
static hasConstruct(construct) {
|
|
6618
|
+
for (const definition of this._classes.values()) {
|
|
6619
|
+
if (definition.construct === construct)
|
|
6620
|
+
return true;
|
|
6621
|
+
}
|
|
6622
|
+
return false;
|
|
6623
|
+
}
|
|
6624
|
+
static adopt(construct) {
|
|
6625
|
+
const metadata = Reflect.getMetadata(METADATA_KEYS.CONTAINER, construct);
|
|
6626
|
+
if (!metadata?.name)
|
|
6627
|
+
return { status: "unregistered", name: construct.name };
|
|
6628
|
+
const normalized = this.normalizeName(metadata.name);
|
|
6629
|
+
const existing = this._classes.get(normalized);
|
|
6630
|
+
if (!existing) {
|
|
6631
|
+
this.registry(metadata.name, construct, metadata.lifetime, metadata.scope);
|
|
6632
|
+
return { status: "adopted", name: metadata.name };
|
|
6633
|
+
}
|
|
6634
|
+
if (existing.construct === construct) {
|
|
6635
|
+
return { status: "existing", name: metadata.name, existing };
|
|
6636
|
+
}
|
|
6637
|
+
return { status: "collision", name: metadata.name, existing };
|
|
6638
|
+
}
|
|
6639
|
+
static replace(name, construct) {
|
|
6640
|
+
const name_ = this.normalizeName(name);
|
|
6641
|
+
const definition = this._classes.get(name_);
|
|
6642
|
+
this.invalidate(name_);
|
|
6643
|
+
if (definition) {
|
|
6644
|
+
this._classes.set(name_, { ...definition, construct });
|
|
6645
|
+
} else {
|
|
6646
|
+
this.registry(name, construct);
|
|
6647
|
+
}
|
|
6648
|
+
return this;
|
|
6649
|
+
}
|
|
6650
|
+
static unregister(name) {
|
|
6651
|
+
const name_ = this.normalizeName(name);
|
|
6652
|
+
if (this._artifactPaths.has(name_))
|
|
6653
|
+
this._artifactPaths.delete(name_);
|
|
6654
|
+
this._instances.delete(name_);
|
|
6655
|
+
this._dependents.delete(name_);
|
|
6656
|
+
this._classes.delete(name_);
|
|
6657
|
+
return this;
|
|
6658
|
+
}
|
|
6573
6659
|
static clear() {
|
|
6574
6660
|
Logger.info("Clearing injection container");
|
|
6575
6661
|
this._classes.clear();
|
|
@@ -33530,6 +33616,17 @@ class SchedulerManager {
|
|
|
33530
33616
|
}
|
|
33531
33617
|
return this;
|
|
33532
33618
|
}
|
|
33619
|
+
unregister(names) {
|
|
33620
|
+
for (const name of Array.isArray(names) ? names : [names]) {
|
|
33621
|
+
const job = this._jobs.get(name);
|
|
33622
|
+
if (!job)
|
|
33623
|
+
continue;
|
|
33624
|
+
this.clearTimer(job);
|
|
33625
|
+
job.paused = true;
|
|
33626
|
+
this._jobs.delete(name);
|
|
33627
|
+
}
|
|
33628
|
+
return this;
|
|
33629
|
+
}
|
|
33533
33630
|
async start() {
|
|
33534
33631
|
if (!this._config.enabled || this._booted)
|
|
33535
33632
|
return;
|
|
@@ -34696,7 +34793,12 @@ var init_artifacts = __esm(async () => {
|
|
|
34696
34793
|
const artifactType = artifactTypeOf(filename);
|
|
34697
34794
|
return artifactType !== null && this.types.has(artifactType);
|
|
34698
34795
|
}
|
|
34796
|
+
static isBridge(filename) {
|
|
34797
|
+
return /(^|[\\/])artifacts\.bridge\.(ts|mts|cts|js|mjs|cjs)$/.test(filename);
|
|
34798
|
+
}
|
|
34699
34799
|
static classify(filename) {
|
|
34800
|
+
if (this.isBridge(filename))
|
|
34801
|
+
return null;
|
|
34700
34802
|
const artifactType = artifactTypeOf(filename);
|
|
34701
34803
|
if (!artifactType)
|
|
34702
34804
|
return null;
|
|
@@ -34831,7 +34933,7 @@ function validateManifest(manifest) {
|
|
|
34831
34933
|
function manifestJsonSchema() {
|
|
34832
34934
|
return JSON.parse(JSON.stringify(ProjectManifestSchema));
|
|
34833
34935
|
}
|
|
34834
|
-
var MANIFEST_SCHEMA_VERSION = "1.0.0", SUPPORTED_MANIFEST_SCHEMA_VERSIONS, SchemaRecord, RouteExampleSchema, RouteErrorSchema, RouteManifestSchema, McpToolManifestSchema, McpServerManifestSchema, ProjectManifestSchema;
|
|
34936
|
+
var MANIFEST_SCHEMA_VERSION = "1.0.0", SUPPORTED_MANIFEST_SCHEMA_VERSIONS, SchemaRecord, RouteExampleSchema, RouteErrorSchema, RouteManifestSchema, McpToolManifestSchema, McpServerManifestSchema, BridgeArtifactManifestSchema, BridgeUnresolvedManifestSchema, BridgeManifestSchema, ProjectManifestSchema;
|
|
34835
34937
|
var init_schema5 = __esm(() => {
|
|
34836
34938
|
init_typebox();
|
|
34837
34939
|
init_value4();
|
|
@@ -34858,6 +34960,8 @@ var init_schema5 = __esm(() => {
|
|
|
34858
34960
|
handler: t.string(),
|
|
34859
34961
|
file: t.string(),
|
|
34860
34962
|
line: t.number(),
|
|
34963
|
+
origin: t.optional(t.union([t.literal("scan"), t.literal("bridge")])),
|
|
34964
|
+
package: t.optional(t.string()),
|
|
34861
34965
|
input: t.optional(t.string()),
|
|
34862
34966
|
output: t.optional(t.string()),
|
|
34863
34967
|
inputSchema: t.optional(SchemaRecord),
|
|
@@ -34892,6 +34996,27 @@ var init_schema5 = __esm(() => {
|
|
|
34892
34996
|
prompts: t.optional(t.array(t.any())),
|
|
34893
34997
|
resources: t.optional(t.array(t.any()))
|
|
34894
34998
|
});
|
|
34999
|
+
BridgeArtifactManifestSchema = t.object({
|
|
35000
|
+
name: t.string(),
|
|
35001
|
+
kind: t.string(),
|
|
35002
|
+
origin: t.union([t.literal("scan"), t.literal("bridge")]),
|
|
35003
|
+
package: t.optional(t.string()),
|
|
35004
|
+
file: t.optional(t.string())
|
|
35005
|
+
});
|
|
35006
|
+
BridgeUnresolvedManifestSchema = t.object({
|
|
35007
|
+
entry: t.string(),
|
|
35008
|
+
reason: t.string(),
|
|
35009
|
+
code: t.optional(t.string()),
|
|
35010
|
+
package: t.optional(t.string()),
|
|
35011
|
+
file: t.optional(t.string())
|
|
35012
|
+
});
|
|
35013
|
+
BridgeManifestSchema = t.object({
|
|
35014
|
+
file: t.union([t.string(), t.null()]),
|
|
35015
|
+
loaded: t.boolean(),
|
|
35016
|
+
packages: t.array(t.string()),
|
|
35017
|
+
artifacts: t.array(BridgeArtifactManifestSchema),
|
|
35018
|
+
unresolved: t.array(BridgeUnresolvedManifestSchema)
|
|
35019
|
+
});
|
|
34895
35020
|
ProjectManifestSchema = t.object({
|
|
34896
35021
|
schemaVersion: t.string(),
|
|
34897
35022
|
generatedAt: t.string(),
|
|
@@ -34910,13 +35035,1652 @@ var init_schema5 = __esm(() => {
|
|
|
34910
35035
|
artifacts: t.array(t.string()),
|
|
34911
35036
|
config: t.record(t.string(), t.string()),
|
|
34912
35037
|
env: t.array(t.string()),
|
|
34913
|
-
mcp: t.array(McpServerManifestSchema)
|
|
35038
|
+
mcp: t.array(McpServerManifestSchema),
|
|
35039
|
+
bridge: t.optional(BridgeManifestSchema)
|
|
34914
35040
|
}, { additionalProperties: true });
|
|
34915
35041
|
});
|
|
34916
35042
|
|
|
34917
|
-
// source/
|
|
34918
|
-
import fs2 from "node:fs";
|
|
35043
|
+
// source/core/bridge/registry.ts
|
|
34919
35044
|
import path3 from "node:path";
|
|
35045
|
+
function artifactKey(record) {
|
|
35046
|
+
return [record.kind, record.name, record.file ?? "", record.package ?? ""].join("|");
|
|
35047
|
+
}
|
|
35048
|
+
var ArtifactRegistry;
|
|
35049
|
+
var init_registry2 = __esm(() => {
|
|
35050
|
+
init_injection();
|
|
35051
|
+
ArtifactRegistry = class ArtifactRegistry {
|
|
35052
|
+
static byConstruct = new WeakMap;
|
|
35053
|
+
static byKey = new Map;
|
|
35054
|
+
static excludedFiles = new Set;
|
|
35055
|
+
static clear() {
|
|
35056
|
+
this.byKey.clear();
|
|
35057
|
+
this.excludedFiles.clear();
|
|
35058
|
+
}
|
|
35059
|
+
static clearBridge() {
|
|
35060
|
+
for (const [key, record] of [...this.byKey]) {
|
|
35061
|
+
if (record.origin === "bridge" || record.origin === "package") {
|
|
35062
|
+
this.byKey.delete(key);
|
|
35063
|
+
}
|
|
35064
|
+
}
|
|
35065
|
+
}
|
|
35066
|
+
static add(record) {
|
|
35067
|
+
const existing = this.byKey.get(record.key);
|
|
35068
|
+
if (existing)
|
|
35069
|
+
return existing;
|
|
35070
|
+
this.byKey.set(record.key, record);
|
|
35071
|
+
if (record.construct && (typeof record.construct === "function" || typeof record.construct === "object")) {
|
|
35072
|
+
this.byConstruct.set(record.construct, record);
|
|
35073
|
+
}
|
|
35074
|
+
return record;
|
|
35075
|
+
}
|
|
35076
|
+
static getByKey(key) {
|
|
35077
|
+
return this.byKey.get(key);
|
|
35078
|
+
}
|
|
35079
|
+
static getByConstruct(construct) {
|
|
35080
|
+
if (!construct || typeof construct !== "function" && typeof construct !== "object")
|
|
35081
|
+
return;
|
|
35082
|
+
const record = this.byConstruct.get(construct);
|
|
35083
|
+
if (!record)
|
|
35084
|
+
return;
|
|
35085
|
+
return this.byKey.get(record.key) === record ? record : undefined;
|
|
35086
|
+
}
|
|
35087
|
+
static hasConstruct(construct) {
|
|
35088
|
+
return Boolean(this.getByConstruct(construct));
|
|
35089
|
+
}
|
|
35090
|
+
static remove(key) {
|
|
35091
|
+
const record = this.byKey.get(key);
|
|
35092
|
+
if (!record)
|
|
35093
|
+
return;
|
|
35094
|
+
this.byKey.delete(key);
|
|
35095
|
+
if (record.construct && (typeof record.construct === "function" || typeof record.construct === "object")) {
|
|
35096
|
+
const mapped = this.byConstruct.get(record.construct);
|
|
35097
|
+
if (mapped === record) {
|
|
35098
|
+
this.byConstruct.delete(record.construct);
|
|
35099
|
+
}
|
|
35100
|
+
}
|
|
35101
|
+
return record;
|
|
35102
|
+
}
|
|
35103
|
+
static records() {
|
|
35104
|
+
return [...this.byKey.values()];
|
|
35105
|
+
}
|
|
35106
|
+
static recordsByOrigin(origin) {
|
|
35107
|
+
return this.records().filter((record) => record.origin === origin);
|
|
35108
|
+
}
|
|
35109
|
+
static routeInfo(route) {
|
|
35110
|
+
for (const record of this.byKey.values()) {
|
|
35111
|
+
if (record.routes?.includes(route))
|
|
35112
|
+
return record;
|
|
35113
|
+
}
|
|
35114
|
+
const controllerClass = route.handler?._raitonMeta?.controllerClass;
|
|
35115
|
+
if (controllerClass) {
|
|
35116
|
+
const record = this.getByConstruct(controllerClass);
|
|
35117
|
+
if (record)
|
|
35118
|
+
return record;
|
|
35119
|
+
}
|
|
35120
|
+
return;
|
|
35121
|
+
}
|
|
35122
|
+
static excludeFile(filename) {
|
|
35123
|
+
this.excludedFiles.add(path3.resolve(filename));
|
|
35124
|
+
}
|
|
35125
|
+
static isExcludedFile(filename) {
|
|
35126
|
+
return this.excludedFiles.has(path3.resolve(filename));
|
|
35127
|
+
}
|
|
35128
|
+
static setExcludedFiles(files) {
|
|
35129
|
+
this.excludedFiles.clear();
|
|
35130
|
+
for (const file of files)
|
|
35131
|
+
this.excludeFile(file);
|
|
35132
|
+
}
|
|
35133
|
+
static excluded() {
|
|
35134
|
+
return [...this.excludedFiles];
|
|
35135
|
+
}
|
|
35136
|
+
static describeArtifacts(workdir) {
|
|
35137
|
+
const output = [];
|
|
35138
|
+
const seenConstructs = new Set;
|
|
35139
|
+
const seenNames = new Set;
|
|
35140
|
+
const add = (record) => {
|
|
35141
|
+
if (seenNames.has(`${record.kind}:${record.name}`))
|
|
35142
|
+
return;
|
|
35143
|
+
seenNames.add(`${record.kind}:${record.name}`);
|
|
35144
|
+
if (record.construct)
|
|
35145
|
+
seenConstructs.add(record.construct);
|
|
35146
|
+
output.push({
|
|
35147
|
+
name: record.name,
|
|
35148
|
+
kind: record.kind,
|
|
35149
|
+
origin: record.origin === "scan" ? "scan" : "bridge",
|
|
35150
|
+
...record.package ? { package: record.package } : {},
|
|
35151
|
+
...record.file ? { file: path3.relative(workdir, record.file).split(path3.sep).join("/") } : {}
|
|
35152
|
+
});
|
|
35153
|
+
};
|
|
35154
|
+
for (const record of this.records())
|
|
35155
|
+
add(record);
|
|
35156
|
+
for (const definition of Injection.classes.values()) {
|
|
35157
|
+
if (seenConstructs.has(definition.construct))
|
|
35158
|
+
continue;
|
|
35159
|
+
if (seenNames.has(`di:${definition.name}`))
|
|
35160
|
+
continue;
|
|
35161
|
+
const file = Injection.getArtifactPath(definition.name);
|
|
35162
|
+
add({
|
|
35163
|
+
name: definition.name,
|
|
35164
|
+
kind: "di",
|
|
35165
|
+
origin: "scan",
|
|
35166
|
+
construct: definition.construct,
|
|
35167
|
+
...file ? { file } : {}
|
|
35168
|
+
});
|
|
35169
|
+
}
|
|
35170
|
+
return output.sort((left, right) => `${left.origin}:${left.kind}:${left.name}`.localeCompare(`${right.origin}:${right.kind}:${right.name}`));
|
|
35171
|
+
}
|
|
35172
|
+
};
|
|
35173
|
+
});
|
|
35174
|
+
|
|
35175
|
+
// source/bin/constants.ts
|
|
35176
|
+
var isBunUsed, isDenoUsed, isNodeUsed;
|
|
35177
|
+
var init_constants2 = __esm(() => {
|
|
35178
|
+
isBunUsed = typeof globalThis.Bun !== "undefined";
|
|
35179
|
+
isDenoUsed = typeof globalThis.Deno !== "undefined";
|
|
35180
|
+
isNodeUsed = !isBunUsed && !isDenoUsed;
|
|
35181
|
+
});
|
|
35182
|
+
|
|
35183
|
+
// source/core/bridge/classifier.ts
|
|
35184
|
+
function isClass2(value) {
|
|
35185
|
+
if (typeof value !== "function")
|
|
35186
|
+
return false;
|
|
35187
|
+
if (!/^\s*class[\s{]/.test(Function.prototype.toString.call(value)))
|
|
35188
|
+
return false;
|
|
35189
|
+
try {
|
|
35190
|
+
Reflect.construct(Object, [], value);
|
|
35191
|
+
return true;
|
|
35192
|
+
} catch {
|
|
35193
|
+
return false;
|
|
35194
|
+
}
|
|
35195
|
+
}
|
|
35196
|
+
function metadataOf(key, construct) {
|
|
35197
|
+
const prototype = construct?.prototype;
|
|
35198
|
+
return (prototype ? Reflect.getMetadata(key, prototype) : undefined) ?? Reflect.getMetadata(key, construct);
|
|
35199
|
+
}
|
|
35200
|
+
function hasControllerMetadata(construct) {
|
|
35201
|
+
const metadata = metadataOf(METADATA_KEYS.CONTROLLERS, construct);
|
|
35202
|
+
return Boolean(metadata) && (Array.isArray(metadata.routes) || Object.prototype.hasOwnProperty.call(metadata, "prefix"));
|
|
35203
|
+
}
|
|
35204
|
+
function classifyConstruct(construct) {
|
|
35205
|
+
if (typeof construct !== "function")
|
|
35206
|
+
return null;
|
|
35207
|
+
const name = construct.name || construct.constructor?.name;
|
|
35208
|
+
if (!name)
|
|
35209
|
+
return null;
|
|
35210
|
+
if (hasControllerMetadata(construct)) {
|
|
35211
|
+
return { construct, name, kind: "controller" };
|
|
35212
|
+
}
|
|
35213
|
+
if (metadataOf(METADATA_KEYS.SOCKETS, construct)) {
|
|
35214
|
+
return { construct, name, kind: "socket" };
|
|
35215
|
+
}
|
|
35216
|
+
if (metadataOf(METADATA_KEYS.MCP, construct)) {
|
|
35217
|
+
return { construct, name, kind: "mcp" };
|
|
35218
|
+
}
|
|
35219
|
+
if (metadataOf(METADATA_KEYS.SCHEDULER, construct)) {
|
|
35220
|
+
return { construct, name, kind: "scheduler" };
|
|
35221
|
+
}
|
|
35222
|
+
if (metadataOf(METADATA_KEYS.CONTAINER, construct)) {
|
|
35223
|
+
return { construct, name, kind: "di" };
|
|
35224
|
+
}
|
|
35225
|
+
return null;
|
|
35226
|
+
}
|
|
35227
|
+
function isBridgeDefinition(value) {
|
|
35228
|
+
return Boolean(value) && typeof value === "object" && Array.isArray(value.artifacts);
|
|
35229
|
+
}
|
|
35230
|
+
function moduleExports(imported) {
|
|
35231
|
+
if (!imported || typeof imported !== "object")
|
|
35232
|
+
return [imported];
|
|
35233
|
+
const values = Object.values(imported);
|
|
35234
|
+
if ("default" in imported && !values.includes(imported.default))
|
|
35235
|
+
values.push(imported.default);
|
|
35236
|
+
return values;
|
|
35237
|
+
}
|
|
35238
|
+
function resolveArtifacts(imported, options = {}) {
|
|
35239
|
+
const kinds = options.kinds ? new Set(options.kinds) : null;
|
|
35240
|
+
const output = [];
|
|
35241
|
+
const seen = new Set;
|
|
35242
|
+
for (const candidate of moduleExports(imported)) {
|
|
35243
|
+
if (seen.has(candidate))
|
|
35244
|
+
continue;
|
|
35245
|
+
seen.add(candidate);
|
|
35246
|
+
const classified = classifyConstruct(candidate);
|
|
35247
|
+
if (!classified)
|
|
35248
|
+
continue;
|
|
35249
|
+
if (kinds && !kinds.has(classified.kind))
|
|
35250
|
+
continue;
|
|
35251
|
+
output.push(classified);
|
|
35252
|
+
}
|
|
35253
|
+
return output;
|
|
35254
|
+
}
|
|
35255
|
+
function exportNames(imported) {
|
|
35256
|
+
if (!imported || typeof imported !== "object")
|
|
35257
|
+
return [];
|
|
35258
|
+
return Object.keys(imported);
|
|
35259
|
+
}
|
|
35260
|
+
var init_classifier = __esm(() => {
|
|
35261
|
+
init_decorators_constant();
|
|
35262
|
+
});
|
|
35263
|
+
|
|
35264
|
+
// source/core/bridge/diagnostics.ts
|
|
35265
|
+
function bridgeDiagnostic(code, options = {}) {
|
|
35266
|
+
const definition = BRIDGE_DIAGNOSTICS[code] ?? BRIDGE_DIAGNOSTICS.BRIDGE_ENTRY_INVALID;
|
|
35267
|
+
return {
|
|
35268
|
+
code,
|
|
35269
|
+
severity: options.severity ?? definition.severity,
|
|
35270
|
+
message: options.message ?? definition.message,
|
|
35271
|
+
action: options.action ?? definition.action,
|
|
35272
|
+
docsUrl: errorDocsUrl(BRIDGE_DOCS_PATH),
|
|
35273
|
+
...options.location ? { location: options.location } : {},
|
|
35274
|
+
...options.entry ? { entry: options.entry } : {},
|
|
35275
|
+
...options.module ? { module: options.module } : {},
|
|
35276
|
+
...options.package ? { package: options.package } : {}
|
|
35277
|
+
};
|
|
35278
|
+
}
|
|
35279
|
+
var BRIDGE_DOCS_PATH = "user-guide/artifact-bridge.md", BRIDGE_DIAGNOSTICS, SUPPORTED_HOOK_NAMES, BridgeError;
|
|
35280
|
+
var init_diagnostics = __esm(() => {
|
|
35281
|
+
init_catalog();
|
|
35282
|
+
init_http_status_enum();
|
|
35283
|
+
BRIDGE_DIAGNOSTICS = {
|
|
35284
|
+
BRIDGE_FILE_NOT_FOUND: {
|
|
35285
|
+
severity: "error",
|
|
35286
|
+
message: "The configured artifacts bridge file was not found",
|
|
35287
|
+
action: "Create the file or fix `artifacts.bridge` in raiton.config.*."
|
|
35288
|
+
},
|
|
35289
|
+
BRIDGE_FILE_INVALID_EXPORT: {
|
|
35290
|
+
severity: "error",
|
|
35291
|
+
message: "The artifacts bridge does not export a valid definition",
|
|
35292
|
+
action: "Export `defineArtifactBridge({ artifacts: [...] })` as the default export."
|
|
35293
|
+
},
|
|
35294
|
+
BRIDGE_IMPORT_FAILED: {
|
|
35295
|
+
severity: "error",
|
|
35296
|
+
message: "The artifacts bridge module failed to load",
|
|
35297
|
+
action: "Fix the import error reported by the runtime, then retry."
|
|
35298
|
+
},
|
|
35299
|
+
BRIDGE_MODULE_NOT_FOUND: {
|
|
35300
|
+
severity: "error",
|
|
35301
|
+
message: "A bridge module specifier could not be resolved",
|
|
35302
|
+
action: "Check the package name, local path and that the dependency is installed."
|
|
35303
|
+
},
|
|
35304
|
+
BRIDGE_ENTRY_INVALID: {
|
|
35305
|
+
severity: "error",
|
|
35306
|
+
message: "A bridge entry is not a supported declaration",
|
|
35307
|
+
action: "Use a decorated class/function, a module specifier, a local path, or a middleware/hook/plugin descriptor."
|
|
35308
|
+
},
|
|
35309
|
+
BRIDGE_ARTIFACT_NOT_FOUND: {
|
|
35310
|
+
severity: "error",
|
|
35311
|
+
message: "The declared module does not expose a decorated artifact",
|
|
35312
|
+
action: "Export a decorated controller/socket/MCP/scheduler/injectable, or remove the entry."
|
|
35313
|
+
},
|
|
35314
|
+
BRIDGE_ARTIFACT_AMBIGUOUS: {
|
|
35315
|
+
severity: "error",
|
|
35316
|
+
message: "A bridge entry is ambiguous",
|
|
35317
|
+
action: "Decorate the class or use `{ middleware }`, `{ hook }` or `{ plugin }` explicitly."
|
|
35318
|
+
},
|
|
35319
|
+
BRIDGE_ARTIFACT_DUPLICATE: {
|
|
35320
|
+
severity: "info",
|
|
35321
|
+
message: "The same bridge artifact is declared more than once",
|
|
35322
|
+
action: "Remove the duplicate declaration; only the first one is mounted."
|
|
35323
|
+
},
|
|
35324
|
+
BRIDGE_NAME_COLLISION: {
|
|
35325
|
+
severity: "error",
|
|
35326
|
+
message: "Two different classes share the same injection name",
|
|
35327
|
+
action: 'Rename one class or use `@Injectable(lifetime, "unique:name")`.'
|
|
35328
|
+
},
|
|
35329
|
+
BRIDGE_ABI_MISMATCH: {
|
|
35330
|
+
severity: "error",
|
|
35331
|
+
message: "A package embeds an incompatible copy of Raiton",
|
|
35332
|
+
action: "Declare `raiton` in `peerDependencies`, remove it from `dependencies`, and rebuild the package."
|
|
35333
|
+
},
|
|
35334
|
+
BRIDGE_RUNTIME_UNSUPPORTED: {
|
|
35335
|
+
severity: "error",
|
|
35336
|
+
message: "The bridge entry cannot run on the current runtime",
|
|
35337
|
+
action: "Compile the package/file to JavaScript or use a runtime that supports TypeScript."
|
|
35338
|
+
},
|
|
35339
|
+
BRIDGE_NOT_BUNDLED: {
|
|
35340
|
+
severity: "error",
|
|
35341
|
+
message: "The artifacts bridge has not been compiled for this production runtime",
|
|
35342
|
+
action: "Run `raiton build` before `raiton start` or the inspection command."
|
|
35343
|
+
},
|
|
35344
|
+
BRIDGE_PACKAGE_FIELD_INVALID: {
|
|
35345
|
+
severity: "error",
|
|
35346
|
+
message: "A package declares an invalid `package.json#raiton.artifacts` field",
|
|
35347
|
+
action: "Use a string, an array of strings, or a bridge definition object."
|
|
35348
|
+
},
|
|
35349
|
+
BRIDGE_HOOK_UNKNOWN: {
|
|
35350
|
+
severity: "error",
|
|
35351
|
+
message: "A bridge hook name is not supported",
|
|
35352
|
+
action: "Use one of: onRequest, preParsing, preHandler, onSend, onResponse."
|
|
35353
|
+
},
|
|
35354
|
+
BRIDGE_DUPLICATE_MOUNT: {
|
|
35355
|
+
severity: "info",
|
|
35356
|
+
message: "The artifact was already mounted by the suffix scan",
|
|
35357
|
+
action: "Remove the bridge entry if the scan already covers the file."
|
|
35358
|
+
}
|
|
35359
|
+
};
|
|
35360
|
+
SUPPORTED_HOOK_NAMES = [
|
|
35361
|
+
"onRequest",
|
|
35362
|
+
"preParsing",
|
|
35363
|
+
"preHandler",
|
|
35364
|
+
"onSend",
|
|
35365
|
+
"onResponse"
|
|
35366
|
+
];
|
|
35367
|
+
for (const [code, definition] of Object.entries(BRIDGE_DIAGNOSTICS)) {
|
|
35368
|
+
if (ERROR_CATALOG[code])
|
|
35369
|
+
continue;
|
|
35370
|
+
ERROR_CATALOG[code] = {
|
|
35371
|
+
code,
|
|
35372
|
+
status: 500 /* INTERNAL_SERVER_ERROR */,
|
|
35373
|
+
message: definition.message,
|
|
35374
|
+
docsPath: BRIDGE_DOCS_PATH,
|
|
35375
|
+
hint: definition.action
|
|
35376
|
+
};
|
|
35377
|
+
}
|
|
35378
|
+
BridgeError = class BridgeError extends Error {
|
|
35379
|
+
code;
|
|
35380
|
+
diagnostic;
|
|
35381
|
+
entry;
|
|
35382
|
+
module;
|
|
35383
|
+
constructor(code, options = {}) {
|
|
35384
|
+
const diagnostic = bridgeDiagnostic(code, options);
|
|
35385
|
+
super(diagnostic.message);
|
|
35386
|
+
this.name = "BridgeError";
|
|
35387
|
+
this.code = code;
|
|
35388
|
+
this.diagnostic = diagnostic;
|
|
35389
|
+
this.entry = options.entry;
|
|
35390
|
+
this.module = options.module;
|
|
35391
|
+
}
|
|
35392
|
+
toJSON() {
|
|
35393
|
+
return {
|
|
35394
|
+
code: this.code,
|
|
35395
|
+
message: this.message,
|
|
35396
|
+
action: this.diagnostic.action,
|
|
35397
|
+
docsUrl: this.diagnostic.docsUrl,
|
|
35398
|
+
...this.diagnostic.location ? { location: this.diagnostic.location } : {},
|
|
35399
|
+
...this.diagnostic.entry ? { entry: this.diagnostic.entry } : {},
|
|
35400
|
+
...this.diagnostic.module ? { module: this.diagnostic.module } : {}
|
|
35401
|
+
};
|
|
35402
|
+
}
|
|
35403
|
+
};
|
|
35404
|
+
});
|
|
35405
|
+
|
|
35406
|
+
// source/core/bridge/resolver.ts
|
|
35407
|
+
import fs2 from "node:fs";
|
|
35408
|
+
import path4 from "node:path";
|
|
35409
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
35410
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
35411
|
+
function isLocalPathSpecifier(specifier) {
|
|
35412
|
+
return LOCAL_PATH_PATTERN.test(specifier);
|
|
35413
|
+
}
|
|
35414
|
+
function isRemoteSpecifier(specifier) {
|
|
35415
|
+
return REMOTE_URL_PATTERN.test(specifier);
|
|
35416
|
+
}
|
|
35417
|
+
function packageNameFromSpecifier(specifier) {
|
|
35418
|
+
if (!specifier || isLocalPathSpecifier(specifier) || isRemoteSpecifier(specifier))
|
|
35419
|
+
return;
|
|
35420
|
+
const segments = specifier.split("/");
|
|
35421
|
+
if (specifier.startsWith("@"))
|
|
35422
|
+
return segments.slice(0, 2).join("/");
|
|
35423
|
+
return segments[0];
|
|
35424
|
+
}
|
|
35425
|
+
function candidatesForLocal(base) {
|
|
35426
|
+
const extension = path4.extname(base).toLowerCase();
|
|
35427
|
+
if (SOURCE_EXTENSIONS.includes(extension)) {
|
|
35428
|
+
const stem = base.slice(0, -extension.length);
|
|
35429
|
+
return [...new Set([base, ...SOURCE_EXTENSIONS.map((candidate) => `${stem}${candidate}`)])];
|
|
35430
|
+
}
|
|
35431
|
+
return [...SOURCE_EXTENSIONS.map((candidate) => `${base}${candidate}`)];
|
|
35432
|
+
}
|
|
35433
|
+
function firstExisting(candidates) {
|
|
35434
|
+
for (const candidate of candidates) {
|
|
35435
|
+
try {
|
|
35436
|
+
if (fs2.existsSync(candidate) && fs2.statSync(candidate).isFile())
|
|
35437
|
+
return candidate;
|
|
35438
|
+
} catch {}
|
|
35439
|
+
}
|
|
35440
|
+
return null;
|
|
35441
|
+
}
|
|
35442
|
+
function resolveLocalModule(specifier, directories) {
|
|
35443
|
+
let raw = specifier;
|
|
35444
|
+
if (specifier.startsWith("file:")) {
|
|
35445
|
+
try {
|
|
35446
|
+
raw = new URL(specifier).pathname;
|
|
35447
|
+
} catch {
|
|
35448
|
+
return null;
|
|
35449
|
+
}
|
|
35450
|
+
}
|
|
35451
|
+
const bases = path4.isAbsolute(raw) ? [raw] : directories.filter(Boolean).map((directory) => path4.resolve(directory, raw));
|
|
35452
|
+
for (const base of bases) {
|
|
35453
|
+
const found = firstExisting(candidatesForLocal(base));
|
|
35454
|
+
if (found)
|
|
35455
|
+
return found;
|
|
35456
|
+
}
|
|
35457
|
+
return null;
|
|
35458
|
+
}
|
|
35459
|
+
function resolveBridgeModule(specifier, options) {
|
|
35460
|
+
if (!specifier || typeof specifier !== "string") {
|
|
35461
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
35462
|
+
message: "Bridge module specifier must be a non-empty string",
|
|
35463
|
+
entry: String(specifier)
|
|
35464
|
+
});
|
|
35465
|
+
}
|
|
35466
|
+
if (isRemoteSpecifier(specifier) && !specifier.startsWith("node:")) {
|
|
35467
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
35468
|
+
message: `Remote URL imports are not supported by the artifacts bridge: ${specifier}`,
|
|
35469
|
+
action: "Import from an installed package or a local file instead.",
|
|
35470
|
+
entry: specifier
|
|
35471
|
+
});
|
|
35472
|
+
}
|
|
35473
|
+
if (isLocalPathSpecifier(specifier)) {
|
|
35474
|
+
const found = resolveLocalModule(specifier, options.directories);
|
|
35475
|
+
if (!found) {
|
|
35476
|
+
throw new BridgeError("BRIDGE_MODULE_NOT_FOUND", {
|
|
35477
|
+
message: `Local bridge module was not found: ${specifier}`,
|
|
35478
|
+
location: options.directories.find(Boolean) ?? options.workdir,
|
|
35479
|
+
entry: specifier
|
|
35480
|
+
});
|
|
35481
|
+
}
|
|
35482
|
+
return { file: found, external: found.includes(`${path4.sep}node_modules${path4.sep}`) };
|
|
35483
|
+
}
|
|
35484
|
+
if (specifier.startsWith("node:")) {
|
|
35485
|
+
return { file: specifier, external: true };
|
|
35486
|
+
}
|
|
35487
|
+
const packageName = packageNameFromSpecifier(specifier);
|
|
35488
|
+
const requireFromProject = createRequire2(path4.join(options.workdir, "package.json"));
|
|
35489
|
+
try {
|
|
35490
|
+
const resolved = requireFromProject.resolve(specifier);
|
|
35491
|
+
return {
|
|
35492
|
+
file: resolved,
|
|
35493
|
+
package: packageName,
|
|
35494
|
+
external: resolved.includes(`${path4.sep}node_modules${path4.sep}`)
|
|
35495
|
+
};
|
|
35496
|
+
} catch {
|
|
35497
|
+
const found = resolveLocalModule(specifier, options.directories);
|
|
35498
|
+
if (found)
|
|
35499
|
+
return { file: found, package: packageName, external: false };
|
|
35500
|
+
throw new BridgeError("BRIDGE_MODULE_NOT_FOUND", {
|
|
35501
|
+
message: `Bridge module could not be resolved: ${specifier}`,
|
|
35502
|
+
action: packageName ? `Install \`${packageName}\` in the project or fix its package name.` : "Fix the module path or install the missing dependency.",
|
|
35503
|
+
entry: specifier,
|
|
35504
|
+
module: packageName
|
|
35505
|
+
});
|
|
35506
|
+
}
|
|
35507
|
+
}
|
|
35508
|
+
async function importBridgeModule(resolved, options = {}) {
|
|
35509
|
+
const url = resolved.file.startsWith("node:") ? resolved.file : pathToFileURL2(resolved.file).href;
|
|
35510
|
+
const href = options.cacheBust && !resolved.file.startsWith("node:") ? `${resolved.file}${resolved.file.includes("?") ? "&" : "?"}v=${Date.now()}&t=${Date.now()}` : url;
|
|
35511
|
+
try {
|
|
35512
|
+
return await import(href);
|
|
35513
|
+
} catch (error) {
|
|
35514
|
+
throw new BridgeError("BRIDGE_IMPORT_FAILED", {
|
|
35515
|
+
message: `Bridge module failed to load: ${resolved.file} (${error?.message ?? error})`,
|
|
35516
|
+
location: resolved.file,
|
|
35517
|
+
entry: resolved.file,
|
|
35518
|
+
module: resolved.package
|
|
35519
|
+
});
|
|
35520
|
+
}
|
|
35521
|
+
}
|
|
35522
|
+
function resolvePackageJson(packageName, workdir) {
|
|
35523
|
+
const requireFromProject = createRequire2(path4.join(workdir, "package.json"));
|
|
35524
|
+
try {
|
|
35525
|
+
return requireFromProject.resolve(`${packageName}/package.json`);
|
|
35526
|
+
} catch {
|
|
35527
|
+
const direct = path4.join(workdir, "node_modules", ...packageName.split("/"), "package.json");
|
|
35528
|
+
if (fs2.existsSync(direct))
|
|
35529
|
+
return direct;
|
|
35530
|
+
return null;
|
|
35531
|
+
}
|
|
35532
|
+
}
|
|
35533
|
+
function readJsonFile(filename) {
|
|
35534
|
+
return JSON.parse(fs2.readFileSync(filename, "utf-8"));
|
|
35535
|
+
}
|
|
35536
|
+
var LOCAL_PATH_PATTERN, REMOTE_URL_PATTERN, SOURCE_EXTENSIONS;
|
|
35537
|
+
var init_resolver = __esm(() => {
|
|
35538
|
+
init_diagnostics();
|
|
35539
|
+
LOCAL_PATH_PATTERN = /^(\.\.?\/|\/|file:)/;
|
|
35540
|
+
REMOTE_URL_PATTERN = /^(https?:|npm:|jsr:|data:|node:)/i;
|
|
35541
|
+
SOURCE_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs", ".tsx", ".jsx"];
|
|
35542
|
+
});
|
|
35543
|
+
|
|
35544
|
+
// source/core/directories.ts
|
|
35545
|
+
import path5 from "node:path";
|
|
35546
|
+
var RaitonDirectories;
|
|
35547
|
+
var init_directories = __esm(() => {
|
|
35548
|
+
init_config2();
|
|
35549
|
+
init_raiton();
|
|
35550
|
+
RaitonDirectories = class RaitonDirectories {
|
|
35551
|
+
static index = `.${Raiton.identifier}`;
|
|
35552
|
+
static bootstrapFile = "main.ts";
|
|
35553
|
+
static compiledBootstrapFile = "main.mjs";
|
|
35554
|
+
static caches(workdir) {
|
|
35555
|
+
return path5.join(workdir, this.index, "caches");
|
|
35556
|
+
}
|
|
35557
|
+
static artifacts(workdir) {
|
|
35558
|
+
return path5.join(workdir, this.index, "artifacts");
|
|
35559
|
+
}
|
|
35560
|
+
static server(workdir) {
|
|
35561
|
+
return path5.join(workdir, this.index, "server");
|
|
35562
|
+
}
|
|
35563
|
+
static root(workdir) {
|
|
35564
|
+
return path5.join(workdir, this.index);
|
|
35565
|
+
}
|
|
35566
|
+
static app() {
|
|
35567
|
+
return path5.join(Raiton.thread?.builder.workdir || "", RaitonConfig.get("rootDir") || "./");
|
|
35568
|
+
}
|
|
35569
|
+
};
|
|
35570
|
+
});
|
|
35571
|
+
|
|
35572
|
+
// source/core/bridge/paths.ts
|
|
35573
|
+
import fs3 from "node:fs";
|
|
35574
|
+
import path6 from "node:path";
|
|
35575
|
+
function candidatesFor(base) {
|
|
35576
|
+
const extension = path6.extname(base).toLowerCase();
|
|
35577
|
+
if (BRIDGE_EXTENSIONS.includes(extension)) {
|
|
35578
|
+
const stem = base.slice(0, -extension.length);
|
|
35579
|
+
return [...new Set([
|
|
35580
|
+
base,
|
|
35581
|
+
...BRIDGE_EXTENSIONS.map((candidate) => `${stem}${candidate}`)
|
|
35582
|
+
])];
|
|
35583
|
+
}
|
|
35584
|
+
return BRIDGE_EXTENSIONS.map((candidate) => `${base}${candidate}`);
|
|
35585
|
+
}
|
|
35586
|
+
function firstExisting2(candidates) {
|
|
35587
|
+
for (const candidate of candidates) {
|
|
35588
|
+
try {
|
|
35589
|
+
if (fs3.existsSync(candidate) && fs3.statSync(candidate).isFile())
|
|
35590
|
+
return candidate;
|
|
35591
|
+
} catch {}
|
|
35592
|
+
}
|
|
35593
|
+
return null;
|
|
35594
|
+
}
|
|
35595
|
+
function resolveBridgeSource(workdir = process.cwd()) {
|
|
35596
|
+
const rootDir = path6.resolve(workdir, RaitonConfig.get("rootDir") || "./");
|
|
35597
|
+
const configured = RaitonConfig.get("artifacts")?.bridge;
|
|
35598
|
+
if (configured === false) {
|
|
35599
|
+
return { file: null, workdir, rootDir, explicit: false, disabled: true, expected: null };
|
|
35600
|
+
}
|
|
35601
|
+
if (typeof configured === "string" && configured.trim()) {
|
|
35602
|
+
const absolute = path6.isAbsolute(configured) ? configured : null;
|
|
35603
|
+
const bases = absolute ? [absolute] : [...new Set([
|
|
35604
|
+
path6.resolve(workdir, configured),
|
|
35605
|
+
path6.resolve(rootDir, configured)
|
|
35606
|
+
])];
|
|
35607
|
+
const candidates = bases.flatMap(candidatesFor);
|
|
35608
|
+
return {
|
|
35609
|
+
file: firstExisting2(candidates),
|
|
35610
|
+
workdir,
|
|
35611
|
+
rootDir,
|
|
35612
|
+
explicit: true,
|
|
35613
|
+
disabled: false,
|
|
35614
|
+
expected: bases[0]
|
|
35615
|
+
};
|
|
35616
|
+
}
|
|
35617
|
+
const expected = path6.join(rootDir, BRIDGE_FILENAME);
|
|
35618
|
+
return {
|
|
35619
|
+
file: firstExisting2(candidatesFor(expected)),
|
|
35620
|
+
workdir,
|
|
35621
|
+
rootDir,
|
|
35622
|
+
explicit: false,
|
|
35623
|
+
disabled: false,
|
|
35624
|
+
expected: candidatesFor(expected)[0]
|
|
35625
|
+
};
|
|
35626
|
+
}
|
|
35627
|
+
function compiledBridgeFile(workdir = process.cwd()) {
|
|
35628
|
+
return path6.join(RaitonDirectories.server(workdir), COMPILED_BRIDGE_FILENAME);
|
|
35629
|
+
}
|
|
35630
|
+
function resolveRuntimeBridge(workdir = process.cwd()) {
|
|
35631
|
+
const source = resolveBridgeSource(workdir);
|
|
35632
|
+
if (isNodeUsed) {
|
|
35633
|
+
const compiled = compiledBridgeFile(workdir);
|
|
35634
|
+
if (fs3.existsSync(compiled)) {
|
|
35635
|
+
return {
|
|
35636
|
+
...source,
|
|
35637
|
+
file: source.file ?? compiled,
|
|
35638
|
+
runtimeFile: compiled,
|
|
35639
|
+
requiresCompiled: true
|
|
35640
|
+
};
|
|
35641
|
+
}
|
|
35642
|
+
}
|
|
35643
|
+
if (!source.file) {
|
|
35644
|
+
return { ...source, runtimeFile: null, requiresCompiled: isNodeUsed };
|
|
35645
|
+
}
|
|
35646
|
+
if (!isNodeUsed) {
|
|
35647
|
+
return { ...source, runtimeFile: source.file, requiresCompiled: false };
|
|
35648
|
+
}
|
|
35649
|
+
return {
|
|
35650
|
+
...source,
|
|
35651
|
+
runtimeFile: source.file,
|
|
35652
|
+
requiresCompiled: true
|
|
35653
|
+
};
|
|
35654
|
+
}
|
|
35655
|
+
function isSameFile(left, right) {
|
|
35656
|
+
if (!left || !right)
|
|
35657
|
+
return false;
|
|
35658
|
+
return path6.resolve(left) === path6.resolve(right);
|
|
35659
|
+
}
|
|
35660
|
+
function isWithin(parent, file) {
|
|
35661
|
+
const relative = path6.relative(path6.resolve(parent), path6.resolve(file));
|
|
35662
|
+
return relative !== "" && !relative.startsWith("..") && !path6.isAbsolute(relative);
|
|
35663
|
+
}
|
|
35664
|
+
function relativeTo(workdir, file) {
|
|
35665
|
+
if (!file)
|
|
35666
|
+
return;
|
|
35667
|
+
return path6.relative(workdir, file).split(path6.sep).join("/");
|
|
35668
|
+
}
|
|
35669
|
+
var BRIDGE_FILENAME = "artifacts.bridge", COMPILED_BRIDGE_FILENAME = "artifacts.bridge.mjs", BRIDGE_EXTENSIONS;
|
|
35670
|
+
var init_paths = __esm(() => {
|
|
35671
|
+
init_config();
|
|
35672
|
+
init_directories();
|
|
35673
|
+
init_constants2();
|
|
35674
|
+
BRIDGE_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
|
|
35675
|
+
});
|
|
35676
|
+
|
|
35677
|
+
// source/core/bridge/packages.ts
|
|
35678
|
+
import fs4 from "node:fs";
|
|
35679
|
+
import path7 from "node:path";
|
|
35680
|
+
function major(version) {
|
|
35681
|
+
if (!version)
|
|
35682
|
+
return null;
|
|
35683
|
+
const match = String(version).replace(/^[^\d]*/, "").match(/^(\d+)/);
|
|
35684
|
+
return match ? Number(match[1]) : null;
|
|
35685
|
+
}
|
|
35686
|
+
function directDependencies(packageJson) {
|
|
35687
|
+
return [...new Set([
|
|
35688
|
+
...Object.keys(packageJson?.dependencies ?? {}),
|
|
35689
|
+
...Object.keys(packageJson?.devDependencies ?? {})
|
|
35690
|
+
])].sort();
|
|
35691
|
+
}
|
|
35692
|
+
function isStringArray(value) {
|
|
35693
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.trim().length > 0);
|
|
35694
|
+
}
|
|
35695
|
+
function normalizeField(field) {
|
|
35696
|
+
if (typeof field === "string" && field.trim())
|
|
35697
|
+
return [field];
|
|
35698
|
+
if (isStringArray(field))
|
|
35699
|
+
return field;
|
|
35700
|
+
if (Array.isArray(field)) {
|
|
35701
|
+
const entries = field.filter((item) => typeof item === "string" || item && typeof item === "object" && Array.isArray(item.artifacts));
|
|
35702
|
+
return entries.length === field.length ? entries : null;
|
|
35703
|
+
}
|
|
35704
|
+
if (field && typeof field === "object" && Array.isArray(field.artifacts)) {
|
|
35705
|
+
return field.artifacts;
|
|
35706
|
+
}
|
|
35707
|
+
return null;
|
|
35708
|
+
}
|
|
35709
|
+
function discoverPackageArtifacts(workdir, options = {}) {
|
|
35710
|
+
const config = RaitonConfig.get("artifacts");
|
|
35711
|
+
const enabled = options.enabled ?? config?.packages ?? true;
|
|
35712
|
+
if (!enabled)
|
|
35713
|
+
return { packages: [], entries: [], diagnostics: [] };
|
|
35714
|
+
const packageFile = path7.join(workdir, "package.json");
|
|
35715
|
+
if (!fs4.existsSync(packageFile))
|
|
35716
|
+
return { packages: [], entries: [], diagnostics: [] };
|
|
35717
|
+
let projectPackage;
|
|
35718
|
+
try {
|
|
35719
|
+
projectPackage = readJsonFile(packageFile);
|
|
35720
|
+
} catch (error) {
|
|
35721
|
+
return {
|
|
35722
|
+
packages: [],
|
|
35723
|
+
entries: [],
|
|
35724
|
+
diagnostics: [bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
|
|
35725
|
+
message: `Cannot read project package.json: ${error?.message ?? error}`,
|
|
35726
|
+
location: packageFile
|
|
35727
|
+
})]
|
|
35728
|
+
};
|
|
35729
|
+
}
|
|
35730
|
+
const allowlist = options.allowlist ?? config?.packageAllowlist;
|
|
35731
|
+
const allowSet = allowlist?.length ? new Set(allowlist) : null;
|
|
35732
|
+
const dependencies = directDependencies(projectPackage).filter((name) => !allowSet || allowSet.has(name));
|
|
35733
|
+
const entries = [];
|
|
35734
|
+
const packages = [];
|
|
35735
|
+
const diagnostics = [];
|
|
35736
|
+
const hostMajor = major(package_default.version);
|
|
35737
|
+
for (const name of dependencies) {
|
|
35738
|
+
const packageJsonFile = resolvePackageJson(name, workdir);
|
|
35739
|
+
if (!packageJsonFile)
|
|
35740
|
+
continue;
|
|
35741
|
+
let packageJson;
|
|
35742
|
+
try {
|
|
35743
|
+
packageJson = readJsonFile(packageJsonFile);
|
|
35744
|
+
} catch (error) {
|
|
35745
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
|
|
35746
|
+
package: name,
|
|
35747
|
+
message: `Cannot read ${name}/package.json: ${error?.message ?? error}`,
|
|
35748
|
+
location: packageJsonFile
|
|
35749
|
+
}));
|
|
35750
|
+
continue;
|
|
35751
|
+
}
|
|
35752
|
+
const field = packageJson?.raiton?.artifacts;
|
|
35753
|
+
if (field === undefined)
|
|
35754
|
+
continue;
|
|
35755
|
+
const normalized = normalizeField(field);
|
|
35756
|
+
if (!normalized) {
|
|
35757
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
|
|
35758
|
+
package: name,
|
|
35759
|
+
message: `${name} declares an invalid package.json#raiton.artifacts field`,
|
|
35760
|
+
location: packageJsonFile
|
|
35761
|
+
}));
|
|
35762
|
+
continue;
|
|
35763
|
+
}
|
|
35764
|
+
const packageRoot = path7.dirname(packageJsonFile);
|
|
35765
|
+
packages.push(name);
|
|
35766
|
+
if (packageJson.dependencies?.raiton) {
|
|
35767
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
|
|
35768
|
+
package: name,
|
|
35769
|
+
message: `${name} embeds Raiton in dependencies instead of peerDependencies`,
|
|
35770
|
+
action: "Move `raiton` to peerDependencies and rebuild the package.",
|
|
35771
|
+
location: packageJsonFile
|
|
35772
|
+
}));
|
|
35773
|
+
}
|
|
35774
|
+
const peer = packageJson.peerDependencies?.raiton;
|
|
35775
|
+
const peerMajor = major(peer);
|
|
35776
|
+
if (peer && hostMajor !== null && peerMajor !== null && peerMajor !== hostMajor) {
|
|
35777
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
|
|
35778
|
+
package: name,
|
|
35779
|
+
message: `${name} targets Raiton ${peer}, host is ${package_default.version}`,
|
|
35780
|
+
action: "Align the package's raiton peerDependency with the host major version and rebuild it.",
|
|
35781
|
+
location: packageJsonFile
|
|
35782
|
+
}));
|
|
35783
|
+
}
|
|
35784
|
+
const nested = path7.join(packageRoot, "node_modules", "raiton", "package.json");
|
|
35785
|
+
if (fs4.existsSync(nested)) {
|
|
35786
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ABI_MISMATCH", {
|
|
35787
|
+
package: name,
|
|
35788
|
+
message: `${name} contains its own copy of Raiton`,
|
|
35789
|
+
action: "Remove the nested raiton copy and declare `raiton` as a peerDependency.",
|
|
35790
|
+
location: nested
|
|
35791
|
+
}));
|
|
35792
|
+
}
|
|
35793
|
+
for (const entry of normalized) {
|
|
35794
|
+
entries.push({
|
|
35795
|
+
entry,
|
|
35796
|
+
package: name,
|
|
35797
|
+
packageRoot,
|
|
35798
|
+
location: packageJsonFile,
|
|
35799
|
+
origin: "package"
|
|
35800
|
+
});
|
|
35801
|
+
}
|
|
35802
|
+
if (options.verbose) {
|
|
35803
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_PACKAGE_FIELD_INVALID", {
|
|
35804
|
+
severity: "info",
|
|
35805
|
+
package: name,
|
|
35806
|
+
message: `${name} declares ${normalized.length} bridge artifact(s)`,
|
|
35807
|
+
action: "No action required.",
|
|
35808
|
+
location: packageJsonFile
|
|
35809
|
+
}));
|
|
35810
|
+
}
|
|
35811
|
+
}
|
|
35812
|
+
return { packages, entries, diagnostics };
|
|
35813
|
+
}
|
|
35814
|
+
var init_packages = __esm(() => {
|
|
35815
|
+
init_config();
|
|
35816
|
+
init_diagnostics();
|
|
35817
|
+
init_resolver();
|
|
35818
|
+
init_package();
|
|
35819
|
+
});
|
|
35820
|
+
|
|
35821
|
+
// source/core/controller/tracker.ts
|
|
35822
|
+
function trackerKey(controllerName, origin = "scan", key) {
|
|
35823
|
+
if (key)
|
|
35824
|
+
return key;
|
|
35825
|
+
return origin === "bridge" ? `bridge:${controllerName}` : controllerName;
|
|
35826
|
+
}
|
|
35827
|
+
|
|
35828
|
+
class ControllerRouteTracker {
|
|
35829
|
+
static getRoutes(controllerName, origin = "scan", key) {
|
|
35830
|
+
return controllerRouteMap.get(trackerKey(controllerName, origin, key)) || [];
|
|
35831
|
+
}
|
|
35832
|
+
static setRoutes(controllerName, routes, origin = "scan", key) {
|
|
35833
|
+
controllerRouteMap.set(trackerKey(controllerName, origin, key), routes);
|
|
35834
|
+
}
|
|
35835
|
+
static removeRoutes(controllerName, router, origin = "scan", key) {
|
|
35836
|
+
const tracker = trackerKey(controllerName, origin, key);
|
|
35837
|
+
const routes = controllerRouteMap.get(tracker);
|
|
35838
|
+
if (!routes)
|
|
35839
|
+
return;
|
|
35840
|
+
for (const route of routes) {
|
|
35841
|
+
router.remove(route);
|
|
35842
|
+
}
|
|
35843
|
+
controllerRouteMap.delete(tracker);
|
|
35844
|
+
}
|
|
35845
|
+
static clear() {
|
|
35846
|
+
controllerRouteMap.clear();
|
|
35847
|
+
}
|
|
35848
|
+
static has(controllerName, origin = "scan", key) {
|
|
35849
|
+
return controllerRouteMap.has(trackerKey(controllerName, origin, key));
|
|
35850
|
+
}
|
|
35851
|
+
}
|
|
35852
|
+
var controllerRouteMap;
|
|
35853
|
+
var init_tracker2 = __esm(() => {
|
|
35854
|
+
controllerRouteMap = new Map;
|
|
35855
|
+
});
|
|
35856
|
+
|
|
35857
|
+
// source/core/artifact-mount.ts
|
|
35858
|
+
function kindForClassification(classification) {
|
|
35859
|
+
switch (classification.channel) {
|
|
35860
|
+
case "hmr:controller":
|
|
35861
|
+
return "controller";
|
|
35862
|
+
case "hmr:socket":
|
|
35863
|
+
return "socket";
|
|
35864
|
+
case "hmr:mcp":
|
|
35865
|
+
return "mcp";
|
|
35866
|
+
case "hmr:scheduler":
|
|
35867
|
+
return "scheduler";
|
|
35868
|
+
default:
|
|
35869
|
+
return "di";
|
|
35870
|
+
}
|
|
35871
|
+
}
|
|
35872
|
+
function isMountableClassification(classification) {
|
|
35873
|
+
return Boolean(classification) && [
|
|
35874
|
+
"hmr:controller",
|
|
35875
|
+
"hmr:socket",
|
|
35876
|
+
"hmr:mcp",
|
|
35877
|
+
"hmr:scheduler"
|
|
35878
|
+
].includes(classification.channel);
|
|
35879
|
+
}
|
|
35880
|
+
async function mountArtifact(construct, kind, application, options) {
|
|
35881
|
+
const name = construct.name || construct.constructor?.name || "AnonymousArtifact";
|
|
35882
|
+
if (kind === "di") {
|
|
35883
|
+
const adopted = Injection.adopt(construct);
|
|
35884
|
+
if (adopted.status === "collision" && options.strictInjectables) {
|
|
35885
|
+
const previousFile = adopted.existing ? Injection.getArtifactPath(adopted.name) : undefined;
|
|
35886
|
+
throw new BridgeError("BRIDGE_NAME_COLLISION", {
|
|
35887
|
+
message: `Injection name "${adopted.name}" is already used by another class`,
|
|
35888
|
+
action: 'Rename one of the classes or declare a unique name with @Injectable(lifetime, "vendor:name").',
|
|
35889
|
+
location: options.file ?? previousFile,
|
|
35890
|
+
entry: name
|
|
35891
|
+
});
|
|
35892
|
+
}
|
|
35893
|
+
if (options.file)
|
|
35894
|
+
Injection.registerArtifactPath(adopted.name || name, options.file);
|
|
35895
|
+
const record = {
|
|
35896
|
+
key: artifactKey({ kind, name: adopted.name || name, file: options.file, package: options.package }),
|
|
35897
|
+
name: adopted.name || name,
|
|
35898
|
+
kind,
|
|
35899
|
+
origin: options.origin,
|
|
35900
|
+
construct,
|
|
35901
|
+
...options.file ? { file: options.file } : {},
|
|
35902
|
+
...options.package ? { package: options.package } : {}
|
|
35903
|
+
};
|
|
35904
|
+
return ArtifactRegistry.add(record);
|
|
35905
|
+
}
|
|
35906
|
+
const adopted = Injection.adopt(construct);
|
|
35907
|
+
if (adopted.status === "collision" && options.strictInjectables) {
|
|
35908
|
+
throw new BridgeError("BRIDGE_NAME_COLLISION", {
|
|
35909
|
+
message: `Injection name "${adopted.name}" is already used by another class`,
|
|
35910
|
+
action: 'Rename one of the classes or declare a unique name with @Injectable(lifetime, "vendor:name").',
|
|
35911
|
+
location: options.file,
|
|
35912
|
+
entry: name
|
|
35913
|
+
});
|
|
35914
|
+
}
|
|
35915
|
+
if (options.file)
|
|
35916
|
+
Injection.registerArtifactPath(name, options.file);
|
|
35917
|
+
let routes;
|
|
35918
|
+
if (kind === "controller") {
|
|
35919
|
+
compileController(construct, application, {
|
|
35920
|
+
origin: options.origin === "scan" ? "scan" : "bridge",
|
|
35921
|
+
...options.origin === "scan" ? {} : { trackerKey: `bridge:${name}` }
|
|
35922
|
+
});
|
|
35923
|
+
routes = ControllerRouteTracker.getRoutes(name, options.origin === "scan" ? "scan" : "bridge", options.origin === "scan" ? undefined : `bridge:${name}`);
|
|
35924
|
+
} else if (kind === "socket") {
|
|
35925
|
+
compileSocket(construct);
|
|
35926
|
+
} else if (kind === "mcp") {
|
|
35927
|
+
compileMcp(construct);
|
|
35928
|
+
} else if (kind === "scheduler") {
|
|
35929
|
+
compileScheduler(construct);
|
|
35930
|
+
}
|
|
35931
|
+
const record = {
|
|
35932
|
+
key: artifactKey({ kind, name, file: options.file, package: options.package }),
|
|
35933
|
+
name,
|
|
35934
|
+
kind,
|
|
35935
|
+
origin: options.origin,
|
|
35936
|
+
construct,
|
|
35937
|
+
...options.file ? { file: options.file } : {},
|
|
35938
|
+
...options.package ? { package: options.package } : {},
|
|
35939
|
+
...routes ? { routes } : {}
|
|
35940
|
+
};
|
|
35941
|
+
return ArtifactRegistry.add(record);
|
|
35942
|
+
}
|
|
35943
|
+
var init_artifact_mount = __esm(async () => {
|
|
35944
|
+
init_injection();
|
|
35945
|
+
init_compiler();
|
|
35946
|
+
init_tracker2();
|
|
35947
|
+
init_builder();
|
|
35948
|
+
init_builder2();
|
|
35949
|
+
init_registry2();
|
|
35950
|
+
init_diagnostics();
|
|
35951
|
+
await init_builder3();
|
|
35952
|
+
});
|
|
35953
|
+
|
|
35954
|
+
// source/core/bridge/loader.ts
|
|
35955
|
+
import fs5 from "node:fs";
|
|
35956
|
+
import path8 from "node:path";
|
|
35957
|
+
function developmentMode(options) {
|
|
35958
|
+
if (options.development !== undefined)
|
|
35959
|
+
return options.development;
|
|
35960
|
+
const thread = Raiton.thread;
|
|
35961
|
+
return Boolean(RaitonConfig.get("develop") || thread?.builder?.options?.hmr || thread?.builder?.options?.serve || true);
|
|
35962
|
+
}
|
|
35963
|
+
function describeEntry(entry) {
|
|
35964
|
+
if (typeof entry === "string")
|
|
35965
|
+
return entry;
|
|
35966
|
+
if (typeof entry === "function")
|
|
35967
|
+
return entry.name || "anonymous function";
|
|
35968
|
+
if (entry && typeof entry === "object") {
|
|
35969
|
+
const kind = ["middleware", "hook", "plugin"].find((key) => (key in entry));
|
|
35970
|
+
if (kind)
|
|
35971
|
+
return `${kind}(${entry[kind]?.name ?? "anonymous"})`;
|
|
35972
|
+
return Object.keys(entry).join(",") || "object";
|
|
35973
|
+
}
|
|
35974
|
+
return String(entry);
|
|
35975
|
+
}
|
|
35976
|
+
var EMPTY_STATE, BridgeLoader;
|
|
35977
|
+
var init_loader = __esm(async () => {
|
|
35978
|
+
init_build3();
|
|
35979
|
+
init_injection();
|
|
35980
|
+
init_raiton();
|
|
35981
|
+
init_config();
|
|
35982
|
+
init_constants2();
|
|
35983
|
+
init_registry2();
|
|
35984
|
+
init_classifier();
|
|
35985
|
+
init_diagnostics();
|
|
35986
|
+
init_resolver();
|
|
35987
|
+
init_paths();
|
|
35988
|
+
init_packages();
|
|
35989
|
+
init_tracker2();
|
|
35990
|
+
init_tracker();
|
|
35991
|
+
init_metadata();
|
|
35992
|
+
init_metadata2();
|
|
35993
|
+
init_metadata4();
|
|
35994
|
+
init_manager();
|
|
35995
|
+
await init_artifact_mount();
|
|
35996
|
+
EMPTY_STATE = {
|
|
35997
|
+
descriptor: null,
|
|
35998
|
+
sourceFile: null,
|
|
35999
|
+
runtimeFile: null,
|
|
36000
|
+
loaded: false,
|
|
36001
|
+
disabled: false,
|
|
36002
|
+
missing: false,
|
|
36003
|
+
packages: [],
|
|
36004
|
+
artifacts: [],
|
|
36005
|
+
unresolved: [],
|
|
36006
|
+
diagnostics: [],
|
|
36007
|
+
localFiles: []
|
|
36008
|
+
};
|
|
36009
|
+
BridgeLoader = class BridgeLoader {
|
|
36010
|
+
static _state = { ...EMPTY_STATE };
|
|
36011
|
+
static get state() {
|
|
36012
|
+
return this._state;
|
|
36013
|
+
}
|
|
36014
|
+
static get current() {
|
|
36015
|
+
return this._state.descriptor;
|
|
36016
|
+
}
|
|
36017
|
+
static async reset() {
|
|
36018
|
+
this._state = { ...EMPTY_STATE };
|
|
36019
|
+
ArtifactRegistry.setExcludedFiles([]);
|
|
36020
|
+
}
|
|
36021
|
+
static async load(options = {}) {
|
|
36022
|
+
const workdir = options.workdir ?? process.cwd();
|
|
36023
|
+
const development = developmentMode(options);
|
|
36024
|
+
const resolution = resolveRuntimeBridge(workdir);
|
|
36025
|
+
this._state = {
|
|
36026
|
+
...EMPTY_STATE,
|
|
36027
|
+
sourceFile: resolution.file,
|
|
36028
|
+
runtimeFile: resolution.runtimeFile,
|
|
36029
|
+
disabled: resolution.disabled,
|
|
36030
|
+
missing: Boolean(resolution.explicit && !resolution.file)
|
|
36031
|
+
};
|
|
36032
|
+
const artifacts = [];
|
|
36033
|
+
const unresolved = [];
|
|
36034
|
+
const diagnostics = [];
|
|
36035
|
+
const seen = new Map;
|
|
36036
|
+
const logical = new Map;
|
|
36037
|
+
const register = (artifact) => {
|
|
36038
|
+
const identity = this.identityOf(artifact);
|
|
36039
|
+
const duplicate = seen.get(identity);
|
|
36040
|
+
if (duplicate) {
|
|
36041
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ARTIFACT_DUPLICATE", {
|
|
36042
|
+
entry: artifact.name,
|
|
36043
|
+
message: `Bridge artifact "${artifact.name}" is declared more than once`
|
|
36044
|
+
}));
|
|
36045
|
+
return;
|
|
36046
|
+
}
|
|
36047
|
+
const logicalKey = `${artifact.kind}|${artifact.name}|${artifact.package ?? ""}`;
|
|
36048
|
+
const existing = logical.get(logicalKey);
|
|
36049
|
+
if (existing) {
|
|
36050
|
+
if (existing.construct === artifact.construct) {
|
|
36051
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ARTIFACT_DUPLICATE", {
|
|
36052
|
+
entry: artifact.name,
|
|
36053
|
+
message: `Bridge artifact "${artifact.name}" is declared more than once`
|
|
36054
|
+
}));
|
|
36055
|
+
return;
|
|
36056
|
+
}
|
|
36057
|
+
if (existing.file && artifact.file && existing.file !== artifact.file) {
|
|
36058
|
+
throw new BridgeError("BRIDGE_NAME_COLLISION", {
|
|
36059
|
+
message: `Bridge artifact "${artifact.name}" is declared from two different files`,
|
|
36060
|
+
action: "Use a unique class name or remove the duplicate declaration.",
|
|
36061
|
+
location: artifact.file,
|
|
36062
|
+
entry: artifact.name,
|
|
36063
|
+
package: artifact.package
|
|
36064
|
+
});
|
|
36065
|
+
}
|
|
36066
|
+
if (!existing.file && artifact.file) {
|
|
36067
|
+
const index = artifacts.indexOf(existing);
|
|
36068
|
+
if (index !== -1)
|
|
36069
|
+
artifacts[index] = artifact;
|
|
36070
|
+
seen.delete(this.identityOf(existing));
|
|
36071
|
+
logical.set(logicalKey, artifact);
|
|
36072
|
+
seen.set(identity, artifact);
|
|
36073
|
+
return;
|
|
36074
|
+
}
|
|
36075
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_ARTIFACT_DUPLICATE", {
|
|
36076
|
+
entry: artifact.name,
|
|
36077
|
+
message: `Bridge artifact "${artifact.name}" is declared more than once`
|
|
36078
|
+
}));
|
|
36079
|
+
return;
|
|
36080
|
+
}
|
|
36081
|
+
seen.set(identity, artifact);
|
|
36082
|
+
logical.set(logicalKey, artifact);
|
|
36083
|
+
artifacts.push(artifact);
|
|
36084
|
+
};
|
|
36085
|
+
let definition = null;
|
|
36086
|
+
let runtimeFile = resolution.runtimeFile;
|
|
36087
|
+
let descriptorFile = null;
|
|
36088
|
+
let baseDirectories = [resolution.rootDir, workdir];
|
|
36089
|
+
if (!resolution.disabled && !resolution.file && resolution.explicit) {
|
|
36090
|
+
const message = `Configured artifacts bridge was not found: ${resolution.expected}`;
|
|
36091
|
+
if (development) {
|
|
36092
|
+
const diagnostic = bridgeDiagnostic("BRIDGE_FILE_NOT_FOUND", {
|
|
36093
|
+
severity: "warning",
|
|
36094
|
+
message,
|
|
36095
|
+
location: resolution.expected ?? workdir
|
|
36096
|
+
});
|
|
36097
|
+
diagnostics.push(diagnostic);
|
|
36098
|
+
Logger.warn(`[bridge] ${message}`);
|
|
36099
|
+
} else {
|
|
36100
|
+
throw new BridgeError("BRIDGE_FILE_NOT_FOUND", {
|
|
36101
|
+
message,
|
|
36102
|
+
location: resolution.expected ?? workdir,
|
|
36103
|
+
entry: resolution.expected ?? undefined
|
|
36104
|
+
});
|
|
36105
|
+
}
|
|
36106
|
+
} else if (!resolution.disabled && resolution.file) {
|
|
36107
|
+
if (isNodeUsed && !fs5.existsSync(compiledBridgeFile(workdir))) {
|
|
36108
|
+
throw new BridgeError("BRIDGE_NOT_BUNDLED", {
|
|
36109
|
+
message: `The artifacts bridge has not been compiled for Node.js: ${relativeTo(workdir, resolution.file)}`,
|
|
36110
|
+
location: resolution.file,
|
|
36111
|
+
entry: relativeTo(workdir, resolution.file),
|
|
36112
|
+
action: "Run `raiton build` first, then start the compiled application."
|
|
36113
|
+
});
|
|
36114
|
+
}
|
|
36115
|
+
runtimeFile = resolution.runtimeFile ?? resolution.file;
|
|
36116
|
+
descriptorFile = relativeTo(workdir, resolution.file) ?? resolution.file;
|
|
36117
|
+
baseDirectories = [path8.dirname(resolution.file), resolution.rootDir, workdir];
|
|
36118
|
+
const imported = await importBridgeModule({
|
|
36119
|
+
file: runtimeFile,
|
|
36120
|
+
package: undefined,
|
|
36121
|
+
external: runtimeFile.includes(`${path8.sep}node_modules${path8.sep}`)
|
|
36122
|
+
}, { cacheBust: Boolean(options.cacheBust && !isNodeUsed) });
|
|
36123
|
+
definition = this.definitionFrom(imported, runtimeFile);
|
|
36124
|
+
const context = {
|
|
36125
|
+
origin: "bridge",
|
|
36126
|
+
directories: baseDirectories,
|
|
36127
|
+
cacheBust: Boolean(options.cacheBust && !isNodeUsed),
|
|
36128
|
+
location: descriptorFile
|
|
36129
|
+
};
|
|
36130
|
+
const resolved = await this.resolveEntries(definition.artifacts, context, { diagnostics, unresolved });
|
|
36131
|
+
for (const artifact of resolved)
|
|
36132
|
+
register(artifact);
|
|
36133
|
+
}
|
|
36134
|
+
const packageDiscovery = discoverPackageArtifacts(workdir, {
|
|
36135
|
+
enabled: RaitonConfig.get("artifacts")?.packages ?? true,
|
|
36136
|
+
allowlist: RaitonConfig.get("artifacts")?.packageAllowlist,
|
|
36137
|
+
verbose: Boolean(RaitonConfig.get("verbose"))
|
|
36138
|
+
});
|
|
36139
|
+
diagnostics.push(...packageDiscovery.diagnostics);
|
|
36140
|
+
const fatal = packageDiscovery.diagnostics.find((diagnostic) => diagnostic.severity === "error");
|
|
36141
|
+
if (fatal) {
|
|
36142
|
+
throw new BridgeError(fatal.code, {
|
|
36143
|
+
message: fatal.message,
|
|
36144
|
+
action: fatal.action,
|
|
36145
|
+
location: fatal.location,
|
|
36146
|
+
package: fatal.package
|
|
36147
|
+
});
|
|
36148
|
+
}
|
|
36149
|
+
for (const entry of packageDiscovery.entries) {
|
|
36150
|
+
const packageContext = {
|
|
36151
|
+
origin: "package",
|
|
36152
|
+
package: entry.package,
|
|
36153
|
+
packageRoot: entry.packageRoot,
|
|
36154
|
+
directories: [entry.packageRoot, ...baseDirectories],
|
|
36155
|
+
cacheBust: Boolean(options.cacheBust && !isNodeUsed),
|
|
36156
|
+
location: entry.location
|
|
36157
|
+
};
|
|
36158
|
+
const packageResolved = await this.resolveEntries([entry.entry], packageContext, { diagnostics, unresolved });
|
|
36159
|
+
for (const artifact of packageResolved)
|
|
36160
|
+
register(artifact);
|
|
36161
|
+
}
|
|
36162
|
+
const localFiles = artifacts.map((artifact) => artifact.file).filter((file) => Boolean(file) && !file.includes(`${path8.sep}node_modules${path8.sep}`));
|
|
36163
|
+
ArtifactRegistry.setExcludedFiles(localFiles);
|
|
36164
|
+
const loaded = Boolean(definition) || artifacts.length > 0;
|
|
36165
|
+
this._state = {
|
|
36166
|
+
descriptor: definition && descriptorFile ? {
|
|
36167
|
+
file: descriptorFile,
|
|
36168
|
+
runtimeFile: relativeTo(workdir, runtimeFile),
|
|
36169
|
+
loaded: true,
|
|
36170
|
+
packages: packageDiscovery.packages,
|
|
36171
|
+
artifacts,
|
|
36172
|
+
unresolved,
|
|
36173
|
+
localFiles
|
|
36174
|
+
} : null,
|
|
36175
|
+
sourceFile: resolution.file,
|
|
36176
|
+
runtimeFile,
|
|
36177
|
+
loaded,
|
|
36178
|
+
disabled: resolution.disabled,
|
|
36179
|
+
missing: Boolean(resolution.explicit && !resolution.file),
|
|
36180
|
+
packages: packageDiscovery.packages,
|
|
36181
|
+
artifacts,
|
|
36182
|
+
unresolved,
|
|
36183
|
+
diagnostics,
|
|
36184
|
+
localFiles
|
|
36185
|
+
};
|
|
36186
|
+
if (loaded) {
|
|
36187
|
+
const summary = `[bridge] ${artifacts.length} artifact(s), ${packageDiscovery.packages.length} package(s), ${diagnostics.filter((d) => d.severity !== "info").length} warning(s)`;
|
|
36188
|
+
if (RaitonConfig.get("verbose"))
|
|
36189
|
+
Logger.info(summary);
|
|
36190
|
+
}
|
|
36191
|
+
return this._state;
|
|
36192
|
+
}
|
|
36193
|
+
static async mount(application) {
|
|
36194
|
+
if (!this._state.loaded)
|
|
36195
|
+
return this;
|
|
36196
|
+
this.adoptAll(this._state.artifacts);
|
|
36197
|
+
for (const artifact of this._state.artifacts) {
|
|
36198
|
+
await this.mountArtifact(artifact, application, true);
|
|
36199
|
+
}
|
|
36200
|
+
return this;
|
|
36201
|
+
}
|
|
36202
|
+
static async reload(options = {}) {
|
|
36203
|
+
const thread = Raiton.thread;
|
|
36204
|
+
const application = thread?.application;
|
|
36205
|
+
if (!application)
|
|
36206
|
+
return this._state;
|
|
36207
|
+
if (isNodeUsed) {
|
|
36208
|
+
thread?.restart?.();
|
|
36209
|
+
return this._state;
|
|
36210
|
+
}
|
|
36211
|
+
const previous = this._state;
|
|
36212
|
+
const previousArtifacts = [...previous.artifacts];
|
|
36213
|
+
let nextState;
|
|
36214
|
+
try {
|
|
36215
|
+
nextState = await this.load({ ...options, cacheBust: true, development: true });
|
|
36216
|
+
} catch (error) {
|
|
36217
|
+
this._state = previous;
|
|
36218
|
+
ArtifactRegistry.setExcludedFiles(previous.localFiles);
|
|
36219
|
+
throw error;
|
|
36220
|
+
}
|
|
36221
|
+
if (!nextState.loaded) {
|
|
36222
|
+
for (const artifact of previousArtifacts) {
|
|
36223
|
+
this.unmountArtifact(this.mountedRecord(artifact), application);
|
|
36224
|
+
}
|
|
36225
|
+
return nextState;
|
|
36226
|
+
}
|
|
36227
|
+
const previousByKey = new Map(previousArtifacts.map((artifact) => [this.stableKey(artifact), artifact]));
|
|
36228
|
+
const nextByKey = new Map(nextState.artifacts.map((artifact) => [this.stableKey(artifact), artifact]));
|
|
36229
|
+
const removed = [];
|
|
36230
|
+
const updated = [];
|
|
36231
|
+
for (const [key, previousArtifact] of previousByKey) {
|
|
36232
|
+
const nextArtifact = nextByKey.get(key);
|
|
36233
|
+
if (!nextArtifact) {
|
|
36234
|
+
removed.push(previousArtifact);
|
|
36235
|
+
continue;
|
|
36236
|
+
}
|
|
36237
|
+
if (this.identityOf(previousArtifact) !== this.identityOf(nextArtifact)) {
|
|
36238
|
+
updated.push(nextArtifact);
|
|
36239
|
+
}
|
|
36240
|
+
}
|
|
36241
|
+
for (const artifact of removed) {
|
|
36242
|
+
this.unmountArtifact(this.mountedRecord(artifact), application);
|
|
36243
|
+
}
|
|
36244
|
+
for (const artifact of updated) {
|
|
36245
|
+
this.unmountArtifact(this.mountedRecord(artifact), application);
|
|
36246
|
+
}
|
|
36247
|
+
for (const artifact of updated) {
|
|
36248
|
+
if (typeof artifact.construct === "function" && Injection.has(artifact.name)) {
|
|
36249
|
+
Injection.replace(artifact.name, artifact.construct);
|
|
36250
|
+
}
|
|
36251
|
+
}
|
|
36252
|
+
this.adoptAll(nextState.artifacts);
|
|
36253
|
+
const updatedKeys = new Set(updated.map((artifact) => this.stableKey(artifact)));
|
|
36254
|
+
for (const artifact of nextState.artifacts) {
|
|
36255
|
+
const key = this.stableKey(artifact);
|
|
36256
|
+
const previousArtifact = previousByKey.get(key);
|
|
36257
|
+
const changed = !previousArtifact || updatedKeys.has(key) || this.identityOf(previousArtifact) !== this.identityOf(artifact);
|
|
36258
|
+
if (changed)
|
|
36259
|
+
await this.mountArtifact(artifact, application, true);
|
|
36260
|
+
}
|
|
36261
|
+
if (RaitonConfig.get("verbose")) {
|
|
36262
|
+
Logger.info(`[bridge] reloaded: +${nextState.artifacts.length - previousArtifacts.length} -${removed.length} ~${updated.length}`);
|
|
36263
|
+
}
|
|
36264
|
+
return nextState;
|
|
36265
|
+
}
|
|
36266
|
+
static diagnose(workdir = process.cwd()) {
|
|
36267
|
+
const diagnostics = [];
|
|
36268
|
+
const resolution = resolveRuntimeBridge(workdir);
|
|
36269
|
+
if (typeof Reflect.getMetadata !== "function") {
|
|
36270
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_RUNTIME_UNSUPPORTED", {
|
|
36271
|
+
message: "reflect-metadata is not loaded in this runtime",
|
|
36272
|
+
action: "Import `reflect-metadata` at the top of the application entry point."
|
|
36273
|
+
}));
|
|
36274
|
+
}
|
|
36275
|
+
if (resolution.disabled)
|
|
36276
|
+
return diagnostics;
|
|
36277
|
+
if (resolution.explicit && !resolution.file) {
|
|
36278
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_FILE_NOT_FOUND", {
|
|
36279
|
+
location: resolution.expected ?? workdir
|
|
36280
|
+
}));
|
|
36281
|
+
} else if (resolution.file && isNodeUsed && !fs5.existsSync(compiledBridgeFile(workdir))) {
|
|
36282
|
+
diagnostics.push(bridgeDiagnostic("BRIDGE_NOT_BUNDLED", {
|
|
36283
|
+
location: resolution.file,
|
|
36284
|
+
entry: relativeTo(workdir, resolution.file)
|
|
36285
|
+
}));
|
|
36286
|
+
}
|
|
36287
|
+
const packageDiscovery = discoverPackageArtifacts(workdir, {
|
|
36288
|
+
enabled: RaitonConfig.get("artifacts")?.packages ?? true,
|
|
36289
|
+
allowlist: RaitonConfig.get("artifacts")?.packageAllowlist
|
|
36290
|
+
});
|
|
36291
|
+
diagnostics.push(...packageDiscovery.diagnostics);
|
|
36292
|
+
for (const diagnostic of this._state.diagnostics) {
|
|
36293
|
+
if (!diagnostics.some((existing) => existing.code === diagnostic.code && existing.message === diagnostic.message)) {
|
|
36294
|
+
diagnostics.push(diagnostic);
|
|
36295
|
+
}
|
|
36296
|
+
}
|
|
36297
|
+
return diagnostics;
|
|
36298
|
+
}
|
|
36299
|
+
static definitionFrom(imported, runtimeFile) {
|
|
36300
|
+
const candidate = imported?.default ?? imported;
|
|
36301
|
+
if (!candidate || typeof candidate !== "object" || !Array.isArray(candidate.artifacts)) {
|
|
36302
|
+
throw new BridgeError("BRIDGE_FILE_INVALID_EXPORT", {
|
|
36303
|
+
message: `The artifacts bridge must default-export defineArtifactBridge({ artifacts: [...] }) (${relativeTo(process.cwd(), runtimeFile) ?? runtimeFile})`,
|
|
36304
|
+
location: runtimeFile,
|
|
36305
|
+
entry: relativeTo(process.cwd(), runtimeFile)
|
|
36306
|
+
});
|
|
36307
|
+
}
|
|
36308
|
+
return {
|
|
36309
|
+
...candidate,
|
|
36310
|
+
artifacts: candidate.artifacts
|
|
36311
|
+
};
|
|
36312
|
+
}
|
|
36313
|
+
static async resolveEntries(entries, context, state, depth = 0) {
|
|
36314
|
+
if (depth > 8) {
|
|
36315
|
+
throw new BridgeError("BRIDGE_FILE_INVALID_EXPORT", {
|
|
36316
|
+
message: "Bridge definitions are nested too deeply",
|
|
36317
|
+
location: context.location
|
|
36318
|
+
});
|
|
36319
|
+
}
|
|
36320
|
+
const output = [];
|
|
36321
|
+
for (const entry of entries) {
|
|
36322
|
+
if (typeof entry === "string") {
|
|
36323
|
+
output.push(...await this.resolveModuleEntry(entry, context, state, depth));
|
|
36324
|
+
continue;
|
|
36325
|
+
}
|
|
36326
|
+
if (typeof entry === "function") {
|
|
36327
|
+
const classified = classifyConstruct(entry);
|
|
36328
|
+
if (!classified) {
|
|
36329
|
+
throw new BridgeError("BRIDGE_ARTIFACT_AMBIGUOUS", {
|
|
36330
|
+
message: `Bridge entry "${entry.name || "anonymous"}" is a function without artifact metadata or descriptor`,
|
|
36331
|
+
action: "Decorate the class, or declare it as `{ middleware }`, `{ hook }` or `{ plugin }`.",
|
|
36332
|
+
location: context.location,
|
|
36333
|
+
entry: entry.name || "anonymous"
|
|
36334
|
+
});
|
|
36335
|
+
}
|
|
36336
|
+
output.push({
|
|
36337
|
+
name: classified.name,
|
|
36338
|
+
kind: classified.kind,
|
|
36339
|
+
construct: entry,
|
|
36340
|
+
origin: context.origin,
|
|
36341
|
+
...context.package ? { package: context.package } : {},
|
|
36342
|
+
...this.fileForConstruct(entry) ? { file: this.fileForConstruct(entry) } : {}
|
|
36343
|
+
});
|
|
36344
|
+
continue;
|
|
36345
|
+
}
|
|
36346
|
+
if (entry && typeof entry === "object") {
|
|
36347
|
+
if (isBridgeDefinition(entry)) {
|
|
36348
|
+
output.push(...await this.resolveEntries(entry.artifacts, context, state, depth + 1));
|
|
36349
|
+
continue;
|
|
36350
|
+
}
|
|
36351
|
+
output.push(this.resolveDescriptor(entry, context));
|
|
36352
|
+
continue;
|
|
36353
|
+
}
|
|
36354
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
36355
|
+
message: `Unsupported bridge entry: ${describeEntry(entry)}`,
|
|
36356
|
+
action: "Use a decorated class/function, a module specifier, a local path, or a middleware/hook/plugin descriptor.",
|
|
36357
|
+
location: context.location,
|
|
36358
|
+
entry: describeEntry(entry)
|
|
36359
|
+
});
|
|
36360
|
+
}
|
|
36361
|
+
return output;
|
|
36362
|
+
}
|
|
36363
|
+
static async resolveModuleEntry(specifier, context, state, depth) {
|
|
36364
|
+
const resolved = resolveBridgeModule(specifier, {
|
|
36365
|
+
directories: context.directories,
|
|
36366
|
+
workdir: context.directories[context.directories.length - 1] ?? process.cwd()
|
|
36367
|
+
});
|
|
36368
|
+
if (resolved.file.startsWith("node:")) {
|
|
36369
|
+
throw new BridgeError("BRIDGE_MODULE_NOT_FOUND", {
|
|
36370
|
+
message: `Runtime builtins cannot expose bridge artifacts: ${specifier}`,
|
|
36371
|
+
entry: specifier,
|
|
36372
|
+
module: specifier
|
|
36373
|
+
});
|
|
36374
|
+
}
|
|
36375
|
+
if (isNodeUsed && /\.(ts|mts|cts|tsx)$/i.test(resolved.file)) {
|
|
36376
|
+
throw new BridgeError("BRIDGE_RUNTIME_UNSUPPORTED", {
|
|
36377
|
+
message: `Bridge local entry is TypeScript but the current runtime cannot import it: ${specifier}`,
|
|
36378
|
+
action: "Import the class directly in the bridge (recommended) or compile the file to JavaScript.",
|
|
36379
|
+
location: resolved.file,
|
|
36380
|
+
entry: specifier
|
|
36381
|
+
});
|
|
36382
|
+
}
|
|
36383
|
+
if (isLocalPathSpecifier(specifier) || !resolved.external) {
|
|
36384
|
+
ArtifactRegistry.excludeFile(resolved.file);
|
|
36385
|
+
context = {
|
|
36386
|
+
...context,
|
|
36387
|
+
directories: [...context.directories, path8.dirname(resolved.file)]
|
|
36388
|
+
};
|
|
36389
|
+
}
|
|
36390
|
+
const imported = await importBridgeModule(resolved, {
|
|
36391
|
+
cacheBust: Boolean(context.cacheBust && !resolved.external)
|
|
36392
|
+
});
|
|
36393
|
+
const candidate = imported?.default ?? imported;
|
|
36394
|
+
if (isBridgeDefinition(candidate)) {
|
|
36395
|
+
return this.resolveEntries(candidate.artifacts, {
|
|
36396
|
+
...context,
|
|
36397
|
+
location: resolved.file,
|
|
36398
|
+
...resolved.package ? { package: resolved.package } : {}
|
|
36399
|
+
}, state, depth + 1);
|
|
36400
|
+
}
|
|
36401
|
+
const artifacts = resolveArtifacts(imported);
|
|
36402
|
+
if (!artifacts.length) {
|
|
36403
|
+
throw new BridgeError("BRIDGE_ARTIFACT_NOT_FOUND", {
|
|
36404
|
+
message: `Module "${specifier}" exposes no decorated artifact (exports: ${exportNames(imported).join(", ") || "none"})`,
|
|
36405
|
+
action: "Export a decorated controller/socket/MCP/scheduler/injectable, or remove the entry.",
|
|
36406
|
+
location: resolved.file,
|
|
36407
|
+
entry: specifier,
|
|
36408
|
+
module: resolved.package ?? specifier
|
|
36409
|
+
});
|
|
36410
|
+
}
|
|
36411
|
+
const packageName = context.package ?? resolved.package ?? packageNameFromSpecifier(specifier);
|
|
36412
|
+
return artifacts.map((artifact) => ({
|
|
36413
|
+
name: artifact.name,
|
|
36414
|
+
kind: artifact.kind,
|
|
36415
|
+
construct: artifact.construct,
|
|
36416
|
+
origin: context.origin,
|
|
36417
|
+
...packageName ? { package: packageName } : {},
|
|
36418
|
+
file: resolved.file
|
|
36419
|
+
}));
|
|
36420
|
+
}
|
|
36421
|
+
static resolveDescriptor(entry, context) {
|
|
36422
|
+
const keys = ["plugin", "middleware", "hook"].filter((key) => (key in entry));
|
|
36423
|
+
if (keys.length !== 1) {
|
|
36424
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
36425
|
+
message: `Ambiguous bridge descriptor: expected exactly one of middleware, hook or plugin (${describeEntry(entry)})`,
|
|
36426
|
+
action: "Declare `{ middleware }`, `{ hook, handler }` or `{ plugin }`.",
|
|
36427
|
+
location: context.location,
|
|
36428
|
+
entry: describeEntry(entry)
|
|
36429
|
+
});
|
|
36430
|
+
}
|
|
36431
|
+
if (keys[0] === "plugin") {
|
|
36432
|
+
const descriptor = entry;
|
|
36433
|
+
if (!descriptor.plugin || typeof descriptor.plugin !== "object" || typeof descriptor.plugin.setup !== "function") {
|
|
36434
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
36435
|
+
message: "A plugin descriptor requires an object with a `setup` function",
|
|
36436
|
+
action: "Pass `{ plugin: myPlugin }`.",
|
|
36437
|
+
location: context.location,
|
|
36438
|
+
entry: "plugin"
|
|
36439
|
+
});
|
|
36440
|
+
}
|
|
36441
|
+
return {
|
|
36442
|
+
name: descriptor.name || descriptor.plugin.name || "plugin",
|
|
36443
|
+
kind: "plugin",
|
|
36444
|
+
plugin: descriptor.plugin,
|
|
36445
|
+
origin: context.origin,
|
|
36446
|
+
...context.package ? { package: context.package } : {}
|
|
36447
|
+
};
|
|
36448
|
+
}
|
|
36449
|
+
if (keys[0] === "hook") {
|
|
36450
|
+
const descriptor = entry;
|
|
36451
|
+
if (!SUPPORTED_HOOK_NAMES.includes(descriptor.hook)) {
|
|
36452
|
+
throw new BridgeError("BRIDGE_HOOK_UNKNOWN", {
|
|
36453
|
+
message: `Unsupported bridge hook "${String(descriptor.hook)}"`,
|
|
36454
|
+
action: `Use one of: ${SUPPORTED_HOOK_NAMES.join(", ")}.`,
|
|
36455
|
+
location: context.location,
|
|
36456
|
+
entry: String(descriptor.hook)
|
|
36457
|
+
});
|
|
36458
|
+
}
|
|
36459
|
+
if (typeof descriptor.handler !== "function") {
|
|
36460
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
36461
|
+
message: "A hook descriptor requires a `handler` function",
|
|
36462
|
+
action: 'Pass `{ hook: "onRequest", handler: myHook }`.',
|
|
36463
|
+
location: context.location,
|
|
36464
|
+
entry: "hook"
|
|
36465
|
+
});
|
|
36466
|
+
}
|
|
36467
|
+
return {
|
|
36468
|
+
name: descriptor.name || descriptor.handler.name || `bridge-${descriptor.hook}`,
|
|
36469
|
+
kind: "hook",
|
|
36470
|
+
hook: descriptor.hook,
|
|
36471
|
+
handler: descriptor.handler,
|
|
36472
|
+
origin: context.origin,
|
|
36473
|
+
...context.package ? { package: context.package } : {}
|
|
36474
|
+
};
|
|
36475
|
+
}
|
|
36476
|
+
const descriptor = entry;
|
|
36477
|
+
const middleware = descriptor.middleware;
|
|
36478
|
+
if (typeof middleware !== "function" && (typeof middleware !== "object" || middleware === null)) {
|
|
36479
|
+
throw new BridgeError("BRIDGE_ENTRY_INVALID", {
|
|
36480
|
+
message: "A middleware descriptor requires a function, class or middleware object",
|
|
36481
|
+
action: "Pass `{ middleware: myMiddleware }`.",
|
|
36482
|
+
location: context.location,
|
|
36483
|
+
entry: "middleware"
|
|
36484
|
+
});
|
|
36485
|
+
}
|
|
36486
|
+
return {
|
|
36487
|
+
name: descriptor.name || middleware.name || "middleware",
|
|
36488
|
+
kind: "middleware",
|
|
36489
|
+
...isClass2(middleware) ? { construct: middleware } : { middleware },
|
|
36490
|
+
origin: context.origin,
|
|
36491
|
+
...context.package ? { package: context.package } : {}
|
|
36492
|
+
};
|
|
36493
|
+
}
|
|
36494
|
+
static adoptAll(artifacts) {
|
|
36495
|
+
for (const artifact of artifacts) {
|
|
36496
|
+
if (typeof artifact.construct !== "function")
|
|
36497
|
+
continue;
|
|
36498
|
+
const adopted = Injection.adopt(artifact.construct);
|
|
36499
|
+
if (adopted.status === "collision") {
|
|
36500
|
+
const previousFile = adopted.existing ? Injection.getArtifactPath(adopted.name) : undefined;
|
|
36501
|
+
throw new BridgeError("BRIDGE_NAME_COLLISION", {
|
|
36502
|
+
message: `Injection name "${adopted.name}" is already used by another class (${artifact.name})`,
|
|
36503
|
+
action: 'Rename one class or declare a unique name with @Injectable(lifetime, "vendor:name").',
|
|
36504
|
+
location: artifact.file ?? previousFile,
|
|
36505
|
+
entry: artifact.name,
|
|
36506
|
+
package: artifact.package
|
|
36507
|
+
});
|
|
36508
|
+
}
|
|
36509
|
+
}
|
|
36510
|
+
}
|
|
36511
|
+
static async mountArtifact(artifact, application, strict) {
|
|
36512
|
+
const root = application.root;
|
|
36513
|
+
if (artifact.kind === "plugin") {
|
|
36514
|
+
if (artifact.plugin)
|
|
36515
|
+
application.register(artifact.plugin);
|
|
36516
|
+
ArtifactRegistry.add({
|
|
36517
|
+
key: artifactKey({ kind: "plugin", name: artifact.name, file: artifact.file, package: artifact.package }),
|
|
36518
|
+
name: artifact.name,
|
|
36519
|
+
kind: "plugin",
|
|
36520
|
+
origin: artifact.origin,
|
|
36521
|
+
pluginName: artifact.name,
|
|
36522
|
+
...artifact.file ? { file: artifact.file } : {},
|
|
36523
|
+
...artifact.package ? { package: artifact.package } : {}
|
|
36524
|
+
});
|
|
36525
|
+
return;
|
|
36526
|
+
}
|
|
36527
|
+
if (artifact.kind === "middleware") {
|
|
36528
|
+
const pipeline = root?.middleware;
|
|
36529
|
+
if (!pipeline)
|
|
36530
|
+
return;
|
|
36531
|
+
const instance = this.middlewareInstance(artifact);
|
|
36532
|
+
if (this.hasMiddleware(pipeline, artifact.name, instance)) {
|
|
36533
|
+
this._state.diagnostics.push(bridgeDiagnostic("BRIDGE_DUPLICATE_MOUNT", {
|
|
36534
|
+
entry: artifact.name,
|
|
36535
|
+
message: `Middleware "${artifact.name}" is already registered`
|
|
36536
|
+
}));
|
|
36537
|
+
return;
|
|
36538
|
+
}
|
|
36539
|
+
pipeline.use(instance);
|
|
36540
|
+
ArtifactRegistry.add({
|
|
36541
|
+
key: artifactKey({ kind: "middleware", name: artifact.name, file: artifact.file, package: artifact.package }),
|
|
36542
|
+
name: artifact.name,
|
|
36543
|
+
kind: "middleware",
|
|
36544
|
+
origin: artifact.origin,
|
|
36545
|
+
construct: artifact.construct,
|
|
36546
|
+
middlewareName: artifact.name,
|
|
36547
|
+
handler: instance,
|
|
36548
|
+
...artifact.file ? { file: artifact.file } : {},
|
|
36549
|
+
...artifact.package ? { package: artifact.package } : {}
|
|
36550
|
+
});
|
|
36551
|
+
return;
|
|
36552
|
+
}
|
|
36553
|
+
if (artifact.kind === "hook") {
|
|
36554
|
+
const hooks = root?.hooks;
|
|
36555
|
+
if (!hooks || !artifact.hook || !artifact.handler)
|
|
36556
|
+
return;
|
|
36557
|
+
if (hooks.hasHandler?.(artifact.hook, artifact.handler)) {
|
|
36558
|
+
this._state.diagnostics.push(bridgeDiagnostic("BRIDGE_DUPLICATE_MOUNT", {
|
|
36559
|
+
entry: artifact.name,
|
|
36560
|
+
message: `Hook "${artifact.hook}" handler is already registered`
|
|
36561
|
+
}));
|
|
36562
|
+
return;
|
|
36563
|
+
}
|
|
36564
|
+
hooks.add(artifact.hook, artifact.handler);
|
|
36565
|
+
ArtifactRegistry.add({
|
|
36566
|
+
key: artifactKey({ kind: "hook", name: artifact.name, file: artifact.file, package: artifact.package }),
|
|
36567
|
+
name: artifact.name,
|
|
36568
|
+
kind: "hook",
|
|
36569
|
+
origin: artifact.origin,
|
|
36570
|
+
hookName: artifact.hook,
|
|
36571
|
+
handler: artifact.handler,
|
|
36572
|
+
...artifact.file ? { file: artifact.file } : {},
|
|
36573
|
+
...artifact.package ? { package: artifact.package } : {}
|
|
36574
|
+
});
|
|
36575
|
+
return;
|
|
36576
|
+
}
|
|
36577
|
+
const construct = artifact.construct;
|
|
36578
|
+
if (typeof construct !== "function") {
|
|
36579
|
+
throw new BridgeError("BRIDGE_ARTIFACT_NOT_FOUND", {
|
|
36580
|
+
message: `Bridge artifact "${artifact.name}" has no construct and cannot be mounted`,
|
|
36581
|
+
entry: artifact.name,
|
|
36582
|
+
location: artifact.file
|
|
36583
|
+
});
|
|
36584
|
+
}
|
|
36585
|
+
if (ArtifactRegistry.hasConstruct(construct)) {
|
|
36586
|
+
this._state.diagnostics.push(bridgeDiagnostic("BRIDGE_DUPLICATE_MOUNT", {
|
|
36587
|
+
entry: artifact.name,
|
|
36588
|
+
message: `Artifact "${artifact.name}" is already mounted`
|
|
36589
|
+
}));
|
|
36590
|
+
return;
|
|
36591
|
+
}
|
|
36592
|
+
await mountArtifact(construct, artifact.kind, application, {
|
|
36593
|
+
origin: artifact.origin,
|
|
36594
|
+
file: artifact.file,
|
|
36595
|
+
package: artifact.package,
|
|
36596
|
+
strictInjectables: strict
|
|
36597
|
+
});
|
|
36598
|
+
}
|
|
36599
|
+
static unmountArtifact(record, application) {
|
|
36600
|
+
if (!record)
|
|
36601
|
+
return;
|
|
36602
|
+
const root = application.root;
|
|
36603
|
+
if (record.kind === "controller") {
|
|
36604
|
+
ControllerRouteTracker.removeRoutes(record.name, root?.router, "bridge", `bridge:${record.name}`);
|
|
36605
|
+
Injection.invalidateCascade(record.name);
|
|
36606
|
+
} else if (record.kind === "mcp") {
|
|
36607
|
+
McpRouteTracker.removeRoutes(record.name, root?.router);
|
|
36608
|
+
unregisterMcpServer(record.name);
|
|
36609
|
+
Injection.invalidateCascade(record.name);
|
|
36610
|
+
} else if (record.kind === "socket") {
|
|
36611
|
+
const metadata = record.construct ? getSocketMetadata(record.construct.prototype ?? record.construct) : undefined;
|
|
36612
|
+
if (metadata?.namespace)
|
|
36613
|
+
unregisterSocket(metadata.namespace);
|
|
36614
|
+
Injection.invalidateCascade(record.name);
|
|
36615
|
+
} else if (record.kind === "scheduler") {
|
|
36616
|
+
unregisterScheduler(record.name);
|
|
36617
|
+
const metadata = record.construct ? getSchedulerMetadata(record.construct.prototype ?? record.construct) : undefined;
|
|
36618
|
+
if (metadata?.jobs?.length) {
|
|
36619
|
+
SchedulerManager.current.unregister?.(metadata.jobs.map((job) => job.name));
|
|
36620
|
+
}
|
|
36621
|
+
Injection.invalidateCascade(record.name);
|
|
36622
|
+
} else if (record.kind === "middleware") {
|
|
36623
|
+
if (record.handler) {
|
|
36624
|
+
root?.middleware?.remove(record.handler);
|
|
36625
|
+
} else if (record.middlewareName) {
|
|
36626
|
+
root?.middleware?.remove(record.middlewareName);
|
|
36627
|
+
}
|
|
36628
|
+
} else if (record.kind === "hook") {
|
|
36629
|
+
if (record.hookName && record.handler)
|
|
36630
|
+
root?.hooks?.remove(record.hookName, record.handler);
|
|
36631
|
+
} else if (record.kind === "di") {
|
|
36632
|
+
const definition = Injection.definition(record.name);
|
|
36633
|
+
if (definition?.construct === record.construct) {
|
|
36634
|
+
Injection.unregister(record.name);
|
|
36635
|
+
} else {
|
|
36636
|
+
Injection.invalidateCascade(record.name);
|
|
36637
|
+
}
|
|
36638
|
+
}
|
|
36639
|
+
ArtifactRegistry.remove(record.key);
|
|
36640
|
+
}
|
|
36641
|
+
static mountedRecord(artifact) {
|
|
36642
|
+
return ArtifactRegistry.getByKey(this.stableKey(artifact));
|
|
36643
|
+
}
|
|
36644
|
+
static stableKey(artifact) {
|
|
36645
|
+
return artifactKey({
|
|
36646
|
+
kind: artifact.kind,
|
|
36647
|
+
name: artifact.name,
|
|
36648
|
+
file: artifact.file,
|
|
36649
|
+
package: artifact.package
|
|
36650
|
+
});
|
|
36651
|
+
}
|
|
36652
|
+
static identityOf(artifact) {
|
|
36653
|
+
return artifact.construct ?? artifact.handler ?? artifact.plugin ?? artifact.middleware ?? artifact.name;
|
|
36654
|
+
}
|
|
36655
|
+
static fileForConstruct(construct) {
|
|
36656
|
+
if (typeof construct !== "function")
|
|
36657
|
+
return;
|
|
36658
|
+
return Injection.getArtifactPath(construct.name);
|
|
36659
|
+
}
|
|
36660
|
+
static middlewareInstance(artifact) {
|
|
36661
|
+
const candidate = artifact.construct ?? artifact.middleware;
|
|
36662
|
+
if (artifact.construct && isClass2(artifact.construct)) {
|
|
36663
|
+
try {
|
|
36664
|
+
return Injection.resolve(artifact.construct);
|
|
36665
|
+
} catch {
|
|
36666
|
+
return new artifact.construct;
|
|
36667
|
+
}
|
|
36668
|
+
}
|
|
36669
|
+
return candidate;
|
|
36670
|
+
}
|
|
36671
|
+
static hasMiddleware(pipeline, name, instance) {
|
|
36672
|
+
if (pipeline.has?.(instance))
|
|
36673
|
+
return true;
|
|
36674
|
+
if (name && pipeline.hasName?.(name))
|
|
36675
|
+
return true;
|
|
36676
|
+
return false;
|
|
36677
|
+
}
|
|
36678
|
+
};
|
|
36679
|
+
});
|
|
36680
|
+
|
|
36681
|
+
// source/manifest/manifest.ts
|
|
36682
|
+
import fs6 from "node:fs";
|
|
36683
|
+
import path9 from "node:path";
|
|
34920
36684
|
function invalidateManifest() {
|
|
34921
36685
|
cachedManifest = null;
|
|
34922
36686
|
cachedWorkdir = null;
|
|
@@ -34929,10 +36693,10 @@ function describeType(value) {
|
|
|
34929
36693
|
return typeof value;
|
|
34930
36694
|
}
|
|
34931
36695
|
function resolveRoot(workdir) {
|
|
34932
|
-
return
|
|
36696
|
+
return path9.resolve(workdir, RaitonConfig.get("rootDir") || "./");
|
|
34933
36697
|
}
|
|
34934
36698
|
function relative(workdir, filename) {
|
|
34935
|
-
return
|
|
36699
|
+
return path9.relative(workdir, filename).split(path9.sep).join("/");
|
|
34936
36700
|
}
|
|
34937
36701
|
function schemaName(schema) {
|
|
34938
36702
|
if (!schema)
|
|
@@ -34941,9 +36705,9 @@ function schemaName(schema) {
|
|
|
34941
36705
|
}
|
|
34942
36706
|
function routeLine(filename, propertyKey) {
|
|
34943
36707
|
try {
|
|
34944
|
-
if (!filename || !
|
|
36708
|
+
if (!filename || !fs6.existsSync(filename))
|
|
34945
36709
|
return 0;
|
|
34946
|
-
const lines =
|
|
36710
|
+
const lines = fs6.readFileSync(filename, "utf-8").split(/\r?\n/);
|
|
34947
36711
|
const pattern = new RegExp(`\\b${propertyKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*\\(`);
|
|
34948
36712
|
const index = lines.findIndex((line) => pattern.test(line));
|
|
34949
36713
|
return index >= 0 ? index + 1 : 0;
|
|
@@ -34983,6 +36747,7 @@ function buildRoutes(workdir) {
|
|
|
34983
36747
|
const controllerName = controllerClass?.name ?? "Controller";
|
|
34984
36748
|
const file = Injection.getArtifactPath(controllerName) ?? "";
|
|
34985
36749
|
const contract = routeContracts(route.handler, controllerClass, routeMeta.propertyKey);
|
|
36750
|
+
const ownership = ArtifactRegistry.routeInfo(route);
|
|
34986
36751
|
const inputSchema = contract?.input && !isCompositeInput(contract.input) ? contractToJsonSchema(contract.input) : contract?.input && isCompositeInput(contract.input) && contract.input.body ? contractToJsonSchema(contract.input.body) : undefined;
|
|
34987
36752
|
const outputSchema = contract?.output ? contractToJsonSchema(contract.output) : undefined;
|
|
34988
36753
|
const composite = contract?.input && isCompositeInput(contract.input) ? contract.input : undefined;
|
|
@@ -35017,7 +36782,11 @@ function buildRoutes(workdir) {
|
|
|
35017
36782
|
...paramsSchema ? { paramsSchema } : {},
|
|
35018
36783
|
...headersSchema ? { headersSchema } : {},
|
|
35019
36784
|
examples: completedExamples,
|
|
35020
|
-
errors: errorsForRoute(contract)
|
|
36785
|
+
errors: errorsForRoute(contract),
|
|
36786
|
+
...ownership ? {
|
|
36787
|
+
origin: ownership.origin === "scan" ? "scan" : "bridge",
|
|
36788
|
+
...ownership.package ? { package: ownership.package } : {}
|
|
36789
|
+
} : { origin: "scan" }
|
|
35021
36790
|
});
|
|
35022
36791
|
}
|
|
35023
36792
|
output.sort((left, right) => `${left.path}:${left.method}`.localeCompare(`${right.path}:${right.method}`));
|
|
@@ -35060,12 +36829,12 @@ function buildInjection() {
|
|
|
35060
36829
|
}
|
|
35061
36830
|
function buildArtifacts(workdir) {
|
|
35062
36831
|
const root = resolveRoot(workdir);
|
|
35063
|
-
if (!
|
|
36832
|
+
if (!fs6.existsSync(root))
|
|
35064
36833
|
return [];
|
|
35065
36834
|
const found = new Set;
|
|
35066
36835
|
try {
|
|
35067
|
-
for (const entry of
|
|
35068
|
-
const filename =
|
|
36836
|
+
for (const entry of fs6.readdirSync(root, { recursive: true })) {
|
|
36837
|
+
const filename = path9.join(root, String(entry));
|
|
35069
36838
|
const classification = Artifacts.classify(filename);
|
|
35070
36839
|
if (classification)
|
|
35071
36840
|
found.add(classification.artifactType);
|
|
@@ -35084,21 +36853,21 @@ function buildEnv(workdir) {
|
|
|
35084
36853
|
names.add(match[1]);
|
|
35085
36854
|
}
|
|
35086
36855
|
};
|
|
35087
|
-
if (
|
|
36856
|
+
if (fs6.existsSync(root)) {
|
|
35088
36857
|
try {
|
|
35089
|
-
for (const entry of
|
|
35090
|
-
const file =
|
|
36858
|
+
for (const entry of fs6.readdirSync(root, { recursive: true })) {
|
|
36859
|
+
const file = path9.join(root, String(entry));
|
|
35091
36860
|
if (!/\.(ts|tsx|js|mjs|cjs|mts|cts)$/.test(file))
|
|
35092
36861
|
continue;
|
|
35093
|
-
collect(
|
|
36862
|
+
collect(fs6.readFileSync(file, "utf-8"));
|
|
35094
36863
|
}
|
|
35095
36864
|
} catch {}
|
|
35096
36865
|
}
|
|
35097
36866
|
for (const envFile of [".env.example", ".env.sample"]) {
|
|
35098
|
-
const filename =
|
|
35099
|
-
if (!
|
|
36867
|
+
const filename = path9.join(workdir, envFile);
|
|
36868
|
+
if (!fs6.existsSync(filename))
|
|
35100
36869
|
continue;
|
|
35101
|
-
for (const line of
|
|
36870
|
+
for (const line of fs6.readFileSync(filename, "utf-8").split(/\r?\n/)) {
|
|
35102
36871
|
const match = line.match(/^\s*([A-Z][A-Z0-9_]*)\s*=/);
|
|
35103
36872
|
if (match)
|
|
35104
36873
|
names.add(match[1]);
|
|
@@ -35167,6 +36936,43 @@ function buildConfig() {
|
|
|
35167
36936
|
}
|
|
35168
36937
|
return output;
|
|
35169
36938
|
}
|
|
36939
|
+
function describeUnresolvedEntry(entry) {
|
|
36940
|
+
if (typeof entry === "string")
|
|
36941
|
+
return entry;
|
|
36942
|
+
if (typeof entry === "function")
|
|
36943
|
+
return entry.name || "anonymous function";
|
|
36944
|
+
if (entry && typeof entry === "object") {
|
|
36945
|
+
const key = ["middleware", "hook", "plugin"].find((name) => (name in entry));
|
|
36946
|
+
if (key)
|
|
36947
|
+
return `${key}(${entry[key]?.name ?? "anonymous"})`;
|
|
36948
|
+
return Object.keys(entry).slice(0, 6).join(",") || "object";
|
|
36949
|
+
}
|
|
36950
|
+
return String(entry);
|
|
36951
|
+
}
|
|
36952
|
+
function buildBridge(workdir) {
|
|
36953
|
+
const state = BridgeLoader.state;
|
|
36954
|
+
if (!state.loaded && !state.sourceFile && !state.missing)
|
|
36955
|
+
return;
|
|
36956
|
+
return {
|
|
36957
|
+
file: state.sourceFile ? relative(workdir, state.sourceFile) : null,
|
|
36958
|
+
loaded: state.loaded,
|
|
36959
|
+
packages: state.packages,
|
|
36960
|
+
artifacts: state.artifacts.map((artifact) => ({
|
|
36961
|
+
name: artifact.name,
|
|
36962
|
+
kind: artifact.kind,
|
|
36963
|
+
origin: "bridge",
|
|
36964
|
+
...artifact.package ? { package: artifact.package } : {},
|
|
36965
|
+
...artifact.file ? { file: relative(workdir, artifact.file) } : {}
|
|
36966
|
+
})),
|
|
36967
|
+
unresolved: state.unresolved.map((item) => ({
|
|
36968
|
+
entry: describeUnresolvedEntry(item.entry),
|
|
36969
|
+
reason: item.reason,
|
|
36970
|
+
...item.code ? { code: item.code } : {},
|
|
36971
|
+
...item.package ? { package: item.package } : {},
|
|
36972
|
+
...item.file ? { file: relative(workdir, item.file) } : {}
|
|
36973
|
+
}))
|
|
36974
|
+
};
|
|
36975
|
+
}
|
|
35170
36976
|
function generateManifest(options = {}) {
|
|
35171
36977
|
const workdir = options.workdir ?? process.cwd();
|
|
35172
36978
|
if (!options.refresh && cachedManifest && cachedWorkdir === workdir) {
|
|
@@ -35174,7 +36980,8 @@ function generateManifest(options = {}) {
|
|
|
35174
36980
|
}
|
|
35175
36981
|
const runtime = RaitonThread.current?.runtime?.type ?? "unknown";
|
|
35176
36982
|
const sourceRoot = RaitonConfig.get("rootDir") || "./";
|
|
35177
|
-
const entry =
|
|
36983
|
+
const entry = path9.join(sourceRoot, "main.ts").split(path9.sep).join("/");
|
|
36984
|
+
const bridge = buildBridge(workdir);
|
|
35178
36985
|
const manifest = {
|
|
35179
36986
|
schemaVersion: MANIFEST_SCHEMA_VERSION,
|
|
35180
36987
|
generatedAt: new Date().toISOString(),
|
|
@@ -35193,15 +37000,16 @@ function generateManifest(options = {}) {
|
|
|
35193
37000
|
artifacts: buildArtifacts(workdir),
|
|
35194
37001
|
config: buildConfig(),
|
|
35195
37002
|
env: buildEnv(workdir),
|
|
35196
|
-
mcp: buildMcp(workdir)
|
|
37003
|
+
mcp: buildMcp(workdir),
|
|
37004
|
+
...bridge ? { bridge } : {}
|
|
35197
37005
|
};
|
|
35198
37006
|
cachedManifest = manifest;
|
|
35199
37007
|
cachedWorkdir = workdir;
|
|
35200
37008
|
return manifest;
|
|
35201
37009
|
}
|
|
35202
37010
|
function writeManifest(filename, manifest) {
|
|
35203
|
-
|
|
35204
|
-
|
|
37011
|
+
fs6.mkdirSync(path9.dirname(filename), { recursive: true });
|
|
37012
|
+
fs6.writeFileSync(filename, JSON.stringify(manifest, null, 2) + `
|
|
35205
37013
|
`, "utf-8");
|
|
35206
37014
|
}
|
|
35207
37015
|
var cachedManifest = null, cachedWorkdir = null, ENV_PATTERNS;
|
|
@@ -35214,10 +37022,12 @@ var init_manifest = __esm(async () => {
|
|
|
35214
37022
|
init_contracts();
|
|
35215
37023
|
init_schema5();
|
|
35216
37024
|
init_decorators();
|
|
37025
|
+
init_registry2();
|
|
35217
37026
|
init_package();
|
|
35218
37027
|
await __promiseAll([
|
|
35219
37028
|
init_thread(),
|
|
35220
|
-
init_artifacts()
|
|
37029
|
+
init_artifacts(),
|
|
37030
|
+
init_loader()
|
|
35221
37031
|
]);
|
|
35222
37032
|
ENV_PATTERNS = [
|
|
35223
37033
|
/process\.env\.([A-Z][A-Z0-9_]*)/g,
|
|
@@ -35227,7 +37037,7 @@ var init_manifest = __esm(async () => {
|
|
|
35227
37037
|
});
|
|
35228
37038
|
|
|
35229
37039
|
// source/debug/runtime.ts
|
|
35230
|
-
import
|
|
37040
|
+
import path10 from "node:path";
|
|
35231
37041
|
function maskSecrets(message) {
|
|
35232
37042
|
return String(message).replace(/(authorization\s*[:=]\s*)([^\s,;]+)/gi, "$1***").replace(/(bearer\s+)([A-Za-z0-9._~+/=-]+)/gi, "$1***").replace(/((?:password|passwd|secret|token|api[-_]?key)\s*[:=]\s*["']?)([^\s"',;]+)/gi, "$1***").slice(0, 512);
|
|
35233
37043
|
}
|
|
@@ -35331,7 +37141,7 @@ async function loadDebugManifest(refresh = false) {
|
|
|
35331
37141
|
}
|
|
35332
37142
|
function sessionJournalFile(workdir) {
|
|
35333
37143
|
const root = workdir ?? getDebugRuntime()?.workdir ?? process.cwd();
|
|
35334
|
-
return
|
|
37144
|
+
return path10.join(root, ".raiton", "debug-session.json");
|
|
35335
37145
|
}
|
|
35336
37146
|
var GLOBAL_KEY = "__raitonDebugRuntime", LOG_CAPACITY = 200;
|
|
35337
37147
|
var init_runtime2 = __esm(() => {
|
|
@@ -35339,12 +37149,12 @@ var init_runtime2 = __esm(() => {
|
|
|
35339
37149
|
});
|
|
35340
37150
|
|
|
35341
37151
|
// source/debug/source.ts
|
|
35342
|
-
import
|
|
35343
|
-
import
|
|
37152
|
+
import fs7 from "node:fs";
|
|
37153
|
+
import path11 from "node:path";
|
|
35344
37154
|
function relativePath(workdir, filename) {
|
|
35345
37155
|
if (!filename)
|
|
35346
37156
|
return "";
|
|
35347
|
-
return
|
|
37157
|
+
return path11.relative(workdir, filename).split(path11.sep).join("/");
|
|
35348
37158
|
}
|
|
35349
37159
|
function relativeLocation(location2, workdir = process.cwd()) {
|
|
35350
37160
|
if (!location2)
|
|
@@ -35353,7 +37163,7 @@ function relativeLocation(location2, workdir = process.cwd()) {
|
|
|
35353
37163
|
if (!match)
|
|
35354
37164
|
return location2;
|
|
35355
37165
|
const file = match[1];
|
|
35356
|
-
if (!
|
|
37166
|
+
if (!path11.isAbsolute(file))
|
|
35357
37167
|
return location2;
|
|
35358
37168
|
return `${relativePath(workdir, file)}:${match[2]}`;
|
|
35359
37169
|
}
|
|
@@ -35365,9 +37175,9 @@ function methodLine(filename, propertyKey) {
|
|
|
35365
37175
|
if (cached !== undefined)
|
|
35366
37176
|
return cached;
|
|
35367
37177
|
try {
|
|
35368
|
-
if (!
|
|
37178
|
+
if (!fs7.existsSync(filename))
|
|
35369
37179
|
return 0;
|
|
35370
|
-
const lines =
|
|
37180
|
+
const lines = fs7.readFileSync(filename, "utf-8").split(/\r?\n/);
|
|
35371
37181
|
const escaped = propertyKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
35372
37182
|
const pattern = new RegExp(`^\\s*(?:async\\s+)?${escaped}\\s*(?:<[^>]*>)?\\s*\\(`);
|
|
35373
37183
|
const loose = new RegExp(`\\b${escaped}\\s*\\(`);
|
|
@@ -35666,40 +37476,15 @@ var init_handler2 = __esm(() => {
|
|
|
35666
37476
|
init_collector();
|
|
35667
37477
|
});
|
|
35668
37478
|
|
|
35669
|
-
// source/core/controller/tracker.ts
|
|
35670
|
-
class ControllerRouteTracker {
|
|
35671
|
-
static getRoutes(controllerName) {
|
|
35672
|
-
return controllerRouteMap.get(controllerName) || [];
|
|
35673
|
-
}
|
|
35674
|
-
static setRoutes(controllerName, routes) {
|
|
35675
|
-
controllerRouteMap.set(controllerName, routes);
|
|
35676
|
-
}
|
|
35677
|
-
static removeRoutes(controllerName, router) {
|
|
35678
|
-
const routes = controllerRouteMap.get(controllerName);
|
|
35679
|
-
if (!routes)
|
|
35680
|
-
return;
|
|
35681
|
-
for (const route of routes) {
|
|
35682
|
-
router.remove(route);
|
|
35683
|
-
}
|
|
35684
|
-
controllerRouteMap.delete(controllerName);
|
|
35685
|
-
}
|
|
35686
|
-
static clear() {
|
|
35687
|
-
controllerRouteMap.clear();
|
|
35688
|
-
}
|
|
35689
|
-
}
|
|
35690
|
-
var controllerRouteMap;
|
|
35691
|
-
var init_tracker2 = __esm(() => {
|
|
35692
|
-
controllerRouteMap = new Map;
|
|
35693
|
-
});
|
|
35694
|
-
|
|
35695
37479
|
// source/core/controller/compiler.ts
|
|
35696
|
-
function compileController(ControllerClass, app) {
|
|
37480
|
+
function compileController(ControllerClass, app, options = {}) {
|
|
35697
37481
|
const instance = Injection.resolve(ControllerClass);
|
|
35698
37482
|
const metadata = getControllerMetadata(ControllerClass.prototype);
|
|
35699
37483
|
const name = ControllerClass.name;
|
|
37484
|
+
const origin = options.origin ?? "scan";
|
|
35700
37485
|
const rootScope = app.root;
|
|
35701
37486
|
if (rootScope?.router) {
|
|
35702
|
-
ControllerRouteTracker.removeRoutes(name, rootScope.router);
|
|
37487
|
+
ControllerRouteTracker.removeRoutes(name, rootScope.router, origin, options.trackerKey);
|
|
35703
37488
|
}
|
|
35704
37489
|
const routes = [];
|
|
35705
37490
|
for (const route of metadata.routes) {
|
|
@@ -35709,7 +37494,7 @@ function compileController(ControllerClass, app) {
|
|
|
35709
37494
|
const registered = rootScope?.router ? rootScope.router.add(route.method, path, handler) : app.route(route.method, path, handler);
|
|
35710
37495
|
routes.push(registered);
|
|
35711
37496
|
}
|
|
35712
|
-
ControllerRouteTracker.setRoutes(name, routes);
|
|
37497
|
+
ControllerRouteTracker.setRoutes(name, routes, origin, options.trackerKey);
|
|
35713
37498
|
return instance;
|
|
35714
37499
|
}
|
|
35715
37500
|
var init_compiler = __esm(() => {
|
|
@@ -35721,18 +37506,18 @@ var init_compiler = __esm(() => {
|
|
|
35721
37506
|
});
|
|
35722
37507
|
|
|
35723
37508
|
// source/core/controller/builder.ts
|
|
35724
|
-
import
|
|
35725
|
-
import
|
|
37509
|
+
import fs8 from "node:fs";
|
|
37510
|
+
import path12 from "node:path";
|
|
35726
37511
|
|
|
35727
37512
|
class ControllerBuilder {
|
|
35728
37513
|
static async scan(workdir) {
|
|
35729
|
-
const files =
|
|
37514
|
+
const files = fs8.readdirSync(workdir, { recursive: true }).map((file) => file.toString());
|
|
35730
37515
|
const output = [];
|
|
35731
37516
|
const timestamp = Date.now();
|
|
35732
37517
|
const entries = files.map((file) => {
|
|
35733
|
-
const filename =
|
|
37518
|
+
const filename = path12.join(workdir, file);
|
|
35734
37519
|
return { filename, classification: Artifacts.classify(filename) };
|
|
35735
|
-
});
|
|
37520
|
+
}).filter(({ filename }) => !Artifacts.isBridge(filename) && !ArtifactRegistry.isExcludedFile(filename));
|
|
35736
37521
|
for (const { filename, classification } of entries) {
|
|
35737
37522
|
if (classification?.channel !== "hmr:di")
|
|
35738
37523
|
continue;
|
|
@@ -35758,32 +37543,37 @@ class ControllerBuilder {
|
|
|
35758
37543
|
const resolvedClassification = classification === undefined ? Artifacts.classify(filename) : classification;
|
|
35759
37544
|
if (!resolvedClassification)
|
|
35760
37545
|
return;
|
|
35761
|
-
|
|
35762
|
-
const isSocket = resolvedClassification.channel === "hmr:socket";
|
|
35763
|
-
const isMcp = resolvedClassification.channel === "hmr:mcp";
|
|
35764
|
-
const isScheduler = resolvedClassification.channel === "hmr:scheduler";
|
|
35765
|
-
if (!isController && !isSocket && !isMcp && !isScheduler)
|
|
37546
|
+
if (!isMountableClassification(resolvedClassification))
|
|
35766
37547
|
return;
|
|
35767
37548
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
35768
|
-
const artifact = resolveArtifact(imported, {
|
|
37549
|
+
const artifact = resolveArtifact(imported, {
|
|
37550
|
+
isController: resolvedClassification.channel === "hmr:controller",
|
|
37551
|
+
isSocket: resolvedClassification.channel === "hmr:socket",
|
|
37552
|
+
isMcp: resolvedClassification.channel === "hmr:mcp",
|
|
37553
|
+
isScheduler: resolvedClassification.channel === "hmr:scheduler"
|
|
37554
|
+
});
|
|
35769
37555
|
if (!artifact)
|
|
35770
37556
|
return;
|
|
37557
|
+
return await this.buildArtifact(artifact, resolvedClassification, "scan", { file: filename });
|
|
37558
|
+
}
|
|
37559
|
+
static async buildArtifact(artifact, classification, origin = "scan", options = {}) {
|
|
37560
|
+
if (!artifact || !isMountableClassification(classification))
|
|
37561
|
+
return;
|
|
35771
37562
|
if (!RaitonThread.current?.application)
|
|
35772
37563
|
return;
|
|
35773
|
-
const
|
|
35774
|
-
if (
|
|
35775
|
-
|
|
35776
|
-
|
|
35777
|
-
|
|
35778
|
-
|
|
35779
|
-
if (isMcp) {
|
|
35780
|
-
return compileMcp(artifact);
|
|
35781
|
-
}
|
|
35782
|
-
if (isScheduler) {
|
|
35783
|
-
return compileScheduler(artifact);
|
|
37564
|
+
const existing = ArtifactRegistry.getByConstruct(artifact);
|
|
37565
|
+
if (existing) {
|
|
37566
|
+
if (origin === "bridge" && existing.origin !== "bridge" && existing.origin !== "package") {
|
|
37567
|
+
Logger.debug(`[bridge] ${artifact.name ?? "artifact"} already mounted by the scan; skipping duplicate`);
|
|
37568
|
+
}
|
|
37569
|
+
return existing;
|
|
35784
37570
|
}
|
|
35785
|
-
const
|
|
35786
|
-
|
|
37571
|
+
const record = await mountArtifact(artifact, kindForClassification(classification), RaitonThread.current.application, {
|
|
37572
|
+
origin,
|
|
37573
|
+
file: options.file,
|
|
37574
|
+
package: options.package
|
|
37575
|
+
});
|
|
37576
|
+
return record;
|
|
35787
37577
|
}
|
|
35788
37578
|
static async recompile(modulo, filename) {
|
|
35789
37579
|
const app = RaitonThread.current?.application;
|
|
@@ -35833,16 +37623,16 @@ function isDecoratedArtifact(candidate, keys) {
|
|
|
35833
37623
|
return keys.some((key) => (prototype ? Boolean(Reflect.getMetadata(key, prototype)) : false) || Boolean(Reflect.getMetadata(key, candidate)));
|
|
35834
37624
|
}
|
|
35835
37625
|
var init_builder4 = __esm(async () => {
|
|
35836
|
-
|
|
35837
|
-
init_builder();
|
|
35838
|
-
init_builder2();
|
|
37626
|
+
init_build3();
|
|
35839
37627
|
init_injection2();
|
|
35840
37628
|
init_decorators_constant();
|
|
35841
37629
|
init_tracker2();
|
|
37630
|
+
init_registry2();
|
|
37631
|
+
init_compiler();
|
|
35842
37632
|
await __promiseAll([
|
|
35843
|
-
init_builder3(),
|
|
35844
37633
|
init_thread(),
|
|
35845
|
-
init_artifacts()
|
|
37634
|
+
init_artifacts(),
|
|
37635
|
+
init_artifact_mount()
|
|
35846
37636
|
]);
|
|
35847
37637
|
});
|
|
35848
37638
|
|
|
@@ -36156,14 +37946,6 @@ var init_body_parser_plugin = __esm(() => {
|
|
|
36156
37946
|
installedScopes = new WeakSet;
|
|
36157
37947
|
});
|
|
36158
37948
|
|
|
36159
|
-
// source/bin/constants.ts
|
|
36160
|
-
var isBunUsed, isDenoUsed, isNodeUsed;
|
|
36161
|
-
var init_constants2 = __esm(() => {
|
|
36162
|
-
isBunUsed = typeof globalThis.Bun !== "undefined";
|
|
36163
|
-
isDenoUsed = typeof globalThis.Deno !== "undefined";
|
|
36164
|
-
isNodeUsed = !isBunUsed && !isDenoUsed;
|
|
36165
|
-
});
|
|
36166
|
-
|
|
36167
37949
|
// source/framework/observability/shutdown.ts
|
|
36168
37950
|
class ShutdownManager {
|
|
36169
37951
|
inFlight = 0;
|
|
@@ -36309,8 +38091,18 @@ class RaitonThread {
|
|
|
36309
38091
|
await this.runtime.prepare?.();
|
|
36310
38092
|
Readiness.markReady();
|
|
36311
38093
|
const scanRoot = isNodeUsed ? this.builder.out || this.builder.source : this.builder.source;
|
|
38094
|
+
ArtifactRegistry.clear();
|
|
38095
|
+
await BridgeLoader.load({
|
|
38096
|
+
workdir: this.builder.workdir,
|
|
38097
|
+
development: this.application.development
|
|
38098
|
+
});
|
|
36312
38099
|
if (scanRoot) {
|
|
36313
38100
|
await ControllerBuilder.scan(scanRoot);
|
|
38101
|
+
}
|
|
38102
|
+
if (BridgeLoader.state.loaded) {
|
|
38103
|
+
await BridgeLoader.mount(this.application);
|
|
38104
|
+
}
|
|
38105
|
+
if (scanRoot) {
|
|
36314
38106
|
registerDefaultHealthCheck(this.application);
|
|
36315
38107
|
}
|
|
36316
38108
|
if (this._options.serve) {
|
|
@@ -36369,9 +38161,11 @@ var init_thread = __esm(async () => {
|
|
|
36369
38161
|
init_config();
|
|
36370
38162
|
init_schema();
|
|
36371
38163
|
init_shutdown();
|
|
38164
|
+
init_registry2();
|
|
36372
38165
|
await __promiseAll([
|
|
36373
38166
|
init_runtime(),
|
|
36374
|
-
init_controller()
|
|
38167
|
+
init_controller(),
|
|
38168
|
+
init_loader()
|
|
36375
38169
|
]);
|
|
36376
38170
|
});
|
|
36377
38171
|
|
|
@@ -37032,34 +38826,6 @@ var init_config2 = __esm(() => {
|
|
|
37032
38826
|
init_schema();
|
|
37033
38827
|
});
|
|
37034
38828
|
|
|
37035
|
-
// source/core/directories.ts
|
|
37036
|
-
import path7 from "node:path";
|
|
37037
|
-
var RaitonDirectories;
|
|
37038
|
-
var init_directories = __esm(() => {
|
|
37039
|
-
init_config2();
|
|
37040
|
-
init_raiton();
|
|
37041
|
-
RaitonDirectories = class RaitonDirectories {
|
|
37042
|
-
static index = `.${Raiton.identifier}`;
|
|
37043
|
-
static bootstrapFile = "main.ts";
|
|
37044
|
-
static compiledBootstrapFile = "main.mjs";
|
|
37045
|
-
static caches(workdir) {
|
|
37046
|
-
return path7.join(workdir, this.index, "caches");
|
|
37047
|
-
}
|
|
37048
|
-
static artifacts(workdir) {
|
|
37049
|
-
return path7.join(workdir, this.index, "artifacts");
|
|
37050
|
-
}
|
|
37051
|
-
static server(workdir) {
|
|
37052
|
-
return path7.join(workdir, this.index, "server");
|
|
37053
|
-
}
|
|
37054
|
-
static root(workdir) {
|
|
37055
|
-
return path7.join(workdir, this.index);
|
|
37056
|
-
}
|
|
37057
|
-
static app() {
|
|
37058
|
-
return path7.join(Raiton.thread?.builder.workdir || "", RaitonConfig.get("rootDir") || "./");
|
|
37059
|
-
}
|
|
37060
|
-
};
|
|
37061
|
-
});
|
|
37062
|
-
|
|
37063
38829
|
// node_modules/esbuild/lib/main.js
|
|
37064
38830
|
var require_main = __commonJS(function(exports, module) {
|
|
37065
38831
|
var __dirname = "/home/runner/work/raiton/raiton/node_modules/esbuild/lib", __filename = "/home/runner/work/raiton/raiton/node_modules/esbuild/lib/main.js";
|
|
@@ -39709,10 +41475,11 @@ error: ${text}`);
|
|
|
39709
41475
|
});
|
|
39710
41476
|
|
|
39711
41477
|
// source/core/builder.ts
|
|
39712
|
-
import
|
|
39713
|
-
import
|
|
41478
|
+
import path13 from "node:path";
|
|
41479
|
+
import fs9 from "node:fs";
|
|
39714
41480
|
import { watch } from "fs";
|
|
39715
41481
|
import { execSync } from "node:child_process";
|
|
41482
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
39716
41483
|
|
|
39717
41484
|
class RaitonBuilder {
|
|
39718
41485
|
workdir;
|
|
@@ -39723,6 +41490,7 @@ class RaitonBuilder {
|
|
|
39723
41490
|
_bootstrapperFile = null;
|
|
39724
41491
|
_compiledVersionNumber = 1;
|
|
39725
41492
|
_watcher;
|
|
41493
|
+
_bridgeWatcher;
|
|
39726
41494
|
constructor(workdir, options = {}) {
|
|
39727
41495
|
this.workdir = workdir;
|
|
39728
41496
|
this.options = options;
|
|
@@ -39743,8 +41511,33 @@ class RaitonBuilder {
|
|
|
39743
41511
|
return this._watcher;
|
|
39744
41512
|
}
|
|
39745
41513
|
async parse(filename, type) {
|
|
39746
|
-
|
|
41514
|
+
const configuredBridge = resolveBridgeSource(this.workdir);
|
|
41515
|
+
const bridgePath = configuredBridge.file ?? configuredBridge.expected;
|
|
41516
|
+
if (bridgePath && isSameFile(filename, bridgePath) && !fs9.existsSync(filename)) {
|
|
41517
|
+
invalidateManifest();
|
|
41518
|
+
invalidateSourceCache();
|
|
41519
|
+
rotateDebugBuild();
|
|
41520
|
+
if (isNodeUsed) {
|
|
41521
|
+
Raiton.thread?.restart();
|
|
41522
|
+
return;
|
|
41523
|
+
}
|
|
41524
|
+
return await BridgeLoader.reload({ workdir: this.workdir, development: true });
|
|
41525
|
+
}
|
|
41526
|
+
if (!fs9.existsSync(filename))
|
|
39747
41527
|
return;
|
|
41528
|
+
const bridge = resolveBridgeSource(this.workdir);
|
|
41529
|
+
if (bridge.file && isSameFile(filename, bridge.file)) {
|
|
41530
|
+
invalidateManifest();
|
|
41531
|
+
invalidateSourceCache();
|
|
41532
|
+
rotateDebugBuild();
|
|
41533
|
+
if (isNodeUsed) {
|
|
41534
|
+
Raiton.thread?.restart();
|
|
41535
|
+
return;
|
|
41536
|
+
}
|
|
41537
|
+
const state = await BridgeLoader.reload({ workdir: this.workdir, development: true });
|
|
41538
|
+
Logger.log(LBadge.debug("HMR"), `[bridge] ${path13.relative(this.workdir, filename)} (${state.artifacts.length} artifact(s))`);
|
|
41539
|
+
return state;
|
|
41540
|
+
}
|
|
39748
41541
|
const classification = Artifacts.classify(filename);
|
|
39749
41542
|
if (!classification)
|
|
39750
41543
|
return;
|
|
@@ -39769,8 +41562,8 @@ class RaitonBuilder {
|
|
|
39769
41562
|
async parsing() {
|
|
39770
41563
|
if (typeof this._source != "string")
|
|
39771
41564
|
throw new Throwable("Application source not found");
|
|
39772
|
-
for (const filename of [...
|
|
39773
|
-
await this.parse(
|
|
41565
|
+
for (const filename of [...fs9.readdirSync(this._source, { recursive: true })])
|
|
41566
|
+
await this.parse(path13.join(this._source, String(filename)));
|
|
39774
41567
|
return this;
|
|
39775
41568
|
}
|
|
39776
41569
|
watching() {
|
|
@@ -39778,21 +41571,33 @@ class RaitonBuilder {
|
|
|
39778
41571
|
throw new Throwable("Application source not found");
|
|
39779
41572
|
this._watcher = watch(this._source, { recursive: true }, (event, relativePath) => {
|
|
39780
41573
|
if (this._source && relativePath) {
|
|
39781
|
-
this.parse(
|
|
41574
|
+
this.parse(path13.join(this._source, relativePath));
|
|
39782
41575
|
}
|
|
39783
41576
|
});
|
|
41577
|
+
const bridge = resolveBridgeSource(this.workdir);
|
|
41578
|
+
if (bridge.file && !isWithin(this._source, bridge.file)) {
|
|
41579
|
+
try {
|
|
41580
|
+
this._bridgeWatcher = watch(bridge.file, (event) => {
|
|
41581
|
+
this.parse(bridge.file, event).catch((error) => {
|
|
41582
|
+
Logger.error("[bridge] reload failed", error?.message ?? error);
|
|
41583
|
+
});
|
|
41584
|
+
});
|
|
41585
|
+
} catch (error) {
|
|
41586
|
+
Logger.debug("[bridge] cannot watch bridge file", error?.message ?? error);
|
|
41587
|
+
}
|
|
41588
|
+
}
|
|
39784
41589
|
return this;
|
|
39785
41590
|
}
|
|
39786
41591
|
async initialize() {
|
|
39787
41592
|
const rootDir = RaitonConfig.get("rootDir") || "./";
|
|
39788
|
-
this._source =
|
|
39789
|
-
this._out =
|
|
39790
|
-
if (!
|
|
41593
|
+
this._source = path13.resolve(this.workdir, rootDir);
|
|
41594
|
+
this._out = path13.resolve(this.workdir, RaitonDirectories.server(this.workdir));
|
|
41595
|
+
if (!fs9.existsSync(this._source))
|
|
39791
41596
|
throw new Error(`Source directory "${this._source}" does not exists`);
|
|
39792
|
-
if (!
|
|
39793
|
-
|
|
39794
|
-
this._bootstrapper =
|
|
39795
|
-
this._bootstrapperFile =
|
|
41597
|
+
if (!fs9.existsSync(this._out))
|
|
41598
|
+
fs9.mkdirSync(this._out, { recursive: true });
|
|
41599
|
+
this._bootstrapper = path13.join(this._source, RaitonDirectories.bootstrapFile);
|
|
41600
|
+
this._bootstrapperFile = path13.join(RaitonDirectories.server(this.workdir), RaitonDirectories.compiledBootstrapFile);
|
|
39796
41601
|
return this;
|
|
39797
41602
|
}
|
|
39798
41603
|
async prepare() {
|
|
@@ -39813,49 +41618,49 @@ class RaitonBuilder {
|
|
|
39813
41618
|
Raiton.signals.listen("hmr:di", async ({ filename, version, timestamp }) => {
|
|
39814
41619
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39815
41620
|
Artifacts.reloadDi(imported, filename);
|
|
39816
|
-
Logger.log(LBadge.debug("HMR"), `[di] ${
|
|
41621
|
+
Logger.log(LBadge.debug("HMR"), `[di] ${path13.relative(this.workdir, filename)}`);
|
|
39817
41622
|
});
|
|
39818
41623
|
}
|
|
39819
41624
|
listenHmrController() {
|
|
39820
41625
|
Raiton.signals.listen("hmr:controller", async ({ filename, version, timestamp }) => {
|
|
39821
41626
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39822
41627
|
await ControllerBuilder.recompile(imported, filename);
|
|
39823
|
-
Logger.log(LBadge.debug("HMR"), `[controller] ${
|
|
41628
|
+
Logger.log(LBadge.debug("HMR"), `[controller] ${path13.relative(this.workdir, filename)}`);
|
|
39824
41629
|
});
|
|
39825
41630
|
}
|
|
39826
41631
|
listenHmrSocket() {
|
|
39827
41632
|
Raiton.signals.listen("hmr:socket", async ({ filename, version, timestamp }) => {
|
|
39828
41633
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39829
41634
|
await ControllerBuilder.build({ filename, version, timestamp });
|
|
39830
|
-
Logger.log(LBadge.debug("HMR"), `[socket] ${
|
|
41635
|
+
Logger.log(LBadge.debug("HMR"), `[socket] ${path13.relative(this.workdir, filename)}`);
|
|
39831
41636
|
});
|
|
39832
41637
|
}
|
|
39833
41638
|
listenHmrMiddleware() {
|
|
39834
41639
|
Raiton.signals.listen("hmr:middleware", async ({ filename, version, timestamp }) => {
|
|
39835
41640
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39836
41641
|
Artifacts.reloadMiddleware(imported, filename);
|
|
39837
|
-
Logger.log(LBadge.debug("HMR"), `[middleware] ${
|
|
41642
|
+
Logger.log(LBadge.debug("HMR"), `[middleware] ${path13.relative(this.workdir, filename)}`);
|
|
39838
41643
|
});
|
|
39839
41644
|
}
|
|
39840
41645
|
listenHmrHook() {
|
|
39841
41646
|
Raiton.signals.listen("hmr:hook", async ({ filename, version, timestamp }) => {
|
|
39842
41647
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39843
41648
|
Artifacts.reloadHook(imported, filename);
|
|
39844
|
-
Logger.log(LBadge.debug("HMR"), `[hook] ${
|
|
41649
|
+
Logger.log(LBadge.debug("HMR"), `[hook] ${path13.relative(this.workdir, filename)}`);
|
|
39845
41650
|
});
|
|
39846
41651
|
}
|
|
39847
41652
|
listenHmrMcp() {
|
|
39848
41653
|
Raiton.signals.listen("hmr:mcp", async ({ filename, version, timestamp }) => {
|
|
39849
41654
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39850
41655
|
Artifacts.reloadMcp(imported, filename);
|
|
39851
|
-
Logger.log(LBadge.debug("HMR"), `[mcp] ${
|
|
41656
|
+
Logger.log(LBadge.debug("HMR"), `[mcp] ${path13.relative(this.workdir, filename)}`);
|
|
39852
41657
|
});
|
|
39853
41658
|
}
|
|
39854
41659
|
listenHmrScheduler() {
|
|
39855
41660
|
Raiton.signals.listen("hmr:scheduler", async ({ filename, version, timestamp }) => {
|
|
39856
41661
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
39857
41662
|
Artifacts.reloadScheduler(imported, filename);
|
|
39858
|
-
Logger.log(LBadge.debug("HMR"), `[scheduler] ${
|
|
41663
|
+
Logger.log(LBadge.debug("HMR"), `[scheduler] ${path13.relative(this.workdir, filename)}`);
|
|
39859
41664
|
});
|
|
39860
41665
|
}
|
|
39861
41666
|
async build(thread) {
|
|
@@ -39867,18 +41672,60 @@ class RaitonBuilder {
|
|
|
39867
41672
|
throw new Error("Bootstrapper not found");
|
|
39868
41673
|
if (!this.bootstrapperFile)
|
|
39869
41674
|
throw new Error("Bootstrapper file not found");
|
|
39870
|
-
const source =
|
|
39871
|
-
const output =
|
|
41675
|
+
const source = path13.relative(this.workdir, this._source);
|
|
41676
|
+
const output = path13.relative(this.workdir, this._out);
|
|
39872
41677
|
Logger.log(LBadge.notice("Building"), "application");
|
|
39873
41678
|
Logger.log(LBadge.info("Source"), source);
|
|
39874
41679
|
Logger.log(LBadge.info("Output"), output);
|
|
39875
41680
|
await this.typecheck();
|
|
39876
41681
|
await this.compile();
|
|
41682
|
+
await this.validateBridgeOutput();
|
|
41683
|
+
return this;
|
|
41684
|
+
}
|
|
41685
|
+
async validateBridgeOutput() {
|
|
41686
|
+
if (!isNodeUsed || !this._out)
|
|
41687
|
+
return this;
|
|
41688
|
+
const bridge = resolveBridgeSource(this.workdir);
|
|
41689
|
+
if (!bridge.file)
|
|
41690
|
+
return this;
|
|
41691
|
+
const compiled = path13.join(this._out, "artifacts.bridge.mjs");
|
|
41692
|
+
if (!fs9.existsSync(compiled))
|
|
41693
|
+
return this;
|
|
41694
|
+
let imported;
|
|
41695
|
+
try {
|
|
41696
|
+
imported = await import(pathToFileURL3(compiled).href);
|
|
41697
|
+
} catch (error) {
|
|
41698
|
+
throw new BridgeError("BRIDGE_IMPORT_FAILED", {
|
|
41699
|
+
message: `Compiled bridge failed to load: ${error?.message ?? error}`,
|
|
41700
|
+
location: compiled
|
|
41701
|
+
});
|
|
41702
|
+
}
|
|
41703
|
+
const definition = imported?.default ?? imported;
|
|
41704
|
+
if (!definition || !Array.isArray(definition.artifacts)) {
|
|
41705
|
+
throw new BridgeError("BRIDGE_FILE_INVALID_EXPORT", {
|
|
41706
|
+
message: "The compiled bridge does not export a valid definition",
|
|
41707
|
+
location: compiled
|
|
41708
|
+
});
|
|
41709
|
+
}
|
|
41710
|
+
for (const entry of definition.artifacts) {
|
|
41711
|
+
if (typeof entry !== "string")
|
|
41712
|
+
continue;
|
|
41713
|
+
if (!/^(\.\.?\/|\/)/.test(entry))
|
|
41714
|
+
continue;
|
|
41715
|
+
if (/\.(ts|mts|cts|tsx)$/i.test(entry)) {
|
|
41716
|
+
throw new BridgeError("BRIDGE_RUNTIME_UNSUPPORTED", {
|
|
41717
|
+
message: `Local bridge entry is TypeScript and cannot be imported on Node.js: ${entry}`,
|
|
41718
|
+
action: "Import the class directly in artifacts.bridge.ts (recommended) or compile the file to JavaScript.",
|
|
41719
|
+
location: compiled,
|
|
41720
|
+
entry
|
|
41721
|
+
});
|
|
41722
|
+
}
|
|
41723
|
+
}
|
|
39877
41724
|
return this;
|
|
39878
41725
|
}
|
|
39879
41726
|
async typecheck() {
|
|
39880
|
-
const tsconfigPath =
|
|
39881
|
-
if (!
|
|
41727
|
+
const tsconfigPath = path13.join(this.workdir, "tsconfig.json");
|
|
41728
|
+
if (!fs9.existsSync(tsconfigPath))
|
|
39882
41729
|
return this;
|
|
39883
41730
|
try {
|
|
39884
41731
|
execSync(`cd ${this.workdir} && npx tsc -p tsconfig.json --noEmit`, { stdio: "inherit" });
|
|
@@ -39897,17 +41744,40 @@ class RaitonBuilder {
|
|
|
39897
41744
|
const outfile = this.bootstrapperFile;
|
|
39898
41745
|
if (!outfile)
|
|
39899
41746
|
throw new Error("Bootstrapper file not found");
|
|
41747
|
+
const bridge = resolveBridgeSource(this.workdir);
|
|
41748
|
+
if (bridge.explicit && !bridge.file) {
|
|
41749
|
+
throw new BridgeError("BRIDGE_FILE_NOT_FOUND", {
|
|
41750
|
+
location: bridge.expected ?? this.workdir,
|
|
41751
|
+
entry: bridge.expected ?? undefined
|
|
41752
|
+
});
|
|
41753
|
+
}
|
|
39900
41754
|
const { build } = await Promise.resolve().then(() => __toESM(require_main(), 1));
|
|
39901
|
-
|
|
39902
|
-
entryPoints: [this.bootstrapper],
|
|
41755
|
+
const shared = {
|
|
39903
41756
|
bundle: true,
|
|
39904
41757
|
platform: "node",
|
|
39905
41758
|
format: "esm",
|
|
39906
41759
|
target: "node20",
|
|
39907
|
-
outfile,
|
|
39908
41760
|
sourcemap: true,
|
|
39909
41761
|
packages: "external",
|
|
39910
41762
|
external: ["@protorians/*", "argon2", "bcrypt"]
|
|
41763
|
+
};
|
|
41764
|
+
if (bridge.file) {
|
|
41765
|
+
await build({
|
|
41766
|
+
...shared,
|
|
41767
|
+
entryPoints: [
|
|
41768
|
+
{ in: this.bootstrapper, out: "main" },
|
|
41769
|
+
{ in: bridge.file, out: "artifacts.bridge" }
|
|
41770
|
+
],
|
|
41771
|
+
outdir: this._out,
|
|
41772
|
+
outExtension: { ".js": ".mjs" }
|
|
41773
|
+
});
|
|
41774
|
+
Logger.log(LBadge.info("Bridge"), path13.relative(this.workdir, bridge.file));
|
|
41775
|
+
return this;
|
|
41776
|
+
}
|
|
41777
|
+
await build({
|
|
41778
|
+
...shared,
|
|
41779
|
+
entryPoints: [this.bootstrapper],
|
|
41780
|
+
outfile
|
|
39911
41781
|
});
|
|
39912
41782
|
return this;
|
|
39913
41783
|
}
|
|
@@ -39919,11 +41789,14 @@ class RaitonBuilder {
|
|
|
39919
41789
|
const compiled = this.bootstrapperFile;
|
|
39920
41790
|
if (!compiled)
|
|
39921
41791
|
throw new Error("Bootstrapper file not found");
|
|
39922
|
-
|
|
41792
|
+
const bridge = resolveBridgeSource(this.workdir);
|
|
41793
|
+
const bridgeCompiled = bridge.file ? path13.join(this._out, "artifacts.bridge.mjs") : null;
|
|
41794
|
+
const needsCompile = this.options.hmr || !fs9.existsSync(compiled) || Boolean(bridgeCompiled && !fs9.existsSync(bridgeCompiled));
|
|
41795
|
+
if (needsCompile)
|
|
39923
41796
|
await this.compile();
|
|
39924
41797
|
entry = compiled;
|
|
39925
41798
|
}
|
|
39926
|
-
if (!
|
|
41799
|
+
if (!fs9.existsSync(entry))
|
|
39927
41800
|
throw new Error(`Bootstrapper file "${entry}" does not exists`);
|
|
39928
41801
|
const bootstrapper = await import(entry);
|
|
39929
41802
|
if (!("default" in bootstrapper))
|
|
@@ -39945,11 +41818,14 @@ var init_builder5 = __esm(async () => {
|
|
|
39945
41818
|
init_constants2();
|
|
39946
41819
|
init_runtime2();
|
|
39947
41820
|
init_source();
|
|
41821
|
+
init_paths();
|
|
41822
|
+
init_diagnostics();
|
|
39948
41823
|
await __promiseAll([
|
|
39949
41824
|
init_thread(),
|
|
39950
41825
|
init_controller(),
|
|
39951
41826
|
init_artifacts(),
|
|
39952
|
-
init_manifest()
|
|
41827
|
+
init_manifest(),
|
|
41828
|
+
init_loader()
|
|
39953
41829
|
]);
|
|
39954
41830
|
});
|
|
39955
41831
|
// source/core/command.ts
|
|
@@ -40059,61 +41935,6 @@ var init_cli_output = __esm(() => {
|
|
|
40059
41935
|
};
|
|
40060
41936
|
});
|
|
40061
41937
|
|
|
40062
|
-
// source/commands/artifact.command.ts
|
|
40063
|
-
var ArtifactCommand;
|
|
40064
|
-
var init_artifact_command = __esm(async () => {
|
|
40065
|
-
init_cli_output();
|
|
40066
|
-
init_config();
|
|
40067
|
-
await init_manifest();
|
|
40068
|
-
ArtifactCommand = class ArtifactCommand extends RaitonCommand {
|
|
40069
|
-
name = "artifact";
|
|
40070
|
-
description = "Inspect artifacts detected in the project";
|
|
40071
|
-
register() {
|
|
40072
|
-
this.cli.command("artifact").alias("art").description(this.description).option("--dump", "Dump artifacts detected by the project scanner").option("--json", "Emit a machine-readable list on stdout").action((options) => this.run(options).catch((error) => fail(error, options.json)));
|
|
40073
|
-
}
|
|
40074
|
-
async run(options) {
|
|
40075
|
-
await RaitonConfig.sync(this.workdir, { force: true });
|
|
40076
|
-
const manifest = generateManifest({ refresh: true, workdir: this.workdir });
|
|
40077
|
-
if (options.json) {
|
|
40078
|
-
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, artifacts: manifest.artifacts, types: RaitonConfig.get("artifacts")?.types ?? [] }, true);
|
|
40079
|
-
return;
|
|
40080
|
-
}
|
|
40081
|
-
if (!manifest.artifacts.length) {
|
|
40082
|
-
print("No artifact detected. Use documented suffixes such as `.controller.ts` or `.service.ts`.");
|
|
40083
|
-
return;
|
|
40084
|
-
}
|
|
40085
|
-
print(`Detected artifact types (${manifest.artifacts.length}):`);
|
|
40086
|
-
for (const artifact of manifest.artifacts)
|
|
40087
|
-
print(` - ${artifact}`);
|
|
40088
|
-
print("Create one with `raiton generate <type> <name>`.");
|
|
40089
|
-
}
|
|
40090
|
-
};
|
|
40091
|
-
});
|
|
40092
|
-
|
|
40093
|
-
// source/commands/build.command.ts
|
|
40094
|
-
var BuildCommand;
|
|
40095
|
-
var init_build_command = __esm(async () => {
|
|
40096
|
-
init_build3();
|
|
40097
|
-
await init_core();
|
|
40098
|
-
BuildCommand = class BuildCommand extends RaitonCommand {
|
|
40099
|
-
name = "build";
|
|
40100
|
-
description = "Build the application";
|
|
40101
|
-
register() {
|
|
40102
|
-
this.cli.command(this.name).alias("b").description("Build the application").option("--develop, -d", "Build in development mode").option("--bootstrap, -b", "Bootstrap the application").action(this.run.bind(this));
|
|
40103
|
-
}
|
|
40104
|
-
async run(options) {
|
|
40105
|
-
if (options.develop)
|
|
40106
|
-
Logger.warn(LBadge.log("Dev Mode"));
|
|
40107
|
-
const builder = new RaitonBuilder(this.workdir, {
|
|
40108
|
-
serve: options.develop,
|
|
40109
|
-
hmr: options.develop
|
|
40110
|
-
});
|
|
40111
|
-
await builder.prepare();
|
|
40112
|
-
await builder.boot();
|
|
40113
|
-
}
|
|
40114
|
-
};
|
|
40115
|
-
});
|
|
40116
|
-
|
|
40117
41938
|
// source/manifest/introspect.ts
|
|
40118
41939
|
async function introspectProject(workdir = process.cwd(), options = {}) {
|
|
40119
41940
|
await RaitonConfig.sync(workdir, { force: true });
|
|
@@ -40150,15 +41971,15 @@ var init_introspect = __esm(async () => {
|
|
|
40150
41971
|
});
|
|
40151
41972
|
|
|
40152
41973
|
// source/bin/project-utils.ts
|
|
40153
|
-
import
|
|
40154
|
-
import
|
|
41974
|
+
import path14 from "node:path";
|
|
41975
|
+
import fs10 from "node:fs";
|
|
40155
41976
|
async function loadProject(workdir, json = false) {
|
|
40156
41977
|
await Promise.resolve().then(() => init_config());
|
|
40157
41978
|
await RaitonConfig.sync(workdir, { force: true });
|
|
40158
41979
|
const rootDir = RaitonConfig.get("rootDir") || "./source";
|
|
40159
|
-
const bootstrapper =
|
|
41980
|
+
const bootstrapper = path14.resolve(workdir, rootDir, "main.ts");
|
|
40160
41981
|
const candidates = [bootstrapper];
|
|
40161
|
-
if (!candidates.some((candidate) =>
|
|
41982
|
+
if (!candidates.some((candidate) => fs10.existsSync(candidate))) {
|
|
40162
41983
|
throw new CliError("Project entry point source/main.ts was not found", {
|
|
40163
41984
|
code: "PREREQUISITE_MISSING",
|
|
40164
41985
|
hint: "Create source/main.ts or set rootDir in raiton.config.ts.",
|
|
@@ -40171,6 +41992,15 @@ async function loadProject(workdir, json = false) {
|
|
|
40171
41992
|
} catch (error) {
|
|
40172
41993
|
if (error instanceof CliError)
|
|
40173
41994
|
throw error;
|
|
41995
|
+
if (error?.code && String(error.code).startsWith("BRIDGE_")) {
|
|
41996
|
+
throw new CliError(error.message ?? String(error), {
|
|
41997
|
+
code: error.code,
|
|
41998
|
+
hint: error.diagnostic?.action ?? "Fix the bridge declaration, then retry.",
|
|
41999
|
+
docsUrl: error.diagnostic?.docsUrl,
|
|
42000
|
+
location: error.diagnostic?.location,
|
|
42001
|
+
exitCode: 2 /* PREREQUISITE_MISSING */
|
|
42002
|
+
});
|
|
42003
|
+
}
|
|
40174
42004
|
throw new CliError(error?.message ?? String(error), {
|
|
40175
42005
|
code: "INTROSPECTION_FAILED",
|
|
40176
42006
|
hint: "Fix the bootstrapper or configuration, then run `raiton doctor`.",
|
|
@@ -40212,6 +42042,74 @@ var init_project_utils = __esm(async () => {
|
|
|
40212
42042
|
await init_introspect();
|
|
40213
42043
|
});
|
|
40214
42044
|
|
|
42045
|
+
// source/commands/artifact.command.ts
|
|
42046
|
+
var ArtifactCommand;
|
|
42047
|
+
var init_artifact_command = __esm(async () => {
|
|
42048
|
+
init_cli_output();
|
|
42049
|
+
init_config();
|
|
42050
|
+
init_registry2();
|
|
42051
|
+
await init_project_utils();
|
|
42052
|
+
ArtifactCommand = class ArtifactCommand extends RaitonCommand {
|
|
42053
|
+
name = "artifact";
|
|
42054
|
+
description = "Inspect artifacts detected in the project";
|
|
42055
|
+
register() {
|
|
42056
|
+
this.cli.command("artifact").alias("art").description(this.description).option("--dump", "Dump artifacts and their origin (scan or bridge)").option("--json", "Emit a machine-readable list on stdout").action((options) => this.run(options).catch((error) => fail(error, options.json)));
|
|
42057
|
+
}
|
|
42058
|
+
async run(options) {
|
|
42059
|
+
await RaitonConfig.sync(this.workdir, { force: true });
|
|
42060
|
+
const { manifest } = await loadProject(this.workdir, options.json);
|
|
42061
|
+
const artifacts = ArtifactRegistry.describeArtifacts(this.workdir);
|
|
42062
|
+
if (options.json) {
|
|
42063
|
+
print({
|
|
42064
|
+
schemaVersion: CLI_JSON_SCHEMA_VERSION,
|
|
42065
|
+
artifacts,
|
|
42066
|
+
types: manifest.artifacts,
|
|
42067
|
+
...manifest.bridge ? { bridge: manifest.bridge } : {}
|
|
42068
|
+
}, true);
|
|
42069
|
+
return;
|
|
42070
|
+
}
|
|
42071
|
+
if (!artifacts.length) {
|
|
42072
|
+
print("No artifact detected. Use documented suffixes such as `.controller.ts` or declare entries in `artifacts.bridge.ts`.");
|
|
42073
|
+
return;
|
|
42074
|
+
}
|
|
42075
|
+
print(`Detected artifacts (${artifacts.length}):`);
|
|
42076
|
+
for (const artifact of artifacts) {
|
|
42077
|
+
const location2 = artifact.package ? `package ${artifact.package}` : artifact.file ?? "";
|
|
42078
|
+
print(` - ${artifact.name} [${artifact.kind}] origin=${artifact.origin}${location2 ? ` ${location2}` : ""}`);
|
|
42079
|
+
}
|
|
42080
|
+
if (manifest.bridge) {
|
|
42081
|
+
print(`Bridge: ${manifest.bridge.file ?? "none"} (${manifest.bridge.artifacts.length} artifact(s), ${manifest.bridge.unresolved.length} unresolved)`);
|
|
42082
|
+
}
|
|
42083
|
+
print("Create one with `raiton generate <type> <name>` or declare it in `artifacts.bridge.ts`.");
|
|
42084
|
+
}
|
|
42085
|
+
};
|
|
42086
|
+
});
|
|
42087
|
+
|
|
42088
|
+
// source/commands/build.command.ts
|
|
42089
|
+
var BuildCommand;
|
|
42090
|
+
var init_build_command = __esm(async () => {
|
|
42091
|
+
init_build3();
|
|
42092
|
+
init_cli_output();
|
|
42093
|
+
await init_core();
|
|
42094
|
+
BuildCommand = class BuildCommand extends RaitonCommand {
|
|
42095
|
+
name = "build";
|
|
42096
|
+
description = "Build the application";
|
|
42097
|
+
register() {
|
|
42098
|
+
this.cli.command(this.name).alias("b").description("Build the application").option("--develop, -d", "Build in development mode").option("--bootstrap, -b", "Bootstrap the application").action((options) => this.run(options).catch((error) => fail(error)));
|
|
42099
|
+
}
|
|
42100
|
+
async run(options) {
|
|
42101
|
+
if (options.develop)
|
|
42102
|
+
Logger.warn(LBadge.log("Dev Mode"));
|
|
42103
|
+
const builder = new RaitonBuilder(this.workdir, {
|
|
42104
|
+
serve: options.develop,
|
|
42105
|
+
hmr: options.develop
|
|
42106
|
+
});
|
|
42107
|
+
await builder.prepare();
|
|
42108
|
+
await builder.boot();
|
|
42109
|
+
}
|
|
42110
|
+
};
|
|
42111
|
+
});
|
|
42112
|
+
|
|
40215
42113
|
// source/debug/config.ts
|
|
40216
42114
|
function envFlag(name) {
|
|
40217
42115
|
const raw = process.env[name];
|
|
@@ -40334,17 +42232,17 @@ var init_config3 = __esm(() => {
|
|
|
40334
42232
|
});
|
|
40335
42233
|
|
|
40336
42234
|
// source/debug/session.ts
|
|
40337
|
-
import
|
|
40338
|
-
import
|
|
42235
|
+
import fs11 from "node:fs";
|
|
42236
|
+
import path15 from "node:path";
|
|
40339
42237
|
function empty() {
|
|
40340
42238
|
return { schemaVersion: DEBUG_SCHEMA_VERSION, updatedAt: new Date().toISOString(), entries: [] };
|
|
40341
42239
|
}
|
|
40342
42240
|
function readSessionFile(workdir) {
|
|
40343
42241
|
const filename = sessionJournalFile(workdir);
|
|
40344
42242
|
try {
|
|
40345
|
-
if (!
|
|
42243
|
+
if (!fs11.existsSync(filename))
|
|
40346
42244
|
return empty();
|
|
40347
|
-
const raw =
|
|
42245
|
+
const raw = fs11.readFileSync(filename, "utf-8");
|
|
40348
42246
|
if (!raw.trim())
|
|
40349
42247
|
return empty();
|
|
40350
42248
|
const parsed = JSON.parse(raw);
|
|
@@ -40396,10 +42294,10 @@ function appendSessionEntry(entry, workdir) {
|
|
|
40396
42294
|
}
|
|
40397
42295
|
function writeAtomic(filename, content) {
|
|
40398
42296
|
try {
|
|
40399
|
-
|
|
42297
|
+
fs11.mkdirSync(path15.dirname(filename), { recursive: true });
|
|
40400
42298
|
const temporary = `${filename}.${process.pid}.tmp`;
|
|
40401
|
-
|
|
40402
|
-
|
|
42299
|
+
fs11.writeFileSync(temporary, content, "utf-8");
|
|
42300
|
+
fs11.renameSync(temporary, filename);
|
|
40403
42301
|
} catch {}
|
|
40404
42302
|
}
|
|
40405
42303
|
var MAX_ENTRIES = 1000, MAX_BYTES, TTL_MS = 900000;
|
|
@@ -41172,8 +43070,8 @@ var init_requests = __esm(() => {
|
|
|
41172
43070
|
});
|
|
41173
43071
|
|
|
41174
43072
|
// source/commands/debug.shared.ts
|
|
41175
|
-
import
|
|
41176
|
-
import
|
|
43073
|
+
import fs12 from "node:fs";
|
|
43074
|
+
import path16 from "node:path";
|
|
41177
43075
|
function collect(value, previous = []) {
|
|
41178
43076
|
return [...previous, value];
|
|
41179
43077
|
}
|
|
@@ -41197,8 +43095,8 @@ function parseData(value, workdir) {
|
|
|
41197
43095
|
return;
|
|
41198
43096
|
let content = value;
|
|
41199
43097
|
if (value.startsWith("@")) {
|
|
41200
|
-
const filename =
|
|
41201
|
-
if (!
|
|
43098
|
+
const filename = path16.resolve(workdir, value.slice(1));
|
|
43099
|
+
if (!fs12.existsSync(filename)) {
|
|
41202
43100
|
throw new CliError(`Data file not found: ${value.slice(1)}`, {
|
|
41203
43101
|
code: "FILE_NOT_FOUND",
|
|
41204
43102
|
hint: "Check the --data @file path.",
|
|
@@ -41206,7 +43104,7 @@ function parseData(value, workdir) {
|
|
|
41206
43104
|
exitCode: 2 /* PREREQUISITE_MISSING */
|
|
41207
43105
|
});
|
|
41208
43106
|
}
|
|
41209
|
-
content =
|
|
43107
|
+
content = fs12.readFileSync(filename, "utf-8");
|
|
41210
43108
|
}
|
|
41211
43109
|
try {
|
|
41212
43110
|
return JSON.parse(content);
|
|
@@ -41697,14 +43595,14 @@ var init_client = __esm(() => {
|
|
|
41697
43595
|
});
|
|
41698
43596
|
|
|
41699
43597
|
// source/bin/file-utils.ts
|
|
41700
|
-
import
|
|
41701
|
-
import
|
|
43598
|
+
import fs13 from "node:fs";
|
|
43599
|
+
import path17 from "node:path";
|
|
41702
43600
|
function writeFiles(baseDir, files, options = {}) {
|
|
41703
43601
|
const resolved = files.map((file) => ({
|
|
41704
43602
|
...file,
|
|
41705
|
-
absolute:
|
|
43603
|
+
absolute: path17.resolve(baseDir, file.path)
|
|
41706
43604
|
}));
|
|
41707
|
-
const conflicts = resolved.filter((file) =>
|
|
43605
|
+
const conflicts = resolved.filter((file) => fs13.existsSync(file.absolute)).map((file) => path17.relative(baseDir, file.absolute));
|
|
41708
43606
|
if (conflicts.length && !options.force) {
|
|
41709
43607
|
throw new CliError(`Refusing to overwrite existing file(s): ${conflicts.join(", ")}`, {
|
|
41710
43608
|
code: "FILE_CONFLICT",
|
|
@@ -41723,8 +43621,8 @@ function writeFiles(baseDir, files, options = {}) {
|
|
|
41723
43621
|
}
|
|
41724
43622
|
const written = [];
|
|
41725
43623
|
for (const file of resolved) {
|
|
41726
|
-
|
|
41727
|
-
|
|
43624
|
+
fs13.mkdirSync(path17.dirname(file.absolute), { recursive: true });
|
|
43625
|
+
fs13.writeFileSync(file.absolute, file.content, "utf-8");
|
|
41728
43626
|
written.push(file.path);
|
|
41729
43627
|
}
|
|
41730
43628
|
return {
|
|
@@ -41734,8 +43632,8 @@ function writeFiles(baseDir, files, options = {}) {
|
|
|
41734
43632
|
dryRun: false
|
|
41735
43633
|
};
|
|
41736
43634
|
}
|
|
41737
|
-
function
|
|
41738
|
-
if (!
|
|
43635
|
+
function readJsonFile2(filename) {
|
|
43636
|
+
if (!fs13.existsSync(filename)) {
|
|
41739
43637
|
throw new CliError(`File not found: ${filename}`, {
|
|
41740
43638
|
code: "FILE_NOT_FOUND",
|
|
41741
43639
|
hint: "Check the path and try again.",
|
|
@@ -41744,7 +43642,7 @@ function readJsonFile(filename) {
|
|
|
41744
43642
|
});
|
|
41745
43643
|
}
|
|
41746
43644
|
try {
|
|
41747
|
-
return JSON.parse(
|
|
43645
|
+
return JSON.parse(fs13.readFileSync(filename, "utf-8"));
|
|
41748
43646
|
} catch (error) {
|
|
41749
43647
|
throw new CliError(`Invalid JSON in ${filename}: ${error.message}`, {
|
|
41750
43648
|
code: "INVALID_JSON",
|
|
@@ -41758,7 +43656,7 @@ var init_file_utils = __esm(() => {
|
|
|
41758
43656
|
});
|
|
41759
43657
|
|
|
41760
43658
|
// source/commands/client.command.ts
|
|
41761
|
-
import
|
|
43659
|
+
import path18 from "node:path";
|
|
41762
43660
|
var ClientCommand;
|
|
41763
43661
|
var init_client_command = __esm(async () => {
|
|
41764
43662
|
init_cli_output();
|
|
@@ -41778,7 +43676,7 @@ var init_client_command = __esm(async () => {
|
|
|
41778
43676
|
baseUrl: options.baseUrl || undefined
|
|
41779
43677
|
});
|
|
41780
43678
|
const outDir = options.out ?? "./sdk";
|
|
41781
|
-
const result = writeFiles(
|
|
43679
|
+
const result = writeFiles(path18.resolve(this.workdir, outDir), [
|
|
41782
43680
|
{ path: "index.ts", content }
|
|
41783
43681
|
], {
|
|
41784
43682
|
force: options.force,
|
|
@@ -41787,7 +43685,7 @@ var init_client_command = __esm(async () => {
|
|
|
41787
43685
|
const payload = {
|
|
41788
43686
|
schemaVersion: CLI_JSON_SCHEMA_VERSION,
|
|
41789
43687
|
status: options.dryRun ? "planned" : "generated",
|
|
41790
|
-
output:
|
|
43688
|
+
output: path18.resolve(this.workdir, outDir),
|
|
41791
43689
|
routes: manifest.routes.length,
|
|
41792
43690
|
files: result.files
|
|
41793
43691
|
};
|
|
@@ -41903,8 +43801,8 @@ var init_contract = __esm(() => {
|
|
|
41903
43801
|
});
|
|
41904
43802
|
|
|
41905
43803
|
// source/commands/contract.command.ts
|
|
41906
|
-
import
|
|
41907
|
-
import
|
|
43804
|
+
import path19 from "node:path";
|
|
43805
|
+
import fs14 from "node:fs";
|
|
41908
43806
|
var ContractCommand;
|
|
41909
43807
|
var init_contract_command = __esm(async () => {
|
|
41910
43808
|
init_cli_output();
|
|
@@ -41921,8 +43819,8 @@ var init_contract_command = __esm(async () => {
|
|
|
41921
43819
|
}
|
|
41922
43820
|
async check(options) {
|
|
41923
43821
|
const { manifest } = await loadProject(this.workdir, options.json);
|
|
41924
|
-
const baselineFile =
|
|
41925
|
-
const baseline =
|
|
43822
|
+
const baselineFile = path19.resolve(this.workdir, options.baseline);
|
|
43823
|
+
const baseline = readJsonFile2(baselineFile);
|
|
41926
43824
|
const result = checkContracts(manifest, baseline);
|
|
41927
43825
|
if (options.json) {
|
|
41928
43826
|
print({
|
|
@@ -41947,9 +43845,9 @@ var init_contract_command = __esm(async () => {
|
|
|
41947
43845
|
}
|
|
41948
43846
|
async snapshot(options) {
|
|
41949
43847
|
const { manifest } = await loadProject(this.workdir, options.json);
|
|
41950
|
-
const filename =
|
|
41951
|
-
if (
|
|
41952
|
-
throw new CliError(`Refusing to overwrite existing baseline: ${
|
|
43848
|
+
const filename = path19.resolve(this.workdir, options.out);
|
|
43849
|
+
if (fs14.existsSync(filename) && !options.force) {
|
|
43850
|
+
throw new CliError(`Refusing to overwrite existing baseline: ${path19.relative(this.workdir, filename)}`, {
|
|
41953
43851
|
code: "FILE_CONFLICT",
|
|
41954
43852
|
hint: "Pass --force to overwrite the contract baseline explicitly.",
|
|
41955
43853
|
location: filename,
|
|
@@ -41958,19 +43856,19 @@ var init_contract_command = __esm(async () => {
|
|
|
41958
43856
|
}
|
|
41959
43857
|
if (options.dryRun) {
|
|
41960
43858
|
if (options.json) {
|
|
41961
|
-
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "planned", file:
|
|
43859
|
+
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "planned", file: path19.relative(this.workdir, filename) }, true);
|
|
41962
43860
|
} else {
|
|
41963
|
-
print(`Would write contract baseline to ${
|
|
43861
|
+
print(`Would write contract baseline to ${path19.relative(process.cwd(), filename)}`);
|
|
41964
43862
|
}
|
|
41965
43863
|
return;
|
|
41966
43864
|
}
|
|
41967
|
-
|
|
41968
|
-
|
|
43865
|
+
fs14.mkdirSync(path19.dirname(filename), { recursive: true });
|
|
43866
|
+
fs14.writeFileSync(filename, JSON.stringify(manifest, null, 2) + `
|
|
41969
43867
|
`, "utf-8");
|
|
41970
43868
|
if (options.json) {
|
|
41971
43869
|
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "snapshot", file: filename, routes: manifest.routes.length }, true);
|
|
41972
43870
|
} else {
|
|
41973
|
-
print(`Contract baseline written to ${
|
|
43871
|
+
print(`Contract baseline written to ${path19.relative(process.cwd(), filename)}`);
|
|
41974
43872
|
}
|
|
41975
43873
|
}
|
|
41976
43874
|
};
|
|
@@ -42617,8 +44515,8 @@ var init_framework = __esm(async () => {
|
|
|
42617
44515
|
|
|
42618
44516
|
// source/bin/cli-tools.ts
|
|
42619
44517
|
import { spawn as spawn2 } from "node:child_process";
|
|
42620
|
-
import
|
|
42621
|
-
import
|
|
44518
|
+
import path20 from "node:path";
|
|
44519
|
+
import fs15 from "node:fs";
|
|
42622
44520
|
|
|
42623
44521
|
class CliTools {
|
|
42624
44522
|
static get cwd() {
|
|
@@ -42626,12 +44524,12 @@ class CliTools {
|
|
|
42626
44524
|
}
|
|
42627
44525
|
static cliEntry(appdir) {
|
|
42628
44526
|
if (isNodeUsed) {
|
|
42629
|
-
const built =
|
|
42630
|
-
if (
|
|
44527
|
+
const built = path20.join(appdir, "build", "bin", "index.mjs");
|
|
44528
|
+
if (fs15.existsSync(built))
|
|
42631
44529
|
return built;
|
|
42632
|
-
return
|
|
44530
|
+
return path20.join(appdir, "bin", "index.mjs");
|
|
42633
44531
|
}
|
|
42634
|
-
return
|
|
44532
|
+
return path20.join(appdir, "bin", "index.ts");
|
|
42635
44533
|
}
|
|
42636
44534
|
static set cwd(value) {
|
|
42637
44535
|
if (isDenoUsed) {
|
|
@@ -42682,8 +44580,8 @@ class CliTools {
|
|
|
42682
44580
|
const cmd = typeof command == "string" ? command : command[0];
|
|
42683
44581
|
const cmdArgs = typeof command == "string" ? args : [...command.slice(1), ...args];
|
|
42684
44582
|
if (cmd.endsWith(".ts")) {
|
|
42685
|
-
const entry = CliTools.cliEntry(
|
|
42686
|
-
if (
|
|
44583
|
+
const entry = CliTools.cliEntry(path20.resolve(cmd, "..", ".."));
|
|
44584
|
+
if (fs15.existsSync(entry)) {
|
|
42687
44585
|
return spawn2("node", [entry, ...cmdArgs], options);
|
|
42688
44586
|
}
|
|
42689
44587
|
return spawn2("node", [cmd, ...cmdArgs], options);
|
|
@@ -42738,8 +44636,8 @@ var init_develop_command = __esm(async () => {
|
|
|
42738
44636
|
});
|
|
42739
44637
|
|
|
42740
44638
|
// source/commands/docs.command.ts
|
|
42741
|
-
import
|
|
42742
|
-
import
|
|
44639
|
+
import fs16 from "node:fs";
|
|
44640
|
+
import path21 from "node:path";
|
|
42743
44641
|
function relativeRoutes(manifest) {
|
|
42744
44642
|
if (!manifest.routes.length)
|
|
42745
44643
|
return "No route is currently mounted.";
|
|
@@ -42780,14 +44678,14 @@ ${relativeRoutes(manifest)}
|
|
|
42780
44678
|
function fullReference(manifest, docsDir) {
|
|
42781
44679
|
const sections = [compactIndex(manifest)];
|
|
42782
44680
|
for (const file of GUIDE_FILES) {
|
|
42783
|
-
const filename =
|
|
42784
|
-
if (!
|
|
44681
|
+
const filename = path21.join(docsDir, file);
|
|
44682
|
+
if (!fs16.existsSync(filename))
|
|
42785
44683
|
continue;
|
|
42786
44684
|
sections.push(`
|
|
42787
44685
|
|
|
42788
44686
|
<!-- ${file} -->
|
|
42789
44687
|
|
|
42790
|
-
${
|
|
44688
|
+
${fs16.readFileSync(filename, "utf-8")}`);
|
|
42791
44689
|
}
|
|
42792
44690
|
sections.push(`
|
|
42793
44691
|
|
|
@@ -42911,6 +44809,7 @@ var init_docs_command = __esm(async () => {
|
|
|
42911
44809
|
"user-guide/api/routes.md",
|
|
42912
44810
|
"user-guide/responses.md",
|
|
42913
44811
|
"user-guide/injection.md",
|
|
44812
|
+
"user-guide/artifact-bridge.md",
|
|
42914
44813
|
"user-guide/contracts.md",
|
|
42915
44814
|
"user-guide/mcp.md",
|
|
42916
44815
|
"user-guide/observability.md",
|
|
@@ -42957,7 +44856,7 @@ var init_docs_command = __esm(async () => {
|
|
|
42957
44856
|
current = generateManifest({ refresh: true, workdir: this.workdir });
|
|
42958
44857
|
}
|
|
42959
44858
|
const manifest = { ...current, generatedAt: "generated" };
|
|
42960
|
-
const docsDir =
|
|
44859
|
+
const docsDir = path21.resolve(this.workdir, options.out ?? "docs");
|
|
42961
44860
|
const generated = {
|
|
42962
44861
|
"llms.txt": compactIndex(manifest),
|
|
42963
44862
|
"llms-full.txt": fullReference(manifest, docsDir),
|
|
@@ -42974,17 +44873,17 @@ var init_docs_command = __esm(async () => {
|
|
|
42974
44873
|
const stale = [];
|
|
42975
44874
|
if (options.check) {
|
|
42976
44875
|
for (const [relative, content] of Object.entries(generated)) {
|
|
42977
|
-
const filename =
|
|
42978
|
-
if (!
|
|
44876
|
+
const filename = path21.join(docsDir, relative);
|
|
44877
|
+
if (!fs16.existsSync(filename) || fs16.readFileSync(filename, "utf-8") !== content) {
|
|
42979
44878
|
stale.push(relative);
|
|
42980
44879
|
}
|
|
42981
44880
|
}
|
|
42982
44881
|
return { schemaVersion: CLI_JSON_SCHEMA_VERSION, output: docsDir, files: Object.keys(generated), stale };
|
|
42983
44882
|
}
|
|
42984
44883
|
for (const [relative, content] of Object.entries(generated)) {
|
|
42985
|
-
const filename =
|
|
42986
|
-
|
|
42987
|
-
|
|
44884
|
+
const filename = path21.join(docsDir, relative);
|
|
44885
|
+
fs16.mkdirSync(path21.dirname(filename), { recursive: true });
|
|
44886
|
+
fs16.writeFileSync(filename, content, "utf-8");
|
|
42988
44887
|
}
|
|
42989
44888
|
return { schemaVersion: CLI_JSON_SCHEMA_VERSION, output: docsDir, files: Object.keys(generated), stale: [] };
|
|
42990
44889
|
}
|
|
@@ -42992,8 +44891,8 @@ var init_docs_command = __esm(async () => {
|
|
|
42992
44891
|
});
|
|
42993
44892
|
|
|
42994
44893
|
// source/commands/doctor.command.ts
|
|
42995
|
-
import
|
|
42996
|
-
import
|
|
44894
|
+
import fs17 from "node:fs";
|
|
44895
|
+
import path22 from "node:path";
|
|
42997
44896
|
import net from "node:net";
|
|
42998
44897
|
function runtimeVersion() {
|
|
42999
44898
|
const versions = process.versions;
|
|
@@ -43017,7 +44916,10 @@ var init_doctor_command = __esm(async () => {
|
|
|
43017
44916
|
init_config();
|
|
43018
44917
|
init_catalog();
|
|
43019
44918
|
init_constants2();
|
|
43020
|
-
await
|
|
44919
|
+
await __promiseAll([
|
|
44920
|
+
init_project_utils(),
|
|
44921
|
+
init_loader()
|
|
44922
|
+
]);
|
|
43021
44923
|
DoctorCommand = class DoctorCommand extends RaitonCommand {
|
|
43022
44924
|
name = "doctor";
|
|
43023
44925
|
description = "Diagnose the runtime, configuration and project prerequisites";
|
|
@@ -43054,12 +44956,12 @@ ${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${resu
|
|
|
43054
44956
|
const add = (code, severity, message, action, docsPath = "user-guide/cli.md", location2) => issues.push({ code, severity, message, action, docsUrl: errorDocsUrl(docsPath), location: location2 });
|
|
43055
44957
|
const runtime = runtimeVersion();
|
|
43056
44958
|
add("RUNTIME", "info", `Runtime: ${runtime.name} ${runtime.version}`, "No action required.");
|
|
43057
|
-
const packageFile =
|
|
43058
|
-
if (!
|
|
44959
|
+
const packageFile = path22.join(this.workdir, "package.json");
|
|
44960
|
+
if (!fs17.existsSync(packageFile)) {
|
|
43059
44961
|
add("PACKAGE_MISSING", "error", "package.json not found", "Run `raiton new` or create a package.json.", "user-guide/getting-started.md", packageFile);
|
|
43060
44962
|
} else {
|
|
43061
44963
|
try {
|
|
43062
|
-
const pkg = JSON.parse(
|
|
44964
|
+
const pkg = JSON.parse(fs17.readFileSync(packageFile, "utf-8"));
|
|
43063
44965
|
const raitonVersion = pkg.dependencies?.raiton ?? pkg.devDependencies?.raiton;
|
|
43064
44966
|
if (raitonVersion) {
|
|
43065
44967
|
add("FRAMEWORK_VERSION", "info", `Raiton dependency: ${raitonVersion}`, "No action required.");
|
|
@@ -43081,19 +44983,30 @@ ${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${resu
|
|
|
43081
44983
|
for (const configError of RaitonConfig.errors) {
|
|
43082
44984
|
add("CONFIG_FIELD", "error", `Configuration: ${configError.field} ${configError.message}`, "Fix the field in raiton.config.*.", "user-guide/config.md", RaitonConfig.source ?? undefined);
|
|
43083
44985
|
}
|
|
43084
|
-
const
|
|
43085
|
-
|
|
43086
|
-
|
|
44986
|
+
const bridgeDiagnostics = BridgeLoader.diagnose(this.workdir);
|
|
44987
|
+
for (const diagnostic of bridgeDiagnostics) {
|
|
44988
|
+
issues.push({
|
|
44989
|
+
code: diagnostic.code,
|
|
44990
|
+
severity: diagnostic.severity,
|
|
44991
|
+
message: diagnostic.message,
|
|
44992
|
+
action: diagnostic.action,
|
|
44993
|
+
docsUrl: diagnostic.docsUrl,
|
|
44994
|
+
location: diagnostic.location
|
|
44995
|
+
});
|
|
44996
|
+
}
|
|
44997
|
+
const root = path22.resolve(this.workdir, RaitonConfig.get("rootDir") || "./");
|
|
44998
|
+
if (!fs17.existsSync(root)) {
|
|
44999
|
+
add("SOURCE_MISSING", "error", `Source directory not found: ${path22.relative(this.workdir, root)}`, "Create the directory or fix rootDir.", "user-guide/config.md", root);
|
|
43087
45000
|
}
|
|
43088
|
-
const entry =
|
|
43089
|
-
if (!
|
|
45001
|
+
const entry = path22.join(root, "main.ts");
|
|
45002
|
+
if (!fs17.existsSync(entry)) {
|
|
43090
45003
|
add("ENTRY_MISSING", "error", "Entry point source/main.ts not found", "Create source/main.ts exporting a default bootstrapper.", "user-guide/getting-started.md", entry);
|
|
43091
45004
|
}
|
|
43092
|
-
const tsconfig =
|
|
43093
|
-
if (!
|
|
45005
|
+
const tsconfig = path22.join(this.workdir, "tsconfig.json");
|
|
45006
|
+
if (!fs17.existsSync(tsconfig)) {
|
|
43094
45007
|
add("TSCONFIG_MISSING", "warning", "tsconfig.json not found", "Add a tsconfig with experimentalDecorators and emitDecoratorMetadata.", "user-guide/getting-started.md", tsconfig);
|
|
43095
45008
|
} else {
|
|
43096
|
-
const content =
|
|
45009
|
+
const content = fs17.readFileSync(tsconfig, "utf-8");
|
|
43097
45010
|
if (!content.includes("experimentalDecorators")) {
|
|
43098
45011
|
add("DECORATORS_DISABLED", "warning", "tsconfig.json does not enable experimentalDecorators", "Enable experimentalDecorators for controllers and MCP tools.", "user-guide/getting-started.md", tsconfig);
|
|
43099
45012
|
}
|
|
@@ -43111,6 +45024,22 @@ ${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${resu
|
|
|
43111
45024
|
}
|
|
43112
45025
|
try {
|
|
43113
45026
|
const { manifest } = await loadProject(this.workdir, true);
|
|
45027
|
+
if (BridgeLoader.state.loaded) {
|
|
45028
|
+
const state = BridgeLoader.state;
|
|
45029
|
+
add("BRIDGE_LOADED", "info", `Bridge loaded: ${state.artifacts.length} artifact(s), ${state.packages.length} package(s)`, "No action required.", "user-guide/artifact-bridge.md", state.sourceFile ?? undefined);
|
|
45030
|
+
for (const diagnostic of state.diagnostics) {
|
|
45031
|
+
if (issues.some((issue) => issue.code === diagnostic.code && issue.message === diagnostic.message))
|
|
45032
|
+
continue;
|
|
45033
|
+
issues.push({
|
|
45034
|
+
code: diagnostic.code,
|
|
45035
|
+
severity: diagnostic.severity,
|
|
45036
|
+
message: diagnostic.message,
|
|
45037
|
+
action: diagnostic.action,
|
|
45038
|
+
docsUrl: diagnostic.docsUrl,
|
|
45039
|
+
location: diagnostic.location
|
|
45040
|
+
});
|
|
45041
|
+
}
|
|
45042
|
+
}
|
|
43114
45043
|
const envIssue = await this.fixEnv(manifest.env, options.fix, fixed);
|
|
43115
45044
|
if (envIssue)
|
|
43116
45045
|
add(...envIssue);
|
|
@@ -43135,7 +45064,19 @@ ${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${resu
|
|
|
43135
45064
|
}
|
|
43136
45065
|
}
|
|
43137
45066
|
} catch (error) {
|
|
43138
|
-
if (error?.code
|
|
45067
|
+
if (error?.code && String(error.code).startsWith("BRIDGE_")) {
|
|
45068
|
+
const message = error.message;
|
|
45069
|
+
if (!issues.some((issue) => issue.code === error.code && issue.message === message)) {
|
|
45070
|
+
issues.push({
|
|
45071
|
+
code: error.code,
|
|
45072
|
+
severity: "error",
|
|
45073
|
+
message,
|
|
45074
|
+
action: error.diagnostic?.action ?? error.hint ?? "Fix the bridge declaration and retry.",
|
|
45075
|
+
docsUrl: error.diagnostic?.docsUrl ?? error.docsUrl ?? errorDocsUrl("user-guide/artifact-bridge.md"),
|
|
45076
|
+
location: error.diagnostic?.location ?? error.location
|
|
45077
|
+
});
|
|
45078
|
+
}
|
|
45079
|
+
} else if (error?.code !== "PREREQUISITE_MISSING") {
|
|
43139
45080
|
add("INTROSPECTION_FAILED", "error", `Could not inspect the project: ${error.message}`, "Fix the bootstrapper, then run `raiton doctor` again.", "user-guide/cli.md");
|
|
43140
45081
|
}
|
|
43141
45082
|
}
|
|
@@ -43149,11 +45090,11 @@ ${result.summary.errors} error(s), ${result.summary.warnings} warning(s), ${resu
|
|
|
43149
45090
|
async fixEnv(names, fix, fixed) {
|
|
43150
45091
|
if (!names.length)
|
|
43151
45092
|
return null;
|
|
43152
|
-
const file =
|
|
43153
|
-
if (
|
|
45093
|
+
const file = path22.join(this.workdir, ".env.example");
|
|
45094
|
+
if (fs17.existsSync(file))
|
|
43154
45095
|
return null;
|
|
43155
45096
|
if (fix) {
|
|
43156
|
-
|
|
45097
|
+
fs17.writeFileSync(file, names.map((name) => `${name}=`).join(`
|
|
43157
45098
|
`) + `
|
|
43158
45099
|
`, "utf-8");
|
|
43159
45100
|
fixed.push(".env.example");
|
|
@@ -43705,8 +45646,8 @@ var init_generate_command = __esm(() => {
|
|
|
43705
45646
|
});
|
|
43706
45647
|
|
|
43707
45648
|
// source/commands/inspect.command.ts
|
|
43708
|
-
import
|
|
43709
|
-
import
|
|
45649
|
+
import path23 from "node:path";
|
|
45650
|
+
import fs18 from "node:fs";
|
|
43710
45651
|
var InspectCommand;
|
|
43711
45652
|
var init_inspect_command = __esm(async () => {
|
|
43712
45653
|
init_cli_output();
|
|
@@ -43758,9 +45699,9 @@ var init_inspect_command = __esm(async () => {
|
|
|
43758
45699
|
throw error;
|
|
43759
45700
|
}
|
|
43760
45701
|
if (options.out) {
|
|
43761
|
-
const filename =
|
|
43762
|
-
if (
|
|
43763
|
-
throw new CliError(`Refusing to overwrite existing manifest: ${
|
|
45702
|
+
const filename = path23.resolve(this.workdir, options.out);
|
|
45703
|
+
if (fs18.existsSync(filename) && !options.force) {
|
|
45704
|
+
throw new CliError(`Refusing to overwrite existing manifest: ${path23.relative(this.workdir, filename)}`, {
|
|
43764
45705
|
code: "FILE_CONFLICT",
|
|
43765
45706
|
hint: "Pass --force to overwrite the manifest explicitly.",
|
|
43766
45707
|
location: filename,
|
|
@@ -43769,7 +45710,7 @@ var init_inspect_command = __esm(async () => {
|
|
|
43769
45710
|
}
|
|
43770
45711
|
writeManifest(filename, manifest);
|
|
43771
45712
|
if (!options.json)
|
|
43772
|
-
print(`Manifest written to ${
|
|
45713
|
+
print(`Manifest written to ${path23.relative(process.cwd(), filename)}`);
|
|
43773
45714
|
}
|
|
43774
45715
|
if (options.check) {
|
|
43775
45716
|
if (options.json)
|
|
@@ -43783,6 +45724,9 @@ var init_inspect_command = __esm(async () => {
|
|
|
43783
45724
|
} else {
|
|
43784
45725
|
print(`Manifest ${manifest.schemaVersion} · ${manifest.framework.name} ${manifest.framework.version}`);
|
|
43785
45726
|
print(`Routes: ${manifest.routes.length} · artifacts: ${manifest.artifacts.length} · MCP servers: ${manifest.mcp.length}`);
|
|
45727
|
+
if (manifest.bridge) {
|
|
45728
|
+
print(`Bridge: ${manifest.bridge.file ?? "none"} · loaded: ${manifest.bridge.loaded} · entries: ${manifest.bridge.artifacts.length} · unresolved: ${manifest.bridge.unresolved.length}`);
|
|
45729
|
+
}
|
|
43786
45730
|
if (manifest.routes.length) {
|
|
43787
45731
|
for (const route of manifest.routes) {
|
|
43788
45732
|
print(` ${route.method.padEnd(6)} ${route.path} → ${route.controller}.${route.handler} (${route.file}:${route.line})`);
|
|
@@ -45120,8 +47064,8 @@ var init_project_templates = __esm(() => {
|
|
|
45120
47064
|
});
|
|
45121
47065
|
|
|
45122
47066
|
// source/commands/new.command.ts
|
|
45123
|
-
import
|
|
45124
|
-
import
|
|
47067
|
+
import path24 from "node:path";
|
|
47068
|
+
import fs19 from "node:fs";
|
|
45125
47069
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
45126
47070
|
function detectRuntime() {
|
|
45127
47071
|
if (isBunUsed)
|
|
@@ -45156,8 +47100,8 @@ var init_new_command = __esm(() => {
|
|
|
45156
47100
|
async run(name, options) {
|
|
45157
47101
|
const template = assertTemplate(options.template ?? "api");
|
|
45158
47102
|
const runtime = assertRuntime(options.runtime ?? detectRuntime());
|
|
45159
|
-
const target = options.dir ?
|
|
45160
|
-
if (
|
|
47103
|
+
const target = options.dir ? path24.resolve(this.workdir, options.dir) : path24.resolve(this.workdir, name);
|
|
47104
|
+
if (fs19.existsSync(target) && !fs19.statSync(target).isDirectory()) {
|
|
45161
47105
|
throw new CliError(`Target exists and is not a directory: ${target}`, {
|
|
45162
47106
|
code: "INVALID_TARGET",
|
|
45163
47107
|
hint: "Choose another directory or remove the file.",
|
|
@@ -45209,14 +47153,14 @@ var init_new_command = __esm(() => {
|
|
|
45209
47153
|
return;
|
|
45210
47154
|
}
|
|
45211
47155
|
print(`Created ${payload.project} (${template}, ${runtime}) in ${target}`);
|
|
45212
|
-
print(`Next: cd ${
|
|
47156
|
+
print(`Next: cd ${path24.relative(process.cwd(), target) || "."} && ${runtime === "node" ? "npx raiton dev" : runtime === "deno" ? "deno task dev" : "bun raiton dev"}`);
|
|
45213
47157
|
}
|
|
45214
47158
|
};
|
|
45215
47159
|
});
|
|
45216
47160
|
|
|
45217
47161
|
// source/commands/openapi.command.ts
|
|
45218
|
-
import
|
|
45219
|
-
import
|
|
47162
|
+
import path25 from "node:path";
|
|
47163
|
+
import fs20 from "node:fs";
|
|
45220
47164
|
var OpenApiCommand;
|
|
45221
47165
|
var init_openapi_command = __esm(async () => {
|
|
45222
47166
|
init_cli_output();
|
|
@@ -45244,9 +47188,9 @@ var init_openapi_command = __esm(async () => {
|
|
|
45244
47188
|
description: options.description ?? ""
|
|
45245
47189
|
});
|
|
45246
47190
|
if (options.out) {
|
|
45247
|
-
const filename =
|
|
45248
|
-
if (
|
|
45249
|
-
throw new CliError(`Refusing to overwrite existing file: ${
|
|
47191
|
+
const filename = path25.resolve(this.workdir, options.out);
|
|
47192
|
+
if (fs20.existsSync(filename) && !options.force) {
|
|
47193
|
+
throw new CliError(`Refusing to overwrite existing file: ${path25.relative(this.workdir, filename)}`, {
|
|
45250
47194
|
code: "FILE_CONFLICT",
|
|
45251
47195
|
hint: "Pass --force to overwrite the OpenAPI document explicitly.",
|
|
45252
47196
|
location: filename,
|
|
@@ -45255,19 +47199,19 @@ var init_openapi_command = __esm(async () => {
|
|
|
45255
47199
|
}
|
|
45256
47200
|
if (options.dryRun) {
|
|
45257
47201
|
if (options.json) {
|
|
45258
|
-
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "planned", file:
|
|
47202
|
+
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "planned", file: path25.relative(this.workdir, filename) }, true);
|
|
45259
47203
|
} else {
|
|
45260
|
-
print(`Would write OpenAPI document to ${
|
|
47204
|
+
print(`Would write OpenAPI document to ${path25.relative(process.cwd(), filename)}`);
|
|
45261
47205
|
}
|
|
45262
47206
|
return;
|
|
45263
47207
|
}
|
|
45264
|
-
|
|
45265
|
-
|
|
47208
|
+
fs20.mkdirSync(path25.dirname(filename), { recursive: true });
|
|
47209
|
+
fs20.writeFileSync(filename, JSON.stringify(spec, null, 2) + `
|
|
45266
47210
|
`, "utf-8");
|
|
45267
47211
|
if (options.json) {
|
|
45268
|
-
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "exported", file:
|
|
47212
|
+
print({ schemaVersion: CLI_JSON_SCHEMA_VERSION, status: "exported", file: path25.relative(this.workdir, filename), paths: Object.keys(spec.paths ?? {}).length }, true);
|
|
45269
47213
|
} else {
|
|
45270
|
-
print(`OpenAPI document written to ${
|
|
47214
|
+
print(`OpenAPI document written to ${path25.relative(process.cwd(), filename)}`);
|
|
45271
47215
|
}
|
|
45272
47216
|
return;
|
|
45273
47217
|
}
|
|
@@ -45414,13 +47358,14 @@ var init_routes_command = __esm(async () => {
|
|
|
45414
47358
|
var StartCommand;
|
|
45415
47359
|
var init_start_command = __esm(async () => {
|
|
45416
47360
|
init_build3();
|
|
47361
|
+
init_cli_output();
|
|
45417
47362
|
await init_core();
|
|
45418
47363
|
StartCommand = class StartCommand extends RaitonCommand {
|
|
45419
47364
|
name = "start";
|
|
45420
47365
|
description = "Run the application in production mode";
|
|
45421
47366
|
child = null;
|
|
45422
47367
|
register() {
|
|
45423
|
-
this.cli.command(this.name).alias("run").description("Start the application in production mode").option("--develop, -d", "Build in development mode").action(this.run.
|
|
47368
|
+
this.cli.command(this.name).alias("run").description("Start the application in production mode").option("--develop, -d", "Build in development mode").action((options) => this.run(options).catch((error) => fail(error)));
|
|
45424
47369
|
}
|
|
45425
47370
|
async run(options) {
|
|
45426
47371
|
if (options.develop)
|
|
@@ -45574,16 +47519,16 @@ var init_verify = __esm(() => {
|
|
|
45574
47519
|
});
|
|
45575
47520
|
|
|
45576
47521
|
// source/commands/verify.command.ts
|
|
45577
|
-
import
|
|
45578
|
-
import
|
|
47522
|
+
import path26 from "node:path";
|
|
47523
|
+
import fs21 from "node:fs";
|
|
45579
47524
|
function loadOpenApiRoutes(workdir) {
|
|
45580
47525
|
const candidates = [
|
|
45581
|
-
|
|
45582
|
-
|
|
45583
|
-
|
|
45584
|
-
|
|
47526
|
+
path26.join(workdir, "openapi.json"),
|
|
47527
|
+
path26.join(workdir, ".raiton", "openapi.json"),
|
|
47528
|
+
path26.join(workdir, "docs", "openapi.json"),
|
|
47529
|
+
path26.join(workdir, "docs", "generated", "openapi.json")
|
|
45585
47530
|
];
|
|
45586
|
-
const filename = candidates.find((candidate) =>
|
|
47531
|
+
const filename = candidates.find((candidate) => fs21.existsSync(candidate));
|
|
45587
47532
|
if (!filename) {
|
|
45588
47533
|
throw new CliError("No OpenAPI document found", {
|
|
45589
47534
|
code: "OPENAPI_NOT_FOUND",
|
|
@@ -45593,7 +47538,7 @@ function loadOpenApiRoutes(workdir) {
|
|
|
45593
47538
|
}
|
|
45594
47539
|
let document2;
|
|
45595
47540
|
try {
|
|
45596
|
-
document2 = JSON.parse(
|
|
47541
|
+
document2 = JSON.parse(fs21.readFileSync(filename, "utf-8"));
|
|
45597
47542
|
} catch (error) {
|
|
45598
47543
|
throw new CliError(`Invalid OpenAPI document: ${error.message}`, {
|
|
45599
47544
|
code: "INVALID_OPENAPI",
|
|
@@ -45735,6 +47680,8 @@ var init_why_command = __esm(async () => {
|
|
|
45735
47680
|
handler: route.handler,
|
|
45736
47681
|
decorator: `@${route.method.charAt(0)}${route.method.slice(1).toLowerCase()}("${route.path}")`,
|
|
45737
47682
|
artifact: route.controller === "Application" ? "application" : "controller",
|
|
47683
|
+
origin: route.origin ?? "scan",
|
|
47684
|
+
...route.package ? { package: route.package } : {},
|
|
45738
47685
|
input: route.input,
|
|
45739
47686
|
output: route.output
|
|
45740
47687
|
};
|
|
@@ -45747,6 +47694,9 @@ var init_why_command = __esm(async () => {
|
|
|
45747
47694
|
print(` controller: ${origin.controller}.${origin.handler}`);
|
|
45748
47695
|
print(` decorator: ${origin.decorator}`);
|
|
45749
47696
|
print(` artifact: ${origin.artifact}`);
|
|
47697
|
+
print(` origin: ${origin.origin}`);
|
|
47698
|
+
if (origin.package)
|
|
47699
|
+
print(` package: ${origin.package}`);
|
|
45750
47700
|
if (origin.input)
|
|
45751
47701
|
print(` input: ${origin.input}`);
|
|
45752
47702
|
if (origin.output)
|
|
@@ -45803,8 +47753,8 @@ var init_commands_registry = __esm(async () => {
|
|
|
45803
47753
|
});
|
|
45804
47754
|
|
|
45805
47755
|
// source/core/commands.ts
|
|
45806
|
-
import
|
|
45807
|
-
import
|
|
47756
|
+
import fs22 from "node:fs";
|
|
47757
|
+
import path27 from "node:path";
|
|
45808
47758
|
|
|
45809
47759
|
class RaitonCommands {
|
|
45810
47760
|
cli;
|
|
@@ -45817,9 +47767,9 @@ class RaitonCommands {
|
|
|
45817
47767
|
this.workdir = workdir;
|
|
45818
47768
|
}
|
|
45819
47769
|
async harvest() {
|
|
45820
|
-
const dir =
|
|
45821
|
-
if (
|
|
45822
|
-
const files =
|
|
47770
|
+
const dir = path27.join(this.appdir, "commands");
|
|
47771
|
+
if (fs22.existsSync(dir)) {
|
|
47772
|
+
const files = fs22.readdirSync(dir);
|
|
45823
47773
|
for (const file of files) {
|
|
45824
47774
|
if (file.startsWith("~"))
|
|
45825
47775
|
continue;
|
|
@@ -45827,7 +47777,7 @@ class RaitonCommands {
|
|
|
45827
47777
|
continue;
|
|
45828
47778
|
if (!file.includes(".command."))
|
|
45829
47779
|
continue;
|
|
45830
|
-
const filepath =
|
|
47780
|
+
const filepath = path27.join(dir, file);
|
|
45831
47781
|
const mod = await import(filepath);
|
|
45832
47782
|
const capability = new mod.default(this.cli, this.workdir, this.appdir);
|
|
45833
47783
|
if (!(capability instanceof RaitonCommand))
|
|
@@ -45899,6 +47849,23 @@ var init_mcp3 = __esm(async () => {
|
|
|
45899
47849
|
init_tracker();
|
|
45900
47850
|
});
|
|
45901
47851
|
|
|
47852
|
+
// source/core/bridge/definition.ts
|
|
47853
|
+
var init_definition = __esm(() => {
|
|
47854
|
+
init_diagnostics();
|
|
47855
|
+
});
|
|
47856
|
+
|
|
47857
|
+
// source/core/bridge/index.ts
|
|
47858
|
+
var init_bridge = __esm(async () => {
|
|
47859
|
+
init_diagnostics();
|
|
47860
|
+
init_definition();
|
|
47861
|
+
init_classifier();
|
|
47862
|
+
init_registry2();
|
|
47863
|
+
init_paths();
|
|
47864
|
+
init_resolver();
|
|
47865
|
+
init_packages();
|
|
47866
|
+
init_loader();
|
|
47867
|
+
});
|
|
47868
|
+
|
|
45902
47869
|
// source/core/index.ts
|
|
45903
47870
|
var init_core = __esm(async () => {
|
|
45904
47871
|
init_config2();
|
|
@@ -45915,6 +47882,7 @@ var init_core = __esm(async () => {
|
|
|
45915
47882
|
init_plugins();
|
|
45916
47883
|
init_middleware();
|
|
45917
47884
|
init_router2();
|
|
47885
|
+
init_bridge();
|
|
45918
47886
|
});
|
|
45919
47887
|
|
|
45920
47888
|
// node_modules/commander/index.js
|