@modern-js/bff-runtime 2.0.0-beta.2 → 2.0.0-beta.4

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,17 @@
1
1
  # @modern-js/bff-runtime
2
2
 
3
+ ## 2.0.0-beta.4
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ## 2.0.0-beta.3
10
+
11
+ ### Major Changes
12
+
13
+ - dda38c9c3e: chore: v2
14
+
3
15
  ## 2.0.0-beta.2
4
16
 
5
17
  ### Major Changes
@@ -1,5 +1,7 @@
1
- export * from 'farrow-schema';
2
- // export * from 'farrow-api';
3
- // export * from 'farrow-pipeline';
4
-
5
- export { match, isHandler, isSchemaHandler } from "./match";
1
+ export * from "farrow-schema";
2
+ import { match, isHandler, isSchemaHandler } from "./match";
3
+ export {
4
+ isHandler,
5
+ isSchemaHandler,
6
+ match
7
+ };
@@ -1,40 +1,71 @@
1
- import { toSchemaCtor, Struct, NonStrict } from 'farrow-schema';
2
- import { createSchemaValidator } from 'farrow-schema/validator';
3
- import { HandleSuccess, InputValidationError, OutputValidationError } from "./response";
4
- const getErrorMessage = error => {
5
- let {
6
- message
7
- } = error;
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import {
22
+ toSchemaCtor,
23
+ Struct,
24
+ NonStrict
25
+ } from "farrow-schema";
26
+ import {
27
+ createSchemaValidator
28
+ } from "farrow-schema/validator";
29
+ import {
30
+ HandleSuccess,
31
+ InputValidationError,
32
+ OutputValidationError
33
+ } from "./response";
34
+ const getErrorMessage = (error) => {
35
+ let { message } = error;
8
36
  if (Array.isArray(error.path) && error.path.length > 0) {
9
- message = `path: ${JSON.stringify(error.path)}\n${message}`;
37
+ message = `path: ${JSON.stringify(error.path)}
38
+ ${message}`;
10
39
  }
11
40
  return message;
12
41
  };
13
- const HANDLER_WITH_SCHEMA = 'HANDLER_WITH_SCHEMA';
14
- export const isSchemaHandler = input => input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
15
- export const isHandler = input => input && typeof input === 'function';
16
- export const baseMatch = (schema, handler) => {
42
+ const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
43
+ const isSchemaHandler = (input) => input && (input == null ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
44
+ const isHandler = (input) => input && typeof input === "function";
45
+ const baseMatch = (schema, handler) => {
17
46
  const validateApiInput = createRequestSchemaValidator(schema.request);
18
- const validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
19
- const handle = async input => {
47
+ const validateApiOutput = createSchemaValidator(
48
+ toSchemaCtor(schema.response)
49
+ );
50
+ const handle = (input) => __async(void 0, null, function* () {
20
51
  const inputResult = validateApiInput(input);
21
52
  if (inputResult.isErr) {
22
53
  return InputValidationError(getErrorMessage(inputResult.value));
23
54
  }
24
- const output = await handler(input);
55
+ const output = yield handler(input);
25
56
  const outputResult = validateApiOutput(output);
26
57
  if (outputResult.isErr) {
27
58
  return OutputValidationError(getErrorMessage(outputResult.value));
28
59
  }
29
60
  return HandleSuccess(output);
30
- };
61
+ });
31
62
  return Object.assign(handle, {
32
63
  schema,
33
64
  [HANDLER_WITH_SCHEMA]: true
34
65
  });
35
66
  };
36
- export const match = baseMatch;
37
- const createRequestSchemaValidator = schema => {
67
+ const match = baseMatch;
68
+ const createRequestSchemaValidator = (schema) => {
38
69
  const descriptors = {};
39
70
  if (schema.params) {
40
71
  descriptors.params = schema.params;
@@ -53,4 +84,10 @@ const createRequestSchemaValidator = schema => {
53
84
  }
54
85
  const RequestStruct = Struct(descriptors);
55
86
  return createSchemaValidator(NonStrict(RequestStruct));
56
- };
87
+ };
88
+ export {
89
+ baseMatch,
90
+ isHandler,
91
+ isSchemaHandler,
92
+ match
93
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +1,17 @@
1
- // eslint-disable-next-line @typescript-eslint/no-redeclare
2
- export const HandleSuccess = output => ({
3
- type: 'HandleSuccess',
1
+ const HandleSuccess = (output) => ({
2
+ type: "HandleSuccess",
4
3
  value: output
5
4
  });
6
- // eslint-disable-next-line @typescript-eslint/no-redeclare
7
- export const InputValidationError = message => ({
8
- type: 'InputValidationError',
5
+ const InputValidationError = (message) => ({
6
+ type: "InputValidationError",
9
7
  message
10
8
  });
11
- // eslint-disable-next-line @typescript-eslint/no-redeclare
12
- export const OutputValidationError = message => ({
13
- type: 'OutputValidationError',
9
+ const OutputValidationError = (message) => ({
10
+ type: "OutputValidationError",
14
11
  message
15
- });
12
+ });
13
+ export {
14
+ HandleSuccess,
15
+ InputValidationError,
16
+ OutputValidationError
17
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,41 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- match: true,
8
- isHandler: true,
9
- isSchemaHandler: true
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 });
10
8
  };
11
- Object.defineProperty(exports, "isHandler", {
12
- enumerable: true,
13
- get: function () {
14
- return _match.isHandler;
15
- }
16
- });
17
- Object.defineProperty(exports, "isSchemaHandler", {
18
- enumerable: true,
19
- get: function () {
20
- return _match.isSchemaHandler;
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 });
21
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 stdin_exports = {};
20
+ __export(stdin_exports, {
21
+ isHandler: () => import_match.isHandler,
22
+ isSchemaHandler: () => import_match.isSchemaHandler,
23
+ match: () => import_match.match
22
24
  });
23
- Object.defineProperty(exports, "match", {
24
- enumerable: true,
25
- get: function () {
26
- return _match.match;
27
- }
28
- });
29
- var _farrowSchema = require("farrow-schema");
30
- Object.keys(_farrowSchema).forEach(function (key) {
31
- if (key === "default" || key === "__esModule") return;
32
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
33
- if (key in exports && exports[key] === _farrowSchema[key]) return;
34
- Object.defineProperty(exports, key, {
35
- enumerable: true,
36
- get: function () {
37
- return _farrowSchema[key];
38
- }
39
- });
40
- });
41
- var _match = require("./match");
25
+ module.exports = __toCommonJS(stdin_exports);
26
+ __reExport(stdin_exports, require("farrow-schema"), module.exports);
27
+ var import_match = require("./match");
@@ -1,50 +1,86 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ baseMatch: () => baseMatch,
21
+ isHandler: () => isHandler,
22
+ isSchemaHandler: () => isSchemaHandler,
23
+ match: () => match
5
24
  });
6
- exports.match = exports.isSchemaHandler = exports.isHandler = exports.baseMatch = void 0;
7
- var _farrowSchema = require("farrow-schema");
8
- var _validator = require("farrow-schema/validator");
9
- var _response = require("./response");
10
- const getErrorMessage = error => {
11
- let {
12
- message
13
- } = error;
25
+ module.exports = __toCommonJS(stdin_exports);
26
+ var import_farrow_schema = require("farrow-schema");
27
+ var import_validator = require("farrow-schema/validator");
28
+ var import_response = require("./response");
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
49
+ const getErrorMessage = (error) => {
50
+ let { message } = error;
14
51
  if (Array.isArray(error.path) && error.path.length > 0) {
15
- message = `path: ${JSON.stringify(error.path)}\n${message}`;
52
+ message = `path: ${JSON.stringify(error.path)}
53
+ ${message}`;
16
54
  }
17
55
  return message;
18
56
  };
19
- const HANDLER_WITH_SCHEMA = 'HANDLER_WITH_SCHEMA';
20
- const isSchemaHandler = input => input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
21
- exports.isSchemaHandler = isSchemaHandler;
22
- const isHandler = input => input && typeof input === 'function';
23
- exports.isHandler = isHandler;
57
+ const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
58
+ const isSchemaHandler = (input) => input && (input == null ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
59
+ const isHandler = (input) => input && typeof input === "function";
24
60
  const baseMatch = (schema, handler) => {
25
61
  const validateApiInput = createRequestSchemaValidator(schema.request);
26
- const validateApiOutput = (0, _validator.createSchemaValidator)((0, _farrowSchema.toSchemaCtor)(schema.response));
27
- const handle = async input => {
62
+ const validateApiOutput = (0, import_validator.createSchemaValidator)(
63
+ (0, import_farrow_schema.toSchemaCtor)(schema.response)
64
+ );
65
+ const handle = (input) => __async(void 0, null, function* () {
28
66
  const inputResult = validateApiInput(input);
29
67
  if (inputResult.isErr) {
30
- return (0, _response.InputValidationError)(getErrorMessage(inputResult.value));
68
+ return (0, import_response.InputValidationError)(getErrorMessage(inputResult.value));
31
69
  }
32
- const output = await handler(input);
70
+ const output = yield handler(input);
33
71
  const outputResult = validateApiOutput(output);
34
72
  if (outputResult.isErr) {
35
- return (0, _response.OutputValidationError)(getErrorMessage(outputResult.value));
73
+ return (0, import_response.OutputValidationError)(getErrorMessage(outputResult.value));
36
74
  }
37
- return (0, _response.HandleSuccess)(output);
38
- };
75
+ return (0, import_response.HandleSuccess)(output);
76
+ });
39
77
  return Object.assign(handle, {
40
78
  schema,
41
79
  [HANDLER_WITH_SCHEMA]: true
42
80
  });
43
81
  };
44
- exports.baseMatch = baseMatch;
45
82
  const match = baseMatch;
46
- exports.match = match;
47
- const createRequestSchemaValidator = schema => {
83
+ const createRequestSchemaValidator = (schema) => {
48
84
  const descriptors = {};
49
85
  if (schema.params) {
50
86
  descriptors.params = schema.params;
@@ -61,6 +97,6 @@ const createRequestSchemaValidator = schema => {
61
97
  if (schema.cookies) {
62
98
  descriptors.cookies = schema.cookies;
63
99
  }
64
- const RequestStruct = (0, _farrowSchema.Struct)(descriptors);
65
- return (0, _validator.createSchemaValidator)((0, _farrowSchema.NonStrict)(RequestStruct));
66
- };
100
+ const RequestStruct = (0, import_farrow_schema.Struct)(descriptors);
101
+ return (0, import_validator.createSchemaValidator)((0, import_farrow_schema.NonStrict)(RequestStruct));
102
+ };
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,24 +1,36 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ HandleSuccess: () => HandleSuccess,
21
+ InputValidationError: () => InputValidationError,
22
+ OutputValidationError: () => OutputValidationError
5
23
  });
6
- exports.OutputValidationError = exports.InputValidationError = exports.HandleSuccess = void 0;
7
- // eslint-disable-next-line @typescript-eslint/no-redeclare
8
- const HandleSuccess = output => ({
9
- type: 'HandleSuccess',
24
+ module.exports = __toCommonJS(stdin_exports);
25
+ const HandleSuccess = (output) => ({
26
+ type: "HandleSuccess",
10
27
  value: output
11
28
  });
12
- exports.HandleSuccess = HandleSuccess;
13
- // eslint-disable-next-line @typescript-eslint/no-redeclare
14
- const InputValidationError = message => ({
15
- type: 'InputValidationError',
29
+ const InputValidationError = (message) => ({
30
+ type: "InputValidationError",
16
31
  message
17
32
  });
18
- exports.InputValidationError = InputValidationError;
19
- // eslint-disable-next-line @typescript-eslint/no-redeclare
20
- const OutputValidationError = message => ({
21
- type: 'OutputValidationError',
33
+ const OutputValidationError = (message) => ({
34
+ type: "OutputValidationError",
22
35
  message
23
36
  });
24
- exports.OutputValidationError = OutputValidationError;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,5 +1,3 @@
1
- export * from 'farrow-schema';
2
- // export * from 'farrow-api';
3
- // export * from 'farrow-pipeline';
4
-
5
- export { match, isHandler, isSchemaHandler } from "./match";
1
+ export * from "farrow-schema";
2
+ import { match, isHandler, isSchemaHandler } from "./match";
3
+ export { isHandler, isSchemaHandler, match };
@@ -1,85 +1,220 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import { toSchemaCtor, Struct, NonStrict } from 'farrow-schema';
5
- import { createSchemaValidator } from 'farrow-schema/validator';
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
+ }
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
+ };
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;
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: []
52
+ };
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) {
123
+ op = [
124
+ 6,
125
+ e
126
+ ];
127
+ y = 0;
128
+ } finally{
129
+ f = t = 0;
130
+ }
131
+ if (op[0] & 5) throw op[1];
132
+ return {
133
+ value: op[0] ? op[1] : void 0,
134
+ done: true
135
+ };
136
+ }
137
+ };
138
+ import { toSchemaCtor, Struct, NonStrict } from "farrow-schema";
139
+ import { createSchemaValidator } from "farrow-schema/validator";
6
140
  import { HandleSuccess, InputValidationError, OutputValidationError } from "./response";
7
- var getErrorMessage = function getErrorMessage(error) {
8
- var message = error.message;
9
- if (Array.isArray(error.path) && error.path.length > 0) {
10
- message = "path: ".concat(JSON.stringify(error.path), "\n").concat(message);
11
- }
12
- return message;
141
+ 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;
13
147
  };
14
- var HANDLER_WITH_SCHEMA = 'HANDLER_WITH_SCHEMA';
15
- export var isSchemaHandler = function isSchemaHandler(input) {
16
- return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
148
+ 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;
17
151
  };
18
- export var isHandler = function isHandler(input) {
19
- return input && typeof input === 'function';
152
+ var isHandler = function(input) {
153
+ return input && typeof input === "function";
20
154
  };
21
- export var baseMatch = function baseMatch(schema, handler) {
22
- var validateApiInput = createRequestSchemaValidator(schema.request);
23
- var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
24
- var handle = /*#__PURE__*/function () {
25
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
26
- var inputResult, output, outputResult;
27
- return _regeneratorRuntime().wrap(function _callee$(_context) {
28
- while (1) {
29
- switch (_context.prev = _context.next) {
30
- case 0:
31
- inputResult = validateApiInput(input);
32
- if (!inputResult.isErr) {
33
- _context.next = 3;
34
- break;
35
- }
36
- return _context.abrupt("return", InputValidationError(getErrorMessage(inputResult.value)));
37
- case 3:
38
- _context.next = 5;
39
- return handler(input);
40
- case 5:
41
- output = _context.sent;
42
- outputResult = validateApiOutput(output);
43
- if (!outputResult.isErr) {
44
- _context.next = 9;
45
- break;
46
- }
47
- return _context.abrupt("return", OutputValidationError(getErrorMessage(outputResult.value)));
48
- case 9:
49
- return _context.abrupt("return", HandleSuccess(output));
50
- case 10:
51
- case "end":
52
- return _context.stop();
53
- }
54
- }
55
- }, _callee);
56
- }));
57
- return function handle(_x) {
58
- return _ref.apply(this, arguments);
59
- };
60
- }();
61
- return Object.assign(handle, _defineProperty({
62
- schema: schema
63
- }, HANDLER_WITH_SCHEMA, true));
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));
198
+ };
199
+ var match = baseMatch;
200
+ 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));
64
219
  };
65
- export var match = baseMatch;
66
- var createRequestSchemaValidator = function createRequestSchemaValidator(schema) {
67
- var descriptors = {};
68
- if (schema.params) {
69
- descriptors.params = schema.params;
70
- }
71
- if (schema.query) {
72
- descriptors.query = schema.query;
73
- }
74
- if (schema.data) {
75
- descriptors.data = schema.data;
76
- }
77
- if (schema.headers) {
78
- descriptors.headers = schema.headers;
79
- }
80
- if (schema.cookies) {
81
- descriptors.cookies = schema.cookies;
82
- }
83
- var RequestStruct = Struct(descriptors);
84
- return createSchemaValidator(NonStrict(RequestStruct));
85
- };
220
+ export { baseMatch, isHandler, isSchemaHandler, match };
@@ -1 +1 @@
1
- export {};
1
+ "use strict";
@@ -1,21 +1,19 @@
1
- // eslint-disable-next-line @typescript-eslint/no-redeclare
2
- export var HandleSuccess = function HandleSuccess(output) {
3
- return {
4
- type: 'HandleSuccess',
5
- value: output
6
- };
1
+ var HandleSuccess = function(output) {
2
+ return {
3
+ type: "HandleSuccess",
4
+ value: output
5
+ };
7
6
  };
8
- // eslint-disable-next-line @typescript-eslint/no-redeclare
9
- export var InputValidationError = function InputValidationError(message) {
10
- return {
11
- type: 'InputValidationError',
12
- message: message
13
- };
7
+ var InputValidationError = function(message) {
8
+ return {
9
+ type: "InputValidationError",
10
+ message: message
11
+ };
14
12
  };
15
- // eslint-disable-next-line @typescript-eslint/no-redeclare
16
- export var OutputValidationError = function OutputValidationError(message) {
17
- return {
18
- type: 'OutputValidationError',
19
- message: message
20
- };
21
- };
13
+ var OutputValidationError = function(message) {
14
+ return {
15
+ type: "OutputValidationError",
16
+ message: message
17
+ };
18
+ };
19
+ export { HandleSuccess, InputValidationError, OutputValidationError };
@@ -1 +1 @@
1
- export {};
1
+ "use strict";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.2",
14
+ "version": "2.0.0-beta.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -39,8 +39,8 @@
39
39
  "jest": "^27",
40
40
  "ts-jest": "^27.0.5",
41
41
  "typescript": "^4",
42
- "@scripts/build": "2.0.0-beta.2",
43
- "@scripts/jest-config": "2.0.0-beta.2"
42
+ "@scripts/build": "2.0.0-beta.4",
43
+ "@scripts/jest-config": "2.0.0-beta.4"
44
44
  },
45
45
  "publishConfig": {
46
46
  "registry": "https://registry.npmjs.org/",