This commit is contained in:
henrique 2024-08-23 18:14:10 -03:00
commit 76cb157319
18 changed files with 48 additions and 56 deletions

View file

@ -6,6 +6,7 @@ import Path from 'path';
import { exec } from 'child_process'; import { exec } from 'child_process';
import pjson from './package.json' assert { type: 'json' }; import pjson from './package.json' assert { type: 'json' };
// Displays version of Node JS being used at runtime and others attributes. // Displays version of Node JS being used at runtime and others attributes.
process.stdout.write(`General Bots. BotServer@${pjson.version}, botlib@${pjson.dependencies.botlib}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `); process.stdout.write(`General Bots. BotServer@${pjson.version}, botlib@${pjson.dependencies.botlib}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `);
@ -15,8 +16,8 @@ var __dirname = process.env.PWD || process.cwd();
try { try {
var run = () => { var run = () => {
import('./dist/src/app.js').then((gb)=> { import('./dist/src/webapp.js').then((gb)=> {
gb.GBServer.run() gb.GBUI.run()
}); });
}; };
var processDist = () => { var processDist = () => {

View file

@ -124,11 +124,13 @@
"cli-progress": "3.12.0", "cli-progress": "3.12.0",
"cli-spinner": "0.2.10", "cli-spinner": "0.2.10",
"core-js": "3.37.1", "core-js": "3.37.1",
"csv-database": "^0.9.2",
"data-forge": "1.10.2", "data-forge": "1.10.2",
"date-diff": "1.0.2", "date-diff": "1.0.2",
"docximager": "0.0.4", "docximager": "0.0.4",
"docxtemplater": "3.47.4", "docxtemplater": "3.47.4",
"dotenv-extended": "2.9.0", "dotenv-extended": "2.9.0",
"electron": "32.0.1",
"exceljs": "4.4.0", "exceljs": "4.4.0",
"express": "4.19.2", "express": "4.19.2",
"express-remove-route": "1.0.0", "express-remove-route": "1.0.0",
@ -198,7 +200,6 @@
"sequelize": "6.28.2", "sequelize": "6.28.2",
"sequelize-cli": "6.6.0", "sequelize-cli": "6.6.0",
"sequelize-typescript": "2.1.5", "sequelize-typescript": "2.1.5",
"sharp": "0.33.4",
"simple-git": "3.24.0", "simple-git": "3.24.0",
"speakingurl": "14.0.1", "speakingurl": "14.0.1",
"sqlite3": "5.1.7", "sqlite3": "5.1.7",

View file

@ -35,7 +35,7 @@ import { GBServer } from '../../../src/app.js';
import Fs from 'fs'; import Fs from 'fs';
import SwaggerClient from 'swagger-client'; import SwaggerClient from 'swagger-client';
import { spawn } from 'child_process'; import { spawn } from 'child_process';
import { CodeServices } from '../../gpt.gblib/services/CodeServices.js'; import { CodeServices } from '../../llm.gblib/services/CodeServices.js';
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js'; import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
import { GBUtil } from '../../../src/util.js'; import { GBUtil } from '../../../src/util.js';

View file

@ -39,7 +39,6 @@ import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import urlJoin from 'url-join'; import urlJoin from 'url-join';
import { GBServer } from '../../../src/app.js'; import { GBServer } from '../../../src/app.js';
import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js'; import { GBLogEx } from '../../core.gbapp/services/GBLogEx.js';
import sharp from 'sharp';
/** /**
* Image processing services of conversation to be called by BASIC. * Image processing services of conversation to be called by BASIC.
@ -55,22 +54,8 @@ export class ImageProcessingServices {
GBLogEx.info(min, `BASIC: Image Processing SHARPEN ${file}.`); GBLogEx.info(min, `BASIC: Image Processing SHARPEN ${file}.`);
const gbfile = DialogKeywords.getFileByHandle(file); const gbfile = DialogKeywords.getFileByHandle(file);
const data = await sharp(gbfile.data)
.sharpen({
sigma: 2,
m1: 0,
m2: 3,
x1: 3,
y2: 15,
y3: 15
})
.toBuffer();
const newFile = { // TODO: sharp.
filename: gbfile.filename,
data: data
};
return; return;
} }

View file

@ -56,12 +56,11 @@ import Docxtemplater from 'docxtemplater';
import pptxTemplaterModule from 'pptxtemplater'; import pptxTemplaterModule from 'pptxtemplater';
import _ from 'lodash'; import _ from 'lodash';
import { pdfToPng, PngPageOutput } from 'pdf-to-png-converter'; import { pdfToPng, PngPageOutput } from 'pdf-to-png-converter';
import sharp from 'sharp';
import ImageModule from 'open-docxtemplater-image-module'; import ImageModule from 'open-docxtemplater-image-module';
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js'; import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
import { WebAutomationServices } from './WebAutomationServices.js'; import { WebAutomationServices } from './WebAutomationServices.js';
import { KeywordsExpressions } from './KeywordsExpressions.js'; import { KeywordsExpressions } from './KeywordsExpressions.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js'; import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import mime from 'mime-types'; import mime from 'mime-types';
import exts from '../../../extensions.json' assert { type: 'json' }; import exts from '../../../extensions.json' assert { type: 'json' };
import { SecService } from '../../security.gbapp/services/SecService.js'; import { SecService } from '../../security.gbapp/services/SecService.js';
@ -1998,11 +1997,11 @@ export class SystemKeywords {
return (orientation || 0) >= 5 ? [height, width] : [width, height]; return (orientation || 0) >= 5 ? [height, width] : [width, height];
}; };
const metadata = await sharp(buf).metadata(); // TODO: sharp. const metadata = await sharp(buf).metadata();
const size = getNormalSize({ const size = getNormalSize({
width: metadata['width'], width: 400,
height: metadata['height'], height: 400,
orientation: metadata['orientation'] orientation: '0'
}); });
url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(imageName)); url = urlJoin(GBServer.globals.publicAddress, min.botId, 'cache', Path.basename(imageName));
images[index++] = { url: url, size: size, buf: buf }; images[index++] = { url: url, size: size, buf: buf };

View file

@ -53,7 +53,6 @@ import puppeteer, { Page } from 'puppeteer';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter'; import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
import { Document } from 'langchain/document'; import { Document } from 'langchain/document';
import getColors from 'get-image-colors'; import getColors from 'get-image-colors';
import sharp from 'sharp';
import { import {
GBDialogStep, GBDialogStep,
@ -83,7 +82,7 @@ import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import { GBVMService } from '../../basic.gblib/services/GBVMService.js'; import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js'; import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { GBMinService } from '../../core.gbapp/services/GBMinService.js'; import { GBMinService } from '../../core.gbapp/services/GBMinService.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js'; import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import { GBUtil } from '../../../src/util.js'; import { GBUtil } from '../../../src/util.js';
/** /**
@ -1070,14 +1069,14 @@ export class KBService implements IGBKBService {
const logoBinary = await page.goto(logo); const logoBinary = await page.goto(logo);
const buffer = await logoBinary.buffer(); const buffer = await logoBinary.buffer();
const logoFilename = Path.basename(logo); const logoFilename = Path.basename(logo);
sharp(buffer) // TODO: sharp(buffer)
.resize({ // .resize({
width: 48, // width: 48,
height: 48, // height: 48,
fit: 'inside', // Resize the image to fit within the specified dimensions // fit: 'inside', // Resize the image to fit within the specified dimensions
withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller // withoutEnlargement: true // Don't enlarge the image if its dimensions are already smaller
}) // })
.toFile(Path.join(logoPath, logoFilename)); // .toFile(Path.join(logoPath, logoFilename));
await min.core['setConfig'](min, 'Logo', logoFilename); await min.core['setConfig'](min, 'Logo', logoFilename);
} catch (error) { } catch (error) {
GBLogEx.debug(min, error); GBLogEx.debug(min, error);

View file

@ -47,7 +47,7 @@ import { GBSSR } from '../../core.gbapp/services/GBSSR.js';
import pkg from 'whatsapp-web.js'; import pkg from 'whatsapp-web.js';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js'; import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js';
import { ChatServices } from '../../gpt.gblib/services/ChatServices.js'; import { ChatServices } from '../../llm.gblib/services/ChatServices.js';
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js'; import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
import { GBUtil } from '../../../src/util.js'; import { GBUtil } from '../../../src/util.js';
const { WAState, Client, MessageMedia } = pkg; const { WAState, Client, MessageMedia } = pkg;

View file

@ -1,13 +1,15 @@
import { GBConfigService } from "../packages/core.gbapp/services/GBConfigService"; import { GBConfigService } from '../packages/core.gbapp/services/GBConfigService.js';
import { app, BrowserWindow } from 'electron'; const {app} = (await import('electron')).default;
import path from 'path'; import path from 'path';
import url from 'url'; import url from 'url';
export function runUI() { export function runUI() {
// Create the browser window. // Create the browser window.
const win = new BrowserWindow({ width: 800, height: 600, title: 'General Bots Studio' }); const win = null;// new BrowserWindow({ width: 800, height: 600, title: 'General Bots Studio' });
import('./app.js').then(gb => {
gb.GBServer.run();
// and load the index.html of the app. // and load the index.html of the app.
win.loadURL( win.loadURL(
url.format({ url.format({
@ -16,6 +18,11 @@ import url from 'url';
slashes: true slashes: true
}) })
); );
});
} }
export class GBUI {
static run() {
app.on('ready', runUI); app.on('ready', runUI);
}
}

View file

@ -43,7 +43,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
item: { item: {
id: 23872, id: 23872,
valor: 20, valor: 20,
nome: Caipirinha Limão nome: Guaraná
}, },
itensAcompanhamento: [ itensAcompanhamento: [
{ {
@ -59,7 +59,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
item: { item: {
id: 25510, id: 25510,
valor: 12, valor: 12,
nome: Heineken Lata 350ml nome: Laranja Lata 350ml
}, },
itensAcompanhamento: [], itensAcompanhamento: [],
quantidade: 1, quantidade: 1,
@ -68,7 +68,7 @@ Segue o exemplo do JSON do Pedido, apague os itens e mande um com o pedido feito
], ],
barracaId: ${barraca}, barracaId: ${barraca},
usuarioId: ${operador}, usuarioId: ${operador},
identificadorConta: Rafael, identificadorConta: Areia,
tipoEntregaId: 2, tipoEntregaId: 2,
camposTipoEntrega: { camposTipoEntrega: {
Mesa: 5 Mesa: 5