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

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 (36) hide show
  1. package/{authAssignment-zERupLM6.d.ts → authAssignment-CaUZqlvm.d.ts} +44 -25
  2. package/databases/models/authItem.ts +14 -0
  3. package/databases/models/authRole.ts +9 -0
  4. package/databases/models/index.ts +4 -1
  5. package/databases/models/oauthAccessToken.ts +16 -0
  6. package/databases/models/oauthRefreshToken.ts +16 -0
  7. package/databases/models/users.ts +20 -1
  8. package/databases/schema/authItem.ts +92 -91
  9. package/databases/schema/authItemChild.ts +33 -32
  10. package/databases/schema/authRole.ts +97 -85
  11. package/databases/schema/authRoleChild.ts +43 -36
  12. package/databases/schema/index.ts +12 -10
  13. package/databases/schema/menu.ts +113 -113
  14. package/databases/schema/msModule.ts +72 -72
  15. package/databases/schema/oauthAccessToken.ts +61 -0
  16. package/databases/schema/oauthRefreshToken.ts +61 -0
  17. package/databases/schema/users.ts +207 -185
  18. package/databases/tables/authAssignment.d.ts +1 -1
  19. package/databases/tables/authAssignment.js +209 -139
  20. package/databases/tables/authRole.d.ts +1 -1
  21. package/databases/tables/authRole.js +90 -22
  22. package/databases/tables/authRoleChild.d.ts +2 -14
  23. package/databases/tables/authRoleChild.js +529 -7
  24. package/databases/tables/index.d.ts +3 -2
  25. package/databases/tables/index.js +387 -240
  26. package/databases/tables/mdContent.d.ts +1 -1
  27. package/databases/tables/mdContent.js +211 -141
  28. package/databases/tables/mdContentGroup.d.ts +1 -1
  29. package/databases/tables/mdContentGroup.js +211 -141
  30. package/databases/tables/oauthAccessToken.d.ts +22 -0
  31. package/databases/tables/oauthAccessToken.js +640 -0
  32. package/databases/tables/oauthRefreshToken.d.ts +22 -0
  33. package/databases/tables/oauthRefreshToken.js +640 -0
  34. package/databases/tables/users.d.ts +1 -1
  35. package/databases/tables/users.js +211 -141
  36. package/package.json +1 -1
@@ -57,6 +57,44 @@ declare class mdContent extends Model<mdContentAttributes, mdContentAttributes>
57
57
  mdContentGroup?: mdContentGroup;
58
58
  }
59
59
 
60
+ interface authRoleChildAttributes {
61
+ roleId: number;
62
+ keyName: string;
63
+ permission?: object;
64
+ }
65
+ declare class authRoleChild extends Model<authRoleChildAttributes, authRoleChildAttributes> implements authRoleChildAttributes {
66
+ roleId: number;
67
+ keyName: string;
68
+ permission?: object;
69
+ authRole?: authRole;
70
+ }
71
+
72
+ interface authRoleAttributes {
73
+ id?: number;
74
+ uuid: string;
75
+ name: string;
76
+ display?: string;
77
+ status?: number;
78
+ createdBy?: string;
79
+ createdDate?: Date;
80
+ updatedBy?: string;
81
+ updatedDate?: Date;
82
+ }
83
+ declare class authRole extends Model<authRoleAttributes, authRoleAttributes> implements authRoleAttributes {
84
+ id?: number;
85
+ uuid: string;
86
+ name: string;
87
+ display?: string;
88
+ status?: number;
89
+ createdBy?: string;
90
+ createdDate?: Date;
91
+ updatedBy?: string;
92
+ updatedDate?: Date;
93
+ authAssignments?: authAssignment[];
94
+ authRoleChildren?: authRoleChild[];
95
+ user: users;
96
+ }
97
+
60
98
  interface usersAttributes {
61
99
  id?: number;
62
100
  uuid: string;
@@ -79,6 +117,8 @@ interface usersAttributes {
79
117
  createdDate?: Date;
80
118
  updatedBy?: string;
81
119
  updatedDate?: Date;
120
+ secretKey?: string;
121
+ is2fa?: number;
82
122
  }
83
123
  declare class users extends Model<usersAttributes, usersAttributes> implements usersAttributes {
84
124
  id?: number;
@@ -89,6 +129,7 @@ declare class users extends Model<usersAttributes, usersAttributes> implements u
89
129
  verificationToken?: string;
90
130
  email?: string;
91
131
  authKey?: string;
132
+ secretKey: string;
92
133
  accessToken?: string;
93
134
  userLevel?: number;
94
135
  userAuthen?: string;
@@ -98,36 +139,14 @@ declare class users extends Model<usersAttributes, usersAttributes> implements u
98
139
  lastName?: string;
99
140
  phone?: string;
100
141
  status?: number;
142
+ is2fa: number;
101
143
  createdBy?: string;
102
144
  createdDate?: Date;
103
145
  updatedBy?: string;
104
146
  updatedDate?: Date;
105
147
  authAssignments?: authAssignment[];
106
148
  mdContents?: mdContent[];
107
- }
108
-
109
- interface authRoleAttributes {
110
- id?: number;
111
- uuid: string;
112
- name: string;
113
- display?: string;
114
- status?: number;
115
- createdBy?: string;
116
- createdDate?: Date;
117
- updatedBy?: string;
118
- updatedDate?: Date;
119
- }
120
- declare class authRole extends Model<authRoleAttributes, authRoleAttributes> implements authRoleAttributes {
121
- id?: number;
122
- uuid: string;
123
- name: string;
124
- display?: string;
125
- status?: number;
126
- createdBy?: string;
127
- createdDate?: Date;
128
- updatedBy?: string;
129
- updatedDate?: Date;
130
- authAssignments?: authAssignment[];
149
+ authRoles?: authRole[];
131
150
  }
132
151
 
133
152
  interface authAssignmentAttributes {
@@ -149,4 +168,4 @@ declare class authAssignment extends Model<authAssignmentAttributes, authAssignm
149
168
  authRole?: authRole;
150
169
  }
151
170
 
152
- export { type authAssignmentAttributes as a, authAssignment as b, type authRoleAttributes as c, authRole as d, mdContent as e, type mdContentGroupAttributes as f, mdContentGroup as g, users as h, type mdContentAttributes as m, type usersAttributes as u };
171
+ export { type authAssignmentAttributes as a, authAssignment as b, type authRoleAttributes as c, authRole as d, type authRoleChildAttributes as e, authRoleChild as f, mdContent as g, type mdContentGroupAttributes as h, mdContentGroup as i, users as j, type mdContentAttributes as m, type usersAttributes as u };
@@ -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
  }
@@ -1,86 +1,98 @@
1
- import {
2
- Model, Table, Column, DataType, Index, Sequelize, ForeignKey, HasMany
3
- } from "sequelize-typescript";
4
- import { authAssignment } from "./authAssignment";
5
-
6
- export interface authRoleAttributes {
7
- id?: number;
8
- uuid: string;
9
- name: string;
10
- display?: string;
11
- status?: number;
12
- createdBy?: string;
13
- createdDate?: Date;
14
- updatedBy?: string;
15
- updatedDate?: Date;
16
- }
17
-
18
- @Table({
19
- tableName: "auth_role",
20
- timestamps: false
21
- })
22
- export class authRole extends Model<authRoleAttributes, authRoleAttributes> implements authRoleAttributes {
23
-
24
- @Column({
25
- primaryKey: true,
26
- autoIncrement: true,
27
- type: DataType.INTEGER
28
- })
29
- declare id?: number;
30
-
31
- @Column({
32
- type: DataType.STRING(60)
33
- })
34
- declare uuid: string;
35
-
36
- @Column({
37
- type: DataType.STRING(100)
38
- })
39
- declare name: string;
40
-
41
- @Column({
42
- allowNull: true,
43
- type: DataType.STRING(255)
44
- })
45
- declare display?: string;
46
-
47
- @Column({
48
- allowNull: true,
49
- type: DataType.INTEGER
50
- })
51
- declare status?: number;
52
-
53
- @Column({
54
- field: "created_by",
55
- allowNull: true,
56
- type: DataType.STRING(60)
57
- })
58
- declare createdBy?: string;
59
-
60
- @Column({
61
- field: "created_date",
62
- allowNull: true,
63
- type: DataType.DATE
64
- })
65
- declare createdDate?: Date;
66
-
67
- @Column({
68
- field: "updated_by",
69
- allowNull: true,
70
- type: DataType.STRING(60)
71
- })
72
- declare updatedBy?: string;
73
-
74
- @Column({
75
- field: "updated_date",
76
- allowNull: true,
77
- type: DataType.DATE
78
- })
79
- declare updatedDate?: Date;
80
-
81
- @HasMany(() => authAssignment, {
82
- sourceKey: "id"
83
- })
84
- declare authAssignments?: authAssignment[];
85
-
1
+ import {
2
+ Model, Table, Column, DataType, Index, Sequelize, ForeignKey, HasMany, BelongsTo
3
+ } from "sequelize-typescript";
4
+ import { authAssignment } from "./authAssignment";
5
+ import { authRoleChild } from "./authRoleChild";
6
+ import { users } from "./users";
7
+
8
+ export interface authRoleAttributes {
9
+ id?: number;
10
+ uuid: string;
11
+ name: string;
12
+ display?: string;
13
+ status?: number;
14
+ createdBy?: string;
15
+ createdDate?: Date;
16
+ updatedBy?: string;
17
+ updatedDate?: Date;
18
+ }
19
+
20
+ @Table({
21
+ tableName: "auth_role",
22
+ timestamps: false
23
+ })
24
+ export class authRole extends Model<authRoleAttributes, authRoleAttributes> implements authRoleAttributes {
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
+ type: DataType.STRING(100)
40
+ })
41
+ declare name: string;
42
+
43
+ @Column({
44
+ allowNull: true,
45
+ type: DataType.STRING(255)
46
+ })
47
+ declare display?: string;
48
+
49
+ @Column({
50
+ allowNull: true,
51
+ type: DataType.INTEGER
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
+ @HasMany(() => authAssignment, {
84
+ sourceKey: "id"
85
+ })
86
+ declare authAssignments?: authAssignment[];
87
+
88
+ @HasMany(() => authRoleChild, {
89
+ sourceKey: "id"
90
+ })
91
+ declare authRoleChildren?: authRoleChild[];
92
+
93
+ @BelongsTo(() => users, {
94
+ foreignKey: "created_by",
95
+ targetKey: "uuid"
96
+ })
97
+ declare user: users;
86
98
  }