fix(basic.gblib): Databases. #392 @othonlima.
This commit is contained in:
parent
77a3a9a7a6
commit
165619960d
7 changed files with 34 additions and 63 deletions
|
@ -37,6 +37,7 @@
|
|||
"build-docs": "typedoc --options typedoc.json src/",
|
||||
"test": "node test.js",
|
||||
"start": "NODE_NO_WARNINGS=1 node ./boot.mjs --loader ts-node/esm --require ./suppress-node-warnings.cjs",
|
||||
"debug": "NODE_NO_WARNINGS=1 node ./boot.mjs --loader ts-node/esm --require ./suppress-node-warnings.cjs --inspect",
|
||||
"reverse-proxy": "node_modules/.bin/ngrok http 4242",
|
||||
"watch:build": "tsc --watch",
|
||||
"posttypedoc": "shx cp .nojekyll docs/reference/.nojekyll",
|
||||
|
@ -70,9 +71,9 @@
|
|||
"@microsoft/microsoft-graph-client": "3.0.4",
|
||||
"@nlpjs/basic": "4.26.1",
|
||||
"@nosferatu500/textract": "3.1.2",
|
||||
"@push-rpc/core": "1.1.5",
|
||||
"@push-rpc/http": "1.1.5",
|
||||
"@push-rpc/websocket": "1.1.5",
|
||||
"@push-rpc/core": "1.8.2",
|
||||
"@push-rpc/http": "1.8.2",
|
||||
"@push-rpc/websocket": "1.8.2",
|
||||
"@semantic-release/changelog": "5.0.1",
|
||||
"@semantic-release/exec": "5.0.0",
|
||||
"@semantic-release/git": "9.0.0",
|
||||
|
|
|
@ -41,8 +41,7 @@ import { GuaribasSchedule } from '../core.gbapp/models/GBModel.js';
|
|||
import { Sequelize } from 'sequelize-typescript';
|
||||
import Koa from 'koa';
|
||||
import cors from '@koa/cors';
|
||||
import { createHttpKoaMiddleware } from '@push-rpc/http';
|
||||
import { HttpServerOptions } from '@push-rpc/http/dist/server.js';
|
||||
import { createKoaHttpMiddleware } from '@push-rpc/http';
|
||||
import { GBServer } from '../../src/app.js';
|
||||
import { SocketServer } from '@push-rpc/core';
|
||||
import * as koaBody from 'koa-body';
|
||||
|
@ -50,10 +49,10 @@ import * as koaBody from 'koa-body';
|
|||
export function createKoaHttpServer(
|
||||
port: number,
|
||||
getRemoteId: (ctx: Koa.Context) => string,
|
||||
opts: Partial<HttpServerOptions> = {}
|
||||
opts:{}
|
||||
): SocketServer {
|
||||
const { onError, onConnection, middleware } =
|
||||
createHttpKoaMiddleware(getRemoteId, opts);
|
||||
createKoaHttpMiddleware(getRemoteId);
|
||||
|
||||
const app = new Koa();
|
||||
app.use(cors({ origin: '*' }));
|
||||
|
|
|
@ -159,8 +159,8 @@ export class GBVMService extends GBService {
|
|||
"encoding": "0.1.13",
|
||||
"isomorphic-fetch": "3.0.0",
|
||||
"punycode": "2.1.1",
|
||||
"@push-rpc/core": "1.1.5",
|
||||
"@push-rpc/http": "1.1.5",
|
||||
"@push-rpc/core": "1.8.2",
|
||||
"@push-rpc/http": "1.8.2",
|
||||
"vm2": "3.9.11"
|
||||
}
|
||||
}`;
|
||||
|
@ -572,14 +572,14 @@ export class GBVMService extends GBService {
|
|||
let url;
|
||||
const agent = http.Agent({ keepAlive: true });
|
||||
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/api/v3/${min.botId}/dk';
|
||||
const dk = (await createRpcClient(0, () => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/api/v3/${min.botId}/sys';
|
||||
const sys = (await createRpcClient(0, () => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/api/v3/${min.botId}/wa';
|
||||
const wa = (await createRpcClient(0, () => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/api/v3/${min.botId}/img';
|
||||
const img = (await createRpcClient(0, () => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/dk';
|
||||
const dk = (await createRpcClient(() => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/sys';
|
||||
const sys = (await createRpcClient(() => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/wa';
|
||||
const wa = (await createRpcClient(() => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
url = 'http://localhost:${GBVMService.API_PORT}/${min.botId}/img';
|
||||
const img = (await createRpcClient(() => createHttpClient(url, {agent: agent}), optsRPC)).remote;
|
||||
|
||||
${code}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ export class KeywordsExpressions {
|
|||
|
||||
// Performs GET request using the constructed URL
|
||||
|
||||
__data = await sys.get ({pid: pid, file: __url, addressOrHeaders: headers, httpUsername, httpPs});
|
||||
__data = await sys.getHttp ({pid: pid, file: __url, addressOrHeaders: headers, httpUsername, httpPs});
|
||||
|
||||
// Updates current variable handlers.
|
||||
|
||||
|
@ -649,7 +649,7 @@ export class KeywordsExpressions {
|
|||
|
||||
// Handles the GET http version.
|
||||
else {
|
||||
return `${$1} = await sys.get ({pid: pid, file: ${$2}, addressOrHeaders: headers, httpUsername, httpPs})`;
|
||||
return `${$1} = await sys.getHttp ({pid: pid, file: ${$2}, addressOrHeaders: headers, httpUsername, httpPs})`;
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
|
@ -666,16 +666,16 @@ export class SystemKeywords {
|
|||
const definition = this.getTableFromName(table, min);
|
||||
|
||||
let dst = {};
|
||||
// Uppercases fields.
|
||||
let i = 0;
|
||||
Object.keys(fieldsValues).forEach(fieldSrc => {
|
||||
const field = fieldsNames[i].charAt(0).toUpperCase() + fieldsNames[i].slice(1);
|
||||
// Uppercases fields.
|
||||
let i = 0;
|
||||
Object.keys(fieldsValues).forEach(fieldSrc => {
|
||||
const field = fieldsNames[i].charAt(0).toUpperCase() + fieldsNames[i].slice(1);
|
||||
|
||||
dst[field] = fieldsValues[fieldSrc];
|
||||
dst[field] = fieldsValues[fieldSrc];
|
||||
|
||||
i++;
|
||||
});
|
||||
|
||||
i++;
|
||||
});
|
||||
|
||||
let item;
|
||||
await retry(
|
||||
async (bail) => {
|
||||
|
@ -683,7 +683,7 @@ export class SystemKeywords {
|
|||
},
|
||||
{
|
||||
retries: 5,
|
||||
onRetry: (err)=>{GBLog.error(`Retrying due to: ${err.message}.`);}
|
||||
onRetry: (err) => { GBLog.error(`Retrying due to: ${err.message}.`); }
|
||||
}
|
||||
|
||||
);
|
||||
|
@ -811,7 +811,7 @@ export class SystemKeywords {
|
|||
* @example value = GET "file.xlsx", "A2"
|
||||
*
|
||||
*/
|
||||
public async get({ pid, file, addressOrHeaders, httpUsername, httpPs, qs, streaming }): Promise<any> {
|
||||
public async getHttp({ pid, file, addressOrHeaders, httpUsername, httpPs, qs, streaming }): Promise<any> {
|
||||
const { min, user } = await DialogKeywords.getProcessInfo(pid);
|
||||
if (file.startsWith('http')) {
|
||||
return await this.getByHttp({
|
||||
|
@ -1682,7 +1682,7 @@ export class SystemKeywords {
|
|||
}
|
||||
|
||||
if (res) { res['pageMode'] = pageMode; }
|
||||
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
@ -2102,8 +2102,7 @@ export class SystemKeywords {
|
|||
else {
|
||||
table = this.cachedMerge[pid][file];
|
||||
}
|
||||
|
||||
|
||||
|
||||
let key1Index, key2Index;
|
||||
|
||||
if (key1) {
|
||||
|
@ -2230,8 +2229,9 @@ export class SystemKeywords {
|
|||
|
||||
if (storage) {
|
||||
|
||||
let dst={};
|
||||
// Uppercases fields.
|
||||
let dst = {};
|
||||
|
||||
// Uppercases fields.
|
||||
let i = 0;
|
||||
Object.keys(fieldsValues).forEach(fieldSrc => {
|
||||
const field = fieldsNames[i].charAt(0).toUpperCase() + fieldsNames[i].slice(1);
|
||||
|
|
|
@ -37,22 +37,16 @@
|
|||
'use strict';
|
||||
import cliProgress from 'cli-progress';
|
||||
import { DialogSet, TextPrompt } from 'botbuilder-dialogs';
|
||||
import express from 'express';
|
||||
import SwaggerClient from 'swagger-client';
|
||||
import removeRoute from 'express-remove-route';
|
||||
import AuthenticationContext from 'adal-node';
|
||||
import { FacebookAdapter } from 'botbuilder-adapter-facebook';
|
||||
import path from 'path';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Fs from 'fs';
|
||||
import arrayBufferToBuffer from 'arraybuffer-to-buffer';
|
||||
import { NlpManager } from 'node-nlp';
|
||||
import Koa from 'koa';
|
||||
import cors from '@koa/cors';
|
||||
import { createRpcServer } from '@push-rpc/core';
|
||||
import { createHttpKoaMiddleware } from '@push-rpc/http';
|
||||
import { HttpServerOptions } from '@push-rpc/http/dist/server.js';
|
||||
import { List } from 'whatsapp-web.js';
|
||||
import wash from 'washyourmouthoutwithsoap';
|
||||
import {
|
||||
AutoSaveStateMiddleware,
|
||||
|
@ -100,7 +94,6 @@ import { createKoaHttpServer } from '../../basic.gblib/index.js';
|
|||
import { DebuggerService } from '../../basic.gblib/services/DebuggerService.js';
|
||||
import { ImageProcessingServices } from '../../basic.gblib/services/ImageProcessingServices.js';
|
||||
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices.js';
|
||||
import mime from 'mime-types';
|
||||
|
||||
/**
|
||||
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
||||
|
@ -1613,11 +1606,9 @@ export class GBMinService {
|
|||
connected(remoteId: string, connections: number): void { },
|
||||
messageIn(...params): void {
|
||||
params.shift();
|
||||
GBLogEx.verbose(0, '[IN] ' + params);
|
||||
},
|
||||
messageOut(...params): void {
|
||||
params.shift();
|
||||
GBLogEx.verbose(0, '[OUT] ' + params);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
20
src/app.ts
20
src/app.ts
|
@ -59,9 +59,6 @@ import * as winston from 'winston-logs-display';
|
|||
import { RootData } from './RootData.js';
|
||||
import { GBSSR } from '../packages/core.gbapp/services/GBSSR.js';
|
||||
import { Mutex } from 'async-mutex';
|
||||
import { setFlagsFromString } from 'v8';
|
||||
import { runInNewContext } from 'vm';
|
||||
|
||||
|
||||
/**
|
||||
* General Bots open-core entry point.
|
||||
|
@ -79,23 +76,6 @@ export class GBServer {
|
|||
GBConfigService.init();
|
||||
const port = GBConfigService.getServerPort();
|
||||
|
||||
setFlagsFromString('--expose_gc');
|
||||
|
||||
const runGC = () => {
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
// Do something here
|
||||
GBLog.info('Running GC...');
|
||||
|
||||
const gc = runInNewContext('gc'); // nocommit
|
||||
gc();
|
||||
runGC();
|
||||
}, 5 * 60 * 1000);
|
||||
}
|
||||
runGC();
|
||||
|
||||
|
||||
if (process.env.TEST_SHELL) {
|
||||
GBLog.info(`Running TEST_SHELL: ${process.env.TEST_SHELL}...`);
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue