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