@azure-rest/maps-geolocation 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 +26 -17
- package/dist/browser/MapsGeolocation.d.ts +6 -6
- package/dist/browser/MapsGeolocation.js.map +1 -1
- package/dist/commonjs/MapsGeolocation.d.ts +6 -6
- package/dist/commonjs/MapsGeolocation.js.map +1 -1
- package/dist/esm/MapsGeolocation.d.ts +6 -6
- package/dist/esm/MapsGeolocation.js.map +1 -1
- package/dist/react-native/MapsGeolocation.d.ts +6 -6
- package/dist/react-native/MapsGeolocation.js.map +1 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -60,9 +60,10 @@ You'll need to register the new Microsoft Entra ID application and grant access
|
|
|
60
60
|
You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options.
|
|
61
61
|
The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation](https://learn.microsoft.com/azure/azure-maps/how-to-manage-authentication#view-authentication-details) on how to find it.
|
|
62
62
|
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
64
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
65
|
+
import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
66
|
+
|
|
66
67
|
const credential = new DefaultAzureCredential();
|
|
67
68
|
const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
68
69
|
```
|
|
@@ -75,9 +76,10 @@ You can authenticate with your Azure Maps Subscription Key. Please install the["
|
|
|
75
76
|
npm install @azure/core-auth
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
80
|
+
import { AzureKeyCredential } from "@azure/core-auth";
|
|
81
|
+
import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
82
|
+
|
|
81
83
|
const credential = new AzureKeyCredential("<subscription-key>");
|
|
82
84
|
const client = MapsGeolocation(credential);
|
|
83
85
|
```
|
|
@@ -98,11 +100,11 @@ npm install @azure/core-auth
|
|
|
98
100
|
|
|
99
101
|
Finally, you can use the SAS token to authenticate the client:
|
|
100
102
|
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
```ts snippet:ReadmeSampleCreateClient_SAS
|
|
104
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
105
|
+
import { AzureMapsManagementClient } from "@azure/arm-maps";
|
|
106
|
+
import { AzureSASCredential } from "@azure/core-auth";
|
|
107
|
+
import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
106
108
|
|
|
107
109
|
const subscriptionId = "<subscription ID of the map account>";
|
|
108
110
|
const resourceGroupName = "<resource group name of the map account>";
|
|
@@ -114,6 +116,7 @@ const mapsAccountSasParameters = {
|
|
|
114
116
|
principalId: "<principle ID (object ID) of the managed identity>",
|
|
115
117
|
signingKey: "primaryKey",
|
|
116
118
|
};
|
|
119
|
+
|
|
117
120
|
const credential = new DefaultAzureCredential();
|
|
118
121
|
const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
|
|
119
122
|
const { accountSasToken } = await managementClient.accounts.listSas(
|
|
@@ -121,9 +124,11 @@ const { accountSasToken } = await managementClient.accounts.listSas(
|
|
|
121
124
|
accountName,
|
|
122
125
|
mapsAccountSasParameters,
|
|
123
126
|
);
|
|
127
|
+
|
|
124
128
|
if (accountSasToken === undefined) {
|
|
125
129
|
throw new Error("No accountSasToken was found for the Maps Account.");
|
|
126
130
|
}
|
|
131
|
+
|
|
127
132
|
const sasCredential = new AzureSASCredential(accountSasToken);
|
|
128
133
|
const client = MapsGeolocation(sasCredential);
|
|
129
134
|
```
|
|
@@ -138,8 +143,12 @@ const client = MapsGeolocation(sasCredential);
|
|
|
138
143
|
|
|
139
144
|
You can get the country code from a IP address:
|
|
140
145
|
|
|
141
|
-
```
|
|
142
|
-
|
|
146
|
+
```ts snippet:ReadmeSampleGetCountryCode
|
|
147
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
148
|
+
import MapsGeolocation, { isUnexpected } from "@azure-rest/maps-geolocation";
|
|
149
|
+
|
|
150
|
+
const credential = new DefaultAzureCredential();
|
|
151
|
+
const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
143
152
|
|
|
144
153
|
const result = await client.path("/geolocation/ip/{format}", "json").get({
|
|
145
154
|
queryParameters: { ip: "2001:4898:80e8:b::189" },
|
|
@@ -148,9 +157,11 @@ const result = await client.path("/geolocation/ip/{format}", "json").get({
|
|
|
148
157
|
if (isUnexpected(result)) {
|
|
149
158
|
throw result.body.error;
|
|
150
159
|
}
|
|
160
|
+
|
|
151
161
|
if (!result.body.countryRegion) {
|
|
152
162
|
throw new Error("No country region was found for the IP address.");
|
|
153
163
|
}
|
|
164
|
+
|
|
154
165
|
console.log(`The country code for the IP address is ${result.body.countryRegion.isoCode}`);
|
|
155
166
|
```
|
|
156
167
|
|
|
@@ -160,16 +171,14 @@ console.log(`The country code for the IP address is ${result.body.countryRegion.
|
|
|
160
171
|
|
|
161
172
|
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`:
|
|
162
173
|
|
|
163
|
-
```
|
|
164
|
-
|
|
174
|
+
```ts snippet:SetLogLevel
|
|
175
|
+
import { setLogLevel } from "@azure/logger";
|
|
165
176
|
|
|
166
177
|
setLogLevel("info");
|
|
167
178
|
```
|
|
168
179
|
|
|
169
180
|
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
170
181
|
|
|
171
|
-
|
|
172
|
-
|
|
173
182
|
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest
|
|
174
183
|
[npm_package]: https://www.npmjs.com/package/@azure-rest/maps-geolocation
|
|
175
184
|
[api_ref]: https://learn.microsoft.com/javascript/api/@azure-rest/maps-geolocation?view=azure-node-preview
|
|
@@ -5,9 +5,9 @@ import type { MapsGeolocationClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsGeolocationClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
10
9
|
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
10
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
11
11
|
*
|
|
12
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
13
13
|
* const client = MapsGeolocation(credential);
|
|
@@ -21,9 +21,9 @@ export default function MapsGeolocation(credential: AzureKeyCredential, options?
|
|
|
21
21
|
* Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
26
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
27
27
|
*
|
|
28
28
|
* const credential = new DefaultAzureCredential();
|
|
29
29
|
* const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
@@ -38,9 +38,9 @@ export default function MapsGeolocation(credential: TokenCredential, mapsAccount
|
|
|
38
38
|
* Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
43
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
44
44
|
*
|
|
45
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
46
46
|
* const client = MapsGeolocation(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import
|
|
1
|
+
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAA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AAI,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsGeolocation(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsGeolocationClient {\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,9 +5,9 @@ import type { MapsGeolocationClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsGeolocationClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
10
9
|
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
10
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
11
11
|
*
|
|
12
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
13
13
|
* const client = MapsGeolocation(credential);
|
|
@@ -21,9 +21,9 @@ export default function MapsGeolocation(credential: AzureKeyCredential, options?
|
|
|
21
21
|
* Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
26
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
27
27
|
*
|
|
28
28
|
* const credential = new DefaultAzureCredential();
|
|
29
29
|
* const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
@@ -38,9 +38,9 @@ export default function MapsGeolocation(credential: TokenCredential, mapsAccount
|
|
|
38
38
|
* Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
43
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
44
44
|
*
|
|
45
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
46
46
|
* const client = MapsGeolocation(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C,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,kBAAY,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import
|
|
1
|
+
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAqElC,kCAyCC;;AA1GD,gDAAsE;AACtE,oDAA8D;AAE9D,4EAAgD;AAChD,kEAA4E;AA6D5E,SAAwB,eAAe,CACrC,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,kBAAY,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,kBAAY,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,kBAAY,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsGeolocation(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsGeolocationClient {\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,9 +5,9 @@ import type { MapsGeolocationClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsGeolocationClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
10
9
|
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
10
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
11
11
|
*
|
|
12
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
13
13
|
* const client = MapsGeolocation(credential);
|
|
@@ -21,9 +21,9 @@ export default function MapsGeolocation(credential: AzureKeyCredential, options?
|
|
|
21
21
|
* Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
26
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
27
27
|
*
|
|
28
28
|
* const credential = new DefaultAzureCredential();
|
|
29
29
|
* const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
@@ -38,9 +38,9 @@ export default function MapsGeolocation(credential: TokenCredential, mapsAccount
|
|
|
38
38
|
* Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
43
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
44
44
|
*
|
|
45
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
46
46
|
* const client = MapsGeolocation(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAqE,EACrE,oBAA4C,EAAE,EAC9C,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.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport type { AzureKeyCredential, AzureSASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import
|
|
1
|
+
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsGeolocation(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsGeolocationClient {\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,9 +5,9 @@ import type { MapsGeolocationClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsGeolocationClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
10
9
|
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
10
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
11
11
|
*
|
|
12
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
13
13
|
* const client = MapsGeolocation(credential);
|
|
@@ -21,9 +21,9 @@ export default function MapsGeolocation(credential: AzureKeyCredential, options?
|
|
|
21
21
|
* Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
26
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
27
27
|
*
|
|
28
28
|
* const credential = new DefaultAzureCredential();
|
|
29
29
|
* const client = MapsGeolocation(credential, "<maps-account-client-id>");
|
|
@@ -38,9 +38,9 @@ export default function MapsGeolocation(credential: TokenCredential, mapsAccount
|
|
|
38
38
|
* Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* import MapsGeolocation from "@azure-rest/maps-geo-location";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
43
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsGeolocation from "@azure-rest/maps-geolocation";
|
|
44
44
|
*
|
|
45
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
46
46
|
* const client = MapsGeolocation(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts\n * import
|
|
1
|
+
{"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,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 { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsGeolocationClient } from \"./generated/index.js\";\nimport createClient from \"./generated/index.js\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * Creates an instance of MapsGeolocationClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsGeolocation(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsGeolocation(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the Route Client\n */\nexport default function MapsGeolocation(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsGeolocationClient;\n/**\n * Creates an instance of MapsGeolocation from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsGeolocation from \"@azure-rest/maps-geolocation\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsGeolocation(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the Geolocation Client\n */\nexport default function MapsGeolocation(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsGeolocationClient;\nexport default function MapsGeolocation(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsGeolocationClient {\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-geolocation",
|
|
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 MapsGeolocationClient.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
51
51
|
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
|
52
52
|
"unit-test:node": "dev-tool run test:vitest",
|
|
53
|
-
"update-snippets": "
|
|
53
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"autoPublish": false,
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@azure-rest/core-client": "^2.3.
|
|
58
|
+
"@azure-rest/core-client": "^2.3.3",
|
|
59
59
|
"@azure/core-auth": "^1.9.0",
|
|
60
|
-
"@azure/core-rest-pipeline": "^1.
|
|
60
|
+
"@azure/core-rest-pipeline": "^1.19.0",
|
|
61
61
|
"@azure/logger": "^1.1.4",
|
|
62
62
|
"@azure/maps-common": "1.0.0-beta.2",
|
|
63
63
|
"tslib": "^2.8.1"
|
|
@@ -66,19 +66,19 @@
|
|
|
66
66
|
"@azure-tools/test-credential": "^2.0.0",
|
|
67
67
|
"@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
|
|
68
68
|
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
|
69
|
-
"@azure/core-util": "^1.
|
|
69
|
+
"@azure/core-util": "^1.11.0",
|
|
70
70
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
71
71
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
72
|
-
"@azure/identity": "^4.0
|
|
72
|
+
"@azure/identity": "^4.6.0",
|
|
73
73
|
"@types/node": "^18.0.0",
|
|
74
|
-
"@vitest/browser": "^3.0.
|
|
75
|
-
"@vitest/coverage-istanbul": "^3.0.
|
|
74
|
+
"@vitest/browser": "^3.0.5",
|
|
75
|
+
"@vitest/coverage-istanbul": "^3.0.5",
|
|
76
76
|
"autorest": "latest",
|
|
77
77
|
"dotenv": "^16.0.0",
|
|
78
78
|
"eslint": "^9.9.0",
|
|
79
|
-
"playwright": "^1.
|
|
79
|
+
"playwright": "^1.50.1",
|
|
80
80
|
"typescript": "~5.7.2",
|
|
81
|
-
"vitest": "^3.0.
|
|
81
|
+
"vitest": "^3.0.5"
|
|
82
82
|
},
|
|
83
83
|
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest/README.md",
|
|
84
84
|
"//metadata": {
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
},
|
|
104
104
|
"type": "module",
|
|
105
105
|
"tshy": {
|
|
106
|
+
"project": "./tsconfig.src.json",
|
|
106
107
|
"exports": {
|
|
107
108
|
"./package.json": "./package.json",
|
|
108
109
|
".": "./src/index.ts"
|
|
@@ -115,8 +116,7 @@
|
|
|
115
116
|
"browser",
|
|
116
117
|
"react-native"
|
|
117
118
|
],
|
|
118
|
-
"selfLink": false
|
|
119
|
-
"project": "./tsconfig.src.json"
|
|
119
|
+
"selfLink": false
|
|
120
120
|
},
|
|
121
121
|
"exports": {
|
|
122
122
|
"./package.json": "./package.json",
|
|
@@ -138,5 +138,6 @@
|
|
|
138
138
|
"default": "./dist/commonjs/index.js"
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
}
|
|
141
|
+
},
|
|
142
|
+
"react-native": "./dist/react-native/index.js"
|
|
142
143
|
}
|