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.
Files changed (89) hide show
  1. package/BaseChyz.ts +53 -15
  2. package/Doc/Moel kullanma.md +13 -0
  3. package/Examples/Controllers/ApiController.ts +35 -26
  4. package/Examples/Controllers/BasicApiController.ts +121 -0
  5. package/Examples/Controllers/KeyCloakController.ts +4 -4
  6. package/Examples/Controllers/SiteController.ts +18 -8
  7. package/Examples/Models/AuthAssignment.ts +50 -0
  8. package/Examples/Models/AuthItem.ts +59 -0
  9. package/Examples/Models/AuthItemChild.ts +49 -0
  10. package/Examples/Models/Categories.ts +14 -3
  11. package/Examples/Models/Customer.ts +2 -2
  12. package/Examples/Models/KeycloakUser.ts +4 -0
  13. package/Examples/Models/Order.ts +5 -5
  14. package/Examples/Models/OrderItem.ts +2 -2
  15. package/Examples/Models/ProductModels.ts +4 -5
  16. package/Examples/Models/ProductToCategories.ts +15 -4
  17. package/Examples/Models/Products.ts +9 -8
  18. package/Examples/Models/Stocks.ts +2 -2
  19. package/Examples/Models/User.ts +8 -1
  20. package/Examples/Models/UserPermission.ts +2 -2
  21. package/Examples/Models/index.ts +19 -0
  22. package/Examples/index.ts +6 -0
  23. package/Examples/log/app.log +9456 -0
  24. package/Examples/log/errors.log +1904 -0
  25. package/Examples/tsconfig.json +2 -1
  26. package/README.md +267 -16
  27. package/base/ActionFilter.ts +1 -1
  28. package/base/BaseError.ts +3 -1
  29. package/base/InvalidArgumentException.ts +16 -0
  30. package/base/Model.ts +69 -51
  31. package/base/ModelManager.ts +19 -0
  32. package/base/RestClient.ts +4 -4
  33. package/base/ValidationHttpException.ts +1 -1
  34. package/base/index.ts +2 -0
  35. package/dist/BaseChyz.js +46 -8
  36. package/dist/BaseChyz.js.map +1 -1
  37. package/dist/base/ActionFilter.js +1 -1
  38. package/dist/base/ActionFilter.js.map +1 -1
  39. package/dist/base/BaseError.js +5 -1
  40. package/dist/base/BaseError.js.map +1 -1
  41. package/dist/base/InvalidArgumentException.js +18 -0
  42. package/dist/base/InvalidArgumentException.js.map +1 -0
  43. package/dist/base/Model.js +44 -30
  44. package/dist/base/Model.js.map +1 -1
  45. package/dist/base/ModelManager.js +9 -0
  46. package/dist/base/ModelManager.js.map +1 -0
  47. package/dist/base/RestClient.js +4 -4
  48. package/dist/base/RestClient.js.map +1 -1
  49. package/dist/base/ValidationHttpException.js +1 -1
  50. package/dist/base/index.js +2 -0
  51. package/dist/base/index.js.map +1 -1
  52. package/dist/filters/AccessControl.js +15 -3
  53. package/dist/filters/AccessControl.js.map +1 -1
  54. package/dist/filters/AccessRule.js +99 -38
  55. package/dist/filters/AccessRule.js.map +1 -1
  56. package/dist/filters/auth/HttpBasicAuth.js +65 -0
  57. package/dist/filters/auth/HttpBasicAuth.js.map +1 -1
  58. package/dist/filters/auth/JwtHttpBearerAuth.js +1 -1
  59. package/dist/filters/auth/JwtHttpBearerAuth.js.map +1 -1
  60. package/dist/filters/auth/index.js +1 -0
  61. package/dist/filters/auth/index.js.map +1 -1
  62. package/dist/index.js +2 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/package.json +55 -0
  65. package/dist/rbac/AuthAssignment.js +45 -0
  66. package/dist/rbac/AuthAssignment.js.map +1 -0
  67. package/dist/rbac/AuthItem.js +52 -0
  68. package/dist/rbac/AuthItem.js.map +1 -0
  69. package/dist/rbac/AuthItemChild.js +44 -0
  70. package/dist/rbac/AuthItemChild.js.map +1 -0
  71. package/dist/rbac/AuthManager.js +359 -0
  72. package/dist/rbac/AuthManager.js.map +1 -0
  73. package/dist/web/WebUser.js +78 -0
  74. package/dist/web/WebUser.js.map +1 -1
  75. package/filters/AccessControl.ts +19 -6
  76. package/filters/AccessRule.ts +61 -16
  77. package/filters/auth/HttpBasicAuth.ts +68 -0
  78. package/filters/auth/JwtHttpBearerAuth.ts +1 -1
  79. package/filters/auth/index.ts +1 -0
  80. package/index.ts +2 -2
  81. package/package-lock.json +5259 -0
  82. package/package.json +6 -6
  83. package/rbac/AuthAssignment.ts +50 -0
  84. package/rbac/AuthItem.ts +57 -0
  85. package/rbac/AuthItemChild.ts +50 -0
  86. package/rbac/AuthManager.ts +398 -0
  87. package/web/IdentityInterface.ts +6 -0
  88. package/web/WebUser.ts +88 -1
  89. package/Examples/yarn.lock +0 -2549
@@ -1,5 +1,5 @@
1
1
  import {DataTypes, Model, Relation} from "../../base";
2
- import {OrderItem} from "./OrderItem";
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: OrderItem.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
 
@@ -20,8 +20,8 @@ export class OrderItemClass extends Model {
20
20
  }
21
21
 
22
22
  }
23
- const OrderItem = new OrderItemClass()
24
- export { OrderItem };
23
+ // const OrderItem = new OrderItemClass()
24
+ // export { OrderItem };
25
25
 
26
26
 
27
27
 
@@ -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
- categories_id: {
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
- import {ProductModels} from "./ProductModels";
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: "hasOne",
40
- foreignKey: "id",
41
- sourceKey: "model_id",
42
- model: ProductModels.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}
@@ -56,5 +56,5 @@ export class StocksClass extends Model {
56
56
  }
57
57
  }
58
58
 
59
- const Stocks = new StocksClass();
60
- export {Stocks}
59
+ // const Stocks = new StocksClass();
60
+ // export {Stocks}
@@ -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
  }
@@ -33,5 +33,5 @@ export class UserPermissionClass extends Model {
33
33
  }
34
34
  }
35
35
 
36
- const UserPermission = new UserPermissionClass();
37
- export {UserPermission}
36
+ // const UserPermission = new UserPermissionClass();
37
+ // export {UserPermission}
@@ -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,