@modern-js/bff-core 2.35.1 → 2.37.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/cjs/api.js +40 -14
- package/dist/cjs/client/generateClient.js +42 -23
- package/dist/cjs/client/index.js +20 -4
- package/dist/cjs/client/result.js +25 -15
- package/dist/cjs/errors/http.js +28 -18
- package/dist/cjs/index.js +53 -47
- package/dist/cjs/operators/http.js +93 -89
- package/dist/cjs/router/constants.js +37 -32
- package/dist/cjs/router/index.js +94 -65
- package/dist/cjs/router/types.js +15 -3
- package/dist/cjs/router/utils.js +52 -36
- package/dist/cjs/types.js +33 -27
- package/dist/cjs/utils/alias.js +51 -34
- package/dist/cjs/utils/debug.js +26 -9
- package/dist/cjs/utils/index.js +34 -13
- package/dist/cjs/utils/meta.js +29 -21
- package/dist/cjs/utils/storage.js +37 -11
- package/dist/cjs/utils/validate.js +40 -22
- package/dist/esm/api.js +4 -1
- package/dist/esm/client/generateClient.js +6 -2
- package/dist/esm/client/result.js +6 -2
- package/dist/esm/errors/http.js +6 -2
- package/dist/esm/index.js +15 -3
- package/dist/esm/operators/http.js +36 -17
- package/dist/esm/router/constants.js +16 -7
- package/dist/esm/router/index.js +4 -1
- package/dist/esm/router/types.js +0 -1
- package/dist/esm/router/utils.js +12 -5
- package/dist/esm/types.js +14 -6
- package/dist/esm/utils/alias.js +8 -3
- package/dist/esm/utils/debug.js +4 -1
- package/dist/esm/utils/index.js +4 -1
- package/dist/esm/utils/meta.js +10 -4
- package/dist/esm/utils/storage.js +3 -1
- package/dist/esm/utils/validate.js +8 -3
- package/package.json +7 -7
package/dist/cjs/utils/alias.js
CHANGED
|
@@ -1,40 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getRelativeRuntimePath;
|
|
15
|
-
},
|
|
16
|
-
createMatchPath: function() {
|
|
17
|
-
return createMatchPath;
|
|
18
|
-
},
|
|
19
|
-
registerPaths: function() {
|
|
20
|
-
return registerPaths;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var alias_exports = {};
|
|
30
|
+
__export(alias_exports, {
|
|
31
|
+
createMatchPath: () => createMatchPath,
|
|
32
|
+
getRelativeRuntimePath: () => getRelativeRuntimePath,
|
|
33
|
+
registerPaths: () => registerPaths
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const _module = /* @__PURE__ */ _interop_require_default._(require("module"));
|
|
35
|
+
module.exports = __toCommonJS(alias_exports);
|
|
36
|
+
var path = __toESM(require("path"));
|
|
37
|
+
var os = __toESM(require("os"));
|
|
38
|
+
var import_fs = __toESM(require("fs"));
|
|
39
|
+
var import_module = __toESM(require("module"));
|
|
29
40
|
const getRelativeRuntimePath = (appDirectory, serverRuntimePath) => {
|
|
30
41
|
let relativeRuntimePath = "";
|
|
31
|
-
if (
|
|
32
|
-
relativeRuntimePath = `../${
|
|
42
|
+
if (os.platform() === "win32") {
|
|
43
|
+
relativeRuntimePath = `../${path.relative(appDirectory, serverRuntimePath)}`;
|
|
33
44
|
} else {
|
|
34
|
-
relativeRuntimePath =
|
|
45
|
+
relativeRuntimePath = path.join("../", path.relative(appDirectory, serverRuntimePath));
|
|
35
46
|
}
|
|
36
47
|
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
|
|
37
|
-
relativeRuntimePath = `./${
|
|
48
|
+
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
38
49
|
}
|
|
39
50
|
return relativeRuntimePath;
|
|
40
51
|
};
|
|
@@ -58,10 +69,10 @@ const createMatchPath = (paths) => {
|
|
|
58
69
|
foundPaths
|
|
59
70
|
];
|
|
60
71
|
}
|
|
61
|
-
foundPaths = foundPaths.filter((foundPath) =>
|
|
72
|
+
foundPaths = foundPaths.filter((foundPath) => path.isAbsolute(foundPath));
|
|
62
73
|
for (const p of foundPaths) {
|
|
63
74
|
const foundPath = request.replace(found, p);
|
|
64
|
-
if (
|
|
75
|
+
if (import_fs.default.existsSync(foundPath)) {
|
|
65
76
|
return foundPath;
|
|
66
77
|
}
|
|
67
78
|
}
|
|
@@ -71,10 +82,10 @@ const createMatchPath = (paths) => {
|
|
|
71
82
|
};
|
|
72
83
|
};
|
|
73
84
|
const registerPaths = (paths) => {
|
|
74
|
-
const originalResolveFilename =
|
|
75
|
-
const { builtinModules } =
|
|
85
|
+
const originalResolveFilename = import_module.default._resolveFilename;
|
|
86
|
+
const { builtinModules } = import_module.default;
|
|
76
87
|
const matchPath = createMatchPath(paths);
|
|
77
|
-
|
|
88
|
+
import_module.default._resolveFilename = function(request, _parent) {
|
|
78
89
|
const isCoreModule = builtinModules.includes(request);
|
|
79
90
|
if (!isCoreModule) {
|
|
80
91
|
const matched = matchPath(request);
|
|
@@ -89,6 +100,12 @@ const registerPaths = (paths) => {
|
|
|
89
100
|
return originalResolveFilename.apply(this, arguments);
|
|
90
101
|
};
|
|
91
102
|
return () => {
|
|
92
|
-
|
|
103
|
+
import_module.default._resolveFilename = originalResolveFilename;
|
|
93
104
|
};
|
|
94
105
|
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
createMatchPath,
|
|
109
|
+
getRelativeRuntimePath,
|
|
110
|
+
registerPaths
|
|
111
|
+
});
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var debug_exports = {};
|
|
20
|
+
__export(debug_exports, {
|
|
21
|
+
debug: () => debug
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(debug_exports);
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
25
|
+
const debug = (0, import_utils.createDebugger)("bff");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
debug
|
|
10
29
|
});
|
|
11
|
-
const _utils = require("@modern-js/utils");
|
|
12
|
-
const debug = (0, _utils.createDebugger)("bff");
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
debug: () => import_debug.debug
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
__reExport(utils_exports, require("./storage"), module.exports);
|
|
26
|
+
__reExport(utils_exports, require("./alias"), module.exports);
|
|
27
|
+
var import_debug = require("./debug");
|
|
28
|
+
__reExport(utils_exports, require("./meta"), module.exports);
|
|
29
|
+
__reExport(utils_exports, require("./validate"), module.exports);
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
debug,
|
|
33
|
+
...require("./storage"),
|
|
34
|
+
...require("./alias"),
|
|
35
|
+
...require("./meta"),
|
|
36
|
+
...require("./validate")
|
|
10
37
|
});
|
|
11
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
|
12
|
-
_export_star._(require("./storage"), exports);
|
|
13
|
-
_export_star._(require("./alias"), exports);
|
|
14
|
-
const _debug = require("./debug");
|
|
15
|
-
_export_star._(require("./meta"), exports);
|
|
16
|
-
_export_star._(require("./validate"), exports);
|
package/dist/cjs/utils/meta.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return HANDLER_WITH_META;
|
|
15
|
-
},
|
|
16
|
-
INPUT_PARAMS_DECIDER: function() {
|
|
17
|
-
return INPUT_PARAMS_DECIDER;
|
|
18
|
-
},
|
|
19
|
-
isWithMetaHandler: function() {
|
|
20
|
-
return isWithMetaHandler;
|
|
21
|
-
},
|
|
22
|
-
isInputParamsDeciderHandler: function() {
|
|
23
|
-
return isInputParamsDeciderHandler;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var meta_exports = {};
|
|
20
|
+
__export(meta_exports, {
|
|
21
|
+
HANDLER_WITH_META: () => HANDLER_WITH_META,
|
|
22
|
+
INPUT_PARAMS_DECIDER: () => INPUT_PARAMS_DECIDER,
|
|
23
|
+
isInputParamsDeciderHandler: () => isInputParamsDeciderHandler,
|
|
24
|
+
isWithMetaHandler: () => isWithMetaHandler
|
|
25
25
|
});
|
|
26
|
+
module.exports = __toCommonJS(meta_exports);
|
|
26
27
|
const HANDLER_WITH_META = "HANDLER_WITH_META";
|
|
27
28
|
const INPUT_PARAMS_DECIDER = "INPUT_PARAMS_DECIDER";
|
|
28
29
|
const isWithMetaHandler = (handler) => {
|
|
@@ -31,3 +32,10 @@ const isWithMetaHandler = (handler) => {
|
|
|
31
32
|
const isInputParamsDeciderHandler = (handler) => {
|
|
32
33
|
return typeof handler === "function" && handler[INPUT_PARAMS_DECIDER];
|
|
33
34
|
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
HANDLER_WITH_META,
|
|
38
|
+
INPUT_PARAMS_DECIDER,
|
|
39
|
+
isInputParamsDeciderHandler,
|
|
40
|
+
isWithMetaHandler
|
|
41
|
+
});
|
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var storage_exports = {};
|
|
30
|
+
__export(storage_exports, {
|
|
31
|
+
createStorage: () => createStorage
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(storage_exports);
|
|
34
|
+
var ah = __toESM(require("async_hooks"));
|
|
13
35
|
const createStorage = () => {
|
|
14
36
|
let storage;
|
|
15
|
-
if (typeof
|
|
16
|
-
storage = new
|
|
37
|
+
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
|
38
|
+
storage = new ah.AsyncLocalStorage();
|
|
17
39
|
}
|
|
18
40
|
const run = (context, cb) => {
|
|
19
41
|
if (!storage) {
|
|
@@ -46,3 +68,7 @@ const createStorage = () => {
|
|
|
46
68
|
useContext
|
|
47
69
|
};
|
|
48
70
|
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
createStorage
|
|
74
|
+
});
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getTypeErrorMessage;
|
|
15
|
-
},
|
|
16
|
-
ERR_INVALID_ARG_TYPE: function() {
|
|
17
|
-
return ERR_INVALID_ARG_TYPE;
|
|
18
|
-
},
|
|
19
|
-
validateFunction: function() {
|
|
20
|
-
return validateFunction;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var validate_exports = {};
|
|
30
|
+
__export(validate_exports, {
|
|
31
|
+
ERR_INVALID_ARG_TYPE: () => ERR_INVALID_ARG_TYPE,
|
|
32
|
+
getTypeErrorMessage: () => getTypeErrorMessage,
|
|
33
|
+
validateFunction: () => validateFunction
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
module.exports = __toCommonJS(validate_exports);
|
|
36
|
+
var import_util = __toESM(require("util"));
|
|
25
37
|
const getTypeErrorMessage = (actual) => {
|
|
26
38
|
let msg = "";
|
|
27
39
|
if (actual == null) {
|
|
@@ -33,13 +45,13 @@ const getTypeErrorMessage = (actual) => {
|
|
|
33
45
|
if ((_actual_constructor = actual.constructor) === null || _actual_constructor === void 0 ? void 0 : _actual_constructor.name) {
|
|
34
46
|
msg += `. Received an instance of ${actual.constructor.name}`;
|
|
35
47
|
} else {
|
|
36
|
-
const inspected =
|
|
48
|
+
const inspected = import_util.default.inspect(actual, {
|
|
37
49
|
depth: -1
|
|
38
50
|
});
|
|
39
51
|
msg += `. Received ${inspected}`;
|
|
40
52
|
}
|
|
41
53
|
} else {
|
|
42
|
-
let inspected =
|
|
54
|
+
let inspected = import_util.default.inspect(actual, {
|
|
43
55
|
colors: false
|
|
44
56
|
});
|
|
45
57
|
if (inspected.length > 25) {
|
|
@@ -61,3 +73,9 @@ const validateFunction = (maybeFunc, name) => {
|
|
|
61
73
|
}
|
|
62
74
|
return true;
|
|
63
75
|
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
ERR_INVALID_ARG_TYPE,
|
|
79
|
+
getTypeErrorMessage,
|
|
80
|
+
validateFunction
|
|
81
|
+
});
|
package/dist/esm/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import compose from "koa-compose";
|
|
3
3
|
import { validateFunction, HANDLER_WITH_META } from "./utils";
|
|
4
|
-
|
|
4
|
+
function Api(...args) {
|
|
5
5
|
const handler = args.pop();
|
|
6
6
|
validateFunction(handler, "Apihandler");
|
|
7
7
|
const operators = args;
|
|
@@ -45,3 +45,6 @@ export function Api(...args) {
|
|
|
45
45
|
runner[HANDLER_WITH_META] = true;
|
|
46
46
|
return runner;
|
|
47
47
|
}
|
|
48
|
+
export {
|
|
49
|
+
Api
|
|
50
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
2
|
import { ApiRouter } from "../router";
|
|
3
3
|
import { Ok, Err } from "./result";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const DEFAULT_CLIENT_REQUEST_CREATOR = "@modern-js/create-request";
|
|
5
|
+
const generateClient = async ({ appDir, resourcePath, apiDir, lambdaDir, prefix, port, target, requestCreator, fetcher, requireResolve = require.resolve, httpMethodDecider }) => {
|
|
6
6
|
if (!requestCreator) {
|
|
7
7
|
requestCreator = requireResolve(`${DEFAULT_CLIENT_REQUEST_CREATOR}${target ? `/${target}` : ""}`).replace(/\\/g, "/");
|
|
8
8
|
} else {
|
|
@@ -47,3 +47,7 @@ ${fetcher ? `import { fetch } from '${fetcher}';
|
|
|
47
47
|
return Ok(`${importCode}
|
|
48
48
|
${handlersCode}`);
|
|
49
49
|
};
|
|
50
|
+
export {
|
|
51
|
+
DEFAULT_CLIENT_REQUEST_CREATOR,
|
|
52
|
+
generateClient
|
|
53
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const Err = (value) => {
|
|
2
2
|
const err = {
|
|
3
3
|
kind: "Err",
|
|
4
4
|
value,
|
|
@@ -7,7 +7,7 @@ export const Err = (value) => {
|
|
|
7
7
|
};
|
|
8
8
|
return err;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
const Ok = (value) => {
|
|
11
11
|
const ok = {
|
|
12
12
|
kind: "Ok",
|
|
13
13
|
value,
|
|
@@ -16,3 +16,7 @@ export const Ok = (value) => {
|
|
|
16
16
|
};
|
|
17
17
|
return ok;
|
|
18
18
|
};
|
|
19
|
+
export {
|
|
20
|
+
Err,
|
|
21
|
+
Ok
|
|
22
|
+
};
|
package/dist/esm/errors/http.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
|
|
2
|
+
class HttpError extends Error {
|
|
3
3
|
constructor(status, message) {
|
|
4
4
|
super(message);
|
|
5
5
|
_define_property(this, "status", void 0);
|
|
6
6
|
this.status = status;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
class ValidationError extends HttpError {
|
|
10
10
|
constructor(status, message) {
|
|
11
11
|
super(status, message);
|
|
12
12
|
_define_property(this, "code", void 0);
|
|
13
13
|
this.code = "VALIDATION_ERROR";
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
export {
|
|
17
|
+
HttpError,
|
|
18
|
+
ValidationError
|
|
19
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Api } from "./api";
|
|
2
|
+
import { HttpError, ValidationError } from "./errors/http";
|
|
3
3
|
export * from "./router";
|
|
4
4
|
export * from "./types";
|
|
5
5
|
export * from "./client";
|
|
6
6
|
export * from "./operators/http";
|
|
7
|
-
|
|
7
|
+
import { getRelativeRuntimePath, HANDLER_WITH_META, isWithMetaHandler, INPUT_PARAMS_DECIDER, isInputParamsDeciderHandler, createStorage, registerPaths } from "./utils";
|
|
8
|
+
export {
|
|
9
|
+
Api,
|
|
10
|
+
HANDLER_WITH_META,
|
|
11
|
+
HttpError,
|
|
12
|
+
INPUT_PARAMS_DECIDER,
|
|
13
|
+
ValidationError,
|
|
14
|
+
createStorage,
|
|
15
|
+
getRelativeRuntimePath,
|
|
16
|
+
isInputParamsDeciderHandler,
|
|
17
|
+
isWithMetaHandler,
|
|
18
|
+
registerPaths
|
|
19
|
+
};
|
|
@@ -11,7 +11,7 @@ const validateInput = async (schema, input) => {
|
|
|
11
11
|
throw error;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const createHttpOperator = (method) => {
|
|
15
15
|
return (urlPath) => {
|
|
16
16
|
return {
|
|
17
17
|
name: method,
|
|
@@ -25,16 +25,16 @@ export const createHttpOperator = (method) => {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
const Get = createHttpOperator(HttpMethod.Get);
|
|
29
|
+
const Post = createHttpOperator(HttpMethod.Post);
|
|
30
|
+
const Put = createHttpOperator(HttpMethod.Put);
|
|
31
|
+
const Delete = createHttpOperator(HttpMethod.Delete);
|
|
32
|
+
const Connect = createHttpOperator(HttpMethod.Connect);
|
|
33
|
+
const Trace = createHttpOperator(HttpMethod.Trace);
|
|
34
|
+
const Patch = createHttpOperator(HttpMethod.Patch);
|
|
35
|
+
const Options = createHttpOperator(HttpMethod.Options);
|
|
36
|
+
const Head = createHttpOperator(HttpMethod.Head);
|
|
37
|
+
const Data = (schema) => {
|
|
38
38
|
return {
|
|
39
39
|
name: HttpMetadata.Data,
|
|
40
40
|
metadata({ setMetadata }) {
|
|
@@ -50,7 +50,7 @@ export const Data = (schema) => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
const Query = (schema) => {
|
|
54
54
|
return {
|
|
55
55
|
name: HttpMetadata.Query,
|
|
56
56
|
metadata({ setMetadata }) {
|
|
@@ -66,7 +66,7 @@ export const Query = (schema) => {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
const Params = (schema) => {
|
|
70
70
|
return {
|
|
71
71
|
name: HttpMetadata.Params,
|
|
72
72
|
metadata({ setMetadata }) {
|
|
@@ -82,7 +82,7 @@ export const Params = (schema) => {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
|
|
85
|
+
const Headers = (schema) => {
|
|
86
86
|
return {
|
|
87
87
|
name: HttpMetadata.Headers,
|
|
88
88
|
metadata({ setMetadata }) {
|
|
@@ -108,7 +108,7 @@ const setResponseMeta = (helper, type, value) => {
|
|
|
108
108
|
}
|
|
109
109
|
]);
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
const HttpCode = (statusCode) => {
|
|
112
112
|
return {
|
|
113
113
|
name: "HttpCode",
|
|
114
114
|
metadata(helper) {
|
|
@@ -116,7 +116,7 @@ export const HttpCode = (statusCode) => {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
const SetHeaders = (headers) => {
|
|
120
120
|
return {
|
|
121
121
|
name: "SetHeaders",
|
|
122
122
|
metadata(helper) {
|
|
@@ -124,7 +124,7 @@ export const SetHeaders = (headers) => {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
|
-
|
|
127
|
+
const Redirect = (url) => {
|
|
128
128
|
return {
|
|
129
129
|
name: "Redirect",
|
|
130
130
|
metadata(helper) {
|
|
@@ -132,3 +132,22 @@ export const Redirect = (url) => {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
|
+
export {
|
|
136
|
+
Connect,
|
|
137
|
+
Data,
|
|
138
|
+
Delete,
|
|
139
|
+
Get,
|
|
140
|
+
Head,
|
|
141
|
+
Headers,
|
|
142
|
+
HttpCode,
|
|
143
|
+
Options,
|
|
144
|
+
Params,
|
|
145
|
+
Patch,
|
|
146
|
+
Post,
|
|
147
|
+
Put,
|
|
148
|
+
Query,
|
|
149
|
+
Redirect,
|
|
150
|
+
SetHeaders,
|
|
151
|
+
Trace,
|
|
152
|
+
createHttpOperator
|
|
153
|
+
};
|