ismx-nexo-node-app 0.4.187 → 0.4.189
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/dist/js/api/ServiceRestFormalTemplate.js +52 -27
- package/dist/js/business/BusinessServer.js +1 -0
- package/dist/types/api/ServiceRestFormalTemplate.d.ts +2 -2
- package/package.json +1 -1
- package/src/main/node/api/ServiceRestFormalTemplate.ts +65 -32
- package/src/main/node/business/BusinessServer.ts +1 -0
|
@@ -15,37 +15,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const Service_1 = require("./Service");
|
|
16
16
|
const ServiceRestFormal_1 = __importDefault(require("./ServiceRestFormal"));
|
|
17
17
|
class ServiceRestFormalTemplate {
|
|
18
|
-
constructor(resource, database, tableName) {
|
|
18
|
+
constructor(resource, database, tableName, options = {}) {
|
|
19
19
|
this.indexer = "id";
|
|
20
20
|
this.resource = resource;
|
|
21
21
|
this.database = database;
|
|
22
22
|
this.tableName = tableName;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
23
|
+
if (options.get !== '404') {
|
|
24
|
+
this.get = new ServiceRestFormal_1.default("GET", `${resource}`, options.get);
|
|
25
|
+
this.get.serveRestFormal = this.serveGet.bind(this);
|
|
26
|
+
}
|
|
27
|
+
if (options.getList !== '404') {
|
|
28
|
+
this.getList = new ServiceRestFormal_1.default("GET", `${resource}/list`, options.getList);
|
|
29
|
+
this.getList.serveRestFormal = this.serveGetList.bind(this);
|
|
30
|
+
}
|
|
31
|
+
if (options.getKeymap !== '404') {
|
|
32
|
+
this.getKeymap = new ServiceRestFormal_1.default("GET", `${resource}/keymap`, options.getKeymap);
|
|
33
|
+
this.getKeymap.serveRestFormal = this.serveGetKeymap.bind(this);
|
|
34
|
+
}
|
|
35
|
+
if (options.put !== '404') {
|
|
36
|
+
this.put = new ServiceRestFormal_1.default("PUT", `${resource}`, options.put);
|
|
37
|
+
this.put.serveRestFormal = this.servePut.bind(this);
|
|
38
|
+
}
|
|
39
|
+
if (options.postList !== '404') {
|
|
40
|
+
this.postList = new ServiceRestFormal_1.default("POST", `${resource}/list`, options.postList);
|
|
41
|
+
this.postList.serveRestFormal = this.servePostList.bind(this);
|
|
42
|
+
}
|
|
43
|
+
if (options.postKeymap !== '404') {
|
|
44
|
+
this.postKeymap = new ServiceRestFormal_1.default("POST", `${resource}/keymap`, options.postKeymap);
|
|
45
|
+
this.postKeymap.serveRestFormal = this.servePostKeymap.bind(this);
|
|
46
|
+
}
|
|
47
|
+
if (options.post !== '404') {
|
|
48
|
+
this.post = new ServiceRestFormal_1.default("POST", `${resource}`, options.post);
|
|
49
|
+
this.post.serveRestFormal = this.servePost.bind(this);
|
|
50
|
+
}
|
|
51
|
+
if (options.del !== '404') {
|
|
52
|
+
this.del = new ServiceRestFormal_1.default("DELETE", `${resource}`, options.del);
|
|
53
|
+
this.del.serveRestFormal = this.serveDel.bind(this);
|
|
54
|
+
}
|
|
55
|
+
if (options.page !== '404') {
|
|
56
|
+
this.page = new ServiceRestFormal_1.default("GET", `${resource}/page`, options.page);
|
|
57
|
+
this.page.serveRestFormal = this.servePage.bind(this);
|
|
58
|
+
}
|
|
59
|
+
if (options.map !== '404') {
|
|
60
|
+
this.map = new ServiceRestFormal_1.default("GET", `${resource}/map`, options.map);
|
|
61
|
+
this.map.serveRestFormal = this.serveMap.bind(this);
|
|
62
|
+
}
|
|
63
|
+
if (options.select !== '404') {
|
|
64
|
+
this.select = new ServiceRestFormal_1.default("GET", `${resource}/select`, options.select);
|
|
65
|
+
this.select.serveRestFormal = this.serveSelect.bind(this);
|
|
66
|
+
}
|
|
67
|
+
if (options.exist !== '404') {
|
|
68
|
+
this.exist = new ServiceRestFormal_1.default("GET", `${resource}/exist`, options.exist);
|
|
69
|
+
}
|
|
70
|
+
if (options.count !== '404') {
|
|
71
|
+
this.count = new ServiceRestFormal_1.default("GET", `${resource}/count`, options.count);
|
|
72
|
+
this.count.serveRestFormal = this.serveCount.bind(this);
|
|
73
|
+
}
|
|
49
74
|
}
|
|
50
75
|
getFormalId(request) {
|
|
51
76
|
var _a;
|
|
@@ -130,6 +130,7 @@ class BusinessServer extends Business_1.default {
|
|
|
130
130
|
// Asigna un valor único a la llamada de la API.
|
|
131
131
|
request.id = Math.ceil(Math.random() * 1000000).toString();
|
|
132
132
|
request.timestamp = new Date();
|
|
133
|
+
request.multipart = request.files;
|
|
133
134
|
let indexParams = request.url.indexOf('?');
|
|
134
135
|
let endpoint = indexParams > 0 ? request.url.substring(0, indexParams) : request.url;
|
|
135
136
|
request.endpoint = !!endpoint ? endpoint : "/";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRequest, HttpResponse } from "./Service";
|
|
1
|
+
import { HttpRequest, HttpResponse, ServiceType } from "./Service";
|
|
2
2
|
import ServiceRestFormal from "./ServiceRestFormal";
|
|
3
3
|
import { Pagination, Transient } from "../repository/Repository";
|
|
4
4
|
import RepositoryDatabase from "../repository/RepositoryDatabase";
|
|
@@ -27,7 +27,7 @@ export default class ServiceRestFormalTemplate<Model = any> {
|
|
|
27
27
|
readonly map: ServiceRestFormal<any, {
|
|
28
28
|
[key: string]: Model;
|
|
29
29
|
}>;
|
|
30
|
-
constructor(resource: string, database: RepositoryDatabase, tableName: string);
|
|
30
|
+
constructor(resource: string, database: RepositoryDatabase, tableName: string, options?: Partial<Record<keyof ServiceRestFormalTemplate, (ServiceType | "404")>>);
|
|
31
31
|
protected indexer: string;
|
|
32
32
|
getFormalId(request: HttpRequest): string;
|
|
33
33
|
getFormalPage(request: HttpRequest): {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {HttpRequest, HttpResponse} from "./Service";
|
|
1
|
+
import {HttpRequest, HttpResponse, ServiceType} from "./Service";
|
|
2
2
|
import ServiceRestFormal, {Wrapper} from "./ServiceRestFormal";
|
|
3
3
|
import {Pagination, Transient} from "../repository/Repository";
|
|
4
4
|
import RepositoryDatabase from "../repository/RepositoryDatabase";
|
|
@@ -24,41 +24,74 @@ export default class ServiceRestFormalTemplate<Model=any>
|
|
|
24
24
|
readonly page!: ServiceRestFormal<any, Pagination<Model>>;
|
|
25
25
|
readonly map!: ServiceRestFormal<any, { [key:string]: Model }>;
|
|
26
26
|
|
|
27
|
-
constructor(resource: string, database: RepositoryDatabase, tableName: string) {
|
|
27
|
+
constructor(resource: string, database: RepositoryDatabase, tableName: string, options: Partial<Record<keyof ServiceRestFormalTemplate, (ServiceType | "404")>> = {}) {
|
|
28
28
|
this.resource = resource;
|
|
29
29
|
this.database = database;
|
|
30
30
|
this.tableName = tableName;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
32
|
+
if (options.get !== '404') {
|
|
33
|
+
this.get = new ServiceRestFormal("GET", `${resource}`, options.get);
|
|
34
|
+
this.get.serveRestFormal = this.serveGet.bind(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (options.getList !== '404') {
|
|
38
|
+
this.getList = new ServiceRestFormal("GET", `${resource}/list`, options.getList);
|
|
39
|
+
this.getList.serveRestFormal = this.serveGetList.bind(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.getKeymap !== '404') {
|
|
43
|
+
this.getKeymap = new ServiceRestFormal("GET", `${resource}/keymap`, options.getKeymap);
|
|
44
|
+
this.getKeymap.serveRestFormal = this.serveGetKeymap.bind(this);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (options.put !== '404') {
|
|
48
|
+
this.put = new ServiceRestFormal("PUT", `${resource}`, options.put);
|
|
49
|
+
this.put.serveRestFormal = this.servePut.bind(this);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (options.postList !== '404') {
|
|
53
|
+
this.postList = new ServiceRestFormal("POST", `${resource}/list`, options.postList);
|
|
54
|
+
this.postList.serveRestFormal = this.servePostList.bind(this);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (options.postKeymap !== '404') {
|
|
58
|
+
this.postKeymap = new ServiceRestFormal("POST", `${resource}/keymap`, options.postKeymap);
|
|
59
|
+
this.postKeymap.serveRestFormal = this.servePostKeymap.bind(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (options.post !== '404') {
|
|
63
|
+
this.post = new ServiceRestFormal("POST", `${resource}`, options.post);
|
|
64
|
+
this.post.serveRestFormal = this.servePost.bind(this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (options.del !== '404') {
|
|
68
|
+
this.del = new ServiceRestFormal("DELETE", `${resource}`, options.del)
|
|
69
|
+
this.del.serveRestFormal = this.serveDel.bind(this);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (options.page !== '404') {
|
|
73
|
+
this.page = new ServiceRestFormal("GET", `${resource}/page`, options.page);
|
|
74
|
+
this.page.serveRestFormal = this.servePage.bind(this);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (options.map !== '404') {
|
|
78
|
+
this.map = new ServiceRestFormal("GET", `${resource}/map`, options.map);
|
|
79
|
+
this.map.serveRestFormal = this.serveMap.bind(this);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (options.select !== '404') {
|
|
83
|
+
this.select = new ServiceRestFormal("GET", `${resource}/select`, options.select);
|
|
84
|
+
this.select.serveRestFormal = this.serveSelect.bind(this);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (options.exist !== '404') {
|
|
88
|
+
this.exist = new ServiceRestFormal("GET", `${resource}/exist`, options.exist);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (options.count !== '404') {
|
|
92
|
+
this.count = new ServiceRestFormal("GET", `${resource}/count`, options.count);
|
|
93
|
+
this.count.serveRestFormal = this.serveCount.bind(this);
|
|
94
|
+
}
|
|
62
95
|
}
|
|
63
96
|
|
|
64
97
|
protected indexer = "id"
|
|
@@ -108,6 +108,7 @@ export default class BusinessServer extends Business
|
|
|
108
108
|
// Asigna un valor único a la llamada de la API.
|
|
109
109
|
request.id = Math.ceil(Math.random() * 1000000).toString();
|
|
110
110
|
request.timestamp = new Date();
|
|
111
|
+
request.multipart = request.files;
|
|
111
112
|
|
|
112
113
|
let indexParams = request.url.indexOf('?');
|
|
113
114
|
let endpoint = indexParams > 0 ? request.url.substring(0,indexParams) : request.url
|