chyz 2.0.0-rc.5 → 2.0.0-rc.8
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 +2 -6
- package/BaseChyz.d.ts.map +1 -1
- package/BaseChyz.js +86 -61
- package/base/ActionFilter.js +3 -6
- package/base/BaseError.js +2 -5
- package/base/CBaseObject.js +2 -2
- package/base/CRequest.d.ts +2 -0
- package/base/CRequest.d.ts.map +1 -0
- package/base/CRequest.js +10 -0
- package/base/Component.js +2 -5
- package/base/Logs.d.ts +22 -0
- package/base/Logs.d.ts.map +1 -0
- package/base/Logs.js +57 -0
- package/base/Model.js +4 -4
- package/base/RestClient.d.ts +0 -2
- package/base/RestClient.d.ts.map +1 -1
- package/base/RestClient.js +0 -1
- package/base/index.d.ts +1 -0
- package/base/index.d.ts.map +1 -1
- package/base/index.js +3 -1
- package/filters/AccessControl.js +3 -6
- package/filters/AccessRule.js +7 -10
- package/filters/auth/HttpHeaderAuth.js +2 -5
- package/index.d.ts +9 -4
- package/index.d.ts.map +1 -1
- package/index.js +5 -16
- package/package.json +1 -3
- package/rbac/AuthManager.js +9 -12
- package/requiments/Utils.d.ts +8 -2
- package/requiments/Utils.d.ts.map +1 -1
- package/requiments/Utils.js +4 -2
- package/web/WebUser.js +2 -2
- package/base/Logger.d.ts +0 -18
- package/base/Logger.d.ts.map +0 -1
- package/base/Logger.js +0 -49
package/BaseChyz.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Logger } from "./base/Logger";
|
|
1
|
+
import { Logs } from "./base/Logs";
|
|
3
2
|
export default class BaseChyz {
|
|
4
3
|
private config;
|
|
5
4
|
static app: string;
|
|
@@ -8,7 +7,7 @@ export default class BaseChyz {
|
|
|
8
7
|
private _port;
|
|
9
8
|
static db: any;
|
|
10
9
|
static routes: any;
|
|
11
|
-
static
|
|
10
|
+
static logs: Logs;
|
|
12
11
|
private static _validate;
|
|
13
12
|
private _controllerpath;
|
|
14
13
|
private static controllers;
|
|
@@ -31,9 +30,6 @@ export default class BaseChyz {
|
|
|
31
30
|
static get validate(): any;
|
|
32
31
|
static set validate(value: any);
|
|
33
32
|
app(config?: any): BaseChyz;
|
|
34
|
-
logProvider(): any;
|
|
35
|
-
getLogger(): any;
|
|
36
|
-
static logs(...args: any[]): any;
|
|
37
33
|
static trace(...args: any[]): void;
|
|
38
34
|
static debug(...args: any[]): void;
|
|
39
35
|
static info(...args: any[]): void;
|
package/BaseChyz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAwEjC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,OAAO,CAAC,MAAM,CAAM;IACpB,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,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACnB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiB;IACzC,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAA4B;IACtD,OAAc,UAAU,EAAE,GAAG,CAAK;IAClC,OAAc,WAAW,EAAE,GAAG,CAAK;IAGnC,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,EAE/B;IAED,IAAI;IAoCJ;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAErB;IAGD,MAAM,KAAK,QAAQ,IAAI,GAAG,CAEzB;IAED,MAAM,KAAK,QAAQ,CAAC,KAAK,EAAE,GAAG,EAE7B;IAED,GAAG,CAAC,MAAM,GAAE,GAAQ,GAAG,QAAQ;WAoDjB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIpB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAInB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAInB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIpB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAKpB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAItB,CAAC,CAAC,IAAI,EAAE,MAAM;IAKrB,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,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;IAqCV,KAAK;CAwBf"}
|
package/BaseChyz.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,18 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
require("reflect-metadata");
|
|
16
35
|
const base_1 = require("./base");
|
|
17
|
-
const Utils_1 =
|
|
18
|
-
const
|
|
36
|
+
const Utils_1 = __importStar(require("./requiments/Utils"));
|
|
37
|
+
const Logs_1 = require("./base/Logs");
|
|
19
38
|
const https = require('https');
|
|
20
39
|
const express = require("express");
|
|
21
40
|
const compression = require('compression');
|
|
22
|
-
const log4js = require("log4js");
|
|
23
41
|
const fs = require('fs');
|
|
24
42
|
const validate = require('validate.js');
|
|
25
43
|
/**
|
|
@@ -44,7 +62,7 @@ validate.validators.array = (arrayItems, itemConstraints) => {
|
|
|
44
62
|
errors[index] = { error: error };
|
|
45
63
|
return errors;
|
|
46
64
|
}, {});
|
|
47
|
-
return Utils_1.
|
|
65
|
+
return Utils_1.Utils.isEmpty(arrayItemErrors) ? null : { errors: arrayItemErrors };
|
|
48
66
|
};
|
|
49
67
|
validate.validators.tokenString = (items, itemConstraints) => {
|
|
50
68
|
let arrayItems = items.split(",");
|
|
@@ -54,11 +72,30 @@ validate.validators.tokenString = (items, itemConstraints) => {
|
|
|
54
72
|
errors[index] = { error: error };
|
|
55
73
|
return errors;
|
|
56
74
|
}, {});
|
|
57
|
-
return Utils_1.
|
|
75
|
+
return Utils_1.Utils.isEmpty(arrayItemErrors) ? null : { errors: arrayItemErrors };
|
|
58
76
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
const ip = require('ip');
|
|
78
|
+
const bodyParser = require('body-parser');
|
|
79
|
+
const methodOverride = require('method-override');
|
|
80
|
+
const Server = express();
|
|
81
|
+
/**
|
|
82
|
+
* set request id
|
|
83
|
+
*/
|
|
84
|
+
Object.defineProperty(Server.request, 'reqId', {
|
|
85
|
+
configurable: true,
|
|
86
|
+
enumerable: true,
|
|
87
|
+
writable: true
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(Server.request, 'user', {
|
|
90
|
+
configurable: true,
|
|
91
|
+
enumerable: true,
|
|
92
|
+
writable: true
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(Server.request, 'identity', {
|
|
95
|
+
configurable: true,
|
|
96
|
+
enumerable: true,
|
|
97
|
+
writable: true
|
|
98
|
+
});
|
|
62
99
|
class BaseChyz {
|
|
63
100
|
constructor() {
|
|
64
101
|
this._port = 3001;
|
|
@@ -71,26 +108,6 @@ class BaseChyz {
|
|
|
71
108
|
this._controllerpath = value;
|
|
72
109
|
}
|
|
73
110
|
init() {
|
|
74
|
-
if (this.config.logger instanceof Logger_1.Logger)
|
|
75
|
-
BaseChyz.logger = this.config.logger;
|
|
76
|
-
/**
|
|
77
|
-
* set request id
|
|
78
|
-
*/
|
|
79
|
-
Object.defineProperty(BaseChyz.express.request, 'reqId', {
|
|
80
|
-
configurable: true,
|
|
81
|
-
enumerable: true,
|
|
82
|
-
writable: true
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(BaseChyz.express.request, 'user', {
|
|
85
|
-
configurable: true,
|
|
86
|
-
enumerable: true,
|
|
87
|
-
writable: true
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(BaseChyz.express.request, 'identity', {
|
|
90
|
-
configurable: true,
|
|
91
|
-
enumerable: true,
|
|
92
|
-
writable: true
|
|
93
|
-
});
|
|
94
111
|
/**
|
|
95
112
|
* server port setting
|
|
96
113
|
*/
|
|
@@ -142,16 +159,22 @@ class BaseChyz {
|
|
|
142
159
|
* Config set
|
|
143
160
|
*/
|
|
144
161
|
this.config = config;
|
|
162
|
+
/**
|
|
163
|
+
* log setting
|
|
164
|
+
*/
|
|
165
|
+
if (this.config.logs instanceof Logs_1.Logs) {
|
|
166
|
+
BaseChyz.logs = this.config.logs;
|
|
167
|
+
}
|
|
145
168
|
// logger setting
|
|
146
169
|
// this.logProvider().level = log4js.levels.ALL;
|
|
147
170
|
// this.logProvider().configure(this._logConfig);
|
|
148
|
-
let components = Utils_1.
|
|
171
|
+
let components = Utils_1.Utils.findKeyValue(config, "components");
|
|
149
172
|
if (components) {
|
|
150
173
|
for (const componentsKey in components) {
|
|
151
174
|
let comp = components[componentsKey];
|
|
152
175
|
BaseChyz.debug("Create Component ", componentsKey);
|
|
153
176
|
try {
|
|
154
|
-
BaseChyz.components[componentsKey] = Utils_1.
|
|
177
|
+
BaseChyz.components[componentsKey] = Utils_1.Utils.createObject(new comp.class, comp);
|
|
155
178
|
(_a = BaseChyz.components[componentsKey]) === null || _a === void 0 ? void 0 : _a.init();
|
|
156
179
|
}
|
|
157
180
|
catch (e) {
|
|
@@ -159,11 +182,11 @@ class BaseChyz {
|
|
|
159
182
|
}
|
|
160
183
|
}
|
|
161
184
|
}
|
|
162
|
-
let middlewares = Utils_1.
|
|
185
|
+
let middlewares = Utils_1.Utils.findKeyValue(config, "middlewares");
|
|
163
186
|
if (middlewares) {
|
|
164
187
|
for (const middlewareKey in middlewares) {
|
|
165
188
|
let middleware1 = middlewares[middlewareKey];
|
|
166
|
-
BaseChyz.
|
|
189
|
+
BaseChyz.debug("Create middlewares ", middlewareKey);
|
|
167
190
|
BaseChyz.middlewares[middlewareKey] = middleware1;
|
|
168
191
|
// BaseChyz.middlewares[middlewareKey] = Utils.createObject(new middleware1.class, middleware1);
|
|
169
192
|
}
|
|
@@ -171,35 +194,26 @@ class BaseChyz {
|
|
|
171
194
|
this.init();
|
|
172
195
|
return this;
|
|
173
196
|
}
|
|
174
|
-
logProvider() {
|
|
175
|
-
return log4js;
|
|
176
|
-
}
|
|
177
|
-
getLogger() {
|
|
178
|
-
return this.logProvider().getLogger(this.constructor.name);
|
|
179
|
-
}
|
|
180
|
-
static logs(...args) {
|
|
181
|
-
return log4js.getLogger(this.name);
|
|
182
|
-
}
|
|
183
197
|
static trace(...args) {
|
|
184
|
-
BaseChyz.logs
|
|
198
|
+
BaseChyz.logs.fatal(...arguments);
|
|
185
199
|
}
|
|
186
200
|
static debug(...args) {
|
|
187
|
-
BaseChyz.logs
|
|
201
|
+
BaseChyz.logs.debug(...arguments);
|
|
188
202
|
}
|
|
189
203
|
static info(...args) {
|
|
190
|
-
BaseChyz.logs
|
|
204
|
+
BaseChyz.logs.info(...arguments);
|
|
191
205
|
}
|
|
192
206
|
static warn(...args) {
|
|
193
|
-
BaseChyz.logs
|
|
207
|
+
BaseChyz.logs.warn(...arguments);
|
|
194
208
|
}
|
|
195
209
|
static error(...args) {
|
|
196
|
-
BaseChyz.logs
|
|
210
|
+
BaseChyz.logs.error(...arguments);
|
|
197
211
|
}
|
|
198
212
|
static fatal(...args) {
|
|
199
|
-
BaseChyz.logs
|
|
213
|
+
BaseChyz.logs.fatal(...arguments);
|
|
200
214
|
}
|
|
201
215
|
static warning(...args) {
|
|
202
|
-
BaseChyz.logs
|
|
216
|
+
BaseChyz.logs.warn(...arguments);
|
|
203
217
|
}
|
|
204
218
|
static t(text) {
|
|
205
219
|
return text;
|
|
@@ -246,6 +260,9 @@ class BaseChyz {
|
|
|
246
260
|
models[className.replace("Class", "")] = new model[className];
|
|
247
261
|
}
|
|
248
262
|
});
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
249
266
|
base_1.ModelManager._register(models);
|
|
250
267
|
for (const key of Object.keys(base_1.ModelManager)) {
|
|
251
268
|
if (key != "_register") {
|
|
@@ -261,8 +278,17 @@ class BaseChyz {
|
|
|
261
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
262
279
|
// let articlesEndpoints: string[] = [];
|
|
263
280
|
for (const file of fs.readdirSync(`${this._controllerpath}/`)) {
|
|
264
|
-
let controller = require(`${this._controllerpath}/${file}`);
|
|
265
|
-
|
|
281
|
+
// let controller = require(`${this._controllerpath}/${file}`);
|
|
282
|
+
let controller = (yield Promise.resolve().then(() => __importStar(require(`${this._controllerpath}/${file}`))));
|
|
283
|
+
if (controller[file.replace(".ts", "")]) {
|
|
284
|
+
controller = controller[file.replace(".ts", "")];
|
|
285
|
+
}
|
|
286
|
+
else if (controller.default) {
|
|
287
|
+
controller = controller.default;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
throw new base_1.InvalidConfigException((0, Utils_1.default)("Invalid Controller"));
|
|
291
|
+
}
|
|
266
292
|
// This is our instantiated class
|
|
267
293
|
const instance = new controller();
|
|
268
294
|
BaseChyz.controllers.push(instance);
|
|
@@ -272,12 +298,12 @@ class BaseChyz {
|
|
|
272
298
|
// Our `routes` array containing all our routes for this controller
|
|
273
299
|
// @ts-ignore
|
|
274
300
|
const routes = Reflect.getMetadata('routes', controller);
|
|
275
|
-
BaseChyz.
|
|
301
|
+
BaseChyz.debug("Controller load ", controller.name, `(${prefix})`);
|
|
276
302
|
if (routes) {
|
|
277
303
|
routes.forEach(route => {
|
|
278
304
|
let actionId = route.path == "/" || route.path == "" ? instance.defaultAction : route.path;
|
|
279
305
|
route.id = actionId;
|
|
280
|
-
BaseChyz.
|
|
306
|
+
BaseChyz.debug("Controller route Path", prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`));
|
|
281
307
|
BaseChyz.express[route.requestMethod](prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`), (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
282
308
|
try {
|
|
283
309
|
BaseChyz.debug(`Call Request id ${instance.id}`);
|
|
@@ -320,11 +346,10 @@ class BaseChyz {
|
|
|
320
346
|
BaseChyz.express.use(bodyParser.json({ limit: '1mb' }));
|
|
321
347
|
BaseChyz.express.use(bodyParser.urlencoded({ limit: '1mb', extended: true })); // support encoded bodies
|
|
322
348
|
BaseChyz.express.use(methodOverride());
|
|
323
|
-
BaseChyz.express.use(methodOverride());
|
|
324
349
|
// CORS
|
|
325
350
|
BaseChyz.express.use(function (req, res, next) {
|
|
326
351
|
// @ts-ignore
|
|
327
|
-
req.reqId = Utils_1.
|
|
352
|
+
req.reqId = Utils_1.Utils.uniqueId("chyzzzz_");
|
|
328
353
|
res.setHeader('Content-Type', 'application/json');
|
|
329
354
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
330
355
|
res.setHeader("Access-Control-Allow-Credentials", "true");
|
|
@@ -336,7 +361,7 @@ class BaseChyz {
|
|
|
336
361
|
BaseChyz.express.use(compression());
|
|
337
362
|
//Middlewares
|
|
338
363
|
for (const middleware1 of Object.keys(BaseChyz.middlewares)) {
|
|
339
|
-
if (!Utils_1.
|
|
364
|
+
if (!Utils_1.Utils.isFunction(middleware1)) {
|
|
340
365
|
let keycloak = BaseChyz.middlewares[middleware1].keycloak;
|
|
341
366
|
BaseChyz.express.use(keycloak.middleware(BaseChyz.middlewares[middleware1].config));
|
|
342
367
|
}
|
|
@@ -371,8 +396,8 @@ class BaseChyz {
|
|
|
371
396
|
}
|
|
372
397
|
}
|
|
373
398
|
exports.default = BaseChyz;
|
|
374
|
-
BaseChyz.express =
|
|
375
|
-
BaseChyz.
|
|
399
|
+
BaseChyz.express = Server;
|
|
400
|
+
BaseChyz.logs = new Logs_1.Logs();
|
|
376
401
|
BaseChyz._validate = validate;
|
|
377
402
|
BaseChyz.controllers = [];
|
|
378
403
|
BaseChyz.components = {};
|
package/base/ActionFilter.js
CHANGED
|
@@ -8,12 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.ActionFilter = void 0;
|
|
16
|
-
const Utils_1 =
|
|
13
|
+
const Utils_1 = require("../requiments/Utils");
|
|
17
14
|
const CBaseObject_1 = require("./CBaseObject");
|
|
18
15
|
class ActionFilter extends CBaseObject_1.CBaseObject {
|
|
19
16
|
constructor() {
|
|
@@ -60,13 +57,13 @@ class ActionFilter extends CBaseObject_1.CBaseObject {
|
|
|
60
57
|
let id = action.id;
|
|
61
58
|
let onlyMatch = false;
|
|
62
59
|
let exceptMatch = false;
|
|
63
|
-
if (Utils_1.
|
|
60
|
+
if (Utils_1.Utils.isEmpty(this.only)) {
|
|
64
61
|
onlyMatch = true;
|
|
65
62
|
}
|
|
66
63
|
else {
|
|
67
64
|
onlyMatch = false;
|
|
68
65
|
for (const onlyKey of this.only) {
|
|
69
|
-
if (Utils_1.
|
|
66
|
+
if (Utils_1.Utils.matchWildcard(action.id, onlyKey)) {
|
|
70
67
|
onlyMatch = true;
|
|
71
68
|
break;
|
|
72
69
|
}
|
package/base/BaseError.js
CHANGED
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
* E-mail: cihan@chy.com.tr
|
|
6
6
|
* Github:https://github.com/cihan53/
|
|
7
7
|
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.BaseError = void 0;
|
|
13
|
-
const Utils_1 =
|
|
10
|
+
const Utils_1 = require("../requiments/Utils");
|
|
14
11
|
class BaseError extends Error {
|
|
15
12
|
constructor(message, statusCode = 500) {
|
|
16
13
|
super(message);
|
|
17
|
-
this.message = Utils_1.
|
|
14
|
+
this.message = Utils_1.Utils.isString(message) ? message : JSON.stringify(message);
|
|
18
15
|
this.name = this.constructor.name; // good practice
|
|
19
16
|
this.statusCode = statusCode; // error code for responding to client
|
|
20
17
|
//Error.captureStackTrace(this)
|
package/base/CBaseObject.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.CBaseObject = void 0;
|
|
10
|
-
const
|
|
10
|
+
const index_1 = require("../index");
|
|
11
11
|
class CBaseObject {
|
|
12
12
|
init() {
|
|
13
|
-
|
|
13
|
+
index_1.BaseChyz.debug("BaseObject init.....");
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.CBaseObject = CBaseObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CRequest.d.ts","sourceRoot":"","sources":["../../src/base/CRequest.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC"}
|
package/base/CRequest.js
ADDED
package/base/Component.js
CHANGED
|
@@ -5,13 +5,10 @@
|
|
|
5
5
|
* E-mail: cihan@chy.com.tr
|
|
6
6
|
* Github:https://github.com/cihan53/
|
|
7
7
|
*/
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.Component = void 0;
|
|
13
10
|
const CBaseObject_1 = require("./CBaseObject");
|
|
14
|
-
const Utils_1 =
|
|
11
|
+
const Utils_1 = require("../requiments/Utils");
|
|
15
12
|
class Component extends CBaseObject_1.CBaseObject {
|
|
16
13
|
constructor() {
|
|
17
14
|
/**
|
|
@@ -50,7 +47,7 @@ class Component extends CBaseObject_1.CBaseObject {
|
|
|
50
47
|
}
|
|
51
48
|
attachBehaviorInternal(name, behavior) {
|
|
52
49
|
if (!this._behaviors.hasOwnProperty(name)) {
|
|
53
|
-
let beh = Utils_1.
|
|
50
|
+
let beh = Utils_1.Utils.createObject(new behavior[name].class, behavior[name]);
|
|
54
51
|
beh.init();
|
|
55
52
|
this._behaviors[name] = beh;
|
|
56
53
|
}
|
package/base/Logs.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Configurable } from "./Configurable";
|
|
2
|
+
export declare class Logs implements Configurable {
|
|
3
|
+
name: string;
|
|
4
|
+
configs: any;
|
|
5
|
+
constructor(name?: string, configs?: any);
|
|
6
|
+
init(): void;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
Provider(): any;
|
|
12
|
+
logs(...args: any[]): any;
|
|
13
|
+
debug(...args: any[]): void;
|
|
14
|
+
info(...args: any[]): void;
|
|
15
|
+
warn(...args: any[]): void;
|
|
16
|
+
error(...args: any[]): void;
|
|
17
|
+
fatal(...args: any[]): void;
|
|
18
|
+
warning(...args: any[]): void;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: Logs;
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=Logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logs.d.ts","sourceRoot":"","sources":["../../src/base/Logs.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,IAAK,YAAW,YAAY;IAE9B,IAAI,SAAyB;IAC7B,OAAO,EAAE,GAAG,CAA6C;gBAGpD,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IASxC,IAAI;IAKJ;;;OAGG;IACI,QAAQ;IAIR,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAInB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAInB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAInB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAKpB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAIhC;;AAED,wBAA0B"}
|
package/base/Logs.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022.. 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.Logs = void 0;
|
|
12
|
+
const log4js = require("log4js");
|
|
13
|
+
class Logs {
|
|
14
|
+
constructor(name, configs) {
|
|
15
|
+
var _a;
|
|
16
|
+
this.name = this.constructor.name;
|
|
17
|
+
this.configs = (_a = require('../log/config/log4js.json')) !== null && _a !== void 0 ? _a : {};
|
|
18
|
+
if (name)
|
|
19
|
+
this.name = name;
|
|
20
|
+
if (configs)
|
|
21
|
+
this.configs = configs;
|
|
22
|
+
this.Provider().configure(this.configs);
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
this.Provider().configure(this.configs);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @constructor
|
|
30
|
+
*/
|
|
31
|
+
Provider() {
|
|
32
|
+
return log4js;
|
|
33
|
+
}
|
|
34
|
+
logs(...args) {
|
|
35
|
+
return log4js.getLogger(this.name);
|
|
36
|
+
}
|
|
37
|
+
debug(...args) {
|
|
38
|
+
this.logs().debug(...arguments);
|
|
39
|
+
}
|
|
40
|
+
info(...args) {
|
|
41
|
+
this.logs().info(...arguments);
|
|
42
|
+
}
|
|
43
|
+
warn(...args) {
|
|
44
|
+
this.logs().warn(...arguments);
|
|
45
|
+
}
|
|
46
|
+
error(...args) {
|
|
47
|
+
this.logs().error(...arguments);
|
|
48
|
+
}
|
|
49
|
+
fatal(...args) {
|
|
50
|
+
this.logs().fatal(...arguments);
|
|
51
|
+
}
|
|
52
|
+
warning(...args) {
|
|
53
|
+
this.logs().warn(...arguments);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Logs = Logs;
|
|
57
|
+
exports.default = new Logs();
|
package/base/Model.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.Model = exports.NOW = exports.DataTypes = void 0;
|
|
22
22
|
const BaseChyz_1 = __importDefault(require("../BaseChyz"));
|
|
23
|
-
const Utils_1 =
|
|
23
|
+
const Utils_1 = require("../requiments/Utils");
|
|
24
24
|
const Component_1 = require("./Component");
|
|
25
25
|
const InvalidConfigException_1 = require("./InvalidConfigException");
|
|
26
26
|
const sequelize_1 = require("sequelize");
|
|
@@ -93,7 +93,7 @@ class Model extends Component_1.Component {
|
|
|
93
93
|
this._sequelize = sequelize;
|
|
94
94
|
else
|
|
95
95
|
this._sequelize = this.getDb();
|
|
96
|
-
if (!Utils_1.
|
|
96
|
+
if (!Utils_1.Utils.isEmpty(this.attributes())) {
|
|
97
97
|
this._model = this._sequelize.define(this._tableName, this.attributes(), {
|
|
98
98
|
tableName: this.tableName(),
|
|
99
99
|
timestamps: false,
|
|
@@ -457,7 +457,7 @@ class Model extends Component_1.Component {
|
|
|
457
457
|
*/
|
|
458
458
|
load(data, formName = null) {
|
|
459
459
|
let scope = formName === null ? this.formName() : formName;
|
|
460
|
-
if (scope === '' && !Utils_1.
|
|
460
|
+
if (scope === '' && !Utils_1.Utils.isEmpty(data)) {
|
|
461
461
|
this.setAttribute(data);
|
|
462
462
|
return true;
|
|
463
463
|
}
|
|
@@ -469,7 +469,7 @@ class Model extends Component_1.Component {
|
|
|
469
469
|
}
|
|
470
470
|
bulkLoad(data, formName = null) {
|
|
471
471
|
let scope = formName === null ? this.formName() : formName;
|
|
472
|
-
if (scope === '' && !Utils_1.
|
|
472
|
+
if (scope === '' && !Utils_1.Utils.isEmpty(data)) {
|
|
473
473
|
this.setAttribute(data);
|
|
474
474
|
return true;
|
|
475
475
|
}
|
package/base/RestClient.d.ts
CHANGED
package/base/RestClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestClient.d.ts","sourceRoot":"","sources":["../../src/base/RestClient.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,qBAAa,UAAW,SAAQ,SAAS;IAC9B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAC,OAAO,GAAC,GAAM;IAI5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAC,OAAO,GAAC,GAAM;IAI3C,IAAI,CAAC,MAAM,EAAE,GAAG;CAG1B
|
|
1
|
+
{"version":3,"file":"RestClient.d.ts","sourceRoot":"","sources":["../../src/base/RestClient.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAItC,qBAAa,UAAW,SAAQ,SAAS;IAC9B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAC,OAAO,GAAC,GAAM;IAI5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAC,OAAO,GAAC,GAAM;IAI3C,IAAI,CAAC,MAAM,EAAE,GAAG;CAG1B"}
|
package/base/RestClient.js
CHANGED
package/base/index.d.ts
CHANGED
package/base/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAC,KAAK,EAAC,QAAQ,EAAC,SAAS,EAAE,GAAG,EAAC,MAAM,SAAS,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AACnE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAC,KAAK,EAAC,QAAQ,EAAC,SAAS,EAAE,GAAG,EAAC,MAAM,SAAS,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA"}
|
package/base/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModelManager = exports.RestClient = exports.NOW = exports.DataTypes = exports.Model = exports.ValidationHttpException = exports.DataErrorDbException = exports.UnauthorizedHttpException = exports.NotFoundHttpException = exports.InvalidArgumentException = exports.InvalidConfigException = exports.ForbiddenHttpException = exports.DbConnection = exports.CWebController = exports.Component = exports.Behavior = exports.ActionFilter = exports.BaseError = void 0;
|
|
3
|
+
exports.ModelManager = exports.RestClient = exports.NOW = exports.DataTypes = exports.Model = exports.ValidationHttpException = exports.DataErrorDbException = exports.UnauthorizedHttpException = exports.NotFoundHttpException = exports.InvalidArgumentException = exports.InvalidConfigException = exports.ForbiddenHttpException = exports.DbConnection = exports.CWebController = exports.Component = exports.Behavior = exports.ActionFilter = exports.BaseError = exports.Logs = void 0;
|
|
4
|
+
var Logs_1 = require("./Logs");
|
|
5
|
+
Object.defineProperty(exports, "Logs", { enumerable: true, get: function () { return Logs_1.Logs; } });
|
|
4
6
|
var BaseError_1 = require("./BaseError");
|
|
5
7
|
Object.defineProperty(exports, "BaseError", { enumerable: true, get: function () { return BaseError_1.BaseError; } });
|
|
6
8
|
var ActionFilter_1 = require("./ActionFilter");
|
package/filters/AccessControl.js
CHANGED
|
@@ -8,9 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.AccessControl = void 0;
|
|
16
13
|
/*
|
|
@@ -24,7 +21,7 @@ const ForbiddenHttpException_1 = require("../base/ForbiddenHttpException");
|
|
|
24
21
|
const ActionFilter_1 = require("../base/ActionFilter");
|
|
25
22
|
const AccessRule_1 = require("./AccessRule");
|
|
26
23
|
const WebUser_1 = require("../web/WebUser");
|
|
27
|
-
const Utils_1 =
|
|
24
|
+
const Utils_1 = require("../requiments/Utils");
|
|
28
25
|
class AccessControl extends ActionFilter_1.ActionFilter {
|
|
29
26
|
constructor() {
|
|
30
27
|
super(...arguments);
|
|
@@ -35,11 +32,11 @@ class AccessControl extends ActionFilter_1.ActionFilter {
|
|
|
35
32
|
var _a;
|
|
36
33
|
super.init();
|
|
37
34
|
if (this.user == undefined) {
|
|
38
|
-
this.user = (_a = Utils_1.
|
|
35
|
+
this.user = (_a = Utils_1.Utils.cloneDeep(index_1.BaseChyz.getComponent("user"))) !== null && _a !== void 0 ? _a : new WebUser_1.WebUser();
|
|
39
36
|
}
|
|
40
37
|
this.rules.forEach((rule, index) => {
|
|
41
38
|
if (rule === Object(rule)) {
|
|
42
|
-
this.rules[index] = Utils_1.
|
|
39
|
+
this.rules[index] = Utils_1.Utils.createObject(new AccessRule_1.AccessRule(), rule);
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
}
|
package/filters/AccessRule.js
CHANGED
|
@@ -8,14 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.AccessRule = void 0;
|
|
16
13
|
const Component_1 = require("../base/Component");
|
|
17
14
|
const InvalidConfigException_1 = require("../base/InvalidConfigException");
|
|
18
|
-
const Utils_1 =
|
|
15
|
+
const Utils_1 = require("../requiments/Utils");
|
|
19
16
|
var _ = require('lodash');
|
|
20
17
|
class AccessRule extends Component_1.Component {
|
|
21
18
|
constructor() {
|
|
@@ -99,11 +96,11 @@ class AccessRule extends Component_1.Component {
|
|
|
99
96
|
}
|
|
100
97
|
matchRole(user) {
|
|
101
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
let items = Utils_1.
|
|
103
|
-
if (!Utils_1.
|
|
104
|
-
items = Utils_1.
|
|
99
|
+
let items = Utils_1.Utils.isEmpty(this.roles) ? [] : this.roles;
|
|
100
|
+
if (!Utils_1.Utils.isEmpty(this.permissions)) {
|
|
101
|
+
items = Utils_1.Utils.merge(items, this.permissions);
|
|
105
102
|
}
|
|
106
|
-
if (Utils_1.
|
|
103
|
+
if (Utils_1.Utils.isEmpty(items)) {
|
|
107
104
|
return true;
|
|
108
105
|
}
|
|
109
106
|
if (!user) {
|
|
@@ -125,8 +122,8 @@ class AccessRule extends Component_1.Component {
|
|
|
125
122
|
}
|
|
126
123
|
else {
|
|
127
124
|
//roleparams
|
|
128
|
-
if (!Utils_1.
|
|
129
|
-
roleParams = !Utils_1.
|
|
125
|
+
if (!Utils_1.Utils.isEmpty(this.roleParams)) {
|
|
126
|
+
roleParams = !Utils_1.Utils.isArray(this.roleParams) ? this.roleParams.apply(this) : this.roleParams;
|
|
130
127
|
}
|
|
131
128
|
if (yield user.can(item, this.roleParams)) {
|
|
132
129
|
return true;
|
|
@@ -14,13 +14,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.HttpHeaderAuth = void 0;
|
|
22
19
|
const AuthMethod_1 = require("./AuthMethod");
|
|
23
|
-
const Utils_1 =
|
|
20
|
+
const Utils_1 = require("../../requiments/Utils");
|
|
24
21
|
class HttpHeaderAuth extends AuthMethod_1.AuthMethod {
|
|
25
22
|
constructor() {
|
|
26
23
|
super(...arguments);
|
|
@@ -34,7 +31,7 @@ class HttpHeaderAuth extends AuthMethod_1.AuthMethod {
|
|
|
34
31
|
let key = Object.keys(request.headers).find(key => key.toLowerCase() === this.header.toLowerCase());
|
|
35
32
|
if (key) {
|
|
36
33
|
let authHeader = request.headers[key];
|
|
37
|
-
if (!Utils_1.
|
|
34
|
+
if (!Utils_1.Utils.isEmpty(authHeader)) {
|
|
38
35
|
if (this.pattern) {
|
|
39
36
|
//preg_match
|
|
40
37
|
let matches = authHeader.match(this.pattern);
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
declare module "express-serve-static-core" {
|
|
2
|
+
interface Request {
|
|
3
|
+
identity: any;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
import { RestClient } from "./base/RestClient";
|
|
2
7
|
import BaseChyz from "./BaseChyz";
|
|
3
8
|
/**
|
|
4
9
|
*
|
|
5
10
|
*/
|
|
6
11
|
declare const Chyz: BaseChyz;
|
|
7
|
-
export { Request, Response, NextFunction } from "
|
|
12
|
+
export { Request, Response, NextFunction } from "./base/CRequest";
|
|
8
13
|
export { RouteDefinition } from "./model/RouteDefinition";
|
|
9
14
|
export { WebUser } from "./web/WebUser";
|
|
10
15
|
export { BaseChyz, RestClient };
|
|
11
|
-
export { ActionFilter, BaseError, Behavior, Component, Configurable, CWebController, DbConnection, ForbiddenHttpException, InvalidConfigException, InvalidArgumentException, NotFoundHttpException, UnauthorizedHttpException, DataErrorDbException, ValidationHttpException, Model, ModelManager, } from "./base";
|
|
16
|
+
export { Logs, ActionFilter, BaseError, Behavior, Component, Configurable, CWebController, DbConnection, ForbiddenHttpException, InvalidConfigException, InvalidArgumentException, NotFoundHttpException, UnauthorizedHttpException, DataErrorDbException, ValidationHttpException, Model, ModelManager, } from "./base";
|
|
12
17
|
export * from "./filters";
|
|
13
18
|
export * from "./filters/auth";
|
|
14
19
|
export * from "./decorator";
|
|
15
|
-
export *
|
|
20
|
+
export * from "./requiments/Utils";
|
|
16
21
|
export default Chyz;
|
|
17
22
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,QAAQ,2BAA2B,CAAC;IACvC,UAAU,OAAO;QACb,QAAQ,EAAE,GAAG,CAAC;KACjB;CACJ;AAGD,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC;;GAEG;AACH,QAAA,MAAM,IAAI,UAAiB,CAAC;AAC5B,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,CAAA;AAC7B,OAAO,EACH,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,EACL,YAAY,GACf,MAAM,QAAQ,CAAC;AAChB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,eAAe,IAAI,CAAC"}
|
package/index.js
CHANGED
|
@@ -18,28 +18,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
18
18
|
if (k2 === undefined) k2 = k;
|
|
19
19
|
o[k2] = m[k];
|
|
20
20
|
}));
|
|
21
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
-
}) : function(o, v) {
|
|
24
|
-
o["default"] = v;
|
|
25
|
-
});
|
|
26
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
23
|
};
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
26
|
};
|
|
39
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.
|
|
41
|
-
const RestClient_1 =
|
|
42
|
-
exports
|
|
28
|
+
exports.ModelManager = exports.Model = exports.ValidationHttpException = exports.DataErrorDbException = exports.UnauthorizedHttpException = exports.NotFoundHttpException = exports.InvalidArgumentException = exports.InvalidConfigException = exports.ForbiddenHttpException = exports.DbConnection = exports.CWebController = exports.Component = exports.Behavior = exports.BaseError = exports.ActionFilter = exports.Logs = exports.RestClient = exports.BaseChyz = exports.WebUser = void 0;
|
|
29
|
+
const RestClient_1 = require("./base/RestClient");
|
|
30
|
+
Object.defineProperty(exports, "RestClient", { enumerable: true, get: function () { return RestClient_1.RestClient; } });
|
|
43
31
|
const BaseChyz_1 = __importDefault(require("./BaseChyz"));
|
|
44
32
|
exports.BaseChyz = BaseChyz_1.default;
|
|
45
33
|
/**
|
|
@@ -49,6 +37,7 @@ const Chyz = new BaseChyz_1.default();
|
|
|
49
37
|
var WebUser_1 = require("./web/WebUser");
|
|
50
38
|
Object.defineProperty(exports, "WebUser", { enumerable: true, get: function () { return WebUser_1.WebUser; } });
|
|
51
39
|
var base_1 = require("./base");
|
|
40
|
+
Object.defineProperty(exports, "Logs", { enumerable: true, get: function () { return base_1.Logs; } });
|
|
52
41
|
Object.defineProperty(exports, "ActionFilter", { enumerable: true, get: function () { return base_1.ActionFilter; } });
|
|
53
42
|
Object.defineProperty(exports, "BaseError", { enumerable: true, get: function () { return base_1.BaseError; } });
|
|
54
43
|
Object.defineProperty(exports, "Behavior", { enumerable: true, get: function () { return base_1.Behavior; } });
|
|
@@ -67,5 +56,5 @@ Object.defineProperty(exports, "ModelManager", { enumerable: true, get: function
|
|
|
67
56
|
__exportStar(require("./filters"), exports);
|
|
68
57
|
__exportStar(require("./filters/auth"), exports);
|
|
69
58
|
__exportStar(require("./decorator"), exports);
|
|
70
|
-
|
|
59
|
+
__exportStar(require("./requiments/Utils"), exports);
|
|
71
60
|
exports.default = Chyz;
|
package/package.json
CHANGED
package/rbac/AuthManager.js
CHANGED
|
@@ -8,14 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.AuthManager = void 0;
|
|
16
13
|
const base_1 = require("../base");
|
|
17
14
|
const index_1 = require("../index");
|
|
18
|
-
const Utils_1 =
|
|
15
|
+
const Utils_1 = require("../requiments/Utils");
|
|
19
16
|
class AuthManager extends base_1.Component {
|
|
20
17
|
constructor() {
|
|
21
18
|
super(...arguments);
|
|
@@ -58,7 +55,7 @@ class AuthManager extends base_1.Component {
|
|
|
58
55
|
* @todo
|
|
59
56
|
* Rule test edilmeli
|
|
60
57
|
*/
|
|
61
|
-
if (assignments[itemname] || Utils_1.
|
|
58
|
+
if (assignments[itemname] || Utils_1.Utils.find(this.defaultRoles, itemname)) {
|
|
62
59
|
return true;
|
|
63
60
|
}
|
|
64
61
|
/**
|
|
@@ -134,11 +131,11 @@ class AuthManager extends base_1.Component {
|
|
|
134
131
|
roles[roleName] = role;
|
|
135
132
|
let _roles = yield this.getRoles();
|
|
136
133
|
let _r = {};
|
|
137
|
-
Utils_1.
|
|
134
|
+
Utils_1.Utils.forEach(_roles, (item) => {
|
|
138
135
|
if (result.result[item.name])
|
|
139
136
|
_r[item.name] = item;
|
|
140
137
|
});
|
|
141
|
-
return Utils_1.
|
|
138
|
+
return Utils_1.Utils.merge(roles, _r);
|
|
142
139
|
});
|
|
143
140
|
}
|
|
144
141
|
/**
|
|
@@ -151,7 +148,7 @@ class AuthManager extends base_1.Component {
|
|
|
151
148
|
const result = { result: {} };
|
|
152
149
|
let permissions = {};
|
|
153
150
|
yield this.getChildrenRecursive(roleName, childrenList, result);
|
|
154
|
-
if (Utils_1.
|
|
151
|
+
if (Utils_1.Utils.isEmpty(result.result)) {
|
|
155
152
|
return {};
|
|
156
153
|
}
|
|
157
154
|
let itemResult = yield base_1.ModelManager.AuthItem.findAll({
|
|
@@ -177,7 +174,7 @@ class AuthManager extends base_1.Component {
|
|
|
177
174
|
}
|
|
178
175
|
let directPermission = yield this.getDirectPermissionsByUser(userId);
|
|
179
176
|
let inheritedPermission = yield this.getInheritedPermissionsByUser(userId);
|
|
180
|
-
return Utils_1.
|
|
177
|
+
return Utils_1.Utils.merge(directPermission, inheritedPermission);
|
|
181
178
|
});
|
|
182
179
|
}
|
|
183
180
|
/**
|
|
@@ -214,7 +211,7 @@ class AuthManager extends base_1.Component {
|
|
|
214
211
|
for (const userAssignmentElement of userAssignment) {
|
|
215
212
|
this.getChildrenRecursive(userAssignmentElement.item_name, childrenList, result);
|
|
216
213
|
}
|
|
217
|
-
if (Utils_1.
|
|
214
|
+
if (Utils_1.Utils.isEmpty(result.result)) {
|
|
218
215
|
return {};
|
|
219
216
|
}
|
|
220
217
|
let itemResult = yield base_1.ModelManager.AuthItem.findAll({
|
|
@@ -328,7 +325,7 @@ class AuthManager extends base_1.Component {
|
|
|
328
325
|
let items = yield base_1.ModelManager.AuthItemChild.findAll();
|
|
329
326
|
let parents = {};
|
|
330
327
|
for (const item of items) {
|
|
331
|
-
parents[item["parent"]] = Utils_1.
|
|
328
|
+
parents[item["parent"]] = Utils_1.Utils.concat(parents[item["parent"]] || [], [item["child"]]);
|
|
332
329
|
}
|
|
333
330
|
return parents;
|
|
334
331
|
});
|
|
@@ -350,7 +347,7 @@ class AuthManager extends base_1.Component {
|
|
|
350
347
|
* @since 2.0.11
|
|
351
348
|
*/
|
|
352
349
|
hasNoAssignments(assignments) {
|
|
353
|
-
return Utils_1.
|
|
350
|
+
return Utils_1.Utils.isEmpty(assignments) && Utils_1.Utils.isEmpty(this.defaultRoles);
|
|
354
351
|
}
|
|
355
352
|
}
|
|
356
353
|
exports.AuthManager = AuthManager;
|
package/requiments/Utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/requiments/Utils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/requiments/Utils.ts"],"names":[],"mappings":"AAkGA;;;GAGG;AACH,QAAA,MAAM,CAAC,SAAmB,MAAM,WAE/B,CAAA;AAED,eAAO,MAAM,KAAK,KAOjB,CAAA;AACD,OAAO,EAAC,CAAC,EAAC,CAAA;AACV,eAAe,CAAC,CAAC"}
|
package/requiments/Utils.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
// import _ from "lodash";
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.t = exports.Utils = void 0;
|
|
10
11
|
const _ = require('lodash');
|
|
11
12
|
/**
|
|
12
13
|
*
|
|
@@ -102,9 +103,10 @@ const matchWildcard = (pattern, string, options = {}) => {
|
|
|
102
103
|
const t = function (text) {
|
|
103
104
|
return text;
|
|
104
105
|
};
|
|
105
|
-
exports.
|
|
106
|
+
exports.t = t;
|
|
107
|
+
exports.Utils = Object.assign({ findKeyValue,
|
|
106
108
|
createObject,
|
|
107
|
-
findKeyValue,
|
|
108
109
|
sleep,
|
|
109
110
|
matchWildcard,
|
|
110
111
|
toQuery }, _);
|
|
112
|
+
exports.default = t;
|
package/web/WebUser.js
CHANGED
|
@@ -23,7 +23,7 @@ const BaseChyz_1 = __importDefault(require("../BaseChyz"));
|
|
|
23
23
|
const Component_1 = require("../base/Component");
|
|
24
24
|
const ForbiddenHttpException_1 = require("../base/ForbiddenHttpException");
|
|
25
25
|
const InvalidConfigException_1 = require("../base/InvalidConfigException");
|
|
26
|
-
const Utils_1 =
|
|
26
|
+
const Utils_1 = require("../requiments/Utils");
|
|
27
27
|
class WebUser extends Component_1.Component {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments);
|
|
@@ -137,7 +137,7 @@ class WebUser extends Component_1.Component {
|
|
|
137
137
|
if ((accessChecker = this.getAccessChecker()) == null)
|
|
138
138
|
return false;
|
|
139
139
|
access = yield accessChecker.checkAccess(this.getId(), permissionName, params);
|
|
140
|
-
if (allowCaching && Utils_1.
|
|
140
|
+
if (allowCaching && Utils_1.Utils.isEmpty(params)) {
|
|
141
141
|
// this._access[$permissionName] = $access;
|
|
142
142
|
}
|
|
143
143
|
return access;
|
package/base/Logger.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Configurable } from "./Configurable";
|
|
2
|
-
export declare class Logger implements Configurable {
|
|
3
|
-
configs: any;
|
|
4
|
-
init(): void;
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
Provider(): any;
|
|
10
|
-
static logs(...args: any[]): any;
|
|
11
|
-
static debug(...args: any[]): void;
|
|
12
|
-
static info(...args: any[]): void;
|
|
13
|
-
static warn(...args: any[]): void;
|
|
14
|
-
static error(...args: any[]): void;
|
|
15
|
-
static fatal(...args: any[]): void;
|
|
16
|
-
static warning(...args: any[]): void;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=Logger.d.ts.map
|
package/base/Logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/base/Logger.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,qBAAa,MAAO,YAAW,YAAY;IAEhC,OAAO,EAAE,GAAG,CAA6C;IAEhE,IAAI;IAIJ;;;OAGG;IACH,QAAQ;IAIR,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIZ,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIpB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAInB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAInB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAIpB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;WAKpB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAIvC"}
|
package/base/Logger.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2022.. 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.Logger = void 0;
|
|
12
|
-
const log4js = require("log4js");
|
|
13
|
-
class Logger {
|
|
14
|
-
constructor() {
|
|
15
|
-
var _a;
|
|
16
|
-
this.configs = (_a = require('../log/config/log4js.json')) !== null && _a !== void 0 ? _a : {};
|
|
17
|
-
}
|
|
18
|
-
init() {
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
Provider() {
|
|
25
|
-
return log4js;
|
|
26
|
-
}
|
|
27
|
-
static logs(...args) {
|
|
28
|
-
return log4js.getLogger(this.name);
|
|
29
|
-
}
|
|
30
|
-
static debug(...args) {
|
|
31
|
-
Logger.logs().debug(...arguments);
|
|
32
|
-
}
|
|
33
|
-
static info(...args) {
|
|
34
|
-
Logger.logs().info(...arguments);
|
|
35
|
-
}
|
|
36
|
-
static warn(...args) {
|
|
37
|
-
Logger.logs().warn(...arguments);
|
|
38
|
-
}
|
|
39
|
-
static error(...args) {
|
|
40
|
-
Logger.logs().error(...arguments);
|
|
41
|
-
}
|
|
42
|
-
static fatal(...args) {
|
|
43
|
-
Logger.logs().fatal(...arguments);
|
|
44
|
-
}
|
|
45
|
-
static warning(...args) {
|
|
46
|
-
Logger.logs().warn(...arguments);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.Logger = Logger;
|