Merge remote-tracking branch 'remotes/origin/master' into MigrationToBotFmwV4
2
.github/ISSUE_TEMPLATE/requirement
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
**Description**
|
||||||
|
A clear and concise description of what the requirement is.
|
34
README.md
|
@ -1,5 +1,6 @@
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
Welcome to General Bot Community Edition
|
Welcome to General Bot Community Edition
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -11,6 +12,17 @@ Everyone can create bots by just copying and pasting some files and using their
|
||||||
favorite tools like Excel (or any text editor) or Photoshop (or any image
|
favorite tools like Excel (or any text editor) or Photoshop (or any image
|
||||||
editor).
|
editor).
|
||||||
|
|
||||||
|
Package Quick Reference
|
||||||
|
------------
|
||||||
|
|Whatsapp|Web|Core|KB|
|
||||||
|
|----|-----|----|----|
|
||||||
|
|[whatsapp.gblib](https://github.com/pragmatismo-io/BotServer/tree/master/deploy/whatsapp.gblib)|[default.gbui](https://github.com/pragmatismo-io/BotServer/tree/master/deploy/default.gbui)|[core.gbapp](https://github.com/pragmatismo-io/BotServer/tree/master/deploy/core.gbapp)|[kb.gbapp](https://github.com/pragmatismo-io/BotServer/tree/master/deploy/kb.gbapp)|
|
||||||
|
|
||||||
|
Package Architecture
|
||||||
|
--------------------
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### What is Bot Server?
|
### What is Bot Server?
|
||||||
|
|
||||||
Bot Server accelerates the process of developing a bot. It provisions all code
|
Bot Server accelerates the process of developing a bot. It provisions all code
|
||||||
|
@ -21,11 +33,23 @@ a zip file, editing and uploading it back to the server (deploying process) with
|
||||||
no code. The Bot Server also provides a framework to develop bot packages in a more
|
no code. The Bot Server also provides a framework to develop bot packages in a more
|
||||||
advanced fashion writing custom code in editors like Visual Studio Code, Atom or Brackets.
|
advanced fashion writing custom code in editors like Visual Studio Code, Atom or Brackets.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### The same build process for everyone
|
### The same build process for everyone
|
||||||
|
|
||||||
GeneralBots aims to delivery bots in azure in a very easy and fast fashion. Use
|
GeneralBots aims to delivery bots in azure in a very easy and fast fashion. Use
|
||||||
Office tools like Word or Excel to edit your Bot - using code (JavaScript or TypeScript) just to empower custom requirements.
|
Office tools like Word or Excel to edit your Bot - using code (JavaScript or TypeScript) just to empower custom requirements.
|
||||||
|
|
||||||
|
|
||||||
|
#### Use Excel for Quick edits
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### Use Visual Studio for a complete .gbai package building system
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
How To
|
How To
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -72,6 +96,11 @@ Note:
|
||||||
|
|
||||||
* Whenever you are ready to turn your open-source bot ideas in form of .gbapp (source-code) and artifacts like .gbkb, .gbtheme, .gbot or the .gbai full package read [CONTRIBUTING.md](https://github.com/pragmatismo-io/BotServer/blob/master/CONTRIBUTING.md) about performing Pull Requests (PR) and creating other public custom packages repositories of your own personal or organization General Bot Community Edition powered packages.
|
* Whenever you are ready to turn your open-source bot ideas in form of .gbapp (source-code) and artifacts like .gbkb, .gbtheme, .gbot or the .gbai full package read [CONTRIBUTING.md](https://github.com/pragmatismo-io/BotServer/blob/master/CONTRIBUTING.md) about performing Pull Requests (PR) and creating other public custom packages repositories of your own personal or organization General Bot Community Edition powered packages.
|
||||||
|
|
||||||
|
### Running unit tests
|
||||||
|
|
||||||
|
1. Enter the BotServer root folder.
|
||||||
|
2. Run tests by `npm test`.
|
||||||
|
|
||||||
### Just copy the source code to your machine
|
### Just copy the source code to your machine
|
||||||
|
|
||||||
1. [Download] the Zip file of (https://codeload.github.com/pragmatismo-io/BotServer/zip/master)
|
1. [Download] the Zip file of (https://codeload.github.com/pragmatismo-io/BotServer/zip/master)
|
||||||
|
@ -89,6 +118,7 @@ the UI application itself (HTML & JS).
|
||||||
Package Types
|
Package Types
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
||||||
### .gbai
|
### .gbai
|
||||||
|
|
||||||
Embraces all packages types (content, logic & conversation) into a pluggable bot
|
Embraces all packages types (content, logic & conversation) into a pluggable bot
|
||||||
|
@ -166,8 +196,8 @@ here is a list of admin commands related to deploying .gb* files.
|
||||||
### Credits & Inspiration
|
### Credits & Inspiration
|
||||||
|
|
||||||
* Rodrigo Rodriguez (me@rodrigorodriguez.com) - Coding, Docs & Architecture.
|
* Rodrigo Rodriguez (me@rodrigorodriguez.com) - Coding, Docs & Architecture.
|
||||||
* David Lerner (david.lerner@hotmail.com) - UI, UX & Theming
|
* David Lerner (david.lerner@hotmail.com) - UI, UX & Theming.
|
||||||
* Eduardo Romeiro (eromeirosp@outlook.com) - Content & UX
|
* Eduardo Romeiro (eromeirosp@outlook.com) - Content & UX.
|
||||||
* Jorge Ramos (jramos@pobox.com) - Coding, Docs & Architecture.
|
* Jorge Ramos (jramos@pobox.com) - Coding, Docs & Architecture.
|
||||||
|
|
||||||
Powered by Microsoft [BOT Framework](https://dev.botframework.com/) and [Azure](http://www.azure.com).
|
Powered by Microsoft [BOT Framework](https://dev.botframework.com/) and [Azure](http://www.azure.com).
|
||||||
|
|
11
VERSION.md
|
@ -1,5 +1,16 @@
|
||||||
# Release History
|
# Release History
|
||||||
|
|
||||||
|
## Version 0.0.31
|
||||||
|
|
||||||
|
- FIX: Updated dependencies versions.
|
||||||
|
|
||||||
|
## Version 0.0.30
|
||||||
|
|
||||||
|
- FIX: Packages updated.
|
||||||
|
- NEW: DATABASE_SYNC_ALTER environment parameter.
|
||||||
|
- NEW: DATABASE_SYNC_FORCE environment parameter.
|
||||||
|
- NEW: Define constraint names in MSSQL.
|
||||||
|
|
||||||
## Version 0.0.29
|
## Version 0.0.29
|
||||||
|
|
||||||
- NEW: Added STT and TTS capabilities to default.gbui.
|
- NEW: Added STT and TTS capabilities to default.gbui.
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
import { AzureSearch } from "pragmatismo-io-framework";
|
import { AzureSearch } from "pragmatismo-io-framework";
|
||||||
const { DialogSet, TextPrompt, NumberPrompt } = require('botbuilder-dialogs');
|
const { DialogSet, TextPrompt, NumberPrompt } = require('botbuilder-dialogs');
|
||||||
const { createTextPrompt, createNumberPrompt } = require('botbuilder-prompts');
|
const { createTextPrompt, createNumberPrompt } = require('botbuilder-prompts');
|
||||||
|
|
|
@ -30,30 +30,31 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
|
const UrlJoin = require('url-join');
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
|
||||||
import { AdminDialog } from './dialogs/AdminDialog';
|
import { AdminDialog } from './dialogs/AdminDialog';
|
||||||
import { GBMinInstance, IGBPackage } from "botlib";
|
import { GBMinInstance, IGBPackage, IGBCoreService } from 'botlib';
|
||||||
|
|
||||||
import { Sequelize } from 'sequelize-typescript';
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { IGBCoreService } from 'botlib';
|
|
||||||
|
|
||||||
export class GBAdminPackage implements IGBPackage {
|
export class GBAdminPackage implements IGBPackage {
|
||||||
|
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
}
|
}
|
||||||
unloadPackage(core: IGBCoreService): void {
|
|
||||||
|
|
||||||
|
unloadPackage(core: IGBCoreService): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
AdminDialog.setup(min.bot, min);
|
AdminDialog.setup(min.bot, min);
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
onNewSession(min: GBMinInstance, dc: any): void {
|
|
||||||
|
|
||||||
|
onNewSession(min: GBMinInstance, dc: any): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,17 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sequelize,
|
|
||||||
DataTypes,
|
DataTypes,
|
||||||
DataTypeUUIDv4,
|
DataTypeUUIDv4,
|
||||||
DataTypeDate,
|
DataTypeDate,
|
||||||
DataTypeDecimal
|
DataTypeDecimal
|
||||||
} from "sequelize";
|
} from "sequelize";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Sequelize,
|
||||||
Table,
|
Table,
|
||||||
Column,
|
Column,
|
||||||
Model,
|
Model,
|
||||||
|
@ -56,13 +56,14 @@ import {
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
AutoIncrement
|
AutoIncrement
|
||||||
} from "sequelize-typescript";
|
} from "sequelize-typescript";
|
||||||
|
|
||||||
import { GuaribasSubject } from "../../kb.gbapp/models";
|
import { GuaribasSubject } from "../../kb.gbapp/models";
|
||||||
import { GuaribasUser } from "../../security.gblib/models";
|
import { GuaribasUser } from "../../security.gblib/models";
|
||||||
import { GuaribasChannel, GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
import { GuaribasChannel, GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
||||||
|
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasConversation extends Model<GuaribasConversation> {
|
export class GuaribasConversation extends Model<GuaribasConversation> {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
|
@ -81,15 +82,13 @@ export class GuaribasConversation extends Model<GuaribasConversation> {
|
||||||
|
|
||||||
@Column rateDate: Date;
|
@Column rateDate: Date;
|
||||||
|
|
||||||
@Column({
|
@Column(DataType.FLOAT)
|
||||||
type: DataType.FLOAT
|
|
||||||
})
|
|
||||||
@Column
|
@Column
|
||||||
rate: number;
|
rate: number;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
creationDate: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@Column text: string;
|
@Column text: string;
|
||||||
|
|
||||||
|
@ -106,6 +105,7 @@ export class GuaribasConversation extends Model<GuaribasConversation> {
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasConversationMessage extends Model<GuaribasConversationMessage> {
|
export class GuaribasConversationMessage extends Model<GuaribasConversationMessage> {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
|
@ -115,16 +115,16 @@ export class GuaribasConversationMessage extends Model<GuaribasConversationMessa
|
||||||
@Column
|
@Column
|
||||||
subjectId: number;
|
subjectId: number;
|
||||||
|
|
||||||
@Column({ type: DataType.TEXT })
|
@Column(DataType.TEXT)
|
||||||
content: string;
|
content: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
creationDate: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedOn: Date;
|
updatedAt: Date;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasConversation)
|
@ForeignKey(() => GuaribasConversation)
|
||||||
@Column
|
@Column
|
||||||
|
|
|
@ -34,13 +34,11 @@
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
|
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
||||||
|
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { ConsoleDirectLine } from "./services/ConsoleDirectLine";
|
import { ConsoleDirectLine } from "./services/ConsoleDirectLine";
|
||||||
|
|
||||||
|
|
||||||
export class GBConsolePackage implements IGBPackage {
|
export class GBConsolePackage implements IGBPackage {
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
channel: ConsoleDirectLine;
|
channel: ConsoleDirectLine;
|
||||||
|
@ -49,7 +47,6 @@ export class GBConsolePackage implements IGBPackage {
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
|
@ -57,9 +54,8 @@ export class GBConsolePackage implements IGBPackage {
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
onNewSession(min: GBMinInstance, dc: any): void {
|
|
||||||
|
|
||||||
|
onNewSession(min: GBMinInstance, dc: any): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,170 +33,190 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sequelize,
|
DataTypes,
|
||||||
DataTypes,
|
DataTypeUUIDv4,
|
||||||
DataTypeUUIDv4,
|
DataTypeDate,
|
||||||
DataTypeDate,
|
DataTypeDecimal
|
||||||
DataTypeDecimal
|
|
||||||
} from "sequelize";
|
} from "sequelize";
|
||||||
import {
|
|
||||||
Table,
|
|
||||||
Column,
|
|
||||||
Model,
|
|
||||||
HasMany,
|
|
||||||
BelongsTo,
|
|
||||||
BelongsToMany,
|
|
||||||
Length,
|
|
||||||
ForeignKey,
|
|
||||||
CreatedAt,
|
|
||||||
UpdatedAt,
|
|
||||||
DataType,
|
|
||||||
IsUUID,
|
|
||||||
PrimaryKey,
|
|
||||||
AutoIncrement
|
|
||||||
} from "sequelize-typescript";
|
|
||||||
import { IGBInstance } from "botlib";
|
|
||||||
|
|
||||||
|
import {
|
||||||
|
Sequelize,
|
||||||
|
Table,
|
||||||
|
Column,
|
||||||
|
Model,
|
||||||
|
HasMany,
|
||||||
|
BelongsTo,
|
||||||
|
BelongsToMany,
|
||||||
|
Length,
|
||||||
|
ForeignKey,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
DataType,
|
||||||
|
IsUUID,
|
||||||
|
PrimaryKey,
|
||||||
|
AutoIncrement
|
||||||
|
} from "sequelize-typescript";
|
||||||
|
|
||||||
|
import { IGBInstance } from "botlib";
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInstance {
|
export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInstance {
|
||||||
|
|
||||||
@Column
|
@PrimaryKey
|
||||||
whoAmIVideo: string;
|
@AutoIncrement
|
||||||
|
@Column
|
||||||
|
instanceId: number;
|
||||||
|
|
||||||
@PrimaryKey
|
@Column
|
||||||
@AutoIncrement
|
whoAmIVideo: string;
|
||||||
@Column
|
|
||||||
instanceId: number;
|
|
||||||
|
|
||||||
@Column botId: string;
|
@Column botId: string;
|
||||||
|
|
||||||
@Column title: string;
|
@Column title: string;
|
||||||
|
|
||||||
@Column description: string;
|
@Column description: string;
|
||||||
|
|
||||||
@Column version: string;
|
@Column version: string;
|
||||||
|
|
||||||
@Column enabledAdmin: boolean;
|
@Column enabledAdmin: boolean;
|
||||||
|
|
||||||
/* Services section on bot.json */
|
/* Services section on bot.json */
|
||||||
|
|
||||||
@Column engineName: string;
|
@Column engineName: string;
|
||||||
|
|
||||||
@Column marketplaceId: string;
|
@Column marketplaceId: string;
|
||||||
|
|
||||||
@Column textAnalyticsKey: string;
|
@Column textAnalyticsKey: string;
|
||||||
|
|
||||||
@Column marketplacePassword: string;
|
@Column marketplacePassword: string;
|
||||||
|
|
||||||
@Column webchatKey: string;
|
@Column webchatKey: string;
|
||||||
|
|
||||||
@Column whatsappBotKey: string;
|
@Column whatsappBotKey: string;
|
||||||
|
|
||||||
@Column whatsappServiceKey: string;
|
@Column whatsappServiceKey: string;
|
||||||
|
|
||||||
@Column whatsappServiceNumber: string;
|
@Column whatsappServiceNumber: string;
|
||||||
|
|
||||||
@Column whatsappServiceUrl: string;
|
@Column whatsappServiceUrl: string;
|
||||||
|
|
||||||
@Column whatsappServiceWebhookUrl: string;
|
@Column whatsappServiceWebhookUrl: string;
|
||||||
|
|
||||||
@Column speechKey: string;
|
@Column speechKey: string;
|
||||||
|
|
||||||
@Column spellcheckerKey: string;
|
@Column spellcheckerKey: string;
|
||||||
|
|
||||||
@Column theme: string;
|
@Column theme: string;
|
||||||
|
|
||||||
@Column ui: string;
|
@Column ui: string;
|
||||||
|
|
||||||
@Column kb: string;
|
@Column kb: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(512)) nlpServerUrl: string;
|
||||||
nlpAppId: string;
|
|
||||||
|
@Column
|
||||||
|
nlpAppId: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
nlpSubscriptionKey: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@Column({ type: DataType.STRING(512) })
|
||||||
|
nlpServerUrl: string;
|
||||||
|
|
||||||
@Column
|
@Column searchHost: string;
|
||||||
nlpSubscriptionKey: string;
|
|
||||||
|
|
||||||
@Column
|
@Column searchKey: string;
|
||||||
@Column({ type: DataType.STRING(512) })
|
|
||||||
nlpServerUrl: string;
|
|
||||||
|
|
||||||
@Column searchHost: string;
|
@Column searchIndex: string;
|
||||||
|
|
||||||
@Column searchKey: string;
|
@Column searchIndexer: string;
|
||||||
|
|
||||||
@Column searchIndex: string;
|
/* Settings section of bot.json */
|
||||||
|
|
||||||
@Column searchIndexer: string;
|
@Column(DataType.FLOAT) nlpVsSearch: number;
|
||||||
|
|
||||||
/* Settings section of bot.json */
|
@Column(DataType.FLOAT) searchScore: number;
|
||||||
|
|
||||||
@Column({
|
@Column(DataType.FLOAT) nlpScore: number;
|
||||||
type: DataType.FLOAT
|
|
||||||
})
|
|
||||||
nlpVsSearch: number;
|
|
||||||
|
|
||||||
@Column({
|
@Column
|
||||||
type: DataType.FLOAT
|
@CreatedAt
|
||||||
})
|
createdAt: Date;
|
||||||
searchScore: number;
|
|
||||||
|
|
||||||
@Column({
|
@Column
|
||||||
type: DataType.FLOAT
|
@UpdatedAt
|
||||||
})
|
updatedAt: Date;
|
||||||
nlpScore: number;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
@CreatedAt
|
|
||||||
creationDate: Date;
|
|
||||||
|
|
||||||
@Column
|
|
||||||
@UpdatedAt
|
|
||||||
updatedOn: Date;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasPackage extends Model<GuaribasPackage> {
|
export class GuaribasPackage extends Model<GuaribasPackage> {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
packageId: number;
|
packageId: number;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
packageName: string;
|
packageName: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
|
|
||||||
|
@BelongsTo(() => GuaribasInstance)
|
||||||
|
instance: GuaribasInstance;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@CreatedAt
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@UpdatedAt
|
||||||
|
updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasChannel extends Model<GuaribasChannel> {
|
export class GuaribasChannel extends Model<GuaribasChannel> {
|
||||||
@PrimaryKey
|
|
||||||
@AutoIncrement
|
|
||||||
@Column
|
|
||||||
channelId: number;
|
|
||||||
|
|
||||||
@Column title: string;
|
@PrimaryKey
|
||||||
|
@AutoIncrement
|
||||||
|
@Column
|
||||||
|
channelId: number;
|
||||||
|
|
||||||
|
@Column title: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@CreatedAt
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@UpdatedAt
|
||||||
|
updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasException extends Model<GuaribasException> {
|
export class GuaribasException extends Model<GuaribasException> {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
exceptionId: number;
|
exceptionId: number;
|
||||||
|
|
||||||
@Column message: string;
|
@Column message: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
|
|
||||||
@Column
|
@BelongsTo(() => GuaribasInstance)
|
||||||
@CreatedAt
|
instance: GuaribasInstance;
|
||||||
creationDate: Date;
|
|
||||||
|
@Column
|
||||||
|
@CreatedAt
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
@UpdatedAt
|
||||||
|
updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class GBConfigService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(key: string): any {
|
static get(key: string): string | undefined {
|
||||||
let value = process.env["container:" + key];
|
let value = process.env["container:" + key];
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
@ -71,9 +71,19 @@ export class GBConfigService {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "DATABASE_SYNC":
|
case "DATABASE_SYNC":
|
||||||
|
case "DATABASE_SYNC_ALTER":
|
||||||
|
case "DATABASE_SYNC_FORCE":
|
||||||
value = "false";
|
value = "false";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "DATABASE_LOGGING":
|
||||||
|
value = "false";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "DATABASE_ENCRYPT":
|
||||||
|
value = "true";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.trace(
|
logger.trace(
|
||||||
`Guaribas General Error: Invalid key on .env file: '${key}'`
|
`Guaribas General Error: Invalid key on .env file: '${key}'`
|
||||||
|
|
|
@ -41,7 +41,7 @@ const UrlJoin = require("url-join");
|
||||||
const Walk = require("fs-walk");
|
const Walk = require("fs-walk");
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
|
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { Promise } from "bluebird";
|
import { Promise } from "bluebird";
|
||||||
import { GBConfigService } from "./GBConfigService";
|
import { GBConfigService } from "./GBConfigService";
|
||||||
import { DataTypeUUIDv1 } from "sequelize";
|
import { DataTypeUUIDv1 } from "sequelize";
|
||||||
|
@ -56,9 +56,13 @@ export class GBCoreService implements IGBCoreService {
|
||||||
|
|
||||||
public sequelize: Sequelize;
|
public sequelize: Sequelize;
|
||||||
|
|
||||||
|
private queryGenerator: any;
|
||||||
|
private createTableQuery: (tableName, attributes, options) => string;
|
||||||
|
private changeColumnQuery: (tableName, attributes) => string;
|
||||||
|
|
||||||
/** Dialect used. Tested: mssql and sqlite. */
|
/** Dialect used. Tested: mssql and sqlite. */
|
||||||
|
|
||||||
dialect: string;
|
private dialect: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dialect = GBConfigService.get("DATABASE_DIALECT");
|
this.dialect = GBConfigService.get("DATABASE_DIALECT");
|
||||||
|
@ -67,11 +71,11 @@ export class GBCoreService implements IGBCoreService {
|
||||||
/** Get config and connect to storage. */
|
/** Get config and connect to storage. */
|
||||||
initDatabase(cb) {
|
initDatabase(cb) {
|
||||||
|
|
||||||
let host = "";
|
let host: string | undefined;
|
||||||
let database = "";
|
let database: string | undefined;
|
||||||
let username = "";
|
let username: string | undefined;
|
||||||
let password = "";
|
let password: string | undefined;
|
||||||
let storage = "";
|
let storage: string | undefined;
|
||||||
|
|
||||||
if (this.dialect === "mssql") {
|
if (this.dialect === "mssql") {
|
||||||
host = GBConfigService.get("DATABASE_HOST");
|
host = GBConfigService.get("DATABASE_HOST");
|
||||||
|
@ -82,14 +86,11 @@ export class GBCoreService implements IGBCoreService {
|
||||||
storage = GBConfigService.get("DATABASE_STORAGE");
|
storage = GBConfigService.get("DATABASE_STORAGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = GBConfigService.get("DATABASE_LOGGING");
|
let logging = (GBConfigService.get("DATABASE_LOGGING") === "true")
|
||||||
let logging: boolean | Function = false;
|
? (str: string) => { logger.trace(str); }
|
||||||
|
: false;
|
||||||
|
|
||||||
if (value && value == "1") {
|
let encrypt = (GBConfigService.get("DATABASE_ENCRYPT") === "true");
|
||||||
logging = (str) => {
|
|
||||||
logger.trace(str);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sequelize = new Sequelize({
|
this.sequelize = new Sequelize({
|
||||||
host: host,
|
host: host,
|
||||||
|
@ -100,9 +101,8 @@ export class GBCoreService implements IGBCoreService {
|
||||||
operatorsAliases: false,
|
operatorsAliases: false,
|
||||||
dialect: this.dialect,
|
dialect: this.dialect,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
|
|
||||||
dialectOptions: {
|
dialectOptions: {
|
||||||
encrypt: true
|
encrypt: encrypt
|
||||||
},
|
},
|
||||||
pool: {
|
pool: {
|
||||||
max: 32,
|
max: 32,
|
||||||
|
@ -110,26 +110,106 @@ export class GBCoreService implements IGBCoreService {
|
||||||
idle: 40000,
|
idle: 40000,
|
||||||
evict: 40000,
|
evict: 40000,
|
||||||
acquire: 40000
|
acquire: 40000
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
cb();
|
|
||||||
|
if (this.dialect === "mssql") {
|
||||||
|
this.queryGenerator = this.sequelize.getQueryInterface().QueryGenerator;
|
||||||
|
this.createTableQuery = this.queryGenerator.createTableQuery;
|
||||||
|
this.queryGenerator.createTableQuery = (tableName, attributes, options) =>
|
||||||
|
this.createTableQueryOverride(tableName, attributes, options);
|
||||||
|
this.changeColumnQuery = this.queryGenerator.changeColumnQuery;
|
||||||
|
this.queryGenerator.changeColumnQuery = (tableName, attributes) =>
|
||||||
|
this.changeColumnQueryOverride(tableName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
setImmediate(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private createTableQueryOverride(tableName, attributes, options): string {
|
||||||
|
let sql: string = this.createTableQuery.apply(this.queryGenerator,
|
||||||
|
[tableName, attributes, options]);
|
||||||
|
// let sql: string = '' +
|
||||||
|
// 'IF OBJECT_ID(\'[UserGroup]\', \'U\') IS NULL\n' +
|
||||||
|
// 'CREATE TABLE [UserGroup] (\n' +
|
||||||
|
// ' [id] INTEGER NOT NULL IDENTITY(1,1),\n' +
|
||||||
|
// ' [userId] INTEGER NULL,\n' +
|
||||||
|
// ' [groupId] INTEGER NULL,\n' +
|
||||||
|
// ' [instanceId] INTEGER NULL,\n' +
|
||||||
|
// ' PRIMARY KEY ([id1], [id2]),\n' +
|
||||||
|
// ' FOREIGN KEY ([userId1], [userId2], [userId3]) REFERENCES [User] ([userId1], [userId2], [userId3]) ON DELETE NO ACTION,\n' +
|
||||||
|
// ' FOREIGN KEY ([groupId1], [groupId2]) REFERENCES [Group] ([groupId1], [groupId1]) ON DELETE NO ACTION,\n' +
|
||||||
|
// ' FOREIGN KEY ([instanceId]) REFERENCES [Instance] ([instanceId]) ON DELETE NO ACTION);';
|
||||||
|
const re1 = /CREATE\s+TABLE\s+\[([^\]]*)\]/;
|
||||||
|
const matches = re1.exec(sql);
|
||||||
|
if (matches) {
|
||||||
|
const table = matches[1];
|
||||||
|
const re2 = /PRIMARY\s+KEY\s+\(\[[^\]]*\](?:,\s*\[[^\]]*\])*\)/;
|
||||||
|
sql = sql.replace(re2, (match: string, ...args: any[]): string => {
|
||||||
|
return 'CONSTRAINT [' + table + '_pk] ' + match;
|
||||||
|
});
|
||||||
|
const re3 = /FOREIGN\s+KEY\s+\((\[[^\]]*\](?:,\s*\[[^\]]*\])*)\)/g;
|
||||||
|
const re4 = /\[([^\]]*)\]/g;
|
||||||
|
sql = sql.replace(re3, (match: string, ...args: any[]): string => {
|
||||||
|
const fkcols = args[0];
|
||||||
|
let fkname = table;
|
||||||
|
let matches = re4.exec(fkcols);
|
||||||
|
while (matches != null) {
|
||||||
|
fkname += '_' + matches[1];
|
||||||
|
matches = re4.exec(fkcols);
|
||||||
|
}
|
||||||
|
return 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
private changeColumnQueryOverride(tableName, attributes): string {
|
||||||
|
let sql: string = this.changeColumnQuery.apply(this.queryGenerator,
|
||||||
|
[tableName, attributes]);
|
||||||
|
// let sql = '' +
|
||||||
|
// 'ALTER TABLE [UserGroup]\n' +
|
||||||
|
// ' ADD CONSTRAINT [invalid1] FOREIGN KEY ([userId1], [userId2], [userId3]) REFERENCES [User] ([userId1], [userId2], [userId3]) ON DELETE NO ACTION,\n' +
|
||||||
|
// ' CONSTRAINT [invalid2] FOREIGN KEY ([groupId1], [groupId2]) REFERENCES [Group] ([groupId1], [groupId2]) ON DELETE NO ACTION, \n' +
|
||||||
|
// ' CONSTRAINT [invalid3] FOREIGN KEY ([instanceId1]) REFERENCES [Instance] ([instanceId1]) ON DELETE NO ACTION;\n';
|
||||||
|
const re1 = /ALTER\s+TABLE\s+\[([^\]]*)\]/;
|
||||||
|
const matches = re1.exec(sql);
|
||||||
|
if (matches) {
|
||||||
|
const table = matches[1];
|
||||||
|
const re2 = /(ADD\s+)?CONSTRAINT\s+\[([^\]]*)\]\s+FOREIGN\s+KEY\s+\((\[[^\]]*\](?:,\s*\[[^\]]*\])*)\)/g;
|
||||||
|
const re3 = /\[([^\]]*)\]/g;
|
||||||
|
sql = sql.replace(re2, (match: string, ...args: any[]): string => {
|
||||||
|
const fkcols = args[2];
|
||||||
|
let fkname = table;
|
||||||
|
let matches = re3.exec(fkcols);
|
||||||
|
while (matches != null) {
|
||||||
|
fkname += '_' + matches[1];
|
||||||
|
matches = re3.exec(fkcols);
|
||||||
|
}
|
||||||
|
return (args[0] ? args[0] : '') + 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncDatabaseStructure(cb) {
|
syncDatabaseStructure(cb) {
|
||||||
if (GBConfigService.get("DATABASE_SYNC") === "true") {
|
if (GBConfigService.get("DATABASE_SYNC") === "true") {
|
||||||
|
const alter = (GBConfigService.get("DATABASE_SYNC_ALTER") === "true");
|
||||||
|
const force = (GBConfigService.get("DATABASE_SYNC_FORCE") === "true");
|
||||||
logger.trace("Syncing database...");
|
logger.trace("Syncing database...");
|
||||||
this.sequelize.sync().then(value => {
|
this.sequelize.sync({
|
||||||
|
alter: alter,
|
||||||
|
force: force
|
||||||
|
}).then(value => {
|
||||||
logger.trace("Database synced.");
|
logger.trace("Database synced.");
|
||||||
cb();
|
cb();
|
||||||
});
|
}, err => logger.error(err));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
logger.trace("Database synchronization is disabled.");
|
logger.trace("Database synchronization is disabled.");
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all items to start several listeners.
|
* Loads all items to start several listeners.
|
||||||
* @param cb Instances loaded or error info.
|
* @param cb Instances loaded or error info.
|
||||||
|
@ -149,8 +229,8 @@ export class GBCoreService implements IGBCoreService {
|
||||||
if (reason.message.indexOf("no such table: GuaribasInstance") != -1) {
|
if (reason.message.indexOf("no such table: GuaribasInstance") != -1) {
|
||||||
cb([], null);
|
cb([], null);
|
||||||
} else {
|
} else {
|
||||||
cb(null, reason);
|
|
||||||
logger.trace(`GuaribasServiceError: ${reason}`);
|
logger.trace(`GuaribasServiceError: ${reason}`);
|
||||||
|
cb(null, reason);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ import { KBService } from './../../kb.gbapp/services/KBService';
|
||||||
import { GBImporter } from "./GBImporter";
|
import { GBImporter } from "./GBImporter";
|
||||||
import { GBCoreService } from "./GBCoreService";
|
import { GBCoreService } from "./GBCoreService";
|
||||||
import { GBServiceCallback, IGBCoreService, IGBInstance } from "botlib";
|
import { GBServiceCallback, IGBCoreService, IGBInstance } from "botlib";
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { Promise } from "bluebird";
|
import { Promise } from "bluebird";
|
||||||
import { GBConfigService } from "./GBConfigService";
|
import { GBConfigService } from "./GBConfigService";
|
||||||
import { DataTypeUUIDv1 } from "sequelize";
|
import { DataTypeUUIDv1 } from "sequelize";
|
||||||
|
|
|
@ -41,7 +41,7 @@ const Walk = require("fs-walk");
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
|
|
||||||
import { KBService } from './../../kb.gbapp/services/KBService';
|
import { KBService } from './../../kb.gbapp/services/KBService';
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { Promise } from "bluebird";
|
import { Promise } from "bluebird";
|
||||||
import Fs = require("fs");
|
import Fs = require("fs");
|
||||||
import Path = require("path");
|
import Path = require("path");
|
||||||
|
@ -96,7 +96,7 @@ export class GBImporter {
|
||||||
packageJson = Object.assign(packageJson, settings, servicesJson);
|
packageJson = Object.assign(packageJson, settings, servicesJson);
|
||||||
|
|
||||||
GuaribasInstance.create(packageJson).then((instance: IGBInstance) => {
|
GuaribasInstance.create(packageJson).then((instance: IGBInstance) => {
|
||||||
|
|
||||||
// PACKAGE: security.json loading
|
// PACKAGE: security.json loading
|
||||||
let service = new SecService();
|
let service = new SecService();
|
||||||
service.importSecurityFile(localPath, instance);
|
service.importSecurityFile(localPath, instance);
|
||||||
|
|
|
@ -33,13 +33,14 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sequelize,
|
|
||||||
DataTypes,
|
DataTypes,
|
||||||
DataTypeUUIDv4,
|
DataTypeUUIDv4,
|
||||||
DataTypeDate,
|
DataTypeDate,
|
||||||
DataTypeDecimal
|
DataTypeDecimal
|
||||||
} from "sequelize";
|
} from "sequelize";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Sequelize,
|
||||||
Table,
|
Table,
|
||||||
Column,
|
Column,
|
||||||
Model,
|
Model,
|
||||||
|
@ -55,6 +56,7 @@ import {
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
AutoIncrement
|
AutoIncrement
|
||||||
} from "sequelize-typescript";
|
} from "sequelize-typescript";
|
||||||
|
|
||||||
import { GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
import { GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
|
|
22
deploy/default.gbui/package-lock.json
generated
|
@ -1430,21 +1430,21 @@
|
||||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||||
},
|
},
|
||||||
"botframework-directlinejs": {
|
"botframework-directlinejs": {
|
||||||
"version": "0.9.15",
|
"version": "0.9.16",
|
||||||
"resolved": "https://registry.npmjs.org/botframework-directlinejs/-/botframework-directlinejs-0.9.15.tgz",
|
"resolved": "https://registry.npmjs.org/botframework-directlinejs/-/botframework-directlinejs-0.9.16.tgz",
|
||||||
"integrity": "sha512-uDD5LMCckFKCl8Qr6TMnHjEcl1bKp/MTvlvzRsthvEoNTlzSLo7j8wHLlNYcisr3vPaMx+XAcBniUQjwBLImjQ==",
|
"integrity": "sha512-HcIgeGUBH8zYy2ydlNTgS5GaOkK2BFcfkfSxgVWnF2nV0eIIE2nOepHfAYVtv70zQSX0dU9CedUNgQW343AA6Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"rxjs": "5.4.3"
|
"rxjs": "5.4.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"botframework-webchat": {
|
"botframework-webchat": {
|
||||||
"version": "0.13.1",
|
"version": "0.14.3-master.2cc3c75",
|
||||||
"resolved": "https://registry.npmjs.org/botframework-webchat/-/botframework-webchat-0.13.1.tgz",
|
"resolved": "https://registry.npmjs.org/botframework-webchat/-/botframework-webchat-0.14.3-master.2cc3c75.tgz",
|
||||||
"integrity": "sha512-hF80h8xxvic8vgH0FnLY+zAgs17mAf4YKG8+Z0EP8MGXE4KhwCnLwntklhc0WUUY7afoOu+14yc4NBksVOSWuA==",
|
"integrity": "sha512-aJmxAd2oPef9Jih1Ws+ebWJi1lHnCkC3OKawaAVCL6+yu7YeTqrCcPws9G2d8uUiqUzLJ9bvfKdCA2kDlpAe/A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"adaptivecards": "1.0.0",
|
"adaptivecards": "1.0.0",
|
||||||
"bluebird": "3.5.1",
|
"bluebird": "3.5.1",
|
||||||
"botframework-directlinejs": "0.9.15",
|
"botframework-directlinejs": "0.9.16",
|
||||||
"core-js": "2.4.1",
|
"core-js": "2.4.1",
|
||||||
"jspeech": "0.1.1",
|
"jspeech": "0.1.1",
|
||||||
"markdown-it": "8.3.1",
|
"markdown-it": "8.3.1",
|
||||||
|
@ -1455,7 +1455,7 @@
|
||||||
"redux": "3.7.2",
|
"redux": "3.7.2",
|
||||||
"redux-observable": "0.13.0",
|
"redux-observable": "0.13.0",
|
||||||
"rxjs": "5.4.3",
|
"rxjs": "5.4.3",
|
||||||
"simple-update-in": "1.2.0",
|
"simple-update-in": "1.3.0",
|
||||||
"tslib": "1.7.1"
|
"tslib": "1.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -9876,9 +9876,9 @@
|
||||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
||||||
},
|
},
|
||||||
"simple-update-in": {
|
"simple-update-in": {
|
||||||
"version": "1.2.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.0.tgz",
|
||||||
"integrity": "sha512-a6s2H/Px+TXHlJG6FvBpVQU4qnz2BFjMzPfuzdqnGabKUntbIeRknTasCwlWKrXhD1QBSPZ9XoiGF8EpRLjpiQ=="
|
"integrity": "sha512-XQdzyPAjHeqcBDJfUBKgfnurtE9Z/PC7Jh73DAiNlS4vMkdVTrtNpg5GJEGSDOtJ5LPQdZ/BWTx5GNzsP89mlA=="
|
||||||
},
|
},
|
||||||
"slash": {
|
"slash": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
|
|
@ -33,13 +33,14 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sequelize,
|
|
||||||
DataTypes,
|
DataTypes,
|
||||||
DataTypeUUIDv4,
|
DataTypeUUIDv4,
|
||||||
DataTypeDate,
|
DataTypeDate,
|
||||||
DataTypeDecimal
|
DataTypeDecimal
|
||||||
} from "sequelize";
|
} from "sequelize";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Sequelize,
|
||||||
Table,
|
Table,
|
||||||
Column,
|
Column,
|
||||||
Model,
|
Model,
|
||||||
|
@ -59,7 +60,6 @@ import {
|
||||||
import { GuaribasUser } from "../../security.gblib/models";
|
import { GuaribasUser } from "../../security.gblib/models";
|
||||||
import { GuaribasInstance, GuaribasPackage } from "../../core.gbapp/models/GBModel";
|
import { GuaribasInstance, GuaribasPackage } from "../../core.gbapp/models/GBModel";
|
||||||
|
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasSubject extends Model<GuaribasSubject> {
|
export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
|
@ -84,7 +84,7 @@ export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
@BelongsTo(() => GuaribasSubject, "parentSubjectId")
|
@BelongsTo(() => GuaribasSubject, "parentSubjectId")
|
||||||
parentSubject: GuaribasSubject;
|
parentSubject: GuaribasSubject;
|
||||||
|
|
||||||
@HasMany(() => GuaribasSubject, {foreignKey: "parentSubjectId"})
|
@HasMany(() => GuaribasSubject, { foreignKey: "parentSubjectId" })
|
||||||
childrenSubjects: GuaribasSubject[];
|
childrenSubjects: GuaribasSubject[];
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
|
@ -107,10 +107,8 @@ export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
package: GuaribasPackage;
|
package: GuaribasPackage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
|
@ -118,42 +116,42 @@ export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
@Column
|
@Column
|
||||||
questionId: number;
|
questionId: number;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(64) })
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject1: string;
|
subject1: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(64) })
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject2: string;
|
subject2: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(64) })
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject3: string;
|
subject3: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(64) })
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject4: string;
|
subject4: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(1024) })
|
@Column(DataType.STRING(1024))
|
||||||
@Column
|
@Column
|
||||||
keywords: string;
|
keywords: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(512) })
|
@Column(DataType.STRING(512))
|
||||||
from: string;
|
from: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(512) })
|
@Column(DataType.STRING(512))
|
||||||
to: string;
|
to: string;
|
||||||
|
|
||||||
@Column({ type: DataType.TEXT })
|
@Column(DataType.TEXT)
|
||||||
content: string;
|
content: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
creationDate: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedOn: Date;
|
updatedAt: Date;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasAnswer)
|
@ForeignKey(() => GuaribasAnswer)
|
||||||
@Column
|
@Column
|
||||||
|
@ -189,16 +187,16 @@ export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
||||||
@Column
|
@Column
|
||||||
format: string;
|
format: string;
|
||||||
|
|
||||||
@Column({ type: DataType.TEXT })
|
@Column(DataType.TEXT)
|
||||||
content: string;
|
content: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
creationDate: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedOn: Date;
|
updatedAt: Date;
|
||||||
|
|
||||||
@HasMany(() => GuaribasQuestion)
|
@HasMany(() => GuaribasQuestion)
|
||||||
questions: GuaribasQuestion[];
|
questions: GuaribasQuestion[];
|
||||||
|
|
|
@ -30,17 +30,17 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sequelize,
|
|
||||||
DataTypes,
|
DataTypes,
|
||||||
DataTypeUUIDv4,
|
DataTypeUUIDv4,
|
||||||
DataTypeDate,
|
DataTypeDate,
|
||||||
DataTypeDecimal
|
DataTypeDecimal
|
||||||
} from "sequelize";
|
} from "sequelize";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
Sequelize,
|
||||||
Table,
|
Table,
|
||||||
Column,
|
Column,
|
||||||
Model,
|
Model,
|
||||||
|
@ -56,8 +56,8 @@ import {
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
AutoIncrement
|
AutoIncrement
|
||||||
} from "sequelize-typescript";
|
} from "sequelize-typescript";
|
||||||
import { GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
|
||||||
|
|
||||||
|
import { GuaribasInstance } from "../../core.gbapp/models/GBModel";
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasUser extends Model<GuaribasUser> {
|
export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
|
@ -75,18 +75,15 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
|
|
||||||
@Column email: string;
|
@Column email: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(512) })
|
@Column(DataType.STRING(512))
|
||||||
@Column
|
|
||||||
internalAddress: string;
|
internalAddress: string;
|
||||||
|
|
||||||
@ForeignKey(() =>
|
@ForeignKey(() => GuaribasInstance)
|
||||||
GuaribasInstance)
|
|
||||||
@Column
|
@Column
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
instance: GuaribasInstance;
|
instance: GuaribasInstance;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
|
@ -100,12 +97,11 @@ export class GuaribasGroup extends Model<GuaribasGroup> {
|
||||||
@Column
|
@Column
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number;
|
instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance )
|
@BelongsTo(() => GuaribasInstance)
|
||||||
instance: GuaribasInstance;
|
instance: GuaribasInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,8 +204,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
// Ignore own messages.
|
// Ignore own messages.
|
||||||
// TODO: this.botId instead of "general-bot-9672a8d3"
|
// TODO: this.botId instead of "general-bot-9672a8d3"
|
||||||
activities = activities.filter((m) => { return m.from.id === "general-bot-9672a8d3" && m.type === "message" });
|
activities = activities.filter((m) => { return (m.from.id === "GeneralBot-Netshoes") && m.type === "message" });
|
||||||
|
|
||||||
if (activities.length) {
|
if (activities.length) {
|
||||||
|
|
||||||
// Print other messages.
|
// Print other messages.
|
||||||
|
|
BIN
docs/images/general-bots-block-architecture.png
Normal file
After Width: | Height: | Size: 1 MiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 78 KiB |
BIN
docs/images/general-bots-stack.png
Normal file
After Width: | Height: | Size: 1,013 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 480 B |
Before Width: | Height: | Size: 855 B After Width: | Height: | Size: 855 B |