@azure-rest/ai-anomaly-detector 1.0.0-alpha.20221107.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/index.js +266 -0
- package/dist/index.js.map +1 -0
- package/dist-esm/src/anomalyDetectorRest.js +27 -0
- package/dist-esm/src/anomalyDetectorRest.js.map +1 -0
- package/dist-esm/src/clientDefinitions.js +4 -0
- package/dist-esm/src/clientDefinitions.js.map +1 -0
- package/dist-esm/src/index.js +14 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/isUnexpected.js +80 -0
- package/dist-esm/src/isUnexpected.js.map +1 -0
- package/dist-esm/src/models.js +4 -0
- package/dist-esm/src/models.js.map +1 -0
- package/dist-esm/src/outputModels.js +4 -0
- package/dist-esm/src/outputModels.js.map +1 -0
- package/dist-esm/src/paginateHelper.js +103 -0
- package/dist-esm/src/paginateHelper.js.map +1 -0
- package/dist-esm/src/parameters.js +4 -0
- package/dist-esm/src/parameters.js.map +1 -0
- package/dist-esm/src/pollingHelper.js +48 -0
- package/dist-esm/src/pollingHelper.js.map +1 -0
- package/dist-esm/src/responses.js +4 -0
- package/dist-esm/src/responses.js.map +1 -0
- package/package.json +129 -0
- package/review/ai-anomaly-detector.api.md +768 -0
- package/types/ai-anomaly-detector.d.ts +834 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Microsoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Azure AnomalyDetectorRest REST client library for JavaScript
|
|
2
|
+
|
|
3
|
+
AnomalyDetector Rest Client
|
|
4
|
+
|
|
5
|
+
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
|
|
6
|
+
|
|
7
|
+
Key links:
|
|
8
|
+
|
|
9
|
+
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest)
|
|
10
|
+
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-anomaly-detector)
|
|
11
|
+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-anomaly-detector?view=azure-node-preview)
|
|
12
|
+
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/samples)
|
|
13
|
+
|
|
14
|
+
## Getting started
|
|
15
|
+
|
|
16
|
+
### Currently supported environments
|
|
17
|
+
|
|
18
|
+
- LTS versions of Node.js
|
|
19
|
+
|
|
20
|
+
### Prerequisites
|
|
21
|
+
|
|
22
|
+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
|
|
23
|
+
|
|
24
|
+
### Install the `@azure-rest/ai-anomaly-detector` package
|
|
25
|
+
|
|
26
|
+
Install the Azure AnomalyDetectorRest REST client REST client library for JavaScript with `npm`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @azure-rest/ai-anomaly-detector
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Create and authenticate a `AnomalyDetectorRestClient`
|
|
33
|
+
|
|
34
|
+
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
|
|
35
|
+
provide an instance of the desired credential type obtained from the
|
|
36
|
+
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
|
|
37
|
+
|
|
38
|
+
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
|
|
39
|
+
|
|
40
|
+
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
|
|
41
|
+
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
|
|
42
|
+
can be used to authenticate the client.
|
|
43
|
+
|
|
44
|
+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
|
|
45
|
+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
|
|
46
|
+
|
|
47
|
+
## Troubleshooting
|
|
48
|
+
|
|
49
|
+
### Logging
|
|
50
|
+
|
|
51
|
+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
const { setLogLevel } = require("@azure/logger");
|
|
55
|
+
|
|
56
|
+
setLogLevel("info");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coreClient = require('@azure-rest/core-client');
|
|
6
|
+
var corePaging = require('@azure/core-paging');
|
|
7
|
+
var coreLro = require('@azure/core-lro');
|
|
8
|
+
|
|
9
|
+
// Copyright (c) Microsoft Corporation.
|
|
10
|
+
/**
|
|
11
|
+
* Initialize a new instance of the class AnomalyDetectorRestClient class.
|
|
12
|
+
* @param Endpoint type: string Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
|
|
13
|
+
* @param ApiVersion type: string Anomaly Detector API version (for example, v1.1).
|
|
14
|
+
* @param credentials type: KeyCredential
|
|
15
|
+
*/
|
|
16
|
+
function createClient(Endpoint, credentials, options = {}) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : "v1.1";
|
|
19
|
+
const baseUrl = (_b = options.baseUrl) !== null && _b !== void 0 ? _b : `${Endpoint}/anomalydetector/${apiVersion}`;
|
|
20
|
+
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
21
|
+
apiKeyHeaderName: "Ocp-Apim-Subscription-Key",
|
|
22
|
+
} });
|
|
23
|
+
const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`;
|
|
24
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
25
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
26
|
+
: `${userAgentInfo}`;
|
|
27
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
28
|
+
userAgentPrefix,
|
|
29
|
+
} });
|
|
30
|
+
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Copyright (c) Microsoft Corporation.
|
|
35
|
+
// Licensed under the MIT license.
|
|
36
|
+
const responseMap = {
|
|
37
|
+
"POST /timeseries/entire/detect": ["200"],
|
|
38
|
+
"POST /timeseries/last/detect": ["200"],
|
|
39
|
+
"POST /timeseries/changepoint/detect": ["200"],
|
|
40
|
+
"GET /multivariate/detect-batch/{resultId}": ["200"],
|
|
41
|
+
"POST /multivariate/models": ["201"],
|
|
42
|
+
"GET /multivariate/models": ["200"],
|
|
43
|
+
"DELETE /multivariate/models/{modelId}": ["204"],
|
|
44
|
+
"GET /multivariate/models/{modelId}": ["200"],
|
|
45
|
+
"POST /multivariate/models/{modelId}:detect-batch": ["202"],
|
|
46
|
+
"GET /multivariate/models/{modelId}:detect-batch": ["202"],
|
|
47
|
+
"POST /multivariate/models/{modelId}:detect-last": ["200"],
|
|
48
|
+
};
|
|
49
|
+
function isUnexpected(response) {
|
|
50
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
51
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
52
|
+
const method = response.request.method;
|
|
53
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
54
|
+
if (!pathDetails) {
|
|
55
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
56
|
+
}
|
|
57
|
+
return !pathDetails.includes(response.status);
|
|
58
|
+
}
|
|
59
|
+
function getParametrizedPathSuccess(method, path) {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
|
+
const pathParts = path.split("/");
|
|
62
|
+
// Traverse list to match the longest candidate
|
|
63
|
+
// matchedLen: the length of candidate path
|
|
64
|
+
// matchedValue: the matched status code array
|
|
65
|
+
let matchedLen = -1, matchedValue = [];
|
|
66
|
+
// Iterate the responseMap to find a match
|
|
67
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
68
|
+
// Extracting the path from the map key which is in format
|
|
69
|
+
// GET /path/foo
|
|
70
|
+
if (!key.startsWith(method)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const candidatePath = getPathFromMapKey(key);
|
|
74
|
+
// Get each part of the url path
|
|
75
|
+
const candidateParts = candidatePath.split("/");
|
|
76
|
+
// track if we have found a match to return the values found.
|
|
77
|
+
let found = true;
|
|
78
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
79
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
80
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
81
|
+
// If the current part of the candidate is a "template" part
|
|
82
|
+
// Try to use the suffix of pattern to match the path
|
|
83
|
+
// {guid} ==> $
|
|
84
|
+
// {guid}:export ==> :export$
|
|
85
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
86
|
+
if (!isMatched) {
|
|
87
|
+
found = false;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// If the candidate part is not a template and
|
|
93
|
+
// the parts don't match mark the candidate as not found
|
|
94
|
+
// to move on with the next candidate path.
|
|
95
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
96
|
+
found = false;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// We finished evaluating the current candidate parts
|
|
101
|
+
// Update the matched value if and only if we found the longer pattern
|
|
102
|
+
if (found && candidatePath.length > matchedLen) {
|
|
103
|
+
matchedLen = candidatePath.length;
|
|
104
|
+
matchedValue = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return matchedValue;
|
|
108
|
+
}
|
|
109
|
+
function getPathFromMapKey(mapKey) {
|
|
110
|
+
const pathStart = mapKey.indexOf("/");
|
|
111
|
+
return mapKey.slice(pathStart);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Copyright (c) Microsoft Corporation.
|
|
115
|
+
/**
|
|
116
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
117
|
+
* @param client - Client to use for sending the next page requests
|
|
118
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
119
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
120
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
121
|
+
*/
|
|
122
|
+
function paginate(client, initialResponse, options = {}) {
|
|
123
|
+
let firstRun = true;
|
|
124
|
+
// We need to check the response for success before trying to inspect it looking for
|
|
125
|
+
// the properties to use for nextLink and itemName
|
|
126
|
+
checkPagingRequest(initialResponse);
|
|
127
|
+
const { itemName, nextLinkName } = getPaginationProperties(initialResponse);
|
|
128
|
+
const { customGetPage } = options;
|
|
129
|
+
const pagedResult = {
|
|
130
|
+
firstPageLink: "",
|
|
131
|
+
getPage: typeof customGetPage === "function"
|
|
132
|
+
? customGetPage
|
|
133
|
+
: async (pageLink) => {
|
|
134
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
135
|
+
firstRun = false;
|
|
136
|
+
checkPagingRequest(result);
|
|
137
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
138
|
+
const values = getElements(result.body, itemName);
|
|
139
|
+
return {
|
|
140
|
+
page: values,
|
|
141
|
+
nextPageLink: nextLink,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Gets for the value of nextLink in the body
|
|
149
|
+
*/
|
|
150
|
+
function getNextLink(body, nextLinkName) {
|
|
151
|
+
if (!nextLinkName) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
const nextLink = body[nextLinkName];
|
|
155
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
156
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
157
|
+
}
|
|
158
|
+
return nextLink;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Gets the elements of the current request in the body.
|
|
162
|
+
*/
|
|
163
|
+
function getElements(body, itemName) {
|
|
164
|
+
const value = body[itemName];
|
|
165
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
166
|
+
// The fact that this must be an array is used above to calculate the
|
|
167
|
+
// type of elements in the page in PaginateReturn
|
|
168
|
+
if (!Array.isArray(value)) {
|
|
169
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
170
|
+
}
|
|
171
|
+
return value !== null && value !== void 0 ? value : [];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Checks if a request failed
|
|
175
|
+
*/
|
|
176
|
+
function checkPagingRequest(response) {
|
|
177
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
178
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
179
|
+
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Extracts the itemName and nextLinkName from the initial response to use them for pagination
|
|
184
|
+
*/
|
|
185
|
+
function getPaginationProperties(initialResponse) {
|
|
186
|
+
// Build a set with the passed custom nextLinkNames
|
|
187
|
+
const nextLinkNames = new Set(["nextLink"]);
|
|
188
|
+
// Build a set with the passed custom set of itemNames
|
|
189
|
+
const itemNames = new Set(["value", "models"]);
|
|
190
|
+
let nextLinkName;
|
|
191
|
+
let itemName;
|
|
192
|
+
for (const name of nextLinkNames) {
|
|
193
|
+
const nextLink = initialResponse.body[name];
|
|
194
|
+
if (nextLink) {
|
|
195
|
+
nextLinkName = name;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const name of itemNames) {
|
|
200
|
+
const item = initialResponse.body[name];
|
|
201
|
+
if (item) {
|
|
202
|
+
itemName = name;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (!itemName) {
|
|
207
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${[
|
|
208
|
+
...itemNames,
|
|
209
|
+
].join(" OR ")}`);
|
|
210
|
+
}
|
|
211
|
+
return { itemName, nextLinkName };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Copyright (c) Microsoft Corporation.
|
|
215
|
+
/**
|
|
216
|
+
* Helper function that builds a Poller object to help polling a long running operation.
|
|
217
|
+
* @param client - Client to use for sending the request to get additional pages.
|
|
218
|
+
* @param initialResponse - The initial response.
|
|
219
|
+
* @param options - Options to set a resume state or custom polling interval.
|
|
220
|
+
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
221
|
+
*/
|
|
222
|
+
function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
223
|
+
const poller = {
|
|
224
|
+
requestMethod: initialResponse.request.method,
|
|
225
|
+
requestPath: initialResponse.request.url,
|
|
226
|
+
sendInitialRequest: async () => {
|
|
227
|
+
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
228
|
+
// we are not triggering the initial request here, just extracting the information from the
|
|
229
|
+
// response we were provided.
|
|
230
|
+
return getLroResponse(initialResponse);
|
|
231
|
+
},
|
|
232
|
+
sendPollRequest: async (path) => {
|
|
233
|
+
// This is the callback that is going to be called to poll the service
|
|
234
|
+
// to get the latest status. We use the client provided and the polling path
|
|
235
|
+
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
236
|
+
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
237
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
238
|
+
const lroResponse = getLroResponse(response);
|
|
239
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
240
|
+
return lroResponse;
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
return new coreLro.LroEngine(poller, options);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Converts a Rest Client response to a response that the LRO engine knows about
|
|
247
|
+
* @param response - a rest client http response
|
|
248
|
+
* @returns - An LRO response that the LRO engine can work with
|
|
249
|
+
*/
|
|
250
|
+
function getLroResponse(response) {
|
|
251
|
+
if (Number.isNaN(response.status)) {
|
|
252
|
+
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
flatResponse: response,
|
|
256
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Copyright (c) Microsoft Corporation.
|
|
261
|
+
|
|
262
|
+
exports["default"] = createClient;
|
|
263
|
+
exports.getLongRunningPoller = getLongRunningPoller;
|
|
264
|
+
exports.isUnexpected = isUnexpected;
|
|
265
|
+
exports.paginate = paginate;
|
|
266
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/anomalyDetectorRest.ts","../src/isUnexpected.ts","../src/paginateHelper.ts","../src/pollingHelper.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { AnomalyDetectorRestClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class AnomalyDetectorRestClient class.\n * @param Endpoint type: string Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).\n * @param ApiVersion type: string Anomaly Detector API version (for example, v1.1).\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n Endpoint: string,\n credentials: KeyCredential,\n options: ClientOptions & { apiVersion?: string } = {}\n): AnomalyDetectorRestClient {\n const apiVersion = options.apiVersion ?? \"v1.1\";\n const baseUrl = options.baseUrl ?? `${Endpoint}/anomalydetector/${apiVersion}`;\n\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as AnomalyDetectorRestClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DetectUnivariateEntireSeries200Response,\n DetectUnivariateEntireSeriesDefaultResponse,\n DetectUnivariateLastPoint200Response,\n DetectUnivariateLastPointDefaultResponse,\n DetectUnivariateChangePoint200Response,\n DetectUnivariateChangePointDefaultResponse,\n GetMultivariateBatchDetectionResult200Response,\n GetMultivariateBatchDetectionResultDefaultResponse,\n CreateAndTrainMultivariateModel201Response,\n CreateAndTrainMultivariateModelDefaultResponse,\n ListMultivariateModels200Response,\n ListMultivariateModelsDefaultResponse,\n DeleteMultivariateModel204Response,\n DeleteMultivariateModelDefaultResponse,\n GetMultivariateModel200Response,\n GetMultivariateModelDefaultResponse,\n DetectMultivariateBatchAnomaly202Response,\n DetectMultivariateBatchAnomalyDefaultResponse,\n DetectMultivariateLastAnomaly200Response,\n DetectMultivariateLastAnomalyDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /timeseries/entire/detect\": [\"200\"],\n \"POST /timeseries/last/detect\": [\"200\"],\n \"POST /timeseries/changepoint/detect\": [\"200\"],\n \"GET /multivariate/detect-batch/{resultId}\": [\"200\"],\n \"POST /multivariate/models\": [\"201\"],\n \"GET /multivariate/models\": [\"200\"],\n \"DELETE /multivariate/models/{modelId}\": [\"204\"],\n \"GET /multivariate/models/{modelId}\": [\"200\"],\n \"POST /multivariate/models/{modelId}:detect-batch\": [\"202\"],\n \"GET /multivariate/models/{modelId}:detect-batch\": [\"202\"],\n \"POST /multivariate/models/{modelId}:detect-last\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse\n): response is DetectUnivariateEntireSeriesDefaultResponse;\nexport function isUnexpected(\n response: DetectUnivariateLastPoint200Response | DetectUnivariateLastPointDefaultResponse\n): response is DetectUnivariateLastPointDefaultResponse;\nexport function isUnexpected(\n response: DetectUnivariateChangePoint200Response | DetectUnivariateChangePointDefaultResponse\n): response is DetectUnivariateChangePointDefaultResponse;\nexport function isUnexpected(\n response:\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n): response is GetMultivariateBatchDetectionResultDefaultResponse;\nexport function isUnexpected(\n response:\n | CreateAndTrainMultivariateModel201Response\n | CreateAndTrainMultivariateModelDefaultResponse\n): response is CreateAndTrainMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response: ListMultivariateModels200Response | ListMultivariateModelsDefaultResponse\n): response is ListMultivariateModelsDefaultResponse;\nexport function isUnexpected(\n response: DeleteMultivariateModel204Response | DeleteMultivariateModelDefaultResponse\n): response is DeleteMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response: GetMultivariateModel200Response | GetMultivariateModelDefaultResponse\n): response is GetMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response:\n | DetectMultivariateBatchAnomaly202Response\n | DetectMultivariateBatchAnomalyDefaultResponse\n): response is DetectMultivariateBatchAnomalyDefaultResponse;\nexport function isUnexpected(\n response: DetectMultivariateLastAnomaly200Response | DetectMultivariateLastAnomalyDefaultResponse\n): response is DetectMultivariateLastAnomalyDefaultResponse;\nexport function isUnexpected(\n response:\n | DetectUnivariateEntireSeries200Response\n | DetectUnivariateEntireSeriesDefaultResponse\n | DetectUnivariateLastPoint200Response\n | DetectUnivariateLastPointDefaultResponse\n | DetectUnivariateChangePoint200Response\n | DetectUnivariateChangePointDefaultResponse\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n | CreateAndTrainMultivariateModel201Response\n | CreateAndTrainMultivariateModelDefaultResponse\n | ListMultivariateModels200Response\n | ListMultivariateModelsDefaultResponse\n | DeleteMultivariateModel204Response\n | DeleteMultivariateModelDefaultResponse\n | GetMultivariateModel200Response\n | GetMultivariateModelDefaultResponse\n | DetectMultivariateBatchAnomaly202Response\n | DetectMultivariateBatchAnomalyDefaultResponse\n | DetectMultivariateLastAnomaly200Response\n | DetectMultivariateLastAnomalyDefaultResponse\n): response is\n | DetectUnivariateEntireSeriesDefaultResponse\n | DetectUnivariateLastPointDefaultResponse\n | DetectUnivariateChangePointDefaultResponse\n | GetMultivariateBatchDetectionResultDefaultResponse\n | CreateAndTrainMultivariateModelDefaultResponse\n | ListMultivariateModelsDefaultResponse\n | DeleteMultivariateModelDefaultResponse\n | GetMultivariateModelDefaultResponse\n | DetectMultivariateBatchAnomalyDefaultResponse\n | DetectMultivariateLastAnomalyDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\"\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getPagedAsyncIterator, PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { Client, createRestError, PathUncheckedResponse } from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends\n | {\n body: { value?: infer TPage };\n }\n | {\n body: { models?: infer TPage };\n }\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {}\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n // We need to check the response for success before trying to inspect it looking for\n // the properties to use for nextLink and itemName\n checkPagingRequest(initialResponse);\n const { itemName, nextLinkName } = getPaginationProperties(initialResponse);\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response\n );\n }\n}\n\n/**\n * Extracts the itemName and nextLinkName from the initial response to use them for pagination\n */\nfunction getPaginationProperties(initialResponse: PathUncheckedResponse) {\n // Build a set with the passed custom nextLinkNames\n const nextLinkNames = new Set([\"nextLink\"]);\n\n // Build a set with the passed custom set of itemNames\n const itemNames = new Set([\"value\", \"models\"]);\n\n let nextLinkName: string | undefined;\n let itemName: string | undefined;\n\n for (const name of nextLinkNames) {\n const nextLink = (initialResponse.body as Record<string, unknown>)[name] as string;\n if (nextLink) {\n nextLinkName = name;\n break;\n }\n }\n\n for (const name of itemNames) {\n const item = (initialResponse.body as Record<string, unknown>)[name] as string;\n if (item) {\n itemName = name;\n break;\n }\n }\n\n if (!itemName) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${[\n ...itemNames,\n ].join(\" OR \")}`\n );\n }\n\n return { itemName, nextLinkName };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState,\n} from \"@azure/core-lro\";\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n): PollerLike<PollOperationState<TResult>, TResult> {\n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client.pathUnchecked(path ?? initialResponse.request.url).get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] = initialResponse.request.url;\n return lroResponse;\n },\n };\n\n return new LroEngine(poller, options);\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO engine knows about\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO engine can work with\n */\nfunction getLroResponse<TResult extends HttpResponse>(response: TResult): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport AnomalyDetectorRest from \"./anomalyDetectorRest\";\n\nexport * from \"./anomalyDetectorRest\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default AnomalyDetectorRest;\n"],"names":["getClient","getPagedAsyncIterator","createRestError","LroEngine"],"mappings":";;;;;;;;AAAA;AAOA;;;;;AAKG;AACW,SAAU,YAAY,CAClC,QAAgB,EAChB,WAA0B,EAC1B,OAAA,GAAmD,EAAE,EAAA;;IAErD,MAAM,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,MAAM,CAAC;AAChD,IAAA,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,QAAQ,CAAA,iBAAA,EAAoB,UAAU,CAAA,CAAE,CAAC;AAE/E,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,WAAW,EAAE;AACX,YAAA,gBAAgB,EAAE,2BAA2B;AAC9C,SAAA,EAAA,CACF,CAAC;IAEF,MAAM,aAAa,GAAG,CAAA,8CAAA,CAAgD,CAAC;IACvE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe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,IAAJ,IAAI,KAAA,KAAA,CAAA,GAAJ,IAAI,GAAI,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AACvF,YAAA,MAAM,WAAW,GAAG,cAAc,CAAC,QAAmB,CAAC,CAAC;AACxD,YAAA,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;AACnF,YAAA,OAAO,WAAW,CAAC;SACpB;KACF,CAAC;AAEF,IAAA,OAAO,IAAIC,iBAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;AAIG;AACH,SAAS,cAAc,CAA+B,QAAiB,EAAA;IACrE,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CAAC,CAAA,oDAAA,EAAuD,QAAQ,CAAC,MAAM,CAAE,CAAA,CAAC,CAAC;AAC/F,KAAA;IAED,OAAO;AACL,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,WAAW,kCACN,QAAQ,CAAA,EAAA,EACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EACpB,CAAA;KACF,CAAC;AACJ;;ACnEA;;;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { getClient } from "@azure-rest/core-client";
|
|
4
|
+
/**
|
|
5
|
+
* Initialize a new instance of the class AnomalyDetectorRestClient class.
|
|
6
|
+
* @param Endpoint type: string Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).
|
|
7
|
+
* @param ApiVersion type: string Anomaly Detector API version (for example, v1.1).
|
|
8
|
+
* @param credentials type: KeyCredential
|
|
9
|
+
*/
|
|
10
|
+
export default function createClient(Endpoint, credentials, options = {}) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const apiVersion = (_a = options.apiVersion) !== null && _a !== void 0 ? _a : "v1.1";
|
|
13
|
+
const baseUrl = (_b = options.baseUrl) !== null && _b !== void 0 ? _b : `${Endpoint}/anomalydetector/${apiVersion}`;
|
|
14
|
+
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
15
|
+
apiKeyHeaderName: "Ocp-Apim-Subscription-Key",
|
|
16
|
+
} });
|
|
17
|
+
const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`;
|
|
18
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
19
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
20
|
+
: `${userAgentInfo}`;
|
|
21
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
22
|
+
userAgentPrefix,
|
|
23
|
+
} });
|
|
24
|
+
const client = getClient(baseUrl, credentials, options);
|
|
25
|
+
return client;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=anomalyDetectorRest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anomalyDetectorRest.js","sourceRoot":"","sources":["../../src/anomalyDetectorRest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAInE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAAgB,EAChB,WAA0B,EAC1B,UAAmD,EAAE;;IAErD,MAAM,UAAU,GAAG,MAAA,OAAO,CAAC,UAAU,mCAAI,MAAM,CAAC;IAChD,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,GAAG,QAAQ,oBAAoB,UAAU,EAAE,CAAC;IAE/E,OAAO,mCACF,OAAO,KACV,WAAW,EAAE;YACX,gBAAgB,EAAE,2BAA2B;SAC9C,GACF,CAAC;IAEF,MAAM,aAAa,GAAG,gDAAgD,CAAC;IACvE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,GACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAA8B,CAAC;IAErF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { AnomalyDetectorRestClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class AnomalyDetectorRestClient class.\n * @param Endpoint type: string Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).\n * @param ApiVersion type: string Anomaly Detector API version (for example, v1.1).\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n Endpoint: string,\n credentials: KeyCredential,\n options: ClientOptions & { apiVersion?: string } = {}\n): AnomalyDetectorRestClient {\n const apiVersion = options.apiVersion ?? \"v1.1\";\n const baseUrl = options.baseUrl ?? `${Endpoint}/anomalydetector/${apiVersion}`;\n\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"Ocp-Apim-Subscription-Key\",\n },\n };\n\n const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n };\n\n const client = getClient(baseUrl, credentials, options) as AnomalyDetectorRestClient;\n\n return client;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../src/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DetectUnivariateEntireSeriesParameters,\n DetectUnivariateLastPointParameters,\n DetectUnivariateChangePointParameters,\n GetMultivariateBatchDetectionResultParameters,\n CreateAndTrainMultivariateModelParameters,\n ListMultivariateModelsParameters,\n DeleteMultivariateModelParameters,\n GetMultivariateModelParameters,\n DetectMultivariateBatchAnomalyParameters,\n DetectMultivariateLastAnomalyParameters,\n} from \"./parameters\";\nimport {\n DetectUnivariateEntireSeries200Response,\n DetectUnivariateEntireSeriesDefaultResponse,\n DetectUnivariateLastPoint200Response,\n DetectUnivariateLastPointDefaultResponse,\n DetectUnivariateChangePoint200Response,\n DetectUnivariateChangePointDefaultResponse,\n GetMultivariateBatchDetectionResult200Response,\n GetMultivariateBatchDetectionResultDefaultResponse,\n CreateAndTrainMultivariateModel201Response,\n CreateAndTrainMultivariateModelDefaultResponse,\n ListMultivariateModels200Response,\n ListMultivariateModelsDefaultResponse,\n DeleteMultivariateModel204Response,\n DeleteMultivariateModelDefaultResponse,\n GetMultivariateModel200Response,\n GetMultivariateModelDefaultResponse,\n DetectMultivariateBatchAnomaly202Response,\n DetectMultivariateBatchAnomalyDefaultResponse,\n DetectMultivariateLastAnomaly200Response,\n DetectMultivariateLastAnomalyDefaultResponse,\n} from \"./responses\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface DetectUnivariateEntireSeries {\n /** This operation generates a model with 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. */\n post(\n options: DetectUnivariateEntireSeriesParameters\n ): StreamableMethod<\n DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse\n >;\n}\n\nexport interface DetectUnivariateLastPoint {\n /** This operation generates a model using the points that you sent into the API, and based on all data to determine whether the last point is anomalous. */\n post(\n options: DetectUnivariateLastPointParameters\n ): StreamableMethod<\n DetectUnivariateLastPoint200Response | DetectUnivariateLastPointDefaultResponse\n >;\n}\n\nexport interface DetectUnivariateChangePoint {\n /** Evaluate change point score of every series point */\n post(\n options: DetectUnivariateChangePointParameters\n ): StreamableMethod<\n DetectUnivariateChangePoint200Response | DetectUnivariateChangePointDefaultResponse\n >;\n}\n\nexport interface GetMultivariateBatchDetectionResult {\n /** For asynchronous inference, get multivariate anomaly detection result based on resultId returned by the BatchDetectAnomaly api. */\n get(\n options?: GetMultivariateBatchDetectionResultParameters\n ): StreamableMethod<\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n >;\n}\n\nexport interface CreateAndTrainMultivariateModel {\n /** Create and train a multivariate anomaly detection model. The request must include a source parameter to indicate an externally accessible Azure blob storage URI.There are two types of data input: An URI pointed to an Azure blob storage folder which contains multiple CSV files, and each CSV file contains two columns, timestamp and variable. Another type of input is an URI pointed to a CSV file in Azure blob storage, which contains all the variables and a timestamp column. */\n post(\n options: CreateAndTrainMultivariateModelParameters\n ): StreamableMethod<\n CreateAndTrainMultivariateModel201Response | CreateAndTrainMultivariateModelDefaultResponse\n >;\n /** List models of a resource. */\n get(\n options?: ListMultivariateModelsParameters\n ): StreamableMethod<ListMultivariateModels200Response | ListMultivariateModelsDefaultResponse>;\n}\n\nexport interface DeleteMultivariateModel {\n /** Delete an existing multivariate model according to the modelId */\n delete(\n options?: DeleteMultivariateModelParameters\n ): StreamableMethod<DeleteMultivariateModel204Response | DeleteMultivariateModelDefaultResponse>;\n /** Get detailed information of multivariate model, including the training status and variables used in the model. */\n get(\n options?: GetMultivariateModelParameters\n ): StreamableMethod<GetMultivariateModel200Response | GetMultivariateModelDefaultResponse>;\n}\n\nexport interface DetectMultivariateBatchAnomaly {\n /** Submit multivariate anomaly detection task with the modelId of trained model and inference data, the input schema should be the same with the training request. The request will complete asynchronously and return a resultId to query the detection result.The request should be a source link to indicate an externally accessible Azure storage Uri, either pointed to an Azure blob storage folder, or pointed to a CSV file in Azure blob storage. */\n post(\n options: DetectMultivariateBatchAnomalyParameters\n ): StreamableMethod<\n DetectMultivariateBatchAnomaly202Response | DetectMultivariateBatchAnomalyDefaultResponse\n >;\n}\n\nexport interface DetectMultivariateLastAnomaly {\n /** Submit multivariate anomaly detection task with the modelId of trained model and inference data, and the inference data should be put into request body in a JSON format. The request will complete synchronously and return the detection immediately in the response body. */\n post(\n options: DetectMultivariateLastAnomalyParameters\n ): StreamableMethod<\n DetectMultivariateLastAnomaly200Response | DetectMultivariateLastAnomalyDefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/timeseries/entire/detect' has methods for the following verbs: post */\n (path: \"/timeseries/entire/detect\"): DetectUnivariateEntireSeries;\n /** Resource for '/timeseries/last/detect' has methods for the following verbs: post */\n (path: \"/timeseries/last/detect\"): DetectUnivariateLastPoint;\n /** Resource for '/timeseries/changepoint/detect' has methods for the following verbs: post */\n (path: \"/timeseries/changepoint/detect\"): DetectUnivariateChangePoint;\n /** Resource for '/multivariate/detect-batch/\\{resultId\\}' has methods for the following verbs: get */\n (\n path: \"/multivariate/detect-batch/{resultId}\",\n resultId: string\n ): GetMultivariateBatchDetectionResult;\n /** Resource for '/multivariate/models' has methods for the following verbs: post, get */\n (path: \"/multivariate/models\"): CreateAndTrainMultivariateModel;\n /** Resource for '/multivariate/models/\\{modelId\\}' has methods for the following verbs: delete, get */\n (path: \"/multivariate/models/{modelId}\", modelId: string): DeleteMultivariateModel;\n /** Resource for '/multivariate/models/\\{modelId\\}:detect-batch' has methods for the following verbs: post */\n (\n path: \"/multivariate/models/{modelId}:detect-batch\",\n modelId: string\n ): DetectMultivariateBatchAnomaly;\n /** Resource for '/multivariate/models/\\{modelId\\}:detect-last' has methods for the following verbs: post */\n (\n path: \"/multivariate/models/{modelId}:detect-last\",\n modelId: string\n ): DetectMultivariateLastAnomaly;\n}\n\nexport type AnomalyDetectorRestClient = Client & {\n path: Routes;\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import AnomalyDetectorRest from "./anomalyDetectorRest";
|
|
4
|
+
export * from "./anomalyDetectorRest";
|
|
5
|
+
export * from "./parameters";
|
|
6
|
+
export * from "./responses";
|
|
7
|
+
export * from "./clientDefinitions";
|
|
8
|
+
export * from "./isUnexpected";
|
|
9
|
+
export * from "./models";
|
|
10
|
+
export * from "./outputModels";
|
|
11
|
+
export * from "./paginateHelper";
|
|
12
|
+
export * from "./pollingHelper";
|
|
13
|
+
export default AnomalyDetectorRest;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport AnomalyDetectorRest from \"./anomalyDetectorRest\";\n\nexport * from \"./anomalyDetectorRest\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./models\";\nexport * from \"./outputModels\";\nexport * from \"./paginateHelper\";\nexport * from \"./pollingHelper\";\n\nexport default AnomalyDetectorRest;\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
const responseMap = {
|
|
4
|
+
"POST /timeseries/entire/detect": ["200"],
|
|
5
|
+
"POST /timeseries/last/detect": ["200"],
|
|
6
|
+
"POST /timeseries/changepoint/detect": ["200"],
|
|
7
|
+
"GET /multivariate/detect-batch/{resultId}": ["200"],
|
|
8
|
+
"POST /multivariate/models": ["201"],
|
|
9
|
+
"GET /multivariate/models": ["200"],
|
|
10
|
+
"DELETE /multivariate/models/{modelId}": ["204"],
|
|
11
|
+
"GET /multivariate/models/{modelId}": ["200"],
|
|
12
|
+
"POST /multivariate/models/{modelId}:detect-batch": ["202"],
|
|
13
|
+
"GET /multivariate/models/{modelId}:detect-batch": ["202"],
|
|
14
|
+
"POST /multivariate/models/{modelId}:detect-last": ["200"],
|
|
15
|
+
};
|
|
16
|
+
export function isUnexpected(response) {
|
|
17
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
18
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
19
|
+
const method = response.request.method;
|
|
20
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
21
|
+
if (!pathDetails) {
|
|
22
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
23
|
+
}
|
|
24
|
+
return !pathDetails.includes(response.status);
|
|
25
|
+
}
|
|
26
|
+
function getParametrizedPathSuccess(method, path) {
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
|
+
const pathParts = path.split("/");
|
|
29
|
+
// Traverse list to match the longest candidate
|
|
30
|
+
// matchedLen: the length of candidate path
|
|
31
|
+
// matchedValue: the matched status code array
|
|
32
|
+
let matchedLen = -1, matchedValue = [];
|
|
33
|
+
// Iterate the responseMap to find a match
|
|
34
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
35
|
+
// Extracting the path from the map key which is in format
|
|
36
|
+
// GET /path/foo
|
|
37
|
+
if (!key.startsWith(method)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const candidatePath = getPathFromMapKey(key);
|
|
41
|
+
// Get each part of the url path
|
|
42
|
+
const candidateParts = candidatePath.split("/");
|
|
43
|
+
// track if we have found a match to return the values found.
|
|
44
|
+
let found = true;
|
|
45
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
46
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
47
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
48
|
+
// If the current part of the candidate is a "template" part
|
|
49
|
+
// Try to use the suffix of pattern to match the path
|
|
50
|
+
// {guid} ==> $
|
|
51
|
+
// {guid}:export ==> :export$
|
|
52
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
53
|
+
if (!isMatched) {
|
|
54
|
+
found = false;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// If the candidate part is not a template and
|
|
60
|
+
// the parts don't match mark the candidate as not found
|
|
61
|
+
// to move on with the next candidate path.
|
|
62
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
63
|
+
found = false;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// We finished evaluating the current candidate parts
|
|
68
|
+
// Update the matched value if and only if we found the longer pattern
|
|
69
|
+
if (found && candidatePath.length > matchedLen) {
|
|
70
|
+
matchedLen = candidatePath.length;
|
|
71
|
+
matchedValue = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return matchedValue;
|
|
75
|
+
}
|
|
76
|
+
function getPathFromMapKey(mapKey) {
|
|
77
|
+
const pathStart = mapKey.indexOf("/");
|
|
78
|
+
return mapKey.slice(pathStart);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=isUnexpected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyBlC,MAAM,WAAW,GAA6B;IAC5C,gCAAgC,EAAE,CAAC,KAAK,CAAC;IACzC,8BAA8B,EAAE,CAAC,KAAK,CAAC;IACvC,qCAAqC,EAAE,CAAC,KAAK,CAAC;IAC9C,2CAA2C,EAAE,CAAC,KAAK,CAAC;IACpD,2BAA2B,EAAE,CAAC,KAAK,CAAC;IACpC,0BAA0B,EAAE,CAAC,KAAK,CAAC;IACnC,uCAAuC,EAAE,CAAC,KAAK,CAAC;IAChD,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,kDAAkD,EAAE,CAAC,KAAK,CAAC;IAC3D,iDAAiD,EAAE,CAAC,KAAK,CAAC;IAC1D,iDAAiD,EAAE,CAAC,KAAK,CAAC;CAC3D,CAAC;AAsCF,MAAM,UAAU,YAAY,CAC1B,QAoBgD;IAYhD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IACvC,IAAI,WAAW,GAAG,WAAW,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IA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G,cAAc,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAC/C,GAAG,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC;gBAClC,4DAA4D;gBAC5D,qDAAqD;gBACrD,eAAe;gBACf,6BAA6B;gBAC7B,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,GAAG,MAAA,cAAc,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAC1E,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CACnB,CAAC;gBAEF,IAAI,CAAC,SAAS,EAAE;oBACd,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;gBACD,SAAS;aACV;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;gBACtC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;aACP;SACF;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE;YAC9C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;SACtB;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n DetectUnivariateEntireSeries200Response,\n DetectUnivariateEntireSeriesDefaultResponse,\n DetectUnivariateLastPoint200Response,\n DetectUnivariateLastPointDefaultResponse,\n DetectUnivariateChangePoint200Response,\n DetectUnivariateChangePointDefaultResponse,\n GetMultivariateBatchDetectionResult200Response,\n GetMultivariateBatchDetectionResultDefaultResponse,\n CreateAndTrainMultivariateModel201Response,\n CreateAndTrainMultivariateModelDefaultResponse,\n ListMultivariateModels200Response,\n ListMultivariateModelsDefaultResponse,\n DeleteMultivariateModel204Response,\n DeleteMultivariateModelDefaultResponse,\n GetMultivariateModel200Response,\n GetMultivariateModelDefaultResponse,\n DetectMultivariateBatchAnomaly202Response,\n DetectMultivariateBatchAnomalyDefaultResponse,\n DetectMultivariateLastAnomaly200Response,\n DetectMultivariateLastAnomalyDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /timeseries/entire/detect\": [\"200\"],\n \"POST /timeseries/last/detect\": [\"200\"],\n \"POST /timeseries/changepoint/detect\": [\"200\"],\n \"GET /multivariate/detect-batch/{resultId}\": [\"200\"],\n \"POST /multivariate/models\": [\"201\"],\n \"GET /multivariate/models\": [\"200\"],\n \"DELETE /multivariate/models/{modelId}\": [\"204\"],\n \"GET /multivariate/models/{modelId}\": [\"200\"],\n \"POST /multivariate/models/{modelId}:detect-batch\": [\"202\"],\n \"GET /multivariate/models/{modelId}:detect-batch\": [\"202\"],\n \"POST /multivariate/models/{modelId}:detect-last\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse\n): response is DetectUnivariateEntireSeriesDefaultResponse;\nexport function isUnexpected(\n response: DetectUnivariateLastPoint200Response | DetectUnivariateLastPointDefaultResponse\n): response is DetectUnivariateLastPointDefaultResponse;\nexport function isUnexpected(\n response: DetectUnivariateChangePoint200Response | DetectUnivariateChangePointDefaultResponse\n): response is DetectUnivariateChangePointDefaultResponse;\nexport function isUnexpected(\n response:\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n): response is GetMultivariateBatchDetectionResultDefaultResponse;\nexport function isUnexpected(\n response:\n | CreateAndTrainMultivariateModel201Response\n | CreateAndTrainMultivariateModelDefaultResponse\n): response is CreateAndTrainMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response: ListMultivariateModels200Response | ListMultivariateModelsDefaultResponse\n): response is ListMultivariateModelsDefaultResponse;\nexport function isUnexpected(\n response: DeleteMultivariateModel204Response | DeleteMultivariateModelDefaultResponse\n): response is DeleteMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response: GetMultivariateModel200Response | GetMultivariateModelDefaultResponse\n): response is GetMultivariateModelDefaultResponse;\nexport function isUnexpected(\n response:\n | DetectMultivariateBatchAnomaly202Response\n | DetectMultivariateBatchAnomalyDefaultResponse\n): response is DetectMultivariateBatchAnomalyDefaultResponse;\nexport function isUnexpected(\n response: DetectMultivariateLastAnomaly200Response | DetectMultivariateLastAnomalyDefaultResponse\n): response is DetectMultivariateLastAnomalyDefaultResponse;\nexport function isUnexpected(\n response:\n | DetectUnivariateEntireSeries200Response\n | DetectUnivariateEntireSeriesDefaultResponse\n | DetectUnivariateLastPoint200Response\n | DetectUnivariateLastPointDefaultResponse\n | DetectUnivariateChangePoint200Response\n | DetectUnivariateChangePointDefaultResponse\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n | CreateAndTrainMultivariateModel201Response\n | CreateAndTrainMultivariateModelDefaultResponse\n | ListMultivariateModels200Response\n | ListMultivariateModelsDefaultResponse\n | DeleteMultivariateModel204Response\n | DeleteMultivariateModelDefaultResponse\n | GetMultivariateModel200Response\n | GetMultivariateModelDefaultResponse\n | DetectMultivariateBatchAnomaly202Response\n | DetectMultivariateBatchAnomalyDefaultResponse\n | DetectMultivariateLastAnomaly200Response\n | DetectMultivariateLastAnomalyDefaultResponse\n): response is\n | DetectUnivariateEntireSeriesDefaultResponse\n | DetectUnivariateLastPointDefaultResponse\n | DetectUnivariateChangePointDefaultResponse\n | GetMultivariateBatchDetectionResultDefaultResponse\n | CreateAndTrainMultivariateModelDefaultResponse\n | ListMultivariateModelsDefaultResponse\n | DeleteMultivariateModelDefaultResponse\n | GetMultivariateModelDefaultResponse\n | DetectMultivariateBatchAnomalyDefaultResponse\n | DetectMultivariateLastAnomalyDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\"\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** The request of entire or last anomaly detection. */\nexport interface DetectRequest {\n /** 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. */\n series: Array<TimeSeriesPoint>;\n /** Optional argument, can be one of yearly, monthly, weekly, daily, hourly, minutely, secondly, microsecond or none. If granularity is not present, it will be none by default. If granularity is none, the timestamp property in time series point can be absent. */\n granularity?:\n | \"yearly\"\n | \"monthly\"\n | \"weekly\"\n | \"daily\"\n | \"hourly\"\n | \"minutely\"\n | \"secondly\"\n | \"microsecond\"\n | \"none\";\n /** 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}. */\n customInterval?: number;\n /** Optional argument, periodic value of a time series. If the value is null or does not present, the API will determine the period automatically. */\n period?: number;\n /** Optional argument, advanced model parameter, max anomaly ratio in a time series. */\n maxAnomalyRatio?: number;\n /** 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. */\n sensitivity?: number;\n /** Used to specify how to deal with missing values in the input series, it's used when granularity is not \"none\". */\n imputeMode?: \"auto\" | \"previous\" | \"linear\" | \"fixed\" | \"zero\" | \"notFill\";\n /** Used to specify the value to fill, it's used when granularity is not \"none\" and imputeMode is \"fixed\". */\n imputeFixedValue?: number;\n}\n\n/** The definition of input timeseries points. */\nexport interface TimeSeriesPoint {\n /** Optional argument, timestamp of a data point (ISO8601 format). */\n timestamp?: Date | string;\n /** The measurement of that point, should be float. */\n value: number;\n}\n\n/** The request of change point detection. */\nexport interface ChangePointDetectRequest {\n /** Time series data points. Points should be sorted by timestamp in ascending order to match the change point detection result. */\n series: Array<TimeSeriesPoint>;\n /** Can only be one of yearly, monthly, weekly, daily, hourly, minutely or secondly. Granularity is used for verify whether input series is valid. */\n granularity:\n | \"yearly\"\n | \"monthly\"\n | \"weekly\"\n | \"daily\"\n | \"hourly\"\n | \"minutely\"\n | \"secondly\"\n | \"microsecond\"\n | \"none\";\n /** 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}. */\n customInterval?: number;\n /** Optional argument, periodic value of a time series. If the value is null or does not present, the API will determine the period automatically. */\n period?: number;\n /** Optional argument, advanced model parameter, a default stableTrendWindow will be used in detection. */\n stableTrendWindow?: number;\n /** Optional argument, advanced model parameter, between 0.0-1.0, the lower the value is, the larger the trend error will be which means less change point will be accepted. */\n threshold?: number;\n}\n\nexport interface ErrorResponse {\n /** The error code. */\n code: string;\n /** The message explaining the error reported by the service. */\n message: string;\n}\n\nexport interface VariableState {\n /** Variable name in variable states. */\n variable?: string;\n /** Proportion of missing values that need to be filled by fillNAMethod. */\n filledNARatio?: number;\n /** Number of effective data points before applying fillNAMethod. */\n effectiveCount?: number;\n /** First valid timestamp with value of input data. */\n firstTimestamp?: Date | string;\n /** Last valid timestamp with value of input data. */\n lastTimestamp?: Date | string;\n}\n\n/** Detection request for batch inference. This is an asynchronous inference which will need another API to get detection results. */\nexport interface DetectionRequest {\n /** Source link to the input data to indicate an accessible Azure storage Uri, either pointed to an Azure blob storage folder, or pointed to a CSV file in Azure blob storage based on you data schema selection. The data schema should be exactly the same with those used in the training phase. */\n dataSource: string;\n /** An optional field, which is used to specify the number of top contributed variables for one anomalous timestamp in the response. The default number is 10. */\n topContributorCount: number;\n /** A required field, indicating the start time of data for detection, which should be date-time of ISO 8601 format. */\n startTime: Date | string;\n /** A required field, indicating the end time of data for detection, which should be date-time of ISO 8601 format. */\n endTime: Date | string;\n}\n\n/** Training result of a model including its status, errors and diagnostics information. */\nexport interface ModelInfo {\n /** Source link to the input data to indicate an accessible Azure storage Uri, either pointed to an Azure blob storage folder, or pointed to a CSV file in Azure blob storage based on you data schema selection. */\n dataSource: string;\n /** Data schema of input data source: OneTable or MultiTable. The default DataSchema is OneTable. */\n dataSchema?: \"OneTable\" | \"MultiTable\";\n /** A required field, indicating the start time of training data, which should be date-time of ISO 8601 format. */\n startTime: Date | string;\n /** A required field, indicating the end time of training data, which should be date-time of ISO 8601 format. */\n endTime: Date | string;\n /** An optional field. The display name of the model whose maximum length is 24 characters. */\n displayName?: string;\n /** An optional field, indicating how many previous timestamps will be used to detect whether the timestamp is anomaly or not. */\n slidingWindow?: number;\n /** An optional field, indicating the manner to align multiple variables. */\n alignPolicy?: AlignPolicy;\n /** Model status. One of CREATED, RUNNING, READY, and FAILED. */\n status?: \"CREATED\" | \"RUNNING\" | \"READY\" | \"FAILED\";\n /** Error messages when failed to create a model. */\n errors?: Array<ErrorResponse>;\n /** Diagnostics information to help inspect the states of model or variable. */\n diagnosticsInfo?: DiagnosticsInfo;\n}\n\n/** An optional field, indicating the manner to align multiple variables. */\nexport interface AlignPolicy {\n /** An optional field, indicating how to align different variables to the same time-range. Either Inner or Outer. */\n alignMode?: \"Inner\" | \"Outer\";\n /** An optional field, indicating how missing values will be filled. One of Previous, Subsequent, Linear, Zero, Fixed. */\n fillNAMethod?: \"Previous\" | \"Subsequent\" | \"Linear\" | \"Zero\" | \"Fixed\";\n /** An optional field. Required when fillNAMethod is Fixed. */\n paddingValue?: number;\n}\n\n/** Diagnostics information to help inspect the states of model or variable. */\nexport interface DiagnosticsInfo {\n modelState?: ModelState;\n variableStates?: Array<VariableState>;\n}\n\nexport interface ModelState {\n /** This indicates the number of passes of the entire training dataset the algorithm has completed. */\n epochIds?: Array<number>;\n /** List of metrics used to assess how the model fits the training data for each epoch. */\n trainLosses?: Array<number>;\n /** List of metrics used to assess how the model fits the validation set for each epoch. */\n validationLosses?: Array<number>;\n /** Latency for each epoch. */\n latenciesInSeconds?: Array<number>;\n}\n\nexport interface LastDetectionRequest {\n /** This contains the inference data, including the name, timestamps(ISO 8601) and values of variables. */\n variables: Array<VariableValues>;\n /** An optional field, which is used to specify the number of top contributed variables for one anomalous timestamp in the response. The default number is 10. */\n topContributorCount: number;\n}\n\nexport interface VariableValues {\n /** Variable name of last detection request. */\n variable: string;\n /** Timestamps of last detection request */\n timestamps: Array<string>;\n /** Values of variables. */\n values: Array<number>;\n}\n"]}
|