new(all): Sequelize updated to v6.
This commit is contained in:
parent
0335b715cd
commit
30f263e786
34 changed files with 2355 additions and 1038 deletions
|
@ -248,8 +248,8 @@
|
||||||
* **all:** Packages updated and new DirectLine behaviour fixed. ([517689f](https://github.com/GeneralBots/BotServer/commit/517689fafee83f4461df1d9dfc530e969ac6fc9f))
|
* **all:** Packages updated and new DirectLine behaviour fixed. ([517689f](https://github.com/GeneralBots/BotServer/commit/517689fafee83f4461df1d9dfc530e969ac6fc9f))
|
||||||
* **all:** Removed security breach. ([0202ed0](https://github.com/GeneralBots/BotServer/commit/0202ed0ef54711181baf84525b730eee8fc62a44))
|
* **all:** Removed security breach. ([0202ed0](https://github.com/GeneralBots/BotServer/commit/0202ed0ef54711181baf84525b730eee8fc62a44))
|
||||||
* **all:** Removed security breach. ([dad67d2](https://github.com/GeneralBots/BotServer/commit/dad67d27ba0963aa272837934a2ee6daa9145928))
|
* **all:** Removed security breach. ([dad67d2](https://github.com/GeneralBots/BotServer/commit/dad67d27ba0963aa272837934a2ee6daa9145928))
|
||||||
* **all:** Sequelize base members demand declare keyword on timestamp fields. ([42719e7](https://github.com/GeneralBots/BotServer/commit/42719e7ba0cbb6df50880ee0cf626516424ab59b))
|
* **all:** Sequelize base members demand keyword on timestamp fields. ([42719e7](https://github.com/GeneralBots/BotServer/commit/42719e7ba0cbb6df50880ee0cf626516424ab59b))
|
||||||
* **all:** Sequelize base members demand declare keyword on timestamp fields. ([493889b](https://github.com/GeneralBots/BotServer/commit/493889beb218eed8a1ed4dd9550d6d952714bb56))
|
* **all:** Sequelize base members demand keyword on timestamp fields. ([493889b](https://github.com/GeneralBots/BotServer/commit/493889beb218eed8a1ed4dd9550d6d952714bb56))
|
||||||
* **azuredeployer.gbapp:** New pricing table. ([7f641bd](https://github.com/GeneralBots/BotServer/commit/7f641bd5df3fa5c88f34164193ff1bd6b1d7e956))
|
* **azuredeployer.gbapp:** New pricing table. ([7f641bd](https://github.com/GeneralBots/BotServer/commit/7f641bd5df3fa5c88f34164193ff1bd6b1d7e956))
|
||||||
* **basic.gbapp:** Call to SEND FILE with .md files working OK. ([80b91c4](https://github.com/GeneralBots/BotServer/commit/80b91c437001a890131e509d67604e42c27cea2e))
|
* **basic.gbapp:** Call to SEND FILE with .md files working OK. ([80b91c4](https://github.com/GeneralBots/BotServer/commit/80b91c437001a890131e509d67604e42c27cea2e))
|
||||||
* **basic.gblib:** Autostart bug, more logging. ([3d90bd8](https://github.com/GeneralBots/BotServer/commit/3d90bd872e093d24336df4d83991b67dc90d1d80))
|
* **basic.gblib:** Autostart bug, more logging. ([3d90bd8](https://github.com/GeneralBots/BotServer/commit/3d90bd872e093d24336df4d83991b67dc90d1d80))
|
||||||
|
|
2927
package-lock.json
generated
2927
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -76,7 +76,7 @@
|
||||||
"botbuilder-ai": "4.11.0",
|
"botbuilder-ai": "4.11.0",
|
||||||
"botbuilder-dialogs": "4.11.0",
|
"botbuilder-dialogs": "4.11.0",
|
||||||
"botframework-connector": "4.11.0",
|
"botframework-connector": "4.11.0",
|
||||||
"botlib": "1.9.4",
|
"botlib": "1.10.1",
|
||||||
"cli-spinner": "0.2.10",
|
"cli-spinner": "0.2.10",
|
||||||
"core-js": "3.14.0",
|
"core-js": "3.14.0",
|
||||||
"date-diff": "0.2.2",
|
"date-diff": "0.2.2",
|
||||||
|
@ -109,14 +109,15 @@
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"safe-buffer": "5.2.1",
|
"safe-buffer": "5.2.1",
|
||||||
"scanf": "1.1.2",
|
"scanf": "1.1.2",
|
||||||
"sequelize": "5.21.5",
|
"sequelize": "6.5.0",
|
||||||
"sequelize-typescript": "1.1.0",
|
"sequelize-cli": "6.2.0",
|
||||||
|
"sequelize-typescript": "2.1.0",
|
||||||
"simple-git": "2.39.1",
|
"simple-git": "2.39.1",
|
||||||
"speakingurl": "14.0.1",
|
"speakingurl": "14.0.1",
|
||||||
"sppull": "2.7.0",
|
"sppull": "2.7.0",
|
||||||
"strict-password-generator": "1.1.2",
|
"strict-password-generator": "1.1.2",
|
||||||
"swagger-client": "2.1.18",
|
"swagger-client": "2.1.18",
|
||||||
"tedious": "9.2.1",
|
"tedious": "14.0.0",
|
||||||
"textract": "2.5.0",
|
"textract": "2.5.0",
|
||||||
"typescript": "3.6.4",
|
"typescript": "3.6.4",
|
||||||
"url-join": "4.0.1",
|
"url-join": "4.0.1",
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { GBMinInstance, IGBDialog, GBLog, IGBPackage } from 'botlib';
|
import { GBMinInstance, IGBDialog, GBLog, IGBPackage } from 'botlib';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
import { GBImporter } from '../../core.gbapp/services/GBImporterService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
|
|
|
@ -51,20 +51,21 @@ import {
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasAdmin extends Model<GuaribasAdmin> {
|
export class GuaribasAdmin extends Model<GuaribasAdmin> {
|
||||||
|
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public key: string;
|
public key: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(4000))
|
@Column(DataType.STRING(4000))
|
||||||
public value: string;
|
public value: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
|
|
||||||
import { AuthenticationContext, TokenResponse } from 'adal-node';
|
import { AuthenticationContext, TokenResponse } from 'adal-node';
|
||||||
import { GBLog, GBMinInstance, IGBAdminService, IGBCoreService, IGBDeployer, IGBInstance } from 'botlib';
|
import { GBLog, GBMinInstance, IGBAdminService, IGBCoreService, IGBDeployer, IGBInstance } from 'botlib';
|
||||||
import urlJoin = require('url-join');
|
import { FindOptions } from 'sequelize/types';
|
||||||
|
const urlJoin = require('url-join');
|
||||||
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
|
||||||
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
|
@ -212,7 +213,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setValue(instanceId: number, key: string, value: string) {
|
public async setValue(instanceId: number, key: string, value: string) {
|
||||||
const options = { where: {} };
|
const options = <FindOptions>{ where: {} };
|
||||||
options.where = { key: key };
|
options.where = { key: key };
|
||||||
let admin = await GuaribasAdmin.findOne(options);
|
let admin = await GuaribasAdmin.findOne(options);
|
||||||
if (admin === null) {
|
if (admin === null) {
|
||||||
|
@ -229,7 +230,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
authenticatorTenant: string,
|
authenticatorTenant: string,
|
||||||
authenticatorAuthorityHostUrl: string
|
authenticatorAuthorityHostUrl: string
|
||||||
): Promise<IGBInstance> {
|
): Promise<IGBInstance> {
|
||||||
const options = { where: {} };
|
const options = <FindOptions>{ where: {} };
|
||||||
options.where = { instanceId: instanceId };
|
options.where = { instanceId: instanceId };
|
||||||
const item = await GuaribasInstance.findOne(options);
|
const item = await GuaribasInstance.findOne(options);
|
||||||
item.authenticatorTenant = authenticatorTenant;
|
item.authenticatorTenant = authenticatorTenant;
|
||||||
|
@ -239,7 +240,7 @@ export class GBAdminService implements IGBAdminService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getValue(instanceId: number, key: string): Promise<string> {
|
public async getValue(instanceId: number, key: string): Promise<string> {
|
||||||
const options = { where: {} };
|
const options = <FindOptions>{ where: {} };
|
||||||
options.where = { key: key, instanceId: instanceId };
|
options.where = { key: key, instanceId: instanceId };
|
||||||
const obj = await GuaribasAdmin.findOne(options);
|
const obj = await GuaribasAdmin.findOne(options);
|
||||||
|
|
||||||
|
|
|
@ -66,42 +66,43 @@ export class GuaribasConversation extends Model<GuaribasConversation> {
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public conversationId: number;
|
public conversationId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasSubject)
|
@ForeignKey(() => GuaribasSubject)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public startSubjectId: number;
|
public startSubjectId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasSubject)
|
@BelongsTo(() => GuaribasSubject)
|
||||||
public startSubject: GuaribasSubject;
|
public startSubject: GuaribasSubject;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasChannel)
|
@ForeignKey(() => GuaribasChannel)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public channelId: string;
|
public channelId: string;
|
||||||
|
|
||||||
@Column public rateDate: Date;
|
@Column(DataType.DATE)
|
||||||
|
public rateDate: Date;
|
||||||
|
|
||||||
@Column(DataType.FLOAT)
|
@Column(DataType.FLOAT)
|
||||||
@Column
|
|
||||||
public rate: number;
|
public rate: number;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
@Column
|
|
||||||
public feedback: string;
|
public feedback: string;
|
||||||
|
|
||||||
@Column
|
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
|
@Column(DataType.DATE)
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column public text: string;
|
@Column(DataType.STRING(255))
|
||||||
|
public text: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasUser)
|
@ForeignKey(() => GuaribasUser)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public startedByUserId: number;
|
public startedByUserId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasUser)
|
@BelongsTo(() => GuaribasUser)
|
||||||
|
@ -116,27 +117,28 @@ export class GuaribasConversationMessage extends Model<GuaribasConversationMessa
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public conversationMessageId: number;
|
public conversationMessageId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasSubject)
|
@ForeignKey(() => GuaribasSubject)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public subjectId: number;
|
public subjectId: number;
|
||||||
|
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
public content: string;
|
public content: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
|
||||||
//tslint:disable-next-line:no-use-before-declare
|
//tslint:disable-next-line:no-use-before-declare
|
||||||
@ForeignKey(() => GuaribasConversation)
|
@ForeignKey(() => GuaribasConversation)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public conversationId: number;
|
public conversationId: number;
|
||||||
|
|
||||||
//tslint:disable-next-line:no-use-before-declare
|
//tslint:disable-next-line:no-use-before-declare
|
||||||
|
@ -144,11 +146,11 @@ export class GuaribasConversationMessage extends Model<GuaribasConversationMessa
|
||||||
public conversation: GuaribasConversation;
|
public conversation: GuaribasConversation;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasUser)
|
@ForeignKey(() => GuaribasUser)
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public userId: number;
|
public userId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasUser)
|
@BelongsTo(() => GuaribasUser)
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AzureText } from 'pragmatismo-io-framework';
|
import { AzureText } from 'pragmatismo-io-framework';
|
||||||
|
import { FindOptions } from 'sequelize/types';
|
||||||
import { GBServer } from '../../../src/app';
|
import { GBServer } from '../../../src/app';
|
||||||
import { GuaribasUser } from '../../security.gbapp/models';
|
import { GuaribasUser } from '../../security.gbapp/models';
|
||||||
import { GuaribasConversation, GuaribasConversationMessage } from '../models';
|
import { GuaribasConversation, GuaribasConversationMessage } from '../models';
|
||||||
|
@ -68,7 +69,7 @@ export class AnalyticsService {
|
||||||
feedback
|
feedback
|
||||||
);
|
);
|
||||||
|
|
||||||
const options = { where: { } };
|
const options = <FindOptions>{ where: { } };
|
||||||
options.where = { conversationId: conversationId, instanceId: instanceId };
|
options.where = { conversationId: conversationId, instanceId: instanceId };
|
||||||
const item = await GuaribasConversation.findOne(options);
|
const item = await GuaribasConversation.findOne(options);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ const git = simplegit();
|
||||||
|
|
||||||
// tslint:disable-next-line:no-submodule-imports
|
// tslint:disable-next-line:no-submodule-imports
|
||||||
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models';
|
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
|
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
|
||||||
const publicIp = require('public-ip');
|
const publicIp = require('public-ip');
|
||||||
const WebSiteResponseTimeout = 900;
|
const WebSiteResponseTimeout = 900;
|
||||||
|
|
|
@ -55,24 +55,25 @@ import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||||
//tslint:disable-next-line:max-classes-per-file
|
//tslint:disable-next-line:max-classes-per-file
|
||||||
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
||||||
|
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public schedule: string;
|
public schedule: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
import { GBDialogStep, GBLog, GBMinInstance } from 'botlib';
|
import { GBDialogStep, GBLog, GBMinInstance } from 'botlib';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { GBServer } from '../../../src/app';
|
import { GBServer } from '../../../src/app';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { SecService } from '../../security.gbapp/services/SecService';
|
import { SecService } from '../../security.gbapp/services/SecService';
|
||||||
|
|
|
@ -38,7 +38,7 @@ import * as fs from 'fs';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { TSCompiler } from './TSCompiler';
|
import { TSCompiler } from './TSCompiler';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { DialogKeywords } from './DialogKeywords';
|
import { DialogKeywords } from './DialogKeywords';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
||||||
|
|
|
@ -37,6 +37,7 @@ import { GBServer } from '../../../src/app';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
import { GBVMService } from '../../basic.gblib/services/GBVMService';
|
||||||
import { GuaribasSchedule } from '../../core.gbapp/models/GBModel';
|
import { GuaribasSchedule } from '../../core.gbapp/models/GBModel';
|
||||||
|
import { FindOptions } from 'sequelize/types';
|
||||||
|
|
||||||
const cron = require('node-cron');
|
const cron = require('node-cron');
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ export class ScheduleServices extends GBService {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (record === null) {
|
if (record === null) {
|
||||||
record = await GuaribasSchedule.create({
|
record = await GuaribasSchedule.create(<GuaribasSchedule>{
|
||||||
instanceId: min.instance.instanceId,
|
instanceId: min.instance.instanceId,
|
||||||
name: name,
|
name: name,
|
||||||
schedule: schedule
|
schedule: schedule
|
||||||
|
@ -109,7 +110,7 @@ export class ScheduleServices extends GBService {
|
||||||
GBLog.info(`Loading instances from storage...`);
|
GBLog.info(`Loading instances from storage...`);
|
||||||
let schedules;
|
let schedules;
|
||||||
try {
|
try {
|
||||||
const options = { where: { instanceId: min.instance.instanceId } };
|
const options = <FindOptions>{ where: { instanceId: min.instance.instanceId } };
|
||||||
schedules = await GuaribasSchedule.findAll(options);
|
schedules = await GuaribasSchedule.findAll(options);
|
||||||
if (process.env.ENDPOINT_UPDATE === 'true') {
|
if (process.env.ENDPOINT_UPDATE === 'true') {
|
||||||
await CollectionUtil.asyncForEach(schedules, async item => {
|
await CollectionUtil.asyncForEach(schedules, async item => {
|
||||||
|
|
|
@ -34,11 +34,10 @@ import { GBDialogStep, GBLog, GBMinInstance } from 'botlib';
|
||||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import * as request from 'request-promise-native';
|
import * as request from 'request-promise-native';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||||
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
|
||||||
import { DialogKeywords } from './DialogKeywords';
|
import { DialogKeywords } from './DialogKeywords';
|
||||||
const request = require('request-promise-native');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const sgMail = require('@sendgrid/mail');
|
const sgMail = require('@sendgrid/mail');
|
||||||
const ComputerVisionClient = require('@azure/cognitiveservices-computervision').ComputerVisionClient;
|
const ComputerVisionClient = require('@azure/cognitiveservices-computervision').ComputerVisionClient;
|
||||||
|
|
|
@ -60,95 +60,94 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public botEndpoint: string;
|
public botEndpoint: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public whoAmIVideo: string;
|
public whoAmIVideo: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public botId: string;
|
public botId: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public title: string;
|
public title: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(16) })
|
@Column({ type: DataType.STRING(16) })
|
||||||
public activationCode: string;
|
public activationCode: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(16) })
|
@Column({ type: DataType.STRING(16) })
|
||||||
public state: string;
|
public state: string;
|
||||||
|
|
||||||
@Column
|
|
||||||
public version: string;
|
public version: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public enabledAdmin: boolean;
|
public enabledAdmin: boolean;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public engineName: string;
|
public engineName: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public marketplaceId: string;
|
public marketplaceId: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public textAnalyticsKey: string;
|
public textAnalyticsKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public textAnalyticsEndpoint: string;
|
public textAnalyticsEndpoint: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(64) })
|
@Column({ type: DataType.STRING(64) })
|
||||||
public translatorKey: string;
|
public translatorKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
@Column({ type: DataType.STRING(128) })
|
@Column({ type: DataType.STRING(128) })
|
||||||
public translatorEndpoint: string;
|
public translatorEndpoint: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public marketplacePassword: string;
|
public marketplacePassword: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public webchatKey: string;
|
public webchatKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public authenticatorTenant: string;
|
public authenticatorTenant: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public authenticatorAuthorityHostUrl: string;
|
public authenticatorAuthorityHostUrl: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public cloudSubscriptionId: string;
|
public cloudSubscriptionId: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public cloudUsername: string;
|
public cloudUsername: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public cloudPassword: string;
|
public cloudPassword: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public cloudLocation: string;
|
public cloudLocation: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public googleBotKey: string;
|
public googleBotKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public googleChatApiKey: string;
|
public googleChatApiKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public googleChatSubscriptionName: string;
|
public googleChatSubscriptionName: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public googleClientEmail: string;
|
public googleClientEmail: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(4000) })
|
@Column({ type: DataType.STRING(4000) })
|
||||||
public googlePrivateKey: string;
|
public googlePrivateKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public googleProjectId: string;
|
public googleProjectId: string;
|
||||||
|
|
||||||
@Column({ type: DataType.STRING(255) })
|
@Column({ type: DataType.STRING(255) })
|
||||||
|
@ -160,95 +159,95 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
@Column({ type: DataType.STRING(512) })
|
@Column({ type: DataType.STRING(512) })
|
||||||
facebookWorkplaceAccessToken: string;
|
facebookWorkplaceAccessToken: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public whatsappBotKey: string;
|
public whatsappBotKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public whatsappServiceKey: string;
|
public whatsappServiceKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public whatsappServiceNumber: string;
|
public whatsappServiceNumber: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public whatsappServiceUrl: string;
|
public whatsappServiceUrl: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public smsKey: string;
|
public smsKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public smsSecret: string;
|
public smsSecret: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public smsServiceNumber: string;
|
public smsServiceNumber: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public speechKey: string;
|
public speechKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public speechEndpoint: string;
|
public speechEndpoint: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public spellcheckerKey: string;
|
public spellcheckerKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public spellcheckerEndpoint: string;
|
public spellcheckerEndpoint: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public theme: string;
|
public theme: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public ui: string;
|
public ui: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public kb: string;
|
public kb: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public nlpAppId: string;
|
public nlpAppId: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public nlpKey: string;
|
public nlpKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
@Column({ type: DataType.STRING(512) })
|
@Column({ type: DataType.STRING(512) })
|
||||||
public nlpEndpoint: string;
|
public nlpEndpoint: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public nlpAuthoringKey: string;
|
public nlpAuthoringKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public deploymentPaths: string;
|
public deploymentPaths: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public searchHost: string;
|
public searchHost: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public searchKey: string;
|
public searchKey: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public searchIndex: string;
|
public searchIndex: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public searchIndexer: string;
|
public searchIndexer: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storageUsername: string;
|
public storageUsername: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storagePassword: string;
|
public storagePassword: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storageName: string;
|
public storageName: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storageServer: string;
|
public storageServer: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storageDialect: string;
|
public storageDialect: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public storagePath: string;
|
public storagePath: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public adminPass: string;
|
public adminPass: string;
|
||||||
|
|
||||||
@Column(DataType.FLOAT)
|
@Column(DataType.FLOAT)
|
||||||
|
@ -260,11 +259,11 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
@Column(DataType.FLOAT)
|
@Column(DataType.FLOAT)
|
||||||
public nlpScore: number;
|
public nlpScore: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
@ -279,24 +278,24 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
export class GuaribasPackage extends Model<GuaribasPackage> {
|
export class GuaribasPackage extends Model<GuaribasPackage> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public packageId: number;
|
public packageId: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public packageName: string;
|
public packageName: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
@ -311,17 +310,17 @@ export class GuaribasPackage extends Model<GuaribasPackage> {
|
||||||
export class GuaribasChannel extends Model<GuaribasChannel> {
|
export class GuaribasChannel extends Model<GuaribasChannel> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public channelId: number;
|
public channelId: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public title: string;
|
public title: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
@ -334,24 +333,24 @@ export class GuaribasChannel extends Model<GuaribasChannel> {
|
||||||
export class GuaribasException extends Model<GuaribasException> {
|
export class GuaribasException extends Model<GuaribasException> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public exceptionId: number;
|
public exceptionId: number;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public message: string;
|
public message: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
@ -360,21 +359,21 @@ export class GuaribasException extends Model<GuaribasException> {
|
||||||
//tslint:disable-next-line:max-classes-per-file
|
//tslint:disable-next-line:max-classes-per-file
|
||||||
export class GuaribasApplications extends Model<GuaribasApplications> {
|
export class GuaribasApplications extends Model<GuaribasApplications> {
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
@ -383,24 +382,24 @@ export class GuaribasApplications extends Model<GuaribasApplications> {
|
||||||
//tslint:disable-next-line:max-classes-per-file
|
//tslint:disable-next-line:max-classes-per-file
|
||||||
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
export class GuaribasSchedule extends Model<GuaribasSchedule> {
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.STRING(255))
|
||||||
public schedule: string;
|
public schedule: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -930,6 +930,10 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const analytics = new AnalyticsService();
|
const analytics = new AnalyticsService();
|
||||||
|
if (!user.conversation)
|
||||||
|
{
|
||||||
|
user.conversation = await analytics.createConversation(user);
|
||||||
|
}
|
||||||
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
|
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
|
||||||
|
|
||||||
if (!isNaN(member.id) && !member.id.startsWith('1000')) {
|
if (!isNaN(member.id) && !member.id.startsWith('1000')) {
|
||||||
|
|
|
@ -171,15 +171,6 @@ export class GBCoreService implements IGBCoreService {
|
||||||
// Specifies custom setup for MSFT...
|
// Specifies custom setup for MSFT...
|
||||||
|
|
||||||
if (this.dialect === 'mssql') {
|
if (this.dialect === 'mssql') {
|
||||||
this.queryGenerator = this.sequelize.getQueryInterface().QueryGenerator;
|
|
||||||
// tslint:disable:no-unsafe-any
|
|
||||||
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);
|
|
||||||
// tslint:enable:no-unsafe-any
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +194,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syncronizes structure between model and tables in storage.
|
* Syncronizes structure between model and tables in storage.
|
||||||
*/
|
*/
|
||||||
public async syncDatabaseStructure() {
|
public async syncDatabaseStructure() {
|
||||||
|
@ -213,7 +204,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
|
|
||||||
return await this.sequelize.sync({
|
return await this.sequelize.sync({
|
||||||
alter: alter,
|
alter: alter,
|
||||||
force: false // Keep it false this due to data loss danger.
|
force: false // Keep it false due to data loss danger.
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const msg = `Database synchronization is disabled.`;
|
const msg = `Database synchronization is disabled.`;
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
const Fs = require('fs');
|
const Fs = require('fs');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
|
@ -551,7 +551,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
* Deploys a new package to the database storage (just a group).
|
* Deploys a new package to the database storage (just a group).
|
||||||
*/
|
*/
|
||||||
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
public async deployPackageToStorage(instanceId: number, packageName: string): Promise<GuaribasPackage> {
|
||||||
return await GuaribasPackage.create({
|
return await GuaribasPackage.create(<GuaribasPackage>{
|
||||||
packageName: packageName,
|
packageName: packageName,
|
||||||
instanceId: instanceId
|
instanceId: instanceId
|
||||||
});
|
});
|
||||||
|
@ -814,14 +814,6 @@ export class GBDeployer implements IGBDeployer {
|
||||||
GBLog.info(`Transpiling default.gbui...`);
|
GBLog.info(`Transpiling default.gbui...`);
|
||||||
child_process.execSync(`${npm} run build`, { cwd: root });
|
child_process.execSync(`${npm} run build`, { cwd: root });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up node_modules folder as it is only needed during compile time.
|
|
||||||
|
|
||||||
// const nodeModules = urlJoin(root, 'node_modules');
|
|
||||||
// if (Fs.existsSync(nodeModules)) {
|
|
||||||
// rimraf.sync(nodeModules);
|
|
||||||
// GBLog.info(`Cleaning default.gbui node_modules...`);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,8 +37,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { GBMinInstance, IGBCoreService, IGBInstance } from 'botlib';
|
import { GBMinInstance, IGBCoreService, IGBInstance } from 'botlib';
|
||||||
import fs = require('fs');
|
import { CreateOptions } from 'sequelize/types';
|
||||||
import urlJoin = require('url-join');
|
const fs = require('fs');
|
||||||
|
const urlJoin = require('url-join');
|
||||||
import { GBServer } from '../../../src/app';
|
import { GBServer } from '../../../src/app';
|
||||||
import { GuaribasInstance } from '../models/GBModel';
|
import { GuaribasInstance } from '../models/GBModel';
|
||||||
import { GBConfigService } from './GBConfigService';
|
import { GBConfigService } from './GBConfigService';
|
||||||
|
@ -94,8 +95,8 @@ export class GBImporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createBotInstance(botId: string) {
|
public async createBotInstance(botId: string) {
|
||||||
const fullSettingsJson = { ...GBServer.globals.bootInstance };
|
const fullSettingsJson=<GuaribasInstance> { ...GBServer.globals.bootInstance };
|
||||||
fullSettingsJson.botId = botId;
|
fullSettingsJson['botId'] = botId;
|
||||||
|
|
||||||
return await GuaribasInstance.create(fullSettingsJson);
|
return await GuaribasInstance.create(fullSettingsJson);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { FeedbackDialog } from './dialogs/FeedbackDialog';
|
import { FeedbackDialog } from './dialogs/FeedbackDialog';
|
||||||
import { QualityDialog } from './dialogs/QualityDialog';
|
import { QualityDialog } from './dialogs/QualityDialog';
|
||||||
import { GuaribasQuestionAlternate } from './models/index';
|
import { GuaribasQuestionAlternate } from './models/index';
|
||||||
|
|
|
@ -40,6 +40,7 @@ import {
|
||||||
AutoIncrement,
|
AutoIncrement,
|
||||||
BelongsTo,
|
BelongsTo,
|
||||||
Column,
|
Column,
|
||||||
|
DataType,
|
||||||
ForeignKey,
|
ForeignKey,
|
||||||
Model,
|
Model,
|
||||||
PrimaryKey,
|
PrimaryKey,
|
||||||
|
@ -55,15 +56,17 @@ export class GuaribasQuestionAlternate extends Model<GuaribasQuestionAlternate>
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public quickAnswerId: number;
|
public quickAnswerId: number;
|
||||||
|
|
||||||
@Column public questionTyped: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public questionTyped: string;
|
||||||
|
|
||||||
@Column public questionText: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public questionText: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
import { FindOptions, NonNullFindOptions } from 'sequelize/types';
|
||||||
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models';
|
import { GuaribasQuestion } from '../../../packages/kb.gbapp/models';
|
||||||
import { GuaribasConversation } from '../../analytics.gblib/models';
|
import { GuaribasConversation } from '../../analytics.gblib/models';
|
||||||
import { GuaribasQuestionAlternate } from '../models';
|
import { GuaribasQuestionAlternate } from '../models';
|
||||||
|
@ -69,7 +70,7 @@ export class CSService {
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
questionTyped: string,
|
questionTyped: string,
|
||||||
questionText: string): Promise<GuaribasQuestionAlternate> {
|
questionText: string): Promise<GuaribasQuestionAlternate> {
|
||||||
return await GuaribasQuestionAlternate.create({
|
return await GuaribasQuestionAlternate.create(<GuaribasQuestionAlternate>{
|
||||||
questionTyped: questionTyped,
|
questionTyped: questionTyped,
|
||||||
questionText: questionText
|
questionText: questionText
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
|
|
|
@ -67,23 +67,27 @@ import { GuaribasUser } from '../../security.gbapp/models';
|
||||||
export class GuaribasSubject extends Model<GuaribasSubject> {
|
export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public subjectId: number;
|
public subjectId: number;
|
||||||
|
|
||||||
@Column public internalId: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public internalId: string;
|
||||||
|
|
||||||
@Column public title: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public title: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public description: string;
|
public description: string;
|
||||||
|
|
||||||
@Column public from: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public from: string;
|
||||||
|
|
||||||
@Column public to: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public to: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasSubject)
|
@ForeignKey(() => GuaribasSubject)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public parentSubjectId: number;
|
public parentSubjectId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasSubject, 'parentSubjectId')
|
@BelongsTo(() => GuaribasSubject, 'parentSubjectId')
|
||||||
|
@ -93,21 +97,21 @@ export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
public childrenSubjects: GuaribasSubject[];
|
public childrenSubjects: GuaribasSubject[];
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasUser)
|
@ForeignKey(() => GuaribasUser)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public responsibleUserId: number;
|
public responsibleUserId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasUser)
|
@BelongsTo(() => GuaribasUser)
|
||||||
public responsibleUser: GuaribasUser;
|
public responsibleUser: GuaribasUser;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public packageId: number;
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
|
@ -121,30 +125,30 @@ export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public questionId: number;
|
public questionId: number;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public subject1: string;
|
public subject1: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public subject2: string;
|
public subject2: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public subject3: string;
|
public subject3: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public subject4: string;
|
public subject4: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(1024))
|
@Column(DataType.STRING(1024))
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public keywords: string;
|
public keywords: string;
|
||||||
|
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public skipIndex: boolean;
|
public skipIndex: boolean;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
|
@ -156,28 +160,29 @@ export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
public content: string;
|
public content: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
|
||||||
//tslint:disable-next-line:no-use-before-declare
|
//tslint:disable-next-line:no-use-before-declare
|
||||||
@ForeignKey(() => GuaribasAnswer)
|
@ForeignKey(() => GuaribasAnswer)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public answerId: number;
|
public answerId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
public instance: GuaribasInstance;
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public packageId: number;
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
|
@ -191,28 +196,29 @@ export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public answerId: number;
|
public answerId: number;
|
||||||
|
|
||||||
@Length({ min: 0, max: 512 })
|
@Length({ min: 0, max: 512 })
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public media: string;
|
public media: string;
|
||||||
|
|
||||||
@Length({ min: 0, max: 12 })
|
@Length({ min: 0, max: 12 })
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public format: string;
|
public format: string;
|
||||||
|
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
public content: string;
|
public content: string;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
public createdAt: Date;
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column(DataType.DATE)
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
public updatedAt: Date;
|
public updatedAt: Date;
|
||||||
|
|
||||||
|
|
||||||
@HasMany(() => GuaribasQuestion)
|
@HasMany(() => GuaribasQuestion)
|
||||||
public questions: GuaribasQuestion[];
|
public questions: GuaribasQuestion[];
|
||||||
|
|
||||||
|
@ -223,19 +229,19 @@ export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
||||||
public next: GuaribasQuestion;
|
public next: GuaribasQuestion;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasQuestion)
|
@ForeignKey(() => GuaribasQuestion)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public nextId: number;
|
public nextId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasQuestion)
|
@ForeignKey(() => GuaribasQuestion)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public prevId: number;
|
public prevId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public packageId: number;
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
|
|
|
@ -613,7 +613,7 @@ export class KBService implements IGBKBService {
|
||||||
const fullFilename = urlJoin(file.root, file.name);
|
const fullFilename = urlJoin(file.root, file.name);
|
||||||
content = Fs.readFileSync(fullFilename, 'utf-8');
|
content = Fs.readFileSync(fullFilename, 'utf-8');
|
||||||
|
|
||||||
await GuaribasAnswer.create({
|
await GuaribasAnswer.create(<GuaribasAnswer>{
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
content: content,
|
content: content,
|
||||||
format: '.md',
|
format: '.md',
|
||||||
|
@ -649,7 +649,7 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
content = await min.conversationalService.translate(min, content, 'en');
|
content = await min.conversationalService.translate(min, content, 'en');
|
||||||
await GuaribasAnswer.create({
|
await GuaribasAnswer.create(<GuaribasAnswer>{
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
content: content,
|
content: content,
|
||||||
format: '.docx',
|
format: '.docx',
|
||||||
|
@ -677,7 +677,7 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
const doIt = async (subjects: GuaribasSubject[], parentSubjectId: number) => {
|
const doIt = async (subjects: GuaribasSubject[], parentSubjectId: number) => {
|
||||||
return asyncPromise.eachSeries(subjects, async item => {
|
return asyncPromise.eachSeries(subjects, async item => {
|
||||||
const value = await GuaribasSubject.create({
|
const value = await GuaribasSubject.create(<GuaribasSubject>{
|
||||||
internalId: item.id,
|
internalId: item.id,
|
||||||
parentSubjectId: parentSubjectId,
|
parentSubjectId: parentSubjectId,
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||||
import { Sequelize } from 'sequelize-typescript';
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
|
|
@ -56,23 +56,28 @@ import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
|
||||||
export class GuaribasUser extends Model<GuaribasUser> {
|
export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column(DataType.INTEGER)
|
||||||
public userId: number;
|
public userId: number;
|
||||||
|
|
||||||
@Column public displayName: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public displayName: string;
|
||||||
|
|
||||||
@Column public userSystemId: string;
|
@Column (DataType.STRING(255))
|
||||||
@Column public userName: string;
|
public userSystemId: string;
|
||||||
|
@Column (DataType.STRING(255))
|
||||||
|
public userName: string;
|
||||||
|
|
||||||
@Column public defaultChannel: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public defaultChannel: string;
|
||||||
|
|
||||||
@Column public email: string;
|
@Column (DataType.STRING(255))
|
||||||
|
public email: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(5))
|
@Column(DataType.STRING(5))
|
||||||
public locale: string;
|
public locale: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
|
@ -82,14 +87,14 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
public agentSystemId: string;
|
public agentSystemId: string;
|
||||||
|
|
||||||
@Column(DataType.DATE)
|
@Column(DataType.DATE)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public agentContacted: Date;
|
public agentContacted: Date;
|
||||||
|
|
||||||
@Column(DataType.STRING(16))
|
@Column(DataType.STRING(16))
|
||||||
public agentMode: string;
|
public agentMode: string;
|
||||||
|
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public conversationReference: string;
|
public conversationReference: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
|
@ -103,15 +108,15 @@ export class GuaribasUser extends Model<GuaribasUser> {
|
||||||
export class GuaribasGroup extends Model<GuaribasGroup> {
|
export class GuaribasGroup extends Model<GuaribasGroup> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public groupId: number;
|
public groupId: number;
|
||||||
|
|
||||||
@Length({ min: 0, max: 512 })
|
@Length({ min: 0, max: 512 })
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public displayName: string;
|
public displayName: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
|
@ -124,15 +129,15 @@ export class GuaribasGroup extends Model<GuaribasGroup> {
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasUserGroup extends Model<GuaribasUserGroup> {
|
export class GuaribasUserGroup extends Model<GuaribasUserGroup> {
|
||||||
@ForeignKey(() => GuaribasUser)
|
@ForeignKey(() => GuaribasUser)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public userId: number;
|
public userId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasGroup)
|
@ForeignKey(() => GuaribasGroup)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public groupId: number;
|
public groupId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column (DataType.STRING(255))
|
||||||
public instanceId: number;
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
|
|
|
@ -1,37 +1,16 @@
|
||||||
const Fs = require('fs');
|
const Fs = require('fs');
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
import { ConversationReference } from 'botbuilder';
|
import { ConversationReference } from 'botbuilder';
|
||||||
import { GBLog, GBService, IGBInstance } from 'botlib';
|
import { GBLog, GBService, IGBInstance } from 'botlib';
|
||||||
import { CollectionUtil } from 'pragmatismo-io-framework';
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';
|
||||||
|
import {FindOptions} from 'sequelize';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Security service layer.
|
* Security service layer.
|
||||||
*/
|
*/
|
||||||
export class SecService extends GBService {
|
export class SecService extends GBService {
|
||||||
public async importSecurityFile(localPath: string, instance: IGBInstance) {
|
|
||||||
const security = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'security.json'), 'utf8'));
|
|
||||||
await CollectionUtil.asyncForEach(security.groups, async group => {
|
|
||||||
const groupDb = GuaribasGroup.build({
|
|
||||||
instanceId: instance.instanceId,
|
|
||||||
displayName: group.displayName
|
|
||||||
});
|
|
||||||
const g1 = await groupDb.save();
|
|
||||||
await CollectionUtil.asyncForEach(group.users, async user => {
|
|
||||||
const userDb = GuaribasUser.build({
|
|
||||||
instanceId: instance.instanceId,
|
|
||||||
groupId: g1.groupId,
|
|
||||||
userName: user.userName
|
|
||||||
});
|
|
||||||
const user2 = await userDb.save();
|
|
||||||
const userGroup = GuaribasUserGroup.build();
|
|
||||||
userGroup.groupId = g1.groupId;
|
|
||||||
userGroup.userId = user2.userId;
|
|
||||||
await userGroup.save();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async ensureUser(
|
public async ensureUser(
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
|
@ -66,7 +45,7 @@ export class SecService extends GBService {
|
||||||
* Retrives a conversation reference from contact phone.
|
* Retrives a conversation reference from contact phone.
|
||||||
*/
|
*/
|
||||||
public async getConversationReference(phone: string): Promise<ConversationReference> {
|
public async getConversationReference(phone: string): Promise<ConversationReference> {
|
||||||
const options = { where: { phone: phone } };
|
const options = <FindOptions>{ rejectOnEmpty:true, where: { phone: phone } };
|
||||||
const user = await GuaribasUser.findOne(options);
|
const user = await GuaribasUser.findOne(options);
|
||||||
|
|
||||||
return JSON.parse(user.conversationReference);
|
return JSON.parse(user.conversationReference);
|
||||||
|
@ -76,7 +55,7 @@ export class SecService extends GBService {
|
||||||
* Updates a conversation reference from contact phone.
|
* Updates a conversation reference from contact phone.
|
||||||
*/
|
*/
|
||||||
public async updateConversationReference(phone: string, conversationReference: string) {
|
public async updateConversationReference(phone: string, conversationReference: string) {
|
||||||
const options = { where: { phone: phone } };
|
const options = <FindOptions>{ where: { phone: phone } };
|
||||||
const user = await GuaribasUser.findOne(options);
|
const user = await GuaribasUser.findOne(options);
|
||||||
|
|
||||||
user.conversationReference = conversationReference;
|
user.conversationReference = conversationReference;
|
||||||
|
@ -84,7 +63,7 @@ export class SecService extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateConversationReferenceById(userId: number, conversationReference: string) {
|
public async updateConversationReferenceById(userId: number, conversationReference: string) {
|
||||||
const options = { where: { userId: userId } };
|
const options = <FindOptions>{ where: { userId: userId } };
|
||||||
const user = await GuaribasUser.findOne(options);
|
const user = await GuaribasUser.findOne(options);
|
||||||
|
|
||||||
user.conversationReference = conversationReference;
|
user.conversationReference = conversationReference;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
import { GBService } from 'botlib';
|
import { GBService } from 'botlib';
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
var AdmZip = require("adm-zip");
|
var AdmZip = require("adm-zip");
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
import urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
const Swagger = require('swagger-client');
|
const Swagger = require('swagger-client');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
|
@ -96,6 +96,7 @@ export class GBServer {
|
||||||
server.use(bodyParser.json());
|
server.use(bodyParser.json());
|
||||||
server.use(bodyParser.urlencoded({ extended: true }));
|
server.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
|
||||||
// Creates working directory.
|
// Creates working directory.
|
||||||
|
|
||||||
const workDir = Path.join(process.env.PWD, 'work');
|
const workDir = Path.join(process.env.PWD, 'work');
|
||||||
|
@ -153,6 +154,7 @@ export class GBServer {
|
||||||
|
|
||||||
GBLog.info(`Deploying packages...`);
|
GBLog.info(`Deploying packages...`);
|
||||||
GBServer.globals.sysPackages = await core.loadSysPackages(core);
|
GBServer.globals.sysPackages = await core.loadSysPackages(core);
|
||||||
|
GBLog.info(`Connecting to Bot Storage...`);
|
||||||
await core.checkStorage(azureDeployer);
|
await core.checkStorage(azureDeployer);
|
||||||
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
|
await deployer.deployPackages(core, server, GBServer.globals.appPackages);
|
||||||
await core.syncDatabaseStructure();
|
await core.syncDatabaseStructure();
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"node_modules/@types"
|
"node_modules/@types"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"test/**/*",
|
"test/**/*",
|
||||||
"src/**/*",
|
"src/**/*",
|
||||||
"packages/*.gbapp/**/*",
|
"packages/*.gbapp/**/*",
|
||||||
|
|
Loading…
Add table
Reference in a new issue