@azure-rest/maps-geolocation 1.0.0-beta.3 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,21 +40,21 @@ npm install @azure-rest/maps-geolocation
40
40
 
41
41
  ### Create and authenticate a `MapsGeolocationClient`
42
42
 
43
- You'll need a `credential` instance for authentication when creating the `MapsGeolocationClient` instance used to access the Azure Maps render APIs. You can use either an Azure Active Directory (Azure AD) credential or an Azure subscription key to authenticate. For more information on authentication, see [Authentication with Azure Maps][az_map_auth].
43
+ You'll need a `credential` instance for authentication when creating the `MapsGeolocationClient` instance used to access the Azure Maps render APIs. You can use either a Microsoft Entra ID credential or an Azure subscription key to authenticate. For more information on authentication, see [Authentication with Azure Maps][az_map_auth].
44
44
 
45
- #### Using an Azure AD credential
45
+ #### Using an Microsoft Entra ID credential
46
46
 
47
- To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
47
+ To use an [Microsoft Entra ID token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
48
48
  provide an instance of the desired credential type obtained from the
49
49
  [@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
50
50
 
51
- To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
51
+ To authenticate with Microsoft Entra ID, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
52
52
 
53
53
  After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
54
54
  As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
55
55
  can be used to authenticate the client.
56
56
 
57
- You'll need to register the new Azure AD application and grant access to Azure Maps by assigning the required role to your service principal. For more information, see [Host a daemon on non-Azure resources](https://learn.microsoft.com/azure/azure-maps/how-to-secure-daemon-app#host-a-daemon-on-non-azure-resources). Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
57
+ You'll need to register the new Microsoft Entra ID application and grant access to Azure Maps by assigning the required role to your service principal. For more information, see [Host a daemon on non-Azure resources](https://learn.microsoft.com/azure/azure-maps/how-to-secure-daemon-app#host-a-daemon-on-non-azure-resources). Set the values of the client ID, tenant ID, and client secret of the Microsoft Entra ID application as environment variables:
58
58
  `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
59
59
 
60
60
  You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options.
@@ -99,33 +99,33 @@ npm install @azure/core-auth
99
99
  Finally, you can use the SAS token to authenticate the client:
100
100
 
101
101
  ```javascript
102
- const MapsGeolocation = require("@azure-rest/maps-geolocation").default;
103
- const { AzureSASCredential } = require("@azure/core-auth");
104
- const { DefaultAzureCredential } = require("@azure/identity");
105
- const { AzureMapsManagementClient } = require("@azure/arm-maps");
106
-
107
- const subscriptionId = "<subscription ID of the map account>"
108
- const resourceGroupName = "<resource group name of the map account>";
109
- const accountName = "<name of the map account>";
110
- const mapsAccountSasParameters = {
111
- start: "<start time in ISO format>", // e.g. "2023-11-24T03:51:53.161Z"
112
- expiry: "<expiry time in ISO format>", // maximum value to start + 1 day
113
- maxRatePerSecond: 500,
114
- principalId: "<principle ID (object ID) of the managed identity>",
115
- signingKey: "primaryKey",
116
- };
117
- const credential = new DefaultAzureCredential();
118
- const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
119
- const {accountSasToken} = await managementClient.accounts.listSas(
120
- resourceGroupName,
121
- accountName,
122
- mapsAccountSasParameters
123
- );
124
- if (accountSasToken === undefined) {
125
- throw new Error("No accountSasToken was found for the Maps Account.");
126
- }
127
- const sasCredential = new AzureSASCredential(accountSasToken);
128
- const client = MapsGeolocation(sasCredential);
102
+ const MapsGeolocation = require("@azure-rest/maps-geolocation").default;
103
+ const { AzureSASCredential } = require("@azure/core-auth");
104
+ const { DefaultAzureCredential } = require("@azure/identity");
105
+ const { AzureMapsManagementClient } = require("@azure/arm-maps");
106
+
107
+ const subscriptionId = "<subscription ID of the map account>";
108
+ const resourceGroupName = "<resource group name of the map account>";
109
+ const accountName = "<name of the map account>";
110
+ const mapsAccountSasParameters = {
111
+ start: "<start time in ISO format>", // e.g. "2023-11-24T03:51:53.161Z"
112
+ expiry: "<expiry time in ISO format>", // maximum value to start + 1 day
113
+ maxRatePerSecond: 500,
114
+ principalId: "<principle ID (object ID) of the managed identity>",
115
+ signingKey: "primaryKey",
116
+ };
117
+ const credential = new DefaultAzureCredential();
118
+ const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
119
+ const { accountSasToken } = await managementClient.accounts.listSas(
120
+ resourceGroupName,
121
+ accountName,
122
+ mapsAccountSasParameters,
123
+ );
124
+ if (accountSasToken === undefined) {
125
+ throw new Error("No accountSasToken was found for the Maps Account.");
126
+ }
127
+ const sasCredential = new AzureSASCredential(accountSasToken);
128
+ const client = MapsGeolocation(sasCredential);
129
129
  ```
130
130
 
131
131
  ## Key concepts
package/dist/index.js CHANGED
@@ -4,55 +4,76 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var coreAuth = require('@azure/core-auth');
6
6
  var mapsCommon = require('@azure/maps-common');
7
+ var tslib = require('tslib');
7
8
  var coreClient = require('@azure-rest/core-client');
9
+ var logger$1 = require('@azure/logger');
8
10
  var coreRestPipeline = require('@azure/core-rest-pipeline');
9
11
 
10
12
  // Copyright (c) Microsoft Corporation.
11
- // Licensed under the MIT license.
13
+ // Licensed under the MIT License.
14
+ const logger = logger$1.createClientLogger("maps-geolocation");
15
+
16
+ // Copyright (c) Microsoft Corporation.
17
+ // Licensed under the MIT License.
12
18
  /**
13
- * Initialize a new instance of the class MapsGeolocationClient class.
14
- * @param credentials type: KeyCredential
19
+ * Initialize a new instance of `MapsGeolocationClient`
20
+ * @param credentials - uniquely identify client credential
21
+ * @param options - the parameter for all optional parameters
15
22
  */
16
- function createClient(credentials, options = {}) {
17
- const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
18
- options.apiVersion = options.apiVersion ?? "1.0";
19
- options = {
20
- ...options,
21
- credentials: {
22
- apiKeyHeaderName: "subscription-key"
23
- }
24
- };
25
- const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
23
+ function createClient(credentials, _a = {}) {
24
+ var _b, _c, _d, _e, _f, _g;
25
+ var { apiVersion = "1.0" } = _a, options = tslib.__rest(_a, ["apiVersion"]);
26
+ const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
27
+ const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.4`;
26
28
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
27
29
  ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
28
30
  : `${userAgentInfo}`;
29
- options = {
30
- ...options,
31
- userAgentOptions: {
32
- userAgentPrefix
33
- }
34
- };
35
- const client = coreClient.getClient(baseUrl, credentials, options);
31
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
32
+ userAgentPrefix,
33
+ }, loggingOptions: {
34
+ logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger.info,
35
+ }, credentials: {
36
+ apiKeyHeaderName: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.apiKeyHeaderName) !== null && _g !== void 0 ? _g : "subscription-key",
37
+ } });
38
+ const client = coreClient.getClient(endpointUrl, credentials, options);
39
+ client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
40
+ client.pipeline.addPolicy({
41
+ name: "ClientApiVersionPolicy",
42
+ sendRequest: (req, next) => {
43
+ // Use the apiVersion defined in request url directly
44
+ // Append one if there is no apiVersion and we have one at client options
45
+ const url = new URL(req.url);
46
+ if (!url.searchParams.get("api-version") && apiVersion) {
47
+ req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
48
+ }
49
+ return next(req);
50
+ },
51
+ });
36
52
  return client;
37
53
  }
38
54
 
39
55
  // Copyright (c) Microsoft Corporation.
40
- // Licensed under the MIT license.
56
+ // Licensed under the MIT License.
41
57
  const responseMap = {
42
- "GET /geolocation/ip/{format}": ["200"]
58
+ "GET /geolocation/ip/{format}": ["200"],
43
59
  };
44
60
  function isUnexpected(response) {
45
61
  const lroOriginal = response.headers["x-ms-original-url"];
46
- const url = new URL(lroOriginal ?? response.request.url);
62
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
47
63
  const method = response.request.method;
48
64
  let pathDetails = responseMap[`${method} ${url.pathname}`];
49
65
  if (!pathDetails) {
50
- pathDetails = geParametrizedPathSuccess(method, url.pathname);
66
+ pathDetails = getParametrizedPathSuccess(method, url.pathname);
51
67
  }
52
68
  return !pathDetails.includes(response.status);
53
69
  }
54
- function geParametrizedPathSuccess(method, path) {
70
+ function getParametrizedPathSuccess(method, path) {
71
+ var _a, _b, _c, _d;
55
72
  const pathParts = path.split("/");
73
+ // Traverse list to match the longest candidate
74
+ // matchedLen: the length of candidate path
75
+ // matchedValue: the matched status code array
76
+ let matchedLen = -1, matchedValue = [];
56
77
  // Iterate the responseMap to find a match
57
78
  for (const [key, value] of Object.entries(responseMap)) {
58
79
  // Extracting the path from the map key which is in format
@@ -63,41 +84,39 @@ function geParametrizedPathSuccess(method, path) {
63
84
  const candidatePath = getPathFromMapKey(key);
64
85
  // Get each part of the url path
65
86
  const candidateParts = candidatePath.split("/");
66
- // If the candidate and actual paths don't match in size
67
- // we move on to the next candidate path
68
- if (candidateParts.length === pathParts.length &&
69
- hasParametrizedPath(key)) {
70
- // track if we have found a match to return the values found.
71
- let found = true;
72
- for (let i = 0; i < candidateParts.length; i++) {
73
- if (candidateParts[i]?.startsWith("{") &&
74
- candidateParts[i]?.endsWith("}")) {
75
- // If the current part of the candidate is a "template" part
76
- // it is a match with the actual path part on hand
77
- // skip as the parameterized part can match anything
78
- continue;
79
- }
80
- // If the candidate part is not a template and
81
- // the parts don't match mark the candidate as not found
82
- // to move on with the next candidate path.
83
- if (candidateParts[i] !== pathParts[i]) {
87
+ // track if we have found a match to return the values found.
88
+ let found = true;
89
+ for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
90
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) &&
91
+ ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
92
+ const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
93
+ // If the current part of the candidate is a "template" part
94
+ // Try to use the suffix of pattern to match the path
95
+ // {guid} ==> $
96
+ // {guid}:export ==> :export$
97
+ const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
98
+ if (!isMatched) {
84
99
  found = false;
85
100
  break;
86
101
  }
102
+ continue;
87
103
  }
88
- // We finished evaluating the current candidate parts
89
- // if all parts matched we return the success values form
90
- // the path mapping.
91
- if (found) {
92
- return value;
104
+ // If the candidate part is not a template and
105
+ // the parts don't match mark the candidate as not found
106
+ // to move on with the next candidate path.
107
+ if (candidateParts[i] !== pathParts[j]) {
108
+ found = false;
109
+ break;
93
110
  }
94
111
  }
112
+ // We finished evaluating the current candidate parts
113
+ // Update the matched value if and only if we found the longer pattern
114
+ if (found && candidatePath.length > matchedLen) {
115
+ matchedLen = candidatePath.length;
116
+ matchedValue = value;
117
+ }
95
118
  }
96
- // No match was found, return an empty array.
97
- return [];
98
- }
99
- function hasParametrizedPath(path) {
100
- return path.includes("/{");
119
+ return matchedValue;
101
120
  }
102
121
  function getPathFromMapKey(mapKey) {
103
122
  const pathStart = mapKey.indexOf("/");
@@ -105,11 +124,11 @@ function getPathFromMapKey(mapKey) {
105
124
  }
106
125
 
107
126
  // Copyright (c) Microsoft Corporation.
108
- // Licensed under the MIT license.
127
+ // Licensed under the MIT License.
109
128
  function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {}) {
110
129
  const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
111
130
  /**
112
- * maps service requires a header "ms-x-client-id", which is different from the standard AAD.
131
+ * maps service requires a header "ms-x-client-id", which is different from the standard Microsoft Entra ID.
113
132
  * So we need to do our own implementation.
114
133
  * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
115
134
  */
@@ -121,7 +140,7 @@ function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {})
121
140
  const client = createClient(undefined, options);
122
141
  client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
123
142
  credential,
124
- scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
143
+ scopes: "https://atlas.microsoft.com/.default",
125
144
  }));
126
145
  client.pipeline.addPolicy(mapsCommon.createMapsClientIdPolicy(clientId));
127
146
  return client;
@@ -141,7 +160,7 @@ function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {})
141
160
  }
142
161
 
143
162
  // Copyright (c) Microsoft Corporation.
144
- // Licensed under the MIT license.
163
+ // Licensed under the MIT License.
145
164
 
146
165
  exports.default = MapsGeolocation;
147
166
  exports.isUnexpected = isUnexpected;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/generated/mapsGeolocationClient.ts","../src/generated/isUnexpected.ts","../src/MapsGeolocation.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsGeolocationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class MapsGeolocationClient class.\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n credentials: KeyCredential,\n options: ClientOptions = {}\n): MapsGeolocationClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"1.0\";\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"subscription-key\"\n }\n };\n\n const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n }\n };\n\n const client = getClient(\n baseUrl,\n credentials,\n options\n ) as MapsGeolocationClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geolocation/ip/{format}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse;\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport {\n AzureKeyCredential,\n AzureSASCredential,\n TokenCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsGeolocationClient } from \"./generated\";\nimport createClient from \"./generated\";\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 MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\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 AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"./generated\";\nexport default MapsGeolocation;\n"],"names":["getClient","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy","isSASCredential"],"mappings":";;;;;;;;;AAAA;AACA;AAMA;;;AAGG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE,EAAA;AAE3B,IAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;AACjD,IAAA,OAAO,GAAG;AACR,QAAA,GAAG,OAAO;AACV,QAAA,WAAW,EAAE;AACX,YAAA,gBAAgB,EAAE,kBAAkB;AACrC,SAAA;KACF,CAAC;IAEF,MAAM,aAAa,GAAG,CAAA,2CAAA,CAA6C,CAAC;IACpE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;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CAAC;AACf,KAAA;AAED,IAAA,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C;;ACpHA;AACA;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../generated/logger.ts","../generated/mapsGeolocationClient.ts","../generated/isUnexpected.ts","../src/MapsGeolocation.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"maps-geolocation\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsGeolocationClient } from \"./clientDefinitions\";\n\n/** The optional parameters for the client */\nexport interface MapsGeolocationClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsGeolocationClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"1.0\", ...options }: MapsGeolocationClientOptions = {},\n): MapsGeolocationClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.4`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsGeolocationClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse,\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geolocation/ip/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse,\n): response is GeolocationGetLocationDefaultResponse;\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse,\n): response is GeolocationGetLocationDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport 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\";\nimport createClient from \"../generated\";\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 MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"../generated\";\nexport default MapsGeolocation;\n"],"names":["createClientLogger","__rest","getClient","isTokenCredential","bearerTokenAuthenticationPolicy","createMapsClientIdPolicy","isSASCredential"],"mappings":";;;;;;;;;;;AAAA;AACA;AAGO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,kBAAkB,CAAC;;ACJ5D;AACA;AAaA;;;;AAIG;AACqB,SAAA,YAAY,CAClC,WAA0B,EAC1B,KAAmE,EAAE,EAAA;;QAArE,EAAE,UAAU,GAAG,KAAK,EAAA,GAAA,EAAiD,EAA5C,OAAO,GAAAC,YAAA,CAAA,EAAA,EAAhC,cAAkC,CAAF;AAEhC,IAAA,MAAM,WAAW,GACf,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,QAAQ,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,OAAO,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,6BAA6B;IACtE,MAAM,aAAa,GAAG,CAAA,2CAAA,CAA6C;IACnE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;UACjD,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAA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AC7D,QAAA,OAAO,MAAM;;AAGf,IAAA,IAAIC,wBAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC;AACtD,QAAA,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;AACxB,YAAA,IAAI,EAAE,yBAAyB;AAC/B,YAAA,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,EAAA;AAC7B,gBAAA,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA,QAAA,EAAW,UAAU,CAAC,SAAS,CAAA,CAAE,CAAC;AACvE,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC;aACrB;AACF,SAAA,CAAC;AACF,QAAA,OAAO,MAAM;;AAGf,IAAA,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC;AAC1C;;AC/GA;AACA;;;;;"}
@@ -1,13 +1,13 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { isSASCredential, isTokenCredential, } from "@azure/core-auth";
2
+ // Licensed under the MIT License.
3
+ import { isSASCredential, isTokenCredential } from "@azure/core-auth";
4
4
  import { createMapsClientIdPolicy } from "@azure/maps-common";
5
- import createClient from "./generated";
5
+ import createClient from "../generated";
6
6
  import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
7
7
  export default function MapsGeolocation(credential, clientIdOrOptions = {}, maybeOptions = {}) {
8
8
  const options = typeof clientIdOrOptions === "string" ? maybeOptions : clientIdOrOptions;
9
9
  /**
10
- * maps service requires a header "ms-x-client-id", which is different from the standard AAD.
10
+ * maps service requires a header "ms-x-client-id", which is different from the standard Microsoft Entra ID.
11
11
  * So we need to do our own implementation.
12
12
  * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication
13
13
  */
@@ -19,7 +19,7 @@ export default function MapsGeolocation(credential, clientIdOrOptions = {}, mayb
19
19
  const client = createClient(undefined, options);
20
20
  client.pipeline.addPolicy(bearerTokenAuthenticationPolicy({
21
21
  credential,
22
- scopes: `${options.baseUrl || "https://atlas.microsoft.com"}/.default`,
22
+ scopes: "https://atlas.microsoft.com/.default",
23
23
  }));
24
24
  client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));
25
25
  return client;
@@ -1 +1 @@
1
- {"version":3,"file":"MapsGeolocation.js","sourceRoot":"","sources":["../../src/MapsGeolocation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAIL,eAAe,EACf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AA6D5E,MAAM,CAAC,OAAO,UAAU,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;QACjC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;SACxD;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,+BAA+B,CAAC;YAC9B,UAAU;YACV,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,WAAW;SACvE,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;KACf;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACxB,IAAI,EAAE,yBAAyB;YAC/B,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI;gBAC7B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IAED,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport {\n AzureKeyCredential,\n AzureSASCredential,\n TokenCredential,\n isSASCredential,\n isTokenCredential,\n} from \"@azure/core-auth\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport { MapsGeolocationClient } from \"./generated\";\nimport createClient from \"./generated\";\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 MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\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 AAD.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: `${options.baseUrl || \"https://atlas.microsoft.com\"}/.default`,\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n"]}
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,cAAc,CAAC;AACxC,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\";\nimport createClient from \"../generated\";\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 MapsGeolocation from \"@azure-rest/maps-geolocation\";\n * import { AzureKeyCredential } from \"@azure/core-auth\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { DefaultAzureCredential } from \"@azure/identity\";\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\n * import MapsGeolocation from \"@azure-rest/maps-geo-location\";\n * import { AzureSASCredential } from \"@azure/core-auth\";\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"]}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import MapsGeolocation from "./MapsGeolocation";
4
- export * from "./generated";
4
+ export * from "../generated";
5
5
  export default MapsGeolocation;
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,cAAc,aAAa,CAAC;AAC5B,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"./generated\";\nexport default MapsGeolocation;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,cAAc,cAAc,CAAC;AAC7B,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport MapsGeolocation from \"./MapsGeolocation\";\n\nexport * from \"../generated\";\nexport default MapsGeolocation;\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-beta.3",
5
+ "version": "1.0.0-beta.4",
6
6
  "description": "A generated SDK for MapsGeolocationClient.",
7
7
  "keywords": [
8
8
  "node",
@@ -32,75 +32,72 @@
32
32
  "node": ">=18.0.0"
33
33
  },
34
34
  "scripts": {
35
- "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
35
+ "build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run vendored mkdirp ./review && dev-tool run extract-api",
36
36
  "build:browser": "tsc -p . && dev-tool run bundle",
37
+ "build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api",
37
38
  "build:node": "tsc -p . && dev-tool run bundle --browser-test false",
38
39
  "build:samples": "dev-tool samples publish --force",
39
40
  "build:test": "tsc -p . && dev-tool run bundle",
40
- "build:debug": "tsc -p . && dev-tool run bundle && api-extractor run --local",
41
41
  "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
42
- "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
42
+ "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
43
43
  "execute:samples": "dev-tool samples run samples-dev",
44
- "extract-api": "rimraf review && mkdirp ./review && api-extractor run --local",
44
+ "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api",
45
45
  "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
46
46
  "generate:client": "autorest --typescript swagger/README.md && npm run format",
47
+ "integration-test": "npm run integration-test:node && npm run integration-test:browser",
47
48
  "integration-test:browser": "dev-tool run test:browser",
48
49
  "integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
49
- "integration-test": "npm run integration-test:node && npm run integration-test:browser",
50
- "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
51
- "lint": "eslint package.json api-extractor.json src test --ext .ts",
50
+ "lint": "eslint package.json api-extractor.json src test",
51
+ "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
52
52
  "pack": "npm pack 2>&1",
53
+ "test": "npm run clean && npm run build:test && npm run unit-test",
53
54
  "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser",
54
55
  "test:node": "npm run clean && npm run build:test && npm run unit-test:node",
55
- "test": "npm run clean && npm run build:test && npm run unit-test",
56
56
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
57
- "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
58
57
  "unit-test:browser": "dev-tool run test:browser",
59
- "build": "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"
58
+ "unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
59
+ "update-snippets": "echo skipped"
60
60
  },
61
61
  "sideEffects": false,
62
62
  "autoPublish": false,
63
63
  "dependencies": {
64
- "@azure/core-auth": "^1.3.0",
65
64
  "@azure-rest/core-client": "^1.0.0",
65
+ "@azure/core-auth": "^1.3.0",
66
66
  "@azure/core-rest-pipeline": "^1.8.0",
67
67
  "@azure/maps-common": "1.0.0-beta.2",
68
+ "@azure/logger": "^1.0.0",
68
69
  "tslib": "^2.2.0"
69
70
  },
70
71
  "devDependencies": {
71
- "@microsoft/api-extractor": "^7.31.1",
72
- "autorest": "latest",
73
- "@types/node": "^18.0.0",
74
- "dotenv": "^16.0.0",
75
- "eslint": "^8.0.0",
76
- "mkdirp": "^1.0.4",
77
- "rimraf": "^3.0.0",
78
- "source-map-support": "^0.5.9",
79
- "typescript": "~5.2.0",
80
- "@azure/dev-tool": "^1.0.0",
81
- "@azure/eslint-plugin-azure-sdk": "^3.0.0",
82
72
  "@azure-tools/test-credential": "^1.0.0",
83
- "@azure/identity": "^3.3.0",
84
73
  "@azure-tools/test-recorder": "^3.0.0",
85
- "mocha": "^10.0.0",
86
- "@types/mocha": "^10.0.0",
87
- "cross-env": "^7.0.2",
74
+ "@azure-tools/test-utils": "~1.0.0",
75
+ "@azure/core-util": "^1.9.0",
76
+ "@azure/dev-tool": "^1.0.0",
77
+ "@azure/eslint-plugin-azure-sdk": "^3.0.0",
78
+ "@azure/identity": "^4.0.1",
88
79
  "@types/chai": "^4.2.8",
80
+ "@types/mocha": "^10.0.0",
81
+ "@types/node": "^18.0.0",
82
+ "autorest": "latest",
89
83
  "chai": "^4.2.0",
84
+ "dotenv": "^16.0.0",
85
+ "eslint": "^9.9.0",
86
+ "karma": "^6.2.0",
90
87
  "karma-chrome-launcher": "^3.0.0",
91
88
  "karma-coverage": "^2.0.0",
92
89
  "karma-env-preprocessor": "^0.1.1",
93
90
  "karma-firefox-launcher": "^1.1.0",
94
91
  "karma-junit-reporter": "^2.0.1",
95
- "karma-mocha-reporter": "^2.2.5",
96
92
  "karma-mocha": "^2.0.1",
93
+ "karma-mocha-reporter": "^2.2.5",
97
94
  "karma-source-map-support": "~1.4.0",
98
95
  "karma-sourcemap-loader": "^0.3.8",
99
- "karma": "^6.2.0",
100
- "c8": "^8.0.0",
101
- "@azure/test-utils": "~1.0.0",
96
+ "mocha": "^10.0.0",
97
+ "nyc": "^17.0.0",
98
+ "source-map-support": "^0.5.9",
102
99
  "ts-node": "^10.0.0",
103
- "esm": "^3.2.18"
100
+ "typescript": "~5.6.2"
104
101
  },
105
102
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-geolocation-rest/README.md",
106
103
  "//metadata": {
@@ -4,33 +4,33 @@
4
4
 
5
5
  ```ts
6
6
 
7
- import { AzureKeyCredential } from '@azure/core-auth';
8
- import { AzureSASCredential } from '@azure/core-auth';
7
+ import type { AzureKeyCredential } from '@azure/core-auth';
8
+ import type { AzureSASCredential } from '@azure/core-auth';
9
9
  import { Client } from '@azure-rest/core-client';
10
10
  import { ClientOptions } from '@azure-rest/core-client';
11
11
  import { HttpResponse } from '@azure-rest/core-client';
12
12
  import { RequestParameters } from '@azure-rest/core-client';
13
13
  import { StreamableMethod } from '@azure-rest/core-client';
14
- import { TokenCredential } from '@azure/core-auth';
14
+ import type { TokenCredential } from '@azure/core-auth';
15
15
 
16
16
  // @public
17
17
  export interface CountryRegionOutput {
18
- isoCode?: string;
18
+ readonly isoCode?: string;
19
19
  }
20
20
 
21
21
  // @public
22
22
  export interface ErrorAdditionalInfoOutput {
23
- info?: Record<string, unknown>;
24
- type?: string;
23
+ readonly info?: Record<string, unknown>;
24
+ readonly type?: string;
25
25
  }
26
26
 
27
27
  // @public
28
28
  export interface ErrorDetailOutput {
29
- additionalInfo?: Array<ErrorAdditionalInfoOutput>;
30
- code?: string;
31
- details?: Array<ErrorDetailOutput>;
32
- message?: string;
33
- target?: string;
29
+ readonly additionalInfo?: Array<ErrorAdditionalInfoOutput>;
30
+ readonly code?: string;
31
+ readonly details?: Array<ErrorDetailOutput>;
32
+ readonly message?: string;
33
+ readonly target?: string;
34
34
  }
35
35
 
36
36
  // @public
@@ -75,8 +75,8 @@ export interface GetLocation {
75
75
 
76
76
  // @public
77
77
  export interface IpAddressToLocationResultOutput {
78
- countryRegion?: CountryRegionOutput;
79
- ipAddress?: string;
78
+ readonly countryRegion?: CountryRegionOutput;
79
+ readonly ipAddress?: string;
80
80
  }
81
81
 
82
82
  // @public (undocumented)
@@ -97,6 +97,11 @@ export type MapsGeolocationClient = Client & {
97
97
  path: Routes;
98
98
  };
99
99
 
100
+ // @public
101
+ export interface MapsGeolocationClientOptions extends ClientOptions {
102
+ apiVersion?: string;
103
+ }
104
+
100
105
  // @public (undocumented)
101
106
  export interface Routes {
102
107
  (path: "/geolocation/ip/{format}", format: "json"): GetLocation;
@@ -1,38 +1,38 @@
1
- import { AzureKeyCredential } from '@azure/core-auth';
2
- import { AzureSASCredential } from '@azure/core-auth';
1
+ import type { AzureKeyCredential } from '@azure/core-auth';
2
+ import type { AzureSASCredential } from '@azure/core-auth';
3
3
  import { Client } from '@azure-rest/core-client';
4
4
  import { ClientOptions } from '@azure-rest/core-client';
5
5
  import { HttpResponse } from '@azure-rest/core-client';
6
6
  import { RequestParameters } from '@azure-rest/core-client';
7
7
  import { StreamableMethod } from '@azure-rest/core-client';
8
- import { TokenCredential } from '@azure/core-auth';
8
+ import type { TokenCredential } from '@azure/core-auth';
9
9
 
10
10
  /** The object containing the country/region information. */
11
11
  export declare interface CountryRegionOutput {
12
12
  /** The IP Address's 2-character code [(ISO 3166-1)](https://www.iso.org/iso-3166-country-codes.html) of the country or region. Please note, IP address in ranges reserved for special purpose will return Null for country/region. */
13
- isoCode?: string;
13
+ readonly isoCode?: string;
14
14
  }
15
15
 
16
16
  /** The resource management error additional info. */
17
17
  export declare interface ErrorAdditionalInfoOutput {
18
18
  /** The additional info type. */
19
- type?: string;
19
+ readonly type?: string;
20
20
  /** The additional info. */
21
- info?: Record<string, unknown>;
21
+ readonly info?: Record<string, unknown>;
22
22
  }
23
23
 
24
24
  /** The error detail. */
25
25
  export declare interface ErrorDetailOutput {
26
26
  /** The error code. */
27
- code?: string;
27
+ readonly code?: string;
28
28
  /** The error message. */
29
- message?: string;
29
+ readonly message?: string;
30
30
  /** The error target. */
31
- target?: string;
31
+ readonly target?: string;
32
32
  /** The error details. */
33
- details?: Array<ErrorDetailOutput>;
33
+ readonly details?: Array<ErrorDetailOutput>;
34
34
  /** The error additional info. */
35
- additionalInfo?: Array<ErrorAdditionalInfoOutput>;
35
+ readonly additionalInfo?: Array<ErrorAdditionalInfoOutput>;
36
36
  }
37
37
 
38
38
  /** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */
@@ -42,10 +42,8 @@ export declare interface ErrorResponseOutput {
42
42
  }
43
43
 
44
44
  /**
45
- * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
46
45
  *
47
- *
48
- * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
46
+ * The `Get IP To Location` API is an HTTP `GET` request that, given an IP address, returns the ISO country code from which that IP address is located. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
49
47
  */
50
48
  export declare interface GeolocationGetLocation200Response extends HttpResponse {
51
49
  status: "200";
@@ -53,10 +51,8 @@ export declare interface GeolocationGetLocation200Response extends HttpResponse
53
51
  }
54
52
 
55
53
  /**
56
- * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
57
- *
58
54
  *
59
- * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
55
+ * The `Get IP To Location` API is an HTTP `GET` request that, given an IP address, returns the ISO country code from which that IP address is located. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
60
56
  */
61
57
  export declare interface GeolocationGetLocationDefaultResponse extends HttpResponse {
62
58
  status: string;
@@ -76,10 +72,8 @@ export declare interface GeolocationGetLocationQueryParamProperties {
76
72
 
77
73
  export declare interface GetLocation {
78
74
  /**
79
- * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).
80
- *
81
75
  *
82
- * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
76
+ * The `Get IP To Location` API is an HTTP `GET` request that, given an IP address, returns the ISO country code from which that IP address is located. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.
83
77
  */
84
78
  get(options: GeolocationGetLocationParameters): StreamableMethod<GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse>;
85
79
  }
@@ -87,9 +81,9 @@ export declare interface GetLocation {
87
81
  /** This object is returned from a successful call to IP Address to country/region API */
88
82
  export declare interface IpAddressToLocationResultOutput {
89
83
  /** The object containing the country/region information. */
90
- countryRegion?: CountryRegionOutput;
84
+ readonly countryRegion?: CountryRegionOutput;
91
85
  /** The IP Address of the request. */
92
- ipAddress?: string;
86
+ readonly ipAddress?: string;
93
87
  }
94
88
 
95
89
  export declare function isUnexpected(response: GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse): response is GeolocationGetLocationDefaultResponse;
@@ -151,6 +145,12 @@ export declare type MapsGeolocationClient = Client & {
151
145
  path: Routes;
152
146
  };
153
147
 
148
+ /** The optional parameters for the client */
149
+ export declare interface MapsGeolocationClientOptions extends ClientOptions {
150
+ /** The api version option of the client */
151
+ apiVersion?: string;
152
+ }
153
+
154
154
  export declare interface Routes {
155
155
  /** Resource for '/geolocation/ip/\{format\}' has methods for the following verbs: get */
156
156
  (path: "/geolocation/ip/{format}", format: "json"): GetLocation;
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- export {};
4
- //# sourceMappingURL=clientDefinitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../../src/generated/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { GeolocationGetLocationParameters } from \"./parameters\";\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface GetLocation {\n /**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\n get(\n options: GeolocationGetLocationParameters\n ): StreamableMethod<\n GeolocationGetLocation200Response | GeolocationGetLocationDefaultResponse\n >;\n}\n\nexport interface Routes {\n /** Resource for '/geolocation/ip/\\{format\\}' has methods for the following verbs: get */\n (path: \"/geolocation/ip/{format}\", format: \"json\"): GetLocation;\n}\n\nexport type MapsGeolocationClient = Client & {\n path: Routes;\n};\n"]}
@@ -1,11 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import MapsGeolocationClient from "./mapsGeolocationClient";
4
- export * from "./mapsGeolocationClient";
5
- export * from "./parameters";
6
- export * from "./responses";
7
- export * from "./clientDefinitions";
8
- export * from "./isUnexpected";
9
- export * from "./outputModels";
10
- export default MapsGeolocationClient;
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/generated/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport MapsGeolocationClient from \"./mapsGeolocationClient\";\n\nexport * from \"./mapsGeolocationClient\";\nexport * from \"./parameters\";\nexport * from \"./responses\";\nexport * from \"./clientDefinitions\";\nexport * from \"./isUnexpected\";\nexport * from \"./outputModels\";\n\nexport default MapsGeolocationClient;\n"]}
@@ -1,68 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- const responseMap = {
4
- "GET /geolocation/ip/{format}": ["200"]
5
- };
6
- export function isUnexpected(response) {
7
- const lroOriginal = response.headers["x-ms-original-url"];
8
- const url = new URL(lroOriginal ?? response.request.url);
9
- const method = response.request.method;
10
- let pathDetails = responseMap[`${method} ${url.pathname}`];
11
- if (!pathDetails) {
12
- pathDetails = geParametrizedPathSuccess(method, url.pathname);
13
- }
14
- return !pathDetails.includes(response.status);
15
- }
16
- function geParametrizedPathSuccess(method, path) {
17
- const pathParts = path.split("/");
18
- // Iterate the responseMap to find a match
19
- for (const [key, value] of Object.entries(responseMap)) {
20
- // Extracting the path from the map key which is in format
21
- // GET /path/foo
22
- if (!key.startsWith(method)) {
23
- continue;
24
- }
25
- const candidatePath = getPathFromMapKey(key);
26
- // Get each part of the url path
27
- const candidateParts = candidatePath.split("/");
28
- // If the candidate and actual paths don't match in size
29
- // we move on to the next candidate path
30
- if (candidateParts.length === pathParts.length &&
31
- hasParametrizedPath(key)) {
32
- // track if we have found a match to return the values found.
33
- let found = true;
34
- for (let i = 0; i < candidateParts.length; i++) {
35
- if (candidateParts[i]?.startsWith("{") &&
36
- candidateParts[i]?.endsWith("}")) {
37
- // If the current part of the candidate is a "template" part
38
- // it is a match with the actual path part on hand
39
- // skip as the parameterized part can match anything
40
- continue;
41
- }
42
- // If the candidate part is not a template and
43
- // the parts don't match mark the candidate as not found
44
- // to move on with the next candidate path.
45
- if (candidateParts[i] !== pathParts[i]) {
46
- found = false;
47
- break;
48
- }
49
- }
50
- // We finished evaluating the current candidate parts
51
- // if all parts matched we return the success values form
52
- // the path mapping.
53
- if (found) {
54
- return value;
55
- }
56
- }
57
- }
58
- // No match was found, return an empty array.
59
- return [];
60
- }
61
- function hasParametrizedPath(path) {
62
- return path.includes("/{");
63
- }
64
- function getPathFromMapKey(mapKey) {
65
- const pathStart = mapKey.indexOf("/");
66
- return mapKey.slice(pathStart);
67
- }
68
- //# sourceMappingURL=isUnexpected.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,WAAW,GAA6B;IAC5C,8BAA8B,EAAE,CAAC,KAAK,CAAC;CACxC,CAAC;AAOF,MAAM,UAAU,YAAY,CAC1B,QAEyC;IAEzC,MAAM,WAAW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AE,EAAE;gBAC9C,IACE,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC;oBAClC,cAAc,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAChC;oBACA,4DAA4D;oBAC5D,kDAAkD;oBAClD,oDAAoD;oBACpD,SAAS;iBACV;gBAED,8CAA8C;gBAC9C,wDAAwD;gBACxD,2CAA2C;gBAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;oBACtC,KAAK,GAAG,KAAK,CAAC;oBACd,MAAM;iBACP;aACF;YAED,qDAAqD;YACrD,yDAAyD;YACzD,oBAAoB;YACpB,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;KACF;IAED,6CAA6C;IAC7C,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GeolocationGetLocation200Response,\n GeolocationGetLocationDefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /geolocation/ip/{format}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse;\nexport function isUnexpected(\n response:\n | GeolocationGetLocation200Response\n | GeolocationGetLocationDefaultResponse\n): response is GeolocationGetLocationDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -1,30 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { getClient } from "@azure-rest/core-client";
4
- /**
5
- * Initialize a new instance of the class MapsGeolocationClient class.
6
- * @param credentials type: KeyCredential
7
- */
8
- export default function createClient(credentials, options = {}) {
9
- const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;
10
- options.apiVersion = options.apiVersion ?? "1.0";
11
- options = {
12
- ...options,
13
- credentials: {
14
- apiKeyHeaderName: "subscription-key"
15
- }
16
- };
17
- const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;
18
- const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
19
- ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
20
- : `${userAgentInfo}`;
21
- options = {
22
- ...options,
23
- userAgentOptions: {
24
- userAgentPrefix
25
- }
26
- };
27
- const client = getClient(baseUrl, credentials, options);
28
- return client;
29
- }
30
- //# sourceMappingURL=mapsGeolocationClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapsGeolocationClient.js","sourceRoot":"","sources":["../../../src/generated/mapsGeolocationClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AAInE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,UAAyB,EAAE;IAE3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACjE,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;IACjD,OAAO,GAAG;QACR,GAAG,OAAO;QACV,WAAW,EAAE;YACX,gBAAgB,EAAE,kBAAkB;SACrC;KACF,CAAC;IAEF,MAAM,aAAa,GAAG,6CAA6C,CAAC;IACpE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,GAAG;QACR,GAAG,OAAO;QACV,gBAAgB,EAAE;YAChB,eAAe;SAChB;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,SAAS,CACtB,OAAO,EACP,WAAW,EACX,OAAO,CACiB,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsGeolocationClient } from \"./clientDefinitions\";\n\n/**\n * Initialize a new instance of the class MapsGeolocationClient class.\n * @param credentials type: KeyCredential\n */\nexport default function createClient(\n credentials: KeyCredential,\n options: ClientOptions = {}\n): MapsGeolocationClient {\n const baseUrl = options.baseUrl ?? `https://atlas.microsoft.com`;\n options.apiVersion = options.apiVersion ?? \"1.0\";\n options = {\n ...options,\n credentials: {\n apiKeyHeaderName: \"subscription-key\"\n }\n };\n\n const userAgentInfo = `azsdk-js-maps-geolocation-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n }\n };\n\n const client = getClient(\n baseUrl,\n credentials,\n options\n ) as MapsGeolocationClient;\n\n return client;\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- export {};
4
- //# sourceMappingURL=outputModels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../../src/generated/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/** This object is returned from a successful call to IP Address to country/region API */\nexport interface IpAddressToLocationResultOutput {\n /** The object containing the country/region information. */\n countryRegion?: CountryRegionOutput;\n /** The IP Address of the request. */\n ipAddress?: string;\n}\n\n/** The object containing the country/region information. */\nexport interface CountryRegionOutput {\n /** The IP Address's 2-character code [(ISO 3166-1)](https://www.iso.org/iso-3166-country-codes.html) of the country or region. Please note, IP address in ranges reserved for special purpose will return Null for country/region. */\n isoCode?: string;\n}\n\n/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */\nexport interface ErrorResponseOutput {\n /** The error object. */\n error?: ErrorDetailOutput;\n}\n\n/** The error detail. */\nexport interface ErrorDetailOutput {\n /** The error code. */\n code?: string;\n /** The error message. */\n message?: string;\n /** The error target. */\n target?: string;\n /** The error details. */\n details?: Array<ErrorDetailOutput>;\n /** The error additional info. */\n additionalInfo?: Array<ErrorAdditionalInfoOutput>;\n}\n\n/** The resource management error additional info. */\nexport interface ErrorAdditionalInfoOutput {\n /** The additional info type. */\n type?: string;\n /** The additional info. */\n info?: Record<string, unknown>;\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- export {};
4
- //# sourceMappingURL=parameters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../src/generated/parameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestParameters } from \"@azure-rest/core-client\";\n\nexport interface GeolocationGetLocationQueryParamProperties {\n /** The IP address. Both IPv4 and IPv6 are allowed. */\n ip: string;\n}\n\nexport interface GeolocationGetLocationQueryParam {\n queryParameters: GeolocationGetLocationQueryParamProperties;\n}\n\nexport type GeolocationGetLocationParameters = GeolocationGetLocationQueryParam &\n RequestParameters;\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- export {};
4
- //# sourceMappingURL=responses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../src/generated/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpResponse } from \"@azure-rest/core-client\";\nimport {\n IpAddressToLocationResultOutput,\n ErrorResponseOutput\n} from \"./outputModels\";\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\nexport interface GeolocationGetLocation200Response extends HttpResponse {\n status: \"200\";\n body: IpAddressToLocationResultOutput;\n}\n\n/**\n * **Applies to:** see pricing [tiers](https://aka.ms/AzureMapsPricingTier).\n *\n *\n * This service will return the ISO country code for the provided IP address. Developers can use this information to block or alter certain content based on geographical locations where the application is being viewed from.\n */\nexport interface GeolocationGetLocationDefaultResponse extends HttpResponse {\n status: string;\n body: ErrorResponseOutput;\n}\n"]}