@azure-rest/maps-timezone 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +4 -4
- package/README.md +92 -43
- package/dist/browser/MapsTimeZone.d.ts +6 -5
- package/dist/browser/MapsTimeZone.d.ts.map +1 -1
- package/dist/browser/MapsTimeZone.js.map +1 -1
- package/dist/browser/generated/isUnexpected.js +5 -6
- package/dist/browser/generated/isUnexpected.js.map +1 -1
- package/dist/browser/generated/mapsTimeZoneClient.js +13 -11
- package/dist/browser/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/commonjs/MapsTimeZone.d.ts +6 -5
- package/dist/commonjs/MapsTimeZone.d.ts.map +1 -1
- package/dist/commonjs/MapsTimeZone.js.map +1 -1
- package/dist/commonjs/generated/isUnexpected.js +5 -6
- package/dist/commonjs/generated/isUnexpected.js.map +1 -1
- package/dist/commonjs/generated/mapsTimeZoneClient.js +13 -11
- package/dist/commonjs/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/MapsTimeZone.d.ts +6 -5
- package/dist/esm/MapsTimeZone.d.ts.map +1 -1
- package/dist/esm/MapsTimeZone.js.map +1 -1
- package/dist/esm/generated/isUnexpected.js +5 -6
- package/dist/esm/generated/isUnexpected.js.map +1 -1
- package/dist/esm/generated/mapsTimeZoneClient.js +13 -11
- package/dist/esm/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/react-native/MapsTimeZone.d.ts +6 -5
- package/dist/react-native/MapsTimeZone.d.ts.map +1 -1
- package/dist/react-native/MapsTimeZone.js.map +1 -1
- package/dist/react-native/generated/isUnexpected.js +5 -6
- package/dist/react-native/generated/isUnexpected.js.map +1 -1
- package/dist/react-native/generated/mapsTimeZoneClient.js +13 -11
- package/dist/react-native/generated/mapsTimeZoneClient.js.map +1 -1
- package/package.json +41 -45
- package/review/maps-timezone-node.api.md +374 -0
package/CHANGELOG.md
ADDED
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) Microsoft Corporation.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MIT License
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions:
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Azure Maps Timezone Client
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
\*\*If you are not familiar with our REST client, please spend 5 minutes to take a look at our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library. The REST client provides a lightweight and developer-friendly way to call Azure REST APIs.
|
|
6
6
|
|
|
7
7
|
Key links:
|
|
8
8
|
|
|
@@ -43,12 +43,12 @@ After setup, you can choose which type of [credential](https://github.com/Azure/
|
|
|
43
43
|
Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra ID application as environment variables:
|
|
44
44
|
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
|
45
45
|
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
47
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
48
|
+
import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
49
49
|
|
|
50
50
|
const credential = new DefaultAzureCredential();
|
|
51
|
-
const client = MapsTimeZone(credential);
|
|
51
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
#### Using a Subscription Key Credential
|
|
@@ -59,9 +59,9 @@ You can authenticate with your Azure Maps Subscription Key. Please install the `
|
|
|
59
59
|
npm install @azure/core-auth
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
63
|
+
import { AzureKeyCredential } from "@azure/core-auth";
|
|
64
|
+
import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
65
65
|
|
|
66
66
|
const credential = new AzureKeyCredential("<subscription-key>");
|
|
67
67
|
const client = MapsTimeZone(credential);
|
|
@@ -77,22 +77,23 @@ Second, follow [Managed identities for Azure Maps](https://techcommunity.microso
|
|
|
77
77
|
|
|
78
78
|
Finally, you can use the SAS token to authenticate the client:
|
|
79
79
|
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
```ts snippet:ReadmeSampleCreateClient_SAS
|
|
81
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
82
|
+
import { AzureMapsManagementClient } from "@azure/arm-maps";
|
|
83
|
+
import { AzureSASCredential } from "@azure/core-auth";
|
|
84
|
+
import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
85
85
|
|
|
86
86
|
const subscriptionId = "<subscription ID of the map account>";
|
|
87
87
|
const resourceGroupName = "<resource group name of the map account>";
|
|
88
88
|
const accountName = "<name of the map account>";
|
|
89
89
|
const mapsAccountSasParameters = {
|
|
90
|
-
start: "<start time in ISO format>", // e.g
|
|
90
|
+
start: "<start time in ISO format>", // e.g. "2023-11-24T03:51:53.161Z"
|
|
91
91
|
expiry: "<expiry time in ISO format>", // maximum value to start + 1 day
|
|
92
92
|
maxRatePerSecond: 500,
|
|
93
|
-
principalId: "<
|
|
93
|
+
principalId: "<principle ID (object ID) of the managed identity>",
|
|
94
94
|
signingKey: "primaryKey",
|
|
95
95
|
};
|
|
96
|
+
|
|
96
97
|
const credential = new DefaultAzureCredential();
|
|
97
98
|
const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
|
|
98
99
|
const { accountSasToken } = await managementClient.accounts.listSas(
|
|
@@ -100,9 +101,11 @@ const { accountSasToken } = await managementClient.accounts.listSas(
|
|
|
100
101
|
accountName,
|
|
101
102
|
mapsAccountSasParameters,
|
|
102
103
|
);
|
|
104
|
+
|
|
103
105
|
if (accountSasToken === undefined) {
|
|
104
106
|
throw new Error("No accountSasToken was found for the Maps Account.");
|
|
105
107
|
}
|
|
108
|
+
|
|
106
109
|
const sasCredential = new AzureSASCredential(accountSasToken);
|
|
107
110
|
const client = MapsTimeZone(sasCredential);
|
|
108
111
|
```
|
|
@@ -128,95 +131,141 @@ The following sections provide several code snippets covering some of the most c
|
|
|
128
131
|
|
|
129
132
|
You can get timezone information for a specific IANA time zone ID.
|
|
130
133
|
|
|
131
|
-
```
|
|
134
|
+
```ts snippet:ReadmeSampleGetTimezoneById
|
|
135
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
136
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
137
|
+
|
|
138
|
+
const credential = new DefaultAzureCredential();
|
|
139
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
140
|
+
|
|
132
141
|
const response = await client.path("/timezone/byId/{format}", "json").get({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
queryParameters: {
|
|
143
|
+
query: "America/New_York",
|
|
144
|
+
},
|
|
136
145
|
});
|
|
137
146
|
|
|
138
147
|
if (isUnexpected(response)) {
|
|
139
|
-
|
|
148
|
+
throw response.body.error;
|
|
140
149
|
}
|
|
141
150
|
|
|
142
|
-
|
|
151
|
+
const { ReferenceUtcTimestamp, TimeZones, Version } = response.body;
|
|
152
|
+
console.log(`Reference UTC Timestamp: ${ReferenceUtcTimestamp}`);
|
|
153
|
+
console.log(`Time Zones: ${TimeZones}`);
|
|
154
|
+
console.log(`Version: ${Version}`);
|
|
143
155
|
```
|
|
144
156
|
|
|
145
157
|
### Get timezone by coordinates
|
|
146
158
|
|
|
147
159
|
You can get timezone information for a specific latitude-longitude pair.
|
|
148
160
|
|
|
149
|
-
```
|
|
161
|
+
```ts snippet:ReadmeSampleGetTimezoneByCoordinates
|
|
162
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
163
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
164
|
+
|
|
165
|
+
const credential = new DefaultAzureCredential();
|
|
166
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
167
|
+
|
|
150
168
|
const response = await client.path("/timezone/byCoordinates/{format}", "json").get({
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
169
|
+
queryParameters: {
|
|
170
|
+
query: [40.7128, -74.006],
|
|
171
|
+
},
|
|
154
172
|
});
|
|
155
173
|
|
|
156
174
|
if (isUnexpected(response)) {
|
|
157
|
-
|
|
175
|
+
throw response.body.error;
|
|
158
176
|
}
|
|
159
177
|
|
|
160
|
-
|
|
178
|
+
const { ReferenceUtcTimestamp, TimeZones, Version } = response.body;
|
|
179
|
+
console.log(`Reference UTC Timestamp: ${ReferenceUtcTimestamp}`);
|
|
180
|
+
console.log(`Time Zones: ${TimeZones}`);
|
|
181
|
+
console.log(`Version: ${Version}`);
|
|
161
182
|
```
|
|
162
183
|
|
|
163
184
|
### Get Windows timezone IDs
|
|
164
185
|
|
|
165
186
|
You can get a list of Windows timezone IDs.
|
|
166
187
|
|
|
167
|
-
```
|
|
188
|
+
```ts snippet:ReadmeSampleGetWindowsTimezoneIds
|
|
189
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
190
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
191
|
+
|
|
192
|
+
const credential = new DefaultAzureCredential();
|
|
193
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
194
|
+
|
|
168
195
|
const response = await client.path("/timezone/enumWindows/{format}", "json").get();
|
|
169
196
|
|
|
170
197
|
if (isUnexpected(response)) {
|
|
171
|
-
|
|
198
|
+
throw response.body.error;
|
|
172
199
|
}
|
|
173
200
|
|
|
174
|
-
|
|
201
|
+
for (const timezone of response.body) {
|
|
202
|
+
console.log(`Timezone: ${timezone}`);
|
|
203
|
+
}
|
|
175
204
|
```
|
|
176
205
|
|
|
177
206
|
### Get IANA timezone IDs
|
|
178
207
|
|
|
179
208
|
You can get a list of IANA timezone IDs.
|
|
180
209
|
|
|
181
|
-
```
|
|
210
|
+
```ts snippet:ReadmeSampleGetIanaTimezoneIds
|
|
211
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
212
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
213
|
+
|
|
214
|
+
const credential = new DefaultAzureCredential();
|
|
215
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
216
|
+
|
|
182
217
|
const response = await client.path("/timezone/enumIana/{format}", "json").get();
|
|
183
218
|
|
|
184
219
|
if (isUnexpected(response)) {
|
|
185
|
-
|
|
220
|
+
throw response.body.error;
|
|
186
221
|
}
|
|
187
222
|
|
|
188
|
-
|
|
223
|
+
for (const timezone of response.body) {
|
|
224
|
+
console.log(`Timezone: ${timezone}`);
|
|
225
|
+
}
|
|
189
226
|
```
|
|
190
227
|
|
|
191
228
|
### Get IANA version
|
|
192
229
|
|
|
193
230
|
You can get the current IANA version number.
|
|
194
231
|
|
|
195
|
-
```
|
|
232
|
+
```ts snippet:ReadmeSampleGetIanaVersion
|
|
233
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
234
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
235
|
+
|
|
236
|
+
const credential = new DefaultAzureCredential();
|
|
237
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
238
|
+
|
|
196
239
|
const response = await client.path("/timezone/ianaVersion/{format}", "json").get();
|
|
197
240
|
|
|
198
241
|
if (isUnexpected(response)) {
|
|
199
|
-
|
|
242
|
+
throw response.body.error;
|
|
200
243
|
}
|
|
201
244
|
|
|
202
|
-
console.log(response.body.Version);
|
|
245
|
+
console.log(`IANA Version: ${response.body.Version}`);
|
|
203
246
|
```
|
|
204
247
|
|
|
205
248
|
### Convert Windows timezone to IANA
|
|
206
249
|
|
|
207
250
|
You can convert a Windows timezone ID to a corresponding IANA ID.
|
|
208
251
|
|
|
209
|
-
```
|
|
252
|
+
```ts snippet:ReadmeSampleConvertWindowsTimezoneToIana
|
|
253
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
254
|
+
import MapsTimeZone, { isUnexpected } from "@azure-rest/maps-timezone";
|
|
255
|
+
|
|
256
|
+
const credential = new DefaultAzureCredential();
|
|
257
|
+
const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
258
|
+
|
|
210
259
|
const response = await client.path("/timezone/windowsToIana/{format}", "json").get({
|
|
211
|
-
|
|
260
|
+
queryParameters: { query: "Eastern Standard Time" },
|
|
212
261
|
});
|
|
213
262
|
|
|
214
263
|
if (isUnexpected(response)) {
|
|
215
|
-
|
|
264
|
+
throw response.body.error;
|
|
216
265
|
} else if (response.body) {
|
|
217
|
-
|
|
266
|
+
console.log(`IANA Timezones: ${response.body}`);
|
|
218
267
|
} else {
|
|
219
|
-
|
|
268
|
+
console.error("No data returned");
|
|
220
269
|
}
|
|
221
270
|
```
|
|
222
271
|
|
|
@@ -226,8 +275,8 @@ if (isUnexpected(response)) {
|
|
|
226
275
|
|
|
227
276
|
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
228
277
|
|
|
229
|
-
```
|
|
230
|
-
|
|
278
|
+
```ts snippet:SetLogLevel
|
|
279
|
+
import { setLogLevel } from "@azure/logger";
|
|
231
280
|
|
|
232
281
|
setLogLevel("info");
|
|
233
282
|
```
|
|
@@ -5,7 +5,8 @@ import type { MapsTimeZoneClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsTimeZoneClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
9
|
+
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
9
10
|
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
10
11
|
*
|
|
11
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
@@ -20,9 +21,9 @@ export default function MapsTimeZone(credential: AzureKeyCredential, options?: C
|
|
|
20
21
|
* Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import MapsTimeZoneClient from "@azure-rest/maps-timezone";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
25
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
26
27
|
*
|
|
27
28
|
* const credential = new DefaultAzureCredential();
|
|
28
29
|
* const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
@@ -37,9 +38,9 @@ export default function MapsTimeZone(credential: TokenCredential, mapsAccountCli
|
|
|
37
38
|
* Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
42
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
43
44
|
*
|
|
44
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
45
46
|
* const client = MapsTimeZone(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,eAAe,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,mCAAmC,CAAC;AA6D7D,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,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,CAAC;QAClC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACzD,CAAC;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,sCAAsC;SAC/C,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,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;IAChB,CAAC;IAED,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// 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 { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsTimeZoneClient } from \"./generated/index.js\";\nimport createClient from \"./generated/mapsTimeZoneClient.js\";\n\n/**\n * Creates an instance of MapsTimeZoneClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsTimeZone(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsTimeZone(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 TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsTimeZone(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\nexport default function MapsTimeZone(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsTimeZoneClient {\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"]}
|
|
@@ -10,7 +10,7 @@ const responseMap = {
|
|
|
10
10
|
};
|
|
11
11
|
export function isUnexpected(response) {
|
|
12
12
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
13
|
-
const url = new URL(lroOriginal
|
|
13
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
14
14
|
const method = response.request.method;
|
|
15
15
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
16
16
|
if (!pathDetails) {
|
|
@@ -19,7 +19,6 @@ export function isUnexpected(response) {
|
|
|
19
19
|
return !pathDetails.includes(response.status);
|
|
20
20
|
}
|
|
21
21
|
function getParametrizedPathSuccess(method, path) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
22
|
const pathParts = path.split("/");
|
|
24
23
|
// Traverse list to match the longest candidate
|
|
25
24
|
// matchedLen: the length of candidate path
|
|
@@ -38,14 +37,14 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
38
37
|
// track if we have found a match to return the values found.
|
|
39
38
|
let found = true;
|
|
40
39
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
40
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
41
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
42
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
44
43
|
// If the current part of the candidate is a "template" part
|
|
45
44
|
// Try to use the suffix of pattern to match the path
|
|
46
45
|
// {guid} ==> $
|
|
47
46
|
// {guid}:export ==> :export$
|
|
48
|
-
const isMatched = new RegExp(`${
|
|
47
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
49
48
|
if (!isMatched) {
|
|
50
49
|
found = false;
|
|
51
50
|
break;
|
|
@@ -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,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,MAAM,UAAU,YAA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IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAE3B,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;gBACR,CAAC;gBACD,SAAS;YACX,CAAC;YAED,8CAA8C;YAC9C,wDAAwD;YACxD,2CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n TimeZoneGetTimeZoneByID200Response,\n TimeZoneGetTimeZoneByIDDefaultResponse,\n TimeZoneGetTimeZoneByCoordinates200Response,\n TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n TimeZoneGetWindowsTimezoneIds200Response,\n TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n TimeZoneGetIanaTimezoneIds200Response,\n TimeZoneGetIanaTimezoneIdsDefaultResponse,\n TimeZoneGetIanaVersion200Response,\n TimeZoneGetIanaVersionDefaultResponse,\n TimeZoneConvertWindowsTimezoneToIana200Response,\n TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /timezone/byId/{format}\": [\"200\"],\n \"GET /timezone/byCoordinates/{format}\": [\"200\"],\n \"GET /timezone/enumWindows/{format}\": [\"200\"],\n \"GET /timezone/enumIana/{format}\": [\"200\"],\n \"GET /timezone/ianaVersion/{format}\": [\"200\"],\n \"GET /timezone/windowsToIana/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse,\n): response is TimeZoneGetTimeZoneByIDDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n): response is TimeZoneGetTimeZoneByCoordinatesDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n): response is TimeZoneGetWindowsTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse,\n): response is TimeZoneGetIanaTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse,\n): response is TimeZoneGetIanaVersionDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is TimeZoneConvertWindowsTimezoneToIanaDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse {\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"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
import { getClient } from "@azure-rest/core-client";
|
|
5
4
|
import { logger } from "./logger.js";
|
|
6
5
|
/**
|
|
@@ -8,21 +7,24 @@ import { logger } from "./logger.js";
|
|
|
8
7
|
* @param credentials - uniquely identify client credential
|
|
9
8
|
* @param options - the parameter for all optional parameters
|
|
10
9
|
*/
|
|
11
|
-
export default function createClient(credentials,
|
|
12
|
-
|
|
13
|
-
var { apiVersion = "1.0" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
14
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
10
|
+
export default function createClient(credentials, { apiVersion = "1.0", ...options } = {}) {
|
|
11
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
15
12
|
const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;
|
|
16
13
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
14
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
15
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
16
|
+
options = {
|
|
17
|
+
...options,
|
|
18
|
+
userAgentOptions: {
|
|
20
19
|
userAgentPrefix,
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
},
|
|
21
|
+
loggingOptions: {
|
|
22
|
+
logger: options.loggingOptions?.logger ?? logger.info,
|
|
23
|
+
},
|
|
24
|
+
credentials: {
|
|
25
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
const client = getClient(endpointUrl, credentials, options);
|
|
27
29
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
28
30
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,OAAO,KAAgC,EAAE;IAElE,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACvE,MAAM,aAAa,GAAG,0CAA0C,CAAC;IACjE,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;QACD,cAAc,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI;SACtD;QACD,WAAW,EAAE;YACX,gBAAgB,EACd,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,kBAAkB;SAC9D;KACF,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CACtB,WAAW,EACX,WAAW,EACX,OAAO,CACc,CAAC;IAExB,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,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 { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsTimeZoneClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsTimeZoneClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsTimeZoneClient`\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 }: MapsTimeZoneClientOptions = {},\n): MapsTimeZoneClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-timezone-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 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 MapsTimeZoneClient;\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"]}
|
|
@@ -5,7 +5,8 @@ import type { MapsTimeZoneClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsTimeZoneClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
9
|
+
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
9
10
|
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
10
11
|
*
|
|
11
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
@@ -20,9 +21,9 @@ export default function MapsTimeZone(credential: AzureKeyCredential, options?: C
|
|
|
20
21
|
* Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import MapsTimeZoneClient from "@azure-rest/maps-timezone";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
25
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
26
27
|
*
|
|
27
28
|
* const credential = new DefaultAzureCredential();
|
|
28
29
|
* const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
@@ -37,9 +38,9 @@ export default function MapsTimeZone(credential: TokenCredential, mapsAccountCli
|
|
|
37
38
|
* Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
42
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
43
44
|
*
|
|
44
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
45
46
|
* const client = MapsTimeZone(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,eAAe,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqElC,+BAyCC;;AA1GD,gDAAsE;AACtE,kEAA4E;AAC5E,oDAA8D;AAE9D,sGA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AChB,CAAC;IAED,OAAO,IAAA,+BAAY,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// 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 { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsTimeZoneClient } from \"./generated/index.js\";\nimport createClient from \"./generated/mapsTimeZoneClient.js\";\n\n/**\n * Creates an instance of MapsTimeZoneClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsTimeZone(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsTimeZone(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 TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsTimeZone(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\nexport default function MapsTimeZone(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsTimeZoneClient {\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"]}
|
|
@@ -13,7 +13,7 @@ const responseMap = {
|
|
|
13
13
|
};
|
|
14
14
|
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 @@ function isUnexpected(response) {
|
|
|
22
22
|
return !pathDetails.includes(response.status);
|
|
23
23
|
}
|
|
24
24
|
function getParametrizedPathSuccess(method, path) {
|
|
25
|
-
var _a, _b, _c, _d;
|
|
26
25
|
const pathParts = path.split("/");
|
|
27
26
|
// Traverse list to match the longest candidate
|
|
28
27
|
// matchedLen: the length of candidate path
|
|
@@ -41,14 +40,14 @@ function getParametrizedPathSuccess(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 = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
43
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
44
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
45
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
47
46
|
// If the current part of the candidate is a "template" part
|
|
48
47
|
// Try to use the suffix of pattern to match the path
|
|
49
48
|
// {guid} ==> $
|
|
50
49
|
// {guid}:export ==> :export$
|
|
51
|
-
const isMatched = new RegExp(`${
|
|
50
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
52
51
|
if (!isMatched) {
|
|
53
52
|
found = false;
|
|
54
53
|
break;
|