@modern-js/bff-core 2.15.0 → 2.17.0
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/CHANGELOG.md +21 -0
- package/dist/cjs/api.js +22 -42
- package/dist/cjs/client/generateClient.js +63 -66
- package/dist/cjs/client/index.js +18 -17
- package/dist/cjs/client/result.js +11 -24
- package/dist/cjs/errors/http.js +26 -24
- package/dist/cjs/index.js +41 -50
- package/dist/cjs/operators/http.js +95 -101
- package/dist/cjs/router/constants.js +32 -40
- package/dist/cjs/router/index.js +114 -116
- package/dist/cjs/router/types.js +4 -15
- package/dist/cjs/router/utils.js +33 -50
- package/dist/cjs/types.js +29 -46
- package/dist/cjs/utils/alias.js +78 -58
- package/dist/cjs/utils/debug.js +8 -26
- package/dist/cjs/utils/index.js +24 -30
- package/dist/cjs/utils/meta.js +13 -28
- package/dist/cjs/utils/storage.js +51 -41
- package/dist/cjs/utils/validate.js +27 -44
- package/dist/esm/api.js +5 -5
- package/dist/esm/client/generateClient.js +6 -30
- package/dist/esm/client/result.js +2 -6
- package/dist/esm/errors/http.js +17 -6
- package/dist/esm/index.js +3 -23
- package/dist/esm/operators/http.js +22 -55
- package/dist/esm/router/constants.js +21 -20
- package/dist/esm/router/index.js +58 -61
- package/dist/esm/router/types.js +1 -0
- package/dist/esm/router/utils.js +11 -14
- package/dist/esm/types.js +16 -24
- package/dist/esm/utils/alias.js +12 -18
- package/dist/esm/utils/debug.js +1 -4
- package/dist/esm/utils/index.js +1 -4
- package/dist/esm/utils/meta.js +4 -10
- package/dist/esm/utils/storage.js +2 -6
- package/dist/esm/utils/validate.js +12 -15
- package/package.json +11 -7
|
@@ -26,9 +26,7 @@ const createStorage = () => {
|
|
|
26
26
|
}
|
|
27
27
|
const context = storage.getStore();
|
|
28
28
|
if (!context) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
`Can't call useContext out of scope, it should be placed in the bff function`
|
|
31
|
-
);
|
|
29
|
+
throw new Error(`Can't call useContext out of scope, it should be placed in the bff function`);
|
|
32
30
|
}
|
|
33
31
|
return context;
|
|
34
32
|
};
|
|
@@ -37,6 +35,4 @@ const createStorage = () => {
|
|
|
37
35
|
useContext
|
|
38
36
|
};
|
|
39
37
|
};
|
|
40
|
-
export {
|
|
41
|
-
createStorage
|
|
42
|
-
};
|
|
38
|
+
export { createStorage };
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import util from "util";
|
|
2
|
-
const getTypeErrorMessage = (actual) => {
|
|
3
|
-
var _a;
|
|
2
|
+
export const getTypeErrorMessage = (actual) => {
|
|
4
3
|
let msg = "";
|
|
5
4
|
if (actual == null) {
|
|
6
5
|
msg += `. Received ${actual}`;
|
|
7
6
|
} else if (typeof actual === "function" && actual.name) {
|
|
8
7
|
msg += `. Received function ${actual.name}`;
|
|
9
8
|
} else if (typeof actual === "object") {
|
|
10
|
-
|
|
9
|
+
var _actual_constructor;
|
|
10
|
+
if ((_actual_constructor = actual.constructor) === null || _actual_constructor === void 0 ? void 0 : _actual_constructor.name) {
|
|
11
11
|
msg += `. Received an instance of ${actual.constructor.name}`;
|
|
12
12
|
} else {
|
|
13
|
-
const inspected = util.inspect(actual, {
|
|
13
|
+
const inspected = util.inspect(actual, {
|
|
14
|
+
depth: -1
|
|
15
|
+
});
|
|
14
16
|
msg += `. Received ${inspected}`;
|
|
15
17
|
}
|
|
16
18
|
} else {
|
|
17
|
-
let inspected = util.inspect(actual, {
|
|
19
|
+
let inspected = util.inspect(actual, {
|
|
20
|
+
colors: false
|
|
21
|
+
});
|
|
18
22
|
if (inspected.length > 25) {
|
|
19
23
|
inspected = `${inspected.slice(0, 25)}...`;
|
|
20
24
|
}
|
|
@@ -22,22 +26,15 @@ const getTypeErrorMessage = (actual) => {
|
|
|
22
26
|
}
|
|
23
27
|
return msg;
|
|
24
28
|
};
|
|
25
|
-
class ERR_INVALID_ARG_TYPE extends Error {
|
|
29
|
+
export class ERR_INVALID_ARG_TYPE extends Error {
|
|
26
30
|
constructor(funcName, expectedType, actual) {
|
|
27
|
-
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
28
|
-
actual
|
|
29
|
-
)}`;
|
|
31
|
+
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(actual)}`;
|
|
30
32
|
super(message);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
const validateFunction = (maybeFunc, name) => {
|
|
35
|
+
export const validateFunction = (maybeFunc, name) => {
|
|
34
36
|
if (typeof maybeFunc !== "function") {
|
|
35
37
|
throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
|
|
36
38
|
}
|
|
37
39
|
return true;
|
|
38
40
|
};
|
|
39
|
-
export {
|
|
40
|
-
ERR_INVALID_ARG_TYPE,
|
|
41
|
-
getTypeErrorMessage,
|
|
42
|
-
validateFunction
|
|
43
|
-
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
"description": "A Progressive React Framework for modern web development.",
|
|
4
4
|
"homepage": "https://modernjs.dev",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/modern.js/issues",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/web-infra-dev/modern.js",
|
|
9
|
+
"directory": "packages/server/bff-core"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"keywords": [
|
|
9
13
|
"react",
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
"modern",
|
|
12
16
|
"modern.js"
|
|
13
17
|
],
|
|
14
|
-
"version": "2.
|
|
18
|
+
"version": "2.17.0",
|
|
15
19
|
"jsnext:source": "./src/index.ts",
|
|
16
20
|
"types": "./dist/types/index.d.ts",
|
|
17
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -27,8 +31,8 @@
|
|
|
27
31
|
"@babel/runtime": "^7.18.0",
|
|
28
32
|
"koa-compose": "^4.1.0",
|
|
29
33
|
"reflect-metadata": "^0.1.13",
|
|
30
|
-
"@modern-js/bff-runtime": "2.
|
|
31
|
-
"@modern-js/utils": "2.
|
|
34
|
+
"@modern-js/bff-runtime": "2.17.0",
|
|
35
|
+
"@modern-js/utils": "2.17.0"
|
|
32
36
|
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/jest": "^29",
|
|
@@ -40,9 +44,9 @@
|
|
|
40
44
|
"type-fest": "2.15.0",
|
|
41
45
|
"typescript": "^4",
|
|
42
46
|
"zod": "^3.17.3",
|
|
43
|
-
"@modern-js/types": "2.
|
|
44
|
-
"@scripts/build": "2.
|
|
45
|
-
"@scripts/jest-config": "2.
|
|
47
|
+
"@modern-js/types": "2.17.0",
|
|
48
|
+
"@scripts/build": "2.17.0",
|
|
49
|
+
"@scripts/jest-config": "2.17.0"
|
|
46
50
|
},
|
|
47
51
|
"peerDependencies": {
|
|
48
52
|
"zod": "^3.17.3",
|