@modern-js/bff-core 2.7.1-alpha.6 → 2.9.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 +18 -0
- package/package.json +8 -8
- package/dist/js/modern/api.js +0 -69
- package/dist/js/modern/client/generate-client.js +0 -79
- package/dist/js/modern/client/index.js +0 -1
- package/dist/js/modern/client/result.js +0 -22
- package/dist/js/modern/errors/http.js +0 -16
- package/dist/js/modern/index.js +0 -23
- package/dist/js/modern/operators/http.js +0 -210
- package/dist/js/modern/router/constants.js +0 -32
- package/dist/js/modern/router/index.js +0 -236
- package/dist/js/modern/router/types.js +0 -0
- package/dist/js/modern/router/utils.js +0 -83
- package/dist/js/modern/types.js +0 -45
- package/dist/js/modern/utils/alias.js +0 -76
- package/dist/js/modern/utils/debug.js +0 -5
- package/dist/js/modern/utils/index.js +0 -8
- package/dist/js/modern/utils/meta.js +0 -8
- package/dist/js/modern/utils/storage.js +0 -42
- package/dist/js/modern/utils/validate.js +0 -43
- package/dist/js/node/api.js +0 -98
- package/dist/js/node/client/generate-client.js +0 -109
- package/dist/js/node/client/index.js +0 -17
- package/dist/js/node/client/result.js +0 -46
- package/dist/js/node/errors/http.js +0 -40
- package/dist/js/node/index.js +0 -48
- package/dist/js/node/operators/http.js +0 -241
- package/dist/js/node/router/constants.js +0 -61
- package/dist/js/node/router/index.js +0 -256
- package/dist/js/node/router/types.js +0 -15
- package/dist/js/node/router/utils.js +0 -116
- package/dist/js/node/types.js +0 -73
- package/dist/js/node/utils/alias.js +0 -107
- package/dist/js/node/utils/debug.js +0 -28
- package/dist/js/node/utils/index.js +0 -32
- package/dist/js/node/utils/meta.js +0 -32
- package/dist/js/node/utils/storage.js +0 -71
- package/dist/js/node/utils/validate.js +0 -74
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
});
|