@obisey/nest 0.1.5 → 0.1.7
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 -2
- package/prototipos/baseResolver.d.ts +1 -4
- package/prototipos/baseResolver.js +55 -42
- package/prototipos/baseService.d.ts +1 -3
- package/prototipos/baseService.js +79 -44
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obisey/nest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "NestJS utilities and base classes by Obisey",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"@nestjs/common": "^10.3.3",
|
|
31
31
|
"@nestjs/core": "^10.3.3",
|
|
32
32
|
"@nestjs/graphql": "^12.1.1",
|
|
33
|
-
"@types/moment": "^2.11.29",
|
|
34
33
|
"cache-manager": "^7.0.0",
|
|
35
34
|
"cache-manager-redis-store": "^3.0.1",
|
|
36
35
|
"graphql": "^16.11.0",
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { ReceptorService } from '../receptor';
|
|
2
1
|
export declare function BaseResolver(modelo: string): {
|
|
3
2
|
new <T extends {
|
|
4
3
|
cacheManager: any;
|
|
5
|
-
receptor: ReceptorService;
|
|
6
4
|
belongsTo(universo: any, planeta: any, IdEmpresa: any, pagina?: any): {
|
|
7
5
|
resolvefield: (item: any, where: any, cacheable: any, Clase: any) => Promise<any>;
|
|
8
6
|
query: (servicio: any, IdModelo: any, Clase: any) => Promise<any>;
|
|
@@ -91,9 +89,8 @@ export declare function BaseResolver(modelo: string): {
|
|
|
91
89
|
}): Promise<boolean>;
|
|
92
90
|
eliminarCache(items: string[], borrarSSR?: boolean): Promise<any[]>;
|
|
93
91
|
arbol(universo: any, IdEmpresa: any, planeta: any, servicio: any, Clase: any, subnombre: any, IdPlaneta: any): Promise<any>;
|
|
94
|
-
}>(cacheManager: any
|
|
92
|
+
}>(cacheManager: any): {
|
|
95
93
|
cacheManager: any;
|
|
96
|
-
receptor: ReceptorService;
|
|
97
94
|
belongsTo(universo: any, planeta: any, IdEmpresa: any, pagina?: any): {
|
|
98
95
|
resolvefield: (item: any, where: any, cacheable: any, Clase: any) => Promise<any>;
|
|
99
96
|
query: (servicio: any, IdModelo: any, Clase: any) => Promise<any>;
|
|
@@ -50,9 +50,8 @@ const paginar_1 = require("./utils/paginar");
|
|
|
50
50
|
const _ = __importStar(require("lodash"));
|
|
51
51
|
function BaseResolver(modelo) {
|
|
52
52
|
return class BaseResolver {
|
|
53
|
-
constructor(cacheManager
|
|
53
|
+
constructor(cacheManager) {
|
|
54
54
|
this.cacheManager = cacheManager;
|
|
55
|
-
this.receptor = receptor;
|
|
56
55
|
}
|
|
57
56
|
belongsTo(universo, planeta, IdEmpresa, pagina = null) {
|
|
58
57
|
// 1
|
|
@@ -75,7 +74,6 @@ function BaseResolver(modelo) {
|
|
|
75
74
|
.then((item) => item.$get(planeta));
|
|
76
75
|
},
|
|
77
76
|
ligar: async (servicio, alias, objeto, peticion, borrarSSR = false) => {
|
|
78
|
-
console.log({ alias, modelo, planeta, peticion });
|
|
79
77
|
return this.eliminarCache([
|
|
80
78
|
`${modelo}:${peticion.where.id}`,
|
|
81
79
|
`${alias}:${objeto[`Id${(0, lodash_1.capitalize)(alias)}`]}`,
|
|
@@ -99,7 +97,6 @@ function BaseResolver(modelo) {
|
|
|
99
97
|
// 3
|
|
100
98
|
return {
|
|
101
99
|
resolvefield: async (item, where, cacheable, Clase) => {
|
|
102
|
-
console.log('hasOne');
|
|
103
100
|
return this.uno({
|
|
104
101
|
universo,
|
|
105
102
|
IdEmpresa,
|
|
@@ -321,17 +318,18 @@ function BaseResolver(modelo) {
|
|
|
321
318
|
async basesucesores(universo, IdEmpresa, servicio, item, singular, plural, clase) {
|
|
322
319
|
// console.log('me estoy ejecutando')
|
|
323
320
|
async function detective(item) {
|
|
324
|
-
console.log('item', item.nombre);
|
|
325
321
|
return await item
|
|
326
322
|
.$get(`sub${plural}`)
|
|
327
323
|
.then(async (items) => Promise.all(items.map(async (item) => await detective(item))))
|
|
328
324
|
.then((items) => [...items, item.id]);
|
|
329
325
|
}
|
|
330
326
|
try {
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
327
|
+
// if (
|
|
328
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
329
|
+
// !IdEmpresa
|
|
330
|
+
// ) {
|
|
331
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
332
|
+
// }
|
|
335
333
|
const key = `${universo ? universo : 'pro'}:${IdEmpresa}:${singular}:${item}`;
|
|
336
334
|
const exist = await this.cacheManager.store.hexists(key, 'item');
|
|
337
335
|
console.log('key:', key);
|
|
@@ -363,10 +361,12 @@ function BaseResolver(modelo) {
|
|
|
363
361
|
: array;
|
|
364
362
|
}
|
|
365
363
|
try {
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
364
|
+
// if (
|
|
365
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
366
|
+
// !IdEmpresa
|
|
367
|
+
// ) {
|
|
368
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
369
|
+
// }
|
|
370
370
|
const key = `${universo ? universo : 'pro'}:${IdEmpresa}:${singular}:${item}`;
|
|
371
371
|
const exist = await this.cacheManager.store.hexists(key, 'item');
|
|
372
372
|
if (exist) {
|
|
@@ -390,10 +390,12 @@ function BaseResolver(modelo) {
|
|
|
390
390
|
let tiempo;
|
|
391
391
|
// if (isDev) tiempo = moment();
|
|
392
392
|
try {
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
// if (
|
|
394
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
395
|
+
// !IdEmpresa
|
|
396
|
+
// ) {
|
|
397
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
398
|
+
// }
|
|
397
399
|
let nkey = `${universo ? universo : 'pro'}:${IdEmpresa}:${modelo}:${item.id}`;
|
|
398
400
|
const { resultado, cache } = await (0, cachear_1.cachear)(cacheable, this.cacheManager, (0, keyInterface_1.transformarKey)({
|
|
399
401
|
universo,
|
|
@@ -436,10 +438,12 @@ function BaseResolver(modelo) {
|
|
|
436
438
|
});
|
|
437
439
|
if (resultado)
|
|
438
440
|
await (0, paginar_1.paginar)(this.cacheManager, IdEmpresa, pagina, planeta, resultado.get({ plain: true }));
|
|
439
|
-
if (isDev)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
// if (isDev)
|
|
442
|
+
// console.log(
|
|
443
|
+
// // moment().diff(moment(tiempo), 'milliseconds', true),
|
|
444
|
+
// 'uno',
|
|
445
|
+
// cache,
|
|
446
|
+
// );
|
|
443
447
|
return resultado;
|
|
444
448
|
}
|
|
445
449
|
catch (err) {
|
|
@@ -451,10 +455,12 @@ function BaseResolver(modelo) {
|
|
|
451
455
|
let tiempo;
|
|
452
456
|
// if (isDev) tiempo = moment();
|
|
453
457
|
try {
|
|
454
|
-
if (
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
+
// if (
|
|
459
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
460
|
+
// !IdEmpresa
|
|
461
|
+
// ) {
|
|
462
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
463
|
+
// }
|
|
458
464
|
let nkey = `${universo ? universo : 'pro'}:${IdEmpresa}:${modelo}:${item.id}`;
|
|
459
465
|
let pkey = (id) => `${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:${id}`;
|
|
460
466
|
const { resultado, cache } = await (0, cachear_1.cachear)(cacheable, this.cacheManager, (0, keyInterface_1.transformarKey)({
|
|
@@ -496,10 +502,12 @@ function BaseResolver(modelo) {
|
|
|
496
502
|
return Promise.all(resultado.map((n) => this.cacheManager.store.hset(pkey(n.id), 'item', JSON.stringify(n)))).then(() => this.cacheManager.store.hset(nkey, planeta, JSON.stringify(resultado.map((n) => n.id))));
|
|
497
503
|
});
|
|
498
504
|
await (0, paginar_1.paginar)(this.cacheManager, IdEmpresa, pagina, planeta, resultado.map((n) => n.get({ plain: true })));
|
|
499
|
-
if (isDev)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
505
|
+
// if (isDev)
|
|
506
|
+
// console.log(
|
|
507
|
+
// // moment().diff(moment(tiempo), 'milliseconds', true),
|
|
508
|
+
// 'muchos',
|
|
509
|
+
// cache,
|
|
510
|
+
// );
|
|
503
511
|
return resultado ? resultado : [];
|
|
504
512
|
}
|
|
505
513
|
catch (err) {
|
|
@@ -509,10 +517,12 @@ function BaseResolver(modelo) {
|
|
|
509
517
|
}
|
|
510
518
|
async ligar({ universo, servicio, alias, IdPlaneta, IdModelo, tipo, planeta, through, borrarSSR, }) {
|
|
511
519
|
let IdEmpresa = null;
|
|
512
|
-
if (
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
520
|
+
// if (
|
|
521
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
522
|
+
// !IdEmpresa
|
|
523
|
+
// ) {
|
|
524
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
525
|
+
// }
|
|
516
526
|
let crearKey = (planeta, id) => [
|
|
517
527
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:${id}`,
|
|
518
528
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:paginacion`,
|
|
@@ -534,15 +544,16 @@ function BaseResolver(modelo) {
|
|
|
534
544
|
}
|
|
535
545
|
async desligar({ universo, servicio, alias, IdPlaneta, IdModelo, tipo, planeta, borrarSSR, }) {
|
|
536
546
|
let IdEmpresa = null;
|
|
537
|
-
if (
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
547
|
+
// if (
|
|
548
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
549
|
+
// !IdEmpresa
|
|
550
|
+
// ) {
|
|
551
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
552
|
+
// }
|
|
541
553
|
let crearKey = (planeta, id) => [
|
|
542
554
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:${id}`,
|
|
543
555
|
`${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:paginacion`,
|
|
544
556
|
];
|
|
545
|
-
console.log('simoooon');
|
|
546
557
|
imprimir(`${modelo} ${IdModelo} ${tipo} desligar ${planeta} ${IdPlaneta}`);
|
|
547
558
|
return this.eliminarCache([
|
|
548
559
|
...crearKey(modelo, IdModelo),
|
|
@@ -565,10 +576,12 @@ function BaseResolver(modelo) {
|
|
|
565
576
|
.then((keys) => Promise.all(keys.map((key) => this.cacheManager.del(key))))));
|
|
566
577
|
}
|
|
567
578
|
async arbol(universo, IdEmpresa, planeta, servicio, Clase, subnombre, IdPlaneta) {
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
579
|
+
// if (
|
|
580
|
+
// ['general', 'ecommerce', 'ecreator'].includes(universo) &&
|
|
581
|
+
// !IdEmpresa
|
|
582
|
+
// ) {
|
|
583
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
584
|
+
// }
|
|
572
585
|
const KEY = `${universo ?? 'pro'}:${IdEmpresa}:arbol:${subnombre.replace('sub', '')}`;
|
|
573
586
|
const cache = await this.cacheManager.get(KEY);
|
|
574
587
|
if (cache) {
|
|
@@ -14,7 +14,6 @@ interface Peticion {
|
|
|
14
14
|
export declare function BaseService(modelo: string): {
|
|
15
15
|
new <T extends {
|
|
16
16
|
cacheManager: any;
|
|
17
|
-
receptor: any;
|
|
18
17
|
buscarXid<Ctor>({ value: { id, cacheable }, key, Clase, repository, pagina, }: Peticion): Promise<Ctor>;
|
|
19
18
|
buscarTodos<Ctor>({ value, key, Clase, repository, pagina, cacheable, }: Peticion): Promise<Ctor[]>;
|
|
20
19
|
crear<Ctor>({ value, key, Clase, repository, borrarSSR, }: Peticion): Promise<Ctor>;
|
|
@@ -50,9 +49,8 @@ export declare function BaseService(modelo: string): {
|
|
|
50
49
|
repository: any;
|
|
51
50
|
}): Promise<Ctor>;
|
|
52
51
|
eliminarCache(items: string[], borrarSSR?: boolean): Promise<any[]>;
|
|
53
|
-
}>(cacheManager: any
|
|
52
|
+
}>(cacheManager: any): {
|
|
54
53
|
cacheManager: any;
|
|
55
|
-
receptor: any;
|
|
56
54
|
buscarXid<Ctor>({ value: { id, cacheable }, key, Clase, repository, pagina, }: Peticion): Promise<Ctor>;
|
|
57
55
|
buscarTodos<Ctor>({ value, key, Clase, repository, pagina, cacheable, }: Peticion): Promise<Ctor[]>;
|
|
58
56
|
crear<Ctor>({ value, key, Clase, repository, borrarSSR, }: Peticion): Promise<Ctor>;
|
|
@@ -37,19 +37,22 @@ var stringifyInclude = ({ where, as, include }) => ({
|
|
|
37
37
|
});
|
|
38
38
|
function BaseService(modelo) {
|
|
39
39
|
return class BaseService {
|
|
40
|
-
constructor(cacheManager
|
|
40
|
+
constructor(cacheManager) {
|
|
41
41
|
this.cacheManager = cacheManager;
|
|
42
|
-
this.receptor = receptor;
|
|
43
42
|
}
|
|
44
43
|
buscarXid({ value: { id, cacheable }, key, Clase, repository, pagina, }) {
|
|
45
44
|
return new Promise(async (resolve, reject) => {
|
|
46
|
-
let tiempo;
|
|
45
|
+
// let tiempo;
|
|
47
46
|
// if (isDev) tiempo = moment();
|
|
48
47
|
try {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
// if (
|
|
49
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
50
|
+
// key.universo,
|
|
51
|
+
// ) &&
|
|
52
|
+
// !key.IdEmpresa
|
|
53
|
+
// ) {
|
|
54
|
+
// key.IdEmpresa = await this.receptor.buscarEmpresa();
|
|
55
|
+
// }
|
|
53
56
|
let nkey = `${key.universo ? key.universo : 'pro'}:${key.IdEmpresa}:${key.fragmentos[0].nombre}:${id}`;
|
|
54
57
|
const { resultado, cache } = await (0, cachear_1.cachear)(cacheable, this.cacheManager, (0, keyInterface_1.transformarKey)({ ...key }), (cache) => {
|
|
55
58
|
return Promise.resolve(new repository.sequelize.models[(0, lodash_1.capitalize)(modelo)](JSON.parse(cache)));
|
|
@@ -78,10 +81,12 @@ function BaseService(modelo) {
|
|
|
78
81
|
});
|
|
79
82
|
if (resultado)
|
|
80
83
|
await (0, paginar_1.paginar)(this.cacheManager, key.IdEmpresa, pagina, modelo, resultado.get({ plain: true }));
|
|
81
|
-
if (isDev)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
// if (isDev)
|
|
85
|
+
// console.log(
|
|
86
|
+
// // moment().diff(moment(tiempo), 'milliseconds', true),
|
|
87
|
+
// 'buscarXid',
|
|
88
|
+
// cache,
|
|
89
|
+
// );
|
|
85
90
|
resolve(resultado);
|
|
86
91
|
}
|
|
87
92
|
catch (err) {
|
|
@@ -93,12 +98,16 @@ function BaseService(modelo) {
|
|
|
93
98
|
buscarTodos({ value, key, Clase, repository, pagina, cacheable, }) {
|
|
94
99
|
return new Promise(async (resolve, reject) => {
|
|
95
100
|
try {
|
|
96
|
-
let tiempo;
|
|
101
|
+
// let tiempo;
|
|
97
102
|
// if (isDev) tiempo = moment();
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
// if (
|
|
104
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
105
|
+
// key.universo,
|
|
106
|
+
// ) &&
|
|
107
|
+
// !key.IdEmpresa
|
|
108
|
+
// ) {
|
|
109
|
+
// key.IdEmpresa = await this.receptor.buscarEmpresa();
|
|
110
|
+
// }
|
|
102
111
|
let include = value.include
|
|
103
112
|
? value.include.map((n) => stringifyInclude(n))
|
|
104
113
|
: '';
|
|
@@ -148,10 +157,12 @@ function BaseService(modelo) {
|
|
|
148
157
|
return this.cacheManager.store.hset(nkey, peticion, JSON.stringify(resultado.map((n) => n.id)));
|
|
149
158
|
});
|
|
150
159
|
await (0, paginar_1.paginar)(this.cacheManager, key.IdEmpresa, pagina, modelo, resultado.map((n) => n.get({ plain: true })));
|
|
151
|
-
if (isDev)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
// if (isDev)
|
|
161
|
+
// console.log(
|
|
162
|
+
// // moment().diff(moment(tiempo), 'milliseconds', true),
|
|
163
|
+
// 'paginacion',
|
|
164
|
+
// cache,
|
|
165
|
+
// );
|
|
155
166
|
resolve(resultado ? resultado : []);
|
|
156
167
|
}
|
|
157
168
|
catch (err) {
|
|
@@ -163,11 +174,15 @@ function BaseService(modelo) {
|
|
|
163
174
|
return new Promise(async (resolve, reject) => {
|
|
164
175
|
try {
|
|
165
176
|
let IdEmpresa = key.IdEmpresa;
|
|
166
|
-
console.log({ key: key.IdEmpresa });
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
177
|
+
// console.log({ key: key.IdEmpresa });
|
|
178
|
+
// if (
|
|
179
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
180
|
+
// key.universo,
|
|
181
|
+
// ) &&
|
|
182
|
+
// !key.IdEmpresa
|
|
183
|
+
// ) {
|
|
184
|
+
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
185
|
+
// }
|
|
171
186
|
let item = await repository.create(value);
|
|
172
187
|
const keys = [
|
|
173
188
|
`${key.universo ? key.universo : 'pro'}:${IdEmpresa}:${modelo}`,
|
|
@@ -202,12 +217,16 @@ function BaseService(modelo) {
|
|
|
202
217
|
contar({ value, repository, key }) {
|
|
203
218
|
return new Promise(async (resolve, reject) => {
|
|
204
219
|
try {
|
|
205
|
-
let tiempo;
|
|
206
|
-
// if (isDev) tiempo = moment();
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
220
|
+
// let tiempo;
|
|
221
|
+
// // if (isDev) tiempo = moment();
|
|
222
|
+
// if (
|
|
223
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
224
|
+
// key.universo,
|
|
225
|
+
// ) &&
|
|
226
|
+
// !key.IdEmpresa
|
|
227
|
+
// ) {
|
|
228
|
+
// key.IdEmpresa = await this.receptor.buscarEmpresa();
|
|
229
|
+
// }
|
|
211
230
|
let include = value.include
|
|
212
231
|
? value.include.map((n) => stringifyInclude(n))
|
|
213
232
|
: '';
|
|
@@ -255,10 +274,12 @@ function BaseService(modelo) {
|
|
|
255
274
|
// resultado = await repository.count({...value, distinct: false }),
|
|
256
275
|
// this.cacheManager.set(key$, JSON.stringify(resultado), "EX", tiempo)
|
|
257
276
|
// }
|
|
258
|
-
if (isDev)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
277
|
+
// if (isDev)
|
|
278
|
+
// console.log(
|
|
279
|
+
// // moment().diff(moment(tiempo), 'milliseconds', true),
|
|
280
|
+
// 'contar',
|
|
281
|
+
// cache,
|
|
282
|
+
// );
|
|
262
283
|
resolve(resultado);
|
|
263
284
|
}
|
|
264
285
|
catch (err) {
|
|
@@ -270,10 +291,14 @@ function BaseService(modelo) {
|
|
|
270
291
|
actualizar({ value, options, key, Clase, repository, borrarSSR, }) {
|
|
271
292
|
return new Promise(async (resolve, reject) => {
|
|
272
293
|
try {
|
|
273
|
-
if (
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
294
|
+
// if (
|
|
295
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
296
|
+
// key.universo,
|
|
297
|
+
// ) &&
|
|
298
|
+
// !key.IdEmpresa
|
|
299
|
+
// ) {
|
|
300
|
+
// key.IdEmpresa = await this.receptor.buscarEmpresa();
|
|
301
|
+
// }
|
|
277
302
|
let resultado = await repository.update(value, options);
|
|
278
303
|
// let key$ : string = transformarKey(key)
|
|
279
304
|
const item = await repository.findByPk(value.id);
|
|
@@ -319,10 +344,14 @@ function BaseService(modelo) {
|
|
|
319
344
|
buscaryContar({ value, key, Clase, repository, pagina, }) {
|
|
320
345
|
return new Promise(async (resolve, reject) => {
|
|
321
346
|
try {
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
347
|
+
// if (
|
|
348
|
+
// ['general', 'ecommerce', 'ecreator'].includes(
|
|
349
|
+
// key.universo,
|
|
350
|
+
// ) &&
|
|
351
|
+
// !key.IdEmpresa
|
|
352
|
+
// ) {
|
|
353
|
+
// key.IdEmpresa = await this.receptor.buscarEmpresa();
|
|
354
|
+
// }
|
|
326
355
|
let resultado;
|
|
327
356
|
let key$ = (0, keyInterface_1.transformarKey)(key);
|
|
328
357
|
// const cache = await this.cacheManager.get(key$);
|
|
@@ -356,7 +385,13 @@ function BaseService(modelo) {
|
|
|
356
385
|
async eliminarCache(items, borrarSSR = false) {
|
|
357
386
|
if (borrarSSR)
|
|
358
387
|
redisStore_1.clientSsr.flushdb();
|
|
359
|
-
log(
|
|
388
|
+
// log(
|
|
389
|
+
// chalk.red(
|
|
390
|
+
// 'SSR: SE ELIMINOOOO ALGOOO!!!!!!!!!!!!!!',
|
|
391
|
+
// items,
|
|
392
|
+
// borrarSSR,
|
|
393
|
+
// ),
|
|
394
|
+
// );
|
|
360
395
|
return Promise.all(items.map(async (item) => this.cacheManager
|
|
361
396
|
.keys(`*${item}*`)
|
|
362
397
|
.then((keys) => Promise.all(keys.map((key) => this.cacheManager.del(key))))));
|