threadforge 0.1.1 → 0.2.1
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/README.md +52 -20
- package/bin/forge.js +2 -1058
- package/bin/host-commands.d.ts +2 -0
- package/bin/host-commands.d.ts.map +1 -0
- package/bin/host-commands.js +7 -8
- package/bin/platform-commands.d.ts +2 -0
- package/bin/platform-commands.d.ts.map +1 -0
- package/bin/platform-commands.js +118 -36
- package/dist/cli/base-command.d.ts +12 -0
- package/dist/cli/base-command.d.ts.map +1 -0
- package/dist/cli/base-command.js +25 -0
- package/dist/cli/base-command.js.map +1 -0
- package/dist/cli/commands/build.d.ts +10 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +110 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +12 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +143 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +10 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +138 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +10 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +76 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/host.d.ts +8 -0
- package/dist/cli/commands/host.d.ts.map +1 -0
- package/dist/cli/commands/host.js +20 -0
- package/dist/cli/commands/host.js.map +1 -0
- package/dist/cli/commands/init.d.ts +16 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +246 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/platform.d.ts +8 -0
- package/dist/cli/commands/platform.d.ts.map +1 -0
- package/dist/cli/commands/platform.js +20 -0
- package/dist/cli/commands/platform.js.map +1 -0
- package/dist/cli/commands/restart.d.ts +8 -0
- package/dist/cli/commands/restart.d.ts.map +1 -0
- package/dist/cli/commands/restart.js +13 -0
- package/dist/cli/commands/restart.js.map +1 -0
- package/dist/cli/commands/scaffold/frontend.d.ts +10 -0
- package/dist/cli/commands/scaffold/frontend.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/frontend.js +130 -0
- package/dist/cli/commands/scaffold/frontend.js.map +1 -0
- package/dist/cli/commands/scaffold/react.d.ts +7 -0
- package/dist/cli/commands/scaffold/react.d.ts.map +1 -0
- package/dist/cli/commands/scaffold/react.js +12 -0
- package/dist/cli/commands/scaffold/react.js.map +1 -0
- package/dist/cli/commands/scale.d.ts +8 -0
- package/dist/cli/commands/scale.d.ts.map +1 -0
- package/dist/cli/commands/scale.js +13 -0
- package/dist/cli/commands/scale.js.map +1 -0
- package/dist/cli/commands/start.d.ts +10 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +71 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/status.d.ts +11 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +60 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +10 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +89 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/util/config-discovery.d.ts +8 -0
- package/dist/cli/util/config-discovery.d.ts.map +1 -0
- package/dist/cli/util/config-discovery.js +70 -0
- package/dist/cli/util/config-discovery.js.map +1 -0
- package/dist/cli/util/config-patcher.d.ts +17 -0
- package/dist/cli/util/config-patcher.d.ts.map +1 -0
- package/dist/cli/util/config-patcher.js +439 -0
- package/dist/cli/util/config-patcher.js.map +1 -0
- package/dist/cli/util/frontend-dev.d.ts +8 -0
- package/dist/cli/util/frontend-dev.d.ts.map +1 -0
- package/dist/cli/util/frontend-dev.js +117 -0
- package/dist/cli/util/frontend-dev.js.map +1 -0
- package/dist/cli/util/process.d.ts +5 -0
- package/dist/cli/util/process.d.ts.map +1 -0
- package/dist/cli/util/process.js +17 -0
- package/dist/cli/util/process.js.map +1 -0
- package/dist/cli/util/templates.d.ts +10 -0
- package/dist/cli/util/templates.d.ts.map +1 -0
- package/dist/cli/util/templates.js +157 -0
- package/dist/cli/util/templates.js.map +1 -0
- package/dist/core/AlertSink.d.ts +83 -0
- package/dist/core/AlertSink.d.ts.map +1 -0
- package/dist/core/AlertSink.js +126 -0
- package/dist/core/AlertSink.js.map +1 -0
- package/dist/core/DirectMessageBus.d.ts +88 -0
- package/dist/core/DirectMessageBus.d.ts.map +1 -0
- package/dist/core/DirectMessageBus.js +352 -0
- package/dist/core/DirectMessageBus.js.map +1 -0
- package/dist/core/EndpointResolver.d.ts +111 -0
- package/dist/core/EndpointResolver.d.ts.map +1 -0
- package/dist/core/EndpointResolver.js +336 -0
- package/dist/core/EndpointResolver.js.map +1 -0
- package/dist/core/ForgeContext.d.ts +221 -0
- package/dist/core/ForgeContext.d.ts.map +1 -0
- package/dist/core/ForgeContext.js +1169 -0
- package/dist/core/ForgeContext.js.map +1 -0
- package/dist/core/ForgeEndpoints.d.ts +71 -0
- package/dist/core/ForgeEndpoints.d.ts.map +1 -0
- package/dist/core/ForgeEndpoints.js +442 -0
- package/dist/core/ForgeEndpoints.js.map +1 -0
- package/dist/core/ForgeHost.d.ts +82 -0
- package/dist/core/ForgeHost.d.ts.map +1 -0
- package/dist/core/ForgeHost.js +107 -0
- package/dist/core/ForgeHost.js.map +1 -0
- package/dist/core/ForgePlatform.d.ts +96 -0
- package/dist/core/ForgePlatform.d.ts.map +1 -0
- package/dist/core/ForgePlatform.js +136 -0
- package/dist/core/ForgePlatform.js.map +1 -0
- package/dist/core/ForgeWebSocket.d.ts +56 -0
- package/dist/core/ForgeWebSocket.d.ts.map +1 -0
- package/dist/core/ForgeWebSocket.js +415 -0
- package/dist/core/ForgeWebSocket.js.map +1 -0
- package/dist/core/Ingress.d.ts +329 -0
- package/dist/core/Ingress.d.ts.map +1 -0
- package/dist/core/Ingress.js +694 -0
- package/dist/core/Ingress.js.map +1 -0
- package/dist/core/Interceptors.d.ts +134 -0
- package/dist/core/Interceptors.d.ts.map +1 -0
- package/dist/core/Interceptors.js +416 -0
- package/dist/core/Interceptors.js.map +1 -0
- package/dist/core/Logger.d.ts +20 -0
- package/dist/core/Logger.d.ts.map +1 -0
- package/dist/core/Logger.js +77 -0
- package/dist/core/Logger.js.map +1 -0
- package/dist/core/MessageBus.d.ts +15 -0
- package/dist/core/MessageBus.d.ts.map +1 -0
- package/dist/core/MessageBus.js +18 -0
- package/dist/core/MessageBus.js.map +1 -0
- package/dist/core/Prometheus.d.ts +80 -0
- package/dist/core/Prometheus.d.ts.map +1 -0
- package/dist/core/Prometheus.js +332 -0
- package/dist/core/Prometheus.js.map +1 -0
- package/dist/core/RequestContext.d.ts +214 -0
- package/dist/core/RequestContext.d.ts.map +1 -0
- package/dist/core/RequestContext.js +556 -0
- package/dist/core/RequestContext.js.map +1 -0
- package/dist/core/Router.d.ts +45 -0
- package/dist/core/Router.d.ts.map +1 -0
- package/dist/core/Router.js +285 -0
- package/dist/core/Router.js.map +1 -0
- package/dist/core/RoutingStrategy.d.ts +116 -0
- package/dist/core/RoutingStrategy.d.ts.map +1 -0
- package/dist/core/RoutingStrategy.js +306 -0
- package/dist/core/RoutingStrategy.js.map +1 -0
- package/dist/core/RpcConfig.d.ts +72 -0
- package/dist/core/RpcConfig.d.ts.map +1 -0
- package/dist/core/RpcConfig.js +127 -0
- package/dist/core/RpcConfig.js.map +1 -0
- package/dist/core/SignatureCache.d.ts +81 -0
- package/dist/core/SignatureCache.d.ts.map +1 -0
- package/dist/core/SignatureCache.js +172 -0
- package/dist/core/SignatureCache.js.map +1 -0
- package/dist/core/StaticFileServer.d.ts +34 -0
- package/dist/core/StaticFileServer.d.ts.map +1 -0
- package/dist/core/StaticFileServer.js +497 -0
- package/dist/core/StaticFileServer.js.map +1 -0
- package/dist/core/Supervisor.d.ts +198 -0
- package/dist/core/Supervisor.d.ts.map +1 -0
- package/dist/core/Supervisor.js +1418 -0
- package/dist/core/Supervisor.js.map +1 -0
- package/dist/core/ThreadAllocator.d.ts +52 -0
- package/dist/core/ThreadAllocator.d.ts.map +1 -0
- package/dist/core/ThreadAllocator.js +174 -0
- package/dist/core/ThreadAllocator.js.map +1 -0
- package/dist/core/WorkerChannelManager.d.ts +130 -0
- package/dist/core/WorkerChannelManager.d.ts.map +1 -0
- package/dist/core/WorkerChannelManager.js +956 -0
- package/dist/core/WorkerChannelManager.js.map +1 -0
- package/dist/core/config-enums.d.ts +41 -0
- package/dist/core/config-enums.d.ts.map +1 -0
- package/dist/core/config-enums.js +59 -0
- package/dist/core/config-enums.js.map +1 -0
- package/dist/core/config.d.ts +159 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +694 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/host-config.d.ts +146 -0
- package/dist/core/host-config.d.ts.map +1 -0
- package/dist/core/host-config.js +312 -0
- package/dist/core/host-config.js.map +1 -0
- package/dist/core/ipc-errors.d.ts +27 -0
- package/dist/core/ipc-errors.d.ts.map +1 -0
- package/dist/core/ipc-errors.js +36 -0
- package/dist/core/ipc-errors.js.map +1 -0
- package/dist/core/network-utils.d.ts +35 -0
- package/dist/core/network-utils.d.ts.map +1 -0
- package/dist/core/network-utils.js +145 -0
- package/dist/core/network-utils.js.map +1 -0
- package/dist/core/platform-config.d.ts +142 -0
- package/dist/core/platform-config.d.ts.map +1 -0
- package/dist/core/platform-config.js +299 -0
- package/dist/core/platform-config.js.map +1 -0
- package/dist/decorators/ServiceProxy.d.ts +175 -0
- package/dist/decorators/ServiceProxy.d.ts.map +1 -0
- package/dist/decorators/ServiceProxy.js +969 -0
- package/dist/decorators/ServiceProxy.js.map +1 -0
- package/dist/decorators/index.d.ts +146 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +545 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/deploy/NginxGenerator.d.ts +165 -0
- package/dist/deploy/NginxGenerator.d.ts.map +1 -0
- package/dist/deploy/NginxGenerator.js +781 -0
- package/dist/deploy/NginxGenerator.js.map +1 -0
- package/dist/deploy/PlatformManifestGenerator.d.ts +43 -0
- package/dist/deploy/PlatformManifestGenerator.d.ts.map +1 -0
- package/dist/deploy/PlatformManifestGenerator.js +80 -0
- package/dist/deploy/PlatformManifestGenerator.js.map +1 -0
- package/dist/deploy/RouteManifestGenerator.d.ts +42 -0
- package/dist/deploy/RouteManifestGenerator.d.ts.map +1 -0
- package/dist/deploy/RouteManifestGenerator.js +105 -0
- package/dist/deploy/RouteManifestGenerator.js.map +1 -0
- package/dist/deploy/index.d.ts +210 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +918 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/frontend/FrontendDevLifecycle.d.ts +26 -0
- package/dist/frontend/FrontendDevLifecycle.d.ts.map +1 -0
- package/dist/frontend/FrontendDevLifecycle.js +60 -0
- package/dist/frontend/FrontendDevLifecycle.js.map +1 -0
- package/dist/frontend/FrontendPluginOrchestrator.d.ts +64 -0
- package/dist/frontend/FrontendPluginOrchestrator.d.ts.map +1 -0
- package/dist/frontend/FrontendPluginOrchestrator.js +167 -0
- package/dist/frontend/FrontendPluginOrchestrator.js.map +1 -0
- package/dist/frontend/SiteResolver.d.ts +33 -0
- package/dist/frontend/SiteResolver.d.ts.map +1 -0
- package/dist/frontend/SiteResolver.js +53 -0
- package/dist/frontend/SiteResolver.js.map +1 -0
- package/dist/frontend/StaticMountRegistry.d.ts +36 -0
- package/dist/frontend/StaticMountRegistry.d.ts.map +1 -0
- package/dist/frontend/StaticMountRegistry.js +94 -0
- package/dist/frontend/StaticMountRegistry.js.map +1 -0
- package/dist/frontend/index.d.ts +7 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/{src → dist}/frontend/index.js +4 -2
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/pathUtils.d.ts +8 -0
- package/dist/frontend/pathUtils.d.ts.map +1 -0
- package/dist/frontend/pathUtils.js +17 -0
- package/dist/frontend/pathUtils.js.map +1 -0
- package/dist/frontend/plugins/index.d.ts +2 -0
- package/dist/frontend/plugins/index.d.ts.map +1 -0
- package/{src → dist}/frontend/plugins/index.js +1 -1
- package/dist/frontend/plugins/index.js.map +1 -0
- package/dist/frontend/plugins/viteFrontend.d.ts +51 -0
- package/dist/frontend/plugins/viteFrontend.d.ts.map +1 -0
- package/dist/frontend/plugins/viteFrontend.js +134 -0
- package/dist/frontend/plugins/viteFrontend.js.map +1 -0
- package/dist/frontend/types.d.ts +25 -0
- package/dist/frontend/types.d.ts.map +1 -0
- package/dist/frontend/types.js +2 -0
- package/dist/frontend/types.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/internals.d.ts +21 -0
- package/dist/internals.d.ts.map +1 -0
- package/{src → dist}/internals.js +12 -14
- package/dist/internals.js.map +1 -0
- package/dist/plugins/PluginManager.d.ts +209 -0
- package/dist/plugins/PluginManager.d.ts.map +1 -0
- package/dist/plugins/PluginManager.js +365 -0
- package/dist/plugins/PluginManager.js.map +1 -0
- package/dist/plugins/ScopedPostgres.d.ts +78 -0
- package/dist/plugins/ScopedPostgres.d.ts.map +1 -0
- package/dist/plugins/ScopedPostgres.js +190 -0
- package/dist/plugins/ScopedPostgres.js.map +1 -0
- package/dist/plugins/ScopedRedis.d.ts +88 -0
- package/dist/plugins/ScopedRedis.d.ts.map +1 -0
- package/dist/plugins/ScopedRedis.js +169 -0
- package/dist/plugins/ScopedRedis.js.map +1 -0
- package/dist/plugins/index.d.ts +289 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +1942 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/types.d.ts +59 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/registry/ServiceRegistry.d.ts +305 -0
- package/dist/registry/ServiceRegistry.d.ts.map +1 -0
- package/dist/registry/ServiceRegistry.js +735 -0
- package/dist/registry/ServiceRegistry.js.map +1 -0
- package/dist/scaling/ScaleAdvisor.d.ts +214 -0
- package/dist/scaling/ScaleAdvisor.d.ts.map +1 -0
- package/dist/scaling/ScaleAdvisor.js +526 -0
- package/dist/scaling/ScaleAdvisor.js.map +1 -0
- package/dist/services/Service.d.ts +164 -0
- package/dist/services/Service.d.ts.map +1 -0
- package/dist/services/Service.js +106 -0
- package/dist/services/Service.js.map +1 -0
- package/dist/services/worker-bootstrap.d.ts +15 -0
- package/dist/services/worker-bootstrap.d.ts.map +1 -0
- package/dist/services/worker-bootstrap.js +744 -0
- package/dist/services/worker-bootstrap.js.map +1 -0
- package/dist/templates/auth-service.d.ts +42 -0
- package/dist/templates/auth-service.d.ts.map +1 -0
- package/dist/templates/auth-service.js +54 -0
- package/dist/templates/auth-service.js.map +1 -0
- package/dist/templates/identity-service.d.ts +50 -0
- package/dist/templates/identity-service.d.ts.map +1 -0
- package/dist/templates/identity-service.js +62 -0
- package/dist/templates/identity-service.js.map +1 -0
- package/dist/types/contract.d.ts +120 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/contract.js +69 -0
- package/dist/types/contract.js.map +1 -0
- package/package.json +78 -20
- package/src/core/DirectMessageBus.js +0 -364
- package/src/core/EndpointResolver.js +0 -259
- package/src/core/ForgeContext.js +0 -2236
- package/src/core/ForgeHost.js +0 -122
- package/src/core/ForgePlatform.js +0 -145
- package/src/core/Ingress.js +0 -768
- package/src/core/Interceptors.js +0 -420
- package/src/core/MessageBus.js +0 -321
- package/src/core/Prometheus.js +0 -305
- package/src/core/RequestContext.js +0 -413
- package/src/core/RoutingStrategy.js +0 -330
- package/src/core/Supervisor.js +0 -1349
- package/src/core/ThreadAllocator.js +0 -196
- package/src/core/WorkerChannelManager.js +0 -879
- package/src/core/config.js +0 -637
- package/src/core/host-config.js +0 -311
- package/src/core/network-utils.js +0 -166
- package/src/core/platform-config.js +0 -308
- package/src/decorators/ServiceProxy.js +0 -904
- package/src/decorators/index.js +0 -571
- package/src/deploy/NginxGenerator.js +0 -865
- package/src/deploy/PlatformManifestGenerator.js +0 -96
- package/src/deploy/RouteManifestGenerator.js +0 -112
- package/src/deploy/index.js +0 -984
- package/src/frontend/FrontendDevLifecycle.js +0 -65
- package/src/frontend/FrontendPluginOrchestrator.js +0 -187
- package/src/frontend/SiteResolver.js +0 -63
- package/src/frontend/StaticMountRegistry.js +0 -90
- package/src/frontend/plugins/viteFrontend.js +0 -79
- package/src/frontend/types.js +0 -35
- package/src/index.js +0 -58
- package/src/plugins/PluginManager.js +0 -537
- package/src/plugins/ScopedPostgres.js +0 -192
- package/src/plugins/ScopedRedis.js +0 -142
- package/src/plugins/index.js +0 -1756
- package/src/registry/ServiceRegistry.js +0 -797
- package/src/scaling/ScaleAdvisor.js +0 -442
- package/src/services/Service.js +0 -195
- package/src/services/worker-bootstrap.js +0 -679
- package/src/templates/auth-service.js +0 -65
- package/src/templates/identity-service.js +0 -75
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Platform Manifest Generator
|
|
3
|
-
*
|
|
4
|
-
* Generates a `routes/platform.yaml` manifest for ForgeProxy
|
|
5
|
-
* that describes the platform topology: apps, domains, shared services.
|
|
6
|
-
*
|
|
7
|
-
* ForgeProxy already loads `routes/*.yaml` with `host` and `project_id`
|
|
8
|
-
* fields — this file is supplementary metadata for tooling.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { resolveAppDomains } from "../core/platform-config.js";
|
|
12
|
-
|
|
13
|
-
function yamlString(value) {
|
|
14
|
-
const text = String(value ?? "");
|
|
15
|
-
return `'${text.replace(/'/g, "''")}'`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function yamlArray(values = []) {
|
|
19
|
-
return `[${values.map((value) => yamlString(value)).join(", ")}]`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Generate a platform.yaml manifest.
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} platformConfig - The platform block from the user config
|
|
26
|
-
* @param {Object} hostMeta - From resolveHostConfig().hostMeta
|
|
27
|
-
* @param {Object} [sites] - From resolveHostConfig().sites
|
|
28
|
-
* @returns {string} YAML string
|
|
29
|
-
*/
|
|
30
|
-
export function generatePlatformManifest(platformConfig, hostMeta, sites = {}) {
|
|
31
|
-
const apps = platformConfig.apps ?? {};
|
|
32
|
-
const globalAuth = platformConfig.globalAuth ?? false;
|
|
33
|
-
|
|
34
|
-
let yaml = `# Auto-generated by: forge platform generate\n`;
|
|
35
|
-
yaml += `# Do not edit — regenerate with: forge platform generate\n\n`;
|
|
36
|
-
|
|
37
|
-
yaml += `apps:\n`;
|
|
38
|
-
for (const [appId, app] of Object.entries(apps)) {
|
|
39
|
-
const domains = resolveAppDomains(app);
|
|
40
|
-
const meta = hostMeta?.[appId];
|
|
41
|
-
|
|
42
|
-
yaml += ` ${appId}:\n`;
|
|
43
|
-
yaml += ` domains: ${yamlArray(domains)}\n`;
|
|
44
|
-
|
|
45
|
-
// Reference per-service route manifests
|
|
46
|
-
if (meta?.services?.length > 0) {
|
|
47
|
-
const routeFiles = meta.services.map((s) => `routes/${s.replace(/:/g, "_")}.yaml`);
|
|
48
|
-
if (routeFiles.length === 1) {
|
|
49
|
-
yaml += ` routes: ${yamlString(routeFiles[0])}\n`;
|
|
50
|
-
} else {
|
|
51
|
-
yaml += ` routes:\n`;
|
|
52
|
-
for (const f of routeFiles) {
|
|
53
|
-
yaml += ` - ${yamlString(f)}\n`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (globalAuth) {
|
|
59
|
-
yaml += ` auth_required: true\n`;
|
|
60
|
-
yaml += ` public_paths: ${yamlArray(["/auth/*", "/public/*"])}\n`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (app.static) {
|
|
64
|
-
yaml += ` static: ${yamlString(app.static)}\n`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const site = sites?.[appId];
|
|
68
|
-
if (site?.frontend) {
|
|
69
|
-
yaml += ` frontend:\n`;
|
|
70
|
-
yaml += ` plugin: ${yamlString(site.frontend.plugin)}\n`;
|
|
71
|
-
yaml += ` base_path: ${yamlString(site.frontend.basePath)}\n`;
|
|
72
|
-
yaml += ` out_dir: ${yamlString(site.frontend.outDir)}\n`;
|
|
73
|
-
yaml += ` spa_fallback: ${site.frontend.spaFallback ? "true" : "false"}\n`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Shared services section (auth + identity when globalAuth is enabled)
|
|
78
|
-
if (globalAuth) {
|
|
79
|
-
const sharedEntries = [
|
|
80
|
-
{ name: "auth", prefix: "/auth", mountOnAll: true },
|
|
81
|
-
{ name: "identity", prefix: "/identity", mountOnAll: false },
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
yaml += `\nshared_services:\n`;
|
|
85
|
-
for (const entry of sharedEntries) {
|
|
86
|
-
yaml += ` ${entry.name}:\n`;
|
|
87
|
-
yaml += ` routes: ${yamlString(`routes/${entry.name}.yaml`)}\n`;
|
|
88
|
-
if (entry.mountOnAll) {
|
|
89
|
-
yaml += ` mount_on_all_apps: true\n`;
|
|
90
|
-
}
|
|
91
|
-
yaml += ` prefix: ${yamlString(entry.prefix)}\n`;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return yaml;
|
|
96
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Route Manifest Generator
|
|
3
|
-
*
|
|
4
|
-
* Reads service classes, extracts route + internal method declarations,
|
|
5
|
-
* and generates YAML route manifests for ForgeProxy.
|
|
6
|
-
*
|
|
7
|
-
* `forge generate` produces:
|
|
8
|
-
*
|
|
9
|
-
* # routes/users.yaml
|
|
10
|
-
* service: users
|
|
11
|
-
* prefix: /api/users
|
|
12
|
-
* auth: required
|
|
13
|
-
* rate_limit: 1000/min
|
|
14
|
-
*
|
|
15
|
-
* routes:
|
|
16
|
-
* - method: GET
|
|
17
|
-
* path: /:id
|
|
18
|
-
* handler: getUser
|
|
19
|
-
*
|
|
20
|
-
* # Backend-only methods (callable via IPC, not via HTTP)
|
|
21
|
-
* internal_methods:
|
|
22
|
-
* - name: validatePassword
|
|
23
|
-
* local_only: true # zero-copy, same-process only
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import { getContract, getInternalMethods } from "../decorators/index.js";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Generate a route manifest for a single service.
|
|
30
|
-
*/
|
|
31
|
-
export function generateRouteManifest(serviceName, ServiceClass, serviceConfig = {}) {
|
|
32
|
-
const contract = getContract(ServiceClass);
|
|
33
|
-
if (!contract || (contract.routes.length === 0 && contract.methods.size === 0)) return null;
|
|
34
|
-
|
|
35
|
-
const prefix = ServiceClass.prefix ?? serviceConfig.prefix ?? `/${serviceName}`;
|
|
36
|
-
const auth = ServiceClass.auth ?? serviceConfig.auth ?? "required";
|
|
37
|
-
const rateLimit = ServiceClass.rateLimit ?? serviceConfig.rateLimit ?? null;
|
|
38
|
-
|
|
39
|
-
let yaml = `# Auto-generated by: forge generate\n`;
|
|
40
|
-
yaml += `# Source: ${serviceName} service\n`;
|
|
41
|
-
yaml += `# Do not edit — regenerate with: forge generate\n\n`;
|
|
42
|
-
yaml += `service: '${serviceName}'\n`;
|
|
43
|
-
yaml += `prefix: '${prefix}'\n`;
|
|
44
|
-
yaml += `auth: '${auth}'\n`;
|
|
45
|
-
|
|
46
|
-
if (rateLimit) {
|
|
47
|
-
yaml += `rate_limit: '${rateLimit}'\n`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Multi-project host fields
|
|
51
|
-
if (serviceConfig._projectId) {
|
|
52
|
-
yaml += `project_id: '${serviceConfig._projectId}'\n`;
|
|
53
|
-
}
|
|
54
|
-
if (serviceConfig._hostDomain) {
|
|
55
|
-
yaml += `host: '${serviceConfig._hostDomain}'\n`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// HTTP routes (ForgeProxy handles these)
|
|
59
|
-
if (contract.routes.length > 0) {
|
|
60
|
-
yaml += `\nroutes:\n`;
|
|
61
|
-
for (const route of contract.routes) {
|
|
62
|
-
if (ServiceClass.prototype && typeof ServiceClass.prototype[route.handlerName] !== "function") {
|
|
63
|
-
console.warn(
|
|
64
|
-
`[Deploy] Route handler "${route.handlerName}" for ${route.httpMethod} ${route.path} ` +
|
|
65
|
-
`does not exist on ${serviceName}. Check contract definition.`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
yaml += ` - method: ${route.httpMethod}\n`;
|
|
70
|
-
yaml += ` path: ${route.path}\n`;
|
|
71
|
-
yaml += ` handler: ${route.handlerName}\n`;
|
|
72
|
-
|
|
73
|
-
if (route.auth && route.auth !== auth) {
|
|
74
|
-
yaml += ` auth: ${route.auth}\n`;
|
|
75
|
-
}
|
|
76
|
-
if (route.rateLimit) {
|
|
77
|
-
yaml += ` rate_limit: ${route.rateLimit}\n`;
|
|
78
|
-
}
|
|
79
|
-
if (route.cacheSecs) {
|
|
80
|
-
yaml += ` cache_secs: ${route.cacheSecs}\n`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Internal methods (backend-only, not routed via HTTP)
|
|
86
|
-
const internalMethods = getInternalMethods(ServiceClass);
|
|
87
|
-
if (internalMethods.length > 0) {
|
|
88
|
-
yaml += `\n# Backend-only methods (callable via IPC, not via HTTP)\n`;
|
|
89
|
-
yaml += `internal_methods:\n`;
|
|
90
|
-
for (const method of internalMethods) {
|
|
91
|
-
const meta = contract.methods.get(method);
|
|
92
|
-
yaml += ` - name: ${method}\n`;
|
|
93
|
-
if (meta?.options?.localOnly) {
|
|
94
|
-
yaml += ` local_only: true\n`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return yaml;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Generate route manifests for all services.
|
|
104
|
-
*/
|
|
105
|
-
export function generateAllRouteManifests(serviceClasses, serviceConfigs = {}) {
|
|
106
|
-
const manifests = new Map();
|
|
107
|
-
for (const [name, ServiceClass] of Object.entries(serviceClasses)) {
|
|
108
|
-
const yaml = generateRouteManifest(name, ServiceClass, serviceConfigs[name] ?? {});
|
|
109
|
-
if (yaml) manifests.set(name, yaml);
|
|
110
|
-
}
|
|
111
|
-
return manifests;
|
|
112
|
-
}
|