vona-cli-set-api 1.0.164 → 1.0.167
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/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/src/controller/menu.ts +2 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/controller/passport.ts +2 -2
- package/cli/templates/tools/crud/boilerplate/src/controller/{{resourceName}}.ts_ +12 -6
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}Query.ts_ +9 -0
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}QueryRes.ts_ +9 -0
- package/cli/templates/tools/crud/boilerplate/src/service/{{resourceName}}.ts_ +7 -3
- package/cli/templates/tools/crud/boilerplate/test/{{resourceName}}.test.ts_ +4 -4
- package/package.json +2 -2
|
@@ -2,8 +2,8 @@ import type { IMenus } from 'vona-module-a-menu';
|
|
|
2
2
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
import { DtoMenus } from 'vona-module-a-menu';
|
|
5
|
-
import { Api,
|
|
6
|
-
import { Controller, Web } from 'vona-module-a-web';
|
|
5
|
+
import { Api, v } from 'vona-module-a-openapi';
|
|
6
|
+
import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
7
7
|
|
|
8
8
|
export interface IControllerOptionsMenu extends IDecoratorControllerOptions {}
|
|
9
9
|
|
|
@@ -6,9 +6,9 @@ import type { EntityUser } from '../entity/user.ts';
|
|
|
6
6
|
import { BeanBase } from 'vona';
|
|
7
7
|
import { DtoAuthSimple } from 'vona-module-a-authsimple';
|
|
8
8
|
import { DtoJwtToken } from 'vona-module-a-jwt';
|
|
9
|
-
import { Api,
|
|
9
|
+
import { Api, v } from 'vona-module-a-openapi';
|
|
10
10
|
import { Passport } from 'vona-module-a-user';
|
|
11
|
-
import { Controller, Web } from 'vona-module-a-web';
|
|
11
|
+
import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { DtoPassport } from '../dto/passport.ts';
|
|
14
14
|
import { DtoPassportJwt } from '../dto/passportJwt.ts';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-orm';
|
|
1
|
+
import type { IQueryParams, TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
|
+
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
3
4
|
import { BeanBase } from 'vona';
|
|
4
|
-
import { Api,
|
|
5
|
-
import { Controller, Web } from 'vona-module-a-web';
|
|
5
|
+
import { Api, v } from 'vona-module-a-openapi';
|
|
6
|
+
import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
6
7
|
import { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
8
|
+
import { Dto<%=argv.resourceNameCapitalize%>Query } from '../dto/<%=argv.resourceName%>Query.ts';
|
|
9
|
+
import { Dto<%=argv.resourceNameCapitalize%>QueryRes } from '../dto/<%=argv.resourceName%>QueryRes.ts';
|
|
7
10
|
import { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
8
11
|
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
9
12
|
|
|
@@ -18,9 +21,12 @@ export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
@Web.get()
|
|
21
|
-
@Api.body(
|
|
22
|
-
async
|
|
23
|
-
|
|
24
|
+
@Api.body(Dto<%=argv.resourceNameCapitalize%>QueryRes)
|
|
25
|
+
async findMany(@Arg.queryPro(Dto<%=argv.resourceNameCapitalize%>Query) params: IQueryParams<Model<%=argv.resourceNameCapitalize%>>): Promise<Dto<%=argv.resourceNameCapitalize%>QueryRes> {
|
|
26
|
+
if (!params.orders) {
|
|
27
|
+
params.orders = [['<%=argv.moduleResourceName%>.createdAt', 'desc']];
|
|
28
|
+
}
|
|
29
|
+
return await this.scope.service.<%=argv.resourceName%>.findMany(params);
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
@Web.get(':id')
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
3
|
+
import { Dto } from 'vona-module-a-web';
|
|
4
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
5
|
+
|
|
6
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Query extends IDecoratorDtoOptions {}
|
|
7
|
+
|
|
8
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Query>()
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>Query extends $Dto.queryPage(Entity<%=argv.resourceNameCapitalize%>, ['name']) {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
3
|
+
import { Dto } from 'vona-module-a-web';
|
|
4
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
5
|
+
|
|
6
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>QueryRes extends IDecoratorDtoOptions {}
|
|
7
|
+
|
|
8
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>QueryRes>()
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>QueryRes extends $Dto.selectAndCount(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-orm';
|
|
1
|
+
import type { IQueryParams, TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
3
|
+
import type { Dto<%=argv.resourceNameCapitalize%>QueryRes } from '../dto/<%=argv.resourceName%>QueryRes.ts';
|
|
3
4
|
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
4
5
|
import type { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
6
|
+
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
5
7
|
import { BeanBase } from 'vona';
|
|
6
8
|
import { Service } from 'vona-module-a-bean';
|
|
7
9
|
|
|
@@ -11,8 +13,10 @@ export class Service<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
|
11
13
|
return await this.scope.model.<%=argv.resourceName%>.insert(<%=argv.resourceName%>);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
async
|
|
15
|
-
return await this.scope.model.<%=argv.resourceName%>.
|
|
16
|
+
async findMany(params: IQueryParams<Model<%=argv.resourceNameCapitalize%>>): Promise<Dto<%=argv.resourceNameCapitalize%>QueryRes> {
|
|
17
|
+
return await this.scope.model.<%=argv.resourceName%>.selectAndCount({
|
|
18
|
+
...params,
|
|
19
|
+
});
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
async findOne(id: TableIdentity): Promise<Entity<%=argv.resourceNameCapitalize%> | undefined> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dto<%=argv.resourceNameCapitalize%>Create, Dto<%=argv.resourceNameCapitalize%>Update, Entity<%=argv.resourceNameCapitalize%> } from 'vona-module-<%=argv.moduleInfo.relativeName%>';
|
|
1
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Create, Dto<%=argv.resourceNameCapitalize%>QueryRes, Dto<%=argv.resourceNameCapitalize%>Update, Entity<%=argv.resourceNameCapitalize%> } from 'vona-module-<%=argv.moduleInfo.relativeName%>';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
import { describe, it } from 'node:test';
|
|
4
4
|
import { catchError } from '@cabloy/utils';
|
|
@@ -21,9 +21,9 @@ describe('<%=argv.resourceName%>.test.ts', () => {
|
|
|
21
21
|
// create
|
|
22
22
|
const <%=argv.resourceName%>: Entity<%=argv.resourceNameCapitalize%> = await app.bean.executor.performAction('post', '<%=argv.moduleActionPathRaw%>', { body: data });
|
|
23
23
|
assert.equal(<%=argv.resourceName%>.name, data.name);
|
|
24
|
-
//
|
|
25
|
-
const
|
|
26
|
-
assert.equal(
|
|
24
|
+
// findMany
|
|
25
|
+
const queryRes: Dto<%=argv.resourceNameCapitalize%>QueryRes = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>');
|
|
26
|
+
assert.equal(queryRes.list.findIndex(item => item.name === data.name) > -1, true);
|
|
27
27
|
// update
|
|
28
28
|
await app.bean.executor.performAction('patch', '<%=argv.moduleActionPathRaw%>/:id', {
|
|
29
29
|
params: { id: <%=argv.resourceName%>.id },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.167",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"urllib": "^4.6.11",
|
|
63
63
|
"uuid": "^11.1.0",
|
|
64
|
-
"vona-core": "^5.0.
|
|
64
|
+
"vona-core": "^5.0.47",
|
|
65
65
|
"why-is-node-running": "^3.2.2",
|
|
66
66
|
"yargs-parser": "^21.1.1"
|
|
67
67
|
},
|