@biuxiu/codegen 0.2.11 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/format/api.js +10 -1
- package/dist/index.js +4 -4
- package/dist/libs/nest-lib.d.ts +2 -2
- package/dist/libs/nest-lib.js +1 -1
- package/dist/lua_codegen_bg.wasm +0 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/format/api.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { BaseFormat } from "./base";
|
2
2
|
class ApiFormat extends BaseFormat {
|
3
3
|
#hasInterceptor = false;
|
4
|
+
#isNoAuth = false;
|
4
5
|
#moudleName;
|
5
6
|
#upperName;
|
6
7
|
#apiMap = {};
|
@@ -11,7 +12,7 @@ class ApiFormat extends BaseFormat {
|
|
11
12
|
this.#upperName = moduleName[0].toUpperCase() + moduleName.slice(1);
|
12
13
|
}
|
13
14
|
formatOnceStep() {
|
14
|
-
const { key, interceptor } = this.getCurSchema();
|
15
|
+
const { key, interceptor, noAuth } = this.getCurSchema();
|
15
16
|
if (this.#apiMap[key]) {
|
16
17
|
return;
|
17
18
|
}
|
@@ -20,6 +21,10 @@ class ApiFormat extends BaseFormat {
|
|
20
21
|
this.#hasInterceptor = true;
|
21
22
|
this.content += "\n@UseInterceptors(ClassSerializerInterceptor)\n";
|
22
23
|
}
|
24
|
+
if (noAuth) {
|
25
|
+
this.#isNoAuth = true;
|
26
|
+
this.content += "\n@NoAuthToken()\n";
|
27
|
+
}
|
23
28
|
if (key === "get") {
|
24
29
|
this.content += `
|
25
30
|
@Get(':id')
|
@@ -86,6 +91,10 @@ class ApiFormat extends BaseFormat {
|
|
86
91
|
if (this.#apiMap["add"] || this.#apiMap["update"]) {
|
87
92
|
this.#importCommon += "Body,";
|
88
93
|
}
|
94
|
+
if (this.#isNoAuth) {
|
95
|
+
this.importInfo += `import { NoAuthToken } from '@api/common/utils/passport'
|
96
|
+
`;
|
97
|
+
}
|
89
98
|
if (this.#hasInterceptor) {
|
90
99
|
this.#importCommon += "UseInterceptors,ClassSerializerInterceptor,";
|
91
100
|
}
|
package/dist/index.js
CHANGED
@@ -2,9 +2,9 @@ import { compileToByte } from "./compile";
|
|
2
2
|
import { existsSync } from "fs";
|
3
3
|
import { genLuaTypes } from "./gen-type";
|
4
4
|
import { setConfig, setReverse } from "./config";
|
5
|
-
async function startRun(filePath,
|
5
|
+
async function startRun(filePath, isDelete, config) {
|
6
6
|
if (config) setConfig(config);
|
7
|
-
setReverse(
|
7
|
+
setReverse(isDelete);
|
8
8
|
if (existsSync(filePath)) {
|
9
9
|
try {
|
10
10
|
const data = await compileToByte(filePath);
|
@@ -18,10 +18,10 @@ async function startRun(filePath, isReverse, config) {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
const startGen = (filePath, config) => {
|
21
|
-
return startRun(filePath,
|
21
|
+
return startRun(filePath, false, config);
|
22
22
|
};
|
23
23
|
const startRemove = (filePath, config) => {
|
24
|
-
return startRun(filePath,
|
24
|
+
return startRun(filePath, true, config);
|
25
25
|
};
|
26
26
|
export {
|
27
27
|
genLuaTypes,
|
package/dist/libs/nest-lib.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ApiServiceField, DtoField, EntityField } from '../types';
|
2
|
-
export declare function renderNestCode(
|
2
|
+
export declare function renderNestCode(config: {
|
3
3
|
name: string;
|
4
4
|
path?: string;
|
5
|
-
}): void;
|
5
|
+
}, entity: EntityField[], dto: DtoField[], apiService: ApiServiceField[]): void;
|
package/dist/libs/nest-lib.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { RenderNest } from "../code/nest";
|
2
2
|
import { isReverse } from "../config";
|
3
|
-
function renderNestCode(entity, dto, apiService
|
3
|
+
function renderNestCode(config, entity, dto, apiService) {
|
4
4
|
const api = new RenderNest(config.name, config.path);
|
5
5
|
if (isReverse()) {
|
6
6
|
api.remove();
|
package/dist/lua_codegen_bg.wasm
CHANGED
Binary file
|
package/dist/types.d.ts
CHANGED