chyz 1.0.13-rc.9 → 1.1.0-rc.2

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 (71) hide show
  1. package/BaseChyz.ts +74 -20
  2. package/Doc/Moel kullanma.md +13 -0
  3. package/Examples/Controllers/ApiController.ts +22 -22
  4. package/Examples/Controllers/BasicApiController.ts +121 -0
  5. package/Examples/Controllers/SiteController.ts +18 -8
  6. package/Examples/Models/AuthAssignment.ts +50 -0
  7. package/Examples/Models/AuthItem.ts +59 -0
  8. package/Examples/Models/AuthItemChild.ts +49 -0
  9. package/Examples/Models/Categories.ts +4 -0
  10. package/Examples/Models/KeycloakUser.ts +4 -0
  11. package/Examples/Models/User.ts +30 -2
  12. package/Examples/index.ts +22 -2
  13. package/Examples/log/app.log +14466 -0
  14. package/Examples/log/errors.log +594 -0
  15. package/Examples/package.json +5 -2
  16. package/README.md +265 -12
  17. package/base/ActionFilter.ts +1 -1
  18. package/base/BaseError.ts +4 -2
  19. package/base/DbConnection.ts +9 -5
  20. package/base/Model.ts +231 -30
  21. package/base/ModelManager.ts +6 -1
  22. package/base/RestClient.ts +4 -4
  23. package/base/ValidationHttpException.ts +1 -1
  24. package/dist/BaseChyz.js +61 -14
  25. package/dist/BaseChyz.js.map +1 -1
  26. package/dist/base/ActionFilter.js +1 -1
  27. package/dist/base/ActionFilter.js.map +1 -1
  28. package/dist/base/BaseError.js +6 -2
  29. package/dist/base/BaseError.js.map +1 -1
  30. package/dist/base/DbConnection.js +1 -0
  31. package/dist/base/DbConnection.js.map +1 -1
  32. package/dist/base/Model.js +192 -4
  33. package/dist/base/Model.js.map +1 -1
  34. package/dist/base/ModelManager.js +0 -8
  35. package/dist/base/ModelManager.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/filters/AccessControl.js +15 -3
  40. package/dist/filters/AccessControl.js.map +1 -1
  41. package/dist/filters/AccessRule.js +99 -38
  42. package/dist/filters/AccessRule.js.map +1 -1
  43. package/dist/filters/auth/HttpBasicAuth.js +65 -0
  44. package/dist/filters/auth/HttpBasicAuth.js.map +1 -1
  45. package/dist/filters/auth/index.js +1 -0
  46. package/dist/filters/auth/index.js.map +1 -1
  47. package/dist/package.json +6 -4
  48. package/dist/rbac/AuthAssignment.js +45 -0
  49. package/dist/rbac/AuthAssignment.js.map +1 -0
  50. package/dist/rbac/AuthItem.js +52 -0
  51. package/dist/rbac/AuthItem.js.map +1 -0
  52. package/dist/rbac/AuthItemChild.js +44 -0
  53. package/dist/rbac/AuthItemChild.js.map +1 -0
  54. package/dist/rbac/AuthManager.js +13 -5
  55. package/dist/rbac/AuthManager.js.map +1 -1
  56. package/dist/requiments/Utils.js +5 -1
  57. package/dist/requiments/Utils.js.map +1 -1
  58. package/dist/web/WebUser.js +78 -0
  59. package/dist/web/WebUser.js.map +1 -1
  60. package/filters/AccessControl.ts +19 -6
  61. package/filters/AccessRule.ts +61 -16
  62. package/filters/auth/HttpBasicAuth.ts +68 -0
  63. package/filters/auth/index.ts +1 -0
  64. package/package.json +6 -4
  65. package/rbac/AuthAssignment.ts +50 -0
  66. package/rbac/AuthItem.ts +57 -0
  67. package/rbac/AuthItemChild.ts +50 -0
  68. package/rbac/AuthManager.ts +19 -9
  69. package/requiments/Utils.ts +6 -0
  70. package/web/IdentityInterface.ts +7 -1
  71. package/web/WebUser.ts +88 -1
package/BaseChyz.ts CHANGED
@@ -6,11 +6,49 @@ import Utils from "./requiments/Utils";
6
6
  import {ModelManager} from "./base";
7
7
 
8
8
 
9
+ const https = require('https');
9
10
  const express = require("express");
10
11
  const log4js = require("log4js");
11
12
  const fs = require('fs');
12
13
  const validate = require('validate.js');
13
14
 
15
+ /**
16
+ * Use
17
+ * selectedBox: {
18
+ * array: {
19
+ * id: {
20
+ * numericality: {
21
+ * onlyInteger: true,
22
+ * greaterThan: 0
23
+ * }
24
+ * }
25
+ * }
26
+ * },
27
+ * @param arrayItems
28
+ * @param itemConstraints
29
+ */
30
+ validate.validators.array = (arrayItems: any, itemConstraints: any) => {
31
+ const arrayItemErrors = arrayItems.reduce((errors: any, item: any, index: any) => {
32
+ const error = validate(item, itemConstraints);
33
+ if (error) errors[index] = {error: error};
34
+ return errors;
35
+ }, {});
36
+
37
+ return Utils.isEmpty(arrayItemErrors) ? null : {errors: arrayItemErrors};
38
+ };
39
+
40
+
41
+ validate.validators.tokenString = (items: any, itemConstraints: any) => {
42
+ let arrayItems = items.split(",");
43
+ const arrayItemErrors = arrayItems.reduce((errors: any, item: any, index: any) => {
44
+ const error = validate(item, itemConstraints);
45
+ if (error) errors[index] = {error: error};
46
+ return errors;
47
+ }, {});
48
+
49
+ return Utils.isEmpty(arrayItemErrors) ? null : {errors: arrayItemErrors};
50
+ };
51
+
14
52
  var ip = require('ip');
15
53
  var bodyParser = require('body-parser')
16
54
  var methodOverride = require('method-override')
@@ -23,7 +61,7 @@ export default class BaseChyz {
23
61
  private _port: number = 3001;
24
62
  static db: any;
25
63
  static routes: any;
26
- private static _validate:any=validate;
64
+ private static _validate: any = validate;
27
65
  private _logConfig: any = require('./log/config/log4js.json') ?? {}
28
66
  private _controllerpath: string = "Controllers"
29
67
  private static controllers: Array<Controller> = []
@@ -48,8 +86,7 @@ export default class BaseChyz {
48
86
  }
49
87
 
50
88
  init() {
51
- this.logProvider().level = log4js.levels.ALL;
52
- this.logProvider().configure(this._logConfig);
89
+
53
90
 
54
91
  /**
55
92
  * set request id
@@ -140,16 +177,21 @@ export default class BaseChyz {
140
177
  this.config = config;
141
178
 
142
179
 
180
+ // logger setting
181
+ this.logProvider().level = log4js.levels.ALL;
182
+ this.logProvider().configure(this._logConfig);
183
+
143
184
  let components = Utils.findKeyValue(config, "components")
144
185
  if (components) {
145
186
  for (const componentsKey in components) {
187
+
146
188
  let comp = components[componentsKey];
147
- BaseChyz.logs().info("Create Component ", componentsKey)
189
+ BaseChyz.debug("Create Component ", componentsKey)
148
190
  try {
149
191
  BaseChyz.components[componentsKey] = Utils.createObject(new comp.class, comp);
150
192
  BaseChyz.components[componentsKey]?.init();
151
- }catch (e) {
152
- console.error(e)
193
+ } catch (e) {
194
+ BaseChyz.error("Create Component ", e)
153
195
  }
154
196
 
155
197
  }
@@ -166,7 +208,6 @@ export default class BaseChyz {
166
208
  }
167
209
  }
168
210
 
169
-
170
211
  this.init();
171
212
 
172
213
  return this;
@@ -238,8 +279,8 @@ export default class BaseChyz {
238
279
  if (res.headersSent) {
239
280
  return next(err)
240
281
  }
241
- res.status(500)
242
- res.json('error', {error: err})
282
+
283
+ res.status(500).json({error: err})
243
284
  }
244
285
 
245
286
  public static getComponent(key: any) {
@@ -263,14 +304,14 @@ export default class BaseChyz {
263
304
  // @ts-ignore
264
305
  let className = file.split(".")[0] + "Class";
265
306
  if (model[className])
266
- models[className.replace("Class","")] = new model[className];
307
+ models[className.replace("Class", "")] = new model[className];
267
308
  }
268
309
  })
269
310
 
270
311
  ModelManager._register(models);
271
312
 
272
313
  for (const key of Object.keys(ModelManager)) {
273
- if(key!="_register"){
314
+ if (key != "_register") {
274
315
  ModelManager[key].init();
275
316
  }
276
317
  }
@@ -310,7 +351,7 @@ export default class BaseChyz {
310
351
  BaseChyz.debug(`Call Request id ${instance.id}`)
311
352
  await instance.beforeAction(route, req, res)
312
353
  next()
313
- } catch (e) {
354
+ } catch (e: any) {
314
355
  BaseChyz.error(e);
315
356
 
316
357
  res.status(e.statusCode || 500)
@@ -348,8 +389,8 @@ export default class BaseChyz {
348
389
 
349
390
  public middleware() {
350
391
 
351
- BaseChyz.express.use(bodyParser.json())
352
- BaseChyz.express.use(bodyParser.urlencoded({extended: true})); // support encoded bodies
392
+ BaseChyz.express.use(bodyParser.json({limit: '1mb'}));
393
+ BaseChyz.express.use(bodyParser.urlencoded({limit: '1mb', extended: true})); // support encoded bodies
353
394
  BaseChyz.express.use(methodOverride());
354
395
  BaseChyz.express.use(methodOverride());
355
396
 
@@ -386,12 +427,25 @@ export default class BaseChyz {
386
427
  public Start() {
387
428
 
388
429
  BaseChyz.info("Express Server Starting")
389
- BaseChyz.express.listen(this._port, () => {
390
- BaseChyz.info("Express Server Start ")
391
- BaseChyz.info(`Liten Port ${this._port}`)
392
- BaseChyz.info(`http://localhost:${this._port}`)
393
- BaseChyz.info(`http://${ip.address()}:${this._port}`)
394
- })
430
+
431
+ if (this.config?.ssl) {
432
+ const httpsServer = https.createServer(this.config?.ssl , BaseChyz.express);
433
+ httpsServer.listen(this._port, () => {
434
+ BaseChyz.info("Express Server Start ")
435
+ BaseChyz.info(`Liten Port ${this._port}`)
436
+ BaseChyz.info(`https://localhost:${this._port}`)
437
+ BaseChyz.info(`https://${ip.address()}:${this._port}`)
438
+ })
439
+ }else{
440
+ BaseChyz.express.listen(this._port, () => {
441
+ BaseChyz.info("Express Server Start ")
442
+ BaseChyz.info(`Liten Port ${this._port}`)
443
+ BaseChyz.info(`http://localhost:${this._port}`)
444
+ BaseChyz.info(`http://${ip.address()}:${this._port}`)
445
+ })
446
+ }
447
+
448
+
395
449
  return this;
396
450
  }
397
451
 
@@ -0,0 +1,13 @@
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
+
@@ -18,7 +18,8 @@ import {JwtHttpBearerAuth} from "../../filters/auth";
18
18
 
19
19
  import {ValidationHttpException} from "../../base";
20
20
  import {ForbiddenHttpException} from "../../base";
21
-
21
+ import {ProductsClass} from "../Models/Products";
22
+ import {AccessControl} from "../../filters";
22
23
 
23
24
 
24
25
  @controller("/api")
@@ -35,22 +36,18 @@ class ApiController extends Controller {
35
36
  "class": JwtHttpBearerAuth,
36
37
  // "auth": this.myCheck
37
38
  },
38
- // 'access': {
39
- // 'class': AccessControl,
40
- // 'only': ['login', 'logout', 'signup'],
41
- // 'rules': [
42
- // {
43
- // 'allow': true,
44
- // 'actions': ['login', 'index'],
45
- // 'roles': ['?'],
46
- // },
47
- // {
48
- // 'allow': true,
49
- // 'actions': ['logout', "logout2"],
50
- // 'roles': ['@'],
51
- // }
52
- // ]
53
- // }
39
+ 'access': {
40
+ 'class': AccessControl,
41
+ 'only': ['order/list' ],
42
+ 'rules': [
43
+
44
+ {
45
+ 'allow': true,
46
+ 'actions': ['order/list' ],
47
+ 'roles': ['edis-manager'],
48
+ }
49
+ ]
50
+ }
54
51
  }]
55
52
  }
56
53
 
@@ -68,9 +65,9 @@ class ApiController extends Controller {
68
65
  data.Customer["2fa"] = "true";
69
66
 
70
67
  //Customer Model Create
71
- let customer = ModelManager.Customer;
68
+ let customer = ModelManager.Customer.save();
72
69
  //Order Model Create
73
- let order = ModelManager.Order;
70
+ let order = ModelManager.Order;
74
71
 
75
72
 
76
73
  let transaction
@@ -113,20 +110,23 @@ class ApiController extends Controller {
113
110
 
114
111
  @get("order/list")
115
112
  async listOrder(req: Request, res: Response) {
116
- let product = await ModelManager.Products.findAll({include: [ModelManager.ProductModels.model()]});
113
+ const {Products}: { Products: ProductsClass } = ModelManager;
114
+ let product = await Products.cache().findAll( );
117
115
  return res.json(product)
118
116
 
119
117
  }
120
118
 
121
119
  @get("categories")
122
120
  async Categories(req: Request, res: Response) {
123
- let product = await ModelManager.Categories.findAll( {include:[
121
+ let product = await ModelManager.Categories.findAll({
122
+ include: [
124
123
  {
125
124
  model: ModelManager.Products.model(),
126
125
  // as: 'product',
127
126
  // through: { attributes: [] } // Hide unwanted `PlayerGameTeam` nested object from results
128
127
  }
129
- ]} );
128
+ ]
129
+ });
130
130
  return res.json(product)
131
131
 
132
132
  }
@@ -0,0 +1,121 @@
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
@@ -26,11 +26,12 @@ class SiteController extends Controller {
26
26
  public myCheck(token) {
27
27
  console.log("myyyyyyyyyyyyyyyyyyyyy")
28
28
  }
29
+
29
30
  public behaviors(): any[] {
30
31
  return [{
31
32
  'authenticator': {
32
33
  "class": JwtHttpBearerAuth,
33
- "except":["index","login"]
34
+ "except": ["index", "login"]
34
35
  // "auth": this.myCheck
35
36
  }
36
37
  }]
@@ -88,25 +89,33 @@ class SiteController extends Controller {
88
89
  // @ts-ignore
89
90
  let xForwardedFor = (req.headers['x-forwarded-for'] || '').replace(/:\d+$/, '');
90
91
  let ip = xForwardedFor || req.socket.remoteAddress;
91
- var source: string = req.headers['user-agent'] || '';
92
+ var source: string = req.headers['user-agent'] || '';
92
93
  if (req.headers['x-ucbrowser-ua']) { //special case of UC Browser
93
- source = req.headers['x-ucbrowser-ua']+"";
94
+ source = req.headers['x-ucbrowser-ua'] + "";
94
95
  }
95
96
  token = await JsonWebToken.sign({
96
97
  user: user.id,
97
98
  ip: ip,
98
99
  agent: source,
99
- }, user.authkey, {expiresIn: '1h'});
100
+ platform: "admin",
101
+ role: [
102
+ "admin"
103
+ ],
104
+ permissions: [
105
+ "xxxx",
106
+
107
+ ],
108
+ }, user.authkey, null);
100
109
 
101
- BaseChyz.debug("Db user create access token", username,"expiresIn","1h")
110
+ BaseChyz.debug("Db user create access token", username, "expiresIn", "1h")
102
111
  return res.json({token: token})
103
112
  } else {
104
113
  let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
105
- res.status(500).json( error.toJSON())
114
+ res.status(500).json(error.toJSON())
106
115
  }
107
116
  } else {
108
117
  let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
109
- res.status(500).json( error.toJSON())
118
+ res.status(500).json(error.toJSON())
110
119
  }
111
120
 
112
121
 
@@ -136,4 +145,5 @@ class SiteController extends Controller {
136
145
  return res.send("Post Controller")
137
146
  }
138
147
  }
139
- module.exports=SiteController
148
+
149
+ module.exports = SiteController
@@ -0,0 +1,50 @@
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
+
@@ -0,0 +1,59 @@
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
+
@@ -0,0 +1,49 @@
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
+
@@ -5,10 +5,14 @@
5
5
  * Github:https://github.com/cihan53/
6
6
  */
7
7
  import {DataTypes, Model, ModelManager, Relation} from "../../base";
8
+ import {BaseChyz} from "../../index";
8
9
 
9
10
  export class CategoriesClass extends Model {
10
11
  [x: string]: any;
11
12
 
13
+ constructor( ) {
14
+ super(BaseChyz.getComponent("db2").db);
15
+ }
12
16
  tableName() {
13
17
  return 'categories';
14
18
  }
@@ -61,6 +61,10 @@ export class KeycloakUser implements IdentityInterface {
61
61
  return null;
62
62
  // return keycloak.protect('realm:user');
63
63
  }
64
+
65
+ can(permissionName: string, params: any[], allowCaching: boolean): boolean | null {
66
+ return undefined;
67
+ }
64
68
  }
65
69
 
66
70