@modern-js/bff-core 3.0.0-alpha.1 → 3.0.0-alpha.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/dist/cjs/client/generateClient.js +2 -6
- package/dist/cjs/router/utils.js +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/client/generateClient.mjs +3 -4
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/operators/http.mjs +2 -2
- package/dist/esm/router/constants.mjs +1 -1
- package/dist/esm/router/index.mjs +6 -6
- package/dist/esm/router/utils.mjs +2 -2
- package/dist/esm/utils/index.mjs +5 -5
- package/dist/esm-node/api.mjs +2 -0
- package/dist/esm-node/client/generateClient.mjs +3 -2
- package/dist/esm-node/client/index.mjs +2 -0
- package/dist/esm-node/client/result.mjs +2 -0
- package/dist/esm-node/compatible.mjs +2 -0
- package/dist/esm-node/errors/http.mjs +2 -0
- package/dist/esm-node/index.mjs +2 -0
- package/dist/esm-node/operators/http.mjs +2 -0
- package/dist/esm-node/router/constants.mjs +2 -0
- package/dist/esm-node/router/index.mjs +2 -0
- package/dist/esm-node/router/types.mjs +2 -0
- package/dist/esm-node/router/utils.mjs +3 -1
- package/dist/esm-node/types.mjs +2 -0
- package/dist/esm-node/utils/alias.mjs +2 -0
- package/dist/esm-node/utils/debug.mjs +2 -0
- package/dist/esm-node/utils/index.mjs +2 -0
- package/dist/esm-node/utils/meta.mjs +2 -0
- package/dist/esm-node/utils/storage.mjs +2 -0
- package/dist/esm-node/utils/validate.mjs +2 -0
- package/dist/types/client/generateClient.d.ts +0 -1
- package/package.json +11 -12
- package/rstest.config.ts +10 -0
|
@@ -24,9 +24,8 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
INNER_CLIENT_REQUEST_CREATOR: ()=>INNER_CLIENT_REQUEST_CREATOR
|
|
27
|
+
INNER_CLIENT_REQUEST_CREATOR: ()=>INNER_CLIENT_REQUEST_CREATOR,
|
|
28
|
+
generateClient: ()=>generateClient
|
|
30
29
|
});
|
|
31
30
|
const external_path_namespaceObject = require("path");
|
|
32
31
|
const index_js_namespaceObject = require("../router/index.js");
|
|
@@ -40,7 +39,6 @@ const getPackageName = (appDir)=>{
|
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
const DEFAULT_CLIENT_REQUEST_CREATOR = '@modern-js/create-request';
|
|
44
42
|
const INNER_CLIENT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
45
43
|
const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix, port, target, requestCreator, fetcher, requireResolve = require.resolve, httpMethodDecider, domain })=>{
|
|
46
44
|
requestCreator = requestCreator || INNER_CLIENT_REQUEST_CREATOR;
|
|
@@ -87,11 +85,9 @@ const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix,
|
|
|
87
85
|
${fetcher ? `import { fetch } from '${fetcher}';\n` : ''}`;
|
|
88
86
|
return (0, external_result_js_namespaceObject.Ok)(`${importCode}\n${handlersCode}`);
|
|
89
87
|
};
|
|
90
|
-
exports.DEFAULT_CLIENT_REQUEST_CREATOR = __webpack_exports__.DEFAULT_CLIENT_REQUEST_CREATOR;
|
|
91
88
|
exports.INNER_CLIENT_REQUEST_CREATOR = __webpack_exports__.INNER_CLIENT_REQUEST_CREATOR;
|
|
92
89
|
exports.generateClient = __webpack_exports__.generateClient;
|
|
93
90
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
94
|
-
"DEFAULT_CLIENT_REQUEST_CREATOR",
|
|
95
91
|
"INNER_CLIENT_REQUEST_CREATOR",
|
|
96
92
|
"generateClient"
|
|
97
93
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
package/dist/cjs/router/utils.js
CHANGED
|
@@ -69,7 +69,7 @@ const clearRouteName = (routeName)=>{
|
|
|
69
69
|
const isHandler = (input)=>input && 'function' == typeof input;
|
|
70
70
|
const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
|
|
71
71
|
const requireHandlerModule = async (modulePath)=>{
|
|
72
|
-
const originRequire = 'test' === process.env.NODE_ENV ?
|
|
72
|
+
const originRequire = 'test' === process.env.NODE_ENV ? require : utils_namespaceObject.compatibleRequire;
|
|
73
73
|
const module = await originRequire(modulePath, false);
|
|
74
74
|
if (isFunction(module)) return {
|
|
75
75
|
default: module
|
package/dist/esm/api.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import koa_compose from "koa-compose";
|
|
3
|
-
import { HANDLER_WITH_META, validateFunction } from "./utils";
|
|
3
|
+
import { HANDLER_WITH_META, validateFunction } from "./utils/index.mjs";
|
|
4
4
|
function Api(...args) {
|
|
5
5
|
const handler = args.pop();
|
|
6
6
|
validateFunction(handler, 'Apihandler');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from "path";
|
|
2
|
-
import { ApiRouter } from "../router";
|
|
3
|
-
import { Err, Ok } from "./result";
|
|
2
|
+
import { ApiRouter } from "../router/index.mjs";
|
|
3
|
+
import { Err, Ok } from "./result.mjs";
|
|
4
4
|
const getPackageName = (appDir)=>{
|
|
5
5
|
try {
|
|
6
6
|
const packageJsonPath = resolve(appDir, './package.json');
|
|
@@ -10,7 +10,6 @@ const getPackageName = (appDir)=>{
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
const DEFAULT_CLIENT_REQUEST_CREATOR = '@modern-js/create-request';
|
|
14
13
|
const INNER_CLIENT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
15
14
|
const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix, port, target, requestCreator, fetcher, requireResolve = require.resolve, httpMethodDecider, domain })=>{
|
|
16
15
|
requestCreator = requestCreator || INNER_CLIENT_REQUEST_CREATOR;
|
|
@@ -57,4 +56,4 @@ const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix,
|
|
|
57
56
|
${fetcher ? `import { fetch } from '${fetcher}';\n` : ''}`;
|
|
58
57
|
return Ok(`${importCode}\n${handlersCode}`);
|
|
59
58
|
};
|
|
60
|
-
export {
|
|
59
|
+
export { INNER_CLIENT_REQUEST_CREATOR, generateClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./generateClient";
|
|
1
|
+
export * from "./generateClient.mjs";
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Api } from "./api";
|
|
2
|
-
import { HttpError, ValidationError } from "./errors/http";
|
|
3
|
-
import { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths } from "./utils";
|
|
4
|
-
export * from "./router";
|
|
5
|
-
export * from "./types";
|
|
6
|
-
export * from "./client";
|
|
7
|
-
export * from "./operators/http";
|
|
1
|
+
import { Api } from "./api.mjs";
|
|
2
|
+
import { HttpError, ValidationError } from "./errors/http.mjs";
|
|
3
|
+
import { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths } from "./utils/index.mjs";
|
|
4
|
+
export * from "./router/index.mjs";
|
|
5
|
+
export * from "./types.mjs";
|
|
6
|
+
export * from "./client/index.mjs";
|
|
7
|
+
export * from "./operators/http.mjs";
|
|
8
8
|
export { Api, HANDLER_WITH_META, HttpError, INPUT_PARAMS_DECIDER, ValidationError, createStorage, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidationError } from "../errors/http";
|
|
2
|
-
import { HttpMetadata, HttpMethod, OperatorType, ResponseMetaType, TriggerType } from "../types";
|
|
1
|
+
import { ValidationError } from "../errors/http.mjs";
|
|
2
|
+
import { HttpMetadata, HttpMethod, OperatorType, ResponseMetaType, TriggerType } from "../types.mjs";
|
|
3
3
|
const validateInput = async (schema, input)=>{
|
|
4
4
|
try {
|
|
5
5
|
return await schema.parseAsync(input);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { fs, logger } from "@modern-js/utils";
|
|
3
3
|
import "reflect-metadata";
|
|
4
|
-
import { HttpMethod, OperatorType, TriggerType, httpMethods } from "../types";
|
|
5
|
-
import { INPUT_PARAMS_DECIDER, debug } from "../utils";
|
|
6
|
-
import { API_FILE_RULES, FRAMEWORK_MODE_LAMBDA_DIR } from "./constants";
|
|
7
|
-
import { getFiles, getPathFromFilename, requireHandlerModule, sortRoutes } from "./utils";
|
|
8
|
-
export * from "./types";
|
|
9
|
-
export * from "./constants";
|
|
4
|
+
import { HttpMethod, OperatorType, TriggerType, httpMethods } from "../types.mjs";
|
|
5
|
+
import { INPUT_PARAMS_DECIDER, debug } from "../utils/index.mjs";
|
|
6
|
+
import { API_FILE_RULES, FRAMEWORK_MODE_LAMBDA_DIR } from "./constants.mjs";
|
|
7
|
+
import { getFiles, getPathFromFilename, requireHandlerModule, sortRoutes } from "./utils.mjs";
|
|
8
|
+
export * from "./types.mjs";
|
|
9
|
+
export * from "./constants.mjs";
|
|
10
10
|
class ApiRouter {
|
|
11
11
|
isExistLambda() {
|
|
12
12
|
return this.existLambdaDir;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { compatibleRequire, globby } from "@modern-js/utils";
|
|
3
|
-
import { INDEX_SUFFIX } from "./constants";
|
|
3
|
+
import { INDEX_SUFFIX } from "./constants.mjs";
|
|
4
4
|
const getFiles = (lambdaDir, rules)=>globby.sync(rules, {
|
|
5
5
|
cwd: lambdaDir,
|
|
6
6
|
gitignore: true
|
|
@@ -27,7 +27,7 @@ const clearRouteName = (routeName)=>{
|
|
|
27
27
|
const isHandler = (input)=>input && 'function' == typeof input;
|
|
28
28
|
const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
|
|
29
29
|
const requireHandlerModule = async (modulePath)=>{
|
|
30
|
-
const originRequire = 'test' === process.env.NODE_ENV ?
|
|
30
|
+
const originRequire = 'test' === process.env.NODE_ENV ? require : compatibleRequire;
|
|
31
31
|
const module = await originRequire(modulePath, false);
|
|
32
32
|
if (isFunction(module)) return {
|
|
33
33
|
default: module
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { debug } from "./debug";
|
|
2
|
-
export * from "./storage";
|
|
3
|
-
export * from "./alias";
|
|
4
|
-
export * from "./meta";
|
|
5
|
-
export * from "./validate";
|
|
1
|
+
import { debug } from "./debug.mjs";
|
|
2
|
+
export * from "./storage.mjs";
|
|
3
|
+
export * from "./alias.mjs";
|
|
4
|
+
export * from "./meta.mjs";
|
|
5
|
+
export * from "./validate.mjs";
|
|
6
6
|
export { debug };
|
package/dist/esm-node/api.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
1
3
|
import { resolve } from "path";
|
|
2
4
|
import { ApiRouter } from "../router/index.mjs";
|
|
3
5
|
import { Err, Ok } from "./result.mjs";
|
|
@@ -10,7 +12,6 @@ const getPackageName = (appDir)=>{
|
|
|
10
12
|
return;
|
|
11
13
|
}
|
|
12
14
|
};
|
|
13
|
-
const DEFAULT_CLIENT_REQUEST_CREATOR = '@modern-js/create-request';
|
|
14
15
|
const INNER_CLIENT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
15
16
|
const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix, port, target, requestCreator, fetcher, requireResolve = require.resolve, httpMethodDecider, domain })=>{
|
|
16
17
|
requestCreator = requestCreator || INNER_CLIENT_REQUEST_CREATOR;
|
|
@@ -57,4 +58,4 @@ const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix,
|
|
|
57
58
|
${fetcher ? `import { fetch } from '${fetcher}';\n` : ''}`;
|
|
58
59
|
return Ok(`${importCode}\n${handlersCode}`);
|
|
59
60
|
};
|
|
60
|
-
export {
|
|
61
|
+
export { INNER_CLIENT_REQUEST_CREATOR, generateClient };
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
1
3
|
import { Api } from "./api.mjs";
|
|
2
4
|
import { HttpError, ValidationError } from "./errors/http.mjs";
|
|
3
5
|
import { HANDLER_WITH_META, INPUT_PARAMS_DECIDER, createStorage, getRelativeRuntimePath, isInputParamsDeciderHandler, isWithMetaHandler, registerPaths } from "./utils/index.mjs";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
1
3
|
import path from "path";
|
|
2
4
|
import { compatibleRequire, globby } from "@modern-js/utils";
|
|
3
5
|
import { INDEX_SUFFIX } from "./constants.mjs";
|
|
@@ -27,7 +29,7 @@ const clearRouteName = (routeName)=>{
|
|
|
27
29
|
const isHandler = (input)=>input && 'function' == typeof input;
|
|
28
30
|
const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
|
|
29
31
|
const requireHandlerModule = async (modulePath)=>{
|
|
30
|
-
const originRequire = 'test' === process.env.NODE_ENV ?
|
|
32
|
+
const originRequire = 'test' === process.env.NODE_ENV ? require : compatibleRequire;
|
|
31
33
|
const module = await originRequire(modulePath, false);
|
|
32
34
|
if (isFunction(module)) return {
|
|
33
35
|
default: module
|
package/dist/esm-node/types.mjs
CHANGED
|
@@ -16,6 +16,5 @@ export type GenClientOptions = {
|
|
|
16
16
|
httpMethodDecider?: HttpMethodDecider;
|
|
17
17
|
domain?: string;
|
|
18
18
|
};
|
|
19
|
-
export declare const DEFAULT_CLIENT_REQUEST_CREATOR = "@modern-js/create-request";
|
|
20
19
|
export declare const INNER_CLIENT_REQUEST_CREATOR = "@modern-js/plugin-bff/client";
|
|
21
20
|
export declare const generateClient: ({ appDir, resourcePath, apiDir, lambdaDir, prefix, port, target, requestCreator, fetcher, requireResolve, httpMethodDecider, domain, }: GenClientOptions) => Promise<GenClientResult>;
|
package/package.json
CHANGED
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.0.0-alpha.
|
|
19
|
-
"jsnext:source": "./src/index.ts",
|
|
18
|
+
"version": "3.0.0-alpha.2",
|
|
20
19
|
"types": "./dist/types/index.d.ts",
|
|
21
20
|
"main": "./dist/cjs/index.js",
|
|
22
|
-
"module": "./dist/esm/index.js",
|
|
23
21
|
"exports": {
|
|
24
22
|
".": {
|
|
25
23
|
"types": "./dist/types/index.d.ts",
|
|
26
|
-
"
|
|
24
|
+
"node": {
|
|
25
|
+
"import": "./dist/esm-node/index.mjs",
|
|
26
|
+
"require": "./dist/cjs/index.js"
|
|
27
|
+
},
|
|
27
28
|
"default": "./dist/cjs/index.js"
|
|
28
29
|
}
|
|
29
30
|
},
|
|
@@ -32,21 +33,19 @@
|
|
|
32
33
|
"koa-compose": "^4.1.0",
|
|
33
34
|
"reflect-metadata": "^0.2.2",
|
|
34
35
|
"type-fest": "2.19.0",
|
|
35
|
-
"@modern-js/utils": "3.0.0-alpha.
|
|
36
|
+
"@modern-js/utils": "3.0.0-alpha.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
+
"@rslib/core": "0.19.3",
|
|
39
40
|
"@types/koa-compose": "^3.2.9",
|
|
40
41
|
"@types/node": "^20",
|
|
41
|
-
"jest": "^29.7.0",
|
|
42
42
|
"ts-node": "^10.9.2",
|
|
43
43
|
"tsconfig-paths": "^4.2.0",
|
|
44
|
-
"@rslib/core": "0.19.1",
|
|
45
44
|
"typescript": "^5",
|
|
46
45
|
"zod": "^3.25.76",
|
|
47
|
-
"@modern-js/
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
46
|
+
"@modern-js/rslib": "2.68.10",
|
|
47
|
+
"@modern-js/types": "3.0.0-alpha.2",
|
|
48
|
+
"@scripts/rstest-config": "2.66.0"
|
|
50
49
|
},
|
|
51
50
|
"peerDependencies": {
|
|
52
51
|
"ts-node": "^10.9.2",
|
|
@@ -65,6 +64,6 @@
|
|
|
65
64
|
"scripts": {
|
|
66
65
|
"dev": "rslib build --watch",
|
|
67
66
|
"build": "rslib build",
|
|
68
|
-
"test": "
|
|
67
|
+
"test": "rstest --passWithNoTests"
|
|
69
68
|
}
|
|
70
69
|
}
|