@azure-rest/maps-timezone 1.0.0-alpha.20250211.1 → 1.0.0-alpha.20250213.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/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/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/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/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/package.json +13 -10
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"]}
|
|
@@ -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,sGAA6D;AA6D7D,SAAwB,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,IAAA,6BAAiB,EAAC,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,IAAA,+BAAY,EAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,IAAA,oDAA+B,EAAC;YAC9B,UAAU;YACV,MAAM,EAAE,sCAAsC;SAC/C,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAA,sCAAwB,EAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,IAAA,2BAAe,EAAC,UAAU,CAAC,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAA,+BAAY,EAAC,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,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"]}
|
|
@@ -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"]}
|
|
@@ -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"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@azure-rest/maps-timezone",
|
|
3
3
|
"sdk-type": "client",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
|
-
"version": "1.0.0-alpha.
|
|
5
|
+
"version": "1.0.0-alpha.20250213.2",
|
|
6
6
|
"description": "A generated SDK for MapsTimeZoneClient.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"test:node": "npm run clean && npm run build:test && npm run unit-test:node",
|
|
53
53
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
54
54
|
"unit-test:browser": "echo skipped",
|
|
55
|
-
"unit-test:node": "dev-tool run test:vitest"
|
|
55
|
+
"unit-test:node": "dev-tool run test:vitest",
|
|
56
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
56
57
|
},
|
|
57
58
|
"sideEffects": false,
|
|
58
59
|
"autoPublish": false,
|
|
@@ -60,10 +61,10 @@
|
|
|
60
61
|
"@azure-rest/core-client": "^2.3.1",
|
|
61
62
|
"@azure/core-auth": "^1.9.0",
|
|
62
63
|
"@azure/core-lro": "^2.7.2",
|
|
63
|
-
"@azure/core-rest-pipeline": "^1.
|
|
64
|
+
"@azure/core-rest-pipeline": "^1.19.0",
|
|
65
|
+
"@azure/core-util": "^1.11.0",
|
|
64
66
|
"@azure/logger": "^1.1.4",
|
|
65
67
|
"@azure/maps-common": "1.0.0-beta.2",
|
|
66
|
-
"@azure/core-util": "^1.11.0",
|
|
67
68
|
"tslib": "^2.8.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
@@ -72,16 +73,16 @@
|
|
|
72
73
|
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
|
73
74
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
74
75
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
75
|
-
"@azure/identity": "^4.
|
|
76
|
+
"@azure/identity": "^4.6.0",
|
|
76
77
|
"@types/node": "~22.7.6",
|
|
77
|
-
"@vitest/browser": "^3.0.
|
|
78
|
-
"@vitest/coverage-istanbul": "^3.0.
|
|
78
|
+
"@vitest/browser": "^3.0.5",
|
|
79
|
+
"@vitest/coverage-istanbul": "^3.0.5",
|
|
79
80
|
"autorest": "latest",
|
|
80
81
|
"dotenv": "^16.0.0",
|
|
81
82
|
"eslint": "^9.9.0",
|
|
82
|
-
"playwright": "^1.
|
|
83
|
+
"playwright": "^1.50.1",
|
|
83
84
|
"typescript": "~5.7.2",
|
|
84
|
-
"vitest": "^3.0.
|
|
85
|
+
"vitest": "^3.0.5"
|
|
85
86
|
},
|
|
86
87
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-timezone-rest/README.md",
|
|
87
88
|
"//metadata": {
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
},
|
|
95
96
|
"type": "module",
|
|
96
97
|
"tshy": {
|
|
98
|
+
"project": "./tsconfig.src.json",
|
|
97
99
|
"exports": {
|
|
98
100
|
"./package.json": "./package.json",
|
|
99
101
|
".": "./src/index.ts"
|
|
@@ -129,5 +131,6 @@
|
|
|
129
131
|
"default": "./dist/commonjs/index.js"
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"react-native": "./dist/react-native/index.js"
|
|
133
136
|
}
|