@azure-rest/maps-route 1.0.0-beta.1 → 1.0.0-beta.3
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 +84 -32
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/isUnexpected.js +3 -4
- package/dist-esm/src/generated/isUnexpected.js.map +1 -1
- package/dist-esm/src/generated/mapsRouteClient.js +12 -7
- package/dist-esm/src/generated/mapsRouteClient.js.map +1 -1
- package/dist-esm/src/generated/pollingHelper.js +6 -2
- package/dist-esm/src/generated/pollingHelper.js.map +1 -1
- package/dist-esm/src/helpers.js.map +1 -1
- package/dist-esm/src/mapsRoute.js +12 -1
- package/dist-esm/src/mapsRoute.js.map +1 -1
- package/package.json +22 -22
- package/review/maps-route.api.md +4 -0
- package/types/maps-route-rest.d.ts +19 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Key links:
|
|
|
15
15
|
|
|
16
16
|
### Currently supported environments
|
|
17
17
|
|
|
18
|
-
- [LTS versions of Node.js](https://
|
|
18
|
+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
19
19
|
- Latest versions of Safari, Chrome, Edge and Firefox.
|
|
20
20
|
|
|
21
21
|
### Prerequisites
|
|
@@ -66,12 +66,58 @@ You can authenticate with your Azure Maps Subscription Key.
|
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
68
|
const MapsRoute = require("@azure-rest/maps-route").default;
|
|
69
|
-
const { AzureKeyCredential } = require("@azure
|
|
69
|
+
const { AzureKeyCredential } = require("@azure/core-auth");
|
|
70
70
|
|
|
71
71
|
const credential = new AzureKeyCredential("<subscription-key>");
|
|
72
72
|
const client = MapsRoute(credential);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
#### Using a Shared Access Signature (SAS) Token Credential
|
|
76
|
+
|
|
77
|
+
Shared access signature (SAS) tokens are authentication tokens created using the JSON Web token (JWT) format and are cryptographically signed to prove authentication for an application to the Azure Maps REST API.
|
|
78
|
+
|
|
79
|
+
You can get the SAS token using [`AzureMapsManagementClient.accounts.listSas`](https://learn.microsoft.com/javascript/api/%40azure/arm-maps/accounts?view=azure-node-latest#@azure-arm-maps-accounts-listsas) from ["@azure/arm-maps"](https://www.npmjs.com/package/@azure/arm-maps) package. Please follow the section [Create and authenticate a `AzureMapsManagementClient`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/arm-maps#create-and-authenticate-a-azuremapsmanagementclient) to setup first.
|
|
80
|
+
|
|
81
|
+
Second, follow [Managed identities for Azure Maps](https://techcommunity.microsoft.com/t5/azure-maps-blog/managed-identities-for-azure-maps/ba-p/3666312) to create a managed identity for your Azure Maps account. Copy the principal ID (object ID) of the managed identity.
|
|
82
|
+
|
|
83
|
+
Third, you will need to install["@azure/core-auth"](https://www.npmjs.com/package/@azure/core-auth)package to use `AzureSASCredential`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install @azure/core-auth
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Finally, you can use the SAS token to authenticate the client:
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
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
|
+
```
|
|
120
|
+
|
|
75
121
|
## Examples
|
|
76
122
|
|
|
77
123
|
The following sections provide several code snippets covering some of the most common Azure Maps Route tasks, including:
|
|
@@ -89,15 +135,15 @@ To retrieve the route direction, you need to pass in the parameters the coordina
|
|
|
89
135
|
By default, the Route service will return an array of coordinates. The response will contain the coordinates that make up the path in a list named points. Route response also includes the distance from the start of the route and the estimated elapsed time. These values can be used to calculate the average speed for the entire route.
|
|
90
136
|
|
|
91
137
|
```javascript
|
|
92
|
-
const
|
|
138
|
+
const { toColonDelimitedLatLonString, isUnexpected } = require("@azure-rest/maps-route");
|
|
139
|
+
const routeDirectionsResult1 = await client.path("/route/directions/{format}", "json").get({
|
|
93
140
|
queryParameters: {
|
|
94
141
|
query: "51.368752,-0.118332:41.385426,-0.128929",
|
|
95
142
|
},
|
|
96
143
|
});
|
|
97
144
|
|
|
98
145
|
// You can use the helper function `toColonDelimitedLatLonString` to compose the query string.
|
|
99
|
-
const
|
|
100
|
-
const routeDirectionsResult = await client.path("/route/directions/{format}", "json").get({
|
|
146
|
+
const routeDirectionsResult2 = await client.path("/route/directions/{format}", "json").get({
|
|
101
147
|
queryParameters: {
|
|
102
148
|
query: toColonDelimitedLatLonString([
|
|
103
149
|
// Origin:
|
|
@@ -113,19 +159,22 @@ const routeDirectionsResult = await client.path("/route/directions/{format}", "j
|
|
|
113
159
|
});
|
|
114
160
|
|
|
115
161
|
// Handle the error if the request failed
|
|
116
|
-
if (isUnexpected(
|
|
117
|
-
throw
|
|
162
|
+
if (isUnexpected(routeDirectionsResult2)) {
|
|
163
|
+
throw routeDirectionsResult2.body.error;
|
|
118
164
|
}
|
|
119
165
|
|
|
120
|
-
|
|
121
|
-
console.log(
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
166
|
+
routeDirectionsResult2.body.routes.forEach(({ summary, legs }) => {
|
|
167
|
+
console.log(
|
|
168
|
+
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`
|
|
169
|
+
);
|
|
170
|
+
legs.forEach(({ summary, points }, idx) => {
|
|
171
|
+
console.log(
|
|
172
|
+
`The ${idx + 1}th leg's length is ${summary.lengthInMeters} meters, and it takes ${
|
|
173
|
+
summary.travelTimeInSeconds
|
|
174
|
+
} seconds. Followings are the first 10 points: `
|
|
175
|
+
);
|
|
176
|
+
console.table(points.slice(0, 10));
|
|
177
|
+
});
|
|
129
178
|
});
|
|
130
179
|
```
|
|
131
180
|
|
|
@@ -134,6 +183,7 @@ legs.points.forEach(({ summary: { travelTimeInSeconds }, points }, idx) => {
|
|
|
134
183
|
The service supports commercial vehicle routing, covering commercial trucks routing. The APIs consider specified limits. Such as, the height and weight of the vehicle, and if the vehicle is carrying hazardous cargo. For example, if a vehicle is carrying flammable, the routing engine avoid certain tunnels that are near residential areas.
|
|
135
184
|
|
|
136
185
|
```javascript
|
|
186
|
+
const { toColonDelimitedLatLonString, isUnexpected } = require("@azure-rest/maps-route");
|
|
137
187
|
const routeDirectionsResult = await client.path("/route/directions/{format}", "json").get({
|
|
138
188
|
queryParameters: {
|
|
139
189
|
query: toColonDelimitedLatLonString([
|
|
@@ -158,15 +208,18 @@ if (isUnexpected(routeDirectionsResult)) {
|
|
|
158
208
|
throw routeDirectionsResult.body.error;
|
|
159
209
|
}
|
|
160
210
|
|
|
161
|
-
|
|
162
|
-
console.log(
|
|
163
|
-
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
211
|
+
routeDirectionsResult.body.routes.forEach(({ summary, legs }) => {
|
|
212
|
+
console.log(
|
|
213
|
+
`The total distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`
|
|
214
|
+
);
|
|
215
|
+
legs.forEach(({ summary, points }, idx) => {
|
|
216
|
+
console.log(
|
|
217
|
+
`The ${idx + 1}th leg's length is ${summary.lengthInMeters} meters, and it takes ${
|
|
218
|
+
summary.travelTimeInSeconds
|
|
219
|
+
} seconds. Followings are the first 10 points: `
|
|
220
|
+
);
|
|
221
|
+
console.table(points.slice(0, 10));
|
|
222
|
+
});
|
|
170
223
|
});
|
|
171
224
|
```
|
|
172
225
|
|
|
@@ -182,6 +235,7 @@ For multi-stop routing, up to 150 waypoints may be specified in a single route r
|
|
|
182
235
|
If you want to optimize the best order to visit the given waypoints, then you need to specify `computeBestWaypointOrder=true`. This scenario is also known as the traveling salesman optimization problem.
|
|
183
236
|
|
|
184
237
|
```javascript
|
|
238
|
+
const { toColonDelimitedLatLonString, isUnexpected } = require("@azure-rest/maps-route");
|
|
185
239
|
const routeDirectionsResult = await client.path("/route/directions/{format}", "json").get({
|
|
186
240
|
queryParameters: {
|
|
187
241
|
query: toColonDelimitedLatLonString([
|
|
@@ -194,7 +248,7 @@ const routeDirectionsResult = await client.path("/route/directions/{format}", "j
|
|
|
194
248
|
// Destination:
|
|
195
249
|
[41.385426, -0.128929],
|
|
196
250
|
]),
|
|
197
|
-
|
|
251
|
+
computeBestOrder: true,
|
|
198
252
|
routeType: "shortest",
|
|
199
253
|
},
|
|
200
254
|
});
|
|
@@ -203,12 +257,12 @@ if (isUnexpected(routeDirectionsResult)) {
|
|
|
203
257
|
throw routeDirectionsResult.body.error;
|
|
204
258
|
}
|
|
205
259
|
|
|
206
|
-
const { summary } = routeDirectionsResult.body.routes;
|
|
260
|
+
const { summary } = routeDirectionsResult.body.routes[0];
|
|
207
261
|
console.log(
|
|
208
262
|
`The optimized distance is ${summary.lengthInMeters} meters, and it takes ${summary.travelTimeInSeconds} seconds.`
|
|
209
263
|
);
|
|
210
264
|
console.log("The route is optimized by: ");
|
|
211
|
-
routeDirectionsResult.body.
|
|
265
|
+
routeDirectionsResult.body.optimizedWaypoints.forEach(
|
|
212
266
|
({ providedIndex, optimizedIndex }) => `Moving index ${providedIndex} to ${optimizedIndex}`
|
|
213
267
|
);
|
|
214
268
|
```
|
|
@@ -242,10 +296,8 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
242
296
|

|
|
243
297
|
|
|
244
298
|
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-route-rest
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<!-- [api_ref]: https://docs.microsoft.com/javascript/api/@azure-rest/maps-route?view=azure-node-preview -->
|
|
248
|
-
|
|
299
|
+
[npm_link]: https://www.npmjs.com/package/@azure-rest/maps-route
|
|
300
|
+
[api_ref]: https://docs.microsoft.com/javascript/api/@azure-rest/maps-route
|
|
249
301
|
[samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-route-rest/samples
|
|
250
302
|
[azure_cli]: https://docs.microsoft.com/cli/azure
|
|
251
303
|
[azure_sub]: https://azure.microsoft.com/free/
|
package/dist/index.js
CHANGED
|
@@ -9,24 +9,30 @@ var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
|
9
9
|
var coreLro = require('@azure/core-lro');
|
|
10
10
|
|
|
11
11
|
// Copyright (c) Microsoft Corporation.
|
|
12
|
+
// Licensed under the MIT license.
|
|
12
13
|
/**
|
|
13
14
|
* Initialize a new instance of the class MapsRouteClient class.
|
|
14
15
|
* @param credentials type: KeyCredential
|
|
15
16
|
*/
|
|
16
17
|
function createClient(credentials, options = {}) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options
|
|
20
|
-
|
|
18
|
+
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
19
|
+
options.apiVersion = options.apiVersion ?? "1.0";
|
|
20
|
+
options = {
|
|
21
|
+
...options,
|
|
22
|
+
credentials: {
|
|
21
23
|
apiKeyHeaderName: "subscription-key"
|
|
22
|
-
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
23
26
|
const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.1`;
|
|
24
27
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
25
28
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
26
29
|
: `${userAgentInfo}`;
|
|
27
|
-
options =
|
|
30
|
+
options = {
|
|
31
|
+
...options,
|
|
32
|
+
userAgentOptions: {
|
|
28
33
|
userAgentPrefix
|
|
29
|
-
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
30
36
|
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
31
37
|
return client;
|
|
32
38
|
}
|
|
@@ -46,7 +52,7 @@ const responseMap = {
|
|
|
46
52
|
};
|
|
47
53
|
function isUnexpected(response) {
|
|
48
54
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
49
|
-
const url = new URL(lroOriginal
|
|
55
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
50
56
|
const method = response.request.method;
|
|
51
57
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
52
58
|
if (!pathDetails) {
|
|
@@ -55,7 +61,6 @@ function isUnexpected(response) {
|
|
|
55
61
|
return !pathDetails.includes(response.status);
|
|
56
62
|
}
|
|
57
63
|
function geParametrizedPathSuccess(method, path) {
|
|
58
|
-
var _a, _b;
|
|
59
64
|
const pathParts = path.split("/");
|
|
60
65
|
// Iterate the responseMap to find a match
|
|
61
66
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
@@ -74,8 +79,8 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
74
79
|
// track if we have found a match to return the values found.
|
|
75
80
|
let found = true;
|
|
76
81
|
for (let i = 0; i < candidateParts.length; i++) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
82
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
83
|
+
candidateParts[i]?.endsWith("}")) {
|
|
79
84
|
// If the current part of the candidate is a "template" part
|
|
80
85
|
// it is a match with the actual path part on hand
|
|
81
86
|
// skip as the parameterized part can match anything
|
|
@@ -109,6 +114,7 @@ function getPathFromMapKey(mapKey) {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
// Copyright (c) Microsoft Corporation.
|
|
117
|
+
// Licensed under the MIT license.
|
|
112
118
|
/**
|
|
113
119
|
* Helper function that builds a Poller object to help polling a long running operation.
|
|
114
120
|
* @param client - Client to use for sending the request to get additional pages.
|
|
@@ -132,7 +138,7 @@ function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
132
138
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
133
139
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
134
140
|
const response = await client
|
|
135
|
-
.pathUnchecked(path
|
|
141
|
+
.pathUnchecked(path ?? initialResponse.request.url)
|
|
136
142
|
.get();
|
|
137
143
|
const lroResponse = getLroResponse(response);
|
|
138
144
|
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
@@ -153,11 +159,16 @@ function getLroResponse(response) {
|
|
|
153
159
|
}
|
|
154
160
|
return {
|
|
155
161
|
flatResponse: response,
|
|
156
|
-
rawResponse:
|
|
162
|
+
rawResponse: {
|
|
163
|
+
...response,
|
|
164
|
+
statusCode: Number.parseInt(response.status),
|
|
165
|
+
body: response.body
|
|
166
|
+
}
|
|
157
167
|
};
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
// Copyright (c) Microsoft Corporation.
|
|
171
|
+
// Licensed under the MIT license.
|
|
161
172
|
function MapsRoute(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
162
173
|
const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
|
|
163
174
|
/**
|
|
@@ -178,6 +189,17 @@ function MapsRoute(credential, clientIdOrOptions = {}, maybeOptions = {}) {
|
|
|
178
189
|
client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
|
|
179
190
|
return client;
|
|
180
191
|
}
|
|
192
|
+
if (coreAuth.isSASCredential(credential)) {
|
|
193
|
+
const client = createClient(undefined, options);
|
|
194
|
+
client.pipeline.addPolicy({
|
|
195
|
+
name: "mapsSASCredentialPolicy",
|
|
196
|
+
async sendRequest(request, next) {
|
|
197
|
+
request.headers.set("Authorization", `jwt-sas ${credential.signature}`);
|
|
198
|
+
return next(request);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
return client;
|
|
202
|
+
}
|
|
181
203
|
return createClient(credential, options);
|
|
182
204
|
}
|
|
183
205
|
|
|
@@ -225,9 +247,10 @@ function createRouteDirectionsBatchRequest(queryParamProperties) {
|
|
|
225
247
|
}
|
|
226
248
|
|
|
227
249
|
// Copyright (c) Microsoft Corporation.
|
|
250
|
+
// Licensed under the MIT license.
|
|
228
251
|
|
|
229
252
|
exports.createRouteDirectionsBatchRequest = createRouteDirectionsBatchRequest;
|
|
230
|
-
exports
|
|
253
|
+
exports.default = MapsRoute;
|
|
231
254
|
exports.getLongRunningPoller = getLongRunningPoller;
|
|
232
255
|
exports.isUnexpected = isUnexpected;
|
|
233
256
|
exports.toColonDelimitedLatLonString = toColonDelimitedLatLonString;
|
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 { AzureKeyCredential, TokenCredential, isTokenCredential } 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/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;\nexport default function MapsRoute(\n credential: TokenCredential | AzureKeyCredential,\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 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"],"m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EAAA,WAAW,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC;AAC/C,CAAC;AAED;;;;;;AAMG;AACG,SAAU,4BAA4B,CAAC,WAAqB,EAAA;AAChE,IAAA,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;AAKG;AACG,SAAU,iCAAiC,CAC/C,oBAAmE,EAAA;IAEnE,OAAO;QACL,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,UAAU,MAAM;AACpD,YAAA,KAAK,EACH,GAAG;AACH,gBAAA,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;qBACvB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAI;;oBAEd,IAAI,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,EAAE;AAC1C,wBAAA,OAAO,EAAE,CAAC;AACX,qBAAA;;AAED,oBAAA,IAAI,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,UAAU,KAAK,CAAC,YAAY,IAAI,EAAE;wBAC/D,OAAO,CAAA,EAAG,CAAC,CAAI,CAAA,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;;;;;;;;"}
|
|
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,I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K,UAAU,IAAI,CAAC,KAAK,UAAU,KAAK,CAAC,YAAY,IAAI,EAAE;wBAC/D,OAAO,CAAA,EAAG,CAAC,CAAI,CAAA,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;;;;;;;;"}
|
|
@@ -13,7 +13,7 @@ const responseMap = {
|
|
|
13
13
|
};
|
|
14
14
|
export function isUnexpected(response) {
|
|
15
15
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
16
|
-
const url = new URL(lroOriginal
|
|
16
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
17
17
|
const method = response.request.method;
|
|
18
18
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
19
19
|
if (!pathDetails) {
|
|
@@ -22,7 +22,6 @@ export function isUnexpected(response) {
|
|
|
22
22
|
return !pathDetails.includes(response.status);
|
|
23
23
|
}
|
|
24
24
|
function geParametrizedPathSuccess(method, path) {
|
|
25
|
-
var _a, _b;
|
|
26
25
|
const pathParts = path.split("/");
|
|
27
26
|
// Iterate the responseMap to find a match
|
|
28
27
|
for (const [key, value] of Object.entries(responseMap)) {
|
|
@@ -41,8 +40,8 @@ function geParametrizedPathSuccess(method, path) {
|
|
|
41
40
|
// track if we have found a match to return the values found.
|
|
42
41
|
let found = true;
|
|
43
42
|
for (let i = 0; i < candidateParts.length; i++) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
43
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
44
|
+
candidateParts[i]?.endsWith("}")) {
|
|
46
45
|
// If the current part of the candidate is a "template" part
|
|
47
46
|
// it is a match with the actual path part on hand
|
|
48
47
|
// skip as the parameterized part can match anything
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC7C,4BAA4B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC5C,kCAAkC,EAAE,CAAC,KAAK,CAAC;IAC3C,gCAAgC,EAAE,CAAC,KAAK,CAAC;IACzC,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,2BAA2B,EAAE,CAAC,KAAK,CAAC;IACpC,uCAAuC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACvD,sCAAsC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACtD,4CAA4C,EAAE,CAAC,KAAK,CAAC;CACtD,CAAC;AA2BF,MAAM,UAAU,YAAY,CAC1B,QAYuD;IASvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC7C,4BAA4B,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC5C,kCAAkC,EAAE,CAAC,KAAK,CAAC;IAC3C,gCAAgC,EAAE,CAAC,KAAK,CAAC;IACzC,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,2BAA2B,EAAE,CAAC,KAAK,CAAC;IACpC,uCAAuC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC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GAAG,CAAC,EACxB;YACA,6DAA6D;YAC7D,IAAI,KAAK,GAAG,IAAI,CAAC;YACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,IACE,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;oBAClC,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAChC;oBACA,4DAA4D;oBAC5D,kDAAkD;oBAClD,oDAAoD;oBACpD,SAAS;iBACV;gBAED,8CAA8C;gBAC9C,wDAAwD;gBACxD,2CAA2C;gBAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;oBACtC,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;aACF;YAED,qDAAqD;YACrD,yDAAyD;YACzD,oBAAoB;YACpB,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,6CAA6C;IAC7C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,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 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"]}
|
|
@@ -6,19 +6,24 @@ import { getClient } from "@azure-rest/core-client";
|
|
|
6
6
|
* @param credentials type: KeyCredential
|
|
7
7
|
*/
|
|
8
8
|
export default function createClient(credentials, options = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
options
|
|
12
|
-
|
|
9
|
+
const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
10
|
+
options.apiVersion = options.apiVersion ?? "1.0";
|
|
11
|
+
options = {
|
|
12
|
+
...options,
|
|
13
|
+
credentials: {
|
|
13
14
|
apiKeyHeaderName: "subscription-key"
|
|
14
|
-
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
15
17
|
const userAgentInfo = `azsdk-js-maps-route-rest/1.0.0-beta.1`;
|
|
16
18
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
19
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
20
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
21
|
+
options = {
|
|
22
|
+
...options,
|
|
23
|
+
userAgentOptions: {
|
|
20
24
|
userAgentPrefix
|
|
21
|
-
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
22
27
|
const client = getClient(baseUrl, credentials, options);
|
|
23
28
|
return client;
|
|
24
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsRouteClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRouteClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAInE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE
|
|
1
|
+
{"version":3,"file":"mapsRouteClient.js","sourceRoot":"","sources":["../../../src/generated/mapsRouteClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAInE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE;IAE3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;IACjD,OAAO,GAAG;QACR,GAAG,OAAO;QACV,WAAW,EAAE;YACX,gBAAgB,EAAE,kBAAkB;SACrC;KACF,CAAC;IAEF,MAAM,aAAa,GAAG,uCAAuC,CAAC;IAC9D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,GAAG;QACR,GAAG,OAAO;QACV,gBAAgB,EAAE;YAChB,eAAe;SAChB;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAoB,CAAC;IAE3E,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 { 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"]}
|
|
@@ -24,7 +24,7 @@ export function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
24
24
|
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
25
25
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
26
26
|
const response = await client
|
|
27
|
-
.pathUnchecked(path
|
|
27
|
+
.pathUnchecked(path ?? initialResponse.request.url)
|
|
28
28
|
.get();
|
|
29
29
|
const lroResponse = getLroResponse(response);
|
|
30
30
|
lroResponse.rawResponse.headers["x-ms-original-url"] =
|
|
@@ -45,7 +45,11 @@ function getLroResponse(response) {
|
|
|
45
45
|
}
|
|
46
46
|
return {
|
|
47
47
|
flatResponse: response,
|
|
48
|
-
rawResponse:
|
|
48
|
+
rawResponse: {
|
|
49
|
+
...response,
|
|
50
|
+
statusCode: Number.parseInt(response.status),
|
|
51
|
+
body: response.body
|
|
52
|
+
}
|
|
49
53
|
};
|
|
50
54
|
}
|
|
51
55
|
//# sourceMappingURL=pollingHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../../src/generated/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACv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AAQ,GAAG,MAAM,MAAM;iBAC1B,aAAa,CAAC,IAAI,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;iBAClD,GAAG,EAAE,CAAC;YACT,MAAM,WAAW,GAAG,cAAc,CAAC,QAAmB,CAAC,CAAC;YACxD,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC;gBAClD,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC;YAC9B,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,QAAiB;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjC,MAAM,IAAI,SAAS,CACjB,uDAAuD,QAAQ,CAAC,MAAM,EAAE,CACzE,CAAC;KACH;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,EAAE;YACX,GAAG,QAAQ;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["// 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,WAAqB;IAChE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,oBAAmE;IAEnE,OAAO;QACL,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACpD,KAAK,EACH,GAAG;gBACH,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;qBACvB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,mBAAmB;oBACnB,IAAI,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,EAAE;wBAC1C,OAAO,EAAE,CAAC;qBACX;oBACD,oCAAoC;oBACpC,IAAI,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE;wBAC/D,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;qBAClC;oBACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,CAAC,CAAC;qBACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;qBACvB,IAAI,CAAC,GAAG,CAAC;SACf,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["// 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[]
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAAC,WAAqB;IAChE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,oBAAmE;IAEnE,OAAO;QACL,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACpD,KAAK,EACH,GAAG;gBACH,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;qBACvB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,mBAAmB;oBACnB,IAAI,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI,EAAE;wBAC1C,OAAO,EAAE,CAAC;qBACX;oBACD,oCAAoC;oBACpC,IAAI,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE;wBAC/D,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;qBAClC;oBACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,CAAC,CAAC;qBACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;qBACvB,IAAI,CAAC,GAAG,CAAC;SACf,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["// 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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import { isTokenCredential } from "@azure/core-auth";
|
|
3
|
+
import { isSASCredential, isTokenCredential, } from "@azure/core-auth";
|
|
4
4
|
import { createMapsClientIdPolicy } from "@azure/maps-common";
|
|
5
5
|
import createClient from "./generated";
|
|
6
6
|
import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
@@ -24,6 +24,17 @@ export default function MapsRoute(credential, clientIdOrOptions = {}, maybeOptio
|
|
|
24
24
|
client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));
|
|
25
25
|
return client;
|
|
26
26
|
}
|
|
27
|
+
if (isSASCredential(credential)) {
|
|
28
|
+
const client = createClient(undefined, options);
|
|
29
|
+
client.pipeline.addPolicy({
|
|
30
|
+
name: "mapsSASCredentialPolicy",
|
|
31
|
+
async sendRequest(request, next) {
|
|
32
|
+
request.headers.set("Authorization", `jwt-sas ${credential.signature}`);
|
|
33
|
+
return next(request);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
return client;
|
|
37
|
+
}
|
|
27
38
|
return createClient(credential, options);
|
|
28
39
|
}
|
|
29
40
|
//# sourceMappingURL=mapsRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsRoute.js","sourceRoot":"","sources":["../../src/mapsRoute.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,
|
|
1
|
+
{"version":3,"file":"mapsRoute.js","sourceRoot":"","sources":["../../src/mapsRoute.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAIL,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,UAAqE,EACrE,oBAA4C,EAAE,EAC9C,eAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEzF;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;SACxD;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,+BAA+B,CAAC;YAC9B,UAAU;YACV,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,WAAW;SACvE,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;KACf;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACxB,IAAI,EAAE,yBAAyB;YAC/B,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI;gBAC7B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IAED,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// 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"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@azure-rest/maps-route",
|
|
3
3
|
"sdk-type": "client",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.3",
|
|
6
6
|
"description": "A client library for Azure Maps maps-route",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
],
|
|
40
40
|
"requiredResources": {
|
|
41
41
|
"Azure Maps Resource": "https://docs.microsoft.com/azure/azure-maps/how-to-create-template"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure-rest/maps-route",
|
|
44
|
+
"disableDocsMs": true
|
|
43
45
|
},
|
|
44
46
|
"//metadata": {
|
|
45
47
|
"constantPaths": [
|
|
@@ -50,20 +52,20 @@
|
|
|
50
52
|
]
|
|
51
53
|
},
|
|
52
54
|
"engines": {
|
|
53
|
-
"node": ">=
|
|
55
|
+
"node": ">=18.0.0"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|
|
56
58
|
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
|
|
57
|
-
"build:browser": "tsc -p . &&
|
|
58
|
-
"build:node": "tsc -p . &&
|
|
59
|
+
"build:browser": "tsc -p . && dev-tool run bundle",
|
|
60
|
+
"build:node": "tsc -p . && dev-tool run bundle --browser-test false",
|
|
59
61
|
"build:samples": "dev-tool samples publish --force",
|
|
60
62
|
"build:test": "tsc -p . && dev-tool run bundle",
|
|
61
63
|
"build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
|
|
62
|
-
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
64
|
+
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
63
65
|
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
|
|
64
66
|
"execute:samples": "dev-tool samples run samples-dev",
|
|
65
67
|
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
|
|
66
|
-
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
68
|
+
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
67
69
|
"generate:client": "autorest --typescript swagger/README.md && npm run format",
|
|
68
70
|
"integration-test:browser": "dev-tool run test:browser",
|
|
69
71
|
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
|
@@ -83,48 +85,46 @@
|
|
|
83
85
|
"autoPublish": false,
|
|
84
86
|
"dependencies": {
|
|
85
87
|
"@azure/core-auth": "^1.3.0",
|
|
86
|
-
"@azure-rest/core-client": "1.0.0
|
|
88
|
+
"@azure-rest/core-client": "^1.0.0",
|
|
87
89
|
"@azure/core-rest-pipeline": "^1.8.0",
|
|
88
90
|
"@azure/logger": "^1.0.0",
|
|
89
91
|
"@azure/core-lro": "^2.2.0",
|
|
90
|
-
"@azure/maps-common": "
|
|
92
|
+
"@azure/maps-common": "1.0.0-beta.2",
|
|
91
93
|
"tslib": "^2.4.0"
|
|
92
94
|
},
|
|
93
95
|
"devDependencies": {
|
|
94
96
|
"@microsoft/api-extractor": "^7.31.1",
|
|
95
97
|
"autorest": "latest",
|
|
96
|
-
"@types/node": "^
|
|
97
|
-
"dotenv": "^
|
|
98
|
-
"eslint": "^
|
|
98
|
+
"@types/node": "^18.0.0",
|
|
99
|
+
"dotenv": "^16.0.0",
|
|
100
|
+
"eslint": "^8.0.0",
|
|
99
101
|
"mkdirp": "^1.0.4",
|
|
100
|
-
"prettier": "2.2.1",
|
|
101
102
|
"rimraf": "^3.0.0",
|
|
102
103
|
"source-map-support": "^0.5.9",
|
|
103
|
-
"typescript": "~
|
|
104
|
+
"typescript": "~5.2.0",
|
|
104
105
|
"@azure/dev-tool": "^1.0.0",
|
|
105
106
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
106
107
|
"@azure-tools/test-credential": "^1.0.0",
|
|
107
|
-
"@azure/identity": "^
|
|
108
|
-
"@azure-tools/test-recorder": "^
|
|
109
|
-
"mocha": "^
|
|
110
|
-
"mocha-junit-reporter": "^1.18.0",
|
|
108
|
+
"@azure/identity": "^3.3.0",
|
|
109
|
+
"@azure-tools/test-recorder": "^3.0.0",
|
|
110
|
+
"mocha": "^10.0.0",
|
|
111
111
|
"cross-env": "^7.0.2",
|
|
112
112
|
"@types/chai": "^4.2.8",
|
|
113
113
|
"chai": "^4.2.0",
|
|
114
114
|
"karma-chrome-launcher": "^3.0.0",
|
|
115
115
|
"karma-coverage": "^2.0.0",
|
|
116
|
-
"karma-edge-launcher": "^0.4.2",
|
|
117
116
|
"karma-env-preprocessor": "^0.1.1",
|
|
118
117
|
"karma-firefox-launcher": "^1.1.0",
|
|
119
|
-
"karma-ie-launcher": "^1.0.0",
|
|
120
118
|
"karma-junit-reporter": "^2.0.1",
|
|
121
119
|
"karma-mocha-reporter": "^2.2.5",
|
|
122
120
|
"karma-mocha": "^2.0.1",
|
|
123
121
|
"karma-source-map-support": "~1.4.0",
|
|
124
122
|
"karma-sourcemap-loader": "^0.3.8",
|
|
125
123
|
"karma": "^6.2.0",
|
|
126
|
-
"
|
|
127
|
-
"@types/mocha": "^
|
|
124
|
+
"c8": "^8.0.0",
|
|
125
|
+
"@types/mocha": "^10.0.0",
|
|
126
|
+
"ts-node": "^10.0.0",
|
|
127
|
+
"esm": "^3.2.18"
|
|
128
128
|
},
|
|
129
129
|
"browser": {
|
|
130
130
|
"./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js"
|
package/review/maps-route.api.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
7
|
import { AzureKeyCredential } from '@azure/core-auth';
|
|
8
|
+
import { AzureSASCredential } from '@azure/core-auth';
|
|
8
9
|
import { Client } from '@azure-rest/core-client';
|
|
9
10
|
import { ClientOptions } from '@azure-rest/core-client';
|
|
10
11
|
import { HttpResponse } from '@azure-rest/core-client';
|
|
@@ -223,6 +224,9 @@ function MapsRoute(credential: AzureKeyCredential, options?: ClientOptions): Map
|
|
|
223
224
|
|
|
224
225
|
// @public
|
|
225
226
|
function MapsRoute(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsRouteClient;
|
|
227
|
+
|
|
228
|
+
// @public
|
|
229
|
+
function MapsRoute(credential: AzureSASCredential, options?: ClientOptions): MapsRouteClient;
|
|
226
230
|
export default MapsRoute;
|
|
227
231
|
|
|
228
232
|
// @public (undocumented)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AzureKeyCredential } from '@azure/core-auth';
|
|
2
|
+
import { AzureSASCredential } from '@azure/core-auth';
|
|
2
3
|
import { Client } from '@azure-rest/core-client';
|
|
3
4
|
import { ClientOptions } from '@azure-rest/core-client';
|
|
4
5
|
import { HttpResponse } from '@azure-rest/core-client';
|
|
@@ -275,7 +276,7 @@ declare function MapsRoute(credential: AzureKeyCredential, options?: ClientOptio
|
|
|
275
276
|
*
|
|
276
277
|
* @example
|
|
277
278
|
* ```ts
|
|
278
|
-
* import MapsRoute from "@azure/maps-route";
|
|
279
|
+
* import MapsRoute from "@azure-rest/maps-route";
|
|
279
280
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
280
281
|
*
|
|
281
282
|
* const credential = new DefaultAzureCredential();
|
|
@@ -287,6 +288,23 @@ declare function MapsRoute(credential: AzureKeyCredential, options?: ClientOptio
|
|
|
287
288
|
* @param options - Options used to configure the Route Client
|
|
288
289
|
*/
|
|
289
290
|
declare function MapsRoute(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsRouteClient;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Creates an instance of MapsRoute from an Azure Identity `AzureSASCredential`.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* import MapsRoute from "@azure-rest/maps-route";
|
|
298
|
+
* import { AzureSASCredential } from "@azure/core-auth";
|
|
299
|
+
*
|
|
300
|
+
* const credential = new AzureSASCredential("<SAS Token>");
|
|
301
|
+
* const client = MapsRoute(credential);
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @param credential - An AzureSASCredential instance used to authenticate requests to the service
|
|
305
|
+
* @param options - Options used to configure the Route Client
|
|
306
|
+
*/
|
|
307
|
+
declare function MapsRoute(credential: AzureSASCredential, options?: ClientOptions): MapsRouteClient;
|
|
290
308
|
export default MapsRoute;
|
|
291
309
|
|
|
292
310
|
export declare type MapsRouteClient = Client & {
|