vona-module-a-user 5.0.13 → 5.0.14

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.
@@ -4,6 +4,7 @@ import type { EventOn } from 'vona-module-a-event';
4
4
  /** bean: begin */
5
5
  import type { BeanAuthInner } from '../bean/bean.authInner.ts';
6
6
  import type { BeanPassport } from '../bean/bean.passport.ts';
7
+ import type { BeanRoleInner } from '../bean/bean.roleInner.ts';
7
8
  import type { BeanUserInner } from '../bean/bean.userInner.ts';
8
9
  /** event: end */
9
10
  /** event: begin */
@@ -19,6 +20,7 @@ import type { TypeEventSignoutData, TypeEventSignoutResult } from '../bean/event
19
20
  /** bean: begin */
20
21
  import type { IGuardOptionsAdmin } from '../bean/guard.admin.ts';
21
22
  import type { IGuardOptionsPassport } from '../bean/guard.passport.ts';
23
+ import type { IGuardOptionsRoleName } from '../bean/guard.roleName.ts';
22
24
  import type { IGuardOptionsUserName } from '../bean/guard.userName.ts';
23
25
  import type { config } from '../config/config.ts';
24
26
  /** config: end */
@@ -32,6 +34,7 @@ import 'vona';
32
34
  import 'vona';
33
35
  export * from '../bean/bean.authInner.ts';
34
36
  export * from '../bean/bean.passport.ts';
37
+ export * from '../bean/bean.roleInner.ts';
35
38
  export * from '../bean/bean.userInner.ts';
36
39
  declare module 'vona-module-a-aspect' {
37
40
  interface IGuardRecordGlobal {
@@ -39,6 +42,7 @@ declare module 'vona-module-a-aspect' {
39
42
  }
40
43
  interface IGuardRecordLocal {
41
44
  'a-user:admin': IGuardOptionsAdmin;
45
+ 'a-user:roleName': IGuardOptionsRoleName;
42
46
  'a-user:userName': IGuardOptionsUserName;
43
47
  }
44
48
  }
@@ -47,6 +51,8 @@ declare module 'vona-module-a-user' {
47
51
  }
48
52
  interface GuardPassport {
49
53
  }
54
+ interface GuardRoleName {
55
+ }
50
56
  interface GuardUserName {
51
57
  }
52
58
  }
@@ -55,6 +61,8 @@ declare module 'vona-module-a-user' {
55
61
  export * from '../bean/event.createUserAnonymous.ts';
56
62
  export * from '../bean/event.signin.ts';
57
63
  export * from '../bean/event.signout.ts';
64
+ /** guard: begin */
65
+ export * from '../bean/guard.admin.ts';
58
66
  declare module 'vona' {
59
67
  }
60
68
  declare module 'vona-module-a-user' {
@@ -62,6 +70,8 @@ declare module 'vona-module-a-user' {
62
70
  }
63
71
  interface BeanPassport {
64
72
  }
73
+ interface BeanRoleInner {
74
+ }
65
75
  interface BeanUserInner {
66
76
  }
67
77
  }
@@ -69,12 +79,12 @@ declare module 'vona' {
69
79
  interface IBeanRecordGlobal {
70
80
  authInner: BeanAuthInner;
71
81
  passport: BeanPassport;
82
+ roleInner: BeanRoleInner;
72
83
  userInner: BeanUserInner;
73
84
  }
74
85
  }
75
- /** guard: begin */
76
- export * from '../bean/guard.admin.ts';
77
86
  export * from '../bean/guard.passport.ts';
87
+ export * from '../bean/guard.roleName.ts';
78
88
  export * from '../bean/guard.userName.ts';
79
89
  declare module 'vona' {
80
90
  }
@@ -3,5 +3,5 @@ import { BeanBase } from 'vona';
3
3
  export declare class BeanAuthInner extends BeanBase {
4
4
  private _authInnerAdapter;
5
5
  private get authInnerAdapter();
6
- get(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
6
+ findOne(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import type { IJwtClientRecord, IJwtSignOptions, IJwtToken, IPayloadDataBase } from 'vona-module-a-jwt';
2
2
  import type { IAuthBase, IAuthIdRecord, ISigninOptions } from '../types/auth.ts';
3
3
  import type { IPassportBase } from '../types/passport.ts';
4
+ import type { IRoleBase } from '../types/role.ts';
4
5
  import type { IUserBase, IUserNameRecord } from '../types/user.ts';
5
6
  import { BeanBase } from 'vona';
6
7
  export declare class BeanPassport extends BeanBase {
@@ -15,6 +16,7 @@ export declare class BeanPassport extends BeanBase {
15
16
  getCurrent(): IPassportBase | undefined;
16
17
  getCurrentUser(): IUserBase | undefined;
17
18
  getCurrentAuth(): IAuthBase | undefined;
19
+ getCurrentRoles(): IRoleBase[] | undefined;
18
20
  signin(passport: IPassportBase, options?: ISigninOptions): Promise<IJwtToken>;
19
21
  signout(): Promise<void>;
20
22
  signinSystem<K extends keyof IAuthIdRecord>(authName: IAuthIdRecord[K], authId: K, name?: string, options?: ISigninOptions): Promise<IJwtToken>;
@@ -0,0 +1,10 @@
1
+ import type { TableIdentity } from 'vona-module-a-database';
2
+ import type { IRoleBase } from '../types/role.ts';
3
+ import { BeanBase } from 'vona';
4
+ export declare class BeanRoleInner extends BeanBase {
5
+ private _roleInnerAdapter;
6
+ private get roleInnerAdapter();
7
+ findOneByName(name: string): Promise<IRoleBase | undefined>;
8
+ findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
9
+ findAllByUserId(userId: TableIdentity): Promise<IRoleBase[]>;
10
+ }
@@ -6,8 +6,8 @@ export declare class BeanUserInner extends BeanBase {
6
6
  private get userInnerAdapter();
7
7
  createByProfile(profile: IAuthUserProfile): Promise<IUserBase>;
8
8
  createAnonymous(): Promise<IUserBase>;
9
- getByName(name: string): Promise<IUserBase | undefined>;
10
- get(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
9
+ findOneByName(name: string): Promise<IUserBase | undefined>;
10
+ findOne(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
11
11
  update(user: Partial<IUserBase>): Promise<void>;
12
- delete(user: Partial<IUserBase>): Promise<void>;
12
+ remove(user: Partial<IUserBase>): Promise<void>;
13
13
  }
@@ -0,0 +1,11 @@
1
+ import type { Next } from 'vona';
2
+ import type { IDecoratorGuardOptions, IGuardExecute } from 'vona-module-a-aspect';
3
+ import type { IRoleNameRecord } from '../types/role.ts';
4
+ import { BeanBase } from 'vona';
5
+ export interface IGuardOptionsRoleName extends IDecoratorGuardOptions {
6
+ name?: keyof IRoleNameRecord | (keyof IRoleNameRecord)[];
7
+ passWhenMatched: boolean;
8
+ }
9
+ export declare class GuardRoleName extends BeanBase implements IGuardExecute {
10
+ execute(options: IGuardOptionsRoleName, next: Next): Promise<boolean>;
11
+ }
@@ -10,5 +10,6 @@ export declare function config(_app: VonaApplication): {
10
10
  passport: keyof IServiceRecord;
11
11
  userInner: keyof IServiceRecord;
12
12
  authInner: keyof IServiceRecord;
13
+ roleInner: keyof IServiceRecord;
13
14
  };
14
15
  };
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ import { Event, BeanEventBase } from 'vona-module-a-event';
5
5
  import { Guard, Aspect } from 'vona-module-a-aspect';
6
6
  import { Meta } from 'vona-module-a-meta';
7
7
 
8
- var _dec$a, _dec2$a, _class$a;
9
- let BeanAuthInner = (_dec$a = Bean(), _dec2$a = BeanInfo({
8
+ var _dec$c, _dec2$c, _class$c;
9
+ let BeanAuthInner = (_dec$c = Bean(), _dec2$c = BeanInfo({
10
10
  module: "a-user"
11
- }), _dec$a(_class$a = _dec2$a(_class$a = class BeanAuthInner extends BeanBase {
11
+ }), _dec$c(_class$c = _dec2$c(_class$c = class BeanAuthInner extends BeanBase {
12
12
  constructor(...args) {
13
13
  super(...args);
14
14
  this._authInnerAdapter = void 0;
@@ -20,11 +20,11 @@ let BeanAuthInner = (_dec$a = Bean(), _dec2$a = BeanInfo({
20
20
  }
21
21
  return this._authInnerAdapter;
22
22
  }
23
- async get(auth) {
23
+ async findOne(auth) {
24
24
  if (String(auth.id).charAt(0) === '-') return auth;
25
- return await this.authInnerAdapter.get(auth);
25
+ return await this.authInnerAdapter.findOne(auth);
26
26
  }
27
- }) || _class$a) || _class$a);
27
+ }) || _class$c) || _class$c);
28
28
 
29
29
  let __authAdapter;
30
30
  function setAuthAdapter(authAdapter) {
@@ -60,10 +60,10 @@ function $getUserIdSystem(_userName, userId) {
60
60
  return userId;
61
61
  }
62
62
 
63
- var _dec$9, _dec2$9, _class$9;
64
- let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
63
+ var _dec$b, _dec2$b, _class$b;
64
+ let BeanPassport = (_dec$b = Bean(), _dec2$b = BeanInfo({
65
65
  module: "a-user"
66
- }), _dec$9(_class$9 = _dec2$9(_class$9 = class BeanPassport extends BeanBase {
66
+ }), _dec$b(_class$b = _dec2$b(_class$b = class BeanPassport extends BeanBase {
67
67
  constructor(...args) {
68
68
  super(...args);
69
69
  this._authTokenAdapter = void 0;
@@ -104,6 +104,9 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
104
104
  getCurrentAuth() {
105
105
  return this.ctx.state.passport?.auth;
106
106
  }
107
+ getCurrentRoles() {
108
+ return this.ctx.state.passport?.roles;
109
+ }
107
110
  async signin(passport, options) {
108
111
  // current
109
112
  await this.setCurrent(passport);
@@ -129,7 +132,7 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
129
132
  await this.setCurrent(undefined);
130
133
  }
131
134
  async signinSystem(authName, authId, name, options) {
132
- const user = await this.bean.userInner.getByName(name ?? 'admin');
135
+ const user = await this.bean.userInner.findOneByName(name ?? 'admin');
133
136
  if (!user) return this.app.throw(401);
134
137
  const auth = {
135
138
  id: $getAuthIdSystem(authName, authId)
@@ -251,12 +254,38 @@ let BeanPassport = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
251
254
  return payloadData2;
252
255
  }
253
256
  }
254
- }) || _class$9) || _class$9);
257
+ }) || _class$b) || _class$b);
255
258
 
256
- var _dec$8, _dec2$8, _class$8;
257
- let BeanUserInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
259
+ var _dec$a, _dec2$a, _class$a;
260
+ let BeanRoleInner = (_dec$a = Bean(), _dec2$a = BeanInfo({
261
+ module: "a-user"
262
+ }), _dec$a(_class$a = _dec2$a(_class$a = class BeanRoleInner extends BeanBase {
263
+ constructor(...args) {
264
+ super(...args);
265
+ this._roleInnerAdapter = void 0;
266
+ }
267
+ get roleInnerAdapter() {
268
+ if (!this._roleInnerAdapter) {
269
+ const beanFullName = beanFullNameFromOnionName(this.scope.config.adapter.roleInner, 'service');
270
+ this._roleInnerAdapter = this.bean._getBean(beanFullName);
271
+ }
272
+ return this._roleInnerAdapter;
273
+ }
274
+ findOneByName(name) {
275
+ return this.roleInnerAdapter.findOneByName(name);
276
+ }
277
+ findOne(role) {
278
+ return this.roleInnerAdapter.findOne(role);
279
+ }
280
+ findAllByUserId(userId) {
281
+ return this.roleInnerAdapter.findAllByUserId(userId);
282
+ }
283
+ }) || _class$a) || _class$a);
284
+
285
+ var _dec$9, _dec2$9, _class$9;
286
+ let BeanUserInner = (_dec$9 = Bean(), _dec2$9 = BeanInfo({
258
287
  module: "a-user"
259
- }), _dec$8(_class$8 = _dec2$8(_class$8 = class BeanUserInner extends BeanBase {
288
+ }), _dec$9(_class$9 = _dec2$9(_class$9 = class BeanUserInner extends BeanBase {
260
289
  constructor(...args) {
261
290
  super(...args);
262
291
  this._userInnerAdapter = void 0;
@@ -274,42 +303,42 @@ let BeanUserInner = (_dec$8 = Bean(), _dec2$8 = BeanInfo({
274
303
  createAnonymous() {
275
304
  return this.userInnerAdapter.createAnonymous();
276
305
  }
277
- getByName(name) {
278
- return this.userInnerAdapter.getByName(name);
306
+ findOneByName(name) {
307
+ return this.userInnerAdapter.findOneByName(name);
279
308
  }
280
- get(user) {
281
- return this.userInnerAdapter.get(user);
309
+ findOne(user) {
310
+ return this.userInnerAdapter.findOne(user);
282
311
  }
283
312
  update(user) {
284
313
  return this.userInnerAdapter.update(user);
285
314
  }
286
- delete(user) {
287
- return this.userInnerAdapter.delete(user);
315
+ remove(user) {
316
+ return this.userInnerAdapter.remove(user);
288
317
  }
289
- }) || _class$8) || _class$8);
318
+ }) || _class$9) || _class$9);
319
+
320
+ var _dec$8, _dec2$8, _class$8;
321
+ let EventCreateUserAnonymous = (_dec$8 = Event(), _dec2$8 = BeanInfo({
322
+ module: "a-user"
323
+ }), _dec$8(_class$8 = _dec2$8(_class$8 = class EventCreateUserAnonymous extends BeanEventBase {}) || _class$8) || _class$8);
290
324
 
291
325
  var _dec$7, _dec2$7, _class$7;
292
- let EventCreateUserAnonymous = (_dec$7 = Event(), _dec2$7 = BeanInfo({
326
+ let EventSignin = (_dec$7 = Event(), _dec2$7 = BeanInfo({
293
327
  module: "a-user"
294
- }), _dec$7(_class$7 = _dec2$7(_class$7 = class EventCreateUserAnonymous extends BeanEventBase {}) || _class$7) || _class$7);
328
+ }), _dec$7(_class$7 = _dec2$7(_class$7 = class EventSignin extends BeanEventBase {}) || _class$7) || _class$7);
295
329
 
296
330
  var _dec$6, _dec2$6, _class$6;
297
- let EventSignin = (_dec$6 = Event(), _dec2$6 = BeanInfo({
331
+ let EventSignout = (_dec$6 = Event(), _dec2$6 = BeanInfo({
298
332
  module: "a-user"
299
- }), _dec$6(_class$6 = _dec2$6(_class$6 = class EventSignin extends BeanEventBase {}) || _class$6) || _class$6);
333
+ }), _dec$6(_class$6 = _dec2$6(_class$6 = class EventSignout extends BeanEventBase {}) || _class$6) || _class$6);
300
334
 
301
335
  var _dec$5, _dec2$5, _class$5;
302
- let EventSignout = (_dec$5 = Event(), _dec2$5 = BeanInfo({
303
- module: "a-user"
304
- }), _dec$5(_class$5 = _dec2$5(_class$5 = class EventSignout extends BeanEventBase {}) || _class$5) || _class$5);
305
-
306
- var _dec$4, _dec2$4, _class$4;
307
- let GuardAdmin = (_dec$4 = Guard({
336
+ let GuardAdmin = (_dec$5 = Guard({
308
337
  admin: true,
309
338
  passWhenMatched: true
310
- }), _dec2$4 = BeanInfo({
339
+ }), _dec2$5 = BeanInfo({
311
340
  module: "a-user"
312
- }), _dec$4(_class$4 = _dec2$4(_class$4 = class GuardAdmin extends BeanBase {
341
+ }), _dec$5(_class$5 = _dec2$5(_class$5 = class GuardAdmin extends BeanBase {
313
342
  async execute(options, next) {
314
343
  if (options.admin) {
315
344
  const isAdmin = await this.bean.passport.isAdmin();
@@ -319,16 +348,16 @@ let GuardAdmin = (_dec$4 = Guard({
319
348
  // next
320
349
  return next();
321
350
  }
322
- }) || _class$4) || _class$4);
351
+ }) || _class$5) || _class$5);
323
352
 
324
- var _dec$3, _dec2$3, _class$3;
325
- let GuardPassport = (_dec$3 = Guard({
353
+ var _dec$4, _dec2$4, _class$4;
354
+ let GuardPassport = (_dec$4 = Guard({
326
355
  global: true,
327
356
  public: false,
328
357
  checkAuthToken: true
329
- }), _dec2$3 = BeanInfo({
358
+ }), _dec2$4 = BeanInfo({
330
359
  module: "a-user"
331
- }), _dec$3(_class$3 = _dec2$3(_class$3 = class GuardPassport extends BeanBase {
360
+ }), _dec$4(_class$4 = _dec2$4(_class$4 = class GuardPassport extends BeanBase {
332
361
  async execute(options, next) {
333
362
  // auth token
334
363
  if (!this.bean.passport.getCurrent()) {
@@ -354,6 +383,38 @@ let GuardPassport = (_dec$3 = Guard({
354
383
  // next
355
384
  return next();
356
385
  }
386
+ }) || _class$4) || _class$4);
387
+
388
+ let __roleAdapter;
389
+ function setRoleAdapter(roleAdapter) {
390
+ __roleAdapter = roleAdapter;
391
+ }
392
+ function $getRoleId(role) {
393
+ return __roleAdapter.getRoleId(role);
394
+ }
395
+ function $getRoleName(role) {
396
+ return __roleAdapter.getRoleName(role);
397
+ }
398
+
399
+ var _dec$3, _dec2$3, _class$3;
400
+ let GuardRoleName = (_dec$3 = Guard({
401
+ passWhenMatched: true
402
+ }), _dec2$3 = BeanInfo({
403
+ module: "a-user"
404
+ }), _dec$3(_class$3 = _dec2$3(_class$3 = class GuardRoleName extends BeanBase {
405
+ async execute(options, next) {
406
+ if (!options.name) return this.app.throw(403);
407
+ const user = this.bean.passport.getCurrentUser();
408
+ if (!user || $getUserAnonymous(user)) return this.app.throw(403);
409
+ const roles = this.bean.passport.getCurrentRoles();
410
+ if (!roles) return this.app.throw(403);
411
+ const roleNames = roles?.map(item => $getRoleName(item));
412
+ const optionsName = Array.isArray(options.name) ? options.name : [options.name];
413
+ if (!roleNames.some(roleName => optionsName.includes(roleName))) return this.app.throw(403);
414
+ if (options.passWhenMatched) return true;
415
+ // next
416
+ return next();
417
+ }
357
418
  }) || _class$3) || _class$3);
358
419
 
359
420
  var _dec$2, _dec2$2, _class$2;
@@ -404,7 +465,8 @@ function config(_app) {
404
465
  authToken: 'home-user:authTokenAdapter',
405
466
  passport: 'home-user:passportAdapter',
406
467
  userInner: 'home-user:userInnerAdapter',
407
- authInner: 'home-user:authInnerAdapter'
468
+ authInner: 'home-user:authInnerAdapter',
469
+ roleInner: 'home-user:roleInnerAdapter'
408
470
  }
409
471
  };
410
472
  }
@@ -428,10 +490,14 @@ function Admin(options) {
428
490
  function UserName(options) {
429
491
  return Aspect.guard('a-user:userName', options);
430
492
  }
493
+ function RoleName(options) {
494
+ return Aspect.guard('a-user:roleName', options);
495
+ }
431
496
  const Passport = {
432
497
  admin: Admin,
433
498
  public: Public,
434
- userName: UserName
499
+ userName: UserName,
500
+ roleName: RoleName
435
501
  };
436
502
 
437
- export { $getAuthId, $getAuthIdSystem, $getUserAnonymous, $getUserAvatar, $getUserId, $getUserIdSystem, $getUserLocale, $getUserName, BeanAuthInner, BeanPassport, BeanUserInner, EventCreateUserAnonymous, EventSignin, EventSignout, GuardAdmin, GuardPassport, GuardUserName, MetaPrintTip, Passport, ScopeModuleAUser, config, setAuthAdapter, setUserAdapter };
503
+ export { $getAuthId, $getAuthIdSystem, $getRoleId, $getRoleName, $getUserAnonymous, $getUserAvatar, $getUserId, $getUserIdSystem, $getUserLocale, $getUserName, BeanAuthInner, BeanPassport, BeanRoleInner, BeanUserInner, EventCreateUserAnonymous, EventSignin, EventSignout, GuardAdmin, GuardPassport, GuardRoleName, GuardUserName, MetaPrintTip, Passport, ScopeModuleAUser, config, setAuthAdapter, setRoleAdapter, setUserAdapter };
@@ -1,3 +1,4 @@
1
1
  export * from './auth.ts';
2
2
  export * from './passport.ts';
3
+ export * from './role.ts';
3
4
  export * from './user.ts';
@@ -1,14 +1,17 @@
1
1
  import type { TypeUseOnionOmitOptionsGlobal } from 'vona-module-a-onion';
2
2
  import type { IGuardOptionsAdmin } from '../bean/guard.admin.ts';
3
3
  import type { IGuardOptionsPassport } from '../bean/guard.passport.ts';
4
+ import type { IGuardOptionsRoleName } from '../bean/guard.roleName.ts';
4
5
  import type { IGuardOptionsUserName } from '../bean/guard.userName.ts';
5
6
  declare function Public(options?: Partial<TypeUseOnionOmitOptionsGlobal<IGuardOptionsPassport>>): ClassDecorator & MethodDecorator;
6
7
  declare function Admin(options?: Partial<IGuardOptionsAdmin>): ClassDecorator & MethodDecorator;
7
8
  declare function UserName(options?: Partial<IGuardOptionsUserName>): ClassDecorator & MethodDecorator;
9
+ declare function RoleName(options?: Partial<IGuardOptionsRoleName>): ClassDecorator & MethodDecorator;
8
10
  export interface IDecoratorGroupPassport {
9
11
  admin: typeof Admin;
10
12
  public: typeof Public;
11
13
  userName: typeof UserName;
14
+ roleName: typeof RoleName;
12
15
  }
13
16
  export declare const Passport: IDecoratorGroupPassport;
14
17
  export {};
@@ -0,0 +1,5 @@
1
+ import type { TableIdentity } from 'vona-module-a-database';
2
+ import type { IRoleAdapter, IRoleBase } from '../types/role.ts';
3
+ export declare function setRoleAdapter(roleAdapter: IRoleAdapter): void;
4
+ export declare function $getRoleId(role: IRoleBase): TableIdentity;
5
+ export declare function $getRoleName(role: IRoleBase): string;
@@ -15,5 +15,5 @@ export interface ISigninOptions {
15
15
  authToken?: TypeAuthToken;
16
16
  }
17
17
  export interface IAuthInnerAdapter {
18
- get(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
18
+ findOne(auth: Partial<IAuthBase>): Promise<IAuthBase | undefined>;
19
19
  }
@@ -2,4 +2,5 @@ export * from './auth.ts';
2
2
  export * from './authProfile.ts';
3
3
  export * from './authToken.ts';
4
4
  export * from './passport.ts';
5
+ export * from './role.ts';
5
6
  export * from './user.ts';
@@ -1,9 +1,11 @@
1
1
  import type { IPayloadDataBase } from 'vona-module-a-jwt';
2
2
  import type { IAuthBase } from './auth.ts';
3
+ import type { IRoleBase } from './role.ts';
3
4
  import type { IUserBase } from './user.ts';
4
5
  export interface IPassportBase {
5
6
  user?: IUserBase;
6
7
  auth?: IAuthBase;
8
+ roles?: IRoleBase[];
7
9
  }
8
10
  export interface IPassportAdapter {
9
11
  isAdmin(user: IUserBase): Promise<boolean>;
@@ -0,0 +1,18 @@
1
+ import type { TableIdentity } from 'vona-module-a-database';
2
+ export interface IRoleNameRecord {
3
+ admin: never;
4
+ }
5
+ export interface IRoleIdRecord {
6
+ }
7
+ export interface IRoleBase {
8
+ id: TableIdentity;
9
+ }
10
+ export interface IRoleAdapter {
11
+ getRoleId(role: IRoleBase): TableIdentity;
12
+ getRoleName(role: IRoleBase): string;
13
+ }
14
+ export interface IRoleInnerAdapter {
15
+ findOneByName(name: string): Promise<IRoleBase | undefined>;
16
+ findOne(role: Partial<IRoleBase>): Promise<IRoleBase | undefined>;
17
+ findAllByUserId(userId: TableIdentity): Promise<IRoleBase[]>;
18
+ }
@@ -20,8 +20,8 @@ export interface IUserAdapter {
20
20
  export interface IUserInnerAdapter {
21
21
  createByProfile(profile: IAuthUserProfile): Promise<IUserBase>;
22
22
  createAnonymous(): Promise<IUserBase>;
23
- getByName(name: string): Promise<IUserBase | undefined>;
24
- get(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
23
+ findOneByName(name: string): Promise<IUserBase | undefined>;
24
+ findOne(user: Partial<IUserBase>): Promise<IUserBase | undefined>;
25
25
  update(user: Partial<IUserBase>): Promise<void>;
26
- delete(user: Partial<IUserBase>): Promise<void>;
26
+ remove(user: Partial<IUserBase>): Promise<void>;
27
27
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-user",
3
3
  "type": "module",
4
- "version": "5.0.13",
4
+ "version": "5.0.14",
5
5
  "title": "a-user",
6
6
  "vonaModule": {
7
7
  "dependencies": {}