vona-cli-set-api 1.1.137 → 1.1.139
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/README.md +1 -1
- package/cli/templates/tools/crudStart/boilerplate/src/controller/{{resourceName}}.ts_ +14 -11
- package/cli/templates/tools/crudStart/snippets/3-en-us.ts +11 -1
- package/cli/templates/tools/crudStart/snippets/4-zh-cn.ts +11 -1
- package/dist/index.js +3 -3
- package/dist-cli/templates/tools/crudStart/snippets/3-en-us.js +11 -1
- package/dist-cli/templates/tools/crudStart/snippets/4-zh-cn.js +11 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
|
10
10
|
|
|
11
11
|
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
12
12
|
|
|
13
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
13
14
|
import { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.tsx';
|
|
14
15
|
import { Dto<%=argv.resourceNameCapitalize%>SelectReq } from '../dto/<%=argv.resourceName%>SelectReq.tsx';
|
|
15
16
|
import { Dto<%=argv.resourceNameCapitalize%>SelectRes } from '../dto/<%=argv.resourceName%>SelectRes.tsx';
|
|
@@ -18,40 +19,42 @@ import { Dto<%=argv.resourceNameCapitalize%>View } from '../dto/<%=argv.resource
|
|
|
18
19
|
|
|
19
20
|
export interface IControllerOptions<%=argv.resourceNameCapitalize%> extends IDecoratorControllerOptions {}
|
|
20
21
|
|
|
21
|
-
@Controller<IControllerOptions<%=argv.resourceNameCapitalize%>>('<%=argv.resourceName%>'
|
|
22
|
+
@Controller<IControllerOptions<%=argv.resourceNameCapitalize%>>('<%=argv.resourceName%>', {
|
|
23
|
+
summary: $locale('<%=argv.resourceNameCapitalize%>Controller'),
|
|
24
|
+
})
|
|
22
25
|
@Resource()
|
|
23
26
|
export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
24
|
-
@Web.post()
|
|
27
|
+
@Web.post({ summary: $locale('<%=argv.resourceNameCapitalize%>Create') })
|
|
25
28
|
@Api.body(v.tableIdentity())
|
|
26
|
-
@Passport.
|
|
29
|
+
@Passport.rbac()
|
|
27
30
|
async create(@Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<TableIdentity> {
|
|
28
31
|
return (await this.scope.service.<%=argv.resourceName%>.create(<%=argv.resourceName%>)).id;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
@Web.get()
|
|
34
|
+
@Web.get({ summary: $locale('<%=argv.resourceNameCapitalize%>Select') })
|
|
32
35
|
@Api.body(Dto<%=argv.resourceNameCapitalize%>SelectRes)
|
|
33
|
-
@Passport.
|
|
36
|
+
@Passport.rbac()
|
|
34
37
|
async select(@Arg.filter(Dto<%=argv.resourceNameCapitalize%>SelectReq) params: IQueryParams<Model<%=argv.resourceNameCapitalize%>>): Promise<Dto<%=argv.resourceNameCapitalize%>SelectRes> {
|
|
35
38
|
return await this.scope.service.<%=argv.resourceName%>.select(params);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
@Web.get(':id')
|
|
41
|
+
@Web.get(':id', { summary: $locale('<%=argv.resourceNameCapitalize%>View') })
|
|
39
42
|
@Api.body(v.optional(), v.object(Dto<%=argv.resourceNameCapitalize%>View))
|
|
40
|
-
@Passport.
|
|
43
|
+
@Passport.rbac()
|
|
41
44
|
async view(@Arg.param('id', v.tableIdentity()) id: TableIdentity): Promise<Dto<%=argv.resourceNameCapitalize%>View | undefined> {
|
|
42
45
|
return await this.scope.service.<%=argv.resourceName%>.view(id);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
@Web.patch(':id')
|
|
48
|
+
@Web.patch(':id', { summary: $locale('<%=argv.resourceNameCapitalize%>Update') })
|
|
46
49
|
@Api.body(z.null())
|
|
47
|
-
@Passport.
|
|
50
|
+
@Passport.rbac()
|
|
48
51
|
async update(@Arg.param('id', v.tableIdentity()) id: TableIdentity, @Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Update): Promise<void> {
|
|
49
52
|
await this.scope.service.<%=argv.resourceName%>.update(id, <%=argv.resourceName%>);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
@Web.delete(':id')
|
|
55
|
+
@Web.delete(':id', { summary: $locale('<%=argv.resourceNameCapitalize%>Delete') })
|
|
53
56
|
@Api.body(z.null())
|
|
54
|
-
@Passport.
|
|
57
|
+
@Passport.rbac()
|
|
55
58
|
async delete(@Arg.param('id', v.tableIdentity()) id: TableIdentity): Promise<void> {
|
|
56
59
|
await this.scope.service.<%=argv.resourceName%>.delete(id);
|
|
57
60
|
}
|
|
@@ -30,6 +30,16 @@ export default metadataCustomSnippet({
|
|
|
30
30
|
return fs.readFileSync(targetFile).toString('utf8');
|
|
31
31
|
},
|
|
32
32
|
async transform({ ast, argv }) {
|
|
33
|
-
|
|
33
|
+
const resource = argv.resourceNameCapitalize;
|
|
34
|
+
const resources = {
|
|
35
|
+
...__resources,
|
|
36
|
+
[`${resource}Controller`]: `${resource} Management`,
|
|
37
|
+
[`${resource}Create`]: `Create ${resource}`,
|
|
38
|
+
[`${resource}Select`]: `Query ${resource} List`,
|
|
39
|
+
[`${resource}View`]: `View ${resource}`,
|
|
40
|
+
[`${resource}Update`]: `Update ${resource}`,
|
|
41
|
+
[`${resource}Delete`]: `Delete ${resource}`,
|
|
42
|
+
};
|
|
43
|
+
return locale_transform({ ast, argv, resources });
|
|
34
44
|
},
|
|
35
45
|
});
|
|
@@ -13,6 +13,16 @@ export default metadataCustomSnippet({
|
|
|
13
13
|
file: 'src/config/locale/zh-cn.ts',
|
|
14
14
|
language: 'plain',
|
|
15
15
|
async transform({ ast, argv }) {
|
|
16
|
-
|
|
16
|
+
const resource = argv.resourceNameCapitalize;
|
|
17
|
+
const resources = {
|
|
18
|
+
...__resources,
|
|
19
|
+
[`${resource}Controller`]: `${resource}管理`,
|
|
20
|
+
[`${resource}Create`]: `创建${resource}`,
|
|
21
|
+
[`${resource}Select`]: `查询${resource}列表`,
|
|
22
|
+
[`${resource}View`]: `查看${resource}`,
|
|
23
|
+
[`${resource}Update`]: `更新${resource}`,
|
|
24
|
+
[`${resource}Delete`]: `删除${resource}`,
|
|
25
|
+
};
|
|
26
|
+
return locale_transform({ ast, argv, resources });
|
|
17
27
|
},
|
|
18
28
|
});
|
package/dist/index.js
CHANGED
|
@@ -2851,12 +2851,11 @@ async function generateOnions(sceneName, sceneMeta, moduleName, modulePath) {
|
|
|
2851
2851
|
get scope(): ${scopeModuleName};
|
|
2852
2852
|
}`);
|
|
2853
2853
|
if (!isBeanGlobal) {
|
|
2854
|
-
const contentOnionOptions = onionOptions ?
|
|
2854
|
+
const contentOnionOptions = onionOptions ? `\n get $onionOptions(): ${onionOptions};` : '';
|
|
2855
2855
|
contentScopes.push(`
|
|
2856
2856
|
export interface ${className} {
|
|
2857
2857
|
get $beanFullName(): '${beanFullNameFromOnionName(beanNameFull, sceneName)}';
|
|
2858
|
-
get $onionName(): '${beanNameFull}'
|
|
2859
|
-
${contentOnionOptions}
|
|
2858
|
+
get $onionName(): '${beanNameFull}';${contentOnionOptions}
|
|
2860
2859
|
}`);
|
|
2861
2860
|
}
|
|
2862
2861
|
}
|
|
@@ -3124,6 +3123,7 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
3124
3123
|
content = `// eslint-disable\n${content}`;
|
|
3125
3124
|
}
|
|
3126
3125
|
// save
|
|
3126
|
+
content = content.replace(/[^\S\r\n]+$/gm, '');
|
|
3127
3127
|
await fse.writeFile(metaIndexFile, content);
|
|
3128
3128
|
// await this.helper.formatFile({ fileName: metaIndexFile, logPrefix: 'format: ' });
|
|
3129
3129
|
// locales
|
|
@@ -20,6 +20,16 @@ export default metadataCustomSnippet({
|
|
|
20
20
|
return fs.readFileSync(targetFile).toString('utf8');
|
|
21
21
|
},
|
|
22
22
|
async transform({ ast, argv }) {
|
|
23
|
-
|
|
23
|
+
const resource = argv.resourceNameCapitalize;
|
|
24
|
+
const resources = {
|
|
25
|
+
...__resources,
|
|
26
|
+
[`${resource}Controller`]: `${resource} Management`,
|
|
27
|
+
[`${resource}Create`]: `Create ${resource}`,
|
|
28
|
+
[`${resource}Select`]: `Query ${resource} List`,
|
|
29
|
+
[`${resource}View`]: `View ${resource}`,
|
|
30
|
+
[`${resource}Update`]: `Update ${resource}`,
|
|
31
|
+
[`${resource}Delete`]: `Delete ${resource}`,
|
|
32
|
+
};
|
|
33
|
+
return locale_transform({ ast, argv, resources });
|
|
24
34
|
},
|
|
25
35
|
});
|
|
@@ -10,6 +10,16 @@ export default metadataCustomSnippet({
|
|
|
10
10
|
file: 'src/config/locale/zh-cn.ts',
|
|
11
11
|
language: 'plain',
|
|
12
12
|
async transform({ ast, argv }) {
|
|
13
|
-
|
|
13
|
+
const resource = argv.resourceNameCapitalize;
|
|
14
|
+
const resources = {
|
|
15
|
+
...__resources,
|
|
16
|
+
[`${resource}Controller`]: `${resource}管理`,
|
|
17
|
+
[`${resource}Create`]: `创建${resource}`,
|
|
18
|
+
[`${resource}Select`]: `查询${resource}列表`,
|
|
19
|
+
[`${resource}View`]: `查看${resource}`,
|
|
20
|
+
[`${resource}Update`]: `更新${resource}`,
|
|
21
|
+
[`${resource}Delete`]: `删除${resource}`,
|
|
22
|
+
};
|
|
23
|
+
return locale_transform({ ast, argv, resources });
|
|
14
24
|
},
|
|
15
25
|
});
|
package/package.json
CHANGED