Rename _this and update package.json
This commit is contained in:
parent
b122882aac
commit
af7db2246d
6 changed files with 6164 additions and 33 deletions
|
@ -75,15 +75,15 @@ export class ConsoleDirectLine extends GBService {
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Remove *this* issue.
|
// TODO: Remove *this* issue.
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
directLineClient.then(function (client) {
|
directLineClient.then(function (client) {
|
||||||
client.Conversations.Conversations_StartConversation()
|
client.Conversations.Conversations_StartConversation()
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
return response.obj.conversationId;
|
return response.obj.conversationId;
|
||||||
})
|
})
|
||||||
.then(function (conversationId) {
|
.then(function (conversationId) {
|
||||||
_this.sendMessagesFromConsole(client, conversationId);
|
_this_.sendMessagesFromConsole(client, conversationId);
|
||||||
_this.pollMessages(client, conversationId);
|
_this_.pollMessages(client, conversationId);
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
console.error('Error starting conversation', err);
|
console.error('Error starting conversation', err);
|
||||||
|
@ -92,8 +92,9 @@ export class ConsoleDirectLine extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessagesFromConsole(client, conversationId) {
|
sendMessagesFromConsole(client, conversationId) {
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
var stdin = process.openStdin();
|
process.stdin.resume();
|
||||||
|
var stdin = process.stdin;
|
||||||
process.stdout.write('Command> ');
|
process.stdout.write('Command> ');
|
||||||
stdin.addListener('data', function (e) {
|
stdin.addListener('data', function (e) {
|
||||||
var input = e.toString().trim();
|
var input = e.toString().trim();
|
||||||
|
@ -111,8 +112,8 @@ export class ConsoleDirectLine extends GBService {
|
||||||
text: input,
|
text: input,
|
||||||
type: 'message',
|
type: 'message',
|
||||||
from: {
|
from: {
|
||||||
id: _this.directLineClientName,
|
id: _this_.directLineClientName,
|
||||||
name: _this.directLineClientName
|
name: _this_.directLineClientName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
@ -126,7 +127,7 @@ export class ConsoleDirectLine extends GBService {
|
||||||
|
|
||||||
/** TBD: Poll Messages from conversation using DirectLine client */
|
/** TBD: Poll Messages from conversation using DirectLine client */
|
||||||
pollMessages(client, conversationId) {
|
pollMessages(client, conversationId) {
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
console.log('Starting polling message for conversationId: ' + conversationId);
|
console.log('Starting polling message for conversationId: ' + conversationId);
|
||||||
var watermark = null;
|
var watermark = null;
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
|
@ -135,7 +136,7 @@ export class ConsoleDirectLine extends GBService {
|
||||||
watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages
|
watermark = response.obj.watermark; // use watermark so subsequent requests skip old messages
|
||||||
return response.obj.activities;
|
return response.obj.activities;
|
||||||
})
|
})
|
||||||
.then(_this.printMessages, _this.directLineClientName);
|
.then(_this_.printMessages, _this_.directLineClientName);
|
||||||
}, this.pollInterval);
|
}, this.pollInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +194,6 @@ export class ConsoleDirectLine extends GBService {
|
||||||
console.log('*'.repeat(width + 1) + '/');
|
console.log('*'.repeat(width + 1) + '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -63,7 +63,7 @@ export class GBImporter {
|
||||||
localPath: string,
|
localPath: string,
|
||||||
cb: GBServiceCallback<IGBInstance>
|
cb: GBServiceCallback<IGBInstance>
|
||||||
) {
|
) {
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
|
|
||||||
let packageJson = JSON.parse(
|
let packageJson = JSON.parse(
|
||||||
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")
|
Fs.readFileSync(UrlJoin(localPath, "package.json"), "utf8")
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class GBMinService {
|
||||||
|
|
||||||
buildMin(cb: GBServiceCallback<GBMinInstance>, server: any, appPackages: Array<IGBPackage>) {
|
buildMin(cb: GBServiceCallback<GBMinInstance>, server: any, appPackages: Array<IGBPackage>) {
|
||||||
|
|
||||||
var _this = this;
|
var _this_ = this;
|
||||||
|
|
||||||
// Serves default UI on root address '/'.
|
// Serves default UI on root address '/'.
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export class GBMinService {
|
||||||
|
|
||||||
// Loads all bot instances from storage.
|
// Loads all bot instances from storage.
|
||||||
|
|
||||||
_this.core.loadInstances((instances: IGBInstance[], err) => {
|
_this_.core.loadInstances((instances: IGBInstance[], err) => {
|
||||||
|
|
||||||
// Gets the authorization key for each instance from Bot Service.
|
// Gets the authorization key for each instance from Bot Service.
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ export class GBMinService {
|
||||||
// Returns the instance object to clients requesting bot info.
|
// Returns the instance object to clients requesting bot info.
|
||||||
|
|
||||||
let botId = req.params.botId;
|
let botId = req.params.botId;
|
||||||
_this.core.loadInstance(
|
_this_.core.loadInstance(
|
||||||
botId,
|
botId,
|
||||||
(instance: IGBInstance, err) => {
|
(instance: IGBInstance, err) => {
|
||||||
if (instance) {
|
if (instance) {
|
||||||
|
@ -154,9 +154,9 @@ export class GBMinService {
|
||||||
|
|
||||||
let min = new GBMinInstance();
|
let min = new GBMinInstance();
|
||||||
min.botId = instance.botId;
|
min.botId = instance.botId;
|
||||||
min.core = _this.core;
|
min.core = _this_.core;
|
||||||
min.conversationalService = _this.conversationalService;
|
min.conversationalService = _this_.conversationalService;
|
||||||
_this.core.loadInstance(min.botId, (data, err) => {
|
_this_.core.loadInstance(min.botId, (data, err) => {
|
||||||
|
|
||||||
min.instance = data;
|
min.instance = data;
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ export class GBMinService {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
var _this = this;
|
var _this_ = this;
|
||||||
let totalPackages = 0;
|
let totalPackages = 0;
|
||||||
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
|
let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH");
|
||||||
let paths = [this.deployFolder];
|
let paths = [this.deployFolder];
|
||||||
|
@ -387,7 +387,7 @@ export class GBMinService {
|
||||||
|
|
||||||
botPackages.forEach(e => {
|
botPackages.forEach(e => {
|
||||||
logger.trace(`Deploying bot: ${e}...`);
|
logger.trace(`Deploying bot: ${e}...`);
|
||||||
_this.deployer.deployBot(e, (data, err) => {
|
_this_.deployer.deployBot(e, (data, err) => {
|
||||||
logger.trace(`Bot: ${e} deployed...`);
|
logger.trace(`Bot: ${e} deployed...`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,7 +109,7 @@ class GBUIApp extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBotConnection(secret) {
|
setupBotConnection(secret) {
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
window["botchatDebug"] = true;
|
window["botchatDebug"] = true;
|
||||||
|
|
||||||
const botConnection = new DirectLine({
|
const botConnection = new DirectLine({
|
||||||
|
@ -125,7 +125,7 @@ class GBUIApp extends React.Component {
|
||||||
name: "startGB"
|
name: "startGB"
|
||||||
});
|
});
|
||||||
|
|
||||||
_this.setState({ botConnection: botConnection });
|
_this_.setState({ botConnection: botConnection });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -138,22 +138,22 @@ class GBUIApp extends React.Component {
|
||||||
activity.type === "event" && activity.name === "loadInstance"
|
activity.type === "event" && activity.name === "loadInstance"
|
||||||
)
|
)
|
||||||
.subscribe(activity => {
|
.subscribe(activity => {
|
||||||
_this.setState({ instance: activity.value });
|
_this_.setState({ instance: activity.value });
|
||||||
});
|
});
|
||||||
|
|
||||||
botConnection.activity$
|
botConnection.activity$
|
||||||
.filter(activity => activity.type === "event" && activity.name === "stop")
|
.filter(activity => activity.type === "event" && activity.name === "stop")
|
||||||
.subscribe(activity => {
|
.subscribe(activity => {
|
||||||
if (_this.player) {
|
if (_this_.player) {
|
||||||
_this.player.stop();
|
_this_.player.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
botConnection.activity$
|
botConnection.activity$
|
||||||
.filter(activity => activity.type === "event" && activity.name === "play")
|
.filter(activity => activity.type === "event" && activity.name === "play")
|
||||||
.subscribe(activity => {
|
.subscribe(activity => {
|
||||||
_this.setState({ playerType: activity.value.playerType });
|
_this_.setState({ playerType: activity.value.playerType });
|
||||||
_this.player.play(activity.value.data);
|
_this_.player.play(activity.value.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ export class KBService {
|
||||||
|
|
||||||
// Performs search.
|
// Performs search.
|
||||||
|
|
||||||
var _this = this;
|
var _this_ = this;
|
||||||
|
|
||||||
if (instance.searchKey) {
|
if (instance.searchKey) {
|
||||||
let service = new AzureSearch(
|
let service = new AzureSearch(
|
||||||
|
@ -138,7 +138,7 @@ export class KBService {
|
||||||
// Ponders over configuration.
|
// Ponders over configuration.
|
||||||
|
|
||||||
if (results[0]["@search.score"] >= searchScore) {
|
if (results[0]["@search.score"] >= searchScore) {
|
||||||
_this.getAnswerById(
|
_this_.getAnswerById(
|
||||||
instance.instanceId,
|
instance.instanceId,
|
||||||
results[0].answerId,
|
results[0].answerId,
|
||||||
(answer, err) => {
|
(answer, err) => {
|
||||||
|
@ -476,9 +476,9 @@ export class KBService {
|
||||||
UrlJoin(localPath, "subjects.json"),
|
UrlJoin(localPath, "subjects.json"),
|
||||||
instance
|
instance
|
||||||
);
|
);
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
_this.importKbTabularDirectory(
|
_this_.importKbTabularDirectory(
|
||||||
localPath,
|
localPath,
|
||||||
instance,
|
instance,
|
||||||
packageStorage.packageId
|
packageStorage.packageId
|
||||||
|
@ -491,12 +491,12 @@ export class KBService {
|
||||||
instance: IGBInstance,
|
instance: IGBInstance,
|
||||||
packageId: number
|
packageId: number
|
||||||
) {
|
) {
|
||||||
let _this = this;
|
let _this_ = this;
|
||||||
Walk.files(
|
Walk.files(
|
||||||
UrlJoin(localPath, "tabular"),
|
UrlJoin(localPath, "tabular"),
|
||||||
(basedir, filename, stat, next) => {
|
(basedir, filename, stat, next) => {
|
||||||
if (filename.endsWith(".tsv")) {
|
if (filename.endsWith(".tsv")) {
|
||||||
_this.importKbTabularFile(
|
_this_.importKbTabularFile(
|
||||||
basedir,
|
basedir,
|
||||||
filename,
|
filename,
|
||||||
instance.instanceId,
|
instance.instanceId,
|
||||||
|
|
6130
package-lock.json
generated
Normal file
6130
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue