@obisey/nest 0.1.4 → 0.1.6

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/fecha.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { Dayjs, ConfigType } from 'dayjs';
2
+ import { DurationUnitType, Duration } from 'dayjs/plugin/duration';
3
+ import 'dayjs/locale/es';
4
+ type FechaConfig = {
5
+ year?: number;
6
+ month?: number;
7
+ day?: number;
8
+ hour?: number;
9
+ minute?: number;
10
+ second?: number;
11
+ millisecond?: number;
12
+ };
13
+ export declare function fecha(input?: ConfigType | FechaConfig): Dayjs;
14
+ export declare function duracion(value?: number | Record<string, number> | string, unit?: DurationUnitType): Duration;
15
+ export type { Dayjs, Duration };
package/fecha.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fecha = fecha;
7
+ exports.duracion = duracion;
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
10
+ const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
11
+ const localizedFormat_1 = __importDefault(require("dayjs/plugin/localizedFormat"));
12
+ const isSameOrAfter_1 = __importDefault(require("dayjs/plugin/isSameOrAfter"));
13
+ const isSameOrBefore_1 = __importDefault(require("dayjs/plugin/isSameOrBefore"));
14
+ const customParseFormat_1 = __importDefault(require("dayjs/plugin/customParseFormat"));
15
+ const duration_1 = __importDefault(require("dayjs/plugin/duration"));
16
+ require("dayjs/locale/es");
17
+ // ────────────────────────────────────────────────────────────────
18
+ // Plugins necesarios para emular la mayor parte de la API Moment
19
+ // ────────────────────────────────────────────────────────────────
20
+ dayjs_1.default.extend(utc_1.default);
21
+ dayjs_1.default.extend(advancedFormat_1.default);
22
+ dayjs_1.default.extend(localizedFormat_1.default);
23
+ dayjs_1.default.extend(isSameOrAfter_1.default);
24
+ dayjs_1.default.extend(isSameOrBefore_1.default);
25
+ dayjs_1.default.extend(customParseFormat_1.default);
26
+ dayjs_1.default.extend(duration_1.default);
27
+ dayjs_1.default.locale('es');
28
+ // Type‑guard para identificar si el argumento es un FechaConfig
29
+ function isFechaConfig(input) {
30
+ return (input &&
31
+ typeof input === 'object' &&
32
+ !(input instanceof Date) &&
33
+ !dayjs_1.default.isDayjs(input) &&
34
+ !Array.isArray(input));
35
+ }
36
+ // ────────────────────────────────────────────────────────────────
37
+ // Factory principal → `fecha()` (≈ `moment()`)
38
+ // ────────────────────────────────────────────────────────────────
39
+ function fecha(input) {
40
+ // Caso especial: objeto estilo moment({ hour: 0 })
41
+ if (isFechaConfig(input)) {
42
+ const now = (0, dayjs_1.default)();
43
+ return now
44
+ .set('year', input.year ?? now.year())
45
+ .set('month', input.month ?? now.month())
46
+ .set('date', input.day ?? now.date())
47
+ .set('hour', input.hour ?? 0)
48
+ .set('minute', input.minute ?? 0)
49
+ .set('second', input.second ?? 0)
50
+ .set('millisecond', input.millisecond ?? 0);
51
+ }
52
+ // Otros tipos compatibles con Day.js
53
+ if (input !== undefined) {
54
+ return (0, dayjs_1.default)(input);
55
+ }
56
+ // Sin argumentos → fecha actual
57
+ return (0, dayjs_1.default)();
58
+ }
59
+ // ────────────────────────────────────────────────────────────────
60
+ // Helper para Duration → `duracion()` (≈ `moment.duration()`)
61
+ // ────────────────────────────────────────────────────────────────
62
+ function duracion(value, unit) {
63
+ // @ts-ignore – la definición global de duration se añade por el plugin
64
+ return dayjs_1.default.duration(value, unit);
65
+ }
package/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from './prototipos/utils/formarInclude';
10
10
  export * from './prototipos/utils/formarorder';
11
11
  export * from './prototipos/utils/formarwhere';
12
12
  export * from './types';
13
+ export * from './fecha';
package/index.js CHANGED
@@ -27,3 +27,4 @@ __exportStar(require("./prototipos/utils/formarInclude"), exports);
27
27
  __exportStar(require("./prototipos/utils/formarorder"), exports);
28
28
  __exportStar(require("./prototipos/utils/formarwhere"), exports);
29
29
  __exportStar(require("./types"), exports);
30
+ __exportStar(require("./fecha"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obisey/nest",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "NestJS utilities and base classes by Obisey",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,6 @@
9
9
  "copy:assets": "cp package.json README.md dist/",
10
10
  "publish:dist": "npm run build && npm run copy:assets && cd dist && npm publish --access public"
11
11
  },
12
-
13
12
  "keywords": [
14
13
  "nestjs",
15
14
  "cache",
@@ -22,8 +21,8 @@
22
21
  "license": "MIT",
23
22
  "peerDependencies": {
24
23
  "lodash": "^4.17.21",
25
- "sequelize-typescript": "^2.1.5",
26
- "sequelize": "^6.32.1"
24
+ "sequelize": "^6.32.1",
25
+ "sequelize-typescript": "^2.1.5"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@nestjs/axios": "^4.0.0",
@@ -31,15 +30,15 @@
31
30
  "@nestjs/common": "^10.3.3",
32
31
  "@nestjs/core": "^10.3.3",
33
32
  "@nestjs/graphql": "^12.1.1",
34
- "typegraphql-nestjs": "^0.7.0",
35
- "@types/moment": "^2.11.29",
36
33
  "cache-manager": "^7.0.0",
37
34
  "cache-manager-redis-store": "^3.0.1",
38
35
  "graphql": "^16.11.0",
39
36
  "ioredis": "^5.6.1",
40
37
  "reflect-metadata": "^0.2.2",
38
+ "typegraphql-nestjs": "^0.7.0",
41
39
  "typescript": "^5.4.5"
40
+ },
41
+ "dependencies": {
42
+ "dayjs": "^1.11.13"
42
43
  }
43
-
44
-
45
44
  }
@@ -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, receptor?: ReceptorService): {
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, receptor = null) {
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
332
- !IdEmpresa) {
333
- IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
367
- !IdEmpresa) {
368
- IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
394
- !IdEmpresa) {
395
- IdEmpresa = await this.receptor.buscarEmpresa();
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
- console.log(
441
- // moment().diff(moment(tiempo), 'milliseconds', true),
442
- 'uno', cache);
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
455
- !IdEmpresa) {
456
- IdEmpresa = await this.receptor.buscarEmpresa();
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
- console.log(
501
- // moment().diff(moment(tiempo), 'milliseconds', true),
502
- 'muchos', cache);
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
513
- !IdEmpresa) {
514
- IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
538
- !IdEmpresa) {
539
- IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(universo) &&
569
- !IdEmpresa) {
570
- IdEmpresa = await this.receptor.buscarEmpresa();
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, receptor?: 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, receptor = null) {
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
50
- !key.IdEmpresa) {
51
- key.IdEmpresa = await this.receptor.buscarEmpresa();
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
- console.log(
83
- // moment().diff(moment(tiempo), 'milliseconds', true),
84
- 'buscarXid', cache);
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
99
- !key.IdEmpresa) {
100
- key.IdEmpresa = await this.receptor.buscarEmpresa();
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
- console.log(
153
- // moment().diff(moment(tiempo), 'milliseconds', true),
154
- 'paginacion', cache);
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
168
- !key.IdEmpresa) {
169
- IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
208
- !key.IdEmpresa) {
209
- key.IdEmpresa = await this.receptor.buscarEmpresa();
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
- console.log(
260
- // moment().diff(moment(tiempo), 'milliseconds', true),
261
- 'contar', cache);
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
274
- !key.IdEmpresa) {
275
- key.IdEmpresa = await this.receptor.buscarEmpresa();
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 (['general', 'ecommerce', 'ecreator'].includes(key.universo) &&
323
- !key.IdEmpresa) {
324
- key.IdEmpresa = await this.receptor.buscarEmpresa();
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(chalk.red('SSR: SE ELIMINOOOO ALGOOO!!!!!!!!!!!!!!', items, borrarSSR));
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))))));