Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019 Microsoft
Copyright (c) 2020 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
97 changes: 45 additions & 52 deletions sdk/cognitiveservices/cognitiveservices-luis-authoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

This package contains an isomorphic SDK for LUISAuthoringClient.

Package version | LUIS Authoring API version
--------------- | --------------------------
3.0.0 | /luis/api/v2.0
4.0.0-preview.2 | /luis/authoring/v3.0-preview

### Currently supported environments

- Node.js version 6.x.x or higher
Expand All @@ -22,83 +17,81 @@ npm install @azure/cognitiveservices-luis-authoring

#### nodejs - Authentication, client creation and listPhraseLists features as an example written in TypeScript.

##### Install @azure/ms-rest-azure-js
##### Install @azure/ms-rest-nodeauth

- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
```bash
npm install @azure/ms-rest-azure-js
npm install @azure/ms-rest-nodeauth@"^3.0.0"
```

##### Sample code

```typescript
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
import { LUISAuthoringClient } from "@azure/cognitiveservices-luis-authoring";

let authoringKey = process.env["luis-authoring-key"];
const creds = new CognitiveServicesCredentials(authoringKey);

// check the following link to find your region
// https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-reference-regions
const region = "<your-region>";
const client = new LUISAuthoringClient(
creds,
"https://" + region + ".api.cognitive.microsoft.com/"
);

const appId = "<your-app-id>"; // replace this with your appId.
const versionId = "0.1"; // replace with version of your luis application. Initial value will be 0.1

const skip = 1;
const take = 1;

client.features
.listPhraseLists(appId, versionId, { skip, take })
.then((result) => {
import * as msRest from "@azure/ms-rest-js";
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
import { LUISAuthoringClient, LUISAuthoringModels, LUISAuthoringMappers } from "@azure/cognitiveservices-luis-authoring";
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new LUISAuthoringClient(creds, subscriptionId);
const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a;
const versionId = "testversionId";
const skip = 1;
const take = 1;
client.features.listPhraseLists(appId, versionId, skip, take).then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
console.error(err);
});
}).catch((err) => {
console.error(err);
});
```

#### browser - Authentication, client creation and listPhraseLists features as an example written in JavaScript.

##### Install @azure/ms-rest-browserauth

```bash
npm install @azure/ms-rest-browserauth
```

##### Sample code

- index.html
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

- index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>@azure/cognitiveservices-luis-authoring sample</title>
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
<script src="node_modules/@azure/cognitiveservices-luis-authoring/dist/cognitiveservices-luis-authoring.js"></script>
<script type="text/javascript">
let authoringKey = process.env["luis-authoring-key"];
const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': authoringKey } });

const region = "<your-region>";
const client = new Azure.CognitiveservicesLuisAuthoring.LUISAuthoringClient(
creds,
"https://" + region + ".api.cognitive.microsoft.com/"
);
const appId = "<your-app-id>"; // replace this with your appId.
const versionId = "0.1"; // replace with version of your luis application. Initial value will be 0.1
const skip = 1;
const take = 1;
client.features
.listPhraseLists(appId, versionId, { skip, take })
.then((result) => {
const subscriptionId = "<Subscription_Id>";
const authManager = new msAuth.AuthManager({
clientId: "<client id for your Azure AD app>",
tenant: "<optional tenant for your organization>"
});
authManager.finalizeLogin().then((res) => {
if (!res.isLoggedIn) {
// may cause redirects
authManager.login();
}
const client = new Azure.CognitiveservicesLuisAuthoring.LUISAuthoringClient(res.creds, subscriptionId);
const appId = ec7b1657-199d-4d8a-bbb2-89a11a42e02a;
const versionId = "testversionId";
const skip = 1;
const take = 1;
client.features.listPhraseLists(appId, versionId, skip, take).then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
<body></body>
Expand All @@ -109,4 +102,4 @@ client.features

- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-luis-authoring%2FREADME.png)
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-luis-authoring/README.png)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "LUISAuthoringClient Library with typescript type definitions for node.js and browser.",
"version": "4.0.0-preview.2",
"dependencies": {
"@azure/ms-rest-js": "^2.0.3",
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
},
"keywords": [
Expand All @@ -19,20 +19,13 @@
"module": "./esm/lUISAuthoringClient.js",
"types": "./esm/lUISAuthoringClient.d.ts",
"devDependencies": {
"@types/chai": "^4.2.0",
"@types/mocha": "^5.2.7",
"mocha": "^6.1.4",
"nock": "^10.0.0",
"rollup": "^0.66.2",
"@azure/ms-rest-azure-js": "^2.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"typescript": "^3.5.3",
"rollup": "^1.18.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-node": "^8.3.0",
"typescript": "^3.1.1",
"uglify-js": "^3.4.9",
"ts-mocha": "^6.0.0"
"uglify-js": "^3.6.0"
},
"homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-luis-authoring",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/cognitiveservices-luis-authoring",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
Expand All @@ -57,8 +50,7 @@
"scripts": {
"build": "tsc && rollup -c rollup.config.js && npm run minify",
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-luis-authoring.js.map'\" -o ./dist/cognitiveservices-luis-authoring.min.js ./dist/cognitiveservices-luis-authoring.js",
"prepack": "npm install && npm run build",
"test": "ts-mocha -p tsconfig.test.json test/**/*.test.ts --timeout 100000"
"prepack": "npm install && npm run build"
},
"sideEffects": false,
"autoPublish": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ const config = {
},
banner: `/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* 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.
*/`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class LUISAuthoringClient extends LUISAuthoringClientContext {
apps: operations.Apps;
versions: operations.Versions;
train: operations.Train;
permissions: operations.Permissions;
pattern: operations.Pattern;
settings: operations.Settings;
azureAccounts: operations.AzureAccounts;
Expand All @@ -42,7 +41,6 @@ class LUISAuthoringClient extends LUISAuthoringClientContext {
this.apps = new operations.Apps(this);
this.versions = new operations.Versions(this);
this.train = new operations.Train(this);
this.permissions = new operations.Permissions(this);
this.pattern = new operations.Pattern(this);
this.settings = new operations.Settings(this);
this.azureAccounts = new operations.AzureAccounts(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* 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.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
* 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.
Expand Down
Loading