chyz 1.2.4-rc.5 → 1.2.4-rc.6
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.
- package/BaseChyz.js +17 -6
- package/BaseChyz.js.map +1 -1
- package/Chyz.js +4 -2
- package/Chyz.js.map +1 -1
- package/base/ActionFilter.js +15 -4
- package/base/ActionFilter.js.map +1 -1
- package/base/BaseError.js +4 -2
- package/base/BaseError.js.map +1 -1
- package/base/BaseObject.js +4 -2
- package/base/BaseObject.js.map +1 -1
- package/base/CWebController.js +10 -2
- package/base/CWebController.js.map +1 -1
- package/base/Component.js +4 -2
- package/base/Component.js.map +1 -1
- package/base/DbConnection.js +14 -3
- package/base/DbConnection.js.map +1 -1
- package/base/Model.js +17 -6
- package/base/Model.js.map +1 -1
- package/base/index.js +28 -19
- package/base/index.js.map +1 -1
- package/decorator/index.js +13 -4
- package/decorator/index.js.map +1 -1
- package/filters/AccessControl.js +15 -4
- package/filters/AccessControl.js.map +1 -1
- package/filters/AccessRule.js +15 -4
- package/filters/AccessRule.js.map +1 -1
- package/filters/auth/AuthMethod.js +10 -2
- package/filters/auth/AuthMethod.js.map +1 -1
- package/filters/auth/HttpBasicAuth.js +14 -3
- package/filters/auth/HttpBasicAuth.js.map +1 -1
- package/filters/auth/HttpHeaderAuth.js +14 -3
- package/filters/auth/HttpHeaderAuth.js.map +1 -1
- package/filters/auth/JwtHttpBearerAuth.js +14 -3
- package/filters/auth/JwtHttpBearerAuth.js.map +1 -1
- package/filters/auth/KeyCloakHttpBearerAuth.js +15 -4
- package/filters/auth/KeyCloakHttpBearerAuth.js.map +1 -1
- package/filters/auth/index.js +14 -5
- package/filters/auth/index.js.map +1 -1
- package/filters/index.js +12 -3
- package/filters/index.js.map +1 -1
- package/index.js +19 -7
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/rbac/AuthManager.js +29 -18
- package/rbac/AuthManager.js.map +1 -1
- package/web/WebUser.js +16 -5
- package/web/WebUser.js.map +1 -1
- package/BaseChyz.d.ts +0 -62
- package/Chyz.d.ts +0 -3
- package/base/ActionFilter.d.ts +0 -26
- package/base/BaseError.d.ts +0 -10
- package/base/BaseObject.d.ts +0 -4
- package/base/Behavior.d.ts +0 -3
- package/base/CWebController.d.ts +0 -43
- package/base/Component.d.ts +0 -21
- package/base/Configurable.d.ts +0 -2
- package/base/DataErrorDbException.d.ts +0 -5
- package/base/DbConnection.d.ts +0 -12
- package/base/ForbiddenHttpException.d.ts +0 -4
- package/base/InvalidArgumentException.d.ts +0 -5
- package/base/InvalidConfigException.d.ts +0 -5
- package/base/Model.d.ts +0 -298
- package/base/ModelManager.d.ts +0 -1
- package/base/NotFoundHttpException.d.ts +0 -5
- package/base/RestClient.d.ts +0 -8
- package/base/UnauthorizedHttpException.d.ts +0 -5
- package/base/ValidationHttpException.d.ts +0 -5
- package/base/db/Exception.d.ts +0 -6
- package/base/index.d.ts +0 -18
- package/decorator/Middleware.d.ts +0 -3
- package/decorator/controller.d.ts +0 -2
- package/decorator/enums/ControllerDecoratorParams.d.ts +0 -5
- package/decorator/get.d.ts +0 -2
- package/decorator/index.d.ts +0 -3
- package/decorator/post.d.ts +0 -2
- package/filters/AccessControl.d.ts +0 -11
- package/filters/AccessRule.d.ts +0 -82
- package/filters/auth/AuthInterface.d.ts +0 -25
- package/filters/auth/AuthMethod.d.ts +0 -25
- package/filters/auth/HttpBasicAuth.d.ts +0 -22
- package/filters/auth/HttpBearerAuth.d.ts +0 -17
- package/filters/auth/HttpHeaderAuth.d.ts +0 -14
- package/filters/auth/JwtHttpBearerAuth.d.ts +0 -20
- package/filters/auth/KeyCloakHttpBearerAuth.d.ts +0 -22
- package/filters/auth/index.d.ts +0 -4
- package/filters/index.d.ts +0 -2
- package/index.d.ts +0 -15
- package/model/RouteDefinition.d.ts +0 -6
- package/rbac/AuthAssignment.d.ts +0 -18
- package/rbac/AuthItem.d.ts +0 -26
- package/rbac/AuthItemChild.d.ts +0 -18
- package/rbac/AuthManager.d.ts +0 -111
- package/requiments/Glob.d.ts +0 -2
- package/requiments/ReflectUtil.d.ts +0 -0
- package/requiments/Utils.d.ts +0 -2
- package/validators/BooleanValidator.d.ts +0 -0
- package/validators/CompareValidator.d.ts +0 -0
- package/validators/DateValidator.d.ts +0 -0
- package/validators/EmailValidator.d.ts +0 -0
- package/validators/Validator.d.ts +0 -17
- package/web/IdentityInterface.d.ts +0 -54
- package/web/WebUser.d.ts +0 -71
package/BaseChyz.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export { Request, Response, NextFunction } from "express";
|
|
3
|
-
export default class BaseChyz {
|
|
4
|
-
private config;
|
|
5
|
-
static app: string;
|
|
6
|
-
static httpServer: any;
|
|
7
|
-
static express: any;
|
|
8
|
-
private _port;
|
|
9
|
-
static db: any;
|
|
10
|
-
static routes: any;
|
|
11
|
-
private static _validate;
|
|
12
|
-
private _logConfig;
|
|
13
|
-
private _controllerpath;
|
|
14
|
-
private static controllers;
|
|
15
|
-
static components: any;
|
|
16
|
-
static middlewares: any;
|
|
17
|
-
get logConfig(): any;
|
|
18
|
-
set logConfig(value: any);
|
|
19
|
-
get controllerpath(): string;
|
|
20
|
-
set controllerpath(value: string);
|
|
21
|
-
init(): void;
|
|
22
|
-
/**
|
|
23
|
-
* Listen port number
|
|
24
|
-
* Server port number get
|
|
25
|
-
*/
|
|
26
|
-
get port(): number;
|
|
27
|
-
/**
|
|
28
|
-
* Listen port number
|
|
29
|
-
* Server port number setting
|
|
30
|
-
* @param value
|
|
31
|
-
*/
|
|
32
|
-
set port(value: number);
|
|
33
|
-
static get validate(): any;
|
|
34
|
-
static set validate(value: any);
|
|
35
|
-
app(config?: any): BaseChyz;
|
|
36
|
-
logProvider(): any;
|
|
37
|
-
getLogger(): any;
|
|
38
|
-
static logs(...args: any[]): any;
|
|
39
|
-
static trace(...args: any[]): void;
|
|
40
|
-
static debug(...args: any[]): void;
|
|
41
|
-
static info(...args: any[]): void;
|
|
42
|
-
static warn(...args: any[]): void;
|
|
43
|
-
static error(...args: any[]): void;
|
|
44
|
-
static fatal(...args: any[]): void;
|
|
45
|
-
static warning(...args: any[]): void;
|
|
46
|
-
static t(text: string): string;
|
|
47
|
-
errorLogger(error: any, req: any, res: any, next: any): void;
|
|
48
|
-
errorResponder(error: any, req: any, res: any, next: any): void;
|
|
49
|
-
errorHandler(err: any, req: any, res: any, next: any): any;
|
|
50
|
-
static getComponent(key: any): any;
|
|
51
|
-
static getMiddlewares(key: any): any;
|
|
52
|
-
/**
|
|
53
|
-
* load model
|
|
54
|
-
*/
|
|
55
|
-
loadModels(): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* load contoller
|
|
58
|
-
*/
|
|
59
|
-
loadController(): Promise<void>;
|
|
60
|
-
middleware(): void;
|
|
61
|
-
Start(): this;
|
|
62
|
-
}
|
package/Chyz.d.ts
DELETED
package/base/ActionFilter.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from "express";
|
|
2
|
-
import { Behavior } from "./Behavior";
|
|
3
|
-
export declare class ActionFilter extends Behavior {
|
|
4
|
-
only: any;
|
|
5
|
-
/**
|
|
6
|
-
* @var array list of action IDs that this filter should not apply to.
|
|
7
|
-
* @see only
|
|
8
|
-
*/
|
|
9
|
-
except: never[];
|
|
10
|
-
init(): void;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param route
|
|
14
|
-
* @param req
|
|
15
|
-
* @param res
|
|
16
|
-
*/
|
|
17
|
-
beforeFilter(route: any, req: Request, res: Response): Promise<void>;
|
|
18
|
-
protected isActive(action: any): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* This method is invoked right before an action is to be executed (after all possible filters.)
|
|
21
|
-
* You may override this method to do last-minute preparation for the action.
|
|
22
|
-
* @param Action $action the action to be executed.
|
|
23
|
-
* @return bool whether the action should continue to be executed.
|
|
24
|
-
*/
|
|
25
|
-
beforeAction(route: any, req: Request, res: Response): Promise<boolean>;
|
|
26
|
-
}
|
package/base/BaseError.d.ts
DELETED
package/base/BaseObject.d.ts
DELETED
package/base/Behavior.d.ts
DELETED
package/base/CWebController.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Component } from "./Component";
|
|
2
|
-
import { RouteDefinition } from "../model/RouteDefinition";
|
|
3
|
-
import { Request, Response } from "express";
|
|
4
|
-
export declare class CWebController extends Component {
|
|
5
|
-
/**
|
|
6
|
-
* @var string the ID of this controller.
|
|
7
|
-
*/
|
|
8
|
-
id: string;
|
|
9
|
-
defaultAction: string;
|
|
10
|
-
constructor(config: any);
|
|
11
|
-
init(): void;
|
|
12
|
-
/**
|
|
13
|
-
* This method is invoked right before an action is executed.
|
|
14
|
-
* @param $action
|
|
15
|
-
*/
|
|
16
|
-
beforeAction(route: RouteDefinition, req: Request, res: Response): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* This method is invoked right after an action is executed.
|
|
19
|
-
* @param action
|
|
20
|
-
*/
|
|
21
|
-
afterAction(action: any, req: Request, res: Response): void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
Checks the privilege of the current user.
|
|
26
|
-
|
|
27
|
-
This method should be overridden to check whether the current user has the privilege to run the specified action against the specified data model. If the user does not have access, a yii\web\ForbiddenHttpException should be thrown.
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
checkAccess(action: any, model?: null, params?: any): void;
|
|
31
|
-
/**
|
|
32
|
-
* Send data formatted as JSON.
|
|
33
|
-
|
|
34
|
-
This method is a shortcut for sending data formatted as JSON. It will return the response application component after configuring the format and setting the data that should be formatted. A common usage will b
|
|
35
|
-
*/
|
|
36
|
-
asJson(data: any): void;
|
|
37
|
-
/**
|
|
38
|
-
* Send data formatted as XML.
|
|
39
|
-
|
|
40
|
-
This method is a shortcut for sending data formatted as XML. It will return the response application component after configuring the format and setting the data that should be formatted. A common usage will be:
|
|
41
|
-
*/
|
|
42
|
-
asXml(data: any): void;
|
|
43
|
-
}
|
package/base/Component.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BaseObject } from "./BaseObject";
|
|
2
|
-
export declare class Component extends BaseObject {
|
|
3
|
-
/**
|
|
4
|
-
* @var array the attached event handlers (event name => handlers)
|
|
5
|
-
*/
|
|
6
|
-
private _events;
|
|
7
|
-
/**
|
|
8
|
-
* @var Behavior[]|null the attached behaviors (behavior name => behavior). This is `null` when not initialized.
|
|
9
|
-
*/
|
|
10
|
-
private _behaviors;
|
|
11
|
-
/**
|
|
12
|
-
* Returns a list of behaviors that this component should behave as.
|
|
13
|
-
*/
|
|
14
|
-
behaviors(): never[];
|
|
15
|
-
get getBehaviors(): any;
|
|
16
|
-
/**
|
|
17
|
-
* Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.
|
|
18
|
-
*/
|
|
19
|
-
ensureBehaviors(): void;
|
|
20
|
-
private attachBehaviorInternal;
|
|
21
|
-
}
|
package/base/Configurable.d.ts
DELETED
package/base/DbConnection.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Component } from "./Component";
|
|
2
|
-
export declare class DbConnection extends Component {
|
|
3
|
-
database: string;
|
|
4
|
-
username: string;
|
|
5
|
-
password: string;
|
|
6
|
-
options?: object;
|
|
7
|
-
private _db;
|
|
8
|
-
init(): Promise<void>;
|
|
9
|
-
get db(): any;
|
|
10
|
-
set db(value: any);
|
|
11
|
-
transaction(): any;
|
|
12
|
-
}
|
package/base/Model.d.ts
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
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
|
-
}
|
package/base/ModelManager.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ModelManager: any;
|
package/base/RestClient.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
declare const _default: RestClient;
|
|
8
|
-
export default _default;
|
package/base/db/Exception.d.ts
DELETED
package/base/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from "./ActionFilter";
|
|
2
|
-
export * from "./BaseObject";
|
|
3
|
-
export * from "./BaseError";
|
|
4
|
-
export * from "./Behavior";
|
|
5
|
-
export * from "./Component";
|
|
6
|
-
export * from "./Configurable";
|
|
7
|
-
export * from "./CWebController";
|
|
8
|
-
export * from "./DbConnection";
|
|
9
|
-
export * from "./ForbiddenHttpException";
|
|
10
|
-
export * from "./InvalidConfigException";
|
|
11
|
-
export * from "./InvalidArgumentException";
|
|
12
|
-
export * from "./NotFoundHttpException";
|
|
13
|
-
export * from "./UnauthorizedHttpException";
|
|
14
|
-
export * from "./DataErrorDbException";
|
|
15
|
-
export * from "./ValidationHttpException";
|
|
16
|
-
export * from "./Model";
|
|
17
|
-
export * from "./RestClient";
|
|
18
|
-
export * from "./ModelManager";
|
package/decorator/get.d.ts
DELETED
package/decorator/index.d.ts
DELETED
package/decorator/post.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ActionFilter } from "../base/ActionFilter";
|
|
2
|
-
import { WebUser } from "../web/WebUser";
|
|
3
|
-
import { Request } from "express";
|
|
4
|
-
export declare class AccessControl extends ActionFilter {
|
|
5
|
-
user: any;
|
|
6
|
-
rules: any;
|
|
7
|
-
denyCallback: any;
|
|
8
|
-
init(): void;
|
|
9
|
-
beforeAction(action: any, request: Request): Promise<boolean>;
|
|
10
|
-
denyAccess(user: WebUser): void;
|
|
11
|
-
}
|