New promises and compiling.

This commit is contained in:
Rodrigo Rodriguez 2018-09-09 14:40:09 -03:00
parent 33a62fde01
commit 9466a214b7
8 changed files with 33 additions and 86 deletions

View file

@ -32,8 +32,4 @@
'use strict'; 'use strict';
import { GBError } from './GBError';
export interface GBServiceCallback<T> { (data: T, error: GBError): void }
export class GBService { } export class GBService { }

View file

@ -33,16 +33,12 @@
"use strict"; "use strict";
import { GBMinInstance } from "./GBMinInstance"; import { GBMinInstance } from "./GBMinInstance";
import { GBServiceCallback } from "./GBService";
import { DialogContext } from "botbuilder-dialogs";
export interface IGBConversationalService { export interface IGBConversationalService {
sendEvent(dc:any, name: string, value: any); sendEvent(dc:any, name: string, value: any);
runNLP( runNLP(
dc:any, dc:any,
min: GBMinInstance, min: GBMinInstance,
text: string, text: string
cb: GBServiceCallback<any>
); );
} }

View file

@ -32,16 +32,17 @@
"use strict"; "use strict";
import { GBMinInstance } from "./GBMinInstance";
import { GBServiceCallback } from "./GBService";
import { Sequelize } from "sequelize-typescript"; import { Sequelize } from "sequelize-typescript";
import { IGBInstance } from "./IGBInstance"; import { IGBInstance } from "./IGBInstance";
/**
* This interface defines the core service which is shared among
* bot packages so they can have direct access to base services.
*/
export interface IGBCoreService { export interface IGBCoreService {
sequelize: Sequelize; sequelize: Sequelize;
initDatabase(cb); initDatabase();
syncDatabaseStructure(cb); syncDatabaseStructure();
loadInstances(cb: GBServiceCallback<IGBInstance[]>); loadInstances(): IGBInstance[];
loadInstance(botId: string, cb: GBServiceCallback<IGBInstance>); loadInstance(botId: string): IGBInstance;
} }

View file

@ -39,6 +39,5 @@ export class IGBDialog {
bot: BotAdapter; bot: BotAdapter;
service: GBService; service: GBService;
constructor(bot: BotAdapter) { constructor(bot: BotAdapter) {
} }
} }

View file

@ -36,10 +36,9 @@ export interface IGBInstance {
botId:string; botId:string;
whoAmIVideo: string; whoAmIVideo: string;
applicationPrincipal: string; applicationPrincipal: string;
tenant: string; authenticatorTenant: string;
signUpSignInPolicy: "b2c_1_susi", authenticatorsignUpSignInPolicy: string;
clientID: '47cbaa05-dbb4-46f8-8608-da386c5131f1'} authenticatorClientID: string;
instanceId: number; instanceId: number;
title: string; title: string;
description: string; description: string;

View file

@ -32,29 +32,40 @@
import { IGBCoreService } from './IGBCoreService'; import { IGBCoreService } from './IGBCoreService';
import { Sequelize, Model } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { GBMinInstance } from '.'; import { GBMinInstance } from '.';
"use strict"; // TODO: Include "use strict"; in all files.
export interface IGBPackage{ export interface IGBPackage{
/** Each app has its own set of sys packages. */ /**
* Each app has its own set of sys packages.
*/
sysPackages: IGBPackage[]; sysPackages: IGBPackage[];
/** Called when a package is being loaded, once per server or at demand. */ /**
* Called when a package is being loaded, once per server or at demand.
*/
loadPackage(core: IGBCoreService, sequelize: Sequelize): void; loadPackage(core: IGBCoreService, sequelize: Sequelize): void;
/** Called when a package needs to be unloaded. */ /**
* Called when a package needs to be unloaded.
*/
unloadPackage(core: IGBCoreService): void; unloadPackage(core: IGBCoreService): void;
/** Called when a new bot instance is loaded. */ /**
* Called when a new bot instance is loaded.
*/
loadBot(min: GBMinInstance): void; loadBot(min: GBMinInstance): void;
/** Called whenever a bot instance needs to be shutdown. */ /**
* Called whenever a bot instance needs to be shutdown.
*/
unloadBot(min: GBMinInstance): void; unloadBot(min: GBMinInstance): void;
/** Called in each new dc. */ /**
* Called in each new dc.
*/
onNewSession(min: GBMinInstance, dc: any): void; onNewSession(min: GBMinInstance, dc: any): void;
} }

View file

@ -33,15 +33,6 @@
'use strict'; 'use strict';
export { Sequelize } from 'sequelize-typescript'; export { Sequelize } from 'sequelize-typescript';
import { GBMinInstance } from './GBMinInstance';
import { GBService } from './GBService';
import { GBError } from './GBError';
import { IGBPackage } from './IGBPackage';
import { IGBDialog } from './IGBDialog';
import { IGBCoreService } from './IGBCoreService';
import { IGBConversationalService } from './IGBConversationalService';
export { IGBConversationalService } from './IGBConversationalService'; export { IGBConversationalService } from './IGBConversationalService';
export { IGBCoreService } from './IGBCoreService'; export { IGBCoreService } from './IGBCoreService';
export { IGBDialog } from './IGBDialog'; export { IGBDialog } from './IGBDialog';
@ -49,5 +40,4 @@ 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 { GBServiceCallback } from './GBService';
export { GBMinInstance } from './GBMinInstance'; export { GBMinInstance } from './GBMinInstance';

View file

@ -1,45 +0,0 @@
/******************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ ` _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) ( ) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| 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';
const assert = require('assert');
describe('Array', () => {
describe('#indexOf()', () => {
it('should return -1 when the value is not present', () => {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});