- FIX: Packages updated.
- NEW: DATABASE_SYNC_ALTER environment parameter. - NEW: DATABASE_SYNC_FORCE environment parameter. - NEW: Define constraint names in MSSQL.
This commit is contained in:
parent
0955599855
commit
e4e331730d
24 changed files with 368 additions and 266 deletions
|
@ -1,5 +1,12 @@
|
||||||
# Release History
|
# Release History
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
|
|
||||||
"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";
|
||||||
import { Prompts, Session, UniversalBot } from 'botbuilder';
|
import { Prompts, Session, UniversalBot } from 'botbuilder';
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
|
|
|
@ -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 { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
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, session: Session): void {
|
|
||||||
|
|
||||||
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,29 +34,25 @@
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
||||||
import { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
|
||||||
export class GBAnalyticsPackage implements IGBPackage {
|
export class GBAnalyticsPackage 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 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
onNewSession(min: GBMinInstance, session: Session): 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 { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
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, session: Session): void {
|
|
||||||
|
|
||||||
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ import { GBMinInstance, IGBPackage } from "botlib";
|
||||||
import { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
import { WelcomeDialog } from "./dialogs/WelcomeDialog";
|
import { WelcomeDialog } from "./dialogs/WelcomeDialog";
|
||||||
import { WhoAmIDialog } from "./dialogs/WhoAmIDialog";
|
import { WhoAmIDialog } from "./dialogs/WhoAmIDialog";
|
||||||
import { IGBCoreService} from "botlib";
|
import { IGBCoreService } from "botlib";
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { GuaribasInstance, GuaribasException, GuaribasPackage, GuaribasChannel } from "./models/GBModel";
|
import { GuaribasInstance, GuaribasException, GuaribasPackage, GuaribasChannel } from "./models/GBModel";
|
||||||
|
|
||||||
export class GBCorePackage implements IGBPackage {
|
export class GBCorePackage implements IGBPackage {
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
core.sequelize.addModels([
|
core.sequelize.addModels([
|
||||||
GuaribasInstance,
|
GuaribasInstance,
|
||||||
|
@ -55,7 +55,6 @@ export class GBCorePackage implements IGBPackage {
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
|
@ -64,9 +63,8 @@ export class GBCorePackage implements IGBPackage {
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,164 +33,180 @@
|
||||||
"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;
|
||||||
@Column({ type: DataType.STRING(512) })
|
|
||||||
nlpServerUrl: string;
|
|
||||||
|
|
||||||
@Column searchHost: string;
|
@Column searchHost: string;
|
||||||
|
|
||||||
@Column searchKey: string;
|
@Column searchKey: string;
|
||||||
|
|
||||||
@Column searchIndex: string;
|
@Column searchIndex: string;
|
||||||
|
|
||||||
@Column searchIndexer: string;
|
@Column searchIndexer: string;
|
||||||
|
|
||||||
/* Settings section of bot.json */
|
/* Settings section of bot.json */
|
||||||
|
|
||||||
@Column({
|
@Column(DataType.FLOAT) nlpVsSearch: number;
|
||||||
type: DataType.FLOAT
|
|
||||||
})
|
|
||||||
nlpVsSearch: number;
|
|
||||||
|
|
||||||
@Column({
|
@Column(DataType.FLOAT) searchScore: number;
|
||||||
type: DataType.FLOAT
|
|
||||||
})
|
|
||||||
searchScore: number;
|
|
||||||
|
|
||||||
@Column({
|
@Column(DataType.FLOAT) nlpScore: number;
|
||||||
type: DataType.FLOAT
|
|
||||||
})
|
|
||||||
nlpScore: number;
|
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
creationDate: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedOn: Date;
|
updatedAt: 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);
|
||||||
|
|
|
@ -104,6 +104,13 @@ export class GBMinService {
|
||||||
|
|
||||||
_this_.core.loadInstances((instances: IGBInstance[], err) => {
|
_this_.core.loadInstances((instances: IGBInstance[], err) => {
|
||||||
|
|
||||||
|
// We are running empty !
|
||||||
|
|
||||||
|
if (!instances) {
|
||||||
|
logger.error('The bot server is running empty.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Gets the authorization key for each instance from Bot Service.
|
// Gets the authorization key for each instance from Bot Service.
|
||||||
|
|
||||||
instances.forEach(instance => {
|
instances.forEach(instance => {
|
||||||
|
@ -350,20 +357,16 @@ export class GBMinService {
|
||||||
dirs.forEach(element => {
|
dirs.forEach(element => {
|
||||||
if (element.startsWith('.')) {
|
if (element.startsWith('.')) {
|
||||||
logger.trace(`Ignoring ${element}...`);
|
logger.trace(`Ignoring ${element}...`);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (element.endsWith('.gbot')) {
|
if (element.endsWith('.gbot')) {
|
||||||
botPackages.push(element);
|
botPackages.push(element);
|
||||||
}
|
} else if (element.endsWith('.gbapp')) {
|
||||||
else if (element.endsWith('.gbapp')) {
|
|
||||||
gbappPackages.push(element);
|
gbappPackages.push(element);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
generalPackages.push(element);
|
generalPackages.push(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace(`Starting looking for generalPackages...`);
|
logger.trace(`Starting looking for generalPackages...`);
|
||||||
|
@ -372,7 +375,6 @@ export class GBMinService {
|
||||||
doIt(e);
|
doIt(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/** Deploys all .gbapp files first. */
|
/** Deploys all .gbapp files first. */
|
||||||
|
|
||||||
let appPackagesProcessed = 0;
|
let appPackagesProcessed = 0;
|
||||||
|
@ -382,11 +384,14 @@ export class GBMinService {
|
||||||
// Skips .gbapp inside deploy folder.
|
// Skips .gbapp inside deploy folder.
|
||||||
if (!e.startsWith('deploy')) {
|
if (!e.startsWith('deploy')) {
|
||||||
import(e).then(m => {
|
import(e).then(m => {
|
||||||
let p = new m.Package();
|
let p = new m.Package() as IGBPackage;
|
||||||
p.loadPackage(core, core.sequelize);
|
p.loadPackage(core, core.sequelize);
|
||||||
appPackages.push(p);
|
appPackages.push(p);
|
||||||
logger.trace(`App (.gbapp) deployed: ${e}.`);
|
logger.trace(`App (.gbapp) deployed: ${e}.`);
|
||||||
appPackagesProcessed++;
|
appPackagesProcessed++;
|
||||||
|
}, err => {
|
||||||
|
logger.trace(`Error deploying App (.gbapp): ${e}: ${err}`);
|
||||||
|
appPackagesProcessed++;
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
logger.trace(`Error deploying App (.gbapp): ${e}: ${err}`);
|
logger.trace(`Error deploying App (.gbapp): ${e}: ${err}`);
|
||||||
appPackagesProcessed++;
|
appPackagesProcessed++;
|
||||||
|
@ -396,7 +401,6 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
WaitUntil()
|
WaitUntil()
|
||||||
.interval(1000)
|
.interval(1000)
|
||||||
.times(10)
|
.times(10)
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
import { GuaribasQuestionAlternate } from './models/index';
|
import { GuaribasQuestionAlternate } from './models/index';
|
||||||
import { QualityDialog } from './dialogs/QualityDialog';
|
import { QualityDialog } from './dialogs/QualityDialog';
|
||||||
import { FeedbackDialog } from './dialogs/FeedbackDialog';
|
import { FeedbackDialog } from './dialogs/FeedbackDialog';
|
||||||
|
@ -42,22 +43,24 @@ import { Sequelize } from 'sequelize-typescript';
|
||||||
|
|
||||||
export class GBCustomerSatisfactionPackage implements IGBPackage {
|
export class GBCustomerSatisfactionPackage implements IGBPackage {
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
core.sequelize.addModels([
|
core.sequelize.addModels([
|
||||||
GuaribasQuestionAlternate
|
GuaribasQuestionAlternate
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
FeedbackDialog.setup(min.bot, min);
|
FeedbackDialog.setup(min.bot, min);
|
||||||
QualityDialog.setup(min.bot, min);
|
QualityDialog.setup(min.bot, min);
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -44,31 +44,28 @@ import { Sequelize } from 'sequelize-typescript';
|
||||||
import { IGBCoreService } from 'botlib';
|
import { IGBCoreService } from 'botlib';
|
||||||
|
|
||||||
export class GBKBPackage implements IGBPackage {
|
export class GBKBPackage implements IGBPackage {
|
||||||
|
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
core.sequelize.addModels([
|
core.sequelize.addModels([
|
||||||
GuaribasAnswer,
|
GuaribasAnswer,
|
||||||
GuaribasQuestion,
|
GuaribasQuestion,
|
||||||
GuaribasSubject
|
GuaribasSubject
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
unloadPackage(core: IGBCoreService): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
loadBot(min: GBMinInstance): void {
|
|
||||||
|
|
||||||
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
loadBot(min: GBMinInstance): void {
|
||||||
AskDialog.setup(min.bot, min);
|
AskDialog.setup(min.bot, min);
|
||||||
FaqDialog.setup(min.bot, min);
|
FaqDialog.setup(min.bot, min);
|
||||||
MenuDialog.setup(min.bot, min);
|
MenuDialog.setup(min.bot, min);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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[];
|
||||||
|
|
|
@ -44,7 +44,7 @@ const marked = require("marked");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
||||||
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject } from "../models";
|
import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject } from "../models";
|
||||||
import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib";
|
import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib";
|
||||||
|
@ -129,7 +129,7 @@ export class KBService {
|
||||||
let text = KBService.getSubjectItemsSeparatedBySpaces(
|
let text = KBService.getSubjectItemsSeparatedBySpaces(
|
||||||
subjects
|
subjects
|
||||||
);
|
);
|
||||||
if (text){
|
if (text) {
|
||||||
what = `${what} ${text}`;
|
what = `${what} ${text}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
|
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
||||||
import { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { GuaribasUser, GuaribasGroup, GuaribasUserGroup } from "./models";
|
import { GuaribasUser, GuaribasGroup, GuaribasUserGroup } from "./models";
|
||||||
|
|
||||||
export class GBSecurityPackage implements IGBPackage {
|
export class GBSecurityPackage implements IGBPackage {
|
||||||
sysPackages: IGBPackage[] = null;
|
sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
core.sequelize.addModels([
|
core.sequelize.addModels([
|
||||||
GuaribasGroup,
|
GuaribasGroup,
|
||||||
|
@ -49,19 +49,16 @@ export class GBSecurityPackage implements IGBPackage {
|
||||||
GuaribasUserGroup
|
GuaribasUserGroup
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
loadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
onNewSession(min: GBMinInstance, session: Session): 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,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,39 +34,40 @@
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
||||||
|
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib";
|
||||||
import { Session } from 'botbuilder';
|
import { Session } from 'botbuilder';
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { WhatsappDirectLine } from "./services/WhatsappDirectLine";
|
import { WhatsappDirectLine } from "./services/WhatsappDirectLine";
|
||||||
|
|
||||||
|
|
||||||
export class GBWhatsappPackage implements IGBPackage {
|
export class GBWhatsappPackage implements IGBPackage {
|
||||||
|
sysPackages: IGBPackage[] = null;
|
||||||
|
channel: WhatsappDirectLine;
|
||||||
|
|
||||||
sysPackages: IGBPackage[] = null;
|
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
channel: WhatsappDirectLine;
|
}
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
unloadPackage(core: IGBCoreService): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
loadBot(min: GBMinInstance): void {
|
||||||
|
|
||||||
|
// Only loads engine if it is defined on services.json.
|
||||||
|
|
||||||
|
if (min.instance.whatsappBotKey != "") {
|
||||||
|
this.channel = new WhatsappDirectLine(
|
||||||
|
min.botId,
|
||||||
|
min.instance.whatsappBotKey,
|
||||||
|
min.instance.whatsappServiceKey,
|
||||||
|
min.instance.whatsappServiceNumber,
|
||||||
|
min.instance.whatsappServiceUrl,
|
||||||
|
min.instance.whatsappServiceWebhookUrl
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
unloadBot(min: GBMinInstance): void {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
onNewSession(min: GBMinInstance, session: Session): void {
|
||||||
|
}
|
||||||
loadBot(min: GBMinInstance): void {
|
|
||||||
|
|
||||||
// Only loads engine if it is defined on services.json.
|
|
||||||
|
|
||||||
if (min.instance.whatsappBotKey != "") {
|
|
||||||
this.channel = new WhatsappDirectLine(min.botId, min.instance.whatsappBotKey, min.instance.whatsappServiceKey,
|
|
||||||
min.instance.whatsappServiceNumber, min.instance.whatsappServiceUrl, min.instance.whatsappServiceWebhookUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
onNewSession(min: GBMinInstance, session: Session): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "botserver",
|
"name": "botserver",
|
||||||
"version": "0.0.28",
|
"version": "0.0.30",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -597,9 +597,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"botlib": {
|
"botlib": {
|
||||||
"version": "0.0.25",
|
"version": "0.0.31",
|
||||||
"resolved": "https://registry.npmjs.org/botlib/-/botlib-0.0.25.tgz",
|
"resolved": "https://registry.npmjs.org/botlib/-/botlib-0.0.31.tgz",
|
||||||
"integrity": "sha512-GRR4Hk+seayNzEoceoUYxE6MyAo4YjSH/54Cq+P2v0X2toT7jkdggL5ii2bTzJyHqbaiGYwyh0n8ZDInLk8+dg==",
|
"integrity": "sha512-LgWZsgPnEj5kZx5Hp4yM4ntKKUGrx1ONLyhfHsl/gXX2Pz9AMTtskkMmy5llbV2wdipuD85lorDCNez+nZxFlw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "2.6.1",
|
"async": "2.6.1",
|
||||||
"botbuilder": "3.15.0",
|
"botbuilder": "3.15.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "botserver",
|
"name": "botserver",
|
||||||
"version": "0.0.29",
|
"version": "0.0.30",
|
||||||
"description": "General Bot Community Edition open-core server.",
|
"description": "General Bot Community Edition open-core server.",
|
||||||
"main": "./src/app.ts",
|
"main": "./src/app.ts",
|
||||||
"homepage": "http://www.generalbot.com",
|
"homepage": "http://www.generalbot.com",
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"async": "^2.6.1",
|
"async": "^2.6.1",
|
||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.18.3",
|
||||||
"botbuilder": "^3.15.0",
|
"botbuilder": "^3.15.0",
|
||||||
"botlib": "^0.0.28",
|
"botlib": "^0.0.31",
|
||||||
"chokidar": "^2.0.3",
|
"chokidar": "^2.0.3",
|
||||||
"csv-parse": "^2.4.0",
|
"csv-parse": "^2.4.0",
|
||||||
"dotenv-extended": "^2.0.2",
|
"dotenv-extended": "^2.0.2",
|
||||||
|
|
|
@ -37,8 +37,9 @@ const UrlJoin = require("url-join");
|
||||||
const logger = require("./logger");
|
const logger = require("./logger");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const bodyParser = require("body-parser");
|
const bodyParser = require("body-parser");
|
||||||
|
|
||||||
import { UniversalBot } from "botbuilder";
|
import { UniversalBot } from "botbuilder";
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { GBConfigService } from "../deploy/core.gbapp/services/GBConfigService";
|
import { GBConfigService } from "../deploy/core.gbapp/services/GBConfigService";
|
||||||
import { GBConversationalService } from "../deploy/core.gbapp/services/GBConversationalService";
|
import { GBConversationalService } from "../deploy/core.gbapp/services/GBConversationalService";
|
||||||
import { GBMinService } from "../deploy/core.gbapp/services/GBMinService";
|
import { GBMinService } from "../deploy/core.gbapp/services/GBMinService";
|
||||||
|
@ -56,7 +57,6 @@ import { IGBPackage } from 'botlib';
|
||||||
|
|
||||||
let appPackages = new Array<IGBPackage>();
|
let appPackages = new Array<IGBPackage>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General Bots open-core entry point.
|
* General Bots open-core entry point.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue