Merge pull request #2 from rodrigorodriguez/master

All updates
This commit is contained in:
Rodrigo Rodriguez 2019-06-05 19:03:10 -03:00 committed by GitHub
commit 09a560e07f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1364 additions and 622 deletions

1651
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
{
"name": "botlib",
"version": "0.1.8",
"description": "General Bot base library for building Node.js TypeScript Apps packages (.gbapp)",
"version": "1.2.1",
"description": "General Bot base library for building Node.js TypeScript Apps packages (.gbapp) and Libray packages (.gblib)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "dist/index",
"homepage": "http://www.generalbot.com",
"contributors": [
"Rodrigo Rodriguez <me@rodrigorodriguez.com>",
@ -12,38 +12,37 @@
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/pragmatismo-io/BotLib.git"
"url": "https://github.com/GeneralBots/BotLib.git"
},
"dependencies": {
"async": "2.6.1",
"botbuilder": "4.1.3",
"botbuilder-ai": "4.1.3",
"botbuilder-azure": "4.1.3",
"async": "2.6.2",
"botbuilder": "4.4.0",
"botbuilder-ai": "4.4.0",
"botbuilder-azure": "4.4.0",
"botbuilder-choices": "4.0.0-preview1.2",
"botbuilder-dialogs": "4.1.3",
"botbuilder-location": "2.0.0",
"botbuilder-dialogs": "4.4.0",
"botbuilder-prompts": "4.0.0-preview1.2",
"chrono-node": "1.3.5",
"dotenv-extended": "2.3.0",
"chrono-node": "1.3.11",
"dotenv-extended": "2.4.0",
"iconv-lite": "0.4.24",
"ms": "2.1.1",
"pragmatismo-io-framework": "1.0.18",
"reflect-metadata": "0.1.12",
"sequelize": "4.41.0",
"sequelize-typescript": "0.6.6",
"pragmatismo-io-framework": "1.0.19",
"reflect-metadata": "0.1.13",
"sequelize": "5.8.6",
"sequelize-typescript": "0.6.10",
"wait-until": "0.0.2",
"winston": "3.1.0"
"winston": "3.2.1"
},
"devDependencies": {
"@types/chai": "4.1.7",
"@types/mocha": "5.2.5",
"@types/sequelize": "4.27.30",
"@types/mocha": "5.2.6",
"@types/sequelize": "4.27.49",
"@types/winston": "2.4.4",
"chai": "4.2.0",
"mocha": "5.2.0",
"mocha": "6.1.4",
"mocha-typescript": "1.1.17",
"ts-node": "7.0.1",
"typedoc": "0.13.0",
"typescript": "3.1.6"
"ts-node": "8.1.0",
"typedoc": "0.14.2",
"typescript": "3.4.5"
}
}

5
src/GBDialogStep.ts Normal file
View file

@ -0,0 +1,5 @@
import { DialogContext } from "botbuilder-dialogs";
export class GBDialogStep extends DialogContext {
}

View file

@ -41,8 +41,8 @@ export class GBError {
static createFromCode(GBERROR_TYPE): any { }
getMessageFromErrorCode(type: GBERROR_TYPE) {
if (type == GBERROR_TYPE.nlpGeneralError) {
return `GuaribasBusinessError: Error accessing NLP, check of the service.`
if (type === GBERROR_TYPE.nlpGeneralError) {
return `Error accessing NLP, check of the service.`
}
}

23
src/GBLog.ts Normal file
View file

@ -0,0 +1,23 @@
const logger = require("./logger");
export class GBLog {
public static error(params): void {
logger.error(params);
}
public static warn(params): void {
logger.warn(params);
}
public static info(params): void {
logger.info(params);
}
public static debug(params): void {
logger.debug(params);
}
public static verbose(params): void {
logger.verbose(params);
}
public static silly(params): void {
logger.silly(params);
}
}

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
@ -52,7 +52,10 @@ export class GBMinInstance {
dialogs: DialogSet;
userState: UserState;
userProfile: any;
cbMap: {};
scriptMap: {};
sandBoxMap: {};
constructor() {
this.packages = [];

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
@ -30,10 +30,20 @@
| |
\*****************************************************************************/
"use strict"
"use strict";
import { IGBInstance } from "./IGBinstance";
export interface IGBAdminService {
putValue(key: string, value: string);
getValue(key: string)
acquireElevatedToken(instanceId): Promise<string>;
updateSecurityInfo(
instanceId: number,
authenticatorTenant: string,
authenticatorAuthorityHostUrl: string,
authenticatorClientId: string,
authenticatorClientSecret: string
): Promise<IGBInstance>;
getValue(instanceId: number, key: string): Promise<string>;
setValue(instanceId: number, key: string, value: string): void;
}

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
@ -30,15 +30,13 @@
| |
\*****************************************************************************/
"use strict"
"use strict";
import { GBMinInstance } from "./GBMinInstance"
import { GBMinInstance } from "./GBMinInstance";
import { GBDialogStep } from "./GBDialogStep";
export interface IGBConversationalService {
sendEvent(step:any, name: string, value: any)
runNLP(
step:any,
min: GBMinInstance,
text: string
)
sendEvent(step: GBDialogStep, name: string, value: Object);
routeNLP(step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean>;
getCurrentLanguage(step: GBDialogStep);
}

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
@ -34,7 +34,7 @@
import { Sequelize } from "sequelize-typescript"
import { IGBInstance } from "./IGBInstance"
import { IGBAdminService } from "./IGBAdminService";
import { IGBInstallationDeployer } from "./IGBInstallationDeployer";
/**
* This interface defines the core service which is shared among
@ -42,8 +42,20 @@ import { IGBAdminService } from "./IGBAdminService";
*/
export interface IGBCoreService {
sequelize: Sequelize
initDatabase()
syncDatabaseStructure()
loadInstances(): IGBInstance[]
loadInstance(botId: string): IGBInstance
loadInstances(): Promise<IGBInstance[]>;
loadInstance(botId: string): Promise<IGBInstance>;
loadInstanceById(instanceId: number): Promise<IGBInstance>;
initStorage(): Promise<any>;
createBootInstance(core: IGBCoreService, installationDeployer: IGBInstallationDeployer, proxyAddress: string);
ensureAdminIsSecured();
loadSysPackages(core: IGBCoreService);
ensureProxy(port): Promise<string>;
ensureInstances(instances: IGBInstance[], bootInstance: any, core: IGBCoreService);
checkStorage(azureDeployer: IGBInstallationDeployer);
saveInstance(fullInstance: any);
loadAllInstances(core: IGBCoreService, azureDeployer: IGBInstallationDeployer, proxyAddress: string);
openBrowserInDevelopment();
installWebHook(isGet: boolean, url: string, callback: any);
}

View file

@ -3,7 +3,7 @@ import { BotAdapter } from 'botbuilder'
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |

View file

@ -0,0 +1,58 @@
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| 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 { IGBInstance } from "./IGBInstance";
export interface IGBInstallationDeployer {
updateBotProxy(botId: string, group: string, endpoint: string);
getSubscriptions(credentials);
getKBSearchSchema(indexName);
openStorageFirewall(groupName, serverName);
deployFarm(
proxyAddress: string,
instance: IGBInstance,
credentials,
subscriptionId: string
): Promise<IGBInstance>;
deployToCloud(
title: string,
username: string,
password: string,
cloudLocation: string,
authoringKey: string,
appId: string,
appPassword: string,
subscriptionId: string
);
}

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |

View file

@ -2,7 +2,7 @@
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
@ -34,6 +34,7 @@
import { IGBCoreService } from './IGBCoreService'
import { Sequelize } from 'sequelize-typescript'
import { GBMinInstance } from '.'
import { GBDialogStep } from './GBDialogStep';
// TODO: Include "use strict" in all files.
@ -54,6 +55,11 @@ export interface IGBPackage{
*/
unloadPackage(core: IGBCoreService): void
/**
* Called when a new bot instance is loaded.
*/
getDialogs(min: GBMinInstance)
/**
* Called when a new bot instance is loaded.
*/
@ -65,7 +71,7 @@ export interface IGBPackage{
unloadBot(min: GBMinInstance): void
/**
* Called in each new step.
* Called in each new session.
*/
onNewSession(min: GBMinInstance, step: any): void
onNewSession(min: GBMinInstance, step: GBDialogStep): void
}

View file

@ -30,15 +30,18 @@
| |
\******************************************************************************/
'use strict'
"use strict";
export { Sequelize } from 'sequelize-typescript'
export { IGBConversationalService } from './IGBConversationalService'
export { IGBCoreService } from './IGBCoreService'
export { IGBDialog } from './IGBDialog'
export { IGBPackage } from './IGBPackage'
export { IGBInstance } from './IGBInstance'
export { GBError, GBERROR_TYPE } from './GBError'
export { GBService } from './GBService'
export { GBMinInstance } from './GBMinInstance'
export { IGBAdminService } from './IGBAdminService'
export { Sequelize } from "sequelize-typescript";
export { IGBConversationalService } from "./IGBConversationalService";
export { IGBCoreService } from "./IGBCoreService";
export { IGBDialog } from "./IGBDialog";
export { IGBPackage } from "./IGBPackage";
export { IGBInstance } from "./IGBInstance";
export { GBError, GBERROR_TYPE } from "./GBError";
export { GBService } from "./GBService";
export { GBMinInstance } from "./GBMinInstance";
export { IGBAdminService } from "./IGBAdminService";
export { IGBInstallationDeployer } from "./IGBInstallationDeployer";
export { GBDialogStep } from "./GBDialogStep";
export { GBLog } from "./GBLog";

76
src/logger.ts Normal file
View file

@ -0,0 +1,76 @@
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| 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. |
| |
\*****************************************************************************/
/**
* @fileoverview Logging support.
*/
const { createLogger, format, transports } = require('winston');
const config = {
levels: {
error: 0,
debug: 1,
warn: 2,
data: 3,
info: 4,
verbose: 5,
silly: 6,
custom: 7
},
colors: {
error: 'red',
debug: 'blue',
warn: 'yellow',
data: 'grey',
info: 'green',
verbose: 'cyan',
silly: 'magenta',
custom: 'yellow'
}
};
const logger = createLogger({
format: format.combine(
format.colorize(),
format.simple(),
format.label({ label: 'GeneralBots' }),
format.timestamp(),
format.printf(nfo => {
return `${nfo.timestamp} [${nfo.label}] ${nfo.level}: ${nfo.message}`;
})
),
levels: config.levels,
transports: [new transports.Console()]
});
module.exports = logger;

View file

@ -2,7 +2,7 @@
"compilerOptions": {
"allowJs": false,
"baseUrl": "./",
"declaration": false,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,