@modern-js/bff-runtime 1.2.1 → 1.2.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,35 @@
1
1
  # @modern-js/bff-runtime
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - a1198d509: feat: bump babel 7.18.0
8
+ - Updated dependencies [a1198d509]
9
+ - @modern-js/server-utils@1.2.10
10
+
11
+ ## 1.2.3
12
+
13
+ ### Patch Changes
14
+
15
+ - d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
16
+ - Updated dependencies [d32f35134]
17
+ - Updated dependencies [1a30be07b]
18
+ - @modern-js/server-utils@1.2.6
19
+
20
+ ## 1.2.2
21
+
22
+ ### Patch Changes
23
+
24
+ - 6cffe99d: chore:
25
+ remove react eslint rules for `modern-js` rule set.
26
+ add .eslintrc for each package to speed up linting
27
+ - 60f7d8bf: feat: add tests dir to npmignore
28
+ - Updated dependencies [6cffe99d]
29
+ - Updated dependencies [04ae5262]
30
+ - Updated dependencies [60f7d8bf]
31
+ - @modern-js/server-utils@1.2.3
32
+
3
33
  ## 1.2.1
4
34
 
5
35
  ### Patch Changes
@@ -1,11 +1,6 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
-
5
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
-
7
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
-
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";
9
4
  import { toSchemaCtor, Struct, NonStrict } from 'farrow-schema';
10
5
  import { createSchemaValidator } from 'farrow-schema/validator';
11
6
  import { HandleSuccess, InputValidationError, OutputValidationError } from "./response";
@@ -32,9 +27,9 @@ export var baseMatch = function baseMatch(schema, handler) {
32
27
  var validateApiOutput = createSchemaValidator(toSchemaCtor(schema.response));
33
28
 
34
29
  var handle = /*#__PURE__*/function () {
35
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(input) {
30
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
36
31
  var inputResult, output, outputResult;
37
- return _regeneratorRuntime.wrap(function _callee$(_context) {
32
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
38
33
  while (1) {
39
34
  switch (_context.prev = _context.next) {
40
35
  case 0:
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.1",
14
+ "version": "1.2.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -28,15 +28,15 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7",
32
- "@modern-js/server-utils": "^1.2.1",
31
+ "@babel/runtime": "^7.18.0",
32
+ "@modern-js/server-utils": "^1.2.10",
33
33
  "farrow-api": "^1.10.8",
34
34
  "farrow-http": "^1.10.8",
35
35
  "farrow-pipeline": "^1.10.6",
36
36
  "farrow-schema": "^1.10.8"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/jest": "^26",
39
+ "@types/jest": "^27",
40
40
  "@types/node": "^14",
41
41
  "@types/react": "^17",
42
42
  "@types/react-dom": "^17",
@@ -48,13 +48,35 @@
48
48
  },
49
49
  "publishConfig": {
50
50
  "registry": "https://registry.npmjs.org/",
51
- "access": "public",
52
- "types": "./dist/types/index.d.ts"
51
+ "access": "public"
52
+ },
53
+ "wireit": {
54
+ "build": {
55
+ "command": "modern build",
56
+ "files": [
57
+ "src/**/*",
58
+ "tsconfig.json",
59
+ "package.json"
60
+ ],
61
+ "output": [
62
+ "dist/**/*"
63
+ ]
64
+ },
65
+ "test": {
66
+ "command": "jest --passWithNoTests",
67
+ "files": [
68
+ "src/**/*",
69
+ "tsconfig.json",
70
+ "package.json",
71
+ "tests/**/*"
72
+ ],
73
+ "output": []
74
+ }
53
75
  },
54
76
  "scripts": {
55
77
  "new": "modern new",
56
- "build": "modern build",
57
- "test": "jest --passWithNoTests"
78
+ "build": "wireit",
79
+ "test": "wireit"
58
80
  },
59
81
  "readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
60
82
  }
package/jest.config.js DELETED
@@ -1,8 +0,0 @@
1
- const sharedConfig = require('@scripts/jest-config');
2
-
3
- /** @type {import('@jest/types').Config.InitialOptions} */
4
- module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
- ...sharedConfig,
7
- rootDir: __dirname,
8
- };
package/modern.config.js DELETED
@@ -1,2 +0,0 @@
1
- /** @type {import('@modern-js/module-tools').UserConfig} */
2
- module.exports = {};
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,133 +0,0 @@
1
- import assert from 'assert';
2
- import { baseMatch } from '../src/match';
3
- import { match, isHandler, isSchemaHandler, Any } from '../src';
4
-
5
- describe('match', () => {
6
- it('should work well', async () => {
7
- const foo = baseMatch(
8
- {
9
- request: { data: { foo: Number } },
10
- response: { foo: String },
11
- },
12
- input => ({ foo: String(input.data.foo) }),
13
- );
14
-
15
- const result = await foo({ data: { foo: 0 } });
16
-
17
- expect(result.type).toBe('HandleSuccess');
18
- assert(result.type === 'HandleSuccess');
19
- expect(result.value.foo).toBe('0');
20
- });
21
-
22
- it('should support all file in request', async () => {
23
- const foo = baseMatch(
24
- {
25
- request: {
26
- data: { foo: Number },
27
- params: { id: String },
28
- query: { key: String },
29
- headers: { 'Context-Length': String },
30
- cookies: { sid: String },
31
- },
32
- response: { foo: String },
33
- },
34
- input => ({ foo: String(input.data.foo) }),
35
- );
36
-
37
- const result = await foo({
38
- data: { foo: 0 },
39
- params: { id: 'foo' },
40
- query: { key: 'foo' },
41
- headers: { 'Context-Length': '100' },
42
- cookies: { sid: 'sid0' },
43
- });
44
-
45
- expect(result.type).toBe('HandleSuccess');
46
- assert(result.type === 'HandleSuccess');
47
- expect(result.value.foo).toBe('0');
48
- });
49
-
50
- it('should support body,formData,formUrlencoded when data is not exist', () => {
51
- const foo = baseMatch(
52
- {
53
- request: {},
54
- response: Any,
55
- },
56
- input => input,
57
- );
58
- foo({ body: 'test' });
59
- foo({ formData: { foo: 'test' } as any });
60
- foo({ formUrlencoded: { foo: 'test' } });
61
- });
62
-
63
- it('should fail when input does not match schema', async () => {
64
- const foo = baseMatch(
65
- {
66
- request: { data: { foo: Number } },
67
- response: { foo: String },
68
- },
69
- input => ({ foo: String(input.data.foo) }),
70
- );
71
-
72
- const result = await foo({ data: { foo: true as any } });
73
-
74
- expect(result.type).toBe('InputValidationError');
75
- assert(result.type === 'InputValidationError');
76
- expect(result.message).toBe('path: ["data","foo"]\ntrue is not a number');
77
- });
78
-
79
- it('should fail when output does not match schema', async () => {
80
- const foo = baseMatch(
81
- {
82
- request: { data: { foo: Number } },
83
- response: { foo: String },
84
- },
85
- input => ({ foo: input.data.foo } as any),
86
- );
87
-
88
- const result = await foo({ data: { foo: 0 } });
89
-
90
- expect(result.type).toBe('OutputValidationError');
91
- assert(result.type === 'OutputValidationError');
92
- expect(result.message).toBe('path: ["foo"]\n0 is not a string');
93
- });
94
-
95
- it('should type nest', async () => {
96
- const getFoo = (input: { foo: string }) => input;
97
-
98
- const foo = match(
99
- {
100
- request: { data: { foo: Number } },
101
- response: { foo: String },
102
- },
103
- input => ({ foo: input.data.foo } as any),
104
- );
105
-
106
- const result = await foo({ data: { foo: 0 } });
107
-
108
- getFoo(result);
109
- });
110
-
111
- it('isSchemaHandler', () => {
112
- const foo = baseMatch(
113
- {
114
- request: { data: { foo: Number } },
115
- response: { foo: String },
116
- },
117
- input => ({ foo: String(input.data.foo) }),
118
- );
119
-
120
- expect(isSchemaHandler(foo)).toBeTruthy();
121
- expect(isSchemaHandler({})).toBeFalsy();
122
- expect(isSchemaHandler('test')).toBeFalsy();
123
- expect(isSchemaHandler(null)).toBeFalsy();
124
- });
125
-
126
- it('isHandler', () => {
127
- // eslint-disable-next-line @typescript-eslint/no-empty-function
128
- expect(isHandler(() => {})).toBeTruthy();
129
- expect(isHandler({})).toBeFalsy();
130
- expect(isHandler('test')).toBeFalsy();
131
- expect(isHandler(null)).toBeFalsy();
132
- });
133
- });
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- }
10
- }
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {}
9
- },
10
- "include": ["src"]
11
- }