chyz 2.0.0-rc.8 → 2.0.1-rc.1

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 (153) hide show
  1. package/BaseChyz.d.ts +73 -56
  2. package/BaseChyz.d.ts.map +1 -1
  3. package/BaseChyz.js +569 -404
  4. package/README.md +1 -1
  5. package/base/ActionFilter.d.ts +32 -32
  6. package/base/ActionFilter.d.ts.map +1 -1
  7. package/base/ActionFilter.js +82 -82
  8. package/base/BadRequestHttpException.d.ts +6 -0
  9. package/base/BadRequestHttpException.d.ts.map +1 -0
  10. package/base/BadRequestHttpException.js +17 -0
  11. package/base/BaseError.d.ts +43 -10
  12. package/base/BaseError.d.ts.map +1 -1
  13. package/base/BaseError.js +58 -26
  14. package/base/Behavior.d.ts +3 -3
  15. package/base/Behavior.js +7 -7
  16. package/base/CBaseObject.d.ts +4 -4
  17. package/base/CBaseObject.d.ts.map +1 -1
  18. package/base/CBaseObject.js +16 -16
  19. package/base/CEvents.d.ts +13 -0
  20. package/base/CEvents.d.ts.map +1 -0
  21. package/base/CEvents.js +24 -0
  22. package/base/CRequest.d.ts +1 -1
  23. package/base/CRequest.js +10 -10
  24. package/base/CWebController.d.ts +43 -43
  25. package/base/CWebController.d.ts.map +1 -1
  26. package/base/CWebController.js +81 -74
  27. package/base/Component.d.ts +20 -20
  28. package/base/Component.d.ts.map +1 -1
  29. package/base/Component.js +57 -57
  30. package/base/Configurable.d.ts +2 -2
  31. package/base/Configurable.js +8 -8
  32. package/base/DataErrorDbException.d.ts +5 -5
  33. package/base/DataErrorDbException.d.ts.map +1 -1
  34. package/base/DataErrorDbException.js +17 -17
  35. package/base/DbConnection.d.ts +12 -12
  36. package/base/DbConnection.js +53 -53
  37. package/base/ForbiddenHttpException.d.ts +4 -4
  38. package/base/ForbiddenHttpException.d.ts.map +1 -1
  39. package/base/ForbiddenHttpException.js +16 -16
  40. package/base/InvalidArgumentException.d.ts +5 -5
  41. package/base/InvalidArgumentException.d.ts.map +1 -1
  42. package/base/InvalidArgumentException.js +17 -17
  43. package/base/InvalidConfigException.d.ts +5 -5
  44. package/base/InvalidConfigException.d.ts.map +1 -1
  45. package/base/InvalidConfigException.js +17 -17
  46. package/base/Logs.d.ts +21 -21
  47. package/base/Logs.d.ts.map +1 -1
  48. package/base/Logs.js +57 -57
  49. package/base/Model.d.ts +301 -298
  50. package/base/Model.d.ts.map +1 -1
  51. package/base/Model.js +545 -507
  52. package/base/ModelManager.d.ts +1 -1
  53. package/base/ModelManager.js +19 -19
  54. package/base/NotFoundHttpException.d.ts +5 -5
  55. package/base/NotFoundHttpException.d.ts.map +1 -1
  56. package/base/NotFoundHttpException.js +17 -17
  57. package/base/RestClient.d.ts +6 -6
  58. package/base/RestClient.d.ts.map +1 -1
  59. package/base/RestClient.js +25 -25
  60. package/base/UnauthorizedHttpException.d.ts +5 -5
  61. package/base/UnauthorizedHttpException.d.ts.map +1 -1
  62. package/base/UnauthorizedHttpException.js +17 -17
  63. package/base/ValidationHttpException.d.ts +5 -5
  64. package/base/ValidationHttpException.d.ts.map +1 -1
  65. package/base/ValidationHttpException.js +17 -17
  66. package/base/db/Exception.d.ts +6 -6
  67. package/base/db/Exception.js +15 -15
  68. package/base/index.d.ts +19 -18
  69. package/base/index.d.ts.map +1 -1
  70. package/base/index.js +41 -39
  71. package/decorator/Middleware.d.ts +3 -3
  72. package/decorator/Middleware.js +11 -11
  73. package/decorator/controller.d.ts +2 -2
  74. package/decorator/controller.js +24 -24
  75. package/decorator/delete.d.ts +3 -0
  76. package/decorator/delete.d.ts.map +1 -0
  77. package/decorator/delete.js +36 -0
  78. package/decorator/enums/ControllerDecoratorParams.d.ts +5 -5
  79. package/decorator/enums/ControllerDecoratorParams.js +9 -9
  80. package/decorator/get.d.ts +2 -2
  81. package/decorator/get.js +36 -36
  82. package/decorator/index.d.ts +5 -3
  83. package/decorator/index.d.ts.map +1 -1
  84. package/decorator/index.js +13 -9
  85. package/decorator/post.d.ts +2 -2
  86. package/decorator/post.js +36 -36
  87. package/decorator/put.d.ts +3 -0
  88. package/decorator/put.d.ts.map +1 -0
  89. package/decorator/put.js +36 -0
  90. package/filters/AccessControl.d.ts +12 -12
  91. package/filters/AccessControl.d.ts.map +1 -1
  92. package/filters/AccessControl.js +83 -83
  93. package/filters/AccessRule.d.ts +82 -82
  94. package/filters/AccessRule.d.ts.map +1 -1
  95. package/filters/AccessRule.js +136 -137
  96. package/filters/auth/AuthInterface.d.ts +25 -25
  97. package/filters/auth/AuthInterface.js +2 -2
  98. package/filters/auth/AuthMethod.d.ts +37 -37
  99. package/filters/auth/AuthMethod.d.ts.map +1 -1
  100. package/filters/auth/AuthMethod.js +82 -82
  101. package/filters/auth/HttpBasicAuth.d.ts +23 -22
  102. package/filters/auth/HttpBasicAuth.d.ts.map +1 -1
  103. package/filters/auth/HttpBasicAuth.js +78 -72
  104. package/filters/auth/HttpBearerAuth.d.ts +17 -17
  105. package/filters/auth/HttpBearerAuth.d.ts.map +1 -1
  106. package/filters/auth/HttpBearerAuth.js +33 -32
  107. package/filters/auth/HttpHeaderAuth.d.ts +18 -14
  108. package/filters/auth/HttpHeaderAuth.d.ts.map +1 -1
  109. package/filters/auth/HttpHeaderAuth.js +64 -57
  110. package/filters/auth/JwtHttpBearerAuth.d.ts +20 -20
  111. package/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -1
  112. package/filters/auth/JwtHttpBearerAuth.js +87 -81
  113. package/filters/auth/KeyCloakHttpBearerAuth.d.ts +22 -22
  114. package/filters/auth/KeyCloakHttpBearerAuth.js +116 -116
  115. package/filters/auth/index.d.ts +4 -4
  116. package/filters/auth/index.js +11 -11
  117. package/filters/index.d.ts +2 -2
  118. package/filters/index.js +7 -7
  119. package/index.d.ts +28 -21
  120. package/index.d.ts.map +1 -1
  121. package/index.js +71 -60
  122. package/model/RouteDefinition.d.ts +6 -6
  123. package/model/RouteDefinition.js +8 -8
  124. package/package.json +22 -24
  125. package/rbac/AuthAssignment.d.ts +18 -18
  126. package/rbac/AuthAssignment.js +44 -44
  127. package/rbac/AuthItem.d.ts +26 -26
  128. package/rbac/AuthItem.js +51 -51
  129. package/rbac/AuthItemChild.d.ts +18 -18
  130. package/rbac/AuthItemChild.js +43 -43
  131. package/rbac/AuthManager.d.ts +111 -111
  132. package/rbac/AuthManager.d.ts.map +1 -1
  133. package/rbac/AuthManager.js +356 -355
  134. package/rbac/index.d.ts +5 -0
  135. package/rbac/index.d.ts.map +1 -0
  136. package/rbac/index.js +28 -0
  137. package/requiments/Glob.d.ts +2 -2
  138. package/requiments/Glob.js +10 -10
  139. package/requiments/ReflectUtil.js +24 -24
  140. package/requiments/Utils.d.ts +1 -8
  141. package/requiments/Utils.d.ts.map +1 -1
  142. package/requiments/Utils.js +115 -112
  143. package/validators/BooleanValidator.js +1 -1
  144. package/validators/CompareValidator.js +1 -1
  145. package/validators/DateValidator.js +1 -1
  146. package/validators/EmailValidator.js +1 -1
  147. package/validators/Validator.d.ts +17 -17
  148. package/validators/Validator.js +27 -27
  149. package/web/IdentityInterface.d.ts +55 -54
  150. package/web/IdentityInterface.d.ts.map +1 -1
  151. package/web/IdentityInterface.js +8 -8
  152. package/web/WebUser.d.ts +71 -71
  153. package/web/WebUser.js +165 -165
package/base/Model.d.ts CHANGED
@@ -1,299 +1,302 @@
1
- import { Component } from "./Component";
2
- import { Model as SModel } from "sequelize";
3
- export { DataTypes, NOW } from "sequelize";
4
- export interface Relation {
5
- type: "hasOne" | "hasMany" | "belongsToMany" | "belongsTo";
6
- allowNull?: boolean;
7
- sourceKey?: string;
8
- model: SModel;
9
- foreignKey: string;
10
- name?: string;
11
- through?: any;
12
- as?: string;
13
- }
14
- /**
15
- * ValidateMe.init({
16
- bar: {
17
- type: Sequelize.STRING,
18
- validate: {
19
- is: ["^[a-z]+$",'i'], // will only allow letters
20
- is: /^[a-z]+$/i, // same as the previous example using real RegExp
21
- not: ["[a-z]",'i'], // will not allow letters
22
- isEmail: true, // checks for email format (foo@bar.com)
23
- isUrl: true, // checks for url format (http://foo.com)
24
- isIP: true, // checks for IPv4 (129.89.23.1) or IPv6 format
25
- isIPv4: true, // checks for IPv4 (129.89.23.1)
26
- isIPv6: true, // checks for IPv6 format
27
- isAlpha: true, // will only allow letters
28
- isAlphanumeric: true, // will only allow alphanumeric characters, so "_abc" will fail
29
- isNumeric: true, // will only allow numbers
30
- isInt: true, // checks for valid integers
31
- isFloat: true, // checks for valid floating point numbers
32
- isDecimal: true, // checks for any numbers
33
- isLowercase: true, // checks for lowercase
34
- isUppercase: true, // checks for uppercase
35
- notNull: true, // won't allow null
36
- isNull: true, // only allows null
37
- notEmpty: true, // don't allow empty strings
38
- equals: 'specific value', // only allow a specific value
39
- contains: 'foo', // force specific substrings
40
- notIn: [['foo', 'bar']], // check the value is not one of these
41
- isIn: [['foo', 'bar']], // check the value is one of these
42
- notContains: 'bar', // don't allow specific substrings
43
- len: [2,10], // only allow values with length between 2 and 10
44
- isUUID: 4, // only allow uuids
45
- isDate: true, // only allow date strings
46
- isAfter: "2011-11-05", // only allow date strings after a specific date
47
- isBefore: "2011-11-05", // only allow date strings before a specific date
48
- max: 23, // only allow values <= 23
49
- min: 23, // only allow values >= 23
50
- isCreditCard: true, // check for valid credit card numbers
51
-
52
- // Examples of custom validators:
53
- isEven(value) {
54
- if (parseInt(value) % 2 !== 0) {
55
- throw new Error('Only even values are allowed!');
56
- }
57
- }
58
- isGreaterThanOtherField(value) {
59
- if (parseInt(value) <= parseInt(this.otherField)) {
60
- throw new Error('Bar must be greater than otherField.');
61
- }
62
- }
63
- }
64
- }
65
- }, { sequelize });
66
- */
67
- export declare class Model extends Component {
68
- _sequelize: any;
69
- _register: any;
70
- private _tableName;
71
- private _model;
72
- private _attributes;
73
- private _errors;
74
- constructor(sequelize?: IDBDatabase);
75
- /**
76
- * Returns the database connection used by this AR class.
77
- * By default, the "db" application component is used as the database connection.
78
- * You may override this method if you want to use a different database connection.
79
- * @return Connection the database connection used by this AR class.
80
- */
81
- getDb(): any;
82
- getDbConnection(): any;
83
- get sequelize(): any;
84
- set sequelize(value: any);
85
- provider(): any;
86
- /**
87
- *
88
- */
89
- get errors(): any;
90
- set errors(value: any);
91
- init(): void;
92
- alias(): string;
93
- tableName(): string;
94
- formName(): string;
95
- rules(): never[];
96
- setModel(value: any): void;
97
- model(): any;
98
- save(params?: {}, options?: {}): Promise<any>;
99
- bulkCreate(params?: {}, options?: {}): Promise<any>;
100
- update(params?: {}, options?: {}): any;
101
- delete(params?: {}, options?: {}): any;
102
- /**
103
- * 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.
104
- *
105
- * By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc). Note that since this is a raw query, the metadata are dialect specific. Some dialects return the metadata "within" the results object (as properties on an array). However, two arguments will always be returned, but for MSSQL and MySQL it will be two references to the same object.
106
- *
107
- * const [results, metadata] = await sequelize.query("UPDATE users SET y = 42 WHERE x = 12");
108
- * // Results will be an empty array and metadata will contain the number of affected rows.
109
- *
110
- * In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
111
- *
112
- * const { QueryTypes } = require('@sequelize/core');
113
- * const users = await sequelize.query("SELECT * FROM `users`", { type: QueryTypes.SELECT });
114
- * // We didn't need to destructure the result here - the results were returned directly
115
- *
116
- * Several other query types are available. Peek into the source for details.
117
- *
118
- * A second option is the model. If you pass a model the returned data will be instances of that model.
119
- *
120
- * // Callee is the model definition. This allows you to easily map a query to a predefined model
121
- * const projects = await sequelize.query('SELECT * FROM projects', {
122
- * model: Projects,
123
- * mapToModel: true // pass true here if you have any mapped fields
124
- * });
125
- * // Each element of `projects` is now an instance of Project
126
- *
127
- * See more options in the query API reference. Some examples:
128
- * ``
129
- * const { QueryTypes } = require('@sequelize/core');
130
- * await sequelize.query('SELECT 1', {
131
- * // A function (or false) for logging your queries
132
- * // Will get called for every SQL query that gets sent
133
- * // to the server.
134
- * logging: console.log,
135
- *
136
- * // If plain is true, then sequelize will only return the first
137
- * // record of the result set. In case of false it will return all records.
138
- * plain: false,
139
- *
140
- * // Set this to true if you don't have a model definition for your query.
141
- * raw: false,
142
- *
143
- * // The type of query you are executing. The query type affects how results are formatted before they are passed back.
144
- * type: QueryTypes.SELECT
145
- * });
146
- *``
147
- * // Note the second argument being null!
148
- * // Even if we declared a callee here, the raw: true would
149
- * // supersede and return a raw object.
150
- * console.log(await sequelize.query('SELECT * FROM projects', { raw: true }));
151
- *
152
- * ##"Dotted" attributes and the nest option
153
- *
154
- * If an attribute name of the table contains dots, the resulting objects can become nested objects by setting the nest: true option. This is achieved with dottie.js under the hood. See below:
155
- *
156
- * Without nest: true:
157
- * ``
158
- * const { QueryTypes } = require('@sequelize/core');
159
- * const records = await sequelize.query('select 1 as `foo.bar.baz`', {
160
- * type: QueryTypes.SELECT
161
- * });
162
- * console.log(JSON.stringify(records[0], null, 2));
163
- *
164
- * {
165
- * "foo.bar.baz": 1
166
- * }
167
- *
168
- * With nest: true:
169
- *
170
- * const { QueryTypes } = require('@sequelize/core');
171
- * const records = await sequelize.query('select 1 as `foo.bar.baz`', {
172
- * nest: true,
173
- * type: QueryTypes.SELECT
174
- * });
175
- * console.log(JSON.stringify(records[0], null, 2));
176
- *
177
- * {
178
- * "foo": {
179
- * "bar": {
180
- * "baz": 1
181
- * }
182
- * }
183
- * }
184
- * ``
185
- * ##Replacements
186
- *
187
- * Replacements in a query can be done in two different ways, either using named parameters (starting with :), or unnamed, represented by a ?. Replacements are passed in the options object.
188
- *
189
- * If an array is passed, ? will be replaced in the order that they appear in the array
190
- * If an object is passed, :key will be replaced with the keys from that object. If the object contains keys not found in the query or vice versa, an exception will be thrown.
191
- * ``
192
- * const { QueryTypes } = require('@sequelize/core');
193
- *
194
- * await sequelize.query(
195
- * 'SELECT * FROM projects WHERE status = ?',
196
- * {
197
- * replacements: ['active'],
198
- * type: QueryTypes.SELECT
199
- * }
200
- * );
201
- *
202
- * await sequelize.query(
203
- * 'SELECT * FROM projects WHERE status = :status',
204
- * {
205
- * replacements: { status: 'active' },
206
- * type: QueryTypes.SELECT
207
- * }
208
- * );
209
- * ``
210
- * Array replacements will automatically be handled, the following query searches for projects where the status matches an array of values.
211
- * ``
212
- * const { QueryTypes } = require('@sequelize/core');
213
- *
214
- * await sequelize.query(
215
- * 'SELECT * FROM projects WHERE status IN(:status)',
216
- * {
217
- * replacements: { status: ['active', 'inactive'] },
218
- * type: QueryTypes.SELECT
219
- * }
220
- * );
221
- * ``
222
- * To use the wildcard operator %, append it to your replacement. The following query matches users with names that start with 'ben'.
223
- * ``
224
- * const { QueryTypes } = require('@sequelize/core');
225
- *
226
- * await sequelize.query(
227
- * 'SELECT * FROM users WHERE name LIKE :search_name',
228
- * {
229
- * replacements: { search_name: 'ben%' },
230
- * type: QueryTypes.SELECT
231
- * }
232
- * ); ``
233
- *
234
- * ##Bind Parameter
235
- *
236
- * Bind parameters are like replacements. Except replacements are escaped and inserted into the query by sequelize before the query is sent to the database, while bind parameters are sent to the database outside the SQL query text. A query can have either bind parameters or replacements. Bind parameters are referred to by either $1, $2, ... (numeric) or $key (alpha-numeric). This is independent of the dialect.
237
- *
238
- * If an array is passed, $1 is bound to the 1st element in the array (bind[0])
239
- * If an object is passed, $key is bound to object['key']. Each key must begin with a non-numeric char. $1 is not a valid key, even if object['1'] exists.
240
- * In either case $$ can be used to escape a literal $ sign.
241
- *
242
- * The array or object must contain all bound values or Sequelize will throw an exception. This applies even to cases in which the database may ignore the bound parameter.
243
- *
244
- * The database may add further restrictions to this. Bind parameters cannot be SQL keywords, nor table or column names. They are also ignored in quoted text or data. In PostgreSQL it may also be needed to typecast them, if the type cannot be inferred from the context $1::varchar.
245
- *``
246
- * const { QueryTypes } = require('@sequelize/core');
247
- *
248
- * await sequelize.query(
249
- * 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $1',
250
- * {
251
- * bind: ['active'],
252
- * type: QueryTypes.SELECT
253
- * }
254
- * ); ``
255
- *
256
- * `` await sequelize.query(
257
- * 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $status',
258
- * {
259
- * bind: { status: 'active' },
260
- * type: QueryTypes.SELECT
261
- * }
262
- * );``
263
- * @param query
264
- */
265
- rawQuery(query: string, options?: any): Promise<any>;
266
- /**
267
- *
268
- * @param args
269
- */
270
- findOne(...args: any[]): any;
271
- /**
272
- *
273
- * @param args
274
- */
275
- findAll(...args: any[]): any;
276
- /**
277
- * return {count : number , rows: any}
278
- * @param args
279
- */
280
- findAndCountAll(...args: any[]): any;
281
- validate(): void;
282
- /**
283
- *
284
- * @param data
285
- * @param formName
286
- */
287
- load(data: any, formName?: any): boolean;
288
- bulkLoad(data: any, formName?: any): boolean;
289
- setAttribute(values: any, safeOnly?: boolean): void;
290
- attributes(): {};
291
- /**
292
- * relation return array
293
- * [
294
- *
295
- * ]
296
- */
297
- relations(): Relation[];
298
- }
1
+ import { Component } from "./Component";
2
+ import { Model as SModel } from "sequelize";
3
+ export { DataTypes, NOW } from "sequelize";
4
+ export interface Relation {
5
+ [key: string]: any;
6
+ type: "hasOne" | "hasMany" | "belongsToMany" | "belongsTo";
7
+ allowNull?: boolean;
8
+ sourceKey?: string;
9
+ model: SModel;
10
+ foreignKey: string;
11
+ name?: string;
12
+ through?: any;
13
+ as?: string;
14
+ on?: any;
15
+ scope?: any;
16
+ }
17
+ /**
18
+ * ValidateMe.init({
19
+ bar: {
20
+ type: Sequelize.STRING,
21
+ validate: {
22
+ is: ["^[a-z]+$",'i'], // will only allow letters
23
+ is: /^[a-z]+$/i, // same as the previous example using real RegExp
24
+ not: ["[a-z]",'i'], // will not allow letters
25
+ isEmail: true, // checks for email format (foo@bar.com)
26
+ isUrl: true, // checks for url format (http://foo.com)
27
+ isIP: true, // checks for IPv4 (129.89.23.1) or IPv6 format
28
+ isIPv4: true, // checks for IPv4 (129.89.23.1)
29
+ isIPv6: true, // checks for IPv6 format
30
+ isAlpha: true, // will only allow letters
31
+ isAlphanumeric: true, // will only allow alphanumeric characters, so "_abc" will fail
32
+ isNumeric: true, // will only allow numbers
33
+ isInt: true, // checks for valid integers
34
+ isFloat: true, // checks for valid floating point numbers
35
+ isDecimal: true, // checks for any numbers
36
+ isLowercase: true, // checks for lowercase
37
+ isUppercase: true, // checks for uppercase
38
+ notNull: true, // won't allow null
39
+ isNull: true, // only allows null
40
+ notEmpty: true, // don't allow empty strings
41
+ equals: 'specific value', // only allow a specific value
42
+ contains: 'foo', // force specific substrings
43
+ notIn: [['foo', 'bar']], // check the value is not one of these
44
+ isIn: [['foo', 'bar']], // check the value is one of these
45
+ notContains: 'bar', // don't allow specific substrings
46
+ len: [2,10], // only allow values with length between 2 and 10
47
+ isUUID: 4, // only allow uuids
48
+ isDate: true, // only allow date strings
49
+ isAfter: "2011-11-05", // only allow date strings after a specific date
50
+ isBefore: "2011-11-05", // only allow date strings before a specific date
51
+ max: 23, // only allow values <= 23
52
+ min: 23, // only allow values >= 23
53
+ isCreditCard: true, // check for valid credit card numbers
54
+
55
+ // Examples of custom validators:
56
+ isEven(value) {
57
+ if (parseInt(value) % 2 !== 0) {
58
+ throw new Error('Only even values are allowed!');
59
+ }
60
+ }
61
+ isGreaterThanOtherField(value) {
62
+ if (parseInt(value) <= parseInt(this.otherField)) {
63
+ throw new Error('Bar must be greater than otherField.');
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }, { sequelize });
69
+ */
70
+ export declare class Model extends Component {
71
+ _provider: any;
72
+ _register: any;
73
+ private readonly _tableName;
74
+ private _model;
75
+ private _attributes;
76
+ private _errors;
77
+ constructor(sequelize?: IDBDatabase);
78
+ /**
79
+ * Returns the database connection used by this AR class.
80
+ * By default, the "db" application component is used as the database connection.
81
+ * You may override this method if you want to use a different database connection.
82
+ * @return Connection the database connection used by this AR class.
83
+ */
84
+ getDb(): any;
85
+ getDbConnection(): any;
86
+ get provider(): any;
87
+ set provider(value: any);
88
+ /**
89
+ *
90
+ */
91
+ get errors(): any;
92
+ set errors(value: any);
93
+ init(): void;
94
+ alias(): string;
95
+ tableName(): string;
96
+ formName(): string;
97
+ rules(): never[];
98
+ setModel(value: any): void;
99
+ model(): any;
100
+ save(params?: {}, options?: {}): Promise<any>;
101
+ bulkCreate(params?: {}, options?: {}): Promise<any>;
102
+ update(params?: {}, options?: {}): any;
103
+ delete(params?: {}, options?: {}): any;
104
+ /**
105
+ * 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.
106
+ *
107
+ * By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc). Note that since this is a raw query, the metadata are dialect specific. Some dialects return the metadata "within" the results object (as properties on an array). However, two arguments will always be returned, but for MSSQL and MySQL it will be two references to the same object.
108
+ *
109
+ * const [results, metadata] = await sequelize.query("UPDATE users SET y = 42 WHERE x = 12");
110
+ * // Results will be an empty array and metadata will contain the number of affected rows.
111
+ *
112
+ * In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
113
+ *
114
+ * const { QueryTypes } = require('@sequelize/core');
115
+ * const users = await sequelize.query("SELECT * FROM `users`", { type: QueryTypes.SELECT });
116
+ * // We didn't need to destructure the result here - the results were returned directly
117
+ *
118
+ * Several other query types are available. Peek into the source for details.
119
+ *
120
+ * A second option is the model. If you pass a model the returned data will be instances of that model.
121
+ *
122
+ * // Callee is the model definition. This allows you to easily map a query to a predefined model
123
+ * const projects = await sequelize.query('SELECT * FROM projects', {
124
+ * model: Projects,
125
+ * mapToModel: true // pass true here if you have any mapped fields
126
+ * });
127
+ * // Each element of `projects` is now an instance of Project
128
+ *
129
+ * See more options in the query API reference. Some examples:
130
+ * ``
131
+ * const { QueryTypes } = require('@sequelize/core');
132
+ * await sequelize.query('SELECT 1', {
133
+ * // A function (or false) for logging your queries
134
+ * // Will get called for every SQL query that gets sent
135
+ * // to the server.
136
+ * logging: console.log,
137
+ *
138
+ * // If plain is true, then sequelize will only return the first
139
+ * // record of the result set. In case of false it will return all records.
140
+ * plain: false,
141
+ *
142
+ * // Set this to true if you don't have a model definition for your query.
143
+ * raw: false,
144
+ *
145
+ * // The type of query you are executing. The query type affects how results are formatted before they are passed back.
146
+ * type: QueryTypes.SELECT
147
+ * });
148
+ *``
149
+ * // Note the second argument being null!
150
+ * // Even if we declared a callee here, the raw: true would
151
+ * // supersede and return a raw object.
152
+ * console.log(await sequelize.query('SELECT * FROM projects', { raw: true }));
153
+ *
154
+ * ##"Dotted" attributes and the nest option
155
+ *
156
+ * If an attribute name of the table contains dots, the resulting objects can become nested objects by setting the nest: true option. This is achieved with dottie.js under the hood. See below:
157
+ *
158
+ * Without nest: true:
159
+ * ``
160
+ * const { QueryTypes } = require('@sequelize/core');
161
+ * const records = await sequelize.query('select 1 as `foo.bar.baz`', {
162
+ * type: QueryTypes.SELECT
163
+ * });
164
+ * console.log(JSON.stringify(records[0], null, 2));
165
+ *
166
+ * {
167
+ * "foo.bar.baz": 1
168
+ * }
169
+ *
170
+ * With nest: true:
171
+ *
172
+ * const { QueryTypes } = require('@sequelize/core');
173
+ * const records = await sequelize.query('select 1 as `foo.bar.baz`', {
174
+ * nest: true,
175
+ * type: QueryTypes.SELECT
176
+ * });
177
+ * console.log(JSON.stringify(records[0], null, 2));
178
+ *
179
+ * {
180
+ * "foo": {
181
+ * "bar": {
182
+ * "baz": 1
183
+ * }
184
+ * }
185
+ * }
186
+ * ``
187
+ * ##Replacements
188
+ *
189
+ * Replacements in a query can be done in two different ways, either using named parameters (starting with :), or unnamed, represented by a ?. Replacements are passed in the options object.
190
+ *
191
+ * If an array is passed, ? will be replaced in the order that they appear in the array
192
+ * If an object is passed, :key will be replaced with the keys from that object. If the object contains keys not found in the query or vice versa, an exception will be thrown.
193
+ * ``
194
+ * const { QueryTypes } = require('@sequelize/core');
195
+ *
196
+ * await sequelize.query(
197
+ * 'SELECT * FROM projects WHERE status = ?',
198
+ * {
199
+ * replacements: ['active'],
200
+ * type: QueryTypes.SELECT
201
+ * }
202
+ * );
203
+ *
204
+ * await sequelize.query(
205
+ * 'SELECT * FROM projects WHERE status = :status',
206
+ * {
207
+ * replacements: { status: 'active' },
208
+ * type: QueryTypes.SELECT
209
+ * }
210
+ * );
211
+ * ``
212
+ * Array replacements will automatically be handled, the following query searches for projects where the status matches an array of values.
213
+ * ``
214
+ * const { QueryTypes } = require('@sequelize/core');
215
+ *
216
+ * await sequelize.query(
217
+ * 'SELECT * FROM projects WHERE status IN(:status)',
218
+ * {
219
+ * replacements: { status: ['active', 'inactive'] },
220
+ * type: QueryTypes.SELECT
221
+ * }
222
+ * );
223
+ * ``
224
+ * To use the wildcard operator %, append it to your replacement. The following query matches users with names that start with 'ben'.
225
+ * ``
226
+ * const { QueryTypes } = require('@sequelize/core');
227
+ *
228
+ * await sequelize.query(
229
+ * 'SELECT * FROM users WHERE name LIKE :search_name',
230
+ * {
231
+ * replacements: { search_name: 'ben%' },
232
+ * type: QueryTypes.SELECT
233
+ * }
234
+ * ); ``
235
+ *
236
+ * ##Bind Parameter
237
+ *
238
+ * Bind parameters are like replacements. Except replacements are escaped and inserted into the query by sequelize before the query is sent to the database, while bind parameters are sent to the database outside the SQL query text. A query can have either bind parameters or replacements. Bind parameters are referred to by either $1, $2, ... (numeric) or $key (alpha-numeric). This is independent of the dialect.
239
+ *
240
+ * If an array is passed, $1 is bound to the 1st element in the array (bind[0])
241
+ * If an object is passed, $key is bound to object['key']. Each key must begin with a non-numeric char. $1 is not a valid key, even if object['1'] exists.
242
+ * In either case $$ can be used to escape a literal $ sign.
243
+ *
244
+ * The array or object must contain all bound values or Sequelize will throw an exception. This applies even to cases in which the database may ignore the bound parameter.
245
+ *
246
+ * The database may add further restrictions to this. Bind parameters cannot be SQL keywords, nor table or column names. They are also ignored in quoted text or data. In PostgreSQL it may also be needed to typecast them, if the type cannot be inferred from the context $1::varchar.
247
+ *``
248
+ * const { QueryTypes } = require('@sequelize/core');
249
+ *
250
+ * await sequelize.query(
251
+ * 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $1',
252
+ * {
253
+ * bind: ['active'],
254
+ * type: QueryTypes.SELECT
255
+ * }
256
+ * ); ``
257
+ *
258
+ * `` await sequelize.query(
259
+ * 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $status',
260
+ * {
261
+ * bind: { status: 'active' },
262
+ * type: QueryTypes.SELECT
263
+ * }
264
+ * );``
265
+ * @param query
266
+ * @param options
267
+ */
268
+ rawQuery(query: string, options?: any): Promise<any>;
269
+ /**
270
+ *
271
+ * @param args
272
+ */
273
+ findOne(...args: any[]): any;
274
+ /**
275
+ *
276
+ * @param args
277
+ */
278
+ findAll(...args: any[]): any;
279
+ /**
280
+ * return {count : number , rows: any}
281
+ * @param args
282
+ */
283
+ findAndCountAll(...args: any[]): any;
284
+ validate(): void;
285
+ /**
286
+ *
287
+ * @param data
288
+ * @param formName
289
+ */
290
+ load(data: any, formName?: any): boolean;
291
+ bulkLoad(data: any, formName?: any): boolean;
292
+ setAttribute(values: any, safeOnly?: boolean): void;
293
+ attributes(): {};
294
+ /**
295
+ * relation return array
296
+ * [
297
+ *
298
+ * ]
299
+ */
300
+ relations(): Relation[];
301
+ }
299
302
  //# sourceMappingURL=Model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Model.d.ts","sourceRoot":"","sources":["../../src/base/Model.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAqE,KAAK,IAAI,MAAM,EAAoE,MAAM,WAAW,CAAC;AAGjL,OAAO,EAAC,SAAS,EAAC,GAAG,EAAC,MAAM,WAAW,CAAC;AAGxC,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,eAAe,GAAG,WAAW,CAAC;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,C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