@modern-js/bff-core 1.21.7-beta.0 → 1.22.2-beta.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 +72 -0
- package/dist/js/modern/api.js +49 -25
- package/dist/js/modern/client/generate-client.js +52 -25
- package/dist/js/modern/client/index.js +1 -1
- package/dist/js/modern/client/result.js +9 -8
- package/dist/js/modern/errors/http.js +8 -7
- package/dist/js/modern/index.js +19 -3
- package/dist/js/modern/operators/http.js +139 -87
- package/dist/js/modern/router/constants.js +31 -11
- package/dist/js/modern/router/index.js +66 -69
- package/dist/js/modern/router/types.js +0 -1
- package/dist/js/modern/router/utils.js +36 -37
- package/dist/js/modern/types.js +45 -37
- package/dist/js/modern/utils/alias.js +32 -30
- package/dist/js/modern/utils/debug.js +5 -2
- package/dist/js/modern/utils/index.js +5 -2
- package/dist/js/modern/utils/meta.js +8 -4
- package/dist/js/modern/utils/storage.js +8 -4
- package/dist/js/modern/utils/validate.js +22 -23
- package/dist/js/node/api.js +78 -32
- package/dist/js/node/client/generate-client.js +85 -38
- package/dist/js/node/client/index.js +17 -16
- package/dist/js/node/client/result.js +31 -14
- package/dist/js/node/errors/http.js +28 -11
- package/dist/js/node/index.js +45 -111
- package/dist/js/node/operators/http.js +184 -124
- package/dist/js/node/router/constants.js +60 -24
- package/dist/js/node/router/index.js +110 -125
- package/dist/js/node/router/types.js +15 -5
- package/dist/js/node/router/utils.js +71 -51
- package/dist/js/node/types.js +71 -47
- package/dist/js/node/utils/alias.js +63 -42
- package/dist/js/node/utils/debug.js +27 -8
- package/dist/js/node/utils/index.js +28 -59
- package/dist/js/node/utils/meta.js +30 -10
- package/dist/js/node/utils/storage.js +36 -11
- package/dist/js/node/utils/validate.js +49 -28
- package/dist/types/router/constants.d.ts +1 -0
- package/dist/types/router/index.d.ts +1 -0
- package/package.json +5 -10
|
@@ -1,42 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var alias_exports = {};
|
|
25
|
+
__export(alias_exports, {
|
|
26
|
+
createMatchPath: () => createMatchPath,
|
|
27
|
+
getRelativeRuntimePath: () => getRelativeRuntimePath,
|
|
28
|
+
registerPaths: () => registerPaths
|
|
5
29
|
});
|
|
6
|
-
|
|
7
|
-
var path =
|
|
8
|
-
var os =
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
30
|
+
module.exports = __toCommonJS(alias_exports);
|
|
31
|
+
var path = __toESM(require("path"));
|
|
32
|
+
var os = __toESM(require("os"));
|
|
33
|
+
var import_fs = __toESM(require("fs"));
|
|
34
|
+
var import_module = __toESM(require("module"));
|
|
14
35
|
const getRelativeRuntimePath = (appDirectory, serverRuntimePath) => {
|
|
15
|
-
let relativeRuntimePath =
|
|
16
|
-
if (os.platform() ===
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
let relativeRuntimePath = "";
|
|
37
|
+
if (os.platform() === "win32") {
|
|
38
|
+
relativeRuntimePath = `../${path.relative(
|
|
39
|
+
appDirectory,
|
|
40
|
+
serverRuntimePath
|
|
41
|
+
)}`;
|
|
19
42
|
} else {
|
|
20
|
-
|
|
21
|
-
|
|
43
|
+
relativeRuntimePath = path.join(
|
|
44
|
+
"../",
|
|
45
|
+
path.relative(appDirectory, serverRuntimePath)
|
|
46
|
+
);
|
|
22
47
|
}
|
|
23
|
-
if (process.env.NODE_ENV ===
|
|
48
|
+
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
|
|
24
49
|
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
25
50
|
}
|
|
26
51
|
return relativeRuntimePath;
|
|
27
52
|
};
|
|
28
|
-
|
|
29
|
-
const sortByLongestPrefix = arr => {
|
|
53
|
+
const sortByLongestPrefix = (arr) => {
|
|
30
54
|
return arr.concat().sort((a, b) => b.length - a.length);
|
|
31
55
|
};
|
|
32
|
-
const createMatchPath = paths => {
|
|
56
|
+
const createMatchPath = (paths) => {
|
|
33
57
|
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
34
58
|
const sortedPaths = {};
|
|
35
|
-
sortedKeys.forEach(key => {
|
|
59
|
+
sortedKeys.forEach((key) => {
|
|
36
60
|
sortedPaths[key] = paths[key];
|
|
37
61
|
});
|
|
38
|
-
return request => {
|
|
39
|
-
const found = Object.keys(sortedPaths).find(key => {
|
|
62
|
+
return (request) => {
|
|
63
|
+
const found = Object.keys(sortedPaths).find((key) => {
|
|
40
64
|
return request.startsWith(key);
|
|
41
65
|
});
|
|
42
66
|
if (found) {
|
|
@@ -44,10 +68,10 @@ const createMatchPath = paths => {
|
|
|
44
68
|
if (!Array.isArray(foundPaths)) {
|
|
45
69
|
foundPaths = [foundPaths];
|
|
46
70
|
}
|
|
47
|
-
foundPaths = foundPaths.filter(foundPath => path.isAbsolute(foundPath));
|
|
71
|
+
foundPaths = foundPaths.filter((foundPath) => path.isAbsolute(foundPath));
|
|
48
72
|
for (const p of foundPaths) {
|
|
49
73
|
const foundPath = request.replace(found, p);
|
|
50
|
-
if (
|
|
74
|
+
if (import_fs.default.existsSync(foundPath)) {
|
|
51
75
|
return foundPath;
|
|
52
76
|
}
|
|
53
77
|
}
|
|
@@ -56,31 +80,28 @@ const createMatchPath = paths => {
|
|
|
56
80
|
return null;
|
|
57
81
|
};
|
|
58
82
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const registerPaths = paths => {
|
|
63
|
-
const originalResolveFilename = _module.default._resolveFilename;
|
|
64
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
65
|
-
const {
|
|
66
|
-
builtinModules
|
|
67
|
-
} = _module.default;
|
|
83
|
+
const registerPaths = (paths) => {
|
|
84
|
+
const originalResolveFilename = import_module.default._resolveFilename;
|
|
85
|
+
const { builtinModules } = import_module.default;
|
|
68
86
|
const matchPath = createMatchPath(paths);
|
|
69
|
-
|
|
87
|
+
import_module.default._resolveFilename = function(request, _parent) {
|
|
70
88
|
const isCoreModule = builtinModules.includes(request);
|
|
71
89
|
if (!isCoreModule) {
|
|
72
90
|
const matched = matchPath(request);
|
|
73
91
|
if (matched) {
|
|
74
|
-
|
|
75
|
-
const modifiedArguments = [matched, ...[].slice.call(arguments, 1)]; // Passes all arguments. Even those that is not specified above.
|
|
92
|
+
const modifiedArguments = [matched, ...[].slice.call(arguments, 1)];
|
|
76
93
|
return originalResolveFilename.apply(this, modifiedArguments);
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
|
-
// eslint-disable-next-line prefer-rest-params
|
|
80
96
|
return originalResolveFilename.apply(this, arguments);
|
|
81
97
|
};
|
|
82
98
|
return () => {
|
|
83
|
-
|
|
99
|
+
import_module.default._resolveFilename = originalResolveFilename;
|
|
84
100
|
};
|
|
85
101
|
};
|
|
86
|
-
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
createMatchPath,
|
|
105
|
+
getRelativeRuntimePath,
|
|
106
|
+
registerPaths
|
|
107
|
+
});
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var debug_exports = {};
|
|
19
|
+
__export(debug_exports, {
|
|
20
|
+
debug: () => debug
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(debug_exports);
|
|
23
|
+
var import_utils = require("@modern-js/utils");
|
|
24
|
+
const debug = (0, import_utils.createDebugger)("bff");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
debug
|
|
5
28
|
});
|
|
6
|
-
exports.debug = void 0;
|
|
7
|
-
var _utils = require("@modern-js/utils");
|
|
8
|
-
const debug = (0, _utils.createDebugger)('bff');
|
|
9
|
-
exports.debug = debug;
|
|
@@ -1,63 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
14
|
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
debug: () => import_debug.debug
|
|
14
22
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _alias = require("./alias");
|
|
28
|
-
Object.keys(_alias).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _alias[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _alias[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _debug = require("./debug");
|
|
40
|
-
var _meta = require("./meta");
|
|
41
|
-
Object.keys(_meta).forEach(function (key) {
|
|
42
|
-
if (key === "default" || key === "__esModule") return;
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
44
|
-
if (key in exports && exports[key] === _meta[key]) return;
|
|
45
|
-
Object.defineProperty(exports, key, {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return _meta[key];
|
|
49
|
-
}
|
|
50
|
-
});
|
|
23
|
+
module.exports = __toCommonJS(utils_exports);
|
|
24
|
+
__reExport(utils_exports, require("./storage"), module.exports);
|
|
25
|
+
__reExport(utils_exports, require("./alias"), module.exports);
|
|
26
|
+
var import_debug = require("./debug");
|
|
27
|
+
__reExport(utils_exports, require("./meta"), module.exports);
|
|
28
|
+
__reExport(utils_exports, require("./validate"), module.exports);
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
debug
|
|
51
32
|
});
|
|
52
|
-
var _validate = require("./validate");
|
|
53
|
-
Object.keys(_validate).forEach(function (key) {
|
|
54
|
-
if (key === "default" || key === "__esModule") return;
|
|
55
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
56
|
-
if (key in exports && exports[key] === _validate[key]) return;
|
|
57
|
-
Object.defineProperty(exports, key, {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function () {
|
|
60
|
-
return _validate[key];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var meta_exports = {};
|
|
19
|
+
__export(meta_exports, {
|
|
20
|
+
HANDLER_WITH_META: () => HANDLER_WITH_META,
|
|
21
|
+
isWithMetaHandler: () => isWithMetaHandler
|
|
5
22
|
});
|
|
6
|
-
|
|
7
|
-
const HANDLER_WITH_META =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return typeof handler === 'function' && handler[HANDLER_WITH_META];
|
|
23
|
+
module.exports = __toCommonJS(meta_exports);
|
|
24
|
+
const HANDLER_WITH_META = "HANDLER_WITH_META";
|
|
25
|
+
const isWithMetaHandler = (handler) => {
|
|
26
|
+
return typeof handler === "function" && handler[HANDLER_WITH_META];
|
|
11
27
|
};
|
|
12
|
-
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
HANDLER_WITH_META,
|
|
31
|
+
isWithMetaHandler
|
|
32
|
+
});
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var storage_exports = {};
|
|
25
|
+
__export(storage_exports, {
|
|
26
|
+
createStorage: () => createStorage
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var ah =
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
module.exports = __toCommonJS(storage_exports);
|
|
29
|
+
var ah = __toESM(require("async_hooks"));
|
|
10
30
|
const createStorage = () => {
|
|
11
31
|
let storage;
|
|
12
|
-
if (typeof ah.AsyncLocalStorage !==
|
|
32
|
+
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
|
13
33
|
storage = new ah.AsyncLocalStorage();
|
|
14
34
|
}
|
|
15
35
|
const run = (context, cb) => {
|
|
@@ -34,7 +54,9 @@ const createStorage = () => {
|
|
|
34
54
|
}
|
|
35
55
|
const context = storage.getStore();
|
|
36
56
|
if (!context) {
|
|
37
|
-
throw new Error(
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Can't call useContext out of scope, it should be placed in the bff function`
|
|
59
|
+
);
|
|
38
60
|
}
|
|
39
61
|
return context;
|
|
40
62
|
};
|
|
@@ -43,4 +65,7 @@ const createStorage = () => {
|
|
|
43
65
|
useContext
|
|
44
66
|
};
|
|
45
67
|
};
|
|
46
|
-
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
createStorage
|
|
71
|
+
});
|
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var validate_exports = {};
|
|
25
|
+
__export(validate_exports, {
|
|
26
|
+
ERR_INVALID_ARG_TYPE: () => ERR_INVALID_ARG_TYPE,
|
|
27
|
+
getTypeErrorMessage: () => getTypeErrorMessage,
|
|
28
|
+
validateFunction: () => validateFunction
|
|
5
29
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let msg = '';
|
|
30
|
+
module.exports = __toCommonJS(validate_exports);
|
|
31
|
+
var import_util = __toESM(require("util"));
|
|
32
|
+
const getTypeErrorMessage = (actual) => {
|
|
33
|
+
var _a;
|
|
34
|
+
let msg = "";
|
|
12
35
|
if (actual == null) {
|
|
13
36
|
msg += `. Received ${actual}`;
|
|
14
|
-
} else if (typeof actual ===
|
|
37
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
15
38
|
msg += `. Received function ${actual.name}`;
|
|
16
|
-
} else if (typeof actual ===
|
|
17
|
-
|
|
18
|
-
if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
|
|
39
|
+
} else if (typeof actual === "object") {
|
|
40
|
+
if ((_a = actual.constructor) == null ? void 0 : _a.name) {
|
|
19
41
|
msg += `. Received an instance of ${actual.constructor.name}`;
|
|
20
42
|
} else {
|
|
21
|
-
const inspected =
|
|
22
|
-
depth: -1
|
|
23
|
-
});
|
|
43
|
+
const inspected = import_util.default.inspect(actual, { depth: -1 });
|
|
24
44
|
msg += `. Received ${inspected}`;
|
|
25
45
|
}
|
|
26
46
|
} else {
|
|
27
|
-
let inspected =
|
|
28
|
-
colors: false
|
|
29
|
-
});
|
|
47
|
+
let inspected = import_util.default.inspect(actual, { colors: false });
|
|
30
48
|
if (inspected.length > 25) {
|
|
31
49
|
inspected = `${inspected.slice(0, 25)}...`;
|
|
32
50
|
}
|
|
@@ -34,20 +52,23 @@ const getTypeErrorMessage = actual => {
|
|
|
34
52
|
}
|
|
35
53
|
return msg;
|
|
36
54
|
};
|
|
37
|
-
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
39
|
-
exports.getTypeErrorMessage = getTypeErrorMessage;
|
|
40
55
|
class ERR_INVALID_ARG_TYPE extends Error {
|
|
41
56
|
constructor(funcName, expectedType, actual) {
|
|
42
|
-
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
57
|
+
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
58
|
+
actual
|
|
59
|
+
)}`;
|
|
43
60
|
super(message);
|
|
44
61
|
}
|
|
45
62
|
}
|
|
46
|
-
exports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
|
|
47
63
|
const validateFunction = (maybeFunc, name) => {
|
|
48
|
-
if (typeof maybeFunc !==
|
|
49
|
-
throw new ERR_INVALID_ARG_TYPE(name,
|
|
64
|
+
if (typeof maybeFunc !== "function") {
|
|
65
|
+
throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
|
|
50
66
|
}
|
|
51
67
|
return true;
|
|
52
68
|
};
|
|
53
|
-
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
ERR_INVALID_ARG_TYPE,
|
|
72
|
+
getTypeErrorMessage,
|
|
73
|
+
validateFunction
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.22.2-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.18.0",
|
|
29
|
-
"@modern-js/bff-runtime": "2.0.0-beta.
|
|
30
|
-
"@modern-js/utils": "2.0.0-beta.
|
|
29
|
+
"@modern-js/bff-runtime": "2.0.0-beta.4",
|
|
30
|
+
"@modern-js/utils": "2.0.0-beta.4",
|
|
31
31
|
"esbuild": "0.15.7",
|
|
32
32
|
"esbuild-register": "^3.3.3",
|
|
33
33
|
"koa-compose": "^4.1.0",
|
|
34
34
|
"reflect-metadata": "^0.1.13"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@scripts/build": "2.0.0-beta.
|
|
38
|
-
"@scripts/jest-config": "2.0.0-beta.
|
|
37
|
+
"@scripts/build": "2.0.0-beta.4",
|
|
38
|
+
"@scripts/jest-config": "2.0.0-beta.4",
|
|
39
39
|
"@types/jest": "^27",
|
|
40
40
|
"@types/koa-compose": "^3.2.5",
|
|
41
41
|
"@types/node": "^14",
|
|
@@ -52,11 +52,6 @@
|
|
|
52
52
|
"optional": true
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"modernConfig": {
|
|
56
|
-
"output": {
|
|
57
|
-
"packageMode": "node-js"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
55
|
"publishConfig": {
|
|
61
56
|
"registry": "https://registry.npmjs.org/",
|
|
62
57
|
"access": "public"
|