@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.17 → 3.9.0-ultramodern.19
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/effect/context.js +28 -4
- package/dist/cjs/effect/edge-dispatcher.js +5 -5
- package/dist/cjs/effect/edge.js +26 -6
- package/dist/cjs/effect/entry-shape.js +39 -14
- package/dist/cjs/effect/index.js +8 -8
- package/dist/cjs/effect/operation-context.js +2 -6
- package/dist/esm/effect/context.mjs +21 -6
- package/dist/esm/effect/edge-dispatcher.mjs +1 -1
- package/dist/esm/effect/edge.mjs +2 -0
- package/dist/esm/effect/entry-shape.mjs +27 -4
- package/dist/esm/effect/index.mjs +1 -1
- package/dist/esm/effect/operation-context.mjs +1 -2
- package/dist/esm-node/effect/context.mjs +21 -6
- package/dist/esm-node/effect/edge-dispatcher.mjs +1 -1
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/entry-shape.mjs +28 -8
- package/dist/esm-node/effect/index.mjs +1 -1
- package/dist/esm-node/effect/operation-context.mjs +1 -2
- package/dist/types/effect/context.d.ts +14 -1
- package/dist/types/effect/edge-dispatcher.d.ts +1 -1
- package/dist/types/effect/edge.d.ts +2 -0
- package/dist/types/effect/entry-shape.d.ts +12 -0
- package/dist/types/effect/handler/types.d.ts +1 -1
- package/dist/types/effect/operation-context.d.ts +0 -1
- package/package.json +26 -34
- package/src/effect/context.ts +64 -12
- package/src/effect/edge-dispatcher.ts +7 -6
- package/src/effect/edge.ts +5 -0
- package/src/effect/entry-shape.ts +93 -15
- package/src/effect/handler/batch.ts +0 -2
- package/src/effect/handler/definition.ts +0 -1
- package/src/effect/handler/types.ts +2 -3
- package/src/effect/index.ts +1 -1
- package/src/effect/operation-context.ts +0 -4
- package/dist/cjs/effect/edge-context.js +0 -61
- package/dist/esm/effect/edge-context.mjs +0 -14
- package/dist/esm-node/effect/edge-context.mjs +0 -15
- package/dist/types/effect/edge-context.d.ts +0 -5
- package/src/effect/edge-context.ts +0 -51
|
@@ -28,28 +28,52 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
EFFECT_BFF_CONTEXT_STORAGE_SHARE: ()=>EFFECT_BFF_CONTEXT_STORAGE_SHARE,
|
|
32
|
+
adoptEffectContextStorage: ()=>adoptEffectContextStorage,
|
|
31
33
|
createEffectOperationContext: ()=>external_operation_context_js_namespaceObject.createEffectOperationContext,
|
|
34
|
+
getEffectContextStorage: ()=>getEffectContextStorage,
|
|
32
35
|
runWithEffectContext: ()=>runWithEffectContext,
|
|
33
36
|
useEffectContext: ()=>useEffectContext,
|
|
34
37
|
useOperationContext: ()=>useOperationContext
|
|
35
38
|
});
|
|
36
|
-
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
37
39
|
const external_operation_context_js_namespaceObject = require("./operation-context.js");
|
|
38
40
|
const globalStore = globalThis;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
+
const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
|
|
42
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
43
|
+
if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
|
|
44
|
+
const EFFECT_BFF_CONTEXT_STORAGE_SHARE = '@modern-js/bff-effect/context-storage';
|
|
45
|
+
let effectContextStorage = new AsyncLocalStorage();
|
|
46
|
+
let effectContextStorageUsed = false;
|
|
47
|
+
const usedEffectContextStorage = ()=>{
|
|
48
|
+
effectContextStorageUsed = true;
|
|
49
|
+
return effectContextStorage;
|
|
50
|
+
};
|
|
51
|
+
const runWithEffectContext = (context, cb)=>usedEffectContextStorage().run(context, cb);
|
|
41
52
|
const useEffectContext = ()=>{
|
|
42
|
-
const context =
|
|
53
|
+
const context = usedEffectContextStorage().getStore();
|
|
43
54
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
44
55
|
return context;
|
|
45
56
|
};
|
|
57
|
+
const getEffectContextStorage = ()=>effectContextStorage;
|
|
58
|
+
function adoptEffectContextStorage(storage) {
|
|
59
|
+
const candidate = storage;
|
|
60
|
+
if ('function' != typeof candidate?.run || 'function' != typeof candidate.getStore) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_CONTEXT_STORAGE_SHARE} must provide an AsyncLocalStorage.`);
|
|
61
|
+
if (effectContextStorageUsed && candidate !== effectContextStorage) throw new Error('[BFF][Effect] A backend federation container received the host request storage after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
62
|
+
effectContextStorage = candidate;
|
|
63
|
+
}
|
|
46
64
|
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
65
|
+
exports.EFFECT_BFF_CONTEXT_STORAGE_SHARE = __webpack_exports__.EFFECT_BFF_CONTEXT_STORAGE_SHARE;
|
|
66
|
+
exports.adoptEffectContextStorage = __webpack_exports__.adoptEffectContextStorage;
|
|
47
67
|
exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
|
|
68
|
+
exports.getEffectContextStorage = __webpack_exports__.getEffectContextStorage;
|
|
48
69
|
exports.runWithEffectContext = __webpack_exports__.runWithEffectContext;
|
|
49
70
|
exports.useEffectContext = __webpack_exports__.useEffectContext;
|
|
50
71
|
exports.useOperationContext = __webpack_exports__.useOperationContext;
|
|
51
72
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
73
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
74
|
+
"adoptEffectContextStorage",
|
|
52
75
|
"createEffectOperationContext",
|
|
76
|
+
"getEffectContextStorage",
|
|
53
77
|
"runWithEffectContext",
|
|
54
78
|
"useEffectContext",
|
|
55
79
|
"useOperationContext"
|
|
@@ -93,15 +93,15 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
93
93
|
defineEffectBff: ()=>external_handler_js_namespaceObject.defineEffectBff,
|
|
94
94
|
defineEffectRpcBff: ()=>external_handler_js_namespaceObject.defineEffectRpcBff,
|
|
95
95
|
dispatchEffectBffRequest: ()=>dispatchEffectBffRequest,
|
|
96
|
-
runWithEffectContext: ()=>
|
|
97
|
-
useEffectContext: ()=>
|
|
98
|
-
useOperationContext: ()=>
|
|
96
|
+
runWithEffectContext: ()=>context_namespaceObject.runWithEffectContext,
|
|
97
|
+
useEffectContext: ()=>context_namespaceObject.useEffectContext,
|
|
98
|
+
useOperationContext: ()=>context_namespaceObject.useOperationContext
|
|
99
99
|
});
|
|
100
|
+
const context_namespaceObject = require("@modern-js/bff-effect/context");
|
|
100
101
|
const bff_policy_namespaceObject = require("@modern-js/server-runtime-extensions/bff-policy");
|
|
101
102
|
const Effect_namespaceObject = require("effect/Effect");
|
|
102
103
|
const external_headers_js_namespaceObject = require("../headers.js");
|
|
103
104
|
const external_dispatch_js_namespaceObject = require("./dispatch.js");
|
|
104
|
-
const external_edge_context_js_namespaceObject = require("./edge-context.js");
|
|
105
105
|
const external_module_js_namespaceObject = require("./module.js");
|
|
106
106
|
const Config_namespaceObject = require("effect/Config");
|
|
107
107
|
const Layer_namespaceObject = require("effect/Layer");
|
|
@@ -136,7 +136,7 @@ function restoreEffectBffMountPath(request, prefix) {
|
|
|
136
136
|
async function dispatchEffectBffRequest(handler, request, options = {}) {
|
|
137
137
|
return (0, external_dispatch_js_namespaceObject.dispatchEffectBffRequestWithContext)(handler, request, {
|
|
138
138
|
...options,
|
|
139
|
-
runWithEffectContext:
|
|
139
|
+
runWithEffectContext: context_namespaceObject.runWithEffectContext
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
async function createEffectBffEdgeDispatcher(options) {
|
package/dist/cjs/effect/edge.js
CHANGED
|
@@ -3,8 +3,14 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"./edge-dispatcher" (module) {
|
|
4
4
|
module.exports = require("./edge-dispatcher.js");
|
|
5
5
|
},
|
|
6
|
+
"./entry-shape" (module) {
|
|
7
|
+
module.exports = require("./entry-shape.js");
|
|
8
|
+
},
|
|
6
9
|
"./generated-entry" (module) {
|
|
7
10
|
module.exports = require("./generated-entry.js");
|
|
11
|
+
},
|
|
12
|
+
"@modern-js/bff-effect/context" (module) {
|
|
13
|
+
module.exports = require("@modern-js/bff-effect/context");
|
|
8
14
|
}
|
|
9
15
|
};
|
|
10
16
|
var __webpack_module_cache__ = {};
|
|
@@ -54,20 +60,34 @@ function __webpack_require__(moduleId) {
|
|
|
54
60
|
var __webpack_exports__ = {};
|
|
55
61
|
(()=>{
|
|
56
62
|
__webpack_require__.r(__webpack_exports__);
|
|
57
|
-
var
|
|
63
|
+
var _modern_js_bff_effect_context__rspack_import_0 = __webpack_require__("@modern-js/bff-effect/context");
|
|
64
|
+
var _edge_dispatcher__rspack_import_1 = __webpack_require__("./edge-dispatcher");
|
|
58
65
|
var __rspack_reexport = {};
|
|
59
|
-
for(const __rspack_import_key in
|
|
66
|
+
for(const __rspack_import_key in _edge_dispatcher__rspack_import_1)if ([
|
|
67
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
68
|
+
"default",
|
|
69
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
60
70
|
"createEffectBffEdgeDispatcherFactory",
|
|
61
|
-
"
|
|
62
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
71
|
+
"adoptEffectBffShareScope"
|
|
72
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_edge_dispatcher__rspack_import_1[__rspack_import_key];
|
|
63
73
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
64
|
-
var
|
|
74
|
+
var _entry_shape__rspack_import_2 = __webpack_require__("./entry-shape");
|
|
75
|
+
var _generated_entry__rspack_import_3 = __webpack_require__("./generated-entry");
|
|
65
76
|
__webpack_require__.d(__webpack_exports__, {
|
|
66
|
-
|
|
77
|
+
EFFECT_BFF_CONTEXT_STORAGE_SHARE: ()=>_modern_js_bff_effect_context__rspack_import_0.EFFECT_BFF_CONTEXT_STORAGE_SHARE,
|
|
78
|
+
EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE: ()=>_entry_shape__rspack_import_2.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE,
|
|
79
|
+
adoptEffectBffShareScope: ()=>_entry_shape__rspack_import_2.adoptEffectBffShareScope,
|
|
80
|
+
createEffectBffEdgeDispatcherFactory: ()=>_generated_entry__rspack_import_3.createEffectBffEdgeDispatcherFactory
|
|
67
81
|
});
|
|
68
82
|
})();
|
|
83
|
+
exports.EFFECT_BFF_CONTEXT_STORAGE_SHARE = __webpack_exports__.EFFECT_BFF_CONTEXT_STORAGE_SHARE;
|
|
84
|
+
exports.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = __webpack_exports__.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE;
|
|
85
|
+
exports.adoptEffectBffShareScope = __webpack_exports__.adoptEffectBffShareScope;
|
|
69
86
|
exports.createEffectBffEdgeDispatcherFactory = __webpack_exports__.createEffectBffEdgeDispatcherFactory;
|
|
70
87
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
89
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
90
|
+
"adoptEffectBffShareScope",
|
|
71
91
|
"createEffectBffEdgeDispatcherFactory"
|
|
72
92
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
73
93
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -30,6 +30,16 @@ var __webpack_require__ = {};
|
|
|
30
30
|
})();
|
|
31
31
|
var __webpack_exports__ = {};
|
|
32
32
|
__webpack_require__.r(__webpack_exports__);
|
|
33
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
+
EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE: ()=>EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE,
|
|
35
|
+
adoptEffectBffShareScope: ()=>adoptEffectBffShareScope,
|
|
36
|
+
classifyEffectBffEntryModule: ()=>classifyEffectBffEntryModule,
|
|
37
|
+
isValidatorAwareHandlerFactory: ()=>isValidatorAwareHandlerFactory,
|
|
38
|
+
registerValidatorAwareHandlerFactory: ()=>registerValidatorAwareHandlerFactory,
|
|
39
|
+
strictEffectApproachMessage: ()=>strictEffectApproachMessage
|
|
40
|
+
});
|
|
41
|
+
const context_namespaceObject = require("@modern-js/bff-effect/context");
|
|
42
|
+
const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
|
|
33
43
|
function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
34
44
|
const factories = new WeakSet();
|
|
35
45
|
return {
|
|
@@ -44,10 +54,7 @@ function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
|
44
54
|
}
|
|
45
55
|
function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
46
56
|
const moduleUrl = __rslib_import_meta_url__;
|
|
47
|
-
if ('string' != typeof moduleUrl || !moduleUrl.startsWith('file:'))
|
|
48
|
-
if ("u" > typeof __modernjs_backend_private_capability__) return __modernjs_backend_private_capability__;
|
|
49
|
-
return createLocalValidatorAwareHandlerFactoryRegistry();
|
|
50
|
-
}
|
|
57
|
+
if ('string' != typeof moduleUrl || !moduleUrl.startsWith('file:')) return createLocalValidatorAwareHandlerFactoryRegistry();
|
|
51
58
|
const moduleBuiltin = process.getBuiltinModule('node:module');
|
|
52
59
|
try {
|
|
53
60
|
return moduleBuiltin.createRequire(moduleUrl)("#effect-entry-shape-registry");
|
|
@@ -56,12 +63,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
|
56
63
|
throw error;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
|
-
|
|
66
|
+
let validatorAwareHandlerFactoryRegistry;
|
|
67
|
+
function handlerFactoryRegistry() {
|
|
68
|
+
validatorAwareHandlerFactoryRegistry ??= loadNodeValidatorAwareHandlerFactoryRegistry();
|
|
69
|
+
return validatorAwareHandlerFactoryRegistry;
|
|
70
|
+
}
|
|
71
|
+
const adoptShared = (shareScope, name, adopt)=>{
|
|
72
|
+
const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
|
|
73
|
+
const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
|
|
74
|
+
if ('function' != typeof shared?.get) return Promise.resolve();
|
|
75
|
+
return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
|
|
76
|
+
};
|
|
77
|
+
function adoptEffectBffShareScope(shareScope) {
|
|
78
|
+
return Promise.all([
|
|
79
|
+
adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
|
|
80
|
+
adoptShared(shareScope, context_namespaceObject.EFFECT_BFF_CONTEXT_STORAGE_SHARE, context_namespaceObject.adoptEffectContextStorage)
|
|
81
|
+
]).then(()=>void 0);
|
|
82
|
+
}
|
|
83
|
+
function adoptHandlerFactoryRegistry(registry) {
|
|
84
|
+
if ('function' != typeof registry?.register || 'function' != typeof registry.is) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE} must provide a handler factory registry.`);
|
|
85
|
+
if (void 0 !== validatorAwareHandlerFactoryRegistry && validatorAwareHandlerFactoryRegistry !== registry) throw new Error('[BFF][Effect] A backend federation container received the host handler factory registry after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
86
|
+
validatorAwareHandlerFactoryRegistry = registry;
|
|
87
|
+
}
|
|
60
88
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
61
|
-
return
|
|
89
|
+
return handlerFactoryRegistry().register(factory);
|
|
62
90
|
}
|
|
63
91
|
function isValidatorAwareHandlerFactory(factory) {
|
|
64
|
-
return
|
|
92
|
+
return handlerFactoryRegistry().is(factory);
|
|
65
93
|
}
|
|
66
94
|
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
67
95
|
function isEffectEntryRecord(value) {
|
|
@@ -94,18 +122,15 @@ function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
|
94
122
|
hasRuntimeLayer
|
|
95
123
|
};
|
|
96
124
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
isValidatorAwareHandlerFactory: ()=>isValidatorAwareHandlerFactory,
|
|
100
|
-
registerValidatorAwareHandlerFactory: ()=>registerValidatorAwareHandlerFactory
|
|
101
|
-
}, {
|
|
102
|
-
strictEffectApproachMessage: strictEffectApproachMessage
|
|
103
|
-
});
|
|
125
|
+
exports.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = __webpack_exports__.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE;
|
|
126
|
+
exports.adoptEffectBffShareScope = __webpack_exports__.adoptEffectBffShareScope;
|
|
104
127
|
exports.classifyEffectBffEntryModule = __webpack_exports__.classifyEffectBffEntryModule;
|
|
105
128
|
exports.isValidatorAwareHandlerFactory = __webpack_exports__.isValidatorAwareHandlerFactory;
|
|
106
129
|
exports.registerValidatorAwareHandlerFactory = __webpack_exports__.registerValidatorAwareHandlerFactory;
|
|
107
130
|
exports.strictEffectApproachMessage = __webpack_exports__.strictEffectApproachMessage;
|
|
108
131
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
132
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
133
|
+
"adoptEffectBffShareScope",
|
|
109
134
|
"classifyEffectBffEntryModule",
|
|
110
135
|
"isValidatorAwareHandlerFactory",
|
|
111
136
|
"registerValidatorAwareHandlerFactory",
|
package/dist/cjs/effect/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"./context" (module) {
|
|
4
|
-
module.exports = require("./context.js");
|
|
5
|
-
},
|
|
6
3
|
"./edge" (module) {
|
|
7
4
|
module.exports = require("./edge.js");
|
|
8
5
|
},
|
|
@@ -17,6 +14,9 @@ var __webpack_modules__ = {
|
|
|
17
14
|
},
|
|
18
15
|
"@effect/opentelemetry" (module) {
|
|
19
16
|
module.exports = require("@effect/opentelemetry");
|
|
17
|
+
},
|
|
18
|
+
"@modern-js/bff-effect/context" (module) {
|
|
19
|
+
module.exports = require("@modern-js/bff-effect/context");
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
var __webpack_module_cache__ = {};
|
|
@@ -67,7 +67,7 @@ var __webpack_exports__ = {};
|
|
|
67
67
|
(()=>{
|
|
68
68
|
__webpack_require__.r(__webpack_exports__);
|
|
69
69
|
var _effect_opentelemetry__rspack_import_0 = __webpack_require__("@effect/opentelemetry");
|
|
70
|
-
var
|
|
70
|
+
var _modern_js_bff_effect_context__rspack_import_1 = __webpack_require__("@modern-js/bff-effect/context");
|
|
71
71
|
var _edge__rspack_import_2 = __webpack_require__("./edge");
|
|
72
72
|
var _endpoint_contracts__rspack_import_3 = __webpack_require__("./endpoint-contracts");
|
|
73
73
|
var __rspack_reexport = {};
|
|
@@ -104,12 +104,12 @@ var __webpack_exports__ = {};
|
|
|
104
104
|
OpenTelemetry: ()=>_effect_opentelemetry__rspack_import_0,
|
|
105
105
|
createEffectBffEdgeHandler: ()=>_edge__rspack_import_2.createEffectBffEdgeHandler,
|
|
106
106
|
createEffectBffTestHandler: ()=>_edge__rspack_import_2.createEffectBffTestHandler,
|
|
107
|
-
createEffectOperationContext: ()=>
|
|
107
|
+
createEffectOperationContext: ()=>_modern_js_bff_effect_context__rspack_import_1.createEffectOperationContext,
|
|
108
108
|
dispatchEffectBffRequest: ()=>_edge__rspack_import_2.dispatchEffectBffRequest,
|
|
109
109
|
resolveEffectBffModuleHandler: ()=>_module__rspack_import_5.resolveEffectBffModuleHandler,
|
|
110
|
-
runWithEffectContext: ()=>
|
|
111
|
-
useEffectContext: ()=>
|
|
112
|
-
useOperationContext: ()=>
|
|
110
|
+
runWithEffectContext: ()=>_modern_js_bff_effect_context__rspack_import_1.runWithEffectContext,
|
|
111
|
+
useEffectContext: ()=>_modern_js_bff_effect_context__rspack_import_1.useEffectContext,
|
|
112
|
+
useOperationContext: ()=>_modern_js_bff_effect_context__rspack_import_1.useOperationContext
|
|
113
113
|
});
|
|
114
114
|
})();
|
|
115
115
|
exports.OpenTelemetry = __webpack_exports__.OpenTelemetry;
|
|
@@ -28,11 +28,9 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
createEffectOperationContext: ()=>createEffectOperationContext
|
|
32
|
-
kEffectContextStorage: ()=>kEffectContextStorage
|
|
31
|
+
createEffectOperationContext: ()=>createEffectOperationContext
|
|
33
32
|
});
|
|
34
33
|
const request_context_namespaceObject = require("@modern-js/runtime-extensions/request-context");
|
|
35
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
36
34
|
const readHeader = (headers, header)=>{
|
|
37
35
|
const value = headers.get(header);
|
|
38
36
|
return value && value.length > 0 ? value : void 0;
|
|
@@ -106,10 +104,8 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
106
104
|
};
|
|
107
105
|
};
|
|
108
106
|
exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
|
|
109
|
-
exports.kEffectContextStorage = __webpack_exports__.kEffectContextStorage;
|
|
110
107
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
111
|
-
"createEffectOperationContext"
|
|
112
|
-
"kEffectContextStorage"
|
|
108
|
+
"createEffectOperationContext"
|
|
113
109
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
114
110
|
Object.defineProperty(exports, '__esModule', {
|
|
115
111
|
value: true
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { createEffectOperationContext, kEffectContextStorage } from "./operation-context.mjs";
|
|
3
1
|
const globalStore = globalThis;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
2
|
+
const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
|
|
3
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
4
|
+
if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
|
|
5
|
+
const EFFECT_BFF_CONTEXT_STORAGE_SHARE = '@modern-js/bff-effect/context-storage';
|
|
6
|
+
let effectContextStorage = new AsyncLocalStorage();
|
|
7
|
+
let effectContextStorageUsed = false;
|
|
8
|
+
const usedEffectContextStorage = ()=>{
|
|
9
|
+
effectContextStorageUsed = true;
|
|
10
|
+
return effectContextStorage;
|
|
11
|
+
};
|
|
12
|
+
const runWithEffectContext = (context, cb)=>usedEffectContextStorage().run(context, cb);
|
|
6
13
|
const useEffectContext = ()=>{
|
|
7
|
-
const context =
|
|
14
|
+
const context = usedEffectContextStorage().getStore();
|
|
8
15
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
9
16
|
return context;
|
|
10
17
|
};
|
|
18
|
+
const getEffectContextStorage = ()=>effectContextStorage;
|
|
19
|
+
function adoptEffectContextStorage(storage) {
|
|
20
|
+
const candidate = storage;
|
|
21
|
+
if ('function' != typeof candidate?.run || 'function' != typeof candidate.getStore) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_CONTEXT_STORAGE_SHARE} must provide an AsyncLocalStorage.`);
|
|
22
|
+
if (effectContextStorageUsed && candidate !== effectContextStorage) throw new Error('[BFF][Effect] A backend federation container received the host request storage after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
23
|
+
effectContextStorage = candidate;
|
|
24
|
+
}
|
|
11
25
|
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
12
|
-
export { createEffectOperationContext
|
|
26
|
+
export { createEffectOperationContext } from "./operation-context.mjs";
|
|
27
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage, getEffectContextStorage, runWithEffectContext, useEffectContext, useOperationContext };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
1
2
|
import { evaluateCrossProjectPolicy, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
|
|
2
3
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
3
4
|
import { toHeaderRecord } from "../headers.mjs";
|
|
4
5
|
import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
|
|
5
|
-
import { runWithEffectContext, useEffectContext, useOperationContext } from "./edge-context.mjs";
|
|
6
6
|
import { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
7
7
|
import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
|
|
8
8
|
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
package/dist/esm/effect/edge.mjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from "./edge-dispatcher.mjs";
|
|
2
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from "@modern-js/bff-effect/context";
|
|
3
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope } from "./entry-shape.mjs";
|
|
2
4
|
export { createEffectBffEdgeDispatcherFactory } from "./generated-entry.mjs";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage } from "@modern-js/bff-effect/context";
|
|
2
|
+
const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
|
|
1
3
|
function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
2
4
|
const factories = new WeakSet();
|
|
3
5
|
return {
|
|
@@ -10,12 +12,33 @@ function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
|
10
12
|
}
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
|
-
|
|
15
|
+
let validatorAwareHandlerFactoryRegistry;
|
|
16
|
+
function handlerFactoryRegistry() {
|
|
17
|
+
validatorAwareHandlerFactoryRegistry ??= createLocalValidatorAwareHandlerFactoryRegistry();
|
|
18
|
+
return validatorAwareHandlerFactoryRegistry;
|
|
19
|
+
}
|
|
20
|
+
const adoptShared = (shareScope, name, adopt)=>{
|
|
21
|
+
const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
|
|
22
|
+
const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
|
|
23
|
+
if ('function' != typeof shared?.get) return Promise.resolve();
|
|
24
|
+
return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
|
|
25
|
+
};
|
|
26
|
+
function adoptEffectBffShareScope(shareScope) {
|
|
27
|
+
return Promise.all([
|
|
28
|
+
adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
|
|
29
|
+
adoptShared(shareScope, EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage)
|
|
30
|
+
]).then(()=>void 0);
|
|
31
|
+
}
|
|
32
|
+
function adoptHandlerFactoryRegistry(registry) {
|
|
33
|
+
if ('function' != typeof registry?.register || 'function' != typeof registry.is) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE} must provide a handler factory registry.`);
|
|
34
|
+
if (void 0 !== validatorAwareHandlerFactoryRegistry && validatorAwareHandlerFactoryRegistry !== registry) throw new Error('[BFF][Effect] A backend federation container received the host handler factory registry after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
35
|
+
validatorAwareHandlerFactoryRegistry = registry;
|
|
36
|
+
}
|
|
14
37
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
15
|
-
return
|
|
38
|
+
return handlerFactoryRegistry().register(factory);
|
|
16
39
|
}
|
|
17
40
|
function isValidatorAwareHandlerFactory(factory) {
|
|
18
|
-
return
|
|
41
|
+
return handlerFactoryRegistry().is(factory);
|
|
19
42
|
}
|
|
20
43
|
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
21
44
|
function isEffectEntryRecord(value) {
|
|
@@ -48,4 +71,4 @@ function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
|
48
71
|
hasRuntimeLayer
|
|
49
72
|
};
|
|
50
73
|
}
|
|
51
|
-
export { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
74
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as __rspack_external__effect_opentelemetry_66324c75 from "@effect/opentelemetry";
|
|
2
2
|
export * from "./endpoint-contracts.mjs";
|
|
3
3
|
export * from "./handler.mjs";
|
|
4
|
-
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "
|
|
4
|
+
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
5
5
|
export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest } from "./edge.mjs";
|
|
6
6
|
export { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
7
7
|
export { __rspack_external__effect_opentelemetry_66324c75 as OpenTelemetry };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/runtime-extensions/request-context";
|
|
2
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
3
2
|
const readHeader = (headers, header)=>{
|
|
4
3
|
const value = headers.get(header);
|
|
5
4
|
return value && value.length > 0 ? value : void 0;
|
|
@@ -72,4 +71,4 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
72
71
|
} : {}
|
|
73
72
|
};
|
|
74
73
|
};
|
|
75
|
-
export { createEffectOperationContext
|
|
74
|
+
export { createEffectOperationContext };
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
import { createEffectOperationContext, kEffectContextStorage } from "./operation-context.mjs";
|
|
4
2
|
const globalStore = globalThis;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
|
|
4
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
5
|
+
if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
|
|
6
|
+
const EFFECT_BFF_CONTEXT_STORAGE_SHARE = '@modern-js/bff-effect/context-storage';
|
|
7
|
+
let effectContextStorage = new AsyncLocalStorage();
|
|
8
|
+
let effectContextStorageUsed = false;
|
|
9
|
+
const usedEffectContextStorage = ()=>{
|
|
10
|
+
effectContextStorageUsed = true;
|
|
11
|
+
return effectContextStorage;
|
|
12
|
+
};
|
|
13
|
+
const runWithEffectContext = (context, cb)=>usedEffectContextStorage().run(context, cb);
|
|
7
14
|
const useEffectContext = ()=>{
|
|
8
|
-
const context =
|
|
15
|
+
const context = usedEffectContextStorage().getStore();
|
|
9
16
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
10
17
|
return context;
|
|
11
18
|
};
|
|
19
|
+
const getEffectContextStorage = ()=>effectContextStorage;
|
|
20
|
+
function adoptEffectContextStorage(storage) {
|
|
21
|
+
const candidate = storage;
|
|
22
|
+
if ('function' != typeof candidate?.run || 'function' != typeof candidate.getStore) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_CONTEXT_STORAGE_SHARE} must provide an AsyncLocalStorage.`);
|
|
23
|
+
if (effectContextStorageUsed && candidate !== effectContextStorage) throw new Error('[BFF][Effect] A backend federation container received the host request storage after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
24
|
+
effectContextStorage = candidate;
|
|
25
|
+
}
|
|
12
26
|
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
13
|
-
export { createEffectOperationContext
|
|
27
|
+
export { createEffectOperationContext } from "./operation-context.mjs";
|
|
28
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage, getEffectContextStorage, runWithEffectContext, useEffectContext, useOperationContext };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
2
3
|
import { evaluateCrossProjectPolicy, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
|
|
3
4
|
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
4
5
|
import { toHeaderRecord } from "../headers.mjs";
|
|
5
6
|
import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
|
|
6
|
-
import { runWithEffectContext, useEffectContext, useOperationContext } from "./edge-context.mjs";
|
|
7
7
|
import { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
8
8
|
import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
|
|
9
9
|
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
export * from "./edge-dispatcher.mjs";
|
|
3
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from "@modern-js/bff-effect/context";
|
|
4
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope } from "./entry-shape.mjs";
|
|
3
5
|
export { createEffectBffEdgeDispatcherFactory } from "./generated-entry.mjs";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage } from "@modern-js/bff-effect/context";
|
|
3
|
+
const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
|
|
2
4
|
function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
3
5
|
const factories = new WeakSet();
|
|
4
6
|
return {
|
|
@@ -13,10 +15,7 @@ function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
|
13
15
|
}
|
|
14
16
|
function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
15
17
|
const moduleUrl = import.meta.url;
|
|
16
|
-
if ('string' != typeof moduleUrl || !moduleUrl.startsWith('file:'))
|
|
17
|
-
if ("u" > typeof __modernjs_backend_private_capability__) return __modernjs_backend_private_capability__;
|
|
18
|
-
return createLocalValidatorAwareHandlerFactoryRegistry();
|
|
19
|
-
}
|
|
18
|
+
if ('string' != typeof moduleUrl || !moduleUrl.startsWith('file:')) return createLocalValidatorAwareHandlerFactoryRegistry();
|
|
20
19
|
const moduleBuiltin = process.getBuiltinModule('node:module');
|
|
21
20
|
try {
|
|
22
21
|
return moduleBuiltin.createRequire(moduleUrl)("#effect-entry-shape-registry");
|
|
@@ -25,12 +24,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
|
25
24
|
throw error;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
let validatorAwareHandlerFactoryRegistry;
|
|
28
|
+
function handlerFactoryRegistry() {
|
|
29
|
+
validatorAwareHandlerFactoryRegistry ??= loadNodeValidatorAwareHandlerFactoryRegistry();
|
|
30
|
+
return validatorAwareHandlerFactoryRegistry;
|
|
31
|
+
}
|
|
32
|
+
const adoptShared = (shareScope, name, adopt)=>{
|
|
33
|
+
const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
|
|
34
|
+
const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
|
|
35
|
+
if ('function' != typeof shared?.get) return Promise.resolve();
|
|
36
|
+
return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
|
|
37
|
+
};
|
|
38
|
+
function adoptEffectBffShareScope(shareScope) {
|
|
39
|
+
return Promise.all([
|
|
40
|
+
adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
|
|
41
|
+
adoptShared(shareScope, EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage)
|
|
42
|
+
]).then(()=>void 0);
|
|
43
|
+
}
|
|
44
|
+
function adoptHandlerFactoryRegistry(registry) {
|
|
45
|
+
if ('function' != typeof registry?.register || 'function' != typeof registry.is) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE} must provide a handler factory registry.`);
|
|
46
|
+
if (void 0 !== validatorAwareHandlerFactoryRegistry && validatorAwareHandlerFactoryRegistry !== registry) throw new Error('[BFF][Effect] A backend federation container received the host handler factory registry after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
47
|
+
validatorAwareHandlerFactoryRegistry = registry;
|
|
48
|
+
}
|
|
29
49
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
30
|
-
return
|
|
50
|
+
return handlerFactoryRegistry().register(factory);
|
|
31
51
|
}
|
|
32
52
|
function isValidatorAwareHandlerFactory(factory) {
|
|
33
|
-
return
|
|
53
|
+
return handlerFactoryRegistry().is(factory);
|
|
34
54
|
}
|
|
35
55
|
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
36
56
|
function isEffectEntryRecord(value) {
|
|
@@ -63,4 +83,4 @@ function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
|
63
83
|
hasRuntimeLayer
|
|
64
84
|
};
|
|
65
85
|
}
|
|
66
|
-
export { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
86
|
+
export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
|
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
import * as __rspack_external__effect_opentelemetry_66324c75 from "@effect/opentelemetry";
|
|
3
3
|
export * from "./endpoint-contracts.mjs";
|
|
4
4
|
export * from "./handler.mjs";
|
|
5
|
-
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "
|
|
5
|
+
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
|
|
6
6
|
export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest } from "./edge.mjs";
|
|
7
7
|
export { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
8
8
|
export { __rspack_external__effect_opentelemetry_66324c75 as OpenTelemetry };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/runtime-extensions/request-context";
|
|
3
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
4
3
|
const readHeader = (headers, header)=>{
|
|
5
4
|
const value = headers.get(header);
|
|
6
5
|
return value && value.length > 0 ? value : void 0;
|
|
@@ -73,4 +72,4 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
73
72
|
} : {}
|
|
74
73
|
};
|
|
75
74
|
};
|
|
76
|
-
export { createEffectOperationContext
|
|
75
|
+
export { createEffectOperationContext };
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { EffectContext, EffectContextStorage } from './operation-context.js';
|
|
2
2
|
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Module Federation share through which a backend federation host hands its
|
|
5
|
+
* request storage to the containers it initializes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EFFECT_BFF_CONTEXT_STORAGE_SHARE = "@modern-js/bff-effect/context-storage";
|
|
3
8
|
export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
|
|
4
9
|
export declare const useEffectContext: () => EffectContext;
|
|
10
|
+
/** @internal The storage a backend federation host shares with containers. */
|
|
11
|
+
export declare const getEffectContextStorage: () => EffectContextStorage;
|
|
12
|
+
/**
|
|
13
|
+
* @internal Called through `adoptEffectBffShareScope()` from a backend
|
|
14
|
+
* federation container's `init()`, so its endpoints read the context the
|
|
15
|
+
* host dispatcher enters.
|
|
16
|
+
*/
|
|
17
|
+
export declare function adoptEffectContextStorage(storage: unknown): void;
|
|
5
18
|
export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
|
|
@@ -3,6 +3,7 @@ import { type DispatchEffectBffRequestOptions } from './dispatch.js';
|
|
|
3
3
|
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler.js';
|
|
4
4
|
import { type EffectApiModule, type EffectBffRequestHandler } from './module.js';
|
|
5
5
|
import type { EffectContext } from './operation-context.js';
|
|
6
|
+
export { runWithEffectContext, useEffectContext, useOperationContext, } from './context.js';
|
|
6
7
|
export * as Config from 'effect/Config';
|
|
7
8
|
export * as Effect from 'effect/Effect';
|
|
8
9
|
export * as Layer from 'effect/Layer';
|
|
@@ -11,7 +12,6 @@ export * as Schema from 'effect/Schema';
|
|
|
11
12
|
export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams, } from 'effect/unstable/http';
|
|
12
13
|
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi, } from 'effect/unstable/httpapi';
|
|
13
14
|
export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils, } from 'effect/unstable/rpc';
|
|
14
|
-
export { runWithEffectContext, useEffectContext, useOperationContext, } from './edge-context.js';
|
|
15
15
|
export type { EffectApiClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler.js';
|
|
16
16
|
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler.js';
|
|
17
17
|
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from './context.js';
|
|
1
2
|
export * from './edge-dispatcher.js';
|
|
3
|
+
export { adoptEffectBffShareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, } from './entry-shape.js';
|
|
2
4
|
export { createEffectBffEdgeDispatcherFactory } from './generated-entry.js';
|