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