@modern-js/bff-runtime 2.35.0 → 2.36.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.
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var compatible_exports = {};
16
+ module.exports = __toCommonJS(compatible_exports);
package/dist/cjs/index.js CHANGED
@@ -1,25 +1,35 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- match: function() {
14
- return _match.match;
15
- },
16
- isHandler: function() {
17
- return _match.isHandler;
18
- },
19
- isSchemaHandler: function() {
20
- return _match.isSchemaHandler;
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 });
21
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 src_exports = {};
21
+ __export(src_exports, {
22
+ isHandler: () => import_match.isHandler,
23
+ isSchemaHandler: () => import_match.isSchemaHandler,
24
+ match: () => import_match.match
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ __reExport(src_exports, require("farrow-schema"), module.exports);
28
+ var import_match = require("./match");
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ isHandler,
32
+ isSchemaHandler,
33
+ match,
34
+ ...require("farrow-schema")
22
35
  });
23
- const _export_star = require("@swc/helpers/_/_export_star");
24
- _export_star._(require("farrow-schema"), exports);
25
- const _match = require("./match");
package/dist/cjs/match.js CHANGED
@@ -1,31 +1,32 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- isSchemaHandler: function() {
14
- return isSchemaHandler;
15
- },
16
- isHandler: function() {
17
- return isHandler;
18
- },
19
- baseMatch: function() {
20
- return baseMatch;
21
- },
22
- match: function() {
23
- return match;
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 match_exports = {};
20
+ __export(match_exports, {
21
+ baseMatch: () => baseMatch,
22
+ isHandler: () => isHandler,
23
+ isSchemaHandler: () => isSchemaHandler,
24
+ match: () => match
25
25
  });
26
- const _farrowschema = require("farrow-schema");
27
- const _validator = require("farrow-schema/validator");
28
- const _response = require("./response");
26
+ module.exports = __toCommonJS(match_exports);
27
+ var import_farrow_schema = require("farrow-schema");
28
+ var import_validator = require("farrow-schema/validator");
29
+ var import_response = require("./response");
29
30
  const getErrorMessage = (error) => {
30
31
  let { message } = error;
31
32
  if (Array.isArray(error.path) && error.path.length > 0) {
@@ -35,25 +36,22 @@ ${message}`;
35
36
  return message;
36
37
  };
37
38
  const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
38
- const isSchemaHandler = (input) => {
39
- var _input;
40
- return input && ((_input = input) === null || _input === void 0 ? void 0 : _input[HANDLER_WITH_SCHEMA]) === true;
41
- };
39
+ const isSchemaHandler = (input) => input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
42
40
  const isHandler = (input) => input && typeof input === "function";
43
41
  const baseMatch = (schema, handler) => {
44
42
  const validateApiInput = createRequestSchemaValidator(schema.request);
45
- const validateApiOutput = (0, _validator.createSchemaValidator)((0, _farrowschema.toSchemaCtor)(schema.response));
43
+ const validateApiOutput = (0, import_validator.createSchemaValidator)((0, import_farrow_schema.toSchemaCtor)(schema.response));
46
44
  const handle = async (input) => {
47
45
  const inputResult = validateApiInput(input);
48
46
  if (inputResult.isErr) {
49
- return (0, _response.InputValidationError)(getErrorMessage(inputResult.value));
47
+ return (0, import_response.InputValidationError)(getErrorMessage(inputResult.value));
50
48
  }
51
49
  const output = await handler(input);
52
50
  const outputResult = validateApiOutput(output);
53
51
  if (outputResult.isErr) {
54
- return (0, _response.OutputValidationError)(getErrorMessage(outputResult.value));
52
+ return (0, import_response.OutputValidationError)(getErrorMessage(outputResult.value));
55
53
  }
56
- return (0, _response.HandleSuccess)(output);
54
+ return (0, import_response.HandleSuccess)(output);
57
55
  };
58
56
  return Object.assign(handle, {
59
57
  schema,
@@ -78,6 +76,13 @@ const createRequestSchemaValidator = (schema) => {
78
76
  if (schema.cookies) {
79
77
  descriptors.cookies = schema.cookies;
80
78
  }
81
- const RequestStruct = (0, _farrowschema.Struct)(descriptors);
82
- return (0, _validator.createSchemaValidator)((0, _farrowschema.NonStrict)(RequestStruct));
79
+ const RequestStruct = (0, import_farrow_schema.Struct)(descriptors);
80
+ return (0, import_validator.createSchemaValidator)((0, import_farrow_schema.NonStrict)(RequestStruct));
83
81
  };
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ baseMatch,
85
+ isHandler,
86
+ isSchemaHandler,
87
+ match
88
+ });
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var request_exports = {};
16
+ module.exports = __toCommonJS(request_exports);
@@ -1,25 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- HandleSuccess: function() {
14
- return HandleSuccess;
15
- },
16
- InputValidationError: function() {
17
- return InputValidationError;
18
- },
19
- OutputValidationError: function() {
20
- return OutputValidationError;
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 });
21
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var response_exports = {};
20
+ __export(response_exports, {
21
+ HandleSuccess: () => HandleSuccess,
22
+ InputValidationError: () => InputValidationError,
23
+ OutputValidationError: () => OutputValidationError
22
24
  });
25
+ module.exports = __toCommonJS(response_exports);
23
26
  const HandleSuccess = (output) => ({
24
27
  type: "HandleSuccess",
25
28
  value: output
@@ -32,3 +35,9 @@ const OutputValidationError = (message) => ({
32
35
  type: "OutputValidationError",
33
36
  message
34
37
  });
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ HandleSuccess,
41
+ InputValidationError,
42
+ OutputValidationError
43
+ });
package/dist/cjs/types.js CHANGED
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -1 +0,0 @@
1
- export {};
package/dist/esm/index.js CHANGED
@@ -1,2 +1,7 @@
1
1
  export * from "farrow-schema";
2
- export { match, isHandler, isSchemaHandler } from "./match";
2
+ import { match, isHandler, isSchemaHandler } from "./match";
3
+ export {
4
+ isHandler,
5
+ isSchemaHandler,
6
+ match
7
+ };
package/dist/esm/match.js CHANGED
@@ -12,14 +12,13 @@ var getErrorMessage = function(error) {
12
12
  return message;
13
13
  };
14
14
  var HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
15
- export var isSchemaHandler = function(input) {
16
- var _input;
17
- return input && ((_input = input) === null || _input === void 0 ? void 0 : _input[HANDLER_WITH_SCHEMA]) === true;
15
+ var isSchemaHandler = function(input) {
16
+ return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
18
17
  };
19
- export var isHandler = function(input) {
18
+ var isHandler = function(input) {
20
19
  return input && typeof input === "function";
21
20
  };
22
- export var baseMatch = function(schema, handler) {
21
+ var baseMatch = function(schema, handler) {
23
22
  var validateApiInput = createRequestSchemaValidator(schema.request);
24
23
  var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
25
24
  var handle = function() {
@@ -60,10 +59,10 @@ export var baseMatch = function(schema, handler) {
60
59
  };
61
60
  }();
62
61
  return Object.assign(handle, _define_property({
63
- schema: schema
62
+ schema
64
63
  }, HANDLER_WITH_SCHEMA, true));
65
64
  };
66
- export var match = baseMatch;
65
+ var match = baseMatch;
67
66
  var createRequestSchemaValidator = function(schema) {
68
67
  var descriptors = {};
69
68
  if (schema.params) {
@@ -84,3 +83,9 @@ var createRequestSchemaValidator = function(schema) {
84
83
  var RequestStruct = Struct(descriptors);
85
84
  return createSchemaValidator(NonStrict(RequestStruct));
86
85
  };
86
+ export {
87
+ baseMatch,
88
+ isHandler,
89
+ isSchemaHandler,
90
+ match
91
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +1,23 @@
1
- export var HandleSuccess = function(output) {
1
+ var HandleSuccess = function(output) {
2
2
  return {
3
3
  type: "HandleSuccess",
4
4
  value: output
5
5
  };
6
6
  };
7
- export var InputValidationError = function(message) {
7
+ var InputValidationError = function(message) {
8
8
  return {
9
9
  type: "InputValidationError",
10
- message: message
10
+ message
11
11
  };
12
12
  };
13
- export var OutputValidationError = function(message) {
13
+ var OutputValidationError = function(message) {
14
14
  return {
15
15
  type: "OutputValidationError",
16
- message: message
16
+ message
17
17
  };
18
18
  };
19
+ export {
20
+ HandleSuccess,
21
+ InputValidationError,
22
+ OutputValidationError
23
+ };
package/dist/esm/types.js CHANGED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +1,7 @@
1
1
  export * from "farrow-schema";
2
- export { match, isHandler, isSchemaHandler } from "./match";
2
+ import { match, isHandler, isSchemaHandler } from "./match";
3
+ export {
4
+ isHandler,
5
+ isSchemaHandler,
6
+ match
7
+ };
@@ -10,12 +10,9 @@ ${message}`;
10
10
  return message;
11
11
  };
12
12
  const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
13
- export const isSchemaHandler = (input) => {
14
- var _input;
15
- return input && ((_input = input) === null || _input === void 0 ? void 0 : _input[HANDLER_WITH_SCHEMA]) === true;
16
- };
17
- export const isHandler = (input) => input && typeof input === "function";
18
- export const baseMatch = (schema, handler) => {
13
+ const isSchemaHandler = (input) => input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
14
+ const isHandler = (input) => input && typeof input === "function";
15
+ const baseMatch = (schema, handler) => {
19
16
  const validateApiInput = createRequestSchemaValidator(schema.request);
20
17
  const validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
21
18
  const handle = async (input) => {
@@ -35,7 +32,7 @@ export const baseMatch = (schema, handler) => {
35
32
  [HANDLER_WITH_SCHEMA]: true
36
33
  });
37
34
  };
38
- export const match = baseMatch;
35
+ const match = baseMatch;
39
36
  const createRequestSchemaValidator = (schema) => {
40
37
  const descriptors = {};
41
38
  if (schema.params) {
@@ -56,3 +53,9 @@ const createRequestSchemaValidator = (schema) => {
56
53
  const RequestStruct = Struct(descriptors);
57
54
  return createSchemaValidator(NonStrict(RequestStruct));
58
55
  };
56
+ export {
57
+ baseMatch,
58
+ isHandler,
59
+ isSchemaHandler,
60
+ match
61
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +1,17 @@
1
- export const HandleSuccess = (output) => ({
1
+ const HandleSuccess = (output) => ({
2
2
  type: "HandleSuccess",
3
3
  value: output
4
4
  });
5
- export const InputValidationError = (message) => ({
5
+ const InputValidationError = (message) => ({
6
6
  type: "InputValidationError",
7
7
  message
8
8
  });
9
- export const OutputValidationError = (message) => ({
9
+ const OutputValidationError = (message) => ({
10
10
  type: "OutputValidationError",
11
11
  message
12
12
  });
13
+ export {
14
+ HandleSuccess,
15
+ InputValidationError,
16
+ OutputValidationError
17
+ };
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.35.0",
18
+ "version": "2.36.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -42,8 +42,8 @@
42
42
  "jest": "^29",
43
43
  "ts-jest": "^29.1.0",
44
44
  "typescript": "^5",
45
- "@scripts/build": "2.35.0",
46
- "@scripts/jest-config": "2.35.0"
45
+ "@scripts/build": "2.36.0",
46
+ "@scripts/jest-config": "2.36.0"
47
47
  },
48
48
  "publishConfig": {
49
49
  "registry": "https://registry.npmjs.org/",