@modern-js/bff-runtime 2.35.1 → 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.
- package/dist/cjs/compatible.js +15 -3
- package/dist/cjs/index.js +31 -21
- package/dist/cjs/match.js +38 -30
- package/dist/cjs/request.js +15 -3
- package/dist/cjs/response.js +27 -18
- package/dist/cjs/types.js +15 -3
- package/dist/esm/compatible.js +0 -1
- package/dist/esm/index.js +6 -1
- package/dist/esm/match.js +11 -5
- package/dist/esm/request.js +0 -1
- package/dist/esm/response.js +10 -5
- package/dist/esm/types.js +0 -1
- package/dist/esm-node/compatible.js +0 -1
- package/dist/esm-node/index.js +6 -1
- package/dist/esm-node/match.js +10 -4
- package/dist/esm-node/request.js +0 -1
- package/dist/esm-node/response.js +8 -3
- package/dist/esm-node/types.js +0 -1
- package/package.json +3 -3
package/dist/cjs/compatible.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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) {
|
|
@@ -39,18 +40,18 @@ const isSchemaHandler = (input) => input && (input === null || input === void 0
|
|
|
39
40
|
const isHandler = (input) => input && typeof input === "function";
|
|
40
41
|
const baseMatch = (schema, handler) => {
|
|
41
42
|
const validateApiInput = createRequestSchemaValidator(schema.request);
|
|
42
|
-
const validateApiOutput = (0,
|
|
43
|
+
const validateApiOutput = (0, import_validator.createSchemaValidator)((0, import_farrow_schema.toSchemaCtor)(schema.response));
|
|
43
44
|
const handle = async (input) => {
|
|
44
45
|
const inputResult = validateApiInput(input);
|
|
45
46
|
if (inputResult.isErr) {
|
|
46
|
-
return (0,
|
|
47
|
+
return (0, import_response.InputValidationError)(getErrorMessage(inputResult.value));
|
|
47
48
|
}
|
|
48
49
|
const output = await handler(input);
|
|
49
50
|
const outputResult = validateApiOutput(output);
|
|
50
51
|
if (outputResult.isErr) {
|
|
51
|
-
return (0,
|
|
52
|
+
return (0, import_response.OutputValidationError)(getErrorMessage(outputResult.value));
|
|
52
53
|
}
|
|
53
|
-
return (0,
|
|
54
|
+
return (0, import_response.HandleSuccess)(output);
|
|
54
55
|
};
|
|
55
56
|
return Object.assign(handle, {
|
|
56
57
|
schema,
|
|
@@ -75,6 +76,13 @@ const createRequestSchemaValidator = (schema) => {
|
|
|
75
76
|
if (schema.cookies) {
|
|
76
77
|
descriptors.cookies = schema.cookies;
|
|
77
78
|
}
|
|
78
|
-
const RequestStruct = (0,
|
|
79
|
-
return (0,
|
|
79
|
+
const RequestStruct = (0, import_farrow_schema.Struct)(descriptors);
|
|
80
|
+
return (0, import_validator.createSchemaValidator)((0, import_farrow_schema.NonStrict)(RequestStruct));
|
|
80
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
|
+
});
|
package/dist/cjs/request.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
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);
|
package/dist/cjs/response.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
3
|
-
|
|
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);
|
package/dist/esm/compatible.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/index.js
CHANGED
package/dist/esm/match.js
CHANGED
|
@@ -12,13 +12,13 @@ var getErrorMessage = function(error) {
|
|
|
12
12
|
return message;
|
|
13
13
|
};
|
|
14
14
|
var HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
|
|
15
|
-
|
|
15
|
+
var isSchemaHandler = function(input) {
|
|
16
16
|
return input && (input === null || input === void 0 ? void 0 : input[HANDLER_WITH_SCHEMA]) === true;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
var isHandler = function(input) {
|
|
19
19
|
return input && typeof input === "function";
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
var baseMatch = function(schema, handler) {
|
|
22
22
|
var validateApiInput = createRequestSchemaValidator(schema.request);
|
|
23
23
|
var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
|
|
24
24
|
var handle = function() {
|
|
@@ -59,10 +59,10 @@ export var baseMatch = function(schema, handler) {
|
|
|
59
59
|
};
|
|
60
60
|
}();
|
|
61
61
|
return Object.assign(handle, _define_property({
|
|
62
|
-
schema
|
|
62
|
+
schema
|
|
63
63
|
}, HANDLER_WITH_SCHEMA, true));
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
var match = baseMatch;
|
|
66
66
|
var createRequestSchemaValidator = function(schema) {
|
|
67
67
|
var descriptors = {};
|
|
68
68
|
if (schema.params) {
|
|
@@ -83,3 +83,9 @@ var createRequestSchemaValidator = function(schema) {
|
|
|
83
83
|
var RequestStruct = Struct(descriptors);
|
|
84
84
|
return createSchemaValidator(NonStrict(RequestStruct));
|
|
85
85
|
};
|
|
86
|
+
export {
|
|
87
|
+
baseMatch,
|
|
88
|
+
isHandler,
|
|
89
|
+
isSchemaHandler,
|
|
90
|
+
match
|
|
91
|
+
};
|
package/dist/esm/request.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/esm/response.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
var HandleSuccess = function(output) {
|
|
2
2
|
return {
|
|
3
3
|
type: "HandleSuccess",
|
|
4
4
|
value: output
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
var InputValidationError = function(message) {
|
|
8
8
|
return {
|
|
9
9
|
type: "InputValidationError",
|
|
10
|
-
message
|
|
10
|
+
message
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
var OutputValidationError = function(message) {
|
|
14
14
|
return {
|
|
15
15
|
type: "OutputValidationError",
|
|
16
|
-
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 {};
|
package/dist/esm-node/index.js
CHANGED
package/dist/esm-node/match.js
CHANGED
|
@@ -10,9 +10,9 @@ ${message}`;
|
|
|
10
10
|
return message;
|
|
11
11
|
};
|
|
12
12
|
const HANDLER_WITH_SCHEMA = "HANDLER_WITH_SCHEMA";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) => {
|
|
16
16
|
const validateApiInput = createRequestSchemaValidator(schema.request);
|
|
17
17
|
const validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
|
|
18
18
|
const handle = async (input) => {
|
|
@@ -32,7 +32,7 @@ export const baseMatch = (schema, handler) => {
|
|
|
32
32
|
[HANDLER_WITH_SCHEMA]: true
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
const match = baseMatch;
|
|
36
36
|
const createRequestSchemaValidator = (schema) => {
|
|
37
37
|
const descriptors = {};
|
|
38
38
|
if (schema.params) {
|
|
@@ -53,3 +53,9 @@ const createRequestSchemaValidator = (schema) => {
|
|
|
53
53
|
const RequestStruct = Struct(descriptors);
|
|
54
54
|
return createSchemaValidator(NonStrict(RequestStruct));
|
|
55
55
|
};
|
|
56
|
+
export {
|
|
57
|
+
baseMatch,
|
|
58
|
+
isHandler,
|
|
59
|
+
isSchemaHandler,
|
|
60
|
+
match
|
|
61
|
+
};
|
package/dist/esm-node/request.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
const HandleSuccess = (output) => ({
|
|
2
2
|
type: "HandleSuccess",
|
|
3
3
|
value: output
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
const InputValidationError = (message) => ({
|
|
6
6
|
type: "InputValidationError",
|
|
7
7
|
message
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
const OutputValidationError = (message) => ({
|
|
10
10
|
type: "OutputValidationError",
|
|
11
11
|
message
|
|
12
12
|
});
|
|
13
|
+
export {
|
|
14
|
+
HandleSuccess,
|
|
15
|
+
InputValidationError,
|
|
16
|
+
OutputValidationError
|
|
17
|
+
};
|
package/dist/esm-node/types.js
CHANGED
|
@@ -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.
|
|
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.
|
|
46
|
-
"@scripts/jest-config": "2.
|
|
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/",
|