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.
@@ -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
- this.get = new ServiceRestFormal_1.default("GET", `${resource}`);
24
- this.getList = new ServiceRestFormal_1.default("GET", `${resource}/list`);
25
- this.getKeymap = new ServiceRestFormal_1.default("GET", `${resource}/keymap`);
26
- this.put = new ServiceRestFormal_1.default("PUT", `${resource}`);
27
- this.postList = new ServiceRestFormal_1.default("POST", `${resource}/list`);
28
- this.postKeymap = new ServiceRestFormal_1.default("POST", `${resource}/keymap`);
29
- this.post = new ServiceRestFormal_1.default("POST", `${resource}`);
30
- this.del = new ServiceRestFormal_1.default("DELETE", `${resource}`);
31
- this.page = new ServiceRestFormal_1.default("GET", `${resource}/page`);
32
- this.map = new ServiceRestFormal_1.default("GET", `${resource}/map`);
33
- this.select = new ServiceRestFormal_1.default("GET", `${resource}/select`);
34
- this.exist = new ServiceRestFormal_1.default("GET", `${resource}/exist`);
35
- this.count = new ServiceRestFormal_1.default("GET", `${resource}/count`);
36
- this.get.serveRestFormal = this.serveGet.bind(this);
37
- this.getList.serveRestFormal = this.serveGetList.bind(this);
38
- this.getKeymap.serveRestFormal = this.serveGetKeymap.bind(this);
39
- this.postList.serveRestFormal = this.servePostList.bind(this);
40
- this.postKeymap.serveRestFormal = this.servePostKeymap.bind(this);
41
- this.page.serveRestFormal = this.servePage.bind(this);
42
- this.map.serveRestFormal = this.serveMap.bind(this);
43
- this.select.serveRestFormal = this.serveSelect.bind(this);
44
- this.exist.serveRestFormal = this.serveExist.bind(this);
45
- this.count.serveRestFormal = this.serveCount.bind(this);
46
- this.post.serveRestFormal = this.servePost.bind(this);
47
- this.put.serveRestFormal = this.servePut.bind(this);
48
- this.del.serveRestFormal = this.serveDel.bind(this);
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,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.187",
3
+ "version": "0.4.189",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -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
- this.get = new ServiceRestFormal("GET", `${resource}`);
33
- this.getList = new ServiceRestFormal("GET", `${resource}/list`);
34
- this.getKeymap = new ServiceRestFormal("GET", `${resource}/keymap`);
35
-
36
- this.put = new ServiceRestFormal("PUT", `${resource}`);
37
- this.postList = new ServiceRestFormal("POST", `${resource}/list`);
38
- this.postKeymap = new ServiceRestFormal("POST", `${resource}/keymap`);
39
-
40
- this.post = new ServiceRestFormal("POST", `${resource}`);
41
- this.del = new ServiceRestFormal("DELETE", `${resource}`)
42
-
43
- this.page = new ServiceRestFormal("GET", `${resource}/page`);
44
- this.map = new ServiceRestFormal("GET", `${resource}/map`);
45
- this.select = new ServiceRestFormal("GET", `${resource}/select`);
46
- this.exist = new ServiceRestFormal("GET", `${resource}/exist`);
47
- this.count = new ServiceRestFormal("GET", `${resource}/count`);
48
-
49
- this.get.serveRestFormal = this.serveGet.bind(this);
50
- this.getList.serveRestFormal = this.serveGetList.bind(this);
51
- this.getKeymap.serveRestFormal = this.serveGetKeymap.bind(this);
52
- this.postList.serveRestFormal = this.servePostList.bind(this);
53
- this.postKeymap.serveRestFormal = this.servePostKeymap.bind(this);
54
- this.page.serveRestFormal = this.servePage.bind(this);
55
- this.map.serveRestFormal = this.serveMap.bind(this);
56
- this.select.serveRestFormal = this.serveSelect.bind(this);
57
- this.exist.serveRestFormal = this.serveExist.bind(this);
58
- this.count.serveRestFormal = this.serveCount.bind(this);
59
- this.post.serveRestFormal = this.servePost.bind(this);
60
- this.put.serveRestFormal = this.servePut.bind(this);
61
- this.del.serveRestFormal = this.serveDel.bind(this);
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