commit
09a560e07f
16 changed files with 1364 additions and 622 deletions
1651
package-lock.json
generated
1651
package-lock.json
generated
File diff suppressed because it is too large
Load diff
45
package.json
45
package.json
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "botlib",
|
"name": "botlib",
|
||||||
"version": "0.1.8",
|
"version": "1.2.1",
|
||||||
"description": "General Bot base library for building Node.js TypeScript Apps packages (.gbapp)",
|
"description": "General Bot base library for building Node.js TypeScript Apps packages (.gbapp) and Libray packages (.gblib)",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index",
|
||||||
"homepage": "http://www.generalbot.com",
|
"homepage": "http://www.generalbot.com",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Rodrigo Rodriguez <me@rodrigorodriguez.com>",
|
"Rodrigo Rodriguez <me@rodrigorodriguez.com>",
|
||||||
|
|
@ -12,38 +12,37 @@
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pragmatismo-io/BotLib.git"
|
"url": "https://github.com/GeneralBots/BotLib.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "2.6.1",
|
"async": "2.6.2",
|
||||||
"botbuilder": "4.1.3",
|
"botbuilder": "4.4.0",
|
||||||
"botbuilder-ai": "4.1.3",
|
"botbuilder-ai": "4.4.0",
|
||||||
"botbuilder-azure": "4.1.3",
|
"botbuilder-azure": "4.4.0",
|
||||||
"botbuilder-choices": "4.0.0-preview1.2",
|
"botbuilder-choices": "4.0.0-preview1.2",
|
||||||
"botbuilder-dialogs": "4.1.3",
|
"botbuilder-dialogs": "4.4.0",
|
||||||
"botbuilder-location": "2.0.0",
|
|
||||||
"botbuilder-prompts": "4.0.0-preview1.2",
|
"botbuilder-prompts": "4.0.0-preview1.2",
|
||||||
"chrono-node": "1.3.5",
|
"chrono-node": "1.3.11",
|
||||||
"dotenv-extended": "2.3.0",
|
"dotenv-extended": "2.4.0",
|
||||||
"iconv-lite": "0.4.24",
|
"iconv-lite": "0.4.24",
|
||||||
"ms": "2.1.1",
|
"ms": "2.1.1",
|
||||||
"pragmatismo-io-framework": "1.0.18",
|
"pragmatismo-io-framework": "1.0.19",
|
||||||
"reflect-metadata": "0.1.12",
|
"reflect-metadata": "0.1.13",
|
||||||
"sequelize": "4.41.0",
|
"sequelize": "5.8.6",
|
||||||
"sequelize-typescript": "0.6.6",
|
"sequelize-typescript": "0.6.10",
|
||||||
"wait-until": "0.0.2",
|
"wait-until": "0.0.2",
|
||||||
"winston": "3.1.0"
|
"winston": "3.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "4.1.7",
|
"@types/chai": "4.1.7",
|
||||||
"@types/mocha": "5.2.5",
|
"@types/mocha": "5.2.6",
|
||||||
"@types/sequelize": "4.27.30",
|
"@types/sequelize": "4.27.49",
|
||||||
"@types/winston": "2.4.4",
|
"@types/winston": "2.4.4",
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"mocha": "5.2.0",
|
"mocha": "6.1.4",
|
||||||
"mocha-typescript": "1.1.17",
|
"mocha-typescript": "1.1.17",
|
||||||
"ts-node": "7.0.1",
|
"ts-node": "8.1.0",
|
||||||
"typedoc": "0.13.0",
|
"typedoc": "0.14.2",
|
||||||
"typescript": "3.1.6"
|
"typescript": "3.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
5
src/GBDialogStep.ts
Normal file
5
src/GBDialogStep.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { DialogContext } from "botbuilder-dialogs";
|
||||||
|
|
||||||
|
|
||||||
|
export class GBDialogStep extends DialogContext {
|
||||||
|
}
|
||||||
|
|
@ -41,8 +41,8 @@ export class GBError {
|
||||||
static createFromCode(GBERROR_TYPE): any { }
|
static createFromCode(GBERROR_TYPE): any { }
|
||||||
|
|
||||||
getMessageFromErrorCode(type: GBERROR_TYPE) {
|
getMessageFromErrorCode(type: GBERROR_TYPE) {
|
||||||
if (type == GBERROR_TYPE.nlpGeneralError) {
|
if (type === GBERROR_TYPE.nlpGeneralError) {
|
||||||
return `GuaribasBusinessError: Error accessing NLP, check of the service.`
|
return `Error accessing NLP, check of the service.`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
23
src/GBLog.ts
Normal file
23
src/GBLog.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
@ -52,7 +52,10 @@ export class GBMinInstance {
|
||||||
dialogs: DialogSet;
|
dialogs: DialogSet;
|
||||||
userState: UserState;
|
userState: UserState;
|
||||||
userProfile: any;
|
userProfile: any;
|
||||||
|
|
||||||
cbMap: {};
|
cbMap: {};
|
||||||
|
scriptMap: {};
|
||||||
|
sandBoxMap: {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.packages = [];
|
this.packages = [];
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
@ -30,10 +30,20 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
"use strict";
|
||||||
|
|
||||||
|
import { IGBInstance } from "./IGBinstance";
|
||||||
|
|
||||||
export interface IGBAdminService {
|
export interface IGBAdminService {
|
||||||
putValue(key: string, value: string);
|
acquireElevatedToken(instanceId): Promise<string>;
|
||||||
getValue(key: string)
|
updateSecurityInfo(
|
||||||
acquireElevatedToken(instanceId):Promise<string>;
|
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;
|
||||||
}
|
}
|
||||||
|
|
@ -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 {
|
export interface IGBConversationalService {
|
||||||
sendEvent(step:any, name: string, value: any)
|
sendEvent(step: GBDialogStep, name: string, value: Object);
|
||||||
runNLP(
|
routeNLP(step: GBDialogStep, min: GBMinInstance, text: string): Promise<boolean>;
|
||||||
step:any,
|
getCurrentLanguage(step: GBDialogStep);
|
||||||
min: GBMinInstance,
|
|
||||||
text: string
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
import { Sequelize } from "sequelize-typescript"
|
import { Sequelize } from "sequelize-typescript"
|
||||||
import { IGBInstance } from "./IGBInstance"
|
import { IGBInstance } from "./IGBInstance"
|
||||||
import { IGBAdminService } from "./IGBAdminService";
|
import { IGBInstallationDeployer } from "./IGBInstallationDeployer";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines the core service which is shared among
|
* This interface defines the core service which is shared among
|
||||||
|
|
@ -42,8 +42,20 @@ import { IGBAdminService } from "./IGBAdminService";
|
||||||
*/
|
*/
|
||||||
export interface IGBCoreService {
|
export interface IGBCoreService {
|
||||||
sequelize: Sequelize
|
sequelize: Sequelize
|
||||||
initDatabase()
|
|
||||||
syncDatabaseStructure()
|
syncDatabaseStructure()
|
||||||
loadInstances(): IGBInstance[]
|
loadInstances(): Promise<IGBInstance[]>;
|
||||||
loadInstance(botId: string): 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ import { BotAdapter } from 'botbuilder'
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
|
||||||
58
src/IGBInstallationDeployer.ts
Normal file
58
src/IGBInstallationDeployer.ts
Normal 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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
|
||||||
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
|
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
|
||||||
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
|
||||||
| | | ( )_) | |
|
| | | ( )_) | |
|
||||||
| (_) \___/' |
|
| (_) \___/' |
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
import { IGBCoreService } from './IGBCoreService'
|
import { IGBCoreService } from './IGBCoreService'
|
||||||
import { Sequelize } from 'sequelize-typescript'
|
import { Sequelize } from 'sequelize-typescript'
|
||||||
import { GBMinInstance } from '.'
|
import { GBMinInstance } from '.'
|
||||||
|
import { GBDialogStep } from './GBDialogStep';
|
||||||
|
|
||||||
// TODO: Include "use strict" in all files.
|
// TODO: Include "use strict" in all files.
|
||||||
|
|
||||||
|
|
@ -54,6 +55,11 @@ export interface IGBPackage{
|
||||||
*/
|
*/
|
||||||
unloadPackage(core: IGBCoreService): void
|
unloadPackage(core: IGBCoreService): void
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a new bot instance is loaded.
|
||||||
|
*/
|
||||||
|
getDialogs(min: GBMinInstance)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a new bot instance is loaded.
|
* Called when a new bot instance is loaded.
|
||||||
*/
|
*/
|
||||||
|
|
@ -65,7 +71,7 @@ export interface IGBPackage{
|
||||||
unloadBot(min: GBMinInstance): void
|
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
|
||||||
}
|
}
|
||||||
25
src/index.ts
25
src/index.ts
|
|
@ -30,15 +30,18 @@
|
||||||
| |
|
| |
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
'use strict'
|
"use strict";
|
||||||
|
|
||||||
export { Sequelize } from 'sequelize-typescript'
|
export { Sequelize } from "sequelize-typescript";
|
||||||
export { IGBConversationalService } from './IGBConversationalService'
|
export { IGBConversationalService } from "./IGBConversationalService";
|
||||||
export { IGBCoreService } from './IGBCoreService'
|
export { IGBCoreService } from "./IGBCoreService";
|
||||||
export { IGBDialog } from './IGBDialog'
|
export { IGBDialog } from "./IGBDialog";
|
||||||
export { IGBPackage } from './IGBPackage'
|
export { IGBPackage } from "./IGBPackage";
|
||||||
export { IGBInstance } from './IGBInstance'
|
export { IGBInstance } from "./IGBInstance";
|
||||||
export { GBError, GBERROR_TYPE } from './GBError'
|
export { GBError, GBERROR_TYPE } from "./GBError";
|
||||||
export { GBService } from './GBService'
|
export { GBService } from "./GBService";
|
||||||
export { GBMinInstance } from './GBMinInstance'
|
export { GBMinInstance } from "./GBMinInstance";
|
||||||
export { IGBAdminService } from './IGBAdminService'
|
export { IGBAdminService } from "./IGBAdminService";
|
||||||
|
export { IGBInstallationDeployer } from "./IGBInstallationDeployer";
|
||||||
|
export { GBDialogStep } from "./GBDialogStep";
|
||||||
|
export { GBLog } from "./GBLog";
|
||||||
|
|
|
||||||
76
src/logger.ts
Normal file
76
src/logger.ts
Normal 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;
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowJs": false,
|
"allowJs": false,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
"declaration": false,
|
"declaration": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue