fix(core.gbapp): Update of all packages and nodejs to 19.1.0.
This commit is contained in:
parent
9393081e58
commit
a315d21cfe
69 changed files with 15490 additions and 11249 deletions
2
.vscode/launch.json.template
vendored
2
.vscode/launch.json.template
vendored
|
@ -6,7 +6,7 @@
|
|||
"request": "launch",
|
||||
"sourceMaps": true,
|
||||
"name": "Debug Program",
|
||||
"program": "${workspaceRoot}/boot.js",
|
||||
"program": "${workspaceRoot}/boot.mjs",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const Fs = require('fs');
|
||||
const Path = require('path');
|
||||
const { exec } = require('child_process');
|
||||
var pjson = require('./package.json');
|
||||
import Fs from 'fs';
|
||||
import Path from 'path';
|
||||
import { exec } from 'child_process';
|
||||
import pjson from './package.json' assert { type: "json" };
|
||||
import * as GBServer from "./dist/src/app.js";
|
||||
|
||||
// Displays version of Node JS being used at runtime and others attributes.
|
||||
|
||||
|
@ -19,15 +20,14 @@ console.log(`[GB Runtime] debugPort = ${process.debugPort}`);
|
|||
var now = () => {
|
||||
return (new Date()).toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC';
|
||||
}
|
||||
|
||||
var __dirname = process.env.PWD;
|
||||
try {
|
||||
|
||||
var run = () => {
|
||||
|
||||
console.log(`[GB Runtime] Initializing General Bots (BotServer)...`);
|
||||
const GBServer = require("./dist/src/app").GBServer
|
||||
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
|
||||
process.env.PWD = __dirname;
|
||||
GBServer.run();
|
||||
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${import.meta.url}'`);
|
||||
GBServer.GBServer.run();
|
||||
}
|
||||
var processDist = () => {
|
||||
if (!Fs.existsSync('dist')) {
|
2
gbot.cmd
2
gbot.cmd
|
@ -12,4 +12,4 @@ ECHO Compiling...
|
|||
CALL node_modules\.bin\tsc
|
||||
|
||||
:ALLSET
|
||||
node boot.js
|
||||
node boot.cjs
|
||||
|
|
24743
package-lock.json
generated
24743
package-lock.json
generated
File diff suppressed because it is too large
Load diff
187
package.json
187
package.json
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"name": "botserver",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.0",
|
||||
"type": "module",
|
||||
"description": "General Bot Community Edition open-core server.",
|
||||
"main": "./boot.js",
|
||||
"main": "./boot.mjs",
|
||||
"bugs": "https://github.com/pragmatismo-io/BotServer/issues",
|
||||
"homepage": "https://github.com/pragmatismo-io/BotServer/#readme",
|
||||
"contributors": [
|
||||
|
@ -13,13 +14,13 @@
|
|||
"Dário Vieira <dario.junior3@gmail.com>"
|
||||
],
|
||||
"engines": {
|
||||
"node": "=14.19.3"
|
||||
"node": "=19.1.0"
|
||||
},
|
||||
"license": "AGPL-3.0",
|
||||
"preferGlobal": true,
|
||||
"private": false,
|
||||
"bin": {
|
||||
"gbot": "./boot.js"
|
||||
"gbot": "./boot.cjs"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -33,7 +34,7 @@
|
|||
"build-gbui": "cd packages/default.gbui && echo SKIP_PREFLIGHT_CHECK=true >.env && npm install && npm run build",
|
||||
"build-docs": "typedoc --options typedoc.json src/",
|
||||
"test": "node test.js",
|
||||
"start": "node ./boot.js",
|
||||
"start": "node ./boot.cjs",
|
||||
"reverse-proxy": "node_modules/.bin/ngrok http 4242",
|
||||
"watch:build": "tsc --watch",
|
||||
"posttypedoc": "shx cp .nojekyll docs/reference/.nojekyll",
|
||||
|
@ -49,21 +50,21 @@
|
|||
"commit": "git-cz"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure/cognitiveservices-computervision": "8.1.0",
|
||||
"@azure/ms-rest-js": "2.5.1",
|
||||
"@google-cloud/pubsub": "2.13.0",
|
||||
"@google-cloud/translate": "6.2.6",
|
||||
"@hubspot/api-client": "5.0.0",
|
||||
"@microsoft/microsoft-graph-client": "2.2.1",
|
||||
"@semantic-release/changelog": "5.0.1",
|
||||
"@semantic-release/exec": "5.0.0",
|
||||
"@semantic-release/git": "9.0.0",
|
||||
"@sendgrid/mail": "7.4.4",
|
||||
"@types/node": "8.0.0",
|
||||
"@types/validator": "13.1.4",
|
||||
"adal-node": "0.2.2",
|
||||
"adm-zip": "0.5.6",
|
||||
"alasql": "^1.7.3",
|
||||
"@azure/cognitiveservices-computervision": "8.2.0",
|
||||
"@azure/ms-rest-js": "2.6.2",
|
||||
"@google-cloud/pubsub": "3.2.1",
|
||||
"@google-cloud/translate": "7.0.4",
|
||||
"@hubspot/api-client": "7.1.2",
|
||||
"@microsoft/microsoft-graph-client": "3.0.4",
|
||||
"@semantic-release/changelog": "6.0.1",
|
||||
"@semantic-release/exec": "6.0.3",
|
||||
"@semantic-release/git": "10.0.1",
|
||||
"@sendgrid/mail": "7.7.0",
|
||||
"@types/node": "18.11.9",
|
||||
"@types/validator": "13.7.10",
|
||||
"adal-node": "0.2.3",
|
||||
"adm-zip": "0.5.9",
|
||||
"alasql": "2.1.6",
|
||||
"any-shell-escape": "0.1.1",
|
||||
"async-promises": "0.2.3",
|
||||
"azure-arm-cognitiveservices": "3.0.0",
|
||||
|
@ -73,63 +74,63 @@
|
|||
"azure-arm-website": "5.7.0",
|
||||
"azure-search-client": "3.1.5",
|
||||
"basic-auth": "2.0.1",
|
||||
"billboard.js": "^3.4.1",
|
||||
"billboard.js": "3.6.3",
|
||||
"bluebird": "3.7.2",
|
||||
"body-parser": "1.19.0",
|
||||
"botbuilder": "4.11.0",
|
||||
"botbuilder-adapter-facebook": "1.0.11",
|
||||
"botbuilder-ai": "4.11.0",
|
||||
"botbuilder-dialogs": "4.11.0",
|
||||
"botframework-connector": "4.11.0",
|
||||
"botlib": "1.10.9",
|
||||
"c3-chart-maker": "^0.2.8",
|
||||
"chrome-remote-interface": "^0.31.3",
|
||||
"cli-progress": "^3.11.2",
|
||||
"body-parser": "1.20.1",
|
||||
"botbuilder": "4.18.0",
|
||||
"botbuilder-adapter-facebook": "1.0.12",
|
||||
"botbuilder-ai": "4.18.0",
|
||||
"botbuilder-dialogs": "4.18.0",
|
||||
"botframework-connector": "4.18.0",
|
||||
"botlib": "3.0.0",
|
||||
"c3-chart-maker": "0.2.8",
|
||||
"chrome-remote-interface": "0.31.3",
|
||||
"cli-progress": "3.11.2",
|
||||
"cli-spinner": "0.2.10",
|
||||
"core-js": "3.14.0",
|
||||
"data-forge": "^1.9.5",
|
||||
"date-diff": "0.2.2",
|
||||
"debugger-api": "^0.1.2",
|
||||
"docxtemplater": "^3.31.1",
|
||||
"core-js": "3.26.1",
|
||||
"data-forge": "1.9.6",
|
||||
"date-diff": "1.0.2",
|
||||
"debugger-api": "0.1.2",
|
||||
"docxtemplater": "3.32.4",
|
||||
"dotenv-extended": "2.9.0",
|
||||
"exceljs": "4.2.1",
|
||||
"express": "4.17.1",
|
||||
"exceljs": "4.3.0",
|
||||
"express": "4.18.2",
|
||||
"express-remove-route": "1.0.0",
|
||||
"ffmpeg-static": "4.3.0",
|
||||
"google-libphonenumber": "3.2.21",
|
||||
"googleapis": "75.0.0",
|
||||
"ibm-watson": "6.1.1",
|
||||
"indent.js": "^0.3.5",
|
||||
"js-beautify": "1.13.13",
|
||||
"keyv": "^4.5.0",
|
||||
"koa": "^2.13.4",
|
||||
"koa-body": "^5.0.0",
|
||||
"koa-router": "^12.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"luxon": "2.0.2",
|
||||
"mammoth": "^1.4.21",
|
||||
"marked": "2.0.7",
|
||||
"ffmpeg-static": "5.1.0",
|
||||
"google-libphonenumber": "3.2.31",
|
||||
"googleapis": "109.0.1",
|
||||
"ibm-watson": "7.1.2",
|
||||
"indent.js": "0.3.5",
|
||||
"js-beautify": "1.14.7",
|
||||
"keyv": "4.5.2",
|
||||
"koa": "2.13.4",
|
||||
"koa-body": "6.0.1",
|
||||
"koa-router": "12.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"luxon": "3.1.0",
|
||||
"mammoth": "1.5.1",
|
||||
"marked": "4.2.2",
|
||||
"momentjs": "2.0.0",
|
||||
"ms-rest-azure": "3.0.0",
|
||||
"ms-rest-azure": "3.0.2",
|
||||
"nexmo": "2.9.1",
|
||||
"node-cron": "3.0.0",
|
||||
"node-nlp": "^3.10.2",
|
||||
"node-tesseract-ocr": "^2.2.1",
|
||||
"npm": "7.21.0",
|
||||
"node-cron": "3.0.2",
|
||||
"node-nlp": "3.10.2",
|
||||
"node-tesseract-ocr": "2.2.1",
|
||||
"npm": "9.1.2",
|
||||
"opn": "6.0.0",
|
||||
"pdf-extraction": "1.0.2",
|
||||
"pdfkit": "^0.13.0",
|
||||
"phone": "2.4.21",
|
||||
"pizzip": "^3.0.6",
|
||||
"pdfkit": "0.13.0",
|
||||
"phone": "3.1.30",
|
||||
"pizzip": "3.1.3",
|
||||
"pptxtemplater": "1.0.5",
|
||||
"pragmatismo-io-framework": "1.0.20",
|
||||
"prism-media": "1.3.1",
|
||||
"public-ip": "4.0.4",
|
||||
"punycode": "^2.1.1",
|
||||
"puppeteer": "13.7.0",
|
||||
"puppeteer-extra": "^3.3.4",
|
||||
"puppeteer-extra-plugin-stealth": "2.4.5",
|
||||
"qrcode": "^1.5.0",
|
||||
"prism-media": "1.3.4",
|
||||
"public-ip": "6.0.1",
|
||||
"punycode": "2.1.1",
|
||||
"puppeteer": "19.2.2",
|
||||
"puppeteer-extra": "3.3.4",
|
||||
"puppeteer-extra-plugin-stealth": "2.11.1",
|
||||
"qrcode": "1.5.1",
|
||||
"qrcode-terminal": "0.12.0",
|
||||
"readline": "1.3.0",
|
||||
"reflect-metadata": "0.1.13",
|
||||
|
@ -138,50 +139,50 @@
|
|||
"rimraf": "3.0.2",
|
||||
"safe-buffer": "5.2.1",
|
||||
"scanf": "1.1.2",
|
||||
"sequelize": "6.5.0",
|
||||
"sequelize-cli": "6.2.0",
|
||||
"sequelize-typescript": "2.1.0",
|
||||
"simple-git": "2.39.1",
|
||||
"sequelize": "6.25.6",
|
||||
"sequelize-cli": "6.5.2",
|
||||
"sequelize-typescript": "2.1.5",
|
||||
"simple-git": "3.15.0",
|
||||
"speakingurl": "14.0.1",
|
||||
"sppull": "2.7.0",
|
||||
"sppull": "3.0.1",
|
||||
"ssr-for-bots": "1.0.1-c",
|
||||
"strict-password-generator": "1.1.2",
|
||||
"swagger-client": "2.1.18",
|
||||
"tabulator-tables": "^5.2.6",
|
||||
"tedious": "14.0.0",
|
||||
"tabulator-tables": "5.4.2",
|
||||
"tedious": "15.1.2",
|
||||
"textract": "2.5.0",
|
||||
"twitter-api-v2": "1.12.7",
|
||||
"typescript": "3.6.4",
|
||||
"typescript-rest-rpc": "^1.0.10",
|
||||
"url-join": "4.0.1",
|
||||
"twitter-api-v2": "1.12.9",
|
||||
"typescript": "4.9.3",
|
||||
"typescript-rest-rpc": "1.0.10",
|
||||
"url-join": "5.0.0",
|
||||
"vbscript-to-typescript": "1.0.8",
|
||||
"vhost": "^3.0.2",
|
||||
"vm2": "^3.9.11",
|
||||
"vm2-process": "^2.1.1",
|
||||
"vhost": "3.0.2",
|
||||
"vm2": "3.9.11",
|
||||
"vm2-process": "2.1.1",
|
||||
"walk-promise": "0.2.0",
|
||||
"washyourmouthoutwithsoap": "1.0.2",
|
||||
"whatsapp-web.js": "1.18.0",
|
||||
"winston": "^2.4.2",
|
||||
"winston-logs-display": "^1.0.0",
|
||||
"yarn": "^1.22.19"
|
||||
"whatsapp-web.js": "1.18.3",
|
||||
"winston": "3.8.2",
|
||||
"winston-logs-display": "1.0.0",
|
||||
"yarn": "1.22.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/puppeteer": "5.4.6",
|
||||
"@types/url-join": "4.0.0",
|
||||
"@types/puppeteer": "5.4.7",
|
||||
"@types/url-join": "4.0.1",
|
||||
"@types/winston": "2.4.4",
|
||||
"ban-sensitive-files": "1.9.15",
|
||||
"commitizen": "4.2.4",
|
||||
"ban-sensitive-files": "1.9.18",
|
||||
"commitizen": "4.2.5",
|
||||
"cz-conventional-changelog": "3.3.0",
|
||||
"dependency-check": "4.1.0",
|
||||
"git-issues": "1.3.1",
|
||||
"license-checker": "25.0.1",
|
||||
"ngrok": "4.0.1",
|
||||
"ngrok": "4.3.3",
|
||||
"nsp": "3.2.1",
|
||||
"prettier-standard": "16.4.1",
|
||||
"semantic-release": "17.4.3",
|
||||
"simple-commit-message": "4.1.2",
|
||||
"semantic-release": "19.0.5",
|
||||
"simple-commit-message": "4.1.3",
|
||||
"travis-deploy-once": "5.0.11",
|
||||
"ts-node": "10.0.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tslint": "6.1.2"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
|
|
@ -36,14 +36,14 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
import crypto from 'crypto';
|
||||
import urlJoin from 'url-join';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog, GBLog, IGBPackage } from 'botlib';
|
||||
const urlJoin = require('url-join');
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBAdminService } from '../services/GBAdminService';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import { GBAdminService } from '../services/GBAdminService.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { AdminDialog } from './dialogs/AdminDialog';
|
||||
import { GuaribasAdmin } from './models/AdminModel';
|
||||
import { AdminDialog } from './dialogs/AdminDialog.js';
|
||||
import { GuaribasAdmin } from './models/AdminModel.js';
|
||||
|
||||
/**
|
||||
* The package for admin.gbapp.
|
||||
|
|
|
@ -52,20 +52,20 @@ import {
|
|||
export class GuaribasAdmin extends Model<GuaribasAdmin> {
|
||||
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public key: string;
|
||||
declare key: string;
|
||||
|
||||
@Column(DataType.STRING(4000))
|
||||
public value: string;
|
||||
declare value: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
}
|
||||
|
|
|
@ -39,18 +39,18 @@
|
|||
import { AuthenticationContext, TokenResponse } from 'adal-node';
|
||||
import { GBLog, GBMinInstance, IGBAdminService, IGBCoreService, IGBDeployer, IGBInstance } from 'botlib';
|
||||
import { FindOptions } from 'sequelize/types';
|
||||
const urlJoin = require('url-join');
|
||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||
import { GBSharePointService } from '../../sharepoint.gblib/services/SharePointService';
|
||||
import { GuaribasAdmin } from '../models/AdminModel';
|
||||
const Path = require('path');
|
||||
const msRestAzure = require('ms-rest-azure');
|
||||
const PasswordGenerator = require('strict-password-generator').default;
|
||||
const crypto = require("crypto");
|
||||
import urlJoin from 'url-join';
|
||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService.js';
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel.js';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService.js';
|
||||
import { GBSharePointService } from '../../sharepoint.gblib/services/SharePointService.js';
|
||||
import { GuaribasAdmin } from '../models/AdminModel.js';
|
||||
import msRestAzure from 'ms-rest-azure';
|
||||
import Path from 'path';
|
||||
import PasswordGenerator from 'strict-password-generator';
|
||||
import crypto from 'crypto';
|
||||
|
||||
/**
|
||||
* Services for server administration.
|
||||
|
@ -68,25 +68,27 @@ export class GBAdminService implements IGBAdminService {
|
|||
}
|
||||
|
||||
public static generateUuid(): string {
|
||||
return msRestAzure.generateUuid();
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
|
||||
public static getNodeVersion() {
|
||||
return "19.1.0";
|
||||
const packageJson = urlJoin(process.cwd(), 'package.json');
|
||||
// tslint:disable-next-line: non-literal-require
|
||||
const pjson = require(packageJson);
|
||||
// TODO
|
||||
// const pjson = require(packageJson);
|
||||
|
||||
return pjson.engines.node.replace('=', '');
|
||||
// return pjson.engines.node.replace('=', '');
|
||||
}
|
||||
|
||||
public static async getADALTokenFromUsername(username: string, password: string) {
|
||||
const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password);
|
||||
|
||||
return credentials.tokenCache._entries[0].accessToken;
|
||||
return (credentials as any).tokenCache._entries[0].accessToken;
|
||||
}
|
||||
|
||||
public static async getADALCredentialsFromUsername(username: string, password: string) {
|
||||
return await msRestAzure.loginWithUsernamePassword(username, password);
|
||||
return await msRestAzure.loginWithUsernamePassword(username, password)
|
||||
}
|
||||
|
||||
public static getMobileCode() {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { GuaribasConversation, GuaribasConversationMessage } from './models';
|
||||
import { GuaribasConversation, GuaribasConversationMessage } from './models/index.js';
|
||||
|
||||
/**
|
||||
* .gblib Package handler.
|
||||
|
|
|
@ -54,9 +54,9 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript';
|
||||
|
||||
import { GuaribasChannel, GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||
import { GuaribasSubject } from '../../kb.gbapp/models';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { GuaribasChannel, GuaribasInstance } from '../../core.gbapp/models/GBModel.js';
|
||||
import { GuaribasSubject } from '../../kb.gbapp/models/index.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
|
||||
/**
|
||||
* A conversation that groups many messages.
|
||||
|
@ -67,45 +67,45 @@ export class GuaribasConversation extends Model<GuaribasConversation> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public conversationId: number;
|
||||
declare conversationId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasSubject)
|
||||
@Column(DataType.INTEGER)
|
||||
public startSubjectId: number;
|
||||
declare startSubjectId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasSubject)
|
||||
public startSubject: GuaribasSubject;
|
||||
declare startSubject: GuaribasSubject;
|
||||
|
||||
@ForeignKey(() => GuaribasChannel)
|
||||
@Column(DataType.INTEGER)
|
||||
public channelId: string;
|
||||
declare channelId: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
public rateDate: Date;
|
||||
declare rateDate: Date;
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
public rate: number;
|
||||
declare rate: number;
|
||||
|
||||
@Column(DataType.STRING(512))
|
||||
public feedback: string;
|
||||
declare feedback: string;
|
||||
|
||||
@CreatedAt
|
||||
@Column(DataType.DATE)
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public text: string;
|
||||
declare text: string;
|
||||
|
||||
@ForeignKey(() => GuaribasUser)
|
||||
@Column(DataType.INTEGER)
|
||||
public startedByUserId: number;
|
||||
declare startedByUserId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasUser)
|
||||
public startedBy: GuaribasUser;
|
||||
declare startedBy: GuaribasUser;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,41 +117,41 @@ export class GuaribasConversationMessage extends Model<GuaribasConversationMessa
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public conversationMessageId: number;
|
||||
declare conversationMessageId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasSubject)
|
||||
@Column(DataType.INTEGER)
|
||||
public subjectId: number;
|
||||
declare subjectId: number;
|
||||
|
||||
@Column(DataType.TEXT)
|
||||
public content: string;
|
||||
declare content: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
|
||||
//tslint:disable-next-line:no-use-before-declare
|
||||
@ForeignKey(() => GuaribasConversation)
|
||||
@Column(DataType.INTEGER)
|
||||
public conversationId: number;
|
||||
declare conversationId: number;
|
||||
|
||||
//tslint:disable-next-line:no-use-before-declare
|
||||
@BelongsTo(() => GuaribasConversation)
|
||||
public conversation: GuaribasConversation;
|
||||
declare conversation: GuaribasConversation;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasUser)
|
||||
@Column(DataType.INTEGER)
|
||||
public userId: number;
|
||||
declare userId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasUser)
|
||||
public user: GuaribasUser;
|
||||
declare user: GuaribasUser;
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
|
||||
import { AzureText } from 'pragmatismo-io-framework';
|
||||
import { FindOptions } from 'sequelize/types';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { GuaribasConversation, GuaribasConversationMessage } from '../models';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import { GuaribasConversation, GuaribasConversationMessage } from '../models/index.js';
|
||||
|
||||
/**
|
||||
* Base services for Bot Analytics.
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, IGBInstallationDeployer, IGBInstance } from 'botlib';
|
||||
import * as fs from 'fs';
|
||||
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
|
||||
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
|
||||
const scanf = require('scanf');
|
||||
import * as Fs from 'fs';
|
||||
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService.js';
|
||||
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService.js';
|
||||
import scanf from 'scanf';
|
||||
|
||||
/**
|
||||
* Handles command-line dialog for getting info for Boot Bot.
|
||||
|
@ -49,7 +49,7 @@ export class StartDialog {
|
|||
public static async createBaseInstance(installationDeployer: IGBInstallationDeployer) {
|
||||
// No .env so asks for cloud credentials to start a new farm.
|
||||
|
||||
if (!fs.existsSync(`.env`)) {
|
||||
if (!Fs.existsSync(`.env`)) {
|
||||
process.stdout.write(
|
||||
'A empty enviroment is detected. To start automatic deploy, please enter some information:\n'
|
||||
);
|
||||
|
|
|
@ -36,31 +36,27 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { HttpHeaders, HttpMethods, ServiceClient, WebResource } from '@azure/ms-rest-js';
|
||||
import urlJoin from 'url-join';
|
||||
import { HttpMethods, ServiceClient, WebResource } from '@azure/ms-rest-js';
|
||||
import { CognitiveServicesManagementClient } from 'azure-arm-cognitiveservices';
|
||||
import { ResourceManagementClient, SubscriptionClient } from 'azure-arm-resource';
|
||||
import { SearchManagementClient } from 'azure-arm-search';
|
||||
import { SqlManagementClient } from 'azure-arm-sql';
|
||||
import { WebSiteManagementClient } from 'azure-arm-website';
|
||||
//tslint:disable-next-line:no-submodule-imports
|
||||
import { AppServicePlan, Site, SiteConfigResource, SiteLogsConfig, SiteSourceControl } from 'azure-arm-website/lib/models';
|
||||
import { AppServicePlan, Site, SiteLogsConfig, SiteSourceControl } from 'azure-arm-website/lib/models/index.js';
|
||||
import { GBLog, IGBInstallationDeployer, IGBInstance, IGBDeployer, IGBCoreService } from 'botlib';
|
||||
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
|
||||
import { GBCorePackage } from '../../../packages/core.gbapp';
|
||||
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
|
||||
import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer';
|
||||
const MicrosoftGraph = require("@microsoft/microsoft-graph-client");
|
||||
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService.js';
|
||||
import { GBCorePackage } from '../../../packages/core.gbapp/index.js';
|
||||
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService.js';
|
||||
import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer.js';
|
||||
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models/index.js';
|
||||
import MicrosoftGraph from "@microsoft/microsoft-graph-client";
|
||||
import Spinner from 'cli-spinner';
|
||||
import * as publicIp from 'public-ip';
|
||||
|
||||
const Spinner = require('cli-spinner').Spinner;
|
||||
// tslint:disable-next-line: no-submodule-imports
|
||||
|
||||
// tslint:disable-next-line:no-submodule-imports
|
||||
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models';
|
||||
const urlJoin = require('url-join');
|
||||
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
|
||||
const publicIp = require('public-ip');
|
||||
const WebSiteResponseTimeout = 900;
|
||||
|
||||
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
|
||||
/**
|
||||
* Deployer for Microsoft cloud.
|
||||
*/
|
||||
|
@ -347,7 +343,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password);
|
||||
const storageClient = new SqlManagementClient(credentials, subscriptionId);
|
||||
|
||||
const ip = await publicIp.v4();
|
||||
const ip = await publicIp.publicIpv4();
|
||||
let params = {
|
||||
startIpAddress: ip,
|
||||
endIpAddress: ip
|
||||
|
@ -404,7 +400,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
await this.createSearch(name, searchName, instance.cloudLocation);
|
||||
const searchKeys = await this.searchClient.adminKeys.get(name, searchName);
|
||||
instance.searchHost = `${searchName}.search.windows.net`;
|
||||
instance.searchIndex = 'azuresql-index';
|
||||
instance.searchIndex = 'azuresql-index.js';
|
||||
instance.searchIndexer = 'azuresql-indexer';
|
||||
instance.searchKey = searchKeys.primaryKey;
|
||||
|
||||
|
|
|
@ -37,15 +37,16 @@
|
|||
'use strict';
|
||||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { GuaribasSchedule } from '../core.gbapp/models/GBModel';
|
||||
import { GuaribasSchedule } from '../core.gbapp/models/GBModel.js';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { createServerRouter } from "typescript-rest-rpc/lib/server"
|
||||
import { DialogKeywords } from './services/DialogKeywords';
|
||||
const Koa = require('koa');
|
||||
import { createServerRouter } from "typescript-rest-rpc/lib/server.js"
|
||||
import { DialogKeywords } from './services/DialogKeywords.js';
|
||||
import * as koaBody from "koa-body"
|
||||
import { SystemKeywords } from './services/SystemKeywords';
|
||||
import { WebAutomationKeywords } from './services/WebAutomationKeywords';
|
||||
import { DebuggerService } from './services/DebuggerService';
|
||||
import { SystemKeywords } from './services/SystemKeywords.js';
|
||||
import { WebAutomationKeywords } from './services/WebAutomationKeywords.js';
|
||||
import { DebuggerService } from './services/DebuggerService.js';
|
||||
import Koa from 'koa';
|
||||
|
||||
const app = new Koa()
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,7 @@ export class GBBasicPackage implements IGBPackage {
|
|||
|
||||
public async loadPackage(core: IGBCoreService, sequelize: Sequelize): Promise<void> {
|
||||
core.sequelize.addModels([GuaribasSchedule]);
|
||||
app.use(koaBody({ multipart: true }));
|
||||
app.use(koaBody.koaBody({ multipart: true }));
|
||||
app.listen(1111);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,31 +49,31 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript';
|
||||
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel.js';
|
||||
|
||||
@Table
|
||||
//tslint:disable-next-line:max-classes-per-file
|
||||
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
||||
|
||||
@Column (DataType.STRING(255))
|
||||
public name: string;
|
||||
declare name: string;
|
||||
|
||||
@Column (DataType.STRING(255))
|
||||
public schedule: string;
|
||||
declare schedule: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR';
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR.js';
|
||||
|
||||
export class ChartServices {
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, GBMinInstance } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { DialogKeywords } from './DialogKeywords';
|
||||
const Swagger = require('swagger-client');
|
||||
const fs = require('fs');
|
||||
const { spawn } = require('child_process');
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import { DialogKeywords } from './DialogKeywords.js';
|
||||
import Fs from 'fs';
|
||||
import Swagger from 'swagger-client';
|
||||
import { spawn } from 'child_process';
|
||||
|
||||
/**
|
||||
* Web Automation services of conversation to be called by BASIC.
|
||||
|
@ -299,7 +299,7 @@ export class DebuggerService {
|
|||
let min: GBMinInstance = GBServer.globals.minInstances.filter(p => p.instance.botId === botId)[0];
|
||||
|
||||
this.client = await new Swagger({
|
||||
spec: JSON.parse(fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||
usePromise: true
|
||||
});
|
||||
this.client.clientAuthorizations.add(
|
||||
|
|
|
@ -33,36 +33,31 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, GBMinInstance } from 'botlib';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
import { ChartServices } from './ChartServices';
|
||||
const urlJoin = require('url-join');
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { SystemKeywords } from './SystemKeywords';
|
||||
import { GBMinService } from '../../core.gbapp/services/GBMinService';
|
||||
import { HubSpotServices } from '../../hubspot.gblib/services/HubSpotServices';
|
||||
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
import { ChartServices } from './ChartServices.js';
|
||||
import urlJoin from 'url-join';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { SystemKeywords } from './SystemKeywords.js';
|
||||
import * as wpp from 'whatsapp-web.js';
|
||||
import { HubSpotServices } from '../../hubspot.gblib/services/HubSpotServices.js';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import * as request from 'request-promise-native';
|
||||
import { Messages } from '../strings';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import { Messages } from '../strings.js';
|
||||
import * as Fs from 'fs';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
|
||||
|
||||
const DateDiff = require('date-diff');
|
||||
const { Buttons } = require('whatsapp-web.js');
|
||||
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||
const phone = require('phone');
|
||||
|
||||
const Path = require('path');
|
||||
const sgMail = require('@sendgrid/mail');
|
||||
var mammoth = require("mammoth");
|
||||
const qrcode = require('qrcode');
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import phoneUtil from 'google-libphonenumber';
|
||||
import phone from 'phone';
|
||||
import DateDiff from 'date-diff';
|
||||
import { Buttons } from 'whatsapp-web.js';
|
||||
import tesseract from 'node-tesseract-ocr';
|
||||
import Path from 'path';
|
||||
import sgMail from '@sendgrid/mail';
|
||||
import mammoth from 'mammoth';
|
||||
import qrcode from 'qrcode';
|
||||
|
||||
/**
|
||||
* Base services of conversation to be called by BASIC.
|
||||
|
@ -232,7 +227,7 @@ export class DialogKeywords {
|
|||
*/
|
||||
public async getOCR({localFile}) {
|
||||
GBLog.info(`BASIC: OCR processing on ${localFile}.`);
|
||||
const tesseract = require("node-tesseract-ocr")
|
||||
|
||||
|
||||
const config = {
|
||||
lang: "eng",
|
||||
|
@ -290,8 +285,6 @@ export class DialogKeywords {
|
|||
* @example list = ACTIVE TASKS
|
||||
*/
|
||||
public async getActiveTasks({}) {
|
||||
let s = new HubSpotServices(null, null, process.env.HUBSPOT_KEY);
|
||||
return await s.getActiveTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,9 +293,6 @@ export class DialogKeywords {
|
|||
* @example CREATE DEAL dealname,contato,empresa,amount
|
||||
*/
|
||||
public async createDeal({dealName, contact, company, amount}) {
|
||||
let s = new HubSpotServices(null, null, process.env.HUBSPOT_KEY);
|
||||
let deal = await s.createDeal(dealName, contact, company, amount);
|
||||
return deal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,8 +301,6 @@ export class DialogKeywords {
|
|||
* @example list = FIND CONTACT "Sandra"
|
||||
*/
|
||||
public async fndContact({name}) {
|
||||
let s = new HubSpotServices(null, null, process.env.HUBSPOT_KEY);
|
||||
return await s.searchContact(name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -703,7 +691,7 @@ export class DialogKeywords {
|
|||
response = await request.get(options);
|
||||
}
|
||||
|
||||
fs.writeFile(localFileName, response, (fsError) => {
|
||||
Fs.writeFile(localFileName, response, (fsError) => {
|
||||
if (fsError) {
|
||||
throw fsError;
|
||||
}
|
||||
|
@ -772,12 +760,12 @@ export class DialogKeywords {
|
|||
let i = 0;
|
||||
await CollectionUtil.asyncForEach(args, async arg => {
|
||||
i++;
|
||||
// DISABLED: choices.push({ body: arg, id: `button${i}` });
|
||||
choices.push({ body: arg, id: `button${i}` });
|
||||
await this.talk(arg);
|
||||
});
|
||||
|
||||
// DISABLED const button = new Buttons(Messages[locale].choices, choices, ' ', ' ');
|
||||
// await this.talk(button);
|
||||
const button = new wpp.Buttons(Messages[locale].choices, choices, ' ', ' ');
|
||||
// TODO: await this.talk(button);
|
||||
|
||||
GBLog.info(`BASIC: HEAR with [${args.toString()}] (Asking for input).`);
|
||||
}
|
||||
|
@ -826,7 +814,7 @@ export class DialogKeywords {
|
|||
// await Promise.all(replyPromises);
|
||||
|
||||
// result = {
|
||||
// data: fs.readFileSync(successfulSaves[0]['localPath']),
|
||||
// data: Fs.readFileSync(successfulSaves[0]['localPath']),
|
||||
// filename: successfulSaves[0]['fileName']
|
||||
// };
|
||||
|
||||
|
@ -938,7 +926,7 @@ export class DialogKeywords {
|
|||
|
||||
let phoneNumber;
|
||||
try {
|
||||
phoneNumber = phone(text, 'BRA')[0]; // TODO: Use accordingly to the person.
|
||||
phoneNumber = phone(text, {country:'BRA'})[0]; // TODO: Use accordingly to the person.
|
||||
phoneNumber = phoneUtil.parse(phoneNumber);
|
||||
} catch (error) {
|
||||
await this.talk(Messages[locale].validation_enter_valid_mobile);
|
||||
|
|
|
@ -33,23 +33,21 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, GBMinInstance, GBService, IGBCoreService, GBDialogStep } from 'botlib';
|
||||
import * as fs from 'fs';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { TSCompiler } from './TSCompiler';
|
||||
import * as Fs from 'fs';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { TSCompiler } from './TSCompiler.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { ScheduleServices } from './ScheduleServices';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
//tslint:disable-next-line:no-submodule-imports
|
||||
const urlJoin = require('url-join');
|
||||
const { NodeVM, VMScript } = require('vm2');
|
||||
const { createVm2Pool } = require('./vm2-process/index');
|
||||
const vb2ts = require('./vbscript-to-typescript');
|
||||
const beautify = require('js-beautify').js;
|
||||
const textract = require('textract');
|
||||
const walkPromise = require('walk-promise');
|
||||
const child_process = require('child_process');
|
||||
const Path = require('path');
|
||||
const indent = require('indent.js');
|
||||
import { ScheduleServices } from './ScheduleServices.js';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
import urlJoin from 'url-join';
|
||||
import { NodeVM, VMScript } from 'vm2';
|
||||
import { createVm2Pool } from './vm2-process/index.js';
|
||||
import * as vb2ts from './vbscript-to-typescript.js';
|
||||
import textract from 'textract';
|
||||
import walkPromise from 'walk-promise';
|
||||
import child_process from 'child_process';
|
||||
import Path from 'path';
|
||||
import indent from 'indent.js';
|
||||
/**
|
||||
* @fileoverview Decision was to priorize security(isolation) and debugging,
|
||||
* over a beautiful BASIC transpiler (to be done).
|
||||
|
@ -73,11 +71,11 @@ export class GBVMService extends GBService {
|
|||
const wordFile = filename;
|
||||
const vbsFile = filename.substr(0, filename.indexOf('docx')) + 'vbs';
|
||||
const fullVbsFile = urlJoin(folder, vbsFile);
|
||||
const docxStat = fs.statSync(urlJoin(folder, wordFile));
|
||||
const docxStat = Fs.statSync(urlJoin(folder, wordFile));
|
||||
const interval = 3000; // If compiled is older 30 seconds, then recompile.
|
||||
let writeVBS = true;
|
||||
if (fs.existsSync(fullVbsFile)) {
|
||||
const vbsStat = fs.statSync(fullVbsFile);
|
||||
if (Fs.existsSync(fullVbsFile)) {
|
||||
const vbsStat = Fs.statSync(fullVbsFile);
|
||||
if (docxStat['mtimeMs'] < vbsStat['mtimeMs'] + interval) {
|
||||
writeVBS = false;
|
||||
}
|
||||
|
@ -98,13 +96,13 @@ export class GBVMService extends GBService {
|
|||
await s.deleteScheduleIfAny(min, mainName);
|
||||
}
|
||||
text = text.replace(/^\s*SET SCHEDULE (.*)/gim, '');
|
||||
fs.writeFileSync(urlJoin(folder, vbsFile), text);
|
||||
Fs.writeFileSync(urlJoin(folder, vbsFile), text);
|
||||
}
|
||||
|
||||
// Process node_modules install.
|
||||
|
||||
const node_modules = urlJoin(folder, 'node_modules');
|
||||
if (!fs.existsSync(node_modules)) {
|
||||
if (!Fs.existsSync(node_modules)) {
|
||||
const packageJson = `
|
||||
{
|
||||
"name": "${min.botId}.gbdialog",
|
||||
|
@ -120,7 +118,7 @@ export class GBVMService extends GBService {
|
|||
"vm2": "3.9.11"
|
||||
}
|
||||
}`;
|
||||
fs.writeFileSync(urlJoin(folder, 'package.json'), packageJson);
|
||||
Fs.writeFileSync(urlJoin(folder, 'package.json'), packageJson);
|
||||
|
||||
GBLog.info(`BASIC: Installing .gbdialog node_modules for ${min.botId}...`);
|
||||
const npmPath = urlJoin(process.env.PWD, 'node_modules', '.bin', 'npm');
|
||||
|
@ -131,21 +129,21 @@ export class GBVMService extends GBService {
|
|||
|
||||
const fullFilename = urlJoin(folder, filename);
|
||||
if (process.env.GBDIALOG_HOTSWAP) {
|
||||
fs.watchFile(fullFilename, async () => {
|
||||
Fs.watchFile(fullFilename, async () => {
|
||||
await this.translateBASIC(fullFilename, min, deployer, mainName);
|
||||
});
|
||||
}
|
||||
|
||||
const compiledAt = fs.statSync(fullFilename);
|
||||
const compiledAt = Fs.statSync(fullFilename);
|
||||
const jsfile = urlJoin(folder, `${filename}.js`);
|
||||
|
||||
if (fs.existsSync(jsfile)) {
|
||||
const jsStat = fs.statSync(jsfile);
|
||||
if (Fs.existsSync(jsfile)) {
|
||||
const jsStat = Fs.statSync(jsfile);
|
||||
const interval = 30000; // If compiled is older 30 seconds, then recompile.
|
||||
if (compiledAt.isFile() && compiledAt['mtimeMs'] > jsStat['mtimeMs'] + interval) {
|
||||
await this.translateBASIC(fullFilename, min, deployer, mainName);
|
||||
} else {
|
||||
const parsedCode: string = fs.readFileSync(jsfile, 'utf8');
|
||||
const parsedCode: string = Fs.readFileSync(jsfile, 'utf8');
|
||||
|
||||
min.sandBoxMap[mainName.toLowerCase().trim()] = parsedCode;
|
||||
}
|
||||
|
@ -160,7 +158,7 @@ export class GBVMService extends GBService {
|
|||
|
||||
// Converts General Bots BASIC into regular VBS
|
||||
|
||||
let basicCode: string = fs.readFileSync(filename, 'utf8');
|
||||
let basicCode: string = Fs.readFileSync(filename, 'utf8');
|
||||
|
||||
// Processes END keyword, removing extracode, useful
|
||||
// for development in .gbdialog.
|
||||
|
@ -195,17 +193,17 @@ export class GBVMService extends GBService {
|
|||
// To use include, two /publish will be necessary (for now)
|
||||
// because of alphabet order may raise not found errors.
|
||||
|
||||
let includeCode: string = fs.readFileSync(includeName, 'utf8');
|
||||
let includeCode: string = Fs.readFileSync(includeName, 'utf8');
|
||||
basicCode = basicCode.replace(/^include\b.*$/gmi, includeCode);
|
||||
}
|
||||
} while (include);
|
||||
|
||||
const [vbsCode, jsonMap] = await this.convertGBASICToVBS(min, basicCode);
|
||||
const {code, jsonMap} = await this.convertGBASICToVBS(min, basicCode);
|
||||
const vbsFile = `${filename}.compiled`;
|
||||
const mapFile = `${filename}.map`;
|
||||
|
||||
fs.writeFileSync(vbsFile, vbsCode);
|
||||
fs.writeFileSync(mapFile, JSON.stringify(jsonMap));
|
||||
Fs.writeFileSync(vbsFile, code);
|
||||
Fs.writeFileSync(mapFile, JSON.stringify(jsonMap));
|
||||
|
||||
// Converts VBS into TS.
|
||||
|
||||
|
@ -214,8 +212,8 @@ export class GBVMService extends GBService {
|
|||
// Convert TS into JS.
|
||||
|
||||
const tsfile: string = `${filename}.ts`;
|
||||
let tsCode: string = fs.readFileSync(tsfile, 'utf8');
|
||||
fs.writeFileSync(tsfile, tsCode);
|
||||
let tsCode: string = Fs.readFileSync(tsfile, 'utf8');
|
||||
Fs.writeFileSync(tsfile, tsCode);
|
||||
const tsc = new TSCompiler();
|
||||
tsc.compile([tsfile]);
|
||||
|
||||
|
@ -223,15 +221,15 @@ export class GBVMService extends GBService {
|
|||
|
||||
const jsfile = `${tsfile}.js`.replace('.ts', '');
|
||||
|
||||
if (fs.existsSync(jsfile)) {
|
||||
let code: string = fs.readFileSync(jsfile, 'utf8');
|
||||
if (Fs.existsSync(jsfile)) {
|
||||
let code: string = Fs.readFileSync(jsfile, 'utf8');
|
||||
|
||||
code.replace(/^.*exports.*$/gm, '');
|
||||
|
||||
code = `
|
||||
return (async () => {
|
||||
require('isomorphic-fetch');
|
||||
const rest = require ('typescript-rest-rpc/lib/client');
|
||||
const rest from 'typescript-rest-rpc/lib/client');
|
||||
|
||||
// Interprocess communication from local HTTP to the BotServer.
|
||||
|
||||
|
@ -275,7 +273,7 @@ export class GBVMService extends GBService {
|
|||
|
||||
`;
|
||||
code = indent.js(code, {tabString: '\t'});
|
||||
fs.writeFileSync(jsfile, code);
|
||||
Fs.writeFileSync(jsfile, code);
|
||||
min.sandBoxMap[mainName.toLowerCase().trim()] = code;
|
||||
GBLog.info(`[GBVMService] Finished loading of ${filename}, JavaScript from Word: \n ${code}`);
|
||||
}
|
||||
|
@ -378,7 +376,7 @@ export class GBVMService extends GBService {
|
|||
}
|
||||
|
||||
code = `${allLines.join('\n')}\n%>`;
|
||||
return [code, jsonMap];
|
||||
return {code, jsonMap};
|
||||
}
|
||||
|
||||
private getKeywords() {
|
||||
|
@ -841,7 +839,6 @@ export class GBVMService extends GBService {
|
|||
script: runnerPath
|
||||
});
|
||||
|
||||
const port = run.port;
|
||||
const result = await run(code, { filename: scriptPath, sandbox: sandbox });
|
||||
|
||||
return result;
|
||||
|
|
|
@ -33,13 +33,12 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, GBMinInstance, GBService } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
||||
import { GuaribasSchedule } from '../../core.gbapp/models/GBModel';
|
||||
import { FindOptions } from 'sequelize/types';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
|
||||
import { GuaribasSchedule } from '../../core.gbapp/models/GBModel.js';
|
||||
|
||||
const cron = require('node-cron');
|
||||
import cron from 'node-cron';
|
||||
|
||||
/**
|
||||
* @fileoverview Schedule Services.
|
||||
|
|
|
@ -31,32 +31,28 @@
|
|||
\*****************************************************************************/
|
||||
'use strict';
|
||||
import { GBDialogStep, GBLog, GBMinInstance } from 'botlib';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import * as request from 'request-promise-native';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { DialogKeywords } from './DialogKeywords';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBVMService } from './GBVMService';
|
||||
import { ThisPath } from 'botbuilder-dialogs';
|
||||
const Fs = require('fs');
|
||||
const Excel = require('exceljs');
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR';
|
||||
const urlJoin = require('url-join');
|
||||
|
||||
const { TwitterApi } = require('twitter-api-v2');
|
||||
|
||||
|
||||
const Path = require('path');
|
||||
const ComputerVisionClient = require('@azure/cognitiveservices-computervision').ComputerVisionClient;
|
||||
const ApiKeyCredentials = require('@azure/ms-rest-js').ApiKeyCredentials;
|
||||
const alasql = require('alasql');
|
||||
const PizZip = require("pizzip");
|
||||
const Docxtemplater = require("docxtemplater");
|
||||
const pptxTemplaterModule = require('pptxtemplater');
|
||||
|
||||
const _ = require('lodash');
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { DialogKeywords } from './DialogKeywords.js';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBVMService } from './GBVMService.js';
|
||||
import Fs from 'fs';
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR.js';
|
||||
import urlJoin from 'url-join';
|
||||
import Excel from 'exceljs';
|
||||
import { TwitterApi } from 'twitter-api-v2';
|
||||
import tesseract from 'node-tesseract-ocr';
|
||||
import Path from 'path';
|
||||
import ComputerVisionClient from '@azure/cognitiveservices-computervision';
|
||||
import ApiKeyCredentials from '@azure/ms-rest-js';
|
||||
import alasql from 'alasql';
|
||||
import PizZip from 'pizzip';
|
||||
import Docxtemplater from 'docxtemplater';
|
||||
import pptxTemplaterModule from 'pptxtemplater';
|
||||
import _ from 'lodash';
|
||||
|
||||
/**
|
||||
* @fileoverview General Bots server core.
|
||||
|
@ -114,8 +110,8 @@ export class SystemKeywords {
|
|||
*
|
||||
*/
|
||||
public async seeCaption({url}) {
|
||||
const computerVisionClient = new ComputerVisionClient(
|
||||
new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': process.env.VISION_KEY } }),
|
||||
const computerVisionClient = new ComputerVisionClient.ComputerVisionClient(
|
||||
new ApiKeyCredentials.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': process.env.VISION_KEY } }),
|
||||
process.env.VISION_ENDPOINT);
|
||||
|
||||
let caption = (await computerVisionClient.describeImage(url)).captions[0];
|
||||
|
@ -127,13 +123,11 @@ export class SystemKeywords {
|
|||
);
|
||||
GBLog.info(`GBVision (caption): '${caption.text}' (Confidence: ${caption.confidence.toFixed(2)})`);
|
||||
|
||||
caption = await this.min.conversationalService.translate(
|
||||
return await this.min.conversationalService.translate(
|
||||
this.min,
|
||||
caption,
|
||||
caption.text,
|
||||
contentLocale
|
||||
);
|
||||
|
||||
return caption.text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,8 +136,8 @@ export class SystemKeywords {
|
|||
*
|
||||
*/
|
||||
public async seeText({url}) {
|
||||
const computerVisionClient = new ComputerVisionClient(
|
||||
new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': process.env.VISION_KEY } }),
|
||||
const computerVisionClient = new ComputerVisionClient.ComputerVisionClient(
|
||||
new ApiKeyCredentials.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': process.env.VISION_KEY } }),
|
||||
process.env.VISION_ENDPOINT);
|
||||
|
||||
const result = (await computerVisionClient.recognizePrintedText(true, url));
|
||||
|
@ -481,7 +475,7 @@ export class SystemKeywords {
|
|||
|
||||
GBLog.info(`BASIC: Defining '${address}' in '${file}' to '${value}' (SET). `);
|
||||
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
|
||||
const botId = this.min.instance.botId;
|
||||
const path = `/${botId}.gbai/${botId}.gbdata`;
|
||||
|
@ -530,7 +524,7 @@ export class SystemKeywords {
|
|||
public async saveFile({file, data}): Promise<any> {
|
||||
|
||||
GBLog.info(`BASIC: Saving '${file}' (SAVE file).`);
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
const path = `/${botId}.gbai/${botId}.gbdata`;
|
||||
|
||||
|
@ -566,7 +560,7 @@ export class SystemKeywords {
|
|||
const file = args[0];
|
||||
args.shift();
|
||||
GBLog.info(`BASIC: Saving '${file}' (SAVE). Args: ${args.join(',')}.`);
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
const path = `/${botId}.gbai/${botId}.gbdata`;
|
||||
|
||||
|
@ -614,7 +608,7 @@ export class SystemKeywords {
|
|||
}
|
||||
else {
|
||||
GBLog.info(`BASIC: GET '${addressOrHeaders}' in '${file}'.`);
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
const path = `/${botId}.gbai/${botId}.gbdata`;
|
||||
|
||||
|
@ -752,11 +746,11 @@ export class SystemKeywords {
|
|||
header = [];
|
||||
rows = [];
|
||||
|
||||
for (let i = 0; i < worksheet._rows.length; i++) {
|
||||
const r = worksheet._rows[i];
|
||||
for (let i = 0; i < worksheet.rowCount; i++) {
|
||||
const r = worksheet.getRow(i+1);
|
||||
let outRow = [];
|
||||
for (let j = 0; j < r._cells.length; j++) {
|
||||
outRow.push(r._cells[j].text);
|
||||
for (let j = 0; j < r.cellCount; j++) {
|
||||
outRow.push(r.getCell(j+1).text);
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -769,7 +763,7 @@ export class SystemKeywords {
|
|||
|
||||
} else {
|
||||
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
|
||||
let document
|
||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
||||
|
@ -1065,7 +1059,7 @@ export class SystemKeywords {
|
|||
*/
|
||||
public async createFolder({name}) {
|
||||
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
let path = `/${botId}.gbai/${botId}.gbdrive`;
|
||||
|
||||
|
@ -1121,7 +1115,7 @@ export class SystemKeywords {
|
|||
*
|
||||
*/
|
||||
public async shareFolder({folder, email, message}) {
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const root = urlJoin(`/${this.min.botId}.gbai/${this.min.botId}.gbdrive`, folder);
|
||||
|
||||
const src = await client.api(
|
||||
|
@ -1153,7 +1147,7 @@ export class SystemKeywords {
|
|||
*/
|
||||
public async copyFile({src, dest}) {
|
||||
GBLog.info(`BASIC: BEGINING COPY '${src}' to '${dest}'`);
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
|
||||
// Normalizes all slashes.
|
||||
|
@ -1173,7 +1167,7 @@ export class SystemKeywords {
|
|||
let folder;
|
||||
if (dest.indexOf('/') !== -1) {
|
||||
const pathOnly = Path.dirname(dest);
|
||||
folder = await this.createFolder(pathOnly);
|
||||
folder = await this.createFolder({name:pathOnly});
|
||||
}
|
||||
else {
|
||||
folder = await client.api(
|
||||
|
@ -1222,7 +1216,7 @@ export class SystemKeywords {
|
|||
*/
|
||||
public async convert({src, dest}) {
|
||||
GBLog.info(`BASIC: CONVERT '${src}' to '${dest}'`);
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
|
||||
// Normalizes all slashes.
|
||||
|
@ -1242,7 +1236,7 @@ export class SystemKeywords {
|
|||
let folder;
|
||||
if (dest.indexOf('/') !== -1) {
|
||||
const pathOnly = Path.dirname(dest);
|
||||
folder = await this.createFolder(pathOnly);
|
||||
folder = await this.createFolder({name:pathOnly});
|
||||
}
|
||||
else {
|
||||
folder = await client.api(
|
||||
|
@ -1395,7 +1389,7 @@ export class SystemKeywords {
|
|||
|
||||
// Downloads template from .gbdrive.
|
||||
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let template = await this.internalGetDocument(client, baseUrl, path, templateName);
|
||||
const url = template['@microsoft.graph.downloadUrl'];
|
||||
const localName = Path.join('work', gbaiName, 'cache', ``);
|
||||
|
@ -1425,43 +1419,39 @@ export class SystemKeywords {
|
|||
public screenCapture() {
|
||||
// scrcpy
|
||||
|
||||
const tesseract = require("node-tesseract-ocr")
|
||||
const robot = require('robotjs')
|
||||
const Jimp = require('jimp')
|
||||
|
||||
function captureImage({ x, y, w, h }) {
|
||||
const pic = robot.screen.capture(x, y, w, h)
|
||||
const width = pic.byteWidth / pic.bytesPerPixel // pic.width is sometimes wrong!
|
||||
const height = pic.height
|
||||
const image = new Jimp(width, height)
|
||||
let red, green, blue
|
||||
pic.image.forEach((byte, i) => {
|
||||
switch (i % 4) {
|
||||
case 0: return blue = byte
|
||||
case 1: return green = byte
|
||||
case 2: return red = byte
|
||||
case 3:
|
||||
image.bitmap.data[i - 3] = red
|
||||
image.bitmap.data[i - 2] = green
|
||||
image.bitmap.data[i - 1] = blue
|
||||
image.bitmap.data[i] = 255
|
||||
}
|
||||
})
|
||||
return image
|
||||
}
|
||||
let file = 'out.png';
|
||||
captureImage({ x: 60, y: 263, w: 250, h: 83 }).write(file)
|
||||
// function captureImage({ x, y, w, h }) {
|
||||
// const pic = robot.screen.capture(x, y, w, h)
|
||||
// const width = pic.byteWidth / pic.bytesPerPixel // pic.width is sometimes wrong!
|
||||
// const height = pic.height
|
||||
// const image = new Jimp(width, height)
|
||||
// let red, green, blue
|
||||
// pic.image.forEach((byte, i) => {
|
||||
// switch (i % 4) {
|
||||
// case 0: return blue = byte
|
||||
// case 1: return green = byte
|
||||
// case 2: return red = byte
|
||||
// case 3:
|
||||
// image.bitmap.data[i - 3] = red
|
||||
// image.bitmap.data[i - 2] = green
|
||||
// image.bitmap.data[i - 1] = blue
|
||||
// image.bitmap.data[i] = 255
|
||||
// }
|
||||
// })
|
||||
// return image
|
||||
// }
|
||||
// let file = 'out.png';
|
||||
// captureImage({ x: 60, y: 263, w: 250, h: 83 }).write(file)
|
||||
|
||||
|
||||
const config = {
|
||||
lang: "eng",
|
||||
oem: 1,
|
||||
psm: 3,
|
||||
}
|
||||
// const config = {
|
||||
// lang: "eng",
|
||||
// oem: 1,
|
||||
// psm: 3,
|
||||
// }
|
||||
|
||||
tesseract.recognize(file, config).then(value => {
|
||||
console.log(value);
|
||||
});
|
||||
// tesseract.recognize(file, config).then(value => {
|
||||
// console.log(value);
|
||||
// });
|
||||
}
|
||||
|
||||
private numberToLetters(num) {
|
||||
|
@ -1501,7 +1491,7 @@ export class SystemKeywords {
|
|||
|
||||
let results;
|
||||
let header, rows;
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
|
||||
let document
|
||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
||||
|
|
|
@ -33,18 +33,17 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, GBMinInstance } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { DialogKeywords } from './DialogKeywords';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { createBrowser } from '../../core.gbapp/services/GBSSR.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import { DialogKeywords } from './DialogKeywords.js';
|
||||
import * as request from 'request-promise-native';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
const Path = require('path');
|
||||
const Fs = require('fs');
|
||||
const url = require('url');
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import urlJoin from 'url-join';
|
||||
import Fs from 'fs';
|
||||
import Path from 'path';
|
||||
import url from 'url';
|
||||
|
||||
/**
|
||||
* Web Automation services of conversation to be called by BASIC.
|
||||
|
@ -371,7 +370,7 @@ export class WebAutomationKeywords {
|
|||
} else {
|
||||
result = await request.get(options);
|
||||
}
|
||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let {baseUrl, client} = await GBDeployer.internalGetDriveClient(this.min);
|
||||
const botId = this.min.instance.botId;
|
||||
|
||||
// Normalizes all slashes.
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// Source: https://github.com/uweg/vbscript-to-typescript
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var fs_1 = require("fs");
|
||||
var path = require("path");
|
||||
function convertFile(file) {
|
||||
|
||||
import fs_1 from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export function convertFile(file) {
|
||||
var extension = path.extname(file);
|
||||
var withoutExtension = file.substr(0, file.length - extension.length);
|
||||
var targetFile = withoutExtension + ".ts";
|
||||
|
@ -13,12 +14,12 @@ function convertFile(file) {
|
|||
console.log("Writing to \"" + targetFile + "\"...");
|
||||
fs_1.writeFileSync(targetFile, result);
|
||||
}
|
||||
exports.convertFile = convertFile;
|
||||
function convert(input, name) {
|
||||
|
||||
export function convert(input, name) {
|
||||
var result = convertImports(input, name);
|
||||
return result;
|
||||
}
|
||||
exports.convert = convert;
|
||||
|
||||
function convertImports(input, name) {
|
||||
var items = [];
|
||||
var result = input.replace(/<!-- #include file="(.*?\/)?(.*?).asp" -->/gi, function (input, group1, group2) {
|
||||
|
@ -37,7 +38,7 @@ function convertImports(input, name) {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
exports.convertImports = convertImports;
|
||||
|
||||
function convertCode(input) {
|
||||
var result = input.replace(/<%([^=][\s\S]*?)%>/gi, function (input, group1) {
|
||||
var code = group1;
|
||||
|
@ -53,7 +54,7 @@ function convertCode(input) {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
exports.convertCode = convertCode;
|
||||
|
||||
function convertExpressions(input) {
|
||||
var result = input.replace(/<%=([\s\S]*?)%>/gi, function (input, group1) {
|
||||
var content = convertPRec(group1);
|
||||
|
@ -62,7 +63,7 @@ function convertExpressions(input) {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
exports.convertExpressions = convertExpressions;
|
||||
|
||||
function convertStrings(input) {
|
||||
var result = input.replace(/%>([\s\S]+?)<%/gi, "\nResponse.Write(`$1`);\n");
|
||||
// Entire document is a string
|
||||
|
@ -83,7 +84,7 @@ function convertStrings(input) {
|
|||
result = result.replace(/^<%/, "");
|
||||
return result;
|
||||
}
|
||||
exports.convertStrings = convertStrings;
|
||||
|
||||
function convertComments(input) {
|
||||
var result = '';
|
||||
var splitted = input.split(/(".*")/gim);
|
||||
|
@ -98,7 +99,7 @@ function convertComments(input) {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
exports.convertComments = convertComments;
|
||||
|
||||
function convertIfStatements(input) {
|
||||
var result = input.replace(/if +(.*?) +then/gi, function (input, group1) {
|
||||
var condition = convertConditions(group1);
|
||||
|
@ -108,25 +109,25 @@ function convertIfStatements(input) {
|
|||
result = result.replace(/else(?!{)/gi, "\n}\nelse {\n");
|
||||
return result;
|
||||
}
|
||||
exports.convertIfStatements = convertIfStatements;
|
||||
|
||||
function convertSwitchStatements(input) {
|
||||
var result = input.replace(/select case +(.*)/gi, "\nswitch ($1) {\n");
|
||||
result = result.replace(/end select/gi, "\n}\n");
|
||||
return result;
|
||||
}
|
||||
exports.convertSwitchStatements = convertSwitchStatements;
|
||||
|
||||
function convertFunctions(input) {
|
||||
var result = input.replace(/function +(.*)\((.*)\)/gi, "\n$1 = ($2) => {\n");
|
||||
result = result.replace(/end function/gi, "\n}\n");
|
||||
return result;
|
||||
}
|
||||
exports.convertFunctions = convertFunctions;
|
||||
|
||||
function convertForStatements(input) {
|
||||
var result = input.replace(/for +(.*to.*)/gi, "\nfor ($1) {\n");
|
||||
result = result.replace(/^ *next *$/gim, "}\n");
|
||||
return result;
|
||||
}
|
||||
exports.convertForStatements = convertForStatements;
|
||||
|
||||
function convertConditions(input) {
|
||||
var result = input.replace(/ +and +/gi, " && ");
|
||||
result = result.replace(/ +or +/gi, " || ");
|
||||
|
@ -134,7 +135,7 @@ function convertConditions(input) {
|
|||
result = result.replace(/ += +/gi, " === ");
|
||||
return result;
|
||||
}
|
||||
exports.convertConditions = convertConditions;
|
||||
|
||||
function convertLoops(input) {
|
||||
var result = input.replace(/do while +(.*)/gi, function (input, group1) {
|
||||
var condition = convertConditions(group1);
|
||||
|
@ -144,14 +145,14 @@ function convertLoops(input) {
|
|||
result = result.replace(/^ *loop *$/gim, "}\n");
|
||||
return result;
|
||||
}
|
||||
exports.convertLoops = convertLoops;
|
||||
|
||||
function convertPRec(input) {
|
||||
var result = input.replace(/(p_rec\("\S+?"\))/gi, "$1.Value");
|
||||
return result;
|
||||
}
|
||||
exports.convertPRec = convertPRec;
|
||||
|
||||
function convertPLan(input) {
|
||||
var result = input.replace(/(l_\S+?)\(p_lan\)/gi, "$1[p_lan]");
|
||||
return result;
|
||||
}
|
||||
exports.convertPLan = convertPLan;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const crypto2 = require('crypto');
|
||||
const { spawn } = require('child_process');
|
||||
const CDP = require('chrome-remote-interface');
|
||||
const {} = require('child_process');
|
||||
const net = require('net');
|
||||
import crypto2 from 'crypto';
|
||||
import { spawn } from 'child_process';
|
||||
import CDP from 'chrome-remote-interface';
|
||||
import {} from 'child_process';
|
||||
import net from 'net';
|
||||
import { GBLog } from 'botlib';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GBServer } from '../../../../src/app';
|
||||
import { DebuggerService } from '../DebuggerService';
|
||||
const finalStream = require('final-stream');
|
||||
import { GBServer } from '../../../../src/app.js';
|
||||
import { DebuggerService } from '../DebuggerService.js';
|
||||
import finalStream from 'final-stream';
|
||||
|
||||
const waitUntil = condition => {
|
||||
if (condition()) {
|
||||
|
@ -26,7 +26,7 @@ const waitUntil = condition => {
|
|||
});
|
||||
};
|
||||
|
||||
const createVm2Pool = ({ min, max, ...limits }) => {
|
||||
export const createVm2Pool = ({ min, max, ...limits }) => {
|
||||
limits = Object.assign(
|
||||
{
|
||||
cpu: 100,
|
||||
|
@ -65,7 +65,7 @@ const createVm2Pool = ({ min, max, ...limits }) => {
|
|||
|
||||
|
||||
childProcess.stdout.on('data', data => {
|
||||
childProcess.socket = childProcess.socket || data.toString().trim();
|
||||
childProcess['socket'] = childProcess['socket'] || data.toString().trim();
|
||||
});
|
||||
|
||||
childProcess.stderr.on('data', data => {
|
||||
|
@ -88,7 +88,7 @@ const createVm2Pool = ({ min, max, ...limits }) => {
|
|||
});
|
||||
|
||||
let socket = null;
|
||||
await waitUntil(() => childProcess.socket);
|
||||
await waitUntil(() => childProcess['socket']);
|
||||
|
||||
GBServer.globals.debuggers[limits.botId].childProcess = ref;
|
||||
|
||||
|
@ -175,7 +175,7 @@ const createVm2Pool = ({ min, max, ...limits }) => {
|
|||
|
||||
await debug();
|
||||
}
|
||||
socket = net.createConnection(childProcess.socket);
|
||||
socket = net.createConnection(childProcess['socket']);
|
||||
socket.write(JSON.stringify({ code, scope }) + '\n');
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
|
@ -215,4 +215,3 @@ const createVm2Pool = ({ min, max, ...limits }) => {
|
|||
};
|
||||
};
|
||||
|
||||
exports.createVm2Pool = createVm2Pool;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const { VMScript, NodeVM } = require('vm2');
|
||||
const crypto1 = require('crypto');
|
||||
const net1 = require('net');
|
||||
import { VMScript, NodeVM } from 'vm2';
|
||||
import crypto1 from 'crypto';
|
||||
import net1 from 'net';
|
||||
|
||||
const evaluate = async (script, scope) => {
|
||||
const vm = new NodeVM({
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { ConsoleDirectLine } from './services/ConsoleDirectLine';
|
||||
import { ConsoleDirectLine } from './services/ConsoleDirectLine.js';
|
||||
|
||||
/**
|
||||
* Package for console.glib.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const Swagger = require('swagger-client');
|
||||
const rp = require('request-promise');
|
||||
import Swagger from 'swagger-client';
|
||||
import rp from 'request-promise';
|
||||
import { GBLog, GBService } from 'botlib';
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { Messages } from '../strings';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBConversationalService } from '../services/GBConversationalService';
|
||||
import { Messages } from '../strings.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBConversationalService } from '../services/GBConversationalService.js';
|
||||
/**
|
||||
* Dialog for the bot explains about itself.
|
||||
*/
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { Messages } from '../strings';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBConversationalService } from '../services/GBConversationalService';
|
||||
import { Messages } from '../strings.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBConversationalService } from '../services/GBConversationalService.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
/**
|
||||
* Dialog for the bot explains about itself.
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { GBConversationalService } from '../services/GBConversationalService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { GBConversationalService } from '../services/GBConversationalService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
/**
|
||||
* Dialog for the bot explains about itself.
|
||||
*/
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBConversationalService } from '../services/GBConversationalService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBConversationalService } from '../services/GBConversationalService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
|
||||
/**
|
||||
* Dialog for Welcoming people.
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBConversationalService } from '../services/GBConversationalService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBConversationalService } from '../services/GBConversationalService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
/**
|
||||
* Dialog for the bot explains about itself.
|
||||
*/
|
||||
|
|
|
@ -38,12 +38,12 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { BroadcastDialog } from './dialogs/BroadcastDialog';
|
||||
import { LanguageDialog } from './dialogs/LanguageDialog';
|
||||
import { SwitchBotDialog } from './dialogs/SwitchBot';
|
||||
import { WelcomeDialog } from './dialogs/WelcomeDialog';
|
||||
import { WhoAmIDialog } from './dialogs/WhoAmIDialog';
|
||||
import { GuaribasChannel, GuaribasException, GuaribasInstance, GuaribasPackage } from './models/GBModel';
|
||||
import { BroadcastDialog } from './dialogs/BroadcastDialog.js';
|
||||
import { LanguageDialog } from './dialogs/LanguageDialog.js';
|
||||
import { SwitchBotDialog } from './dialogs/SwitchBot.js';
|
||||
import { WelcomeDialog } from './dialogs/WelcomeDialog.js';
|
||||
import { WhoAmIDialog } from './dialogs/WhoAmIDialog.js';
|
||||
import { GuaribasChannel, GuaribasException, GuaribasInstance, GuaribasPackage } from './models/GBModel.js';
|
||||
|
||||
/**
|
||||
* Package for core.gbapp.
|
||||
|
|
|
@ -47,4 +47,4 @@ import {
|
|||
Table,
|
||||
UpdatedAt
|
||||
} from 'sequelize-typescript';
|
||||
import { GuaribasInstance } from './GBModel';
|
||||
import { GuaribasInstance } from './GBModel.js';
|
||||
|
|
|
@ -61,215 +61,215 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public botEndpoint: string;
|
||||
declare botEndpoint: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public whoAmIVideo: string;
|
||||
declare whoAmIVideo: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public botId: string;
|
||||
declare botId: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public title: string;
|
||||
declare title: string;
|
||||
|
||||
@Column({ type: DataType.STRING(16) })
|
||||
public activationCode: string;
|
||||
declare activationCode: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public description: string;
|
||||
declare description: string;
|
||||
|
||||
@Column({ type: DataType.STRING(16) })
|
||||
public state: string;
|
||||
declare state: string;
|
||||
|
||||
public version: string;
|
||||
declare version: string;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public botKey: string;
|
||||
declare botKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public enabledAdmin: boolean;
|
||||
declare enabledAdmin: boolean;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public engineName: string;
|
||||
declare engineName: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public marketplaceId: string;
|
||||
declare marketplaceId: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public textAnalyticsKey: string;
|
||||
declare textAnalyticsKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public textAnalyticsEndpoint: string;
|
||||
declare textAnalyticsEndpoint: string;
|
||||
|
||||
@Column({ type: DataType.STRING(64) })
|
||||
public translatorKey: string;
|
||||
declare translatorKey: string;
|
||||
|
||||
@Column({ type: DataType.STRING(128) })
|
||||
public translatorEndpoint: string;
|
||||
declare translatorEndpoint: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public marketplacePassword: string;
|
||||
declare marketplacePassword: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public webchatKey: string;
|
||||
declare webchatKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public authenticatorTenant: string;
|
||||
declare authenticatorTenant: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public authenticatorAuthorityHostUrl: string;
|
||||
declare authenticatorAuthorityHostUrl: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public cloudSubscriptionId: string;
|
||||
declare cloudSubscriptionId: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public cloudUsername: string;
|
||||
declare cloudUsername: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public cloudPassword: string;
|
||||
declare cloudPassword: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public cloudLocation: string;
|
||||
declare cloudLocation: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public googleBotKey: string;
|
||||
declare googleBotKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public googleChatApiKey: string;
|
||||
declare googleChatApiKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public googleChatSubscriptionName: string;
|
||||
declare googleChatSubscriptionName: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public googleClientEmail: string;
|
||||
declare googleClientEmail: string;
|
||||
|
||||
@Column({ type: DataType.STRING(4000) })
|
||||
public googlePrivateKey: string;
|
||||
declare googlePrivateKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public googleProjectId: string;
|
||||
declare googleProjectId: string;
|
||||
|
||||
@Column({ type: DataType.STRING(255) })
|
||||
facebookWorkplaceVerifyToken: string;
|
||||
declare facebookWorkplaceVerifyToken: string;
|
||||
|
||||
@Column({ type: DataType.STRING(255) })
|
||||
facebookWorkplaceAppSecret: string;
|
||||
declare facebookWorkplaceAppSecret: string;
|
||||
|
||||
@Column({ type: DataType.STRING(512) })
|
||||
facebookWorkplaceAccessToken: string;
|
||||
declare facebookWorkplaceAccessToken: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public whatsappBotKey: string;
|
||||
declare whatsappBotKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public whatsappServiceKey: string;
|
||||
declare whatsappServiceKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public whatsappServiceNumber: string;
|
||||
declare whatsappServiceNumber: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public whatsappServiceUrl: string;
|
||||
declare whatsappServiceUrl: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public smsKey: string;
|
||||
declare smsKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public smsSecret: string;
|
||||
declare smsSecret: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public smsServiceNumber: string;
|
||||
declare smsServiceNumber: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public speechKey: string;
|
||||
declare speechKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public speechEndpoint: string;
|
||||
declare speechEndpoint: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public spellcheckerKey: string;
|
||||
declare spellcheckerKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public spellcheckerEndpoint: string;
|
||||
declare spellcheckerEndpoint: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public theme: string;
|
||||
declare theme: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public ui: string;
|
||||
declare ui: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public kb: string;
|
||||
declare kb: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public nlpAppId: string;
|
||||
declare nlpAppId: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public nlpKey: string;
|
||||
declare nlpKey: string;
|
||||
|
||||
@Column({ type: DataType.STRING(512) })
|
||||
public nlpEndpoint: string;
|
||||
declare nlpEndpoint: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public nlpAuthoringKey: string;
|
||||
declare nlpAuthoringKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public deploymentPaths: string;
|
||||
declare deploymentPaths: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public searchHost: string;
|
||||
declare searchHost: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public searchKey: string;
|
||||
declare searchKey: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public searchIndex: string;
|
||||
declare searchIndex: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public searchIndexer: string;
|
||||
declare searchIndexer: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storageUsername: string;
|
||||
declare storageUsername: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storagePassword: string;
|
||||
declare storagePassword: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storageName: string;
|
||||
declare storageName: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storageServer: string;
|
||||
declare storageServer: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storageDialect: string;
|
||||
declare storageDialect: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public storagePath: string;
|
||||
declare storagePath: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public adminPass: string;
|
||||
declare adminPass: string;
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
public nlpVsSearch: number; // TODO: Remove field.
|
||||
declare nlpVsSearch: number; // TODO: Remove field.
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
public searchScore: number;
|
||||
declare searchScore: number;
|
||||
|
||||
@Column(DataType.FLOAT)
|
||||
public nlpScore: number;
|
||||
declare nlpScore: number;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
@Column(DataType.STRING(4000))
|
||||
public params: string;
|
||||
declare params: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,28 +280,28 @@ export class GuaribasPackage extends Model<GuaribasPackage> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public packageId: number;
|
||||
declare packageId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public packageName: string;
|
||||
declare packageName: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
@Column({ type: DataType.STRING(512) })
|
||||
public custom: string;
|
||||
declare custom: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,18 +312,18 @@ export class GuaribasChannel extends Model<GuaribasChannel> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public channelId: number;
|
||||
declare channelId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public title: string;
|
||||
declare title: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,25 +335,25 @@ export class GuaribasException extends Model<GuaribasException> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public exceptionId: number;
|
||||
declare exceptionId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public message: string;
|
||||
declare message: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
}
|
||||
|
||||
@Table
|
||||
|
@ -361,22 +361,22 @@ export class GuaribasException extends Model<GuaribasException> {
|
|||
export class GuaribasApplications extends Model<GuaribasApplications> {
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public name: string;
|
||||
declare name: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
}
|
||||
|
||||
@Table
|
||||
|
@ -384,23 +384,23 @@ export class GuaribasApplications extends Model<GuaribasApplications> {
|
|||
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public name: string;
|
||||
declare name: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public schedule: string;
|
||||
declare schedule: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog } from 'botlib';
|
||||
import * as en from 'dotenv-extended';
|
||||
|
||||
/**
|
||||
* @fileoverview General Bots server core.
|
||||
|
@ -58,7 +59,7 @@ export class GBConfigService {
|
|||
|
||||
public static init(): any {
|
||||
try {
|
||||
require('dotenv-extended').load({
|
||||
en.load({
|
||||
encoding: 'utf8',
|
||||
silent: true,
|
||||
path: '.env',
|
||||
|
|
|
@ -39,31 +39,30 @@
|
|||
import { MessageFactory, RecognizerResult, TurnContext } from 'botbuilder';
|
||||
import { LuisRecognizer } from 'botbuilder-ai';
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { Readable } from 'stream';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService.js';
|
||||
import { MicrosoftAppCredentials } from 'botframework-connector';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBConfigService } from './GBConfigService.js';
|
||||
import { CollectionUtil, AzureText } from 'pragmatismo-io-framework';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { GBMinService } from './GBMinService';
|
||||
const urlJoin = require('url-join');
|
||||
const PasswordGenerator = require('strict-password-generator').default;
|
||||
const Nexmo = require('nexmo');
|
||||
const { join } = require('path');
|
||||
const shell = require('any-shell-escape');
|
||||
const { exec } = require('child_process');
|
||||
const prism = require('prism-media');
|
||||
const request = require('request-promise-native');
|
||||
const fs = require('fs');
|
||||
const SpeechToTextV1 = require('ibm-watson/speech-to-text/v1');
|
||||
const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
|
||||
const { IamAuthenticator } = require('ibm-watson/auth');
|
||||
const marked = require('marked');
|
||||
const { Translate } = require('@google-cloud/translate').v2;
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import { GBMinService } from './GBMinService.js';
|
||||
import urlJoin from 'url-join';
|
||||
import Fs from 'fs';
|
||||
import PasswordGenerator from 'strict-password-generator';
|
||||
import Nexmo from 'nexmo';
|
||||
import { join } from 'path';
|
||||
import shell from 'any-shell-escape';
|
||||
import { exec } from 'child_process';
|
||||
import prism from 'prism-media';
|
||||
import request from 'request-promise-native';
|
||||
import SpeechToTextV1 from 'ibm-watson/speech-to-text/v1.js';
|
||||
import TextToSpeechV1 from 'ibm-watson/text-to-speech/v1.js';
|
||||
import { IamAuthenticator } from 'ibm-watson/auth/index.js';
|
||||
import * as marked from 'marked';
|
||||
import Translate from '@google-cloud/translate';
|
||||
|
||||
/**
|
||||
* Provides basic services for handling messages and dispatching to back-end
|
||||
|
@ -309,7 +308,7 @@ export class GBConversationalService {
|
|||
apiSecret: min.instance.smsSecret
|
||||
});
|
||||
// tslint:disable-next-line:no-unsafe-any
|
||||
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, (err, data) => {
|
||||
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text,{}, (err, data) => {
|
||||
const message = data.messages ? data.messages[0] : {};
|
||||
if (err || message['error-text']) {
|
||||
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`);
|
||||
|
@ -317,7 +316,7 @@ export class GBConversationalService {
|
|||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
}, );
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -350,17 +349,16 @@ export class GBConversationalService {
|
|||
let res = await textToSpeech.synthesize(params);
|
||||
const waveFilename = `work/tmp${name}.pcm`;
|
||||
|
||||
let audio = '';
|
||||
audio = await textToSpeech.repairWavHeaderStream(res.result);
|
||||
fs.writeFileSync(waveFilename, audio);
|
||||
let audio = await textToSpeech.repairWavHeaderStream(res.result as any);
|
||||
Fs.writeFileSync(waveFilename, audio);
|
||||
|
||||
const oggFilenameOnly = `tmp${name}.ogg`;
|
||||
const oggFilename = `work/${oggFilenameOnly}`;
|
||||
const output = fs.createWriteStream(oggFilename);
|
||||
const output = Fs.createWriteStream(oggFilename);
|
||||
const transcoder = new prism.FFmpeg({
|
||||
args: ['-analyzeduration', '0', '-loglevel', '0', '-f', 'opus', '-ar', '16000', '-ac', '1']
|
||||
});
|
||||
fs.createReadStream(waveFilename).pipe(transcoder).pipe(output);
|
||||
Fs.createReadStream(waveFilename).pipe(transcoder).pipe(output);
|
||||
|
||||
let url = urlJoin(GBServer.globals.publicAddress, 'audios', oggFilenameOnly);
|
||||
resolve(url);
|
||||
|
@ -383,7 +381,7 @@ export class GBConversationalService {
|
|||
|
||||
const dest = `work/tmp${name}.wav`;
|
||||
const src = `work/tmp${name}.ogg`;
|
||||
fs.writeFileSync(src, oggFile.read());
|
||||
Fs.writeFileSync(src, oggFile.read());
|
||||
|
||||
const makeMp3 = shell([
|
||||
'node_modules/ffmpeg-static/ffmpeg.exe',
|
||||
|
@ -406,7 +404,7 @@ export class GBConversationalService {
|
|||
GBLog.error(error);
|
||||
return Promise.reject(error);
|
||||
} else {
|
||||
let data = fs.readFileSync(dest);
|
||||
let data = Fs.readFileSync(dest);
|
||||
|
||||
const speechToText = new SpeechToTextV1({
|
||||
authenticator: new IamAuthenticator({ apikey: process.env.WATSON_STT_KEY }),
|
||||
|
@ -461,7 +459,7 @@ export class GBConversationalService {
|
|||
GBLog.verbose(`Translated text(playMarkdown): ${text}.`);
|
||||
}
|
||||
|
||||
var renderer = new marked.Renderer();
|
||||
var renderer = new marked.marked.Renderer();
|
||||
renderer.oldImage = renderer.image;
|
||||
renderer.image = function (href, title, text) {
|
||||
var videos = ['webm', 'mp4', 'mov'];
|
||||
|
@ -859,7 +857,7 @@ export class GBConversationalService {
|
|||
if (min.instance.googleProjectId) {
|
||||
// Instantiates a client
|
||||
|
||||
const translate = new Translate({
|
||||
const translate = new Translate.v2.Translate({
|
||||
projectId: min.instance.googleProjectId,
|
||||
credentials: { client_email: min.instance.googleClientEmail, private_key: min.instance.googlePrivateKey.replace(/\\n/gm, '\n') }
|
||||
});
|
||||
|
|
|
@ -37,30 +37,29 @@
|
|||
'use strict';
|
||||
|
||||
import { GBLog, IGBCoreService, IGBInstallationDeployer, IGBInstance, IGBPackage } from 'botlib';
|
||||
import * as fs from 'fs';
|
||||
import * as Fs from 'fs';
|
||||
import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
|
||||
import { Op, Dialect } from 'sequelize';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBAdminPackage } from '../../admin.gbapp/index';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { GBAnalyticsPackage } from '../../analytics.gblib';
|
||||
import { StartDialog } from '../../azuredeployer.gbapp/dialogs/StartDialog';
|
||||
import { GBCorePackage } from '../../core.gbapp';
|
||||
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp';
|
||||
import { GBKBPackage } from '../../kb.gbapp';
|
||||
import { GBSecurityPackage } from '../../security.gbapp';
|
||||
import { GBWhatsappPackage } from '../../whatsapp.gblib/index';
|
||||
import { GuaribasInstance } from '../models/GBModel';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import { GBAzureDeployerPackage } from '../../azuredeployer.gbapp';
|
||||
import { GBSharePointPackage } from '../../sharepoint.gblib';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBAdminPackage } from '../../admin.gbapp/index.js';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { GBAnalyticsPackage } from '../../analytics.gblib/index.js';
|
||||
import { StartDialog } from '../../azuredeployer.gbapp/dialogs/StartDialog.js';
|
||||
import { GBCorePackage } from '../../core.gbapp/index.js';
|
||||
import { GBCustomerSatisfactionPackage } from '../../customer-satisfaction.gbapp/index.js';
|
||||
import { GBKBPackage } from '../../kb.gbapp/index.js';
|
||||
import { GBSecurityPackage } from '../../security.gbapp/index.js';
|
||||
import { GBWhatsappPackage } from '../../whatsapp.gblib/index.js';
|
||||
import { GuaribasInstance } from '../models/GBModel.js';
|
||||
import { GBConfigService } from './GBConfigService.js';
|
||||
import { GBAzureDeployerPackage } from '../../azuredeployer.gbapp/index.js';
|
||||
import { GBSharePointPackage } from '../../sharepoint.gblib/index.js';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GBBasicPackage } from '../../basic.gblib';
|
||||
import { GBGoogleChatPackage } from '../../google-chat.gblib';
|
||||
import { GBHubSpotPackage } from '../../hubspot.gblib';
|
||||
|
||||
const opn = require('opn');
|
||||
const cron = require('node-cron');
|
||||
import { GBBasicPackage } from '../../basic.gblib/index.js';
|
||||
import { GBGoogleChatPackage } from '../../google-chat.gblib/index.js';
|
||||
import { GBHubSpotPackage } from '../../hubspot.gblib/index.js';
|
||||
import opn from 'opn';
|
||||
import ngrok from 'ngrok';
|
||||
|
||||
/**
|
||||
* GBCoreService contains main logic for handling storage services related
|
||||
|
@ -288,7 +287,7 @@ STORAGE_SYNC_ALTER=true
|
|||
ENDPOINT_UPDATE=true
|
||||
`;
|
||||
|
||||
fs.writeFileSync('.env', env);
|
||||
Fs.writeFileSync('.env', env);
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,9 +298,9 @@ ENDPOINT_UPDATE=true
|
|||
*/
|
||||
public async ensureProxy(port): Promise<string> {
|
||||
try {
|
||||
if (fs.existsSync('node_modules/ngrok/bin/ngrok.exe') || fs.existsSync('node_modules/ngrok/bin/ngrok')) {
|
||||
const ngrok = require('ngrok');
|
||||
return await ngrok.connect({ port: port }, 10);
|
||||
if (Fs.existsSync('node_modules/ngrok/bin/ngrok.exe') || Fs.existsSync('node_modules/ngrok/bin/ngrok')) {
|
||||
|
||||
return await ngrok.connect({ port: port});
|
||||
} else {
|
||||
GBLog.warn('ngrok executable not found (only tested on Windows). Check installation or node_modules folder.');
|
||||
|
||||
|
|
|
@ -36,27 +36,27 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const Path = require('path');
|
||||
const urlJoin = require('url-join');
|
||||
const Fs = require('fs');
|
||||
const express = require('express');
|
||||
const child_process = require('child_process');
|
||||
const rimraf = require('rimraf');
|
||||
const request = require('request-promise-native');
|
||||
const vhost = require('vhost')
|
||||
import Path from 'path';
|
||||
import express from 'express';
|
||||
import child_process from 'child_process';
|
||||
import rimraf from 'rimraf';
|
||||
import request from 'request-promise-native';
|
||||
import vhost from 'vhost'
|
||||
import urlJoin from 'url-join';
|
||||
import Fs from 'fs';
|
||||
import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBDeployer, IGBInstance, IGBPackage } from 'botlib';
|
||||
import { AzureSearch } from 'pragmatismo-io-framework';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
||||
import { GuaribasPackage } from '../models/GBModel';
|
||||
import { GBAdminService } from './../../admin.gbapp/services/GBAdminService';
|
||||
import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||
import { KBService } from './../../kb.gbapp/services/KBService';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import { GBImporter } from './GBImporterService';
|
||||
import { TeamsService } from '../../teams.gblib/services/TeamsService';
|
||||
const MicrosoftGraph = require('@microsoft/microsoft-graph-client');
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
|
||||
import { GuaribasPackage } from '../models/GBModel.js';
|
||||
import { GBAdminService } from './../../admin.gbapp/services/GBAdminService.js';
|
||||
import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService.js';
|
||||
import { KBService } from './../../kb.gbapp/services/KBService.js';
|
||||
import { GBConfigService } from './GBConfigService.js';
|
||||
import { GBImporter } from './GBImporterService.js';
|
||||
import { TeamsService } from '../../teams.gblib/services/TeamsService.js';
|
||||
import MicrosoftGraph from '@microsoft/microsoft-graph-client';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
}
|
||||
});
|
||||
const baseUrl = `https://graph.microsoft.com/v1.0/sites/${siteId}/lists/${libraryId}`;
|
||||
return [baseUrl, client];
|
||||
return {baseUrl, client};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,7 +452,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
GBLog.info(`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
|
||||
|
||||
if (!baseUrl) {
|
||||
[baseUrl, client] = await GBDeployer.internalGetDriveClient(min);
|
||||
client = await GBDeployer.internalGetDriveClient(min);
|
||||
|
||||
remotePath = remotePath.replace(/\\/gi, '/');
|
||||
const parts = remotePath.split('/');
|
||||
|
@ -479,7 +479,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
|
||||
GBLog.info(`Download URL: ${url}`);
|
||||
|
||||
const res = await client
|
||||
const res = await client.client
|
||||
.api(url)
|
||||
.get();
|
||||
const documents = res.value;
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
|
||||
import { GBMinInstance, IGBCoreService, IGBInstance } from 'botlib';
|
||||
import { CreateOptions } from 'sequelize/types';
|
||||
const fs = require('fs');
|
||||
const urlJoin = require('url-join');
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GuaribasInstance } from '../models/GBModel';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import Fs from 'fs';
|
||||
import urlJoin from 'url-join';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GuaribasInstance } from '../models/GBModel.js';
|
||||
import { GBConfigService } from './GBConfigService.js';
|
||||
|
||||
/**
|
||||
* Handles the importing of packages.
|
||||
|
@ -56,7 +56,7 @@ export class GBImporter {
|
|||
|
||||
public async importIfNotExistsBotPackage(botId: string,
|
||||
packageName: string, localPath: string, additionalInstance: IGBInstance = null) {
|
||||
const settingsJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
|
||||
const settingsJson = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'settings.json'), 'utf8'));
|
||||
if (botId === undefined) {
|
||||
botId = settingsJson.botId;
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ export class GBImporter {
|
|||
localPath: string,
|
||||
settingsJson: any
|
||||
) {
|
||||
const packageJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
const servicesJson = JSON.parse(fs.readFileSync(urlJoin(localPath, 'services.json'), 'utf8'));
|
||||
const packageJson = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
const servicesJson = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'services.json'), 'utf8'));
|
||||
|
||||
const fullSettingsJson = { ...GBServer.globals.bootInstance, ...packageJson, ...settingsJson, ...servicesJson };
|
||||
|
||||
|
|
|
@ -35,19 +35,18 @@
|
|||
*/
|
||||
|
||||
'use strict';
|
||||
const cliProgress = require('cli-progress');
|
||||
const { DialogSet, TextPrompt } = require('botbuilder-dialogs');
|
||||
const express = require('express');
|
||||
const Swagger = require('swagger-client');
|
||||
const Fs = require('fs');
|
||||
const request = require('request-promise-native');
|
||||
const removeRoute = require('express-remove-route');
|
||||
const AuthenticationContext = require('adal-node').AuthenticationContext;
|
||||
const wash = require('washyourmouthoutwithsoap');
|
||||
const { FacebookAdapter } = require('botbuilder-adapter-facebook');
|
||||
const path = require('path');
|
||||
const { NerManager } = require('node-nlp');
|
||||
const mkdirp = require('mkdirp');
|
||||
import cliProgress from 'cli-progress';
|
||||
import { DialogSet, TextPrompt } from 'botbuilder-dialogs';
|
||||
import express from 'express';
|
||||
import Swagger from 'swagger-client';
|
||||
import request from 'request-promise-native';
|
||||
import removeRoute from 'express-remove-route';
|
||||
import AuthenticationContext from 'adal-node';
|
||||
import wash from 'washyourmouthoutwithsoap';
|
||||
import { FacebookAdapter } from 'botbuilder-adapter-facebook';
|
||||
import path from 'path';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Fs from 'fs';
|
||||
import {
|
||||
AutoSaveStateMiddleware,
|
||||
BotFrameworkAdapter,
|
||||
|
@ -69,25 +68,26 @@ import {
|
|||
} from 'botlib';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { MicrosoftAppCredentials } from 'botframework-connector';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { GuaribasConversationMessage } from '../../analytics.gblib/models';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
||||
import { AskDialogArgs } from '../../kb.gbapp/dialogs/AskDialog';
|
||||
import { KBService } from '../../kb.gbapp/services/KBService';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine';
|
||||
import { Messages } from '../strings';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import { GBConversationalService } from './GBConversationalService';
|
||||
import { GBDeployer } from './GBDeployer';
|
||||
import urlJoin = require('url-join');
|
||||
import fs = require('fs');
|
||||
import { GoogleChatDirectLine } from '../../google-chat.gblib/services/GoogleChatDirectLine';
|
||||
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices';
|
||||
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { GuaribasConversationMessage } from '../../analytics.gblib/models/index.js';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService.js';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
|
||||
import { AskDialogArgs } from '../../kb.gbapp/dialogs/AskDialog.js';
|
||||
import { KBService } from '../../kb.gbapp/services/KBService.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import { GBConfigService } from './GBConfigService.js';
|
||||
import { GBConversationalService } from './GBConversationalService.js';
|
||||
import { GBDeployer } from './GBDeployer.js';
|
||||
import urlJoin from 'url-join';
|
||||
import fs from 'fs';
|
||||
import { GoogleChatDirectLine } from '../../google-chat.gblib/services/GoogleChatDirectLine.js';
|
||||
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices.js';
|
||||
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
|
||||
import { ssrForBots } from './GBSSR';
|
||||
import * as nlp from 'node-nlp';
|
||||
|
||||
/**
|
||||
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
||||
|
@ -268,33 +268,33 @@ export class GBMinService {
|
|||
// Install per bot deployed packages.
|
||||
|
||||
let packagePath = `work/${min.botId}.gbai/${min.botId}.gbdialog`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
if (Fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gbapp`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
if (Fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gbtheme`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
if (Fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
packagePath = `work/${min.botId}.gbai/${min.botId}.gblib`;
|
||||
if (fs.existsSync(packagePath)) {
|
||||
if (Fs.existsSync(packagePath)) {
|
||||
await this.deployer.deployPackage(min, packagePath);
|
||||
}
|
||||
|
||||
let dir = `work/${min.botId}.gbai/cache`;
|
||||
|
||||
if (!fs.existsSync(dir)) {
|
||||
if (!Fs.existsSync(dir)) {
|
||||
mkdirp.sync(dir);
|
||||
}
|
||||
dir = `work/${min.botId}.gbai/profile`;
|
||||
if (!fs.existsSync(dir)) {
|
||||
if (!Fs.existsSync(dir)) {
|
||||
mkdirp.sync(dir);
|
||||
}
|
||||
dir = `work/${min.botId}.gbai/uploads`;
|
||||
if (!fs.existsSync(dir)) {
|
||||
if (!Fs.existsSync(dir)) {
|
||||
mkdirp.sync(dir);
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ export class GBMinService {
|
|||
GBLog.info(`Starting auto test with '${process.env.TEST_MESSAGE}'.`);
|
||||
|
||||
const client = await new Swagger({
|
||||
spec: JSON.parse(fs.readFileSync('directline-3.0.json', 'utf8')), usePromise: true
|
||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')), usePromise: true
|
||||
});
|
||||
client.clientAuthorizations.add(
|
||||
'AuthorizationBotConnector',
|
||||
|
@ -472,7 +472,7 @@ export class GBMinService {
|
|||
GBLog.error(msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
const authenticationContext = new AuthenticationContext(
|
||||
const authenticationContext = new AuthenticationContext.AuthenticationContext(
|
||||
urlJoin(min.instance.authenticatorAuthorityHostUrl, min.instance.authenticatorTenant)
|
||||
);
|
||||
const resource = 'https://graph.microsoft.com';
|
||||
|
@ -491,12 +491,12 @@ export class GBMinService {
|
|||
GBLog.error(msg);
|
||||
res.send(msg);
|
||||
} else {
|
||||
|
||||
|
||||
// Saves token to the database.
|
||||
|
||||
await this.adminService.setValue(instance.instanceId, 'accessToken', token.accessToken);
|
||||
await this.adminService.setValue(instance.instanceId, 'refreshToken', token.refreshToken);
|
||||
await this.adminService.setValue(instance.instanceId, 'expiresOn', token.expiresOn.toString());
|
||||
await this.adminService.setValue(instance.instanceId, 'accessToken', token['accessToken']);
|
||||
await this.adminService.setValue(instance.instanceId, 'refreshToken', token['refreshToken']);
|
||||
await this.adminService.setValue(instance.instanceId, 'expiresOn', token['expiresOn'].toString());
|
||||
await this.adminService.setValue(instance.instanceId, 'AntiCSRFAttackState', undefined);
|
||||
|
||||
// Inform the home for default .gbui after finishing token retrival.
|
||||
|
@ -664,7 +664,7 @@ export class GBMinService {
|
|||
min.sandBoxMap = {};
|
||||
min["scheduleMap"] = {};
|
||||
min["conversationWelcomed"] = {};
|
||||
min["nerEngine"] = new NerManager();;
|
||||
min["nerEngine"] = new nlp.default.NerManager();
|
||||
min.packages = sysPackages;
|
||||
min.appPackages = appPackages;
|
||||
|
||||
|
|
|
@ -36,15 +36,15 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const puppeteer = require('puppeteer-extra')
|
||||
const Fs = require('fs');
|
||||
import puppeteer from 'puppeteer-extra';
|
||||
import Fs from 'fs';
|
||||
|
||||
// const StealthPlugin = require('puppeteer-extra-plugin-stealth')
|
||||
// const StealthPlugin from 'puppeteer-extra-plugin-stealth')
|
||||
// puppeteer.use(StealthPlugin());
|
||||
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import urljoin = require("url-join");
|
||||
const Path = require('path');
|
||||
import urljoin from "url-join";
|
||||
|
||||
|
||||
// https://hackernoon.com/tips-and-tricks-for-web-scraping-with-puppeteer-ed391a63d952
|
||||
// Dont download all resources, we just need the HTML
|
||||
|
@ -114,7 +114,6 @@ async function createBrowser(profilePath): Promise<any> {
|
|||
args: args,
|
||||
ignoreHTTPSErrors: true,
|
||||
headless: false,
|
||||
devTools: false,
|
||||
defaultViewport: null,
|
||||
ignoreDefaultArgs: ["--enable-automation", "--enable-blink-features=IdleDetection"]
|
||||
});
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBMinService } from '../../core.gbapp/services/GBMinService';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { CSService } from '../services/CSService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBMinService } from '../../core.gbapp/services/GBMinService.js';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { CSService } from '../services/CSService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
|
||||
/**
|
||||
* Dialog for feedback collecting.
|
||||
|
|
|
@ -40,10 +40,10 @@ import { GBMinInstance, IGBDialog } from 'botlib';
|
|||
|
||||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { CSService } from '../services/CSService';
|
||||
import { Messages } from '../strings';
|
||||
import { AnalyticsService } from '../../analytics.gblib/services/AnalyticsService.js';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
|
||||
import { CSService } from '../services/CSService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
|
||||
/**
|
||||
* Dialog for collecting quality of answer.
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
'use strict';
|
||||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
const urlJoin = require('url-join');
|
||||
import { FeedbackDialog } from './dialogs/FeedbackDialog';
|
||||
import { QualityDialog } from './dialogs/QualityDialog';
|
||||
import { GuaribasQuestionAlternate } from './models/index';
|
||||
import urlJoin from 'url-join';
|
||||
import { FeedbackDialog } from './dialogs/FeedbackDialog.js';
|
||||
import { QualityDialog } from './dialogs/QualityDialog.js';
|
||||
import { GuaribasQuestionAlternate } from './models/index.js';
|
||||
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import {
|
|||
Table
|
||||
} from 'sequelize-typescript';
|
||||
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel.js';
|
||||
|
||||
/**
|
||||
* List of saved alternate questions.
|
||||
|
@ -58,18 +58,18 @@ export class GuaribasQuestionAlternate extends Model<GuaribasQuestionAlternate>
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public quickAnswerId: number;
|
||||
declare quickAnswerId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public questionTyped: string;
|
||||
declare questionTyped: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public questionText: string;
|
||||
declare questionText: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
\*****************************************************************************/
|
||||
|
||||
import { FindOptions, NonNullFindOptions } from 'sequelize/types';
|
||||
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models';
|
||||
import { GuaribasConversation } from '../../analytics.gblib/models';
|
||||
import { GuaribasQuestionAlternate } from '../models';
|
||||
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models/index.js';
|
||||
import { GuaribasConversation } from '../../analytics.gblib/models/index.js';
|
||||
import { GuaribasQuestionAlternate } from '../models/index.js';
|
||||
|
||||
/**
|
||||
* Customer Satisfaction Service Layer.
|
||||
|
|
26
packages/default.gbui/package-lock.json
generated
26
packages/default.gbui/package-lock.json
generated
|
@ -2229,26 +2229,26 @@
|
|||
"resolved": "https://registry.npmjs.org/@midudev/react-static-content/-/react-static-content-1.0.4.tgz",
|
||||
"integrity": "sha512-P2+rdqhysYNon5/noOoUiFJghVxbl64qGgxsKwe10mjrkQvgIy4vCcOLN5Nw00er/cBSuWY/hVHkuSeQ6sI5VA=="
|
||||
},
|
||||
"@nodelib/fs.scandir": {
|
||||
"@nodelib/Fs.scandir": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/Fs.scandir/-/Fs.scandir-2.1.5.tgz",
|
||||
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
|
||||
"requires": {
|
||||
"@nodelib/fs.stat": "2.0.5",
|
||||
"@nodelib/Fs.stat": "2.0.5",
|
||||
"run-parallel": "^1.1.9"
|
||||
}
|
||||
},
|
||||
"@nodelib/fs.stat": {
|
||||
"@nodelib/Fs.stat": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/Fs.stat/-/Fs.stat-2.0.5.tgz",
|
||||
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A=="
|
||||
},
|
||||
"@nodelib/fs.walk": {
|
||||
"@nodelib/Fs.walk": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.7.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/Fs.walk/-/Fs.walk-1.2.7.tgz",
|
||||
"integrity": "sha512-BTIhocbPBSrRmHxOAJFtR18oLhxTtAFDAvL8hY1S3iU8k+E60W/YFs4jrixGzQjMpF4qPXxIQHcjVD9dz1C2QA==",
|
||||
"requires": {
|
||||
"@nodelib/fs.scandir": "2.1.5",
|
||||
"@nodelib/Fs.scandir": "2.1.5",
|
||||
"fastq": "^1.6.0"
|
||||
}
|
||||
},
|
||||
|
@ -8189,8 +8189,8 @@
|
|||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz",
|
||||
"integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==",
|
||||
"requires": {
|
||||
"@nodelib/fs.stat": "^2.0.2",
|
||||
"@nodelib/fs.walk": "^1.2.3",
|
||||
"@nodelib/Fs.stat": "^2.0.2",
|
||||
"@nodelib/Fs.walk": "^1.2.3",
|
||||
"glob-parent": "^5.1.0",
|
||||
"merge2": "^1.3.0",
|
||||
"micromatch": "^4.0.2",
|
||||
|
@ -8581,9 +8581,9 @@
|
|||
"readable-stream": "1 || 2"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"Fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/Fs.realpath/-/Fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"fsevents": {
|
||||
|
@ -8662,7 +8662,7 @@
|
|||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",
|
||||
"integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"Fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { GoogleChatDirectLine } from './services/GoogleChatDirectLine';
|
||||
import { GoogleChatDirectLine } from './services/GoogleChatDirectLine.js';
|
||||
|
||||
/**
|
||||
* Package for GoogleChat.gblib
|
||||
|
|
|
@ -30,14 +30,14 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
const Swagger = require('swagger-client');
|
||||
const fs = require('fs');
|
||||
const { google } = require('googleapis')
|
||||
const { promisify } = require('util');
|
||||
const { PubSub } = require('@google-cloud/pubsub');
|
||||
import Swagger from 'swagger-client';
|
||||
import { google } from 'googleapis';
|
||||
import { promisify } from 'util';
|
||||
import { PubSub } from '@google-cloud/pubsub';
|
||||
import Fs from 'fs';
|
||||
import { GBLog, GBMinInstance, GBService } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
|
||||
/**
|
||||
* Support for Google Chat.
|
||||
|
@ -97,7 +97,7 @@ export class GoogleChatDirectLine extends GBService {
|
|||
|
||||
this.directLineClient =
|
||||
new Swagger({
|
||||
spec: JSON.parse(fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')),
|
||||
usePromise: true
|
||||
});
|
||||
const client = await this.directLineClient;
|
||||
|
@ -270,9 +270,9 @@ export class GoogleChatDirectLine extends GBService {
|
|||
);
|
||||
await jwtClient.authorize();
|
||||
const chat = google.chat({version: 'v1', auth: jwtClient});
|
||||
chat.spaces.messages.createAsync = promisify(chat.spaces.messages.create);
|
||||
|
||||
|
||||
const res = await chat.spaces.messages.createAsync({
|
||||
const res = await chat.spaces.messages.create({
|
||||
parent: `spaces/${spaces}`,
|
||||
threadKey: threadKey,
|
||||
requestBody: {
|
||||
|
|
|
@ -30,13 +30,11 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
const Swagger = require('swagger-client');
|
||||
const fs = require('fs');
|
||||
const { promisify } = require('util');
|
||||
|
||||
import { GBLog, GBMinInstance, GBService } from 'botlib';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
const hubspot = require('@hubspot/api-client');
|
||||
import { promisify } from 'util';
|
||||
import Swagger from 'swagger-client';
|
||||
import * as hubspot from '@hubspot/api-client';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -44,157 +42,5 @@ const hubspot = require('@hubspot/api-client');
|
|||
*/
|
||||
export class HubSpotServices extends GBService {
|
||||
|
||||
public static conversationIds = {};
|
||||
public pollInterval = 5000;
|
||||
|
||||
public botId: string;
|
||||
public min: GBMinInstance;
|
||||
private key: any;
|
||||
|
||||
constructor(
|
||||
min: GBMinInstance,
|
||||
botId,
|
||||
key
|
||||
) {
|
||||
super();
|
||||
|
||||
this.min = min;
|
||||
this.botId = botId;
|
||||
this.key = key;
|
||||
|
||||
}
|
||||
public static async asyncForEach(array, callback) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
}
|
||||
|
||||
public async addDealNote(name, note)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async createDeal(dealName, contact, company, amount) {
|
||||
const dealObj = {
|
||||
properties: {
|
||||
dealname: dealName,
|
||||
dealstage: 'appointmentscheduled',
|
||||
pipeline: 'default',
|
||||
amount: amount
|
||||
},
|
||||
}
|
||||
const contactObj = {
|
||||
properties: {
|
||||
firstname: contact
|
||||
},
|
||||
}
|
||||
const companyObj = {
|
||||
properties: {
|
||||
name: company,
|
||||
},
|
||||
}
|
||||
|
||||
const hubspotClient = new hubspot.Client({ apiKey: this.key });
|
||||
const createDealResponse = await hubspotClient.crm.deals.basicApi.create(dealObj);
|
||||
const createContactResponse = await hubspotClient.crm.contacts.basicApi.create(contactObj);
|
||||
const createCompanyResponse = await hubspotClient.crm.companies.basicApi.create(companyObj);
|
||||
|
||||
await hubspotClient.crm.deals.associationsApi.create(
|
||||
createDealResponse.body.id,
|
||||
'contacts',
|
||||
createContactResponse.body.id,
|
||||
'deal_to_contact'
|
||||
)
|
||||
|
||||
await hubspotClient.crm.deals.associationsApi.create(
|
||||
createDealResponse.body.id,
|
||||
'companies',
|
||||
createCompanyResponse.body.id,
|
||||
'deal_to_company'
|
||||
)
|
||||
|
||||
return createDealResponse.body;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async createContact(firstName, lastName, domain, companyName) {
|
||||
const contactObj = {
|
||||
properties: {
|
||||
firstname: firstName,
|
||||
lastname: lastName,
|
||||
},
|
||||
}
|
||||
const companyObj = {
|
||||
properties: {
|
||||
domain: domain,
|
||||
name: companyName,
|
||||
},
|
||||
}
|
||||
|
||||
const hubspotClient = new hubspot.Client({ apiKey: this.key })
|
||||
const createContactResponse = await hubspotClient.crm.contacts.basicApi.create(contactObj)
|
||||
const createCompanyResponse = await hubspotClient.crm.companies.basicApi.create(companyObj)
|
||||
|
||||
return await hubspotClient.crm.companies.associationsApi.create(
|
||||
createCompanyResponse.body.id,
|
||||
'contacts',
|
||||
createContactResponse.body.id,
|
||||
'company_to_contact'
|
||||
)
|
||||
}
|
||||
|
||||
public async searchContact(query) {
|
||||
const client = new hubspot.Client({ apiKey: this.key });
|
||||
const sort = JSON.stringify({ propertyName: 'createdate', direction: 'DESCENDING' })
|
||||
|
||||
const properties = ['createdate', 'firstname', 'lastname', 'phone', 'email']
|
||||
const limit = 100
|
||||
const after = 0
|
||||
|
||||
const publicObjectSearchRequest = {
|
||||
sorts: [sort],
|
||||
query,
|
||||
properties,
|
||||
limit,
|
||||
after,
|
||||
}
|
||||
|
||||
const result = await client.crm.contacts.searchApi.doSearch(publicObjectSearchRequest)
|
||||
return result.body.results;
|
||||
}
|
||||
|
||||
|
||||
public async getActiveTasks(): Promise<[]> {
|
||||
|
||||
const client = new hubspot.Client({ apiKey: this.key });
|
||||
let properties = ['hs_task_subject', 'hubspot_owner_id', 'hs_task_status', 'hs_task_priority'];
|
||||
const pageSize = 100;
|
||||
let list;
|
||||
list = [];
|
||||
|
||||
let r = await client.crm.objects.basicApi.getPage("TASK", pageSize, 0, properties);
|
||||
list = list.concat(r.body.results);
|
||||
|
||||
while (r.body.results && r.body.results.length === pageSize) {
|
||||
r = await client.crm.objects.basicApi.getPage("TASK", pageSize, r.body.paging.next.after, properties);
|
||||
list = list.concat(r.body.results);
|
||||
}
|
||||
|
||||
let final;
|
||||
final = [];
|
||||
list.forEach(e => {
|
||||
if (e.properties.hs_task_status === "NOT_STARTED") {
|
||||
e['status'] = e.properties.hs_task_status;
|
||||
e['title'] = e.properties.hs_task_subject;
|
||||
e['ownerId'] = e.properties.hubspot_owner_id;
|
||||
e['priority'] = e.properties.hs_task_priority;
|
||||
|
||||
final.push(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return final;
|
||||
}
|
||||
}
|
|
@ -36,19 +36,19 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBLog, GBMinInstance, IGBDialog, IGBPackage } from 'botlib';
|
||||
import { Messages } from '../strings';
|
||||
import { KBService } from './../services/KBService';
|
||||
import { GuaribasAnswer } from '../models';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { Messages } from '../strings.js';
|
||||
import { KBService } from './../services/KBService.js';
|
||||
import { GuaribasAnswer } from '../models/index.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { CollectionUtil, AzureText } from 'pragmatismo-io-framework';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService.js';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
|
||||
/**
|
||||
* Dialog arguments.
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { Messages } from '../strings';
|
||||
import { KBService } from './../services/KBService';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import { KBService } from './../services/KBService.js';
|
||||
|
||||
/**
|
||||
* Handle display of FAQ allowing direct access to KB.
|
||||
|
|
|
@ -36,15 +36,15 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { GuaribasSubject } from '../models';
|
||||
import { KBService } from '../services/KBService';
|
||||
import { Messages } from '../strings';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
|
||||
import { GuaribasSubject } from '../models/index.js';
|
||||
import { KBService } from '../services/KBService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
|
||||
/**
|
||||
* Dialog arguments.
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { AskDialog } from './dialogs/AskDialog';
|
||||
import { FaqDialog } from './dialogs/FaqDialog';
|
||||
import { MenuDialog } from './dialogs/MenuDialog';
|
||||
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from './models/index';
|
||||
import { AskDialog } from './dialogs/AskDialog.js';
|
||||
import { FaqDialog } from './dialogs/FaqDialog.js';
|
||||
import { MenuDialog } from './dialogs/MenuDialog.js';
|
||||
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from './models/index.js';
|
||||
|
||||
/**
|
||||
* Package for kb.gbapp.
|
||||
|
|
|
@ -57,8 +57,8 @@ import {
|
|||
import {
|
||||
GuaribasInstance,
|
||||
GuaribasPackage
|
||||
} from '../../core.gbapp/models/GBModel';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
} from '../../core.gbapp/models/GBModel.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
|
||||
/**
|
||||
* Subjects to group the pair of questions and answers.
|
||||
|
@ -68,53 +68,53 @@ export class GuaribasSubject extends Model<GuaribasSubject> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public subjectId: number;
|
||||
declare subjectId: number;
|
||||
|
||||
@Column(DataType.INTEGER)
|
||||
public internalId: string;
|
||||
declare internalId: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public title: string;
|
||||
declare title: string;
|
||||
|
||||
@Column(DataType.STRING(512))
|
||||
public description: string;
|
||||
declare description: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public from: string;
|
||||
declare from: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public to: string;
|
||||
declare to: string;
|
||||
|
||||
@ForeignKey(() => GuaribasSubject)
|
||||
@Column(DataType.INTEGER)
|
||||
public parentSubjectId: number;
|
||||
declare parentSubjectId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasSubject, 'parentSubjectId')
|
||||
public parentSubject: GuaribasSubject;
|
||||
declare parentSubject: GuaribasSubject;
|
||||
|
||||
@HasMany(() => GuaribasSubject, { foreignKey: 'parentSubjectId' })
|
||||
public childrenSubjects: GuaribasSubject[];
|
||||
declare childrenSubjects: GuaribasSubject[];
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@ForeignKey(() => GuaribasUser)
|
||||
@Column(DataType.INTEGER)
|
||||
public responsibleUserId: number;
|
||||
declare responsibleUserId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasUser)
|
||||
public responsibleUser: GuaribasUser;
|
||||
declare responsibleUser: GuaribasUser;
|
||||
|
||||
@ForeignKey(() => GuaribasPackage)
|
||||
@Column(DataType.INTEGER)
|
||||
public packageId: number;
|
||||
declare packageId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasPackage)
|
||||
public package: GuaribasPackage;
|
||||
declare package: GuaribasPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,62 +125,62 @@ export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public questionId: number;
|
||||
declare questionId: number;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public subject1: string;
|
||||
declare subject1: string;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public subject2: string;
|
||||
declare subject2: string;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public subject3: string;
|
||||
declare subject3: string;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public subject4: string;
|
||||
declare subject4: string;
|
||||
|
||||
@Column(DataType.STRING(1024))
|
||||
public keywords: string;
|
||||
declare keywords: string;
|
||||
|
||||
@Column(DataType.BOOLEAN)
|
||||
public skipIndex: boolean;
|
||||
declare skipIndex: boolean;
|
||||
|
||||
@Column(DataType.STRING(512))
|
||||
public from: string;
|
||||
declare from: string;
|
||||
|
||||
@Column(DataType.STRING(512))
|
||||
public to: string;
|
||||
declare to: string;
|
||||
|
||||
@Column(DataType.TEXT)
|
||||
public content: string;
|
||||
declare content: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
|
||||
//tslint:disable-next-line:no-use-before-declare
|
||||
@ForeignKey(() => GuaribasAnswer)
|
||||
@Column(DataType.INTEGER)
|
||||
public answerId: number;
|
||||
declare answerId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasPackage)
|
||||
@Column(DataType.INTEGER)
|
||||
public packageId: number;
|
||||
declare packageId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasPackage)
|
||||
public package: GuaribasPackage;
|
||||
declare package: GuaribasPackage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,53 +191,53 @@ export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public answerId: number;
|
||||
declare answerId: number;
|
||||
|
||||
@Length({ min: 0, max: 512 })
|
||||
@Column(DataType.STRING(512))
|
||||
public media: string;
|
||||
declare media: string;
|
||||
|
||||
@Length({ min: 0, max: 12 })
|
||||
@Column(DataType.STRING(12))
|
||||
public format: string;
|
||||
declare format: string;
|
||||
|
||||
@Column(DataType.TEXT)
|
||||
public content: string;
|
||||
declare content: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@CreatedAt
|
||||
public createdAt: Date;
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
@UpdatedAt
|
||||
public updatedAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
|
||||
@HasMany(() => GuaribasQuestion)
|
||||
public questions: GuaribasQuestion[];
|
||||
declare questions: GuaribasQuestion[];
|
||||
|
||||
@HasOne(() => GuaribasQuestion)
|
||||
public prev: GuaribasQuestion;
|
||||
declare prev: GuaribasQuestion;
|
||||
|
||||
@HasOne(() => GuaribasQuestion)
|
||||
public next: GuaribasQuestion;
|
||||
declare next: GuaribasQuestion;
|
||||
|
||||
@ForeignKey(() => GuaribasQuestion)
|
||||
@Column(DataType.INTEGER)
|
||||
public nextId: number;
|
||||
declare nextId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasQuestion)
|
||||
@Column(DataType.INTEGER)
|
||||
public prevId: number;
|
||||
declare prevId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasPackage)
|
||||
@Column(DataType.INTEGER)
|
||||
public packageId: number;
|
||||
declare packageId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasPackage)
|
||||
public package: GuaribasPackage;
|
||||
declare package: GuaribasPackage;
|
||||
}
|
||||
|
|
|
@ -34,17 +34,16 @@
|
|||
* @fileoverview Knowledge base services and logic.
|
||||
*/
|
||||
|
||||
const Path = require('path');
|
||||
const Fs = require('fs');
|
||||
const urlJoin = require('url-join');
|
||||
const path = require('path');
|
||||
const asyncPromise = require('async-promises');
|
||||
const walkPromise = require('walk-promise');
|
||||
// tslint:disable-next-line:newline-per-chained-call
|
||||
const { SearchService } = require('azure-search-client');
|
||||
const Excel = require('exceljs');
|
||||
const getSlug = require('speakingurl');
|
||||
import { GBServer } from '../../../src/app';
|
||||
import Path from 'path';
|
||||
import Fs from 'fs';
|
||||
import urlJoin from 'url-join';
|
||||
import path from 'path';
|
||||
import asyncPromise from 'async-promises';
|
||||
import walkPromise from 'walk-promise';
|
||||
import { SearchService } from 'azure-search-client';
|
||||
import Excel from 'exceljs';
|
||||
import getSlug from 'speakingurl';
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import {
|
||||
GBDialogStep,
|
||||
GBLog,
|
||||
|
@ -57,15 +56,15 @@ import {
|
|||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { Op } from 'sequelize';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||
import { GuaribasPackage } from '../../core.gbapp/models/GBModel';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService';
|
||||
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models';
|
||||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
||||
const request = require('request-promise-native');
|
||||
const textract = require('textract');
|
||||
const pdf = require("pdf-extraction");
|
||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService.js';
|
||||
import { GuaribasPackage } from '../../core.gbapp/models/GBModel.js';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
||||
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService.js';
|
||||
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models/index.js';
|
||||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService.js';
|
||||
import request from 'request-promise-native';
|
||||
import textract from 'textract';
|
||||
import pdf from "pdf-extraction";
|
||||
|
||||
/**
|
||||
* Result for quey on KB data.
|
||||
|
@ -425,8 +424,8 @@ export class KBService implements IGBKBService {
|
|||
// when loading worksheets collection.
|
||||
|
||||
let worksheet: any;
|
||||
for (let t = 0; t < data._worksheets.length; t++) {
|
||||
worksheet = data._worksheets[t];
|
||||
for (let t = 0; t < data.worksheets.length; t++) {
|
||||
worksheet = data.worksheets[t];
|
||||
if (worksheet) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
import { TokenResponse } from 'botbuilder';
|
||||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { Messages } from '../strings';
|
||||
import { Messages } from '../strings.js';
|
||||
|
||||
/**
|
||||
* Dialogs for handling Menu control.
|
||||
|
|
|
@ -36,16 +36,11 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
|
||||
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { Messages } from '../strings';
|
||||
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||
const phone = require('phone');
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import * as phone from 'google-libphonenumber';
|
||||
|
||||
/**
|
||||
* Dialogs for handling Menu control.
|
||||
|
@ -112,14 +107,15 @@ export class ProfileDialog extends IGBDialog {
|
|||
const locale = step.context.activity.locale;
|
||||
let phoneNumber;
|
||||
try {
|
||||
phoneNumber = phone(step.result, 'BRA')[0]; // TODO: Use accordingly to the person.
|
||||
phoneNumber = phoneUtil.parse(phoneNumber);
|
||||
let p = phone.PhoneNumberUtil.getInstance();
|
||||
phoneNumber = p(step.result, 'BRA')[0]; // TODO: Use accordingly to the person.
|
||||
phoneNumber = phone.phoneUtil.parse(phoneNumber);
|
||||
} catch (error) {
|
||||
await step.context.sendActivity(Messages[locale].validation_enter_valid_mobile);
|
||||
|
||||
return await step.replaceDialog('/profile_mobile', step.activeDialog.state.options);
|
||||
}
|
||||
if (!phoneUtil.isPossibleNumber(phoneNumber)) {
|
||||
if (!phone.phoneUtil.isPossibleNumber(phoneNumber)) {
|
||||
await step.context.sendActivity(Messages[locale].validation_enter_valid_mobile);
|
||||
|
||||
return await step.replaceDialog('/profile_mobile', step.activeDialog.state.options);
|
||||
|
|
|
@ -36,13 +36,11 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { OAuthDialog } from './dialogs/OAuthDialog';
|
||||
import { ProfileDialog } from './dialogs/ProfileDialog';
|
||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from './models';
|
||||
import { OAuthDialog } from './dialogs/OAuthDialog.js';
|
||||
import { ProfileDialog } from './dialogs/ProfileDialog.js';
|
||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from './models/index.js';
|
||||
|
||||
/**
|
||||
* Package for the security module.
|
||||
|
|
|
@ -48,7 +48,7 @@ import {
|
|||
Table
|
||||
} from 'sequelize-typescript';
|
||||
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel.js';
|
||||
|
||||
/**
|
||||
* A user and its metadata.
|
||||
|
@ -58,46 +58,46 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public userId: number;
|
||||
declare userId: number;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public displayName: string;
|
||||
declare displayName: string;
|
||||
|
||||
@Column(DataType.INTEGER)
|
||||
public userSystemId: string;
|
||||
declare userSystemId: string;
|
||||
@Column(DataType.STRING(255))
|
||||
public userName: string;
|
||||
declare userName: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public defaultChannel: string;
|
||||
declare defaultChannel: string;
|
||||
|
||||
@Column(DataType.STRING(255))
|
||||
public email: string;
|
||||
declare email: string;
|
||||
|
||||
@Column(DataType.STRING(5))
|
||||
public locale: string;
|
||||
declare locale: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@Column(DataType.INTEGER)
|
||||
public agentSystemId: string;
|
||||
declare agentSystemId: string;
|
||||
|
||||
@Column(DataType.DATE)
|
||||
public agentContacted: Date;
|
||||
declare agentContacted: Date;
|
||||
|
||||
@Column(DataType.STRING(16))
|
||||
public agentMode: string;
|
||||
declare agentMode: string;
|
||||
|
||||
@Column(DataType.TEXT)
|
||||
public conversationReference: string;
|
||||
declare conversationReference: string;
|
||||
|
||||
@Column(DataType.STRING(64))
|
||||
public hearOnDialog: string;
|
||||
declare hearOnDialog: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,18 +108,18 @@ export class GuaribasGroup extends Model<GuaribasGroup> {
|
|||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column(DataType.INTEGER)
|
||||
public groupId: number;
|
||||
declare groupId: number;
|
||||
|
||||
@Length({ min: 0, max: 512 })
|
||||
@Column(DataType.STRING(512))
|
||||
public displayName: string;
|
||||
declare displayName: string;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,22 +129,22 @@ export class GuaribasGroup extends Model<GuaribasGroup> {
|
|||
export class GuaribasUserGroup extends Model<GuaribasUserGroup> {
|
||||
@ForeignKey(() => GuaribasUser)
|
||||
@Column(DataType.INTEGER)
|
||||
public userId: number;
|
||||
declare userId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasGroup)
|
||||
@Column(DataType.INTEGER)
|
||||
public groupId: number;
|
||||
declare groupId: number;
|
||||
|
||||
@ForeignKey(() => GuaribasInstance)
|
||||
@Column(DataType.INTEGER)
|
||||
public instanceId: number;
|
||||
declare instanceId: number;
|
||||
|
||||
@BelongsTo(() => GuaribasInstance)
|
||||
public instance: GuaribasInstance;
|
||||
declare instance: GuaribasInstance;
|
||||
|
||||
@BelongsTo(() => GuaribasGroup)
|
||||
public group: GuaribasGroup;
|
||||
declare group: GuaribasGroup;
|
||||
|
||||
@BelongsTo(() => GuaribasUser)
|
||||
public user: GuaribasUser;
|
||||
declare user: GuaribasUser;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const Fs = require('fs');
|
||||
const urlJoin = require('url-join');
|
||||
import Fs from 'fs';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
import { ConversationReference } from 'botbuilder';
|
||||
import { GBLog, GBMinInstance, GBService, IGBInstance } from 'botlib';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models/index.js';
|
||||
import { FindOptions } from 'sequelize';
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,29 +36,12 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const { sppull } = require('sppull');
|
||||
|
||||
|
||||
/**
|
||||
* Service facade for SharePoint Online.
|
||||
*/
|
||||
export class GBSharePointService {
|
||||
|
||||
public async downloadFolder(localPath: string, siteUrl: string, folderUrl: string, username: string, password: string) {
|
||||
|
||||
const context = {
|
||||
siteUrl: siteUrl,
|
||||
creds: {
|
||||
username: username,
|
||||
password: password
|
||||
}
|
||||
};
|
||||
|
||||
const options = {
|
||||
spRootFolder: folderUrl,
|
||||
dlRootFolder: localPath
|
||||
};
|
||||
|
||||
return await sppull(context, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,11 +30,9 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
import { GBService } from 'botlib';
|
||||
const fs = require('fs');
|
||||
var AdmZip = require("adm-zip");
|
||||
|
||||
import Fs from 'fs';
|
||||
import AdmZip from 'adm-zip';
|
||||
|
||||
/**
|
||||
* Support for Whatsapp.
|
||||
|
@ -51,7 +49,7 @@ export class TeamsService extends GBService {
|
|||
}
|
||||
|
||||
public async getManifest(marketplaceId, botName, botDescription, id, packageName, yourName) {
|
||||
let content = fs.readFileSync('teams-manifest.json', 'utf8');
|
||||
let content = Fs.readFileSync('teams-manifest.json', 'utf8');
|
||||
|
||||
content = content.replace(/\@\@marketplaceId/gi, marketplaceId);
|
||||
content = content.replace(/\@\@botName/gi, botName);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||
import { Sequelize } from 'sequelize-typescript';
|
||||
import { WhatsappDirectLine } from './services/WhatsappDirectLine';
|
||||
import { WhatsappDirectLine } from './services/WhatsappDirectLine.js';
|
||||
|
||||
/**
|
||||
* Package for whatsapp.gblib
|
||||
|
|
|
@ -30,29 +30,23 @@
|
|||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
const urlJoin = require('url-join');
|
||||
|
||||
const Swagger = require('swagger-client');
|
||||
const fs = require('fs');
|
||||
const Path = require('path');
|
||||
import urlJoin from 'url-join';
|
||||
import Swagger from 'swagger-client';
|
||||
import Path from 'path';
|
||||
import Fs from 'fs';
|
||||
import { GBLog, GBMinInstance, GBService, IGBPackage } from 'botlib';
|
||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||
import * as request from 'request-promise-native';
|
||||
import { GBServer } from '../../../src/app';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { Messages } from '../strings';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords';
|
||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||
import { GBMinService } from '../../core.gbapp/services/GBMinService';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
const { MessageMedia, Client, LocalAuth } = require('whatsapp-web.js');
|
||||
const qrcode = require('qrcode-terminal');
|
||||
|
||||
import { GBServer } from '../../../src/app.js';
|
||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService.js';
|
||||
import { SecService } from '../../security.gbapp/services/SecService.js';
|
||||
import { Messages } from '../strings.js';
|
||||
import { GuaribasUser } from '../../security.gbapp/models/index.js';
|
||||
import { GBMinService } from '../../core.gbapp/services/GBMinService.js';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
||||
import * as wpp from 'whatsapp-web.js';
|
||||
import qrcode from 'qrcode-terminal';
|
||||
import express from 'express';
|
||||
|
||||
/**
|
||||
* Support for Whatsapp.
|
||||
|
@ -117,7 +111,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
this.directLineClient =
|
||||
new Swagger({
|
||||
spec: JSON.parse(fs.readFileSync('directline-3.0.json', 'utf8')), usePromise: true
|
||||
spec: JSON.parse(Fs.readFileSync('directline-3.0.json', 'utf8')), usePromise: true
|
||||
});
|
||||
const client = await this.directLineClient;
|
||||
|
||||
|
@ -164,8 +158,8 @@ export class WhatsappDirectLine extends GBService {
|
|||
puppeteer = { browserWSEndpoint: browserWSEndpoint };
|
||||
}
|
||||
|
||||
const client = this.customClient = new Client({
|
||||
authStrategy: new LocalAuth({
|
||||
const client = this.customClient = new wpp.Client({
|
||||
authStrategy: new wpp.LocalAuth({
|
||||
clientId: this.min.botId,
|
||||
dataPath: localName
|
||||
}),
|
||||
|
@ -194,7 +188,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
// const qrBuf = await s.getQRCode(qr);
|
||||
// const gbaiName = `${this.min.botId}.gbai`;
|
||||
// const localName = Path.join('work', gbaiName, 'cache', `qr${GBAdminService.getRndReadableIdentifier()}.png`);
|
||||
// fs.writeFileSync(localName, qrBuf);
|
||||
// Fs.writeFileSync(localName, qrBuf);
|
||||
// const url = urlJoin(
|
||||
// GBServer.globals.publicAddress,
|
||||
// this.min.botId,
|
||||
|
@ -291,7 +285,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
}
|
||||
|
||||
if (setUrl && options&& this.whatsappServiceUrl) {
|
||||
const express = require('express');
|
||||
|
||||
GBServer.globals.server.use(`/audios`, express.static('work'));
|
||||
|
||||
if (options) {
|
||||
|
@ -729,7 +723,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
let options;
|
||||
switch (this.provider) {
|
||||
case 'GeneralBots':
|
||||
const attachment = await MessageMedia.fromUrl(url);
|
||||
const attachment = await wpp.MessageMedia.fromUrl(url);
|
||||
if (to.indexOf('@') == -1) {
|
||||
if (to.length == 18) {
|
||||
to = to + '@g.us';
|
||||
|
@ -806,7 +800,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
switch (this.provider) {
|
||||
case 'GeneralBots':
|
||||
|
||||
const attachment = MessageMedia.fromUrl(url);
|
||||
const attachment = wpp.MessageMedia.fromUrl(url);
|
||||
await this.customClient.sendMessage(to, attachment);
|
||||
|
||||
break;
|
||||
|
|
42
src/app.ts
42
src/app.ts
|
@ -36,24 +36,24 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
const https = require('https');
|
||||
const mkdirp = require('mkdirp');
|
||||
const Path = require('path');
|
||||
|
||||
import * as fs from 'fs';
|
||||
import express from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import https from 'https';
|
||||
import mkdirp from 'mkdirp';
|
||||
import Path from 'path';
|
||||
import * as Fs from 'fs';
|
||||
import { GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
|
||||
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
|
||||
import { AzureDeployerService } from '../packages/azuredeployer.gbapp/services/AzureDeployerService';
|
||||
import { GBConfigService } from '../packages/core.gbapp/services/GBConfigService';
|
||||
import { GBConversationalService } from '../packages/core.gbapp/services/GBConversationalService';
|
||||
import { GBCoreService } from '../packages/core.gbapp/services/GBCoreService';
|
||||
import { GBDeployer } from '../packages/core.gbapp/services/GBDeployer';
|
||||
import { GBImporter } from '../packages/core.gbapp/services/GBImporterService';
|
||||
import { GBMinService } from '../packages/core.gbapp/services/GBMinService';
|
||||
var auth = require('basic-auth');
|
||||
const child_process = require('child_process');
|
||||
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService.js';
|
||||
import { AzureDeployerService } from '../packages/azuredeployer.gbapp/services/AzureDeployerService.js';
|
||||
import { GBConfigService } from '../packages/core.gbapp/services/GBConfigService.js';
|
||||
import { GBConversationalService } from '../packages/core.gbapp/services/GBConversationalService.js';
|
||||
import { GBCoreService } from '../packages/core.gbapp/services/GBCoreService.js';
|
||||
import { GBDeployer } from '../packages/core.gbapp/services/GBDeployer.js';
|
||||
import { GBImporter } from '../packages/core.gbapp/services/GBImporterService.js';
|
||||
import { GBMinService } from '../packages/core.gbapp/services/GBMinService.js';
|
||||
import auth from 'basic-auth';
|
||||
import child_process from 'child_process';
|
||||
import * as winston from 'winston-logs-display';
|
||||
|
||||
/**
|
||||
* Global shared server data;
|
||||
|
@ -117,7 +117,7 @@ export class GBServer {
|
|||
// Creates working directory.
|
||||
|
||||
const workDir = Path.join(process.env.PWD, 'work');
|
||||
if (!fs.existsSync(workDir)) {
|
||||
if (!Fs.existsSync(workDir)) {
|
||||
mkdirp.sync(workDir);
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ export class GBServer {
|
|||
// If global log enabled, reorders transports adding web logging.
|
||||
|
||||
const loggers = GBLog.getLogger();
|
||||
require('winston-logs-display')(server, loggers[1]);
|
||||
winston.default(server, loggers[1]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,14 +254,14 @@ export class GBServer {
|
|||
if (process.env.CERTIFICATE_PFX) {
|
||||
let options = {
|
||||
passphrase: process.env.CERTIFICATE_PASSPHRASE,
|
||||
pfx: fs.readFileSync(process.env.CERTIFICATE_PFX)
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE_PFX)
|
||||
};
|
||||
const httpsServer = https.createServer(options, server).listen(port, mainCallback);
|
||||
|
||||
if (process.env.CERTIFICATE2_PFX) {
|
||||
let options = {
|
||||
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
|
||||
pfx: fs.readFileSync(process.env.CERTIFICATE2_PFX)
|
||||
pfx: Fs.readFileSync(process.env.CERTIFICATE2_PFX)
|
||||
};
|
||||
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
"declaration": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"mapRoot": "./dist/",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": false,
|
||||
"module": "ESNext",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"*": [
|
||||
|
|
Loading…
Add table
Reference in a new issue