Skip to content

Commit

Permalink
fix: [#4204] Fix remaining eslint warnings - botbuilder-ai (#4236)
Browse files Browse the repository at this point in the history
* Fix eslint issues in botbuilder-ai

* Update botbuilder-ai compat

* Fix eslint disable rule

* ammend

* Revert "Fix eslint disable rule"

This reverts commit 36bef89.

* Commit reverted.

Co-authored-by: Emiliano Quiroga <emiliano.quiroga@7-11.com>
  • Loading branch information
sw-joelmut and Emiliano Quiroga authored Jul 13, 2022
1 parent 5c1d429 commit 0148107
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 18 deletions.
10 changes: 2 additions & 8 deletions libraries/botbuilder-ai/etc/botbuilder-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ export class CustomQuestionAnswering implements QnAMakerClient_2, QnAMakerTeleme
[key: string]: number;
}): Promise<QnAMakerResults>;
getLowScoreVariation(queryResult: QnAMakerResult[]): QnAMakerResult[];
// (undocumented)
get logPersonalInformation(): boolean;
protected onQnaResults(qnaResults: QnAMakerResult[], turnContext: TurnContext, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
}): Promise<void>;
// (undocumented)
get telemetryClient(): BotTelemetryClient;
}

Expand Down Expand Up @@ -278,7 +276,7 @@ export interface LuisApplication {
endpointKey: string;
}

// @public (undocumented)
// @public
export class LuisBotComponent extends BotComponent {
// (undocumented)
configureServices(services: ServiceCollection, _configuration: Configuration): void;
Expand Down Expand Up @@ -313,7 +311,6 @@ export class LuisRecognizer implements LuisRecognizerTelemetryClient {
}): Promise<{
[key: string]: string;
}>;
// (undocumented)
get logPersonalInformation(): boolean;
protected onRecognizerResults(recognizerResult: RecognizerResult, turnContext: TurnContext, telemetryProperties?: {
[key: string]: string;
Expand All @@ -326,7 +323,6 @@ export class LuisRecognizer implements LuisRecognizerTelemetryClient {
intent: string;
score: number;
}>;
// (undocumented)
get telemetryClient(): BotTelemetryClient;
static topIntent(results?: RecognizerResult, defaultIntent?: string, minScore?: number): string;
}
Expand Down Expand Up @@ -460,14 +456,12 @@ export class QnAMaker implements QnAMakerClient, QnAMakerTelemetryClient {
[key: string]: number;
}): Promise<QnAMakerResults>;
getLowScoreVariation(queryResult: QnAMakerResult[]): QnAMakerResult[];
// (undocumented)
get logPersonalInformation(): boolean;
protected onQnaResults(qnaResults: QnAMakerResult[], turnContext: TurnContext, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
}): Promise<void>;
// (undocumented)
get telemetryClient(): BotTelemetryClient;
}

Expand All @@ -480,7 +474,7 @@ export const QNAMAKER_TRACE_NAME = "QnAMaker";
// @public (undocumented)
export const QNAMAKER_TRACE_TYPE = "https://www.qnamaker.ai/schemas/trace";

// @public (undocumented)
// @public
export class QnAMakerBotComponent extends BotComponent {
// (undocumented)
configureServices(services: ServiceCollection, _configuration: Configuration): void;
Expand Down
4 changes: 2 additions & 2 deletions libraries/botbuilder-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"@azure/cognitiveservices-luis-runtime": "2.0.0",
"@azure/ms-rest-js": "1.9.1",
"adaptive-expressions": "4.1.6",
"botbuilder-core": "4.1.6",
"botbuilder-dialogs": "4.1.6",
"botbuilder-dialogs-adaptive-runtime-core": "4.1.6",
"botbuilder-dialogs-declarative": "4.1.6",
"lodash": "^4.17.21",
Expand All @@ -42,8 +44,6 @@
},
"devDependencies": {
"@types/node-fetch": "^2.5.7",
"botbuilder-core": "4.1.6",
"botbuilder-dialogs": "4.1.6",
"fs-extra": "^7.0.1",
"nock": "^11.9.1"
},
Expand Down
12 changes: 10 additions & 2 deletions libraries/botbuilder-ai/src/customQuestionAnswering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,20 @@ export class CustomQuestionAnswering implements QnAMakerClient, QnAMakerTelemetr
this._logPersonalInformation = logPersonalInformation || false;
}

// Gets a value indicating whether determines whether to log personal information that came from the user.
/**
* Gets a value indicating whether determines whether to log personal information that came from the user.
*
* @returns True to determine whether to log personal information that came from the user; otherwise, false.
*/
get logPersonalInformation(): boolean {
return this._logPersonalInformation;
}

// Gets the currently configured botTelemetryClient that logs the events.
/**
* Gets the currently configured BotTelemetryClient that logs the events.
*
* @returns Currently configured BotTelemetryClient that logs the events.
*/
get telemetryClient(): BotTelemetryClient {
return this._telemetryClient;
}
Expand Down
10 changes: 9 additions & 1 deletion libraries/botbuilder-ai/src/luisAdaptivePredictionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ export interface LuisAdaptivePredictionOptionsConfiguration {
*/
slot?: string | Expression | StringExpression;
}

/**
* Converts optional parameters for a LUIS prediction request.
*/
export class LuisAdaptivePredictionOptionsConverter
implements Converter<LuisAdaptivePredictionOptionsConfiguration, LuisAdaptivePredictionOptions> {
/**
* Converts the provided options configuration into an object of [LuisAdaptivePredictionOptions](xref:botbuilder-ai.LuisAdaptivePredictionOptions) type.
*
* @param config Options configuration for LuisAdaptivePredictionOptions.
* @returns The converted options configuration to the [LuisAdaptivePredictionOptions](xref:botbuilder-ai.LuisAdaptivePredictionOptions) interface.
*/
convert(config: LuisAdaptivePredictionOptionsConfiguration): LuisAdaptivePredictionOptions {
const options = Object.entries(config).reduce((options: LuisAdaptivePredictionOptions, [key, value]) => {
switch (key) {
Expand Down
4 changes: 4 additions & 0 deletions libraries/botbuilder-ai/src/luisAdaptiveRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export class LuisAdaptiveRecognizer extends Recognizer implements LuisAdaptiveRe
'=settings.runtimeSettings.telemetry.logPersonalInformation'
);

/**
* @param property Properties that extend RecognizerConfiguration.
* @returns Expression converter.
*/
getConverter(property: keyof LuisAdaptiveRecognizerConfiguration): Converter | ConverterFactory {
switch (property) {
case 'applicationId':
Expand Down
7 changes: 7 additions & 0 deletions libraries/botbuilder-ai/src/luisBotComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import { ComponentDeclarativeTypes } from 'botbuilder-dialogs-declarative';
import { Configuration, ServiceCollection } from 'botbuilder-dialogs-adaptive-runtime-core';
import { LuisAdaptiveRecognizer } from './luisAdaptiveRecognizer';

/**
*LUIS @see cref="BotComponent" definition.
*/
export class LuisBotComponent extends BotComponent {
/**
* @param services Services collection to register dependency injection.
* @param _configuration Configuration for the bot component.
*/
configureServices(services: ServiceCollection, _configuration: Configuration): void {
services.composeFactory<ComponentDeclarativeTypes[]>('declarativeTypes', (declarativeTypes) =>
declarativeTypes.concat({
Expand Down
3 changes: 3 additions & 0 deletions libraries/botbuilder-ai/src/luisComponentRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class LuisComponentRegistration extends ComponentRegistration {
declarativeTypes: [],
});

/**
* Define component assets for Luis.
*/
constructor() {
super();

Expand Down
12 changes: 10 additions & 2 deletions libraries/botbuilder-ai/src/luisRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,20 @@ export class LuisRecognizer implements LuisRecognizerTelemetryClient {
}
}

// Gets a value indicating whether determines whether to log personal information that came from the user.
/**
* Gets a value indicating whether determines whether to log personal information that came from the user.
*
* @returns True if will log personal information into the BotTelemetryClient.TrackEvent method; otherwise the properties will be filtered.
*/
get logPersonalInformation(): boolean {
return this._logPersonalInformation;
}

// Gets the currently configured botTelemetryClient that logs the events.
/**
* Gets the currently configured BotTelemetryClient that logs the events.
*
* @returns Currently configured BotTelemetryClient that logs the LuisResult event.
*/
get telemetryClient(): BotTelemetryClient {
return this._telemetryClient;
}
Expand Down
14 changes: 11 additions & 3 deletions libraries/botbuilder-ai/src/qnaMaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class QnAMaker implements QnAMakerClient, QnAMakerTelemetryClient {
* @param {QnAMakerEndpoint} endpoint The endpoint of the knowledge base to query.
* @param {QnAMakerOptions} options (Optional) additional settings used to configure the instance.
* @param {BotTelemetryClient} telemetryClient The BotTelemetryClient used for logging telemetry events.
* @param {boolean} logPersonalInformation Set to true to include personally indentifiable information in telemetry events.
* @param {boolean} logPersonalInformation Set to true to include personally identifiable information in telemetry events.
*/
constructor(
private readonly endpoint: QnAMakerEndpoint,
Expand Down Expand Up @@ -179,12 +179,20 @@ export class QnAMaker implements QnAMakerClient, QnAMakerTelemetryClient {
this._logPersonalInformation = logPersonalInformation || false;
}

// Gets a value indicating whether determines whether to log personal information that came from the user.
/**
* Gets a value indicating whether determines whether to log personal information that came from the user.
*
* @returns True if will log personal information into the BotTelemetryClient.TrackEvent method; otherwise the properties will be filtered.
*/
get logPersonalInformation(): boolean {
return this._logPersonalInformation;
}

// Gets the currently configured botTelemetryClient that logs the events.
/**
* Gets the currently configured BotTelemetryClient that logs the events.
*
* @returns The currently configured BotTelemetryClient that logs the QnaMessage event.
*/
get telemetryClient(): BotTelemetryClient {
return this._telemetryClient;
}
Expand Down
7 changes: 7 additions & 0 deletions libraries/botbuilder-ai/src/qnaMakerBotComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import { Configuration, ServiceCollection } from 'botbuilder-dialogs-adaptive-ru
import { QnAMakerDialog } from './qnaMakerDialog';
import { QnAMakerRecognizer } from './qnaMakerRecognizer';

/**
* Class which contains registration of components for QnAMaker.
*/
export class QnAMakerBotComponent extends BotComponent {
/**
* @param services Services collection to mimic dependency injection.
* @param _configuration Configuration for the bot component.
*/
configureServices(services: ServiceCollection, _configuration: Configuration): void {
services.composeFactory<ComponentDeclarativeTypes[]>('declarativeTypes', (declarativeTypes) =>
declarativeTypes.concat({
Expand Down
3 changes: 3 additions & 0 deletions libraries/botbuilder-ai/src/qnaMakerComponentRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class QnAMakerComponentRegistration extends ComponentRegistration {
declarativeTypes: [],
});

/**
* Create an instance of QnAMakerComponentRegistration.
*/
constructor() {
super();

Expand Down
4 changes: 4 additions & 0 deletions libraries/botbuilder-ai/src/qnaMakerDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ export class QnAMakerDialog extends WaterfallDialog implements QnAMakerDialogCon
this.addStep(this.displayQnAResult.bind(this));
}

/**
* @param property Properties that extend QnAMakerDialogConfiguration.
* @returns The expression converter.
*/
getConverter(property: keyof QnAMakerDialogConfiguration): Converter | ConverterFactory {
switch (property) {
case 'knowledgeBaseId':
Expand Down
4 changes: 4 additions & 0 deletions libraries/botbuilder-ai/src/qnaMakerRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export class QnAMakerRecognizer extends Recognizer implements QnAMakerRecognizer
'=settings.runtimeSettings.telemetry.logPersonalInformation'
);

/**
* @param property Properties that extend QnAMakerRecognizerConfiguration.
* @returns The expression converter.
*/
getConverter(property: keyof QnAMakerRecognizerConfiguration): Converter | ConverterFactory {
switch (property) {
case 'knowledgeBaseId':
Expand Down
16 changes: 16 additions & 0 deletions libraries/botbuilder-ai/src/qnamaker-utils/bindToActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,25 @@
import { Activity } from 'botbuilder-core';
import { DialogContext, TemplateInterface } from 'botbuilder-dialogs';

/**
* Creates a new template to send the user based on the activity.
*/
export class BindToActivity implements TemplateInterface<Partial<Activity>> {
/**
* Initializes a new instance of the [BindToActivity](xref:botbuilder-ai.BindToActivity) class.
*
* @param activity The activity to send the user.
* @returns Template to send the user.
*/
constructor(private readonly activity: Partial<Activity>) {}

/**
* Binds the provided activity.
*
* @param _context The dialog context.
* @param _data Data to bind to. If Null, then dc.State will be used.
* @returns The linked activity.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
async bind(_context: DialogContext, _data?: object): Promise<Partial<Activity>> {
return this.activity;
Expand Down

0 comments on commit 0148107

Please sign in to comment.