diff --git a/lib/services/computerVision/LICENSE.txt b/lib/services/computerVision/LICENSE.txt index a70e8cf660..5431ba98b9 100644 --- a/lib/services/computerVision/LICENSE.txt +++ b/lib/services/computerVision/LICENSE.txt @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2018 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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2018 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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/computerVision/README.md b/lib/services/computerVision/README.md index 16ca36ca1d..4b50cf75de 100644 --- a/lib/services/computerVision/README.md +++ b/lib/services/computerVision/README.md @@ -16,16 +16,19 @@ npm install azure-cognitiveservices-computervision ```javascript const msRestAzure = require('ms-rest-azure'); - const CognitiveServicesManagement = require("azure-arm-cognitiveservices"); + const CognitiveServicesManagement = require('azure-arm-cognitiveservices'); + const SubscriptionId = 'your-subscription-key'; + const ResourceGroup = 'your-resource-group-name'; + const ResourceName = 'resource-name'; let client; let createAccount = msRestAzure.interactiveLogin().then((credentials) => { - client = new CognitiveServicesManagement(credentials, suite.subscriptionId); - return client.accounts.create('groupname', 'accountname', { + client = new CognitiveServicesManagement(credentials, SubscriptionId); + return client.accounts.create(ResourceGroup, ResourceName, { sku: { - name: "F0" + name: 'F0' }, - kind: "ComputerVision", - location: "westus", + kind: 'ComputerVision', + location: 'westus', properties: {} }); }).catch((err) => { @@ -39,7 +42,7 @@ npm install azure-cognitiveservices-computervision ```javascript let serviceKey; createAccount.then((result) => { - return client.accounts.listKeys('groupname', 'accountname'); + return client.accounts.listKeys(ResourceGroup, ResourceName); }).then((result) => { serviceKey = result.key1; console.log(result.key2); @@ -62,12 +65,12 @@ npm install azure-cognitiveservices-computervision ### Computer Vision API ```javascript - const ComputerVisionAPIClient = require('azure-cognitiveservices-computervision'); + const ComputerVisionClient = require('azure-cognitiveservices-computervision'); - let client = new ComputerVisionAPIClient(credentials); - let fileStream = fs.createReadStream('pathToSomeImage.jpg'); + let client = new ComputerVisionClient(credentials, 'https://westus.api.cognitive.microsoft.com'); + let fileStream = require('fs').createReadStream('pathToSomeImage.jpg'); client.analyzeImageInStreamWithHttpOperationResponse(fileStream, { - visualFeatures: ["Categories", "Tags", "Description"] + visualFeatures: ['Categories', 'Tags', 'Description'] }).then((response) => { console.log(response.body.tags); console.log(response.body.description.captions[0]); diff --git a/lib/services/computerVision/lib/computerVisionAPIClient.d.ts b/lib/services/computerVision/lib/computerVisionClient.d.ts similarity index 80% rename from lib/services/computerVision/lib/computerVisionAPIClient.d.ts rename to lib/services/computerVision/lib/computerVisionClient.d.ts index c95b834679..da9bc26142 100644 --- a/lib/services/computerVision/lib/computerVisionAPIClient.d.ts +++ b/lib/services/computerVision/lib/computerVisionClient.d.ts @@ -11,15 +11,15 @@ import { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest'; import * as models from "./models"; -export default class ComputerVisionAPIClient extends ServiceClient { +export default class ComputerVisionClient extends ServiceClient { /** * @class - * Initializes a new instance of the ComputerVisionAPIClient class. + * Initializes a new instance of the ComputerVisionClient class. * @constructor * * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. * - * @param {azureRegions} azureRegion - Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' + * @param {string} endpoint - Supported Cognitive Services endpoints * * @param {object} [options] - The parameter options * @@ -31,11 +31,11 @@ export default class ComputerVisionAPIClient extends ServiceClient { * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy * */ - constructor(credentials: ServiceClientCredentials, azureRegion: string, options?: ServiceClientOptions); + constructor(credentials: ServiceClientCredentials, endpoint: string, options?: ServiceClientOptions); credentials: ServiceClientCredentials; - azureRegion: string; + endpoint: string; /** @@ -104,7 +104,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * parameter to allow you to choose which features to return. By default, * image categories are returned in the response. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -125,11 +125,11 @@ export default class ComputerVisionAPIClient extends ServiceClient { * feature types include:Celebrities - identifies celebrities if detected in * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -149,7 +149,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * parameter to allow you to choose which features to return. By default, * image categories are returned in the response. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -170,11 +170,11 @@ export default class ComputerVisionAPIClient extends ServiceClient { * feature types include:Celebrities - identifies celebrities if detected in * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -221,7 +221,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * @param {number} height Height of the thumbnail. It must be between 1 and * 1024. Recommended minimum of 50. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -254,7 +254,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * @param {number} height Height of the thumbnail. It must be between 1 and * 1024. Recommended minimum of 50. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -303,7 +303,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * image orientation and correct it before further processing (e.g. if it's * upside-down). * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -337,7 +337,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * image orientation and correct it before further processing (e.g. if it's * upside-down). * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -388,13 +388,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * response will contain an error code and a message to help understand what * went wrong. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -404,7 +410,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - describeImageWithHttpOperationResponse(url: string, options?: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + describeImageWithHttpOperationResponse(url: string, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation generates a description of an image in human readable @@ -417,13 +423,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * response will contain an error code and a message to help understand what * went wrong. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -449,9 +461,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - describeImage(url: string, options?: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + describeImage(url: string, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; describeImage(url: string, callback: ServiceCallback): void; - describeImage(url: string, options: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + describeImage(url: string, options: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -460,13 +472,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -476,7 +494,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - tagImageWithHttpOperationResponse(url: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + tagImageWithHttpOperationResponse(url: string, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation generates a list of words, or tags, that are relevant to the @@ -484,13 +502,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -516,9 +540,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - tagImage(url: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + tagImage(url: string, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; tagImage(url: string, callback: ServiceCallback): void; - tagImage(url: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + tagImage(url: string, options: { language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -531,13 +555,18 @@ export default class ComputerVisionAPIClient extends ServiceClient { * If the request failed, the response will contain an error code and a message * to help understand what went wrong. * - * @param {string} model The domain-specific content to recognize. Possible - * values include: 'Celebrities', 'Landmarks' + * @param {string} model The domain-specific content to recognize. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -547,7 +576,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - analyzeImageByDomainWithHttpOperationResponse(model: string, url: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + analyzeImageByDomainWithHttpOperationResponse(model: string, url: string, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation recognizes content within an image by applying a @@ -559,13 +588,18 @@ export default class ComputerVisionAPIClient extends ServiceClient { * If the request failed, the response will contain an error code and a message * to help understand what went wrong. * - * @param {string} model The domain-specific content to recognize. Possible - * values include: 'Celebrities', 'Landmarks' + * @param {string} model The domain-specific content to recognize. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -591,24 +625,23 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - analyzeImageByDomain(model: string, url: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + analyzeImageByDomain(model: string, url: string, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; analyzeImageByDomain(model: string, url: string, callback: ServiceCallback): void; - analyzeImageByDomain(model: string, url: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + analyzeImageByDomain(model: string, url: string, options: { language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * - * @param {string} url + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {object} [options] Optional Parameters. + * @param {string} url Publicly reachable URL of an image * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -619,21 +652,20 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - recognizeTextWithHttpOperationResponse(url: string, options?: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + recognizeTextWithHttpOperationResponse(url: string, mode: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * - * @param {string} url + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {object} [options] Optional Parameters. + * @param {string} url Publicly reachable URL of an image * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -659,9 +691,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - recognizeText(url: string, options?: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; - recognizeText(url: string, callback: ServiceCallback): void; - recognizeText(url: string, options: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + recognizeText(url: string, mode: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + recognizeText(url: string, mode: string, callback: ServiceCallback): void; + recognizeText(url: string, mode: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -670,7 +702,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * Recognize Text interface. * * @param {string} operationId Id of the text operation returned in the - * response of the 'Recognize Handwritten Text' + * response of the 'Recognize Text' * * @param {object} [options] Optional Parameters. * @@ -691,7 +723,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * Recognize Text interface. * * @param {string} operationId Id of the text operation returned in the - * response of the 'Recognize Handwritten Text' + * response of the 'Recognize Text' * * @param {object} [options] Optional Parameters. * @@ -745,16 +777,16 @@ export default class ComputerVisionAPIClient extends ServiceClient { * black&white.Adult - detects if the image is pornographic in nature (depicts * nudity or a sex act). Sexually suggestive content is also detected. * - * @param {string} [options.details] A string indicating which domain-specific + * @param {array} [options.details] A string indicating which domain-specific * details to return. Multiple values should be comma-separated. Valid visual * feature types include:Celebrities - identifies celebrities if detected in - * the image. Possible values include: 'Celebrities', 'Landmarks' + * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -765,7 +797,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - analyzeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + analyzeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation extracts a rich set of visual features based on the image @@ -787,16 +819,16 @@ export default class ComputerVisionAPIClient extends ServiceClient { * black&white.Adult - detects if the image is pornographic in nature (depicts * nudity or a sex act). Sexually suggestive content is also detected. * - * @param {string} [options.details] A string indicating which domain-specific + * @param {array} [options.details] A string indicating which domain-specific * details to return. Multiple values should be comma-separated. Valid visual * feature types include:Celebrities - identifies celebrities if detected in - * the image. Possible values include: 'Celebrities', 'Landmarks' + * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -823,9 +855,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - analyzeImageInStream(image: stream.Readable, options?: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + analyzeImageInStream(image: stream.Readable, options?: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; analyzeImageInStream(image: stream.Readable, callback: ServiceCallback): void; - analyzeImageInStream(image: stream.Readable, options: { visualFeatures? : string[], details? : string, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + analyzeImageInStream(image: stream.Readable, options: { visualFeatures? : string[], details? : string[], language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1014,9 +1046,15 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1026,7 +1064,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - describeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + describeImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation generates a description of an image in human readable @@ -1043,9 +1081,15 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1071,9 +1115,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - describeImageInStream(image: stream.Readable, options?: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + describeImageInStream(image: stream.Readable, options?: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; describeImageInStream(image: stream.Readable, callback: ServiceCallback): void; - describeImageInStream(image: stream.Readable, options: { maxCandidates? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + describeImageInStream(image: stream.Readable, options: { maxCandidates? : number, language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1082,13 +1126,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * * @param {object} image An image stream. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1098,7 +1148,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - tagImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + tagImageInStreamWithHttpOperationResponse(image: stream.Readable, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation generates a list of words, or tags, that are relevant to the @@ -1106,13 +1156,19 @@ export default class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * * @param {object} image An image stream. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1138,9 +1194,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - tagImageInStream(image: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + tagImageInStream(image: stream.Readable, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; tagImageInStream(image: stream.Readable, callback: ServiceCallback): void; - tagImageInStream(image: stream.Readable, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + tagImageInStream(image: stream.Readable, options: { language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -1159,6 +1215,12 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1168,7 +1230,7 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - analyzeImageByDomainInStreamWithHttpOperationResponse(model: string, image: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + analyzeImageByDomainInStreamWithHttpOperationResponse(model: string, image: stream.Readable, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; /** * This operation recognizes content within an image by applying a @@ -1186,6 +1248,12 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1211,24 +1279,23 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - analyzeImageByDomainInStream(model: string, image: stream.Readable, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + analyzeImageByDomainInStream(model: string, image: stream.Readable, options?: { language? : string, customHeaders? : { [headerName: string]: string; } }): Promise; analyzeImageByDomainInStream(model: string, image: stream.Readable, callback: ServiceCallback): void; - analyzeImageByDomainInStream(model: string, image: stream.Readable, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + analyzeImageByDomainInStream(model: string, image: stream.Readable, options: { language? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * * @param {object} image An image stream. * - * @param {object} [options] Optional Parameters. + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1239,21 +1306,20 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error|ServiceError} - The error object. */ - recognizeTextInStreamWithHttpOperationResponse(image: stream.Readable, options?: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise>; + recognizeTextInStreamWithHttpOperationResponse(image: stream.Readable, mode: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * * @param {object} image An image stream. * - * @param {object} [options] Optional Parameters. + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1279,9 +1345,9 @@ export default class ComputerVisionAPIClient extends ServiceClient { * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - recognizeTextInStream(image: stream.Readable, options?: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }): Promise; - recognizeTextInStream(image: stream.Readable, callback: ServiceCallback): void; - recognizeTextInStream(image: stream.Readable, options: { detectHandwriting? : boolean, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + recognizeTextInStream(image: stream.Readable, mode: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + recognizeTextInStream(image: stream.Readable, mode: string, callback: ServiceCallback): void; + recognizeTextInStream(image: stream.Readable, mode: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } -export { ComputerVisionAPIClient, models as ComputerVisionAPIModels }; +export { ComputerVisionClient, models as ComputerVisionModels }; diff --git a/lib/services/computerVision/lib/computerVisionAPIClient.js b/lib/services/computerVision/lib/computerVisionClient.js similarity index 86% rename from lib/services/computerVision/lib/computerVisionAPIClient.js rename to lib/services/computerVision/lib/computerVisionClient.js index c092f26ae8..aedb787387 100644 --- a/lib/services/computerVision/lib/computerVisionAPIClient.js +++ b/lib/services/computerVision/lib/computerVisionClient.js @@ -58,14 +58,8 @@ function _listModels(options, callback) { } // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); @@ -74,7 +68,7 @@ function _listModels(options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'models'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); // Create HTTP transport objects let httpRequest = new WebResource(); @@ -155,7 +149,7 @@ function _listModels(options, callback) { * parameter to allow you to choose which features to return. By default, * image categories are returned in the response. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -176,11 +170,11 @@ function _listModels(options, callback) { * feature types include:Celebrities - identifies celebrities if detected in * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -213,21 +207,15 @@ function _analyzeImage(url, options, callback) { let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (Array.isArray(visualFeatures)) { for (let i = 0; i < visualFeatures.length; i++) { if (visualFeatures[i]) { - let allowedValues1 = [ 'ImageType', 'Faces', 'Adult', 'Categories', 'Color', 'Tags', 'Description' ]; - if (!allowedValues1.some( function(item) { return item === visualFeatures[i]; })) { - throw new Error(visualFeatures[i] + ' is not a valid value. The valid values are: ' + allowedValues1); + let allowedValues = [ 'ImageType', 'Faces', 'Adult', 'Categories', 'Color', 'Tags', 'Description' ]; + if (!allowedValues.some( function(item) { return item === visualFeatures[i]; })) { + throw new Error(visualFeatures[i] + ' is not a valid value. The valid values are: ' + allowedValues); } } } @@ -235,18 +223,15 @@ function _analyzeImage(url, options, callback) { if (Array.isArray(details)) { for (let i1 = 0; i1 < details.length; i1++) { if (details[i1]) { - let allowedValues2 = [ 'Celebrities', 'Landmarks' ]; - if (!allowedValues2.some( function(item) { return item === details[i1]; })) { - throw new Error(details[i1] + ' is not a valid value. The valid values are: ' + allowedValues2); + let allowedValues1 = [ 'Celebrities', 'Landmarks' ]; + if (!allowedValues1.some( function(item) { return item === details[i1]; })) { + throw new Error(details[i1] + ' is not a valid value. The valid values are: ' + allowedValues1); } } } } - if (language) { - let allowedValues3 = [ 'en', 'zh' ]; - if (!allowedValues3.some( function(item) { return item === language; })) { - throw new Error(language + ' is not a valid value. The valid values are: ' + allowedValues3); - } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { throw new Error('url cannot be null or undefined and it must be of type string.'); @@ -263,7 +248,7 @@ function _analyzeImage(url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'analyze'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; if (visualFeatures !== null && visualFeatures !== undefined) { queryParameters.push('visualFeatures=' + encodeURIComponent(visualFeatures.join(','))); @@ -379,7 +364,7 @@ function _analyzeImage(url, options, callback) { * @param {number} height Height of the thumbnail. It must be between 1 and * 1024. Recommended minimum of 50. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -414,14 +399,8 @@ function _generateThumbnail(width, height, url, options, callback) { let smartCropping = (options && options.smartCropping !== undefined) ? options.smartCropping : false; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (width === null || width === undefined || typeof width !== 'number') { throw new Error('width cannot be null or undefined and it must be of type number.'); @@ -467,7 +446,7 @@ function _generateThumbnail(width, height, url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'generateThumbnail'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; queryParameters.push('width=' + encodeURIComponent(width.toString())); queryParameters.push('height=' + encodeURIComponent(height.toString())); @@ -557,7 +536,7 @@ function _generateThumbnail(width, height, url, options, callback) { * image orientation and correct it before further processing (e.g. if it's * upside-down). * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -596,22 +575,16 @@ function _recognizePrintedText(detectOrientation, url, options, callback) { let language = (options && options.language !== undefined) ? options.language : 'unk'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (detectOrientation === null || detectOrientation === undefined || typeof detectOrientation !== 'boolean') { throw new Error('detectOrientation cannot be null or undefined and it must be of type boolean.'); } if (language) { - let allowedValues1 = [ 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' ]; - if (!allowedValues1.some( function(item) { return item === language; })) { - throw new Error(language + ' is not a valid value. The valid values are: ' + allowedValues1); + let allowedValues = [ 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' ]; + if (!allowedValues.some( function(item) { return item === language; })) { + throw new Error(language + ' is not a valid value. The valid values are: ' + allowedValues); } } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { @@ -629,7 +602,7 @@ function _recognizePrintedText(detectOrientation, url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ocr'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; queryParameters.push('detectOrientation=' + encodeURIComponent(detectOrientation.toString())); if (language !== null && language !== undefined) { @@ -736,13 +709,19 @@ function _recognizePrintedText(detectOrientation, url, options, callback) { * response will contain an error code and a message to help understand what * went wrong. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -769,20 +748,18 @@ function _describeImage(url, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : '1'; + let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : 1; + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates.valueOf() !== 'string') { - throw new Error('maxCandidates must be of type string.'); + if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates !== 'number') { + throw new Error('maxCandidates must be of type number.'); + } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { throw new Error('url cannot be null or undefined and it must be of type string.'); @@ -799,10 +776,13 @@ function _describeImage(url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'describe'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; if (maxCandidates !== null && maxCandidates !== undefined) { - queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates)); + queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates.toString())); + } + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -900,13 +880,19 @@ function _describeImage(url, options, callback) { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -933,16 +919,14 @@ function _tagImage(url, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { throw new Error('url cannot be null or undefined and it must be of type string.'); @@ -959,7 +943,14 @@ function _tagImage(url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'tag'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1057,13 +1048,18 @@ function _tagImage(url, options, callback) { * If the request failed, the response will contain an error code and a message * to help understand what went wrong. * - * @param {string} model The domain-specific content to recognize. Possible - * values include: 'Celebrities', 'Landmarks' + * @param {string} model The domain-specific content to recognize. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -1090,24 +1086,17 @@ function _analyzeImageByDomain(model, url, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (model) { - let allowedValues1 = [ 'Celebrities', 'Landmarks' ]; - if (!allowedValues1.some( function(item) { return item === model; })) { - throw new Error(model + ' is not a valid value. The valid values are: ' + allowedValues1); - } - } else { - throw new Error('model cannot be null or undefined.'); + if (model === null || model === undefined || typeof model.valueOf() !== 'string') { + throw new Error('model cannot be null or undefined and it must be of type string.'); + } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { throw new Error('url cannot be null or undefined and it must be of type string.'); @@ -1124,8 +1113,15 @@ function _analyzeImageByDomain(model, url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'models/{model}/analyze'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{model}', encodeURIComponent(model)); + let queryParameters = []; + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -1215,17 +1211,16 @@ function _analyzeImageByDomain(model, url, options, callback) { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * - * @param {string} url + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {object} [options] Optional Parameters. + * @param {string} url Publicly reachable URL of an image * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1242,7 +1237,7 @@ function _analyzeImageByDomain(model, url, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _recognizeText(url, options, callback) { +function _recognizeText(url, mode, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -1252,20 +1247,18 @@ function _recognizeText(url, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let detectHandwriting = (options && options.detectHandwriting !== undefined) ? options.detectHandwriting : false; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (mode) { + let allowedValues = [ 'Handwritten', 'Printed' ]; + if (!allowedValues.some( function(item) { return item === mode; })) { + throw new Error(mode + ' is not a valid value. The valid values are: ' + allowedValues); } } else { - throw new Error('this.azureRegion cannot be null or undefined.'); - } - if (detectHandwriting !== null && detectHandwriting !== undefined && typeof detectHandwriting !== 'boolean') { - throw new Error('detectHandwriting must be of type boolean.'); + throw new Error('mode cannot be null or undefined.'); } if (url === null || url === undefined || typeof url.valueOf() !== 'string') { throw new Error('url cannot be null or undefined and it must be of type string.'); @@ -1282,11 +1275,9 @@ function _recognizeText(url, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'recognizeText'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; - if (detectHandwriting !== null && detectHandwriting !== undefined) { - queryParameters.push('detectHandwriting=' + encodeURIComponent(detectHandwriting.toString())); - } + queryParameters.push('mode=' + encodeURIComponent(mode)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -1366,7 +1357,7 @@ function _recognizeText(url, options, callback) { * Recognize Text interface. * * @param {string} operationId Id of the text operation returned in the - * response of the 'Recognize Handwritten Text' + * response of the 'Recognize Text' * * @param {object} [options] Optional Parameters. * @@ -1398,14 +1389,8 @@ function _getTextOperationResult(operationId, options, callback) { } // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (operationId === null || operationId === undefined || typeof operationId.valueOf() !== 'string') { throw new Error('operationId cannot be null or undefined and it must be of type string.'); @@ -1417,7 +1402,7 @@ function _getTextOperationResult(operationId, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'textOperations/{operationId}'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{operationId}', encodeURIComponent(operationId)); // Create HTTP transport objects @@ -1512,16 +1497,16 @@ function _getTextOperationResult(operationId, options, callback) { * black&white.Adult - detects if the image is pornographic in nature (depicts * nudity or a sex act). Sexually suggestive content is also detected. * - * @param {string} [options.details] A string indicating which domain-specific + * @param {array} [options.details] A string indicating which domain-specific * details to return. Multiple values should be comma-separated. Valid visual * feature types include:Celebrities - identifies celebrities if detected in - * the image. Possible values include: 'Celebrities', 'Landmarks' + * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -1554,27 +1539,28 @@ function _analyzeImageInStream(image, options, callback) { let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (Array.isArray(visualFeatures)) { for (let i = 0; i < visualFeatures.length; i++) { if (visualFeatures[i]) { - let allowedValues1 = [ 'ImageType', 'Faces', 'Adult', 'Categories', 'Color', 'Tags', 'Description' ]; - if (!allowedValues1.some( function(item) { return item === visualFeatures[i]; })) { - throw new Error(visualFeatures[i] + ' is not a valid value. The valid values are: ' + allowedValues1); + let allowedValues = [ 'ImageType', 'Faces', 'Adult', 'Categories', 'Color', 'Tags', 'Description' ]; + if (!allowedValues.some( function(item) { return item === visualFeatures[i]; })) { + throw new Error(visualFeatures[i] + ' is not a valid value. The valid values are: ' + allowedValues); } } } } - if (details !== null && details !== undefined && typeof details.valueOf() !== 'string') { - throw new Error('details must be of type string.'); + if (Array.isArray(details)) { + for (let i1 = 0; i1 < details.length; i1++) { + if (details[i1]) { + let allowedValues1 = [ 'Celebrities', 'Landmarks' ]; + if (!allowedValues1.some( function(item) { return item === details[i1]; })) { + throw new Error(details[i1] + ' is not a valid value. The valid values are: ' + allowedValues1); + } + } + } } if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { throw new Error('language must be of type string.'); @@ -1589,13 +1575,13 @@ function _analyzeImageInStream(image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'analyze'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; if (visualFeatures !== null && visualFeatures !== undefined) { queryParameters.push('visualFeatures=' + encodeURIComponent(visualFeatures.join(','))); } if (details !== null && details !== undefined) { - queryParameters.push('details=' + encodeURIComponent(details)); + queryParameters.push('details=' + encodeURIComponent(details.join(','))); } if (language !== null && language !== undefined) { queryParameters.push('language=' + encodeURIComponent(language)); @@ -1728,14 +1714,8 @@ function _generateThumbnailInStream(width, height, image, options, callback) { let smartCropping = (options && options.smartCropping !== undefined) ? options.smartCropping : false; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (width === null || width === undefined || typeof width !== 'number') { throw new Error('width cannot be null or undefined and it must be of type number.'); @@ -1776,7 +1756,7 @@ function _generateThumbnailInStream(width, height, image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'generateThumbnail'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; queryParameters.push('width=' + encodeURIComponent(width.toString())); queryParameters.push('height=' + encodeURIComponent(height.toString())); @@ -1827,10 +1807,6 @@ function _generateThumbnailInStream(width, height, image, options, callback) { error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } - if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { - let resultMapper = new client.models['ComputerVisionError']().mapper(); - error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); - } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; @@ -1897,19 +1873,13 @@ function _recognizePrintedTextInStream(detectOrientation, image, options, callba let language = (options && options.language !== undefined) ? options.language : 'unk'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (language) { - let allowedValues1 = [ 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' ]; - if (!allowedValues1.some( function(item) { return item === language; })) { - throw new Error(language + ' is not a valid value. The valid values are: ' + allowedValues1); + let allowedValues = [ 'unk', 'zh-Hans', 'zh-Hant', 'cs', 'da', 'nl', 'en', 'fi', 'fr', 'de', 'el', 'hu', 'it', 'ja', 'ko', 'nb', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', 'ar', 'ro', 'sr-Cyrl', 'sr-Latn', 'sk' ]; + if (!allowedValues.some( function(item) { return item === language; })) { + throw new Error(language + ' is not a valid value. The valid values are: ' + allowedValues); } } if (detectOrientation === null || detectOrientation === undefined || typeof detectOrientation !== 'boolean') { @@ -1925,7 +1895,7 @@ function _recognizePrintedTextInStream(detectOrientation, image, options, callba // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'ocr'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; if (language !== null && language !== undefined) { queryParameters.push('language=' + encodeURIComponent(language)); @@ -2024,9 +1994,15 @@ function _recognizePrintedTextInStream(detectOrientation, image, options, callba * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2053,20 +2029,18 @@ function _describeImageInStream(image, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : '1'; + let maxCandidates = (options && options.maxCandidates !== undefined) ? options.maxCandidates : 1; + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } - if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates.valueOf() !== 'string') { - throw new Error('maxCandidates must be of type string.'); + if (maxCandidates !== null && maxCandidates !== undefined && typeof maxCandidates !== 'number') { + throw new Error('maxCandidates must be of type number.'); + } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (image === null || image === undefined) { throw new Error('image cannot be null or undefined and it must be of type object.'); @@ -2078,10 +2052,13 @@ function _describeImageInStream(image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'describe'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; if (maxCandidates !== null && maxCandidates !== undefined) { - queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates)); + queryParameters.push('maxCandidates=' + encodeURIComponent(maxCandidates.toString())); + } + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); @@ -2167,13 +2144,19 @@ function _describeImageInStream(image, options, callback) { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * * @param {object} image An image stream. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2200,16 +2183,14 @@ function _tagImageInStream(image, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); + } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); } if (image === null || image === undefined) { throw new Error('image cannot be null or undefined and it must be of type object.'); @@ -2221,7 +2202,14 @@ function _tagImageInStream(image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'tag'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); + let queryParameters = []; + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -2313,6 +2301,12 @@ function _tagImageInStream(image, options, callback) { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -2339,20 +2333,18 @@ function _analyzeImageByDomainInStream(model, image, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } + let language = (options && options.language !== undefined) ? options.language : 'en'; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (model === null || model === undefined || typeof model.valueOf() !== 'string') { throw new Error('model cannot be null or undefined and it must be of type string.'); } + if (language !== null && language !== undefined && typeof language.valueOf() !== 'string') { + throw new Error('language must be of type string.'); + } if (image === null || image === undefined) { throw new Error('image cannot be null or undefined and it must be of type object.'); } @@ -2363,8 +2355,15 @@ function _analyzeImageByDomainInStream(model, image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'models/{model}/analyze'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); requestUrl = requestUrl.replace('{model}', encodeURIComponent(model)); + let queryParameters = []; + if (language !== null && language !== undefined) { + queryParameters.push('language=' + encodeURIComponent(language)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } // Create HTTP transport objects let httpRequest = new WebResource(); @@ -2442,17 +2441,16 @@ function _analyzeImageByDomainInStream(model, image, options, callback) { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * * @param {object} image An image stream. * - * @param {object} [options] Optional Parameters. + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -2469,7 +2467,7 @@ function _analyzeImageByDomainInStream(model, image, options, callback) { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ -function _recognizeTextInStream(image, options, callback) { +function _recognizeTextInStream(image, mode, options, callback) { /* jshint validthis: true */ let client = this; if(!callback && typeof options === 'function') { @@ -2479,24 +2477,22 @@ function _recognizeTextInStream(image, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let detectHandwriting = (options && options.detectHandwriting !== undefined) ? options.detectHandwriting : false; // Validate try { - if (this.azureRegion) { - let allowedValues = [ 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' ]; - let enumValue = this.azureRegion; - if (!allowedValues.some( function(item) { return item === enumValue; })) { - throw new Error(enumValue + ' is not a valid value. The valid values are: ' + allowedValues); - } - } else { - throw new Error('this.azureRegion cannot be null or undefined.'); - } - if (detectHandwriting !== null && detectHandwriting !== undefined && typeof detectHandwriting !== 'boolean') { - throw new Error('detectHandwriting must be of type boolean.'); + if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') { + throw new Error('this.endpoint cannot be null or undefined and it must be of type string.'); } if (image === null || image === undefined) { throw new Error('image cannot be null or undefined and it must be of type object.'); } + if (mode) { + let allowedValues = [ 'Handwritten', 'Printed' ]; + if (!allowedValues.some( function(item) { return item === mode; })) { + throw new Error(mode + ' is not a valid value. The valid values are: ' + allowedValues); + } + } else { + throw new Error('mode cannot be null or undefined.'); + } } catch (error) { return callback(error); } @@ -2504,11 +2500,9 @@ function _recognizeTextInStream(image, options, callback) { // Construct URL let baseUrl = this.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'recognizeText'; - requestUrl = requestUrl.replace('{AzureRegion}', this.azureRegion); + requestUrl = requestUrl.replace('{Endpoint}', this.endpoint); let queryParameters = []; - if (detectHandwriting !== null && detectHandwriting !== undefined) { - queryParameters.push('detectHandwriting=' + encodeURIComponent(detectHandwriting.toString())); - } + queryParameters.push('mode=' + encodeURIComponent(mode)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -2570,33 +2564,33 @@ function _recognizeTextInStream(image, options, callback) { }); } -/** Class representing a ComputerVisionAPIClient. */ -class ComputerVisionAPIClient extends ServiceClient { +/** Class representing a ComputerVisionClient. */ +class ComputerVisionClient extends ServiceClient { /** - * Create a ComputerVisionAPIClient. + * Create a ComputerVisionClient. * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. - * @param {azureRegions} azureRegion - Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' + * @param {string} endpoint - Supported Cognitive Services endpoints * @param {object} [options] - The parameter options * @param {Array} [options.filters] - Filters to be added to the request pipeline * @param {object} [options.requestOptions] - Options for the underlying request object * {@link https://github.com/request/request#requestoptions-callback Options doc} * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy */ - constructor(credentials, azureRegion, options) { + constructor(credentials, endpoint, options) { if (credentials === null || credentials === undefined) { throw new Error('\'credentials\' cannot be null.'); } - if (azureRegion === null || azureRegion === undefined) { - throw new Error('\'azureRegion\' cannot be null.'); + if (endpoint === null || endpoint === undefined) { + throw new Error('\'endpoint\' cannot be null.'); } if (!options) options = {}; super(credentials, options); - this.baseUri = 'https://{AzureRegion}.api.cognitive.microsoft.com/vision/v1.0'; + this.baseUri = '{Endpoint}/vision/v2.0'; this.credentials = credentials; - this.azureRegion = azureRegion; + this.endpoint = endpoint; let packageInfo = this.getPackageJsonInfo(__dirname); this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); @@ -2713,7 +2707,7 @@ class ComputerVisionAPIClient extends ServiceClient { * parameter to allow you to choose which features to return. By default, * image categories are returned in the response. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -2734,11 +2728,11 @@ class ComputerVisionAPIClient extends ServiceClient { * feature types include:Celebrities - identifies celebrities if detected in * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -2770,7 +2764,7 @@ class ComputerVisionAPIClient extends ServiceClient { * parameter to allow you to choose which features to return. By default, * image categories are returned in the response. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -2791,11 +2785,11 @@ class ComputerVisionAPIClient extends ServiceClient { * feature types include:Celebrities - identifies celebrities if detected in * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -2857,7 +2851,7 @@ class ComputerVisionAPIClient extends ServiceClient { * @param {number} height Height of the thumbnail. It must be between 1 and * 1024. Recommended minimum of 50. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -2902,7 +2896,7 @@ class ComputerVisionAPIClient extends ServiceClient { * @param {number} height Height of the thumbnail. It must be between 1 and * 1024. Recommended minimum of 50. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -2966,7 +2960,7 @@ class ComputerVisionAPIClient extends ServiceClient { * image orientation and correct it before further processing (e.g. if it's * upside-down). * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -3012,7 +3006,7 @@ class ComputerVisionAPIClient extends ServiceClient { * image orientation and correct it before further processing (e.g. if it's * upside-down). * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * @@ -3078,13 +3072,19 @@ class ComputerVisionAPIClient extends ServiceClient { * response will contain an error code and a message to help understand what * went wrong. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3119,13 +3119,19 @@ class ComputerVisionAPIClient extends ServiceClient { * response will contain an error code and a message to help understand what * went wrong. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3177,13 +3183,19 @@ class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3213,13 +3225,19 @@ class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3275,13 +3293,18 @@ class ComputerVisionAPIClient extends ServiceClient { * If the request failed, the response will contain an error code and a message * to help understand what went wrong. * - * @param {string} model The domain-specific content to recognize. Possible - * values include: 'Celebrities', 'Landmarks' + * @param {string} model The domain-specific content to recognize. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3315,13 +3338,18 @@ class ComputerVisionAPIClient extends ServiceClient { * If the request failed, the response will contain an error code and a message * to help understand what went wrong. * - * @param {string} model The domain-specific content to recognize. Possible - * values include: 'Celebrities', 'Landmarks' + * @param {string} model The domain-specific content to recognize. * - * @param {string} url + * @param {string} url Publicly reachable URL of an image * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3369,17 +3397,16 @@ class ComputerVisionAPIClient extends ServiceClient { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * - * @param {string} url + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {object} [options] Optional Parameters. + * @param {string} url Publicly reachable URL of an image * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -3390,11 +3417,11 @@ class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - recognizeTextWithHttpOperationResponse(url, options) { + recognizeTextWithHttpOperationResponse(url, mode, options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._recognizeText(url, options, (err, result, request, response) => { + self._recognizeText(url, mode, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -3406,17 +3433,16 @@ class ComputerVisionAPIClient extends ServiceClient { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * - * @param {string} url + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {object} [options] Optional Parameters. + * @param {string} url Publicly reachable URL of an image * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -3442,7 +3468,7 @@ class ComputerVisionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - recognizeText(url, options, optionalCallback) { + recognizeText(url, mode, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -3451,14 +3477,14 @@ class ComputerVisionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._recognizeText(url, options, (err, result, request, response) => { + self._recognizeText(url, mode, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._recognizeText(url, options, optionalCallback); + return self._recognizeText(url, mode, options, optionalCallback); } } @@ -3468,7 +3494,7 @@ class ComputerVisionAPIClient extends ServiceClient { * Recognize Text interface. * * @param {string} operationId Id of the text operation returned in the - * response of the 'Recognize Handwritten Text' + * response of the 'Recognize Text' * * @param {object} [options] Optional Parameters. * @@ -3501,7 +3527,7 @@ class ComputerVisionAPIClient extends ServiceClient { * Recognize Text interface. * * @param {string} operationId Id of the text operation returned in the - * response of the 'Recognize Handwritten Text' + * response of the 'Recognize Text' * * @param {object} [options] Optional Parameters. * @@ -3570,16 +3596,16 @@ class ComputerVisionAPIClient extends ServiceClient { * black&white.Adult - detects if the image is pornographic in nature (depicts * nudity or a sex act). Sexually suggestive content is also detected. * - * @param {string} [options.details] A string indicating which domain-specific + * @param {array} [options.details] A string indicating which domain-specific * details to return. Multiple values should be comma-separated. Valid visual * feature types include:Celebrities - identifies celebrities if detected in - * the image. Possible values include: 'Celebrities', 'Landmarks' + * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -3624,16 +3650,16 @@ class ComputerVisionAPIClient extends ServiceClient { * black&white.Adult - detects if the image is pornographic in nature (depicts * nudity or a sex act). Sexually suggestive content is also detected. * - * @param {string} [options.details] A string indicating which domain-specific + * @param {array} [options.details] A string indicating which domain-specific * details to return. Multiple values should be comma-separated. Valid visual * feature types include:Celebrities - identifies celebrities if detected in - * the image. Possible values include: 'Celebrities', 'Landmarks' + * the image. * - * @param {string} [options.language] A string indicating which language to - * return. The service will return recognition results in specified language. - * If this parameter is not specified, the default value is - * "en".Supported languages:en - English, Default.zh - Simplified - * Chinese. Possible values include: 'en', 'zh' + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -3920,9 +3946,15 @@ class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -3961,9 +3993,15 @@ class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * - * @param {string} [options.maxCandidates] Maximum number of candidate + * @param {number} [options.maxCandidates] Maximum number of candidate * descriptions to be returned. The default is 1. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4015,13 +4053,19 @@ class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * * @param {object} image An image stream. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4051,13 +4095,19 @@ class ComputerVisionAPIClient extends ServiceClient { * on objects, living beings, scenery or actions found in images. Unlike * categories, tags are not organized according to a hierarchical * classification system, but correspond to image content. Tags may contain - * hints to avoid ambiguity or provide context, for example the tag “cello” may - * be accompanied by the hint “musical instrument”. All tags are in English. + * hints to avoid ambiguity or provide context, for example the tag 'cello' may + * be accompanied by the hint 'musical instrument'. All tags are in English. * * @param {object} image An image stream. * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4119,6 +4169,12 @@ class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4158,6 +4214,12 @@ class ComputerVisionAPIClient extends ServiceClient { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.language] The desired language for output + * generation. If this parameter is not specified, the default value is + * "en".Supported languages:en - English, Default. es - Spanish, ja - + * Japanese, pt - Portuguese, zh - Simplified Chinese. Possible values include: + * 'en', 'es', 'ja', 'pt', 'zh' + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -4205,17 +4267,16 @@ class ComputerVisionAPIClient extends ServiceClient { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * * @param {object} image An image stream. * - * @param {object} [options] Optional Parameters. + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -4226,11 +4287,11 @@ class ComputerVisionAPIClient extends ServiceClient { * * @reject {Error} - The error object. */ - recognizeTextInStreamWithHttpOperationResponse(image, options) { + recognizeTextInStreamWithHttpOperationResponse(image, mode, options) { let client = this; let self = this; return new Promise((resolve, reject) => { - self._recognizeTextInStream(image, options, (err, result, request, response) => { + self._recognizeTextInStream(image, mode, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -4242,17 +4303,16 @@ class ComputerVisionAPIClient extends ServiceClient { /** * Recognize Text operation. When you use the Recognize Text interface, the - * response contains a field called “Operation-Location”. The - * “Operation-Location” field contains the URL that you must use for your Get - * Handwritten Text Operation Result operation. + * response contains a field called 'Operation-Location'. The + * 'Operation-Location' field contains the URL that you must use for your Get + * Recognize Text Operation Result operation. * * @param {object} image An image stream. * - * @param {object} [options] Optional Parameters. + * @param {string} mode Type of text to recognize. Possible values include: + * 'Handwritten', 'Printed' * - * @param {boolean} [options.detectHandwriting] If “true” is specified, - * handwriting recognition is performed. If this parameter is set to “false” or - * is not specified, printed text recognition is performed. + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -4278,7 +4338,7 @@ class ComputerVisionAPIClient extends ServiceClient { * * {stream} [response] - The HTTP Response stream if an error did not occur. */ - recognizeTextInStream(image, options, optionalCallback) { + recognizeTextInStream(image, mode, options, optionalCallback) { let client = this; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -4287,20 +4347,20 @@ class ComputerVisionAPIClient extends ServiceClient { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._recognizeTextInStream(image, options, (err, result, request, response) => { + self._recognizeTextInStream(image, mode, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._recognizeTextInStream(image, options, optionalCallback); + return self._recognizeTextInStream(image, mode, options, optionalCallback); } } } -module.exports = ComputerVisionAPIClient; -module.exports['default'] = ComputerVisionAPIClient; -module.exports.ComputerVisionAPIClient = ComputerVisionAPIClient; -module.exports.ComputerVisionAPIModels = models; +module.exports = ComputerVisionClient; +module.exports['default'] = ComputerVisionClient; +module.exports.ComputerVisionClient = ComputerVisionClient; +module.exports.ComputerVisionModels = models; diff --git a/lib/services/computerVision/lib/models/adultInfo.js b/lib/services/computerVision/lib/models/adultInfo.js index 5bcbbb905c..58525a446c 100644 --- a/lib/services/computerVision/lib/models/adultInfo.js +++ b/lib/services/computerVision/lib/models/adultInfo.js @@ -45,6 +45,7 @@ class AdultInfo { modelProperties: { isAdultContent: { required: false, + nullable: false, serializedName: 'isAdultContent', type: { name: 'Boolean' @@ -52,6 +53,7 @@ class AdultInfo { }, isRacyContent: { required: false, + nullable: false, serializedName: 'isRacyContent', type: { name: 'Boolean' @@ -59,6 +61,7 @@ class AdultInfo { }, adultScore: { required: false, + nullable: false, serializedName: 'adultScore', type: { name: 'Number' @@ -66,6 +69,7 @@ class AdultInfo { }, racyScore: { required: false, + nullable: false, serializedName: 'racyScore', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/category.js b/lib/services/computerVision/lib/models/category.js index ec05c90198..6eb031d7dc 100644 --- a/lib/services/computerVision/lib/models/category.js +++ b/lib/services/computerVision/lib/models/category.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An object describing identified category. * @@ -21,9 +19,11 @@ class Category { * Create a Category. * @member {string} [name] Name of the category. * @member {number} [score] Scoring of the category. - * @member {object} [detail] Additional category detail if available. + * @member {object} [detail] * @member {array} [detail.celebrities] An array of celebrities if any * identified. + * @member {array} [detail.landmarks] An array of landmarks if any + * identified. */ constructor() { } @@ -51,6 +51,7 @@ class Category { }, score: { required: false, + nullable: false, serializedName: 'score', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/categoryDetail.js b/lib/services/computerVision/lib/models/categoryDetail.js index e810bb4067..4718c5365c 100644 --- a/lib/services/computerVision/lib/models/categoryDetail.js +++ b/lib/services/computerVision/lib/models/categoryDetail.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An object describing additional category details. * @@ -20,6 +18,7 @@ class CategoryDetail { /** * Create a CategoryDetail. * @member {array} [celebrities] An array of celebrities if any identified. + * @member {array} [landmarks] An array of landmarks if any identified. */ constructor() { } @@ -52,6 +51,21 @@ class CategoryDetail { } } } + }, + landmarks: { + required: false, + serializedName: 'landmarks', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LandmarksModelElementType', + type: { + name: 'Composite', + className: 'LandmarksModel' + } + } + } } } } diff --git a/lib/services/computerVision/lib/models/celebritiesModel.js b/lib/services/computerVision/lib/models/celebritiesModel.js index 64017f715e..2d359b4fa2 100644 --- a/lib/services/computerVision/lib/models/celebritiesModel.js +++ b/lib/services/computerVision/lib/models/celebritiesModel.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An object describing possible celebrity identification. * @@ -57,6 +55,7 @@ class CelebritiesModel { }, confidence: { required: false, + nullable: false, serializedName: 'confidence', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/celebrityResults.js b/lib/services/computerVision/lib/models/celebrityResults.js new file mode 100644 index 0000000000..a467e5fa03 --- /dev/null +++ b/lib/services/computerVision/lib/models/celebrityResults.js @@ -0,0 +1,80 @@ +/* + * 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. + */ + +'use strict'; + +/** + * List of celebrities recognized in the image. + * + */ +class CelebrityResults { + /** + * Create a CelebrityResults. + * @member {array} [celebrities] + * @member {string} [requestId] Id of the REST API request. + * @member {object} [metadata] + * @member {number} [metadata.width] Image width + * @member {number} [metadata.height] Image height + * @member {string} [metadata.format] Image format + */ + constructor() { + } + + /** + * Defines the metadata of CelebrityResults + * + * @returns {object} metadata of CelebrityResults + * + */ + mapper() { + return { + required: false, + serializedName: 'CelebrityResults', + type: { + name: 'Composite', + className: 'CelebrityResults', + modelProperties: { + celebrities: { + required: false, + serializedName: 'celebrities', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CelebritiesModelElementType', + type: { + name: 'Composite', + className: 'CelebritiesModel' + } + } + } + }, + requestId: { + required: false, + serializedName: 'requestId', + type: { + name: 'String' + } + }, + metadata: { + required: false, + serializedName: 'metadata', + type: { + name: 'Composite', + className: 'ImageMetadata' + } + } + } + } + }; + } +} + +module.exports = CelebrityResults; diff --git a/lib/services/computerVision/lib/models/colorInfo.js b/lib/services/computerVision/lib/models/colorInfo.js index 879e6b8628..8bf9b9eacd 100644 --- a/lib/services/computerVision/lib/models/colorInfo.js +++ b/lib/services/computerVision/lib/models/colorInfo.js @@ -80,6 +80,7 @@ class ColorInfo { }, isBWImg: { required: false, + nullable: false, serializedName: 'isBWImg', type: { name: 'Boolean' diff --git a/lib/services/computerVision/lib/models/domainModelResults.js b/lib/services/computerVision/lib/models/domainModelResults.js index fb960d641c..dc04bef424 100644 --- a/lib/services/computerVision/lib/models/domainModelResults.js +++ b/lib/services/computerVision/lib/models/domainModelResults.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Result of image analysis using a specific domain model including additional * metadata. @@ -20,10 +18,9 @@ const models = require('./index'); class DomainModelResults { /** * Create a DomainModelResults. - * @member {array} [celebrities] An array of possible celebritied identified - * in the image. + * @member {object} [result] Model-specific response * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Additional image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format @@ -45,19 +42,11 @@ class DomainModelResults { name: 'Composite', className: 'DomainModelResults', modelProperties: { - celebrities: { + result: { required: false, - serializedName: 'result.celebrities', + serializedName: 'result', type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'CelebritiesModelElementType', - type: { - name: 'Composite', - className: 'CelebritiesModel' - } - } + name: 'Object' } }, requestId: { diff --git a/lib/services/computerVision/lib/models/faceDescription.js b/lib/services/computerVision/lib/models/faceDescription.js index c3228be77d..cb475e6926 100644 --- a/lib/services/computerVision/lib/models/faceDescription.js +++ b/lib/services/computerVision/lib/models/faceDescription.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An object describing a face identified in the image. * @@ -51,6 +49,7 @@ class FaceDescription { modelProperties: { age: { required: false, + nullable: false, serializedName: 'age', type: { name: 'Number' @@ -60,7 +59,8 @@ class FaceDescription { required: false, serializedName: 'gender', type: { - name: 'String' + name: 'Enum', + allowedValues: [ 'Male', 'Female' ] } }, faceRectangle: { diff --git a/lib/services/computerVision/lib/models/faceRectangle.js b/lib/services/computerVision/lib/models/faceRectangle.js index d1456c1e79..5f0c40d94b 100644 --- a/lib/services/computerVision/lib/models/faceRectangle.js +++ b/lib/services/computerVision/lib/models/faceRectangle.js @@ -43,6 +43,7 @@ class FaceRectangle { modelProperties: { left: { required: false, + nullable: false, serializedName: 'left', type: { name: 'Number' @@ -50,6 +51,7 @@ class FaceRectangle { }, top: { required: false, + nullable: false, serializedName: 'top', type: { name: 'Number' @@ -57,6 +59,7 @@ class FaceRectangle { }, width: { required: false, + nullable: false, serializedName: 'width', type: { name: 'Number' @@ -64,6 +67,7 @@ class FaceRectangle { }, height: { required: false, + nullable: false, serializedName: 'height', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/imageAnalysis.js b/lib/services/computerVision/lib/models/imageAnalysis.js index 403ff712cb..7d90e68c6a 100644 --- a/lib/services/computerVision/lib/models/imageAnalysis.js +++ b/lib/services/computerVision/lib/models/imageAnalysis.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Result of AnalyzeImage operation. * @@ -20,8 +18,7 @@ class ImageAnalysis { /** * Create a ImageAnalysis. * @member {array} [categories] An array indicating identified categories. - * @member {object} [adult] A property scoring on whether the image is - * adult-oriented and/or racy. + * @member {object} [adult] * @member {boolean} [adult.isAdultContent] A value indicating if the image * contains adult-oriented content. * @member {boolean} [adult.isRacyContent] A value indicating if the image is @@ -30,7 +27,7 @@ class ImageAnalysis { * much of adult content is within the image. * @member {number} [adult.racyScore] Score from 0 to 1 that indicates how * suggestive is the image. - * @member {object} [color] A property scoring on color spectrums. + * @member {object} [color] * @member {string} [color.dominantColorForeground] Possible dominant * foreground color. * @member {string} [color.dominantColorBackground] Possible dominant @@ -40,25 +37,19 @@ class ImageAnalysis { * @member {string} [color.accentColor] Possible accent color. * @member {boolean} [color.isBWImg] A value indicating if the image is black * and white. - * @member {object} [imageType] A property indicating type of image (whether - * it's clipart or line drawing) + * @member {object} [imageType] * @member {number} [imageType.clipArtType] Confidence level that the image * is a clip art. * @member {number} [imageType.lineDrawingType] Confidence level that the * image is a line drawing. * @member {array} [tags] A list of tags with confidence level. - * @member {object} [description] Description of the image. + * @member {object} [description] * @member {array} [description.tags] A collection of image tags. * @member {array} [description.captions] A list of captions, sorted by * confidence level. - * @member {string} [description.requestId] Id of the REST API request. - * @member {object} [description.metadata] Image metadata - * @member {number} [description.metadata.width] Image width - * @member {number} [description.metadata.height] Image height - * @member {string} [description.metadata.format] Image format * @member {array} [faces] An array of possible faces within the image. * @member {string} [requestId] Id of the request for tracking purposes. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format diff --git a/lib/services/computerVision/lib/models/imageCaption.js b/lib/services/computerVision/lib/models/imageCaption.js index 9e8b094787..e6b32dc698 100644 --- a/lib/services/computerVision/lib/models/imageCaption.js +++ b/lib/services/computerVision/lib/models/imageCaption.js @@ -47,6 +47,7 @@ class ImageCaption { }, confidence: { required: false, + nullable: false, serializedName: 'confidence', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/imageDescription.js b/lib/services/computerVision/lib/models/imageDescription.js index 3eae3446a5..3e2cf79f79 100644 --- a/lib/services/computerVision/lib/models/imageDescription.js +++ b/lib/services/computerVision/lib/models/imageDescription.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A collection of content tags, along with a list of captions sorted by * confidence level, and image metadata. @@ -23,7 +21,7 @@ class ImageDescription { * @member {array} [tags] A collection of image tags. * @member {array} [captions] A list of captions, sorted by confidence level. * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format @@ -76,14 +74,14 @@ class ImageDescription { }, requestId: { required: false, - serializedName: 'description.requestId', + serializedName: 'requestId', type: { name: 'String' } }, metadata: { required: false, - serializedName: 'description.metadata', + serializedName: 'metadata', type: { name: 'Composite', className: 'ImageMetadata' diff --git a/lib/services/computerVision/lib/models/imageDescriptionDetails.js b/lib/services/computerVision/lib/models/imageDescriptionDetails.js index 6a8cf6c228..728b711d0e 100644 --- a/lib/services/computerVision/lib/models/imageDescriptionDetails.js +++ b/lib/services/computerVision/lib/models/imageDescriptionDetails.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A collection of content tags, along with a list of captions sorted by * confidence level, and image metadata. @@ -22,11 +20,6 @@ class ImageDescriptionDetails { * Create a ImageDescriptionDetails. * @member {array} [tags] A collection of image tags. * @member {array} [captions] A list of captions, sorted by confidence level. - * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata - * @member {number} [metadata.width] Image width - * @member {number} [metadata.height] Image height - * @member {string} [metadata.format] Image format */ constructor() { } @@ -73,21 +66,6 @@ class ImageDescriptionDetails { } } } - }, - requestId: { - required: false, - serializedName: 'requestId', - type: { - name: 'String' - } - }, - metadata: { - required: false, - serializedName: 'metadata', - type: { - name: 'Composite', - className: 'ImageMetadata' - } } } } diff --git a/lib/services/computerVision/lib/models/imageMetadata.js b/lib/services/computerVision/lib/models/imageMetadata.js index c1fc151d66..0de0d93484 100644 --- a/lib/services/computerVision/lib/models/imageMetadata.js +++ b/lib/services/computerVision/lib/models/imageMetadata.js @@ -40,6 +40,7 @@ class ImageMetadata { modelProperties: { width: { required: false, + nullable: false, serializedName: 'width', type: { name: 'Number' @@ -47,6 +48,7 @@ class ImageMetadata { }, height: { required: false, + nullable: false, serializedName: 'height', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/imageTag.js b/lib/services/computerVision/lib/models/imageTag.js index c8234782f4..d77dd51ddb 100644 --- a/lib/services/computerVision/lib/models/imageTag.js +++ b/lib/services/computerVision/lib/models/imageTag.js @@ -20,6 +20,7 @@ class ImageTag { * @member {string} [name] The tag value * @member {number} [confidence] The level of confidence the service has in * the caption + * @member {string} [hint] Optional categorization for the tag */ constructor() { } @@ -47,10 +48,18 @@ class ImageTag { }, confidence: { required: false, + nullable: false, serializedName: 'confidence', type: { name: 'Number' } + }, + hint: { + required: false, + serializedName: 'hint', + type: { + name: 'String' + } } } } diff --git a/lib/services/computerVision/lib/models/imageType.js b/lib/services/computerVision/lib/models/imageType.js index e0db87503c..d22c9178b3 100644 --- a/lib/services/computerVision/lib/models/imageType.js +++ b/lib/services/computerVision/lib/models/imageType.js @@ -41,6 +41,7 @@ class ImageType { modelProperties: { clipArtType: { required: false, + nullable: false, serializedName: 'clipArtType', type: { name: 'Number' @@ -48,6 +49,7 @@ class ImageType { }, lineDrawingType: { required: false, + nullable: false, serializedName: 'lineDrawingType', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/imageUrl.js b/lib/services/computerVision/lib/models/imageUrl.js index 3feb6972d1..1727196bb1 100644 --- a/lib/services/computerVision/lib/models/imageUrl.js +++ b/lib/services/computerVision/lib/models/imageUrl.js @@ -16,7 +16,7 @@ class ImageUrl { /** * Create a ImageUrl. - * @member {string} url + * @member {string} url Publicly reachable URL of an image */ constructor() { } diff --git a/lib/services/computerVision/lib/models/index.d.ts b/lib/services/computerVision/lib/models/index.d.ts index 66e853c48d..dc24f7edd3 100644 --- a/lib/services/computerVision/lib/models/index.d.ts +++ b/lib/services/computerVision/lib/models/index.d.ts @@ -104,6 +104,20 @@ export interface CelebritiesModel { faceRectangle?: FaceRectangle; } +/** + * @class + * Initializes a new instance of the LandmarksModel class. + * @constructor + * A landmark recognized in the image + * + * @member {string} [name] Name of the landmark. + * @member {number} [confidence] Confidence level for the landmark recognition. + */ +export interface LandmarksModel { + name?: string; + confidence?: number; +} + /** * @class * Initializes a new instance of the CategoryDetail class. @@ -111,9 +125,11 @@ export interface CelebritiesModel { * An object describing additional category details. * * @member {array} [celebrities] An array of celebrities if any identified. + * @member {array} [landmarks] An array of landmarks if any identified. */ export interface CategoryDetail { celebrities?: CelebritiesModel[]; + landmarks?: LandmarksModel[]; } /** @@ -124,9 +140,10 @@ export interface CategoryDetail { * * @member {string} [name] Name of the category. * @member {number} [score] Scoring of the category. - * @member {object} [detail] Additional category detail if available. + * @member {object} [detail] * @member {array} [detail.celebrities] An array of celebrities if any * identified. + * @member {array} [detail.landmarks] An array of landmarks if any identified. */ export interface Category { name?: string; @@ -204,10 +221,12 @@ export interface ImageType { * @member {string} [name] The tag value * @member {number} [confidence] The level of confidence the service has in the * caption + * @member {string} [hint] Optional categorization for the tag */ export interface ImageTag { name?: string; confidence?: number; + hint?: string; } /** @@ -225,22 +244,6 @@ export interface ImageCaption { confidence?: number; } -/** - * @class - * Initializes a new instance of the ImageMetadata class. - * @constructor - * Image metadata - * - * @member {number} [width] Image width - * @member {number} [height] Image height - * @member {string} [format] Image format - */ -export interface ImageMetadata { - width?: number; - height?: number; - format?: string; -} - /** * @class * Initializes a new instance of the ImageDescriptionDetails class. @@ -250,17 +253,10 @@ export interface ImageMetadata { * * @member {array} [tags] A collection of image tags. * @member {array} [captions] A list of captions, sorted by confidence level. - * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata - * @member {number} [metadata.width] Image width - * @member {number} [metadata.height] Image height - * @member {string} [metadata.format] Image format */ export interface ImageDescriptionDetails { tags?: string[]; captions?: ImageCaption[]; - requestId?: string; - metadata?: ImageMetadata; } /** @@ -288,6 +284,22 @@ export interface FaceDescription { faceRectangle?: FaceRectangle; } +/** + * @class + * Initializes a new instance of the ImageMetadata class. + * @constructor + * Image metadata + * + * @member {number} [width] Image width + * @member {number} [height] Image height + * @member {string} [format] Image format + */ +export interface ImageMetadata { + width?: number; + height?: number; + format?: string; +} + /** * @class * Initializes a new instance of the ImageAnalysis class. @@ -295,8 +307,7 @@ export interface FaceDescription { * Result of AnalyzeImage operation. * * @member {array} [categories] An array indicating identified categories. - * @member {object} [adult] A property scoring on whether the image is - * adult-oriented and/or racy. + * @member {object} [adult] * @member {boolean} [adult.isAdultContent] A value indicating if the image * contains adult-oriented content. * @member {boolean} [adult.isRacyContent] A value indicating if the image is @@ -305,7 +316,7 @@ export interface FaceDescription { * much of adult content is within the image. * @member {number} [adult.racyScore] Score from 0 to 1 that indicates how * suggestive is the image. - * @member {object} [color] A property scoring on color spectrums. + * @member {object} [color] * @member {string} [color.dominantColorForeground] Possible dominant * foreground color. * @member {string} [color.dominantColorBackground] Possible dominant @@ -314,25 +325,19 @@ export interface FaceDescription { * @member {string} [color.accentColor] Possible accent color. * @member {boolean} [color.isBWImg] A value indicating if the image is black * and white. - * @member {object} [imageType] A property indicating type of image (whether - * it's clipart or line drawing) + * @member {object} [imageType] * @member {number} [imageType.clipArtType] Confidence level that the image is * a clip art. * @member {number} [imageType.lineDrawingType] Confidence level that the image * is a line drawing. * @member {array} [tags] A list of tags with confidence level. - * @member {object} [description] Description of the image. + * @member {object} [description] * @member {array} [description.tags] A collection of image tags. * @member {array} [description.captions] A list of captions, sorted by * confidence level. - * @member {string} [description.requestId] Id of the REST API request. - * @member {object} [description.metadata] Image metadata - * @member {number} [description.metadata.width] Image width - * @member {number} [description.metadata.height] Image height - * @member {string} [description.metadata.format] Image format * @member {array} [faces] An array of possible faces within the image. * @member {string} [requestId] Id of the request for tracking purposes. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format @@ -412,7 +417,8 @@ export interface OcrRegion { * @class * Initializes a new instance of the OcrResult class. * @constructor - * @member {object} [language] + * @member {string} [language] The BCP-47 language code of the text in the + * image. * @member {number} [textAngle] The angle, in degrees, of the detected text * with respect to the closest horizontal or vertical direction. After rotating * the input image clockwise by this angle, the recognized text lines become @@ -432,7 +438,7 @@ export interface OcrRegion { * a region of recognized text. */ export interface OcrResult { - language?: OcrResult; + language?: string; textAngle?: number; orientation?: string; regions?: OcrRegion[]; @@ -471,20 +477,57 @@ export interface ListModelsResult { * Result of image analysis using a specific domain model including additional * metadata. * - * @member {array} [celebrities] An array of possible celebritied identified in - * the image. + * @member {object} [result] Model-specific response * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Additional image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format */ export interface DomainModelResults { + result?: any; + requestId?: string; + metadata?: ImageMetadata; +} + +/** + * @class + * Initializes a new instance of the CelebrityResults class. + * @constructor + * List of celebrities recognized in the image. + * + * @member {array} [celebrities] + * @member {string} [requestId] Id of the REST API request. + * @member {object} [metadata] + * @member {number} [metadata.width] Image width + * @member {number} [metadata.height] Image height + * @member {string} [metadata.format] Image format + */ +export interface CelebrityResults { celebrities?: CelebritiesModel[]; requestId?: string; metadata?: ImageMetadata; } +/** + * @class + * Initializes a new instance of the LandmarkResults class. + * @constructor + * List of landmarks recognized in the image. + * + * @member {array} [landmarks] + * @member {string} [requestId] Id of the REST API request. + * @member {object} [metadata] + * @member {number} [metadata.width] Image width + * @member {number} [metadata.height] Image height + * @member {string} [metadata.format] Image format + */ +export interface LandmarkResults { + landmarks?: LandmarksModel[]; + requestId?: string; + metadata?: ImageMetadata; +} + /** * @class * Initializes a new instance of the ImageDescription class. @@ -495,7 +538,7 @@ export interface DomainModelResults { * @member {array} [tags] A collection of image tags. * @member {array} [captions] A list of captions, sorted by confidence level. * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format @@ -515,7 +558,7 @@ export interface ImageDescription { * * @member {array} [tags] A list of tags with confidence level. * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format @@ -549,7 +592,7 @@ export interface ComputerVisionError { * @class * Initializes a new instance of the ImageUrl class. * @constructor - * @member {string} url + * @member {string} url Publicly reachable URL of an image */ export interface ImageUrl { url: string; diff --git a/lib/services/computerVision/lib/models/index.js b/lib/services/computerVision/lib/models/index.js index 510ed06644..e56fc144a6 100644 --- a/lib/services/computerVision/lib/models/index.js +++ b/lib/services/computerVision/lib/models/index.js @@ -20,6 +20,7 @@ exports.RecognitionResult = require('./recognitionResult'); exports.TextOperationResult = require('./textOperationResult'); exports.FaceRectangle = require('./faceRectangle'); exports.CelebritiesModel = require('./celebritiesModel'); +exports.LandmarksModel = require('./landmarksModel'); exports.CategoryDetail = require('./categoryDetail'); exports.Category = require('./category'); exports.AdultInfo = require('./adultInfo'); @@ -27,9 +28,9 @@ exports.ColorInfo = require('./colorInfo'); exports.ImageType = require('./imageType'); exports.ImageTag = require('./imageTag'); exports.ImageCaption = require('./imageCaption'); -exports.ImageMetadata = require('./imageMetadata'); exports.ImageDescriptionDetails = require('./imageDescriptionDetails'); exports.FaceDescription = require('./faceDescription'); +exports.ImageMetadata = require('./imageMetadata'); exports.ImageAnalysis = require('./imageAnalysis'); exports.OcrWord = require('./ocrWord'); exports.OcrLine = require('./ocrLine'); @@ -38,6 +39,8 @@ exports.OcrResult = require('./ocrResult'); exports.ModelDescription = require('./modelDescription'); exports.ListModelsResult = require('./listModelsResult'); exports.DomainModelResults = require('./domainModelResults'); +exports.CelebrityResults = require('./celebrityResults'); +exports.LandmarkResults = require('./landmarkResults'); exports.ImageDescription = require('./imageDescription'); exports.TagResult = require('./tagResult'); exports.ComputerVisionError = require('./computerVisionError'); diff --git a/lib/services/computerVision/lib/models/landmarkResults.js b/lib/services/computerVision/lib/models/landmarkResults.js new file mode 100644 index 0000000000..56f3bae1a2 --- /dev/null +++ b/lib/services/computerVision/lib/models/landmarkResults.js @@ -0,0 +1,80 @@ +/* + * 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. + */ + +'use strict'; + +/** + * List of landmarks recognized in the image. + * + */ +class LandmarkResults { + /** + * Create a LandmarkResults. + * @member {array} [landmarks] + * @member {string} [requestId] Id of the REST API request. + * @member {object} [metadata] + * @member {number} [metadata.width] Image width + * @member {number} [metadata.height] Image height + * @member {string} [metadata.format] Image format + */ + constructor() { + } + + /** + * Defines the metadata of LandmarkResults + * + * @returns {object} metadata of LandmarkResults + * + */ + mapper() { + return { + required: false, + serializedName: 'LandmarkResults', + type: { + name: 'Composite', + className: 'LandmarkResults', + modelProperties: { + landmarks: { + required: false, + serializedName: 'landmarks', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LandmarksModelElementType', + type: { + name: 'Composite', + className: 'LandmarksModel' + } + } + } + }, + requestId: { + required: false, + serializedName: 'requestId', + type: { + name: 'String' + } + }, + metadata: { + required: false, + serializedName: 'metadata', + type: { + name: 'Composite', + className: 'ImageMetadata' + } + } + } + } + }; + } +} + +module.exports = LandmarkResults; diff --git a/lib/services/computerVision/lib/models/landmarkResultsLandmarksItem.js b/lib/services/computerVision/lib/models/landmarkResultsLandmarksItem.js new file mode 100644 index 0000000000..2a14231315 --- /dev/null +++ b/lib/services/computerVision/lib/models/landmarkResultsLandmarksItem.js @@ -0,0 +1,61 @@ +/* + * 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. + */ + +'use strict'; + +/** + * A landmark recognized in the image + * + */ +class LandmarkResultsLandmarksItem { + /** + * Create a LandmarkResultsLandmarksItem. + * @member {string} [name] Name of the landmark. + * @member {number} [confidence] Confidence level for the landmark + * recognition. + */ + constructor() { + } + + /** + * Defines the metadata of LandmarkResultsLandmarksItem + * + * @returns {object} metadata of LandmarkResultsLandmarksItem + * + */ + mapper() { + return { + required: false, + serializedName: 'LandmarkResults_landmarksItem', + type: { + name: 'Composite', + className: 'LandmarkResultsLandmarksItem', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + confidence: { + required: false, + serializedName: 'confidence', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = LandmarkResultsLandmarksItem; diff --git a/lib/services/computerVision/lib/models/landmarksModel.js b/lib/services/computerVision/lib/models/landmarksModel.js new file mode 100644 index 0000000000..ded34475a8 --- /dev/null +++ b/lib/services/computerVision/lib/models/landmarksModel.js @@ -0,0 +1,62 @@ +/* + * 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. + */ + +'use strict'; + +/** + * A landmark recognized in the image + * + */ +class LandmarksModel { + /** + * Create a LandmarksModel. + * @member {string} [name] Name of the landmark. + * @member {number} [confidence] Confidence level for the landmark + * recognition. + */ + constructor() { + } + + /** + * Defines the metadata of LandmarksModel + * + * @returns {object} metadata of LandmarksModel + * + */ + mapper() { + return { + required: false, + serializedName: 'LandmarksModel', + type: { + name: 'Composite', + className: 'LandmarksModel', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + confidence: { + required: false, + nullable: false, + serializedName: 'confidence', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = LandmarksModel; diff --git a/lib/services/computerVision/lib/models/line.js b/lib/services/computerVision/lib/models/line.js index 0b232d7e66..d81a85116c 100644 --- a/lib/services/computerVision/lib/models/line.js +++ b/lib/services/computerVision/lib/models/line.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class representing a Line. */ diff --git a/lib/services/computerVision/lib/models/listModelsResult.js b/lib/services/computerVision/lib/models/listModelsResult.js index 7b48245495..e507a26e6b 100644 --- a/lib/services/computerVision/lib/models/listModelsResult.js +++ b/lib/services/computerVision/lib/models/listModelsResult.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Result of the List Domain Models operation. * diff --git a/lib/services/computerVision/lib/models/ocrLine.js b/lib/services/computerVision/lib/models/ocrLine.js index fc7321924c..3299e2d9e0 100644 --- a/lib/services/computerVision/lib/models/ocrLine.js +++ b/lib/services/computerVision/lib/models/ocrLine.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * An object describing a single recognized line of text. * diff --git a/lib/services/computerVision/lib/models/ocrRegion.js b/lib/services/computerVision/lib/models/ocrRegion.js index ec88fefd8e..1c59ca3608 100644 --- a/lib/services/computerVision/lib/models/ocrRegion.js +++ b/lib/services/computerVision/lib/models/ocrRegion.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * A region consists of multiple lines (e.g. a column of text in a multi-column * document). diff --git a/lib/services/computerVision/lib/models/ocrResult.js b/lib/services/computerVision/lib/models/ocrResult.js index 5a0704d280..57b65d70a3 100644 --- a/lib/services/computerVision/lib/models/ocrResult.js +++ b/lib/services/computerVision/lib/models/ocrResult.js @@ -10,15 +10,14 @@ 'use strict'; -const models = require('./index'); - /** * Class representing a OcrResult. */ class OcrResult { /** * Create a OcrResult. - * @member {object} [language] + * @member {string} [language] The BCP-47 language code of the text in the + * image. * @member {number} [textAngle] The angle, in degrees, of the detected text * with respect to the closest horizontal or vertical direction. After * rotating the input image clockwise by this angle, the recognized text @@ -58,12 +57,12 @@ class OcrResult { required: false, serializedName: 'language', type: { - name: 'Composite', - className: 'OcrResult' + name: 'String' } }, textAngle: { required: false, + nullable: false, serializedName: 'textAngle', type: { name: 'Number' diff --git a/lib/services/computerVision/lib/models/recognitionResult.js b/lib/services/computerVision/lib/models/recognitionResult.js index 3e91015cae..1a0ed5b46e 100644 --- a/lib/services/computerVision/lib/models/recognitionResult.js +++ b/lib/services/computerVision/lib/models/recognitionResult.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class representing a RecognitionResult. */ diff --git a/lib/services/computerVision/lib/models/tagResult.js b/lib/services/computerVision/lib/models/tagResult.js index 6bc33ce148..d86538fb5a 100644 --- a/lib/services/computerVision/lib/models/tagResult.js +++ b/lib/services/computerVision/lib/models/tagResult.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * The results of a image tag operation, including any tags and image metadata. * @@ -21,7 +19,7 @@ class TagResult { * Create a TagResult. * @member {array} [tags] A list of tags with confidence level. * @member {string} [requestId] Id of the REST API request. - * @member {object} [metadata] Image metadata + * @member {object} [metadata] * @member {number} [metadata.width] Image width * @member {number} [metadata.height] Image height * @member {string} [metadata.format] Image format diff --git a/lib/services/computerVision/lib/models/textOperationResult.js b/lib/services/computerVision/lib/models/textOperationResult.js index 8d2834fb01..5117cade6e 100644 --- a/lib/services/computerVision/lib/models/textOperationResult.js +++ b/lib/services/computerVision/lib/models/textOperationResult.js @@ -10,8 +10,6 @@ 'use strict'; -const models = require('./index'); - /** * Class representing a TextOperationResult. */ @@ -42,6 +40,7 @@ class TextOperationResult { modelProperties: { status: { required: false, + nullable: false, serializedName: 'status', type: { name: 'Enum', diff --git a/lib/services/computerVision/package-lock.json b/lib/services/computerVision/package-lock.json new file mode 100644 index 0000000000..3ba6b5401d --- /dev/null +++ b/lib/services/computerVision/package-lock.json @@ -0,0 +1,385 @@ +{ + "name": "azure-cognitiveservices-computervision", + "version": "3.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "requires": { + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" + } + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "fast-deep-equal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "^1.0.0" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", + "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "requires": { + "ajv": "^5.3.0", + "har-schema": "^2.0.0" + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "mime-db": { + "version": "1.35.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz", + "integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==" + }, + "mime-types": { + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz", + "integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==", + "requires": { + "mime-db": "~1.35.0" + } + }, + "moment": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" + }, + "ms-rest": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/ms-rest/-/ms-rest-2.3.6.tgz", + "integrity": "sha512-M+Lx9P7Wy4TeAk7jqPLwGS1QS1gvxF6Xo+OHv5j1g3Kcb44T/GTUuSjxTKarF6aKyeacZH1ZD++Nt7pcql7dDA==", + "requires": { + "duplexer": "^0.1.1", + "is-buffer": "^1.1.6", + "is-stream": "^1.1.0", + "moment": "^2.21.0", + "request": "^2.87.0", + "through": "^2.3.8", + "tunnel": "0.0.5", + "uuid": "^3.2.1" + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sshpk": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", + "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + }, + "tunnel": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz", + "integrity": "sha512-gj5sdqherx4VZKMcBA4vewER7zdK25Td+z1npBqpbDys4eJrLx+SlYjJvq1bDXs2irkuJM5pf8ktaEQVipkrbA==" + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + } + } +} diff --git a/lib/services/computerVision/package.json b/lib/services/computerVision/package.json index ca99a6d703..3cec76a6a3 100644 --- a/lib/services/computerVision/package.json +++ b/lib/services/computerVision/package.json @@ -1,21 +1,24 @@ { "name": "azure-cognitiveservices-computervision", "author": "Microsoft Corporation", - "description": "ComputerVisionAPIClient Library with typescript type definitions for node", - "version": "1.0.1", + "description": "ComputerVisionClient Library with typescript type definitions for node", + "version": "3.0.0", "dependencies": { - "ms-rest": "^2.3.2" + "ms-rest": "^2.3.3" }, - "keywords": [ "node", "azure" ], + "keywords": [ + "node", + "azure" + ], "license": "MIT", - "main": "./lib/computerVisionAPIClient.js", - "types": "./lib/computerVisionAPIClient.d.ts", - "homepage": "http://github.com/azure/azure-sdk-for-node", + "main": "./lib/computerVisionClient.js", + "types": "./lib/computerVisionClient.d.ts", + "homepage": "https://github.com/azure/azure-sdk-for-node/tree/master/lib/services/computerVision", "repository": { "type": "git", "url": "https://github.com/azure/azure-sdk-for-node.git" }, "bugs": { - "url": "http://github.com/Azure/azure-sdk-for-node/issues" + "url": "https://github.com/azure/azure-sdk-for-node/issues" } } diff --git a/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_wolves.nock.js b/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_wolves.nock.js index d8d99d0fab..074344bb20 100644 --- a/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_wolves.nock.js +++ b/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_wolves.nock.js @@ -9,7 +9,7 @@ exports.scopes = [[function (nock) { var result = nock('https://westus.api.cognitive.microsoft.com:443') .filteringRequestBody(function (path) { return '*';}) -.post('/vision/v1.0/analyze?visualFeatures=Categories%2CTags%2CDescription&language=en', '*') +.post('/vision/v2.0/analyze?visualFeatures=Categories%2CTags%2CDescription&language=en', '*') .reply(200, "{\"categories\":[{\"name\":\"others_\",\"score\":0.015625},{\"name\":\"outdoor_\",\"score\":0.00390625}],\"tags\":[{\"name\":\"animal\",\"confidence\":0.99737191200256348},{\"name\":\"mammal\",\"confidence\":0.94876688718795776,\"hint\":\"animal\"},{\"name\":\"wolf\",\"confidence\":0.86433804035186768,\"hint\":\"animal\"}],\"description\":{\"tags\":[\"animal\",\"mammal\",\"wolf\",\"looking\",\"sitting\",\"bear\",\"standing\",\"black\",\"top\",\"cat\",\"dark\",\"white\",\"face\",\"close\",\"laying\",\"large\",\"brown\",\"water\",\"snow\"],\"captions\":[{\"text\":\"a close up of a wolf\",\"confidence\":0.77825483485410529}]},\"requestId\":\"31f79dee-fd70-4134-8214-0c51ab8179ae\",\"metadata\":{\"width\":960,\"height\":595,\"format\":\"Jpeg\"}}", { 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '644', diff --git a/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_words_I_Love_You.nock.js b/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_words_I_Love_You.nock.js index 5b981c4ecf..9dab132ea8 100644 --- a/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_words_I_Love_You.nock.js +++ b/test/recordings/computervision-tests/Computer_Vision_Analyze_image._should_detect_words_I_Love_You.nock.js @@ -9,12 +9,12 @@ exports.scopes = [[function (nock) { var result = nock('https://westus.api.cognitive.microsoft.com:443') .filteringRequestBody(function (path) { return '*';}) -.post('/vision/v1.0/recognizeText?detectHandwriting=false', '*') +.post('/vision/v2.0/recognizeText?mode=Printed', '*') .reply(202, "", { 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '0', expires: '-1', - 'operation-location': 'https://westus.api.cognitive.microsoft.com/vision/v1.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978', + 'operation-location': 'https://westus.api.cognitive.microsoft.com/vision/v2.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978', 'x-aspnet-version': '4.0.30319', 'x-powered-by': 'ASP.NET', 'apim-request-id': '537a1743-3545-4372-9378-94db04de93dc', @@ -26,7 +26,7 @@ nock('https://westus.api.cognitive.microsoft.com:443') function (nock) { var result = nock('https://westus.api.cognitive.microsoft.com:443') - .get('/vision/v1.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978') + .get('/vision/v2.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978') .reply(200, "{\"status\":\"Running\"}", { 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '20', @@ -43,7 +43,7 @@ nock('https://westus.api.cognitive.microsoft.com:443') function (nock) { var result = nock('https://westus.api.cognitive.microsoft.com:443') - .get('/vision/v1.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978') + .get('/vision/v2.0/textOperations/59af55bf-2e0e-43f7-a4aa-ec0b8e2ae978') .reply(200, "{\"status\":\"Succeeded\",\"recognitionResult\":{\"lines\":[{\"boundingBox\":[64,55,445,58,444,120,63,118],\"text\":\"I Love You\",\"words\":[{\"boundingBox\":[65,58,110,58,110,122,65,122],\"text\":\"I\"},{\"boundingBox\":[88,58,293,58,293,122,89,122],\"text\":\"Love\"},{\"boundingBox\":[279,58,455,58,455,122,279,122],\"text\":\"You\"}]}]}}", { 'cache-control': 'no-cache', pragma: 'no-cache', 'content-length': '308', diff --git a/test/services/cognitiveServicesVision/computerVisionAPIClient-tests.js b/test/services/cognitiveServicesVision/computerVisionClient-tests.js similarity index 100% rename from test/services/cognitiveServicesVision/computerVisionAPIClient-tests.js rename to test/services/cognitiveServicesVision/computerVisionClient-tests.js