diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/package.json b/sdk/cognitiveservices/cognitiveservices-luis-authoring/package.json index 3c48fe53f88a..e25ad46b9817 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/package.json +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/package.json @@ -2,7 +2,7 @@ "name": "@azure/cognitiveservices-luis-authoring", "author": "Microsoft Corporation", "description": "LUISAuthoringClient Library with typescript type definitions for node.js and browser.", - "version": "4.0.0-preview.2", + "version": "4.0.0-preview.3", "dependencies": { "@azure/ms-rest-js": "^2.0.4", "tslib": "^1.10.0" diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/lUISAuthoringClientContext.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/lUISAuthoringClientContext.ts index c59f53aafcf2..52484b1a316e 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/lUISAuthoringClientContext.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/lUISAuthoringClientContext.ts @@ -11,7 +11,7 @@ import * as msRest from "@azure/ms-rest-js"; const packageName = "@azure/cognitiveservices-luis-authoring"; -const packageVersion = "4.0.0-preview.2"; +const packageVersion = "4.0.0-preview.3"; export class LUISAuthoringClientContext extends msRest.ServiceClient { endpoint: string; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/operations/permissions.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/operations/permissions.ts deleted file mode 100644 index 81a1b15f8103..000000000000 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/src/operations/permissions.ts +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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 * as msRest from "@azure/ms-rest-js"; -import * as Models from "../models"; -import * as Mappers from "../models/permissionsMappers"; -import * as Parameters from "../models/parameters"; -import { LUISAuthoringClientContext } from "../lUISAuthoringClientContext"; - -/** Class representing a Permissions. */ -export class Permissions { - private readonly client: LUISAuthoringClientContext; - - /** - * Create a Permissions. - * @param {LUISAuthoringClientContext} client Reference to the service client. - */ - constructor(client: LUISAuthoringClientContext) { - this.client = client; - } - - /** - * Gets the list of user emails that have permissions to access your application. - * @param appId The application ID. - * @param [options] The optional parameters - * @returns Promise - */ - list(appId: string, options?: msRest.RequestOptionsBase): Promise; - /** - * @param appId The application ID. - * @param callback The callback - */ - list(appId: string, callback: msRest.ServiceCallback): void; - /** - * @param appId The application ID. - * @param options The optional parameters - * @param callback The callback - */ - list(appId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - list(appId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - appId, - options - }, - listOperationSpec, - callback) as Promise; - } - - /** - * Adds a user to the allowed list of users to access this LUIS application. Users are added using - * their email address. - * @param appId The application ID. - * @param userToAdd A model containing the user's email address. - * @param [options] The optional parameters - * @returns Promise - */ - add(appId: string, userToAdd: Models.UserCollaborator, options?: msRest.RequestOptionsBase): Promise; - /** - * @param appId The application ID. - * @param userToAdd A model containing the user's email address. - * @param callback The callback - */ - add(appId: string, userToAdd: Models.UserCollaborator, callback: msRest.ServiceCallback): void; - /** - * @param appId The application ID. - * @param userToAdd A model containing the user's email address. - * @param options The optional parameters - * @param callback The callback - */ - add(appId: string, userToAdd: Models.UserCollaborator, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - add(appId: string, userToAdd: Models.UserCollaborator, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - appId, - userToAdd, - options - }, - addOperationSpec, - callback) as Promise; - } - - /** - * Removes a user from the allowed list of users to access this LUIS application. Users are removed - * using their email address. - * @param appId The application ID. - * @param userToDelete A model containing the user's email address. - * @param [options] The optional parameters - * @returns Promise - */ - deleteMethod(appId: string, userToDelete: Models.UserCollaborator, options?: msRest.RequestOptionsBase): Promise; - /** - * @param appId The application ID. - * @param userToDelete A model containing the user's email address. - * @param callback The callback - */ - deleteMethod(appId: string, userToDelete: Models.UserCollaborator, callback: msRest.ServiceCallback): void; - /** - * @param appId The application ID. - * @param userToDelete A model containing the user's email address. - * @param options The optional parameters - * @param callback The callback - */ - deleteMethod(appId: string, userToDelete: Models.UserCollaborator, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - deleteMethod(appId: string, userToDelete: Models.UserCollaborator, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - appId, - userToDelete, - options - }, - deleteMethodOperationSpec, - callback) as Promise; - } - - /** - * Replaces the current user access list with the new list sent in the body. If an empty list is - * sent, all access to other users will be removed. - * @param appId The application ID. - * @param collaborators A model containing a list of user email addresses. - * @param [options] The optional parameters - * @returns Promise - */ - update(appId: string, collaborators: Models.CollaboratorsArray, options?: msRest.RequestOptionsBase): Promise; - /** - * @param appId The application ID. - * @param collaborators A model containing a list of user email addresses. - * @param callback The callback - */ - update(appId: string, collaborators: Models.CollaboratorsArray, callback: msRest.ServiceCallback): void; - /** - * @param appId The application ID. - * @param collaborators A model containing a list of user email addresses. - * @param options The optional parameters - * @param callback The callback - */ - update(appId: string, collaborators: Models.CollaboratorsArray, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - update(appId: string, collaborators: Models.CollaboratorsArray, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - appId, - collaborators, - options - }, - updateOperationSpec, - callback) as Promise; - } -} - -// Operation Specifications -const serializer = new msRest.Serializer(Mappers); -const listOperationSpec: msRest.OperationSpec = { - httpMethod: "GET", - path: "apps/{appId}/permissions", - urlParameters: [ - Parameters.endpoint, - Parameters.appId - ], - responses: { - 200: { - bodyMapper: Mappers.UserAccessList - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const addOperationSpec: msRest.OperationSpec = { - httpMethod: "POST", - path: "apps/{appId}/permissions", - urlParameters: [ - Parameters.endpoint, - Parameters.appId - ], - requestBody: { - parameterPath: "userToAdd", - mapper: { - ...Mappers.UserCollaborator, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.OperationStatus - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const deleteMethodOperationSpec: msRest.OperationSpec = { - httpMethod: "DELETE", - path: "apps/{appId}/permissions", - urlParameters: [ - Parameters.endpoint, - Parameters.appId - ], - requestBody: { - parameterPath: "userToDelete", - mapper: { - ...Mappers.UserCollaborator, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.OperationStatus - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; - -const updateOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", - path: "apps/{appId}/permissions", - urlParameters: [ - Parameters.endpoint, - Parameters.appId - ], - requestBody: { - parameterPath: "collaborators", - mapper: { - ...Mappers.CollaboratorsArray, - required: true - } - }, - responses: { - 200: { - bodyMapper: Mappers.OperationStatus - }, - default: { - bodyMapper: Mappers.ErrorResponse - } - }, - serializer -}; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/appVersionImport.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/appVersionImport.test.ts index ee4f2eaf7be3..3b7061527b4a 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/appVersionImport.test.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/appVersionImport.test.ts @@ -79,10 +79,10 @@ describe("Import Tests", () => { usageScenario: "IoT" }); let app = JSON.parse(data); - const newVersion = await client.versions.importV2App(importV2Version.body, app, { appName: "Test Import V2 Version LUIS App" }); - var newVersionApp = await client.apps.get(newVersion.body); + const newVersion = await client.versions.importV2App(importV2Version.body, app); + var newVersionApp = await client.apps.get(importV2Version.body); - chai.expect(newVersionApp).to.exist; + chai.expect(newVersionApp.versionsCount).equal(2); await delay(1000); var deleteRespose = await client.apps.deleteMethod(importV2Version.body); diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/apps.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/apps.test.ts index b3d045b615ec..03e70145734d 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/apps.test.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/apps.test.ts @@ -9,7 +9,7 @@ import { BaseTest } from "../baseTest"; import { LUISAuthoringClient } from "../../src/lUISAuthoringClient"; import { AppsAddResponse } from "../../src/models"; -const trainedAppID = "4a696805-d784-4040-a0ba-043cc831b779"; +const trainedAppID = BaseTest.GlobalAppId; let testingApp: AppsAddResponse; describe("Apps Module Functionality Tests", () => { @@ -272,7 +272,7 @@ describe("Apps Module Functionality Tests", () => { await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { let resultsUS = await client.apps.listAvailableCustomPrebuiltDomainsForCulture("en-us"); let resultsCN = await client.apps.listAvailableCustomPrebuiltDomainsForCulture("zh-cn"); - + for (let resultUS of resultsUS) { chai.expect(BaseTest.doesListContain(resultsCN, "description", resultUS.description)).to.be.false; } diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/examples.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/examples.test.ts index a5029cf2ee53..7b340226ebfe 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/examples.test.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/examples.test.ts @@ -59,6 +59,50 @@ describe("Example Module Functionality Tests", () => { }); }); + it("should add example with nested children", async () => { + await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { + const appId = await client.apps.add({ + name: "Examples Test App", + description: "New LUIS App", + culture: "en-us", + domain: "Comics", + usageScenario: "IoT" + }); + await client.model.addIntent(appId.body, "0.1", { name: "WeatherInPlace" }); + await client.model.addEntity(appId.body, "0.1", { + name: "Place", + children:[{ + name: "City" + }, + { + name: "Country" + } + ]}); + let example = { + text: "whats the weather in buenos aires, argentina?", + intentName: "WeatherInPlace", + entityLabels: [{ + entityName: "Place", + startCharIndex: 21, + endCharIndex: 43, + children: [{ + entityName: "City", + startCharIndex: 21, + endCharIndex: 32 + }, + { + entityName: "Country", + startCharIndex: 35, + endCharIndex: 43 + }] + }] + }; + const result = await client.examples.add(appId.body, "0.1", example, {enableNestedChildren: true}); + await client.apps.deleteMethod(appId.body); + chai.expect(result.utteranceText).to.eql(example.text) + }); + }); + it("should add examples in batch", async () => { await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { const appId = await client.apps.add({ diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/features.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/features.test.ts index 8ca52e140c54..7e183684cf44 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/features.test.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/features.test.ts @@ -22,9 +22,22 @@ describe("Features Module Functionality", () => { var versionId = "0.2"; var features = await client.features.list(appId.body, versionId); await client.apps.deleteMethod(appId.body); - chai.expect(features.patternFeatures.length > 0).to.be.true; chai.expect(features.phraselistFeatures.length > 0).to.be.true; }); }); }); + + it('should add required feature', async () => { + await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { + var entityId = await client.model.addEntity(BaseTest.GlobalAppId, BaseTest.GlobalVersionId, {name: "flat entity"}); + var featureEntityId = await client.model.addEntity(BaseTest.GlobalAppId, BaseTest.GlobalVersionId, {name: "feature entity"}); + client.features.addEntityFeature(BaseTest.GlobalAppId, BaseTest.GlobalVersionId, entityId.body, { + modelName: "feature entity", + isRequired: true + }) + var features = await client.features.list(BaseTest.GlobalAppId, BaseTest.GlobalVersionId); + await client.model.deleteEntity(BaseTest.GlobalAppId, BaseTest.GlobalVersionId, entityId.body); + await client.model.deleteEntity(BaseTest.GlobalAppId, BaseTest.GlobalVersionId, featureEntityId.body); + }); + }); }); diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/import.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/import.test.ts index 356a5dd691e3..287d9b1ac8ca 100644 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/import.test.ts +++ b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/import.test.ts @@ -39,7 +39,7 @@ describe("Import Tests", () => { if (err) { throw err; } - let importLuApplication = await client.apps.importLuFromat(app); + let importLuApplication = await client.apps.importLuFormat(app); var testApp = await client.apps.get(importLuApplication.body); chai.expect(testApp).to.exist; diff --git a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/pernissions.test.ts b/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/pernissions.test.ts deleted file mode 100644 index 1a0370515805..000000000000 --- a/sdk/cognitiveservices/cognitiveservices-luis-authoring/test/Luis/pernissions.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - */ - -import * as chai from "chai"; -import { LUISAuthoringClient } from "../../src/lUISAuthoringClient"; -import { BaseTest } from "../baseTest"; - - -describe("Permissions Module Functionality Tests", () => { - - it('should list permissions', async () => { - await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { - await client.permissions.update(BaseTest.GlobalAppId, { emails: ["guest@outlook.com", "invited.user@live.com"] }); - let result = await client.permissions.list(BaseTest.GlobalAppId); - await client.permissions.deleteMethod(BaseTest.GlobalAppId, { email: "guest@outlook.com" }); - await client.permissions.deleteMethod(BaseTest.GlobalAppId, { email: "invited.user@live.com" }); - chai.expect(result.owner).to.eql(BaseTest.OwnerEmail); - chai.expect(result.emails).to.eql(["guest@outlook.com", "invited.user@live.com"]) - }); - }); - - it('should add permissions', async () => { - await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { - await client.permissions.add(BaseTest.GlobalAppId, { email: "guest@outlook.com" }); - let result = await client.permissions.list(BaseTest.GlobalAppId); - await client.permissions.deleteMethod(BaseTest.GlobalAppId, { email: "guest@outlook.com" }); - let found: boolean = false; - for (let e of result.emails) { - if (e == "guest@outlook.com") { - found = true; - } - } - chai.expect(found).to.be.true; - }); - }); - - it('should delete permissions', async () => { - await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { - await client.permissions.add(BaseTest.GlobalAppId, { email: "guest@outlook.com" }); - await client.permissions.deleteMethod(BaseTest.GlobalAppId, { email: "guest@outlook.com" }); - let result = await client.permissions.list(BaseTest.GlobalAppId); - - let found: boolean = false; - for (let e of result.emails) { - if (e == "guest@outlook.com") { - found = true; - } - } - chai.expect(found).to.be.false; - - - }); - }); - - it('should update permission', async () => { - await BaseTest.useClientFor(async (client: LUISAuthoringClient) => { - let collaborators = { emails: ["guest@outlook.com", "invited.user@live.com"] }; - await client.permissions.update(BaseTest.GlobalAppId, collaborators); - let result = await client.permissions.list(BaseTest.GlobalAppId); - await client.permissions.update(BaseTest.GlobalAppId, { emails: ["guest@outlook.com"] }); - chai.expect(result.emails).to.eql(collaborators.emails); - }); - }); -});