@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.8 → 3.9.3-ultramodern.1
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/assembly.js +2 -2
- package/dist/cjs/data-platform/batch/options.js +48 -0
- package/dist/cjs/data-platform/batch/queue.js +48 -83
- package/dist/cjs/effect/context.js +28 -4
- package/dist/cjs/effect/edge-dispatcher.js +19 -19
- package/dist/cjs/effect/edge.js +26 -6
- package/dist/cjs/effect/entry-shape.js +38 -10
- package/dist/cjs/effect/handler/batch-handler.js +2 -3
- package/dist/cjs/effect/handler/batch.js +0 -9
- package/dist/cjs/effect/handler/http.js +1 -1
- package/dist/cjs/effect/handler/openapi.js +3 -3
- package/dist/cjs/effect/handler/rpc.js +2 -2
- package/dist/cjs/effect/handler.js +26 -26
- package/dist/cjs/effect/index.js +8 -8
- package/dist/cjs/effect/module.js +6 -2
- package/dist/cjs/effect/operation-context.js +3 -7
- package/dist/cjs/effect/rpcSerialization.js +1 -3
- package/dist/cjs/effect-client/cross-project.js +8 -11
- package/dist/cjs/effect-client/index.js +10 -10
- package/dist/cjs/microvertical-api.js +1 -1
- package/dist/esm/assembly.mjs +1 -1
- package/dist/esm/data-platform/batch/options.mjs +10 -0
- package/dist/esm/data-platform/batch/queue.mjs +48 -83
- package/dist/esm/effect/context.mjs +21 -6
- package/dist/esm/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm/effect/edge.mjs +2 -0
- package/dist/esm/effect/entry-shape-registry.mjs +2 -2
- package/dist/esm/effect/entry-shape.mjs +27 -4
- package/dist/esm/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm/effect/handler/batch.mjs +1 -7
- package/dist/esm/effect/handler/http.mjs +1 -1
- package/dist/esm/effect/handler/openapi.mjs +2 -2
- package/dist/esm/effect/handler/rpc.mjs +2 -2
- package/dist/esm/effect/handler.mjs +6 -6
- package/dist/esm/effect/index.mjs +1 -1
- package/dist/esm/effect/module.mjs +5 -1
- package/dist/esm/effect/operation-context.mjs +2 -3
- package/dist/esm/effect/rpcSerialization.mjs +1 -3
- package/dist/esm/effect-client/cross-project.mjs +8 -11
- package/dist/esm/effect-client/index.mjs +5 -5
- package/dist/esm/microvertical-api.mjs +1 -1
- package/dist/esm-node/assembly.mjs +1 -1
- 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/effect/context.mjs +21 -6
- package/dist/esm-node/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/entry-shape.mjs +27 -4
- package/dist/esm-node/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm-node/effect/handler/batch.mjs +1 -7
- package/dist/esm-node/effect/handler/http.mjs +1 -1
- package/dist/esm-node/effect/handler/openapi.mjs +2 -2
- package/dist/esm-node/effect/handler/rpc.mjs +2 -2
- package/dist/esm-node/effect/handler.mjs +6 -6
- package/dist/esm-node/effect/index.mjs +1 -1
- package/dist/esm-node/effect/module.mjs +5 -1
- package/dist/esm-node/effect/operation-context.mjs +2 -3
- package/dist/esm-node/effect/rpcSerialization.mjs +1 -3
- package/dist/esm-node/effect-client/cross-project.mjs +8 -11
- package/dist/esm-node/effect-client/index.mjs +5 -5
- package/dist/esm-node/microvertical-api.mjs +1 -1
- package/dist/types/assembly.d.ts +2 -2
- 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 +14 -1
- package/dist/types/effect/edge-dispatcher.d.ts +4 -4
- package/dist/types/effect/edge.d.ts +2 -0
- package/dist/types/effect/entry-shape.d.ts +14 -0
- package/dist/types/effect/handler/batch.d.ts +0 -1
- package/dist/types/effect/handler/definition.d.ts +2 -2
- package/dist/types/effect/handler/http.d.ts +2 -2
- package/dist/types/effect/handler/openapi.d.ts +2 -2
- package/dist/types/effect/handler/rpc.d.ts +1 -1
- package/dist/types/effect/handler/types.d.ts +5 -5
- package/dist/types/effect/handler.d.ts +5 -5
- package/dist/types/effect/module.d.ts +2 -1
- package/dist/types/effect/operation-context.d.ts +0 -1
- package/dist/types/effect/rpcSerialization.d.ts +1 -1
- package/dist/types/effect-client/cross-project.d.ts +2 -2
- package/dist/types/effect-client/index.d.ts +6 -6
- package/dist/types/microvertical-api.d.ts +4 -4
- package/package.json +39 -45
- package/src/assembly.ts +3 -2
- package/src/data-platform/batch/options.ts +20 -0
- package/src/data-platform/batch/queue.ts +61 -89
- package/src/effect/context.ts +64 -12
- package/src/effect/edge-dispatcher.ts +13 -12
- package/src/effect/edge.ts +5 -0
- package/src/effect/entry-shape.ts +97 -7
- package/src/effect/handler/batch-handler.ts +6 -12
- package/src/effect/handler/batch.ts +0 -12
- package/src/effect/handler/definition.ts +2 -3
- package/src/effect/handler/http.ts +4 -3
- package/src/effect/handler/openapi.ts +2 -2
- package/src/effect/handler/rpc.ts +3 -2
- package/src/effect/handler/types.ts +6 -12
- package/src/effect/handler.ts +5 -5
- package/src/effect/index.ts +1 -1
- package/src/effect/module.ts +8 -1
- package/src/effect/operation-context.ts +1 -5
- package/src/effect/rpcSerialization.ts +1 -3
- package/src/effect-client/cross-project.ts +11 -16
- package/src/effect-client/index.ts +11 -15
- package/src/microvertical-api.ts +1 -1
- 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
|
@@ -30,8 +30,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createOpenApiLayer: ()=>createOpenApiLayer
|
|
32
32
|
});
|
|
33
|
-
const http_namespaceObject = require("effect/
|
|
34
|
-
const
|
|
33
|
+
const http_namespaceObject = require("effect/http");
|
|
34
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
35
35
|
const DEFAULT_OPENAPI_PATH = '/openapi.json';
|
|
36
36
|
function normalizeOpenApiPath(pathname) {
|
|
37
37
|
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
@@ -47,7 +47,7 @@ function getOpenApiOptions(openapi) {
|
|
|
47
47
|
function createOpenApiLayer(api, openapi) {
|
|
48
48
|
const openApiOptions = getOpenApiOptions(openapi);
|
|
49
49
|
if (!openApiOptions) return null;
|
|
50
|
-
return http_namespaceObject.HttpRouter.add('GET', openApiOptions.path, http_namespaceObject.HttpServerResponse.jsonUnsafe(
|
|
50
|
+
return http_namespaceObject.HttpRouter.add('GET', openApiOptions.path, http_namespaceObject.HttpServerResponse.jsonUnsafe(http_api_namespaceObject.OpenApi.fromApi(api)));
|
|
51
51
|
}
|
|
52
52
|
exports.createOpenApiLayer = __webpack_exports__.createOpenApiLayer;
|
|
53
53
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -31,9 +31,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
createRpcApiHandler: ()=>createRpcApiHandler,
|
|
32
32
|
normalizeRpcPath: ()=>normalizeRpcPath
|
|
33
33
|
});
|
|
34
|
+
const http_namespaceObject = require("effect/http");
|
|
34
35
|
const Layer_namespaceObject = require("effect/Layer");
|
|
35
|
-
const
|
|
36
|
-
const rpc_namespaceObject = require("effect/unstable/rpc");
|
|
36
|
+
const rpc_namespaceObject = require("effect/rpc");
|
|
37
37
|
const external_rpcSerialization_js_namespaceObject = require("../rpcSerialization.js");
|
|
38
38
|
function normalizeRpcPath(pathname) {
|
|
39
39
|
if (!pathname || '/' === pathname) return '/rpc';
|
|
@@ -21,14 +21,14 @@ var __webpack_modules__ = {
|
|
|
21
21
|
"effect/Schema" (module) {
|
|
22
22
|
module.exports = require("effect/Schema");
|
|
23
23
|
},
|
|
24
|
-
"effect/
|
|
25
|
-
module.exports = require("effect/
|
|
24
|
+
"effect/http" (module) {
|
|
25
|
+
module.exports = require("effect/http");
|
|
26
26
|
},
|
|
27
|
-
"effect/
|
|
28
|
-
module.exports = require("effect/
|
|
27
|
+
"effect/http-api" (module) {
|
|
28
|
+
module.exports = require("effect/http-api");
|
|
29
29
|
},
|
|
30
|
-
"effect/
|
|
31
|
-
module.exports = require("effect/
|
|
30
|
+
"effect/rpc" (module) {
|
|
31
|
+
module.exports = require("effect/rpc");
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
var __webpack_module_cache__ = {};
|
|
@@ -80,16 +80,13 @@ var __webpack_exports__ = {};
|
|
|
80
80
|
__webpack_require__.r(__webpack_exports__);
|
|
81
81
|
var effect_Config__rspack_import_0 = __webpack_require__("effect/Config");
|
|
82
82
|
var effect_Effect__rspack_import_1 = __webpack_require__("effect/Effect");
|
|
83
|
-
var
|
|
84
|
-
var effect_Option__rspack_import_3 = __webpack_require__("effect/Option");
|
|
85
|
-
var effect_Schema__rspack_import_4 = __webpack_require__("effect/Schema");
|
|
86
|
-
var effect_unstable_http__rspack_import_5 = __webpack_require__("effect/unstable/http");
|
|
83
|
+
var effect_http__rspack_import_2 = __webpack_require__("effect/http");
|
|
87
84
|
var __rspack_reexport = {};
|
|
88
|
-
for(const __rspack_import_key in
|
|
85
|
+
for(const __rspack_import_key in effect_http__rspack_import_2)if ([
|
|
89
86
|
"Config",
|
|
87
|
+
"HttpTraceContext",
|
|
90
88
|
"Layer",
|
|
91
89
|
"Schema",
|
|
92
|
-
"HttpTraceContext",
|
|
93
90
|
"HttpApiBuilder",
|
|
94
91
|
"defineEffectBff",
|
|
95
92
|
"default",
|
|
@@ -97,15 +94,15 @@ var __webpack_exports__ = {};
|
|
|
97
94
|
"defineEffectRpcBff",
|
|
98
95
|
"createHttpApiHandler",
|
|
99
96
|
"Option"
|
|
100
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
97
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>effect_http__rspack_import_2[__rspack_import_key];
|
|
101
98
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
102
|
-
var
|
|
99
|
+
var effect_http_api__rspack_import_3 = __webpack_require__("effect/http-api");
|
|
103
100
|
var __rspack_reexport = {};
|
|
104
|
-
for(const __rspack_import_key in
|
|
101
|
+
for(const __rspack_import_key in effect_http_api__rspack_import_3)if ([
|
|
105
102
|
"Config",
|
|
103
|
+
"HttpTraceContext",
|
|
106
104
|
"Layer",
|
|
107
105
|
"Schema",
|
|
108
|
-
"HttpTraceContext",
|
|
109
106
|
"HttpApiBuilder",
|
|
110
107
|
"defineEffectBff",
|
|
111
108
|
"default",
|
|
@@ -113,15 +110,17 @@ var __webpack_exports__ = {};
|
|
|
113
110
|
"defineEffectRpcBff",
|
|
114
111
|
"createHttpApiHandler",
|
|
115
112
|
"Option"
|
|
116
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
113
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>effect_http_api__rspack_import_3[__rspack_import_key];
|
|
117
114
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
118
|
-
var
|
|
115
|
+
var effect_Layer__rspack_import_4 = __webpack_require__("effect/Layer");
|
|
116
|
+
var effect_Option__rspack_import_5 = __webpack_require__("effect/Option");
|
|
117
|
+
var effect_rpc__rspack_import_6 = __webpack_require__("effect/rpc");
|
|
119
118
|
var __rspack_reexport = {};
|
|
120
|
-
for(const __rspack_import_key in
|
|
119
|
+
for(const __rspack_import_key in effect_rpc__rspack_import_6)if ([
|
|
121
120
|
"Config",
|
|
121
|
+
"HttpTraceContext",
|
|
122
122
|
"Layer",
|
|
123
123
|
"Schema",
|
|
124
|
-
"HttpTraceContext",
|
|
125
124
|
"HttpApiBuilder",
|
|
126
125
|
"defineEffectBff",
|
|
127
126
|
"default",
|
|
@@ -129,18 +128,19 @@ var __webpack_exports__ = {};
|
|
|
129
128
|
"defineEffectRpcBff",
|
|
130
129
|
"createHttpApiHandler",
|
|
131
130
|
"Option"
|
|
132
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
131
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>effect_rpc__rspack_import_6[__rspack_import_key];
|
|
133
132
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
133
|
+
var effect_Schema__rspack_import_7 = __webpack_require__("effect/Schema");
|
|
134
134
|
var _handler_definition__rspack_import_8 = __webpack_require__("./handler/definition");
|
|
135
135
|
var _handler_http__rspack_import_9 = __webpack_require__("./handler/http");
|
|
136
136
|
__webpack_require__.d(__webpack_exports__, {
|
|
137
137
|
Config: ()=>effect_Config__rspack_import_0,
|
|
138
138
|
Effect: ()=>effect_Effect__rspack_import_1,
|
|
139
|
-
HttpApiBuilder: ()=>
|
|
140
|
-
HttpTraceContext: ()=>
|
|
141
|
-
Layer: ()=>
|
|
142
|
-
Option: ()=>
|
|
143
|
-
Schema: ()=>
|
|
139
|
+
HttpApiBuilder: ()=>effect_http_api__rspack_import_3.HttpApiBuilder,
|
|
140
|
+
HttpTraceContext: ()=>effect_http__rspack_import_2.HttpTraceContext,
|
|
141
|
+
Layer: ()=>effect_Layer__rspack_import_4,
|
|
142
|
+
Option: ()=>effect_Option__rspack_import_5,
|
|
143
|
+
Schema: ()=>effect_Schema__rspack_import_7,
|
|
144
144
|
createHttpApiHandler: ()=>_handler_http__rspack_import_9.createHttpApiHandler,
|
|
145
145
|
defineEffectBff: ()=>_handler_definition__rspack_import_8.defineEffectBff,
|
|
146
146
|
defineEffectRpcBff: ()=>_handler_definition__rspack_import_8.defineEffectRpcBff
|
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;
|
|
@@ -30,7 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
resolveEffectBffModuleHandler: ()=>resolveEffectBffModuleHandler
|
|
32
32
|
});
|
|
33
|
-
const
|
|
33
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
34
34
|
const external_entry_shape_js_namespaceObject = require("./entry-shape.js");
|
|
35
35
|
const external_handler_js_namespaceObject = require("./handler.js");
|
|
36
36
|
function isRequestHandler(value) {
|
|
@@ -66,7 +66,7 @@ function classifyEffectBffRuntimeEntryShape(module) {
|
|
|
66
66
|
return (0, external_entry_shape_js_namespaceObject.classifyEffectBffEntryModule)(module, {
|
|
67
67
|
isRequestHandler,
|
|
68
68
|
isValidatorAwareHandlerFactory: external_entry_shape_js_namespaceObject.isValidatorAwareHandlerFactory,
|
|
69
|
-
isHttpApi:
|
|
69
|
+
isHttpApi: http_api_namespaceObject.HttpApi.isHttpApi
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
@@ -74,6 +74,10 @@ function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
|
74
74
|
if (facts.unsupportedShape) {
|
|
75
75
|
if (rejectUnsupportedEffectModuleShape(options, facts.unsupportedShape)) return null;
|
|
76
76
|
}
|
|
77
|
+
if (void 0 !== facts.module.rpc && !facts.createHandlerValidatorAware) {
|
|
78
|
+
rejectUnsupportedEffectModuleShape(options, 'unbranded RPC runtime');
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
77
81
|
if ('function' == typeof facts.createHandler) {
|
|
78
82
|
if (facts.createHandlerValidatorAware) {
|
|
79
83
|
const factory = facts.createHandler;
|
|
@@ -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;
|
|
@@ -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
|
|
@@ -30,7 +30,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
getRpcSerializationLayer: ()=>getRpcSerializationLayer
|
|
32
32
|
});
|
|
33
|
-
const rpc_namespaceObject = require("effect/
|
|
33
|
+
const rpc_namespaceObject = require("effect/rpc");
|
|
34
34
|
function getRpcSerializationLayer(serialization) {
|
|
35
35
|
switch(serialization){
|
|
36
36
|
case 'ndjson':
|
|
@@ -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
|
}
|
|
@@ -33,13 +33,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
const bff_policy_namespaceObject = require("@modern-js/server-runtime-extensions/bff-policy");
|
|
34
34
|
const Effect_namespaceObject = require("effect/Effect");
|
|
35
35
|
const Schema_namespaceObject = require("effect/Schema");
|
|
36
|
-
const http_namespaceObject = require("effect/
|
|
37
|
-
const
|
|
36
|
+
const http_namespaceObject = require("effect/http");
|
|
37
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
38
38
|
const encodeJson = Schema_namespaceObject.encodeSync(Schema_namespaceObject.fromJsonString(Schema_namespaceObject.Unknown));
|
|
39
39
|
function withCrossProjectPolicy(api, options, client) {
|
|
40
40
|
const contracts = {};
|
|
41
41
|
const prefix = options.prefix.replace(/\/$/, '');
|
|
42
|
-
|
|
42
|
+
http_api_namespaceObject.HttpApi.reflect(api, {
|
|
43
43
|
onGroup: ()=>{},
|
|
44
44
|
onEndpoint: ({ endpoint })=>{
|
|
45
45
|
const routePath = `${prefix}${'/' === endpoint.path ? '' : endpoint.path}` || '/';
|
|
@@ -62,14 +62,11 @@ function withCrossProjectPolicy(api, options, client) {
|
|
|
62
62
|
const contract = observed && contracts[`${observed.method}:${observed.routePath}`];
|
|
63
63
|
if (void 0 === contract) return Effect_namespaceObject.die(new Error('[BFF][Effect] Request has no matching shared operation contract.'));
|
|
64
64
|
return Effect_namespaceObject.gen(function*() {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
const digest = yield* Effect_namespaceObject.promise(()=>globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(input)));
|
|
72
|
-
const schemaHash = Array.from(new Uint8Array(digest), (value)=>value.toString(16).padStart(2, '0')).join('');
|
|
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));
|
|
73
70
|
return request.pipe(http_namespaceObject.HttpClientRequest.setHeader(bff_policy_namespaceObject.BFF_ENVELOPE_HEADER, encodeJson({
|
|
74
71
|
requestId: options.requestId
|
|
75
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({
|
|
@@ -30,11 +30,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
Effect: ()=>Effect_namespaceObject,
|
|
32
32
|
EffectRpcClientError: ()=>EffectRpcClientError,
|
|
33
|
-
HttpApi: ()=>
|
|
34
|
-
HttpApiClient: ()=>
|
|
35
|
-
HttpApiEndpoint: ()=>
|
|
36
|
-
HttpApiGroup: ()=>
|
|
37
|
-
HttpApiSchema: ()=>
|
|
33
|
+
HttpApi: ()=>http_api_namespaceObject.HttpApi,
|
|
34
|
+
HttpApiClient: ()=>http_api_namespaceObject.HttpApiClient,
|
|
35
|
+
HttpApiEndpoint: ()=>http_api_namespaceObject.HttpApiEndpoint,
|
|
36
|
+
HttpApiGroup: ()=>http_api_namespaceObject.HttpApiGroup,
|
|
37
|
+
HttpApiSchema: ()=>http_api_namespaceObject.HttpApiSchema,
|
|
38
38
|
HttpClientError: ()=>HttpClientError_namespaceObject,
|
|
39
39
|
Layer: ()=>Layer_namespaceObject,
|
|
40
40
|
Rpc: ()=>rpc_namespaceObject.Rpc,
|
|
@@ -54,16 +54,16 @@ const request_context_namespaceObject = require("@modern-js/runtime-extensions/r
|
|
|
54
54
|
const Data_namespaceObject = require("effect/Data");
|
|
55
55
|
const Effect_namespaceObject = require("effect/Effect");
|
|
56
56
|
const Exit_namespaceObject = require("effect/Exit");
|
|
57
|
+
const http_namespaceObject = require("effect/http");
|
|
58
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
57
59
|
const Layer_namespaceObject = require("effect/Layer");
|
|
58
60
|
const ManagedRuntime_namespaceObject = require("effect/ManagedRuntime");
|
|
61
|
+
const rpc_namespaceObject = require("effect/rpc");
|
|
59
62
|
const Scope_namespaceObject = require("effect/Scope");
|
|
60
|
-
const http_namespaceObject = require("effect/unstable/http");
|
|
61
|
-
const httpapi_namespaceObject = require("effect/unstable/httpapi");
|
|
62
|
-
const rpc_namespaceObject = require("effect/unstable/rpc");
|
|
63
63
|
const rpcSerialization_js_namespaceObject = require("../effect/rpcSerialization.js");
|
|
64
64
|
const external_cross_project_js_namespaceObject = require("./cross-project.js");
|
|
65
|
+
const HttpClientError_namespaceObject = require("effect/http/HttpClientError");
|
|
65
66
|
const Schema_namespaceObject = require("effect/Schema");
|
|
66
|
-
const HttpClientError_namespaceObject = require("effect/unstable/http/HttpClientError");
|
|
67
67
|
class EffectRpcClientError extends Data_namespaceObject.TaggedError('EffectRpcClientError') {
|
|
68
68
|
}
|
|
69
69
|
function isRecord(value) {
|
|
@@ -102,7 +102,7 @@ function makeEffectHttpApiClient(api, options) {
|
|
|
102
102
|
const policyClient = options?.crossProject !== void 0 ? (0, external_cross_project_js_namespaceObject.withCrossProjectPolicy)(api, options.crossProject, contextClient) : contextClient;
|
|
103
103
|
return 'function' == typeof options?.transformClient ? options.transformClient(policyClient) : policyClient;
|
|
104
104
|
};
|
|
105
|
-
return
|
|
105
|
+
return http_api_namespaceObject.HttpApiClient.make(api, {
|
|
106
106
|
baseUrl: options?.baseUrl,
|
|
107
107
|
transformClient,
|
|
108
108
|
transformResponse: options?.transformResponse
|
package/dist/esm/assembly.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpApiBuilder } from "effect/
|
|
1
|
+
import { HttpApiBuilder } from "effect/http-api";
|
|
2
2
|
import { defineEffectBff } from "./effect/handler/definition.mjs";
|
|
3
3
|
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
4
4
|
const assembleEffectBffRuntime = ({ api, handlers, transport })=>{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function normalizeBatchLimits(options = {}) {
|
|
2
|
+
return {
|
|
3
|
+
maxBatchSize: Math.max(1, options.maxBatchSize ?? 16),
|
|
4
|
+
maxBatchBytes: Math.max(1024, options.maxBatchBytes ?? 65536),
|
|
5
|
+
allowedMethods: new Set((void 0 !== options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
|
|
6
|
+
'GET'
|
|
7
|
+
]).map((method)=>method.toUpperCase()))
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { normalizeBatchLimits };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stableStringify } from "../codec.mjs";
|
|
2
2
|
import { DEFAULT_DATA_BATCH_HEADER } from "../types.mjs";
|
|
3
|
+
import { normalizeBatchLimits } from "./options.mjs";
|
|
3
4
|
import { decodeBatchBody, isNullBodyStatus } from "./protocol.mjs";
|
|
4
5
|
import { createBatchId, measureTextBytes, normalizeMethod, shouldBatchRequest, toHeaderRecord, toRequestBody } from "./request.mjs";
|
|
5
6
|
import { isBatchResponsePayload, parseResponseLikeCreateRequest } from "./response.mjs";
|
|
@@ -78,7 +79,6 @@ class BatchBucketRegistry {
|
|
|
78
79
|
if (existing) return existing;
|
|
79
80
|
const next = {
|
|
80
81
|
items: [],
|
|
81
|
-
bytes: 0,
|
|
82
82
|
batchId: createBatchId(),
|
|
83
83
|
sentAt: Date.now(),
|
|
84
84
|
timer: null,
|
|
@@ -97,12 +97,8 @@ class BatchBucketRegistry {
|
|
|
97
97
|
}
|
|
98
98
|
function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
99
99
|
const flushIntervalMs = Math.max(0, options.flushIntervalMs ?? 8);
|
|
100
|
-
const maxBatchSize =
|
|
101
|
-
const maxBatchBytes = Math.max(1024, options.maxBatchBytes ?? 65536);
|
|
100
|
+
const { maxBatchSize, maxBatchBytes, allowedMethods } = normalizeBatchLimits(options);
|
|
102
101
|
const requestTimeoutMs = options.requestTimeoutMs;
|
|
103
|
-
const allowedMethods = new Set((options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
|
|
104
|
-
'GET'
|
|
105
|
-
]).map((method)=>method.toUpperCase()));
|
|
106
102
|
const onEvent = options.onEvent;
|
|
107
103
|
const buckets = bucketRegistry ?? new BatchBucketRegistry();
|
|
108
104
|
const pendingByKey = new Map();
|
|
@@ -135,7 +131,6 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
135
131
|
const index = bucket.items.indexOf(request);
|
|
136
132
|
if (-1 === index) return;
|
|
137
133
|
bucket.items.splice(index, 1);
|
|
138
|
-
bucket.bytes = measurePayload(bucket, bucket.items);
|
|
139
134
|
if (0 === bucket.items.length && bucket.timer) {
|
|
140
135
|
clearTimeout(bucket.timer);
|
|
141
136
|
bucket.timer = null;
|
|
@@ -177,7 +172,11 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
177
172
|
if (!SAFE_REPLAY_METHODS.has(request.item.method)) throw new Error(`Batch result is unknown for ${request.item.method}; automatic replay is disabled (${reason}).`);
|
|
178
173
|
return runSingle(request);
|
|
179
174
|
};
|
|
180
|
-
const
|
|
175
|
+
const finishFlush = (bucketKey, bucket)=>{
|
|
176
|
+
bucket.flushing = false;
|
|
177
|
+
if (bucket.items.length > 0 && !bucket.timer) flushBucket(bucketKey);
|
|
178
|
+
buckets.releaseIfIdle(bucketKey, bucket);
|
|
179
|
+
};
|
|
181
180
|
const flushBucket = async (bucketKey)=>{
|
|
182
181
|
const bucket = buckets.get(bucketKey);
|
|
183
182
|
if (!bucket || bucket.flushing) return;
|
|
@@ -194,7 +193,6 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
194
193
|
sentAt: bucket.sentAt
|
|
195
194
|
};
|
|
196
195
|
bucket.items = [];
|
|
197
|
-
bucket.bytes = 0;
|
|
198
196
|
rotatePayloadIdentity(bucket);
|
|
199
197
|
const firstItem = items[0];
|
|
200
198
|
if (!firstItem) {
|
|
@@ -210,14 +208,25 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
210
208
|
size: items.length,
|
|
211
209
|
reason: disabledEndpoints.has(endpoint) ? 'batch-disabled' : void 0
|
|
212
210
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
try {
|
|
212
|
+
await settleRequests(items, runSingle);
|
|
213
|
+
} finally{
|
|
214
|
+
finishFlush(bucketKey, bucket);
|
|
215
|
+
}
|
|
217
216
|
return;
|
|
218
217
|
}
|
|
219
218
|
const payload = createPayload(payloadIdentity, items);
|
|
220
219
|
const batchId = payload.batchId;
|
|
220
|
+
const settleAmbiguousBatchRequests = (reason)=>{
|
|
221
|
+
emitDataBatchTransportEvent(onEvent, {
|
|
222
|
+
type: 'fallback',
|
|
223
|
+
endpoint,
|
|
224
|
+
batchId,
|
|
225
|
+
size: items.length,
|
|
226
|
+
reason
|
|
227
|
+
});
|
|
228
|
+
return settleRequests(items, (request)=>runAfterAmbiguousBatch(request, reason));
|
|
229
|
+
};
|
|
221
230
|
emitDataBatchTransportEvent(onEvent, {
|
|
222
231
|
type: 'flush',
|
|
223
232
|
endpoint,
|
|
@@ -268,42 +277,13 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
268
277
|
batchId,
|
|
269
278
|
reason: `batch-endpoint-unavailable-${String(response.status)}`
|
|
270
279
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
endpoint,
|
|
274
|
-
batchId,
|
|
275
|
-
size: items.length,
|
|
276
|
-
reason: `batch-response-${String(response.status)}`
|
|
277
|
-
});
|
|
278
|
-
await settleAmbiguousBatchRequests(items, `batch-response-${String(response.status)}`);
|
|
279
|
-
bucket.flushing = false;
|
|
280
|
+
await settleRequests(items, (request)=>runAfterAmbiguousBatch(request, `batch-response-${String(response.status)}`));
|
|
281
|
+
} else await settleAmbiguousBatchRequests(`batch-response-${String(response.status)}`);
|
|
280
282
|
return;
|
|
281
283
|
}
|
|
282
284
|
const result = await runWithSignal(controller.signal, async ()=>response.json());
|
|
283
|
-
if (!isBatchResponsePayload(result))
|
|
284
|
-
|
|
285
|
-
type: 'fallback',
|
|
286
|
-
endpoint,
|
|
287
|
-
batchId,
|
|
288
|
-
size: items.length,
|
|
289
|
-
reason: 'invalid-batch-response'
|
|
290
|
-
});
|
|
291
|
-
await settleAmbiguousBatchRequests(items, 'invalid-batch-response');
|
|
292
|
-
bucket.flushing = false;
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (result.batchId !== batchId) {
|
|
296
|
-
emitDataBatchTransportEvent(onEvent, {
|
|
297
|
-
type: 'fallback',
|
|
298
|
-
endpoint,
|
|
299
|
-
batchId,
|
|
300
|
-
size: items.length,
|
|
301
|
-
reason: 'mismatched-batch-id'
|
|
302
|
-
});
|
|
303
|
-
await settleAmbiguousBatchRequests(items, 'mismatched-batch-id');
|
|
304
|
-
bucket.flushing = false;
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
285
|
+
if (!isBatchResponsePayload(result)) return void await settleAmbiguousBatchRequests('invalid-batch-response');
|
|
286
|
+
if (result.batchId !== batchId) return void await settleAmbiguousBatchRequests('mismatched-batch-id');
|
|
307
287
|
const itemMap = new Map();
|
|
308
288
|
for (const item of result.items)itemMap.set(item.id, item);
|
|
309
289
|
await settleRequests(items, async (request)=>{
|
|
@@ -327,19 +307,10 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
327
307
|
});
|
|
328
308
|
return;
|
|
329
309
|
}
|
|
330
|
-
|
|
331
|
-
type: 'fallback',
|
|
332
|
-
endpoint,
|
|
333
|
-
batchId,
|
|
334
|
-
size: items.length,
|
|
335
|
-
reason: 'batch-transport-error'
|
|
336
|
-
});
|
|
337
|
-
await settleAmbiguousBatchRequests(items, 'batch-transport-error');
|
|
310
|
+
await settleAmbiguousBatchRequests('batch-transport-error');
|
|
338
311
|
} finally{
|
|
339
312
|
for (const item of items)item.abortBatchIfUnused = void 0;
|
|
340
|
-
bucket
|
|
341
|
-
if (bucket.items.length > 0 && !bucket.timer) flushBucket(bucketKey);
|
|
342
|
-
buckets.releaseIfIdle(bucketKey, bucket);
|
|
313
|
+
finishFlush(bucketKey, bucket);
|
|
343
314
|
}
|
|
344
315
|
};
|
|
345
316
|
const pendingReadPromises = new Map();
|
|
@@ -363,7 +334,20 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
363
334
|
const sourceSignal = initDefinesSignal ? initSignal ?? void 0 : sourceRequest?.signal;
|
|
364
335
|
const requestUrl = toAbsoluteUrl(input);
|
|
365
336
|
const endpoint = normalizeBatchEndpoint(requestUrl, options.endpoint).toString();
|
|
337
|
+
const itemHeaders = {
|
|
338
|
+
...headers
|
|
339
|
+
};
|
|
340
|
+
delete itemHeaders.authorization;
|
|
341
|
+
delete itemHeaders.cookie;
|
|
366
342
|
return {
|
|
343
|
+
itemHeaders,
|
|
344
|
+
itemPath: `${requestUrl.pathname}${requestUrl.search}`,
|
|
345
|
+
bucketKey: stableStringify({
|
|
346
|
+
endpoint,
|
|
347
|
+
authorization: headers.authorization ?? null,
|
|
348
|
+
cookie: headers.cookie ?? null,
|
|
349
|
+
credentials
|
|
350
|
+
}),
|
|
367
351
|
requestUrl,
|
|
368
352
|
endpoint,
|
|
369
353
|
method,
|
|
@@ -396,22 +380,11 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
396
380
|
batchEndpoint: request.endpoint,
|
|
397
381
|
requestUrl: request.requestUrl
|
|
398
382
|
})) return;
|
|
399
|
-
const itemHeaders = {
|
|
400
|
-
...request.headers
|
|
401
|
-
};
|
|
402
|
-
delete itemHeaders.authorization;
|
|
403
|
-
delete itemHeaders.cookie;
|
|
404
|
-
const bucketKey = stableStringify({
|
|
405
|
-
endpoint: request.endpoint,
|
|
406
|
-
authorization: request.headers.authorization ?? null,
|
|
407
|
-
cookie: request.headers.cookie ?? null,
|
|
408
|
-
credentials: request.credentials
|
|
409
|
-
});
|
|
410
383
|
return stableStringify({
|
|
411
|
-
bucketKey,
|
|
412
|
-
path:
|
|
384
|
+
bucketKey: request.bucketKey,
|
|
385
|
+
path: request.itemPath,
|
|
413
386
|
method: request.method,
|
|
414
|
-
headers: itemHeaders,
|
|
387
|
+
headers: request.itemHeaders,
|
|
415
388
|
body: null
|
|
416
389
|
});
|
|
417
390
|
};
|
|
@@ -429,26 +402,19 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
429
402
|
const itemId = `${Date.now().toString(36)}_${nextItemId.toString(36)}_${Math.random().toString(16).slice(2, 8)}`;
|
|
430
403
|
nextItemId += 1;
|
|
431
404
|
const itemHeaders = {
|
|
432
|
-
...request.
|
|
405
|
+
...request.itemHeaders
|
|
433
406
|
};
|
|
434
|
-
delete itemHeaders.authorization;
|
|
435
|
-
delete itemHeaders.cookie;
|
|
436
407
|
if (preparedBody.body && preparedBody.inferredContentType && !itemHeaders['content-type']) itemHeaders['content-type'] = preparedBody.inferredContentType;
|
|
437
408
|
const item = {
|
|
438
409
|
id: itemId,
|
|
439
|
-
path:
|
|
410
|
+
path: request.itemPath,
|
|
440
411
|
method: request.method,
|
|
441
412
|
headers: itemHeaders,
|
|
442
413
|
...preparedBody.body ? {
|
|
443
414
|
body: preparedBody.body
|
|
444
415
|
} : {}
|
|
445
416
|
};
|
|
446
|
-
const bucketKey =
|
|
447
|
-
endpoint: request.endpoint,
|
|
448
|
-
authorization: request.headers.authorization ?? null,
|
|
449
|
-
cookie: request.headers.cookie ?? null,
|
|
450
|
-
credentials: request.credentials
|
|
451
|
-
});
|
|
417
|
+
const { bucketKey } = request;
|
|
452
418
|
const key = stableStringify({
|
|
453
419
|
bucketKey,
|
|
454
420
|
path: item.path,
|
|
@@ -542,13 +508,12 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
542
508
|
}
|
|
543
509
|
}
|
|
544
510
|
bucket.items.push(queued);
|
|
545
|
-
bucket.bytes = measurePayload(bucket, bucket.items);
|
|
546
511
|
emitDataBatchTransportEvent(onEvent, {
|
|
547
512
|
type: 'enqueue',
|
|
548
513
|
endpoint: request.endpoint,
|
|
549
514
|
size: bucket.items.length
|
|
550
515
|
});
|
|
551
|
-
if (bucket.items.length >= maxBatchSize || bucket.
|
|
516
|
+
if (bucket.items.length >= maxBatchSize || measurePayload(bucket, bucket.items) >= maxBatchBytes) {
|
|
552
517
|
flushBucket(bucketKey);
|
|
553
518
|
return queued.promise;
|
|
554
519
|
}
|