@azure-rest/ai-anomaly-detector 1.0.0-beta.1 → 1.0.0-beta.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/CHANGELOG.md +15 -0
- package/LICENSE +4 -4
- package/README.md +272 -17
- package/dist/browser/anomalyDetectorRest.d.ts +13 -0
- package/dist/browser/anomalyDetectorRest.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/anomalyDetectorRest.js +13 -8
- package/dist/browser/anomalyDetectorRest.js.map +1 -0
- package/dist/browser/clientDefinitions.d.ts +95 -0
- package/dist/browser/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/clientDefinitions.js +4 -0
- package/dist/browser/clientDefinitions.js.map +1 -0
- package/dist/browser/index.d.ts +11 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +13 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/isUnexpected.d.ts +12 -0
- package/dist/browser/isUnexpected.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/isUnexpected.js +5 -6
- package/dist/browser/isUnexpected.js.map +1 -0
- package/dist/browser/models.d.ts +252 -0
- package/dist/browser/models.d.ts.map +1 -0
- package/dist/browser/models.js +4 -0
- package/{dist-esm/src → dist/browser}/models.js.map +1 -1
- package/dist/browser/outputModels.d.ts +367 -0
- package/dist/browser/outputModels.d.ts.map +1 -0
- package/dist/browser/outputModels.js +4 -0
- package/{dist-esm/src → dist/browser}/outputModels.js.map +1 -1
- package/dist/browser/package.json +3 -0
- package/dist/browser/paginateHelper.d.ts +47 -0
- package/dist/browser/paginateHelper.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/paginateHelper.js +2 -2
- package/dist/browser/paginateHelper.js.map +1 -0
- package/dist/browser/parameters.d.ts +46 -0
- package/dist/browser/parameters.d.ts.map +1 -0
- package/dist/browser/parameters.js +4 -0
- package/dist/browser/parameters.js.map +1 -0
- package/dist/browser/responses.d.ts +155 -0
- package/dist/browser/responses.d.ts.map +1 -0
- package/dist/browser/responses.js +4 -0
- package/dist/browser/responses.js.map +1 -0
- package/dist/commonjs/anomalyDetectorRest.d.ts +13 -0
- package/dist/commonjs/anomalyDetectorRest.d.ts.map +1 -0
- package/dist/commonjs/anomalyDetectorRest.js +34 -0
- package/dist/commonjs/anomalyDetectorRest.js.map +1 -0
- package/dist/commonjs/clientDefinitions.d.ts +95 -0
- package/dist/commonjs/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/clientDefinitions.js +5 -0
- package/dist/commonjs/clientDefinitions.js.map +1 -0
- package/dist/commonjs/index.d.ts +11 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +16 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/isUnexpected.d.ts +12 -0
- package/dist/commonjs/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/isUnexpected.js +81 -0
- package/dist/commonjs/isUnexpected.js.map +1 -0
- package/dist/commonjs/models.d.ts +252 -0
- package/dist/commonjs/models.d.ts.map +1 -0
- package/dist/commonjs/models.js +5 -0
- package/dist/commonjs/models.js.map +1 -0
- package/dist/commonjs/outputModels.d.ts +367 -0
- package/dist/commonjs/outputModels.d.ts.map +1 -0
- package/dist/commonjs/outputModels.js +5 -0
- package/dist/commonjs/outputModels.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/paginateHelper.d.ts +47 -0
- package/dist/commonjs/paginateHelper.d.ts.map +1 -0
- package/dist/commonjs/paginateHelper.js +106 -0
- package/dist/commonjs/paginateHelper.js.map +1 -0
- package/dist/commonjs/parameters.d.ts +46 -0
- package/dist/commonjs/parameters.d.ts.map +1 -0
- package/dist/commonjs/parameters.js +5 -0
- package/dist/commonjs/parameters.js.map +1 -0
- package/dist/commonjs/responses.d.ts +155 -0
- package/dist/commonjs/responses.d.ts.map +1 -0
- package/dist/commonjs/responses.js +5 -0
- package/dist/commonjs/responses.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/anomalyDetectorRest.d.ts +13 -0
- package/dist/esm/anomalyDetectorRest.d.ts.map +1 -0
- package/dist/esm/anomalyDetectorRest.js +31 -0
- package/dist/esm/anomalyDetectorRest.js.map +1 -0
- package/dist/esm/clientDefinitions.d.ts +95 -0
- package/dist/esm/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/clientDefinitions.js +4 -0
- package/dist/esm/clientDefinitions.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/isUnexpected.d.ts +12 -0
- package/dist/esm/isUnexpected.d.ts.map +1 -0
- package/dist/esm/isUnexpected.js +78 -0
- package/dist/esm/isUnexpected.js.map +1 -0
- package/dist/esm/models.d.ts +252 -0
- package/dist/esm/models.d.ts.map +1 -0
- package/dist/esm/models.js +4 -0
- package/dist/esm/models.js.map +1 -0
- package/dist/esm/outputModels.d.ts +367 -0
- package/dist/esm/outputModels.d.ts.map +1 -0
- package/dist/esm/outputModels.js +4 -0
- package/dist/esm/outputModels.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/paginateHelper.d.ts +47 -0
- package/dist/esm/paginateHelper.d.ts.map +1 -0
- package/dist/esm/paginateHelper.js +103 -0
- package/dist/esm/paginateHelper.js.map +1 -0
- package/dist/esm/parameters.d.ts +46 -0
- package/dist/esm/parameters.d.ts.map +1 -0
- package/dist/esm/parameters.js +4 -0
- package/dist/esm/parameters.js.map +1 -0
- package/dist/esm/responses.d.ts +155 -0
- package/dist/esm/responses.d.ts.map +1 -0
- package/dist/esm/responses.js +4 -0
- package/dist/esm/responses.js.map +1 -0
- package/dist/react-native/anomalyDetectorRest.d.ts +13 -0
- package/dist/react-native/anomalyDetectorRest.d.ts.map +1 -0
- package/dist/react-native/anomalyDetectorRest.js +31 -0
- package/dist/react-native/anomalyDetectorRest.js.map +1 -0
- package/dist/react-native/clientDefinitions.d.ts +95 -0
- package/dist/react-native/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/clientDefinitions.js +4 -0
- package/dist/react-native/clientDefinitions.js.map +1 -0
- package/dist/react-native/index.d.ts +11 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +13 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/isUnexpected.d.ts +12 -0
- package/dist/react-native/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/isUnexpected.js +78 -0
- package/dist/react-native/isUnexpected.js.map +1 -0
- package/dist/react-native/models.d.ts +252 -0
- package/dist/react-native/models.d.ts.map +1 -0
- package/dist/react-native/models.js +4 -0
- package/dist/react-native/models.js.map +1 -0
- package/dist/react-native/outputModels.d.ts +367 -0
- package/dist/react-native/outputModels.d.ts.map +1 -0
- package/dist/react-native/outputModels.js +4 -0
- package/dist/react-native/outputModels.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/paginateHelper.d.ts +47 -0
- package/dist/react-native/paginateHelper.d.ts.map +1 -0
- package/dist/react-native/paginateHelper.js +103 -0
- package/dist/react-native/paginateHelper.js.map +1 -0
- package/dist/react-native/parameters.d.ts +46 -0
- package/dist/react-native/parameters.d.ts.map +1 -0
- package/dist/react-native/parameters.js +4 -0
- package/dist/react-native/parameters.js.map +1 -0
- package/dist/react-native/responses.d.ts +155 -0
- package/dist/react-native/responses.d.ts.map +1 -0
- package/dist/react-native/responses.js +4 -0
- package/dist/react-native/responses.js.map +1 -0
- package/package.json +86 -80
- package/review/{ai-anomaly-detector.api.md → ai-anomaly-detector-node.api.md} +9 -9
- package/dist/index.js +0 -216
- package/dist/index.js.map +0 -1
- package/dist-esm/src/anomalyDetectorRest.js.map +0 -1
- package/dist-esm/src/clientDefinitions.js +0 -4
- package/dist-esm/src/clientDefinitions.js.map +0 -1
- package/dist-esm/src/index.js +0 -13
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/isUnexpected.js.map +0 -1
- package/dist-esm/src/models.js +0 -4
- package/dist-esm/src/outputModels.js +0 -4
- package/dist-esm/src/paginateHelper.js.map +0 -1
- package/dist-esm/src/parameters.js +0 -4
- package/dist-esm/src/parameters.js.map +0 -1
- package/dist-esm/src/responses.js +0 -4
- package/dist-esm/src/responses.js.map +0 -1
- package/types/ai-anomaly-detector.d.ts +0 -1086
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@azure-rest/ai-anomaly-detector",
|
|
3
3
|
"sdk-type": "client",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.2",
|
|
6
6
|
"description": "A generated SDK for AnomalyDetectorRest.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -13,98 +13,51 @@
|
|
|
13
13
|
"isomorphic"
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"main": "dist/index.js",
|
|
17
|
-
"module": "./dist
|
|
18
|
-
"types": "./
|
|
16
|
+
"main": "./dist/commonjs/index.js",
|
|
17
|
+
"module": "./dist/esm/index.js",
|
|
18
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
19
19
|
"repository": "github:Azure/azure-sdk-for-js",
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist/",
|
|
25
|
-
"dist-esm/src/",
|
|
26
|
-
"types/ai-anomaly-detector.d.ts",
|
|
27
25
|
"README.md",
|
|
28
26
|
"LICENSE",
|
|
29
|
-
"review
|
|
27
|
+
"review/",
|
|
28
|
+
"CHANGELOG.md"
|
|
30
29
|
],
|
|
31
30
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
36
|
-
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
|
|
37
|
-
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
|
|
38
|
-
"build:samples": "echo skipped.",
|
|
39
|
-
"build:test": "tsc -p . && dev-tool run bundle",
|
|
40
|
-
"build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
|
|
41
|
-
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
42
|
-
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
|
43
|
-
"execute:samples": "dev-tool samples run samples-dev",
|
|
44
|
-
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
|
|
45
|
-
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
46
|
-
"generate:client": "autorest --typescript swagger/README.md && npm run format",
|
|
47
|
-
"integration-test:browser": "dev-tool run test:browser",
|
|
48
|
-
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
|
49
|
-
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
50
|
-
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
|
51
|
-
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
|
52
|
-
"pack": "npm pack 2>&1",
|
|
53
|
-
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
|
|
54
|
-
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
|
|
55
|
-
"test": "npm run clean && npm run build:test && npm run unit-test",
|
|
56
|
-
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
57
|
-
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
|
58
|
-
"unit-test:browser": "dev-tool run test:browser",
|
|
59
|
-
"build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"
|
|
31
|
+
"node": ">=20.0.0"
|
|
60
32
|
},
|
|
61
33
|
"sideEffects": false,
|
|
62
34
|
"autoPublish": false,
|
|
63
35
|
"dependencies": {
|
|
64
|
-
"@azure/core-
|
|
65
|
-
"@azure
|
|
66
|
-
"@azure/core-
|
|
67
|
-
"@azure/
|
|
68
|
-
"
|
|
69
|
-
"@azure/
|
|
70
|
-
"
|
|
36
|
+
"@azure-rest/core-client": "^2.3.1",
|
|
37
|
+
"@azure/core-auth": "^1.9.0",
|
|
38
|
+
"@azure/core-lro": "^2.7.2",
|
|
39
|
+
"@azure/core-paging": "^1.6.2",
|
|
40
|
+
"@azure/core-rest-pipeline": "^1.18.1",
|
|
41
|
+
"@azure/logger": "^1.1.4",
|
|
42
|
+
"tslib": "^2.8.1"
|
|
71
43
|
},
|
|
72
44
|
"devDependencies": {
|
|
73
|
-
"@
|
|
45
|
+
"@azure/identity": "4.11.1",
|
|
46
|
+
"@types/node": "^20.19.0",
|
|
47
|
+
"@vitest/browser": "^3.2.3",
|
|
48
|
+
"@vitest/coverage-istanbul": "^3.2.3",
|
|
74
49
|
"autorest": "latest",
|
|
75
|
-
"
|
|
76
|
-
"dotenv": "^
|
|
77
|
-
"eslint": "^
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"source-map-support": "^0.5.9",
|
|
82
|
-
"typescript": "~4.6.0",
|
|
50
|
+
"csv-parse": "^6.0.0",
|
|
51
|
+
"dotenv": "^16.0.0",
|
|
52
|
+
"eslint": "^9.33.0",
|
|
53
|
+
"playwright": "^1.50.1",
|
|
54
|
+
"typescript": "~5.8.3",
|
|
55
|
+
"vitest": "^3.2.3",
|
|
83
56
|
"@azure/dev-tool": "^1.0.0",
|
|
57
|
+
"@azure-tools/test-credential": "^2.1.1",
|
|
58
|
+
"@azure-tools/test-utils-vitest": "^1.0.0",
|
|
84
59
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
85
|
-
"@azure-tools/test-
|
|
86
|
-
"@azure/identity": "^2.0.1",
|
|
87
|
-
"@azure-tools/test-recorder": "^2.0.0",
|
|
88
|
-
"mocha": "^7.1.1",
|
|
89
|
-
"@types/mocha": "^7.0.2",
|
|
90
|
-
"mocha-junit-reporter": "^1.18.0",
|
|
91
|
-
"cross-env": "^7.0.2",
|
|
92
|
-
"@types/chai": "^4.2.8",
|
|
93
|
-
"chai": "^4.2.0",
|
|
94
|
-
"karma-chrome-launcher": "^3.0.0",
|
|
95
|
-
"karma-coverage": "^2.0.0",
|
|
96
|
-
"karma-edge-launcher": "^0.4.2",
|
|
97
|
-
"karma-env-preprocessor": "^0.1.1",
|
|
98
|
-
"karma-firefox-launcher": "^1.1.0",
|
|
99
|
-
"karma-ie-launcher": "^1.0.0",
|
|
100
|
-
"karma-junit-reporter": "^2.0.1",
|
|
101
|
-
"karma-mocha-reporter": "^2.2.5",
|
|
102
|
-
"karma-mocha": "^2.0.1",
|
|
103
|
-
"karma-source-map-support": "~1.4.0",
|
|
104
|
-
"karma-sourcemap-loader": "^0.3.8",
|
|
105
|
-
"karma": "^6.2.0",
|
|
106
|
-
"nyc": "^14.0.0",
|
|
107
|
-
"csv-parse": "^5.0.3"
|
|
60
|
+
"@azure-tools/test-recorder": "^4.1.0"
|
|
108
61
|
},
|
|
109
62
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/anomalydetector/ai-anomaly-detector-rest/README.md",
|
|
110
63
|
"//metadata": {
|
|
@@ -115,15 +68,68 @@
|
|
|
115
68
|
}
|
|
116
69
|
]
|
|
117
70
|
},
|
|
118
|
-
"browser":
|
|
119
|
-
"./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
|
|
120
|
-
},
|
|
71
|
+
"browser": "./dist/browser/index.js",
|
|
121
72
|
"//sampleConfiguration": {
|
|
122
73
|
"productName": "AnomalyDetectorRest",
|
|
123
74
|
"productSlugs": [
|
|
124
75
|
"azure"
|
|
125
76
|
],
|
|
126
|
-
"disableDocsMs": true
|
|
127
|
-
|
|
77
|
+
"disableDocsMs": true
|
|
78
|
+
},
|
|
79
|
+
"type": "module",
|
|
80
|
+
"tshy": {
|
|
81
|
+
"project": "../../../tsconfig.src.build.json",
|
|
82
|
+
"exports": {
|
|
83
|
+
"./package.json": "./package.json",
|
|
84
|
+
".": "./src/index.ts"
|
|
85
|
+
},
|
|
86
|
+
"dialects": [
|
|
87
|
+
"esm",
|
|
88
|
+
"commonjs"
|
|
89
|
+
],
|
|
90
|
+
"esmDialects": [
|
|
91
|
+
"browser",
|
|
92
|
+
"react-native"
|
|
93
|
+
],
|
|
94
|
+
"selfLink": false
|
|
95
|
+
},
|
|
96
|
+
"exports": {
|
|
97
|
+
"./package.json": "./package.json",
|
|
98
|
+
".": {
|
|
99
|
+
"browser": {
|
|
100
|
+
"types": "./dist/browser/index.d.ts",
|
|
101
|
+
"default": "./dist/browser/index.js"
|
|
102
|
+
},
|
|
103
|
+
"react-native": {
|
|
104
|
+
"types": "./dist/react-native/index.d.ts",
|
|
105
|
+
"default": "./dist/react-native/index.js"
|
|
106
|
+
},
|
|
107
|
+
"import": {
|
|
108
|
+
"types": "./dist/esm/index.d.ts",
|
|
109
|
+
"default": "./dist/esm/index.js"
|
|
110
|
+
},
|
|
111
|
+
"require": {
|
|
112
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
113
|
+
"default": "./dist/commonjs/index.js"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
|
|
119
|
+
"build:samples": "tsc -p tsconfig.samples.json",
|
|
120
|
+
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
121
|
+
"clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
|
122
|
+
"execute:samples": "dev-tool samples run samples-dev",
|
|
123
|
+
"extract-api": "dev-tool run vendored rimraf review && dev-tool run extract-api",
|
|
124
|
+
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
125
|
+
"generate:client": "autorest --typescript swagger/README.md && npm run format",
|
|
126
|
+
"lint": "eslint package.json src test",
|
|
127
|
+
"lint:fix": "eslint package.json src test --fix --fix-type [problem,suggestion]",
|
|
128
|
+
"pack": "pnpm pack 2>&1",
|
|
129
|
+
"test": "npm run test:node && npm run test:browser",
|
|
130
|
+
"test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
|
131
|
+
"test:node": "dev-tool run test:vitest",
|
|
132
|
+
"test:node:esm": "dev-tool run test:vitest --esm",
|
|
133
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
128
134
|
}
|
|
129
|
-
}
|
|
135
|
+
}
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import { Client } from '@azure-rest/core-client';
|
|
8
|
-
import { ClientOptions } from '@azure-rest/core-client';
|
|
9
|
-
import { HttpResponse } from '@azure-rest/core-client';
|
|
10
|
-
import { KeyCredential } from '@azure/core-auth';
|
|
11
|
-
import { PagedAsyncIterableIterator } from '@azure/core-paging';
|
|
12
|
-
import { PathUncheckedResponse } from '@azure-rest/core-client';
|
|
13
|
-
import { RawHttpHeaders } from '@azure/core-rest-pipeline';
|
|
14
|
-
import { RequestParameters } from '@azure-rest/core-client';
|
|
15
|
-
import { StreamableMethod } from '@azure-rest/core-client';
|
|
7
|
+
import type { Client } from '@azure-rest/core-client';
|
|
8
|
+
import type { ClientOptions } from '@azure-rest/core-client';
|
|
9
|
+
import type { HttpResponse } from '@azure-rest/core-client';
|
|
10
|
+
import type { KeyCredential } from '@azure/core-auth';
|
|
11
|
+
import type { PagedAsyncIterableIterator } from '@azure/core-paging';
|
|
12
|
+
import type { PathUncheckedResponse } from '@azure-rest/core-client';
|
|
13
|
+
import type { RawHttpHeaders } from '@azure/core-rest-pipeline';
|
|
14
|
+
import type { RequestParameters } from '@azure-rest/core-client';
|
|
15
|
+
import type { StreamableMethod } from '@azure-rest/core-client';
|
|
16
16
|
|
|
17
17
|
// @public
|
|
18
18
|
export interface AlignPolicy {
|
package/dist/index.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
// Copyright (c) Microsoft Corporation.
|
|
9
|
-
/**
|
|
10
|
-
* Initialize a new instance of the class AnomalyDetectorRestClient class.
|
|
11
|
-
* @param Endpoint type: string
|
|
12
|
-
* @param credentials type: KeyCredential
|
|
13
|
-
*/
|
|
14
|
-
function createClient(Endpoint, credentials, options = {}) {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
const ApiVersion = (_a = options.ApiVersion) !== null && _a !== void 0 ? _a : "v1.1";
|
|
17
|
-
const baseUrl = (_b = options.baseUrl) !== null && _b !== void 0 ? _b : `${Endpoint}/anomalydetector/${ApiVersion}`;
|
|
18
|
-
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
19
|
-
apiKeyHeaderName: "Ocp-Apim-Subscription-Key",
|
|
20
|
-
} });
|
|
21
|
-
const userAgentInfo = `azsdk-js-ai-anomaly-detector-rest/1.0.0-beta.1`;
|
|
22
|
-
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
23
|
-
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
24
|
-
: `${userAgentInfo}`;
|
|
25
|
-
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
26
|
-
userAgentPrefix,
|
|
27
|
-
} });
|
|
28
|
-
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
29
|
-
return client;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Copyright (c) Microsoft Corporation.
|
|
33
|
-
// Licensed under the MIT license.
|
|
34
|
-
const responseMap = {
|
|
35
|
-
"POST /timeseries/entire/detect": ["200"],
|
|
36
|
-
"POST /timeseries/last/detect": ["200"],
|
|
37
|
-
"POST /timeseries/changepoint/detect": ["200"],
|
|
38
|
-
"GET /multivariate/detect-batch/{resultId}": ["200"],
|
|
39
|
-
"POST /multivariate/models": ["201"],
|
|
40
|
-
"GET /multivariate/models": ["200"],
|
|
41
|
-
"DELETE /multivariate/models/{modelId}": ["204"],
|
|
42
|
-
"GET /multivariate/models/{modelId}": ["200"],
|
|
43
|
-
"POST /multivariate/models/{modelId}:detect-batch": ["202"],
|
|
44
|
-
"POST /multivariate/models/{modelId}:detect-last": ["200"],
|
|
45
|
-
};
|
|
46
|
-
function isUnexpected(response) {
|
|
47
|
-
const lroOriginal = response.headers["x-ms-original-url"];
|
|
48
|
-
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
49
|
-
const method = response.request.method;
|
|
50
|
-
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
51
|
-
if (!pathDetails) {
|
|
52
|
-
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
53
|
-
}
|
|
54
|
-
return !pathDetails.includes(response.status);
|
|
55
|
-
}
|
|
56
|
-
function getParametrizedPathSuccess(method, path) {
|
|
57
|
-
var _a, _b, _c, _d;
|
|
58
|
-
const pathParts = path.split("/");
|
|
59
|
-
// Traverse list to match the longest candidate
|
|
60
|
-
// matchedLen: the length of candidate path
|
|
61
|
-
// matchedValue: the matched status code array
|
|
62
|
-
let matchedLen = -1, matchedValue = [];
|
|
63
|
-
// Iterate the responseMap to find a match
|
|
64
|
-
for (const [key, value] of Object.entries(responseMap)) {
|
|
65
|
-
// Extracting the path from the map key which is in format
|
|
66
|
-
// GET /path/foo
|
|
67
|
-
if (!key.startsWith(method)) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const candidatePath = getPathFromMapKey(key);
|
|
71
|
-
// Get each part of the url path
|
|
72
|
-
const candidateParts = candidatePath.split("/");
|
|
73
|
-
// track if we have found a match to return the values found.
|
|
74
|
-
let found = true;
|
|
75
|
-
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
76
|
-
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
77
|
-
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
78
|
-
// If the current part of the candidate is a "template" part
|
|
79
|
-
// Try to use the suffix of pattern to match the path
|
|
80
|
-
// {guid} ==> $
|
|
81
|
-
// {guid}:export ==> :export$
|
|
82
|
-
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
83
|
-
if (!isMatched) {
|
|
84
|
-
found = false;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
// If the candidate part is not a template and
|
|
90
|
-
// the parts don't match mark the candidate as not found
|
|
91
|
-
// to move on with the next candidate path.
|
|
92
|
-
if (candidateParts[i] !== pathParts[j]) {
|
|
93
|
-
found = false;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// We finished evaluating the current candidate parts
|
|
98
|
-
// Update the matched value if and only if we found the longer pattern
|
|
99
|
-
if (found && candidatePath.length > matchedLen) {
|
|
100
|
-
matchedLen = candidatePath.length;
|
|
101
|
-
matchedValue = value;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return matchedValue;
|
|
105
|
-
}
|
|
106
|
-
function getPathFromMapKey(mapKey) {
|
|
107
|
-
const pathStart = mapKey.indexOf("/");
|
|
108
|
-
return mapKey.slice(pathStart);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Copyright (c) Microsoft Corporation.
|
|
112
|
-
/**
|
|
113
|
-
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
114
|
-
* @param client - Client to use for sending the next page requests
|
|
115
|
-
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
116
|
-
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
117
|
-
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
118
|
-
*/
|
|
119
|
-
function paginate(client, initialResponse, options = {}) {
|
|
120
|
-
let firstRun = true;
|
|
121
|
-
// We need to check the response for success before trying to inspect it looking for
|
|
122
|
-
// the properties to use for nextLink and itemName
|
|
123
|
-
checkPagingRequest(initialResponse);
|
|
124
|
-
const { itemName, nextLinkName } = getPaginationProperties(initialResponse);
|
|
125
|
-
const { customGetPage } = options;
|
|
126
|
-
const pagedResult = {
|
|
127
|
-
firstPageLink: "",
|
|
128
|
-
getPage: typeof customGetPage === "function"
|
|
129
|
-
? customGetPage
|
|
130
|
-
: async (pageLink) => {
|
|
131
|
-
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
132
|
-
firstRun = false;
|
|
133
|
-
checkPagingRequest(result);
|
|
134
|
-
const nextLink = getNextLink(result.body, nextLinkName);
|
|
135
|
-
const values = getElements(result.body, itemName);
|
|
136
|
-
return {
|
|
137
|
-
page: values,
|
|
138
|
-
nextPageLink: nextLink,
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Gets for the value of nextLink in the body
|
|
146
|
-
*/
|
|
147
|
-
function getNextLink(body, nextLinkName) {
|
|
148
|
-
if (!nextLinkName) {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
const nextLink = body[nextLinkName];
|
|
152
|
-
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
153
|
-
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
154
|
-
}
|
|
155
|
-
return nextLink;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Gets the elements of the current request in the body.
|
|
159
|
-
*/
|
|
160
|
-
function getElements(body, itemName) {
|
|
161
|
-
const value = body[itemName];
|
|
162
|
-
// value has to be an array according to the x-ms-pageable extension.
|
|
163
|
-
// The fact that this must be an array is used above to calculate the
|
|
164
|
-
// type of elements in the page in PaginateReturn
|
|
165
|
-
if (!Array.isArray(value)) {
|
|
166
|
-
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
167
|
-
}
|
|
168
|
-
return value !== null && value !== void 0 ? value : [];
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Checks if a request failed
|
|
172
|
-
*/
|
|
173
|
-
function checkPagingRequest(response) {
|
|
174
|
-
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
175
|
-
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
176
|
-
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Extracts the itemName and nextLinkName from the initial response to use them for pagination
|
|
181
|
-
*/
|
|
182
|
-
function getPaginationProperties(initialResponse) {
|
|
183
|
-
// Build a set with the passed custom nextLinkNames
|
|
184
|
-
const nextLinkNames = new Set(["nextLink"]);
|
|
185
|
-
// Build a set with the passed custom set of itemNames
|
|
186
|
-
const itemNames = new Set(["value", "models"]);
|
|
187
|
-
let nextLinkName;
|
|
188
|
-
let itemName;
|
|
189
|
-
for (const name of nextLinkNames) {
|
|
190
|
-
const nextLink = initialResponse.body[name];
|
|
191
|
-
if (nextLink) {
|
|
192
|
-
nextLinkName = name;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
for (const name of itemNames) {
|
|
197
|
-
const item = initialResponse.body[name];
|
|
198
|
-
if (item) {
|
|
199
|
-
itemName = name;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!itemName) {
|
|
204
|
-
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${[
|
|
205
|
-
...itemNames,
|
|
206
|
-
].join(" OR ")}`);
|
|
207
|
-
}
|
|
208
|
-
return { itemName, nextLinkName };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// Copyright (c) Microsoft Corporation.
|
|
212
|
-
|
|
213
|
-
exports["default"] = createClient;
|
|
214
|
-
exports.isUnexpected = isUnexpected;
|
|
215
|
-
exports.paginate = paginate;
|
|
216
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/anomalyDetectorRest.ts","../src/isUnexpected.ts","../src/paginateHelper.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\nexport interface AnomalyDetectorRestClientOptions extends ClientOptions {\n ApiVersion?: string;\n}\n\n/**\n * Initialize a new instance of the class AnomalyDetectorRestClient class.\n * @param Endpoint type: string\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n Endpoint: string,\n credentials: KeyCredential,\n options: AnomalyDetectorRestClientOptions = {}\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 TrainMultivariateModel201Response,\n TrainMultivariateModelDefaultResponse,\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 \"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: TrainMultivariateModel201Response | TrainMultivariateModelDefaultResponse\n): response is TrainMultivariateModelDefaultResponse;\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 | TrainMultivariateModel201Response\n | TrainMultivariateModelDefaultResponse\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 | TrainMultivariateModelDefaultResponse\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 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\";\n\nexport default AnomalyDetectorRest;\n"],"names":["getClient","getPagedAsyncIterator","createRestError"],"mappings":";;;;;;;AAAA;AAWA;;;;AAIG;AACW,SAAU,YAAY,CAClC,QAAgB,EAChB,WAA0B,EAC1B,OAAA,GAA4C,EAAE,EAAA;;IAE9C,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;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE,CAAC;AACzB,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA,EAAA,CACF,CAAC;IAEF,MAAM,MAAM,GAAGA,oBAAS,C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B,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\nexport interface AnomalyDetectorRestClientOptions extends ClientOptions {\n ApiVersion?: string;\n}\n\n/**\n * Initialize a new instance of the class AnomalyDetectorRestClient class.\n * @param Endpoint type: string\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n Endpoint: string,\n credentials: KeyCredential,\n options: AnomalyDetectorRestClientOptions = {}\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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 TrainMultivariateModelParameters,\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 TrainMultivariateModel201Response,\n TrainMultivariateModelDefaultResponse,\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 /**\n * This operation generates a model with an entire series, each point is detected\n * with the same model. With this method, points before and after a certain point\n * are used to determine whether it is an anomaly. The entire detection can give\n * user an overall status of the time series.\n */\n post(\n options: DetectUnivariateEntireSeriesParameters\n ): StreamableMethod<\n DetectUnivariateEntireSeries200Response | DetectUnivariateEntireSeriesDefaultResponse\n >;\n}\n\nexport interface DetectUnivariateLastPoint {\n /**\n * This operation generates a model using the points that you sent into the API,\n * and based on all data to determine whether the last point is anomalous.\n */\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 /**\n * For asynchronous inference, get multivariate anomaly detection result based on\n * resultId returned by the BatchDetectAnomaly api.\n */\n get(\n options?: GetMultivariateBatchDetectionResultParameters\n ): StreamableMethod<\n | GetMultivariateBatchDetectionResult200Response\n | GetMultivariateBatchDetectionResultDefaultResponse\n >;\n}\n\nexport interface TrainMultivariateModel {\n /**\n * Create and train a multivariate anomaly detection model. The request must\n * include a source parameter to indicate an externally accessible Azure blob\n * storage URI.There are two types of data input: An URI pointed to an Azure blob\n * storage folder which contains multiple CSV files, and each CSV file contains\n * two columns, timestamp and variable. Another type of input is an URI pointed to\n * a CSV file in Azure blob storage, which contains all the variables and a\n * timestamp column.\n */\n post(\n options: TrainMultivariateModelParameters\n ): StreamableMethod<TrainMultivariateModel201Response | TrainMultivariateModelDefaultResponse>;\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 /**\n * Get detailed information of multivariate model, including the training status\n * and variables used in the model.\n */\n get(\n options?: GetMultivariateModelParameters\n ): StreamableMethod<GetMultivariateModel200Response | GetMultivariateModelDefaultResponse>;\n}\n\nexport interface DetectMultivariateBatchAnomaly {\n /**\n * Submit multivariate anomaly detection task with the modelId of trained model\n * and inference data, the input schema should be the same with the training\n * request. The request will complete asynchronously and return a resultId to\n * query the detection result.The request should be a source link to indicate an\n * externally accessible Azure storage Uri, either pointed to an Azure blob\n * storage folder, or pointed to a CSV file in Azure blob storage.\n */\n post(\n options: DetectMultivariateBatchAnomalyParameters\n ): StreamableMethod<\n DetectMultivariateBatchAnomaly202Response | DetectMultivariateBatchAnomalyDefaultResponse\n >;\n}\n\nexport interface DetectMultivariateLastAnomaly {\n /**\n * Submit multivariate anomaly detection task with the modelId of trained model\n * and inference data, and the inference data should be put into request body in a\n * JSON format. The request will complete synchronously and return the detection\n * immediately in the response body.\n */\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\"): TrainMultivariateModel;\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"]}
|
package/dist-esm/src/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 default AnomalyDetectorRest;
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAEjC,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\";\n\nexport default AnomalyDetectorRest;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,8BAA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S;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 TrainMultivariateModel201Response,\n TrainMultivariateModelDefaultResponse,\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 \"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: TrainMultivariateModel201Response | TrainMultivariateModelDefaultResponse\n): response is TrainMultivariateModelDefaultResponse;\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 | TrainMultivariateModel201Response\n | TrainMultivariateModelDefaultResponse\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 | TrainMultivariateModelDefaultResponse\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"]}
|
package/dist-esm/src/models.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,qBAAqB,EAA2C,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAU,eAAe,EAAyB,MAAM,yBAAyB,CAAC;AA6CzF;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,eAA0B,EAC1B,UAAoC,EAAE;IAItC,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,oFAAoF;IACpF,kDAAkD;IAClD,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACpC,MAAM,EAAE,QA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AAI,CAAW,CAAC;QAC/E,IAAI,IAAI,EAAE;YACR,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM;SACP;KACF;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,kFAAkF;YAChF,GAAG,SAAS;SACb,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACjB,CAAC;KACH;IAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// 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"]}
|