@obisey/nest 0.1.35 → 0.1.37
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 +11 -3
- package/prototipos/__tests__/baseResolver.e2e.spec.d.ts +9 -0
- package/prototipos/__tests__/baseResolver.e2e.spec.js +172 -0
- package/prototipos/__tests__/baseResolver.integration.spec.d.ts +8 -0
- package/prototipos/__tests__/baseResolver.integration.spec.js +105 -0
- package/prototipos/__tests__/baseResolver.spec.d.ts +14 -0
- package/prototipos/__tests__/baseResolver.spec.js +305 -0
- package/prototipos/__tests__/baseService.e2e.simple.spec.d.ts +7 -0
- package/prototipos/__tests__/baseService.e2e.simple.spec.js +92 -0
- package/prototipos/__tests__/baseService.e2e.validation.spec.d.ts +7 -0
- package/prototipos/__tests__/baseService.e2e.validation.spec.js +157 -0
- package/prototipos/__tests__/baseService.integration.spec.d.ts +8 -0
- package/prototipos/__tests__/baseService.integration.spec.js +115 -0
- package/prototipos/__tests__/baseService.spec.d.ts +14 -0
- package/prototipos/__tests__/baseService.spec.js +253 -0
- package/prototipos/__tests__/cachear-types.spec.d.ts +8 -0
- package/prototipos/__tests__/cachear-types.spec.js +79 -0
- package/prototipos/__tests__/graphql-flow.e2e.spec.d.ts +9 -0
- package/prototipos/__tests__/graphql-flow.e2e.spec.js +270 -0
- package/prototipos/__tests__/test-helpers/mock-sequelize.d.ts +83 -0
- package/prototipos/__tests__/test-helpers/mock-sequelize.js +138 -0
- package/prototipos/baseResolver.d.ts +8 -8
- package/prototipos/baseResolver.js +23 -17
- package/prototipos/baseService.js +23 -75
- package/prototipos/utils/cachear.d.ts +12 -2
- package/prototipos/utils/cachear.js +14 -9
- package/adapters/index.d.ts +0 -11
- package/adapters/index.js +0 -27
- package/adapters/sequelize/index.d.ts +0 -5
- package/adapters/sequelize/index.js +0 -9
- package/adapters/sequelize/property.adapter.d.ts +0 -79
- package/adapters/sequelize/property.adapter.js +0 -134
- package/prototipos/index.d.ts +0 -9
- package/prototipos/index.js +0 -26
- package/receptor.d.ts +0 -25
- package/receptor.js +0 -153
- package/redisStore.d.ts +0 -11
- package/redisStore.js +0 -78
package/receptor.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.ReceptorService = void 0;
|
|
49
|
-
const axios_1 = require("@nestjs/axios");
|
|
50
|
-
const common_1 = require("@nestjs/common");
|
|
51
|
-
const _ = __importStar(require("lodash"));
|
|
52
|
-
const core_1 = require("@nestjs/core");
|
|
53
|
-
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
54
|
-
let ReceptorService = class ReceptorService {
|
|
55
|
-
constructor(cacheManager, request, httpService, config) {
|
|
56
|
-
this.cacheManager = cacheManager;
|
|
57
|
-
this.request = request;
|
|
58
|
-
this.httpService = httpService;
|
|
59
|
-
this.config = config;
|
|
60
|
-
this.conexiones = {};
|
|
61
|
-
this.conexionesActivas = {};
|
|
62
|
-
}
|
|
63
|
-
hola() {
|
|
64
|
-
console.log('holaaaa');
|
|
65
|
-
}
|
|
66
|
-
get globalUrl() {
|
|
67
|
-
if (!this.config?.globalUrl) {
|
|
68
|
-
throw new Error(`globalUrl is not configured in ReceptorService. You must pass it during provider registration.`);
|
|
69
|
-
}
|
|
70
|
-
return this.config.globalUrl;
|
|
71
|
-
}
|
|
72
|
-
async buscarConexiones() {
|
|
73
|
-
const bases = await this.cacheManager.get('basesdedatos');
|
|
74
|
-
if (!bases)
|
|
75
|
-
await this.httpService
|
|
76
|
-
.get(`${this.globalUrl}/global/emisor`)
|
|
77
|
-
.toPromise()
|
|
78
|
-
.then(({ data }) => {
|
|
79
|
-
if (data) {
|
|
80
|
-
this.cacheManager.set('basesdedatos', JSON.stringify(data));
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return Promise.resolve(JSON.parse(bases));
|
|
85
|
-
}
|
|
86
|
-
async buscarEmpresa() {
|
|
87
|
-
const KEY = this.request.req.headers['host']?.replace('www.', '');
|
|
88
|
-
let IdEmpresa = await this.cacheManager.get(KEY);
|
|
89
|
-
if (IdEmpresa)
|
|
90
|
-
return IdEmpresa;
|
|
91
|
-
const conexiones = await this.buscarConexiones();
|
|
92
|
-
IdEmpresa = _.findKey(conexiones, (o) => o.dominios
|
|
93
|
-
.map((d) => d.nombre)
|
|
94
|
-
.includes(this.request.req.headers['host']));
|
|
95
|
-
await this.cacheManager.set(KEY, IdEmpresa);
|
|
96
|
-
return IdEmpresa;
|
|
97
|
-
}
|
|
98
|
-
buscar({ req }, conexion, host_) {
|
|
99
|
-
return this.httpService
|
|
100
|
-
.get(`${this.globalUrl}/global/emisor`)
|
|
101
|
-
.toPromise()
|
|
102
|
-
.then(async ({ data }) => {
|
|
103
|
-
console.log('data');
|
|
104
|
-
let IdEmpresa = req.session?.IdEmpresa;
|
|
105
|
-
const host = host_ ?? req.headers['host'];
|
|
106
|
-
const asignar = async () => {
|
|
107
|
-
const conexionActiva = this.conexionesActivas[IdEmpresa];
|
|
108
|
-
console.log('conexionActiva', conexionActiva);
|
|
109
|
-
if (conexionActiva) {
|
|
110
|
-
console.log('ReceptorService.buscar.then.asignar.conexionActiva');
|
|
111
|
-
return conexionActiva;
|
|
112
|
-
}
|
|
113
|
-
const baseDeDatos = data[IdEmpresa];
|
|
114
|
-
console.log('baseDeDatos', baseDeDatos);
|
|
115
|
-
if (baseDeDatos) {
|
|
116
|
-
const coneccion = new conexion(baseDeDatos);
|
|
117
|
-
Object.assign(this.conexionesActivas, {
|
|
118
|
-
[IdEmpresa]: coneccion,
|
|
119
|
-
});
|
|
120
|
-
//ts-ignore
|
|
121
|
-
console.log('ReceptorService.buscar.then.asignar.baseDeDatos', coneccion.config.database);
|
|
122
|
-
return coneccion;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
// console.log({ IdEmpresa, host })
|
|
126
|
-
if (IdEmpresa) {
|
|
127
|
-
const db = await asignar();
|
|
128
|
-
// console.log(db)
|
|
129
|
-
return db;
|
|
130
|
-
}
|
|
131
|
-
if (host) {
|
|
132
|
-
IdEmpresa = _.findKey(data, (o) => o.dominios.map((d) => d.nombre).includes(host));
|
|
133
|
-
console.log('ReceptorService.buscar.then.host', host, IdEmpresa);
|
|
134
|
-
const db = await asignar();
|
|
135
|
-
return db;
|
|
136
|
-
}
|
|
137
|
-
// console.log('ReceptorService.buscar.then', null);
|
|
138
|
-
return null;
|
|
139
|
-
})
|
|
140
|
-
.catch((err) => {
|
|
141
|
-
console.log('no coneta el receptor', err);
|
|
142
|
-
return null;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
exports.ReceptorService = ReceptorService;
|
|
147
|
-
exports.ReceptorService = ReceptorService = __decorate([
|
|
148
|
-
(0, common_1.Injectable)(),
|
|
149
|
-
__param(0, (0, common_1.Inject)(cache_manager_1.CACHE_MANAGER)),
|
|
150
|
-
__param(1, (0, common_1.Inject)(core_1.REQUEST)),
|
|
151
|
-
__param(3, (0, common_1.Optional)()),
|
|
152
|
-
__metadata("design:paramtypes", [Object, Object, axios_1.HttpService, Object])
|
|
153
|
-
], ReceptorService);
|
package/redisStore.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as redisStore from 'cache-manager-redis-store';
|
|
2
|
-
export declare const client: any;
|
|
3
|
-
export declare const clientWhatsapp: any;
|
|
4
|
-
export declare const clientSsr: any;
|
|
5
|
-
export declare const redisConfig: {
|
|
6
|
-
store: typeof redisStore;
|
|
7
|
-
host: string;
|
|
8
|
-
db: number;
|
|
9
|
-
port: number;
|
|
10
|
-
};
|
|
11
|
-
export declare const redisSession: any;
|
package/redisStore.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.redisSession = exports.redisConfig = exports.clientSsr = exports.clientWhatsapp = exports.client = void 0;
|
|
37
|
-
const redisStore = __importStar(require("cache-manager-redis-store"));
|
|
38
|
-
const Redis = __importStar(require("ioredis"));
|
|
39
|
-
exports.client = new Redis.default({
|
|
40
|
-
port: 6379,
|
|
41
|
-
// host: process.env.NODE_ENV == "production"?"172.19.0.24" :"172.19.0.24",
|
|
42
|
-
host: process.env.NODE_ENV == 'production' ? 'redis' : '127.0.0.1',
|
|
43
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.11" :"172.18.0.15",
|
|
44
|
-
family: 4,
|
|
45
|
-
db: 3,
|
|
46
|
-
});
|
|
47
|
-
exports.clientWhatsapp = new Redis.default({
|
|
48
|
-
port: 6379,
|
|
49
|
-
// host: process.env.NODE_ENV == "production"?"172.19.0.24" :"172.19.0.24",
|
|
50
|
-
host: process.env.NODE_ENV == 'production' ? 'redis' : '127.0.0.1',
|
|
51
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.11" :"172.18.0.15",
|
|
52
|
-
family: 4,
|
|
53
|
-
db: 4,
|
|
54
|
-
});
|
|
55
|
-
exports.clientSsr = new Redis.default({
|
|
56
|
-
port: 6379,
|
|
57
|
-
// host: process.env.NODE_ENV == "production"?"172.19.0.24" :"172.19.0.24",
|
|
58
|
-
host: process.env.NODE_ENV == 'production' ? 'redis' : '127.0.0.1',
|
|
59
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.11" :"172.18.0.15",
|
|
60
|
-
family: 4,
|
|
61
|
-
db: 1,
|
|
62
|
-
});
|
|
63
|
-
exports.redisConfig = {
|
|
64
|
-
store: redisStore,
|
|
65
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.15" :"72.18.0.15",
|
|
66
|
-
host: process.env.NODE_ENV == 'production' ? 'redis' : '127.0.0.1',
|
|
67
|
-
db: 3,
|
|
68
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.11" :"172.18.0.15",
|
|
69
|
-
port: 6379,
|
|
70
|
-
};
|
|
71
|
-
exports.redisSession = new Redis.default({
|
|
72
|
-
port: 6379,
|
|
73
|
-
// host: process.env.NODE_ENV == "production"?"172.19.0.24" :"172.19.0.24",
|
|
74
|
-
host: process.env.NODE_ENV == 'production' ? 'redis' : '127.0.0.1',
|
|
75
|
-
// host: process.env.NODE_ENV == "production"?"172.18.0.11" :"172.18.0.15",
|
|
76
|
-
family: 4,
|
|
77
|
-
db: 5,
|
|
78
|
-
});
|