@bleedingdev/modern-js-plugin-bff 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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/cli.js +9 -5
- package/dist/cjs/constants.js +13 -9
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/loader.js +32 -5
- package/dist/cjs/runtime/create-request/index.js +9 -5
- package/dist/cjs/runtime/data-platform/index.js +50 -26
- package/dist/cjs/runtime/effect/adapter.js +99 -93
- package/dist/cjs/runtime/effect/context.js +19 -7
- package/dist/cjs/runtime/effect/edge.js +169 -0
- package/dist/cjs/runtime/effect/endpoint-contracts.js +130 -0
- package/dist/cjs/runtime/effect/handler.js +642 -0
- package/dist/cjs/runtime/effect/index.js +30 -547
- package/dist/cjs/runtime/effect/module.js +151 -0
- package/dist/cjs/runtime/effect/operation-context.js +103 -0
- package/dist/cjs/runtime/effect-client/index.js +22 -6
- package/dist/cjs/runtime/effect-client/runtime.js +266 -0
- package/dist/cjs/runtime/hono/adapter.js +30 -14
- package/dist/cjs/runtime/hono/index.js +9 -5
- package/dist/cjs/runtime/hono/operators.js +9 -5
- package/dist/cjs/runtime/safe-failure.js +83 -0
- package/dist/cjs/server.js +9 -5
- package/dist/cjs/utils/clientGenerator.js +13 -9
- package/dist/cjs/utils/createHonoRoutes.js +9 -5
- package/dist/cjs/utils/crossProjectApiPlugin.js +9 -5
- package/dist/cjs/utils/crossProjectServerPolicy.js +104 -0
- package/dist/cjs/utils/effectClientGenerator.js +116 -488
- package/dist/cjs/utils/pluginGenerator.js +9 -5
- package/dist/cjs/utils/runtimeGenerator.js +9 -5
- package/dist/esm/loader.mjs +23 -0
- package/dist/esm/runtime/data-platform/index.mjs +33 -22
- package/dist/esm/runtime/effect/adapter.mjs +91 -89
- package/dist/esm/runtime/effect/context.mjs +3 -1
- package/dist/esm/runtime/effect/edge.mjs +83 -0
- package/dist/esm/runtime/effect/endpoint-contracts.mjs +68 -0
- package/dist/esm/runtime/effect/handler.mjs +470 -0
- package/dist/esm/runtime/effect/index.mjs +3 -437
- package/dist/esm/runtime/effect/module.mjs +113 -0
- package/dist/esm/runtime/effect/operation-context.mjs +65 -0
- package/dist/esm/runtime/effect-client/index.mjs +14 -2
- package/dist/esm/runtime/effect-client/runtime.mjs +228 -0
- package/dist/esm/runtime/hono/adapter.mjs +21 -9
- package/dist/esm/runtime/safe-failure.mjs +45 -0
- package/dist/esm/utils/clientGenerator.mjs +5 -5
- package/dist/esm/utils/crossProjectServerPolicy.mjs +50 -0
- package/dist/esm/utils/effectClientGenerator.mjs +105 -484
- package/dist/esm-node/loader.mjs +23 -0
- package/dist/esm-node/runtime/data-platform/index.mjs +33 -22
- package/dist/esm-node/runtime/effect/adapter.mjs +91 -89
- package/dist/esm-node/runtime/effect/context.mjs +3 -1
- package/dist/esm-node/runtime/effect/edge.mjs +84 -0
- package/dist/esm-node/runtime/effect/endpoint-contracts.mjs +69 -0
- package/dist/esm-node/runtime/effect/handler.mjs +471 -0
- package/dist/esm-node/runtime/effect/index.mjs +3 -437
- package/dist/esm-node/runtime/effect/module.mjs +114 -0
- package/dist/esm-node/runtime/effect/operation-context.mjs +66 -0
- package/dist/esm-node/runtime/effect-client/index.mjs +14 -2
- package/dist/esm-node/runtime/effect-client/runtime.mjs +229 -0
- package/dist/esm-node/runtime/hono/adapter.mjs +21 -9
- package/dist/esm-node/runtime/safe-failure.mjs +46 -0
- package/dist/esm-node/utils/clientGenerator.mjs +5 -5
- package/dist/esm-node/utils/crossProjectServerPolicy.mjs +52 -0
- package/dist/esm-node/utils/effectClientGenerator.mjs +105 -484
- package/dist/types/runtime/create-request/index.d.ts +1 -0
- package/dist/types/runtime/data-platform/index.d.ts +4 -0
- package/dist/types/runtime/effect/adapter.d.ts +25 -0
- package/dist/types/runtime/effect/context.d.ts +3 -6
- package/dist/types/runtime/effect/edge.d.ts +25 -0
- package/dist/types/runtime/effect/endpoint-contracts.d.ts +62 -0
- package/dist/types/runtime/effect/handler.d.ts +203 -0
- package/dist/types/runtime/effect/index.d.ts +2 -170
- package/dist/types/runtime/effect/module.d.ts +48 -0
- package/dist/types/runtime/effect/operation-context.d.ts +10 -0
- package/dist/types/runtime/effect-client/index.d.ts +6 -1
- package/dist/types/runtime/effect-client/runtime.d.ts +71 -0
- package/dist/types/runtime/hono/adapter.d.ts +3 -0
- package/dist/types/runtime/safe-failure.d.ts +1 -0
- package/dist/types/utils/createHonoRoutes.d.ts +3 -3
- package/dist/types/utils/crossProjectServerPolicy.d.ts +35 -0
- package/dist/types/utils/effectClientGenerator.d.ts +16 -2
- package/package.json +41 -20
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -24,10 +28,13 @@ var __webpack_require__ = {};
|
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createEffectOperationContext: ()=>external_operation_context_js_namespaceObject.createEffectOperationContext,
|
|
27
32
|
runWithEffectContext: ()=>runWithEffectContext,
|
|
28
|
-
useEffectContext: ()=>useEffectContext
|
|
33
|
+
useEffectContext: ()=>useEffectContext,
|
|
34
|
+
useOperationContext: ()=>useOperationContext
|
|
29
35
|
});
|
|
30
36
|
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
37
|
+
const external_operation_context_js_namespaceObject = require("./operation-context.js");
|
|
31
38
|
const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
|
|
32
39
|
const globalStore = globalThis;
|
|
33
40
|
const effectContextStorage = globalStore[kEffectContextStorage] ?? (globalStore[kEffectContextStorage] = new external_node_async_hooks_namespaceObject.AsyncLocalStorage());
|
|
@@ -37,11 +44,16 @@ const useEffectContext = ()=>{
|
|
|
37
44
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
38
45
|
return context;
|
|
39
46
|
};
|
|
47
|
+
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
48
|
+
exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
|
|
40
49
|
exports.runWithEffectContext = __webpack_exports__.runWithEffectContext;
|
|
41
50
|
exports.useEffectContext = __webpack_exports__.useEffectContext;
|
|
51
|
+
exports.useOperationContext = __webpack_exports__.useOperationContext;
|
|
42
52
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
53
|
+
"createEffectOperationContext",
|
|
43
54
|
"runWithEffectContext",
|
|
44
|
-
"useEffectContext"
|
|
55
|
+
"useEffectContext",
|
|
56
|
+
"useOperationContext"
|
|
45
57
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
58
|
Object.defineProperty(exports, '__esModule', {
|
|
47
59
|
value: true
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"../safe-failure" (module) {
|
|
4
|
+
module.exports = require("../safe-failure.js");
|
|
5
|
+
},
|
|
6
|
+
"./handler" (module) {
|
|
7
|
+
module.exports = require("./handler.js");
|
|
8
|
+
},
|
|
9
|
+
"./module" (module) {
|
|
10
|
+
module.exports = require("./module.js");
|
|
11
|
+
},
|
|
12
|
+
"./operation-context" (module) {
|
|
13
|
+
module.exports = require("./operation-context.js");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
37
|
+
var define = (defs, kind)=>{
|
|
38
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
[kind]: defs[key]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
define(getters, "get");
|
|
44
|
+
define(values, "value");
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
(()=>{
|
|
48
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
49
|
+
})();
|
|
50
|
+
(()=>{
|
|
51
|
+
__webpack_require__.r = (exports1)=>{
|
|
52
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
53
|
+
value: 'Module'
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
})();
|
|
60
|
+
var __webpack_exports__ = {};
|
|
61
|
+
(()=>{
|
|
62
|
+
__webpack_require__.r(__webpack_exports__);
|
|
63
|
+
var _safe_failure__rspack_import_0 = __webpack_require__("../safe-failure");
|
|
64
|
+
var _module__rspack_import_1 = __webpack_require__("./module");
|
|
65
|
+
var _operation_context__rspack_import_2 = __webpack_require__("./operation-context");
|
|
66
|
+
var _handler__rspack_import_3 = __webpack_require__("./handler");
|
|
67
|
+
var __rspack_reexport = {};
|
|
68
|
+
for(const __rspack_import_key in _handler__rspack_import_3)if ([
|
|
69
|
+
"default",
|
|
70
|
+
"dispatchEffectBffRequest",
|
|
71
|
+
"createEffectOperationContext",
|
|
72
|
+
"createEffectBffEdgeHandler"
|
|
73
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_handler__rspack_import_3[__rspack_import_key];
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
75
|
+
function normalizePrefix(prefix) {
|
|
76
|
+
if (!prefix || '/' === prefix) return '';
|
|
77
|
+
return prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
|
|
78
|
+
}
|
|
79
|
+
function removePrefixFromPath(pathname, prefix) {
|
|
80
|
+
const normalized = normalizePrefix(prefix);
|
|
81
|
+
if (!normalized || pathname !== normalized && !pathname.startsWith(`${normalized}/`)) return pathname;
|
|
82
|
+
const sliced = pathname.slice(normalized.length);
|
|
83
|
+
return sliced.startsWith('/') ? sliced : `/${sliced}`;
|
|
84
|
+
}
|
|
85
|
+
function matchesPrefix(pathname, prefix) {
|
|
86
|
+
const normalized = normalizePrefix(prefix);
|
|
87
|
+
return !normalized || pathname === normalized || pathname.startsWith(`${normalized}/`);
|
|
88
|
+
}
|
|
89
|
+
function createRequestForMountedPrefix(req, prefix) {
|
|
90
|
+
const url = new URL(req.url);
|
|
91
|
+
const nextPath = removePrefixFromPath(url.pathname, prefix);
|
|
92
|
+
if (nextPath === url.pathname) return req;
|
|
93
|
+
url.pathname = nextPath;
|
|
94
|
+
return new Request(url, req);
|
|
95
|
+
}
|
|
96
|
+
function createEdgeEffectContext(originalRequest, effectRequest, options) {
|
|
97
|
+
const originalPath = options.path || new URL(originalRequest.url).pathname;
|
|
98
|
+
const method = options.method || originalRequest.method;
|
|
99
|
+
return {
|
|
100
|
+
request: effectRequest,
|
|
101
|
+
env: options.env || {},
|
|
102
|
+
path: originalPath,
|
|
103
|
+
method,
|
|
104
|
+
operationContext: (0, _operation_context__rspack_import_2.createEffectOperationContext)({
|
|
105
|
+
request: effectRequest,
|
|
106
|
+
env: options.env || {},
|
|
107
|
+
path: originalPath,
|
|
108
|
+
method
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function createRuntimeErrorResponse(error) {
|
|
113
|
+
return (0, _safe_failure__rspack_import_0.createSafeFailureResponse)(error);
|
|
114
|
+
}
|
|
115
|
+
async function dispatchEffectBffRequest(handler, request, options = {}) {
|
|
116
|
+
const requestPathname = new URL(request.url).pathname;
|
|
117
|
+
if (!matchesPrefix(requestPathname, options.prefix)) return new Response(null, {
|
|
118
|
+
status: 404
|
|
119
|
+
});
|
|
120
|
+
const effectRequest = createRequestForMountedPrefix(request, options.prefix);
|
|
121
|
+
const effectContext = createEdgeEffectContext(request, effectRequest, options);
|
|
122
|
+
try {
|
|
123
|
+
const response = handler.length > 1 ? await handler(effectRequest, effectContext) : await handler(effectRequest);
|
|
124
|
+
if (!(response instanceof Response)) throw new Error('[BFF][Effect] Effect handler must return a Response instance.');
|
|
125
|
+
return new Response(response.body, response);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (error instanceof Response) return new Response(error.body, error);
|
|
128
|
+
if (options.onError) {
|
|
129
|
+
const errorResponse = await options.onError(error, effectContext);
|
|
130
|
+
if (errorResponse instanceof Response) return errorResponse;
|
|
131
|
+
}
|
|
132
|
+
return createRuntimeErrorResponse(error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function createEffectBffEdgeHandler(options) {
|
|
136
|
+
const loaded = await (0, _module__rspack_import_1.resolveEffectBffModuleHandler)(options.module, {
|
|
137
|
+
openapi: options.openapi,
|
|
138
|
+
dataPlatform: options.dataPlatform,
|
|
139
|
+
onWarning: options.onWarning
|
|
140
|
+
});
|
|
141
|
+
if (!loaded) throw new Error('[BFF][Effect] Invalid Effect edge module. Export { api, layer }, createHandler, or handler.');
|
|
142
|
+
return {
|
|
143
|
+
handler: (request, dispatchOptions = {})=>dispatchEffectBffRequest(loaded.handler, request, {
|
|
144
|
+
...dispatchOptions,
|
|
145
|
+
prefix: options.prefix,
|
|
146
|
+
onError: options.onError
|
|
147
|
+
}),
|
|
148
|
+
dispose: async ()=>{
|
|
149
|
+
await loaded.dispose?.();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
154
|
+
createEffectBffEdgeHandler: ()=>createEffectBffEdgeHandler,
|
|
155
|
+
createEffectOperationContext: ()=>_operation_context__rspack_import_2.createEffectOperationContext,
|
|
156
|
+
dispatchEffectBffRequest: ()=>dispatchEffectBffRequest
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
159
|
+
exports.createEffectBffEdgeHandler = __webpack_exports__.createEffectBffEdgeHandler;
|
|
160
|
+
exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
|
|
161
|
+
exports.dispatchEffectBffRequest = __webpack_exports__.dispatchEffectBffRequest;
|
|
162
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
|
+
"createEffectBffEdgeHandler",
|
|
164
|
+
"createEffectOperationContext",
|
|
165
|
+
"dispatchEffectBffRequest"
|
|
166
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
167
|
+
Object.defineProperty(exports, '__esModule', {
|
|
168
|
+
value: true
|
|
169
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
collectEffectEndpoints: ()=>collectEffectEndpoints,
|
|
32
|
+
createEffectEndpointContractHash: ()=>createEffectEndpointContractHash,
|
|
33
|
+
createEffectOperationContractSource: ()=>createEffectOperationContractSource,
|
|
34
|
+
ensureLeadingSlash: ()=>ensureLeadingSlash,
|
|
35
|
+
extractHttpApiFromModule: ()=>extractHttpApiFromModule,
|
|
36
|
+
getEffectRoutePath: ()=>getEffectRoutePath,
|
|
37
|
+
normalizeEffectPrefix: ()=>normalizeEffectPrefix,
|
|
38
|
+
resolveEffectApiId: ()=>resolveEffectApiId,
|
|
39
|
+
toOperationContractSources: ()=>toOperationContractSources
|
|
40
|
+
});
|
|
41
|
+
const bff_core_namespaceObject = require("@modern-js/bff-core");
|
|
42
|
+
function ensureLeadingSlash(pathname) {
|
|
43
|
+
return pathname.startsWith('/') ? pathname : `/${pathname}`;
|
|
44
|
+
}
|
|
45
|
+
function normalizeEffectPrefix(prefix) {
|
|
46
|
+
if ('/' === prefix) return '';
|
|
47
|
+
return ensureLeadingSlash(prefix || '/api');
|
|
48
|
+
}
|
|
49
|
+
function getEffectRoutePath(prefix, endpointPath) {
|
|
50
|
+
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
51
|
+
const normalizedEndpointPath = ensureLeadingSlash(endpointPath);
|
|
52
|
+
const finalEndpointPath = '/' === normalizedEndpointPath ? '' : endpointPath;
|
|
53
|
+
if (!normalizedPrefix && !finalEndpointPath) return '/';
|
|
54
|
+
return `${normalizedPrefix}${finalEndpointPath || ''}`;
|
|
55
|
+
}
|
|
56
|
+
function resolveEffectApiId(api) {
|
|
57
|
+
const fallback = 'EffectHttpApi';
|
|
58
|
+
if ('identifier' in api && 'string' == typeof api.identifier && api.identifier) return api.identifier;
|
|
59
|
+
return fallback;
|
|
60
|
+
}
|
|
61
|
+
function collectEffectEndpoints(reflect, api, prefix) {
|
|
62
|
+
const endpoints = [];
|
|
63
|
+
const apiId = resolveEffectApiId(api);
|
|
64
|
+
reflect(api, {
|
|
65
|
+
onGroup: ()=>{},
|
|
66
|
+
onEndpoint: ({ group, endpoint })=>{
|
|
67
|
+
endpoints.push({
|
|
68
|
+
apiId,
|
|
69
|
+
groupName: String(group.identifier),
|
|
70
|
+
endpointName: String(endpoint.name),
|
|
71
|
+
method: String(endpoint.method).toUpperCase(),
|
|
72
|
+
routePath: getEffectRoutePath(prefix, String(endpoint.path))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return endpoints.sort((a, b)=>{
|
|
77
|
+
if (a.groupName === b.groupName) return a.endpointName.localeCompare(b.endpointName);
|
|
78
|
+
return a.groupName.localeCompare(b.groupName);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function toOperationContractSources(endpoints) {
|
|
82
|
+
return endpoints.map(createEffectOperationContractSource);
|
|
83
|
+
}
|
|
84
|
+
function createEffectOperationContractSource(endpoint) {
|
|
85
|
+
return {
|
|
86
|
+
name: endpoint.endpointName,
|
|
87
|
+
httpMethod: endpoint.method,
|
|
88
|
+
routePath: endpoint.routePath
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function isRecord(value) {
|
|
92
|
+
return 'object' == typeof value && null !== value;
|
|
93
|
+
}
|
|
94
|
+
async function extractHttpApiFromModule(mod, isHttpApi) {
|
|
95
|
+
if (!isRecord(mod)) return null;
|
|
96
|
+
if (isHttpApi(mod.api)) return mod.api;
|
|
97
|
+
const entry = mod.default;
|
|
98
|
+
if (isRecord(entry) && isHttpApi(entry.api)) return entry.api;
|
|
99
|
+
if ('function' == typeof entry && 0 === entry.length) {
|
|
100
|
+
const output = await entry();
|
|
101
|
+
if (isRecord(output) && isHttpApi(output.api)) return output.api;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
function createEffectEndpointContractHash(endpoint, requestId) {
|
|
106
|
+
return (0, bff_core_namespaceObject.createOperationContractHash)(createEffectOperationContractSource(endpoint), requestId);
|
|
107
|
+
}
|
|
108
|
+
exports.collectEffectEndpoints = __webpack_exports__.collectEffectEndpoints;
|
|
109
|
+
exports.createEffectEndpointContractHash = __webpack_exports__.createEffectEndpointContractHash;
|
|
110
|
+
exports.createEffectOperationContractSource = __webpack_exports__.createEffectOperationContractSource;
|
|
111
|
+
exports.ensureLeadingSlash = __webpack_exports__.ensureLeadingSlash;
|
|
112
|
+
exports.extractHttpApiFromModule = __webpack_exports__.extractHttpApiFromModule;
|
|
113
|
+
exports.getEffectRoutePath = __webpack_exports__.getEffectRoutePath;
|
|
114
|
+
exports.normalizeEffectPrefix = __webpack_exports__.normalizeEffectPrefix;
|
|
115
|
+
exports.resolveEffectApiId = __webpack_exports__.resolveEffectApiId;
|
|
116
|
+
exports.toOperationContractSources = __webpack_exports__.toOperationContractSources;
|
|
117
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
118
|
+
"collectEffectEndpoints",
|
|
119
|
+
"createEffectEndpointContractHash",
|
|
120
|
+
"createEffectOperationContractSource",
|
|
121
|
+
"ensureLeadingSlash",
|
|
122
|
+
"extractHttpApiFromModule",
|
|
123
|
+
"getEffectRoutePath",
|
|
124
|
+
"normalizeEffectPrefix",
|
|
125
|
+
"resolveEffectApiId",
|
|
126
|
+
"toOperationContractSources"
|
|
127
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
128
|
+
Object.defineProperty(exports, '__esModule', {
|
|
129
|
+
value: true
|
|
130
|
+
});
|