chyz 1.0.13-rc.3 → 1.0.13-rc.4

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 (176) hide show
  1. package/{dist/BaseChyz.js → BaseChyz.js} +0 -0
  2. package/{dist/BaseChyz.js.map → BaseChyz.js.map} +0 -0
  3. package/{dist/Chyz.js → Chyz.js} +0 -0
  4. package/{dist/Chyz.js.map → Chyz.js.map} +0 -0
  5. package/{dist/base → base}/ActionFilter.js +0 -0
  6. package/{dist/base → base}/ActionFilter.js.map +0 -0
  7. package/{dist/base → base}/BaseError.js +0 -0
  8. package/{dist/base → base}/BaseError.js.map +0 -0
  9. package/{dist/base → base}/BaseObject.js +0 -0
  10. package/{dist/base → base}/BaseObject.js.map +0 -0
  11. package/{dist/base → base}/Behavior.js +0 -0
  12. package/{dist/base → base}/Behavior.js.map +0 -0
  13. package/{dist/base → base}/Component.js +0 -0
  14. package/{dist/base → base}/Component.js.map +0 -0
  15. package/{dist/base → base}/Configurable.js +0 -0
  16. package/{dist/base → base}/Configurable.js.map +0 -0
  17. package/{dist/base → base}/Controller.js +0 -0
  18. package/{dist/base → base}/Controller.js.map +0 -0
  19. package/{dist/base → base}/DataErrorDbException.js +0 -0
  20. package/{dist/base → base}/DataErrorDbException.js.map +0 -0
  21. package/{dist/base → base}/DbConnection.js +0 -0
  22. package/{dist/base → base}/DbConnection.js.map +0 -0
  23. package/{dist/base → base}/ForbiddenHttpException.js +0 -0
  24. package/{dist/base → base}/ForbiddenHttpException.js.map +0 -0
  25. package/{dist/base → base}/InvalidConfigException.js +0 -0
  26. package/{dist/base → base}/InvalidConfigException.js.map +0 -0
  27. package/{dist/base → base}/Model.js +0 -0
  28. package/{dist/base → base}/Model.js.map +0 -0
  29. package/{dist/base → base}/NotFoundHttpException.js +0 -0
  30. package/{dist/base → base}/NotFoundHttpException.js.map +0 -0
  31. package/{dist/base → base}/RestClient.js +0 -0
  32. package/{dist/base → base}/RestClient.js.map +0 -0
  33. package/{dist/base → base}/UnauthorizedHttpException.js +0 -0
  34. package/{dist/base → base}/UnauthorizedHttpException.js.map +0 -0
  35. package/{dist/base → base}/ValidationHttpException.js +0 -0
  36. package/{dist/base → base}/ValidationHttpException.js.map +0 -0
  37. package/{dist/base → base}/db/Exception.js +0 -0
  38. package/{dist/base → base}/db/Exception.js.map +0 -0
  39. package/{dist/base → base}/index.js +0 -0
  40. package/{dist/base → base}/index.js.map +0 -0
  41. package/{dist/decorator → decorator}/Middleware.js +0 -0
  42. package/{dist/decorator → decorator}/Middleware.js.map +0 -0
  43. package/{dist/decorator → decorator}/controller.js +0 -0
  44. package/{dist/decorator → decorator}/controller.js.map +0 -0
  45. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js +0 -0
  46. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js.map +0 -0
  47. package/{dist/decorator → decorator}/get.js +0 -0
  48. package/{dist/decorator → decorator}/get.js.map +0 -0
  49. package/{dist/decorator → decorator}/index.js +0 -0
  50. package/{dist/decorator → decorator}/index.js.map +0 -0
  51. package/{dist/decorator → decorator}/post.js +0 -0
  52. package/{dist/decorator → decorator}/post.js.map +0 -0
  53. package/{dist/filters → filters}/AccessControl.js +0 -0
  54. package/{dist/filters → filters}/AccessControl.js.map +0 -0
  55. package/{dist/filters → filters}/AccessRule.js +0 -0
  56. package/{dist/filters → filters}/AccessRule.js.map +0 -0
  57. package/{dist/filters → filters}/auth/AuthInterface.js +0 -0
  58. package/{dist/filters → filters}/auth/AuthInterface.js.map +0 -0
  59. package/{dist/filters → filters}/auth/AuthMethod.js +0 -0
  60. package/{dist/filters → filters}/auth/AuthMethod.js.map +0 -0
  61. package/{dist/filters → filters}/auth/HttpBasicAuth.js +0 -0
  62. package/{dist/filters → filters}/auth/HttpBasicAuth.js.map +0 -0
  63. package/{dist/filters → filters}/auth/HttpBearerAuth.js +0 -0
  64. package/{dist/filters → filters}/auth/HttpBearerAuth.js.map +0 -0
  65. package/{dist/filters → filters}/auth/HttpHeaderAuth.js +0 -0
  66. package/{dist/filters → filters}/auth/HttpHeaderAuth.js.map +0 -0
  67. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js +0 -0
  68. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js.map +0 -0
  69. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
  70. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
  71. package/{dist/filters → filters}/auth/index.js +0 -0
  72. package/{dist/filters → filters}/auth/index.js.map +0 -0
  73. package/{dist/filters → filters}/index.js +0 -0
  74. package/{dist/filters → filters}/index.js.map +0 -0
  75. package/{dist/index.js → index.js} +0 -0
  76. package/{dist/index.js.map → index.js.map} +0 -0
  77. package/{dist/model → model}/RouteDefinition.js +0 -0
  78. package/{dist/model → model}/RouteDefinition.js.map +0 -0
  79. package/package.json +1 -1
  80. package/{dist/requiments → requiments}/Glob.js +0 -0
  81. package/{dist/requiments → requiments}/Glob.js.map +0 -0
  82. package/{dist/requiments → requiments}/ReflectUtil.js +0 -0
  83. package/{dist/requiments → requiments}/ReflectUtil.js.map +0 -0
  84. package/{dist/requiments → requiments}/Utils.js +0 -0
  85. package/{dist/requiments → requiments}/Utils.js.map +0 -0
  86. package/{dist/validators → validators}/BooleanValidator.js +0 -0
  87. package/{dist/validators → validators}/BooleanValidator.js.map +0 -0
  88. package/{dist/validators → validators}/CompareValidator.js +0 -0
  89. package/{dist/validators → validators}/CompareValidator.js.map +0 -0
  90. package/{dist/validators → validators}/DateValidator.js +0 -0
  91. package/{dist/validators → validators}/DateValidator.js.map +0 -0
  92. package/{dist/validators → validators}/EmailValidator.js +0 -0
  93. package/{dist/validators → validators}/EmailValidator.js.map +0 -0
  94. package/{dist/validators → validators}/Validator.js +0 -0
  95. package/{dist/validators → validators}/Validator.js.map +0 -0
  96. package/{dist/web → web}/IdentityInterface.js +0 -0
  97. package/{dist/web → web}/IdentityInterface.js.map +0 -0
  98. package/{dist/web → web}/WebUser.js +0 -0
  99. package/{dist/web → web}/WebUser.js.map +0 -0
  100. package/BaseChyz.ts +0 -361
  101. package/Chyz.ts +0 -11
  102. package/Examples/Controllers/ApiController.ts +0 -131
  103. package/Examples/Controllers/KeyCloakController.ts +0 -100
  104. package/Examples/Controllers/PublicController.ts +0 -42
  105. package/Examples/Controllers/SiteController.ts +0 -139
  106. package/Examples/Models/Categories.ts +0 -36
  107. package/Examples/Models/Customer.ts +0 -115
  108. package/Examples/Models/KeycloakUser.ts +0 -66
  109. package/Examples/Models/Order.ts +0 -64
  110. package/Examples/Models/OrderItem.ts +0 -27
  111. package/Examples/Models/ProductModels.ts +0 -50
  112. package/Examples/Models/ProductToCategories.ts +0 -35
  113. package/Examples/Models/Products.ts +0 -49
  114. package/Examples/Models/Stocks.ts +0 -60
  115. package/Examples/Models/User.ts +0 -100
  116. package/Examples/Models/UserPermission.ts +0 -37
  117. package/Examples/index-keycloack.ts +0 -78
  118. package/Examples/index.ts +0 -39
  119. package/Examples/keycloak.json +0 -7
  120. package/Examples/log/access.log +0 -0
  121. package/Examples/log/app.log +0 -923
  122. package/Examples/log/errors.log +0 -80
  123. package/Examples/package.json +0 -46
  124. package/Examples/tsconfig.json +0 -20
  125. package/base/ActionFilter.ts +0 -71
  126. package/base/BaseError.ts +0 -26
  127. package/base/BaseObject.ts +0 -19
  128. package/base/Behavior.ts +0 -6
  129. package/base/Component.ts +0 -66
  130. package/base/Configurable.ts +0 -10
  131. package/base/Controller.ts +0 -84
  132. package/base/DataErrorDbException.ts +0 -16
  133. package/base/DbConnection.ts +0 -51
  134. package/base/ForbiddenHttpException.ts +0 -15
  135. package/base/InvalidConfigException.ts +0 -16
  136. package/base/Model.ts +0 -354
  137. package/base/NotFoundHttpException.ts +0 -14
  138. package/base/RestClient.ts +0 -28
  139. package/base/UnauthorizedHttpException.ts +0 -17
  140. package/base/ValidationHttpException.ts +0 -14
  141. package/base/db/Exception.ts +0 -14
  142. package/base/index.ts +0 -16
  143. package/decorator/Middleware.ts +0 -9
  144. package/decorator/controller.ts +0 -22
  145. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  146. package/decorator/get.ts +0 -37
  147. package/decorator/index.ts +0 -3
  148. package/decorator/post.ts +0 -36
  149. package/dist/README.md +0 -270
  150. package/dist/log/config/log4js.json +0 -55
  151. package/dist/package.json +0 -55
  152. package/filters/AccessControl.ts +0 -64
  153. package/filters/AccessRule.ts +0 -137
  154. package/filters/auth/AuthInterface.ts +0 -34
  155. package/filters/auth/AuthMethod.ts +0 -88
  156. package/filters/auth/HttpBasicAuth.ts +0 -7
  157. package/filters/auth/HttpBearerAuth.ts +0 -31
  158. package/filters/auth/HttpHeaderAuth.ts +0 -53
  159. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  160. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  161. package/filters/auth/index.ts +0 -3
  162. package/filters/index.ts +0 -2
  163. package/index.ts +0 -14
  164. package/model/RouteDefinition.ts +0 -18
  165. package/package-lock.json +0 -5259
  166. package/requiments/Glob.ts +0 -9
  167. package/requiments/ReflectUtil.ts +0 -26
  168. package/requiments/Utils.ts +0 -57
  169. package/tsconfig.json +0 -18
  170. package/validators/BooleanValidator.ts +0 -0
  171. package/validators/CompareValidator.ts +0 -0
  172. package/validators/DateValidator.ts +0 -0
  173. package/validators/EmailValidator.ts +0 -0
  174. package/validators/Validator.ts +0 -27
  175. package/web/IdentityInterface.ts +0 -62
  176. package/web/WebUser.ts +0 -100
@@ -1,131 +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} from "../../base";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {get} from "../../decorator";
15
- import {post} from "../../decorator";
16
- import {controller} from "../../decorator";
17
- import {JwtHttpBearerAuth} from "../../filters/auth";
18
-
19
- import {ValidationHttpException} from "../../base";
20
- import {ForbiddenHttpException} from "../../base";
21
- import {OrderClass, Order} from "../Models/Order";
22
- import {CustomerClass, Customer} from "../Models/Customer";
23
- import {Products} from "../Models/Products";
24
- import {ProductModels} from "../Models/ProductModels";
25
-
26
- @controller("/api")
27
- class ApiController extends Controller {
28
-
29
- public myCheck(token) {
30
- console.log("myyyyyyyyyyyyyyyyyyyyy")
31
- }
32
-
33
- public behaviors(): any[] {
34
-
35
- return [{
36
- 'authenticator': {
37
- "class": JwtHttpBearerAuth,
38
- // "auth": this.myCheck
39
- },
40
- // 'access': {
41
- // 'class': AccessControl,
42
- // 'only': ['login', 'logout', 'signup'],
43
- // 'rules': [
44
- // {
45
- // 'allow': true,
46
- // 'actions': ['login', 'index'],
47
- // 'roles': ['?'],
48
- // },
49
- // {
50
- // 'allow': true,
51
- // 'actions': ['logout', "logout2"],
52
- // 'roles': ['@'],
53
- // }
54
- // ]
55
- // }
56
- }]
57
- }
58
-
59
- @get("/")
60
- Index(req: Request, res: Response) {
61
-
62
- BaseChyz.logs().info("Site Controller Burası", this.id)
63
- return res.json({message: "index sayfası"})
64
- }
65
-
66
- @post("orderCreate")
67
- async Login(req: Request, res: Response) {
68
- let data = req.body;
69
- data.Customer.status = "true";
70
- data.Customer["2fa"] = "true";
71
-
72
- //Customer Model Create
73
- let customer: CustomerClass = Customer;
74
- //Order Model Create
75
- let order: OrderClass = Order;
76
-
77
-
78
- let transaction
79
- try {
80
- // get transaction
81
- transaction = await BaseChyz.getComponent("db").transaction();
82
-
83
-
84
- customer.load(data, "Customer");//load customer data
85
- let cus: any = await customer.save({}, {transaction});
86
-
87
- if (!cus) {
88
- throw new ValidationHttpException(customer.errors);
89
- }
90
-
91
- data.Order.customer_id = cus.id;
92
- // data.Order.total = 0;
93
- // data.Order.status = true;
94
- order.load(data, "Order");
95
- let res1 = await order.save({}, {transaction});
96
- if (!res1) {
97
- throw new ValidationHttpException(order.errors);
98
- }
99
-
100
- // commit
101
- await transaction.commit();
102
-
103
- } catch (e) {
104
- if (transaction) {
105
- await transaction.rollback();
106
- BaseChyz.warn("Rollback transaction")
107
- }
108
-
109
- if (e instanceof ValidationHttpException)
110
- throw new ValidationHttpException(e.message)
111
- else
112
- throw new ForbiddenHttpException(e.message)
113
- }
114
- return res.send("Post Controller")
115
- }
116
-
117
-
118
- @get("order/list")
119
- async listOrder(req: Request, res: Response) {
120
- let product = await Products.findAll({include: [ProductModels.model()]});
121
- return res.json(product)
122
-
123
- }
124
-
125
- error(req: Request, res: Response) {
126
- BaseChyz.logs().info("Error Sayfası")
127
- return res.send("Post Controller")
128
- }
129
- }
130
-
131
- module.exports = ApiController
@@ -1,100 +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} from "../../base/Controller";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {get,post,controller} from "../../decorator";
15
-
16
- import {ValidationHttpException,ForbiddenHttpException} from "../../base";
17
- import {KeyCloakHttpBearerAuth} from "../../filters/auth/KeyCloakHttpBearerAuth";
18
-
19
- import {OrderClass, Order} from "../Models/Order";
20
- import {CustomerClass, Customer} from "../Models/Customer";
21
-
22
- @controller("/oauth2.0")
23
- class ApiController extends Controller {
24
-
25
- public behaviors(): any[] {
26
-
27
- return [{
28
- 'authenticator': {
29
- "class": KeyCloakHttpBearerAuth,
30
- // "auth": this.myCheck
31
- }
32
- }]
33
- }
34
-
35
- @get("/")
36
- Index(req: Request, res: Response) {
37
-
38
- BaseChyz.logs().info("Site Controller Burası", this.id)
39
- return res.json({message: "index sayfası"})
40
- }
41
-
42
- @post("orderCreate")
43
- async Login(req: Request, res: Response) {
44
- let data = req.body;
45
- data.Customer.status = "true";
46
- data.Customer["2fa"] = "true";
47
-
48
- //Customer Model Create
49
- let customer: CustomerClass = Customer;
50
- //Order Model Create
51
- let order: OrderClass = Order ;
52
-
53
-
54
- let transaction
55
- try {
56
- // get transaction
57
- transaction = await BaseChyz.getComponent("db").transaction();
58
-
59
-
60
- customer.load(data, "Customer");//load customer data
61
- let cus: any = await customer.save({}, {transaction});
62
-
63
- if (!cus) {
64
- throw new ValidationHttpException(customer.errors);
65
- }
66
-
67
- data.Order.customer_id = cus.id;
68
- // data.Order.total = 0;
69
- // data.Order.status = true;
70
- order.load(data, "Order");
71
- let res1 = await order.save({}, {transaction});
72
- if (!res1) {
73
- throw new ValidationHttpException(order.errors);
74
- }
75
-
76
- // commit
77
- await transaction.commit();
78
-
79
- } catch (e) {
80
- if (transaction) {
81
- await transaction.rollback();
82
- BaseChyz.warn("Rollback transaction")
83
- }
84
-
85
- if (e instanceof ValidationHttpException)
86
- throw new ValidationHttpException(e.message)
87
- else
88
- throw new ForbiddenHttpException(e.message)
89
- }
90
- return res.send("Post Controller")
91
- }
92
-
93
-
94
- error(req: Request, res: Response) {
95
- BaseChyz.logs().info("Error Sayfası")
96
- return res.send("Post Controller")
97
- }
98
- }
99
-
100
- module.exports = ApiController
@@ -1,42 +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} from "../../base/Controller";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {get} from "../../decorator/get";
15
- import {controller} from "../../decorator/controller";
16
-
17
- @controller("/public")
18
- class PublicController extends Controller {
19
-
20
- public myCheck(token) {
21
- console.log("myyyyyyyyyyyyyyyyyyyyy")
22
- }
23
-
24
- public behaviors(): any[] {
25
-
26
- return [ ]
27
- }
28
-
29
- @get("/")
30
- Index(req: Request, res: Response) {
31
-
32
- BaseChyz.logs().info("Site Controller Burası", super.id)
33
- return res.json({message: "index sayfası"})
34
- }
35
-
36
-
37
- error(req: Request, res: Response) {
38
- BaseChyz.logs().info("Error Sayfası")
39
- return res.send("Post Controller")
40
- }
41
- }
42
- module.exports=PublicController
@@ -1,139 +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 {Controller} from "../../base";
9
- import BaseChyz from "../../BaseChyz";
10
- // @ts-ignore
11
- import {Request, Response} from "express";
12
- import {get} from "../../decorator";
13
- import {post} from "../../decorator";
14
- import {controller} from "../../decorator";
15
- import {User} from "../Models/User";
16
- import {ForbiddenHttpException} from "../../base";
17
- import {JwtHttpBearerAuth} from "../../filters/auth";
18
-
19
- const bcrypt = require('bcrypt');
20
- const JsonWebToken = require("jsonwebtoken");
21
-
22
-
23
- @controller("/site")
24
- class SiteController extends Controller {
25
-
26
- public myCheck(token) {
27
- console.log("myyyyyyyyyyyyyyyyyyyyy")
28
- }
29
- public behaviors(): any[] {
30
- return [{
31
- 'authenticator': {
32
- "class": JwtHttpBearerAuth,
33
- "except":["index","login"]
34
- // "auth": this.myCheck
35
- }
36
- }]
37
- }
38
-
39
-
40
- // public behaviors(): any[] {
41
- //
42
- // return [{
43
- // // 'authenticator': {
44
- // // "class": JwtHttpBearerAuth,
45
- // // // "auth": this.myCheck
46
- // // },
47
- // 'access': {
48
- // 'class': AccessControl,
49
- // 'only': ['login', 'logout','index' ],
50
- // 'rules': [
51
- // {
52
- // 'allow': false,
53
- // 'actions': ['login', 'index' ],
54
- // 'roles': ['?'],
55
- // },
56
- // {
57
- // 'allow': true,
58
- // 'actions': ['logout', "logout2"],
59
- // 'roles': ['@'],
60
- // }
61
- // ]
62
- // }
63
- // }]
64
- // }
65
-
66
- @get("index")
67
- Index(req: Request, res: Response) {
68
-
69
- BaseChyz.logs().info("Site Controller Burası", this.id)
70
- return res.json({message: "index sayfası"})
71
- }
72
-
73
- @post("login")
74
- async login(req: Request, res: Response) {
75
- let UserModel: User = new User();
76
- let token
77
- let username = req.body.username;
78
- let password = req.body.password;
79
-
80
-
81
- let user = await UserModel.findOne({where: {username: username}})
82
- if (user) {
83
- BaseChyz.debug("Db found user", username)
84
- const match = await bcrypt.compare(password, user.password);
85
- if (match) {
86
- BaseChyz.debug("Db user verify", username)
87
- //login
88
- // @ts-ignore
89
- let xForwardedFor = (req.headers['x-forwarded-for'] || '').replace(/:\d+$/, '');
90
- let ip = xForwardedFor || req.socket.remoteAddress;
91
- var source: string = req.headers['user-agent'] || '';
92
- if (req.headers['x-ucbrowser-ua']) { //special case of UC Browser
93
- source = req.headers['x-ucbrowser-ua']+"";
94
- }
95
- token = await JsonWebToken.sign({
96
- user: user.id,
97
- ip: ip,
98
- agent: source,
99
- }, user.authkey, {expiresIn: '1h'});
100
-
101
- BaseChyz.debug("Db user create access token", username,"expiresIn","1h")
102
- return res.json({token: token})
103
- } else {
104
- let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
105
- res.status(500).json( error.toJSON())
106
- }
107
- } else {
108
- let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
109
- res.status(500).json( error.toJSON())
110
- }
111
-
112
-
113
- }
114
-
115
- @get("logout")
116
- logout(req: Request, res: Response) {
117
-
118
- // @ts-ignore
119
- let identity = req.user ?? BaseChyz.getComponent("user").getIdentity();
120
- // console.log("logout2", identity.id)
121
- //console.log(identity)
122
-
123
- BaseChyz.logs().info("Logout Controller")
124
- return res.send("Logout Controller")
125
- }
126
-
127
- @get("signup")
128
- logout2(req: Request, res: Response) {
129
-
130
-
131
- return res.send("Logout Controller")
132
- }
133
-
134
- error(req: Request, res: Response) {
135
- BaseChyz.logs().info("Error Sayfası")
136
- return res.send("Post Controller")
137
- }
138
- }
139
- module.exports=SiteController
@@ -1,36 +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
- import {DataTypes, Model} from "../../base";
8
-
9
- export class CategoriesClass extends Model {
10
- [x: string]: any;
11
-
12
- tableName() {
13
- return 'categories';
14
- }
15
-
16
-
17
- attributes() {
18
- return {
19
- // Model attributes are defined here
20
- title: {
21
- type: DataTypes.STRING,
22
- allowNull: false
23
- },
24
- properties: {
25
- type: DataTypes.STRING,
26
- allowNull: false
27
- }
28
-
29
- }
30
- }
31
-
32
-
33
- }
34
-
35
- const Categories = new CategoriesClass();
36
- export {Categories};
@@ -1,115 +0,0 @@
1
- // @ts-ignore
2
- import {DataTypes, Model} from "../../base";
3
-
4
- export class CustomerClass extends Model {
5
- [x: string]: any;
6
-
7
- public tableName() {
8
- return 'customer';
9
- }
10
-
11
- public attributes() {
12
- return {
13
- name: {
14
- type: DataTypes.STRING,
15
- allowNull: false,
16
- validate: {
17
- notEmpty: true,
18
- is: ["^[a-z0-9A-Z]+$", 'i'],
19
- len: [4, 255],
20
- }
21
- },
22
- firstname: {
23
- type: DataTypes.STRING,
24
- validate: {
25
- is: ["^[a-z0-9A-Z]+$", 'i'],
26
- len: [4, 255],
27
- }
28
- },
29
- lastname: {
30
- type: DataTypes.STRING,
31
- validate: {
32
- is: ["^[a-z0-9A-Z]+$", 'i'],
33
- len: [4, 255],
34
- }
35
- },
36
- companyName: {
37
- type: DataTypes.STRING,
38
- allowNull: true,
39
- validate: {
40
- is: /^[0-9A-Za-z =().:;+-şŞçÇöÖğĞıİüÜ]+$/i,
41
- len: [4, 255],
42
- }
43
- },
44
- email: {
45
- type: DataTypes.STRING,
46
- validate: {
47
- isEmail: true
48
- }
49
- },
50
- gsm_phone: {
51
- type: DataTypes.STRING,
52
- validate: {
53
- is: ["^[0-9 +]+$", 'i'],
54
- }
55
- },
56
- country: {
57
- type: DataTypes.STRING,
58
- validate: {
59
- isAlpha: true,
60
- }
61
- },
62
- address: {
63
- type: DataTypes.STRING,
64
- validate: {
65
- is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$", "i"],
66
- }
67
- },
68
- taxoffice: {
69
- type: DataTypes.STRING,
70
- validate: {
71
- is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$", "i"],
72
- }
73
- },
74
- taxnumber: {
75
- unique: true,
76
- type: DataTypes.STRING,
77
- validate: {
78
- is: ["^[0-9]+$", 'i'],
79
- }
80
- },
81
- username: {
82
- unique: true,
83
- type: DataTypes.STRING,
84
- validate: {
85
- isEmail: true
86
- }
87
- },
88
- password: {
89
- type: DataTypes.STRING,
90
- validate: {
91
- is: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?\.#&])[A-Za-z\d$@$!%*\.?&]{8,12}/
92
- }
93
- },
94
- "2fa": {
95
- type: DataTypes.BOOLEAN,
96
- validate: {
97
- isBoolean: true
98
- }
99
- },
100
- status: {
101
- type: DataTypes.BOOLEAN,
102
- validate: {
103
- isBoolean: true
104
- }
105
- }
106
- }
107
- }
108
-
109
- }
110
-
111
- const Customer = new CustomerClass();
112
- export {Customer};
113
-
114
-
115
-
@@ -1,66 +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 {IdentityInterface} from "../../web/IdentityInterface";
9
- import {DataTypes, Model} from "../../base";
10
- import BaseChyz from "../../BaseChyz";
11
-
12
- const JsonWebToken = require("jsonwebtoken");
13
-
14
- export class KeycloakUser implements IdentityInterface {
15
-
16
- [x: string]: any;
17
-
18
-
19
- findIdentity(id: number) {
20
- throw new Error("Method not implemented.");
21
- }
22
-
23
- getId(): number {
24
- throw new Error("Method not implemented.");
25
- }
26
-
27
- getAuthKey(): string {
28
- throw new Error("Method not implemented.");
29
- }
30
-
31
- validateAuthKey(authKey: string): boolean {
32
- throw new Error("Method not implemented.");
33
- }
34
-
35
- public attributes() {
36
- return {
37
- // Model attributes are defined here
38
- username: {
39
- type: DataTypes.STRING,
40
- allowNull: false
41
- },
42
- password: {
43
- type: DataTypes.STRING,
44
- allowNull: false
45
- },
46
- user_role: {
47
- type: DataTypes.STRING,
48
- allowNull: false
49
- },
50
- salt_text: {
51
- type: DataTypes.STRING
52
- // allowNull defaults to true
53
- }
54
- }
55
- }
56
-
57
- async findIdentityByAccessToken(token, type) {
58
- console.log(token,type)
59
- // console.log(this)
60
- // console.log(BaseChyz)
61
- return null;
62
- // return keycloak.protect('realm:user');
63
- }
64
- }
65
-
66
-
@@ -1,64 +0,0 @@
1
- import {DataTypes, Model, Relation} from "../../base";
2
- import {OrderItem} from "./OrderItem";
3
-
4
- export class OrderClass extends Model {
5
- [x: string]: any;
6
-
7
- tableName() {
8
- return 'order';
9
- }
10
-
11
-
12
- attributes() {
13
-
14
- return {
15
- customer_id: {
16
- allowNull: false,
17
- type: DataTypes.INTEGER,
18
- },
19
-
20
- crm_order_id: {
21
- allowNull: false,
22
- type: DataTypes.INTEGER,
23
- },
24
-
25
- total: {
26
- allowNull: false,
27
- type: DataTypes.FLOAT,
28
- },
29
-
30
- created_date: {
31
- allowNull: false,
32
- type: DataTypes.DATE,
33
- // @ts-ignore
34
- defaultValue: Model.NOW
35
- },
36
- status: {
37
- type: DataTypes.BOOLEAN,
38
- allowNull: false,
39
- validate: {
40
- isBoolean: true
41
- }
42
- }
43
- }
44
- }
45
-
46
-
47
- relation(): Relation[] {
48
- return [
49
- {
50
- type: "hasOne",
51
- sourceKey: "order_id",
52
- foreignKey: "id",
53
- model: OrderItem.model()
54
- }
55
- ]
56
- }
57
- }
58
-
59
- const Order = new OrderClass()
60
- export {Order};
61
-
62
-
63
-
64
-