@bleedingdev/modern-js-runtime-extensions 3.9.0-ultramodern.1 → 3.9.0-ultramodern.11
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/buildIdentity.js +73 -0
- 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/localisedLoaderIdentity.js +51 -0
- package/dist/cjs/prefetchPolicy.js +52 -0
- package/dist/cjs/reactContext.js +45 -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 +105 -0
- package/dist/cjs/routerState.js +204 -0
- package/dist/cjs/routerStatePlugin.js +86 -0
- package/dist/cjs/routerStateTypes.js +18 -0
- package/dist/cjs/rsc-disabled/rscDisabledClientBrowserRuntime.js +69 -0
- package/dist/cjs/rsc-disabled/rscDisabledClientEdgeRuntime.js +61 -0
- package/dist/cjs/rsc-disabled/rscDisabledClientNodeRuntime.js +65 -0
- package/dist/cjs/rsc-disabled/rscDisabledRuntimeError.js +42 -0
- package/dist/cjs/rsc-disabled/rscDisabledServerEdgeRuntime.js +93 -0
- package/dist/cjs/rsc-disabled/rscDisabledServerNodeRuntime.js +101 -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/buildIdentity.mjs +35 -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/localisedLoaderIdentity.mjs +13 -0
- package/dist/esm/prefetchPolicy.mjs +11 -0
- package/dist/esm/reactContext.mjs +7 -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 +58 -0
- package/dist/esm/routerState.mjs +139 -0
- package/dist/esm/routerStatePlugin.mjs +48 -0
- package/dist/esm/routerStateTypes.mjs +0 -0
- package/dist/esm/rsc-disabled/rscDisabledClientBrowserRuntime.mjs +10 -0
- package/dist/esm/rsc-disabled/rscDisabledClientEdgeRuntime.mjs +8 -0
- package/dist/esm/rsc-disabled/rscDisabledClientNodeRuntime.mjs +9 -0
- package/dist/esm/rsc-disabled/rscDisabledRuntimeError.mjs +4 -0
- package/dist/esm/rsc-disabled/rscDisabledServerEdgeRuntime.mjs +16 -0
- package/dist/esm/rsc-disabled/rscDisabledServerNodeRuntime.mjs +18 -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/buildIdentity.mjs +36 -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/localisedLoaderIdentity.mjs +14 -0
- package/dist/esm-node/prefetchPolicy.mjs +12 -0
- package/dist/esm-node/reactContext.mjs +8 -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 +59 -0
- package/dist/esm-node/routerState.mjs +140 -0
- package/dist/esm-node/routerStatePlugin.mjs +49 -0
- package/dist/esm-node/routerStateTypes.mjs +1 -0
- package/dist/esm-node/rsc-disabled/rscDisabledClientBrowserRuntime.mjs +11 -0
- package/dist/esm-node/rsc-disabled/rscDisabledClientEdgeRuntime.mjs +9 -0
- package/dist/esm-node/rsc-disabled/rscDisabledClientNodeRuntime.mjs +10 -0
- package/dist/esm-node/rsc-disabled/rscDisabledRuntimeError.mjs +5 -0
- package/dist/esm-node/rsc-disabled/rscDisabledServerEdgeRuntime.mjs +17 -0
- package/dist/esm-node/rsc-disabled/rscDisabledServerNodeRuntime.mjs +19 -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/buildIdentity.d.ts +37 -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/localisedLoaderIdentity.d.ts +10 -0
- package/dist/types/prefetchPolicy.d.ts +4 -0
- package/dist/types/reactContext.d.ts +6 -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 +55 -0
- package/dist/types/routerState.d.ts +18 -0
- package/dist/types/routerStatePlugin.d.ts +19 -0
- package/dist/types/routerStateTypes.d.ts +40 -0
- package/dist/types/rsc-disabled/rscDisabledClientBrowserRuntime.d.ts +9 -0
- package/dist/types/rsc-disabled/rscDisabledClientEdgeRuntime.d.ts +7 -0
- package/dist/types/rsc-disabled/rscDisabledClientNodeRuntime.d.ts +8 -0
- package/dist/types/rsc-disabled/rscDisabledRuntimeError.d.ts +1 -0
- package/dist/types/rsc-disabled/rscDisabledServerEdgeRuntime.d.ts +15 -0
- package/dist/types/rsc-disabled/rscDisabledServerNodeRuntime.d.ts +17 -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 +239 -14
- package/rslib.config.mts +17 -2
- package/rstest.config.mts +33 -2
- package/src/buildIdentity.ts +61 -0
- 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/localisedLoaderIdentity.ts +30 -0
- package/src/prefetchPolicy.ts +33 -0
- package/src/reactContext.ts +16 -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 +160 -0
- package/src/routerState.ts +290 -0
- package/src/routerStatePlugin.ts +86 -0
- package/src/routerStateTypes.ts +46 -0
- package/src/rsc-disabled/rscDisabledClientBrowserRuntime.ts +10 -0
- package/src/rsc-disabled/rscDisabledClientEdgeRuntime.ts +8 -0
- package/src/rsc-disabled/rscDisabledClientNodeRuntime.ts +9 -0
- package/src/rsc-disabled/rscDisabledRuntimeError.ts +3 -0
- package/src/rsc-disabled/rscDisabledServerEdgeRuntime.ts +16 -0
- package/src/rsc-disabled/rscDisabledServerNodeRuntime.ts +18 -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 +51 -0
- package/tests/contextExtensions.test.ts +27 -0
- package/tests/headRuntime.test.tsx +229 -0
- package/tests/rendererHead.test.ts +1 -113
- package/tests/request-policy/browser-policy.test.ts +108 -0
- package/tests/request-policy/client-isolation.test.ts +109 -0
- package/tests/request-policy/node-policy.test.ts +447 -0
- package/tests/request-policy/policyCore.test.ts +129 -0
- package/tests/request-policy/requestContext.test.ts +66 -0
- package/tests/request-policy/requestFactory.outbound-contract.test.ts +290 -0
- package/tests/request-policy/traceparent.test.ts +52 -0
- package/tests/request-policy/transport-retry.test.ts +367 -0
- package/tests/routeHydration.test.ts +180 -0
- package/tests/routerPrefetchPolicy.test.ts +102 -0
- package/tests/routerProvider.test.ts +29 -0
- package/tests/routerState.test.ts +78 -0
- package/tests/routerStatePlugin.test.ts +63 -0
- package/tests/runtimeContextProjection.test.ts +83 -0
- package/tests/safeFailure.test.ts +10 -28
- package/tests/shellStream.test.ts +37 -0
- package/tests/workspaceEvents.test.ts +221 -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,9 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createFromFetch = disabledRscRuntime;
|
|
4
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
5
|
+
const createServerReference = disabledRscRuntime;
|
|
6
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
7
|
+
const encodeReply = disabledRscRuntime;
|
|
8
|
+
const registerServerReference = disabledRscRuntime;
|
|
9
|
+
export { createFromFetch, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createFromFetch = disabledRscRuntime;
|
|
4
|
+
const createFromNodeStream = disabledRscRuntime;
|
|
5
|
+
const createFromReadableStream = disabledRscRuntime;
|
|
6
|
+
const createServerReference = disabledRscRuntime;
|
|
7
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
8
|
+
const encodeReply = disabledRscRuntime;
|
|
9
|
+
const registerServerReference = disabledRscRuntime;
|
|
10
|
+
export { createFromFetch, createFromNodeStream, createFromReadableStream, createServerReference, createTemporaryReferenceSet, encodeReply, registerServerReference };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createServerEntry = disabledRscRuntime;
|
|
4
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
5
|
+
const decodeAction = disabledRscRuntime;
|
|
6
|
+
const decodeFormState = disabledRscRuntime;
|
|
7
|
+
const decodeReply = disabledRscRuntime;
|
|
8
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
9
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
10
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
11
|
+
const ensureServerActions = disabledRscRuntime;
|
|
12
|
+
const loadServerAction = disabledRscRuntime;
|
|
13
|
+
const registerClientReference = disabledRscRuntime;
|
|
14
|
+
const registerServerReference = disabledRscRuntime;
|
|
15
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
16
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
17
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { disabledRscRuntime } from "./rscDisabledRuntimeError.mjs";
|
|
3
|
+
const createServerEntry = disabledRscRuntime;
|
|
4
|
+
const createTemporaryReferenceSet = disabledRscRuntime;
|
|
5
|
+
const decodeAction = disabledRscRuntime;
|
|
6
|
+
const decodeFormState = disabledRscRuntime;
|
|
7
|
+
const decodeReply = disabledRscRuntime;
|
|
8
|
+
const decodeReplyFromAsyncIterable = disabledRscRuntime;
|
|
9
|
+
const decodeReplyFromBusboy = disabledRscRuntime;
|
|
10
|
+
const decryptServerActionBoundArgs = disabledRscRuntime;
|
|
11
|
+
const encryptServerActionBoundArgs = disabledRscRuntime;
|
|
12
|
+
const ensureServerActions = disabledRscRuntime;
|
|
13
|
+
const loadServerAction = disabledRscRuntime;
|
|
14
|
+
const registerClientReference = disabledRscRuntime;
|
|
15
|
+
const registerServerReference = disabledRscRuntime;
|
|
16
|
+
const renderToPipeableStream = disabledRscRuntime;
|
|
17
|
+
const renderToReadableStream = disabledRscRuntime;
|
|
18
|
+
const setServerActionBoundArgsEncryption = disabledRscRuntime;
|
|
19
|
+
export { createServerEntry, createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, decodeReplyFromAsyncIterable, decodeReplyFromBusboy, decryptServerActionBoundArgs, encryptServerActionBoundArgs, ensureServerActions, loadServerAction, registerClientReference, registerServerReference, renderToPipeableStream, renderToReadableStream, setServerActionBoundArgsEncryption };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { stripRuntimeContextExtensions } from "./contextExtensions.mjs";
|
|
3
|
+
function createRscSafeRequestContext(ssrContext) {
|
|
4
|
+
const requestContext = {
|
|
5
|
+
request: {
|
|
6
|
+
params: {},
|
|
7
|
+
pathname: '',
|
|
8
|
+
query: {},
|
|
9
|
+
headers: {},
|
|
10
|
+
host: '',
|
|
11
|
+
url: ''
|
|
12
|
+
},
|
|
13
|
+
response: {
|
|
14
|
+
setHeader () {},
|
|
15
|
+
status () {},
|
|
16
|
+
locals: {}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(requestContext.response, 'setHeader', {
|
|
20
|
+
enumerable: false
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(requestContext.response, 'status', {
|
|
23
|
+
enumerable: false
|
|
24
|
+
});
|
|
25
|
+
if (void 0 === ssrContext) return requestContext;
|
|
26
|
+
const { request, response } = ssrContext;
|
|
27
|
+
return {
|
|
28
|
+
request: {
|
|
29
|
+
url: request.url,
|
|
30
|
+
userAgent: request.userAgent,
|
|
31
|
+
cookie: request.cookie,
|
|
32
|
+
pathname: request.pathname,
|
|
33
|
+
query: {
|
|
34
|
+
...request.query
|
|
35
|
+
},
|
|
36
|
+
params: {
|
|
37
|
+
...request.params
|
|
38
|
+
},
|
|
39
|
+
headers: {
|
|
40
|
+
...request.headers
|
|
41
|
+
},
|
|
42
|
+
host: request.host,
|
|
43
|
+
referer: request.referer
|
|
44
|
+
},
|
|
45
|
+
response: Object.assign(requestContext.response, {
|
|
46
|
+
locals: response.locals ?? {}
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function projectRuntimeContext(projection, options) {
|
|
51
|
+
let internalContext = projection.internalContext;
|
|
52
|
+
let publicContext = {
|
|
53
|
+
...projection.publicContext
|
|
54
|
+
};
|
|
55
|
+
stripRuntimeContextExtensions(publicContext);
|
|
56
|
+
if (options.isRsc && false === options.context.isBrowser) {
|
|
57
|
+
const requestContext = createRscSafeRequestContext(options.context.ssrContext);
|
|
58
|
+
internalContext = {
|
|
59
|
+
...internalContext,
|
|
60
|
+
context: requestContext,
|
|
61
|
+
requestContext
|
|
62
|
+
};
|
|
63
|
+
delete internalContext.ssrContext;
|
|
64
|
+
publicContext = {
|
|
65
|
+
...publicContext,
|
|
66
|
+
context: requestContext,
|
|
67
|
+
requestContext
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
internalContext,
|
|
72
|
+
publicContext
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export { projectRuntimeContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -13,7 +13,7 @@ const createConservingWebShellStream = (source, context, marker, onMissingMarker
|
|
|
13
13
|
markerFound = candidate.includes(marker);
|
|
14
14
|
markerCarry = markerFound ? '' : candidate.slice(-(marker.length - 1));
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
const transform = new TransformStream({
|
|
17
17
|
transform (chunk, controller) {
|
|
18
18
|
const decoded = decoder.decode(chunk, {
|
|
19
19
|
stream: true
|
|
@@ -34,6 +34,38 @@ const createConservingWebShellStream = (source, context, marker, onMissingMarker
|
|
|
34
34
|
const output = headProcessor.finish(decoded);
|
|
35
35
|
if (output) controller.enqueue(encoder.encode(output));
|
|
36
36
|
}
|
|
37
|
-
})
|
|
37
|
+
});
|
|
38
|
+
const piping = source.pipeTo(transform.writable);
|
|
39
|
+
piping.catch(()=>{});
|
|
40
|
+
const reader = transform.readable.getReader();
|
|
41
|
+
return new ReadableStream({
|
|
42
|
+
async pull (controller) {
|
|
43
|
+
try {
|
|
44
|
+
const result = await reader.read();
|
|
45
|
+
if (result.done) {
|
|
46
|
+
await piping;
|
|
47
|
+
controller.close();
|
|
48
|
+
reader.releaseLock();
|
|
49
|
+
} else controller.enqueue(result.value);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
await piping.catch(()=>{});
|
|
52
|
+
controller.error(error);
|
|
53
|
+
reader.releaseLock();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async cancel (reason) {
|
|
57
|
+
try {
|
|
58
|
+
await reader.cancel(reason);
|
|
59
|
+
} finally{
|
|
60
|
+
try {
|
|
61
|
+
await piping.catch((error)=>{
|
|
62
|
+
if (error !== reason) throw error;
|
|
63
|
+
});
|
|
64
|
+
} finally{
|
|
65
|
+
reader.releaseLock();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
38
70
|
};
|
|
39
71
|
export { createConservingWebShellStream };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const ultramodernWorkspaceEventNames = {
|
|
3
|
+
navigate: 'ultramodern:navigate',
|
|
4
|
+
performanceSignal: 'ultramodern:performance-signal',
|
|
5
|
+
remoteReady: 'ultramodern:remote-ready',
|
|
6
|
+
routeSettled: 'ultramodern:route-settled'
|
|
7
|
+
};
|
|
8
|
+
class UltramodernWorkspaceEventValidationError {
|
|
9
|
+
constructor(eventName, payload){
|
|
10
|
+
this.name = 'UltramodernWorkspaceEventValidationError';
|
|
11
|
+
this.message = `Invalid payload for UltraModern workspace event "${eventName}"`;
|
|
12
|
+
this.eventName = eventName;
|
|
13
|
+
this.payload = payload;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
17
|
+
const isNonEmptyString = (value)=>'string' == typeof value && value.trim().length > 0;
|
|
18
|
+
const isNonNegativeNumber = (value)=>'number' == typeof value && Number.isFinite(value) && value >= 0;
|
|
19
|
+
const isUltramodernWorkspaceLocale = (value)=>'en' === value || 'cs' === value;
|
|
20
|
+
const isPerformanceReadinessSignalId = (value)=>'bfcache' === value || 'core-web-vitals-rum' === value || 'duplicate-prefetch-warmup' === value || 'cache-policy-sanity' === value || 'save-data-behavior' === value || 'cloudflare-ssr-cache-hints' === value;
|
|
21
|
+
const isPerformanceReadinessSignalStatus = (value)=>'pass' === value || 'warn' === value || 'fail' === value;
|
|
22
|
+
const hasOptionalString = (value, key)=>void 0 === value[key] || isNonEmptyString(value[key]);
|
|
23
|
+
const hasOptionalBoolean = (value, key)=>void 0 === value[key] || 'boolean' == typeof value[key];
|
|
24
|
+
const hasOptionalRecord = (value, key)=>void 0 === value[key] || isRecord(value[key]);
|
|
25
|
+
const hasOptionalNonNegativeNumber = (value, key)=>void 0 === value[key] || isNonNegativeNumber(value[key]);
|
|
26
|
+
const hasOptionalLocale = (value, key)=>void 0 === value[key] || isUltramodernWorkspaceLocale(value[key]);
|
|
27
|
+
const isUltramodernNavigatePayload = (payload)=>isRecord(payload) && isNonEmptyString(payload.to) && hasOptionalBoolean(payload, 'replace') && hasOptionalRecord(payload, 'state');
|
|
28
|
+
const isUltramodernRouteSettledPayload = (payload)=>isRecord(payload) && isNonEmptyString(payload.pathname) && hasOptionalLocale(payload, 'locale') && hasOptionalString(payload, 'title');
|
|
29
|
+
const isUltramodernRemoteReadyPayload = (payload)=>isRecord(payload) && isNonEmptyString(payload.appId) && hasOptionalString(payload, 'build') && hasOptionalString(payload, 'surface') && hasOptionalString(payload, 'version');
|
|
30
|
+
const isUltramodernPerformanceSignalPayload = (payload)=>isRecord(payload) && isPerformanceReadinessSignalId(payload.signalId) && isPerformanceReadinessSignalStatus(payload.status) && hasOptionalNonNegativeNumber(payload, 'durationMs') && hasOptionalRecord(payload, 'detail');
|
|
31
|
+
const ultramodernWorkspaceEventValidators = {
|
|
32
|
+
[ultramodernWorkspaceEventNames.navigate]: isUltramodernNavigatePayload,
|
|
33
|
+
[ultramodernWorkspaceEventNames.performanceSignal]: isUltramodernPerformanceSignalPayload,
|
|
34
|
+
[ultramodernWorkspaceEventNames.remoteReady]: isUltramodernRemoteReadyPayload,
|
|
35
|
+
[ultramodernWorkspaceEventNames.routeSettled]: isUltramodernRouteSettledPayload
|
|
36
|
+
};
|
|
37
|
+
const isUltramodernWorkspaceEventPayload = (eventName, payload)=>ultramodernWorkspaceEventValidators[eventName](payload);
|
|
38
|
+
const assertUltramodernWorkspaceEventPayload = (eventName, payload)=>{
|
|
39
|
+
if (!isUltramodernWorkspaceEventPayload(eventName, payload)) throw new UltramodernWorkspaceEventValidationError(eventName, payload);
|
|
40
|
+
return payload;
|
|
41
|
+
};
|
|
42
|
+
const createUltramodernWorkspaceEvent = (eventName, payload)=>new CustomEvent(eventName, {
|
|
43
|
+
bubbles: true,
|
|
44
|
+
composed: true,
|
|
45
|
+
detail: assertUltramodernWorkspaceEventPayload(eventName, payload)
|
|
46
|
+
});
|
|
47
|
+
const dispatchUltramodernWorkspaceEvent = (target, eventName, payload)=>target.dispatchEvent(createUltramodernWorkspaceEvent(eventName, payload));
|
|
48
|
+
const onUltramodernWorkspaceEvent = (target, eventName, handler)=>{
|
|
49
|
+
const listener = (event)=>{
|
|
50
|
+
if (!('detail' in event)) throw new UltramodernWorkspaceEventValidationError(eventName, void 0);
|
|
51
|
+
const customEvent = event;
|
|
52
|
+
handler(assertUltramodernWorkspaceEventPayload(eventName, customEvent.detail), customEvent);
|
|
53
|
+
};
|
|
54
|
+
target.addEventListener(eventName, listener);
|
|
55
|
+
return ()=>{
|
|
56
|
+
target.removeEventListener(eventName, listener);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const dispatchUltramodernNavigate = (target, payload)=>dispatchUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.navigate, payload);
|
|
60
|
+
const dispatchUltramodernRouteSettled = (target, payload)=>dispatchUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.routeSettled, payload);
|
|
61
|
+
const dispatchUltramodernRemoteReady = (target, payload)=>dispatchUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.remoteReady, payload);
|
|
62
|
+
const dispatchUltramodernPerformanceSignal = (target, payload)=>dispatchUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.performanceSignal, payload);
|
|
63
|
+
const onUltramodernNavigate = (target, handler)=>onUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.navigate, handler);
|
|
64
|
+
const onUltramodernRouteSettled = (target, handler)=>onUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.routeSettled, handler);
|
|
65
|
+
const onUltramodernRemoteReady = (target, handler)=>onUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.remoteReady, handler);
|
|
66
|
+
const onUltramodernPerformanceSignal = (target, handler)=>onUltramodernWorkspaceEvent(target, ultramodernWorkspaceEventNames.performanceSignal, handler);
|
|
67
|
+
export { UltramodernWorkspaceEventValidationError, assertUltramodernWorkspaceEventPayload, createUltramodernWorkspaceEvent, dispatchUltramodernNavigate, dispatchUltramodernPerformanceSignal, dispatchUltramodernRemoteReady, dispatchUltramodernRouteSettled, dispatchUltramodernWorkspaceEvent, isUltramodernNavigatePayload, isUltramodernPerformanceSignalPayload, isUltramodernRemoteReadyPayload, isUltramodernRouteSettledPayload, isUltramodernWorkspaceEventPayload, onUltramodernNavigate, onUltramodernPerformanceSignal, onUltramodernRemoteReady, onUltramodernRouteSettled, onUltramodernWorkspaceEvent, ultramodernWorkspaceEventNames };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface BuildIdentity {
|
|
2
|
+
readonly build: string;
|
|
3
|
+
readonly buildMarker: string;
|
|
4
|
+
readonly sourceRevision: string;
|
|
5
|
+
}
|
|
6
|
+
interface BuildArtifact {
|
|
7
|
+
readonly deliveryUnit: BuildIdentity;
|
|
8
|
+
readonly surfaces: {
|
|
9
|
+
readonly api: BuildIdentity;
|
|
10
|
+
readonly ui: BuildIdentity;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface BuildIdentityReaders {
|
|
14
|
+
readonly buildMarker: () => string;
|
|
15
|
+
readonly sourceRevision: () => string;
|
|
16
|
+
}
|
|
17
|
+
/** Read compiler constants in the caller, even when this package is external. */
|
|
18
|
+
export declare function resolveUltramodernBuildArtifact<Artifact extends BuildArtifact>(artifact: Artifact, readers?: BuildIdentityReaders): Artifact & {
|
|
19
|
+
deliveryUnit: {
|
|
20
|
+
build: string;
|
|
21
|
+
buildMarker: string;
|
|
22
|
+
sourceRevision: string;
|
|
23
|
+
};
|
|
24
|
+
surfaces: {
|
|
25
|
+
api: {
|
|
26
|
+
build: string;
|
|
27
|
+
buildMarker: string;
|
|
28
|
+
sourceRevision: string;
|
|
29
|
+
};
|
|
30
|
+
ui: {
|
|
31
|
+
build: string;
|
|
32
|
+
buildMarker: string;
|
|
33
|
+
sourceRevision: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fork-owned runtime-context extension mechanism.
|
|
3
|
+
*
|
|
4
|
+
* Plugins must not add ad-hoc fields to `TRuntimeContext` /
|
|
5
|
+
* `TInternalRuntimeContext`. Instead they store state in a single internal
|
|
6
|
+
* slot (a `Map` keyed by symbol) attached to the context object under a
|
|
7
|
+
* symbol property, so nothing leaks into string-key enumeration
|
|
8
|
+
* (`Object.keys`, `JSON.stringify`). Object spreads preserve the slot.
|
|
9
|
+
*
|
|
10
|
+
* `Symbol.for` is used for both the slot and the extension keys so that the
|
|
11
|
+
* mechanism stays coherent even if this module is instantiated twice
|
|
12
|
+
* (e.g. esm/cjs interop in test runners).
|
|
13
|
+
*/
|
|
14
|
+
export interface RuntimeContextExtension<T> {
|
|
15
|
+
/** Stable identity of this extension. */
|
|
16
|
+
readonly key: symbol;
|
|
17
|
+
get(context: object): T | undefined;
|
|
18
|
+
set(context: object, value: T): void;
|
|
19
|
+
remove(context: object): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Removes the extension slot from a context object.
|
|
23
|
+
*
|
|
24
|
+
* The symbol slot crosses object spreads while remaining absent from string-key
|
|
25
|
+
* enumeration and JSON. Callers can still explicitly clear the original context.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripRuntimeContextExtensions(context: object): void;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a typed accessor pair over the shared extension slot.
|
|
30
|
+
*
|
|
31
|
+
* The `id` must be globally unique (it is interned via `Symbol.for`); use a
|
|
32
|
+
* package-prefixed name such as `@modern-js/plugin-tanstack:router-state`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createRuntimeContextExtension<T>(id: string): RuntimeContextExtension<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Helmet as AsyncHelmet, type HelmetProps } from 'react-helmet-async';
|
|
3
|
+
import type { HelmetContextSlot } from './helmetContext.js';
|
|
4
|
+
export interface HeadRenderContext {
|
|
5
|
+
runtimeContext: object;
|
|
6
|
+
helmetContext: HelmetContextSlot;
|
|
7
|
+
}
|
|
8
|
+
export declare function createHeadRuntime(): {
|
|
9
|
+
Head: (props: React.PropsWithChildren<HelmetProps>) => React.CElement<React.PropsWithChildren<HelmetProps>, AsyncHelmet> | React.ReactElement<{}, string | React.JSXElementConstructor<any>> | null;
|
|
10
|
+
wrapServerRoot(root: React.ReactNode, state: HeadRenderContext): React.JSX.Element;
|
|
11
|
+
wrapClientRoot(root: React.ReactNode): React.JSX.Element;
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fork-owned helmet state, stored via the runtime-context extension slot
|
|
3
|
+
* instead of an ad-hoc `_helmetContext` field on `TInternalRuntimeContext`.
|
|
4
|
+
*/
|
|
5
|
+
import type { HelmetServerState } from 'react-helmet-async';
|
|
6
|
+
export interface HelmetContextSlot {
|
|
7
|
+
helmet?: HelmetServerState | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function getHelmetContext(context: object): HelmetContextSlot | undefined;
|
|
10
|
+
export declare function ensureHelmetContext(context: object): HelmetContextSlot;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface RouteNode {
|
|
2
|
+
id?: string;
|
|
3
|
+
children?: RouteNode[];
|
|
4
|
+
modernLocalisedRoute?: {
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
/** Map a source loader ID only to its own alias already matched by the router. */
|
|
9
|
+
export declare function resolveLocalisedLoaderRouteId(routes: RouteNode[], requestedId: string, matchedIds?: (string | undefined)[]): string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type PrefetchBehavior = 'intent' | 'render' | 'viewport' | 'none';
|
|
2
|
+
export declare function resolvePreloadFromPrefetch(prefetch: PrefetchBehavior | undefined, preload: unknown): {} | null;
|
|
3
|
+
export declare function normalizePreloadBehavior(preload: PrefetchBehavior | false | undefined, prefetch: PrefetchBehavior): PrefetchBehavior;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Federation can bundle a runtime subpath separately from its shared root.
|
|
3
|
+
* Share React context identity across those copies, leaving request values to
|
|
4
|
+
* React's providers. Public and internal contexts retain separate identities.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getRuntimeReactContext<T>(kind: 'public' | 'internal', create: () => T): T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Create a browser producer client with its own configuration and policy. */
|
|
2
|
+
export declare const createClient: () => {
|
|
3
|
+
configure: (options: import("./types.js").IOptions<typeof fetch>) => void;
|
|
4
|
+
createRequest: import("./types.js").RequestCreator<typeof fetch>;
|
|
5
|
+
createUploader: import("./types.js").UploadCreator;
|
|
6
|
+
};
|
|
7
|
+
export declare const configure: (options: import("./types.js").IOptions<typeof fetch>) => void, createRequest: import("./types.js").RequestCreator<typeof fetch>, createUploader: import("./types.js").UploadCreator;
|
|
8
|
+
export { CrossOriginEnvelopePolicyError, IdentityBindingViolationError, OperationContractViolationError, ProducerClientNotInitializedError, ProducerDomainNotConfiguredError, } from './policyCore.js';
|
|
9
|
+
export * from './requestContext.js';
|
|
10
|
+
export * from './types.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestClient } from '@modern-js/create-request/client';
|
|
2
|
+
import type { IOptions, RequestCreator, TransportTarget, UploadCreator } from './types.js';
|
|
3
|
+
type HeaderMap = Record<string, any>;
|
|
4
|
+
type PolicyEnvironment = {
|
|
5
|
+
target: TransportTarget;
|
|
6
|
+
resolveSourceOrigin: (incomingHeaders: HeaderMap) => string | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** Bind fork producer policy to one isolated native request client. */
|
|
9
|
+
export declare const createPolicyClient: <F>(nativeClient: RequestClient<F>, environment: PolicyEnvironment) => {
|
|
10
|
+
configure: (options: IOptions<F>) => void;
|
|
11
|
+
createRequest: RequestCreator<F>;
|
|
12
|
+
createUploader: UploadCreator;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Create a server producer client with its own configuration and policy. */
|
|
2
|
+
export declare const createClient: () => {
|
|
3
|
+
configure: (options: import("./types.js").IOptions<typeof fetch>) => void;
|
|
4
|
+
createRequest: import("./types.js").RequestCreator<typeof fetch>;
|
|
5
|
+
createUploader: import("./types.js").UploadCreator;
|
|
6
|
+
};
|
|
7
|
+
export declare const configure: (options: import("./types.js").IOptions<typeof fetch>) => void, createRequest: import("./types.js").RequestCreator<typeof fetch>, createUploader: import("./types.js").UploadCreator;
|
|
8
|
+
export { CrossOriginEnvelopePolicyError, IdentityBindingViolationError, OperationContractViolationError, ProducerClientNotInitializedError, ProducerDomainNotConfiguredError, } from './policyCore.js';
|
|
9
|
+
export * from './requestContext.js';
|
|
10
|
+
export * from './types.js';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { IdentityBindingViolation, OperationContext, OperationContractOptions, OperationContractViolation, TransportTarget } from './types.js';
|
|
2
|
+
export declare const TRACEPARENT_HEADER = "traceparent";
|
|
3
|
+
export declare const isSecuredRequestId: (requestId: string) => boolean;
|
|
4
|
+
export declare const isEmptyDomain: (domain?: string) => boolean;
|
|
5
|
+
export declare const firstHeaderValue: (value: unknown) => any;
|
|
6
|
+
export declare const findHeaderKey: (headers: Record<string, any>, header: string) => string | undefined;
|
|
7
|
+
export declare const readHeader: (headers: Record<string, any>, header: string) => any;
|
|
8
|
+
export declare const writeHeader: (headers: Record<string, any>, header: string, value: unknown) => void;
|
|
9
|
+
export declare const deleteHeader: (headers: Record<string, any>, header: string) => void;
|
|
10
|
+
export declare const toOrigin: (value?: string) => string | undefined;
|
|
11
|
+
export declare const parseTraceparentValue: (value: unknown) => import("./traceparent.js").TraceparentContext | undefined;
|
|
12
|
+
export declare const buildOperationContext: ({ requestId, method, path, operationContext, traceparent, }: {
|
|
13
|
+
requestId: string;
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
operationContext?: OperationContext | undefined;
|
|
17
|
+
traceparent?: unknown;
|
|
18
|
+
}) => {
|
|
19
|
+
requestId: string;
|
|
20
|
+
operationId: string;
|
|
21
|
+
routePath: string;
|
|
22
|
+
method: string;
|
|
23
|
+
schemaHash?: string | undefined;
|
|
24
|
+
operationVersion?: number | undefined;
|
|
25
|
+
traceparent?: string | undefined;
|
|
26
|
+
traceId?: string | undefined;
|
|
27
|
+
spanId?: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
type OperationContextPayload = ReturnType<typeof buildOperationContext>;
|
|
30
|
+
export declare class ProducerClientNotInitializedError extends Error {
|
|
31
|
+
readonly code = "BFF_PRODUCER_CLIENT_NOT_INITIALIZED";
|
|
32
|
+
constructor(requestId: string);
|
|
33
|
+
}
|
|
34
|
+
export declare class ProducerDomainNotConfiguredError extends Error {
|
|
35
|
+
readonly code = "BFF_PRODUCER_DOMAIN_NOT_CONFIGURED";
|
|
36
|
+
constructor(requestId: string);
|
|
37
|
+
}
|
|
38
|
+
export declare class CrossOriginEnvelopePolicyError extends Error {
|
|
39
|
+
readonly code = "BFF_CROSS_ORIGIN_ENVELOPE_NOT_ALLOWED";
|
|
40
|
+
constructor(requestId: string, sourceOrigin?: string, targetOrigin?: string);
|
|
41
|
+
}
|
|
42
|
+
export declare class IdentityBindingViolationError extends Error {
|
|
43
|
+
readonly code = "BFF_IDENTITY_BINDING_VIOLATION";
|
|
44
|
+
readonly violation: IdentityBindingViolation;
|
|
45
|
+
constructor(violation: IdentityBindingViolation);
|
|
46
|
+
}
|
|
47
|
+
export declare class OperationContractViolationError extends Error {
|
|
48
|
+
readonly code = "BFF_OPERATION_CONTRACT_VIOLATION";
|
|
49
|
+
readonly violation: OperationContractViolation;
|
|
50
|
+
constructor(violation: OperationContractViolation);
|
|
51
|
+
}
|
|
52
|
+
export declare const validateOperationContract: ({ requestId, target, contextPayload, operationContract, }: {
|
|
53
|
+
requestId: string;
|
|
54
|
+
target: TransportTarget;
|
|
55
|
+
contextPayload: OperationContextPayload;
|
|
56
|
+
operationContract: OperationContractOptions | undefined;
|
|
57
|
+
}) => void;
|
|
58
|
+
export declare const resolveConfiguredRequest: <F>(configuredRequests: Map<string, F>, requestId: string, fallback: F) => F;
|
|
59
|
+
/**
|
|
60
|
+
* Builds the JSON value for the `x-modernjs-bff-envelope` header and throws
|
|
61
|
+
* when the cross-origin envelope policy denies the flow. Returns the
|
|
62
|
+
* serialized envelope.
|
|
63
|
+
*/
|
|
64
|
+
export declare const buildEnvelopeHeaderValue: ({ requestId, target, sourceOrigin, targetOrigin, traceContext, allowCrossOriginEnvelope, }: {
|
|
65
|
+
requestId: string;
|
|
66
|
+
target: TransportTarget;
|
|
67
|
+
sourceOrigin: string | undefined;
|
|
68
|
+
targetOrigin: string | undefined;
|
|
69
|
+
traceContext: {
|
|
70
|
+
traceId: string;
|
|
71
|
+
spanId: string;
|
|
72
|
+
} | null | undefined;
|
|
73
|
+
allowCrossOriginEnvelope: boolean | ((options: {
|
|
74
|
+
requestId: string;
|
|
75
|
+
sourceOrigin?: string;
|
|
76
|
+
targetOrigin?: string;
|
|
77
|
+
target: TransportTarget;
|
|
78
|
+
}) => boolean) | undefined;
|
|
79
|
+
}) => string;
|
|
80
|
+
/**
|
|
81
|
+
* Derives the operation context for a secured requestId, validates it against
|
|
82
|
+
* the configured operation contract and writes the `x-operation-id` and
|
|
83
|
+
* `x-modernjs-bff-operation-context` headers (without clobbering caller
|
|
84
|
+
* provided values for the id header).
|
|
85
|
+
*/
|
|
86
|
+
export declare const attachOperationContextHeaders: ({ headers, requestId, target, method, path, operationContext, operationContract, operationContextHeader, operationContextDetailHeader, }: {
|
|
87
|
+
headers: Record<string, any>;
|
|
88
|
+
requestId: string;
|
|
89
|
+
target: TransportTarget;
|
|
90
|
+
method: string;
|
|
91
|
+
path: string;
|
|
92
|
+
operationContext: OperationContext | undefined;
|
|
93
|
+
operationContract: OperationContractOptions | undefined;
|
|
94
|
+
operationContextHeader: string;
|
|
95
|
+
operationContextDetailHeader: string;
|
|
96
|
+
}) => {
|
|
97
|
+
requestId: string;
|
|
98
|
+
operationId: string;
|
|
99
|
+
routePath: string;
|
|
100
|
+
method: string;
|
|
101
|
+
schemaHash?: string | undefined;
|
|
102
|
+
operationVersion?: number | undefined;
|
|
103
|
+
traceparent?: string | undefined;
|
|
104
|
+
traceId?: string | undefined;
|
|
105
|
+
spanId?: string | undefined;
|
|
106
|
+
};
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OperationContext } from './types.js';
|
|
2
|
+
export declare const BFF_LOCALE_HEADER = "accept-language";
|
|
3
|
+
export declare const BFF_TRACEPARENT_HEADER = "traceparent";
|
|
4
|
+
export type RequestContextInput = {
|
|
5
|
+
headers?: Record<string, unknown>;
|
|
6
|
+
locale?: string;
|
|
7
|
+
traceparent?: string;
|
|
8
|
+
operationContext?: OperationContext;
|
|
9
|
+
};
|
|
10
|
+
export type RequestContextSnapshot = {
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
locale?: string;
|
|
13
|
+
traceparent?: string;
|
|
14
|
+
traceId?: string;
|
|
15
|
+
spanId?: string;
|
|
16
|
+
operationContext?: OperationContext;
|
|
17
|
+
};
|
|
18
|
+
export declare function createRequestContextSnapshot(input?: RequestContextInput): RequestContextSnapshot;
|
|
19
|
+
export declare function createRequestContextHeaders(input?: RequestContextInput): Record<string, string>;
|
|
20
|
+
export { parseTraceparent, type TraceparentContext } from './traceparent.js';
|
|
21
|
+
export type * from './types.js';
|
|
22
|
+
export { BFF_DEFAULT_PROTECTED_IDENTITY_HEADERS, BFF_ENVELOPE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, } from './types.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type TraceparentContext = {
|
|
2
|
+
traceId: string;
|
|
3
|
+
spanId: string;
|
|
4
|
+
sampled: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Parse a W3C trace context `traceparent` header (version 00).
|
|
8
|
+
* All-zero trace ids and span ids are rejected per the W3C spec.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseTraceparent(traceparent: string | undefined | null): TraceparentContext | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransportResilienceOptions, TransportTarget } from './types.js';
|
|
2
|
+
type ExecuteWithResilienceOptions = {
|
|
3
|
+
requestId: string;
|
|
4
|
+
target: TransportTarget;
|
|
5
|
+
method: string;
|
|
6
|
+
url: string;
|
|
7
|
+
init: Record<string, any>;
|
|
8
|
+
fetcher: (...args: any[]) => Promise<any>;
|
|
9
|
+
transport?: TransportResilienceOptions;
|
|
10
|
+
};
|
|
11
|
+
export declare const executeWithResilience: ({ requestId, target, method, url, init, fetcher, transport, }: ExecuteWithResilienceOptions) => Promise<any>;
|
|
12
|
+
export {};
|