@modern-js/bff-core 2.0.0-beta.6 → 2.0.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 +29 -0
- package/dist/js/modern/client/generate-client.js +1 -3
- package/dist/js/node/client/generate-client.js +1 -3
- package/dist/types/client/generate-client.d.ts +2 -2
- package/dist/types/client/result.d.ts +3 -3
- package/dist/types/router/types.d.ts +5 -5
- package/dist/types/router/utils.d.ts +3 -3
- package/dist/types/types.d.ts +12 -12
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @modern-js/bff-core
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [edd1cfb1af]
|
|
12
|
+
- Updated dependencies [dda38c9c3e]
|
|
13
|
+
- Updated dependencies [ffb2ed4]
|
|
14
|
+
- Updated dependencies [bbe4c4ab64]
|
|
15
|
+
- @modern-js/utils@2.0.0
|
|
16
|
+
- @modern-js/bff-runtime@2.0.0
|
|
17
|
+
|
|
18
|
+
## 2.0.0-beta.7
|
|
19
|
+
|
|
20
|
+
### Major Changes
|
|
21
|
+
|
|
22
|
+
- dda38c9c3e: chore: v2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [edd1cfb1af]
|
|
27
|
+
- Updated dependencies [dda38c9c3e]
|
|
28
|
+
- Updated dependencies [bbe4c4ab64]
|
|
29
|
+
- @modern-js/utils@2.0.0-beta.7
|
|
30
|
+
- @modern-js/bff-runtime@2.0.0-beta.7
|
|
31
|
+
|
|
3
32
|
## 2.0.0-beta.6
|
|
4
33
|
|
|
5
34
|
### Major Changes
|
|
@@ -64,9 +64,7 @@ const generateClient = (_0) => __async(void 0, [_0], function* ({
|
|
|
64
64
|
}
|
|
65
65
|
const upperHttpMethod = httpMethod.toUpperCase();
|
|
66
66
|
const routeName = routePath;
|
|
67
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${
|
|
68
|
-
port
|
|
69
|
-
)}${fetcher ? `, fetch` : ""});
|
|
67
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${process.env.PORT || String(port)}${fetcher ? `, fetch` : ""});
|
|
70
68
|
`;
|
|
71
69
|
}
|
|
72
70
|
const importCode = `import { createRequest } from '${requestCreator}';
|
|
@@ -93,9 +93,7 @@ const generateClient = (_0) => __async(void 0, [_0], function* ({
|
|
|
93
93
|
}
|
|
94
94
|
const upperHttpMethod = httpMethod.toUpperCase();
|
|
95
95
|
const routeName = routePath;
|
|
96
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${
|
|
97
|
-
port
|
|
98
|
-
)}${fetcher ? `, fetch` : ""});
|
|
96
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${process.env.PORT || String(port)}${fetcher ? `, fetch` : ""});
|
|
99
97
|
`;
|
|
100
98
|
}
|
|
101
99
|
const importCode = `import { createRequest } from '${requestCreator}';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from './result';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type GenClientResult = Result<string>;
|
|
3
|
+
export type GenClientOptions = {
|
|
4
4
|
resourcePath: string;
|
|
5
5
|
source: string;
|
|
6
6
|
apiDir: string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Err<T = unknown> = {
|
|
2
2
|
kind: 'Err';
|
|
3
3
|
value: T;
|
|
4
4
|
isErr: true;
|
|
5
5
|
isOk: false;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type Ok<T = unknown> = {
|
|
8
8
|
kind: 'Ok';
|
|
9
9
|
value: T;
|
|
10
10
|
isErr: false;
|
|
11
11
|
isOk: true;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type Result<T = unknown, E = string> = Err<E> | Ok<T>;
|
|
14
14
|
export declare const Err: <E = string>(value: E) => Err<E>;
|
|
15
15
|
export declare const Ok: <T, E = string>(value: T) => Result<T, E>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HttpMethod } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type ModuleInfo = {
|
|
3
3
|
filename: string;
|
|
4
4
|
module: HandlerModule;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
6
|
+
type Handler = (...args: any) => any | Promise<any>;
|
|
7
|
+
export type ApiHandler = Handler;
|
|
8
|
+
export type HandlerModule = Record<string, ApiHandler>;
|
|
9
|
+
export type APIHandlerInfo = {
|
|
10
10
|
handler: ApiHandler;
|
|
11
11
|
name: string;
|
|
12
12
|
httpMethod: HttpMethod;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIHandlerInfo, HandlerModule } from './types';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
type MaybeAsync<I> = I | Promise<I>;
|
|
3
|
+
export type NormalHandler = (...args: any[]) => any;
|
|
4
|
+
export type Handler<I, O> = (input: I) => MaybeAsync<O>;
|
|
5
5
|
export declare const getFiles: (lambdaDir: string, rules: string | string[]) => string[];
|
|
6
6
|
export declare const getPathFromFilename: (baseDir: string, filename: string) => string;
|
|
7
7
|
export declare const isHandler: (input: any) => input is Handler<any, any>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -30,17 +30,17 @@ export declare enum HttpMethod {
|
|
|
30
30
|
Option = "OPTION",
|
|
31
31
|
Head = "HEAD",
|
|
32
32
|
}
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
33
|
+
export type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
|
|
34
|
+
export type ExecuteFunc<Outputs> = (helper: ExecuteHelper<Outputs>, next: () => Promise<any>) => Promise<any>;
|
|
35
|
+
export type ExecuteHelper<Outputs> = {
|
|
36
36
|
result?: any;
|
|
37
37
|
inputs: Outputs;
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type MetadataHelper = {
|
|
40
40
|
setMetadata: <T = any>(key: any, value: T) => void;
|
|
41
41
|
getMetadata: <T = any>(key: any) => T;
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export type Operator<Input = any, Output = Input> = {
|
|
44
44
|
name: string;
|
|
45
45
|
inputType?: Input;
|
|
46
46
|
outputType?: Output;
|
|
@@ -48,11 +48,11 @@ export declare type Operator<Input = any, Output = Input> = {
|
|
|
48
48
|
validate?: ExecuteFunc<Output>;
|
|
49
49
|
execute?: ExecuteFunc<Output>;
|
|
50
50
|
};
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
51
|
+
export type MaybeAsync<T> = Promise<T> | T;
|
|
52
|
+
export type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? never : [input: Input]) => Output;
|
|
53
|
+
export type NonNullable<T> = Exclude<T, null | undefined>;
|
|
54
|
+
export type ExtractInputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['inputType']> : void };
|
|
55
|
+
export type ExtractOuputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['outputType']> : void };
|
|
56
|
+
export type ArrayToObject<T, R = {}> = T extends [infer First, ...infer Rest] ? First extends PromiseLike<infer PromiseValue> ? PromiseValue : First extends object ? Merge<First, ArrayToObject<Rest, R>> : ArrayToObject<Rest, R> : R;
|
|
57
|
+
export type AsyncFunction = (...args: any[]) => Promise<any>;
|
|
58
58
|
export declare const httpMethods: HttpMethod[];
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.0.0
|
|
14
|
+
"version": "2.0.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"esbuild-register": "^3.3.3",
|
|
31
31
|
"koa-compose": "^4.1.0",
|
|
32
32
|
"reflect-metadata": "^0.1.13",
|
|
33
|
-
"@modern-js/bff-runtime": "2.0.0
|
|
34
|
-
"@modern-js/utils": "2.0.0
|
|
33
|
+
"@modern-js/bff-runtime": "2.0.0",
|
|
34
|
+
"@modern-js/utils": "2.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "^27",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"type-fest": "2.15.0",
|
|
42
42
|
"typescript": "^4",
|
|
43
43
|
"zod": "^3.17.3",
|
|
44
|
-
"@scripts/
|
|
45
|
-
"@scripts/
|
|
44
|
+
"@scripts/build": "2.0.0",
|
|
45
|
+
"@scripts/jest-config": "2.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^3.17.3"
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"new": "modern-lib new",
|
|
61
|
+
"dev": "modern-lib build --watch",
|
|
61
62
|
"build": "modern-lib build",
|
|
62
63
|
"test": "jest --passWithNoTests"
|
|
63
64
|
}
|