@admc-go-th/admc-library 1.0.21 → 1.0.23

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.
Files changed (46) hide show
  1. package/{authAssignment-zERupLM6.d.ts → authAssignment-DnWdDS8c.d.ts} +4 -0
  2. package/{authItem-Daiko8gP.d.ts → authItem-BglqcLa8.d.ts} +2 -0
  3. package/databases/models/authItem.ts +14 -0
  4. package/databases/models/authRole.ts +9 -0
  5. package/databases/models/index.ts +4 -1
  6. package/databases/models/oauthAccessToken.ts +16 -0
  7. package/databases/models/oauthRefreshToken.ts +16 -0
  8. package/databases/models/users.ts +20 -1
  9. package/databases/schema/authItem.ts +92 -91
  10. package/databases/schema/authItemChild.ts +33 -32
  11. package/databases/schema/index.ts +4 -0
  12. package/databases/schema/mdLink.ts +104 -0
  13. package/databases/schema/menu.ts +7 -0
  14. package/databases/schema/oauthAccessToken.ts +58 -0
  15. package/databases/schema/oauthRefreshToken.ts +58 -0
  16. package/databases/schema/userCenterV.ts +174 -0
  17. package/databases/schema/users.ts +15 -0
  18. package/databases/tables/authAssignment.d.ts +1 -1
  19. package/databases/tables/authAssignment.js +13 -0
  20. package/databases/tables/authItem.d.ts +1 -1
  21. package/databases/tables/authItem.js +6 -0
  22. package/databases/tables/authItemChild.d.ts +1 -1
  23. package/databases/tables/authItemChild.js +6 -0
  24. package/databases/tables/authRole.d.ts +1 -1
  25. package/databases/tables/authRole.js +13 -0
  26. package/databases/tables/index.d.ts +6 -2
  27. package/databases/tables/index.js +364 -0
  28. package/databases/tables/mdContent.d.ts +1 -1
  29. package/databases/tables/mdContent.js +13 -0
  30. package/databases/tables/mdContentGroup.d.ts +1 -1
  31. package/databases/tables/mdContentGroup.js +13 -0
  32. package/databases/tables/mdLink.d.ts +32 -0
  33. package/databases/tables/mdLink.js +124 -0
  34. package/databases/tables/menu.d.ts +1 -1
  35. package/databases/tables/menu.js +6 -0
  36. package/databases/tables/msModule.d.ts +1 -1
  37. package/databases/tables/msModule.js +6 -0
  38. package/databases/tables/oauthAccessToken.d.ts +20 -0
  39. package/databases/tables/oauthAccessToken.js +84 -0
  40. package/databases/tables/oauthRefreshToken.d.ts +20 -0
  41. package/databases/tables/oauthRefreshToken.js +84 -0
  42. package/databases/tables/userCenterV.d.ts +50 -0
  43. package/databases/tables/userCenterV.js +185 -0
  44. package/databases/tables/users.d.ts +1 -1
  45. package/databases/tables/users.js +13 -0
  46. package/package.json +1 -1
@@ -66,6 +66,7 @@ interface usersAttributes {
66
66
  verificationToken?: string;
67
67
  email?: string;
68
68
  authKey?: string;
69
+ secretKey?: string;
69
70
  accessToken?: string;
70
71
  userLevel?: number;
71
72
  userAuthen?: string;
@@ -75,6 +76,7 @@ interface usersAttributes {
75
76
  lastName?: string;
76
77
  phone?: string;
77
78
  status?: number;
79
+ is_2fa?: number;
78
80
  createdBy?: string;
79
81
  createdDate?: Date;
80
82
  updatedBy?: string;
@@ -89,6 +91,7 @@ declare class users extends Model<usersAttributes, usersAttributes> implements u
89
91
  verificationToken?: string;
90
92
  email?: string;
91
93
  authKey?: string;
94
+ secretKey?: string;
92
95
  accessToken?: string;
93
96
  userLevel?: number;
94
97
  userAuthen?: string;
@@ -98,6 +101,7 @@ declare class users extends Model<usersAttributes, usersAttributes> implements u
98
101
  lastName?: string;
99
102
  phone?: string;
100
103
  status?: number;
104
+ is_2fa?: number;
101
105
  createdBy?: string;
102
106
  createdDate?: Date;
103
107
  updatedBy?: string;
@@ -28,6 +28,7 @@ interface menuAttributes {
28
28
  display?: string;
29
29
  description?: string;
30
30
  moduleId?: number;
31
+ sort?: number;
31
32
  status?: number;
32
33
  createdBy?: string;
33
34
  createdDate?: Date;
@@ -42,6 +43,7 @@ declare class menu extends Model<menuAttributes, menuAttributes> implements menu
42
43
  display?: string;
43
44
  description?: string;
44
45
  moduleId?: number;
46
+ sort?: number;
45
47
  status?: number;
46
48
  createdBy?: string;
47
49
  createdDate?: Date;
@@ -0,0 +1,14 @@
1
+ import { FindOptions } from "sequelize/types/model";
2
+ import { authItem as AuthItem } from "../tables";
3
+
4
+ export class authItem extends AuthItem {
5
+ static async findByUUID(
6
+ keyName: string,
7
+ options?: Omit<FindOptions, 'where'>
8
+ ): Promise<AuthItem | null> {
9
+ return await this.findOne({
10
+ where: { keyName: keyName },
11
+ ...options,
12
+ });
13
+ }
14
+ }
@@ -1,5 +1,6 @@
1
1
  import { FindOptions } from "sequelize/types/model";
2
2
  import { authRole as AuthRole } from "../tables";
3
+ import { formatDate } from "../../utils/date";
3
4
 
4
5
  export class authRole extends AuthRole {
5
6
  static async findByUUID(
@@ -11,4 +12,12 @@ export class authRole extends AuthRole {
11
12
  ...options,
12
13
  });
13
14
  }
15
+
16
+ toJSON() {
17
+ const values = super.toJSON() as any;
18
+ values.createdDate = formatDate(values.createdDate);
19
+ values.updatedDate = formatDate(values.updatedDate);
20
+ delete values.id;
21
+ return values;
22
+ }
14
23
  }
@@ -1,4 +1,7 @@
1
1
  export * from "./menu";
2
2
  export * from "./users";
3
3
  export * from "./authRole";
4
- export * from "./authRoleChlid";
4
+ export * from "./authRoleChlid";
5
+ export * from "./oauthAccessToken";
6
+ export * from "./oauthRefreshToken";
7
+ export * from "./authItem";
@@ -0,0 +1,16 @@
1
+ import { FindOptions } from "sequelize/types/model";
2
+ import { oauthAccessToken as OauthAccessToken } from "../tables";
3
+
4
+ export class oauthAccessToken extends OauthAccessToken {
5
+ static async findByAccessToken(
6
+ accessToken: string,
7
+ clientId: string = "",
8
+ userId: number = 0,
9
+ options?: Omit<FindOptions, 'where'>
10
+ ): Promise<OauthAccessToken | null> {
11
+ return await this.findOne({
12
+ where: { accessToken, clientId, userId },
13
+ ...options,
14
+ });
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import { FindOptions } from "sequelize/types/model";
2
+ import { oauthRefreshToken as OauthRefreshToken } from "../tables";
3
+
4
+ export class oauthRefreshToken extends OauthRefreshToken {
5
+ static async findByRefreshToken(
6
+ refreshToken: string,
7
+ clientId: string = "",
8
+ userId: number = 0,
9
+ options?: Omit<FindOptions, 'where'>
10
+ ): Promise<OauthRefreshToken | null> {
11
+ return await this.findOne({
12
+ where: { refreshToken, clientId, userId },
13
+ ...options,
14
+ });
15
+ }
16
+ }
@@ -1,4 +1,4 @@
1
- import { users as Users} from "../tables";
1
+ import { users as Users, authAssignment as AuthAssignment, authRole as AuthRole, authRoleChild as AuthRoleChild } from "../tables";
2
2
  import { formatDate } from "../../utils/date";
3
3
 
4
4
  export class users extends Users {
@@ -12,4 +12,23 @@ export class users extends Users {
12
12
  values.created_date = formatDate(new Date());
13
13
  return values;
14
14
  }
15
+
16
+ static async findRoleByJoin(id: number) {
17
+ const model = await AuthAssignment.findOne({
18
+ where: {
19
+ userId: id
20
+ },
21
+ include: [
22
+ {
23
+ model: AuthRole,
24
+ include: [
25
+ {
26
+ model: AuthRoleChild,
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ });
32
+ return model;
33
+ }
15
34
  }
@@ -1,92 +1,93 @@
1
- import {
2
- Model, Table, Column, DataType, Index, Sequelize, ForeignKey, HasOne, HasMany
3
- } from "sequelize-typescript";
4
- import { menu } from "./menu";
5
- import { authItemChild } from "./authItemChild";
6
-
7
- export interface authItemAttributes {
8
- keyName: string;
9
- type: number;
10
- display: string;
11
- description?: string;
12
- status?: number;
13
- createdBy?: string;
14
- createdDate?: Date;
15
- updatedBy?: string;
16
- updatedDate?: Date;
17
- }
18
-
19
- @Table({
20
- tableName: "auth_item",
21
- timestamps: false
22
- })
23
- export class authItem extends Model<authItemAttributes, authItemAttributes> implements authItemAttributes {
24
-
25
- @Column({
26
- field: "key_name",
27
- primaryKey: true,
28
- type: DataType.STRING(100)
29
- })
30
- declare keyName: string;
31
-
32
- @Column({
33
- type: DataType.SMALLINT
34
- })
35
- declare type: number;
36
-
37
- @Column({
38
- type: DataType.STRING(255)
39
- })
40
- declare display: string;
41
-
42
- @Column({
43
- allowNull: true,
44
- type: DataType.STRING
45
- })
46
- declare description?: string;
47
-
48
- @Column({
49
- allowNull: true,
50
- type: DataType.INTEGER,
51
- defaultValue: "1"
52
- })
53
- declare status?: number;
54
-
55
- @Column({
56
- field: "created_by",
57
- allowNull: true,
58
- type: DataType.STRING(60)
59
- })
60
- declare createdBy?: string;
61
-
62
- @Column({
63
- field: "created_date",
64
- allowNull: true,
65
- type: DataType.DATE
66
- })
67
- declare createdDate?: Date;
68
-
69
- @Column({
70
- field: "updated_by",
71
- allowNull: true,
72
- type: DataType.STRING(60)
73
- })
74
- declare updatedBy?: string;
75
-
76
- @Column({
77
- field: "updated_date",
78
- allowNull: true,
79
- type: DataType.DATE
80
- })
81
- declare updatedDate?: Date;
82
-
83
- @HasOne(() => menu, {
84
- sourceKey: "keyName"
85
- })
86
- declare menu?: menu;
87
-
88
- @HasMany(() => authItemChild, {
89
- sourceKey: "keyName"
90
- })
91
- declare authItemChildren?: authItemChild[];
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey, HasOne, HasMany
3
+ } from "sequelize-typescript";
4
+ import { menu } from "./menu";
5
+ import { authItemChild } from "./authItemChild";
6
+
7
+ export interface authItemAttributes {
8
+ keyName: string;
9
+ type: number;
10
+ display: string;
11
+ description?: string;
12
+ status?: number;
13
+ createdBy?: string;
14
+ createdDate?: Date;
15
+ updatedBy?: string;
16
+ updatedDate?: Date;
17
+ }
18
+
19
+ @Table({
20
+ tableName: "auth_item",
21
+ timestamps: false
22
+ })
23
+ export class authItem extends Model<authItemAttributes, authItemAttributes> implements authItemAttributes {
24
+
25
+ @Column({
26
+ field: "key_name",
27
+ primaryKey: true,
28
+ type: DataType.STRING(100)
29
+ })
30
+ declare keyName: string;
31
+
32
+ @Column({
33
+ type: DataType.SMALLINT
34
+ })
35
+ declare type: number;
36
+
37
+ @Column({
38
+ type: DataType.STRING(255)
39
+ })
40
+ declare display: string;
41
+
42
+ @Column({
43
+ allowNull: true,
44
+ type: DataType.STRING
45
+ })
46
+ declare description?: string;
47
+
48
+ @Column({
49
+ allowNull: true,
50
+ type: DataType.INTEGER,
51
+ defaultValue: "1"
52
+ })
53
+ declare status?: number;
54
+
55
+ @Column({
56
+ field: "created_by",
57
+ allowNull: true,
58
+ type: DataType.STRING(60)
59
+ })
60
+ declare createdBy?: string;
61
+
62
+ @Column({
63
+ field: "created_date",
64
+ allowNull: true,
65
+ type: DataType.DATE
66
+ })
67
+ declare createdDate?: Date;
68
+
69
+ @Column({
70
+ field: "updated_by",
71
+ allowNull: true,
72
+ type: DataType.STRING(60)
73
+ })
74
+ declare updatedBy?: string;
75
+
76
+ @Column({
77
+ field: "updated_date",
78
+ allowNull: true,
79
+ type: DataType.DATE
80
+ })
81
+ declare updatedDate?: Date;
82
+
83
+ @HasOne(() => menu, {
84
+ sourceKey: "keyName"
85
+ })
86
+ declare menu?: menu;
87
+
88
+ @HasMany(() => authItemChild, {
89
+ sourceKey: "keyName"
90
+ })
91
+ declare authItemChildren?: authItemChild[];
92
+
92
93
  }
@@ -1,33 +1,34 @@
1
- import {
2
- Model, Table, Column, DataType, Index, Sequelize, ForeignKey, BelongsTo
3
- } from "sequelize-typescript";
4
- import { authItem } from "./authItem";
5
-
6
- export interface authItemChildAttributes {
7
- parent: string;
8
- child: string;
9
- }
10
-
11
- @Table({
12
- tableName: "auth_item_child",
13
- timestamps: false
14
- })
15
- export class authItemChild extends Model<authItemChildAttributes, authItemChildAttributes> implements authItemChildAttributes {
16
-
17
- @ForeignKey(() => authItem)
18
- @Column({
19
- primaryKey: true,
20
- type: DataType.STRING(64)
21
- })
22
- declare parent: string;
23
-
24
- @ForeignKey(() => authItem)
25
- @Column({
26
- primaryKey: true,
27
- type: DataType.STRING(64)
28
- })
29
- declare child: string;
30
-
31
- @BelongsTo(() => authItem)
32
- declare authItem?: authItem;
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey, BelongsTo
3
+ } from "sequelize-typescript";
4
+ import { authItem } from "./authItem";
5
+
6
+ export interface authItemChildAttributes {
7
+ parent: string;
8
+ child: string;
9
+ }
10
+
11
+ @Table({
12
+ tableName: "auth_item_child",
13
+ timestamps: false
14
+ })
15
+ export class authItemChild extends Model<authItemChildAttributes, authItemChildAttributes> implements authItemChildAttributes {
16
+
17
+ @ForeignKey(() => authItem)
18
+ @Column({
19
+ primaryKey: true,
20
+ type: DataType.STRING(64)
21
+ })
22
+ declare parent: string;
23
+
24
+ @ForeignKey(() => authItem)
25
+ @Column({
26
+ primaryKey: true,
27
+ type: DataType.STRING(64)
28
+ })
29
+ declare child: string;
30
+
31
+ @BelongsTo(() => authItem)
32
+ declare authItem?: authItem;
33
+
33
34
  }
@@ -5,6 +5,10 @@ export * from "./authRole";
5
5
  export * from "./authRoleChild";
6
6
  export * from "./mdContent";
7
7
  export * from "./mdContentGroup";
8
+ export * from "./mdLink";
8
9
  export * from "./menu";
9
10
  export * from "./msModule";
11
+ export * from "./oauthAccessToken";
12
+ export * from "./oauthRefreshToken";
13
+ export * from "./userCenterV";
10
14
  export * from "./users";
@@ -0,0 +1,104 @@
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey
3
+ } from "sequelize-typescript";
4
+
5
+ export interface mdLinkAttributes {
6
+ id?: number;
7
+ uuid: string;
8
+ keyName?: string;
9
+ name?: string;
10
+ url?: string;
11
+ target?: string;
12
+ sort?: number;
13
+ status?: number;
14
+ createdBy?: string;
15
+ createdDate?: Date;
16
+ updatedBy?: string;
17
+ updatedDate?: Date;
18
+ }
19
+
20
+ @Table({
21
+ tableName: "md_link",
22
+ timestamps: false
23
+ })
24
+ export class mdLink extends Model<mdLinkAttributes, mdLinkAttributes> implements mdLinkAttributes {
25
+
26
+ @Column({
27
+ primaryKey: true,
28
+ autoIncrement: true,
29
+ type: DataType.INTEGER
30
+ })
31
+ declare id?: number;
32
+
33
+ @Column({
34
+ type: DataType.STRING(60)
35
+ })
36
+ declare uuid: string;
37
+
38
+ @Column({
39
+ field: "key_name",
40
+ allowNull: true,
41
+ type: DataType.STRING(100)
42
+ })
43
+ declare keyName?: string;
44
+
45
+ @Column({
46
+ allowNull: true,
47
+ type: DataType.STRING(255)
48
+ })
49
+ declare name?: string;
50
+
51
+ @Column({
52
+ allowNull: true,
53
+ type: DataType.STRING(255)
54
+ })
55
+ declare url?: string;
56
+
57
+ @Column({
58
+ allowNull: true,
59
+ type: DataType.STRING(10)
60
+ })
61
+ declare target?: string;
62
+
63
+ @Column({
64
+ allowNull: true,
65
+ type: DataType.INTEGER
66
+ })
67
+ declare sort?: number;
68
+
69
+ @Column({
70
+ allowNull: true,
71
+ type: DataType.INTEGER,
72
+ defaultValue: "1"
73
+ })
74
+ declare status?: number;
75
+
76
+ @Column({
77
+ field: "created_by",
78
+ allowNull: true,
79
+ type: DataType.STRING(60)
80
+ })
81
+ declare createdBy?: string;
82
+
83
+ @Column({
84
+ field: "created_date",
85
+ allowNull: true,
86
+ type: DataType.DATE
87
+ })
88
+ declare createdDate?: Date;
89
+
90
+ @Column({
91
+ field: "updated_by",
92
+ allowNull: true,
93
+ type: DataType.STRING(60)
94
+ })
95
+ declare updatedBy?: string;
96
+
97
+ @Column({
98
+ field: "updated_date",
99
+ allowNull: true,
100
+ type: DataType.DATE
101
+ })
102
+ declare updatedDate?: Date;
103
+
104
+ }
@@ -12,6 +12,7 @@ export interface menuAttributes {
12
12
  display?: string;
13
13
  description?: string;
14
14
  moduleId?: number;
15
+ sort?: number;
15
16
  status?: number;
16
17
  createdBy?: string;
17
18
  createdDate?: Date;
@@ -71,6 +72,12 @@ export class menu extends Model<menuAttributes, menuAttributes> implements menuA
71
72
  })
72
73
  declare moduleId?: number;
73
74
 
75
+ @Column({
76
+ allowNull: true,
77
+ type: DataType.INTEGER
78
+ })
79
+ declare sort?: number;
80
+
74
81
  @Column({
75
82
  allowNull: true,
76
83
  type: DataType.INTEGER
@@ -0,0 +1,58 @@
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey
3
+ } from "sequelize-typescript";
4
+
5
+ export interface oauthAccessTokenAttributes {
6
+ accessToken: string;
7
+ clientId: string;
8
+ userId?: number;
9
+ expires?: Date;
10
+ scope?: string;
11
+ createdDate?: Date;
12
+ }
13
+
14
+ @Table({
15
+ tableName: "oauth_access_token",
16
+ timestamps: false
17
+ })
18
+ export class oauthAccessToken extends Model<oauthAccessTokenAttributes, oauthAccessTokenAttributes> implements oauthAccessTokenAttributes {
19
+
20
+ @Column({
21
+ field: "access_token",
22
+ type: DataType.STRING(1000)
23
+ })
24
+ declare accessToken: string;
25
+
26
+ @Column({
27
+ field: "client_id",
28
+ type: DataType.STRING(32)
29
+ })
30
+ declare clientId: string;
31
+
32
+ @Column({
33
+ field: "user_id",
34
+ allowNull: true,
35
+ type: DataType.INTEGER
36
+ })
37
+ declare userId?: number;
38
+
39
+ @Column({
40
+ type: DataType.DATE,
41
+ defaultValue: DataType.NOW
42
+ })
43
+ declare expires?: Date;
44
+
45
+ @Column({
46
+ allowNull: true,
47
+ type: DataType.STRING(2000)
48
+ })
49
+ declare scope?: string;
50
+
51
+ @Column({
52
+ field: "created_date",
53
+ type: DataType.DATE,
54
+ defaultValue: DataType.NOW
55
+ })
56
+ declare createdDate?: Date;
57
+
58
+ }
@@ -0,0 +1,58 @@
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey
3
+ } from "sequelize-typescript";
4
+
5
+ export interface oauthRefreshTokenAttributes {
6
+ refreshToken: string;
7
+ clientId: string;
8
+ userId?: number;
9
+ expires?: Date;
10
+ scope?: string;
11
+ createdDate?: Date;
12
+ }
13
+
14
+ @Table({
15
+ tableName: "oauth_refresh_token",
16
+ timestamps: false
17
+ })
18
+ export class oauthRefreshToken extends Model<oauthRefreshTokenAttributes, oauthRefreshTokenAttributes> implements oauthRefreshTokenAttributes {
19
+
20
+ @Column({
21
+ field: "refresh_token",
22
+ type: DataType.STRING(1000)
23
+ })
24
+ declare refreshToken: string;
25
+
26
+ @Column({
27
+ field: "client_id",
28
+ type: DataType.STRING(32)
29
+ })
30
+ declare clientId: string;
31
+
32
+ @Column({
33
+ field: "user_id",
34
+ allowNull: true,
35
+ type: DataType.INTEGER
36
+ })
37
+ declare userId?: number;
38
+
39
+ @Column({
40
+ type: DataType.DATE,
41
+ defaultValue: DataType.NOW
42
+ })
43
+ declare expires?: Date;
44
+
45
+ @Column({
46
+ allowNull: true,
47
+ type: DataType.STRING(1000)
48
+ })
49
+ declare scope?: string;
50
+
51
+ @Column({
52
+ field: "created_date",
53
+ type: DataType.DATE,
54
+ defaultValue: DataType.NOW
55
+ })
56
+ declare createdDate?: Date;
57
+
58
+ }