vona-cli-set-api 1.0.283 → 1.0.287
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/package.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/eventListener.activate.ts +2 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/eventListener.register.ts +2 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/role.ts +2 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/user.ts +2 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/passportAdapter.ts +2 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/roleAdapter.ts +4 -5
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/userAdapter.ts +8 -9
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/auth.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/index.ts +4 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/jwt.ts +11 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/passport.ts +3 -9
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/role.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/user.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IEventExecute, NextEvent } from 'vona-module-a-event';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IUser, TypeEventActivateData, TypeEventActivateResult } from 'vona-module-a-user';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
import { EventListener } from 'vona-module-a-event';
|
|
5
5
|
|
|
@@ -11,7 +11,7 @@ export class EventListenerActivate
|
|
|
11
11
|
extends BeanBase
|
|
12
12
|
implements IEventExecute<TypeEventData, TypeEventResult> {
|
|
13
13
|
async execute(data: TypeEventData, next: NextEvent<TypeEventData, TypeEventResult>): Promise<TypeEventResult> {
|
|
14
|
-
const user = data as
|
|
14
|
+
const user = data as IUser;
|
|
15
15
|
if (user.name === 'admin') {
|
|
16
16
|
// role: admin
|
|
17
17
|
const roleAdmin = await this.scope.model.role.get({ name: 'admin' });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IEventExecute, NextEvent } from 'vona-module-a-event';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IUser, TypeEventRegisterData, TypeEventRegisterResult } from 'vona-module-a-user';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
import { EventListener } from 'vona-module-a-event';
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ export class EventListenerRegister
|
|
|
12
12
|
implements IEventExecute<TypeEventData, TypeEventResult> {
|
|
13
13
|
async execute(data: TypeEventData, next: NextEvent<TypeEventData, TypeEventResult>): Promise<TypeEventResult> {
|
|
14
14
|
// next: registered
|
|
15
|
-
const user = await next() as
|
|
15
|
+
const user = await next() as IUser;
|
|
16
16
|
// mail: activate
|
|
17
17
|
if (!data.autoActivate && user.email) {
|
|
18
18
|
await this.bean.mailConfirm.emailConfirm(user);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
import type { IRole } from 'vona-module-a-user';
|
|
2
3
|
import { Api, v } from 'vona-module-a-openapi';
|
|
3
4
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
4
5
|
import { $locale } from '../.metadata/index.ts';
|
|
@@ -6,7 +7,7 @@ import { $locale } from '../.metadata/index.ts';
|
|
|
6
7
|
export interface IEntityOptionsRole extends IDecoratorEntityOptions {}
|
|
7
8
|
|
|
8
9
|
@Entity<IEntityOptionsRole>('homeRole', { openapi: { title: $locale('Role') } })
|
|
9
|
-
export class EntityRole extends EntityBase {
|
|
10
|
+
export class EntityRole extends EntityBase implements IRole {
|
|
10
11
|
@Api.field(v.title($locale('RoleName')))
|
|
11
12
|
name: string;
|
|
12
13
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ILocaleInfos } from 'vona';
|
|
2
2
|
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
3
|
+
import type { IUser } from 'vona-module-a-user';
|
|
3
4
|
import { Api, v } from 'vona-module-a-openapi';
|
|
4
5
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
5
6
|
import { z } from 'zod';
|
|
@@ -8,7 +9,7 @@ import { $locale } from '../.metadata/index.ts';
|
|
|
8
9
|
export interface IEntityOptionsUser extends IDecoratorEntityOptions {}
|
|
9
10
|
|
|
10
11
|
@Entity<IEntityOptionsUser>('homeUser', { openapi: { title: $locale('User') } })
|
|
11
|
-
export class EntityUser extends EntityBase {
|
|
12
|
+
export class EntityUser extends EntityBase implements IUser {
|
|
12
13
|
@Api.field(v.title($locale('UserName')))
|
|
13
14
|
name: string;
|
|
14
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { IPassport,
|
|
1
|
+
import type { IPayloadData } from 'vona-module-a-jwt';
|
|
2
|
+
import type { IPassport, IPassportAdapter } from 'vona-module-a-user';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
import { Service } from 'vona-module-a-bean';
|
|
5
5
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
|
-
import type { IRoleAdapter } from 'vona-module-a-user';
|
|
3
|
-
import type { EntityRole } from 'vona-module-test-vona';
|
|
2
|
+
import type { IRole, IRoleAdapter } from 'vona-module-a-user';
|
|
4
3
|
import { BeanBase } from 'vona';
|
|
5
4
|
import { Service } from 'vona-module-a-bean';
|
|
6
5
|
|
|
7
6
|
@Service()
|
|
8
7
|
export class ServiceRoleAdapter extends BeanBase implements IRoleAdapter {
|
|
9
|
-
async findOneByName(name: string): Promise<
|
|
8
|
+
async findOneByName(name: string): Promise<IRole | undefined> {
|
|
10
9
|
return await this.scope.model.role.getByNameEqI(name);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
async findOne(role: Partial<
|
|
12
|
+
async findOne(role: Partial<IRole>): Promise<IRole | undefined> {
|
|
14
13
|
return await this.scope.model.role.get(role);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
async findAllByUserId(userId: TableIdentity): Promise<
|
|
16
|
+
async findAllByUserId(userId: TableIdentity): Promise<IRole[] | undefined> {
|
|
18
17
|
const user = await this.scope.model.user.get({ id: userId }, { include: { roles: true } });
|
|
19
18
|
return user?.roles;
|
|
20
19
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { TableIdentity } from 'table-identity';
|
|
2
|
-
import type { IAuthUserProfile,
|
|
3
|
-
import type { EntityUser } from '../entity/user.ts';
|
|
2
|
+
import type { IAuthUserProfile, IUser, IUserAdapter } from 'vona-module-a-user';
|
|
4
3
|
import { BeanBase } from 'vona';
|
|
5
4
|
import { Service } from 'vona-module-a-bean';
|
|
6
5
|
|
|
7
6
|
@Service()
|
|
8
7
|
export class ServiceUserAdapter extends BeanBase implements IUserAdapter {
|
|
9
|
-
async create(user: Partial<
|
|
8
|
+
async create(user: Partial<IUser>): Promise<IUser> {
|
|
10
9
|
return await this.scope.model.user.insert(user);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
async userOfProfile(profile: IAuthUserProfile): Promise<Partial<
|
|
12
|
+
async userOfProfile(profile: IAuthUserProfile): Promise<Partial<IUser>> {
|
|
14
13
|
return {
|
|
15
14
|
name: profile.username!,
|
|
16
15
|
email: profile.emails?.[0].value,
|
|
@@ -19,23 +18,23 @@ export class ServiceUserAdapter extends BeanBase implements IUserAdapter {
|
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
async createAnonymous(): Promise<Partial<
|
|
21
|
+
async createAnonymous(): Promise<Partial<IUser>> {
|
|
23
22
|
return { id: -1, anonymous: true, name: 'anonymous' };
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
async findOneByName(name: string): Promise<
|
|
25
|
+
async findOneByName(name: string): Promise<IUser | undefined> {
|
|
27
26
|
return await this.scope.model.user.getByNameEqI(name);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
async findOne(user: Partial<
|
|
29
|
+
async findOne(user: Partial<IUser>): Promise<IUser | undefined> {
|
|
31
30
|
return await this.scope.model.user.get(user);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
async update(user: Partial<
|
|
33
|
+
async update(user: Partial<IUser>): Promise<void> {
|
|
35
34
|
await this.scope.model.user.update(user);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
async remove(user: Partial<
|
|
37
|
+
async remove(user: Partial<IUser>): Promise<void> {
|
|
39
38
|
await this.scope.model.user.delete(user);
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
|
|
3
|
+
export interface IPayloadDataCustom {
|
|
4
|
+
userId: TableIdentity;
|
|
5
|
+
authId: TableIdentity;
|
|
6
|
+
token?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'vona-module-a-jwt' {
|
|
10
|
+
export interface IPayloadData extends IPayloadDataCustom {}
|
|
11
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type { IPayloadDataBase } from 'vona-module-a-jwt';
|
|
3
|
-
import type { IPassportBase } from 'vona-module-a-user';
|
|
1
|
+
export interface IPassportCustom {}
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
authId: TableIdentity;
|
|
8
|
-
token?: string;
|
|
3
|
+
declare module 'vona-module-a-user' {
|
|
4
|
+
export interface IPassport extends IPassportCustom {}
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
export interface IPassport extends IPassportBase {}
|