@modern-js/bff-core 1.22.2-beta.0 → 1.22.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/CHANGELOG.md +21 -132
- package/dist/js/modern/api.js +34 -49
- package/dist/js/modern/client/generate-client.js +34 -52
- package/dist/js/modern/client/index.js +1 -1
- package/dist/js/modern/client/result.js +8 -10
- package/dist/js/modern/errors/http.js +14 -8
- package/dist/js/modern/index.js +3 -19
- package/dist/js/modern/operators/http.js +116 -139
- package/dist/js/modern/router/constants.js +13 -31
- package/dist/js/modern/router/index.js +131 -68
- package/dist/js/modern/router/types.js +1 -0
- package/dist/js/modern/router/utils.js +54 -36
- package/dist/js/modern/types.js +47 -45
- package/dist/js/modern/utils/alias.js +50 -35
- package/dist/js/modern/utils/debug.js +2 -5
- package/dist/js/modern/utils/index.js +2 -5
- package/dist/js/modern/utils/meta.js +4 -8
- package/dist/js/modern/utils/storage.js +14 -8
- package/dist/js/modern/utils/validate.js +29 -23
- package/dist/js/node/api.js +46 -78
- package/dist/js/node/client/generate-client.js +55 -85
- package/dist/js/node/client/index.js +18 -17
- package/dist/js/node/client/result.js +18 -32
- package/dist/js/node/errors/http.js +22 -28
- package/dist/js/node/index.js +122 -45
- package/dist/js/node/operators/http.js +169 -184
- package/dist/js/node/router/constants.js +28 -60
- package/dist/js/node/router/index.js +201 -112
- package/dist/js/node/router/types.js +5 -15
- package/dist/js/node/router/utils.js +78 -71
- package/dist/js/node/types.js +57 -71
- package/dist/js/node/utils/alias.js +73 -65
- package/dist/js/node/utils/debug.js +10 -27
- package/dist/js/node/utils/index.js +68 -28
- package/dist/js/node/utils/meta.js +12 -30
- package/dist/js/node/utils/storage.js +24 -36
- package/dist/js/node/utils/validate.js +44 -50
- package/package.json +40 -12
package/dist/js/node/types.js
CHANGED
|
@@ -1,73 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 types_exports = {};
|
|
19
|
-
__export(types_exports, {
|
|
20
|
-
HttpMetadata: () => HttpMetadata,
|
|
21
|
-
HttpMethod: () => HttpMethod,
|
|
22
|
-
OperatorType: () => OperatorType,
|
|
23
|
-
ResponseMetaType: () => ResponseMetaType,
|
|
24
|
-
TriggerType: () => TriggerType,
|
|
25
|
-
httpMethods: () => httpMethods
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
26
5
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
6
|
+
exports.httpMethods = exports.TriggerType = exports.ResponseMetaType = exports.OperatorType = exports.HttpMethod = exports.HttpMetadata = void 0;
|
|
7
|
+
let OperatorType;
|
|
8
|
+
exports.OperatorType = OperatorType;
|
|
9
|
+
|
|
10
|
+
(function (OperatorType) {
|
|
11
|
+
OperatorType[OperatorType["Trigger"] = 0] = "Trigger";
|
|
12
|
+
OperatorType[OperatorType["Middleware"] = 1] = "Middleware";
|
|
13
|
+
})(OperatorType || (exports.OperatorType = OperatorType = {}));
|
|
14
|
+
|
|
15
|
+
let TriggerType;
|
|
16
|
+
exports.TriggerType = TriggerType;
|
|
17
|
+
|
|
18
|
+
(function (TriggerType) {
|
|
19
|
+
TriggerType[TriggerType["Http"] = 0] = "Http";
|
|
20
|
+
})(TriggerType || (exports.TriggerType = TriggerType = {}));
|
|
21
|
+
|
|
22
|
+
let HttpMetadata;
|
|
23
|
+
exports.HttpMetadata = HttpMetadata;
|
|
24
|
+
|
|
25
|
+
(function (HttpMetadata) {
|
|
26
|
+
HttpMetadata["Method"] = "METHOD";
|
|
27
|
+
HttpMetadata["Data"] = "DATA";
|
|
28
|
+
HttpMetadata["Query"] = "QUERY";
|
|
29
|
+
HttpMetadata["Params"] = "PARAMS";
|
|
30
|
+
HttpMetadata["Headers"] = "HEADERS";
|
|
31
|
+
HttpMetadata["Response"] = "RESPONSE";
|
|
32
|
+
})(HttpMetadata || (exports.HttpMetadata = HttpMetadata = {}));
|
|
33
|
+
|
|
34
|
+
let ResponseMetaType;
|
|
35
|
+
exports.ResponseMetaType = ResponseMetaType;
|
|
36
|
+
|
|
37
|
+
(function (ResponseMetaType) {
|
|
38
|
+
ResponseMetaType[ResponseMetaType["StatusCode"] = 0] = "StatusCode";
|
|
39
|
+
ResponseMetaType[ResponseMetaType["Redirect"] = 1] = "Redirect";
|
|
40
|
+
ResponseMetaType[ResponseMetaType["Headers"] = 2] = "Headers";
|
|
41
|
+
})(ResponseMetaType || (exports.ResponseMetaType = ResponseMetaType = {}));
|
|
42
|
+
|
|
43
|
+
let HttpMethod;
|
|
44
|
+
exports.HttpMethod = HttpMethod;
|
|
45
|
+
|
|
46
|
+
(function (HttpMethod) {
|
|
47
|
+
HttpMethod["Get"] = "GET";
|
|
48
|
+
HttpMethod["Post"] = "POST";
|
|
49
|
+
HttpMethod["Put"] = "PUT";
|
|
50
|
+
HttpMethod["Delete"] = "DELETE";
|
|
51
|
+
HttpMethod["Connect"] = "CONNECT";
|
|
52
|
+
HttpMethod["Trace"] = "TRACE";
|
|
53
|
+
HttpMethod["Patch"] = "PATCH";
|
|
54
|
+
HttpMethod["Option"] = "OPTION";
|
|
55
|
+
HttpMethod["Head"] = "HEAD";
|
|
56
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
57
|
+
|
|
64
58
|
const httpMethods = Object.values(HttpMethod);
|
|
65
|
-
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
HttpMetadata,
|
|
68
|
-
HttpMethod,
|
|
69
|
-
OperatorType,
|
|
70
|
-
ResponseMetaType,
|
|
71
|
-
TriggerType,
|
|
72
|
-
httpMethods
|
|
73
|
-
});
|
|
59
|
+
exports.httpMethods = httpMethods;
|
|
@@ -1,107 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
29
5
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
6
|
+
exports.registerPaths = exports.getRelativeRuntimePath = exports.createMatchPath = void 0;
|
|
7
|
+
|
|
8
|
+
var path = _interopRequireWildcard(require("path"));
|
|
9
|
+
|
|
10
|
+
var os = _interopRequireWildcard(require("os"));
|
|
11
|
+
|
|
12
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
+
|
|
14
|
+
var _module = _interopRequireDefault(require("module"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
35
22
|
const getRelativeRuntimePath = (appDirectory, serverRuntimePath) => {
|
|
36
|
-
let relativeRuntimePath =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)}`;
|
|
23
|
+
let relativeRuntimePath = '';
|
|
24
|
+
|
|
25
|
+
if (os.platform() === 'win32') {
|
|
26
|
+
// isRelative function in babel-plugin-resolver plugin can't handle windows relative path correctly, see babel-plugin-resolver's utils.
|
|
27
|
+
relativeRuntimePath = `../${path.relative(appDirectory, serverRuntimePath)}`;
|
|
42
28
|
} else {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
path.relative(appDirectory, serverRuntimePath)
|
|
46
|
-
);
|
|
29
|
+
// Look up one level, because the artifacts after build have dist directories
|
|
30
|
+
relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
47
31
|
}
|
|
48
|
-
|
|
32
|
+
|
|
33
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
49
34
|
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
50
35
|
}
|
|
36
|
+
|
|
51
37
|
return relativeRuntimePath;
|
|
52
38
|
};
|
|
53
|
-
|
|
39
|
+
|
|
40
|
+
exports.getRelativeRuntimePath = getRelativeRuntimePath;
|
|
41
|
+
|
|
42
|
+
const sortByLongestPrefix = arr => {
|
|
54
43
|
return arr.concat().sort((a, b) => b.length - a.length);
|
|
55
44
|
};
|
|
56
|
-
|
|
45
|
+
|
|
46
|
+
const createMatchPath = paths => {
|
|
57
47
|
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
58
48
|
const sortedPaths = {};
|
|
59
|
-
sortedKeys.forEach(
|
|
49
|
+
sortedKeys.forEach(key => {
|
|
60
50
|
sortedPaths[key] = paths[key];
|
|
61
51
|
});
|
|
62
|
-
return
|
|
63
|
-
const found = Object.keys(sortedPaths).find(
|
|
52
|
+
return request => {
|
|
53
|
+
const found = Object.keys(sortedPaths).find(key => {
|
|
64
54
|
return request.startsWith(key);
|
|
65
55
|
});
|
|
56
|
+
|
|
66
57
|
if (found) {
|
|
67
58
|
let foundPaths = sortedPaths[found];
|
|
59
|
+
|
|
68
60
|
if (!Array.isArray(foundPaths)) {
|
|
69
61
|
foundPaths = [foundPaths];
|
|
70
62
|
}
|
|
71
|
-
|
|
63
|
+
|
|
64
|
+
foundPaths = foundPaths.filter(foundPath => path.isAbsolute(foundPath));
|
|
65
|
+
|
|
72
66
|
for (const p of foundPaths) {
|
|
73
67
|
const foundPath = request.replace(found, p);
|
|
74
|
-
|
|
68
|
+
|
|
69
|
+
if (_fs.default.existsSync(foundPath)) {
|
|
75
70
|
return foundPath;
|
|
76
71
|
}
|
|
77
72
|
}
|
|
73
|
+
|
|
78
74
|
return request.replace(found, foundPaths[0]);
|
|
79
75
|
}
|
|
76
|
+
|
|
80
77
|
return null;
|
|
81
78
|
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
}; // every path must be a absolute path;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
exports.createMatchPath = createMatchPath;
|
|
83
|
+
|
|
84
|
+
const registerPaths = paths => {
|
|
85
|
+
const originalResolveFilename = _module.default._resolveFilename; // eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
86
|
+
|
|
87
|
+
const {
|
|
88
|
+
builtinModules
|
|
89
|
+
} = _module.default;
|
|
86
90
|
const matchPath = createMatchPath(paths);
|
|
87
|
-
|
|
91
|
+
|
|
92
|
+
_module.default._resolveFilename = function (request, _parent) {
|
|
88
93
|
const isCoreModule = builtinModules.includes(request);
|
|
94
|
+
|
|
89
95
|
if (!isCoreModule) {
|
|
90
96
|
const matched = matchPath(request);
|
|
97
|
+
|
|
91
98
|
if (matched) {
|
|
92
|
-
|
|
99
|
+
// eslint-disable-next-line prefer-rest-params
|
|
100
|
+
const modifiedArguments = [matched, ...[].slice.call(arguments, 1)]; // Passes all arguments. Even those that is not specified above.
|
|
101
|
+
|
|
93
102
|
return originalResolveFilename.apply(this, modifiedArguments);
|
|
94
103
|
}
|
|
95
|
-
}
|
|
104
|
+
} // eslint-disable-next-line prefer-rest-params
|
|
105
|
+
|
|
106
|
+
|
|
96
107
|
return originalResolveFilename.apply(this, arguments);
|
|
97
108
|
};
|
|
109
|
+
|
|
98
110
|
return () => {
|
|
99
|
-
|
|
111
|
+
_module.default._resolveFilename = originalResolveFilename;
|
|
100
112
|
};
|
|
101
113
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
createMatchPath,
|
|
105
|
-
getRelativeRuntimePath,
|
|
106
|
-
registerPaths
|
|
107
|
-
});
|
|
114
|
+
|
|
115
|
+
exports.registerPaths = registerPaths;
|
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
28
5
|
});
|
|
6
|
+
exports.debug = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
const debug = (0, _utils.createDebugger)('bff');
|
|
11
|
+
exports.debug = debug;
|
|
@@ -1,32 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
debug: true
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
+
Object.defineProperty(exports, "debug", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _debug.debug;
|
|
14
13
|
}
|
|
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
|
|
22
14
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
|
|
16
|
+
var _storage = require("./storage");
|
|
17
|
+
|
|
18
|
+
Object.keys(_storage).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _storage[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return _storage[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
var _alias = require("./alias");
|
|
31
|
+
|
|
32
|
+
Object.keys(_alias).forEach(function (key) {
|
|
33
|
+
if (key === "default" || key === "__esModule") return;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
35
|
+
if (key in exports && exports[key] === _alias[key]) return;
|
|
36
|
+
Object.defineProperty(exports, key, {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _alias[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var _debug = require("./debug");
|
|
45
|
+
|
|
46
|
+
var _meta = require("./meta");
|
|
47
|
+
|
|
48
|
+
Object.keys(_meta).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
51
|
+
if (key in exports && exports[key] === _meta[key]) return;
|
|
52
|
+
Object.defineProperty(exports, key, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return _meta[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
32
58
|
});
|
|
59
|
+
|
|
60
|
+
var _validate = require("./validate");
|
|
61
|
+
|
|
62
|
+
Object.keys(_validate).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
65
|
+
if (key in exports && exports[key] === _validate[key]) return;
|
|
66
|
+
Object.defineProperty(exports, key, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _validate[key];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
22
5
|
});
|
|
23
|
-
|
|
24
|
-
const HANDLER_WITH_META =
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
exports.isWithMetaHandler = exports.HANDLER_WITH_META = void 0;
|
|
7
|
+
const HANDLER_WITH_META = 'HANDLER_WITH_META';
|
|
8
|
+
exports.HANDLER_WITH_META = HANDLER_WITH_META;
|
|
9
|
+
|
|
10
|
+
const isWithMetaHandler = handler => {
|
|
11
|
+
return typeof handler === 'function' && handler[HANDLER_WITH_META];
|
|
27
12
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
HANDLER_WITH_META,
|
|
31
|
-
isWithMetaHandler
|
|
32
|
-
});
|
|
13
|
+
|
|
14
|
+
exports.isWithMetaHandler = isWithMetaHandler;
|
|
@@ -1,42 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
27
5
|
});
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
exports.createStorage = void 0;
|
|
7
|
+
|
|
8
|
+
var ah = _interopRequireWildcard(require("async_hooks"));
|
|
9
|
+
|
|
10
|
+
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); }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
30
14
|
const createStorage = () => {
|
|
31
15
|
let storage;
|
|
32
|
-
|
|
16
|
+
|
|
17
|
+
if (typeof ah.AsyncLocalStorage !== 'undefined') {
|
|
33
18
|
storage = new ah.AsyncLocalStorage();
|
|
34
19
|
}
|
|
20
|
+
|
|
35
21
|
const run = (context, cb) => {
|
|
36
22
|
if (!storage) {
|
|
37
23
|
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
38
24
|
`);
|
|
39
25
|
}
|
|
26
|
+
|
|
40
27
|
return new Promise((resolve, reject) => {
|
|
41
28
|
storage.run(context, () => {
|
|
42
29
|
try {
|
|
@@ -47,25 +34,26 @@ const createStorage = () => {
|
|
|
47
34
|
});
|
|
48
35
|
});
|
|
49
36
|
};
|
|
37
|
+
|
|
50
38
|
const useContext = () => {
|
|
51
39
|
if (!storage) {
|
|
52
40
|
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
53
41
|
`);
|
|
54
42
|
}
|
|
43
|
+
|
|
55
44
|
const context = storage.getStore();
|
|
45
|
+
|
|
56
46
|
if (!context) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
`Can't call useContext out of scope, it should be placed in the bff function`
|
|
59
|
-
);
|
|
47
|
+
throw new Error(`Can't call useContext out of scope, it should be placed in the bff function`);
|
|
60
48
|
}
|
|
49
|
+
|
|
61
50
|
return context;
|
|
62
51
|
};
|
|
52
|
+
|
|
63
53
|
return {
|
|
64
54
|
run,
|
|
65
55
|
useContext
|
|
66
56
|
};
|
|
67
57
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
createStorage
|
|
71
|
-
});
|
|
58
|
+
|
|
59
|
+
exports.createStorage = createStorage;
|