vona-cli-set-api 1.0.172 → 1.0.174
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-user/src/.metadata/index.ts +30 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/eventListener.activate.ts +28 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/meta.version.ts +7 -8
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/config/locale/en-us.ts +3 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/config/locale/zh-cn.ts +3 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/dto/auth.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/roleUser.ts +2 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/user.ts +9 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/authAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/roleAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/userAdapter.ts +14 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/userInnerAdapter.ts +14 -4
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/passport.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/user.ts +3 -0
- package/cli/templates/tools/crud/boilerplate/src/controller/{{resourceName}}.ts_ +2 -1
- package/cli/templates/tools/crud/boilerplate/src/service/{{resourceName}}.ts_ +2 -1
- package/dist/lib/bean/cli.tools.metadata.js +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import type { TypeEntityMeta,TypeModelsClassLikeGeneral,TypeSymbolKeyFieldsMore,IModelRelationBelongsToMany } from 'vona-module-a-orm';
|
|
3
3
|
import type { TypeEntityOptionsFields,TypeControllerOptionsActions } from 'vona-module-a-openapi';
|
|
4
|
+
import type { TableIdentity } from 'table-identity';
|
|
4
5
|
/** entity: begin */
|
|
5
6
|
export * from '../entity/role.ts';
|
|
6
7
|
export * from '../entity/roleUser.ts';
|
|
@@ -135,7 +136,7 @@ declare module 'vona' {
|
|
|
135
136
|
}
|
|
136
137
|
/** model: end */
|
|
137
138
|
/** model: begin */
|
|
138
|
-
import type { IModelGetOptions, IModelMethodOptions, IModelSelectParams,
|
|
139
|
+
import type { IModelGetOptions, IModelMethodOptions, IModelSelectParams, TypeModelSelectAndCount, TypeModelRelationResult, TypeModelWhere, IModelInsertOptions, TypeModelMutateRelationData, IModelDeleteOptions, IModelUpdateOptions, IModelMutateOptions, IModelSelectCountParams, IModelSelectAggrParams, TypeModelAggrRelationResult, IModelSelectGroupParams, TypeModelGroupRelationResult } from 'vona-module-a-orm';
|
|
139
140
|
import { SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyModelOptions } from 'vona-module-a-orm';
|
|
140
141
|
declare module 'vona-module-home-user' {
|
|
141
142
|
export interface IModelOptionsUser {
|
|
@@ -149,6 +150,7 @@ declare module 'vona-module-home-user' {
|
|
|
149
150
|
[SymbolKeyModelOptions]: IModelOptionsRole;
|
|
150
151
|
get<T extends IModelGetOptions<EntityRole,ModelRole>>(where: TypeModelWhere<EntityRole>, options?: T): Promise<TypeModelRelationResult<EntityRole, ModelRole, T> | undefined>;
|
|
151
152
|
mget<T extends IModelGetOptions<EntityRole,ModelRole>>(ids: TableIdentity[], options?: T): Promise<TypeModelRelationResult<EntityRole, ModelRole, T>[]>;
|
|
153
|
+
selectAndCount<T extends IModelSelectParams<EntityRole,ModelRole,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelSelectAndCount<EntityRole, ModelRole, T>>;
|
|
152
154
|
select<T extends IModelSelectParams<EntityRole,ModelRole,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelRelationResult<EntityRole, ModelRole, T>[]>;
|
|
153
155
|
insert<T extends IModelInsertOptions<EntityRole,ModelRole>>(data?: TypeModelMutateRelationData<EntityRole,ModelRole, T>, options?: T): Promise<TypeModelMutateRelationData<EntityRole,ModelRole, T, true>>;
|
|
154
156
|
insertBulk<T extends IModelInsertOptions<EntityRole,ModelRole>>(items: TypeModelMutateRelationData<EntityRole,ModelRole, T>[], options?: T): Promise<TypeModelMutateRelationData<EntityRole,ModelRole, T, true>[]>;
|
|
@@ -168,6 +170,7 @@ export interface ModelRoleUser {
|
|
|
168
170
|
[SymbolKeyModelOptions]: IModelOptionsRoleUser;
|
|
169
171
|
get<T extends IModelGetOptions<EntityRoleUser,ModelRoleUser>>(where: TypeModelWhere<EntityRoleUser>, options?: T): Promise<TypeModelRelationResult<EntityRoleUser, ModelRoleUser, T> | undefined>;
|
|
170
172
|
mget<T extends IModelGetOptions<EntityRoleUser,ModelRoleUser>>(ids: TableIdentity[], options?: T): Promise<TypeModelRelationResult<EntityRoleUser, ModelRoleUser, T>[]>;
|
|
173
|
+
selectAndCount<T extends IModelSelectParams<EntityRoleUser,ModelRoleUser,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelSelectAndCount<EntityRoleUser, ModelRoleUser, T>>;
|
|
171
174
|
select<T extends IModelSelectParams<EntityRoleUser,ModelRoleUser,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelRelationResult<EntityRoleUser, ModelRoleUser, T>[]>;
|
|
172
175
|
insert<T extends IModelInsertOptions<EntityRoleUser,ModelRoleUser>>(data?: TypeModelMutateRelationData<EntityRoleUser,ModelRoleUser, T>, options?: T): Promise<TypeModelMutateRelationData<EntityRoleUser,ModelRoleUser, T, true>>;
|
|
173
176
|
insertBulk<T extends IModelInsertOptions<EntityRoleUser,ModelRoleUser>>(items: TypeModelMutateRelationData<EntityRoleUser,ModelRoleUser, T>[], options?: T): Promise<TypeModelMutateRelationData<EntityRoleUser,ModelRoleUser, T, true>[]>;
|
|
@@ -187,6 +190,7 @@ export interface ModelUser {
|
|
|
187
190
|
[SymbolKeyModelOptions]: IModelOptionsUser;
|
|
188
191
|
get<T extends IModelGetOptions<EntityUser,ModelUser>>(where: TypeModelWhere<EntityUser>, options?: T): Promise<TypeModelRelationResult<EntityUser, ModelUser, T> | undefined>;
|
|
189
192
|
mget<T extends IModelGetOptions<EntityUser,ModelUser>>(ids: TableIdentity[], options?: T): Promise<TypeModelRelationResult<EntityUser, ModelUser, T>[]>;
|
|
193
|
+
selectAndCount<T extends IModelSelectParams<EntityUser,ModelUser,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelSelectAndCount<EntityUser, ModelUser, T>>;
|
|
190
194
|
select<T extends IModelSelectParams<EntityUser,ModelUser,ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelRelationResult<EntityUser, ModelUser, T>[]>;
|
|
191
195
|
insert<T extends IModelInsertOptions<EntityUser,ModelUser>>(data?: TypeModelMutateRelationData<EntityUser,ModelUser, T>, options?: T): Promise<TypeModelMutateRelationData<EntityUser,ModelUser, T, true>>;
|
|
192
196
|
insertBulk<T extends IModelInsertOptions<EntityUser,ModelUser>>(items: TypeModelMutateRelationData<EntityUser,ModelUser, T>[], options?: T): Promise<TypeModelMutateRelationData<EntityUser,ModelUser, T, true>[]>;
|
|
@@ -294,6 +298,31 @@ declare module 'vona' {
|
|
|
294
298
|
}
|
|
295
299
|
}
|
|
296
300
|
/** service: end */
|
|
301
|
+
/** eventListener: begin */
|
|
302
|
+
export * from '../bean/eventListener.activate.ts';
|
|
303
|
+
|
|
304
|
+
import { type IDecoratorEventListenerOptions } from 'vona-module-a-event';
|
|
305
|
+
declare module 'vona-module-a-event' {
|
|
306
|
+
|
|
307
|
+
export interface IEventListenerRecord {
|
|
308
|
+
'home-user:activate': IDecoratorEventListenerOptions;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
declare module 'vona-module-home-user' {
|
|
314
|
+
|
|
315
|
+
export interface EventListenerActivate {
|
|
316
|
+
/** @internal */
|
|
317
|
+
get scope(): ScopeModuleHomeUser;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface EventListenerActivate {
|
|
321
|
+
get $beanFullName(): 'home-user.eventListener.activate';
|
|
322
|
+
get $onionName(): 'home-user:activate';
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/** eventListener: end */
|
|
297
326
|
/** meta: begin */
|
|
298
327
|
export * from '../bean/meta.index.ts';
|
|
299
328
|
export * from '../bean/meta.version.ts';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IEventExecute, NextEvent } from 'vona-module-a-event';
|
|
2
|
+
import type { TypeEventActivateData, TypeEventActivateResult } from 'vona-module-a-user';
|
|
3
|
+
import type { IUser } from '../types/user.ts';
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { EventListener } from 'vona-module-a-event';
|
|
6
|
+
|
|
7
|
+
type TypeEventData = TypeEventActivateData;
|
|
8
|
+
type TypeEventResult = TypeEventActivateResult;
|
|
9
|
+
|
|
10
|
+
@EventListener({ match: 'a-user:activate' })
|
|
11
|
+
export class EventListenerActivate
|
|
12
|
+
extends BeanBase
|
|
13
|
+
implements IEventExecute<TypeEventData, TypeEventResult> {
|
|
14
|
+
async execute(data: TypeEventData, next: NextEvent<TypeEventData, TypeEventResult>): Promise<TypeEventResult> {
|
|
15
|
+
const user = data as IUser;
|
|
16
|
+
if (user.name === 'admin') {
|
|
17
|
+
// role: admin
|
|
18
|
+
const roleAdmin = await this.scope.model.role.get({ name: 'admin' });
|
|
19
|
+
// userRole: admin
|
|
20
|
+
await this.scope.model.roleUser.insert({
|
|
21
|
+
userId: user.id,
|
|
22
|
+
roleId: roleAdmin!.id,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// next
|
|
26
|
+
return next();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IMetaVersionInit, IMetaVersionInitOptions, IMetaVersionUpdate, IMetaVersionUpdateOptions } from 'vona-module-a-version';
|
|
2
|
+
import type { IUser } from '../types/user.ts';
|
|
2
3
|
import { BeanBase } from 'vona';
|
|
3
4
|
import { Meta } from 'vona-module-a-meta';
|
|
4
5
|
|
|
@@ -20,6 +21,9 @@ export class MetaVersion extends BeanBase implements IMetaVersionUpdate, IMetaVe
|
|
|
20
21
|
table.basicFields();
|
|
21
22
|
table.string(entityUser.name, 255).comment(entityUser.$comment.name);
|
|
22
23
|
table.string(entityUser.avatar, 255).comment(entityUser.$comment.avatar);
|
|
24
|
+
table.string(entityUser.email, 255).comment(entityUser.$comment.email);
|
|
25
|
+
table.string(entityUser.mobile, 255).comment(entityUser.$comment.mobile);
|
|
26
|
+
table.boolean(entityUser.activated).defaultTo(entityUser.$default.activated).comment(entityUser.$comment.activated);
|
|
23
27
|
table.string(entityUser.locale, 255).comment(entityUser.$comment.locale);
|
|
24
28
|
});
|
|
25
29
|
// homeRoleUser
|
|
@@ -35,20 +39,15 @@ export class MetaVersion extends BeanBase implements IMetaVersionUpdate, IMetaVe
|
|
|
35
39
|
async init(options: IMetaVersionInitOptions) {
|
|
36
40
|
if (options.version === 1) {
|
|
37
41
|
// role: admin
|
|
38
|
-
|
|
42
|
+
await this.scope.model.role.insert({
|
|
39
43
|
name: 'admin',
|
|
40
44
|
});
|
|
41
45
|
// user: admin
|
|
42
|
-
|
|
46
|
+
await this.bean.userInner.register({
|
|
43
47
|
name: 'admin',
|
|
44
48
|
avatar: ':emoji:flower',
|
|
45
49
|
locale: undefined,
|
|
46
|
-
});
|
|
47
|
-
// userRole: admin
|
|
48
|
-
await this.scope.model.roleUser.insert({
|
|
49
|
-
userId: userAdmin.id,
|
|
50
|
-
roleId: roleAdmin.id,
|
|
51
|
-
});
|
|
50
|
+
} as IUser, true);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from '
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
2
|
import type { IAuthBase } from 'vona-module-a-user';
|
|
3
3
|
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
4
4
|
import { Api, v } from 'vona-module-a-openapi';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
3
|
import { Api, v } from 'vona-module-a-openapi';
|
|
3
4
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
4
5
|
|
|
@@ -15,6 +15,15 @@ export class EntityUser extends EntityBase {
|
|
|
15
15
|
@Api.field(v.title($locale('UserAvatar')), v.optional())
|
|
16
16
|
avatar?: string;
|
|
17
17
|
|
|
18
|
+
@Api.field(v.title($locale('UserEmail')), v.optional())
|
|
19
|
+
email?: string;
|
|
20
|
+
|
|
21
|
+
@Api.field(v.title($locale('UserMobile')), v.optional())
|
|
22
|
+
mobile?: string;
|
|
23
|
+
|
|
24
|
+
@Api.field(v.title($locale('UserActivated')), v.default(false))
|
|
25
|
+
activated: boolean;
|
|
26
|
+
|
|
18
27
|
@Api.field(v.title($locale('UserLocale')), z.string().optional())
|
|
19
28
|
locale?: keyof ILocaleInfos | undefined;
|
|
20
29
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { ILocaleInfos } from 'vona';
|
|
2
|
-
import type { TableIdentity } from 'vona-module-a-orm';
|
|
3
3
|
import type { IUserBase } from 'vona-module-a-user';
|
|
4
4
|
import type { IUser } from '../types/user.ts';
|
|
5
5
|
import { cast } from 'vona';
|
|
6
6
|
import { setUserAdapter } from 'vona-module-a-user';
|
|
7
7
|
|
|
8
|
-
setUserAdapter({ getUserId, getUserName, getUserAvatar, getUserLocale, getUserAnonymous });
|
|
8
|
+
setUserAdapter({ getUserId, getUserName, getUserAvatar, getUserEmail, getUserMobile, getUserActivated, getUserLocale, getUserAnonymous });
|
|
9
9
|
|
|
10
10
|
function getUserId(user: IUserBase): TableIdentity {
|
|
11
11
|
return cast<IUser>(user).id;
|
|
@@ -19,6 +19,18 @@ function getUserAvatar(user: IUserBase): string | undefined {
|
|
|
19
19
|
return cast<IUser>(user).avatar;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
function getUserEmail(user: IUserBase): string | undefined {
|
|
23
|
+
return cast<IUser>(user).email;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getUserMobile(user: IUserBase): string | undefined {
|
|
27
|
+
return cast<IUser>(user).mobile;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getUserActivated(user: IUserBase): boolean {
|
|
31
|
+
return cast<IUser>(user).activated;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
function getUserLocale(user: IUserBase): keyof ILocaleInfos | undefined {
|
|
23
35
|
return cast<IUser>(user).locale;
|
|
24
36
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { IAuthUserProfile, IUserBase, IUserInnerAdapter } from 'vona-module-a-user';
|
|
2
3
|
import type { IUser } from '../types/user.ts';
|
|
3
4
|
import { BeanBase } from 'vona';
|
|
@@ -5,16 +6,21 @@ import { Service } from 'vona-module-a-bean';
|
|
|
5
6
|
|
|
6
7
|
@Service()
|
|
7
8
|
export class ServiceUserInnerAdapter extends BeanBase implements IUserInnerAdapter {
|
|
8
|
-
async
|
|
9
|
-
return await this.scope.model.user.insert(
|
|
9
|
+
async create(user: Partial<IUser>): Promise<IUserBase> {
|
|
10
|
+
return await this.scope.model.user.insert(user);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async userOfProfile(profile: IAuthUserProfile): Promise<IUserBase> {
|
|
14
|
+
return {
|
|
10
15
|
name: profile.username!,
|
|
16
|
+
email: profile.emails?.[0].value,
|
|
11
17
|
avatar: profile.photos?.[0].value,
|
|
12
18
|
locale: undefined,
|
|
13
|
-
}
|
|
19
|
+
} as IUser;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
async createAnonymous(): Promise<IUserBase> {
|
|
17
|
-
return { id: -1, name: 'anonymous', avatar: undefined, locale: undefined } as
|
|
23
|
+
return { id: -1, name: 'anonymous', avatar: undefined, locale: undefined } as IUser;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
async findOneByName(name: string): Promise<IUserBase | undefined> {
|
|
@@ -32,4 +38,8 @@ export class ServiceUserInnerAdapter extends BeanBase implements IUserInnerAdapt
|
|
|
32
38
|
async remove(user: Partial<IUser>): Promise<void> {
|
|
33
39
|
await this.scope.model.user.delete(user);
|
|
34
40
|
}
|
|
41
|
+
|
|
42
|
+
async setActivated(id: TableIdentity, activated: boolean): Promise<void> {
|
|
43
|
+
await this.scope.model.user.update({ id, activated });
|
|
44
|
+
}
|
|
35
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IPayloadDataBase } from 'vona-module-a-jwt';
|
|
2
|
-
import type { TableIdentity } from '
|
|
2
|
+
import type { TableIdentity } from 'table-identity';
|
|
3
3
|
import type { IPassportBase } from 'vona-module-a-user';
|
|
4
4
|
import type { IAuth } from './auth.ts';
|
|
5
5
|
import type { IUser } from './user.ts';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IQueryParams } from 'vona-module-a-orm';
|
|
2
3
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
4
|
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
4
5
|
import { BeanBase } from 'vona';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IQueryParams } from 'vona-module-a-orm';
|
|
2
3
|
import type { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
3
4
|
import type { Dto<%=argv.resourceNameCapitalize%>QueryRes } from '../dto/<%=argv.resourceName%>QueryRes.ts';
|
|
4
5
|
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
@@ -134,6 +134,7 @@ export class CliToolsMetadata extends BeanCliBase {
|
|
|
134
134
|
_generatePatch(content) {
|
|
135
135
|
if (!content)
|
|
136
136
|
return content;
|
|
137
|
+
content = this._generatePatch_resources(content, 'table-identity', ['TableIdentity'], true);
|
|
137
138
|
content = this._generatePatch_resources(content, 'vona-module-a-openapi', ['TypeEntityOptionsFields', 'TypeControllerOptionsActions'], true);
|
|
138
139
|
content = this._generatePatch_resources(content, 'vona-module-a-orm', [
|
|
139
140
|
'TypeEntityMeta',
|