@pxp-nd/core 1.2.74 → 1.2.75
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/README.md +1 -1
- package/dist/PxpApp.d.ts +54 -54
- package/dist/PxpApp.js +283 -284
- package/dist/ScriptManager.d.ts +1 -1
- package/dist/ScriptManager.js +130 -130
- package/dist/database/script.d.ts +16 -16
- package/dist/database/script.js +143 -143
- package/dist/db.datasource.d.ts +2 -2
- package/dist/db.datasource.js +86 -86
- package/dist/entities/Log.d.ts +32 -32
- package/dist/entities/Log.js +95 -95
- package/dist/entities/ScriptVersion.d.ts +19 -19
- package/dist/entities/ScriptVersion.js +43 -43
- package/dist/index.d.ts +11 -11
- package/dist/index.js +28 -28
- package/dist/interfaces.d.ts +49 -49
- package/dist/interfaces.js +3 -3
- package/dist/lib/pxp/Controller.d.ts +51 -51
- package/dist/lib/pxp/Controller.js +377 -377
- package/dist/lib/pxp/ControllerInterface.d.ts +18 -18
- package/dist/lib/pxp/ControllerInterface.js +2 -2
- package/dist/lib/pxp/Decorators.d.ts +23 -23
- package/dist/lib/pxp/Decorators.js +123 -123
- package/dist/lib/pxp/ListParamInterface.d.ts +23 -23
- package/dist/lib/pxp/ListParamInterface.js +2 -2
- package/dist/lib/pxp/PxpError.d.ts +24 -24
- package/dist/lib/pxp/PxpError.js +57 -57
- package/dist/lib/pxp/RouteDefinition.d.ts +26 -26
- package/dist/lib/pxp/RouteDefinition.js +26 -26
- package/dist/lib/pxp/index.d.ts +20 -20
- package/dist/lib/pxp/index.js +33 -33
- package/dist/lib/pxp/loadControllers.d.ts +4 -4
- package/dist/lib/pxp/loadControllers.js +89 -89
- package/dist/lib/pxp/middlewares/ParseParams.d.ts +4 -4
- package/dist/lib/pxp/middlewares/ParseParams.js +71 -71
- package/dist/lib/pxp/middlewares/isReportMiddleware.d.ts +2 -2
- package/dist/lib/pxp/middlewares/isReportMiddleware.js +13 -13
- package/dist/lib/pxp/utils/Security.d.ts +23 -23
- package/dist/lib/pxp/utils/Security.js +79 -77
- package/dist/lib/pxp/utils/crypto.d.ts +3 -3
- package/dist/lib/pxp/utils/crypto.js +15 -15
- package/dist/lib/reports/fonts/Roboto-Regular-normal.d.ts +2 -2
- package/dist/lib/reports/fonts/Roboto-Regular-normal.js +4 -4
- package/dist/lib/reports/generated.d.ts +4 -4
- package/dist/lib/reports/generated.js +200 -200
- package/dist/lib/reports/helper.d.ts +8 -8
- package/dist/lib/reports/helper.js +49 -49
- package/dist/lib/reports/pdf.d.ts +3 -3
- package/dist/lib/reports/pdf.js +119 -119
- package/dist/lib/reports/report-routes.d.ts +3 -3
- package/dist/lib/reports/report-routes.js +24 -24
- package/dist/lib/reports/xlsx.d.ts +1 -1
- package/dist/lib/reports/xlsx.js +65 -65
- package/dist/sockets/basic-sockets.d.ts +5 -5
- package/dist/sockets/basic-sockets.js +38 -38
- package/dist/sockets/entities/UserIo.d.ts +6 -6
- package/dist/sockets/entities/UserIo.js +30 -30
- package/dist/sockets/entities/index.d.ts +5 -5
- package/dist/sockets/entities/index.js +9 -9
- package/dist/sockets/index.d.ts +2 -2
- package/dist/sockets/index.js +19 -19
- package/dist/sockets/pxp-io-server.d.ts +6 -6
- package/dist/sockets/pxp-io-server.js +50 -50
- package/dist/swaggerOptions.d.ts +16 -16
- package/dist/swaggerOptions.js +20 -20
- package/package.json +65 -65
- package/yalc.lock +9 -9
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kplian Ltda 2020
|
|
3
|
-
*
|
|
4
|
-
* MIT
|
|
5
|
-
*
|
|
6
|
-
* Structure for all controllers.
|
|
7
|
-
*
|
|
8
|
-
* @summary Structure for all controllers.
|
|
9
|
-
* @author Jaime Rivera
|
|
10
|
-
*
|
|
11
|
-
* Created at : 2020-06-13 18:09:48
|
|
12
|
-
* Last modified : 2020-09-17 18:28:21
|
|
13
|
-
*/
|
|
14
|
-
import { Router } from 'express';
|
|
15
|
-
export interface ControllerInterface {
|
|
16
|
-
path: string;
|
|
17
|
-
router: Router;
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Kplian Ltda 2020
|
|
3
|
+
*
|
|
4
|
+
* MIT
|
|
5
|
+
*
|
|
6
|
+
* Structure for all controllers.
|
|
7
|
+
*
|
|
8
|
+
* @summary Structure for all controllers.
|
|
9
|
+
* @author Jaime Rivera
|
|
10
|
+
*
|
|
11
|
+
* Created at : 2020-06-13 18:09:48
|
|
12
|
+
* Last modified : 2020-09-17 18:28:21
|
|
13
|
+
*/
|
|
14
|
+
import { Router } from 'express';
|
|
15
|
+
export interface ControllerInterface {
|
|
16
|
+
path: string;
|
|
17
|
+
router: Router;
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export declare interface ILog {
|
|
2
|
-
[field: string]: 'cc_mask' | 'complete_mask';
|
|
3
|
-
}
|
|
4
|
-
export declare interface IOptionsRoute {
|
|
5
|
-
readOnly?: boolean;
|
|
6
|
-
dbSettings?: 'Procedure' | 'Orm' | 'Query';
|
|
7
|
-
authentication?: boolean;
|
|
8
|
-
log?: boolean | ILog;
|
|
9
|
-
}
|
|
10
|
-
declare const Get: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
11
|
-
declare const Post: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
12
|
-
declare const Put: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
13
|
-
declare const Patch: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
14
|
-
declare const Delete: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
15
|
-
declare const Route: (controllerPath?: string) => ClassDecorator;
|
|
16
|
-
declare const Model: (model: string) => ClassDecorator;
|
|
17
|
-
declare const StoredProcedure: (storedProcedure: string) => ClassDecorator;
|
|
18
|
-
declare const Authentication: (authentication?: boolean) => (target: any, propertyKey: string) => void;
|
|
19
|
-
declare const ReadOnly: (ronly?: boolean) => (target: any, propertyKey: string) => void;
|
|
20
|
-
declare const DbSettings: (modelType: 'Procedure' | 'Orm' | 'Query') => (target: any, propertyKey: string) => void;
|
|
21
|
-
declare const Permission: (permission?: boolean) => (target: any, propertyKey: string) => void;
|
|
22
|
-
declare const Log: (log?: boolean, config?: Record<string, unknown>) => (target: any, propertyKey: string) => void;
|
|
23
|
-
export { Get, Post, Put, Delete, Patch, Route, Authentication, Log, Permission, DbSettings, ReadOnly, Model, StoredProcedure };
|
|
1
|
+
export declare interface ILog {
|
|
2
|
+
[field: string]: 'cc_mask' | 'complete_mask';
|
|
3
|
+
}
|
|
4
|
+
export declare interface IOptionsRoute {
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
dbSettings?: 'Procedure' | 'Orm' | 'Query';
|
|
7
|
+
authentication?: boolean;
|
|
8
|
+
log?: boolean | ILog;
|
|
9
|
+
}
|
|
10
|
+
declare const Get: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
11
|
+
declare const Post: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
12
|
+
declare const Put: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
13
|
+
declare const Patch: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
14
|
+
declare const Delete: (path?: string, options?: IOptionsRoute) => (target: any, propertyKey: string) => void;
|
|
15
|
+
declare const Route: (controllerPath?: string) => ClassDecorator;
|
|
16
|
+
declare const Model: (model: string) => ClassDecorator;
|
|
17
|
+
declare const StoredProcedure: (storedProcedure: string) => ClassDecorator;
|
|
18
|
+
declare const Authentication: (authentication?: boolean) => (target: any, propertyKey: string) => void;
|
|
19
|
+
declare const ReadOnly: (ronly?: boolean) => (target: any, propertyKey: string) => void;
|
|
20
|
+
declare const DbSettings: (modelType: 'Procedure' | 'Orm' | 'Query') => (target: any, propertyKey: string) => void;
|
|
21
|
+
declare const Permission: (permission?: boolean) => (target: any, propertyKey: string) => void;
|
|
22
|
+
declare const Log: (log?: boolean, config?: Record<string, unknown>) => (target: any, propertyKey: string) => void;
|
|
23
|
+
export { Get, Post, Put, Delete, Patch, Route, Authentication, Log, Permission, DbSettings, ReadOnly, Model, StoredProcedure };
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StoredProcedure = exports.Model = exports.ReadOnly = exports.DbSettings = exports.Permission = exports.Log = exports.Authentication = exports.Route = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Kplian Ltda 2020
|
|
6
|
-
*
|
|
7
|
-
* MIT
|
|
8
|
-
*
|
|
9
|
-
* All Pxp Decorators.
|
|
10
|
-
*
|
|
11
|
-
* @summary Pxp decorators.
|
|
12
|
-
* @author Jaime Rivera
|
|
13
|
-
*
|
|
14
|
-
* Created at : 2020-06-13 18:09:48
|
|
15
|
-
* Last modified : 2020-09-17 18:29:51
|
|
16
|
-
*/
|
|
17
|
-
const RouteDefinition_1 = require("./RouteDefinition");
|
|
18
|
-
;
|
|
19
|
-
;
|
|
20
|
-
const setProperty = (target, propertyKey) => (value, name, overwrite = true) => {
|
|
21
|
-
if (!Reflect.hasMetadata(name, target.constructor)) {
|
|
22
|
-
Reflect.defineMetadata(name, {}, target.constructor);
|
|
23
|
-
}
|
|
24
|
-
const valueName = Reflect.getMetadata(name, target.constructor);
|
|
25
|
-
if (!overwrite && !valueName[propertyKey]) {
|
|
26
|
-
valueName[propertyKey] = value;
|
|
27
|
-
}
|
|
28
|
-
else if (overwrite) {
|
|
29
|
-
valueName[propertyKey] = value;
|
|
30
|
-
}
|
|
31
|
-
Reflect.defineMetadata(name, valueName, target.constructor);
|
|
32
|
-
};
|
|
33
|
-
const createOptions = (options) => (target, propertyKey) => {
|
|
34
|
-
options = Object.assign({
|
|
35
|
-
readOnly: true,
|
|
36
|
-
dbSettings: 'Orm',
|
|
37
|
-
authentication: true,
|
|
38
|
-
log: true
|
|
39
|
-
}, options);
|
|
40
|
-
// const newProperty = setProperty(target, propertyKey);
|
|
41
|
-
// // ReadOnly
|
|
42
|
-
// newProperty(options.readOnly, 'readonly', false);
|
|
43
|
-
// // DbSettings
|
|
44
|
-
// newProperty(options.dbSettings, 'dbsettings', false);
|
|
45
|
-
// // Authentication
|
|
46
|
-
// newProperty(options.authentication, 'authentication', false);
|
|
47
|
-
if (!Reflect.hasMetadata('optionsRoute', target.constructor)) {
|
|
48
|
-
Reflect.defineMetadata('optionsRoute', {}, target.constructor);
|
|
49
|
-
}
|
|
50
|
-
const optionsRoute = Reflect.getMetadata('optionsRoute', target.constructor);
|
|
51
|
-
optionsRoute[propertyKey] = options;
|
|
52
|
-
Reflect.defineMetadata('optionsRoute', optionsRoute, target.constructor);
|
|
53
|
-
};
|
|
54
|
-
const setRoute = (path = '', method, options) => (target, propertyKey) => {
|
|
55
|
-
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
56
|
-
Reflect.defineMetadata('routes', [], target.constructor);
|
|
57
|
-
}
|
|
58
|
-
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
59
|
-
routes.push({
|
|
60
|
-
requestMethod: method,
|
|
61
|
-
path: path === '' ? '/' + propertyKey : path,
|
|
62
|
-
methodName: propertyKey
|
|
63
|
-
});
|
|
64
|
-
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
65
|
-
createOptions(options)(target, propertyKey);
|
|
66
|
-
};
|
|
67
|
-
const Get = (path, options) => setRoute(path, RouteDefinition_1.Method.get, options);
|
|
68
|
-
exports.Get = Get;
|
|
69
|
-
const Post = (path, options) => setRoute(path, RouteDefinition_1.Method.post, options);
|
|
70
|
-
exports.Post = Post;
|
|
71
|
-
const Put = (path, options) => setRoute(path, RouteDefinition_1.Method.put, options);
|
|
72
|
-
exports.Put = Put;
|
|
73
|
-
const Patch = (path, options) => setRoute(path, RouteDefinition_1.Method.patch, options);
|
|
74
|
-
exports.Patch = Patch;
|
|
75
|
-
const Delete = (path, options) => setRoute(path, RouteDefinition_1.Method.delete, options);
|
|
76
|
-
exports.Delete = Delete;
|
|
77
|
-
const Route = (controllerPath = '') => {
|
|
78
|
-
return (target) => {
|
|
79
|
-
Reflect.defineMetadata('controller_path', controllerPath, target);
|
|
80
|
-
// Since routes are set by our methods this should almost never be true (except the controller has no methods)
|
|
81
|
-
if (!Reflect.hasMetadata('routes', target)) {
|
|
82
|
-
Reflect.defineMetadata('routes', [], target);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
exports.Route = Route;
|
|
87
|
-
const Model = (model) => {
|
|
88
|
-
return (target) => {
|
|
89
|
-
Reflect.defineMetadata('model', model, target);
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
exports.Model = Model;
|
|
93
|
-
const StoredProcedure = (storedProcedure) => {
|
|
94
|
-
return (target) => {
|
|
95
|
-
Reflect.defineMetadata('storedprocedure', storedProcedure, target);
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
exports.StoredProcedure = StoredProcedure;
|
|
99
|
-
const Authentication = (authentication = true) => (target, propertyKey) => setProperty(target, propertyKey)(authentication, 'authentication');
|
|
100
|
-
exports.Authentication = Authentication;
|
|
101
|
-
const ReadOnly = (ronly = true) => (target, propertyKey) => setProperty(target, propertyKey)(ronly, 'readonly');
|
|
102
|
-
exports.ReadOnly = ReadOnly;
|
|
103
|
-
const DbSettings = (modelType) => (target, propertyKey) => setProperty(target, propertyKey)(modelType, 'dbsettings');
|
|
104
|
-
exports.DbSettings = DbSettings;
|
|
105
|
-
const Permission = (permission = true) => (target, propertyKey) => setProperty(target, propertyKey)(permission, 'permission');
|
|
106
|
-
exports.Permission = Permission;
|
|
107
|
-
const Log = (log = true, config = {}) => {
|
|
108
|
-
return (target, propertyKey) => {
|
|
109
|
-
if (!Reflect.hasMetadata('log', target.constructor)) {
|
|
110
|
-
Reflect.defineMetadata('log', {}, target.constructor);
|
|
111
|
-
}
|
|
112
|
-
if (!Reflect.hasMetadata('logConfig', target.constructor)) {
|
|
113
|
-
Reflect.defineMetadata('logConfig', {}, target.constructor);
|
|
114
|
-
}
|
|
115
|
-
const logVar = Reflect.getMetadata('log', target.constructor);
|
|
116
|
-
logVar[propertyKey] = log;
|
|
117
|
-
const logConfig = Reflect.getMetadata('logConfig', target.constructor);
|
|
118
|
-
logConfig[propertyKey] = config;
|
|
119
|
-
Reflect.defineMetadata('log', logVar, target.constructor);
|
|
120
|
-
Reflect.defineMetadata('logConfig', logConfig, target.constructor);
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
exports.Log = Log;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StoredProcedure = exports.Model = exports.ReadOnly = exports.DbSettings = exports.Permission = exports.Log = exports.Authentication = exports.Route = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Kplian Ltda 2020
|
|
6
|
+
*
|
|
7
|
+
* MIT
|
|
8
|
+
*
|
|
9
|
+
* All Pxp Decorators.
|
|
10
|
+
*
|
|
11
|
+
* @summary Pxp decorators.
|
|
12
|
+
* @author Jaime Rivera
|
|
13
|
+
*
|
|
14
|
+
* Created at : 2020-06-13 18:09:48
|
|
15
|
+
* Last modified : 2020-09-17 18:29:51
|
|
16
|
+
*/
|
|
17
|
+
const RouteDefinition_1 = require("./RouteDefinition");
|
|
18
|
+
;
|
|
19
|
+
;
|
|
20
|
+
const setProperty = (target, propertyKey) => (value, name, overwrite = true) => {
|
|
21
|
+
if (!Reflect.hasMetadata(name, target.constructor)) {
|
|
22
|
+
Reflect.defineMetadata(name, {}, target.constructor);
|
|
23
|
+
}
|
|
24
|
+
const valueName = Reflect.getMetadata(name, target.constructor);
|
|
25
|
+
if (!overwrite && !valueName[propertyKey]) {
|
|
26
|
+
valueName[propertyKey] = value;
|
|
27
|
+
}
|
|
28
|
+
else if (overwrite) {
|
|
29
|
+
valueName[propertyKey] = value;
|
|
30
|
+
}
|
|
31
|
+
Reflect.defineMetadata(name, valueName, target.constructor);
|
|
32
|
+
};
|
|
33
|
+
const createOptions = (options) => (target, propertyKey) => {
|
|
34
|
+
options = Object.assign({
|
|
35
|
+
readOnly: true,
|
|
36
|
+
dbSettings: 'Orm',
|
|
37
|
+
authentication: true,
|
|
38
|
+
log: true
|
|
39
|
+
}, options);
|
|
40
|
+
// const newProperty = setProperty(target, propertyKey);
|
|
41
|
+
// // ReadOnly
|
|
42
|
+
// newProperty(options.readOnly, 'readonly', false);
|
|
43
|
+
// // DbSettings
|
|
44
|
+
// newProperty(options.dbSettings, 'dbsettings', false);
|
|
45
|
+
// // Authentication
|
|
46
|
+
// newProperty(options.authentication, 'authentication', false);
|
|
47
|
+
if (!Reflect.hasMetadata('optionsRoute', target.constructor)) {
|
|
48
|
+
Reflect.defineMetadata('optionsRoute', {}, target.constructor);
|
|
49
|
+
}
|
|
50
|
+
const optionsRoute = Reflect.getMetadata('optionsRoute', target.constructor);
|
|
51
|
+
optionsRoute[propertyKey] = options;
|
|
52
|
+
Reflect.defineMetadata('optionsRoute', optionsRoute, target.constructor);
|
|
53
|
+
};
|
|
54
|
+
const setRoute = (path = '', method, options) => (target, propertyKey) => {
|
|
55
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
56
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
57
|
+
}
|
|
58
|
+
const routes = Reflect.getMetadata('routes', target.constructor);
|
|
59
|
+
routes.push({
|
|
60
|
+
requestMethod: method,
|
|
61
|
+
path: path === '' ? '/' + propertyKey : path,
|
|
62
|
+
methodName: propertyKey
|
|
63
|
+
});
|
|
64
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
65
|
+
createOptions(options)(target, propertyKey);
|
|
66
|
+
};
|
|
67
|
+
const Get = (path, options) => setRoute(path, RouteDefinition_1.Method.get, options);
|
|
68
|
+
exports.Get = Get;
|
|
69
|
+
const Post = (path, options) => setRoute(path, RouteDefinition_1.Method.post, options);
|
|
70
|
+
exports.Post = Post;
|
|
71
|
+
const Put = (path, options) => setRoute(path, RouteDefinition_1.Method.put, options);
|
|
72
|
+
exports.Put = Put;
|
|
73
|
+
const Patch = (path, options) => setRoute(path, RouteDefinition_1.Method.patch, options);
|
|
74
|
+
exports.Patch = Patch;
|
|
75
|
+
const Delete = (path, options) => setRoute(path, RouteDefinition_1.Method.delete, options);
|
|
76
|
+
exports.Delete = Delete;
|
|
77
|
+
const Route = (controllerPath = '') => {
|
|
78
|
+
return (target) => {
|
|
79
|
+
Reflect.defineMetadata('controller_path', controllerPath, target);
|
|
80
|
+
// Since routes are set by our methods this should almost never be true (except the controller has no methods)
|
|
81
|
+
if (!Reflect.hasMetadata('routes', target)) {
|
|
82
|
+
Reflect.defineMetadata('routes', [], target);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
exports.Route = Route;
|
|
87
|
+
const Model = (model) => {
|
|
88
|
+
return (target) => {
|
|
89
|
+
Reflect.defineMetadata('model', model, target);
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.Model = Model;
|
|
93
|
+
const StoredProcedure = (storedProcedure) => {
|
|
94
|
+
return (target) => {
|
|
95
|
+
Reflect.defineMetadata('storedprocedure', storedProcedure, target);
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.StoredProcedure = StoredProcedure;
|
|
99
|
+
const Authentication = (authentication = true) => (target, propertyKey) => setProperty(target, propertyKey)(authentication, 'authentication');
|
|
100
|
+
exports.Authentication = Authentication;
|
|
101
|
+
const ReadOnly = (ronly = true) => (target, propertyKey) => setProperty(target, propertyKey)(ronly, 'readonly');
|
|
102
|
+
exports.ReadOnly = ReadOnly;
|
|
103
|
+
const DbSettings = (modelType) => (target, propertyKey) => setProperty(target, propertyKey)(modelType, 'dbsettings');
|
|
104
|
+
exports.DbSettings = DbSettings;
|
|
105
|
+
const Permission = (permission = true) => (target, propertyKey) => setProperty(target, propertyKey)(permission, 'permission');
|
|
106
|
+
exports.Permission = Permission;
|
|
107
|
+
const Log = (log = true, config = {}) => {
|
|
108
|
+
return (target, propertyKey) => {
|
|
109
|
+
if (!Reflect.hasMetadata('log', target.constructor)) {
|
|
110
|
+
Reflect.defineMetadata('log', {}, target.constructor);
|
|
111
|
+
}
|
|
112
|
+
if (!Reflect.hasMetadata('logConfig', target.constructor)) {
|
|
113
|
+
Reflect.defineMetadata('logConfig', {}, target.constructor);
|
|
114
|
+
}
|
|
115
|
+
const logVar = Reflect.getMetadata('log', target.constructor);
|
|
116
|
+
logVar[propertyKey] = log;
|
|
117
|
+
const logConfig = Reflect.getMetadata('logConfig', target.constructor);
|
|
118
|
+
logConfig[propertyKey] = config;
|
|
119
|
+
Reflect.defineMetadata('log', logVar, target.constructor);
|
|
120
|
+
Reflect.defineMetadata('logConfig', logConfig, target.constructor);
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
exports.Log = Log;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kplian Ltda 2020
|
|
3
|
-
*
|
|
4
|
-
* MIT
|
|
5
|
-
*
|
|
6
|
-
* Interface used to validate params to send to typeorm entity
|
|
7
|
-
*
|
|
8
|
-
* @summary Interface used to validate params to send to typeorm entity
|
|
9
|
-
* @author Jaime Rivera
|
|
10
|
-
*
|
|
11
|
-
* Created at : 2020-06-13 18:09:48
|
|
12
|
-
* Last modified : 2020-09-17 18:26:44
|
|
13
|
-
*/
|
|
14
|
-
export interface ListParam {
|
|
15
|
-
where?: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
skip?: number;
|
|
19
|
-
take?: number;
|
|
20
|
-
order?: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Kplian Ltda 2020
|
|
3
|
+
*
|
|
4
|
+
* MIT
|
|
5
|
+
*
|
|
6
|
+
* Interface used to validate params to send to typeorm entity
|
|
7
|
+
*
|
|
8
|
+
* @summary Interface used to validate params to send to typeorm entity
|
|
9
|
+
* @author Jaime Rivera
|
|
10
|
+
*
|
|
11
|
+
* Created at : 2020-06-13 18:09:48
|
|
12
|
+
* Last modified : 2020-09-17 18:26:44
|
|
13
|
+
*/
|
|
14
|
+
export interface ListParam {
|
|
15
|
+
where?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
skip?: number;
|
|
19
|
+
take?: number;
|
|
20
|
+
order?: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kplian Ltda 2020
|
|
3
|
-
*
|
|
4
|
-
* MIT
|
|
5
|
-
*
|
|
6
|
-
* Error class and middlewares.
|
|
7
|
-
*
|
|
8
|
-
* @summary Here is defined Pxp error class, middleware and promise handler __.
|
|
9
|
-
* @author Jaime Rivera
|
|
10
|
-
*
|
|
11
|
-
* Created at : 2020-06-13 18:09:48
|
|
12
|
-
* Last modified : 2020-09-20 18:20:43
|
|
13
|
-
*/
|
|
14
|
-
import express from 'express';
|
|
15
|
-
declare class PxpError extends Error {
|
|
16
|
-
statusCode: number;
|
|
17
|
-
message: string;
|
|
18
|
-
tecMessage: string;
|
|
19
|
-
errorObject: undefined;
|
|
20
|
-
constructor(statusCode: number, message: string, errorObject?: undefined, stack?: undefined);
|
|
21
|
-
}
|
|
22
|
-
declare const __: (promise: Promise<any>, myShowError?: boolean) => Promise<any>;
|
|
23
|
-
declare const errorMiddleware: (err: PxpError, req: express.Request, res: any) => any;
|
|
24
|
-
export { PxpError, errorMiddleware, __ };
|
|
1
|
+
/**
|
|
2
|
+
* Kplian Ltda 2020
|
|
3
|
+
*
|
|
4
|
+
* MIT
|
|
5
|
+
*
|
|
6
|
+
* Error class and middlewares.
|
|
7
|
+
*
|
|
8
|
+
* @summary Here is defined Pxp error class, middleware and promise handler __.
|
|
9
|
+
* @author Jaime Rivera
|
|
10
|
+
*
|
|
11
|
+
* Created at : 2020-06-13 18:09:48
|
|
12
|
+
* Last modified : 2020-09-20 18:20:43
|
|
13
|
+
*/
|
|
14
|
+
import express from 'express';
|
|
15
|
+
declare class PxpError extends Error {
|
|
16
|
+
statusCode: number;
|
|
17
|
+
message: string;
|
|
18
|
+
tecMessage: string;
|
|
19
|
+
errorObject: undefined;
|
|
20
|
+
constructor(statusCode: number, message: string, errorObject?: undefined, stack?: undefined);
|
|
21
|
+
}
|
|
22
|
+
declare const __: (promise: Promise<any>, myShowError?: boolean) => Promise<any>;
|
|
23
|
+
declare const errorMiddleware: (err: PxpError, req: express.Request, res: any) => any;
|
|
24
|
+
export { PxpError, errorMiddleware, __ };
|
package/dist/lib/pxp/PxpError.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Kplian Ltda 2020
|
|
4
|
-
*
|
|
5
|
-
* MIT
|
|
6
|
-
*
|
|
7
|
-
* Error class and middlewares.
|
|
8
|
-
*
|
|
9
|
-
* @summary Here is defined Pxp error class, middleware and promise handler __.
|
|
10
|
-
* @author Jaime Rivera
|
|
11
|
-
*
|
|
12
|
-
* Created at : 2020-06-13 18:09:48
|
|
13
|
-
* Last modified : 2020-09-20 18:20:43
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.__ = exports.errorMiddleware = exports.PxpError = void 0;
|
|
17
|
-
const genericMessage = 'Web server error. Contact the administrator';
|
|
18
|
-
let showError = false;
|
|
19
|
-
class PxpError extends Error {
|
|
20
|
-
constructor(statusCode, message, errorObject, stack) {
|
|
21
|
-
super();
|
|
22
|
-
this.statusCode = statusCode;
|
|
23
|
-
this.message = statusCode === 500 ? genericMessage : message;
|
|
24
|
-
this.errorObject = errorObject;
|
|
25
|
-
this.tecMessage = message;
|
|
26
|
-
this.stack = stack || this.stack;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.PxpError = PxpError;
|
|
30
|
-
// Pxp async promise error handler
|
|
31
|
-
const __ = (promise, myShowError = false) => (promise
|
|
32
|
-
.then((data) => data)
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
showError = myShowError || showError;
|
|
35
|
-
if (error instanceof PxpError) {
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new PxpError(showError ? 406 : 500, error.message, undefined, error.stack);
|
|
40
|
-
}
|
|
41
|
-
}));
|
|
42
|
-
exports.__ = __;
|
|
43
|
-
// error handler middleware
|
|
44
|
-
const errorMiddleware = (err, req, res) => {
|
|
45
|
-
const { statusCode, message, stack, tecMessage, errorObject } = err;
|
|
46
|
-
const extraObj = process.env.NODE_ENV === 'production' ? {} : { extendedMessage: tecMessage, stack };
|
|
47
|
-
// @todo if production not show tecMessage and stack
|
|
48
|
-
return res.status(err.statusCode || 500).json({
|
|
49
|
-
error: Object.assign({
|
|
50
|
-
code: statusCode,
|
|
51
|
-
message,
|
|
52
|
-
logId: res.logId ? res.logId : undefined,
|
|
53
|
-
errorObject,
|
|
54
|
-
}, extraObj),
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
exports.errorMiddleware = errorMiddleware;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Kplian Ltda 2020
|
|
4
|
+
*
|
|
5
|
+
* MIT
|
|
6
|
+
*
|
|
7
|
+
* Error class and middlewares.
|
|
8
|
+
*
|
|
9
|
+
* @summary Here is defined Pxp error class, middleware and promise handler __.
|
|
10
|
+
* @author Jaime Rivera
|
|
11
|
+
*
|
|
12
|
+
* Created at : 2020-06-13 18:09:48
|
|
13
|
+
* Last modified : 2020-09-20 18:20:43
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.__ = exports.errorMiddleware = exports.PxpError = void 0;
|
|
17
|
+
const genericMessage = 'Web server error. Contact the administrator';
|
|
18
|
+
let showError = false;
|
|
19
|
+
class PxpError extends Error {
|
|
20
|
+
constructor(statusCode, message, errorObject, stack) {
|
|
21
|
+
super();
|
|
22
|
+
this.statusCode = statusCode;
|
|
23
|
+
this.message = statusCode === 500 ? genericMessage : message;
|
|
24
|
+
this.errorObject = errorObject;
|
|
25
|
+
this.tecMessage = message;
|
|
26
|
+
this.stack = stack || this.stack;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.PxpError = PxpError;
|
|
30
|
+
// Pxp async promise error handler
|
|
31
|
+
const __ = (promise, myShowError = false) => (promise
|
|
32
|
+
.then((data) => data)
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
showError = myShowError || showError;
|
|
35
|
+
if (error instanceof PxpError) {
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new PxpError(showError ? 406 : 500, error.message, undefined, error.stack);
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
exports.__ = __;
|
|
43
|
+
// error handler middleware
|
|
44
|
+
const errorMiddleware = (err, req, res) => {
|
|
45
|
+
const { statusCode, message, stack, tecMessage, errorObject } = err;
|
|
46
|
+
const extraObj = process.env.NODE_ENV === 'production' ? {} : { extendedMessage: tecMessage, stack };
|
|
47
|
+
// @todo if production not show tecMessage and stack
|
|
48
|
+
return res.status(err.statusCode || 500).json({
|
|
49
|
+
error: Object.assign({
|
|
50
|
+
code: statusCode,
|
|
51
|
+
message,
|
|
52
|
+
logId: res.logId ? res.logId : undefined,
|
|
53
|
+
errorObject,
|
|
54
|
+
}, extraObj),
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.errorMiddleware = errorMiddleware;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kplian Ltda 2020
|
|
3
|
-
*
|
|
4
|
-
* MIT
|
|
5
|
-
*
|
|
6
|
-
* Route definition interface
|
|
7
|
-
*
|
|
8
|
-
* @summary Route definition interface
|
|
9
|
-
* @author Jaime Rivera
|
|
10
|
-
*
|
|
11
|
-
* Created at : 2020-06-13 18:09:48
|
|
12
|
-
* Last modified : 2020-09-17 18:13:52
|
|
13
|
-
*/
|
|
14
|
-
export declare enum Method {
|
|
15
|
-
get = "get",
|
|
16
|
-
post = "post",
|
|
17
|
-
delete = "delete",
|
|
18
|
-
options = "options",
|
|
19
|
-
put = "put",
|
|
20
|
-
patch = "patch"
|
|
21
|
-
}
|
|
22
|
-
export interface RouteDefinition {
|
|
23
|
-
path: string;
|
|
24
|
-
requestMethod: Method;
|
|
25
|
-
methodName: string;
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Kplian Ltda 2020
|
|
3
|
+
*
|
|
4
|
+
* MIT
|
|
5
|
+
*
|
|
6
|
+
* Route definition interface
|
|
7
|
+
*
|
|
8
|
+
* @summary Route definition interface
|
|
9
|
+
* @author Jaime Rivera
|
|
10
|
+
*
|
|
11
|
+
* Created at : 2020-06-13 18:09:48
|
|
12
|
+
* Last modified : 2020-09-17 18:13:52
|
|
13
|
+
*/
|
|
14
|
+
export declare enum Method {
|
|
15
|
+
get = "get",
|
|
16
|
+
post = "post",
|
|
17
|
+
delete = "delete",
|
|
18
|
+
options = "options",
|
|
19
|
+
put = "put",
|
|
20
|
+
patch = "patch"
|
|
21
|
+
}
|
|
22
|
+
export interface RouteDefinition {
|
|
23
|
+
path: string;
|
|
24
|
+
requestMethod: Method;
|
|
25
|
+
methodName: string;
|
|
26
|
+
}
|