new(all): TRUE multicloud.

This commit is contained in:
Rodrigo Rodriguez 2024-08-20 15:30:47 -03:00
parent 367e45f5f5
commit 6bc15e1a74

View file

@ -69,21 +69,20 @@ export class GBUtil {
public static async getDirectLineClient(min) { public static async getDirectLineClient(min) {
let config = { let config = {
url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`,
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')), spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
requestInterceptor: req => { requestInterceptor: req => {
req.headers['Authorization'] = `Bearer ${min.instance.webchatKey}`; req.headers['Authorization'] = `Bearer ${min.instance.webchatKey}`;
} }
}; };
if (!GBConfigService.get('STORAGE_NAME')) { if (GBConfigService.get('STORAGE_FILE')) {
config['spec'].servers = [{ url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages` }]; (config['url'] = `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages`),
(config['spec'].servers = [{ url: `http://127.0.0.1:${GBConfigService.getServerPort()}/api/messages` }]);
config['openapi'] = '3.0.0'; config['openapi'] = '3.0.0';
} }
return await new SwaggerClient(config);
} }
public static toYAML(data) { public static toYAML(data) {
const extractProps = (obj) => { const extractProps = obj => {
return Object.getOwnPropertyNames(obj).reduce((acc, key) => { return Object.getOwnPropertyNames(obj).reduce((acc, key) => {
const value = obj[key]; const value = obj[key];
acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value; acc[key] = value && typeof value === 'object' && !Array.isArray(value) ? extractProps(value) : value;
@ -93,7 +92,7 @@ export class GBUtil {
const extractedError = extractProps(data); const extractedError = extractProps(data);
return YAML.stringify(extractedError); return YAML.stringify(extractedError);
} }
public static sleep(ms) { public static sleep(ms) {
return new Promise(resolve => { return new Promise(resolve => {