@modern-js/bff-core 2.6.1-alpha.1 → 2.7.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 +27 -0
- package/dist/cjs/client/generateClient.js +3 -3
- package/dist/cjs/operators/http.js +3 -3
- package/dist/cjs/router/index.js +2 -2
- package/dist/cjs/types.js +1 -1
- package/dist/esm/client/generateClient.js +3 -3
- package/dist/esm/operators/http.js +2 -2
- package/dist/esm/router/index.js +2 -2
- package/dist/esm/types.js +1 -1
- package/dist/types/operators/http.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @modern-js/bff-core
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 84bfb439b8: feat: support custom apiDir, lambdaDir and style of writing for bff
|
|
8
|
+
feat: 支持定制 api 目录,lambda 目录,bff 的写法
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 7bb1554194: fix: remove process.env.PORT from the bff generate client code
|
|
13
|
+
fix: 从 bff 的 generate client code 中移除 process.env.PORT
|
|
14
|
+
- 7fff9020e1: chore: make file naming consistent
|
|
15
|
+
|
|
16
|
+
chore: 统一文件命名为小驼峰格式
|
|
17
|
+
|
|
18
|
+
- 1eea234fdd: chore: make test files naming consistent
|
|
19
|
+
|
|
20
|
+
chore: 统一测试文件命名为小驼峰格式
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [0f15fc597c]
|
|
23
|
+
- Updated dependencies [dcad887024]
|
|
24
|
+
- Updated dependencies [a4672f7c16]
|
|
25
|
+
- Updated dependencies [7fff9020e1]
|
|
26
|
+
- Updated dependencies [84bfb439b8]
|
|
27
|
+
- @modern-js/utils@2.7.0
|
|
28
|
+
- @modern-js/bff-runtime@2.7.0
|
|
29
|
+
|
|
3
30
|
## 2.6.0
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
|
@@ -81,13 +81,13 @@ const generateClient = async ({
|
|
|
81
81
|
}
|
|
82
82
|
const upperHttpMethod = httpMethod.toUpperCase();
|
|
83
83
|
const routeName = routePath;
|
|
84
|
-
if (target === "
|
|
85
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${String(
|
|
84
|
+
if (target === "server") {
|
|
85
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${String(
|
|
86
86
|
port
|
|
87
87
|
)}, '${httpMethodDecider ? httpMethodDecider : "functionName"}' ${fetcher ? `, fetch` : ""});
|
|
88
88
|
`;
|
|
89
89
|
} else {
|
|
90
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}',
|
|
90
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${String(
|
|
91
91
|
port
|
|
92
92
|
)}, '${httpMethodDecider ? httpMethodDecider : "functionName"}' ${fetcher ? `, fetch` : ""});
|
|
93
93
|
`;
|
|
@@ -34,7 +34,7 @@ __export(http_exports, {
|
|
|
34
34
|
Head: () => Head,
|
|
35
35
|
Headers: () => Headers,
|
|
36
36
|
HttpCode: () => HttpCode,
|
|
37
|
-
|
|
37
|
+
Options: () => Options,
|
|
38
38
|
Params: () => Params,
|
|
39
39
|
Patch: () => Patch,
|
|
40
40
|
Post: () => Post,
|
|
@@ -80,7 +80,7 @@ const Delete = createHttpOperator(import_types.HttpMethod.Delete);
|
|
|
80
80
|
const Connect = createHttpOperator(import_types.HttpMethod.Connect);
|
|
81
81
|
const Trace = createHttpOperator(import_types.HttpMethod.Trace);
|
|
82
82
|
const Patch = createHttpOperator(import_types.HttpMethod.Patch);
|
|
83
|
-
const
|
|
83
|
+
const Options = createHttpOperator(import_types.HttpMethod.Options);
|
|
84
84
|
const Head = createHttpOperator(import_types.HttpMethod.Head);
|
|
85
85
|
const Data = (schema) => {
|
|
86
86
|
return {
|
|
@@ -197,7 +197,7 @@ const Redirect = (url) => {
|
|
|
197
197
|
Head,
|
|
198
198
|
Headers,
|
|
199
199
|
HttpCode,
|
|
200
|
-
|
|
200
|
+
Options,
|
|
201
201
|
Params,
|
|
202
202
|
Patch,
|
|
203
203
|
Post,
|
package/dist/cjs/router/index.js
CHANGED
|
@@ -165,8 +165,8 @@ class ApiRouter {
|
|
|
165
165
|
return import_types.HttpMethod.Trace;
|
|
166
166
|
case "PATCH":
|
|
167
167
|
return import_types.HttpMethod.Patch;
|
|
168
|
-
case "
|
|
169
|
-
return import_types.HttpMethod.
|
|
168
|
+
case "OPTIONS":
|
|
169
|
+
return import_types.HttpMethod.Options;
|
|
170
170
|
case "DEFAULT": {
|
|
171
171
|
return import_types.HttpMethod.Get;
|
|
172
172
|
}
|
package/dist/cjs/types.js
CHANGED
|
@@ -57,7 +57,7 @@ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
|
57
57
|
HttpMethod2["Connect"] = "CONNECT";
|
|
58
58
|
HttpMethod2["Trace"] = "TRACE";
|
|
59
59
|
HttpMethod2["Patch"] = "PATCH";
|
|
60
|
-
HttpMethod2["
|
|
60
|
+
HttpMethod2["Options"] = "OPTIONS";
|
|
61
61
|
HttpMethod2["Head"] = "HEAD";
|
|
62
62
|
return HttpMethod2;
|
|
63
63
|
})(HttpMethod || {});
|
|
@@ -48,13 +48,13 @@ const generateClient = async ({
|
|
|
48
48
|
}
|
|
49
49
|
const upperHttpMethod = httpMethod.toUpperCase();
|
|
50
50
|
const routeName = routePath;
|
|
51
|
-
if (target === "
|
|
52
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${String(
|
|
51
|
+
if (target === "server") {
|
|
52
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', process.env.PORT || ${String(
|
|
53
53
|
port
|
|
54
54
|
)}, '${httpMethodDecider ? httpMethodDecider : "functionName"}' ${fetcher ? `, fetch` : ""});
|
|
55
55
|
`;
|
|
56
56
|
} else {
|
|
57
|
-
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}',
|
|
57
|
+
handlersCode += `export ${exportStatement} createRequest('${routeName}', '${upperHttpMethod}', ${String(
|
|
58
58
|
port
|
|
59
59
|
)}, '${httpMethodDecider ? httpMethodDecider : "functionName"}' ${fetcher ? `, fetch` : ""});
|
|
60
60
|
`;
|
|
@@ -38,7 +38,7 @@ const Delete = createHttpOperator(HttpMethod.Delete);
|
|
|
38
38
|
const Connect = createHttpOperator(HttpMethod.Connect);
|
|
39
39
|
const Trace = createHttpOperator(HttpMethod.Trace);
|
|
40
40
|
const Patch = createHttpOperator(HttpMethod.Patch);
|
|
41
|
-
const
|
|
41
|
+
const Options = createHttpOperator(HttpMethod.Options);
|
|
42
42
|
const Head = createHttpOperator(HttpMethod.Head);
|
|
43
43
|
const Data = (schema) => {
|
|
44
44
|
return {
|
|
@@ -154,7 +154,7 @@ export {
|
|
|
154
154
|
Head,
|
|
155
155
|
Headers,
|
|
156
156
|
HttpCode,
|
|
157
|
-
|
|
157
|
+
Options,
|
|
158
158
|
Params,
|
|
159
159
|
Patch,
|
|
160
160
|
Post,
|
package/dist/esm/router/index.js
CHANGED
|
@@ -142,8 +142,8 @@ class ApiRouter {
|
|
|
142
142
|
return HttpMethod.Trace;
|
|
143
143
|
case "PATCH":
|
|
144
144
|
return HttpMethod.Patch;
|
|
145
|
-
case "
|
|
146
|
-
return HttpMethod.
|
|
145
|
+
case "OPTIONS":
|
|
146
|
+
return HttpMethod.Options;
|
|
147
147
|
case "DEFAULT": {
|
|
148
148
|
return HttpMethod.Get;
|
|
149
149
|
}
|
package/dist/esm/types.js
CHANGED
|
@@ -30,7 +30,7 @@ var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
|
30
30
|
HttpMethod2["Connect"] = "CONNECT";
|
|
31
31
|
HttpMethod2["Trace"] = "TRACE";
|
|
32
32
|
HttpMethod2["Patch"] = "PATCH";
|
|
33
|
-
HttpMethod2["
|
|
33
|
+
HttpMethod2["Options"] = "OPTIONS";
|
|
34
34
|
HttpMethod2["Head"] = "HEAD";
|
|
35
35
|
return HttpMethod2;
|
|
36
36
|
})(HttpMethod || {});
|
|
@@ -12,7 +12,7 @@ export declare const Delete: (urlPath: string) => Operator<void>;
|
|
|
12
12
|
export declare const Connect: (urlPath: string) => Operator<void>;
|
|
13
13
|
export declare const Trace: (urlPath: string) => Operator<void>;
|
|
14
14
|
export declare const Patch: (urlPath: string) => Operator<void>;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const Options: (urlPath: string) => Operator<void>;
|
|
16
16
|
export declare const Head: (urlPath: string) => Operator<void>;
|
|
17
17
|
export declare const Data: <Schema extends z.ZodType<any, z.ZodTypeDef, any>>(schema: Schema) => Operator<{
|
|
18
18
|
data: z.input<Schema>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare enum HttpMethod {
|
|
|
27
27
|
Connect = "CONNECT",
|
|
28
28
|
Trace = "TRACE",
|
|
29
29
|
Patch = "PATCH",
|
|
30
|
-
|
|
30
|
+
Options = "OPTIONS",
|
|
31
31
|
Head = "HEAD",
|
|
32
32
|
}
|
|
33
33
|
export type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
|
|
@@ -49,7 +49,7 @@ export type Operator<Input = any, Output = Input> = {
|
|
|
49
49
|
execute?: ExecuteFunc<Output>;
|
|
50
50
|
};
|
|
51
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 ?
|
|
52
|
+
export type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? void : [input: Input]) => Output;
|
|
53
53
|
export type NonNullable<T> = Exclude<T, null | undefined>;
|
|
54
54
|
export type ExtractInputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['inputType']> : void };
|
|
55
55
|
export type ExtractOuputType<T> = { [key in keyof T]: T[key] extends Operator<any, any> ? NonNullable<T[key]['outputType']> : void };
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.7.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/index.js",
|
|
@@ -25,24 +25,24 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.18.0",
|
|
28
|
-
"@modern-js/bff-runtime": "2.6.0",
|
|
29
|
-
"@modern-js/utils": "2.6.0",
|
|
30
28
|
"esbuild": "0.15.7",
|
|
31
29
|
"esbuild-register": "^3.3.3",
|
|
32
30
|
"koa-compose": "^4.1.0",
|
|
33
|
-
"reflect-metadata": "^0.1.13"
|
|
31
|
+
"reflect-metadata": "^0.1.13",
|
|
32
|
+
"@modern-js/bff-runtime": "2.7.0",
|
|
33
|
+
"@modern-js/utils": "2.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@modern-js/types": "2.6.0",
|
|
37
|
-
"@scripts/build": "2.6.0",
|
|
38
|
-
"@scripts/jest-config": "2.6.0",
|
|
39
36
|
"@types/jest": "^27",
|
|
40
37
|
"@types/koa-compose": "^3.2.5",
|
|
41
38
|
"@types/node": "^14",
|
|
42
39
|
"jest": "^27",
|
|
43
40
|
"type-fest": "2.15.0",
|
|
44
41
|
"typescript": "^4",
|
|
45
|
-
"zod": "^3.17.3"
|
|
42
|
+
"zod": "^3.17.3",
|
|
43
|
+
"@modern-js/types": "2.7.0",
|
|
44
|
+
"@scripts/jest-config": "2.7.0",
|
|
45
|
+
"@scripts/build": "2.7.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^3.17.3"
|