diff --git a/packages/@azure/cognitiveservices-anomalydetector/LICENSE.txt b/packages/@azure/cognitiveservices-anomalydetector/LICENSE.txt new file mode 100644 index 000000000000..8f3d856145c5 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 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/packages/@azure/cognitiveservices-anomalydetector/README.md b/packages/@azure/cognitiveservices-anomalydetector/README.md new file mode 100644 index 000000000000..34073f21fef5 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/README.md @@ -0,0 +1,116 @@ +## An isomorphic javascript sdk for - AnomalyDetectorClient + +This package contains an isomorphic SDK for AnomalyDetectorClient. + +### Currently supported environments + +- Node.js version 6.x.x or higher +- Browser JavaScript + +### How to Install + +```bash +npm install @azure/cognitiveservices-anomalydetector +``` + +### How to use + +#### nodejs - Authentication, client creation and entireDetect as an example written in TypeScript. + +##### Install @azure/ms-rest-nodeauth + +```bash +npm install @azure/ms-rest-nodeauth +``` + +##### Sample code + +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { AnomalyDetectorClient, AnomalyDetectorModels, AnomalyDetectorMappers } from "@azure/cognitiveservices-anomalydetector"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new AnomalyDetectorClient(creds, subscriptionId); + const body: AnomalyDetectorModels.Request = { + series: [{ + timestamp: new Date().toISOString(), + value: 1.01 + }], + granularity: "yearly", + customInterval: 1, + period: 1, + maxAnomalyRatio: 1.01, + sensitivity: 1 + }; + client.entireDetect(body).then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); +``` + +#### browser - Authentication, client creation and entireDetect as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` + +##### Sample code + +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. + +- index.html +```html + + + + @azure/cognitiveservices-anomalydetector sample + + + + + + + +``` + +## Related projects + +- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) diff --git a/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClient.ts b/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClient.ts new file mode 100644 index 000000000000..c552f1fde50b --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClient.ts @@ -0,0 +1,153 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; +import * as Models from "./models"; +import * as Mappers from "./models/mappers"; +import * as Parameters from "./models/parameters"; +import { AnomalyDetectorClientContext } from "./anomalyDetectorClientContext"; + +class AnomalyDetectorClient extends AnomalyDetectorClientContext { + /** + * Initializes a new instance of the AnomalyDetectorClient class. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(endpoint: string, credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + super(endpoint, credentials, options); + } + + /** + * This operation generates a model using an entire series, each point is detected with the same + * model. With this method, points before and after a certain point are used to determine whether + * it is an anomaly. The entire detection can give user an overall status of the time series. + * @summary Detect anomalies for the entire series in batch. + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param [options] The optional parameters + * @returns Promise + */ + entireDetect(body: Models.Request, options?: msRest.RequestOptionsBase): Promise; + /** + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param callback The callback + */ + entireDetect(body: Models.Request, callback: msRest.ServiceCallback): void; + /** + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param options The optional parameters + * @param callback The callback + */ + entireDetect(body: Models.Request, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + entireDetect(body: Models.Request, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + body, + options + }, + entireDetectOperationSpec, + callback) as Promise; + } + + /** + * This operation generates a model using points before the latest one. With this method, only + * historical points are used to determine whether the target point is an anomaly. The latest point + * detecting operation matches the scenario of real-time monitoring of business metrics. + * @summary Detect anomaly status of the latest point in time series. + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param [options] The optional parameters + * @returns Promise + */ + lastDetect(body: Models.Request, options?: msRest.RequestOptionsBase): Promise; + /** + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param callback The callback + */ + lastDetect(body: Models.Request, callback: msRest.ServiceCallback): void; + /** + * @param body Time series points and period if needed. Advanced model parameters can also be set + * in the request. + * @param options The optional parameters + * @param callback The callback + */ + lastDetect(body: Models.Request, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + lastDetect(body: Models.Request, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + body, + options + }, + lastDetectOperationSpec, + callback) as Promise; + } +} + +// Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const entireDetectOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "timeseries/entire/detect", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.Request, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.EntireDetectResponse + }, + default: { + bodyMapper: Mappers.APIError + } + }, + serializer +}; + +const lastDetectOperationSpec: msRest.OperationSpec = { + httpMethod: "POST", + path: "timeseries/last/detect", + urlParameters: [ + Parameters.endpoint + ], + requestBody: { + parameterPath: "body", + mapper: { + ...Mappers.Request, + required: true + } + }, + responses: { + 200: { + bodyMapper: Mappers.LastDetectResponse + }, + default: { + bodyMapper: Mappers.APIError + } + }, + serializer +}; + +export { + AnomalyDetectorClient, + AnomalyDetectorClientContext, + Models as AnomalyDetectorModels, + Mappers as AnomalyDetectorMappers +}; diff --git a/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClientContext.ts b/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClientContext.ts new file mode 100644 index 000000000000..10a3bcfaa2c7 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/lib/anomalyDetectorClientContext.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +const packageName = "@azure/cognitiveservices-anomalydetector"; +const packageVersion = "1.0.0"; + +export class AnomalyDetectorClientContext extends msRest.ServiceClient { + endpoint: string; + credentials: msRest.ServiceClientCredentials; + + /** + * Initializes a new instance of the AnomalyDetectorClientContext class. + * @param endpoint Supported Cognitive Services endpoints (protocol and hostname, for example: + * https://westus2.api.cognitive.microsoft.com). + * @param credentials Subscription credentials which uniquely identify client subscription. + * @param [options] The parameter options + */ + constructor(endpoint: string, credentials: msRest.ServiceClientCredentials, options?: msRest.ServiceClientOptions) { + if (endpoint === null || endpoint === undefined) { + throw new Error('\'endpoint\' cannot be null.'); + } + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) { + options = {}; + } + if(!options.userAgent) { + const defaultUserAgent = msRest.getDefaultUserAgentValue(); + options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; + } + + super(credentials, options); + + this.baseUri = "{Endpoint}"; + this.requestContentType = "application/json; charset=utf-8"; + this.endpoint = endpoint; + this.credentials = credentials; + + } +} diff --git a/packages/@azure/cognitiveservices-anomalydetector/lib/models/index.ts b/packages/@azure/cognitiveservices-anomalydetector/lib/models/index.ts new file mode 100644 index 000000000000..24e6005047c6 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/lib/models/index.ts @@ -0,0 +1,246 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +/** + * @interface + * An interface representing APIError. + * Error information returned by the API. + * + */ +export interface APIError { + /** + * @member {any} [code] The error code. + */ + code?: any; + /** + * @member {string} [message] A message explaining the error reported by the + * service. + */ + message?: string; +} + +/** + * @interface + * An interface representing Point. + */ +export interface Point { + /** + * @member {Date} timestamp Timestamp of a data point (ISO8601 format). + */ + timestamp: Date; + /** + * @member {number} value The measurement of that point, should be float. + */ + value: number; +} + +/** + * @interface + * An interface representing Request. + */ +export interface Request { + /** + * @member {Point[]} series Time series data points. Points should be sorted + * by timestamp in ascending order to match the anomaly detection result. If + * the data is not sorted correctly or there is duplicated timestamp, the API + * will not work. In such case, an error message will be returned. + */ + series: Point[]; + /** + * @member {Granularity} granularity Can only be one of yearly, monthly, + * weekly, daily, hourly or minutely. Granularity is used for verify whether + * input series is valid. Possible values include: 'yearly', 'monthly', + * 'weekly', 'daily', 'hourly', 'minutely' + */ + granularity: Granularity; + /** + * @member {number} [customInterval] Custom Interval is used to set + * non-standard time interval, for example, if the series is 5 minutes, + * request can be set as {"granularity":"minutely", "customInterval":5}. + */ + customInterval?: number; + /** + * @member {number} [period] Optional argument, periodic value of a time + * series. If the value is null or does not present, the API will determine + * the period automatically. + */ + period?: number; + /** + * @member {number} [maxAnomalyRatio] Optional argument, advanced model + * parameter, max anomaly ratio in a time series. + */ + maxAnomalyRatio?: number; + /** + * @member {number} [sensitivity] Optional argument, advanced model + * parameter, between 0-99, the lower the value is, the larger the margin + * value will be which means less anomalies will be accepted. + */ + sensitivity?: number; +} + +/** + * @interface + * An interface representing EntireDetectResponse. + */ +export interface EntireDetectResponse { + /** + * @member {number} period Frequency extracted from the series, zero means no + * recurrent pattern has been found. + */ + period: number; + /** + * @member {number[]} expectedValues ExpectedValues contain expected value + * for each input point. The index of the array is consistent with the input + * series. + */ + expectedValues: number[]; + /** + * @member {number[]} upperMargins UpperMargins contain upper margin of each + * input point. UpperMargin is used to calculate upperBoundary, which equals + * to expectedValue + (100 - marginScale)*upperMargin. Anomalies in response + * can be filtered by upperBoundary and lowerBoundary. By adjusting + * marginScale value, less significant anomalies can be filtered in client + * side. The index of the array is consistent with the input series. + */ + upperMargins: number[]; + /** + * @member {number[]} lowerMargins LowerMargins contain lower margin of each + * input point. LowerMargin is used to calculate lowerBoundary, which equals + * to expectedValue - (100 - marginScale)*lowerMargin. Points between the + * boundary can be marked as normal ones in client side. The index of the + * array is consistent with the input series. + */ + lowerMargins: number[]; + /** + * @member {boolean[]} isAnomaly IsAnomaly contains anomaly properties for + * each input point. True means an anomaly either negative or positive has + * been detected. The index of the array is consistent with the input series. + */ + isAnomaly: boolean[]; + /** + * @member {boolean[]} isNegativeAnomaly IsNegativeAnomaly contains anomaly + * status in negative direction for each input point. True means a negative + * anomaly has been detected. A negative anomaly means the point is detected + * as an anomaly and its real value is smaller than the expected one. The + * index of the array is consistent with the input series. + */ + isNegativeAnomaly: boolean[]; + /** + * @member {boolean[]} isPositiveAnomaly IsPositiveAnomaly contain anomaly + * status in positive direction for each input point. True means a positive + * anomaly has been detected. A positive anomaly means the point is detected + * as an anomaly and its real value is larger than the expected one. The + * index of the array is consistent with the input series. + */ + isPositiveAnomaly: boolean[]; +} + +/** + * @interface + * An interface representing LastDetectResponse. + */ +export interface LastDetectResponse { + /** + * @member {number} period Frequency extracted from the series, zero means no + * recurrent pattern has been found. + */ + period: number; + /** + * @member {number} suggestedWindow Suggested input series points needed for + * detecting the latest point. + */ + suggestedWindow: number; + /** + * @member {number} expectedValue Expected value of the latest point. + */ + expectedValue: number; + /** + * @member {number} upperMargin Upper margin of the latest point. UpperMargin + * is used to calculate upperBoundary, which equals to expectedValue + (100 - + * marginScale)*upperMargin. If the value of latest point is between + * upperBoundary and lowerBoundary, it should be treated as normal value. By + * adjusting marginScale value, anomaly status of latest point can be + * changed. + */ + upperMargin: number; + /** + * @member {number} lowerMargin Lower margin of the latest point. LowerMargin + * is used to calculate lowerBoundary, which equals to expectedValue - (100 - + * marginScale)*lowerMargin. + */ + lowerMargin: number; + /** + * @member {boolean} isAnomaly Anomaly status of the latest point, true means + * the latest point is an anomaly either in negative direction or positive + * direction. + */ + isAnomaly: boolean; + /** + * @member {boolean} isNegativeAnomaly Anomaly status in negative direction + * of the latest point. True means the latest point is an anomaly and its + * real value is smaller than the expected one. + */ + isNegativeAnomaly: boolean; + /** + * @member {boolean} isPositiveAnomaly Anomaly status in positive direction + * of the latest point. True means the latest point is an anomaly and its + * real value is larger than the expected one. + */ + isPositiveAnomaly: boolean; +} + +/** + * Defines values for Granularity. + * Possible values include: 'yearly', 'monthly', 'weekly', 'daily', 'hourly', 'minutely' + * @readonly + * @enum {string} + */ +export type Granularity = 'yearly' | 'monthly' | 'weekly' | 'daily' | 'hourly' | 'minutely'; + +/** + * Contains response data for the entireDetect operation. + */ +export type EntireDetectResponse2 = EntireDetectResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: EntireDetectResponse; + }; +}; + +/** + * Contains response data for the lastDetect operation. + */ +export type LastDetectResponse2 = LastDetectResponse & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + /** + * The response body as parsed JSON or XML + */ + parsedBody: LastDetectResponse; + }; +}; diff --git a/packages/@azure/cognitiveservices-anomalydetector/lib/models/mappers.ts b/packages/@azure/cognitiveservices-anomalydetector/lib/models/mappers.ts new file mode 100644 index 000000000000..0ffc90ee8e0d --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/lib/models/mappers.ts @@ -0,0 +1,275 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + + +export const APIError: msRest.CompositeMapper = { + serializedName: "APIError", + type: { + name: "Composite", + className: "APIError", + modelProperties: { + code: { + serializedName: "code", + type: { + name: "Object" + } + }, + message: { + serializedName: "message", + type: { + name: "String" + } + } + } + } +}; + +export const Point: msRest.CompositeMapper = { + serializedName: "Point", + type: { + name: "Composite", + className: "Point", + modelProperties: { + timestamp: { + required: true, + serializedName: "timestamp", + type: { + name: "DateTime" + } + }, + value: { + required: true, + serializedName: "value", + type: { + name: "Number" + } + } + } + } +}; + +export const Request: msRest.CompositeMapper = { + serializedName: "Request", + type: { + name: "Composite", + className: "Request", + modelProperties: { + series: { + required: true, + serializedName: "series", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Point" + } + } + } + }, + granularity: { + required: true, + serializedName: "granularity", + type: { + name: "Enum", + allowedValues: [ + "yearly", + "monthly", + "weekly", + "daily", + "hourly", + "minutely" + ] + } + }, + customInterval: { + serializedName: "customInterval", + type: { + name: "Number" + } + }, + period: { + serializedName: "period", + type: { + name: "Number" + } + }, + maxAnomalyRatio: { + serializedName: "maxAnomalyRatio", + type: { + name: "Number" + } + }, + sensitivity: { + serializedName: "sensitivity", + type: { + name: "Number" + } + } + } + } +}; + +export const EntireDetectResponse: msRest.CompositeMapper = { + serializedName: "EntireDetectResponse", + type: { + name: "Composite", + className: "EntireDetectResponse", + modelProperties: { + period: { + required: true, + serializedName: "period", + type: { + name: "Number" + } + }, + expectedValues: { + required: true, + serializedName: "expectedValues", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + upperMargins: { + required: true, + serializedName: "upperMargins", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + lowerMargins: { + required: true, + serializedName: "lowerMargins", + type: { + name: "Sequence", + element: { + type: { + name: "Number" + } + } + } + }, + isAnomaly: { + required: true, + serializedName: "isAnomaly", + type: { + name: "Sequence", + element: { + type: { + name: "Boolean" + } + } + } + }, + isNegativeAnomaly: { + required: true, + serializedName: "isNegativeAnomaly", + type: { + name: "Sequence", + element: { + type: { + name: "Boolean" + } + } + } + }, + isPositiveAnomaly: { + required: true, + serializedName: "isPositiveAnomaly", + type: { + name: "Sequence", + element: { + type: { + name: "Boolean" + } + } + } + } + } + } +}; + +export const LastDetectResponse: msRest.CompositeMapper = { + serializedName: "LastDetectResponse", + type: { + name: "Composite", + className: "LastDetectResponse", + modelProperties: { + period: { + required: true, + serializedName: "period", + type: { + name: "Number" + } + }, + suggestedWindow: { + required: true, + serializedName: "suggestedWindow", + type: { + name: "Number" + } + }, + expectedValue: { + required: true, + serializedName: "expectedValue", + type: { + name: "Number" + } + }, + upperMargin: { + required: true, + serializedName: "upperMargin", + type: { + name: "Number" + } + }, + lowerMargin: { + required: true, + serializedName: "lowerMargin", + type: { + name: "Number" + } + }, + isAnomaly: { + required: true, + serializedName: "isAnomaly", + type: { + name: "Boolean" + } + }, + isNegativeAnomaly: { + required: true, + serializedName: "isNegativeAnomaly", + type: { + name: "Boolean" + } + }, + isPositiveAnomaly: { + required: true, + serializedName: "isPositiveAnomaly", + type: { + name: "Boolean" + } + } + } + } +}; diff --git a/packages/@azure/cognitiveservices-anomalydetector/lib/models/parameters.ts b/packages/@azure/cognitiveservices-anomalydetector/lib/models/parameters.ts new file mode 100644 index 000000000000..ef1746ab6352 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/lib/models/parameters.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as msRest from "@azure/ms-rest-js"; + +export const endpoint: msRest.OperationURLParameter = { + parameterPath: "endpoint", + mapper: { + required: true, + serializedName: "Endpoint", + defaultValue: '', + type: { + name: "String" + } + }, + skipEncoding: true +}; diff --git a/packages/@azure/cognitiveservices-anomalydetector/package.json b/packages/@azure/cognitiveservices-anomalydetector/package.json new file mode 100644 index 000000000000..18efa847cf43 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/package.json @@ -0,0 +1,55 @@ +{ + "name": "@azure/cognitiveservices-anomalydetector", + "author": "Microsoft Corporation", + "description": "AnomalyDetectorClient Library with typescript type definitions for node.js and browser.", + "version": "1.0.0", + "dependencies": { + "@azure/ms-rest-js": "^1.2.0", + "tslib": "^1.9.3" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/cognitiveservices-anomalydetector.js", + "module": "./esm/anomalyDetectorClient.js", + "types": "./esm/anomalyDetectorClient.d.ts", + "devDependencies": { + "typescript": "^3.1.1", + "rollup": "^0.66.2", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "uglify-js": "^3.4.9" + }, + "homepage": "https://github.com/azure/azure-sdk-for-js/tree/master/packages/@azure/cognitiveservices-anomalydetector", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-js.git" + }, + "bugs": { + "url": "https://github.com/azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/**/*.js", + "dist/**/*.js.map", + "dist/**/*.d.ts", + "dist/**/*.d.ts.map", + "esm/**/*.js", + "esm/**/*.js.map", + "esm/**/*.d.ts", + "esm/**/*.d.ts.map", + "lib/**/*.ts", + "rollup.config.js", + "tsconfig.json" + ], + "scripts": { + "build": "tsc && rollup -c rollup.config.js && npm run minify", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/cognitiveservices-anomalydetector.js.map'\" -o ./dist/cognitiveservices-anomalydetector.min.js ./dist/cognitiveservices-anomalydetector.js", + "prepack": "npm install && npm run build" + }, + "sideEffects": false +} diff --git a/packages/@azure/cognitiveservices-anomalydetector/rollup.config.js b/packages/@azure/cognitiveservices-anomalydetector/rollup.config.js new file mode 100644 index 000000000000..a9d5ddc52218 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/rollup.config.js @@ -0,0 +1,37 @@ +import rollup from "rollup"; +import nodeResolve from "rollup-plugin-node-resolve"; +import sourcemaps from "rollup-plugin-sourcemaps"; + +/** + * @type {rollup.RollupFileOptions} + */ +const config = { + input: "./esm/anomalyDetectorClient.js", + external: [ + "@azure/ms-rest-js", + "@azure/ms-rest-azure-js" + ], + output: { + file: "./dist/cognitiveservices-anomalydetector.js", + format: "umd", + name: "Azure.CognitiveservicesAnomalydetector", + sourcemap: true, + globals: { + "@azure/ms-rest-js": "msRest", + "@azure/ms-rest-azure-js": "msRestAzure" + }, + banner: `/* + * 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. + */` + }, + plugins: [ + nodeResolve({ module: true }), + sourcemaps() + ] +}; + +export default config; diff --git a/packages/@azure/cognitiveservices-anomalydetector/tsconfig.json b/packages/@azure/cognitiveservices-anomalydetector/tsconfig.json new file mode 100644 index 000000000000..51ea90961ce5 --- /dev/null +++ b/packages/@azure/cognitiveservices-anomalydetector/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "es6", + "moduleResolution": "node", + "strict": true, + "target": "es5", + "sourceMap": true, + "declarationMap": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es6"], + "declaration": true, + "outDir": "./esm", + "importHelpers": true + }, + "include": ["./lib/**/*.ts"], + "exclude": ["node_modules"] +}