chyz 2.0.0-rc.18 → 2.0.0-rc.20
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.d.ts.map +1 -1
- package/BaseChyz.js +20 -1
- package/base/BaseError.d.ts +1 -1
- package/base/CBaseObject.d.ts.map +1 -1
- package/base/Component.d.ts.map +1 -1
- package/base/Model.d.ts +3 -4
- package/base/Model.d.ts.map +1 -1
- package/base/Model.js +8 -11
- package/base/RestClient.d.ts.map +1 -1
- package/decorator/delete.d.ts +3 -0
- package/decorator/delete.d.ts.map +1 -0
- package/decorator/delete.js +36 -0
- package/decorator/index.d.ts +2 -0
- package/decorator/index.d.ts.map +1 -1
- package/decorator/index.js +5 -1
- package/decorator/put.d.ts +3 -0
- package/decorator/put.d.ts.map +1 -0
- package/decorator/put.js +36 -0
- package/filters/AccessControl.d.ts.map +1 -1
- package/filters/AccessControl.js +1 -0
- package/filters/AccessRule.d.ts.map +1 -1
- package/filters/AccessRule.js +1 -2
- package/package.json +1 -1
package/BaseChyz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AA+FjC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IACvB,MAAM,CAAC,OAAO,MAAS;IACvB,OAAO,CAAC,KAAK,CAAgB;IAC7B,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IACf,M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G,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;IAKrD,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;IAUxD,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG;WAQ7C,YAAY,CAAC,GAAG,EAAE,GAAG;WAKrB,cAAc,CAAC,GAAG,EAAE,GAAG;IAIrC;;OAEG;IACG,UAAU;IAyBhB;;OAEG;IACG,cAAc;IA4Eb,UAAU;IAsDV,KAAK;CAwBf"}
|
package/BaseChyz.js
CHANGED
|
@@ -31,15 +31,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
const base_1 = require("./base");
|
|
36
39
|
const Utils_1 = __importStar(require("./requiments/Utils"));
|
|
37
40
|
const Logs_1 = require("./base/Logs");
|
|
41
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
42
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
38
43
|
const https = require('https');
|
|
39
44
|
const express = require("express");
|
|
40
45
|
const compression = require('compression');
|
|
41
46
|
const fs = require('fs');
|
|
42
47
|
const validate = require('validate.js');
|
|
48
|
+
dayjs_1.default.extend(utc_1.default);
|
|
43
49
|
/**
|
|
44
50
|
* Use
|
|
45
51
|
* selectedBox: {
|
|
@@ -74,6 +80,18 @@ validate.validators.tokenString = (items, itemConstraints) => {
|
|
|
74
80
|
}, {});
|
|
75
81
|
return Utils_1.Utils.isEmpty(arrayItemErrors) ? null : { errors: arrayItemErrors };
|
|
76
82
|
};
|
|
83
|
+
validate.extend(validate.validators.datetime, {
|
|
84
|
+
// The value is guaranteed not to be null or undefined but otherwise it
|
|
85
|
+
// could be anything.
|
|
86
|
+
parse: function (value, options) {
|
|
87
|
+
return +(0, dayjs_1.default)().utc(value);
|
|
88
|
+
},
|
|
89
|
+
// Input is a unix timestamp
|
|
90
|
+
format: function (value, options) {
|
|
91
|
+
var format = options.dateOnly ? "YYYY-MM-DD" : "YYYY-MM-DD hh:mm:ss";
|
|
92
|
+
return (0, dayjs_1.default)().utc(value).format(format);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
77
95
|
const ip = require('ip');
|
|
78
96
|
const bodyParser = require('body-parser');
|
|
79
97
|
const methodOverride = require('method-override');
|
|
@@ -285,10 +303,11 @@ class BaseChyz {
|
|
|
285
303
|
*/
|
|
286
304
|
loadController() {
|
|
287
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
var _a;
|
|
288
307
|
// let articlesEndpoints: string[] = [];
|
|
289
308
|
for (const file of fs.readdirSync(`${this._controllerpath}/`)) {
|
|
290
309
|
// let controller = require(`${this._controllerpath}/${file}`);
|
|
291
|
-
let controller = (yield Promise.resolve().then(() => __importStar(require(
|
|
310
|
+
let controller = (yield (_a = `${this._controllerpath}/${file}`, Promise.resolve().then(() => __importStar(require(_a)))));
|
|
292
311
|
if (controller[file.replace(".ts", "")]) {
|
|
293
312
|
controller = controller[file.replace(".ts", "")];
|
|
294
313
|
}
|
package/base/BaseError.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CBaseObject.d.ts","sourceRoot":"","sources":["../../src/base/CBaseObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CBaseObject.d.ts","sourceRoot":"","sources":["../../src/base/CBaseObject.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C,qBAAa,WAAY,YAAW,YAAY;IAErC,IAAI;CAGd"}
|
package/base/Component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/base/Component.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/base/Component.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAIzC,qBAAa,SAAU,SAAQ,WAAW;IAEtC;;OAEG;IAIH;;OAEG;IAEH,OAAO,CAAC,UAAU,CAA2B;IAG7C;;OAEG;IACI,SAAS,IAAI,GAAG;IAKvB,IAAI,YAAY,IAAI,GAAG,CAEtB;IAED;;OAEG;IACI,eAAe;IAetB,OAAO,CAAC,sBAAsB;CASjC"}
|
package/base/Model.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface Relation {
|
|
|
66
66
|
}, { sequelize });
|
|
67
67
|
*/
|
|
68
68
|
export declare class Model extends Component {
|
|
69
|
-
|
|
69
|
+
_provider: any;
|
|
70
70
|
_register: any;
|
|
71
71
|
private _tableName;
|
|
72
72
|
private _model;
|
|
@@ -81,9 +81,8 @@ export declare class Model extends Component {
|
|
|
81
81
|
*/
|
|
82
82
|
getDb(): any;
|
|
83
83
|
getDbConnection(): any;
|
|
84
|
-
get
|
|
85
|
-
set
|
|
86
|
-
provider(): any;
|
|
84
|
+
get provider(): any;
|
|
85
|
+
set provider(value: any);
|
|
87
86
|
/**
|
|
88
87
|
*
|
|
89
88
|
*/
|
package/base/Model.d.ts.map
CHANGED
|
@@ -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,EAAo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,KAAK;IAIL,SAAS;IAIT,QAAQ;IAIR,KAAK;IAKL,QAAQ,CAAC,KAAK,EAAE,GAAG;IAInB,KAAK;IAKC,IAAI,CAAC,MAAM,KAAK,EAAE,OAAO,KAAK;IAoC9B,UAAU,CAAC,MAAM,KAAK,EAAE,OAAO,KAAK;IAmC1C,MAAM,CAAC,MAAM,KAAK,EAAE,OAAO,KAAK;IAMhC,MAAM,CAAC,MAAM,KAAK,EAAE,OAAO,KAAK;IAMvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkKG;IACU,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,GAA2C;IAMzF;;;OAGG;IACI,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAI7B;;;OAGG;IACI,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAI7B;;;OAGG;IACI,eAAe,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAK9B,QAAQ;IAIf;;;;OAIG;IACI,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,GAAU;IAYpC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,GAAE,GAAU;IAYxC,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,UAAO;IAazC,UAAU;IAIjB;;;;;OAKG;IACI,SAAS,IAAI,QAAQ,EAAE;CAKjC"}
|
package/base/Model.js
CHANGED
|
@@ -90,11 +90,11 @@ class Model extends Component_1.Component {
|
|
|
90
90
|
BaseChyz_1.default.debug("Model constructor", this._tableName);
|
|
91
91
|
// this._sequelize = BaseChyz.getComponent("db").db;
|
|
92
92
|
if (sequelize != null)
|
|
93
|
-
this.
|
|
93
|
+
this._provider = sequelize;
|
|
94
94
|
else
|
|
95
|
-
this.
|
|
95
|
+
this._provider = this.getDb();
|
|
96
96
|
if (!Utils_1.Utils.isEmpty(this.attributes())) {
|
|
97
|
-
this._model = this.
|
|
97
|
+
this._model = this._provider.define(this._tableName, this.attributes(), {
|
|
98
98
|
tableName: this.tableName(),
|
|
99
99
|
timestamps: false,
|
|
100
100
|
createdAt: false,
|
|
@@ -118,14 +118,11 @@ class Model extends Component_1.Component {
|
|
|
118
118
|
getDbConnection() {
|
|
119
119
|
return BaseChyz_1.default.getComponent("db");
|
|
120
120
|
}
|
|
121
|
-
get
|
|
122
|
-
return this.
|
|
121
|
+
get provider() {
|
|
122
|
+
return this._provider;
|
|
123
123
|
}
|
|
124
|
-
set
|
|
125
|
-
this.
|
|
126
|
-
}
|
|
127
|
-
provider() {
|
|
128
|
-
return this._sequelize;
|
|
124
|
+
set provider(value) {
|
|
125
|
+
this._provider = value;
|
|
129
126
|
}
|
|
130
127
|
/**
|
|
131
128
|
*
|
|
@@ -261,7 +258,7 @@ class Model extends Component_1.Component {
|
|
|
261
258
|
delete(params = {}, options = {}) {
|
|
262
259
|
this.errors = {};
|
|
263
260
|
let p = Object.assign(params, this._attributes);
|
|
264
|
-
return this.model().
|
|
261
|
+
return this.model().destroy(p, options);
|
|
265
262
|
}
|
|
266
263
|
/**
|
|
267
264
|
* 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.
|
package/base/RestClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestClient.d.ts","sourceRoot":"","sources":["../../src/base/RestClient.ts"],"names":[],"mappings":"
|
|
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,EAAE,EAAC,OAAO,CAAC,EAAC,GAAG;IAI3C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,EAAC,OAAO,CAAC,EAAC,GAAG;IAI1C,IAAI,CAAC,MAAM,EAAE,GAAG;CAG1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/decorator/delete.ts"],"names":[],"mappings":"AAOA,OAAQ,kBAAkB,CAAC;AAG3B,eAAO,MAAM,GAAG,SAAU,MAAM,KAAG,eAyBlC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.del = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
+
* Author: Cihan Ozturk
|
|
7
|
+
* E-mail: cihan@chy.com.tr
|
|
8
|
+
* Github:https://github.com/cihan53/
|
|
9
|
+
*/
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const del = (path) => {
|
|
13
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return (target, propertyKey) => {
|
|
16
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
+
}
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
+
routes.push({
|
|
27
|
+
id: "",
|
|
28
|
+
requestMethod: 'delete',
|
|
29
|
+
path,
|
|
30
|
+
methodName: propertyKey
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.del = del;
|
package/decorator/index.d.ts
CHANGED
package/decorator/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAA"}
|
package/decorator/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.post = exports.get = exports.controller = void 0;
|
|
3
|
+
exports.del = exports.put = exports.post = exports.get = exports.controller = void 0;
|
|
4
4
|
var controller_1 = require("./controller");
|
|
5
5
|
Object.defineProperty(exports, "controller", { enumerable: true, get: function () { return controller_1.controller; } });
|
|
6
6
|
var get_1 = require("./get");
|
|
7
7
|
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
|
|
8
8
|
var post_1 = require("./post");
|
|
9
9
|
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return post_1.post; } });
|
|
10
|
+
var put_1 = require("./put");
|
|
11
|
+
Object.defineProperty(exports, "put", { enumerable: true, get: function () { return put_1.put; } });
|
|
12
|
+
var delete_1 = require("./delete");
|
|
13
|
+
Object.defineProperty(exports, "del", { enumerable: true, get: function () { return delete_1.del; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"put.d.ts","sourceRoot":"","sources":["../../src/decorator/put.ts"],"names":[],"mappings":"AAOA,OAAQ,kBAAkB,CAAC;AAG3B,eAAO,MAAM,GAAG,SAAU,MAAM,KAAG,eAyBlC,CAAC"}
|
package/decorator/put.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.put = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021. Chy Bilgisayar Bilisim
|
|
6
|
+
* Author: Cihan Ozturk
|
|
7
|
+
* E-mail: cihan@chy.com.tr
|
|
8
|
+
* Github:https://github.com/cihan53/
|
|
9
|
+
*/
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
require("reflect-metadata");
|
|
12
|
+
const put = (path) => {
|
|
13
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return (target, propertyKey) => {
|
|
16
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
17
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
22
|
+
}
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
26
|
+
routes.push({
|
|
27
|
+
id: "",
|
|
28
|
+
requestMethod: 'put',
|
|
29
|
+
path,
|
|
30
|
+
methodName: propertyKey
|
|
31
|
+
});
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.put = put;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessControl.d.ts","sourceRoot":"","sources":["../../src/filters/AccessControl.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAU,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAIvC,qBAAa,aAAc,SAAQ,YAAY;IAEpC,IAAI,EAAE,GAAG,CAAQ;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,YAAY,EAAE,GAAG,CAAQ;IAEzB,IAAI;
|
|
1
|
+
{"version":3,"file":"AccessControl.d.ts","sourceRoot":"","sources":["../../src/filters/AccessControl.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAC,QAAQ,EAAU,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAIvC,qBAAa,aAAc,SAAQ,YAAY;IAEpC,IAAI,EAAE,GAAG,CAAQ;IACjB,KAAK,EAAE,GAAG,CAAC;IACX,YAAY,EAAE,GAAG,CAAQ;IAEzB,IAAI;IAiBE,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAC,GAAG,EAAC,QAAQ;IAiC7D,UAAU,CAAC,IAAI,EAAE,OAAO;CAMlC"}
|
package/filters/AccessControl.js
CHANGED
|
@@ -35,6 +35,7 @@ class AccessControl extends ActionFilter_1.ActionFilter {
|
|
|
35
35
|
this.user = (_a = Utils_1.Utils.cloneDeep(index_1.BaseChyz.getComponent("user"))) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser();
|
|
36
36
|
}
|
|
37
37
|
this.rules.forEach((rule, index) => {
|
|
38
|
+
console.log(rule, index);
|
|
38
39
|
if (rule === Object(rule)) {
|
|
39
40
|
this.rules[index] = Utils_1.Utils.createObject(new AccessRule_1.AccessRule(), rule);
|
|
40
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../src/filters/AccessRule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"AccessRule.d.ts","sourceRoot":"","sources":["../../src/filters/AccessRule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAIhC,qBAAa,UAAW,SAAQ,SAAS;IAErC;;OAEG;IACI,KAAK,EAAE,GAAG,CAAC;IAClB;;;OAGG;IACI,OAAO,EAAE,GAAG,CAAC;IAEpB;;OAEG;IACI,WAAW,EAAE,GAAG,CAAC;IAExB;;;OAGG;IAEI,KAAK,EAAE,GAAG,CAAC;IAElB;;OAEG;IACI,WAAW,EAAE,GAAG,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACI,UAAU,EAAE,GAAG,CAAM;IAG5B;;;;;;;OAOG;IACI,GAAG,EAAE,GAAG,CAAC;IAGH,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAoBhE;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG;IAIjC;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,GAAG;cAezB,SAAS,CAAC,IAAI,EAAE,OAAO;CA6C1C"}
|
package/filters/AccessRule.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.AccessRule = void 0;
|
|
|
13
13
|
const Component_1 = require("../base/Component");
|
|
14
14
|
const InvalidConfigException_1 = require("../base/InvalidConfigException");
|
|
15
15
|
const Utils_1 = require("../requiments/Utils");
|
|
16
|
-
var _ = require('lodash');
|
|
17
16
|
class AccessRule extends Component_1.Component {
|
|
18
17
|
constructor() {
|
|
19
18
|
super(...arguments);
|
|
@@ -75,7 +74,7 @@ class AccessRule extends Component_1.Component {
|
|
|
75
74
|
* @return bool whether the rule applies to the action
|
|
76
75
|
*/
|
|
77
76
|
matchAction(action) {
|
|
78
|
-
return
|
|
77
|
+
return Utils_1.Utils.isEmpty(this.actions) || this.actions.includes(action.id);
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
81
80
|
* @param Controller $controller the controller
|