@shys/crud 1.0.1-beta.8 → 1.0.1-beta.9

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/dist/generator.js CHANGED
@@ -251,25 +251,6 @@ export function buildFiles(params) {
251
251
  idxCount: idxFields.length,
252
252
  }),
253
253
  });
254
- if (onlyEntity) {
255
- return {
256
- files: resultFiles,
257
- Pascal,
258
- pluralKebab,
259
- Camel,
260
- sortable: [],
261
- filterable: [],
262
- searchable: [],
263
- };
264
- }
265
- const createFields = fields.filter(f => {
266
- if (finalBaseFieldNames.includes(f.camel))
267
- return false;
268
- if (f.pk && f.auto)
269
- return false;
270
- return true;
271
- });
272
- const writable = createFields.filter(f => !excludeWritableRegex.test(f.name));
273
254
  const isSensitive = (f) => /password|passwd|salt|token|secret|private_key/i.test(f.name + f.camel);
274
255
  const pkCamel = originalPkInfo?.camel || '';
275
256
  const pkCamels = pkFields.map(f => f.camel);
@@ -300,6 +281,25 @@ export function buildFiles(params) {
300
281
  searchable = hookResult.searchable;
301
282
  }
302
283
  }
284
+ if (onlyEntity) {
285
+ return {
286
+ files: resultFiles,
287
+ Pascal,
288
+ pluralKebab,
289
+ Camel,
290
+ sortable,
291
+ filterable,
292
+ searchable,
293
+ };
294
+ }
295
+ const createFields = fields.filter(f => {
296
+ if (finalBaseFieldNames.includes(f.camel))
297
+ return false;
298
+ if (f.pk && f.auto)
299
+ return false;
300
+ return true;
301
+ });
302
+ const writable = createFields.filter(f => !excludeWritableRegex.test(f.name));
303
303
  const enhancedCreateFields = createFields.map(f => enhanceField(f));
304
304
  const enhancedWritable = writable.map(f => enhanceField(f));
305
305
  const enhancedFilterable = filterableArr.map(f => enhanceField(f));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shys/crud",
3
- "version": "1.0.1-beta.8",
3
+ "version": "1.0.1-beta.9",
4
4
  "description": "MidwayJS v4 模块化 CRUD CLI 生成器",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -1,65 +1,65 @@
1
- import { Inject } from '@midwayjs/core';
2
- import { YSController, CrudPiped } from '@shys/core';
3
- import { {{ Pascal }} } from '../entity/{{ Camel }}.entity';
4
- import { {{ ServiceName }} } from '../service/{{ Camel }}.service';
5
- import {
6
- {{ CreateName }},
7
- {{ UpdateName }},
8
- {{ ReplaceName }},
9
- {{ QueryName }},
10
- } from '../dto/{{ Camel }}';
11
- import { {{ VOName }}, {{ ListVOName }} } from '../vo/{{ Camel }}';
12
-
13
- @YSController({
14
- tagName: {{ tagName | json }},
15
- description: {{ desc | json }},
16
- })
17
- @CrudPiped({
18
- model: {{ Pascal }},
19
- service: {{ ServiceName }},
20
- id: {{ idField | json }},
21
- dto: {
22
- create: {{ CreateName }},
23
- update: {{ UpdateName }},
24
- replace: {{ ReplaceName }},
25
- query: {{ QueryName }},
26
- },
27
- serialize: {
28
- get: {{ VOName }},
29
- list: {{ ListVOName }},
30
- create: {{ VOName }},
31
- update: {{ VOName }},
32
- },
33
- routes: {
34
- only: ['list', 'detail', 'create', 'update', 'replace', 'delete'],
35
- },
36
- query: {
37
- maxLimit: 100,
38
- defaultLimit: 10,
39
- sortable: [{{ sortable }}],
40
- filterable: [{{ filterable }}],
41
- searchable: [{{ searchable }}],
42
- defaultSort: {{ defaultSort }},
43
- },
44
- piped: {
45
- create: {
46
- enabled: true,
47
- stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
48
- validate: { enabled: true, errorStatus: 422 },
49
- },
50
- update: {
51
- enabled: true,
52
- stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
53
- validate: { enabled: true, errorStatus: 422 },
54
- },
55
- replace: {
56
- enabled: true,
57
- stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
58
- validate: { enabled: true, errorStatus: 422 },
59
- },
60
- },
61
- })
62
- export class {{ CtrlName }} {
63
- @Inject()
64
- crudService: {{ ServiceName }};
65
- }
1
+ import { Inject } from '@midwayjs/core';
2
+ import { YSController, CrudPiped } from '@shys/core';
3
+ import { {{ Pascal }} } from '../entity/{{ Camel }}.entity';
4
+ import { {{ ServiceName }} } from '../service/{{ Camel }}.service';
5
+ import {
6
+ {{ CreateName }},
7
+ {{ UpdateName }},
8
+ {{ ReplaceName }},
9
+ {{ QueryName }},
10
+ } from '../dto/{{ Camel }}';
11
+ import { {{ VOName }}, {{ ListVOName }} } from '../vo/{{ Camel }}';
12
+
13
+ @YSController({
14
+ tagName: {{ tagName | json }},
15
+ description: {{ desc | json }},
16
+ })
17
+ @CrudPiped({
18
+ model: {{ Pascal }},
19
+ service: {{ ServiceName }},
20
+ id: {{ idField | json }},
21
+ dto: {
22
+ create: {{ CreateName }},
23
+ update: {{ UpdateName }},
24
+ replace: {{ ReplaceName }},
25
+ query: {{ QueryName }},
26
+ },
27
+ serialize: {
28
+ get: {{ VOName }},
29
+ list: {{ ListVOName }},
30
+ create: {{ VOName }},
31
+ update: {{ VOName }},
32
+ },
33
+ routes: {
34
+ only: ['list', 'detail', 'create', 'update', 'replace', 'delete'],
35
+ },
36
+ query: {
37
+ maxLimit: 100,
38
+ defaultLimit: 10,
39
+ sortable: [{{ sortable }}],
40
+ filterable: [{{ filterable }}],
41
+ searchable: [{{ searchable }}],
42
+ defaultSort: {{ defaultSort }},
43
+ },
44
+ piped: {
45
+ create: {
46
+ enabled: true,
47
+ stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
48
+ validate: { enabled: true, errorStatus: 422 },
49
+ },
50
+ update: {
51
+ enabled: true,
52
+ stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
53
+ validate: { enabled: true, errorStatus: 422 },
54
+ },
55
+ replace: {
56
+ enabled: true,
57
+ stages: ['deserialize', 'sanitize', 'mapFields', 'transform', 'validate'],
58
+ validate: { enabled: true, errorStatus: 422 },
59
+ },
60
+ },
61
+ })
62
+ export class {{ CtrlName }} {
63
+ @Inject()
64
+ crudService: {{ ServiceName }};
65
+ }
@@ -1,4 +1,4 @@
1
- export * from './create.dto';
2
- export * from './update.dto';
3
- export * from './replace.dto';
4
- export * from './query.dto';
1
+ export * from './create.dto';
2
+ export * from './update.dto';
3
+ export * from './replace.dto';
4
+ export * from './query.dto';
@@ -1,17 +1,17 @@
1
- import { ApiPropertyOptional } from '@midwayjs/swagger';
2
- import { Rule } from '@midwayjs/validation';
3
- import * as Joi from 'joi';
4
- import { CrudBaseQueryDto } from '../../../../framework/dto/base.query.dto';
5
-
6
- export class {{ QueryName }} extends CrudBaseQueryDto {
7
- {% for f in filterable -%}
8
- @ApiPropertyOptional({
9
- type: {{ f.swagType | json }},
10
- {% if f.len %} maxLength: {{ f.len }},
11
- {% endif %} description: {{ (f.comment or f.camel) | json }},
12
- })
13
- @Rule({{ f.joiRule }}.optional())
14
- {{ f.camel }}?: {{ f.jsType }};
15
-
16
- {% endfor -%}
17
- }
1
+ import { ApiPropertyOptional } from '@midwayjs/swagger';
2
+ import { Rule } from '@midwayjs/validation';
3
+ import * as Joi from 'joi';
4
+ import { CrudBaseQueryDto } from '../../../../framework/dto/base.query.dto';
5
+
6
+ export class {{ QueryName }} extends CrudBaseQueryDto {
7
+ {% for f in filterable -%}
8
+ @ApiPropertyOptional({
9
+ type: {{ f.swagType | json }},
10
+ {% if f.len %} maxLength: {{ f.len }},
11
+ {% endif %} description: {{ (f.comment or f.camel) | json }},
12
+ })
13
+ @Rule({{ f.joiRule }}.optional())
14
+ {{ f.camel }}?: {{ f.jsType }};
15
+
16
+ {% endfor -%}
17
+ }
@@ -1,20 +1,20 @@
1
- {% if ormInfo.orm === 'typeorm' -%}
2
- import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
3
- import { InjectEntityModel } from '@midwayjs/typeorm';
4
- import { Repository } from 'typeorm';
5
- import { BaseTypeOrmCrudService } from '@shys/core';
6
- import { {{ Pascal }} } from '../entity/{{ Camel }}.entity';
7
-
8
- @Provide()
9
- @Scope(ScopeEnum.Request, { allowDowngrade: true })
10
- export class {{ ServiceName }} extends BaseTypeOrmCrudService<{{ Pascal }}> {
11
- @InjectEntityModel({{ Pascal }})
12
- repo: Repository<{{ Pascal }}>;
13
- }
14
- {%- else -%}
15
- // {{ ormInfo.orm }} Service 模板(请按项目注入方式调整)
16
- import { Provide } from '@midwayjs/core';
17
-
18
- @Provide()
19
- export class {{ ServiceName }} {}
20
- {%- endif %}
1
+ {% if ormInfo.orm === 'typeorm' -%}
2
+ import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
3
+ import { InjectEntityModel } from '@midwayjs/typeorm';
4
+ import { Repository } from 'typeorm';
5
+ import { BaseTypeOrmCrudService } from '@shys/core';
6
+ import { {{ Pascal }} } from '../entity/{{ Camel }}.entity';
7
+
8
+ @Provide()
9
+ @Scope(ScopeEnum.Request, { allowDowngrade: true })
10
+ export class {{ ServiceName }} extends BaseTypeOrmCrudService<{{ Pascal }}> {
11
+ @InjectEntityModel({{ Pascal }})
12
+ repo: Repository<{{ Pascal }}>;
13
+ }
14
+ {%- else -%}
15
+ // {{ ormInfo.orm }} Service 模板(请按项目注入方式调整)
16
+ import { Provide } from '@midwayjs/core';
17
+
18
+ @Provide()
19
+ export class {{ ServiceName }} {}
20
+ {%- endif %}