@obisey/nest 0.1.22 → 0.1.23
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obisey/nest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "NestJS utilities and base classes by Obisey",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -35,12 +35,15 @@
|
|
|
35
35
|
"@types/sequelize": "^4.28.20",
|
|
36
36
|
"cache-manager": "^7.0.0",
|
|
37
37
|
"cache-manager-redis-store": "^3.0.1",
|
|
38
|
+
"express": "^5.0.0",
|
|
38
39
|
"graphql": "^16.0.0",
|
|
39
40
|
"ioredis": "^5.6.1",
|
|
40
41
|
"reflect-metadata": "^0.2.2",
|
|
41
42
|
"sequelize": "^6.37.7",
|
|
42
43
|
"sequelize-typescript": "^2.1.6",
|
|
43
|
-
"typescript": "^5.8.3"
|
|
44
|
-
|
|
44
|
+
"typescript": "^5.8.3"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"dayjs": "^1.11.19"
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -41,7 +41,6 @@ var tiempo = 86400000;
|
|
|
41
41
|
var isDev = false;
|
|
42
42
|
const cachear_1 = require("./utils/cachear");
|
|
43
43
|
const paginar_1 = require("./utils/paginar");
|
|
44
|
-
const getModelId_1 = require("./utils/getModelId");
|
|
45
44
|
const _ = __importStar(require("lodash"));
|
|
46
45
|
function BaseResolver(modelo) {
|
|
47
46
|
return class BaseResolver {
|
|
@@ -469,14 +468,14 @@ function BaseResolver(modelo) {
|
|
|
469
468
|
// ) {
|
|
470
469
|
// IdEmpresa = await this.receptor.buscarEmpresa();
|
|
471
470
|
// }
|
|
472
|
-
let nkey = `${universo ? universo : 'pro'}:${IdEmpresa}:${modelo}:${
|
|
471
|
+
let nkey = `${universo ? universo : 'pro'}:${IdEmpresa}:${modelo}:${item.id}`;
|
|
473
472
|
let pkey = (id) => `${universo ? universo : 'pro'}:${IdEmpresa}:${planeta}:${id}`;
|
|
474
473
|
const { resultado, cache } = await (0, cachear_1.cachear)(cacheable, this.cacheManager, (0, keyInterface_1.transformarKey)({
|
|
475
474
|
universo,
|
|
476
475
|
IdEmpresa,
|
|
477
476
|
tipo,
|
|
478
477
|
fragmentos: [
|
|
479
|
-
{ nombre: modelo, id:
|
|
478
|
+
{ nombre: modelo, id: item.id },
|
|
480
479
|
{ nombre: planeta },
|
|
481
480
|
],
|
|
482
481
|
}), (cache) => Promise.resolve(cache.map((n) => new Clase(JSON.parse(n)))), //Revisar
|
|
@@ -507,7 +506,7 @@ function BaseResolver(modelo) {
|
|
|
507
506
|
}
|
|
508
507
|
}), //observar
|
|
509
508
|
(__, resultado) => {
|
|
510
|
-
return Promise.all(resultado.map((n) => this.redis.hSet(pkey(
|
|
509
|
+
return Promise.all(resultado.map((n) => this.redis.hSet(pkey(n.id), 'item', JSON.stringify(n)))).then(() => this.redis.hSet(nkey, planeta, JSON.stringify(resultado.map((n) => n.id))));
|
|
511
510
|
});
|
|
512
511
|
await (0, paginar_1.paginar)(this.cacheManager, IdEmpresa, pagina, planeta, resultado.map((n) => n.get({ plain: true })));
|
|
513
512
|
// if (isDev)
|
|
@@ -128,7 +128,19 @@ function BaseService(modelo) {
|
|
|
128
128
|
...key,
|
|
129
129
|
include,
|
|
130
130
|
where,
|
|
131
|
-
}), (cache) => Promise.resolve(cache.map((n) =>
|
|
131
|
+
}), (cache) => Promise.resolve(cache.map((n) => {
|
|
132
|
+
const parsed = JSON.parse(n);
|
|
133
|
+
console.log(`[OBISEY-NEST CACHE HIT] ${modelo}:`, {
|
|
134
|
+
cached: parsed,
|
|
135
|
+
modelName: (0, lodash_1.capitalize)(modelo),
|
|
136
|
+
});
|
|
137
|
+
const instance = new repository.sequelize.models[(0, lodash_1.capitalize)(modelo)](parsed);
|
|
138
|
+
console.log(`[OBISEY-NEST DESERIALIZED] ${modelo}:`, {
|
|
139
|
+
id: instance.id,
|
|
140
|
+
hasId: 'id' in instance,
|
|
141
|
+
});
|
|
142
|
+
return instance;
|
|
143
|
+
})), //Revisar
|
|
132
144
|
(resultado) => Promise.resolve(resultado.map((n) => n.get({ plain: true }))), //transformar
|
|
133
145
|
() => new Promise((resolve) => {
|
|
134
146
|
resolve(repository.findAll(value)); //Pedir
|
|
@@ -161,6 +173,7 @@ function BaseService(modelo) {
|
|
|
161
173
|
// 'paginacion',
|
|
162
174
|
// cache,
|
|
163
175
|
// );
|
|
176
|
+
console.log(`[BUSCAR-TODOS-RESULT] modelo=${modelo} items=${resultado.length} cache=${cache}`);
|
|
164
177
|
resolve(resultado ? resultado : []);
|
|
165
178
|
}
|
|
166
179
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function onRedis(datos: any, si?: boolean):
|
|
1
|
+
export declare function onRedis(datos: any, si?: boolean): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const formarInclude: (include: any, mapa: any, tipo: any, conexion: any, required?: boolean) =>
|
|
1
|
+
export declare const formarInclude: (include: any, mapa: any, tipo: any, conexion: any, required?: boolean) => any;
|
|
2
2
|
declare class FilterBasic {
|
|
3
3
|
is: string;
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const formarWhere: (where: any) =>
|
|
1
|
+
export declare const formarWhere: (where: any) => {};
|