@modern-js/bff-core 2.11.0 → 2.11.1-alpha.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/dist/js/modern/api.js +69 -0
- package/dist/js/modern/client/generate-client.js +79 -0
- package/dist/js/modern/client/index.js +1 -0
- package/dist/js/modern/client/result.js +22 -0
- package/dist/js/modern/errors/http.js +16 -0
- package/dist/js/modern/index.js +23 -0
- package/dist/js/modern/operators/http.js +210 -0
- package/dist/js/modern/router/constants.js +32 -0
- package/dist/js/modern/router/index.js +236 -0
- package/dist/js/modern/router/types.js +0 -0
- package/dist/js/modern/router/utils.js +83 -0
- package/dist/js/modern/types.js +45 -0
- package/dist/js/modern/utils/alias.js +76 -0
- package/dist/js/modern/utils/debug.js +5 -0
- package/dist/js/modern/utils/index.js +8 -0
- package/dist/js/modern/utils/meta.js +8 -0
- package/dist/js/modern/utils/storage.js +42 -0
- package/dist/js/modern/utils/validate.js +43 -0
- package/dist/js/node/api.js +98 -0
- package/dist/js/node/client/generate-client.js +109 -0
- package/dist/js/node/client/index.js +17 -0
- package/dist/js/node/client/result.js +46 -0
- package/dist/js/node/errors/http.js +40 -0
- package/dist/js/node/index.js +48 -0
- package/dist/js/node/operators/http.js +241 -0
- package/dist/js/node/router/constants.js +61 -0
- package/dist/js/node/router/index.js +256 -0
- package/dist/js/node/router/types.js +15 -0
- package/dist/js/node/router/utils.js +116 -0
- package/dist/js/node/types.js +73 -0
- package/dist/js/node/utils/alias.js +107 -0
- package/dist/js/node/utils/debug.js +28 -0
- package/dist/js/node/utils/index.js +32 -0
- package/dist/js/node/utils/meta.js +32 -0
- package/dist/js/node/utils/storage.js +71 -0
- package/dist/js/node/utils/validate.js +74 -0
- package/package.json +5 -5
|
@@ -0,0 +1,73 @@
|
|
|
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
|
|
26
|
+
});
|
|
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 || {});
|
|
64
|
+
const httpMethods = Object.values(HttpMethod);
|
|
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
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
|
29
|
+
});
|
|
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"));
|
|
35
|
+
const getRelativeRuntimePath = (appDirectory, serverRuntimePath) => {
|
|
36
|
+
let relativeRuntimePath = "";
|
|
37
|
+
if (os.platform() === "win32") {
|
|
38
|
+
relativeRuntimePath = `../${path.relative(
|
|
39
|
+
appDirectory,
|
|
40
|
+
serverRuntimePath
|
|
41
|
+
)}`;
|
|
42
|
+
} else {
|
|
43
|
+
relativeRuntimePath = path.join(
|
|
44
|
+
"../",
|
|
45
|
+
path.relative(appDirectory, serverRuntimePath)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
|
|
49
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
50
|
+
}
|
|
51
|
+
return relativeRuntimePath;
|
|
52
|
+
};
|
|
53
|
+
const sortByLongestPrefix = (arr) => {
|
|
54
|
+
return arr.concat().sort((a, b) => b.length - a.length);
|
|
55
|
+
};
|
|
56
|
+
const createMatchPath = (paths) => {
|
|
57
|
+
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
58
|
+
const sortedPaths = {};
|
|
59
|
+
sortedKeys.forEach((key) => {
|
|
60
|
+
sortedPaths[key] = paths[key];
|
|
61
|
+
});
|
|
62
|
+
return (request) => {
|
|
63
|
+
const found = Object.keys(sortedPaths).find((key) => {
|
|
64
|
+
return request.startsWith(key);
|
|
65
|
+
});
|
|
66
|
+
if (found) {
|
|
67
|
+
let foundPaths = sortedPaths[found];
|
|
68
|
+
if (!Array.isArray(foundPaths)) {
|
|
69
|
+
foundPaths = [foundPaths];
|
|
70
|
+
}
|
|
71
|
+
foundPaths = foundPaths.filter((foundPath) => path.isAbsolute(foundPath));
|
|
72
|
+
for (const p of foundPaths) {
|
|
73
|
+
const foundPath = request.replace(found, p);
|
|
74
|
+
if (import_fs.default.existsSync(foundPath)) {
|
|
75
|
+
return foundPath;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return request.replace(found, foundPaths[0]);
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const registerPaths = (paths) => {
|
|
84
|
+
const originalResolveFilename = import_module.default._resolveFilename;
|
|
85
|
+
const { builtinModules } = import_module.default;
|
|
86
|
+
const matchPath = createMatchPath(paths);
|
|
87
|
+
import_module.default._resolveFilename = function(request, _parent) {
|
|
88
|
+
const isCoreModule = builtinModules.includes(request);
|
|
89
|
+
if (!isCoreModule) {
|
|
90
|
+
const matched = matchPath(request);
|
|
91
|
+
if (matched) {
|
|
92
|
+
const modifiedArguments = [matched, ...[].slice.call(arguments, 1)];
|
|
93
|
+
return originalResolveFilename.apply(this, modifiedArguments);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return originalResolveFilename.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
return () => {
|
|
99
|
+
import_module.default._resolveFilename = originalResolveFilename;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
createMatchPath,
|
|
105
|
+
getRelativeRuntimePath,
|
|
106
|
+
registerPaths
|
|
107
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
28
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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 __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
|
+
});
|
|
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
|
|
32
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
22
|
+
});
|
|
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];
|
|
27
|
+
};
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
HANDLER_WITH_META,
|
|
31
|
+
isWithMetaHandler
|
|
32
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(storage_exports);
|
|
29
|
+
var ah = __toESM(require("async_hooks"));
|
|
30
|
+
const createStorage = () => {
|
|
31
|
+
let storage;
|
|
32
|
+
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
|
33
|
+
storage = new ah.AsyncLocalStorage();
|
|
34
|
+
}
|
|
35
|
+
const run = (context, cb) => {
|
|
36
|
+
if (!storage) {
|
|
37
|
+
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
storage.run(context, () => {
|
|
42
|
+
try {
|
|
43
|
+
return resolve(cb());
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return reject(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const useContext = () => {
|
|
51
|
+
if (!storage) {
|
|
52
|
+
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
|
53
|
+
`);
|
|
54
|
+
}
|
|
55
|
+
const context = storage.getStore();
|
|
56
|
+
if (!context) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Can't call useContext out of scope, it should be placed in the bff function`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return context;
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
run,
|
|
65
|
+
useContext
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
createStorage
|
|
71
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(validate_exports);
|
|
31
|
+
var import_util = __toESM(require("util"));
|
|
32
|
+
const getTypeErrorMessage = (actual) => {
|
|
33
|
+
var _a;
|
|
34
|
+
let msg = "";
|
|
35
|
+
if (actual == null) {
|
|
36
|
+
msg += `. Received ${actual}`;
|
|
37
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
38
|
+
msg += `. Received function ${actual.name}`;
|
|
39
|
+
} else if (typeof actual === "object") {
|
|
40
|
+
if ((_a = actual.constructor) == null ? void 0 : _a.name) {
|
|
41
|
+
msg += `. Received an instance of ${actual.constructor.name}`;
|
|
42
|
+
} else {
|
|
43
|
+
const inspected = import_util.default.inspect(actual, { depth: -1 });
|
|
44
|
+
msg += `. Received ${inspected}`;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
let inspected = import_util.default.inspect(actual, { colors: false });
|
|
48
|
+
if (inspected.length > 25) {
|
|
49
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
50
|
+
}
|
|
51
|
+
msg += `. Received type ${typeof actual} (${inspected})`;
|
|
52
|
+
}
|
|
53
|
+
return msg;
|
|
54
|
+
};
|
|
55
|
+
class ERR_INVALID_ARG_TYPE extends Error {
|
|
56
|
+
constructor(funcName, expectedType, actual) {
|
|
57
|
+
const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
|
|
58
|
+
actual
|
|
59
|
+
)}`;
|
|
60
|
+
super(message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const validateFunction = (maybeFunc, name) => {
|
|
64
|
+
if (typeof maybeFunc !== "function") {
|
|
65
|
+
throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
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": "2.11.0",
|
|
14
|
+
"version": "2.11.1-alpha.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@babel/runtime": "^7.18.0",
|
|
28
28
|
"koa-compose": "^4.1.0",
|
|
29
29
|
"reflect-metadata": "^0.1.13",
|
|
30
|
-
"@modern-js/
|
|
31
|
-
"@modern-js/
|
|
30
|
+
"@modern-js/utils": "2.11.0",
|
|
31
|
+
"@modern-js/bff-runtime": "2.11.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"typescript": "^4",
|
|
42
42
|
"zod": "^3.17.3",
|
|
43
43
|
"@modern-js/types": "2.11.0",
|
|
44
|
-
"@scripts/
|
|
45
|
-
"@scripts/
|
|
44
|
+
"@scripts/jest-config": "2.11.0",
|
|
45
|
+
"@scripts/build": "2.11.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^3.17.3",
|