@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.2 → 3.9.0-ultramodern.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/cjs/assembly.js +50 -0
- package/dist/cjs/{effect-client/guards.js → data-platform/batch/options.js} +13 -9
- package/dist/cjs/data-platform/batch/queue.js +48 -83
- package/dist/cjs/data-platform/trace.js +2 -2
- package/dist/cjs/effect/context.js +28 -4
- package/dist/cjs/effect/edge-dispatcher.js +12 -12
- package/dist/cjs/effect/edge.js +36 -3
- package/dist/cjs/effect/endpoint-contracts.js +3 -4
- package/dist/cjs/effect/entry-shape.js +40 -12
- package/dist/cjs/effect/generated-entry.js +57 -0
- package/dist/cjs/effect/handler/batch-handler.js +7 -7
- package/dist/cjs/effect/handler/batch.js +8 -10
- package/dist/cjs/effect/handler/definition.js +1 -21
- package/dist/cjs/effect/index.js +8 -8
- package/dist/cjs/effect/module.js +8 -4
- package/dist/cjs/effect/operation-context.js +10 -14
- package/dist/cjs/effect/rpcSerialization.js +0 -2
- package/dist/cjs/effect-client/cross-project.js +89 -0
- package/dist/cjs/effect-client/index.js +5 -3
- package/dist/cjs/microvertical-api.js +120 -0
- package/dist/esm/assembly.mjs +12 -0
- package/dist/esm/data-platform/batch/options.mjs +10 -0
- package/dist/esm/data-platform/batch/queue.mjs +48 -83
- package/dist/esm/data-platform/trace.mjs +1 -1
- package/dist/esm/effect/context.mjs +21 -6
- package/dist/esm/effect/edge-dispatcher.mjs +6 -6
- package/dist/esm/effect/edge.mjs +3 -0
- package/dist/esm/effect/endpoint-contracts.mjs +2 -3
- package/dist/esm/effect/entry-shape-registry.mjs +2 -2
- package/dist/esm/effect/entry-shape.mjs +29 -6
- package/dist/esm/effect/generated-entry.mjs +19 -0
- package/dist/esm/effect/handler/batch-handler.mjs +8 -8
- package/dist/esm/effect/handler/batch.mjs +9 -8
- package/dist/esm/effect/handler/definition.mjs +1 -21
- package/dist/esm/effect/index.mjs +1 -1
- package/dist/esm/effect/module.mjs +8 -4
- package/dist/esm/effect/operation-context.mjs +3 -4
- package/dist/esm/effect/rpcSerialization.mjs +0 -2
- package/dist/esm/effect-client/cross-project.mjs +51 -0
- package/dist/esm/effect-client/index.mjs +4 -2
- package/dist/esm/microvertical-api.mjs +67 -0
- package/dist/esm-node/assembly.mjs +13 -0
- package/dist/esm-node/data-platform/batch/options.mjs +11 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +48 -83
- package/dist/esm-node/data-platform/trace.mjs +1 -1
- package/dist/esm-node/effect/context.mjs +21 -6
- package/dist/esm-node/effect/edge-dispatcher.mjs +6 -6
- package/dist/esm-node/effect/edge.mjs +3 -0
- package/dist/esm-node/effect/endpoint-contracts.mjs +2 -3
- package/dist/esm-node/effect/entry-shape.mjs +29 -6
- package/dist/esm-node/effect/generated-entry.mjs +20 -0
- package/dist/esm-node/effect/handler/batch-handler.mjs +8 -8
- package/dist/esm-node/effect/handler/batch.mjs +9 -8
- package/dist/esm-node/effect/handler/definition.mjs +1 -21
- package/dist/esm-node/effect/index.mjs +1 -1
- package/dist/esm-node/effect/module.mjs +8 -4
- package/dist/esm-node/effect/operation-context.mjs +3 -4
- package/dist/esm-node/effect/rpcSerialization.mjs +0 -2
- package/dist/esm-node/effect-client/cross-project.mjs +52 -0
- package/dist/esm-node/effect-client/index.mjs +4 -2
- package/dist/esm-node/microvertical-api.mjs +68 -0
- package/dist/types/assembly.d.ts +10 -0
- package/dist/types/data-platform/batch/options.d.ts +7 -0
- package/dist/types/data-platform/batch/queue.d.ts +0 -1
- package/dist/types/effect/context.d.ts +15 -2
- package/dist/types/effect/edge-dispatcher.d.ts +3 -3
- package/dist/types/effect/edge.d.ts +3 -0
- package/dist/types/effect/endpoint-contracts.d.ts +2 -20
- package/dist/types/effect/entry-shape.d.ts +16 -2
- package/dist/types/effect/generated-entry.d.ts +7 -0
- package/dist/types/effect/handler/batch.d.ts +7 -2
- package/dist/types/effect/handler/types.d.ts +2 -17
- package/dist/types/effect/handler.d.ts +1 -1
- package/dist/types/effect/module.d.ts +2 -1
- package/dist/types/effect/operation-context.d.ts +1 -2
- package/dist/types/effect-client/cross-project.d.ts +10 -0
- package/dist/types/effect-client/index.d.ts +7 -4
- package/dist/types/microvertical-api.d.ts +65 -0
- package/package.json +47 -42
- package/src/assembly.ts +43 -0
- package/src/data-platform/batch/options.ts +20 -0
- package/src/data-platform/batch/queue.ts +63 -92
- package/src/data-platform/trace.ts +1 -1
- package/src/effect/context.ts +64 -12
- package/src/effect/edge-dispatcher.ts +14 -11
- package/src/effect/edge.ts +6 -0
- package/src/effect/endpoint-contracts.ts +3 -24
- package/src/effect/entry-shape.ts +105 -10
- package/src/effect/generated-entry.ts +36 -0
- package/src/effect/handler/batch-handler.ts +27 -28
- package/src/effect/handler/batch.ts +9 -13
- package/src/effect/handler/definition.ts +0 -45
- package/src/effect/handler/http.ts +2 -2
- package/src/effect/handler/types.ts +3 -32
- package/src/effect/handler.ts +0 -1
- package/src/effect/index.ts +1 -1
- package/src/effect/module.ts +11 -4
- package/src/effect/operation-context.ts +2 -6
- package/src/effect/rpcSerialization.ts +0 -2
- package/src/effect-client/cross-project.ts +104 -0
- package/src/effect-client/index.ts +17 -7
- package/src/microvertical-api.ts +102 -0
- package/dist/cjs/effect/edge-context.js +0 -61
- package/dist/cjs/effect-client/batch.js +0 -73
- package/dist/cjs/effect-client/envelope.js +0 -145
- package/dist/cjs/effect-client/request-context.js +0 -64
- package/dist/cjs/effect-client/request.js +0 -66
- package/dist/cjs/effect-client/runtime.js +0 -100
- package/dist/cjs/effect-client/types.js +0 -18
- package/dist/esm/effect/edge-context.mjs +0 -14
- package/dist/esm/effect-client/batch.mjs +0 -35
- package/dist/esm/effect-client/envelope.mjs +0 -104
- package/dist/esm/effect-client/guards.mjs +0 -3
- package/dist/esm/effect-client/request-context.mjs +0 -23
- package/dist/esm/effect-client/request.mjs +0 -28
- package/dist/esm/effect-client/runtime.mjs +0 -62
- package/dist/esm/effect-client/types.mjs +0 -0
- package/dist/esm-node/effect/edge-context.mjs +0 -15
- package/dist/esm-node/effect-client/batch.mjs +0 -36
- package/dist/esm-node/effect-client/envelope.mjs +0 -105
- package/dist/esm-node/effect-client/guards.mjs +0 -4
- package/dist/esm-node/effect-client/request-context.mjs +0 -24
- package/dist/esm-node/effect-client/request.mjs +0 -29
- package/dist/esm-node/effect-client/runtime.mjs +0 -63
- package/dist/esm-node/effect-client/types.mjs +0 -1
- package/dist/types/effect/edge-context.d.ts +0 -5
- package/dist/types/effect-client/batch.d.ts +0 -2
- package/dist/types/effect-client/envelope.d.ts +0 -15
- package/dist/types/effect-client/guards.d.ts +0 -2
- package/dist/types/effect-client/request-context.d.ts +0 -3
- package/dist/types/effect-client/request.d.ts +0 -1
- package/dist/types/effect-client/runtime.d.ts +0 -5
- package/dist/types/effect-client/types.d.ts +0 -68
- package/src/effect/edge-context.ts +0 -51
- package/src/effect-client/batch.ts +0 -50
- package/src/effect-client/envelope.ts +0 -238
- package/src/effect-client/guards.ts +0 -6
- package/src/effect-client/request-context.ts +0 -54
- package/src/effect-client/request.ts +0 -51
- package/src/effect-client/runtime.ts +0 -122
- package/src/effect-client/types.ts +0 -84
|
@@ -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 {
|
|
@@ -53,12 +63,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
|
53
63
|
throw error;
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
|
-
|
|
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
|
+
}
|
|
57
88
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
58
|
-
return
|
|
89
|
+
return handlerFactoryRegistry().register(factory);
|
|
59
90
|
}
|
|
60
91
|
function isValidatorAwareHandlerFactory(factory) {
|
|
61
|
-
return
|
|
92
|
+
return handlerFactoryRegistry().is(factory);
|
|
62
93
|
}
|
|
63
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.';
|
|
64
95
|
function isEffectEntryRecord(value) {
|
|
@@ -77,13 +108,13 @@ function classifyEffectBffEntryModule(value, predicates) {
|
|
|
77
108
|
if (predicates.isRequestHandler(module.handler)) return createEntryShapeFacts(module, predicates, '`handler` export');
|
|
78
109
|
return createEntryShapeFacts(module, predicates);
|
|
79
110
|
}
|
|
80
|
-
function createEntryShapeFacts(module, predicates,
|
|
111
|
+
function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
81
112
|
const createHandler = 'function' == typeof module.createHandler ? module.createHandler : void 0;
|
|
82
113
|
const api = predicates.isHttpApi(module.api) ? module.api : void 0;
|
|
83
114
|
const hasRuntimeLayer = void 0 !== module.layer;
|
|
84
115
|
return {
|
|
85
116
|
module,
|
|
86
|
-
|
|
117
|
+
unsupportedShape,
|
|
87
118
|
createHandler,
|
|
88
119
|
createHandlerValidatorAware: void 0 !== createHandler && predicates.isValidatorAwareHandlerFactory(createHandler),
|
|
89
120
|
api,
|
|
@@ -91,18 +122,15 @@ function createEntryShapeFacts(module, predicates, legacyShape) {
|
|
|
91
122
|
hasRuntimeLayer
|
|
92
123
|
};
|
|
93
124
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
isValidatorAwareHandlerFactory: ()=>isValidatorAwareHandlerFactory,
|
|
97
|
-
registerValidatorAwareHandlerFactory: ()=>registerValidatorAwareHandlerFactory
|
|
98
|
-
}, {
|
|
99
|
-
strictEffectApproachMessage: strictEffectApproachMessage
|
|
100
|
-
});
|
|
125
|
+
exports.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = __webpack_exports__.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE;
|
|
126
|
+
exports.adoptEffectBffShareScope = __webpack_exports__.adoptEffectBffShareScope;
|
|
101
127
|
exports.classifyEffectBffEntryModule = __webpack_exports__.classifyEffectBffEntryModule;
|
|
102
128
|
exports.isValidatorAwareHandlerFactory = __webpack_exports__.isValidatorAwareHandlerFactory;
|
|
103
129
|
exports.registerValidatorAwareHandlerFactory = __webpack_exports__.registerValidatorAwareHandlerFactory;
|
|
104
130
|
exports.strictEffectApproachMessage = __webpack_exports__.strictEffectApproachMessage;
|
|
105
131
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
132
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
133
|
+
"adoptEffectBffShareScope",
|
|
106
134
|
"classifyEffectBffEntryModule",
|
|
107
135
|
"isValidatorAwareHandlerFactory",
|
|
108
136
|
"registerValidatorAwareHandlerFactory",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createEffectBffEdgeDispatcherFactory: ()=>createEffectBffEdgeDispatcherFactory
|
|
32
|
+
});
|
|
33
|
+
const external_edge_dispatcher_js_namespaceObject = require("./edge-dispatcher.js");
|
|
34
|
+
function createEffectBffEdgeDispatcherFactory(module, generatedOperationContracts) {
|
|
35
|
+
return (options)=>{
|
|
36
|
+
const policy = options?.crossProjectPolicy;
|
|
37
|
+
const crossProjectPolicy = null == policy || null === policy.expectedOperationContracts || 'object' != typeof policy.expectedOperationContracts || Array.isArray(policy.expectedOperationContracts) ? policy : {
|
|
38
|
+
...policy,
|
|
39
|
+
expectedOperationContracts: {
|
|
40
|
+
...policy.expectedOperationContracts,
|
|
41
|
+
...generatedOperationContracts
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return (0, external_edge_dispatcher_js_namespaceObject.createEffectBffEdgeDispatcher)({
|
|
45
|
+
...options,
|
|
46
|
+
crossProjectPolicy,
|
|
47
|
+
module
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.createEffectBffEdgeDispatcherFactory = __webpack_exports__.createEffectBffEdgeDispatcherFactory;
|
|
52
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
53
|
+
"createEffectBffEdgeDispatcherFactory"
|
|
54
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
|
+
Object.defineProperty(exports, '__esModule', {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
@@ -30,7 +30,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createDataPlatformBatchRequestHandler: ()=>createDataPlatformBatchRequestHandler
|
|
32
32
|
});
|
|
33
|
+
const Effect_namespaceObject = require("effect/Effect");
|
|
33
34
|
const index_js_namespaceObject = require("../../data-platform/index.js");
|
|
35
|
+
const options_js_namespaceObject = require("../../data-platform/batch/options.js");
|
|
34
36
|
const protocol_js_namespaceObject = require("../../data-platform/batch/protocol.js");
|
|
35
37
|
const external_batch_js_namespaceObject = require("./batch.js");
|
|
36
38
|
const external_routing_js_namespaceObject = require("./routing.js");
|
|
@@ -122,11 +124,9 @@ function createDataPlatformBatchRequestHandler(options) {
|
|
|
122
124
|
const dataPlatformBatchOptions = options.dataPlatform?.batch;
|
|
123
125
|
const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
|
|
124
126
|
const batchPath = (0, external_batch_js_namespaceObject.normalizeBatchPath)(dataPlatformBatchOptions?.endpoint);
|
|
125
|
-
const batchMaxSize =
|
|
126
|
-
const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
|
|
127
|
+
const { maxBatchSize: batchMaxSize, maxBatchBytes: batchMaxBytes, allowedMethods: batchAllowedMethods } = (0, options_js_namespaceObject.normalizeBatchLimits)(dataPlatformBatchOptions);
|
|
127
128
|
const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
|
|
128
129
|
const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
|
|
129
|
-
const batchAllowedMethods = (0, external_batch_js_namespaceObject.normalizeBatchAllowedMethods)(dataPlatformBatchOptions?.allowedMethods);
|
|
130
130
|
const envelopeHeader = options.dataPlatform?.envelopeHeader || index_js_namespaceObject.DEFAULT_DATA_ENVELOPE_HEADER;
|
|
131
131
|
const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
|
|
132
132
|
const handle = async (request, context)=>{
|
|
@@ -216,25 +216,25 @@ function createDataPlatformBatchRequestHandler(options) {
|
|
|
216
216
|
return (0, protocol_js_namespaceObject.toBatchResponseItem)(itemId, itemResponse, 'HEAD' === itemMethod);
|
|
217
217
|
} catch (error) {
|
|
218
218
|
if (error instanceof external_batch_js_namespaceObject.BatchItemTimeoutError) {
|
|
219
|
-
|
|
219
|
+
Effect_namespaceObject.runSync(Effect_namespaceObject.logError({
|
|
220
220
|
event: 'bff.batch.item.timeout',
|
|
221
221
|
batchId: payload.batchId,
|
|
222
222
|
itemId,
|
|
223
223
|
method: itemMethod,
|
|
224
224
|
path: itemPathname,
|
|
225
225
|
errorName: error.name
|
|
226
|
-
});
|
|
226
|
+
}));
|
|
227
227
|
return (0, external_batch_js_namespaceObject.toBatchItemError)(itemId, 504, 'Batch item request timed out');
|
|
228
228
|
}
|
|
229
229
|
if (error instanceof Response) return (0, protocol_js_namespaceObject.toBatchResponseItem)(itemId, error, 'HEAD' === itemMethod);
|
|
230
|
-
|
|
230
|
+
Effect_namespaceObject.runSync(Effect_namespaceObject.logError({
|
|
231
231
|
event: 'bff.batch.item.failure',
|
|
232
232
|
batchId: payload.batchId,
|
|
233
233
|
itemId,
|
|
234
234
|
method: itemMethod,
|
|
235
235
|
path: itemPathname,
|
|
236
236
|
errorName: error instanceof Error ? error.name : 'UnknownError'
|
|
237
|
-
});
|
|
237
|
+
}));
|
|
238
238
|
return (0, external_batch_js_namespaceObject.toBatchItemError)(itemId, 500, 'Internal Server Error');
|
|
239
239
|
} finally{
|
|
240
240
|
request.signal.removeEventListener('abort', abortFromBatchRequest);
|
|
@@ -32,13 +32,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
createBatchValidationResponse: ()=>createBatchValidationResponse,
|
|
33
33
|
isBatchRequestPayload: ()=>isBatchRequestPayload,
|
|
34
34
|
mapWithConcurrency: ()=>mapWithConcurrency,
|
|
35
|
-
normalizeBatchAllowedMethods: ()=>normalizeBatchAllowedMethods,
|
|
36
35
|
normalizeBatchPath: ()=>normalizeBatchPath,
|
|
37
36
|
prepareJsonRequestBody: ()=>prepareJsonRequestBody,
|
|
38
37
|
promiseWithTimeout: ()=>promiseWithTimeout,
|
|
39
38
|
toBatchItemError: ()=>toBatchItemError,
|
|
40
39
|
toHeaderRecord: ()=>external_headers_js_namespaceObject.toHeaderRecord
|
|
41
40
|
});
|
|
41
|
+
const Data_namespaceObject = require("effect/Data");
|
|
42
42
|
const index_js_namespaceObject = require("../../data-platform/index.js");
|
|
43
43
|
const protocol_js_namespaceObject = require("../../data-platform/batch/protocol.js");
|
|
44
44
|
const external_headers_js_namespaceObject = require("../../headers.js");
|
|
@@ -47,12 +47,6 @@ function normalizeBatchPath(pathname) {
|
|
|
47
47
|
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
48
48
|
return pathname;
|
|
49
49
|
}
|
|
50
|
-
function normalizeBatchAllowedMethods(allowedMethods) {
|
|
51
|
-
const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
|
|
52
|
-
'GET'
|
|
53
|
-
];
|
|
54
|
-
return new Set(source.map((method)=>method.toUpperCase()));
|
|
55
|
-
}
|
|
56
50
|
function isBatchRequestPayload(value) {
|
|
57
51
|
return (0, index_js_namespaceObject.isPlainObject)(value) && 2 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
|
|
58
52
|
}
|
|
@@ -106,7 +100,13 @@ function toBatchItemError(id, status, message) {
|
|
|
106
100
|
}))
|
|
107
101
|
};
|
|
108
102
|
}
|
|
109
|
-
class BatchItemTimeoutError extends
|
|
103
|
+
class BatchItemTimeoutError extends Data_namespaceObject.TaggedError('BatchItemTimeoutError') {
|
|
104
|
+
constructor(message){
|
|
105
|
+
super({
|
|
106
|
+
message
|
|
107
|
+
});
|
|
108
|
+
this.name = 'Error';
|
|
109
|
+
}
|
|
110
110
|
}
|
|
111
111
|
function promiseWithTimeout(effect, timeoutMs, onTimeout) {
|
|
112
112
|
if (timeoutMs <= 0) return effect;
|
|
@@ -147,7 +147,6 @@ exports.BatchItemTimeoutError = __webpack_exports__.BatchItemTimeoutError;
|
|
|
147
147
|
exports.createBatchValidationResponse = __webpack_exports__.createBatchValidationResponse;
|
|
148
148
|
exports.isBatchRequestPayload = __webpack_exports__.isBatchRequestPayload;
|
|
149
149
|
exports.mapWithConcurrency = __webpack_exports__.mapWithConcurrency;
|
|
150
|
-
exports.normalizeBatchAllowedMethods = __webpack_exports__.normalizeBatchAllowedMethods;
|
|
151
150
|
exports.normalizeBatchPath = __webpack_exports__.normalizeBatchPath;
|
|
152
151
|
exports.prepareJsonRequestBody = __webpack_exports__.prepareJsonRequestBody;
|
|
153
152
|
exports.promiseWithTimeout = __webpack_exports__.promiseWithTimeout;
|
|
@@ -158,7 +157,6 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
158
157
|
"createBatchValidationResponse",
|
|
159
158
|
"isBatchRequestPayload",
|
|
160
159
|
"mapWithConcurrency",
|
|
161
|
-
"normalizeBatchAllowedMethods",
|
|
162
160
|
"normalizeBatchPath",
|
|
163
161
|
"prepareJsonRequestBody",
|
|
164
162
|
"promiseWithTimeout",
|
|
@@ -53,30 +53,10 @@ function defineEffectBff(definition) {
|
|
|
53
53
|
validateRequest: options?.validateRequest
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
-
const client = createLoaderMaterializedClientPlaceholder();
|
|
57
56
|
return {
|
|
58
57
|
...definition,
|
|
59
|
-
createHandler
|
|
60
|
-
client
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const LOADER_CLIENT_IGNORED_KEYS = new Set([
|
|
64
|
-
'then',
|
|
65
|
-
'catch',
|
|
66
|
-
'finally',
|
|
67
|
-
'toJSON',
|
|
68
|
-
'$$typeof'
|
|
69
|
-
]);
|
|
70
|
-
function createLoaderMaterializedClientPlaceholder() {
|
|
71
|
-
const explain = (property)=>{
|
|
72
|
-
throw new Error(`[BFF][Effect] client.${String(property)} is not available here: the typed client only exists when the API entry is imported through the "@api/index" transformed path (the BFF loader replaces it with generated client code). On the server, use HttpApiClient or call the Effect layer directly.`);
|
|
58
|
+
createHandler
|
|
73
59
|
};
|
|
74
|
-
return new Proxy(Object.create(null), {
|
|
75
|
-
get (_target, property) {
|
|
76
|
-
if ('symbol' == typeof property || LOADER_CLIENT_IGNORED_KEYS.has(property)) return;
|
|
77
|
-
return explain(property);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
60
|
}
|
|
81
61
|
function defineEffectRpcBff(definition) {
|
|
82
62
|
const createHandler = (options)=>(0, external_rpc_js_namespaceObject.createRpcApiHandler)({
|
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;
|
|
@@ -43,7 +43,7 @@ function shareDispose(dispose) {
|
|
|
43
43
|
return disposePromise;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function rejectUnsupportedEffectModuleShape(options, shape) {
|
|
47
47
|
options.onWarning?.(`${external_entry_shape_js_namespaceObject.strictEffectApproachMessage} Rejected ${shape}.`);
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
@@ -71,8 +71,12 @@ function classifyEffectBffRuntimeEntryShape(module) {
|
|
|
71
71
|
}
|
|
72
72
|
function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
73
73
|
if (!facts) return null;
|
|
74
|
-
if (facts.
|
|
75
|
-
if (
|
|
74
|
+
if (facts.unsupportedShape) {
|
|
75
|
+
if (rejectUnsupportedEffectModuleShape(options, facts.unsupportedShape)) return null;
|
|
76
|
+
}
|
|
77
|
+
if (void 0 !== facts.module.rpc && !facts.createHandlerValidatorAware) {
|
|
78
|
+
rejectUnsupportedEffectModuleShape(options, 'unbranded RPC runtime');
|
|
79
|
+
return null;
|
|
76
80
|
}
|
|
77
81
|
if ('function' == typeof facts.createHandler) {
|
|
78
82
|
if (facts.createHandlerValidatorAware) {
|
|
@@ -85,7 +89,7 @@ function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
|
85
89
|
return createLoadedHandler(webHandler);
|
|
86
90
|
}
|
|
87
91
|
if (void 0 === facts.api || !facts.hasRuntimeLayer) {
|
|
88
|
-
|
|
92
|
+
rejectUnsupportedEffectModuleShape(options, 'unbranded `createHandler` export');
|
|
89
93
|
return null;
|
|
90
94
|
}
|
|
91
95
|
options.onWarning?.(`${external_entry_shape_js_namespaceObject.strictEffectApproachMessage} Ignored unbranded \`createHandler\` export and rebuilt the handler from its { api, layer } exports.`);
|
|
@@ -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
|
-
const
|
|
35
|
-
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
33
|
+
const request_context_namespaceObject = require("@modern-js/runtime-extensions/request-context");
|
|
36
34
|
const readHeader = (headers, header)=>{
|
|
37
35
|
const value = headers.get(header);
|
|
38
36
|
return value && value.length > 0 ? value : void 0;
|
|
@@ -42,7 +40,7 @@ const copyStringField = (target, details, key)=>{
|
|
|
42
40
|
if ('string' == typeof value && value.length > 0) target[key] = value;
|
|
43
41
|
};
|
|
44
42
|
const readOperationContextDetails = (request)=>{
|
|
45
|
-
const rawDetails = readHeader(request.headers,
|
|
43
|
+
const rawDetails = readHeader(request.headers, request_context_namespaceObject.BFF_OPERATION_CONTEXT_DETAIL_HEADER);
|
|
46
44
|
if (!rawDetails) return {};
|
|
47
45
|
try {
|
|
48
46
|
const parsed = JSON.parse(rawDetails);
|
|
@@ -70,16 +68,16 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
70
68
|
delete operationDetails.traceId;
|
|
71
69
|
delete operationDetails.spanId;
|
|
72
70
|
const servicePath = new URL(request.url).pathname;
|
|
73
|
-
const headerTraceparent = readHeader(request.headers,
|
|
74
|
-
const headerTraceContext = (0,
|
|
75
|
-
const detailTraceContext = (0,
|
|
71
|
+
const headerTraceparent = readHeader(request.headers, request_context_namespaceObject.BFF_TRACEPARENT_HEADER);
|
|
72
|
+
const headerTraceContext = (0, request_context_namespaceObject.parseTraceparent)(headerTraceparent);
|
|
73
|
+
const detailTraceContext = (0, request_context_namespaceObject.parseTraceparent)(details.traceparent);
|
|
76
74
|
const traceparent = headerTraceContext ? headerTraceparent : detailTraceContext ? details.traceparent : void 0;
|
|
77
75
|
const parsedTraceparent = headerTraceContext || detailTraceContext || (details.traceId && details.spanId ? {
|
|
78
76
|
traceId: details.traceId,
|
|
79
77
|
spanId: details.spanId
|
|
80
78
|
} : void 0);
|
|
81
|
-
const locale = readHeader(request.headers,
|
|
82
|
-
const headerOperationId = readHeader(request.headers,
|
|
79
|
+
const locale = readHeader(request.headers, request_context_namespaceObject.BFF_LOCALE_HEADER);
|
|
80
|
+
const headerOperationId = readHeader(request.headers, request_context_namespaceObject.BFF_OPERATION_CONTEXT_HEADER);
|
|
83
81
|
return {
|
|
84
82
|
...operationDetails,
|
|
85
83
|
...headerOperationId || details.operationId ? {
|
|
@@ -87,7 +85,7 @@ const createEffectOperationContext = ({ request, path, method })=>{
|
|
|
87
85
|
} : {},
|
|
88
86
|
routePath: servicePath,
|
|
89
87
|
method: (method || request.method || 'GET').toUpperCase(),
|
|
90
|
-
source: 'effect-
|
|
88
|
+
source: 'effect-server',
|
|
91
89
|
...path && path !== servicePath ? {
|
|
92
90
|
attributes: {
|
|
93
91
|
mountedPath: path
|
|
@@ -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
|
|
@@ -39,8 +39,6 @@ function getRpcSerializationLayer(serialization) {
|
|
|
39
39
|
return rpc_namespaceObject.RpcSerialization.layerJsonRpc();
|
|
40
40
|
case 'ndJsonRpc':
|
|
41
41
|
return rpc_namespaceObject.RpcSerialization.layerNdJsonRpc();
|
|
42
|
-
case 'msgPack':
|
|
43
|
-
return rpc_namespaceObject.RpcSerialization.layerMsgPack;
|
|
44
42
|
default:
|
|
45
43
|
return rpc_namespaceObject.RpcSerialization.layerJsonRpc();
|
|
46
44
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
withCrossProjectPolicy: ()=>withCrossProjectPolicy
|
|
32
|
+
});
|
|
33
|
+
const bff_policy_namespaceObject = require("@modern-js/server-runtime-extensions/bff-policy");
|
|
34
|
+
const Effect_namespaceObject = require("effect/Effect");
|
|
35
|
+
const Schema_namespaceObject = require("effect/Schema");
|
|
36
|
+
const http_namespaceObject = require("effect/unstable/http");
|
|
37
|
+
const httpapi_namespaceObject = require("effect/unstable/httpapi");
|
|
38
|
+
const encodeJson = Schema_namespaceObject.encodeSync(Schema_namespaceObject.fromJsonString(Schema_namespaceObject.Unknown));
|
|
39
|
+
function withCrossProjectPolicy(api, options, client) {
|
|
40
|
+
const contracts = {};
|
|
41
|
+
const prefix = options.prefix.replace(/\/$/, '');
|
|
42
|
+
httpapi_namespaceObject.HttpApi.reflect(api, {
|
|
43
|
+
onGroup: ()=>{},
|
|
44
|
+
onEndpoint: ({ endpoint })=>{
|
|
45
|
+
const routePath = `${prefix}${'/' === endpoint.path ? '' : endpoint.path}` || '/';
|
|
46
|
+
const name = endpoint.identifier;
|
|
47
|
+
contracts[`${endpoint.method}:${routePath}`] = {
|
|
48
|
+
operationId: `${options.requestId}:${name}`,
|
|
49
|
+
name,
|
|
50
|
+
method: endpoint.method,
|
|
51
|
+
routePath
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return client.pipe(http_namespaceObject.HttpClient.mapRequestEffect((request)=>{
|
|
56
|
+
const observed = (0, bff_policy_namespaceObject.resolveCrossProjectRequestObservation)({
|
|
57
|
+
method: request.method,
|
|
58
|
+
pathname: new URL(request.url, 'http://effect.invalid').pathname
|
|
59
|
+
}, {
|
|
60
|
+
expectedOperationContracts: contracts
|
|
61
|
+
});
|
|
62
|
+
const contract = observed && contracts[`${observed.method}:${observed.routePath}`];
|
|
63
|
+
if (void 0 === contract) return Effect_namespaceObject.die(new Error('[BFF][Effect] Request has no matching shared operation contract.'));
|
|
64
|
+
return Effect_namespaceObject.gen(function*() {
|
|
65
|
+
const schemaHash = yield* Effect_namespaceObject.promise(()=>(0, bff_policy_namespaceObject.digestOperationContract)({
|
|
66
|
+
httpMethod: contract.method,
|
|
67
|
+
name: contract.name,
|
|
68
|
+
routePath: contract.routePath
|
|
69
|
+
}, options.requestId));
|
|
70
|
+
return request.pipe(http_namespaceObject.HttpClientRequest.setHeader(bff_policy_namespaceObject.BFF_ENVELOPE_HEADER, encodeJson({
|
|
71
|
+
requestId: options.requestId
|
|
72
|
+
})), http_namespaceObject.HttpClientRequest.setHeader(bff_policy_namespaceObject.BFF_OPERATION_CONTEXT_HEADER, contract.operationId), http_namespaceObject.HttpClientRequest.setHeader(bff_policy_namespaceObject.BFF_OPERATION_CONTEXT_DETAIL_HEADER, encodeJson({
|
|
73
|
+
requestId: options.requestId,
|
|
74
|
+
operationId: contract.operationId,
|
|
75
|
+
method: contract.method,
|
|
76
|
+
routePath: contract.routePath,
|
|
77
|
+
schemaHash,
|
|
78
|
+
operationVersion: options.operationVersion
|
|
79
|
+
})));
|
|
80
|
+
});
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
exports.withCrossProjectPolicy = __webpack_exports__.withCrossProjectPolicy;
|
|
84
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
|
+
"withCrossProjectPolicy"
|
|
86
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
87
|
+
Object.defineProperty(exports, '__esModule', {
|
|
88
|
+
value: true
|
|
89
|
+
});
|
|
@@ -50,7 +50,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
50
50
|
runEffectView: ()=>runEffectView,
|
|
51
51
|
view: ()=>view
|
|
52
52
|
});
|
|
53
|
-
const
|
|
53
|
+
const request_context_namespaceObject = require("@modern-js/runtime-extensions/request-context");
|
|
54
54
|
const Data_namespaceObject = require("effect/Data");
|
|
55
55
|
const Effect_namespaceObject = require("effect/Effect");
|
|
56
56
|
const Exit_namespaceObject = require("effect/Exit");
|
|
@@ -61,6 +61,7 @@ const http_namespaceObject = require("effect/unstable/http");
|
|
|
61
61
|
const httpapi_namespaceObject = require("effect/unstable/httpapi");
|
|
62
62
|
const rpc_namespaceObject = require("effect/unstable/rpc");
|
|
63
63
|
const rpcSerialization_js_namespaceObject = require("../effect/rpcSerialization.js");
|
|
64
|
+
const external_cross_project_js_namespaceObject = require("./cross-project.js");
|
|
64
65
|
const Schema_namespaceObject = require("effect/Schema");
|
|
65
66
|
const HttpClientError_namespaceObject = require("effect/unstable/http/HttpClientError");
|
|
66
67
|
class EffectRpcClientError extends Data_namespaceObject.TaggedError('EffectRpcClientError') {
|
|
@@ -91,14 +92,15 @@ function runEffectView(request, selection) {
|
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
function makeEffectHttpApiClient(api, options) {
|
|
94
|
-
const requestContextHeaders = (0,
|
|
95
|
+
const requestContextHeaders = (0, request_context_namespaceObject.createRequestContextHeaders)(options?.requestContext);
|
|
95
96
|
const transformClient = (client)=>{
|
|
96
97
|
const contextClient = 0 === Object.keys(requestContextHeaders).length ? client : client.pipe(http_namespaceObject.HttpClient.mapRequest((request)=>{
|
|
97
98
|
let nextRequest = request;
|
|
98
99
|
for (const [header, value] of Object.entries(requestContextHeaders))if (void 0 === nextRequest.headers[header.toLowerCase()]) nextRequest = http_namespaceObject.HttpClientRequest.setHeader(nextRequest, header, value);
|
|
99
100
|
return nextRequest;
|
|
100
101
|
}));
|
|
101
|
-
|
|
102
|
+
const policyClient = options?.crossProject !== void 0 ? (0, external_cross_project_js_namespaceObject.withCrossProjectPolicy)(api, options.crossProject, contextClient) : contextClient;
|
|
103
|
+
return 'function' == typeof options?.transformClient ? options.transformClient(policyClient) : policyClient;
|
|
102
104
|
};
|
|
103
105
|
return httpapi_namespaceObject.HttpApiClient.make(api, {
|
|
104
106
|
baseUrl: options?.baseUrl,
|