TSLint fixing.
This commit is contained in:
parent
60b935189f
commit
ca565b890a
46 changed files with 497 additions and 384 deletions
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
* text=auto
|
||||||
|
*.js eol=lf
|
||||||
|
*.ts eol=lf
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"trailingComma": "all",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 80,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ script:
|
||||||
- npm run clean
|
- npm run clean
|
||||||
- npm run build
|
- npm run build
|
||||||
- npm run build-docs
|
- npm run build-docs
|
||||||
- npm run tslit
|
- npm run tslint
|
||||||
- npm run coveralls
|
- npm run coveralls
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
|
|
31
package-lock.json
generated
31
package-lock.json
generated
|
@ -2391,7 +2391,8 @@
|
||||||
"builtin-modules": {
|
"builtin-modules": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
|
||||||
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8="
|
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"bytes": {
|
"bytes": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -3287,7 +3288,8 @@
|
||||||
"esprima": {
|
"esprima": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||||
"integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE="
|
"integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"estraverse": {
|
"estraverse": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.0",
|
||||||
|
@ -4893,6 +4895,16 @@
|
||||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
||||||
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
|
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
|
||||||
},
|
},
|
||||||
|
"js-yaml": {
|
||||||
|
"version": "3.12.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
|
||||||
|
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"argparse": "^1.0.7",
|
||||||
|
"esprima": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"jsbn": {
|
"jsbn": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
||||||
|
@ -8607,6 +8619,7 @@
|
||||||
"version": "5.11.0",
|
"version": "5.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz",
|
||||||
"integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=",
|
"integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-code-frame": "^6.22.0",
|
"babel-code-frame": "^6.22.0",
|
||||||
"builtin-modules": "^1.1.1",
|
"builtin-modules": "^1.1.1",
|
||||||
|
@ -8620,17 +8633,6 @@
|
||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
"tslib": "^1.8.0",
|
"tslib": "^1.8.0",
|
||||||
"tsutils": "^2.27.2"
|
"tsutils": "^2.27.2"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"js-yaml": {
|
|
||||||
"version": "3.12.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
|
|
||||||
"integrity": "sha1-6u1lbsg0TxD1J8a/obbiJE3hZ9E=",
|
|
||||||
"requires": {
|
|
||||||
"argparse": "^1.0.7",
|
|
||||||
"esprima": "^4.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslint-microsoft-contrib": {
|
"tslint-microsoft-contrib": {
|
||||||
|
@ -8656,7 +8658,8 @@
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
"version": "2.29.0",
|
"version": "2.29.0",
|
||||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
|
||||||
"integrity": "sha1-MrSIUBRnrL7dS4VJhnOggSrKC5k=",
|
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^1.8.1"
|
"tslib": "^1.8.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"tslint": "tslint ./packages/*/src/**/*.ts -t verbose",
|
"tslint": "tslint ./src ./packages/**/*.ts -t verbose",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"build-docs": "typedoc --options typedoc.json src/",
|
"build-docs": "typedoc --options typedoc.json src/",
|
||||||
"test": "nyc --reporter=html --reporter=text mocha -r ts-node/register packages/**/*.test.ts ",
|
"test": "nyc --reporter=html --reporter=text mocha -r ts-node/register packages/**/*.test.ts ",
|
||||||
|
@ -89,7 +89,6 @@
|
||||||
"swagger-client": "3.8.22",
|
"swagger-client": "3.8.22",
|
||||||
"tedious": "3.0.1",
|
"tedious": "3.0.1",
|
||||||
"ts-node": "7.0.1",
|
"ts-node": "7.0.1",
|
||||||
"tslint": "^5.11.0",
|
|
||||||
"typedoc": "0.13.0",
|
"typedoc": "0.13.0",
|
||||||
"typedoc-plugin-external-module-name": "^1.1.3",
|
"typedoc-plugin-external-module-name": "^1.1.3",
|
||||||
"typedoc-plugin-markdown": "^1.1.18",
|
"typedoc-plugin-markdown": "^1.1.18",
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
|
|
|
@ -30,35 +30,27 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
'use strict'
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
const UrlJoin = require('url-join')
|
'use strict';
|
||||||
|
|
||||||
import { AdminDialog } from './dialogs/AdminDialog'
|
import urlJoin = require('url-join');
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from 'botlib'
|
|
||||||
|
|
||||||
import { Sequelize } from 'sequelize-typescript'
|
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||||
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
import { AdminDialog } from './dialogs/AdminDialog';
|
||||||
import { GuaribasAdmin } from './models/AdminModel';
|
import { GuaribasAdmin } from './models/AdminModel';
|
||||||
|
|
||||||
export class GBAdminPackage implements IGBPackage {
|
export class GBAdminPackage implements IGBPackage {
|
||||||
sysPackages: IGBPackage[] = null
|
public sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
||||||
core.sequelize.addModels([
|
core.sequelize.addModels([GuaribasAdmin]);
|
||||||
GuaribasAdmin
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
public loadBot(min: GBMinInstance): void {
|
||||||
}
|
AdminDialog.setup(min.bot, min);
|
||||||
|
|
||||||
loadBot(min: GBMinInstance): void {
|
|
||||||
AdminDialog.setup(min.bot, min)
|
|
||||||
}
|
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
onNewSession(min: GBMinInstance, step: any): void {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { GuaribasAdmin } from "../models/AdminModel";
|
import { GuaribasAdmin } from "../models/AdminModel";
|
||||||
import { IGBCoreService } from "botlib";
|
import { IGBCoreService } from "botlib";
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DataTypes,
|
DataTypes,
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
import { GuaribasUser } from "../../security.gblib/models"
|
import { GuaribasUser } from "../../security.gblib/models"
|
||||||
import { GuaribasConversation, GuaribasConversationMessage } from "../models"
|
import { GuaribasConversation, GuaribasConversationMessage } from "../models"
|
||||||
|
|
||||||
|
|
|
@ -30,38 +30,40 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
import { GBMinInstance } from "botlib";
|
'use strict';
|
||||||
import { IGBDialog } from "botlib";
|
|
||||||
import { BotAdapter } from "botbuilder";
|
import { BotAdapter } from 'botbuilder';
|
||||||
import { Messages } from "../strings";
|
import { GBMinInstance } from 'botlib';
|
||||||
|
import { IGBDialog } from 'botlib';
|
||||||
|
import { Messages } from '../strings';
|
||||||
|
|
||||||
export class BotFarmDialog extends IGBDialog {
|
export class BotFarmDialog extends IGBDialog {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup dialogs flows and define services call.
|
* Setup dialogs flows and define services call.
|
||||||
*
|
*
|
||||||
* @param bot The bot adapter.
|
* @param bot The bot adapter.
|
||||||
* @param min The minimal bot instance data.
|
* @param min The minimal bot instance data.
|
||||||
*/
|
*/
|
||||||
static setup(bot: BotAdapter, min: GBMinInstance) {
|
public static setup(bot: BotAdapter, min: GBMinInstance) {
|
||||||
min.dialogs.add("/createBotFarm", [
|
min.dialogs.add('/createBotFarm', [
|
||||||
async step => {
|
async step => {
|
||||||
let locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
await step.prompt("choicePrompt", Messages[locale].what_about_me, [
|
await step.prompt('choicePrompt', Messages[locale].what_about_me, [
|
||||||
"1",
|
'1',
|
||||||
"2",
|
'2',
|
||||||
"3",
|
'3',
|
||||||
"4",
|
'4',
|
||||||
"5"
|
'5',
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
let locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
await step.context.sendActivity(Messages[locale].thanks);
|
await step.context.sendActivity(Messages[locale].thanks);
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,32 +30,25 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
'use strict';
|
||||||
import { GBMinInstance, IGBPackage, IGBCoreService } from "botlib"
|
|
||||||
import { Sequelize } from "sequelize-typescript"
|
|
||||||
|
|
||||||
|
const UrlJoin = require('url-join');
|
||||||
|
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
|
||||||
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
|
|
||||||
export class GBWhatsappPackage implements IGBPackage {
|
export class GBWhatsappPackage implements IGBPackage {
|
||||||
|
public sysPackages: IGBPackage[] = null;
|
||||||
|
|
||||||
sysPackages: IGBPackage[] = null
|
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
|
||||||
|
|
||||||
loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
|
public unloadPackage(core: IGBCoreService): void {}
|
||||||
}
|
|
||||||
|
|
||||||
unloadPackage(core: IGBCoreService): void {
|
public loadBot(min: GBMinInstance): void {}
|
||||||
|
|
||||||
}
|
public unloadBot(min: GBMinInstance): void {}
|
||||||
|
public onNewSession(min: GBMinInstance, step: any): void {}
|
||||||
loadBot(min: GBMinInstance): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
unloadBot(min: GBMinInstance): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
onNewSession(min: GBMinInstance, step: any): void {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { GBService, IGBInstance } from "botlib";
|
import { GBService, IGBInstance } from "botlib";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { IGBDialog } from "botlib";
|
import { IGBDialog } from "botlib";
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { IGBDialog } from "botlib";
|
import { IGBDialog } from "botlib";
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
export class GBConfigService {
|
export class GBConfigService {
|
||||||
|
@ -98,9 +102,7 @@ export class GBConfigService {
|
||||||
value = "true";
|
value = "true";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.warn(
|
logger.warn(`Invalid key on .env file: '${key}'`);
|
||||||
`Invalid key on .env file: '${key}'`
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
|
|
||||||
|
@ -75,7 +79,7 @@ export class GBConversationalService implements IGBConversationalService {
|
||||||
mobile: string,
|
mobile: string,
|
||||||
text: string
|
text: string
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve: any, reject: any): any => {
|
||||||
const nexmo = new Nexmo({
|
const nexmo = new Nexmo({
|
||||||
apiKey: min.instance.smsKey,
|
apiKey: min.instance.smsKey,
|
||||||
apiSecret: min.instance.smsSecret
|
apiSecret: min.instance.smsSecret
|
||||||
|
|
|
@ -34,26 +34,21 @@
|
||||||
* @fileoverview General Bots server core.
|
* @fileoverview General Bots server core.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
const logger = require("../../../src/logger");
|
import { IGBCoreService, IGBInstance } from 'botlib';
|
||||||
import { Sequelize } from "sequelize-typescript";
|
import * as fs from 'fs';
|
||||||
import * as fs from "fs";
|
import processExists = require('process-exists');
|
||||||
import { GBConfigService } from "./GBConfigService";
|
import { Sequelize } from 'sequelize-typescript';
|
||||||
import { IGBInstance, IGBCoreService } from "botlib";
|
import logger = require('../../../src/logger');
|
||||||
import { GuaribasInstance } from "../models/GBModel";
|
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
|
||||||
import { GBAdminService } from "../../admin.gbapp/services/GBAdminService";
|
import { GuaribasInstance } from '../models/GBModel';
|
||||||
const processExists = require("process-exists");
|
import { GBConfigService } from './GBConfigService';
|
||||||
const TextDecoder = require("util").TextDecoder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core service layer.
|
* Core service layer.
|
||||||
*/
|
*/
|
||||||
export class GBCoreService implements IGBCoreService {
|
export class GBCoreService implements IGBCoreService {
|
||||||
isCloudSetup() {
|
|
||||||
return GBConfigService.tryGet("STORAGE_DIALECT");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data access layer instance.
|
* Data access layer instance.
|
||||||
*/
|
*/
|
||||||
|
@ -72,12 +67,16 @@ export class GBCoreService implements IGBCoreService {
|
||||||
/**
|
/**
|
||||||
* Custom create table query.
|
* Custom create table query.
|
||||||
*/
|
*/
|
||||||
private createTableQuery: (tableName, attributes, options) => string;
|
private createTableQuery: (
|
||||||
|
tableName: string,
|
||||||
|
attributes: any,
|
||||||
|
options: any,
|
||||||
|
) => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom change column query.
|
* Custom change column query.
|
||||||
*/
|
*/
|
||||||
private changeColumnQuery: (tableName, attributes) => string;
|
private changeColumnQuery: (tableName: string, attributes: any) => string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialect used. Tested: mssql and sqlite.
|
* Dialect used. Tested: mssql and sqlite.
|
||||||
|
@ -94,75 +93,149 @@ export class GBCoreService implements IGBCoreService {
|
||||||
/**
|
/**
|
||||||
* Gets database config and connect to storage.
|
* Gets database config and connect to storage.
|
||||||
*/
|
*/
|
||||||
async initDatabase() {
|
public async initDatabase(): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise(
|
||||||
try {
|
(resolve: any, reject: any): any => {
|
||||||
this.dialect = GBConfigService.get("STORAGE_DIALECT");
|
try {
|
||||||
|
this.dialect = GBConfigService.get('STORAGE_DIALECT');
|
||||||
|
|
||||||
let host: string | undefined;
|
let host: string | undefined;
|
||||||
let database: string | undefined;
|
let database: string | undefined;
|
||||||
let username: string | undefined;
|
let username: string | undefined;
|
||||||
let password: string | undefined;
|
let password: string | undefined;
|
||||||
let storage: string | undefined;
|
let storage: string | undefined;
|
||||||
|
|
||||||
if (this.dialect === "mssql") {
|
if (this.dialect === 'mssql') {
|
||||||
host = GBConfigService.get("STORAGE_SERVER");
|
host = GBConfigService.get('STORAGE_SERVER');
|
||||||
database = GBConfigService.get("STORAGE_NAME");
|
database = GBConfigService.get('STORAGE_NAME');
|
||||||
username = GBConfigService.get("STORAGE_USERNAME");
|
username = GBConfigService.get('STORAGE_USERNAME');
|
||||||
password = GBConfigService.get("STORAGE_PASSWORD");
|
password = GBConfigService.get('STORAGE_PASSWORD');
|
||||||
} else if (this.dialect === "sqlite") {
|
} else if (this.dialect === 'sqlite') {
|
||||||
storage = GBConfigService.get("STORAGE_STORAGE");
|
storage = GBConfigService.get('STORAGE_STORAGE');
|
||||||
} else {
|
} else {
|
||||||
reject(`Unknown dialect: ${this.dialect}.`);
|
reject(`Unknown dialect: ${this.dialect}.`);
|
||||||
}
|
|
||||||
|
|
||||||
let logging =
|
|
||||||
GBConfigService.get("STORAGE_LOGGING") === "true"
|
|
||||||
? (str: string) => {
|
|
||||||
logger.info(str);
|
|
||||||
}
|
|
||||||
: false;
|
|
||||||
|
|
||||||
let encrypt = GBConfigService.get("STORAGE_ENCRYPT") === "true";
|
|
||||||
|
|
||||||
this.sequelize = new Sequelize({
|
|
||||||
host: host,
|
|
||||||
database: database,
|
|
||||||
username: username,
|
|
||||||
password: password,
|
|
||||||
logging: logging,
|
|
||||||
operatorsAliases: false,
|
|
||||||
dialect: this.dialect,
|
|
||||||
storage: storage,
|
|
||||||
dialectOptions: {
|
|
||||||
encrypt: encrypt
|
|
||||||
},
|
|
||||||
pool: {
|
|
||||||
max: 32,
|
|
||||||
min: 8,
|
|
||||||
idle: 40000,
|
|
||||||
evict: 40000,
|
|
||||||
acquire: 40000
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (this.dialect === "mssql") {
|
const logging: any =
|
||||||
this.queryGenerator = this.sequelize.getQueryInterface().QueryGenerator;
|
GBConfigService.get('STORAGE_LOGGING') === 'true'
|
||||||
this.createTableQuery = this.queryGenerator.createTableQuery;
|
? (str: string): void => {
|
||||||
this.queryGenerator.createTableQuery = (
|
logger.info(str);
|
||||||
tableName,
|
}
|
||||||
attributes,
|
: false;
|
||||||
options
|
|
||||||
) => this.createTableQueryOverride(tableName, attributes, options);
|
const encrypt: boolean =
|
||||||
this.changeColumnQuery = this.queryGenerator.changeColumnQuery;
|
GBConfigService.get('STORAGE_ENCRYPT') === 'true';
|
||||||
this.queryGenerator.changeColumnQuery = (tableName, attributes) =>
|
|
||||||
this.changeColumnQueryOverride(tableName, attributes);
|
this.sequelize = new Sequelize({
|
||||||
|
host: host,
|
||||||
|
database: database,
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
logging: logging,
|
||||||
|
operatorsAliases: false,
|
||||||
|
dialect: this.dialect,
|
||||||
|
storage: storage,
|
||||||
|
dialectOptions: {
|
||||||
|
encrypt: encrypt,
|
||||||
|
},
|
||||||
|
pool: {
|
||||||
|
max: 32,
|
||||||
|
min: 8,
|
||||||
|
idle: 40000,
|
||||||
|
evict: 40000,
|
||||||
|
acquire: 40000,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.dialect === 'mssql') {
|
||||||
|
this.queryGenerator = this.sequelize.getQueryInterface().QueryGenerator;
|
||||||
|
this.createTableQuery = this.queryGenerator.createTableQuery;
|
||||||
|
this.queryGenerator.createTableQuery = (
|
||||||
|
tableName,
|
||||||
|
attributes,
|
||||||
|
options,
|
||||||
|
) => this.createTableQueryOverride(tableName, attributes, options);
|
||||||
|
this.changeColumnQuery = this.queryGenerator.changeColumnQuery;
|
||||||
|
this.queryGenerator.changeColumnQuery = (tableName, attributes) =>
|
||||||
|
this.changeColumnQueryOverride(tableName, attributes);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
}
|
}
|
||||||
resolve();
|
},
|
||||||
} catch (error) {
|
);
|
||||||
reject(error);
|
}
|
||||||
}
|
|
||||||
});
|
public async syncDatabaseStructure() {
|
||||||
|
if (GBConfigService.get('STORAGE_SYNC') === 'true') {
|
||||||
|
const alter = GBConfigService.get('STORAGE_SYNC_ALTER') === 'true';
|
||||||
|
const force = GBConfigService.get('STORAGE_SYNC_FORCE') === 'true';
|
||||||
|
logger.info('Syncing database...');
|
||||||
|
return this.sequelize.sync({
|
||||||
|
alter: alter,
|
||||||
|
force: force,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const msg = 'Database synchronization is disabled.';
|
||||||
|
logger.info(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all items to start several listeners.
|
||||||
|
*/
|
||||||
|
public async loadInstances(): Promise<IGBInstance> {
|
||||||
|
return GuaribasInstance.findAll({});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads just one Bot instance by its internal Id.
|
||||||
|
*/
|
||||||
|
public async loadInstanceById(instanceId: string): Promise<IGBInstance> {
|
||||||
|
const options = { where: { instanceId: instanceId } };
|
||||||
|
return GuaribasInstance.findOne(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads just one Bot instance.
|
||||||
|
*/
|
||||||
|
public async loadInstance(botId: string): Promise<IGBInstance> {
|
||||||
|
const options = { where: {} };
|
||||||
|
|
||||||
|
if (botId !== '[default]') {
|
||||||
|
options.where = { botId: botId };
|
||||||
|
}
|
||||||
|
|
||||||
|
return GuaribasInstance.findOne(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async writeEnv(instance: IGBInstance) {
|
||||||
|
const env =
|
||||||
|
`ADDITIONAL_DEPLOY_PATH=\n` +
|
||||||
|
`ADMIN_PASS=${instance.adminPass}\n` +
|
||||||
|
`CLOUD_SUBSCRIPTIONID=${instance.cloudSubscriptionId}\n` +
|
||||||
|
`CLOUD_LOCATION=${instance.cloudLocation}\n` +
|
||||||
|
`CLOUD_GROUP=${instance.botId}\n` +
|
||||||
|
`CLOUD_USERNAME=${instance.cloudUsername}\n` +
|
||||||
|
`CLOUD_PASSWORD=${instance.cloudPassword}\n` +
|
||||||
|
`MARKETPLACE_ID=${instance.marketplaceId}\n` +
|
||||||
|
`MARKETPLACE_SECRET=${instance.marketplacePassword}\n` +
|
||||||
|
`NLP_AUTHORING_KEY=${instance.nlpAuthoringKey}\n` +
|
||||||
|
`STORAGE_DIALECT=${instance.storageDialect}\n` +
|
||||||
|
`STORAGE_SERVER=${instance.storageServer}.database.windows.net\n` +
|
||||||
|
`STORAGE_NAME=${instance.storageName}\n` +
|
||||||
|
`STORAGE_USERNAME=${instance.storageUsername}\n` +
|
||||||
|
`STORAGE_PASSWORD=${instance.storagePassword}\n` +
|
||||||
|
`STORAGE_SYNC=true\n`;
|
||||||
|
|
||||||
|
fs.writeFileSync('.env', env);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ensureProxy(port): Promise<string> {
|
||||||
|
let proxyAddress: string;
|
||||||
|
const ngrok = require('ngrok');
|
||||||
|
return await ngrok.connect({ port: port });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,7 +257,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
let sql: string = this.createTableQuery.apply(this.queryGenerator, [
|
let sql: string = this.createTableQuery.apply(this.queryGenerator, [
|
||||||
tableName,
|
tableName,
|
||||||
attributes,
|
attributes,
|
||||||
options
|
options,
|
||||||
]);
|
]);
|
||||||
const re1 = /CREATE\s+TABLE\s+\[([^\]]*)\]/;
|
const re1 = /CREATE\s+TABLE\s+\[([^\]]*)\]/;
|
||||||
const matches = re1.exec(sql);
|
const matches = re1.exec(sql);
|
||||||
|
@ -194,8 +267,8 @@ export class GBCoreService implements IGBCoreService {
|
||||||
sql = sql.replace(
|
sql = sql.replace(
|
||||||
re2,
|
re2,
|
||||||
(match: string, ...args: any[]): string => {
|
(match: string, ...args: any[]): string => {
|
||||||
return "CONSTRAINT [" + table + "_pk] " + match;
|
return 'CONSTRAINT [' + table + '_pk] ' + match;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
const re3 = /FOREIGN\s+KEY\s+\((\[[^\]]*\](?:,\s*\[[^\]]*\])*)\)/g;
|
const re3 = /FOREIGN\s+KEY\s+\((\[[^\]]*\](?:,\s*\[[^\]]*\])*)\)/g;
|
||||||
const re4 = /\[([^\]]*)\]/g;
|
const re4 = /\[([^\]]*)\]/g;
|
||||||
|
@ -206,11 +279,11 @@ export class GBCoreService implements IGBCoreService {
|
||||||
let fkname = table;
|
let fkname = table;
|
||||||
let matches = re4.exec(fkcols);
|
let matches = re4.exec(fkcols);
|
||||||
while (matches != null) {
|
while (matches != null) {
|
||||||
fkname += "_" + matches[1];
|
fkname += '_' + matches[1];
|
||||||
matches = re4.exec(fkcols);
|
matches = re4.exec(fkcols);
|
||||||
}
|
}
|
||||||
return "CONSTRAINT [" + fkname + "_fk] FOREIGN KEY (" + fkcols + ")";
|
return 'CONSTRAINT [' + fkname + '_fk] FOREIGN KEY (' + fkcols + ')';
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return sql;
|
return sql;
|
||||||
|
@ -227,7 +300,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
private changeColumnQueryOverride(tableName, attributes): string {
|
private changeColumnQueryOverride(tableName, attributes): string {
|
||||||
let sql: string = this.changeColumnQuery.apply(this.queryGenerator, [
|
let sql: string = this.changeColumnQuery.apply(this.queryGenerator, [
|
||||||
tableName,
|
tableName,
|
||||||
attributes
|
attributes,
|
||||||
]);
|
]);
|
||||||
const re1 = /ALTER\s+TABLE\s+\[([^\]]*)\]/;
|
const re1 = /ALTER\s+TABLE\s+\[([^\]]*)\]/;
|
||||||
const matches = re1.exec(sql);
|
const matches = re1.exec(sql);
|
||||||
|
@ -242,91 +315,20 @@ export class GBCoreService implements IGBCoreService {
|
||||||
let fkname = table;
|
let fkname = table;
|
||||||
let matches = re3.exec(fkcols);
|
let matches = re3.exec(fkcols);
|
||||||
while (matches != null) {
|
while (matches != null) {
|
||||||
fkname += "_" + matches[1];
|
fkname += '_' + matches[1];
|
||||||
matches = re3.exec(fkcols);
|
matches = re3.exec(fkcols);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
(args[0] ? args[0] : "") +
|
(args[0] ? args[0] : '') +
|
||||||
"CONSTRAINT [" +
|
'CONSTRAINT [' +
|
||||||
fkname +
|
fkname +
|
||||||
"_fk] FOREIGN KEY (" +
|
'_fk] FOREIGN KEY (' +
|
||||||
fkcols +
|
fkcols +
|
||||||
")"
|
')'
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
async syncDatabaseStructure() {
|
|
||||||
if (GBConfigService.get("STORAGE_SYNC") === "true") {
|
|
||||||
const alter = GBConfigService.get("STORAGE_SYNC_ALTER") === "true";
|
|
||||||
const force = GBConfigService.get("STORAGE_SYNC_FORCE") === "true";
|
|
||||||
logger.info("Syncing database...");
|
|
||||||
return this.sequelize.sync({
|
|
||||||
alter: alter,
|
|
||||||
force: force
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
let msg = "Database synchronization is disabled.";
|
|
||||||
logger.info(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads all items to start several listeners.
|
|
||||||
*/
|
|
||||||
async loadInstances(): Promise<IGBInstance> {
|
|
||||||
return GuaribasInstance.findAll({});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads just one Bot instance by its internal Id.
|
|
||||||
*/
|
|
||||||
async loadInstanceById(instanceId: string): Promise<IGBInstance> {
|
|
||||||
let options = { where: { instanceId: instanceId } };
|
|
||||||
return GuaribasInstance.findOne(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads just one Bot instance.
|
|
||||||
*/
|
|
||||||
async loadInstance(botId: string): Promise<IGBInstance> {
|
|
||||||
let options = { where: {} };
|
|
||||||
|
|
||||||
if (botId != "[default]") {
|
|
||||||
options.where = { botId: botId };
|
|
||||||
}
|
|
||||||
|
|
||||||
return GuaribasInstance.findOne(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async writeEnv(instance: IGBInstance) {
|
|
||||||
let env =
|
|
||||||
`ADDITIONAL_DEPLOY_PATH=\n` +
|
|
||||||
`ADMIN_PASS=${instance.adminPass}\n` +
|
|
||||||
`CLOUD_SUBSCRIPTIONID=${instance.cloudSubscriptionId}\n` +
|
|
||||||
`CLOUD_LOCATION=${instance.cloudLocation}\n` +
|
|
||||||
`CLOUD_GROUP=${instance.botId}\n` +
|
|
||||||
`CLOUD_USERNAME=${instance.cloudUsername}\n` +
|
|
||||||
`CLOUD_PASSWORD=${instance.cloudPassword}\n` +
|
|
||||||
`MARKETPLACE_ID=${instance.marketplaceId}\n`+
|
|
||||||
`MARKETPLACE_SECRET=${instance.marketplacePassword}\n`+
|
|
||||||
`NLP_AUTHORING_KEY=${instance.nlpAuthoringKey}\n`+
|
|
||||||
`STORAGE_DIALECT=${instance.storageDialect}\n` +
|
|
||||||
`STORAGE_SERVER=${instance.storageServer}.database.windows.net\n` +
|
|
||||||
`STORAGE_NAME=${instance.storageName}\n` +
|
|
||||||
`STORAGE_USERNAME=${instance.storageUsername}\n` +
|
|
||||||
`STORAGE_PASSWORD=${instance.storagePassword}\n` +
|
|
||||||
`STORAGE_SYNC=true\n`;
|
|
||||||
|
|
||||||
fs.writeFileSync(".env", env);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async ensureProxy(port): Promise<string> {
|
|
||||||
let proxyAddress: string;
|
|
||||||
const ngrok = require("ngrok");
|
|
||||||
return await ngrok.connect({port:port});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
const Path = require("path");
|
const Path = require("path");
|
||||||
|
@ -72,7 +76,7 @@ export class GBDeployer {
|
||||||
appPackages: Array<IGBPackage>
|
appPackages: Array<IGBPackage>
|
||||||
) {
|
) {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve: any, reject: any): any => {
|
||||||
let totalPackages = 0;
|
let totalPackages = 0;
|
||||||
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
|
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
|
||||||
let paths = [GBDeployer.deployFolder];
|
let paths = [GBDeployer.deployFolder];
|
||||||
|
|
|
@ -31,7 +31,11 @@
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
import Fs = require("fs")
|
import Fs = require("fs")
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const { DialogSet, TextPrompt } = require("botbuilder-dialogs");
|
const { DialogSet, TextPrompt } = require("botbuilder-dialogs");
|
||||||
const UrlJoin = require("url-join");
|
const UrlJoin = require("url-join");
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { CSService } from "../services/CSService";
|
import { CSService } from "../services/CSService";
|
||||||
import { AzureText } from "pragmatismo-io-framework";
|
import { AzureText } from "pragmatismo-io-framework";
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { IGBDialog } from "botlib";
|
import { IGBDialog } from "botlib";
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
import { GuaribasQuestionAlternate } from './models/index'
|
import { GuaribasQuestionAlternate } from './models/index'
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DataTypes,
|
DataTypes,
|
||||||
|
|
|
@ -318,7 +318,7 @@ class GBUIApp extends React.Component {
|
||||||
gbCss = <GBCss instance={this.state.instance} />;
|
gbCss = <GBCss instance={this.state.instance} />;
|
||||||
|
|
||||||
function getToken() {
|
function getToken() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve: any, reject: any): any => {
|
||||||
resolve(token);
|
resolve(token);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
import { IGBDialog } from "botlib";
|
import { IGBDialog } from "botlib";
|
||||||
import { AzureText } from "pragmatismo-io-framework";
|
import { AzureText } from "pragmatismo-io-framework";
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
import { KBService } from './../services/KBService'
|
import { KBService } from './../services/KBService'
|
||||||
import { IGBDialog } from "botlib"
|
import { IGBDialog } from "botlib"
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -30,85 +30,85 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
import {
|
*/
|
||||||
DataTypes,
|
|
||||||
DataTypeUUIDv4,
|
'use strict';
|
||||||
DataTypeDate,
|
|
||||||
DataTypeDecimal
|
|
||||||
} from "sequelize"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AutoIncrement,
|
||||||
|
BelongsTo,
|
||||||
|
Column,
|
||||||
|
CreatedAt,
|
||||||
|
DataType,
|
||||||
|
ForeignKey,
|
||||||
|
HasMany,
|
||||||
|
HasOne,
|
||||||
|
IsUUID,
|
||||||
|
Length,
|
||||||
|
Model,
|
||||||
|
PrimaryKey,
|
||||||
Sequelize,
|
Sequelize,
|
||||||
Table,
|
Table,
|
||||||
Column,
|
UpdatedAt
|
||||||
Model,
|
} from 'sequelize-typescript';
|
||||||
HasMany,
|
|
||||||
BelongsTo,
|
|
||||||
BelongsToMany,
|
|
||||||
Length,
|
|
||||||
ForeignKey,
|
|
||||||
CreatedAt,
|
|
||||||
UpdatedAt,
|
|
||||||
DataType,
|
|
||||||
IsUUID,
|
|
||||||
PrimaryKey,
|
|
||||||
AutoIncrement,
|
|
||||||
HasOne
|
|
||||||
} from "sequelize-typescript"
|
|
||||||
|
|
||||||
import { GuaribasUser } from "../../security.gblib/models"
|
import {
|
||||||
import { GuaribasInstance, GuaribasPackage } from "../../core.gbapp/models/GBModel"
|
GuaribasInstance,
|
||||||
|
GuaribasPackage
|
||||||
|
} from '../../core.gbapp/models/GBModel';
|
||||||
|
import { GuaribasUser } from '../../security.gblib/models';
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
export class GuaribasSubject extends Model<GuaribasSubject> {
|
export class GuaribasSubject extends Model<GuaribasSubject> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
subjectId: number
|
public subjectId: number;
|
||||||
|
|
||||||
@Column internalId: string
|
@Column public internalId: string;
|
||||||
|
|
||||||
@Column title: string
|
@Column public title: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
@Column description: string
|
@Column
|
||||||
|
public description: string;
|
||||||
|
|
||||||
@Column from: string
|
@Column public from: string;
|
||||||
|
|
||||||
@Column to: string
|
@Column public to: string;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasSubject)
|
@ForeignKey(() => GuaribasSubject)
|
||||||
@Column
|
@Column
|
||||||
parentSubjectId: number
|
public parentSubjectId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasSubject, "parentSubjectId")
|
@BelongsTo(() => GuaribasSubject, 'parentSubjectId')
|
||||||
parentSubject: GuaribasSubject
|
public parentSubject: GuaribasSubject;
|
||||||
|
|
||||||
@HasMany(() => GuaribasSubject, { foreignKey: "parentSubjectId" })
|
@HasMany(() => GuaribasSubject, { foreignKey: 'parentSubjectId' })
|
||||||
childrenSubjects: GuaribasSubject[]
|
public childrenSubjects: GuaribasSubject[];
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number
|
public instanceId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
instance: GuaribasInstance
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasUser)
|
@ForeignKey(() => GuaribasUser)
|
||||||
@Column
|
@Column
|
||||||
responsibleUserId: number
|
public responsibleUserId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasUser)
|
@BelongsTo(() => GuaribasUser)
|
||||||
responsibleUser: GuaribasUser
|
public responsibleUser: GuaribasUser;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column
|
||||||
packageId: number
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
package: GuaribasPackage
|
public package: GuaribasPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
|
@ -116,62 +116,62 @@ export class GuaribasQuestion extends Model<GuaribasQuestion> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
questionId: number
|
public questionId: number;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject1: string
|
public subject1: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject2: string
|
public subject2: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject3: string
|
public subject3: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(64))
|
@Column(DataType.STRING(64))
|
||||||
@Column
|
@Column
|
||||||
subject4: string
|
public subject4: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(1024))
|
@Column(DataType.STRING(1024))
|
||||||
@Column
|
@Column
|
||||||
keywords: string
|
public keywords: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
from: string
|
public from: string;
|
||||||
|
|
||||||
@Column(DataType.STRING(512))
|
@Column(DataType.STRING(512))
|
||||||
to: string
|
public to: string;
|
||||||
|
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
content: string
|
public content: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
createdAt: Date
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedAt: Date
|
public updatedAt: Date;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasAnswer)
|
@ForeignKey(() => GuaribasAnswer)
|
||||||
@Column
|
@Column
|
||||||
answerId: number
|
public answerId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasInstance)
|
@BelongsTo(() => GuaribasInstance)
|
||||||
instance: GuaribasInstance
|
public instance: GuaribasInstance;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column
|
||||||
packageId: number
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
package: GuaribasPackage
|
public package: GuaribasPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Table
|
@Table
|
||||||
|
@ -179,53 +179,52 @@ export class GuaribasAnswer extends Model<GuaribasAnswer> {
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@AutoIncrement
|
@AutoIncrement
|
||||||
@Column
|
@Column
|
||||||
answerId: number
|
public answerId: number;
|
||||||
|
|
||||||
@Length({ min: 0, max: 512 })
|
@Length({ min: 0, max: 512 })
|
||||||
@Column
|
@Column
|
||||||
media: string
|
public media: string;
|
||||||
|
|
||||||
@Length({ min: 0, max: 12 })
|
@Length({ min: 0, max: 12 })
|
||||||
@Column
|
@Column
|
||||||
format: string
|
public format: string;
|
||||||
|
|
||||||
@Column(DataType.TEXT)
|
@Column(DataType.TEXT)
|
||||||
content: string
|
public content: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
createdAt: Date
|
public createdAt: Date;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@UpdatedAt
|
@UpdatedAt
|
||||||
updatedAt: Date
|
public updatedAt: Date;
|
||||||
|
|
||||||
@HasMany(() => GuaribasQuestion)
|
@HasMany(() => GuaribasQuestion)
|
||||||
questions: GuaribasQuestion[]
|
public questions: GuaribasQuestion[];
|
||||||
|
|
||||||
@HasOne(() => GuaribasQuestion)
|
@HasOne(() => GuaribasQuestion)
|
||||||
prev: GuaribasQuestion
|
public prev: GuaribasQuestion;
|
||||||
|
|
||||||
@HasOne(() => GuaribasQuestion)
|
@HasOne(() => GuaribasQuestion)
|
||||||
next: GuaribasQuestion
|
public next: GuaribasQuestion;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasQuestion)
|
@ForeignKey(() => GuaribasQuestion)
|
||||||
@Column
|
@Column
|
||||||
nextId: number
|
public nextId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasQuestion)
|
@ForeignKey(() => GuaribasQuestion)
|
||||||
@Column
|
@Column
|
||||||
prevId: number
|
public prevId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasInstance)
|
@ForeignKey(() => GuaribasInstance)
|
||||||
@Column
|
@Column
|
||||||
instanceId: number
|
public instanceId: number;
|
||||||
|
|
||||||
@ForeignKey(() => GuaribasPackage)
|
@ForeignKey(() => GuaribasPackage)
|
||||||
@Column
|
@Column
|
||||||
packageId: number
|
public packageId: number;
|
||||||
|
|
||||||
@BelongsTo(() => GuaribasPackage)
|
@BelongsTo(() => GuaribasPackage)
|
||||||
package: GuaribasPackage
|
public package: GuaribasPackage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DataTypes,
|
DataTypes,
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict"
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const UrlJoin = require("url-join")
|
const UrlJoin = require("url-join")
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,11 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const logger = require("./logger");
|
const logger = require("./logger");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"no-parameter-properties": false,
|
"no-parameter-properties": false,
|
||||||
"no-reserved-keywords": false,
|
"no-reserved-keywords": false,
|
||||||
"no-unnecessary-class":false,
|
"no-unnecessary-class":false,
|
||||||
|
"no-require-imports": false,
|
||||||
"function-name": false,
|
"function-name": false,
|
||||||
"no-redundant-jsdoc": false,
|
"no-redundant-jsdoc": false,
|
||||||
"no-return-await": false,
|
"no-return-await": false,
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
"no-parameter-reassignment":false,
|
"no-parameter-reassignment":false,
|
||||||
"export-name":false,
|
"export-name":false,
|
||||||
"no-relative-imports": false,
|
"no-relative-imports": false,
|
||||||
|
"no-backbone-get-set-outside-model": false,
|
||||||
"max-line-length": [true,{"limit":80,"ignore-pattern":"^\\s+\\*"}]
|
"max-line-length": [true,{"limit":80,"ignore-pattern":"^\\s+\\*"}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue