@modern-js/bff-runtime 2.15.0 → 2.16.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @modern-js/bff-runtime
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e876ab: chore: package.json include the monorepo-relative directory
8
+
9
+ chore: 在 package.json 中声明 monorepo 的子路径
10
+
3
11
  ## 2.15.0
4
12
 
5
13
  ## 2.14.0
@@ -1,15 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var compatible_exports = {};
15
- module.exports = __toCommonJS(compatible_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
package/dist/cjs/index.js CHANGED
@@ -1,33 +1,31 @@
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 src_exports = {};
20
- __export(src_exports, {
21
- isHandler: () => import_match.isHandler,
22
- isSchemaHandler: () => import_match.isSchemaHandler,
23
- match: () => import_match.match
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
24
4
  });
25
- module.exports = __toCommonJS(src_exports);
26
- __reExport(src_exports, require("farrow-schema"), module.exports);
27
- var import_match = require("./match");
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- isHandler,
31
- isSchemaHandler,
32
- match
5
+ function _export(target, all) {
6
+ for (var name in all)
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ match: () => _match.match,
14
+ isHandler: () => _match.isHandler,
15
+ isSchemaHandler: () => _match.isSchemaHandler
33
16
  });
17
+ _export_star(require("farrow-schema"), exports);
18
+ const _match = require("./match");
19
+ function _export_star(from, to) {
20
+ Object.keys(from).forEach(function(k) {
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
22
+ Object.defineProperty(to, k, {
23
+ enumerable: true,
24
+ get: function() {
25
+ return from[k];
26
+ }
27
+ });
28
+ }
29
+ });
30
+ return from;
31
+ }
package/dist/cjs/match.js CHANGED
@@ -1,31 +1,23 @@
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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
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 match_exports = {};
19
- __export(match_exports, {
20
- baseMatch: () => baseMatch,
21
- isHandler: () => isHandler,
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
22
13
  isSchemaHandler: () => isSchemaHandler,
14
+ isHandler: () => isHandler,
15
+ baseMatch: () => baseMatch,
23
16
  match: () => match
24
17
  });
25
- module.exports = __toCommonJS(match_exports);
26
- var import_farrow_schema = require("farrow-schema");
27
- var import_validator = require("farrow-schema/validator");
28
- var import_response = require("./response");
18
+ const _farrowschema = require("farrow-schema");
19
+ const _validator = require("farrow-schema/validator");
20
+ const _response = require("./response");
29
21
  const getErrorMessage = (error) => {
30
22
  let { message } = error;
31
23
  if (Array.isArray(error.path) && error.path.length > 0) {
@@ -35,24 +27,24 @@ ${message}`;
35
27
  return message;
36
28
  };
37
29
  const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
38
- const isSchemaHandler = (input) => input && (input == null ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
30
+ const isSchemaHandler = (input) => {
31
+ return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
32
+ };
39
33
  const isHandler = (input) => input && typeof input === "function";
40
34
  const baseMatch = (schema, handler) => {
41
35
  const validateApiInput = createRequestSchemaValidator(schema.request);
42
- const validateApiOutput = (0, import_validator.createSchemaValidator)(
43
- (0, import_farrow_schema.toSchemaCtor)(schema.response)
44
- );
36
+ const validateApiOutput = (0, _validator.createSchemaValidator)((0, _farrowschema.toSchemaCtor)(schema.response));
45
37
  const handle = async (input) => {
46
38
  const inputResult = validateApiInput(input);
47
39
  if (inputResult.isErr) {
48
- return (0, import_response.InputValidationError)(getErrorMessage(inputResult.value));
40
+ return (0, _response.InputValidationError)(getErrorMessage(inputResult.value));
49
41
  }
50
42
  const output = await handler(input);
51
43
  const outputResult = validateApiOutput(output);
52
44
  if (outputResult.isErr) {
53
- return (0, import_response.OutputValidationError)(getErrorMessage(outputResult.value));
45
+ return (0, _response.OutputValidationError)(getErrorMessage(outputResult.value));
54
46
  }
55
- return (0, import_response.HandleSuccess)(output);
47
+ return (0, _response.HandleSuccess)(output);
56
48
  };
57
49
  return Object.assign(handle, {
58
50
  schema,
@@ -77,13 +69,6 @@ const createRequestSchemaValidator = (schema) => {
77
69
  if (schema.cookies) {
78
70
  descriptors.cookies = schema.cookies;
79
71
  }
80
- const RequestStruct = (0, import_farrow_schema.Struct)(descriptors);
81
- return (0, import_validator.createSchemaValidator)((0, import_farrow_schema.NonStrict)(RequestStruct));
72
+ const RequestStruct = (0, _farrowschema.Struct)(descriptors);
73
+ return (0, _validator.createSchemaValidator)((0, _farrowschema.NonStrict)(RequestStruct));
82
74
  };
83
- // Annotate the CommonJS export names for ESM import in node:
84
- 0 && (module.exports = {
85
- baseMatch,
86
- isHandler,
87
- isSchemaHandler,
88
- match
89
- });
@@ -1,15 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var request_exports = {};
15
- module.exports = __toCommonJS(request_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1,27 +1,19 @@
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) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
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 response_exports = {};
19
- __export(response_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
20
13
  HandleSuccess: () => HandleSuccess,
21
14
  InputValidationError: () => InputValidationError,
22
15
  OutputValidationError: () => OutputValidationError
23
16
  });
24
- module.exports = __toCommonJS(response_exports);
25
17
  const HandleSuccess = (output) => ({
26
18
  type: "HandleSuccess",
27
19
  value: output
@@ -34,9 +26,3 @@ const OutputValidationError = (message) => ({
34
26
  type: "OutputValidationError",
35
27
  message
36
28
  });
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- HandleSuccess,
40
- InputValidationError,
41
- OutputValidationError
42
- });
package/dist/cjs/types.js CHANGED
@@ -1,15 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1 +1 @@
1
- "use strict";
1
+ export {};
package/dist/esm/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "farrow-schema";
2
- import { match, isHandler, isSchemaHandler } from "./match";
3
- export { isHandler, isSchemaHandler, match };
2
+ export { match, isHandler, isSchemaHandler } from "./match";
package/dist/esm/match.js CHANGED
@@ -1,220 +1,226 @@
1
1
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
14
  }
15
- function _asyncToGenerator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(void 0);
27
+ });
28
+ };
29
29
  }
30
- function _defineProperty(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
30
+ function _define_property(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
42
  }
43
- var __generator = this && this.__generator || function(thisArg, body) {
44
- var f, y, t, g, _ = {
45
- label: 0,
46
- sent: function() {
47
- if (t[0] & 1) throw t[1];
48
- return t[1];
49
- },
50
- trys: [],
51
- ops: []
43
+ var __generator = function(thisArg, body) {
44
+ var f, y, t, g, _ = {
45
+ label: 0,
46
+ sent: function() {
47
+ if (t[0] & 1)
48
+ throw t[1];
49
+ return t[1];
50
+ },
51
+ trys: [],
52
+ ops: []
53
+ };
54
+ return g = {
55
+ next: verb(0),
56
+ "throw": verb(1),
57
+ "return": verb(2)
58
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
59
+ return this;
60
+ }), g;
61
+ function verb(n) {
62
+ return function(v) {
63
+ return step([
64
+ n,
65
+ v
66
+ ]);
52
67
  };
53
- return(g = {
54
- next: verb(0),
55
- "throw": verb(1),
56
- "return": verb(2)
57
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
58
- return this;
59
- }), g);
60
- function verb(n) {
61
- return function(v) {
62
- return step([
63
- n,
64
- v
65
- ]);
66
- };
67
- }
68
- function step(op) {
69
- if (f) throw new TypeError("Generator is already executing.");
70
- while(_)try {
71
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
72
- if (y = 0, t) op = [
73
- op[0] & 2,
74
- t.value
75
- ];
76
- switch(op[0]){
77
- case 0:
78
- case 1:
79
- t = op;
80
- break;
81
- case 4:
82
- _.label++;
83
- return {
84
- value: op[1],
85
- done: false
86
- };
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [
91
- 0
92
- ];
93
- continue;
94
- case 7:
95
- op = _.ops.pop();
96
- _.trys.pop();
97
- continue;
98
- default:
99
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
100
- _ = 0;
101
- continue;
102
- }
103
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
104
- _.label = op[1];
105
- break;
106
- }
107
- if (op[0] === 6 && _.label < t[1]) {
108
- _.label = t[1];
109
- t = op;
110
- break;
111
- }
112
- if (t && _.label < t[2]) {
113
- _.label = t[2];
114
- _.ops.push(op);
115
- break;
116
- }
117
- if (t[2]) _.ops.pop();
118
- _.trys.pop();
119
- continue;
120
- }
121
- op = body.call(thisArg, _);
122
- } catch (e) {
68
+ }
69
+ function step(op) {
70
+ if (f)
71
+ throw new TypeError("Generator is already executing.");
72
+ while (_)
73
+ try {
74
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
75
+ return t;
76
+ if (y = 0, t)
77
+ op = [
78
+ op[0] & 2,
79
+ t.value
80
+ ];
81
+ switch (op[0]) {
82
+ case 0:
83
+ case 1:
84
+ t = op;
85
+ break;
86
+ case 4:
87
+ _.label++;
88
+ return {
89
+ value: op[1],
90
+ done: false
91
+ };
92
+ case 5:
93
+ _.label++;
94
+ y = op[1];
123
95
  op = [
124
- 6,
125
- e
96
+ 0
126
97
  ];
127
- y = 0;
128
- } finally{
129
- f = t = 0;
98
+ continue;
99
+ case 7:
100
+ op = _.ops.pop();
101
+ _.trys.pop();
102
+ continue;
103
+ default:
104
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
105
+ _ = 0;
106
+ continue;
107
+ }
108
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
109
+ _.label = op[1];
110
+ break;
111
+ }
112
+ if (op[0] === 6 && _.label < t[1]) {
113
+ _.label = t[1];
114
+ t = op;
115
+ break;
116
+ }
117
+ if (t && _.label < t[2]) {
118
+ _.label = t[2];
119
+ _.ops.push(op);
120
+ break;
121
+ }
122
+ if (t[2])
123
+ _.ops.pop();
124
+ _.trys.pop();
125
+ continue;
130
126
  }
131
- if (op[0] & 5) throw op[1];
132
- return {
133
- value: op[0] ? op[1] : void 0,
134
- done: true
135
- };
136
- }
127
+ op = body.call(thisArg, _);
128
+ } catch (e) {
129
+ op = [
130
+ 6,
131
+ e
132
+ ];
133
+ y = 0;
134
+ } finally {
135
+ f = t = 0;
136
+ }
137
+ if (op[0] & 5)
138
+ throw op[1];
139
+ return {
140
+ value: op[0] ? op[1] : void 0,
141
+ done: true
142
+ };
143
+ }
137
144
  };
138
145
  import { toSchemaCtor, Struct, NonStrict } from "farrow-schema";
139
146
  import { createSchemaValidator } from "farrow-schema/validator";
140
147
  import { HandleSuccess, InputValidationError, OutputValidationError } from "./response";
141
148
  var getErrorMessage = function(error) {
142
- var message = error.message;
143
- if (Array.isArray(error.path) && error.path.length > 0) {
144
- message = "path: ".concat(JSON.stringify(error.path), "\n").concat(message);
145
- }
146
- return message;
149
+ var message = error.message;
150
+ if (Array.isArray(error.path) && error.path.length > 0) {
151
+ message = "path: ".concat(JSON.stringify(error.path), "\n").concat(message);
152
+ }
153
+ return message;
147
154
  };
148
155
  var HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
149
- var isSchemaHandler = function(input) {
150
- return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
156
+ export var isSchemaHandler = function(input) {
157
+ return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
151
158
  };
152
- var isHandler = function(input) {
153
- return input && typeof input === "function";
159
+ export var isHandler = function(input) {
160
+ return input && typeof input === "function";
154
161
  };
155
- var baseMatch = function(schema, handler) {
156
- var validateApiInput = createRequestSchemaValidator(schema.request);
157
- var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
158
- var handle = function() {
159
- var _ref = _asyncToGenerator(function(input) {
160
- var inputResult, output, outputResult;
161
- return __generator(this, function(_state) {
162
- switch(_state.label){
163
- case 0:
164
- inputResult = validateApiInput(input);
165
- if (inputResult.isErr) {
166
- return [
167
- 2,
168
- InputValidationError(getErrorMessage(inputResult.value))
169
- ];
170
- }
171
- return [
172
- 4,
173
- handler(input)
174
- ];
175
- case 1:
176
- output = _state.sent();
177
- outputResult = validateApiOutput(output);
178
- if (outputResult.isErr) {
179
- return [
180
- 2,
181
- OutputValidationError(getErrorMessage(outputResult.value))
182
- ];
183
- }
184
- return [
185
- 2,
186
- HandleSuccess(output)
187
- ];
188
- }
189
- });
190
- });
191
- return function handle(input) {
192
- return _ref.apply(this, arguments);
193
- };
194
- }();
195
- return Object.assign(handle, _defineProperty({
196
- schema: schema
197
- }, HANDLER_WITH_SCHEMA, true));
162
+ export var baseMatch = function(schema, handler) {
163
+ var validateApiInput = createRequestSchemaValidator(schema.request);
164
+ var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
165
+ var handle = function() {
166
+ var _ref = _async_to_generator(function(input) {
167
+ var inputResult, output, outputResult;
168
+ return __generator(this, function(_state) {
169
+ switch (_state.label) {
170
+ case 0:
171
+ inputResult = validateApiInput(input);
172
+ if (inputResult.isErr) {
173
+ return [
174
+ 2,
175
+ InputValidationError(getErrorMessage(inputResult.value))
176
+ ];
177
+ }
178
+ return [
179
+ 4,
180
+ handler(input)
181
+ ];
182
+ case 1:
183
+ output = _state.sent();
184
+ outputResult = validateApiOutput(output);
185
+ if (outputResult.isErr) {
186
+ return [
187
+ 2,
188
+ OutputValidationError(getErrorMessage(outputResult.value))
189
+ ];
190
+ }
191
+ return [
192
+ 2,
193
+ HandleSuccess(output)
194
+ ];
195
+ }
196
+ });
197
+ });
198
+ return function handle2(input) {
199
+ return _ref.apply(this, arguments);
200
+ };
201
+ }();
202
+ return Object.assign(handle, _define_property({
203
+ schema
204
+ }, HANDLER_WITH_SCHEMA, true));
198
205
  };
199
- var match = baseMatch;
206
+ export var match = baseMatch;
200
207
  var createRequestSchemaValidator = function(schema) {
201
- var descriptors = {};
202
- if (schema.params) {
203
- descriptors.params = schema.params;
204
- }
205
- if (schema.query) {
206
- descriptors.query = schema.query;
207
- }
208
- if (schema.data) {
209
- descriptors.data = schema.data;
210
- }
211
- if (schema.headers) {
212
- descriptors.headers = schema.headers;
213
- }
214
- if (schema.cookies) {
215
- descriptors.cookies = schema.cookies;
216
- }
217
- var RequestStruct = Struct(descriptors);
218
- return createSchemaValidator(NonStrict(RequestStruct));
208
+ var descriptors = {};
209
+ if (schema.params) {
210
+ descriptors.params = schema.params;
211
+ }
212
+ if (schema.query) {
213
+ descriptors.query = schema.query;
214
+ }
215
+ if (schema.data) {
216
+ descriptors.data = schema.data;
217
+ }
218
+ if (schema.headers) {
219
+ descriptors.headers = schema.headers;
220
+ }
221
+ if (schema.cookies) {
222
+ descriptors.cookies = schema.cookies;
223
+ }
224
+ var RequestStruct = Struct(descriptors);
225
+ return createSchemaValidator(NonStrict(RequestStruct));
219
226
  };
220
- export { baseMatch, isHandler, isSchemaHandler, match };
@@ -1 +1 @@
1
- "use strict";
1
+ export {};
@@ -1,19 +1,18 @@
1
- var HandleSuccess = function(output) {
2
- return {
3
- type: "HandleSuccess",
4
- value: output
5
- };
1
+ export var HandleSuccess = function(output) {
2
+ return {
3
+ type: "HandleSuccess",
4
+ value: output
5
+ };
6
6
  };
7
- var InputValidationError = function(message) {
8
- return {
9
- type: "InputValidationError",
10
- message: message
11
- };
7
+ export var InputValidationError = function(message) {
8
+ return {
9
+ type: "InputValidationError",
10
+ message
11
+ };
12
12
  };
13
- var OutputValidationError = function(message) {
14
- return {
15
- type: "OutputValidationError",
16
- message: message
17
- };
13
+ export var OutputValidationError = function(message) {
14
+ return {
15
+ type: "OutputValidationError",
16
+ message
17
+ };
18
18
  };
19
- export { HandleSuccess, InputValidationError, OutputValidationError };
package/dist/esm/types.js CHANGED
@@ -1 +1 @@
1
- "use strict";
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,2 @@
1
1
  export * from "farrow-schema";
2
- import { match, isHandler, isSchemaHandler } from "./match";
3
- export {
4
- isHandler,
5
- isSchemaHandler,
6
- match
7
- };
2
+ export { match, isHandler, isSchemaHandler } from "./match";
@@ -1,16 +1,6 @@
1
- import {
2
- toSchemaCtor,
3
- Struct,
4
- NonStrict
5
- } from "farrow-schema";
6
- import {
7
- createSchemaValidator
8
- } from "farrow-schema/validator";
9
- import {
10
- HandleSuccess,
11
- InputValidationError,
12
- OutputValidationError
13
- } from "./response";
1
+ import { toSchemaCtor, Struct, NonStrict } from "farrow-schema";
2
+ import { createSchemaValidator } from "farrow-schema/validator";
3
+ import { HandleSuccess, InputValidationError, OutputValidationError } from "./response";
14
4
  const getErrorMessage = (error) => {
15
5
  let { message } = error;
16
6
  if (Array.isArray(error.path) && error.path.length > 0) {
@@ -20,13 +10,13 @@ ${message}`;
20
10
  return message;
21
11
  };
22
12
  const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
23
- const isSchemaHandler = (input) => input && (input == null ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
24
- const isHandler = (input) => input && typeof input === "function";
25
- const baseMatch = (schema, handler) => {
13
+ export const isSchemaHandler = (input) => {
14
+ return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
15
+ };
16
+ export const isHandler = (input) => input && typeof input === "function";
17
+ export const baseMatch = (schema, handler) => {
26
18
  const validateApiInput = createRequestSchemaValidator(schema.request);
27
- const validateApiOutput = createSchemaValidator(
28
- toSchemaCtor(schema.response)
29
- );
19
+ const validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
30
20
  const handle = async (input) => {
31
21
  const inputResult = validateApiInput(input);
32
22
  if (inputResult.isErr) {
@@ -44,7 +34,7 @@ const baseMatch = (schema, handler) => {
44
34
  [HANDLER_WITH_SCHEMA]: true
45
35
  });
46
36
  };
47
- const match = baseMatch;
37
+ export const match = baseMatch;
48
38
  const createRequestSchemaValidator = (schema) => {
49
39
  const descriptors = {};
50
40
  if (schema.params) {
@@ -65,9 +55,3 @@ const createRequestSchemaValidator = (schema) => {
65
55
  const RequestStruct = Struct(descriptors);
66
56
  return createSchemaValidator(NonStrict(RequestStruct));
67
57
  };
68
- export {
69
- baseMatch,
70
- isHandler,
71
- isSchemaHandler,
72
- match
73
- };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,17 +1,12 @@
1
- const HandleSuccess = (output) => ({
1
+ export const HandleSuccess = (output) => ({
2
2
  type: "HandleSuccess",
3
3
  value: output
4
4
  });
5
- const InputValidationError = (message) => ({
5
+ export const InputValidationError = (message) => ({
6
6
  type: "InputValidationError",
7
7
  message
8
8
  });
9
- const OutputValidationError = (message) => ({
9
+ export const OutputValidationError = (message) => ({
10
10
  type: "OutputValidationError",
11
11
  message
12
12
  });
13
- export {
14
- HandleSuccess,
15
- InputValidationError,
16
- OutputValidationError
17
- };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -3,7 +3,11 @@
3
3
  "description": "A Progressive React Framework for modern web development.",
4
4
  "homepage": "https://modernjs.dev",
5
5
  "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
- "repository": "web-infra-dev/modern.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/web-infra-dev/modern.js",
9
+ "directory": "packages/server/bff-runtime"
10
+ },
7
11
  "license": "MIT",
8
12
  "keywords": [
9
13
  "react",
@@ -11,7 +15,7 @@
11
15
  "modern",
12
16
  "modern.js"
13
17
  ],
14
- "version": "2.15.0",
18
+ "version": "2.16.0",
15
19
  "jsnext:source": "./src/index.ts",
16
20
  "types": "./dist/types/index.d.ts",
17
21
  "main": "./dist/cjs/index.js",
@@ -38,8 +42,8 @@
38
42
  "jest": "^29",
39
43
  "ts-jest": "^29.0.5",
40
44
  "typescript": "^4",
41
- "@scripts/build": "2.15.0",
42
- "@scripts/jest-config": "2.15.0"
45
+ "@scripts/jest-config": "2.16.0",
46
+ "@scripts/build": "2.16.0"
43
47
  },
44
48
  "publishConfig": {
45
49
  "registry": "https://registry.npmjs.org/",