botserver/packages/core.gbapp/models/GBModel.ts

403 lines
9.3 KiB
TypeScript
Raw Normal View History

2018-04-21 02:59:30 -03:00
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' v `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) |
2018-04-21 02:59:30 -03:00
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
| Licensed under the AGPL-3.0. |
2018-11-11 19:09:18 -02:00
| |
2018-04-21 02:59:30 -03:00
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
2018-09-11 19:40:53 -03:00
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
2018-04-21 02:59:30 -03:00
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of Pragmatismo.io. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
2018-11-11 19:09:18 -02:00
/**
* @fileoverview General Bots server core.
*/
'use strict';
2018-04-21 02:59:30 -03:00
import {
AutoIncrement,
BelongsTo,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from 'sequelize-typescript';
2018-04-21 02:59:30 -03:00
import { IGBInstance } from 'botlib';
2018-04-21 02:59:30 -03:00
/**
* Base instance data for a bot.
*/
2018-04-21 02:59:30 -03:00
@Table
2022-11-19 23:34:58 -03:00
export class GuaribasInstance extends Model<GuaribasInstance> implements IGBInstance {
@PrimaryKey
@AutoIncrement
2022-01-03 13:11:21 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
instanceId: number;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
botEndpoint: string;
2018-09-04 15:09:52 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
whoAmIVideo: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
botId: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
title: string;
2018-04-21 02:59:30 -03:00
@Column({ type: DataType.STRING(16) })
2022-11-19 23:34:58 -03:00
activationCode: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
description: string;
2018-04-21 02:59:30 -03:00
@Column({ type: DataType.STRING(16) })
2022-11-19 23:34:58 -03:00
state: string;
2022-11-19 23:34:58 -03:00
version: string;
2018-04-21 02:59:30 -03:00
2022-11-11 21:35:05 -03:00
@Column(DataType.STRING(64))
2022-11-19 23:34:58 -03:00
botKey: string;
2022-11-11 21:35:05 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
enabledAdmin: boolean;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
engineName: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
marketplaceId: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
textAnalyticsKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
textAnalyticsEndpoint: string;
2018-04-21 02:59:30 -03:00
@Column({ type: DataType.STRING(64) })
2022-11-19 23:34:58 -03:00
translatorKey: string;
@Column({ type: DataType.STRING(128) })
2022-11-19 23:34:58 -03:00
translatorEndpoint: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
marketplacePassword: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
webchatKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
authenticatorTenant: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
authenticatorAuthorityHostUrl: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
cloudSubscriptionId: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
cloudUsername: string;
2018-10-25 18:13:51 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
cloudPassword: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
cloudLocation: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
googleBotKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
googleChatApiKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
googleChatSubscriptionName: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
googleClientEmail: string;
@Column({ type: DataType.STRING(4000) })
2022-11-19 23:34:58 -03:00
googlePrivateKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
googleProjectId: string;
2021-07-06 13:18:38 -03:00
@Column({ type: DataType.STRING(255) })
2022-11-19 23:34:58 -03:00
facebookWorkplaceVerifyToken: string;
2021-07-06 13:18:38 -03:00
@Column({ type: DataType.STRING(255) })
2022-11-19 23:34:58 -03:00
facebookWorkplaceAppSecret: string;
2021-07-06 13:18:38 -03:00
@Column({ type: DataType.STRING(512) })
2022-11-19 23:34:58 -03:00
facebookWorkplaceAccessToken: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
whatsappBotKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
whatsappServiceKey: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
whatsappServiceNumber: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
whatsappServiceUrl: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
smsKey: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
smsSecret: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
smsServiceNumber: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
speechKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
speechEndpoint: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
spellcheckerKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
spellcheckerEndpoint: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
theme: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
ui: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
kb: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
nlpAppId: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
nlpKey: string;
@Column({ type: DataType.STRING(512) })
2022-11-19 23:34:58 -03:00
nlpEndpoint: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
nlpAuthoringKey: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
deploymentPaths: string;
2018-10-25 18:13:51 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
searchHost: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
searchKey: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
searchIndex: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
searchIndexer: string;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storageUsername: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storagePassword: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storageName: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storageServer: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storageDialect: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
storagePath: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
adminPass: string;
2018-10-25 18:13:51 -03:00
@Column(DataType.FLOAT)
2022-11-19 23:34:58 -03:00
nlpVsSearch: number; // TODO: Remove field.
2018-04-21 02:59:30 -03:00
@Column(DataType.FLOAT)
2022-11-19 23:34:58 -03:00
searchScore: number;
2018-04-21 02:59:30 -03:00
@Column(DataType.FLOAT)
2022-11-19 23:34:58 -03:00
nlpScore: number;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
@Column(DataType.STRING(4000))
2022-11-19 23:34:58 -03:00
params: string;
2018-04-21 02:59:30 -03:00
}
/**
* Each packaged listed for use in a bot instance.
*/
2018-04-21 02:59:30 -03:00
@Table
export class GuaribasPackage extends Model<GuaribasPackage> {
@PrimaryKey
@AutoIncrement
2022-01-03 13:42:12 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
packageId: number;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
packageName: string;
@ForeignKey(() => GuaribasInstance)
2022-01-03 13:11:21 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
instanceId: number;
2018-04-21 02:59:30 -03:00
@BelongsTo(() => GuaribasInstance)
2022-11-19 23:34:58 -03:00
instance: GuaribasInstance;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
@Column({ type: DataType.STRING(512) })
2022-11-19 23:34:58 -03:00
custom: string;
2018-04-21 02:59:30 -03:00
}
/**
* A bot channel.
*/
2018-04-21 02:59:30 -03:00
@Table
export class GuaribasChannel extends Model<GuaribasChannel> {
@PrimaryKey
@AutoIncrement
2022-01-03 13:42:12 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
channelId: number;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
title: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
2018-04-21 02:59:30 -03:00
}
/**
* An exception that has been thrown.
*/
2018-04-21 02:59:30 -03:00
@Table
//tslint:disable-next-line:max-classes-per-file
2018-04-21 02:59:30 -03:00
export class GuaribasException extends Model<GuaribasException> {
@PrimaryKey
@AutoIncrement
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
exceptionId: number;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
message: string;
2018-04-21 02:59:30 -03:00
@ForeignKey(() => GuaribasInstance)
2022-01-03 13:11:21 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
instanceId: number;
2018-04-21 02:59:30 -03:00
@BelongsTo(() => GuaribasInstance)
2022-11-19 23:34:58 -03:00
instance: GuaribasInstance;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2018-04-21 02:59:30 -03:00
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
}
@Table
//tslint:disable-next-line:max-classes-per-file
export class GuaribasApplications extends Model<GuaribasApplications> {
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
name: string;
@ForeignKey(() => GuaribasInstance)
2022-01-03 13:11:21 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
instanceId: number;
@BelongsTo(() => GuaribasInstance)
2022-11-19 23:34:58 -03:00
instance: GuaribasInstance;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
}
@Table
//tslint:disable-next-line:max-classes-per-file
export class GuaribasSchedule extends Model<GuaribasSchedule> {
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
name: string;
2022-01-03 13:11:21 -03:00
@Column(DataType.STRING(255))
2022-11-19 23:34:58 -03:00
schedule: string;
@ForeignKey(() => GuaribasInstance)
2022-01-03 13:11:21 -03:00
@Column(DataType.INTEGER)
2022-11-19 23:34:58 -03:00
instanceId: number;
@BelongsTo(() => GuaribasInstance)
2022-11-19 23:34:58 -03:00
instance: GuaribasInstance;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@CreatedAt
2022-11-19 23:34:58 -03:00
createdAt: Date;
2022-01-03 13:11:21 -03:00
@Column(DataType.DATE)
@UpdatedAt
2022-11-19 23:34:58 -03:00
updatedAt: Date;
}