@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.
Files changed (38) hide show
  1. package/CHANGELOG.md +21 -132
  2. package/dist/js/modern/api.js +34 -49
  3. package/dist/js/modern/client/generate-client.js +34 -52
  4. package/dist/js/modern/client/index.js +1 -1
  5. package/dist/js/modern/client/result.js +8 -10
  6. package/dist/js/modern/errors/http.js +14 -8
  7. package/dist/js/modern/index.js +3 -19
  8. package/dist/js/modern/operators/http.js +116 -139
  9. package/dist/js/modern/router/constants.js +13 -31
  10. package/dist/js/modern/router/index.js +131 -68
  11. package/dist/js/modern/router/types.js +1 -0
  12. package/dist/js/modern/router/utils.js +54 -36
  13. package/dist/js/modern/types.js +47 -45
  14. package/dist/js/modern/utils/alias.js +50 -35
  15. package/dist/js/modern/utils/debug.js +2 -5
  16. package/dist/js/modern/utils/index.js +2 -5
  17. package/dist/js/modern/utils/meta.js +4 -8
  18. package/dist/js/modern/utils/storage.js +14 -8
  19. package/dist/js/modern/utils/validate.js +29 -23
  20. package/dist/js/node/api.js +46 -78
  21. package/dist/js/node/client/generate-client.js +55 -85
  22. package/dist/js/node/client/index.js +18 -17
  23. package/dist/js/node/client/result.js +18 -32
  24. package/dist/js/node/errors/http.js +22 -28
  25. package/dist/js/node/index.js +122 -45
  26. package/dist/js/node/operators/http.js +169 -184
  27. package/dist/js/node/router/constants.js +28 -60
  28. package/dist/js/node/router/index.js +201 -112
  29. package/dist/js/node/router/types.js +5 -15
  30. package/dist/js/node/router/utils.js +78 -71
  31. package/dist/js/node/types.js +57 -71
  32. package/dist/js/node/utils/alias.js +73 -65
  33. package/dist/js/node/utils/debug.js +10 -27
  34. package/dist/js/node/utils/index.js +68 -28
  35. package/dist/js/node/utils/meta.js +12 -30
  36. package/dist/js/node/utils/storage.js +24 -36
  37. package/dist/js/node/utils/validate.js +44 -50
  38. package/package.json +40 -12
@@ -1,74 +1,68 @@
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
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
29
5
  });
30
- module.exports = __toCommonJS(validate_exports);
31
- var import_util = __toESM(require("util"));
32
- const getTypeErrorMessage = (actual) => {
33
- var _a;
34
- let msg = "";
6
+ exports.validateFunction = exports.getTypeErrorMessage = exports.ERR_INVALID_ARG_TYPE = void 0;
7
+
8
+ var _util = _interopRequireDefault(require("util"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ // fork from https://github.com/nodejs/node/blob/master/lib/internal/errors.js
13
+ const getTypeErrorMessage = actual => {
14
+ let msg = '';
15
+
35
16
  if (actual == null) {
36
17
  msg += `. Received ${actual}`;
37
- } else if (typeof actual === "function" && actual.name) {
18
+ } else if (typeof actual === 'function' && actual.name) {
38
19
  msg += `. Received function ${actual.name}`;
39
- } else if (typeof actual === "object") {
40
- if ((_a = actual.constructor) == null ? void 0 : _a.name) {
20
+ } else if (typeof actual === 'object') {
21
+ var _actual$constructor;
22
+
23
+ if ((_actual$constructor = actual.constructor) !== null && _actual$constructor !== void 0 && _actual$constructor.name) {
41
24
  msg += `. Received an instance of ${actual.constructor.name}`;
42
25
  } else {
43
- const inspected = import_util.default.inspect(actual, { depth: -1 });
26
+ const inspected = _util.default.inspect(actual, {
27
+ depth: -1
28
+ });
29
+
44
30
  msg += `. Received ${inspected}`;
45
31
  }
46
32
  } else {
47
- let inspected = import_util.default.inspect(actual, { colors: false });
33
+ let inspected = _util.default.inspect(actual, {
34
+ colors: false
35
+ });
36
+
48
37
  if (inspected.length > 25) {
49
38
  inspected = `${inspected.slice(0, 25)}...`;
50
39
  }
40
+
51
41
  msg += `. Received type ${typeof actual} (${inspected})`;
52
42
  }
43
+
53
44
  return msg;
54
- };
45
+ }; // eslint-disable-next-line @typescript-eslint/naming-convention
46
+
47
+
48
+ exports.getTypeErrorMessage = getTypeErrorMessage;
49
+
55
50
  class ERR_INVALID_ARG_TYPE extends Error {
56
51
  constructor(funcName, expectedType, actual) {
57
- const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(
58
- actual
59
- )}`;
52
+ const message = `[ERR_INVALID_ARG_TYPE]: The '${funcName}' argument must be of type ${expectedType}${getTypeErrorMessage(actual)}`;
60
53
  super(message);
61
54
  }
55
+
62
56
  }
57
+
58
+ exports.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
59
+
63
60
  const validateFunction = (maybeFunc, name) => {
64
- if (typeof maybeFunc !== "function") {
65
- throw new ERR_INVALID_ARG_TYPE(name, "function", maybeFunc);
61
+ if (typeof maybeFunc !== 'function') {
62
+ throw new ERR_INVALID_ARG_TYPE(name, 'function', maybeFunc);
66
63
  }
64
+
67
65
  return true;
68
66
  };
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
- });
67
+
68
+ exports.validateFunction = validateFunction;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.22.2-beta.0",
14
+ "version": "1.22.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -26,23 +26,23 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.18.0",
29
- "@modern-js/bff-runtime": "2.0.0-beta.4",
30
- "@modern-js/utils": "2.0.0-beta.4",
31
- "esbuild": "0.15.7",
29
+ "esbuild": "^0.14.38",
32
30
  "esbuild-register": "^3.3.3",
33
31
  "koa-compose": "^4.1.0",
34
- "reflect-metadata": "^0.1.13"
32
+ "reflect-metadata": "^0.1.13",
33
+ "@modern-js/bff-runtime": "1.22.2",
34
+ "@modern-js/utils": "1.22.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@scripts/build": "2.0.0-beta.4",
38
- "@scripts/jest-config": "2.0.0-beta.4",
39
37
  "@types/jest": "^27",
40
38
  "@types/koa-compose": "^3.2.5",
41
39
  "@types/node": "^14",
42
40
  "jest": "^27",
43
- "type-fest": "2.15.0",
41
+ "type-fest": "^2.13.0",
44
42
  "typescript": "^4",
45
- "zod": "^3.17.3"
43
+ "zod": "^3.17.3",
44
+ "@scripts/build": "1.22.2",
45
+ "@scripts/jest-config": "1.22.2"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "zod": "^3.17.3"
@@ -52,13 +52,41 @@
52
52
  "optional": true
53
53
  }
54
54
  },
55
+ "modernConfig": {
56
+ "output": {
57
+ "packageMode": "node-js"
58
+ }
59
+ },
55
60
  "publishConfig": {
56
61
  "registry": "https://registry.npmjs.org/",
57
62
  "access": "public"
58
63
  },
64
+ "wireit": {
65
+ "build": {
66
+ "command": "modern build",
67
+ "files": [
68
+ "src/**/*",
69
+ "tsconfig.json",
70
+ "package.json"
71
+ ],
72
+ "output": [
73
+ "dist/**/*"
74
+ ]
75
+ },
76
+ "test": {
77
+ "command": "jest --passWithNoTests",
78
+ "files": [
79
+ "src/**/*",
80
+ "tsconfig.json",
81
+ "package.json",
82
+ "tests/**/*"
83
+ ],
84
+ "output": []
85
+ }
86
+ },
59
87
  "scripts": {
60
- "new": "modern-lib new",
61
- "build": "modern-lib build",
62
- "test": "jest --passWithNoTests"
88
+ "new": "modern new",
89
+ "build": "wireit",
90
+ "test": "wireit"
63
91
  }
64
92
  }