@azure-rest/maps-route 1.0.0-beta.3 → 1.0.0-beta.4
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/README.md +39 -39
- package/dist/index.js +160 -77
- package/dist/index.js.map +1 -1
- package/dist-esm/src/helpers.js +1 -1
- package/dist-esm/src/helpers.js.map +1 -1
- package/dist-esm/src/index.js +2 -2
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/mapsRoute.js +5 -5
- package/dist-esm/src/mapsRoute.js.map +1 -1
- package/package.json +29 -33
- package/review/maps-route.api.md +114 -91
- package/types/maps-route-rest.d.ts +499 -271
- package/dist-esm/src/generated/clientDefinitions.js +0 -4
- package/dist-esm/src/generated/clientDefinitions.js.map +0 -1
- package/dist-esm/src/generated/index.js +0 -13
- package/dist-esm/src/generated/index.js.map +0 -1
- package/dist-esm/src/generated/isUnexpected.js +0 -76
- package/dist-esm/src/generated/isUnexpected.js.map +0 -1
- package/dist-esm/src/generated/mapsRouteClient.js +0 -30
- package/dist-esm/src/generated/mapsRouteClient.js.map +0 -1
- package/dist-esm/src/generated/models.js +0 -4
- package/dist-esm/src/generated/models.js.map +0 -1
- package/dist-esm/src/generated/outputModels.js +0 -4
- package/dist-esm/src/generated/outputModels.js.map +0 -1
- package/dist-esm/src/generated/parameters.js +0 -4
- package/dist-esm/src/generated/parameters.js.map +0 -1
- package/dist-esm/src/generated/pollingHelper.js +0 -55
- package/dist-esm/src/generated/pollingHelper.js.map +0 -1
- package/dist-esm/src/generated/responses.js +0 -4
- package/dist-esm/src/generated/responses.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,19 +35,19 @@ npm install @azure-rest/maps-route
|
|
|
35
35
|
|
|
36
36
|
### Create and authenticate a `MapsRouteClient`
|
|
37
37
|
|
|
38
|
-
To create a client object to access the Azure Maps Route APIs, you will need a `credential` object. The Azure Maps Route client can use
|
|
38
|
+
To create a client object to access the Azure Maps Route APIs, you will need a `credential` object. The Azure Maps Route client can use a Microsoft Entra ID credential or an Azure Key credential to authenticate.
|
|
39
39
|
|
|
40
|
-
#### Using
|
|
40
|
+
#### Using a Microsoft Entra ID Credential
|
|
41
41
|
|
|
42
|
-
You can authenticate with
|
|
42
|
+
You can authenticate with Microsoft Entra ID using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
45
|
npm install @azure/identity
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
You will also need to register a new
|
|
48
|
+
You will also need to register a new Microsoft Entra ID application and grant access to Azure Maps by assigning the suitable role to your service principal. Please refer to the [Manage authentication](https://docs.microsoft.com/azure/azure-maps/how-to-manage-authentication) page.
|
|
49
49
|
|
|
50
|
-
Set the values of the client ID, tenant ID, and client secret of the
|
|
50
|
+
Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra ID application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
|
51
51
|
|
|
52
52
|
You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options.
|
|
53
53
|
The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation](https://docs.microsoft.com/azure/azure-maps/how-to-manage-authentication#view-authentication-details) on how to find it.
|
|
@@ -89,33 +89,33 @@ npm install @azure/core-auth
|
|
|
89
89
|
Finally, you can use the SAS token to authenticate the client:
|
|
90
90
|
|
|
91
91
|
```javascript
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
92
|
+
const MapsRoute = require("@azure-rest/maps-route").default;
|
|
93
|
+
const { AzureSASCredential } = require("@azure/core-auth");
|
|
94
|
+
const { DefaultAzureCredential } = require("@azure/identity");
|
|
95
|
+
const { AzureMapsManagementClient } = require("@azure/arm-maps");
|
|
96
|
+
|
|
97
|
+
const subscriptionId = "<subscription ID of the map account>";
|
|
98
|
+
const resourceGroupName = "<resource group name of the map account>";
|
|
99
|
+
const accountName = "<name of the map account>";
|
|
100
|
+
const mapsAccountSasParameters = {
|
|
101
|
+
start: "<start time in ISO format>", // e.g. "2023-11-24T03:51:53.161Z"
|
|
102
|
+
expiry: "<expiry time in ISO format>", // maximum value to start + 1 day
|
|
103
|
+
maxRatePerSecond: 500,
|
|
104
|
+
principalId: "<principle ID (object ID) of the managed identity>",
|
|
105
|
+
signingKey: "primaryKey",
|
|
106
|
+
};
|
|
107
|
+
const credential = new DefaultAzureCredential();
|
|
108
|
+
const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
|
|
109
|
+
const { accountSasToken } = await managementClient.accounts.listSas(
|
|
110
|
+
resourceGroupName,
|
|
111
|
+
accountName,
|
|
112
|
+
mapsAccountSasParameters,
|
|
113
|
+
);
|
|
114
|
+
if (accountSasToken === undefined) {
|
|
115
|
+
throw new Error("No accountSasToken was found for the Maps Account.");
|
|
116
|
+
}
|
|
117
|
+
const sasCredential = new AzureSASCredential(accountSasToken);
|
|
118
|
+
const client = MapsRoute(sasCredential);
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
## Examples
|
|
@@ -165,13 +165,13 @@ if (isUnexpected(routeDirectionsResult2)) {
|
|
|
165
165
|
|
|
166
166
|
routeDirectionsResult2.body.routes.forEach(({ summary, legs }) => {
|
|
167
167
|
console.log(
|
|
168
|
-
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds
|
|
168
|
+
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`,
|
|
169
169
|
);
|
|
170
170
|
legs.forEach(({ summary, points }, idx) => {
|
|
171
171
|
console.log(
|
|
172
172
|
`The ${idx + 1}th leg's length is ${summary.lengthInMeters} meters, and it takes ${
|
|
173
173
|
summary.travelTimeInSeconds
|
|
174
|
-
} seconds. Followings are the first 10 points:
|
|
174
|
+
} seconds. Followings are the first 10 points: `,
|
|
175
175
|
);
|
|
176
176
|
console.table(points.slice(0, 10));
|
|
177
177
|
});
|
|
@@ -210,13 +210,13 @@ if (isUnexpected(routeDirectionsResult)) {
|
|
|
210
210
|
|
|
211
211
|
routeDirectionsResult.body.routes.forEach(({ summary, legs }) => {
|
|
212
212
|
console.log(
|
|
213
|
-
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds
|
|
213
|
+
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`,
|
|
214
214
|
);
|
|
215
215
|
legs.forEach(({ summary, points }, idx) => {
|
|
216
216
|
console.log(
|
|
217
217
|
`The ${idx + 1}th leg's length is ${summary.lengthInMeters} meters, and it takes ${
|
|
218
218
|
summary.travelTimeInSeconds
|
|
219
|
-
} seconds. Followings are the first 10 points:
|
|
219
|
+
} seconds. Followings are the first 10 points: `,
|
|
220
220
|
);
|
|
221
221
|
console.table(points.slice(0, 10));
|
|
222
222
|
});
|
|
@@ -257,13 +257,13 @@ if (isUnexpected(routeDirectionsResult)) {
|
|
|
257
257
|
throw routeDirectionsResult.body.error;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
const { summary } = routeDirectionsResult.body.routes[0];
|
|
260
|
+
const { summary } = routeDirectionsResult.body.routes[0];
|
|
261
261
|
console.log(
|
|
262
|
-
`The optimized distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds
|
|
262
|
+
`The optimized distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`,
|
|
263
263
|
);
|
|
264
264
|
console.log("The route is optimized by: ");
|
|
265
265
|
routeDirectionsResult.body.optimizedWaypoints.forEach(
|
|
266
|
-
({ providedIndex, optimizedIndex }) => `Moving index ${providedIndex} to ${optimizedIndex}
|
|
266
|
+
({ providedIndex, optimizedIndex }) => `Moving index ${providedIndex} to ${optimizedIndex}`,
|
|
267
267
|
);
|
|
268
268
|
```
|
|
269
269
|
|
package/dist/index.js
CHANGED
|
@@ -4,64 +4,85 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var coreAuth = require('@azure/core-auth');
|
|
6
6
|
var mapsCommon = require('@azure/maps-common');
|
|
7
|
+
var tslib = require('tslib');
|
|
7
8
|
var coreClient = require('@azure-rest/core-client');
|
|
9
|
+
var logger$1 = require('@azure/logger');
|
|
8
10
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
11
|
var coreLro = require('@azure/core-lro');
|
|
10
12
|
|
|
11
13
|
// Copyright (c) Microsoft Corporation.
|
|
12
|
-
// Licensed under the MIT
|
|
14
|
+
// Licensed under the MIT License.
|
|
15
|
+
const logger = logger$1.createClientLogger("maps-route");
|
|
16
|
+
|
|
17
|
+
// Copyright (c) Microsoft Corporation.
|
|
18
|
+
// Licensed under the MIT License.
|
|
13
19
|
/**
|
|
14
|
-
* Initialize a new instance of
|
|
15
|
-
* @param credentials
|
|
20
|
+
* Initialize a new instance of `MapsRouteClient`
|
|
21
|
+
* @param credentials - uniquely identify client credential
|
|
22
|
+
* @param options - the parameter for all optional parameters
|
|
16
23
|
*/
|
|
17
|
-
function createClient(credentials,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
credentials: {
|
|
23
|
-
apiKeyHeaderName: "subscription-key"
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.1`;
|
|
24
|
+
function createClient(credentials, _a = {}) {
|
|
25
|
+
var _b, _c, _d, _e, _f, _g;
|
|
26
|
+
var { apiVersion = "1.0" } = _a, options = tslib.__rest(_a, ["apiVersion"]);
|
|
27
|
+
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
28
|
+
const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.4`;
|
|
27
29
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
28
30
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
29
31
|
: `${userAgentInfo}`;
|
|
30
|
-
options = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
33
|
+
userAgentPrefix,
|
|
34
|
+
}, loggingOptions: {
|
|
35
|
+
logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info,
|
|
36
|
+
}, credentials: {
|
|
37
|
+
apiKeyHeaderName: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.apiKeyHeaderName) !== null && _g !== void 0 ? _g : "subscription-key",
|
|
38
|
+
} });
|
|
39
|
+
const client = coreClient.getClient(endpointUrl, credentials, options);
|
|
40
|
+
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
41
|
+
client.pipeline.addPolicy({
|
|
42
|
+
name: "ClientApiVersionPolicy",
|
|
43
|
+
sendRequest: (req, next) => {
|
|
44
|
+
// Use the apiVersion defined in request url directly
|
|
45
|
+
// Append one if there is no apiVersion and we have one at client options
|
|
46
|
+
const url = new URL(req.url);
|
|
47
|
+
if (!url.searchParams.get("api-version") && apiVersion) {
|
|
48
|
+
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
|
|
49
|
+
}
|
|
50
|
+
return next(req);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
37
53
|
return client;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
// Copyright (c) Microsoft Corporation.
|
|
41
|
-
// Licensed under the MIT
|
|
57
|
+
// Licensed under the MIT License.
|
|
42
58
|
const responseMap = {
|
|
43
|
-
"POST /route/matrix/{format}": ["200", "202"],
|
|
44
59
|
"GET /route/matrix/{format}": ["200", "202"],
|
|
60
|
+
"POST /route/matrix/{format}": ["200", "202"],
|
|
45
61
|
"POST /route/matrix/sync/{format}": ["200"],
|
|
46
62
|
"GET /route/directions/{format}": ["200"],
|
|
47
63
|
"POST /route/directions/{format}": ["200"],
|
|
48
64
|
"GET /route/range/{format}": ["200"],
|
|
49
|
-
"POST /route/directions/batch/{format}": ["200", "202"],
|
|
50
65
|
"GET /route/directions/batch/{format}": ["200", "202"],
|
|
51
|
-
"POST /route/directions/batch/
|
|
66
|
+
"POST /route/directions/batch/{format}": ["200", "202"],
|
|
67
|
+
"POST /route/directions/batch/sync/{format}": ["200"],
|
|
52
68
|
};
|
|
53
69
|
function isUnexpected(response) {
|
|
54
70
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
55
|
-
const url = new URL(lroOriginal
|
|
71
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
56
72
|
const method = response.request.method;
|
|
57
73
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
58
74
|
if (!pathDetails) {
|
|
59
|
-
pathDetails =
|
|
75
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
60
76
|
}
|
|
61
77
|
return !pathDetails.includes(response.status);
|
|
62
78
|
}
|
|
63
|
-
function
|
|
79
|
+
function getParametrizedPathSuccess(method, path) {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
64
81
|
const pathParts = path.split("/");
|
|
82
|
+
// Traverse list to match the longest candidate
|
|
83
|
+
// matchedLen: the length of candidate path
|
|
84
|
+
// matchedValue: the matched status code array
|
|
85
|
+
let matchedLen = -1, matchedValue = [];
|
|
65
86
|
// Iterate the responseMap to find a match
|
|
66
87
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
67
88
|
// Extracting the path from the map key which is in format
|
|
@@ -72,41 +93,39 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
72
93
|
const candidatePath = getPathFromMapKey(key);
|
|
73
94
|
// Get each part of the url path
|
|
74
95
|
const candidateParts = candidatePath.split("/");
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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[i]) {
|
|
96
|
+
// track if we have found a match to return the values found.
|
|
97
|
+
let found = true;
|
|
98
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
99
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) &&
|
|
100
|
+
((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
101
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
102
|
+
// If the current part of the candidate is a "template" part
|
|
103
|
+
// Try to use the suffix of pattern to match the path
|
|
104
|
+
// {guid} ==> $
|
|
105
|
+
// {guid}:export ==> :export$
|
|
106
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
107
|
+
if (!isMatched) {
|
|
93
108
|
found = false;
|
|
94
109
|
break;
|
|
95
110
|
}
|
|
111
|
+
continue;
|
|
96
112
|
}
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// the path
|
|
100
|
-
if (
|
|
101
|
-
|
|
113
|
+
// If the candidate part is not a template and
|
|
114
|
+
// the parts don't match mark the candidate as not found
|
|
115
|
+
// to move on with the next candidate path.
|
|
116
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
117
|
+
found = false;
|
|
118
|
+
break;
|
|
102
119
|
}
|
|
103
120
|
}
|
|
121
|
+
// We finished evaluating the current candidate parts
|
|
122
|
+
// Update the matched value if and only if we found the longer pattern
|
|
123
|
+
if (found && candidatePath.length > matchedLen) {
|
|
124
|
+
matchedLen = candidatePath.length;
|
|
125
|
+
matchedValue = value;
|
|
126
|
+
}
|
|
104
127
|
}
|
|
105
|
-
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
function hasParametrizedPath(path) {
|
|
109
|
-
return path.includes("/{");
|
|
128
|
+
return matchedValue;
|
|
110
129
|
}
|
|
111
130
|
function getPathFromMapKey(mapKey) {
|
|
112
131
|
const pathStart = mapKey.indexOf("/");
|
|
@@ -114,7 +133,7 @@ function getPathFromMapKey(mapKey) {
|
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
// Copyright (c) Microsoft Corporation.
|
|
117
|
-
// Licensed under the MIT
|
|
136
|
+
// Licensed under the MIT License.
|
|
118
137
|
/**
|
|
119
138
|
* Helper function that builds a Poller object to help polling a long running operation.
|
|
120
139
|
* @param client - Client to use for sending the request to get additional pages.
|
|
@@ -122,36 +141,90 @@ function getPathFromMapKey(mapKey) {
|
|
|
122
141
|
* @param options - Options to set a resume state or custom polling interval.
|
|
123
142
|
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
124
143
|
*/
|
|
125
|
-
function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
144
|
+
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
145
|
+
var _a;
|
|
146
|
+
const abortController = new AbortController();
|
|
126
147
|
const poller = {
|
|
127
|
-
requestMethod: initialResponse.request.method,
|
|
128
|
-
requestPath: initialResponse.request.url,
|
|
129
148
|
sendInitialRequest: async () => {
|
|
130
149
|
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
131
150
|
// we are not triggering the initial request here, just extracting the information from the
|
|
132
151
|
// response we were provided.
|
|
133
152
|
return getLroResponse(initialResponse);
|
|
134
153
|
},
|
|
135
|
-
sendPollRequest: async (path) => {
|
|
154
|
+
sendPollRequest: async (path, pollOptions) => {
|
|
136
155
|
// This is the callback that is going to be called to poll the service
|
|
137
156
|
// to get the latest status. We use the client provided and the polling path
|
|
138
157
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
139
158
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
140
|
-
|
|
141
|
-
.
|
|
142
|
-
|
|
159
|
+
function abortListener() {
|
|
160
|
+
abortController.abort();
|
|
161
|
+
}
|
|
162
|
+
const inputAbortSignal = pollOptions === null || pollOptions === void 0 ? void 0 : pollOptions.abortSignal;
|
|
163
|
+
const abortSignal = abortController.signal;
|
|
164
|
+
if (inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.aborted) {
|
|
165
|
+
abortController.abort();
|
|
166
|
+
}
|
|
167
|
+
else if (!abortSignal.aborted) {
|
|
168
|
+
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.addEventListener("abort", abortListener, {
|
|
169
|
+
once: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
let response;
|
|
173
|
+
try {
|
|
174
|
+
response = await client
|
|
175
|
+
.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url)
|
|
176
|
+
.get({ abortSignal });
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
inputAbortSignal === null || inputAbortSignal === void 0 ? void 0 : inputAbortSignal.removeEventListener("abort", abortListener);
|
|
180
|
+
}
|
|
143
181
|
const lroResponse = getLroResponse(response);
|
|
144
182
|
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
145
183
|
initialResponse.request.url;
|
|
146
184
|
return lroResponse;
|
|
147
|
-
}
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
188
|
+
const httpPoller = coreLro.createHttpPoller(poller, options);
|
|
189
|
+
const simplePoller = {
|
|
190
|
+
isDone() {
|
|
191
|
+
return httpPoller.isDone;
|
|
192
|
+
},
|
|
193
|
+
isStopped() {
|
|
194
|
+
return abortController.signal.aborted;
|
|
195
|
+
},
|
|
196
|
+
getOperationState() {
|
|
197
|
+
if (!httpPoller.operationState) {
|
|
198
|
+
throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
|
|
199
|
+
}
|
|
200
|
+
return httpPoller.operationState;
|
|
201
|
+
},
|
|
202
|
+
getResult() {
|
|
203
|
+
return httpPoller.result;
|
|
204
|
+
},
|
|
205
|
+
toString() {
|
|
206
|
+
if (!httpPoller.operationState) {
|
|
207
|
+
throw new Error("Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().");
|
|
208
|
+
}
|
|
209
|
+
return JSON.stringify({
|
|
210
|
+
state: httpPoller.operationState,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
stopPolling() {
|
|
214
|
+
abortController.abort();
|
|
215
|
+
},
|
|
216
|
+
onProgress: httpPoller.onProgress,
|
|
217
|
+
poll: httpPoller.poll,
|
|
218
|
+
pollUntilDone: httpPoller.pollUntilDone,
|
|
219
|
+
serialize: httpPoller.serialize,
|
|
220
|
+
submitted: httpPoller.submitted,
|
|
148
221
|
};
|
|
149
|
-
return
|
|
222
|
+
return simplePoller;
|
|
150
223
|
}
|
|
151
224
|
/**
|
|
152
|
-
* Converts a Rest Client response to a response that the LRO
|
|
225
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
153
226
|
* @param response - a rest client http response
|
|
154
|
-
* @returns - An LRO response that the LRO
|
|
227
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
155
228
|
*/
|
|
156
229
|
function getLroResponse(response) {
|
|
157
230
|
if (Number.isNaN(response.status)) {
|
|
@@ -159,20 +232,29 @@ function getLroResponse(response) {
|
|
|
159
232
|
}
|
|
160
233
|
return {
|
|
161
234
|
flatResponse: response,
|
|
162
|
-
rawResponse: {
|
|
163
|
-
...response,
|
|
164
|
-
statusCode: Number.parseInt(response.status),
|
|
165
|
-
body: response.body
|
|
166
|
-
}
|
|
235
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
167
236
|
};
|
|
168
237
|
}
|
|
169
238
|
|
|
170
239
|
// Copyright (c) Microsoft Corporation.
|
|
171
|
-
// Licensed under the MIT
|
|
240
|
+
// Licensed under the MIT License.
|
|
241
|
+
function buildMultiCollection(items, parameterName) {
|
|
242
|
+
return items
|
|
243
|
+
.map((item, index) => {
|
|
244
|
+
if (index === 0) {
|
|
245
|
+
return item;
|
|
246
|
+
}
|
|
247
|
+
return `${parameterName}=${item}`;
|
|
248
|
+
})
|
|
249
|
+
.join("&");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Copyright (c) Microsoft Corporation.
|
|
253
|
+
// Licensed under the MIT License.
|
|
172
254
|
function MapsRoute(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
173
255
|
const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
|
|
174
256
|
/**
|
|
175
|
-
* maps service requires a header "ms-x-client-id", which is different from the standard
|
|
257
|
+
* maps service requires a header "ms-x-client-id", which is different from the standard Microsoft Entra ID.
|
|
176
258
|
* So we need to do our own implementation.
|
|
177
259
|
* This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
|
|
178
260
|
*/
|
|
@@ -184,7 +266,7 @@ function MapsRoute(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
|
184
266
|
const client = createClient(undefined, options);
|
|
185
267
|
client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
|
|
186
268
|
credential,
|
|
187
|
-
scopes:
|
|
269
|
+
scopes: "https://atlas.microsoft.com/.default",
|
|
188
270
|
}));
|
|
189
271
|
client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
|
|
190
272
|
return client;
|
|
@@ -204,7 +286,7 @@ function MapsRoute(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
|
204
286
|
}
|
|
205
287
|
|
|
206
288
|
// Copyright (c) Microsoft Corporation.
|
|
207
|
-
// Licensed under the MIT
|
|
289
|
+
// Licensed under the MIT License.
|
|
208
290
|
function toLatLonString(coordinates) {
|
|
209
291
|
return `${coordinates[0]},${coordinates[1]}`;
|
|
210
292
|
}
|
|
@@ -247,8 +329,9 @@ function createRouteDirectionsBatchRequest(queryParamProperties) {
|
|
|
247
329
|
}
|
|
248
330
|
|
|
249
331
|
// Copyright (c) Microsoft Corporation.
|
|
250
|
-
// Licensed under the MIT
|
|
332
|
+
// Licensed under the MIT License.
|
|
251
333
|
|
|
334
|
+
exports.buildMultiCollection = buildMultiCollection;
|
|
252
335
|
exports.createRouteDirectionsBatchRequest = createRouteDirectionsBatchRequest;
|
|
253
336
|
exports.default = MapsRoute;
|
|
254
337
|
exports.getLongRunningPoller = getLongRunningPoller;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/generated/mapsRouteClient.ts","../src/generated/isUnexpected.ts","../src/generated/pollingHelper.ts","../src/mapsRoute.ts","../src/helpers.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 { MapsRouteClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class MapsRouteClient class.\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n credentials: KeyCredential,\n options: ClientOptions = {}\n): MapsRouteClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"1.0\";\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"subscription-key\"\n }\n };\n\n const userAgentInfo = `azsdk-js-maps-route-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 MapsRouteClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n RouteRequestRouteMatrixSync200Response,\n RouteRequestRouteMatrixSync408Response,\n RouteRequestRouteMatrixSyncDefaultResponse,\n RouteGetRouteDirections200Response,\n RouteGetRouteDirectionsDefaultResponse,\n RouteGetRouteDirectionsWithAdditionalParameters200Response,\n RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse,\n RouteGetRouteRange200Response,\n RouteGetRouteRangeDefaultResponse,\n RouteRequestRouteDirectionsBatchSync200Response,\n RouteRequestRouteDirectionsBatchSync408Response,\n RouteRequestRouteDirectionsBatchSyncDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"POST /route/matrix/{format}\": [\"200\", \"202\"],\n \"GET /route/matrix/{format}\": [\"200\", \"202\"],\n \"POST /route/matrix/sync/{format}\": [\"200\"],\n \"GET /route/directions/{format}\": [\"200\"],\n \"POST /route/directions/{format}\": [\"200\"],\n \"GET /route/range/{format}\": [\"200\"],\n \"POST /route/directions/batch/{format}\": [\"200\", \"202\"],\n \"GET /route/directions/batch/{format}\": [\"200\", \"202\"],\n \"POST /route/directions/batch/sync/{format}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response:\n | RouteRequestRouteMatrixSync200Response\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse\n): response is RouteRequestRouteMatrixSync408Response;\nexport function isUnexpected(\n response:\n | RouteGetRouteDirections200Response\n | RouteGetRouteDirectionsDefaultResponse\n): response is RouteGetRouteDirectionsDefaultResponse;\nexport function isUnexpected(\n response:\n | RouteGetRouteDirectionsWithAdditionalParameters200Response\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse\n): response is RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse;\nexport function isUnexpected(\n response: RouteGetRouteRange200Response | RouteGetRouteRangeDefaultResponse\n): response is RouteGetRouteRangeDefaultResponse;\nexport function isUnexpected(\n response:\n | RouteRequestRouteDirectionsBatchSync200Response\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse\n): response is RouteRequestRouteDirectionsBatchSync408Response;\nexport function isUnexpected(\n response:\n | RouteRequestRouteMatrixSync200Response\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse\n | RouteGetRouteDirections200Response\n | RouteGetRouteDirectionsDefaultResponse\n | RouteGetRouteDirectionsWithAdditionalParameters200Response\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse\n | RouteGetRouteRange200Response\n | RouteGetRouteRangeDefaultResponse\n | RouteRequestRouteDirectionsBatchSync200Response\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse\n): response is\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse\n | RouteGetRouteDirectionsDefaultResponse\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse\n | RouteGetRouteRangeDefaultResponse\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse {\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 = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\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 // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\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[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\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 { 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\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n 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>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\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 { ClientOptions } from \"@azure-rest/core-client\";\nimport {\n AzureKeyCredential,\n AzureSASCredential,\n TokenCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsRouteClient } from \"./generated\";\nimport createClient from \"./generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsRouteClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsRoute(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsRouteClient;\n/**\n * Creates an instance of MapsRoute from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRoute(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsRouteClient;\n/**\n * Creates an instance of MapsRoute from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsRoute(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsRouteClient;\nexport default function MapsRoute(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsRouteClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { LatLon } from \"@azure/maps-common\";\nimport { BatchRequest, RouteGetRouteDirectionsQueryParamProperties } from \"./generated\";\n\nfunction toLatLonString(coordinates: LatLon): string {\n return `${coordinates[0]},${coordinates[1]}`;\n}\n\n/**\n * Transform an array of [Latitude, Longtitute] to a string in the following format:\n * \"Latitude_1,Longtitute_1:Latitude_2,Longtitute_2:...\"\n *\n * @param coordinates - An array of Latitude/Longtitute pair to transform.\n * @returns The transformed string.\n */\nexport function toColonDelimitedLatLonString(coordinates: LatLon[]): string {\n return coordinates.map((c) => toLatLonString(c)).join(\":\");\n}\n\n/**\n * Create a batch request body of a bunch of route direction requests.\n *\n * @param queryParamProperties - An object of the query parameters for a route direction request\n * @returns The composed batch request.\n */\nexport function createRouteDirectionsBatchRequest(\n queryParamProperties: RouteGetRouteDirectionsQueryParamProperties[],\n): BatchRequest {\n return {\n batchItems: queryParamProperties.map((queryParam) => ({\n query:\n \"?\" +\n Object.entries(queryParam)\n .map(([k, v]) => {\n // Skip if no value\n if (typeof v === \"undefined\" || v === null) {\n return \"\";\n }\n // Check name mappings: Array values\n if ((k === \"departAt\" || k === \"arriveAt\") && v instanceof Date) {\n return `${k}=${v.toISOString()}`;\n }\n return `${k}=${v}`;\n })\n .filter((s) => s !== \"\")\n .join(\"&\"),\n })),\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsRoute from \"./mapsRoute\";\n\nexport * from \"./generated\";\nexport * from \"./helpers\";\n\nexport default MapsRoute;\n"],"names":["getClient","LroEngine","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy","isSASCredential"],"mappings":";;;;;;;;;;AAAA;AACA;AAMA;;;AAGG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE,EAAA;AAE3B,IAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;AACjD,IAAA,OAAO,GAAG;AACR,QAAA,GAAG,OAAO;AACV,QAAA,WAAW,EAAE;AACX,YAAA,gBAAgB,EAAE,kBAAkB;AACrC,SAAA;KACF,CAAC;IAEF,MAAM,aAAa,GAAG,CAAA,qCAAA,CAAuC,CAAC;IAC9D,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,GAAG;AACR,QAAA,GAAG,OAAO;AACV,QAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA;KACF,CAAC;IAE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AA,EAAA,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;AAClC,qBAAA;AACD,oBAAA,OAAO,CAAG,EAAA,CAAC,CAAI,CAAA,EAAA,CAAC,EAAE,CAAC;AACrB,iBAAC,CAAC;qBACD,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;qBACvB,IAAI,CAAC,GAAG,CAAC;AACf,SAAA,CAAC,CAAC;KACJ,CAAC;AACJ;;AClDA;AACA;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../generated/logger.ts","../generated/mapsRouteClient.ts","../generated/isUnexpected.ts","../generated/pollingHelper.ts","../generated/serializeHelper.ts","../src/mapsRoute.ts","../src/helpers.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"maps-route\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsRouteClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface MapsRouteClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsRouteClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"1.0\", ...options }: MapsRouteClientOptions = {},\n): MapsRouteClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.4`;\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 loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsRouteClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n RouteRequestRouteMatrixSync200Response,\n RouteRequestRouteMatrixSync408Response,\n RouteRequestRouteMatrixSyncDefaultResponse,\n RouteGetRouteDirections200Response,\n RouteGetRouteDirectionsDefaultResponse,\n RouteGetRouteDirectionsWithAdditionalParameters200Response,\n RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse,\n RouteGetRouteRange200Response,\n RouteGetRouteRangeDefaultResponse,\n RouteRequestRouteDirectionsBatchSync200Response,\n RouteRequestRouteDirectionsBatchSync408Response,\n RouteRequestRouteDirectionsBatchSyncDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /route/matrix/{format}\": [\"200\", \"202\"],\n \"POST /route/matrix/{format}\": [\"200\", \"202\"],\n \"POST /route/matrix/sync/{format}\": [\"200\"],\n \"GET /route/directions/{format}\": [\"200\"],\n \"POST /route/directions/{format}\": [\"200\"],\n \"GET /route/range/{format}\": [\"200\"],\n \"GET /route/directions/batch/{format}\": [\"200\", \"202\"],\n \"POST /route/directions/batch/{format}\": [\"200\", \"202\"],\n \"POST /route/directions/batch/sync/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | RouteRequestRouteMatrixSync200Response\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse,\n): response is RouteRequestRouteMatrixSync408Response;\nexport function isUnexpected(\n response:\n | RouteGetRouteDirections200Response\n | RouteGetRouteDirectionsDefaultResponse,\n): response is RouteGetRouteDirectionsDefaultResponse;\nexport function isUnexpected(\n response:\n | RouteGetRouteDirectionsWithAdditionalParameters200Response\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse,\n): response is RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse;\nexport function isUnexpected(\n response: RouteGetRouteRange200Response | RouteGetRouteRangeDefaultResponse,\n): response is RouteGetRouteRangeDefaultResponse;\nexport function isUnexpected(\n response:\n | RouteRequestRouteDirectionsBatchSync200Response\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse,\n): response is RouteRequestRouteDirectionsBatchSync408Response;\nexport function isUnexpected(\n response:\n | RouteRequestRouteMatrixSync200Response\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse\n | RouteGetRouteDirections200Response\n | RouteGetRouteDirectionsDefaultResponse\n | RouteGetRouteDirectionsWithAdditionalParameters200Response\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse\n | RouteGetRouteRange200Response\n | RouteGetRouteRangeDefaultResponse\n | RouteRequestRouteDirectionsBatchSync200Response\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse,\n): response is\n | RouteRequestRouteMatrixSync408Response\n | RouteRequestRouteMatrixSyncDefaultResponse\n | RouteGetRouteDirectionsDefaultResponse\n | RouteGetRouteDirectionsWithAdditionalParametersDefaultResponse\n | RouteGetRouteRangeDefaultResponse\n | RouteRequestRouteDirectionsBatchSync408Response\n | RouteRequestRouteDirectionsBatchSyncDefaultResponse {\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 (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\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(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\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 { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<\n TState extends OperationState<TResult>,\n TResult,\n> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: {\n abortSignal?: AbortSignalLike;\n }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n\n /**\n * Returns true if the poller is stopped.\n * @deprecated Use abortSignal status to track this instead.\n */\n isStopped(): boolean;\n}\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 async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {},\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n const abortController = new AbortController();\n const poller: RunningOperation<TResult> = {\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 (\n path: string,\n pollOptions?: { abortSignal?: AbortSignalLike },\n ) => {\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 function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = pollOptions?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n },\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return abortController.signal.aborted;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState,\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted,\n };\n return simplePoller;\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult,\n): OperationResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`,\n );\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\nexport function buildMultiCollection(\n items: string[],\n parameterName: string,\n): string {\n return items\n .map((item, index) => {\n if (index === 0) {\n return item;\n }\n return `${parameterName}=${item}`;\n })\n .join(\"&\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport type { AzureKeyCredential, AzureSASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsRouteClient } from \"../generated\";\nimport createClient from \"../generated\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsRouteClient from a subscription key.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsRoute(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsRouteClient;\n/**\n * Creates an instance of MapsRoute from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRoute(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsRouteClient;\n/**\n * Creates an instance of MapsRoute from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts\n * import MapsRoute from \"@azure-rest/maps-route\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsRoute(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsRoute(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsRouteClient;\nexport default function MapsRoute(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsRouteClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard Microsoft Entra ID.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: \"https://atlas.microsoft.com/.default\",\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LatLon } from \"@azure/maps-common\";\nimport type { BatchRequest, RouteGetRouteDirectionsQueryParamProperties } from \"../generated\";\n\nfunction toLatLonString(coordinates: LatLon): string {\n return `${coordinates[0]},${coordinates[1]}`;\n}\n\n/**\n * Transform an array of [Latitude, Longtitute] to a string in the following format:\n * \"Latitude_1,Longtitute_1:Latitude_2,Longtitute_2:...\"\n *\n * @param coordinates - An array of Latitude/Longtitute pair to transform.\n * @returns The transformed string.\n */\nexport function toColonDelimitedLatLonString(coordinates: LatLon[]): string {\n return coordinates.map((c) => toLatLonString(c)).join(\":\");\n}\n\n/**\n * Create a batch request body of a bunch of route direction requests.\n *\n * @param queryParamProperties - An object of the query parameters for a route direction request\n * @returns The composed batch request.\n */\nexport function createRouteDirectionsBatchRequest(\n queryParamProperties: RouteGetRouteDirectionsQueryParamProperties[],\n): BatchRequest {\n return {\n batchItems: queryParamProperties.map((queryParam) => ({\n query:\n \"?\" +\n Object.entries(queryParam)\n .map(([k, v]) => {\n // Skip if no value\n if (typeof v === \"undefined\" || v === null) {\n return \"\";\n }\n // Check name mappings: Array values\n if ((k === \"departAt\" || k === \"arriveAt\") && v instanceof Date) {\n return `${k}=${v.toISOString()}`;\n }\n return `${k}=${v}`;\n })\n .filter((s) => s !== \"\")\n .join(\"&\"),\n })),\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport MapsRoute from \"./mapsRoute\";\n\nexport * from \"../generated\";\nexport * from \"./helpers\";\n\nexport default MapsRoute;\n"],"names":["createClientLogger","__rest","getClient","createHttpPoller","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy","isSASCredential"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,YAAY,CAAC;;ACJtD;AACA;AAaA;;;;AAIG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,KAA6D,EAAE,EAAA;;QAA/D,EAAE,UAAU,GAAG,KAAK,EAAA,GAAA,EAA2C,EAAtC,OAAO,GAAAC,YAAA,CAAA,EAAA,EAAhC,cAAkC,CAAF;AAEhC,IAAA,MAAM,WAAW,GACf,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,QAAQ,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,6BAA6B;IACtE,MAAM,aAAa,GAAG,CAAA,qCAAA,CAAuC;IAC7D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;UACjD,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE;AACxB,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA,EACD,cAAc,EAAE;YACd,MAAM,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,cAAc,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,K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