Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#4470] Migrate off @azure/ms-rest-js botbuilder-ai #379

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/botbuilder-ai/etc/botbuilder-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import { DialogTurnResult } from 'botbuilder-dialogs';
import { EnumExpression } from 'adaptive-expressions';
import { Expression } from 'adaptive-expressions';
import { IntExpression } from 'adaptive-expressions';
import * as msRest from '@azure/ms-rest-js';
import { NumberExpression } from 'adaptive-expressions';
import { ObjectExpression } from 'adaptive-expressions';
import { Recognizer } from 'botbuilder-dialogs';
import { RecognizerConfiguration } from 'botbuilder-dialogs';
import { RecognizerResult } from 'botbuilder-core';
import { RequestOptionsBase } from '@azure/core-http';
import { ServiceCollection } from 'botbuilder-dialogs-adaptive-runtime-core';
import { StringExpression } from 'adaptive-expressions';
import { TemplateInterface } from 'botbuilder-dialogs';
Expand Down Expand Up @@ -290,7 +290,7 @@ export class LuisComponentRegistration extends ComponentRegistration {
}

// @public
export interface LuisPredictionOptions extends msRest.RequestOptionsBase {
export interface LuisPredictionOptions extends RequestOptionsBase {
bingSpellCheckSubscriptionKey?: string;
includeAllIntents?: boolean;
includeInstanceData?: boolean;
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 @@ -27,13 +27,13 @@
}
},
"dependencies": {
"@azure/cognitiveservices-luis-runtime": "^4.0.0",
"@azure/ms-rest-js": "^2.7.0",
"@azure/core-http": "^3.0.2",
"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",
"botframework-connector": "4.1.6",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
"url-parse": "^1.5.9",
Expand Down
4 changes: 2 additions & 2 deletions libraries/botbuilder-ai/src/luisRecognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import * as msRest from '@azure/ms-rest-js';
import { RequestOptionsBase } from '@azure/core-http';

import Url from 'url-parse';
import { BotTelemetryClient, NullTelemetryClient, RecognizerResult, TurnContext } from 'botbuilder-core';
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface LuisApplication {
*
* Options per LUIS prediction.
*/
export interface LuisPredictionOptions extends msRest.RequestOptionsBase {
export interface LuisPredictionOptions extends RequestOptionsBase {
/**
* If true, return all intents instead of just the top scoring intent.
*/
Expand Down
4 changes: 2 additions & 2 deletions libraries/botbuilder-ai/src/luisRecognizerOptionsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT License.
*/

import * as msRest from '@azure/ms-rest-js';
import { TokenCredentials } from 'botframework-connector';
import * as os from 'os';
import { LuisApplication, LuisRecognizerOptionsV2 } from './luisRecognizer';
import { CompositeChildModel, CompositeEntityModel, EntityModel, LuisResult } from './luisV2-models/luisResult';
Expand Down Expand Up @@ -50,7 +50,7 @@ export class LuisRecognizerV2 extends LuisRecognizerInternal {
// - We have to cast "creds as any" to avoid a build break relating to different versions
// of autorest being used by our various components. This is just a build issue and
// shouldn't effect production bots.
const creds = new msRest.TokenCredentials(application.endpointKey);
const creds = new TokenCredentials(application.endpointKey);
const baseUri = application.endpoint || 'https://westus.api.cognitive.microsoft.com';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.luisClient = new LuisClient(creds as any, baseUri);
Expand Down
46 changes: 46 additions & 0 deletions libraries/botbuilder-ai/src/luisRuntimeClientContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import { ServiceClient, ServiceClientCredentials, ServiceClientOptions } from '@azure/core-http';

/**
* Client for LUIS context
*/
export class LUISRuntimeClientContext extends ServiceClient {
endpoint: string;
credentials: ServiceClientCredentials;

/**
* Initializes a new instance of the LUISRuntimeClientContext class.
*
* @param credentials Subscription credentials which uniquely identify client subscription.
* @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example:
* https://westus.api.cognitive.microsoft.com).
* @param [options] The parameter options
*/
constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions) {
if (endpoint == undefined) {
throw new Error("'endpoint' cannot be null.");
}
if (credentials == undefined) {
throw new Error("'credentials' cannot be null.");
}

if (!options) {
options = {};
}

super(credentials, options);

this.baseUri = '{Endpoint}/luis/v3.0-preview';
this.requestContentType = 'application/json; charset=utf-8';
this.endpoint = endpoint;
this.credentials = credentials;
}
}
20 changes: 10 additions & 10 deletions libraries/botbuilder-ai/src/luisV2-models/luisMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Licensed under the MIT License.
*/

import * as msRest from '@azure/ms-rest-js';
import { CompositeMapper } from '@azure/core-http';

export const IntentModel: msRest.CompositeMapper = {
export const IntentModel: CompositeMapper = {
serializedName: 'IntentModel',
type: {
name: 'Composite',
Expand All @@ -34,7 +34,7 @@ export const IntentModel: msRest.CompositeMapper = {
},
};

export const EntityModel: msRest.CompositeMapper = {
export const EntityModel: CompositeMapper = {
serializedName: 'EntityModel',
type: {
name: 'Composite',
Expand Down Expand Up @@ -77,7 +77,7 @@ export const EntityModel: msRest.CompositeMapper = {
},
};

export const CompositeChildModel: msRest.CompositeMapper = {
export const CompositeChildModel: CompositeMapper = {
serializedName: 'CompositeChildModel',
type: {
name: 'Composite',
Expand All @@ -101,7 +101,7 @@ export const CompositeChildModel: msRest.CompositeMapper = {
},
};

export const CompositeEntityModel: msRest.CompositeMapper = {
export const CompositeEntityModel: CompositeMapper = {
serializedName: 'CompositeEntityModel',
type: {
name: 'Composite',
Expand Down Expand Up @@ -138,7 +138,7 @@ export const CompositeEntityModel: msRest.CompositeMapper = {
},
};

export const Sentiment: msRest.CompositeMapper = {
export const Sentiment: CompositeMapper = {
serializedName: 'Sentiment',
type: {
name: 'Composite',
Expand All @@ -160,7 +160,7 @@ export const Sentiment: msRest.CompositeMapper = {
},
};

export const LuisResult: msRest.CompositeMapper = {
export const LuisResult: CompositeMapper = {
serializedName: 'LuisResult',
type: {
name: 'Composite',
Expand Down Expand Up @@ -244,7 +244,7 @@ export const LuisResult: msRest.CompositeMapper = {
},
};

export const EntityWithScore: msRest.CompositeMapper = {
export const EntityWithScore: CompositeMapper = {
serializedName: 'EntityWithScore',
type: {
name: 'Composite',
Expand All @@ -267,7 +267,7 @@ export const EntityWithScore: msRest.CompositeMapper = {
},
};

export const EntityWithResolution: msRest.CompositeMapper = {
export const EntityWithResolution: CompositeMapper = {
serializedName: 'EntityWithResolution',
type: {
name: 'Composite',
Expand All @@ -286,7 +286,7 @@ export const EntityWithResolution: msRest.CompositeMapper = {
},
};

export const APIError: msRest.CompositeMapper = {
export const APIError: CompositeMapper = {
serializedName: 'APIError',
type: {
name: 'Composite',
Expand Down
18 changes: 9 additions & 9 deletions libraries/botbuilder-ai/src/luisV2-models/luisParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Licensed under the MIT License.
*/

import * as msRest from '@azure/ms-rest-js';
import { OperationURLParameter, OperationQueryParameter } from '@azure/core-http';

export const appId: msRest.OperationURLParameter = {
export const appId: OperationURLParameter = {
parameterPath: 'appId',
mapper: {
required: true,
Expand All @@ -18,7 +18,7 @@ export const appId: msRest.OperationURLParameter = {
},
},
};
export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = {
export const bingSpellCheckSubscriptionKey: OperationQueryParameter = {
parameterPath: ['options', 'bingSpellCheckSubscriptionKey'],
mapper: {
serializedName: 'bing-spell-check-subscription-key',
Expand All @@ -27,7 +27,7 @@ export const bingSpellCheckSubscriptionKey: msRest.OperationQueryParameter = {
},
},
};
export const endpoint: msRest.OperationURLParameter = {
export const endpoint: OperationURLParameter = {
parameterPath: 'endpoint',
mapper: {
required: true,
Expand All @@ -39,7 +39,7 @@ export const endpoint: msRest.OperationURLParameter = {
},
skipEncoding: true,
};
export const log: msRest.OperationQueryParameter = {
export const log: OperationQueryParameter = {
parameterPath: ['options', 'log'],
mapper: {
serializedName: 'log',
Expand All @@ -48,7 +48,7 @@ export const log: msRest.OperationQueryParameter = {
},
},
};
export const spellCheck: msRest.OperationQueryParameter = {
export const spellCheck: OperationQueryParameter = {
parameterPath: ['options', 'spellCheck'],
mapper: {
serializedName: 'spellCheck',
Expand All @@ -57,7 +57,7 @@ export const spellCheck: msRest.OperationQueryParameter = {
},
},
};
export const staging: msRest.OperationQueryParameter = {
export const staging: OperationQueryParameter = {
parameterPath: ['options', 'staging'],
mapper: {
serializedName: 'staging',
Expand All @@ -66,7 +66,7 @@ export const staging: msRest.OperationQueryParameter = {
},
},
};
export const timezoneOffset: msRest.OperationQueryParameter = {
export const timezoneOffset: OperationQueryParameter = {
parameterPath: ['options', 'timezoneOffset'],
mapper: {
serializedName: 'timezoneOffset',
Expand All @@ -75,7 +75,7 @@ export const timezoneOffset: msRest.OperationQueryParameter = {
},
},
};
export const verbose: msRest.OperationQueryParameter = {
export const verbose: OperationQueryParameter = {
parameterPath: ['options', 'verbose'],
mapper: {
serializedName: 'verbose',
Expand Down
16 changes: 8 additions & 8 deletions libraries/botbuilder-ai/src/luisV2-models/luisPrediction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Licensed under the MIT License.
*/

import * as msRest from '@azure/ms-rest-js';
import { LUISRuntimeClientContext } from '@azure/cognitiveservices-luis-runtime';
import { ServiceCallback, OperationSpec, Serializer } from '@azure/core-http';
import { LUISRuntimeClientContext } from '../luisRuntimeClientContext';
import { LuisResult, PredictionResolveOptionalParams, PredictionResolveResponse } from './luisResult';
import * as Parameters from './luisParameters';
import * as Mappers from './luisMappers';
Expand Down Expand Up @@ -44,7 +44,7 @@ export class LuisPrediction {
* @param query The utterance to predict.
* @param callback The callback
*/
resolve(appId: string, query: string, callback: msRest.ServiceCallback<LuisResult>): void;
resolve(appId: string, query: string, callback: ServiceCallback<LuisResult>): void;
/**
* @param appId The LUIS application ID (Guid).
* @param query The utterance to predict.
Expand All @@ -55,7 +55,7 @@ export class LuisPrediction {
appId: string,
query: string,
options: PredictionResolveOptionalParams,
callback: msRest.ServiceCallback<LuisResult>
callback: ServiceCallback<LuisResult>
): void;
/**
* @param appId The LUIS application ID (Guid).
Expand All @@ -67,8 +67,8 @@ export class LuisPrediction {
resolve(
appId: string,
query: string,
options?: PredictionResolveOptionalParams | msRest.ServiceCallback<LuisResult>,
callback?: msRest.ServiceCallback<LuisResult>
options?: PredictionResolveOptionalParams | ServiceCallback<LuisResult>,
callback?: ServiceCallback<LuisResult>
): Promise<PredictionResolveResponse> {
return this.client.sendOperationRequest(
{
Expand All @@ -83,8 +83,8 @@ export class LuisPrediction {
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const resolveOperationSpec: msRest.OperationSpec = {
const serializer = new Serializer(Mappers);
const resolveOperationSpec: OperationSpec = {
httpMethod: 'POST',
path: 'apps/{appId}',
urlParameters: [Parameters.endpoint, Parameters.appId],
Expand Down
10 changes: 5 additions & 5 deletions libraries/botbuilder-ai/src/luisV2-models/luisResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Licensed under the MIT License.
*/

import { LUISRuntimeModels as LuisModels } from '@azure/cognitiveservices-luis-runtime';
import * as msRest from '@azure/ms-rest-js';
import { Sentiment } from './sentiment';
import { HttpResponse, RequestOptionsBase } from '@azure/core-http';

/**
* Prediction, based on the input query, containing intent(s) and entities.
Expand Down Expand Up @@ -40,7 +40,7 @@ export interface LuisResult {
/**
* Sentiment of the input utterance.
*/
sentimentAnalysis?: LuisModels.Sentiment;
sentimentAnalysis?: Sentiment;
/**
* Prediction, based on the input query, containing intents and entities.
*/
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface CompositeChildModel {
/**
* Optional Parameters.
*/
export interface PredictionResolveOptionalParams extends msRest.RequestOptionsBase {
export interface PredictionResolveOptionalParams extends RequestOptionsBase {
/**
* The timezone offset for the location of the request.
*/
Expand Down Expand Up @@ -156,7 +156,7 @@ export type PredictionResolveResponse = LuisResult & {
/**
* The underlying HTTP response.
*/
_response: msRest.HttpResponse & {
_response: HttpResponse & {
/**
* The response body as text (string format)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* Licensed under the MIT License.
*/

import * as msRest from '@azure/ms-rest-js';
import { ServiceClientCredentials, ServiceClientOptions } from '@azure/core-http';
import * as Models from './luisResult';
import * as Mappers from './luisMappers';
import { LuisPrediction } from './luisPrediction';
import { LUISRuntimeClientContext } from '@azure/cognitiveservices-luis-runtime';
import { LUISRuntimeClientContext } from '../luisRuntimeClientContext';

/**
* Represents the LUIS client for V2 of the runtime.
Expand All @@ -29,7 +29,7 @@ class LUISRuntimeClientV2 extends LUISRuntimeClientContext {
* https://westus.api.cognitive.microsoft.com).
* @param [options] The parameter options
*/
constructor(credentials: msRest.ServiceClientCredentials, endpoint: string, options?: msRest.ServiceClientOptions) {
constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions) {
super(credentials, endpoint, options);
this.prediction = new LuisPrediction(this);
super.baseUri = '{Endpoint}/luis/v2.0';
Expand Down
Loading
Loading