@obisey/nest 0.1.6 → 0.1.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/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/prototipos/baseController.js +3 -6
- package/prototipos/baseResolver.js +40 -20
- package/prototipos/baseService.js +5 -8
- package/prototipos/utils/cachear.js +3 -3
package/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export * from './prototipos/utils/activarRedis';
|
|
|
9
9
|
export * from './prototipos/utils/formarInclude';
|
|
10
10
|
export * from './prototipos/utils/formarorder';
|
|
11
11
|
export * from './prototipos/utils/formarwhere';
|
|
12
|
+
export * from './redisStore';
|
|
12
13
|
export * from './types';
|
|
13
14
|
export * from './fecha';
|
package/index.js
CHANGED
|
@@ -26,5 +26,6 @@ __exportStar(require("./prototipos/utils/activarRedis"), exports);
|
|
|
26
26
|
__exportStar(require("./prototipos/utils/formarInclude"), exports);
|
|
27
27
|
__exportStar(require("./prototipos/utils/formarorder"), exports);
|
|
28
28
|
__exportStar(require("./prototipos/utils/formarwhere"), exports);
|
|
29
|
+
__exportStar(require("./redisStore"), exports);
|
|
29
30
|
__exportStar(require("./types"), exports);
|
|
30
31
|
__exportStar(require("./fecha"), exports);
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// const chalk = require('chalk');
|
|
3
|
+
// const log = console.log;
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.BaseController = BaseController;
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const log = console.log;
|
|
6
|
-
var imprimir = (texto) => {
|
|
7
|
-
//log(chalk.yellow(texto))
|
|
8
|
-
};
|
|
9
6
|
const keyInterface_1 = require("./utils/keyInterface");
|
|
10
7
|
const activarRedis_1 = require("./utils/activarRedis");
|
|
11
8
|
function BaseController(modelo) {
|
|
@@ -40,7 +37,7 @@ function BaseController(modelo) {
|
|
|
40
37
|
resultado = JSON.parse(datos);
|
|
41
38
|
}
|
|
42
39
|
else {
|
|
43
|
-
imprimir(`${modelo} ${nombre}`);
|
|
40
|
+
// imprimir(`${modelo} ${nombre}`);
|
|
44
41
|
let temp = null;
|
|
45
42
|
if (tipo === 'DINAMICO')
|
|
46
43
|
temp = {
|
|
@@ -37,11 +37,11 @@ exports.BaseResolver = BaseResolver;
|
|
|
37
37
|
const lodash_1 = require("lodash");
|
|
38
38
|
const keyInterface_1 = require("./utils/keyInterface");
|
|
39
39
|
const formarwhere_1 = require("./utils/formarwhere");
|
|
40
|
-
const chalk = require('chalk');
|
|
41
|
-
const log = console.log;
|
|
42
|
-
var imprimir = (texto) => {
|
|
43
|
-
|
|
44
|
-
};
|
|
40
|
+
// const chalk = require('chalk');
|
|
41
|
+
// const log = console.log;
|
|
42
|
+
// var imprimir = (texto) => {
|
|
43
|
+
// log(chalk.green(texto));
|
|
44
|
+
// };
|
|
45
45
|
var tiempo = 86400000;
|
|
46
46
|
var isDev = false;
|
|
47
47
|
const redisStore_1 = require("../redisStore");
|
|
@@ -68,7 +68,9 @@ function BaseResolver(modelo) {
|
|
|
68
68
|
relacion: 'belongsTo',
|
|
69
69
|
}, pagina),
|
|
70
70
|
query: async (servicio, IdModelo, Clase) => {
|
|
71
|
-
imprimir(
|
|
71
|
+
// imprimir(
|
|
72
|
+
// `${modelo} ${IdModelo} belongsTo query ${planeta}`,
|
|
73
|
+
// );
|
|
72
74
|
return servicio
|
|
73
75
|
.findByPk(IdModelo, pagina)
|
|
74
76
|
.then((item) => item.$get(planeta));
|
|
@@ -110,7 +112,7 @@ function BaseResolver(modelo) {
|
|
|
110
112
|
}, pagina);
|
|
111
113
|
},
|
|
112
114
|
query: async (servicio, IdModelo, Clase) => {
|
|
113
|
-
imprimir(`${modelo} ${IdModelo} hasOne query ${planeta}`);
|
|
115
|
+
// imprimir(`${modelo} ${IdModelo} hasOne query ${planeta}`);
|
|
114
116
|
return servicio
|
|
115
117
|
.findByPk(IdModelo, pagina)
|
|
116
118
|
.then((item) => item.$get(planeta));
|
|
@@ -153,7 +155,9 @@ function BaseResolver(modelo) {
|
|
|
153
155
|
relacion: 'hasManyBelongsToMany',
|
|
154
156
|
}, pagina),
|
|
155
157
|
query: async (servicio, IdModelo, Clase) => {
|
|
156
|
-
imprimir(
|
|
158
|
+
// imprimir(
|
|
159
|
+
// `${modelo} ${IdModelo} hasManyBelongsToMany query ${planeta}`,
|
|
160
|
+
// );
|
|
157
161
|
return servicio
|
|
158
162
|
.findByPk(IdModelo, pagina)
|
|
159
163
|
.then((item) => item.$get(planeta));
|
|
@@ -196,7 +200,7 @@ function BaseResolver(modelo) {
|
|
|
196
200
|
relacion: 'nodo',
|
|
197
201
|
}, pagina),
|
|
198
202
|
query: async (servicio, IdModelo, Clase) => {
|
|
199
|
-
imprimir(`${modelo} ${IdModelo} nodo query ${planeta}`);
|
|
203
|
+
// imprimir(`${modelo} ${IdModelo} nodo query ${planeta}`);
|
|
200
204
|
return servicio
|
|
201
205
|
.findByPk(IdModelo, pagina)
|
|
202
206
|
.then((item) => item.$get(planeta));
|
|
@@ -239,7 +243,7 @@ function BaseResolver(modelo) {
|
|
|
239
243
|
relacion: 'especial',
|
|
240
244
|
}, pagina),
|
|
241
245
|
query: async (servicio, IdModelo, Clase) => {
|
|
242
|
-
imprimir(`${modelo} ${IdModelo} especial query ${planeta}`);
|
|
246
|
+
// imprimir(`${modelo} ${IdModelo} especial query ${planeta}`);
|
|
243
247
|
return servicio
|
|
244
248
|
.findByPk(IdModelo, pagina)
|
|
245
249
|
.then((item) => item.$get(planeta));
|
|
@@ -285,7 +289,9 @@ function BaseResolver(modelo) {
|
|
|
285
289
|
relacion: 'recursiva',
|
|
286
290
|
}, pagina),
|
|
287
291
|
preQuery: async (servicio, IdModelo, Clase) => {
|
|
288
|
-
imprimir(
|
|
292
|
+
// imprimir(
|
|
293
|
+
// `${modelo} ${IdModelo} recursiva query ${planeta}`,
|
|
294
|
+
// );
|
|
289
295
|
return servicio
|
|
290
296
|
.findByPk(IdModelo, pagina)
|
|
291
297
|
.then((item) => item.$get(planeta));
|
|
@@ -302,16 +308,22 @@ function BaseResolver(modelo) {
|
|
|
302
308
|
relacion: 'recursiva',
|
|
303
309
|
}, pagina),
|
|
304
310
|
subQuery: async (servicio, IdModelo, Clase) => {
|
|
305
|
-
imprimir(
|
|
311
|
+
// imprimir(
|
|
312
|
+
// `${modelo} ${IdModelo} recursiva query ${planeta}`,
|
|
313
|
+
// );
|
|
306
314
|
return servicio
|
|
307
315
|
.findByPk(IdModelo, pagina)
|
|
308
316
|
.then((item) => item.$get(planeta));
|
|
309
317
|
},
|
|
310
318
|
ligar: async (IdModelo, IdPlaneta, borrarSSR) => {
|
|
311
|
-
imprimir(
|
|
319
|
+
// imprimir(
|
|
320
|
+
// `${modelo} ${IdModelo} ligar ligar ${planeta} ${IdPlaneta}`,
|
|
321
|
+
// );
|
|
312
322
|
},
|
|
313
323
|
desligar: async (IdModelo, IdPlaneta, borrarSSR) => {
|
|
314
|
-
imprimir(
|
|
324
|
+
// imprimir(
|
|
325
|
+
// `${modelo} ${IdModelo} desligar desligar ${planeta} ${IdPlaneta}`,
|
|
326
|
+
// );
|
|
315
327
|
},
|
|
316
328
|
};
|
|
317
329
|
}
|
|
@@ -448,7 +460,7 @@ function BaseResolver(modelo) {
|
|
|
448
460
|
}
|
|
449
461
|
catch (err) {
|
|
450
462
|
console.log(err);
|
|
451
|
-
log(chalk.red('uno', { modelo, err }, '***********'));
|
|
463
|
+
// log(chalk.red('uno', { modelo, err }, '***********'));
|
|
452
464
|
}
|
|
453
465
|
}
|
|
454
466
|
async muchos({ universo, IdEmpresa, planeta, item, cacheable, where, Clase, tipo, relacion, }, pagina = null) {
|
|
@@ -512,7 +524,7 @@ function BaseResolver(modelo) {
|
|
|
512
524
|
}
|
|
513
525
|
catch (err) {
|
|
514
526
|
console.log(err);
|
|
515
|
-
log(chalk.red('muchos', { modelo, err }, '***********'));
|
|
527
|
+
// log(chalk.red('muchos', { modelo, err }, '***********'));
|
|
516
528
|
}
|
|
517
529
|
}
|
|
518
530
|
async ligar({ universo, servicio, alias, IdPlaneta, IdModelo, tipo, planeta, through, borrarSSR, }) {
|
|
@@ -538,7 +550,7 @@ function BaseResolver(modelo) {
|
|
|
538
550
|
})
|
|
539
551
|
.then((response) => true)
|
|
540
552
|
.catch((err) => {
|
|
541
|
-
log(chalk.red('ligar', alias, err, '***********'));
|
|
553
|
+
// log(chalk.red('ligar', alias, err, '***********'));
|
|
542
554
|
return false;
|
|
543
555
|
});
|
|
544
556
|
}
|
|
@@ -554,7 +566,9 @@ function BaseResolver(modelo) {
|
|
|
554
566
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:${id}`,
|
|
555
567
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:paginacion`,
|
|
556
568
|
];
|
|
557
|
-
imprimir(
|
|
569
|
+
// imprimir(
|
|
570
|
+
// `${modelo} ${IdModelo} ${tipo} desligar ${planeta} ${IdPlaneta}`,
|
|
571
|
+
// );
|
|
558
572
|
return this.eliminarCache([
|
|
559
573
|
...crearKey(modelo, IdModelo),
|
|
560
574
|
...crearKey(planeta, IdPlaneta),
|
|
@@ -563,14 +577,20 @@ function BaseResolver(modelo) {
|
|
|
563
577
|
.then((item) => item.$remove(alias, IdPlaneta))
|
|
564
578
|
.then(() => true)
|
|
565
579
|
.catch((err) => {
|
|
566
|
-
log(chalk.red('desligar', alias, err, '***********'));
|
|
580
|
+
// log(chalk.red('desligar', alias, err, '***********'));
|
|
567
581
|
return false;
|
|
568
582
|
});
|
|
569
583
|
}
|
|
570
584
|
async eliminarCache(items, borrarSSR = false) {
|
|
571
585
|
if (borrarSSR)
|
|
572
586
|
redisStore_1.clientSsr.flushdb();
|
|
573
|
-
log(
|
|
587
|
+
// log(
|
|
588
|
+
// chalk.red(
|
|
589
|
+
// 'SE ELIMINOOOO ALGOOO!!!!!!!!!!!!!!',
|
|
590
|
+
// items,
|
|
591
|
+
// borrarSSR,
|
|
592
|
+
// ),
|
|
593
|
+
// );
|
|
574
594
|
return Promise.all(items.map(async (item) => this.cacheManager
|
|
575
595
|
.keys(`*${item}*`)
|
|
576
596
|
.then((keys) => Promise.all(keys.map((key) => this.cacheManager.del(key))))));
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// const chalk = require('chalk');
|
|
3
|
+
// const log = console.log;
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.redis_on = void 0;
|
|
4
6
|
exports.BaseService = BaseService;
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const log = console.log;
|
|
7
|
-
var imprimir = (texto) => {
|
|
8
|
-
// log(chalk.blue(texto))
|
|
9
|
-
};
|
|
10
7
|
const lodash_1 = require("lodash");
|
|
11
8
|
const cachear_1 = require("./utils/cachear");
|
|
12
9
|
const cifrado_1 = require("./utils/cifrado");
|
|
@@ -316,7 +313,7 @@ function BaseService(modelo) {
|
|
|
316
313
|
reescribir({ value, options, repository }) {
|
|
317
314
|
return new Promise(async (resolve, reject) => {
|
|
318
315
|
try {
|
|
319
|
-
imprimir(`${modelo} ${value.id} reescribir`);
|
|
316
|
+
// imprimir(`${modelo} ${value.id} reescribir`);
|
|
320
317
|
let resultado = await repository.upsert(value, options);
|
|
321
318
|
resolve(resultado);
|
|
322
319
|
}
|
|
@@ -328,7 +325,7 @@ function BaseService(modelo) {
|
|
|
328
325
|
destruir({ value, repository, borrarSSR, }) {
|
|
329
326
|
return new Promise(async (resolve, reject) => {
|
|
330
327
|
try {
|
|
331
|
-
imprimir(`${modelo} ${value.id} destruir`);
|
|
328
|
+
// imprimir(`${modelo} ${value.id} destruir`);
|
|
332
329
|
let resultado = await repository.destroy(value);
|
|
333
330
|
this.cacheManager
|
|
334
331
|
.keys(`*:${modelo}*`) //Obten todos los keys
|
|
@@ -372,7 +369,7 @@ function BaseService(modelo) {
|
|
|
372
369
|
buscarOcrear({ value, repository }) {
|
|
373
370
|
return new Promise(async (resolve, reject) => {
|
|
374
371
|
try {
|
|
375
|
-
imprimir(`${modelo} buscarOcrear`);
|
|
372
|
+
// imprimir(`${modelo} buscarOcrear`);
|
|
376
373
|
let resultado = await repository.findOrCreate(value);
|
|
377
374
|
resolve(resultado);
|
|
378
375
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cachear = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const log = console.log;
|
|
7
|
-
var imprimir = (texto) => log(chalk.blue(texto));
|
|
5
|
+
// const chalk = require('chalk');
|
|
6
|
+
// const log = console.log;
|
|
7
|
+
// var imprimir = (texto) => log(chalk.blue(texto));
|
|
8
8
|
var tiempo = 86400000;
|
|
9
9
|
const cachear = (cacheable, cacheManager, key, revisar, transformar, pedir, observar = (key) => cacheManager.get(key), actualizar = (key, datos) => cacheManager.set(key, datos, 'EX', tiempo)) => {
|
|
10
10
|
return new Promise(async (resolve) => {
|