chyz 1.0.13-rc.20 → 1.0.13-rc.3

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 (85) hide show
  1. package/BaseChyz.ts +15 -53
  2. package/Examples/Controllers/ApiController.ts +26 -35
  3. package/Examples/Controllers/KeyCloakController.ts +4 -4
  4. package/Examples/Controllers/SiteController.ts +8 -18
  5. package/Examples/Models/Categories.ts +3 -14
  6. package/Examples/Models/Customer.ts +2 -2
  7. package/Examples/Models/KeycloakUser.ts +0 -4
  8. package/Examples/Models/Order.ts +5 -5
  9. package/Examples/Models/OrderItem.ts +2 -2
  10. package/Examples/Models/ProductModels.ts +5 -4
  11. package/Examples/Models/ProductToCategories.ts +4 -15
  12. package/Examples/Models/Products.ts +8 -9
  13. package/Examples/Models/Stocks.ts +2 -2
  14. package/Examples/Models/User.ts +1 -8
  15. package/Examples/Models/UserPermission.ts +2 -2
  16. package/Examples/index.ts +0 -6
  17. package/Examples/log/app.log +0 -9456
  18. package/Examples/log/errors.log +0 -1904
  19. package/Examples/tsconfig.json +1 -2
  20. package/README.md +16 -267
  21. package/base/ActionFilter.ts +1 -1
  22. package/base/BaseError.ts +1 -3
  23. package/base/Model.ts +51 -69
  24. package/base/RestClient.ts +4 -4
  25. package/base/ValidationHttpException.ts +1 -1
  26. package/base/index.ts +0 -2
  27. package/dist/BaseChyz.js +8 -46
  28. package/dist/BaseChyz.js.map +1 -1
  29. package/dist/README.md +270 -0
  30. package/dist/base/ActionFilter.js +1 -1
  31. package/dist/base/ActionFilter.js.map +1 -1
  32. package/dist/base/BaseError.js +1 -5
  33. package/dist/base/BaseError.js.map +1 -1
  34. package/dist/base/Model.js +30 -44
  35. package/dist/base/Model.js.map +1 -1
  36. package/dist/base/RestClient.js +4 -4
  37. package/dist/base/RestClient.js.map +1 -1
  38. package/dist/base/ValidationHttpException.js +1 -1
  39. package/dist/base/index.js +0 -2
  40. package/dist/base/index.js.map +1 -1
  41. package/dist/filters/AccessControl.js +3 -15
  42. package/dist/filters/AccessControl.js.map +1 -1
  43. package/dist/filters/AccessRule.js +38 -99
  44. package/dist/filters/AccessRule.js.map +1 -1
  45. package/dist/filters/auth/HttpBasicAuth.js +0 -65
  46. package/dist/filters/auth/HttpBasicAuth.js.map +1 -1
  47. package/dist/filters/auth/JwtHttpBearerAuth.js +1 -1
  48. package/dist/filters/auth/JwtHttpBearerAuth.js.map +1 -1
  49. package/dist/filters/auth/index.js +0 -1
  50. package/dist/filters/auth/index.js.map +1 -1
  51. package/dist/package.json +6 -6
  52. package/dist/web/WebUser.js +0 -78
  53. package/dist/web/WebUser.js.map +1 -1
  54. package/filters/AccessControl.ts +6 -19
  55. package/filters/AccessRule.ts +16 -61
  56. package/filters/auth/HttpBasicAuth.ts +0 -68
  57. package/filters/auth/JwtHttpBearerAuth.ts +1 -1
  58. package/filters/auth/index.ts +0 -1
  59. package/package.json +7 -6
  60. package/web/IdentityInterface.ts +0 -6
  61. package/web/WebUser.ts +1 -88
  62. package/Doc/Moel kullanma.md +0 -13
  63. package/Examples/Controllers/BasicApiController.ts +0 -121
  64. package/Examples/Models/AuthAssignment.ts +0 -50
  65. package/Examples/Models/AuthItem.ts +0 -59
  66. package/Examples/Models/AuthItemChild.ts +0 -49
  67. package/Examples/Models/index.ts +0 -19
  68. package/base/InvalidArgumentException.ts +0 -16
  69. package/base/ModelManager.ts +0 -19
  70. package/dist/base/InvalidArgumentException.js +0 -18
  71. package/dist/base/InvalidArgumentException.js.map +0 -1
  72. package/dist/base/ModelManager.js +0 -9
  73. package/dist/base/ModelManager.js.map +0 -1
  74. package/dist/rbac/AuthAssignment.js +0 -45
  75. package/dist/rbac/AuthAssignment.js.map +0 -1
  76. package/dist/rbac/AuthItem.js +0 -52
  77. package/dist/rbac/AuthItem.js.map +0 -1
  78. package/dist/rbac/AuthItemChild.js +0 -44
  79. package/dist/rbac/AuthItemChild.js.map +0 -1
  80. package/dist/rbac/AuthManager.js +0 -359
  81. package/dist/rbac/AuthManager.js.map +0 -1
  82. package/rbac/AuthAssignment.ts +0 -50
  83. package/rbac/AuthItem.ts +0 -57
  84. package/rbac/AuthItemChild.ts +0 -50
  85. package/rbac/AuthManager.ts +0 -398
@@ -10,72 +10,35 @@ var _ = require('lodash');
10
10
  import {Component} from "../base/Component";
11
11
  import {InvalidConfigException} from "../base/InvalidConfigException";
12
12
  import {Request, Response} from "express";
13
- import Utils from "../requiments/Utils";
14
13
 
15
14
  export class AccessRule extends Component {
16
15
 
17
16
  /**
18
17
  * @var bool whether this is an 'allow' rule or 'deny' rule.
19
18
  */
20
- public allow: any;
19
+ public allow:any;
21
20
  /**
22
21
  * @var array list of action IDs that this rule applies to. The comparison is case-sensitive.
23
22
  * If not set or empty, it means this rule applies to all actions.
24
23
  */
25
- public actions: any;
24
+ public actions:any;
26
25
 
27
26
  /**
28
27
  * @var array list of the controller IDs that this rule applies to.
29
28
  */
30
- public controllers: any;
29
+ public controllers:any;
31
30
 
32
31
  /**
33
32
  * - `?`: matches a guest user (not authenticated yet)
34
33
  * - `@`: matches an authenticated user
35
34
  */
36
35
 
37
- public roles: any;
36
+ public roles:any;
38
37
 
39
38
  /**
40
39
  * @var array list of RBAC (Role-Based Access Control) permissions that this rules applies to.
41
40
  */
42
- public permissions: any;
43
-
44
- /**
45
- * @var array|Closure parameters to pass to the [[User::can()]] function for evaluating
46
- * user permissions in [[$roles]].
47
- *
48
- * If this is an array, it will be passed directly to [[User::can()]]. For example for passing an
49
- * ID from the current request, you may use the following:
50
- *
51
- * ```php
52
- * ['postId' => Yii::$app->request->get('id')]
53
- * ```
54
- *
55
- * You may also specify a closure that returns an array. This can be used to
56
- * evaluate the array values only if they are needed, for example when a model needs to be
57
- * loaded like in the following code:
58
- *
59
- * ```php
60
- * 'rules' => [
61
- * [
62
- * 'allow' => true,
63
- * 'actions' => ['update'],
64
- * 'roles' => ['updatePost'],
65
- * 'roleParams' => function($rule) {
66
- * return ['post' => Post::findOne(Yii::$app->request->get('id'))];
67
- * },
68
- * ],
69
- * ],
70
- * ```
71
- *
72
- * A reference to the [[AccessRule]] instance will be passed to the closure as the first parameter.
73
- *
74
- * @see roles
75
- * @since 2.0.12
76
- */
77
- public roleParams: any = [];
78
-
41
+ public permissions:any;
79
42
 
80
43
  /**
81
44
  * @var array list of user IP addresses that this rule applies to. An IP address
@@ -85,13 +48,13 @@ export class AccessRule extends Component {
85
48
  * 20-bit private network block in RFC1918.
86
49
  * If not set or empty, it means this rule applies to all IP addresses.
87
50
  */
88
- public ips: any;
51
+ public ips:any;
89
52
 
90
53
 
91
- public async allows(action: any, user: WebUser, request: Request) {
54
+ public allows(action:any, user:WebUser, request:Request) {
92
55
  if (
93
56
  this.matchAction(action)
94
- && await this.matchRole(user)
57
+ && this.matchRole(user)
95
58
  ) {
96
59
  return this.allow
97
60
  }
@@ -112,7 +75,7 @@ export class AccessRule extends Component {
112
75
  * @param Action $action the action
113
76
  * @return bool whether the rule applies to the action
114
77
  */
115
- protected matchAction(action: any) {
78
+ protected matchAction(action:any) {
116
79
  return _.isEmpty(this.actions) || this.actions.includes(action.id);
117
80
  }
118
81
 
@@ -120,7 +83,7 @@ export class AccessRule extends Component {
120
83
  * @param Controller $controller the controller
121
84
  * @return bool whether the rule applies to the controller
122
85
  */
123
- protected matchController(controller: any) {
86
+ protected matchController(controller:any) {
124
87
  // if (empty($this->controllers)) {
125
88
  // return true;
126
89
  // }
@@ -135,23 +98,22 @@ export class AccessRule extends Component {
135
98
  return false;
136
99
  }
137
100
 
138
- protected async matchRole(user: WebUser) {
139
- let items = Utils.isEmpty(this.roles) ? [] : this.roles;
101
+ protected matchRole(user:any) {
102
+ let items = _.isEmpty(this.roles) ? [] : this.roles;
140
103
 
141
- if (!Utils.isEmpty(this.permissions)) {
142
- items = Utils.merge(items, this.permissions);
104
+ if (!_.isEmpty(this.permissions)) {
105
+ items = _.merge(items, this.permissions);
143
106
  }
144
107
 
145
- if (Utils.isEmpty(items)) {
108
+ if (_.isEmpty(items)) {
146
109
  return true;
147
110
  }
148
111
 
149
112
 
150
- if (!user) {
113
+ if (user === false) {
151
114
  throw new InvalidConfigException('The user application component must be available to specify roles in AccessRule.');
152
115
  }
153
116
 
154
- let roleParams: any = [];
155
117
  for (const itemsKey in items) {
156
118
  let item = items[itemsKey];
157
119
  if (item === '?') {
@@ -164,13 +126,6 @@ export class AccessRule extends Component {
164
126
  }
165
127
  } else {
166
128
  //roleparams
167
- if (!Utils.isEmpty(this.roleParams)) {
168
- roleParams = !Utils.isArray(this.roleParams) ? this.roleParams.apply(this) : this.roleParams;
169
- }
170
-
171
- if (await user.can(item, this.roleParams)) {
172
- return true;
173
- }
174
129
  }
175
130
  }
176
131
 
@@ -5,71 +5,3 @@
5
5
  * Github:https://github.com/cihan53/
6
6
  */
7
7
 
8
- import {HttpHeaderAuth} from "./HttpHeaderAuth";
9
- import {Request, Response} from "express";
10
- import {WebUser} from "../../web/WebUser";
11
- import Utils from "../../requiments/Utils";
12
- import {AuthMethod} from "./AuthMethod";
13
- import {InvalidConfigException} from "../../base";
14
- import BaseChyz from "../../BaseChyz";
15
-
16
- export class HttpBasicAuth extends AuthMethod {
17
-
18
- /**
19
- * @var string the HTTP header name
20
- */
21
- public header = 'Authorization';
22
-
23
-
24
- /**
25
- * @var string a pattern to use to extract the HTTP authentication value
26
- */
27
-
28
- public pattern = /^Basic\s+(.*?)$/;
29
-
30
-
31
- /**
32
- * @throws InvalidConfigException
33
- */
34
- public init(): void {
35
- super.init();
36
-
37
- if (!this.pattern) {
38
- throw new InvalidConfigException('You must provide pattern to use to extract the HTTP authentication value!');
39
- }
40
-
41
- this.user = BaseChyz.getComponent("user") ?? null;
42
- }
43
-
44
-
45
- async authenticate(user: WebUser, request:Request, response:Response) {
46
-
47
-
48
- let autHeader = this.getHeaderByKey(request.headers, this.header)
49
- if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
50
- return null;
51
- }
52
-
53
- let basicauth = autHeader[1].split(":")
54
-
55
- let identity = await user.loginByAccessToken(basicauth, "HttpBasicAuth");
56
- if (identity === null) {
57
- this.challenge(response);
58
- this.handleFailure(response);
59
- }
60
-
61
- return identity;
62
-
63
-
64
- return null;
65
- }
66
-
67
-
68
- /**
69
- * @throws UnauthorizedHttpException
70
- */
71
- public fail(response:Response): void {
72
- this.challenge(response)
73
- this.handleFailure(response);
74
- }
75
- }
@@ -44,7 +44,7 @@ export class JwtHttpBearerAuth extends HttpBearerAuth {
44
44
  return null;
45
45
  }
46
46
 
47
- // BaseChyz.debug("JSON Web Token.",autHeader);
47
+ BaseChyz.debug("JSON Web Token.",autHeader);
48
48
  let identity = null;
49
49
  let token = null;
50
50
 
@@ -1,4 +1,3 @@
1
1
  export * from "./JwtHttpBearerAuth"
2
2
  export * from "./HttpBearerAuth"
3
3
  export * from "./HttpHeaderAuth"
4
- export * from "./HttpBasicAuth"
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "chyz",
3
- "version": " 1.0.13-rc.20",
4
- "description": "Nodejs Micro service Framework",
3
+ "version": "1.0.13-rc.3",
4
+ "description": "Nodejs MicroServis Framework",
5
+ "main": "index.js",
5
6
  "scripts": {
6
- "dev": "nodemon -t --trace-warnings index.ts",
7
+ "dev": "nodemon index.ts",
7
8
  "debug": "ts-node index.ts",
8
- "build": "rmdir /S /Q .\\dist && npx tsc && xcopy .\\log .\\dist\\log /e /i /h /Y && copy .\\package.json .\\dist\\package.json",
9
+ "build": "rmdir /S /Q .\\dist && npx tsc && xcopy .\\log .\\dist\\log /e /i /h /Y && copy .\\package.json .\\dist\\package.json && copy .\\README.md .\\dist\\README.md ",
10
+ "publish": "cd dist && npm publish",
9
11
  "test": "echo \"Error: no test specified\" && exit 1",
10
12
  "postversion": "git push && git push --tags"
11
13
  },
@@ -36,8 +38,7 @@
36
38
  "pg": "^8.7.1",
37
39
  "pg-hstore": "^2.3.4",
38
40
  "reflect-metadata": "^0.1.13",
39
- "sequelize": "^6.6.5",
40
- "validate.js": "^0.13.1"
41
+ "sequelize": "^6.6.5"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/express": "^4.17.13",
@@ -59,10 +59,4 @@ export interface IdentityInterface {
59
59
  */
60
60
  validateAuthKey(authKey: string): (boolean | null);
61
61
 
62
-
63
- /**
64
- *
65
- */
66
- can(permissionName:string, params: any[] , allowCaching: boolean ): (boolean | null);
67
-
68
62
  }
package/web/WebUser.ts CHANGED
@@ -9,8 +9,6 @@ import {Component} from "../base/Component";
9
9
  import {ForbiddenHttpException} from "../base/ForbiddenHttpException";
10
10
  import {InvalidConfigException} from "../base/InvalidConfigException";
11
11
  import {IdentityInterface} from "./IdentityInterface";
12
- import Utils from "../requiments/Utils";
13
- import {AuthManager} from "../rbac/AuthManager";
14
12
 
15
13
  export class WebUser extends Component {
16
14
 
@@ -19,13 +17,6 @@ export class WebUser extends Component {
19
17
  */
20
18
  public identityClass: any;
21
19
  private _identity: any;
22
- /**
23
- * @var CheckAccessInterface|string|array The access checker object to use for checking access or the application
24
- * component ID of the access checker.
25
- * If not set the application auth manager will be used.
26
- * @since 2.0.9
27
- */
28
- public accessChecker: any = null;
29
20
 
30
21
 
31
22
  get identity() {
@@ -84,7 +75,7 @@ export class WebUser extends Component {
84
75
  if (this.identity && this.login(this.identity)) {
85
76
  return this.identity;
86
77
  }
87
- } else {
78
+ }else{
88
79
  BaseChyz.error("WebUser::findIdentityByAccessToken undefined")
89
80
  }
90
81
  return null;
@@ -106,82 +97,4 @@ export class WebUser extends Component {
106
97
  public afterLogin() {
107
98
 
108
99
  }
109
-
110
- public getId() {
111
- let identity = this.getIdentity();
112
- return identity !== null ? identity.getId() : null;
113
- }
114
-
115
- /**
116
- * Checks if the user can perform the operation as specified by the given permission.
117
- *
118
- * Note that you must configure "authManager" application component in order to use this method.
119
- * Otherwise it will always return false.
120
- *
121
- * @param string $permissionName the name of the permission (e.g. "edit post") that needs access check.
122
- * @param array $params name-value pairs that would be passed to the rules associated
123
- * with the roles and permissions assigned to the user.
124
- * @param bool $allowCaching whether to allow caching the result of access check.
125
- * When this parameter is true (default), if the access check of an operation was performed
126
- * before, its result will be directly returned when calling this method to check the same
127
- * operation. If this parameter is false, this method will always call
128
- * [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this
129
- * caching is effective only within the same request and only works when `$params = []`.
130
- * @return bool whether the user can perform the operation as specified by the given permission.
131
- */
132
- // public function can($permissionName, $params = [], $allowCaching = true)
133
- // {
134
- // if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
135
- // return $this->_access[$permissionName];
136
- // }
137
- // if (($accessChecker = $this->getAccessChecker()) === null) {
138
- // return false;
139
- // }
140
- // $access = $accessChecker->checkAccess($this->getId(), $permissionName, $params);
141
- // if ($allowCaching && empty($params)) {
142
- // $this->_access[$permissionName] = $access;
143
- // }
144
- //
145
- // return $access;
146
- // }
147
-
148
- public async can(permissionName: string, params = [], allowCaching = true) {
149
-
150
- let access;
151
- let accessChecker: AuthManager;
152
- if ((accessChecker = this.getAccessChecker()) == null)
153
- return false;
154
-
155
-
156
- access = await accessChecker.checkAccess(this.getId(), permissionName, params);
157
-
158
- if (allowCaching && Utils.isEmpty(params)) {
159
- // this._access[$permissionName] = $access;
160
- }
161
-
162
- return access;
163
-
164
- }
165
-
166
- /**
167
- * Returns auth manager associated with the user component.
168
- *
169
- * By default this is the `authManager` application component.
170
- * You may override this method to return a different auth manager instance if needed.
171
- * @return \yii\rbac\ManagerInterface
172
- * @since 2.0.6
173
- */
174
- protected getAuthManager(): AuthManager {
175
- return BaseChyz.getComponent('authManager');
176
- }
177
-
178
- /**
179
- * Returns the access checker used for checking access.
180
- * @return CheckAccessInterface
181
- */
182
- protected getAccessChecker():AuthManager {
183
- return this.accessChecker !== null ? this.accessChecker : this.getAuthManager();
184
- }
185
-
186
-
187
100
  }
@@ -1,13 +0,0 @@
1
- ##Model
2
-
3
- Model sınıfı "Sequelize" üzerine inşa edildmiştir ( ileriki zamanlarda farklı yöntemlerde eklemeyi planlıyorum)
4
-
5
- ##public function
6
-
7
- ###getDb:
8
- ###get sequelize:
9
- ###set sequelize:
10
- ###get errors:
11
- ###set errors:
12
- ###init:
13
-
@@ -1,121 +0,0 @@
1
- /*
2
- *
3
- * Copyright (c) 2021-2021.. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- *
8
- */
9
-
10
- import {Controller, ForbiddenHttpException, ModelManager, ValidationHttpException} from "../../base";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {controller, get, post} from "../../decorator";
15
- import {ProductsClass} from "../Models/Products";
16
- import {HttpBasicAuth} from "../../filters/auth/HttpBasicAuth";
17
-
18
-
19
- @controller("/basic/api")
20
- class ApiController extends Controller {
21
-
22
-
23
-
24
- public behaviors(): any[] {
25
-
26
- return [{
27
- 'authenticator': {
28
- "class": HttpBasicAuth,
29
- // "auth": this.myCheck
30
- }
31
- }]
32
- }
33
-
34
- @get("/")
35
- Index(req: Request, res: Response) {
36
-
37
- BaseChyz.logs().info("Site Controller Burası", this.id)
38
- return res.json({message: "index sayfası"})
39
- }
40
-
41
- @post("orderCreate")
42
- async Login(req: Request, res: Response) {
43
- let data = req.body;
44
- data.Customer.status = "true";
45
- data.Customer["2fa"] = "true";
46
-
47
- //Customer Model Create
48
- let customer = ModelManager.Customer.save();
49
- //Order Model Create
50
- let order = ModelManager.Order;
51
-
52
-
53
- let transaction
54
- try {
55
- // get transaction
56
- transaction = await BaseChyz.getComponent("db").transaction();
57
- customer.load(data, "Customer");//load customer data
58
- let cus: any = await customer.save({}, {transaction});
59
-
60
- if (!cus) {
61
- throw new ValidationHttpException(customer.errors);
62
- }
63
-
64
- data.Order.customer_id = cus.id;
65
- // data.Order.total = 0;
66
- // data.Order.status = true;
67
- order.load(data, "Order");
68
- let res1 = await order.save({}, {transaction});
69
- if (!res1) {
70
- throw new ValidationHttpException(order.errors);
71
- }
72
-
73
- // commit
74
- await transaction.commit();
75
-
76
- } catch (e) {
77
- if (transaction) {
78
- await transaction.rollback();
79
- BaseChyz.warn("Rollback transaction")
80
- }
81
-
82
- if (e instanceof ValidationHttpException)
83
- throw new ValidationHttpException(e.message)
84
- else
85
- throw new ForbiddenHttpException(e.message)
86
- }
87
- return res.send("Post Controller")
88
- }
89
-
90
-
91
- @get("order/list")
92
- async listOrder(req: Request, res: Response) {
93
- const {Products}: { Products: ProductsClass } = ModelManager;
94
- let product = await Products.findAll({include: [ModelManager.ProductModels.model()]});
95
- return res.json(product)
96
-
97
- }
98
-
99
- @get("categories")
100
- async Categories(req: Request, res: Response) {
101
- let product = await ModelManager.Categories.findAll({
102
- include: [
103
- {
104
- model: ModelManager.Products.model(),
105
- // as: 'product',
106
- // through: { attributes: [] } // Hide unwanted `PlayerGameTeam` nested object from results
107
- }
108
- ]
109
- });
110
- return res.json(product)
111
-
112
- }
113
-
114
-
115
- error(req: Request, res: Response) {
116
- BaseChyz.logs().info("Error Sayfası")
117
- return res.send("Post Controller")
118
- }
119
- }
120
-
121
- module.exports = ApiController
@@ -1,50 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- import {DataTypes, Model, ModelManager, Relation} from "../../base";
9
-
10
- export class AuthAssignmentClass extends Model {
11
- [x: string]: any;
12
-
13
- tableName() {
14
- return 'auth_assignment';
15
- }
16
- attributes() {
17
- return {
18
-
19
- // Model attributes are defined here
20
- item_name: {
21
- type: DataTypes.STRING,
22
- primaryKey:true,
23
- allowNull: false
24
- },
25
- user_id : {
26
- type: DataTypes.STRING,
27
- allowNull: false
28
- }
29
-
30
- }
31
- }
32
-
33
- init(){
34
- super.init();
35
- this.model().removeAttribute('id')
36
- }
37
-
38
- relations(): Relation[] {
39
- return [
40
- {
41
- type: "hasMany",
42
- foreignKey: "name",
43
- sourceKey:'item_name',
44
- model: ModelManager.AuthItem.model()
45
- }
46
- ]
47
- }
48
-
49
- }
50
-
@@ -1,59 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
-
9
-
10
- import {DataTypes, Model, ModelManager, Relation} from "../../base";
11
-
12
- export class AuthItemClass extends Model {
13
- [x: string]: any;
14
-
15
- tableName() {
16
- return 'auth_item';
17
- }
18
-
19
- attributes() {
20
- return {
21
- // Model attributes are defined here
22
- name: {
23
- type: DataTypes.STRING,
24
- primaryKey:true,
25
- allowNull: false
26
- },
27
- type: {
28
- type: DataTypes.INTEGER,
29
- allowNull: false
30
- },
31
- description: {
32
- type: DataTypes.STRING,
33
- allowNull: false
34
- },
35
- rule_name: {
36
- type: DataTypes.STRING,
37
- allowNull: false
38
- }
39
-
40
- }
41
- }
42
-
43
- init() {
44
- super.init();
45
- this.model().removeAttribute('id')
46
- }
47
-
48
- relations(): Relation[] {
49
- return [
50
- {
51
- type: "hasOne",
52
- foreignKey: "item_name",
53
- model: ModelManager.AuthAssignment.model()
54
- }
55
- ]
56
- }
57
-
58
- }
59
-
@@ -1,49 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
-
9
- import {DataTypes, Model, ModelManager, Relation} from "../../base";
10
-
11
- export class AuthItemChildClass extends Model {
12
- [x: string]: any;
13
-
14
- tableName() {
15
- return 'auth_item_child';
16
- }
17
-
18
- attributes() {
19
- return {
20
- // Model attributes are defined here
21
- parent: {
22
- type: DataTypes.STRING,
23
- primaryKey: true,
24
- allowNull: false
25
- },
26
- child: {
27
- type: DataTypes.STRING,
28
- allowNull: false
29
- }
30
- }
31
- }
32
-
33
- init() {
34
- super.init();
35
- this.model().removeAttribute('id')
36
- }
37
-
38
- relations(): Relation[] {
39
- return [
40
- {
41
- type: "hasOne",
42
- foreignKey: "item_name",
43
- model: ModelManager.AuthAssignment.model()
44
- }
45
- ]
46
- }
47
-
48
- }
49
-