chyz 1.0.13-rc.2 → 1.0.13-rc.20
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/BaseChyz.ts +53 -15
- package/Doc/Moel kullanma.md +13 -0
- package/Examples/Controllers/ApiController.ts +35 -26
- package/Examples/Controllers/BasicApiController.ts +121 -0
- package/Examples/Controllers/KeyCloakController.ts +4 -4
- package/Examples/Controllers/SiteController.ts +18 -8
- package/Examples/Models/AuthAssignment.ts +50 -0
- package/Examples/Models/AuthItem.ts +59 -0
- package/Examples/Models/AuthItemChild.ts +49 -0
- package/Examples/Models/Categories.ts +14 -3
- package/Examples/Models/Customer.ts +2 -2
- package/Examples/Models/KeycloakUser.ts +4 -0
- package/Examples/Models/Order.ts +5 -5
- package/Examples/Models/OrderItem.ts +2 -2
- package/Examples/Models/ProductModels.ts +4 -5
- package/Examples/Models/ProductToCategories.ts +15 -4
- package/Examples/Models/Products.ts +9 -8
- package/Examples/Models/Stocks.ts +2 -2
- package/Examples/Models/User.ts +8 -1
- package/Examples/Models/UserPermission.ts +2 -2
- package/Examples/Models/index.ts +19 -0
- package/Examples/index.ts +6 -0
- package/Examples/log/app.log +9456 -0
- package/Examples/log/errors.log +1904 -0
- package/Examples/tsconfig.json +2 -1
- package/README.md +267 -16
- package/base/ActionFilter.ts +1 -1
- package/base/BaseError.ts +3 -1
- package/base/InvalidArgumentException.ts +16 -0
- package/base/Model.ts +69 -51
- package/base/ModelManager.ts +19 -0
- package/base/RestClient.ts +4 -4
- package/base/ValidationHttpException.ts +1 -1
- package/base/index.ts +2 -0
- package/dist/BaseChyz.js +46 -8
- package/dist/BaseChyz.js.map +1 -1
- package/dist/base/ActionFilter.js +1 -1
- package/dist/base/ActionFilter.js.map +1 -1
- package/dist/base/BaseError.js +5 -1
- package/dist/base/BaseError.js.map +1 -1
- package/dist/base/InvalidArgumentException.js +18 -0
- package/dist/base/InvalidArgumentException.js.map +1 -0
- package/dist/base/Model.js +44 -30
- package/dist/base/Model.js.map +1 -1
- package/dist/base/ModelManager.js +9 -0
- package/dist/base/ModelManager.js.map +1 -0
- package/dist/base/RestClient.js +4 -4
- package/dist/base/RestClient.js.map +1 -1
- package/dist/base/ValidationHttpException.js +1 -1
- package/dist/base/index.js +2 -0
- package/dist/base/index.js.map +1 -1
- package/dist/filters/AccessControl.js +15 -3
- package/dist/filters/AccessControl.js.map +1 -1
- package/dist/filters/AccessRule.js +99 -38
- package/dist/filters/AccessRule.js.map +1 -1
- package/dist/filters/auth/HttpBasicAuth.js +65 -0
- package/dist/filters/auth/HttpBasicAuth.js.map +1 -1
- package/dist/filters/auth/JwtHttpBearerAuth.js +1 -1
- package/dist/filters/auth/JwtHttpBearerAuth.js.map +1 -1
- package/dist/filters/auth/index.js +1 -0
- package/dist/filters/auth/index.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json +55 -0
- package/dist/rbac/AuthAssignment.js +45 -0
- package/dist/rbac/AuthAssignment.js.map +1 -0
- package/dist/rbac/AuthItem.js +52 -0
- package/dist/rbac/AuthItem.js.map +1 -0
- package/dist/rbac/AuthItemChild.js +44 -0
- package/dist/rbac/AuthItemChild.js.map +1 -0
- package/dist/rbac/AuthManager.js +359 -0
- package/dist/rbac/AuthManager.js.map +1 -0
- package/dist/web/WebUser.js +78 -0
- package/dist/web/WebUser.js.map +1 -1
- package/filters/AccessControl.ts +19 -6
- package/filters/AccessRule.ts +61 -16
- package/filters/auth/HttpBasicAuth.ts +68 -0
- package/filters/auth/JwtHttpBearerAuth.ts +1 -1
- package/filters/auth/index.ts +1 -0
- package/index.ts +2 -2
- package/package-lock.json +5259 -0
- package/package.json +6 -6
- package/rbac/AuthAssignment.ts +50 -0
- package/rbac/AuthItem.ts +57 -0
- package/rbac/AuthItemChild.ts +50 -0
- package/rbac/AuthManager.ts +398 -0
- package/web/IdentityInterface.ts +6 -0
- package/web/WebUser.ts +88 -1
- package/Examples/yarn.lock +0 -2549
package/Examples/Models/Order.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {DataTypes, Model, Relation} from "../../base";
|
|
2
|
-
import {
|
|
2
|
+
import {OrderItemClass} from "./OrderItem";
|
|
3
3
|
|
|
4
4
|
export class OrderClass extends Model {
|
|
5
5
|
[x: string]: any;
|
|
@@ -50,15 +50,15 @@ export class OrderClass extends Model {
|
|
|
50
50
|
type: "hasOne",
|
|
51
51
|
sourceKey: "order_id",
|
|
52
52
|
foreignKey: "id",
|
|
53
|
-
model:
|
|
53
|
+
model: (new OrderItemClass()).model()
|
|
54
54
|
}
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const Order = new OrderClass()
|
|
60
|
-
export {Order};
|
|
61
|
-
|
|
59
|
+
// const Order = new OrderClass()
|
|
60
|
+
// export {Order};
|
|
61
|
+
//
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* E-mail: cihan@chy.com.tr
|
|
5
5
|
* Github:https://github.com/cihan53/
|
|
6
6
|
*/
|
|
7
|
-
import {DataTypes, Model, Relation} from "../../base";
|
|
8
|
-
import {Products} from "./Products";
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
9
8
|
|
|
10
9
|
export class ProductModelsClass extends Model {
|
|
11
10
|
[x: string]: any;
|
|
@@ -40,11 +39,11 @@ export class ProductModelsClass extends Model {
|
|
|
40
39
|
type: "hasOne",
|
|
41
40
|
foreignKey: "id",
|
|
42
41
|
sourceKey: "category_id",
|
|
43
|
-
model: Products.model()
|
|
42
|
+
model: ModelManager.Products.model()
|
|
44
43
|
}
|
|
45
44
|
]
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
const ProductModels = new ProductModelsClass();
|
|
50
|
-
export {ProductModels}
|
|
48
|
+
// const ProductModels = new ProductModelsClass();
|
|
49
|
+
// export {ProductModels}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* E-mail: cihan@chy.com.tr
|
|
5
5
|
* Github:https://github.com/cihan53/
|
|
6
6
|
*/
|
|
7
|
-
import {DataTypes, Model} from "../../base";
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
8
|
|
|
9
9
|
export class ProductToCategoriesClass extends Model {
|
|
10
10
|
[x: string]: any;
|
|
@@ -21,7 +21,7 @@ export class ProductToCategoriesClass extends Model {
|
|
|
21
21
|
type: DataTypes.INTEGER,
|
|
22
22
|
allowNull: false
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
category_id: {
|
|
25
25
|
type: DataTypes.INTEGER,
|
|
26
26
|
allowNull: false
|
|
27
27
|
}
|
|
@@ -29,7 +29,18 @@ export class ProductToCategoriesClass extends Model {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// relations(): Relation[] {
|
|
33
|
+
// return [
|
|
34
|
+
// {
|
|
35
|
+
// type: "hasMany",
|
|
36
|
+
// foreignKey: "category_id",
|
|
37
|
+
// sourceKey: "id",
|
|
38
|
+
// model: ModelManager.Categories.model(),
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
// }
|
|
42
|
+
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
const ProductToCategories = new ProductToCategoriesClass()
|
|
35
|
-
export {ProductToCategories}
|
|
45
|
+
// const ProductToCategories = new ProductToCategoriesClass()
|
|
46
|
+
// export {ProductToCategories}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* E-mail: cihan@chy.com.tr
|
|
5
5
|
* Github:https://github.com/cihan53/
|
|
6
6
|
*/
|
|
7
|
-
import {DataTypes, Model, Relation} from "../../base";
|
|
8
|
-
|
|
7
|
+
import {DataTypes, ModelManager, Model, Relation} from "../../base";
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
export class ProductsClass extends Model {
|
|
11
11
|
[x: string]: any;
|
|
@@ -36,14 +36,15 @@ export class ProductsClass extends Model {
|
|
|
36
36
|
relations(): Relation[] {
|
|
37
37
|
return [
|
|
38
38
|
{
|
|
39
|
-
type: "
|
|
40
|
-
foreignKey: "
|
|
41
|
-
sourceKey: "
|
|
42
|
-
model:
|
|
39
|
+
type: "belongsToMany",
|
|
40
|
+
foreignKey: "product_id",
|
|
41
|
+
sourceKey: "id",
|
|
42
|
+
model: ModelManager.Categories.model(),
|
|
43
|
+
through: ModelManager.ProductToCategories.model()
|
|
43
44
|
}
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
const Products = new ProductsClass()
|
|
49
|
-
export {Products}
|
|
49
|
+
// const Products = new ProductsClass()
|
|
50
|
+
// export {Products}
|
package/Examples/Models/User.ts
CHANGED
|
@@ -28,6 +28,11 @@ export class User extends Model implements IdentityInterface {
|
|
|
28
28
|
throw new Error("Method not implemented.");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
can(permissionName: string, params: any[], allowCaching: boolean): boolean | null {
|
|
32
|
+
throw new Error("Method not implemented.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
31
36
|
getAuthKey(): string {
|
|
32
37
|
throw new Error("Method not implemented.");
|
|
33
38
|
}
|
|
@@ -71,8 +76,8 @@ export class User extends Model implements IdentityInterface {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
async findIdentityByAccessToken(token, type) {
|
|
74
|
-
let decoded = JsonWebToken.decode(token, {complete: true})
|
|
75
79
|
|
|
80
|
+
let decoded = JsonWebToken.decode(token, {complete: true})
|
|
76
81
|
if(!decoded.payload.user) {
|
|
77
82
|
return null;
|
|
78
83
|
}
|
|
@@ -97,4 +102,6 @@ export class User extends Model implements IdentityInterface {
|
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
|
|
105
|
+
|
|
106
|
+
|
|
100
107
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
4
|
+
* Author: Cihan Ozturk
|
|
5
|
+
* E-mail: cihan@chy.com.tr
|
|
6
|
+
* Github:https://github.com/cihan53/
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import {ModelManager} from "../../base";
|
|
10
|
+
// import {Order, OrderClass} from "./Order";
|
|
11
|
+
// import {Customer, CustomerClass} from "./Customer";
|
|
12
|
+
// import {Products} from "./Products";
|
|
13
|
+
// import {ProductModels} from "./ProductModels";
|
|
14
|
+
// import {Categories} from "./Categories";
|
|
15
|
+
// import {ProductToCategories} from "./ProductToCategories";
|
|
16
|
+
//
|
|
17
|
+
// Dependencies._register({Order, Customer,CustomerClass,OrderClass, Products, ProductModels, Categories, ProductToCategories});
|
|
18
|
+
//
|
|
19
|
+
// console.log("denmemem")
|
package/Examples/index.ts
CHANGED
|
@@ -7,16 +7,22 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
import {BaseChyz} from "../index";
|
|
10
|
+
|
|
10
11
|
require('dotenv-flow').config();
|
|
11
12
|
import Chyz from "../Chyz";
|
|
12
13
|
import {WebUser} from "../web/WebUser";
|
|
13
14
|
import {User} from "./Models/User";
|
|
14
15
|
import {DbConnection} from "../base";
|
|
16
|
+
import {AuthManager} from "../rbac/AuthManager";
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
let config = {
|
|
17
20
|
port: process.env.PORT,
|
|
18
21
|
controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
|
|
19
22
|
components: {
|
|
23
|
+
authManager: {
|
|
24
|
+
class: AuthManager,
|
|
25
|
+
},
|
|
20
26
|
db: {
|
|
21
27
|
class: DbConnection,
|
|
22
28
|
database: process.env.DBDATABASE,
|