From fe3877c97d23ec97859c4ea9dd041154dbc69490 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Fri, 8 Mar 2019 17:08:42 -0300 Subject: [PATCH] fix(general): tslint being applied in all sources. --- src/GBDialogStep.ts | 5 +++ src/GBLog.ts | 20 +++++++++ src/IGBConversationalService.ts | 6 ++- src/IGBPackage.ts | 5 ++- src/index.ts | 26 +++++------ src/logger.ts | 76 +++++++++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 src/GBDialogStep.ts create mode 100644 src/GBLog.ts create mode 100644 src/logger.ts diff --git a/src/GBDialogStep.ts b/src/GBDialogStep.ts new file mode 100644 index 0000000..7d3fbd0 --- /dev/null +++ b/src/GBDialogStep.ts @@ -0,0 +1,5 @@ + +import { WaterfallStepContext } from "botbuilder-dialogs"; + +export class GBDialogStep extends WaterfallStepContext { +} diff --git a/src/GBLog.ts b/src/GBLog.ts new file mode 100644 index 0000000..4424ce6 --- /dev/null +++ b/src/GBLog.ts @@ -0,0 +1,20 @@ + +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 trace(params): void { + logger.trace(params); + } + public static verbose(params): void { + logger.verbose(params); + } +} diff --git a/src/IGBConversationalService.ts b/src/IGBConversationalService.ts index ea63f02..f0df0a8 100644 --- a/src/IGBConversationalService.ts +++ b/src/IGBConversationalService.ts @@ -33,8 +33,10 @@ "use strict"; import { GBMinInstance } from "./GBMinInstance"; +import { GBDialogStep } from "./GBDialogStep"; export interface IGBConversationalService { - sendEvent(step: any, name: string, value: any); - routeNLP(step: any, min: GBMinInstance, text: string): Promise; + sendEvent(step: GBDialogStep, name: string, value: string); + routeNLP(step: GBDialogStep, min: GBMinInstance, text: string): Promise; + getCurrentLanguage(step: GBDialogStep); } diff --git a/src/IGBPackage.ts b/src/IGBPackage.ts index 507941a..cdc414a 100644 --- a/src/IGBPackage.ts +++ b/src/IGBPackage.ts @@ -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. @@ -70,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 } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 2cd2846..ea10649 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,16 +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 { IGBInstallationDeployer } from './IGBInstallationDeployer' +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"; diff --git a/src/logger.ts b/src/logger.ts new file mode 100644 index 0000000..ee201a7 --- /dev/null +++ b/src/logger.ts @@ -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;