@bleedingdev/modern-js-runtime-extensions 3.9.0-ultramodern.4 → 3.9.0-ultramodern.5
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/dist/cjs/contextExtensions.js +74 -0
- package/dist/cjs/headRuntime.js +91 -0
- package/dist/cjs/helmetContext.js +54 -0
- package/dist/cjs/index.js +18 -4
- package/dist/cjs/prefetchPolicy.js +52 -0
- package/dist/cjs/request-policy/browser.js +139 -0
- package/dist/cjs/request-policy/client.js +234 -0
- package/dist/cjs/request-policy/node.js +149 -0
- package/dist/cjs/request-policy/policyCore.js +266 -0
- package/dist/cjs/request-policy/requestContext.js +137 -0
- package/dist/cjs/request-policy/traceparent.js +56 -0
- package/dist/cjs/request-policy/transport.js +234 -0
- package/dist/cjs/request-policy/types.js +57 -0
- package/dist/cjs/routeHydration.js +127 -0
- package/dist/cjs/routerPrefetchPolicy.js +153 -0
- package/dist/cjs/routerProvider.js +170 -0
- package/dist/cjs/routerState.js +167 -0
- package/dist/cjs/routerStatePlugin.js +86 -0
- package/dist/cjs/routerStateTypes.js +18 -0
- package/dist/cjs/runtimeContextProjection.js +112 -0
- package/dist/cjs/server-config/bffRuntime.js +18 -0
- package/dist/cjs/server-config/index.js +18 -0
- package/dist/cjs/server-config/serverTelemetry.js +18 -0
- package/dist/cjs/shellStream.js +34 -2
- package/dist/cjs/workspaceEvents.js +159 -0
- package/dist/esm/contextExtensions.mjs +33 -0
- package/dist/esm/headRuntime.mjs +43 -0
- package/dist/esm/helmetContext.mjs +13 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/prefetchPolicy.mjs +11 -0
- package/dist/esm/request-policy/browser.mjs +11 -0
- package/dist/esm/request-policy/client.mjs +195 -0
- package/dist/esm/request-policy/policyCore.mjs +171 -0
- package/dist/esm/request-policy/requestContext.mjs +75 -0
- package/dist/esm/request-policy/traceparent.mjs +18 -0
- package/dist/esm/request-policy/transport.mjs +196 -0
- package/dist/esm/request-policy/types.mjs +10 -0
- package/dist/esm/routeHydration.mjs +77 -0
- package/dist/esm/routerPrefetchPolicy.mjs +115 -0
- package/dist/esm/routerProvider.mjs +117 -0
- package/dist/esm/routerState.mjs +105 -0
- package/dist/esm/routerStatePlugin.mjs +48 -0
- package/dist/esm/routerStateTypes.mjs +0 -0
- package/dist/esm/runtimeContextProjection.mjs +74 -0
- package/dist/esm/server-config/bffRuntime.mjs +0 -0
- package/dist/esm/server-config/index.mjs +0 -0
- package/dist/esm/server-config/serverTelemetry.mjs +0 -0
- package/dist/esm/shellStream.mjs +34 -2
- package/dist/esm/workspaceEvents.mjs +66 -0
- package/dist/esm-node/contextExtensions.mjs +34 -0
- package/dist/esm-node/headRuntime.mjs +44 -0
- package/dist/esm-node/helmetContext.mjs +14 -0
- package/dist/esm-node/index.mjs +2 -0
- package/dist/esm-node/prefetchPolicy.mjs +12 -0
- package/dist/esm-node/request-policy/browser.mjs +12 -0
- package/dist/esm-node/request-policy/client.mjs +196 -0
- package/dist/esm-node/request-policy/node.mjs +22 -0
- package/dist/esm-node/request-policy/policyCore.mjs +172 -0
- package/dist/esm-node/request-policy/requestContext.mjs +76 -0
- package/dist/esm-node/request-policy/traceparent.mjs +19 -0
- package/dist/esm-node/request-policy/transport.mjs +197 -0
- package/dist/esm-node/request-policy/types.mjs +11 -0
- package/dist/esm-node/routeHydration.mjs +78 -0
- package/dist/esm-node/routerPrefetchPolicy.mjs +116 -0
- package/dist/esm-node/routerProvider.mjs +118 -0
- package/dist/esm-node/routerState.mjs +106 -0
- package/dist/esm-node/routerStatePlugin.mjs +49 -0
- package/dist/esm-node/routerStateTypes.mjs +1 -0
- package/dist/esm-node/runtimeContextProjection.mjs +75 -0
- package/dist/esm-node/server-config/bffRuntime.mjs +1 -0
- package/dist/esm-node/server-config/index.mjs +1 -0
- package/dist/esm-node/server-config/serverTelemetry.mjs +1 -0
- package/dist/esm-node/shellStream.mjs +34 -2
- package/dist/esm-node/workspaceEvents.mjs +67 -0
- package/dist/types/contextExtensions.d.ts +34 -0
- package/dist/types/headRuntime.d.ts +12 -0
- package/dist/types/helmetContext.d.ts +10 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/prefetchPolicy.d.ts +4 -0
- package/dist/types/request-policy/browser.d.ts +10 -0
- package/dist/types/request-policy/client.d.ts +14 -0
- package/dist/types/request-policy/node.d.ts +10 -0
- package/dist/types/request-policy/policyCore.d.ts +107 -0
- package/dist/types/request-policy/requestContext.d.ts +22 -0
- package/dist/types/request-policy/traceparent.d.ts +10 -0
- package/dist/types/request-policy/transport.d.ts +12 -0
- package/dist/types/request-policy/types.d.ts +144 -0
- package/dist/types/routeHydration.d.ts +24 -0
- package/dist/types/routerPrefetchPolicy.d.ts +28 -0
- package/dist/types/routerProvider.d.ts +77 -0
- package/dist/types/routerState.d.ts +12 -0
- package/dist/types/routerStatePlugin.d.ts +19 -0
- package/dist/types/routerStateTypes.d.ts +40 -0
- package/dist/types/runtimeContextProjection.d.ts +30 -0
- package/dist/types/server-config/bffRuntime.d.ts +122 -0
- package/dist/types/server-config/index.d.ts +2 -0
- package/dist/types/server-config/serverTelemetry.d.ts +322 -0
- package/dist/types/workspaceEvents.d.ts +62 -0
- package/package.json +198 -13
- package/rslib.config.mts +17 -2
- package/rstest.config.mts +33 -2
- package/src/contextExtensions.ts +81 -0
- package/src/headRuntime.tsx +77 -0
- package/src/helmetContext.ts +31 -0
- package/src/index.ts +2 -0
- package/src/prefetchPolicy.ts +33 -0
- package/src/request-policy/browser.ts +22 -0
- package/src/request-policy/client.ts +404 -0
- package/src/request-policy/node.ts +41 -0
- package/src/request-policy/policyCore.ts +424 -0
- package/src/request-policy/requestContext.ts +149 -0
- package/src/request-policy/traceparent.ts +43 -0
- package/src/request-policy/transport.ts +349 -0
- package/src/request-policy/types.ts +229 -0
- package/src/routeHydration.ts +208 -0
- package/src/routerPrefetchPolicy.ts +195 -0
- package/src/routerProvider.ts +340 -0
- package/src/routerState.ts +208 -0
- package/src/routerStatePlugin.ts +86 -0
- package/src/routerStateTypes.ts +46 -0
- package/src/runtimeContextProjection.ts +105 -0
- package/src/server-config/bffRuntime.ts +136 -0
- package/src/server-config/index.ts +2 -0
- package/src/server-config/serverTelemetry.ts +337 -0
- package/src/shellStream.ts +55 -25
- package/src/workspaceEvents.ts +324 -0
- package/tests/buildIdentity.test.ts +2 -4
- package/tests/contextExtensions.test.ts +71 -0
- package/tests/headRuntime.test.tsx +369 -0
- package/tests/nativeSafeFailureCompatibility.test.ts +117 -0
- package/tests/prefetchPolicy.test.ts +51 -0
- package/tests/rendererHead.test.ts +1 -72
- package/tests/request-policy/browser-policy.test.ts +608 -0
- package/tests/request-policy/client-isolation.test.ts +149 -0
- package/tests/request-policy/identityBinding.test.ts +75 -0
- package/tests/request-policy/node-policy.test.ts +741 -0
- package/tests/request-policy/policyCore.test.ts +250 -0
- package/tests/request-policy/requestContext.test.ts +80 -0
- package/tests/request-policy/requestFactory.outbound-contract.test.ts +691 -0
- package/tests/request-policy/traceparent.test.ts +55 -0
- package/tests/request-policy/transport-retry.test.ts +370 -0
- package/tests/routeHydration.test.ts +180 -0
- package/tests/routerPrefetchPolicy.test.ts +102 -0
- package/tests/routerProvider.test.ts +38 -0
- package/tests/routerState.test.ts +157 -0
- package/tests/routerStatePlugin.test.ts +108 -0
- package/tests/runtimeContextProjection.test.ts +135 -0
- package/tests/shellStream.test.ts +37 -0
- package/tests/workspaceEvents.test.ts +391 -0
- package/dist/cjs/rscHtmlStream.js +0 -128
- package/dist/esm/rscHtmlStream.mjs +0 -86
- package/dist/esm-node/rscHtmlStream.mjs +0 -87
- package/dist/types/rscHtmlStream.d.ts +0 -4
- package/src/rscHtmlStream.ts +0 -142
- package/tests/rscHtmlStream.test.ts +0 -153
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PrefetchBehavior = 'intent' | 'render' | 'viewport' | 'none';
|
|
2
|
+
type PrefetchState = {
|
|
3
|
+
code: boolean;
|
|
4
|
+
data: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** Policy-only contract: native links supply elements, route inputs and loads. */
|
|
7
|
+
export declare function createRouterPrefetchPolicy(): {
|
|
8
|
+
canWarmup: () => boolean;
|
|
9
|
+
allowData(route: unknown): boolean;
|
|
10
|
+
observe({ element, prefetch: inputPrefetch, preload: inputPreload, notify, }: {
|
|
11
|
+
element: HTMLAnchorElement | null;
|
|
12
|
+
prefetch?: PrefetchBehavior;
|
|
13
|
+
preload?: PrefetchBehavior | false;
|
|
14
|
+
notify: (state: PrefetchState) => void;
|
|
15
|
+
}): {
|
|
16
|
+
onIntent(): void;
|
|
17
|
+
onCancel(): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
};
|
|
20
|
+
schedule({ runtimeContext, chunkLoader, publicPath, key: operationKey, run, }: {
|
|
21
|
+
runtimeContext: object;
|
|
22
|
+
chunkLoader: object;
|
|
23
|
+
publicPath: string;
|
|
24
|
+
key: string;
|
|
25
|
+
run: () => Promise<unknown>;
|
|
26
|
+
}): () => void;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** Structural plugin contract; the composing integration supplies native hooks. */
|
|
2
|
+
export type RouterProviderPlugin = {
|
|
3
|
+
name?: string;
|
|
4
|
+
registryHooks?: Record<string, unknown>;
|
|
5
|
+
setup?: (api: any) => unknown;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Guard for the wrapper plugin (`router/internal`): a resolved provider is
|
|
10
|
+
* only invoked through `setup`, so registry hooks outside the canonical
|
|
11
|
+
* router hook contract cannot be registered for it. Returns the offending
|
|
12
|
+
* hook names and warns once so they are surfaced instead of silently dropped.
|
|
13
|
+
*/
|
|
14
|
+
export declare function reportUnsupportedProviderRegistryHooks(providerPlugin: {
|
|
15
|
+
name?: string;
|
|
16
|
+
registryHooks?: Record<string, unknown>;
|
|
17
|
+
}, routerProviderRegistryHooks: Record<string, unknown>): string[];
|
|
18
|
+
export type RouterProviderFactory = (userConfig?: any) => RouterProviderPlugin;
|
|
19
|
+
export type RouterProviderRegistration = {
|
|
20
|
+
name: string;
|
|
21
|
+
factory: RouterProviderFactory;
|
|
22
|
+
isDefault?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* App-owned provider catalog. Provider factories close over their module graph,
|
|
26
|
+
* so they must be resolved from the runtime wrapper that owns the app instead
|
|
27
|
+
* of from a page-global first-registration winner.
|
|
28
|
+
*/
|
|
29
|
+
export type RouterProviderRealm = Readonly<{
|
|
30
|
+
defaultProvider?: string;
|
|
31
|
+
get: (name: string) => RouterProviderFactory | undefined;
|
|
32
|
+
names: () => readonly string[];
|
|
33
|
+
}>;
|
|
34
|
+
export declare function createRouterProviderRealm(registrations: readonly RouterProviderRegistration[]): RouterProviderRealm;
|
|
35
|
+
export declare function registerRouterProvider(name: string, factory: RouterProviderFactory, options?: {
|
|
36
|
+
isDefault?: boolean;
|
|
37
|
+
}): void;
|
|
38
|
+
export declare function resolveRouterProvider(framework?: string, options?: {
|
|
39
|
+
/**
|
|
40
|
+
* Provider factories owned by the resolving app/runtime wrapper. A realm
|
|
41
|
+
* is the exclusive provider source when supplied because its factories
|
|
42
|
+
* close over the correct app module graph.
|
|
43
|
+
*/
|
|
44
|
+
realm?: RouterProviderRealm;
|
|
45
|
+
/**
|
|
46
|
+
* Legacy single-provider override retained for published wrappers. New
|
|
47
|
+
* integrations should pass an app-owned `realm`, which supports every
|
|
48
|
+
* provider rather than only the default.
|
|
49
|
+
*/
|
|
50
|
+
localDefault?: {
|
|
51
|
+
name: string;
|
|
52
|
+
factory: RouterProviderFactory;
|
|
53
|
+
};
|
|
54
|
+
}): RouterProviderFactory;
|
|
55
|
+
/**
|
|
56
|
+
* Test-only escape hatch: compatibility registries live on `globalThis`, so
|
|
57
|
+
* unit tests need a way to restore a pristine state between cases.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unsafe_resetRouterProvidersForTesting(): void;
|
|
60
|
+
/** Compose app-owned providers without importing the native runtime graph. */
|
|
61
|
+
export declare function createRouterPlugin<Hooks extends Record<string, unknown>>({ defaultProvider, registryHooks, localProviders, }: {
|
|
62
|
+
defaultProvider: {
|
|
63
|
+
name: string;
|
|
64
|
+
factory: RouterProviderFactory;
|
|
65
|
+
};
|
|
66
|
+
registryHooks: Hooks;
|
|
67
|
+
localProviders?: readonly Omit<RouterProviderRegistration, 'isDefault'>[];
|
|
68
|
+
}): (userConfig?: Record<string, any>) => {
|
|
69
|
+
name: string;
|
|
70
|
+
registryHooks: Hooks;
|
|
71
|
+
setup(api: {
|
|
72
|
+
getRuntimeConfig: () => {
|
|
73
|
+
router?: Record<string, unknown>;
|
|
74
|
+
};
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}): void;
|
|
77
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterServerPrepareResult } from './routerStateTypes.js';
|
|
2
|
+
export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterLifecyclePhase, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from './routerStateTypes.js';
|
|
3
|
+
export declare function getRouterRuntimeState(runtimeContext: object): InternalRouterRuntimeState | undefined;
|
|
4
|
+
export declare function getRouterServerSnapshot(runtimeContext: object): InternalRouterServerSnapshot | undefined;
|
|
5
|
+
type RouterSnapshotLike = Partial<InternalRouterServerSnapshot>;
|
|
6
|
+
export declare function createRouterServerSnapshot(state: RouterSnapshotLike): InternalRouterServerSnapshot;
|
|
7
|
+
export declare function createRouterRuntimeState(state: InternalRouterRuntimeState): InternalRouterRuntimeState;
|
|
8
|
+
export declare function applyRouterRuntimeState<Context extends object>(runtimeContext: Context, state: InternalRouterRuntimeState): Context;
|
|
9
|
+
export declare function applyRouterServerPrepareResult<Context extends object>(runtimeContext: Context, result: RouterServerPrepareResult): Context;
|
|
10
|
+
export declare function getRouterHydrationScripts(runtimeContext: object): string[];
|
|
11
|
+
export declare function getRouterMatchedRouteIds(runtimeContext: object): string[] | undefined;
|
|
12
|
+
export declare function cleanupRouterRuntimeState(runtimeContext: object): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type RouterLifecycleEvent = {
|
|
2
|
+
framework: string;
|
|
3
|
+
phase: string;
|
|
4
|
+
runtimeContext: object;
|
|
5
|
+
basename?: string;
|
|
6
|
+
router?: unknown;
|
|
7
|
+
};
|
|
8
|
+
/** Install fork policy through lifecycle hooks supplied by the native owner. */
|
|
9
|
+
export declare function createRouterStatePlugin<Hooks extends Record<string, unknown>>({ registryHooks, }: {
|
|
10
|
+
registryHooks: Hooks;
|
|
11
|
+
}): {
|
|
12
|
+
name: string;
|
|
13
|
+
registryHooks: Hooks;
|
|
14
|
+
setup(api: {
|
|
15
|
+
onBeforeRender: (callback: (context: object) => void) => unknown;
|
|
16
|
+
onAfterCreateRouter: (callback: (event: RouterLifecycleEvent) => void) => unknown;
|
|
17
|
+
}): void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type BuiltInRouterFramework = 'react-router' | 'tanstack';
|
|
2
|
+
export type RouterFramework = BuiltInRouterFramework | (string & {});
|
|
3
|
+
export interface RouterRouteMatchSnapshot {
|
|
4
|
+
routeId: string;
|
|
5
|
+
assetRouteId?: string;
|
|
6
|
+
pathname?: string;
|
|
7
|
+
params?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export interface InternalRouterServerSnapshot {
|
|
10
|
+
framework?: RouterFramework;
|
|
11
|
+
basename?: string;
|
|
12
|
+
statusCode?: number;
|
|
13
|
+
errors?: Record<string, unknown>;
|
|
14
|
+
routerData?: {
|
|
15
|
+
loaderData?: Record<string, unknown>;
|
|
16
|
+
errors?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
hydrationScript?: string;
|
|
19
|
+
hydrationScripts?: string[];
|
|
20
|
+
matchedRouteIds?: string[];
|
|
21
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
22
|
+
}
|
|
23
|
+
export interface InternalRouterRuntimeState {
|
|
24
|
+
framework: RouterFramework;
|
|
25
|
+
basename?: string;
|
|
26
|
+
instance?: unknown;
|
|
27
|
+
hydrationScript?: string;
|
|
28
|
+
hydrationScripts?: string[];
|
|
29
|
+
matchedRouteIds?: string[];
|
|
30
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
31
|
+
serverSnapshot?: InternalRouterServerSnapshot;
|
|
32
|
+
cleanup?: () => void | Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface RouterServerPrepareResult {
|
|
35
|
+
state: InternalRouterRuntimeState;
|
|
36
|
+
snapshot?: InternalRouterServerSnapshot;
|
|
37
|
+
redirect?: Response;
|
|
38
|
+
cleanup?: () => void | Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export type RouterLifecyclePhase = 'ssr-prepare' | 'client-create' | 'hydrate';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface ProjectionContext {
|
|
2
|
+
isBrowser?: boolean;
|
|
3
|
+
ssrContext?: {
|
|
4
|
+
request: {
|
|
5
|
+
url?: unknown;
|
|
6
|
+
userAgent?: unknown;
|
|
7
|
+
cookie?: unknown;
|
|
8
|
+
pathname?: unknown;
|
|
9
|
+
query?: object;
|
|
10
|
+
params?: object;
|
|
11
|
+
headers?: object;
|
|
12
|
+
host?: unknown;
|
|
13
|
+
referer?: unknown;
|
|
14
|
+
};
|
|
15
|
+
response: {
|
|
16
|
+
locals?: unknown;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare function projectRuntimeContext<InternalContext extends ProjectionContext, PublicContext extends ProjectionContext>(projection: {
|
|
21
|
+
internalContext: InternalContext;
|
|
22
|
+
publicContext: PublicContext;
|
|
23
|
+
}, options: {
|
|
24
|
+
context: InternalContext;
|
|
25
|
+
isRsc: boolean;
|
|
26
|
+
}): {
|
|
27
|
+
internalContext: InternalContext;
|
|
28
|
+
publicContext: PublicContext;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export type BffRuntimeFramework = 'hono' | 'effect';
|
|
2
|
+
/** Fork BFF options, independent of any native server config interface. */
|
|
3
|
+
export interface BffRuntimeUserConfig {
|
|
4
|
+
runtimeFramework?: BffRuntimeFramework;
|
|
5
|
+
effect?: BffEffectUserConfig;
|
|
6
|
+
crossProjectPolicy?: BffCrossProjectPolicyUserConfig;
|
|
7
|
+
}
|
|
8
|
+
export interface BffCrossProjectPolicyUserConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Enable cross-project envelope and operation-context policy checks.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Require cross-project envelope header when policy is enabled.
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
requireEnvelope?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Require operation-context header when policy is enabled.
|
|
23
|
+
*
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
requireOperationContext?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Require operation-context detail header carrying schema/version metadata.
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
requireOperationContextDetails?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Require operation schema hash in operation-context details.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
requireOperationSchemaHash?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Require operation version in operation-context details.
|
|
41
|
+
*
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
requireOperationVersion?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Optional allowlist of producer namespaces derived from requestId.
|
|
47
|
+
*/
|
|
48
|
+
allowedNamespaces?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Optional hook deriving a verified producer identity (namespace) from
|
|
51
|
+
* request headers, e.g. an mTLS subject or gateway-verified JWT claim.
|
|
52
|
+
* When provided, namespace checks bind to this verified value instead of
|
|
53
|
+
* the client-asserted requestId namespace; returning `undefined` denies
|
|
54
|
+
* the request. Without it the namespace checks are advisory only.
|
|
55
|
+
*/
|
|
56
|
+
verifyProducerIdentity?: (headers: Record<string, unknown>) => string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Optional operation-contract map keyed by:
|
|
59
|
+
* - `${METHOD}:${routePath}`
|
|
60
|
+
* - `operation:${requestId}:${operationId}`
|
|
61
|
+
*/
|
|
62
|
+
expectedOperationContracts?: Record<string, {
|
|
63
|
+
schemaHash?: string;
|
|
64
|
+
operationVersion?: number;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Allow operations missing from expectedOperationContracts.
|
|
68
|
+
*
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
allowUnknownOperations?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* HTTP status code used for denied requests.
|
|
74
|
+
*
|
|
75
|
+
* @default 403
|
|
76
|
+
*/
|
|
77
|
+
denyStatus?: number;
|
|
78
|
+
}
|
|
79
|
+
export type BffEffectOpenApiUserConfig = boolean | {
|
|
80
|
+
path?: string;
|
|
81
|
+
};
|
|
82
|
+
export interface BffEffectDataPlatformSelectionUserConfig {
|
|
83
|
+
maxDepth?: number;
|
|
84
|
+
maxFields?: number;
|
|
85
|
+
allowedLeafPaths?: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface BffEffectDataPlatformBatchUserConfig {
|
|
88
|
+
enabled?: boolean;
|
|
89
|
+
endpoint?: `/${string}`;
|
|
90
|
+
maxBatchSize?: number;
|
|
91
|
+
maxBatchBytes?: number;
|
|
92
|
+
flushIntervalMs?: number;
|
|
93
|
+
maxConcurrency?: number;
|
|
94
|
+
requestTimeoutMs?: number;
|
|
95
|
+
allowedMethods?: string[];
|
|
96
|
+
}
|
|
97
|
+
export interface BffEffectDataPlatformUserConfig {
|
|
98
|
+
enabled?: boolean;
|
|
99
|
+
requireEnvelope?: boolean;
|
|
100
|
+
envelopeHeader?: string;
|
|
101
|
+
expectedNamespace?: string;
|
|
102
|
+
validateOrigin?: boolean;
|
|
103
|
+
requireTraceContext?: boolean;
|
|
104
|
+
selection?: BffEffectDataPlatformSelectionUserConfig;
|
|
105
|
+
batch?: BffEffectDataPlatformBatchUserConfig;
|
|
106
|
+
}
|
|
107
|
+
export interface BffEffectUserConfig {
|
|
108
|
+
entry?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Enforce Effect-native API/runtime modules instead of raw request handlers.
|
|
111
|
+
*
|
|
112
|
+
* When enabled, Effect API entries must export a `defineEffectBff(...)`
|
|
113
|
+
* definition or a `{ api, layer }` HttpApi module. Raw `handler` exports,
|
|
114
|
+
* default request handlers, and unbranded custom `createHandler` factories
|
|
115
|
+
* are treated as legacy escape hatches.
|
|
116
|
+
*
|
|
117
|
+
* @default true
|
|
118
|
+
*/
|
|
119
|
+
strictEffectApproach?: true;
|
|
120
|
+
openapi?: BffEffectOpenApiUserConfig;
|
|
121
|
+
dataPlatform?: BffEffectDataPlatformUserConfig;
|
|
122
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
export interface ServerTelemetryExporterOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ServerTelemetryVictoriaMetricsOptions extends ServerTelemetryExporterOptions {
|
|
8
|
+
metricPrefix?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ServerTelemetrySloUserConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Queue utilization ratio threshold that emits SLO degradation alerts.
|
|
13
|
+
*
|
|
14
|
+
* @default 0.8
|
|
15
|
+
*/
|
|
16
|
+
queueUtilizationWarnThreshold?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Total dropped-envelope threshold that emits SLO degradation alerts.
|
|
19
|
+
*
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
queueDroppedWarnThreshold?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Cooldown between SLO alert emissions for the same alert type.
|
|
25
|
+
*
|
|
26
|
+
* @default 60000
|
|
27
|
+
*/
|
|
28
|
+
alertCooldownMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ServerTelemetryCanaryContractGateUserConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Whether this contract gate currently passes.
|
|
33
|
+
*/
|
|
34
|
+
passed: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Optional failure reason used for rollback diagnostics.
|
|
37
|
+
*/
|
|
38
|
+
reason?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ServerTelemetryCanaryAutopilotUserConfig {
|
|
41
|
+
/**
|
|
42
|
+
* Enable automatic contract gate synchronization from a gate snapshot file.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Path to contract gate snapshot JSON file.
|
|
49
|
+
*
|
|
50
|
+
* @default ".modern/contract-gates.json"
|
|
51
|
+
*/
|
|
52
|
+
gateSnapshotPath?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Poll interval for reading gate snapshot changes.
|
|
55
|
+
*
|
|
56
|
+
* @default 15000
|
|
57
|
+
*/
|
|
58
|
+
pollIntervalMs?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Marks gate entries as failed when they are older than this threshold.
|
|
61
|
+
*
|
|
62
|
+
* @default 600000
|
|
63
|
+
*/
|
|
64
|
+
gateStaleAfterMs?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Runtime MF fallback signal ingestion.
|
|
67
|
+
*/
|
|
68
|
+
runtimeFallbackSignal?: ServerTelemetryCanaryRuntimeFallbackSignalUserConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Optional pluggable state store backend for contract gate snapshots.
|
|
71
|
+
* When omitted, snapshots are read/written from gateSnapshotPath on local disk.
|
|
72
|
+
*/
|
|
73
|
+
stateStore?: ServerTelemetryCanaryAutopilotStateStoreUserConfig;
|
|
74
|
+
}
|
|
75
|
+
export interface ServerTelemetryCanaryAutopilotStateStoreUserConfig {
|
|
76
|
+
/**
|
|
77
|
+
* Path or package name of a module that exports
|
|
78
|
+
* `createContractGateSnapshotStore(context)`.
|
|
79
|
+
*/
|
|
80
|
+
module: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional adapter-specific configuration.
|
|
83
|
+
*/
|
|
84
|
+
options?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalUserConfig {
|
|
87
|
+
/**
|
|
88
|
+
* Enable runtime MF fallback signal ingestion endpoint.
|
|
89
|
+
*
|
|
90
|
+
* Opt-in: when enabled, `auth` must be configured with a token
|
|
91
|
+
* (`expectedValue` or `expectedValueEnv`) or server setup throws.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
enabled?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* HTTP endpoint path for runtime fallback events.
|
|
98
|
+
*
|
|
99
|
+
* @default "/_modern/contract-gates/runtime-fallback"
|
|
100
|
+
*/
|
|
101
|
+
endpoint?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Contract gate name updated by runtime fallback events.
|
|
104
|
+
*
|
|
105
|
+
* @default "runtime-mf-fallback-health"
|
|
106
|
+
*/
|
|
107
|
+
gateName?: string;
|
|
108
|
+
/**
|
|
109
|
+
* How long a runtime fallback signal should hold gate failure status.
|
|
110
|
+
*
|
|
111
|
+
* @default 300000
|
|
112
|
+
*/
|
|
113
|
+
failureHoldMs?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Maximum accepted request body size in bytes.
|
|
116
|
+
*
|
|
117
|
+
* @default 16384
|
|
118
|
+
*/
|
|
119
|
+
maxBodyBytes?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Optional runtime trust policy for fallback signal ingestion.
|
|
122
|
+
* Use this to restrict who can mutate canary contract gates.
|
|
123
|
+
*/
|
|
124
|
+
trustPolicy?: ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig;
|
|
125
|
+
/**
|
|
126
|
+
* Optional request authentication for runtime fallback signal endpoint.
|
|
127
|
+
*/
|
|
128
|
+
auth?: ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig;
|
|
129
|
+
}
|
|
130
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig {
|
|
131
|
+
/**
|
|
132
|
+
* Enable auth guard for runtime fallback signal endpoint.
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Header name carrying runtime fallback auth token.
|
|
139
|
+
*
|
|
140
|
+
* @default "x-modernjs-runtime-signal-token"
|
|
141
|
+
*/
|
|
142
|
+
headerName?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Expected token value. Prefer using expectedValueEnv in production.
|
|
145
|
+
*/
|
|
146
|
+
expectedValue?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Name of environment variable that stores expected token value.
|
|
149
|
+
*/
|
|
150
|
+
expectedValueEnv?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig {
|
|
153
|
+
/**
|
|
154
|
+
* Allowlist of app names accepted by runtime fallback signal endpoint.
|
|
155
|
+
* Empty means no app-name allowlist check.
|
|
156
|
+
*/
|
|
157
|
+
allowedApps?: string[];
|
|
158
|
+
/**
|
|
159
|
+
* Allowlist of entry origins accepted by runtime fallback signal endpoint.
|
|
160
|
+
* Values should be URL origins (for example https://erp.example.com).
|
|
161
|
+
* Empty means no entry-origin allowlist check.
|
|
162
|
+
*/
|
|
163
|
+
allowedEntryOrigins?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* Expected runtime digest per appName.
|
|
166
|
+
*/
|
|
167
|
+
expectedRuntimeDigests?: Record<string, string>;
|
|
168
|
+
/**
|
|
169
|
+
* Require runtimeDigest to be present in signal payload metadata.
|
|
170
|
+
*
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
enforceRuntimeDigest?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Maximum accepted signals per app+origin window.
|
|
176
|
+
*
|
|
177
|
+
* @default 30
|
|
178
|
+
*/
|
|
179
|
+
maxSignalsPerWindow?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Sliding window size in milliseconds for maxSignalsPerWindow.
|
|
182
|
+
*
|
|
183
|
+
* @default 60000
|
|
184
|
+
*/
|
|
185
|
+
windowMs?: number;
|
|
186
|
+
/**
|
|
187
|
+
* Drop duplicate fallback events with the same fingerprint during this window.
|
|
188
|
+
*
|
|
189
|
+
* @default 10000
|
|
190
|
+
*/
|
|
191
|
+
dedupeWindowMs?: number;
|
|
192
|
+
}
|
|
193
|
+
export interface ServerTelemetryCanaryUserConfig {
|
|
194
|
+
/**
|
|
195
|
+
* Enable canary rollout/rollback orchestration.
|
|
196
|
+
*
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
enabled?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Periodic canary evaluation interval in milliseconds.
|
|
202
|
+
*
|
|
203
|
+
* @default 15000
|
|
204
|
+
*/
|
|
205
|
+
evaluationIntervalMs?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Required consecutive healthy evaluations before promotion.
|
|
208
|
+
*
|
|
209
|
+
* @default 3
|
|
210
|
+
*/
|
|
211
|
+
minConsecutiveHealthyEvaluations?: number;
|
|
212
|
+
/**
|
|
213
|
+
* Consecutive failing evaluations before automated rollback.
|
|
214
|
+
*
|
|
215
|
+
* @default 2
|
|
216
|
+
*/
|
|
217
|
+
rollbackConsecutiveFailures?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Maximum queue utilization ratio allowed during canary.
|
|
220
|
+
*
|
|
221
|
+
* @default 0.8
|
|
222
|
+
*/
|
|
223
|
+
maxQueueUtilization?: number;
|
|
224
|
+
/**
|
|
225
|
+
* Maximum allowed total dropped envelopes during canary.
|
|
226
|
+
*
|
|
227
|
+
* @default 0
|
|
228
|
+
*/
|
|
229
|
+
maxTotalDropped?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Maximum allowed unhealthy exporters during canary.
|
|
232
|
+
*
|
|
233
|
+
* @default 0
|
|
234
|
+
*/
|
|
235
|
+
maxUnhealthyExporters?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Contract gate map used in rollout decisions.
|
|
238
|
+
* `true` means passing, `false` means failing.
|
|
239
|
+
*/
|
|
240
|
+
contractGates?: Record<string, boolean | ServerTelemetryCanaryContractGateUserConfig>;
|
|
241
|
+
/**
|
|
242
|
+
* Contract-gate autopilot settings.
|
|
243
|
+
*/
|
|
244
|
+
autopilot?: ServerTelemetryCanaryAutopilotUserConfig;
|
|
245
|
+
}
|
|
246
|
+
export interface ServerTelemetryConfigExtension {
|
|
247
|
+
telemetry?: ServerTelemetryUserConfig;
|
|
248
|
+
}
|
|
249
|
+
export interface ServerTelemetryUserConfig {
|
|
250
|
+
/**
|
|
251
|
+
* Enable framework telemetry envelope emission.
|
|
252
|
+
* @default false
|
|
253
|
+
*/
|
|
254
|
+
enabled?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Logical service name attached to every telemetry envelope.
|
|
257
|
+
* @default server.metaName
|
|
258
|
+
*/
|
|
259
|
+
service?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Logical module name attached to every telemetry envelope.
|
|
262
|
+
* @default "server"
|
|
263
|
+
*/
|
|
264
|
+
module?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Environment attached to every telemetry envelope.
|
|
267
|
+
* @default process.env.NODE_ENV || "development"
|
|
268
|
+
*/
|
|
269
|
+
environment?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Sampling rate for monitor events.
|
|
272
|
+
* @default 1
|
|
273
|
+
*/
|
|
274
|
+
samplingRate?: number;
|
|
275
|
+
/**
|
|
276
|
+
* Flush window in milliseconds for exporter batches.
|
|
277
|
+
* @default 1000
|
|
278
|
+
*/
|
|
279
|
+
flushIntervalMs?: number;
|
|
280
|
+
/**
|
|
281
|
+
* Maximum envelopes in one emitted batch.
|
|
282
|
+
* @default 50
|
|
283
|
+
*/
|
|
284
|
+
maxBatchSize?: number;
|
|
285
|
+
/**
|
|
286
|
+
* Maximum envelopes buffered before backpressure drops oldest.
|
|
287
|
+
* @default 1000
|
|
288
|
+
*/
|
|
289
|
+
maxQueueSize?: number;
|
|
290
|
+
/**
|
|
291
|
+
* Envelope attribute keys that should be redacted.
|
|
292
|
+
*/
|
|
293
|
+
redactionKeys?: string[];
|
|
294
|
+
/**
|
|
295
|
+
* Control startup exporter health probe behavior.
|
|
296
|
+
* When enabled (default), server initialization emits a startup probe and
|
|
297
|
+
* marks exporters healthy/unhealthy before serving traffic.
|
|
298
|
+
* When fail-loud mode is enabled (default), initialization throws if at
|
|
299
|
+
* least one configured exporter is unhealthy.
|
|
300
|
+
*
|
|
301
|
+
* @default true
|
|
302
|
+
*/
|
|
303
|
+
failLoudStartup?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Queue backpressure/degradation SLO alert thresholds.
|
|
306
|
+
*/
|
|
307
|
+
slo?: ServerTelemetrySloUserConfig;
|
|
308
|
+
/**
|
|
309
|
+
* Canary rollout and automated rollback orchestration policy.
|
|
310
|
+
*/
|
|
311
|
+
canary?: ServerTelemetryCanaryUserConfig;
|
|
312
|
+
exporters?: {
|
|
313
|
+
/**
|
|
314
|
+
* OpenTelemetry HTTP exporter.
|
|
315
|
+
*/
|
|
316
|
+
otlp?: ServerTelemetryExporterOptions;
|
|
317
|
+
/**
|
|
318
|
+
* VictoriaMetrics Prometheus import exporter.
|
|
319
|
+
*/
|
|
320
|
+
victoriaMetrics?: ServerTelemetryVictoriaMetricsOptions;
|
|
321
|
+
};
|
|
322
|
+
}
|