chyz 2.0.1-rc.36 → 2.0.1-rc.37

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 (231) hide show
  1. package/dist/BaseChyz.d.ts +74 -0
  2. package/dist/BaseChyz.d.ts.map +1 -0
  3. package/dist/BaseChyz.js +586 -0
  4. package/dist/base/ActionFilter.d.ts +32 -0
  5. package/dist/base/ActionFilter.d.ts.map +1 -0
  6. package/dist/base/ActionFilter.js +90 -0
  7. package/dist/base/BadRequestHttpException.d.ts +6 -0
  8. package/dist/base/BadRequestHttpException.d.ts.map +1 -0
  9. package/dist/base/BadRequestHttpException.js +17 -0
  10. package/dist/base/BaseError.d.ts +44 -0
  11. package/dist/base/BaseError.d.ts.map +1 -0
  12. package/{base/BaseError.ts → dist/base/BaseError.js} +18 -26
  13. package/dist/base/Behavior.d.ts +4 -0
  14. package/dist/base/Behavior.d.ts.map +1 -0
  15. package/dist/base/Behavior.js +7 -0
  16. package/dist/base/CBaseObject.d.ts +5 -0
  17. package/dist/base/CBaseObject.d.ts.map +1 -0
  18. package/dist/base/CBaseObject.js +16 -0
  19. package/dist/base/CEvents.d.ts +13 -0
  20. package/dist/base/CEvents.d.ts.map +1 -0
  21. package/dist/base/CEvents.js +24 -0
  22. package/dist/base/CRequest.d.ts +2 -0
  23. package/dist/base/CRequest.d.ts.map +1 -0
  24. package/{base/CRequest.ts → dist/base/CRequest.js} +2 -6
  25. package/dist/base/CWebController.d.ts +44 -0
  26. package/dist/base/CWebController.d.ts.map +1 -0
  27. package/dist/base/CWebController.js +81 -0
  28. package/dist/base/Component.d.ts +21 -0
  29. package/dist/base/Component.d.ts.map +1 -0
  30. package/dist/base/Component.js +57 -0
  31. package/dist/base/Configurable.d.ts +3 -0
  32. package/dist/base/Configurable.d.ts.map +1 -0
  33. package/{requiments/Glob.ts → dist/base/Configurable.js} +2 -3
  34. package/dist/base/DataErrorDbException.d.ts +6 -0
  35. package/dist/base/DataErrorDbException.d.ts.map +1 -0
  36. package/dist/base/DataErrorDbException.js +17 -0
  37. package/dist/base/DbConnection.d.ts +13 -0
  38. package/dist/base/DbConnection.d.ts.map +1 -0
  39. package/dist/base/DbConnection.js +53 -0
  40. package/dist/base/ForbiddenHttpException.d.ts +5 -0
  41. package/dist/base/ForbiddenHttpException.d.ts.map +1 -0
  42. package/dist/base/ForbiddenHttpException.js +16 -0
  43. package/dist/base/InvalidArgumentException.d.ts +6 -0
  44. package/dist/base/InvalidArgumentException.d.ts.map +1 -0
  45. package/dist/base/InvalidArgumentException.js +17 -0
  46. package/dist/base/InvalidConfigException.d.ts +6 -0
  47. package/dist/base/InvalidConfigException.d.ts.map +1 -0
  48. package/dist/base/InvalidConfigException.js +17 -0
  49. package/dist/base/Logs.d.ts +22 -0
  50. package/dist/base/Logs.d.ts.map +1 -0
  51. package/{base/Logs.ts → dist/base/Logs.js} +24 -41
  52. package/dist/base/Model.d.ts +302 -0
  53. package/dist/base/Model.d.ts.map +1 -0
  54. package/{base/Model.ts → dist/base/Model.js} +158 -225
  55. package/dist/base/ModelManager.d.ts +2 -0
  56. package/dist/base/ModelManager.d.ts.map +1 -0
  57. package/{base/ModelManager.ts → dist/base/ModelManager.js} +7 -7
  58. package/dist/base/NotFoundHttpException.d.ts +6 -0
  59. package/dist/base/NotFoundHttpException.d.ts.map +1 -0
  60. package/dist/base/NotFoundHttpException.js +17 -0
  61. package/dist/base/RestClient.d.ts +7 -0
  62. package/dist/base/RestClient.d.ts.map +1 -0
  63. package/dist/base/RestClient.js +25 -0
  64. package/dist/base/UnauthorizedHttpException.d.ts +6 -0
  65. package/dist/base/UnauthorizedHttpException.d.ts.map +1 -0
  66. package/dist/base/UnauthorizedHttpException.js +17 -0
  67. package/dist/base/ValidationHttpException.d.ts +6 -0
  68. package/dist/base/ValidationHttpException.d.ts.map +1 -0
  69. package/dist/base/ValidationHttpException.js +17 -0
  70. package/dist/base/db/Exception.d.ts +7 -0
  71. package/dist/base/db/Exception.d.ts.map +1 -0
  72. package/dist/base/db/Exception.js +15 -0
  73. package/dist/base/index.d.ts +20 -0
  74. package/dist/base/index.d.ts.map +1 -0
  75. package/dist/base/index.js +41 -0
  76. package/dist/decorator/Middleware.d.ts +4 -0
  77. package/dist/decorator/Middleware.d.ts.map +1 -0
  78. package/dist/decorator/Middleware.js +10 -0
  79. package/dist/decorator/controller.d.ts +3 -0
  80. package/dist/decorator/controller.d.ts.map +1 -0
  81. package/{decorator/controller.ts → dist/decorator/controller.js} +9 -7
  82. package/dist/decorator/delete.d.ts +3 -0
  83. package/dist/decorator/delete.d.ts.map +1 -0
  84. package/{decorator/delete.ts → dist/decorator/delete.js} +9 -9
  85. package/dist/decorator/enums/ControllerDecoratorParams.d.ts +6 -0
  86. package/dist/decorator/enums/ControllerDecoratorParams.d.ts.map +1 -0
  87. package/dist/decorator/enums/ControllerDecoratorParams.js +9 -0
  88. package/dist/decorator/get.d.ts +3 -0
  89. package/dist/decorator/get.d.ts.map +1 -0
  90. package/{decorator/get.ts → dist/decorator/get.js} +10 -11
  91. package/dist/decorator/index.d.ts +6 -0
  92. package/dist/decorator/index.d.ts.map +1 -0
  93. package/dist/decorator/index.js +13 -0
  94. package/dist/decorator/post.d.ts +3 -0
  95. package/dist/decorator/post.d.ts.map +1 -0
  96. package/{decorator/post.ts → dist/decorator/post.js} +10 -10
  97. package/dist/decorator/put.d.ts +3 -0
  98. package/dist/decorator/put.d.ts.map +1 -0
  99. package/{decorator/put.ts → dist/decorator/put.js} +9 -9
  100. package/dist/filters/AccessControl.d.ts +12 -0
  101. package/dist/filters/AccessControl.d.ts.map +1 -0
  102. package/dist/filters/AccessControl.js +83 -0
  103. package/dist/filters/AccessRule.d.ts +83 -0
  104. package/dist/filters/AccessRule.d.ts.map +1 -0
  105. package/dist/filters/AccessRule.js +136 -0
  106. package/{filters/auth/AuthInterface.ts → dist/filters/auth/AuthInterface.d.ts} +7 -15
  107. package/dist/filters/auth/AuthInterface.d.ts.map +1 -0
  108. package/dist/filters/auth/AuthInterface.js +2 -0
  109. package/dist/filters/auth/AuthMethod.d.ts +38 -0
  110. package/dist/filters/auth/AuthMethod.d.ts.map +1 -0
  111. package/dist/filters/auth/AuthMethod.js +82 -0
  112. package/dist/filters/auth/HttpBasicAuth.d.ts +24 -0
  113. package/dist/filters/auth/HttpBasicAuth.d.ts.map +1 -0
  114. package/dist/filters/auth/HttpBasicAuth.js +79 -0
  115. package/dist/filters/auth/HttpBearerAuth.d.ts +18 -0
  116. package/dist/filters/auth/HttpBearerAuth.d.ts.map +1 -0
  117. package/dist/filters/auth/HttpBearerAuth.js +33 -0
  118. package/dist/filters/auth/HttpHeaderAuth.d.ts +19 -0
  119. package/dist/filters/auth/HttpHeaderAuth.d.ts.map +1 -0
  120. package/dist/filters/auth/HttpHeaderAuth.js +64 -0
  121. package/dist/filters/auth/JwtHttpBearerAuth.d.ts +21 -0
  122. package/dist/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -0
  123. package/dist/filters/auth/JwtHttpBearerAuth.js +88 -0
  124. package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts +23 -0
  125. package/dist/filters/auth/KeyCloakHttpBearerAuth.d.ts.map +1 -0
  126. package/dist/filters/auth/KeyCloakHttpBearerAuth.js +116 -0
  127. package/dist/filters/auth/index.d.ts +5 -0
  128. package/dist/filters/auth/index.d.ts.map +1 -0
  129. package/dist/filters/auth/index.js +11 -0
  130. package/dist/filters/index.d.ts +3 -0
  131. package/dist/filters/index.d.ts.map +1 -0
  132. package/dist/filters/index.js +7 -0
  133. package/dist/index.d.ts +26 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +73 -0
  136. package/dist/log/log/config/log4js.json +55 -0
  137. package/dist/model/RouteDefinition.d.ts +7 -0
  138. package/dist/model/RouteDefinition.d.ts.map +1 -0
  139. package/{base/Configurable.ts → dist/model/RouteDefinition.js} +2 -4
  140. package/dist/package.json +63 -0
  141. package/dist/rbac/AuthAssignment.d.ts +19 -0
  142. package/dist/rbac/AuthAssignment.d.ts.map +1 -0
  143. package/dist/rbac/AuthAssignment.js +44 -0
  144. package/dist/rbac/AuthItem.d.ts +27 -0
  145. package/dist/rbac/AuthItem.d.ts.map +1 -0
  146. package/{rbac/AuthItem.ts → dist/rbac/AuthItem.js} +16 -22
  147. package/dist/rbac/AuthItemChild.d.ts +19 -0
  148. package/dist/rbac/AuthItemChild.d.ts.map +1 -0
  149. package/{rbac/AuthItemChild.ts → dist/rbac/AuthItemChild.js} +14 -21
  150. package/dist/rbac/AuthManager.d.ts +112 -0
  151. package/dist/rbac/AuthManager.d.ts.map +1 -0
  152. package/dist/rbac/AuthManager.js +356 -0
  153. package/dist/rbac/index.d.ts +5 -0
  154. package/dist/rbac/index.d.ts.map +1 -0
  155. package/dist/rbac/index.js +28 -0
  156. package/dist/requiments/Glob.d.ts +3 -0
  157. package/dist/requiments/Glob.d.ts.map +1 -0
  158. package/dist/requiments/Glob.js +10 -0
  159. package/dist/requiments/ReflectUtil.d.ts +1 -0
  160. package/dist/requiments/ReflectUtil.d.ts.map +1 -0
  161. package/{requiments/ReflectUtil.ts → dist/requiments/ReflectUtil.js} +4 -6
  162. package/dist/requiments/Utils.d.ts +2 -0
  163. package/dist/requiments/Utils.d.ts.map +1 -0
  164. package/{requiments/Utils.ts → dist/requiments/Utils.js} +34 -40
  165. package/dist/validators/BooleanValidator.d.ts +1 -0
  166. package/dist/validators/BooleanValidator.d.ts.map +1 -0
  167. package/dist/validators/BooleanValidator.js +1 -0
  168. package/dist/validators/CompareValidator.d.ts +1 -0
  169. package/dist/validators/CompareValidator.d.ts.map +1 -0
  170. package/dist/validators/CompareValidator.js +1 -0
  171. package/dist/validators/DateValidator.d.ts +1 -0
  172. package/dist/validators/DateValidator.d.ts.map +1 -0
  173. package/dist/validators/DateValidator.js +1 -0
  174. package/dist/validators/EmailValidator.d.ts +1 -0
  175. package/dist/validators/EmailValidator.d.ts.map +1 -0
  176. package/dist/validators/EmailValidator.js +1 -0
  177. package/dist/validators/Validator.d.ts +18 -0
  178. package/dist/validators/Validator.d.ts.map +1 -0
  179. package/dist/validators/Validator.js +27 -0
  180. package/{web/IdentityInterface.ts → dist/web/IdentityInterface.d.ts} +2 -15
  181. package/dist/web/IdentityInterface.d.ts.map +1 -0
  182. package/dist/web/IdentityInterface.js +8 -0
  183. package/dist/web/WebUser.d.ts +72 -0
  184. package/dist/web/WebUser.d.ts.map +1 -0
  185. package/dist/web/WebUser.js +165 -0
  186. package/package.json +16 -56
  187. package/BaseChyz.ts +0 -623
  188. package/base/ActionFilter.ts +0 -88
  189. package/base/BadRequestHttpException.ts +0 -14
  190. package/base/Behavior.ts +0 -6
  191. package/base/CBaseObject.ts +0 -17
  192. package/base/CEvents.ts +0 -24
  193. package/base/CWebController.ts +0 -90
  194. package/base/Component.ts +0 -66
  195. package/base/DataErrorDbException.ts +0 -16
  196. package/base/DbConnection.ts +0 -55
  197. package/base/ForbiddenHttpException.ts +0 -15
  198. package/base/InvalidArgumentException.ts +0 -16
  199. package/base/InvalidConfigException.ts +0 -16
  200. package/base/NotFoundHttpException.ts +0 -14
  201. package/base/RestClient.ts +0 -26
  202. package/base/UnauthorizedHttpException.ts +0 -17
  203. package/base/ValidationHttpException.ts +0 -14
  204. package/base/db/Exception.ts +0 -14
  205. package/base/index.ts +0 -19
  206. package/decorator/Middleware.ts +0 -9
  207. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  208. package/decorator/index.ts +0 -5
  209. package/filters/AccessControl.ts +0 -74
  210. package/filters/AccessRule.ts +0 -182
  211. package/filters/auth/AuthMethod.ts +0 -100
  212. package/filters/auth/HttpBasicAuth.ts +0 -79
  213. package/filters/auth/HttpBearerAuth.ts +0 -34
  214. package/filters/auth/HttpHeaderAuth.ts +0 -61
  215. package/filters/auth/JwtHttpBearerAuth.ts +0 -83
  216. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -114
  217. package/filters/auth/index.ts +0 -4
  218. package/filters/index.ts +0 -2
  219. package/index.ts +0 -80
  220. package/model/RouteDefinition.ts +0 -18
  221. package/rbac/AuthAssignment.ts +0 -50
  222. package/rbac/AuthManager.ts +0 -399
  223. package/rbac/index.ts +0 -12
  224. package/validators/BooleanValidator.ts +0 -0
  225. package/validators/CompareValidator.ts +0 -0
  226. package/validators/DateValidator.ts +0 -0
  227. package/validators/EmailValidator.ts +0 -0
  228. package/validators/Validator.ts +0 -27
  229. package/web/WebUser.ts +0 -187
  230. /package/{README.md → dist/README.md} +0 -0
  231. /package/{log → dist/log}/config/log4js.json +0 -0
@@ -1,48 +1,34 @@
1
+ "use strict";
1
2
  /*
2
3
  * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
4
  * Author: Cihan Ozturk
4
5
  * E-mail: cihan@chy.com.tr
5
6
  * Github:https://github.com/cihan53/
6
7
  */
7
-
8
- import BaseChyz from "../BaseChyz";
9
- import {Utils} from "../requiments/Utils";
10
- import {Component} from "./Component";
11
- import {InvalidConfigException} from "./InvalidConfigException";
12
- import {
13
- DatabaseError,
14
- ExclusionConstraintError,
15
- ForeignKeyConstraintError,
16
- Model as SModel,
17
- QueryOptions,
18
- QueryOptionsWithType,
19
- QueryTypes,
20
- Sequelize,
21
- TimeoutError,
22
- UniqueConstraintError,
23
- ValidationError,
24
- } from "sequelize";
25
- import {Exception} from "./db/Exception";
26
- import {DataErrorDbException} from "./DataErrorDbException";
27
-
28
- export {DataTypes, NOW} from "sequelize";
29
-
30
-
31
- export interface Relation {
32
- [key: string]: any;
33
-
34
- type: "hasOne" | "hasMany" | "belongsToMany" | "belongsTo",
35
- allowNull?: boolean,
36
- sourceKey?: string,
37
- model: SModel,
38
- foreignKey: string,
39
- name?: string,
40
- through?: any,
41
- as?: string,
42
- on?: any,
43
- scope?: any
44
- }
45
-
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.Model = exports.NOW = exports.DataTypes = void 0;
22
+ const BaseChyz_1 = __importDefault(require("../BaseChyz"));
23
+ const Utils_1 = require("../requiments/Utils");
24
+ const Component_1 = require("./Component");
25
+ const InvalidConfigException_1 = require("./InvalidConfigException");
26
+ const sequelize_1 = require("sequelize");
27
+ const Exception_1 = require("./db/Exception");
28
+ const DataErrorDbException_1 = require("./DataErrorDbException");
29
+ var sequelize_2 = require("sequelize");
30
+ Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return sequelize_2.DataTypes; } });
31
+ Object.defineProperty(exports, "NOW", { enumerable: true, get: function () { return sequelize_2.NOW; } });
46
32
  /**
47
33
  * ValidateMe.init({
48
34
  bar: {
@@ -96,29 +82,19 @@ export interface Relation {
96
82
  }
97
83
  }, { sequelize });
98
84
  */
99
-
100
- export class Model extends Component {
101
- _provider: any;
102
- _register: any;
103
- private readonly _tableName: string;
104
- private _model: any;
105
- private _attributes: any = {};
106
- private _errors: any = {}
107
-
108
-
109
- constructor(sequelize?: IDBDatabase) {
85
+ class Model extends Component_1.Component {
86
+ constructor(sequelize) {
110
87
  super();
88
+ this._attributes = {};
89
+ this._errors = {};
111
90
  this._tableName = this.alias();
112
-
113
- BaseChyz.debug("Model constructor", this._tableName)
91
+ BaseChyz_1.default.debug("Model constructor", this._tableName);
114
92
  // this._sequelize = BaseChyz.getComponent("db").db;
115
-
116
93
  if (sequelize != null) {
117
94
  this._provider = sequelize;
118
- } else
95
+ }
96
+ else
119
97
  this._provider = this.getDb();
120
-
121
-
122
98
  /**
123
99
  * override query
124
100
  */
@@ -131,22 +107,19 @@ export class Model extends Component {
131
107
  // throw new DatabaseError(err);
132
108
  // }
133
109
  // };
134
-
135
- this._provider.query = function (sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType<QueryTypes.RAW> | undefined,) {
136
- return Sequelize.prototype.query.apply(this, [sql, options]).catch((err ) => {
137
-
138
-
139
- if( process.env.NODE_ENV=="development" || process.env.NODE_ENV=="dev"){
110
+ this._provider.query = function (sql, options) {
111
+ return sequelize_1.Sequelize.prototype.query.apply(this, [sql, options]).catch((err) => {
112
+ if (process.env.NODE_ENV == "development" || process.env.NODE_ENV == "dev") {
140
113
  // e.stack = e.original;
141
- if( err instanceof DatabaseError){
114
+ if (err instanceof sequelize_1.DatabaseError) {
142
115
  // @ts-ignore
143
116
  delete err.parent;
144
117
  // @ts-ignore
145
118
  delete err.original;
146
119
  }
147
120
  }
148
- throw new DataErrorDbException(err);
149
- })
121
+ throw new DataErrorDbException_1.DataErrorDbException(err);
122
+ });
150
123
  // try {
151
124
  // let r =
152
125
  // console.log(r)
@@ -154,68 +127,55 @@ export class Model extends Component {
154
127
  // console.log(err)
155
128
  // throw new DatabaseError(err);
156
129
  // }
157
- }
158
-
159
- if (!Utils.isEmpty(this.attributes())) {
130
+ };
131
+ if (!Utils_1.Utils.isEmpty(this.attributes())) {
160
132
  this._model = this._provider.define(this._tableName, this.attributes(), {
161
133
  tableName: this.tableName(),
162
134
  timestamps: false,
163
135
  createdAt: false,
164
136
  updateAt: false
165
137
  });
166
-
167
- } else {
168
- throw new InvalidConfigException(BaseChyz.t("Invalid model configuration, is not emty attributes"))
169
138
  }
170
-
139
+ else {
140
+ throw new InvalidConfigException_1.InvalidConfigException(BaseChyz_1.default.t("Invalid model configuration, is not emty attributes"));
141
+ }
171
142
  // this.init();
172
-
173
143
  }
174
-
175
-
176
144
  /**
177
145
  * Returns the database connection used by this AR class.
178
146
  * By default, the "db" application component is used as the database connection.
179
147
  * You may override this method if you want to use a different database connection.
180
148
  * @return Connection the database connection used by this AR class.
181
149
  */
182
- public getDb() {
183
- return BaseChyz.getComponent("db") ? BaseChyz.getComponent("db").db : null
150
+ getDb() {
151
+ return BaseChyz_1.default.getComponent("db") ? BaseChyz_1.default.getComponent("db").db : null;
184
152
  }
185
-
186
- public getDbConnection() {
187
- return BaseChyz.getComponent("db");
153
+ getDbConnection() {
154
+ return BaseChyz_1.default.getComponent("db");
188
155
  }
189
-
190
- get provider(): any {
156
+ get provider() {
191
157
  return this._provider;
192
158
  }
193
-
194
- set provider(value: any) {
159
+ set provider(value) {
195
160
  this._provider = value;
196
161
  }
197
-
198
-
199
162
  /**
200
163
  *
201
164
  */
202
- get errors(): any {
165
+ get errors() {
203
166
  return this._errors;
204
167
  }
205
-
206
- set errors(value: any) {
168
+ set errors(value) {
207
169
  this._errors = value;
208
170
  }
209
-
210
- public init() {
211
- BaseChyz.debug("Model init....", this.constructor.name)
171
+ init() {
172
+ BaseChyz_1.default.debug("Model init....", this.constructor.name);
212
173
  /**
213
174
  * init buraya
214
175
  */
215
- BaseChyz.debug("Relation init....", this.constructor.name)
176
+ BaseChyz_1.default.debug("Relation init....", this.constructor.name);
216
177
  for (const relation of this.relations()) {
217
178
  let m = relation.model;
218
-
219
179
  if (relation.type == "hasOne") {
220
180
  // @ts-ignore
221
181
  delete relation.model;
@@ -227,132 +187,114 @@ export class Model extends Component {
227
187
  delete relation.model;
228
188
  this.model().hasMany(m, relation);
229
189
  }
230
-
231
190
  if (relation.type == "belongsTo") {
232
191
  // @ts-ignore
233
192
  delete relation.model;
234
193
  this.model().belongsTo(m, relation);
235
194
  }
236
-
237
195
  if (relation.type == "belongsToMany") {
238
196
  // @ts-ignore
239
197
  delete relation.model;
240
198
  this.model().belongsToMany(m, relation);
241
199
  }
242
200
  }
243
-
244
-
245
201
  }
246
-
247
- public alias() {
202
+ alias() {
248
203
  return this.constructor.name;
249
204
  }
250
-
251
- public tableName() {
205
+ tableName() {
252
206
  return this._tableName;
253
207
  }
254
-
255
- public formName() {
208
+ formName() {
256
209
  return this.constructor.name;
257
210
  }
258
-
259
- public rules() {
260
- return []
211
+ rules() {
212
+ return [];
261
213
  }
262
-
263
-
264
- public setModel(value: any) {
214
+ setModel(value) {
265
215
  this._model = value;
266
216
  }
267
-
268
- public model() {
217
+ model() {
269
218
  return this._model;
270
219
  }
271
-
272
-
273
- public async save(params = {}, options = {}) {
274
-
275
- this.errors = {};
276
- // now instantiate an object
277
- let p = Object.assign(params, this._attributes)
278
- let result: any;
279
- try {
280
- result = await this.model().create(p, options)
281
- } catch (e: any) {
282
- BaseChyz.debug(`Model[${this.constructor.name}].create`, e)
283
- if (e instanceof ValidationError) {
284
- let validationErrorItems = e.errors;
285
- validationErrorItems.forEach(({message, path}) => {
286
- // @ts-ignore
287
- this._errors[path] = message
288
- })
289
-
290
- return false;
291
- } else if (e instanceof DatabaseError) {
292
-
293
- } else if (e instanceof TimeoutError) {
294
-
295
- } else if (e instanceof UniqueConstraintError) {
296
-
297
- } else if (e instanceof ForeignKeyConstraintError) {
298
-
299
- } else if (e instanceof ExclusionConstraintError) {
300
-
220
+ save() {
221
+ return __awaiter(this, arguments, void 0, function* (params = {}, options = {}) {
222
+ this.errors = {};
223
+ // now instantiate an object
224
+ let p = Object.assign(params, this._attributes);
225
+ let result;
226
+ try {
227
+ result = yield this.model().create(p, options);
301
228
  }
302
- throw new Exception(e.message, this.errors, e.code);
303
- }
304
-
305
- return result;
306
-
229
+ catch (e) {
230
+ BaseChyz_1.default.debug(`Model[${this.constructor.name}].create`, e);
231
+ if (e instanceof sequelize_1.ValidationError) {
232
+ let validationErrorItems = e.errors;
233
+ validationErrorItems.forEach(({ message, path }) => {
234
+ // @ts-ignore
235
+ this._errors[path] = message;
236
+ });
237
+ return false;
238
+ }
239
+ else if (e instanceof sequelize_1.DatabaseError) {
240
+ }
241
+ else if (e instanceof sequelize_1.TimeoutError) {
242
+ }
243
+ else if (e instanceof sequelize_1.UniqueConstraintError) {
244
+ }
245
+ else if (e instanceof sequelize_1.ForeignKeyConstraintError) {
246
+ }
247
+ else if (e instanceof sequelize_1.ExclusionConstraintError) {
248
+ }
249
+ throw new Exception_1.Exception(e.message, this.errors, e.code);
250
+ }
251
+ return result;
252
+ });
307
253
  }
308
-
309
- public async bulkCreate(params = {}, options = {}) {
310
- this.errors = {};
311
- // now instantiate an object
312
- let p = Object.assign(params, this._attributes)
313
- let result: any;
314
- try {
315
- result = await this.model().bulkCreate(p, options)
316
- } catch (e: any) {
317
- BaseChyz.debug(`Model[${this.constructor.name}].bulkCreate`, e)
318
- if (e instanceof ValidationError) {
319
- let validationErrorItems = e.errors;
320
- validationErrorItems.forEach(({message, path}) => {
321
- // @ts-ignore
322
- this._errors[path] = message
323
- })
324
-
325
- return false;
326
- } else if (e instanceof DatabaseError) {
327
-
328
- } else if (e instanceof TimeoutError) {
329
-
330
- } else if (e instanceof UniqueConstraintError) {
331
-
332
- } else if (e instanceof ForeignKeyConstraintError) {
333
-
334
- } else if (e instanceof ExclusionConstraintError) {
335
-
254
+ bulkCreate() {
255
+ return __awaiter(this, arguments, void 0, function* (params = {}, options = {}) {
256
+ this.errors = {};
257
+ // now instantiate an object
258
+ let p = Object.assign(params, this._attributes);
259
+ let result;
260
+ try {
261
+ result = yield this.model().bulkCreate(p, options);
336
262
  }
337
- throw new Exception(e.message, this.errors, e.code);
338
- }
339
-
340
- return result;
341
-
263
+ catch (e) {
264
+ BaseChyz_1.default.debug(`Model[${this.constructor.name}].bulkCreate`, e);
265
+ if (e instanceof sequelize_1.ValidationError) {
266
+ let validationErrorItems = e.errors;
267
+ validationErrorItems.forEach(({ message, path }) => {
268
+ // @ts-ignore
269
+ this._errors[path] = message;
270
+ });
271
+ return false;
272
+ }
273
+ else if (e instanceof sequelize_1.DatabaseError) {
274
+ }
275
+ else if (e instanceof sequelize_1.TimeoutError) {
276
+ }
277
+ else if (e instanceof sequelize_1.UniqueConstraintError) {
278
+ }
279
+ else if (e instanceof sequelize_1.ForeignKeyConstraintError) {
280
+ }
281
+ else if (e instanceof sequelize_1.ExclusionConstraintError) {
282
+ }
283
+ throw new Exception_1.Exception(e.message, this.errors, e.code);
284
+ }
285
+ return result;
286
+ });
342
287
  }
343
-
344
- public update(params = {}, options = {}) {
288
+ update(params = {}, options = {}) {
345
289
  this.errors = {};
346
- let p = Object.assign(params, this._attributes)
347
- return this.model().update(p, options)
290
+ let p = Object.assign(params, this._attributes);
291
+ return this.model().update(p, options);
348
292
  }
349
-
350
- public delete(params = {}, options = {}) {
293
+ delete(params = {}, options = {}) {
351
294
  this.errors = {};
352
- let p = Object.assign(params, this._attributes)
353
- return this.model().destroy(p, options)
295
+ let p = Object.assign(params, this._attributes);
296
+ return this.model().destroy(p, options);
354
297
  }
355
-
356
298
  /**
357
299
  * As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the sequelize.query method.
358
300
  *
@@ -517,96 +459,87 @@ export class Model extends Component {
517
459
  * @param query
518
460
  * @param options
519
461
  */
520
- public async rawQuery(query: string, options: any = {type: QueryTypes.SELECT, nest: true}) {
521
- this.errors = {};
522
- return await this.model().query(query, options);
462
+ rawQuery(query_1) {
463
+ return __awaiter(this, arguments, void 0, function* (query, options = { type: sequelize_1.QueryTypes.SELECT, nest: true }) {
464
+ this.errors = {};
465
+ return yield this.model().query(query, options);
466
+ });
523
467
  }
524
-
525
-
526
468
  /**
527
469
  *
528
470
  * @param args
529
471
  */
530
- public findOne(...args: any[]) {
531
- return this._model.findOne(...arguments)
472
+ findOne(...args) {
473
+ return this._model.findOne(...arguments);
532
474
  }
533
-
534
475
  /**
535
476
  *
536
477
  * @param args
537
478
  */
538
- public findAll(...args: any[]) {
539
- return this._model.findAll(...arguments)
479
+ findAll(...args) {
480
+ return this._model.findAll(...arguments);
540
481
  }
541
-
542
482
  /**
543
483
  * return {count : number , rows: any}
544
484
  * @param args
545
485
  */
546
- public findAndCountAll(...args: any[]) {
547
- return this._model.findAndCountAll(...arguments)
486
+ findAndCountAll(...args) {
487
+ return this._model.findAndCountAll(...arguments);
548
488
  }
549
-
550
-
551
- public validate() {
552
-
489
+ validate() {
553
490
  }
554
-
555
491
  /**
556
492
  *
557
493
  * @param data
558
494
  * @param formName
559
495
  */
560
- public load(data: any, formName: any = null) {
496
+ load(data, formName = null) {
561
497
  let scope = formName === null ? this.formName() : formName;
562
- if (scope === '' && !Utils.isEmpty(data)) {
498
+ if (scope === '' && !Utils_1.Utils.isEmpty(data)) {
563
499
  this.setAttribute(data);
564
500
  return true;
565
- } else if (data[scope]) {
501
+ }
502
+ else if (data[scope]) {
566
503
  this.setAttribute(data[scope]);
567
504
  return true;
568
505
  }
569
506
  return false;
570
507
  }
571
-
572
- public bulkLoad(data: any, formName: any = null) {
508
+ bulkLoad(data, formName = null) {
573
509
  let scope = formName === null ? this.formName() : formName;
574
- if (scope === '' && !Utils.isEmpty(data)) {
510
+ if (scope === '' && !Utils_1.Utils.isEmpty(data)) {
575
511
  this.setAttribute(data);
576
512
  return true;
577
- } else if (data[scope]) {
513
+ }
514
+ else if (data[scope]) {
578
515
  this.setAttribute(data[scope]);
579
516
  return true;
580
517
  }
581
518
  return false;
582
519
  }
583
-
584
- public setAttribute(values: any, safeOnly = true) {
520
+ setAttribute(values, safeOnly = true) {
585
521
  if (values instanceof Object) {
586
522
  let attributes = this.attributes();
587
523
  for (const valueKey in values) {
588
524
  if (Object.keys(attributes).indexOf(valueKey) != -1) {
589
525
  // @ts-ignore
590
- BaseChyz.debug("Model[" + this.formName() + "] attributes value set ", valueKey, values[valueKey])
526
+ BaseChyz_1.default.debug("Model[" + this.formName() + "] attributes value set ", valueKey, values[valueKey]);
591
527
  this._attributes[valueKey] = values[valueKey];
592
528
  }
593
529
  }
594
530
  }
595
531
  }
596
-
597
- public attributes() {
598
- return {}
532
+ attributes() {
533
+ return {};
599
534
  }
600
-
601
535
  /**
602
536
  * relation return array
603
537
  * [
604
538
  *
605
539
  * ]
606
540
  */
607
- public relations(): Relation[] {
608
- return []
541
+ relations() {
542
+ return [];
609
543
  }
610
-
611
-
612
544
  }
545
+ exports.Model = Model;
@@ -0,0 +1,2 @@
1
+ export declare const ModelManager: any;
2
+ //# sourceMappingURL=ModelManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelManager.d.ts","sourceRoot":"","sources":["../../src/base/ModelManager.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,YAAY,EAAE,GAI1B,CAAA"}
@@ -1,5 +1,6 @@
1
- import {Model} from "./Model"
2
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModelManager = void 0;
3
4
  /*
4
5
  *
5
6
  * Copyright (c) 2021.. Chy Bilgisayar Bilisim
@@ -11,9 +12,8 @@ import {Model} from "./Model"
11
12
  // interface ObjectConstructor {
12
13
  // _register(o: Model): void;
13
14
  // }
14
-
15
- export const ModelManager: any = {
16
- _register(map: Model) {
17
- Object.assign(this, map)
15
+ exports.ModelManager = {
16
+ _register(map) {
17
+ Object.assign(this, map);
18
18
  }
19
- }
19
+ };
@@ -0,0 +1,6 @@
1
+ import { BaseError } from "./BaseError";
2
+ export declare class NotFoundHttpException extends BaseError {
3
+ message: any;
4
+ constructor(message: any);
5
+ }
6
+ //# sourceMappingURL=NotFoundHttpException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundHttpException.d.ts","sourceRoot":"","sources":["../../src/base/NotFoundHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,qBAAsB,SAAQ,SAAS;IAC3B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.NotFoundHttpException = void 0;
10
+ const BaseError_1 = require("./BaseError");
11
+ class NotFoundHttpException extends BaseError_1.BaseError {
12
+ constructor(message) {
13
+ super(message, 404);
14
+ this.message = message;
15
+ }
16
+ }
17
+ exports.NotFoundHttpException = NotFoundHttpException;
@@ -0,0 +1,7 @@
1
+ import { Component } from "./Component";
2
+ export declare class RestClient extends Component {
3
+ post(url: string, args?: any, headers?: any): any;
4
+ get(url: string, args?: any, headers?: any): any;
5
+ Rest(params: any): any;
6
+ }
7
+ //# sourceMappingURL=RestClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestClient.d.ts","sourceRoot":"","sources":["../../src/base/RestClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,qBAAa,UAAW,SAAQ,SAAS;IAC9B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAC,OAAO,CAAC,EAAC,GAAG;IAIzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAC,OAAO,CAAC,EAAC,GAAG;IAIxC,IAAI,CAAC,MAAM,EAAE,GAAG;CAG1B"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /*
3
+ *
4
+ * Copyright (c) 2021.. Chy Bilgisayar Bilisim
5
+ * Author: Cihan Ozturk
6
+ * E-mail: cihan@chy.com.tr
7
+ * Github:https://github.com/cihan53/
8
+ *
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.RestClient = void 0;
12
+ const Component_1 = require("./Component");
13
+ const axios = require('axios');
14
+ class RestClient extends Component_1.Component {
15
+ post(url, args, headers) {
16
+ return axios.post(url, Object.assign(Object.assign({}, args), { headers: headers }));
17
+ }
18
+ get(url, args, headers) {
19
+ return axios.get(url, Object.assign(Object.assign({}, args), { headers: headers }));
20
+ }
21
+ Rest(params) {
22
+ return axios(params);
23
+ }
24
+ }
25
+ exports.RestClient = RestClient;
@@ -0,0 +1,6 @@
1
+ import { BaseError } from "./BaseError";
2
+ export declare class UnauthorizedHttpException extends BaseError {
3
+ message: any;
4
+ constructor(message: any);
5
+ }
6
+ //# sourceMappingURL=UnauthorizedHttpException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnauthorizedHttpException.d.ts","sourceRoot":"","sources":["../../src/base/UnauthorizedHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,yBAA0B,SAAQ,SAAS;IAC/B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAIpC"}