feat(scripting): First code changes to VBA implementation.
|
@ -22,13 +22,11 @@ When logging a bug, please be sure to include the following:
|
|||
|
||||
We also accept suggestions in the issue tracker.
|
||||
|
||||
|
||||
In general, things we find useful when reviewing suggestions are:
|
||||
* A description of the problem you're trying to solve
|
||||
* An overview of the suggested solution
|
||||
* Examples of how the suggestion would work in various places
|
||||
|
||||
|
||||
# Instructions for Contributing Code
|
||||
|
||||
## Contributing bug fixes
|
||||
|
|
30
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "botserver",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -7105,11 +7105,13 @@
|
|||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -7122,15 +7124,18 @@
|
|||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -7233,7 +7238,8 @@
|
|||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -7243,6 +7249,7 @@
|
|||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -7255,17 +7262,20 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -7282,6 +7292,7 @@
|
|||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -7354,7 +7365,8 @@
|
|||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -7364,6 +7376,7 @@
|
|||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -7469,6 +7482,7 @@
|
|||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
|
|
@ -43,7 +43,7 @@ import { GBMinInstance } from 'botlib';
|
|||
import { IGBDialog } from 'botlib';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporter';
|
||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||
import { GBAdminService } from '../services/GBAdminService';
|
||||
import { Messages } from '../strings';
|
||||
|
||||
|
|
88
packages/core.gbapp/services/GBAPIService.ts
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*****************************************************************************\
|
||||
| ( )_ _ |
|
||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||
| | | ( )_) | |
|
||||
| (_) \___/' |
|
||||
| |
|
||||
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
||||
| Licensed under the AGPL-3.0. |
|
||||
| |
|
||||
| According to our dual licensing model, this program can be used either |
|
||||
| under the terms of the GNU Affero General Public License, version 3, |
|
||||
| or under a proprietary license. |
|
||||
| |
|
||||
| The texts of the GNU Affero General Public License with an additional |
|
||||
| permission and of our proprietary license can be found at and |
|
||||
| in the LICENSE file you have received along with this program. |
|
||||
| |
|
||||
| This program is distributed in the hope that it will be useful, |
|
||||
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
| GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| "General Bots" is a registered trademark of Pragmatismo.io. |
|
||||
| The licensing of the program under the AGPLv3 does not imply a |
|
||||
| trademark license. Therefore any rights, title and interest in |
|
||||
| our trademarks remain entirely with us. |
|
||||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { BotAdapter } from 'botbuilder';
|
||||
import { GBError } from 'botlib';
|
||||
import { IGBPackage } from 'botlib';
|
||||
import * as fs from 'fs';
|
||||
import { Messages } from '../strings';
|
||||
const logger = require('../../../src/logger');
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { IGBCoreService, IGBInstance } from 'botlib';
|
||||
import { resolve } from 'bluebird';
|
||||
const util = require('util');
|
||||
const vm = require('vm');
|
||||
|
||||
/**
|
||||
* @fileoverview General Bots server core.
|
||||
*/
|
||||
|
||||
export class DialogClass {
|
||||
public step: any;
|
||||
public min: IGBInstance;
|
||||
|
||||
constructor(min: IGBInstance) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public async expectMessage(text: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.min.dialogs.add(
|
||||
new WaterfallDialog('/vmExpect', [
|
||||
async step => {
|
||||
await step.prompt('textPrompt', text);
|
||||
return await step.next();
|
||||
},
|
||||
async step => {
|
||||
resolve(step.result);
|
||||
return await step.next();
|
||||
},
|
||||
]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public sendMessage(text: string) {
|
||||
this.min.dialogs.add(
|
||||
new WaterfallDialog('/vmSend', [
|
||||
async step => {
|
||||
await step.context.sendActivity(text);
|
||||
return await step.next();
|
||||
},
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDe
|
|||
import { GuaribasInstance, GuaribasPackage } from '../models/GBModel';
|
||||
import { KBService } from './../../kb.gbapp/services/KBService';
|
||||
import { GBConfigService } from './GBConfigService';
|
||||
import { GBImporter } from './GBImporter';
|
||||
import { GBImporter } from './GBImporterService';
|
||||
|
||||
/** Deployer service for bots, themes, ai and more. */
|
||||
export class GBDeployer {
|
||||
|
@ -83,160 +83,163 @@ export class GBDeployer {
|
|||
public deployPackages(
|
||||
core: IGBCoreService,
|
||||
server: any,
|
||||
appPackages: IGBPackage[]
|
||||
appPackages: IGBPackage[],
|
||||
) {
|
||||
const _this = this;
|
||||
return new Promise((resolve: any, reject: any): any => {
|
||||
let totalPackages = 0;
|
||||
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
||||
let paths = [GBDeployer.deployFolder];
|
||||
if (additionalPath) {
|
||||
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
||||
}
|
||||
const botPackages = new Array<string>();
|
||||
const gbappPackages = new Array<string>();
|
||||
let generalPackages = new Array<string>();
|
||||
return new Promise(
|
||||
(resolve: any, reject: any): any => {
|
||||
let totalPackages = 0;
|
||||
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
|
||||
let paths = [GBDeployer.deployFolder];
|
||||
if (additionalPath) {
|
||||
|
||||
function doIt(path) {
|
||||
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
||||
const getDirectories = source =>
|
||||
Fs.readdirSync(source)
|
||||
.map(name => Path.join(source, name))
|
||||
.filter(isDirectory);
|
||||
|
||||
const dirs = getDirectories(path);
|
||||
dirs.forEach(element => {
|
||||
if (element.startsWith('.')) {
|
||||
logger.info(`Ignoring ${element}...`);
|
||||
} else {
|
||||
if (element.endsWith('.gbot')) {
|
||||
botPackages.push(element);
|
||||
} else if (element.endsWith('.gbapp')) {
|
||||
gbappPackages.push(element);
|
||||
} else {
|
||||
generalPackages.push(element);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Starting looking for packages (.gbot, .gbtheme, .gbkb, .gbapp)...`
|
||||
);
|
||||
paths.forEach(e => {
|
||||
logger.info(`Looking in: ${e}...`);
|
||||
doIt(e);
|
||||
});
|
||||
|
||||
/** Deploys all .gbapp files first. */
|
||||
|
||||
let appPackagesProcessed = 0;
|
||||
|
||||
gbappPackages.forEach(e => {
|
||||
// Skips .gbapp inside deploy folder.
|
||||
if (!e.startsWith('packages')) {
|
||||
logger.info(`Deploying app: ${e}...`);
|
||||
import(e)
|
||||
.then(m => {
|
||||
const p = new m.Package();
|
||||
p.loadPackage(core, core.sequelize);
|
||||
appPackages.push(p);
|
||||
logger.info(`App (.gbapp) deployed: ${e}.`);
|
||||
appPackagesProcessed++;
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error(`Error deploying App (.gbapp): ${e}: ${err}`);
|
||||
appPackagesProcessed++;
|
||||
});
|
||||
} else {
|
||||
appPackagesProcessed++;
|
||||
paths = paths.concat(additionalPath.toLowerCase().split(';'));
|
||||
}
|
||||
});
|
||||
const botPackages = new Array<string>();
|
||||
const gbappPackages = new Array<string>();
|
||||
let generalPackages = new Array<string>();
|
||||
|
||||
WaitUntil()
|
||||
.interval(1000)
|
||||
.times(10)
|
||||
.condition(function(cb) {
|
||||
logger.info(`Waiting for app package deployment...`);
|
||||
cb(appPackagesProcessed == gbappPackages.length);
|
||||
})
|
||||
.done(async result => {
|
||||
logger.info(`App Package deployment done.`);
|
||||
function doIt(path) {
|
||||
const isDirectory = source => Fs.lstatSync(source).isDirectory();
|
||||
const getDirectories = source =>
|
||||
Fs.readdirSync(source)
|
||||
.map(name => Path.join(source, name))
|
||||
.filter(isDirectory);
|
||||
|
||||
try {
|
||||
await core.syncDatabaseStructure();
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
/** Deploys all .gbot files first. */
|
||||
|
||||
botPackages.forEach(e => {
|
||||
logger.info(`Deploying bot: ${e}...`);
|
||||
_this.deployBot(e);
|
||||
logger.info(`Bot: ${e} deployed...`);
|
||||
});
|
||||
|
||||
/** Then all remaining generalPackages are loaded. */
|
||||
|
||||
generalPackages = generalPackages.filter(p => !p.endsWith('.git'));
|
||||
|
||||
generalPackages.forEach(filename => {
|
||||
const filenameOnly = Path.basename(filename);
|
||||
logger.info(`Deploying package: ${filename}...`);
|
||||
|
||||
/** Handles apps for general bots - .gbapp must stay out of deploy folder. */
|
||||
|
||||
if (
|
||||
Path.extname(filename) === '.gbapp' ||
|
||||
Path.extname(filename) === '.gblib'
|
||||
) {
|
||||
/** Themes for bots. */
|
||||
} else if (Path.extname(filename) === '.gbtheme') {
|
||||
server.use('/themes/' + filenameOnly, express.static(filename));
|
||||
logger.info(
|
||||
`Theme (.gbtheme) assets accessible at: ${'/themes/' +
|
||||
filenameOnly}.`
|
||||
);
|
||||
|
||||
/** Knowledge base for bots. */
|
||||
} else if (Path.extname(filename) === '.gbkb') {
|
||||
server.use(
|
||||
'/kb/' + filenameOnly + '/subjects',
|
||||
express.static(UrlJoin(filename, 'subjects'))
|
||||
);
|
||||
logger.info(
|
||||
`KB (.gbkb) assets accessible at: ${'/kb/' + filenameOnly}.`
|
||||
);
|
||||
} else if (Path.extname(filename) === '.gbui') {
|
||||
// Already Handled
|
||||
const dirs = getDirectories(path);
|
||||
dirs.forEach(element => {
|
||||
if (element.startsWith('.')) {
|
||||
logger.info(`Ignoring ${element}...`);
|
||||
} else {
|
||||
/** Unknown package format. */
|
||||
const err = new Error(`Package type not handled: ${filename}.`);
|
||||
reject(err);
|
||||
}
|
||||
totalPackages++;
|
||||
});
|
||||
|
||||
WaitUntil()
|
||||
.interval(100)
|
||||
.times(5)
|
||||
.condition(function(cb) {
|
||||
logger.info(`Waiting for package deployment...`);
|
||||
cb(totalPackages == generalPackages.length);
|
||||
})
|
||||
.done(function(result) {
|
||||
if (botPackages.length === 0) {
|
||||
logger.info(
|
||||
'No external packages to load, please use ADDITIONAL_DEPLOY_PATH to point to a .gbai package folder.'
|
||||
);
|
||||
if (element.endsWith('.gbot')) {
|
||||
botPackages.push(element);
|
||||
} else if (element.endsWith('.gbapp')) {
|
||||
gbappPackages.push(element);
|
||||
} else {
|
||||
logger.info(`Package deployment done.`);
|
||||
generalPackages.push(element);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Starting looking for packages (.gbot, .gbtheme, .gbkb, .gbapp)...`,
|
||||
);
|
||||
paths.forEach(e => {
|
||||
logger.info(`Looking in: ${e}...`);
|
||||
doIt(e);
|
||||
});
|
||||
});
|
||||
|
||||
/** Deploys all .gbapp files first. */
|
||||
|
||||
let appPackagesProcessed = 0;
|
||||
|
||||
gbappPackages.forEach(e => {
|
||||
// Skips .gbapp inside deploy folder.
|
||||
if (!e.startsWith('packages')) {
|
||||
logger.info(`Deploying app: ${e}...`);
|
||||
import(e)
|
||||
.then(m => {
|
||||
const p = new m.Package();
|
||||
p.loadPackage(core, core.sequelize);
|
||||
appPackages.push(p);
|
||||
logger.info(`App (.gbapp) deployed: ${e}.`);
|
||||
appPackagesProcessed++;
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error(`Error deploying App (.gbapp): ${e}: ${err}`);
|
||||
appPackagesProcessed++;
|
||||
});
|
||||
} else {
|
||||
appPackagesProcessed++;
|
||||
}
|
||||
});
|
||||
|
||||
WaitUntil()
|
||||
.interval(1000)
|
||||
.times(10)
|
||||
.condition(function(cb) {
|
||||
logger.info(`Waiting for app package deployment...`);
|
||||
cb(appPackagesProcessed == gbappPackages.length);
|
||||
})
|
||||
.done(async result => {
|
||||
logger.info(`App Package deployment done.`);
|
||||
|
||||
try {
|
||||
await core.syncDatabaseStructure();
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
/** Deploys all .gbot files first. */
|
||||
|
||||
botPackages.forEach(e => {
|
||||
logger.info(`Deploying bot: ${e}...`);
|
||||
_this.deployBot(e);
|
||||
logger.info(`Bot: ${e} deployed...`);
|
||||
});
|
||||
|
||||
/** Then all remaining generalPackages are loaded. */
|
||||
|
||||
generalPackages = generalPackages.filter(p => !p.endsWith('.git'));
|
||||
|
||||
generalPackages.forEach(filename => {
|
||||
const filenameOnly = Path.basename(filename);
|
||||
logger.info(`Deploying package: ${filename}...`);
|
||||
|
||||
/** Handles apps for general bots - .gbapp must stay out of deploy folder. */
|
||||
|
||||
if (
|
||||
Path.extname(filename) === '.gbapp' ||
|
||||
Path.extname(filename) === '.gblib'
|
||||
) {
|
||||
/** Themes for bots. */
|
||||
} else if (Path.extname(filename) === '.gbtheme') {
|
||||
server.use('/themes/' + filenameOnly, express.static(filename));
|
||||
logger.info(
|
||||
`Theme (.gbtheme) assets accessible at: ${'/themes/' +
|
||||
filenameOnly}.`,
|
||||
);
|
||||
|
||||
/** Knowledge base for bots. */
|
||||
} else if (Path.extname(filename) === '.gbkb') {
|
||||
server.use(
|
||||
'/kb/' + filenameOnly + '/subjects',
|
||||
express.static(UrlJoin(filename, 'subjects')),
|
||||
);
|
||||
logger.info(
|
||||
`KB (.gbkb) assets accessible at: ${'/kb/' + filenameOnly}.`,
|
||||
);
|
||||
} else if (Path.extname(filename) === '.gbui') {
|
||||
// Already Handled
|
||||
} else {
|
||||
/** Unknown package format. */
|
||||
const err = new Error(`Package type not handled: ${filename}.`);
|
||||
reject(err);
|
||||
}
|
||||
totalPackages++;
|
||||
});
|
||||
|
||||
WaitUntil()
|
||||
.interval(100)
|
||||
.times(5)
|
||||
.condition(function(cb) {
|
||||
logger.info(`Waiting for package deployment...`);
|
||||
cb(totalPackages == generalPackages.length);
|
||||
})
|
||||
.done(function(result) {
|
||||
if (botPackages.length === 0) {
|
||||
logger.info(
|
||||
'No external packages to load, please use ADDITIONAL_DEPLOY_PATH to point to a .gbai package folder.',
|
||||
);
|
||||
} else {
|
||||
logger.info(`Package deployment done.`);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,18 +251,18 @@ export class GBDeployer {
|
|||
const packageName = Path.basename(localPath);
|
||||
const instance = await this.importer.importIfNotExistsBotPackage(
|
||||
packageName,
|
||||
localPath
|
||||
localPath,
|
||||
);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public async deployPackageToStorage(
|
||||
instanceId: number,
|
||||
packageName: string
|
||||
packageName: string,
|
||||
): Promise<GuaribasPackage> {
|
||||
return GuaribasPackage.create({
|
||||
packageName: packageName,
|
||||
instanceId: instanceId
|
||||
instanceId: instanceId,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -293,16 +296,25 @@ export class GBDeployer {
|
|||
case '.gbui':
|
||||
break;
|
||||
|
||||
case '.gbdialog':
|
||||
const vm = new VMService(this.core.sequelize);
|
||||
return service.deployKb(this.core, this, localPath);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
const err = GBError.create(
|
||||
`GuaribasBusinessError: Unknow package type: ${packageType}.`
|
||||
`GuaribasBusinessError: Unknow package type: ${packageType}.`,
|
||||
);
|
||||
Promise.reject(err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public async undeployPackageFromLocalPath(instance: IGBInstance, localPath: string) {
|
||||
public async undeployPackageFromLocalPath(
|
||||
instance: IGBInstance,
|
||||
localPath: string,
|
||||
) {
|
||||
const packageType = Path.extname(localPath);
|
||||
const packageName = Path.basename(localPath);
|
||||
|
||||
|
@ -326,7 +338,7 @@ export class GBDeployer {
|
|||
|
||||
default:
|
||||
const err = GBError.create(
|
||||
`GuaribasBusinessError: Unknown package type: ${packageType}.`
|
||||
`GuaribasBusinessError: Unknown package type: ${packageType}.`,
|
||||
);
|
||||
Promise.reject(err);
|
||||
break;
|
||||
|
@ -338,10 +350,12 @@ export class GBDeployer {
|
|||
instance.searchKey,
|
||||
instance.searchHost,
|
||||
instance.searchIndex,
|
||||
instance.searchIndexer
|
||||
instance.searchIndexer,
|
||||
);
|
||||
|
||||
const connectionString = GBDeployer.getConnectionStringFromInstance(instance);
|
||||
const connectionString = GBDeployer.getConnectionStringFromInstance(
|
||||
instance,
|
||||
);
|
||||
|
||||
const dsName = 'gb';
|
||||
try {
|
||||
|
@ -358,7 +372,7 @@ export class GBDeployer {
|
|||
dsName,
|
||||
'GuaribasQuestion',
|
||||
'azuresql',
|
||||
connectionString
|
||||
connectionString,
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -371,17 +385,17 @@ export class GBDeployer {
|
|||
}
|
||||
await search.createIndex(
|
||||
AzureDeployerService.getKBSearchSchema(instance.searchIndex),
|
||||
dsName
|
||||
dsName,
|
||||
);
|
||||
}
|
||||
|
||||
public async getPackageByName(
|
||||
instanceId: number,
|
||||
packageName: string
|
||||
packageName: string,
|
||||
): Promise<GuaribasPackage> {
|
||||
const where = { packageName: packageName, instanceId: instanceId };
|
||||
return GuaribasPackage.findOne({
|
||||
where: where
|
||||
where: where,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -398,7 +412,7 @@ export class GBDeployer {
|
|||
return Promise.resolve(true);
|
||||
} else {
|
||||
return this.deployPackageFromLocalPath(
|
||||
UrlJoin(deployFolder, bootPackage)
|
||||
UrlJoin(deployFolder, bootPackage),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
99
packages/core.gbapp/services/GBVMService.ts
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*****************************************************************************\
|
||||
| ( )_ _ |
|
||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||
| | | ( )_) | |
|
||||
| (_) \___/' |
|
||||
| |
|
||||
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
||||
| Licensed under the AGPL-3.0. |
|
||||
| |
|
||||
| According to our dual licensing model, this program can be used either |
|
||||
| under the terms of the GNU Affero General Public License, version 3, |
|
||||
| or under a proprietary license. |
|
||||
| |
|
||||
| The texts of the GNU Affero General Public License with an additional |
|
||||
| permission and of our proprietary license can be found at and |
|
||||
| in the LICENSE file you have received along with this program. |
|
||||
| |
|
||||
| This program is distributed in the hope that it will be useful, |
|
||||
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
| GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| "General Bots" is a registered trademark of Pragmatismo.io. |
|
||||
| The licensing of the program under the AGPLv3 does not imply a |
|
||||
| trademark license. Therefore any rights, title and interest in |
|
||||
| our trademarks remain entirely with us. |
|
||||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IGBCoreService, IGBInstance } from 'botlib';
|
||||
import { GBError } from 'botlib';
|
||||
import { IGBPackage } from 'botlib';
|
||||
const logger = require('../../../src/logger');
|
||||
import * as fs from 'fs';
|
||||
import { BotAdapter } from 'botbuilder';
|
||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||
import { Messages } from '../strings';
|
||||
import { GBDeployer } from './GBDeployer';
|
||||
const util = require('util');
|
||||
const vm = require('vm');
|
||||
|
||||
/**
|
||||
* @fileoverview General Bots server core.
|
||||
*/
|
||||
|
||||
export class GBVMService implements IGBCoreService {
|
||||
|
||||
public static setup(bot: BotAdapter, min: IGBInstance) {
|
||||
|
||||
}
|
||||
|
||||
public loadJS(
|
||||
filename: string,
|
||||
min: IGBInstance,
|
||||
core: IGBCoreService,
|
||||
deployer: GBDeployer,
|
||||
localPath: string
|
||||
) {
|
||||
|
||||
const sandbox = {
|
||||
animal: 'cat',
|
||||
count: 2,
|
||||
};
|
||||
|
||||
const script = new vm.Script('count += 1; name = "kitty";');
|
||||
const context = vm.createContext(sandbox);
|
||||
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
script.runInContext(context);
|
||||
}
|
||||
|
||||
console.log(util.inspect(sandbox));
|
||||
|
||||
// { animal: 'cat', count: 12, name: 'kitty' }
|
||||
|
||||
const packageType = Path.extname(localPath);
|
||||
const packageName = Path.basename(localPath);
|
||||
logger.info(`[GBDeployer] Opening package: ${localPath}`);
|
||||
const packageObject = JSON.parse(
|
||||
Fs.readFileSync(UrlJoin(localPath, 'package.json'), 'utf8'),
|
||||
);
|
||||
|
||||
const instance = await core.loadInstance(packageObject.botId);
|
||||
logger.info(`[GBDeployer] Importing: ${localPath}`);
|
||||
const p = await deployer.deployPackageToStorage(
|
||||
instance.instanceId,
|
||||
packageName,
|
||||
);
|
||||
await this.importKbPackage(localPath, p, instance);
|
||||
|
||||
deployer.rebuildIndex(instance);
|
||||
logger.info(`[GBDeployer] Finished import of ${localPath}`);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import {GBImporter} from '../services/GBImporter';
|
||||
import {GBImporter} from '../services/GBImporterService';
|
||||
|
||||
describe('Hello function', () => {
|
||||
|
||||
|
|
51
packages/core.gbapp/tests/vm.test.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*****************************************************************************\
|
||||
| ( )_ _ |
|
||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||
| | | ( )_) | |
|
||||
| (_) \___/' |
|
||||
| |
|
||||
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
||||
| Licensed under the AGPL-3.0. |
|
||||
| |
|
||||
| According to our dual licensing model, this program can be used either |
|
||||
| under the terms of the GNU Affero General Public License, version 3, |
|
||||
| or under a proprietary license. |
|
||||
| |
|
||||
| The texts of the GNU Affero General Public License with an additional |
|
||||
| permission and of our proprietary license can be found at and |
|
||||
| in the LICENSE file you have received along with this program. |
|
||||
| |
|
||||
| This program is distributed in the hope that it will be useful, |
|
||||
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
| GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| "General Bots" is a registered trademark of Pragmatismo.io. |
|
||||
| The licensing of the program under the AGPLv3 does not imply a |
|
||||
| trademark license. Therefore any rights, title and interest in |
|
||||
| our trademarks remain entirely with us. |
|
||||
| |
|
||||
\*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Tests for General Bots VM.
|
||||
*/
|
||||
|
||||
import { expect } from 'chai';
|
||||
import { GBVMService } from '../services/GBVMService';
|
||||
|
||||
describe('Load function', () => {
|
||||
it('should fail on invalid file', () => {
|
||||
try {
|
||||
const service = new GBVMService();
|
||||
service.loadJS('invalid.file');
|
||||
} catch (error) {
|
||||
expect(error).to.equal(0);
|
||||
}
|
||||
});
|
||||
});
|
43
packages/default.gbdialog/chat.dialog.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
export function chat() {
|
||||
//****************************************************************************
|
||||
// ( )_ _
|
||||
// _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _
|
||||
// ( //_`\ ( //__)///_` ) ///_ `\/// _ ` _ `\ ///_` )| | | |///,__)/// _ `\ ///_`\
|
||||
// | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) )
|
||||
// | ,__///(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___///
|
||||
// | | ( )_) |
|
||||
// (_) \___///
|
||||
//
|
||||
// General Bots Copyright (c) Pragmatismo.io. All rights reserved.
|
||||
// Licensed under the AGPL-3.0.
|
||||
//
|
||||
// According to our dual licensing model, this program can be used either
|
||||
// under the terms of the GNU Affero General Public License, version 3,
|
||||
// or under a proprietary license.
|
||||
//
|
||||
// The texts of the GNU Affero General Public License with an additional
|
||||
// permission and of our proprietary license can be found at and
|
||||
// in the LICENSE file you have received along with this program.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY, without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// "General Bots" is a registered trademark of Pragmatismo.io.
|
||||
// The licensing of the program under the AGPLv3 does not imply a
|
||||
// trademark license. Therefore any rights, title and interest in
|
||||
// our trademarks remain entirely with us.
|
||||
//
|
||||
//****************************************************************************
|
||||
|
||||
main = () => {
|
||||
bot.addFunction(PegaEmail);
|
||||
|
||||
PegaEmail = bot => {
|
||||
bot.say('Qual seu e-mail?');
|
||||
email = bot.expectEmail;
|
||||
bot.post('/restservice', email);
|
||||
};
|
||||
};
|
||||
}
|
43
packages/default.gbdialog/chat.dialog.vbs
Normal file
|
@ -0,0 +1,43 @@
|
|||
<%
|
||||
|
||||
'****************************************************************************
|
||||
' ( )_ _
|
||||
' _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _
|
||||
' ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\
|
||||
' | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) )
|
||||
' | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/'
|
||||
' | | ( )_) |
|
||||
' (_) \___/'
|
||||
'
|
||||
' General Bots Copyright (c) Pragmatismo.io. All rights reserved.
|
||||
' Licensed under the AGPL-3.0.
|
||||
'
|
||||
' According to our dual licensing model, this program can be used either
|
||||
' under the terms of the GNU Affero General Public License, version 3,
|
||||
' or under a proprietary license.
|
||||
'
|
||||
' The texts of the GNU Affero General Public License with an additional
|
||||
' permission and of our proprietary license can be found at and
|
||||
' in the LICENSE file you have received along with this program.
|
||||
'
|
||||
' This program is distributed in the hope that it will be useful,
|
||||
' but WITHOUT ANY WARRANTY, without even the implied warranty of
|
||||
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
' GNU Affero General Public License for more details.
|
||||
'
|
||||
' "General Bots" is a registered trademark of Pragmatismo.io.
|
||||
' The licensing of the program under the AGPLv3 does not imply a
|
||||
' trademark license. Therefore any rights, title and interest in
|
||||
' our trademarks remain entirely with us.
|
||||
'
|
||||
'****************************************************************************
|
||||
|
||||
function ICanSendEmails()
|
||||
|
||||
bot.say ("Please, what's your e-mail address?")
|
||||
email = bot.expectEmail()
|
||||
bot.sendMail (email, "Olá", "I'm sending a General Bots VBA e-mail.")
|
||||
|
||||
end function
|
||||
|
||||
%>
|
3
packages/default.gbkb/draft.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Últimas notícias
|
||||
Contato
|
||||
Ofertas
|
6
packages/default.gbkb/package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"botId":"pragmatismo-ai-prd",
|
||||
"version": "1.0.0",
|
||||
"description": "Bot pragmatismo.",
|
||||
"license": "Private"
|
||||
}
|
16
packages/default.gbkb/pages/about.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
#Desenvolvimento Personalizado
|
||||
|
||||
General Bots usa linguagem natural para entender o que as pessoas querem, facilitando o desenvolvimento de código. Quando alguém diz: "Preciso do relatório mensal" ou "Imprima o relatório do mês", General Bots entende o mesmo. Utilize o nosso desenvolvimento para estender a conversa com suas próprias regras e intenções.
|
||||
|
||||
#Descoberta
|
||||
|
||||
General Bots pode pró-ativamente sugerir suas habilidades para os usuários baseada no contexto, como solicitação de um pedido, envio de uma mensagem, agendamento de uma conferência telefônica ou qualquer ação definida na sua aplicação.
|
||||
|
||||
#Torne pessoal
|
||||
|
||||
Entregue experiências únicas através do conhecimento que a General Bots possui sobre seus usuários e preferências, para ajudar a tomar decisões e apresentar sempre o melhor cenário.
|
||||
|
||||
#Sem downloads adicionais
|
||||
|
||||
A interface da sua aplicação é automaticamente integrada à General Bots, de modo que não seja necessário realizar download ou instalações.
|
||||
|
58
packages/default.gbkb/subjects.json
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"children": [
|
||||
{
|
||||
"title": "Bots & AI",
|
||||
"description": "Bots & inteligência artificial.",
|
||||
"id": "bots-ai",
|
||||
"children": [
|
||||
{
|
||||
"title": "General Bots",
|
||||
"description": "Plataforma de bots da Pragmatismo.io.",
|
||||
"id": "general-bots"
|
||||
},
|
||||
{
|
||||
"title": "Cortana Intelligence Suite",
|
||||
"description": "Suite de Big Data da Microsoft.",
|
||||
"id": "cortana"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Produtividade",
|
||||
"description": "Artigos sobre sistemas Internos.",
|
||||
"id": "produtividade",
|
||||
"children": [
|
||||
{
|
||||
"title": "Microsoft Project Online",
|
||||
"description": "Artigos sobre o Microsoft Project Online.",
|
||||
"id": "msproject"
|
||||
},
|
||||
{
|
||||
"title": "SharePoint",
|
||||
"description": "SharePoint, sites e serviços.",
|
||||
"id": "sharepoint"
|
||||
},
|
||||
{
|
||||
"title": "Office 365",
|
||||
"description": "Plataforma colaborativa moderna da Microsoft.",
|
||||
"id": "office365"
|
||||
},
|
||||
{
|
||||
"title": "Microsoft Dynamics",
|
||||
"description": "Artigos sobre plataforma de CRM da Microsoft.",
|
||||
"id": "msdynamics"
|
||||
},
|
||||
{
|
||||
"title": "Power BI",
|
||||
"description": "Dashboards modernos e intuitivos.",
|
||||
"id": "powerbi"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Sobre",
|
||||
"description": "Artigos sobre o Bot da Pragmatismo.io",
|
||||
"id": "sobre"
|
||||
}
|
||||
]
|
||||
}
|
BIN
packages/default.gbkb/subjects/bots-ai.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
packages/default.gbkb/subjects/cortana.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
packages/default.gbkb/subjects/general-bots.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
packages/default.gbkb/subjects/msdynamics.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
packages/default.gbkb/subjects/msproject.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
packages/default.gbkb/subjects/office365.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
packages/default.gbkb/subjects/powerbi.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
packages/default.gbkb/subjects/produtividade.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
packages/default.gbkb/subjects/sharepoint.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
packages/default.gbkb/subjects/skype.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
packages/default.gbkb/subjects/sobre.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
packages/default.gbkb/tabular/common-goodbye.tsv
Normal file
|
BIN
packages/default.gbkb/tabular/common-hello.tsv
Normal file
|
BIN
packages/default.gbkb/tabular/common-persona.tsv
Normal file
|
BIN
packages/default.gbkb/tabular/min.tsv
Normal file
|
0
packages/default.gbkb/videos/placeholder
Normal file
|
@ -53,7 +53,7 @@ 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/GBImporter';
|
||||
import { GBImporter } from '../packages/core.gbapp/services/GBImporterService';
|
||||
import { GBMinService } from '../packages/core.gbapp/services/GBMinService';
|
||||
import { GBCustomerSatisfactionPackage } from '../packages/customer-satisfaction.gbapp';
|
||||
import { GBKBPackage } from '../packages/kb.gbapp';
|
||||
|
|