@bleedingdev/modern-js-bff-effect 3.8.3-ultramodern.2
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/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/cjs/data-platform/batch/protocol.js +130 -0
- package/dist/cjs/data-platform/batch/queue.js +623 -0
- package/dist/cjs/data-platform/batch/request.js +121 -0
- package/dist/cjs/data-platform/batch/response.js +65 -0
- package/dist/cjs/data-platform/batch/telemetry.js +71 -0
- package/dist/cjs/data-platform/batch/url.js +69 -0
- package/dist/cjs/data-platform/batch-transport.js +59 -0
- package/dist/cjs/data-platform/codec.js +155 -0
- package/dist/cjs/data-platform/index.js +124 -0
- package/dist/cjs/data-platform/invalidation.js +61 -0
- package/dist/cjs/data-platform/trace.js +73 -0
- package/dist/cjs/data-platform/types.js +48 -0
- package/dist/cjs/data-platform/validation.js +178 -0
- package/dist/cjs/effect/context.js +59 -0
- package/dist/cjs/effect/dispatch.js +101 -0
- package/dist/cjs/effect/edge-context.js +61 -0
- package/dist/cjs/effect/edge-dispatcher.js +354 -0
- package/dist/cjs/effect/edge.js +62 -0
- package/dist/cjs/effect/endpoint-contracts.js +121 -0
- package/dist/cjs/effect/entry-shape-registry.js +31 -0
- package/dist/cjs/effect/entry-shape.js +113 -0
- package/dist/cjs/effect/handler/batch-handler.js +270 -0
- package/dist/cjs/effect/handler/batch.js +170 -0
- package/dist/cjs/effect/handler/definition.js +99 -0
- package/dist/cjs/effect/handler/envelope.js +104 -0
- package/dist/cjs/effect/handler/http.js +107 -0
- package/dist/cjs/effect/handler/openapi.js +58 -0
- package/dist/cjs/effect/handler/routing.js +100 -0
- package/dist/cjs/effect/handler/rpc.js +63 -0
- package/dist/cjs/effect/handler/types.js +43 -0
- package/dist/cjs/effect/handler.js +173 -0
- package/dist/cjs/effect/index.js +137 -0
- package/dist/cjs/effect/module.js +118 -0
- package/dist/cjs/effect/operation-context.js +116 -0
- package/dist/cjs/effect/rpcSerialization.js +54 -0
- package/dist/cjs/effect-client/batch.js +73 -0
- package/dist/cjs/effect-client/envelope.js +145 -0
- package/dist/cjs/effect-client/guards.js +44 -0
- package/dist/cjs/effect-client/index.js +208 -0
- package/dist/cjs/effect-client/request-context.js +64 -0
- package/dist/cjs/effect-client/request.js +66 -0
- package/dist/cjs/effect-client/runtime.js +100 -0
- package/dist/cjs/effect-client/types.js +18 -0
- package/dist/cjs/headers.js +46 -0
- package/dist/cjs/index.js +83 -0
- package/dist/esm/data-platform/batch/protocol.mjs +71 -0
- package/dist/esm/data-platform/batch/queue.mjs +582 -0
- package/dist/esm/data-platform/batch/request.mjs +68 -0
- package/dist/esm/data-platform/batch/response.mjs +24 -0
- package/dist/esm/data-platform/batch/telemetry.mjs +27 -0
- package/dist/esm/data-platform/batch/url.mjs +25 -0
- package/dist/esm/data-platform/batch-transport.mjs +12 -0
- package/dist/esm/data-platform/codec.mjs +90 -0
- package/dist/esm/data-platform/index.mjs +7 -0
- package/dist/esm/data-platform/invalidation.mjs +20 -0
- package/dist/esm/data-platform/trace.mjs +29 -0
- package/dist/esm/data-platform/types.mjs +4 -0
- package/dist/esm/data-platform/validation.mjs +128 -0
- package/dist/esm/effect/context.mjs +12 -0
- package/dist/esm/effect/dispatch.mjs +63 -0
- package/dist/esm/effect/edge-context.mjs +14 -0
- package/dist/esm/effect/edge-dispatcher.mjs +115 -0
- package/dist/esm/effect/edge.mjs +1 -0
- package/dist/esm/effect/endpoint-contracts.mjs +68 -0
- package/dist/esm/effect/entry-shape-registry.mjs +17 -0
- package/dist/esm/effect/entry-shape.mjs +51 -0
- package/dist/esm/effect/handler/batch-handler.mjs +232 -0
- package/dist/esm/effect/handler/batch.mjs +105 -0
- package/dist/esm/effect/handler/definition.mjs +58 -0
- package/dist/esm/effect/handler/envelope.mjs +63 -0
- package/dist/esm/effect/handler/http.mjs +69 -0
- package/dist/esm/effect/handler/openapi.mjs +20 -0
- package/dist/esm/effect/handler/routing.mjs +50 -0
- package/dist/esm/effect/handler/rpc.mjs +22 -0
- package/dist/esm/effect/handler/types.mjs +5 -0
- package/dist/esm/effect/handler.mjs +13 -0
- package/dist/esm/effect/index.mjs +7 -0
- package/dist/esm/effect/module.mjs +80 -0
- package/dist/esm/effect/operation-context.mjs +75 -0
- package/dist/esm/effect/rpcSerialization.mjs +16 -0
- package/dist/esm/effect-client/batch.mjs +35 -0
- package/dist/esm/effect-client/envelope.mjs +104 -0
- package/dist/esm/effect-client/guards.mjs +3 -0
- package/dist/esm/effect-client/index.mjs +110 -0
- package/dist/esm/effect-client/request-context.mjs +23 -0
- package/dist/esm/effect-client/request.mjs +28 -0
- package/dist/esm/effect-client/runtime.mjs +62 -0
- package/dist/esm/effect-client/types.mjs +0 -0
- package/dist/esm/headers.mjs +8 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm-node/data-platform/batch/protocol.mjs +72 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +583 -0
- package/dist/esm-node/data-platform/batch/request.mjs +69 -0
- package/dist/esm-node/data-platform/batch/response.mjs +25 -0
- package/dist/esm-node/data-platform/batch/telemetry.mjs +28 -0
- package/dist/esm-node/data-platform/batch/url.mjs +26 -0
- package/dist/esm-node/data-platform/batch-transport.mjs +13 -0
- package/dist/esm-node/data-platform/codec.mjs +91 -0
- package/dist/esm-node/data-platform/index.mjs +8 -0
- package/dist/esm-node/data-platform/invalidation.mjs +21 -0
- package/dist/esm-node/data-platform/trace.mjs +30 -0
- package/dist/esm-node/data-platform/types.mjs +5 -0
- package/dist/esm-node/data-platform/validation.mjs +129 -0
- package/dist/esm-node/effect/context.mjs +13 -0
- package/dist/esm-node/effect/dispatch.mjs +64 -0
- package/dist/esm-node/effect/edge-context.mjs +15 -0
- package/dist/esm-node/effect/edge-dispatcher.mjs +116 -0
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/endpoint-contracts.mjs +69 -0
- package/dist/esm-node/effect/entry-shape-registry.mjs +18 -0
- package/dist/esm-node/effect/entry-shape.mjs +63 -0
- package/dist/esm-node/effect/handler/batch-handler.mjs +233 -0
- package/dist/esm-node/effect/handler/batch.mjs +106 -0
- package/dist/esm-node/effect/handler/definition.mjs +59 -0
- package/dist/esm-node/effect/handler/envelope.mjs +64 -0
- package/dist/esm-node/effect/handler/http.mjs +70 -0
- package/dist/esm-node/effect/handler/openapi.mjs +21 -0
- package/dist/esm-node/effect/handler/routing.mjs +51 -0
- package/dist/esm-node/effect/handler/rpc.mjs +23 -0
- package/dist/esm-node/effect/handler/types.mjs +6 -0
- package/dist/esm-node/effect/handler.mjs +14 -0
- package/dist/esm-node/effect/index.mjs +8 -0
- package/dist/esm-node/effect/module.mjs +81 -0
- package/dist/esm-node/effect/operation-context.mjs +76 -0
- package/dist/esm-node/effect/rpcSerialization.mjs +17 -0
- package/dist/esm-node/effect-client/batch.mjs +36 -0
- package/dist/esm-node/effect-client/envelope.mjs +105 -0
- package/dist/esm-node/effect-client/guards.mjs +4 -0
- package/dist/esm-node/effect-client/index.mjs +111 -0
- package/dist/esm-node/effect-client/request-context.mjs +24 -0
- package/dist/esm-node/effect-client/request.mjs +29 -0
- package/dist/esm-node/effect-client/runtime.mjs +63 -0
- package/dist/esm-node/effect-client/types.mjs +1 -0
- package/dist/esm-node/headers.mjs +9 -0
- package/dist/esm-node/index.mjs +5 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/types/data-platform/batch/protocol.d.ts +9 -0
- package/dist/types/data-platform/batch/queue.d.ts +47 -0
- package/dist/types/data-platform/batch/request.d.ts +19 -0
- package/dist/types/data-platform/batch/response.d.ts +3 -0
- package/dist/types/data-platform/batch/telemetry.d.ts +4 -0
- package/dist/types/data-platform/batch/url.d.ts +4 -0
- package/dist/types/data-platform/batch-transport.d.ts +3 -0
- package/dist/types/data-platform/codec.d.ts +17 -0
- package/dist/types/data-platform/index.d.ts +8 -0
- package/dist/types/data-platform/invalidation.d.ts +8 -0
- package/dist/types/data-platform/trace.d.ts +4 -0
- package/dist/types/data-platform/types.d.ts +151 -0
- package/dist/types/data-platform/validation.d.ts +29 -0
- package/dist/types/effect/context.d.ts +5 -0
- package/dist/types/effect/dispatch.d.ts +13 -0
- package/dist/types/effect/edge-context.d.ts +5 -0
- package/dist/types/effect/edge-dispatcher.d.ts +37 -0
- package/dist/types/effect/edge.d.ts +1 -0
- package/dist/types/effect/endpoint-contracts.d.ts +67 -0
- package/dist/types/effect/entry-shape.d.ts +32 -0
- package/dist/types/effect/handler/batch-handler.d.ts +11 -0
- package/dist/types/effect/handler/batch.d.ts +15 -0
- package/dist/types/effect/handler/definition.d.ts +7 -0
- package/dist/types/effect/handler/envelope.d.ts +13 -0
- package/dist/types/effect/handler/http.d.ts +15 -0
- package/dist/types/effect/handler/openapi.d.ts +4 -0
- package/dist/types/effect/handler/routing.d.ts +5 -0
- package/dist/types/effect/handler/rpc.d.ts +7 -0
- package/dist/types/effect/handler/types.d.ts +153 -0
- package/dist/types/effect/handler.d.ts +13 -0
- package/dist/types/effect/index.d.ts +6 -0
- package/dist/types/effect/module.d.ts +36 -0
- package/dist/types/effect/operation-context.d.ts +15 -0
- package/dist/types/effect/rpcSerialization.d.ts +3 -0
- package/dist/types/effect-client/batch.d.ts +2 -0
- package/dist/types/effect-client/envelope.d.ts +15 -0
- package/dist/types/effect-client/guards.d.ts +2 -0
- package/dist/types/effect-client/index.d.ts +58 -0
- package/dist/types/effect-client/request-context.d.ts +3 -0
- package/dist/types/effect-client/request.d.ts +1 -0
- package/dist/types/effect-client/runtime.d.ts +5 -0
- package/dist/types/effect-client/types.d.ts +68 -0
- package/dist/types/headers.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +164 -0
- package/src/data-platform/batch/protocol.ts +112 -0
- package/src/data-platform/batch/queue.ts +876 -0
- package/src/data-platform/batch/request.ts +130 -0
- package/src/data-platform/batch/response.ts +74 -0
- package/src/data-platform/batch/telemetry.ts +47 -0
- package/src/data-platform/batch/url.ts +54 -0
- package/src/data-platform/batch-transport.ts +22 -0
- package/src/data-platform/codec.ts +145 -0
- package/src/data-platform/index.ts +63 -0
- package/src/data-platform/invalidation.ts +57 -0
- package/src/data-platform/trace.ts +49 -0
- package/src/data-platform/types.ts +186 -0
- package/src/data-platform/validation.ts +303 -0
- package/src/effect/context.ts +37 -0
- package/src/effect/dispatch.ts +132 -0
- package/src/effect/edge-context.ts +51 -0
- package/src/effect/edge-dispatcher.ts +310 -0
- package/src/effect/edge.ts +1 -0
- package/src/effect/endpoint-contracts.ts +191 -0
- package/src/effect/entry-shape-registry.cjs +16 -0
- package/src/effect/entry-shape-registry.d.cts +6 -0
- package/src/effect/entry-shape.ts +155 -0
- package/src/effect/handler/batch-handler.ts +475 -0
- package/src/effect/handler/batch.ts +182 -0
- package/src/effect/handler/definition.ts +121 -0
- package/src/effect/handler/envelope.ts +133 -0
- package/src/effect/handler/http.ts +133 -0
- package/src/effect/handler/openapi.ts +45 -0
- package/src/effect/handler/routing.ts +91 -0
- package/src/effect/handler/rpc.ts +45 -0
- package/src/effect/handler/types.ts +255 -0
- package/src/effect/handler.ts +33 -0
- package/src/effect/index.ts +22 -0
- package/src/effect/module.ts +186 -0
- package/src/effect/operation-context.ts +144 -0
- package/src/effect/rpcSerialization.ts +20 -0
- package/src/effect-client/batch.ts +50 -0
- package/src/effect-client/envelope.ts +238 -0
- package/src/effect-client/guards.ts +6 -0
- package/src/effect-client/index.ts +325 -0
- package/src/effect-client/request-context.ts +54 -0
- package/src/effect-client/request.ts +51 -0
- package/src/effect-client/runtime.ts +122 -0
- package/src/effect-client/types.ts +84 -0
- package/src/headers.ts +7 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
2
|
+
import { RpcServer } from "effect/unstable/rpc";
|
|
3
|
+
import { getRpcSerializationLayer } from "../rpcSerialization.mjs";
|
|
4
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
|
+
function normalizeRpcPath(pathname) {
|
|
6
|
+
if (!pathname || '/' === pathname) return '/rpc';
|
|
7
|
+
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
8
|
+
return pathname;
|
|
9
|
+
}
|
|
10
|
+
function createRpcApiHandler(options) {
|
|
11
|
+
const rpcPath = normalizeRpcPath(options.path);
|
|
12
|
+
const rpcLayer = __rspack_external_effect_Layer_69c46453.provide(RpcServer.layerHttp({
|
|
13
|
+
group: options.group,
|
|
14
|
+
path: rpcPath,
|
|
15
|
+
protocol: 'http',
|
|
16
|
+
disableTracing: options.disableTracing,
|
|
17
|
+
spanPrefix: options.spanPrefix,
|
|
18
|
+
spanAttributes: options.spanAttributes
|
|
19
|
+
}), __rspack_external_effect_Layer_69c46453.mergeAll(options.layer, getRpcSerializationLayer(options.serialization)));
|
|
20
|
+
return HttpRouter.toWebHandler(rpcLayer);
|
|
21
|
+
}
|
|
22
|
+
export { createRpcApiHandler, normalizeRpcPath };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as __rspack_external_effect_Context_b3520bd3 from "effect/Context";
|
|
2
|
+
const emptyEffectServiceContext = __rspack_external_effect_Context_b3520bd3.empty();
|
|
3
|
+
const isEffectServiceContext = (context)=>'object' == typeof context && null !== context && 'mapUnsafe' in context;
|
|
4
|
+
const toEffectServiceContext = (context)=>isEffectServiceContext(context) ? context : emptyEffectServiceContext;
|
|
5
|
+
export { toEffectServiceContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
|
|
2
|
+
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
3
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
4
|
+
import * as __rspack_external_effect_Option_0498e63a from "effect/Option";
|
|
5
|
+
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
6
|
+
export * from "effect/unstable/http";
|
|
7
|
+
export * from "effect/unstable/httpapi";
|
|
8
|
+
export * from "effect/unstable/rpc";
|
|
9
|
+
export { HttpTraceContext } from "effect/unstable/http";
|
|
10
|
+
export { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
11
|
+
export { defineEffectBff, defineEffectRpcBff } from "./handler/definition.mjs";
|
|
12
|
+
export { createHttpApiHandler } from "./handler/http.mjs";
|
|
13
|
+
export { __rspack_external_effect_Config_76cfa59d as Config, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Option_0498e63a as Option, __rspack_external_effect_Schema_6065f72d as Schema };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as __rspack_external__effect_opentelemetry_66324c75 from "@effect/opentelemetry";
|
|
2
|
+
export * from "./endpoint-contracts.mjs";
|
|
3
|
+
export * from "./handler.mjs";
|
|
4
|
+
export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "./context.mjs";
|
|
5
|
+
export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest } from "./edge.mjs";
|
|
6
|
+
export { resolveEffectBffModuleHandler } from "./module.mjs";
|
|
7
|
+
export { __rspack_external__effect_opentelemetry_66324c75 as OpenTelemetry };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { HttpApi } from "effect/unstable/httpapi";
|
|
2
|
+
import { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, strictEffectApproachMessage } from "./entry-shape.mjs";
|
|
3
|
+
import { createHttpApiHandler } from "./handler.mjs";
|
|
4
|
+
function isRequestHandler(value) {
|
|
5
|
+
return 'function' == typeof value;
|
|
6
|
+
}
|
|
7
|
+
function shareDispose(dispose) {
|
|
8
|
+
let disposePromise;
|
|
9
|
+
return ()=>{
|
|
10
|
+
disposePromise ??= Promise.resolve().then(dispose);
|
|
11
|
+
return disposePromise;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function rejectLegacyEffectModuleShape(options, shape) {
|
|
15
|
+
options.onWarning?.(`${strictEffectApproachMessage} Rejected ${shape}.`);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
function callEffectBffRequestHandler(handler, request, context) {
|
|
19
|
+
return void 0 === context ? handler(request) : handler(request, context);
|
|
20
|
+
}
|
|
21
|
+
function createLoadedHandler(webHandler) {
|
|
22
|
+
return {
|
|
23
|
+
handler: (request, context)=>callEffectBffRequestHandler(webHandler.handler, request, context),
|
|
24
|
+
dispose: shareDispose(webHandler.dispose)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createLoadedHttpApiHandler(webHandler) {
|
|
28
|
+
return createLoadedHandler({
|
|
29
|
+
handler: webHandler.handler,
|
|
30
|
+
dispose: webHandler.dispose
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function classifyEffectBffRuntimeEntryShape(module) {
|
|
34
|
+
return classifyEffectBffEntryModule(module, {
|
|
35
|
+
isRequestHandler: isRequestHandler,
|
|
36
|
+
isValidatorAwareHandlerFactory: isValidatorAwareHandlerFactory,
|
|
37
|
+
isHttpApi: HttpApi.isHttpApi
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
41
|
+
if (!facts) return null;
|
|
42
|
+
if (facts.legacyShape) {
|
|
43
|
+
if (rejectLegacyEffectModuleShape(options, facts.legacyShape)) return null;
|
|
44
|
+
}
|
|
45
|
+
if ('function' == typeof facts.createHandler) {
|
|
46
|
+
if (facts.createHandlerValidatorAware) {
|
|
47
|
+
const factory = facts.createHandler;
|
|
48
|
+
const webHandler = factory({
|
|
49
|
+
openapi: options.openapi,
|
|
50
|
+
dataPlatform: options.dataPlatform,
|
|
51
|
+
validateRequest: options.validateRequest
|
|
52
|
+
});
|
|
53
|
+
return createLoadedHandler(webHandler);
|
|
54
|
+
}
|
|
55
|
+
if (void 0 === facts.api || !facts.hasRuntimeLayer) {
|
|
56
|
+
rejectLegacyEffectModuleShape(options, 'unbranded `createHandler` export');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
options.onWarning?.(`${strictEffectApproachMessage} Ignored unbranded \`createHandler\` export and rebuilt the handler from its { api, layer } exports.`);
|
|
60
|
+
}
|
|
61
|
+
if (void 0 !== facts.api && facts.hasRuntimeLayer) {
|
|
62
|
+
if (void 0 === facts.createHandler) options.onWarning?.('[BFF][Effect] Detected { api, layer } export without createHandler. Prefer `defineEffectBff(...)` from @modern-js/bff-effect/effect to avoid module instance mismatch.');
|
|
63
|
+
const webHandler = createHttpApiHandler({
|
|
64
|
+
api: facts.api,
|
|
65
|
+
layer: facts.layer,
|
|
66
|
+
openapi: options.openapi,
|
|
67
|
+
dataPlatform: options.dataPlatform,
|
|
68
|
+
validateRequest: options.validateRequest
|
|
69
|
+
});
|
|
70
|
+
return createLoadedHttpApiHandler(webHandler);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function resolveNormalizedEffectBffModuleHandler(normalizedModule, options = {}) {
|
|
75
|
+
return resolveClassifiedEffectBffModuleHandler(classifyEffectBffRuntimeEntryShape(normalizedModule), options);
|
|
76
|
+
}
|
|
77
|
+
function resolveEffectBffModuleHandler(mod, options = {}) {
|
|
78
|
+
return Promise.resolve(resolveNormalizedEffectBffModuleHandler(mod, options));
|
|
79
|
+
}
|
|
80
|
+
export { resolveEffectBffModuleHandler };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/create-request";
|
|
2
|
+
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
3
|
+
const readHeader = (headers, header)=>{
|
|
4
|
+
const value = headers.get(header);
|
|
5
|
+
return value && value.length > 0 ? value : void 0;
|
|
6
|
+
};
|
|
7
|
+
const copyStringField = (target, details, key)=>{
|
|
8
|
+
const value = details[key];
|
|
9
|
+
if ('string' == typeof value && value.length > 0) target[key] = value;
|
|
10
|
+
};
|
|
11
|
+
const readOperationContextDetails = (request)=>{
|
|
12
|
+
const rawDetails = readHeader(request.headers, BFF_OPERATION_CONTEXT_DETAIL_HEADER);
|
|
13
|
+
if (!rawDetails) return {};
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(rawDetails);
|
|
16
|
+
if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) return {};
|
|
17
|
+
const details = parsed;
|
|
18
|
+
const safeDetails = {};
|
|
19
|
+
copyStringField(safeDetails, details, 'requestId');
|
|
20
|
+
copyStringField(safeDetails, details, 'operationId');
|
|
21
|
+
copyStringField(safeDetails, details, 'schemaHash');
|
|
22
|
+
copyStringField(safeDetails, details, 'traceparent');
|
|
23
|
+
copyStringField(safeDetails, details, 'traceId');
|
|
24
|
+
copyStringField(safeDetails, details, 'spanId');
|
|
25
|
+
if ('number' == typeof details.operationVersion) safeDetails.operationVersion = details.operationVersion;
|
|
26
|
+
return safeDetails;
|
|
27
|
+
} catch {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const createEffectOperationContext = ({ request, path, method })=>{
|
|
32
|
+
const details = readOperationContextDetails(request);
|
|
33
|
+
const operationDetails = {
|
|
34
|
+
...details
|
|
35
|
+
};
|
|
36
|
+
delete operationDetails.traceparent;
|
|
37
|
+
delete operationDetails.traceId;
|
|
38
|
+
delete operationDetails.spanId;
|
|
39
|
+
const servicePath = new URL(request.url).pathname;
|
|
40
|
+
const headerTraceparent = readHeader(request.headers, BFF_TRACEPARENT_HEADER);
|
|
41
|
+
const headerTraceContext = parseTraceparent(headerTraceparent);
|
|
42
|
+
const detailTraceContext = parseTraceparent(details.traceparent);
|
|
43
|
+
const traceparent = headerTraceContext ? headerTraceparent : detailTraceContext ? details.traceparent : void 0;
|
|
44
|
+
const parsedTraceparent = headerTraceContext || detailTraceContext || (details.traceId && details.spanId ? {
|
|
45
|
+
traceId: details.traceId,
|
|
46
|
+
spanId: details.spanId
|
|
47
|
+
} : void 0);
|
|
48
|
+
const locale = readHeader(request.headers, BFF_LOCALE_HEADER);
|
|
49
|
+
const headerOperationId = readHeader(request.headers, BFF_OPERATION_CONTEXT_HEADER);
|
|
50
|
+
return {
|
|
51
|
+
...operationDetails,
|
|
52
|
+
...headerOperationId || details.operationId ? {
|
|
53
|
+
operationId: headerOperationId || details.operationId
|
|
54
|
+
} : {},
|
|
55
|
+
routePath: servicePath,
|
|
56
|
+
method: (method || request.method || 'GET').toUpperCase(),
|
|
57
|
+
source: 'effect-adapter',
|
|
58
|
+
...path && path !== servicePath ? {
|
|
59
|
+
attributes: {
|
|
60
|
+
mountedPath: path
|
|
61
|
+
}
|
|
62
|
+
} : {},
|
|
63
|
+
...locale ? {
|
|
64
|
+
locale
|
|
65
|
+
} : {},
|
|
66
|
+
...traceparent ? {
|
|
67
|
+
traceparent
|
|
68
|
+
} : {},
|
|
69
|
+
...parsedTraceparent ? {
|
|
70
|
+
traceId: parsedTraceparent.traceId,
|
|
71
|
+
spanId: parsedTraceparent.spanId
|
|
72
|
+
} : {}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export { createEffectOperationContext, kEffectContextStorage };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpcSerialization } from "effect/unstable/rpc";
|
|
2
|
+
function getRpcSerializationLayer(serialization) {
|
|
3
|
+
switch(serialization){
|
|
4
|
+
case 'ndjson':
|
|
5
|
+
return RpcSerialization.layerNdjson;
|
|
6
|
+
case 'jsonRpc':
|
|
7
|
+
return RpcSerialization.layerJsonRpc();
|
|
8
|
+
case 'ndJsonRpc':
|
|
9
|
+
return RpcSerialization.layerNdJsonRpc();
|
|
10
|
+
case 'msgPack':
|
|
11
|
+
return RpcSerialization.layerMsgPack;
|
|
12
|
+
default:
|
|
13
|
+
return RpcSerialization.layerJsonRpc();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export { getRpcSerializationLayer };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createDataBatchTransport } from "../data-platform/index.mjs";
|
|
2
|
+
import { resolveOrigin } from "./envelope.mjs";
|
|
3
|
+
const resolveRuntimeFetch = ()=>'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
|
|
4
|
+
const configureGeneratedEffectClientRuntime = (config, configureRequest)=>{
|
|
5
|
+
const defaultOrigin = config.defaultOrigin;
|
|
6
|
+
if (config.requestId && configureRequest) {
|
|
7
|
+
const configurePayload = {
|
|
8
|
+
requestId: config.requestId,
|
|
9
|
+
requireEnvelope: true,
|
|
10
|
+
identityBinding: {
|
|
11
|
+
enabled: true,
|
|
12
|
+
strict: true
|
|
13
|
+
},
|
|
14
|
+
operationContract: {
|
|
15
|
+
enabled: true,
|
|
16
|
+
strict: true,
|
|
17
|
+
requireSchemaHash: true,
|
|
18
|
+
requireOperationVersion: true
|
|
19
|
+
},
|
|
20
|
+
setDomain: ()=>resolveOrigin(defaultOrigin)
|
|
21
|
+
};
|
|
22
|
+
const runtimeFetch = resolveRuntimeFetch();
|
|
23
|
+
if (false !== config.batch.enabled && runtimeFetch) configurePayload.request = createDataBatchTransport({
|
|
24
|
+
fetch: runtimeFetch,
|
|
25
|
+
endpoint: config.batch.endpoint,
|
|
26
|
+
flushIntervalMs: config.batch.flushIntervalMs,
|
|
27
|
+
maxBatchSize: config.batch.maxBatchSize,
|
|
28
|
+
maxBatchBytes: config.batch.maxBatchBytes,
|
|
29
|
+
requestTimeoutMs: config.batch.requestTimeoutMs,
|
|
30
|
+
allowedMethods: config.batch.allowedMethods
|
|
31
|
+
});
|
|
32
|
+
configureRequest(configurePayload);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export { configureGeneratedEffectClientRuntime };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, createRequestEnvelope, encodeRequestEnvelopeHeader } from "../data-platform/index.mjs";
|
|
2
|
+
import { isRecord, stringOrUndefined } from "./guards.mjs";
|
|
3
|
+
import { normalizeRequest } from "./request.mjs";
|
|
4
|
+
import { applyRequestContext } from "./request-context.mjs";
|
|
5
|
+
const DATA_REQUEST_MODES = new Set([
|
|
6
|
+
'cache-first',
|
|
7
|
+
'stale-while-revalidate',
|
|
8
|
+
'network-only'
|
|
9
|
+
]);
|
|
10
|
+
const DATA_MUTATION_MODES = new Set([
|
|
11
|
+
'optimistic',
|
|
12
|
+
'pessimistic',
|
|
13
|
+
'fire-and-forget'
|
|
14
|
+
]);
|
|
15
|
+
const isDataRequestMode = (value)=>'string' == typeof value && DATA_REQUEST_MODES.has(value);
|
|
16
|
+
const isDataMutationMode = (value)=>'string' == typeof value && DATA_MUTATION_MODES.has(value);
|
|
17
|
+
const normalizeOrigin = (value)=>{
|
|
18
|
+
if ('string' != typeof value || 0 === value.length) return;
|
|
19
|
+
try {
|
|
20
|
+
return new URL(value).origin;
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const resolveOrigin = (defaultOrigin)=>{
|
|
26
|
+
if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
|
|
27
|
+
const globalLocation = globalThis?.location;
|
|
28
|
+
if (globalLocation && 'string' == typeof globalLocation.origin && globalLocation.origin) return globalLocation.origin;
|
|
29
|
+
return defaultOrigin;
|
|
30
|
+
};
|
|
31
|
+
const resolveTargetOrigin = (dataPlatform, defaultOrigin)=>{
|
|
32
|
+
const explicitTargetOrigin = stringOrUndefined(dataPlatform.targetOrigin) || stringOrUndefined(dataPlatform.endpointOrigin);
|
|
33
|
+
if (explicitTargetOrigin) return explicitTargetOrigin;
|
|
34
|
+
return defaultOrigin;
|
|
35
|
+
};
|
|
36
|
+
const shouldAttachEnvelopeHeader = (dataPlatform, defaultOrigin)=>{
|
|
37
|
+
if (true === dataPlatform.allowCrossOriginEnvelope) return true;
|
|
38
|
+
const currentOrigin = normalizeOrigin(resolveOrigin(defaultOrigin));
|
|
39
|
+
const targetOrigin = normalizeOrigin(resolveTargetOrigin(dataPlatform, defaultOrigin));
|
|
40
|
+
if (!currentOrigin || !targetOrigin) return true;
|
|
41
|
+
return currentOrigin === targetOrigin;
|
|
42
|
+
};
|
|
43
|
+
const toEnvelopeInput = (normalizedRequest)=>{
|
|
44
|
+
const payload = {};
|
|
45
|
+
if (isRecord(normalizedRequest.params)) payload.path = normalizedRequest.params;
|
|
46
|
+
if (isRecord(normalizedRequest.query)) payload.query = normalizedRequest.query;
|
|
47
|
+
if ('data' in normalizedRequest && void 0 !== normalizedRequest.data) payload.data = normalizedRequest.data;
|
|
48
|
+
if ('body' in normalizedRequest && void 0 !== normalizedRequest.body) payload.body = normalizedRequest.body;
|
|
49
|
+
if ("u" > typeof FormData && normalizedRequest.formData instanceof FormData) payload.formData = Array.from(normalizedRequest.formData.entries()).map(([key, value])=>[
|
|
50
|
+
key,
|
|
51
|
+
String(value)
|
|
52
|
+
]);
|
|
53
|
+
if ("u" > typeof URLSearchParams && normalizedRequest.formUrlencoded instanceof URLSearchParams) payload.formUrlencoded = normalizedRequest.formUrlencoded.toString();
|
|
54
|
+
return payload;
|
|
55
|
+
};
|
|
56
|
+
const prepareEffectRequest = (options)=>{
|
|
57
|
+
const { endpoint, operation, request, config, createEffectRequestContext } = options;
|
|
58
|
+
const defaultOrigin = config.defaultOrigin;
|
|
59
|
+
const normalizedRequest = applyRequestContext(normalizeRequest(endpoint.method, request), request, createEffectRequestContext);
|
|
60
|
+
const dataPlatform = isRecord(request) && isRecord(request.dataPlatform) ? request.dataPlatform : {};
|
|
61
|
+
const strictEnvelope = true === dataPlatform.requireEnvelope || true === dataPlatform.strict;
|
|
62
|
+
if (!strictEnvelope && !shouldAttachEnvelopeHeader(dataPlatform, defaultOrigin)) return normalizedRequest;
|
|
63
|
+
try {
|
|
64
|
+
const namespace = stringOrUndefined(dataPlatform.appNamespace) || config.appNamespace;
|
|
65
|
+
const origin = stringOrUndefined(dataPlatform.origin) || resolveOrigin(defaultOrigin);
|
|
66
|
+
const envelope = createRequestEnvelope({
|
|
67
|
+
operation: {
|
|
68
|
+
...operation,
|
|
69
|
+
appNamespace: namespace
|
|
70
|
+
},
|
|
71
|
+
scope: {
|
|
72
|
+
appNamespace: namespace,
|
|
73
|
+
origin,
|
|
74
|
+
tenantId: stringOrUndefined(dataPlatform.tenantId),
|
|
75
|
+
userId: stringOrUndefined(dataPlatform.userId),
|
|
76
|
+
sessionId: stringOrUndefined(dataPlatform.sessionId)
|
|
77
|
+
},
|
|
78
|
+
requestInput: {
|
|
79
|
+
method: endpoint.method,
|
|
80
|
+
routePath: endpoint.routePath,
|
|
81
|
+
payload: toEnvelopeInput(normalizedRequest)
|
|
82
|
+
},
|
|
83
|
+
requestMode: isDataRequestMode(dataPlatform.requestMode) ? dataPlatform.requestMode : void 0,
|
|
84
|
+
mutationMode: isDataMutationMode(dataPlatform.mutationMode) ? dataPlatform.mutationMode : void 0,
|
|
85
|
+
selectionPlan: isRecord(dataPlatform.selectionPlan) ? dataPlatform.selectionPlan : void 0,
|
|
86
|
+
traceContext: isRecord(dataPlatform.traceContext) ? dataPlatform.traceContext : void 0,
|
|
87
|
+
requireTraceContext: true === dataPlatform.requireTraceContext
|
|
88
|
+
});
|
|
89
|
+
const headerName = stringOrUndefined(dataPlatform.envelopeHeader) || DEFAULT_DATA_ENVELOPE_HEADER;
|
|
90
|
+
const headers = isRecord(normalizedRequest.headers) ? {
|
|
91
|
+
...normalizedRequest.headers
|
|
92
|
+
} : {};
|
|
93
|
+
if (false === dataPlatform.batch) headers[DEFAULT_DATA_BATCH_HEADER] = 'off';
|
|
94
|
+
headers[headerName] = encodeRequestEnvelopeHeader(envelope);
|
|
95
|
+
return {
|
|
96
|
+
...normalizedRequest,
|
|
97
|
+
headers
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (strictEnvelope) throw error;
|
|
101
|
+
return normalizedRequest;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
export { prepareEffectRequest, resolveOrigin };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createRequestContextHeaders } from "@modern-js/create-request";
|
|
2
|
+
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
3
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
4
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
5
|
+
import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
|
|
6
|
+
import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from "effect/unstable/rpc";
|
|
7
|
+
import { getRpcSerializationLayer } from "../effect/rpcSerialization.mjs";
|
|
8
|
+
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
9
|
+
import * as __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 from "effect/unstable/http/HttpClientError";
|
|
10
|
+
import * as __rspack_external_effect_Data_2b3f4efb from "effect/Data";
|
|
11
|
+
import * as __rspack_external_effect_Exit_1ca64b33 from "effect/Exit";
|
|
12
|
+
import * as __rspack_external_effect_ManagedRuntime_bfe218e3 from "effect/ManagedRuntime";
|
|
13
|
+
import * as __rspack_external_effect_Scope_f87b0bd6 from "effect/Scope";
|
|
14
|
+
class EffectRpcClientError extends __rspack_external_effect_Data_2b3f4efb.TaggedError('EffectRpcClientError') {
|
|
15
|
+
}
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function applySelection(value, selection) {
|
|
20
|
+
if (true === selection || void 0 === selection) return value;
|
|
21
|
+
if (Array.isArray(value)) return value.map((item)=>applySelection(item, selection));
|
|
22
|
+
if (!isRecord(value) || !isRecord(selection)) return value;
|
|
23
|
+
const masked = {};
|
|
24
|
+
for (const key of Object.keys(selection)){
|
|
25
|
+
const selected = selection[key];
|
|
26
|
+
if (void 0 !== selected && key in value && (true === selected || isRecord(selected))) masked[key] = applySelection(value[key], selected);
|
|
27
|
+
}
|
|
28
|
+
return masked;
|
|
29
|
+
}
|
|
30
|
+
function view() {
|
|
31
|
+
return (selection)=>selection;
|
|
32
|
+
}
|
|
33
|
+
function mask(value, selection) {
|
|
34
|
+
return applySelection(value, selection);
|
|
35
|
+
}
|
|
36
|
+
function runEffectView(request, selection) {
|
|
37
|
+
return new Promise((resolve, reject)=>{
|
|
38
|
+
request.then((value)=>resolve(mask(value, selection)), (reason)=>reject(reason));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function makeEffectHttpApiClient(api, options) {
|
|
42
|
+
const requestContextHeaders = createRequestContextHeaders(options?.requestContext);
|
|
43
|
+
const transformClient = (client)=>{
|
|
44
|
+
const contextClient = 0 === Object.keys(requestContextHeaders).length ? client : client.pipe(HttpClient.mapRequest((request)=>{
|
|
45
|
+
let nextRequest = request;
|
|
46
|
+
for (const [header, value] of Object.entries(requestContextHeaders))if (void 0 === nextRequest.headers[header.toLowerCase()]) nextRequest = HttpClientRequest.setHeader(nextRequest, header, value);
|
|
47
|
+
return nextRequest;
|
|
48
|
+
}));
|
|
49
|
+
return 'function' == typeof options?.transformClient ? options.transformClient(contextClient) : contextClient;
|
|
50
|
+
};
|
|
51
|
+
return HttpApiClient.make(api, {
|
|
52
|
+
baseUrl: options?.baseUrl,
|
|
53
|
+
transformClient,
|
|
54
|
+
transformResponse: options?.transformResponse
|
|
55
|
+
}).pipe(__rspack_external_effect_Effect_41060786.provide(FetchHttpClient.layer));
|
|
56
|
+
}
|
|
57
|
+
function makeEffectRpcClient(group, options) {
|
|
58
|
+
const protocolLayer = __rspack_external_effect_Layer_69c46453.provide(RpcClient.layerProtocolHttp({
|
|
59
|
+
url: options.url
|
|
60
|
+
}), __rspack_external_effect_Layer_69c46453.mergeAll(getRpcSerializationLayer(options.serialization), FetchHttpClient.layer));
|
|
61
|
+
const middlewareLayer = options.middlewareLayer ?? __rspack_external_effect_Layer_69c46453.empty;
|
|
62
|
+
const runtimeLayer = __rspack_external_effect_Layer_69c46453.mergeAll(protocolLayer, middlewareLayer);
|
|
63
|
+
return __rspack_external_effect_Effect_41060786.tryPromise({
|
|
64
|
+
try: async ()=>{
|
|
65
|
+
const runtime = __rspack_external_effect_ManagedRuntime_bfe218e3.make(runtimeLayer);
|
|
66
|
+
let scope;
|
|
67
|
+
try {
|
|
68
|
+
const clientScope = await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.make());
|
|
69
|
+
scope = clientScope;
|
|
70
|
+
const client = await runtime.runPromise(RpcClient.make(group, {
|
|
71
|
+
flatten: options.flatten
|
|
72
|
+
}).pipe(__rspack_external_effect_Effect_41060786.provideService(__rspack_external_effect_Scope_f87b0bd6.Scope, clientScope)));
|
|
73
|
+
let disposePromise;
|
|
74
|
+
const clientWithDispose = Object.assign(client, {
|
|
75
|
+
dispose: ()=>{
|
|
76
|
+
disposePromise ??= (async ()=>{
|
|
77
|
+
let scopeCloseError;
|
|
78
|
+
try {
|
|
79
|
+
await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.close(clientScope, __rspack_external_effect_Exit_1ca64b33["void"]));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
scopeCloseError = error;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
await runtime.dispose();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (void 0 === scopeCloseError) throw error;
|
|
87
|
+
}
|
|
88
|
+
if (void 0 !== scopeCloseError) throw scopeCloseError;
|
|
89
|
+
})();
|
|
90
|
+
return disposePromise;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return clientWithDispose;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (void 0 !== scope) try {
|
|
96
|
+
await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.close(scope, __rspack_external_effect_Exit_1ca64b33["void"]));
|
|
97
|
+
} catch {}
|
|
98
|
+
try {
|
|
99
|
+
await runtime.dispose();
|
|
100
|
+
} catch {}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
catch: (error)=>new EffectRpcClientError({
|
|
105
|
+
cause: error
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const runEffectRequest = __rspack_external_effect_Effect_41060786.runPromise;
|
|
110
|
+
export { EffectRpcClientError, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Schema_6065f72d as Schema, __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 as HttpClientError, makeEffectHttpApiClient, makeEffectRpcClient, mask, runEffectRequest, runEffectView, view };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isRecord } from "./guards.mjs";
|
|
2
|
+
const createEffectRequestContext = (createRequestContextHeaders, requestContext)=>{
|
|
3
|
+
if (!isRecord(requestContext)) return {};
|
|
4
|
+
const headers = createRequestContextHeaders ? createRequestContextHeaders(requestContext) : {};
|
|
5
|
+
return {
|
|
6
|
+
...requestContext,
|
|
7
|
+
headers
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
const applyRequestContext = (normalizedRequest, request, createRequestContext)=>{
|
|
11
|
+
if (!isRecord(request) || !isRecord(request.requestContext)) return normalizedRequest;
|
|
12
|
+
const requestContext = createRequestContext(request.requestContext);
|
|
13
|
+
const requestHeaders = isRecord(requestContext.headers) ? requestContext.headers : {};
|
|
14
|
+
if (0 === Object.keys(requestHeaders).length) return normalizedRequest;
|
|
15
|
+
return {
|
|
16
|
+
...normalizedRequest,
|
|
17
|
+
headers: {
|
|
18
|
+
...isRecord(normalizedRequest.headers) ? normalizedRequest.headers : {},
|
|
19
|
+
...requestHeaders
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export { applyRequestContext, createEffectRequestContext };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isRecord } from "./guards.mjs";
|
|
2
|
+
const METHODS_WITHOUT_BODY = new Set([
|
|
3
|
+
'GET',
|
|
4
|
+
'DELETE',
|
|
5
|
+
'HEAD',
|
|
6
|
+
'OPTIONS'
|
|
7
|
+
]);
|
|
8
|
+
const normalizeRequest = (method, request)=>{
|
|
9
|
+
if (!isRecord(request)) return {};
|
|
10
|
+
const payload = {
|
|
11
|
+
...request
|
|
12
|
+
};
|
|
13
|
+
if (isRecord(request.path) && !isRecord(payload.params)) payload.params = request.path;
|
|
14
|
+
if (isRecord(request.urlParams) && !isRecord(payload.query)) payload.query = request.urlParams;
|
|
15
|
+
if (isRecord(request.headers) && !isRecord(payload.headers)) payload.headers = request.headers;
|
|
16
|
+
if ('payload' in request && void 0 !== request.payload) if ("u" > typeof FormData && request.payload instanceof FormData && !('formData' in payload)) payload.formData = request.payload;
|
|
17
|
+
else if (METHODS_WITHOUT_BODY.has(method)) {
|
|
18
|
+
if (isRecord(request.payload)) payload.query = isRecord(payload.query) ? {
|
|
19
|
+
...payload.query,
|
|
20
|
+
...request.payload
|
|
21
|
+
} : request.payload;
|
|
22
|
+
else if (!('body' in payload)) payload.body = request.payload;
|
|
23
|
+
} else if (!isRecord(request.payload) || 'data' in payload) {
|
|
24
|
+
if (!('body' in payload)) payload.body = request.payload;
|
|
25
|
+
} else payload.data = request.payload;
|
|
26
|
+
return payload;
|
|
27
|
+
};
|
|
28
|
+
export { normalizeRequest };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { configureGeneratedEffectClientRuntime } from "./batch.mjs";
|
|
2
|
+
import { prepareEffectRequest } from "./envelope.mjs";
|
|
3
|
+
import { createEffectRequestContext as external_request_context_mjs_createEffectRequestContext } from "./request-context.mjs";
|
|
4
|
+
const createGeneratedEffectClient = (manifest, config, requestRuntime)=>{
|
|
5
|
+
const createRequest = requestRuntime.createRequest;
|
|
6
|
+
const configureRequest = 'function' == typeof requestRuntime.configure ? requestRuntime.configure : void 0;
|
|
7
|
+
const createRequestContextHeaders = 'function' == typeof requestRuntime.createRequestContextHeaders ? requestRuntime.createRequestContextHeaders : void 0;
|
|
8
|
+
const httpMethodDecider = config.httpMethodDecider || 'functionName';
|
|
9
|
+
const port = config.useEnvPort && "u" > typeof process && process.env && process.env.PORT ? process.env.PORT : config.port;
|
|
10
|
+
configureGeneratedEffectClientRuntime(config, configureRequest);
|
|
11
|
+
const createEffectRequestContext = (requestContext)=>external_request_context_mjs_createEffectRequestContext(createRequestContextHeaders, requestContext);
|
|
12
|
+
const client = {};
|
|
13
|
+
const operationManifest = {};
|
|
14
|
+
for (const endpoint of manifest.endpoints){
|
|
15
|
+
const operationId = `${endpoint.method}:${endpoint.routePath}`;
|
|
16
|
+
const operation = {
|
|
17
|
+
appNamespace: config.appNamespace,
|
|
18
|
+
apiId: endpoint.apiId,
|
|
19
|
+
group: endpoint.group,
|
|
20
|
+
endpoint: endpoint.endpoint,
|
|
21
|
+
operationId,
|
|
22
|
+
routePath: endpoint.routePath,
|
|
23
|
+
method: endpoint.method,
|
|
24
|
+
operationVersion: endpoint.operationVersion,
|
|
25
|
+
schemaHash: endpoint.schemaHash,
|
|
26
|
+
version: endpoint.operationVersion
|
|
27
|
+
};
|
|
28
|
+
const sender = createRequest({
|
|
29
|
+
path: endpoint.routePath,
|
|
30
|
+
method: endpoint.method,
|
|
31
|
+
port,
|
|
32
|
+
operationContext: {
|
|
33
|
+
operationId,
|
|
34
|
+
routePath: endpoint.routePath,
|
|
35
|
+
method: endpoint.method,
|
|
36
|
+
schemaHash: endpoint.schemaHash,
|
|
37
|
+
operationVersion: endpoint.operationVersion
|
|
38
|
+
},
|
|
39
|
+
httpMethodDecider,
|
|
40
|
+
...config.requestId ? {
|
|
41
|
+
requestId: config.requestId
|
|
42
|
+
} : {}
|
|
43
|
+
});
|
|
44
|
+
const call = (request = {})=>sender(prepareEffectRequest({
|
|
45
|
+
endpoint,
|
|
46
|
+
operation,
|
|
47
|
+
request,
|
|
48
|
+
config,
|
|
49
|
+
createEffectRequestContext
|
|
50
|
+
}));
|
|
51
|
+
client[endpoint.group] ??= {};
|
|
52
|
+
client[endpoint.group][endpoint.endpoint] = call;
|
|
53
|
+
operationManifest[endpoint.group] ??= {};
|
|
54
|
+
operationManifest[endpoint.group][endpoint.endpoint] = operation;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
client,
|
|
58
|
+
operationManifest,
|
|
59
|
+
createEffectRequestContext
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export { createGeneratedEffectClient };
|
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as __rspack_external__data_platform_index_mjs_e91ceab4 from "./data-platform/index.mjs";
|
|
2
|
+
import * as __rspack_external__effect_client_index_mjs_a83cfa33 from "./effect-client/index.mjs";
|
|
3
|
+
export * from "./effect/index.mjs";
|
|
4
|
+
export { __rspack_external__data_platform_index_mjs_e91ceab4 as DataPlatform, __rspack_external__effect_client_index_mjs_a83cfa33 as EffectClient };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __webpack_modules__ = {};
|
|
2
|
+
var __webpack_module_cache__ = {};
|
|
3
|
+
function __webpack_require__(moduleId) {
|
|
4
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
5
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
7
|
+
exports: {}
|
|
8
|
+
};
|
|
9
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
10
|
+
return module.exports;
|
|
11
|
+
}
|
|
12
|
+
__webpack_require__.m = __webpack_modules__;
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.add = function(modules) {
|
|
15
|
+
Object.assign(__webpack_require__.m, modules);
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
export { __webpack_require__ };
|