@biuxiu/codegen 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  import { ApiServiceField, DtoField, EntityField } from '../types';
2
- export declare function renderNestCode(entity: EntityField[], dto: DtoField[], apiService: ApiServiceField[], config: {
2
+ export declare function renderNestCode(config: {
3
3
  name: string;
4
4
  path?: string;
5
- }): void;
5
+ }, entity: EntityField[], dto: DtoField[], apiService: ApiServiceField[]): void;
@@ -1,6 +1,6 @@
1
1
  import { RenderNest } from "../code/nest";
2
2
  import { isReverse } from "../config";
3
- function renderNestCode(entity, dto, apiService, config) {
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();
Binary file
package/dist/types.d.ts CHANGED
@@ -24,5 +24,6 @@ export type EntityField = FieldSchema & {
24
24
  export type ApiServiceField = {
25
25
  key: 'get' | 'all' | 'delete' | 'update' | 'add';
26
26
  interceptor?: true;
27
+ noAuth?: true;
27
28
  };
28
29
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biuxiu/codegen",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "代码生成工具",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {