@fluojs/runtime 1.1.1 → 1.1.3
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.ko.md +8 -0
- package/README.md +8 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +41 -19
- package/dist/devtools/contracts.d.ts +138 -0
- package/dist/devtools/contracts.d.ts.map +1 -0
- package/dist/devtools/contracts.js +1 -0
- package/dist/devtools/index.d.ts +4 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/snapshot.d.ts +39 -0
- package/dist/devtools/snapshot.d.ts.map +1 -0
- package/dist/devtools/snapshot.js +345 -0
- package/dist/devtools/studio-runtime.d.ts +96 -0
- package/dist/devtools/studio-runtime.d.ts.map +1 -0
- package/dist/devtools/studio-runtime.js +335 -0
- package/dist/http-adapter-shared.js +3 -3
- package/dist/logging/default-logger.d.ts +8 -0
- package/dist/logging/default-logger.d.ts.map +1 -0
- package/dist/logging/default-logger.js +28 -0
- package/dist/node/internal-node.d.ts.map +1 -1
- package/dist/node/internal-node.js +8 -1
- package/package.json +3 -3
package/README.ko.md
CHANGED
|
@@ -80,6 +80,12 @@ await userService.doWork();
|
|
|
80
80
|
await context.close();
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Studio Devtools Bridge
|
|
84
|
+
|
|
85
|
+
`@fluojs/runtime`은 live Studio snapshot과 request trace를 publish할 수 있지만 `process.env`를 직접 읽지 않습니다. `fluo dev --studio`가 애플리케이션 경계에서 sidecar를 시작하고 tokenized Studio config를 만든 뒤, 앱이 runtime을 import하기 전에 해당 명시적 config를 Node 앱 child에 주입합니다. CLI가 제공한 config가 없거나 잘못되었거나 tokenized endpoint가 없으면 Studio instrumentation은 no-op이며 bootstrap 동작은 바뀌지 않습니다.
|
|
86
|
+
|
|
87
|
+
이 MVP에서 전체 지원 대상은 Node dev runner 프로젝트입니다. Bun, Deno, Cloudflare Workers의 live Studio는 dedicated bridge를 구현하고 검증하기 전까지 unsupported입니다. 해당 런타임에서도 Studio config가 없으면 bootstrap은 no-op이어야 합니다. Request trace는 body, cookie, 전체 header를 의도적으로 제외하며, runtime은 local token이 Studio event history에 남지 않도록 publish 전에 trace `url`에서 query string과 fragment를 제거합니다.
|
|
88
|
+
|
|
83
89
|
### 전역 예외 필터
|
|
84
90
|
|
|
85
91
|
부트스트랩 시 필터를 등록하여 횡단 관심사 에러를 처리합니다.
|
|
@@ -144,6 +150,8 @@ class UsersModule {}
|
|
|
144
150
|
- 런타임 health module readiness check는 현재 `RequestContext`를 받으므로, public integration이 internal runtime token을 import하지 않고도 runtime-exposed status provider를 해석할 수 있습니다.
|
|
145
151
|
- 시그널 기반 종료 헬퍼는 bounded drain semantics를 유지하면서 timeout/실패 상황을 로그와 `process.exitCode`로 보고하지만, 최종 프로세스 종료 소유권은 주변 호스트 런타임에 남겨 둡니다.
|
|
146
152
|
- 플랫폼 snapshot 및 diagnostic issue 생산은 런타임에 남아 있고, 그래프 보기, filtering 표현, Mermaid 렌더링은 CLI 및 자동화 호출자가 소비하는 Studio 소유 계약입니다.
|
|
153
|
+
- Runtime-connected Studio instrumentation은 명시적인 CLI 주입 Studio config로만 활성화되며 runtime package source에서 `process.env`를 직접 읽지 않습니다. 유효한 config와 tokenized endpoint가 없으면 non-Node 런타임을 포함해 Studio 관점의 runtime bootstrap은 no-op입니다.
|
|
154
|
+
- Studio request trace는 request/response body, cookie, 전체 header를 제외합니다. Trace `url`은 publish 전에 path-only 형태로 sanitize되어 query token과 fragment가 local Studio event history에 남지 않습니다.
|
|
147
155
|
- 플랫폼 component snapshot은 런타임 소유 계약 payload입니다. 각 component는 `readiness`, `health`, dependency id, telemetry tag, diagnostic issue, 그리고 `ownership.ownsResources` / `ownership.externallyManaged`를 통해 리소스 소유권을 보고합니다. Runtime은 shell snapshot에서 이 ownership flag를 보존하므로 adapter와 package integration이 fluo가 종료해야 하는 리소스와 host가 소유한 외부 관리 리소스를 구분할 수 있습니다.
|
|
148
156
|
- 모듈 그래프 컴파일 결과 캐시는 `moduleGraphCache: true`를 통한 opt-in입니다. 캐시 항목은 root module identity, runtime provider, validation token, core metadata version, compile algorithm version으로 식별되며, 성공한 컴파일만 저장하고 호출자 mutation이 이후 bootstrap을 오염시키지 않도록 격리된 그래프 복사본을 반환합니다.
|
|
149
157
|
|
package/README.md
CHANGED
|
@@ -80,6 +80,12 @@ await userService.doWork();
|
|
|
80
80
|
await context.close();
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
### Studio Devtools Bridge
|
|
84
|
+
|
|
85
|
+
`@fluojs/runtime` can publish live Studio snapshots and request traces, but it does not read `process.env` directly. `fluo dev --studio` is the application boundary that starts the sidecar, creates the tokenized Studio config, and injects that explicit config into the Node app child before the app imports runtime. If that CLI-provided config is absent, malformed, or missing a tokenized endpoint, Studio instrumentation is a no-op and bootstrap behavior remains unchanged.
|
|
86
|
+
|
|
87
|
+
For this MVP, Node dev runner projects are the full support target. Bun, Deno, and Cloudflare Workers remain unsupported for live Studio until a dedicated bridge is implemented and verified; their runtime bootstraps still no-op when Studio config is absent. Request traces intentionally omit bodies, cookies, and full headers, and runtime strips query strings/fragments from the trace `url` before publishing events so local tokens are not copied into Studio event history.
|
|
88
|
+
|
|
83
89
|
### Global Exception Filters
|
|
84
90
|
|
|
85
91
|
Handle cross-cutting errors by registering filters during bootstrap.
|
|
@@ -144,6 +150,8 @@ class UsersModule {}
|
|
|
144
150
|
- Runtime health module readiness checks receive the current `RequestContext`, allowing public integrations to resolve runtime-exposed status providers without importing internal runtime tokens.
|
|
145
151
|
- Signal-driven shutdown helpers preserve bounded drain semantics, log timeout/failure conditions, and set `process.exitCode` when shutdown does not finish cleanly, but they leave final process termination ownership to the surrounding host runtime.
|
|
146
152
|
- Platform snapshot and diagnostic issue production stay in runtime; graph viewing, filtering presentation, and Mermaid rendering are Studio-owned contracts consumed by CLI and automation callers.
|
|
153
|
+
- Runtime-connected Studio instrumentation is activated only by explicit CLI-injected Studio config, never by direct `process.env` reads inside runtime package source. Without valid config and tokenized endpoint, runtime bootstrap is a no-op for Studio, including non-Node runtimes.
|
|
154
|
+
- Studio request traces omit request/response bodies, cookies, and full headers; the trace `url` is sanitized to path-only form before publish so query tokens and fragments are not retained in local Studio event history.
|
|
147
155
|
- Platform component snapshots are runtime-owned contract payloads: each component reports `readiness`, `health`, dependency ids, telemetry tags, diagnostic issues, and resource ownership through `ownership.ownsResources` / `ownership.externallyManaged`. Runtime preserves those ownership flags in shell snapshots so adapters and package integrations can distinguish resources fluo must stop from externally managed resources the host owns.
|
|
148
156
|
- Module graph compile-result caching is opt-in through `moduleGraphCache: true`; it keys entries by root module identity, runtime providers, validation tokens, core metadata versions, and the compile algorithm version, caches only successful compilations, and returns isolated graph copies so caller mutations cannot poison later bootstraps.
|
|
149
157
|
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EAEX,uBAAuB,EAGvB,2BAA2B,EAC3B,sBAAsB,EACtB,eAAe,EAGf,wBAAwB,EACxB,+BAA+B,EAC/B,yBAAyB,EAEzB,gBAAgB,EAChB,UAAU,EAMX,MAAM,YAAY,CAAC;AA6dpB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,gBAAgB,GAAG,CAAC,CAIjG;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,eAAe,CA+B7G;AAo0BD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,WAAW,CAAC,CAiJrG;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;OAOG;WACU,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,WAAW,CAAC;IAOzG;;;;;;;OAOG;WACU,wBAAwB,CACnC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,kBAAkB,CAAC;IAwH9B;;;;;;;;OAQG;WACU,kBAAkB,CAC7B,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,uBAAuB,CAAC;CA+BpC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,oBAAc,CAAC"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -3,9 +3,10 @@ import { InvariantError } from '@fluojs/core';
|
|
|
3
3
|
import { createDispatcher, createHandlerMapping } from '@fluojs/http';
|
|
4
4
|
import { DuplicateProviderError } from './errors.js';
|
|
5
5
|
import { createBootstrapTimingDiagnostics } from './health/diagnostics.js';
|
|
6
|
+
import { applyStudioDevtoolsApplicationOptions, applyStudioDevtoolsContextOptions, createStudioDevtoolsRuntimeFromConfig, publishStudioBootstrapSnapshot } from './devtools/studio-runtime.js';
|
|
6
7
|
import { defineRuntimeModuleMetadata, getRuntimeClassDiMetadata } from './internal/core-metadata.js';
|
|
7
8
|
import { RuntimeDefaultBinder } from './internal/http-runtime.js';
|
|
8
|
-
import {
|
|
9
|
+
import { createDefaultApplicationLogger } from './logging/default-logger.js';
|
|
9
10
|
import { compileModuleGraph, providerToken } from './module-graph.js';
|
|
10
11
|
import { createRuntimePlatformShell } from './platform-shell.js';
|
|
11
12
|
import { APPLICATION_LOGGER, BOOTSTRAP_READY_SIGNAL, COMPILED_MODULES, HTTP_APPLICATION_ADAPTER, PLATFORM_SHELL, RUNTIME_CLEANUP_REGISTRATION, RUNTIME_CONTAINER } from './tokens.js';
|
|
@@ -994,29 +995,34 @@ function createRuntimeDispatcher(bootstrapped, options, logger) {
|
|
|
994
995
|
* @throws {Error} Propagates module-graph, lifecycle, or runtime initialization failures.
|
|
995
996
|
*/
|
|
996
997
|
export async function bootstrapApplication(options) {
|
|
997
|
-
const
|
|
998
|
+
const studioDevtools = createStudioDevtoolsRuntimeFromConfig();
|
|
999
|
+
const effectiveOptions = applyStudioDevtoolsApplicationOptions(options, studioDevtools);
|
|
1000
|
+
const logger = effectiveOptions.logger ?? createDefaultApplicationLogger();
|
|
998
1001
|
let lifecycleInstances = [];
|
|
999
1002
|
let bootstrappedContainer;
|
|
1000
1003
|
let bootstrappedModules = [];
|
|
1001
|
-
const hasHttpAdapter =
|
|
1002
|
-
const adapter =
|
|
1004
|
+
const hasHttpAdapter = effectiveOptions.adapter !== undefined;
|
|
1005
|
+
const adapter = effectiveOptions.adapter ?? {
|
|
1003
1006
|
async close() {},
|
|
1004
1007
|
async listen() {}
|
|
1005
1008
|
};
|
|
1006
1009
|
const runtimeCleanup = [];
|
|
1010
|
+
if (studioDevtools) {
|
|
1011
|
+
runtimeCleanup.push(() => studioDevtools.close());
|
|
1012
|
+
}
|
|
1007
1013
|
const bootstrapReadySignal = createBootstrapReadySignal();
|
|
1008
|
-
const platformShell = createRuntimePlatformShell(
|
|
1009
|
-
const timingEnabled =
|
|
1014
|
+
const platformShell = createRuntimePlatformShell(effectiveOptions.platform?.components);
|
|
1015
|
+
const timingEnabled = effectiveOptions.diagnostics?.timing === true;
|
|
1010
1016
|
const timingStart = timingEnabled ? runtimePerformance.now() : 0;
|
|
1011
1017
|
const timingPhases = [];
|
|
1012
1018
|
try {
|
|
1013
1019
|
logger.log('Starting fluo application...', 'FluoFactory');
|
|
1014
|
-
const runtimeProviders = createRuntimeProviders(
|
|
1020
|
+
const runtimeProviders = createRuntimeProviders(effectiveOptions, logger);
|
|
1015
1021
|
const moduleBootstrapStart = timingEnabled ? runtimePerformance.now() : 0;
|
|
1016
|
-
const bootstrapped = bootstrapModule(
|
|
1017
|
-
duplicateProviderPolicy:
|
|
1022
|
+
const bootstrapped = bootstrapModule(effectiveOptions.rootModule, {
|
|
1023
|
+
duplicateProviderPolicy: effectiveOptions.duplicateProviderPolicy,
|
|
1018
1024
|
logger,
|
|
1019
|
-
moduleGraphCache:
|
|
1025
|
+
moduleGraphCache: effectiveOptions.moduleGraphCache,
|
|
1020
1026
|
providers: runtimeProviders,
|
|
1021
1027
|
validationTokens: [RUNTIME_CONTAINER, COMPILED_MODULES, HTTP_APPLICATION_ADAPTER, RUNTIME_CLEANUP_REGISTRATION, BOOTSTRAP_READY_SIGNAL]
|
|
1022
1028
|
});
|
|
@@ -1058,7 +1064,7 @@ export async function bootstrapApplication(options) {
|
|
|
1058
1064
|
});
|
|
1059
1065
|
}
|
|
1060
1066
|
const dispatcherStart = timingEnabled ? runtimePerformance.now() : 0;
|
|
1061
|
-
const dispatcher = createRuntimeDispatcher(bootstrapped,
|
|
1067
|
+
const dispatcher = createRuntimeDispatcher(bootstrapped, effectiveOptions, logger);
|
|
1062
1068
|
if (timingEnabled) {
|
|
1063
1069
|
timingPhases.push({
|
|
1064
1070
|
durationMs: runtimePerformance.now() - dispatcherStart,
|
|
@@ -1066,7 +1072,13 @@ export async function bootstrapApplication(options) {
|
|
|
1066
1072
|
});
|
|
1067
1073
|
}
|
|
1068
1074
|
const bootstrapTiming = timingEnabled ? createBootstrapTimingDiagnostics(timingPhases, runtimePerformance.now() - timingStart) : undefined;
|
|
1069
|
-
|
|
1075
|
+
publishStudioBootstrapSnapshot(studioDevtools, {
|
|
1076
|
+
modules: bootstrapped.modules,
|
|
1077
|
+
rootModule: effectiveOptions.rootModule,
|
|
1078
|
+
routes: dispatcher.describeRoutes?.() ?? [],
|
|
1079
|
+
timing: bootstrapTiming
|
|
1080
|
+
});
|
|
1081
|
+
return new FluoApplication(bootstrapped.container, bootstrapped.modules, effectiveOptions.rootModule, dispatcher, bootstrapTiming, adapter, hasHttpAdapter, platformShell, lifecycleInstances, logger, runtimeCleanup, createContextCacheableTokenSet(bootstrapped.effectiveProviders, [RUNTIME_CONTAINER, COMPILED_MODULES, HTTP_APPLICATION_ADAPTER, PLATFORM_SHELL, RUNTIME_CLEANUP_REGISTRATION, BOOTSTRAP_READY_SIGNAL]));
|
|
1070
1082
|
} catch (error) {
|
|
1071
1083
|
bootstrapReadySignal.markFailed(error);
|
|
1072
1084
|
logger.error('Failed to bootstrap the fluo application. Check the error below for what failed and how to fix it.', error, 'FluoFactory');
|
|
@@ -1110,24 +1122,29 @@ export class FluoFactory {
|
|
|
1110
1122
|
* @throws {Error} Propagates module-graph, lifecycle, and context bootstrap failures.
|
|
1111
1123
|
*/
|
|
1112
1124
|
static async createApplicationContext(rootModule, options = {}) {
|
|
1113
|
-
const
|
|
1125
|
+
const studioDevtools = createStudioDevtoolsRuntimeFromConfig();
|
|
1126
|
+
const effectiveOptions = applyStudioDevtoolsContextOptions(options, studioDevtools);
|
|
1127
|
+
const logger = effectiveOptions.logger ?? createDefaultApplicationLogger();
|
|
1114
1128
|
let lifecycleInstances = [];
|
|
1115
1129
|
let bootstrappedContainer;
|
|
1116
1130
|
let bootstrappedModules = [];
|
|
1117
1131
|
const runtimeCleanup = [];
|
|
1132
|
+
if (studioDevtools) {
|
|
1133
|
+
runtimeCleanup.push(() => studioDevtools.close());
|
|
1134
|
+
}
|
|
1118
1135
|
const bootstrapReadySignal = createBootstrapReadySignal();
|
|
1119
|
-
const platformShell = createRuntimePlatformShell(
|
|
1120
|
-
const timingEnabled =
|
|
1136
|
+
const platformShell = createRuntimePlatformShell(effectiveOptions.platform?.components);
|
|
1137
|
+
const timingEnabled = effectiveOptions.diagnostics?.timing === true;
|
|
1121
1138
|
const timingStart = timingEnabled ? runtimePerformance.now() : 0;
|
|
1122
1139
|
const timingPhases = [];
|
|
1123
1140
|
try {
|
|
1124
1141
|
logger.log('Starting fluo application context...', 'FluoFactory');
|
|
1125
|
-
const runtimeProviders = createRuntimeProviders(
|
|
1142
|
+
const runtimeProviders = createRuntimeProviders(effectiveOptions, logger);
|
|
1126
1143
|
const moduleBootstrapStart = timingEnabled ? runtimePerformance.now() : 0;
|
|
1127
1144
|
const bootstrapped = bootstrapModule(rootModule, {
|
|
1128
|
-
duplicateProviderPolicy:
|
|
1145
|
+
duplicateProviderPolicy: effectiveOptions.duplicateProviderPolicy,
|
|
1129
1146
|
logger,
|
|
1130
|
-
moduleGraphCache:
|
|
1147
|
+
moduleGraphCache: effectiveOptions.moduleGraphCache,
|
|
1131
1148
|
providers: runtimeProviders,
|
|
1132
1149
|
validationTokens: [RUNTIME_CONTAINER, COMPILED_MODULES, RUNTIME_CLEANUP_REGISTRATION, BOOTSTRAP_READY_SIGNAL]
|
|
1133
1150
|
});
|
|
@@ -1169,6 +1186,11 @@ export class FluoFactory {
|
|
|
1169
1186
|
});
|
|
1170
1187
|
}
|
|
1171
1188
|
const bootstrapTiming = timingEnabled ? createBootstrapTimingDiagnostics(timingPhases, runtimePerformance.now() - timingStart) : undefined;
|
|
1189
|
+
publishStudioBootstrapSnapshot(studioDevtools, {
|
|
1190
|
+
modules: bootstrapped.modules,
|
|
1191
|
+
rootModule,
|
|
1192
|
+
timing: bootstrapTiming
|
|
1193
|
+
});
|
|
1172
1194
|
return new FluoApplicationContext(bootstrapped.container, bootstrapped.modules, rootModule, bootstrapTiming, lifecycleInstances, runtimeCleanup, createContextCacheableTokenSet(bootstrapped.effectiveProviders, [RUNTIME_CONTAINER, COMPILED_MODULES, PLATFORM_SHELL, RUNTIME_CLEANUP_REGISTRATION, BOOTSTRAP_READY_SIGNAL]));
|
|
1173
1195
|
} catch (error) {
|
|
1174
1196
|
bootstrapReadySignal.markFailed(error);
|
|
@@ -1195,7 +1217,7 @@ export class FluoFactory {
|
|
|
1195
1217
|
* @throws {Error} Propagates application-context bootstrap or runtime-resolution failures.
|
|
1196
1218
|
*/
|
|
1197
1219
|
static async createMicroservice(rootModule, options = {}) {
|
|
1198
|
-
const logger = options.logger ??
|
|
1220
|
+
const logger = options.logger ?? createDefaultApplicationLogger();
|
|
1199
1221
|
const microserviceToken = options.microserviceToken ?? DEFAULT_MICROSERVICE_TOKEN;
|
|
1200
1222
|
const context = await FluoFactory.createApplicationContext(rootModule, options);
|
|
1201
1223
|
try {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { BootstrapTimingDiagnostics } from '../health/diagnostics.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines Studio Graph Node Kind values used by the Studio devtool.
|
|
4
|
+
*/
|
|
5
|
+
export type StudioGraphNodeKind = 'module' | 'provider' | 'controller' | 'route' | 'platform' | 'external';
|
|
6
|
+
/**
|
|
7
|
+
* Defines Studio Graph Edge Kind values used by the Studio devtool.
|
|
8
|
+
*/
|
|
9
|
+
export type StudioGraphEdgeKind = 'imports' | 'owns_provider' | 'owns_controller' | 'exposes_route' | 'depends_on' | 'exports';
|
|
10
|
+
/**
|
|
11
|
+
* Describes Studio Graph Node data used by the Studio devtool.
|
|
12
|
+
*/
|
|
13
|
+
export interface StudioGraphNode {
|
|
14
|
+
id: string;
|
|
15
|
+
kind: StudioGraphNodeKind;
|
|
16
|
+
label: string;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
status?: 'active' | 'idle' | 'warning' | 'error';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Describes Studio Graph Edge data used by the Studio devtool.
|
|
22
|
+
*/
|
|
23
|
+
export interface StudioGraphEdge {
|
|
24
|
+
from: string;
|
|
25
|
+
id: string;
|
|
26
|
+
kind: StudioGraphEdgeKind;
|
|
27
|
+
label?: string;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
to: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Describes Studio Route Descriptor data used by the Studio devtool.
|
|
33
|
+
*/
|
|
34
|
+
export interface StudioRouteDescriptor {
|
|
35
|
+
controller: string;
|
|
36
|
+
handler: string;
|
|
37
|
+
id: string;
|
|
38
|
+
method: string;
|
|
39
|
+
module?: string;
|
|
40
|
+
path: string;
|
|
41
|
+
version?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Defines Studio Request Status values used by the Studio devtool.
|
|
45
|
+
*/
|
|
46
|
+
export type StudioRequestStatus = 'started' | 'matched' | 'succeeded' | 'failed' | 'finished';
|
|
47
|
+
/**
|
|
48
|
+
* Describes Studio Request Trace data used by the Studio devtool.
|
|
49
|
+
*/
|
|
50
|
+
export interface StudioRequestTrace {
|
|
51
|
+
controller?: string;
|
|
52
|
+
durationMs?: number;
|
|
53
|
+
error?: {
|
|
54
|
+
message: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
};
|
|
57
|
+
finishedAt?: string;
|
|
58
|
+
handler?: string;
|
|
59
|
+
method: string;
|
|
60
|
+
path: string;
|
|
61
|
+
requestId: string;
|
|
62
|
+
routeId?: string;
|
|
63
|
+
startedAt: string;
|
|
64
|
+
status: StudioRequestStatus;
|
|
65
|
+
statusCode?: number;
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Describes Studio Live Diagnostic data used by the Studio devtool.
|
|
70
|
+
*/
|
|
71
|
+
export interface StudioLiveDiagnostic {
|
|
72
|
+
code: string;
|
|
73
|
+
fixHint?: string;
|
|
74
|
+
message: string;
|
|
75
|
+
scope?: string;
|
|
76
|
+
severity: 'error' | 'warning' | 'info';
|
|
77
|
+
targetId?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Describes Studio Live Snapshot data used by the Studio devtool.
|
|
81
|
+
*/
|
|
82
|
+
export interface StudioLiveSnapshot {
|
|
83
|
+
appId: string;
|
|
84
|
+
diagnostics: StudioLiveDiagnostic[];
|
|
85
|
+
generatedAt: string;
|
|
86
|
+
graph: {
|
|
87
|
+
edges: StudioGraphEdge[];
|
|
88
|
+
nodes: StudioGraphNode[];
|
|
89
|
+
};
|
|
90
|
+
requests: StudioRequestTrace[];
|
|
91
|
+
routes: StudioRouteDescriptor[];
|
|
92
|
+
timing?: BootstrapTimingDiagnostics;
|
|
93
|
+
version: 1;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Describes Studio Live Event Source data used by the Studio devtool.
|
|
97
|
+
*/
|
|
98
|
+
export interface StudioLiveEventSource {
|
|
99
|
+
appId: string;
|
|
100
|
+
runtime: 'node' | 'bun' | 'deno' | 'worker' | 'unknown';
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Describes Studio Live Event Base data used by the Studio devtool.
|
|
104
|
+
*/
|
|
105
|
+
export interface StudioLiveEventBase<TType extends string, TPayload> {
|
|
106
|
+
emittedAt: string;
|
|
107
|
+
epoch: string;
|
|
108
|
+
eventId: string;
|
|
109
|
+
payload: TPayload;
|
|
110
|
+
sequence: number;
|
|
111
|
+
source: StudioLiveEventSource;
|
|
112
|
+
type: TType;
|
|
113
|
+
version: 1;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Defines Studio Heartbeat Payload values used by the Studio devtool.
|
|
117
|
+
*/
|
|
118
|
+
export type StudioHeartbeatPayload = {
|
|
119
|
+
uptimeMs?: number;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Describes Studio Restart Payload data used by the Studio devtool.
|
|
123
|
+
*/
|
|
124
|
+
export interface StudioRestartPayload {
|
|
125
|
+
phase: 'scheduled' | 'starting' | 'started' | 'stopping' | 'stopped';
|
|
126
|
+
reason?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Describes Studio Disconnect Payload data used by the Studio devtool.
|
|
130
|
+
*/
|
|
131
|
+
export interface StudioDisconnectPayload {
|
|
132
|
+
reason?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Defines Studio Live Event values used by the Studio devtool.
|
|
136
|
+
*/
|
|
137
|
+
export type StudioLiveEvent = StudioLiveEventBase<'disconnect', StudioDisconnectPayload> | StudioLiveEventBase<'diagnostic', StudioLiveDiagnostic> | StudioLiveEventBase<'heartbeat', StudioHeartbeatPayload> | StudioLiveEventBase<'request', StudioRequestTrace> | StudioLiveEventBase<'restart', StudioRestartPayload> | StudioLiveEventBase<'snapshot', StudioLiveSnapshot> | StudioLiveEventBase<'timing', BootstrapTimingDiagnostics>;
|
|
138
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/devtools/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AAC3G;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,eAAe,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,GAAG,SAAS,CAAC;AAE/H;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,q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B,CAAC,GACvD,mBAAmB,CAAC,WAAW,EAAE,sBAAsB,CAAC,GACxD,mBAAmB,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAClD,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,CAAC,GACpD,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,CAAC,GACnD,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { StudioGraphEdge, StudioGraphEdgeKind, StudioGraphNode, StudioGraphNodeKind, StudioHeartbeatPayload, StudioLiveDiagnostic, StudioLiveEvent, StudioLiveEventBase, StudioLiveEventSource, StudioLiveSnapshot, StudioRequestStatus, StudioRequestTrace, StudioRouteDescriptor, } from './contracts.js';
|
|
2
|
+
export { createStudioLiveSnapshot, createStudioRouteId, handlerToStudioRouteDescriptor, type StudioLiveSnapshotInput, } from './snapshot.js';
|
|
3
|
+
export { StudioDevtoolsRuntime, applyStudioDevtoolsApplicationOptions, applyStudioDevtoolsContextOptions, createStudioDevtoolsRuntimeFromConfig, createStudioDevtoolsRuntimeFromEnv, publishStudioBootstrapSnapshot, type StudioBootstrapSnapshotInput, type StudioDevtoolsConfig, type StudioDevtoolsRuntimeOptions, type StudioDevtoolsRuntimeTransport, } from './studio-runtime.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/devtools/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,8BAA8B,EAC9B,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,qCAAqC,EACrC,iCAAiC,EACjC,qCAAqC,EACrC,kCAAkC,EAClC,8BAA8B,EAC9B,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createStudioLiveSnapshot, createStudioRouteId, handlerToStudioRouteDescriptor } from './snapshot.js';
|
|
2
|
+
export { StudioDevtoolsRuntime, applyStudioDevtoolsApplicationOptions, applyStudioDevtoolsContextOptions, createStudioDevtoolsRuntimeFromConfig, createStudioDevtoolsRuntimeFromEnv, publishStudioBootstrapSnapshot } from './studio-runtime.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HandlerDescriptor } from '@fluojs/http';
|
|
2
|
+
import { type BootstrapTimingDiagnostics } from '../health/diagnostics.js';
|
|
3
|
+
import type { CompiledModule, ModuleType } from '../types.js';
|
|
4
|
+
import type { StudioLiveDiagnostic, StudioLiveSnapshot, StudioRouteDescriptor } from './contracts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Describes Studio Live Snapshot Input data used by the Studio devtool.
|
|
7
|
+
*/
|
|
8
|
+
export interface StudioLiveSnapshotInput {
|
|
9
|
+
appId: string;
|
|
10
|
+
diagnostics?: readonly StudioLiveDiagnostic[];
|
|
11
|
+
generatedAt?: string;
|
|
12
|
+
modules: readonly CompiledModule[];
|
|
13
|
+
requests?: readonly StudioLiveSnapshot['requests'][number][];
|
|
14
|
+
rootModule: ModuleType;
|
|
15
|
+
routes?: readonly HandlerDescriptor[];
|
|
16
|
+
timing?: BootstrapTimingDiagnostics;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a stable route id shared by runtime request traces and Studio graph snapshots.
|
|
20
|
+
*
|
|
21
|
+
* @param descriptor HTTP handler descriptor to identify.
|
|
22
|
+
* @returns Stable Studio route id for the handler.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createStudioRouteId(descriptor: HandlerDescriptor): string;
|
|
25
|
+
/**
|
|
26
|
+
* Converts an HTTP handler descriptor into the live Studio route contract.
|
|
27
|
+
*
|
|
28
|
+
* @param descriptor HTTP handler descriptor to expose to Studio.
|
|
29
|
+
* @returns Route descriptor consumed by the Studio UI and request traces.
|
|
30
|
+
*/
|
|
31
|
+
export declare function handlerToStudioRouteDescriptor(descriptor: HandlerDescriptor): StudioRouteDescriptor;
|
|
32
|
+
/**
|
|
33
|
+
* Builds the runtime-connected Studio snapshot from compiled modules and HTTP route descriptors.
|
|
34
|
+
*
|
|
35
|
+
* @param input Runtime module graph, route, diagnostic, and timing inputs.
|
|
36
|
+
* @returns Live Studio snapshot for graph, routes, diagnostics, requests, and timing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createStudioLiveSnapshot(input: StudioLiveSnapshotInput): StudioLiveSnapshot;
|
|
39
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/devtools/snapshot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAiC,KAAK,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAG1G,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAIV,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,SAAS,kBAAkB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7D,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,0BAA0B,CAAC;CACrC;AA8KD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAOzE;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,iBAAiB,GAAG,qBAAqB,CAoBnG;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CA6L3F"}
|